Scuttle130 #1 Posted December 10, 2003 Can anyone figure out what I am doing wrong here? Or does anyone have a way to make this more efficient? ; Ship Version 1.0 ; Subsequent versions will allow additions of capabilities ; A learning objective processor 6502 include "vcs.h" include "macro.h" ; Variables SEG.U variables ORG $80 shipx ds 1 shipy ds 1 visibleship ds 1 shipbuffer ds 2 shipdirection ds 2 SEG variables ; Program ; Clear RAM and TIA Start sei cld ldx $FF txs lda #0 ClearMemory sta 0,x dex bne ClearMemory ; Initialization lda #$00 ; Set backgound color to black sta COLUBK lda #$1C ; Set ship color to yellow sta COLUP0 lda #2 ; Set ship x position sta shipx lda #80 ; Set ship y position sta shipy lda #%0001 ; Set ship facing up sta shipdirection ; VSYNC time Main lda #2 sta VSYNC sta WSYNC sta WSYNC sta WSYNC lda #43 ; Set timer for VSYNC sta TIM64T ; Just another way to do Vertical Blank lda #0 sta VSYNC ; Check joystick controls for movement lda #%00010000 ; Down? bit SWCHA bne SkipMoveDown inc shipy lda #%00001000 ; reflect ship graphics sta REFP0 lda #%0001 sta shipdirection SkipMoveDown lda #%00100000 ; Up? bit SWCHA bne SkipMoveUp dec shipy lda #%00000000 ; do not reflect ship graphics sta REFP0 lda #%0001 sta shipdirection SkipMoveUp lda #%01000000 ; Left? bit SWCHA bne SkipMoveLeft dec shipx lda #%00001000 ; reflect ship graphics sta REFP0 lda #%1000 sta shipdirection SkipMoveLeft lda #%10000000 ; Right? bit SWCHA bne SkipMoveRight inc shipx lda #%00000000 ; do not reflect ship graphics sta REFP0 lda #%1000 sta shipdirection SkipMoveRight lda #0 sta shipbuffer WaitForVBLANKEnd lda INTIM bne WaitForVBLANKEnd ; Visible Screen Drawing ldy #191 sta WSYNC sta VBLANK ; Start to draw screen DrawScreen sta WSYNC lda shipbuffer sta GRP0 ldx shipx ; horizontal sprite check cpx #160 bcc LT160 ldx #0 sta shipx LT160 jsr PositionSprite CheckVisibleShip cpy shipy bne SkipVisibleShip lda #8 sta visibleship SkipVisibleShip lda #0 sta shipbuffer ldx visibleship beq FinishDrawScreen DrawShip lda #%0001 cmp shipdirection bne DrawRightShip lda ShipUp-1,x sta shipbuffer dec visibleship jmp FinishDrawScreen DrawRightShip lda ShipRight-1,x sta shipbuffer dec visibleship FinishDrawScreen dey bne DrawScreen lda #2 sta WSYNC sta VBLANK ldx #30 Overscan sta WSYNC dex bne Overscan jmp Main Divide15 .byte 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 .byte 01,01,01,01,01,01,01,01,01,01,01,01,01,01,01 .byte 02,02,02,02,02,02,02,02,02,02,02,02,02,02,02 .byte 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 .byte 04,04,04,04,04,04,04,04,04,04,04,04,04,04,04 .byte 05,05,05,05,05,05,05,05,05,05,05,05,05,05,05 .byte 06,06,06,06,06,06,06,06,06,06,06,06,06,06,06 .byte 07,07,07,07,07,07,07,07,07,07,07,07,07,07,07 ; .byte 08,08,08,08,08,08,08,08,08,08,08,08,08,08,08 ; .byte 09,09,09,09,09,09,09,09,09,09,09,09,09,09,09 ; .byte 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10 ; .byte 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11 ; .byte 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12 ; .byte 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13 ; .byte 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 ; .byte 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15 ; .byte 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16 ; .byte 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17 ; .byte 18,18,18,18,18,18,18,18,18,18,18,18,18,18,18 PositionSprite sta WSYNC lda Divide15,x tax Loop dex bne Loop sta RESP0 rts ShipUp .byte #$44 ;01000100 .byte #$28 ;00111000 .byte #$FE ;11111110 .byte #$7C ;01111100 .byte #$28 ;00111000 .byte #$10 ;00010000 .byte #$10 ;00010000 .byte #$10 ;00010000 ShipRight .byte #$20 ;00100000 .byte #$B0 ;10110000 .byte #$78 ;01111000 .byte #$7F ;01111111 .byte #$78 ;01111000 .byte #$B0 ;10110000 .byte #$20 ;00100000 .byte #$00 ;00000000 ; Interrupt Vectors ORG $FFFA InterruptVectors .word Start ; NMI .word Start ; Reset .word Start ; IRQ ; DASM execution code: ; dasm {filename}.asm -l{filename}.txt -f3 -v5 -s{filename}.txt -o{filename}.bin ; ; FSB execution code ; fsb {output file}.asm {red file}.bmp {green file}.bmp {blue file}.bmp Quote Share this post Link to post Share on other sites
Cybergoth #2 Posted December 10, 2003 Hi there! I spot several *substandard* techniques in that source. Joystick reading is done way more efficient and horizontal positioning is done in a few bytes without such a giant table for example. I'd suggest you should subscribe [stella] to improve your programming "Kung Fu" Try browsing the [stella] archive for "Battlezone;positioning" for example. Greetings, Manuel Quote Share this post Link to post Share on other sites
Thomas Jentzsch #3 Posted December 10, 2003 BTW: Please use ... to make your source more readable and formatted as it was. Quote Share this post Link to post Share on other sites
Tom #4 Posted December 10, 2003 your trying to cram your whole program into the ram. change SEG variables ; Program into something like SEG code org $f000 ; Program after this it displays something that might be a ship, but it's still buggy. your timing is totally screwed up, run it with z26 with the -n switch and you'll see. Quote Share this post Link to post Share on other sites
Cybergoth #5 Posted December 10, 2003 Hi there! after this it displays something that might be a ship, but it's still buggy. your timing is totally screwed up, run it with z26 with the -n switch and you'll see. Also it will execute only coarse positioning. Greetings, Manuel Quote Share this post Link to post Share on other sites
Scuttle130 #6 Posted December 10, 2003 Thank you! Thank you! Thank you! This stuff can be so frustrating, escpecially to a newbie!!!! Quote Share this post Link to post Share on other sites