easmith Posted January 15, 2018 Share Posted January 15, 2018 Got over my first hurdle of horizontal positioning and moving. Much thanks to those who answered my question! Now I am a little confused as to how to handle to player missile graphic. Specifically , the difference between / appropriate place for ENAMO, RESM0 , and RESP0. see my code below. I am trying to have it where when fire button is pressed, missile only one scanline tall. is reset to one line above player at player hor. pos., then the missile rises one scanline per frame ( classic slide and shoot) . Seems like logic should work but I'm obviously missing something major. Missile is being drawn in seemingly random location and disappears when button pressed. I do not have RESM0 is my code anywhere but I suppose I should. Any help would be appreciated! Missile code is in red processor 6502 include "vcs.h" include "macro.h" seg.u Variables org $80YPos .byteYPosA .byteMissileheight .bytePlayerheight equ 9Alienheight equ 10 seg Code org $f000Player .byte #%00000000 .byte #%11111111 .byte #%10000001 .byte #%11111111 .byte #%01111110 .byte #%00111100 .byte #%00111100 .byte #%00011000 .byte #%00011000 Alien .byte #%00000000 .byte #%00011000 .byte #%00111100 .byte #%01111110 .byte #%11111111 .byte #%11100111 .byte #%11111111 .byte #%01111110 .byte #%00111100 .byte #%00011000 Start sei ; disable interrupts cld ; ldx $ff ; stack pointer txs ; assign stack $ff lda #0 ldx #$ffZeroZP sta $,X ; reset mem dex bne ZeroZP lda #%00000001 sta CTRLPF lda #55 sta COLUP0 ; mirror playfield lda #%0000101 sta NUSIZ0 ; player 0 twice as wide lda #88 sta COLUP1 lda #20 sta YPos lda #21 sta Missileheight ; missile is at top of player initially lda #140 ;place alien vertically sta YPosA lda #75 ;place player hor sec sta WSYNC sta HMCLRPosloopplayer sbc #15 bcs Posloopplayer eor #7 asl asl asl sta HMP0 sta RESP0 lda #75 ; place alien hor sec sta WSYNC sta HMCLRPosloopAlien sbc #15 bcs PosloopAlien eor #7 asl asl asl sta HMP1 sta RESP1 sta WSYNC sta HMOVE lda #0 sta HMP1 NextFrame ; start draw lda #2 ldx #49 sta WSYNC sta VSYNC stx TIM64T sta WSYNC lda #0 sta WSYNC sta VSYNC VertBlank sta WSYNC lda INTIM bne VertBlank sta VBLANK lda #$33 sta COLUPF ldx #7 lda #%11110000 sta PF0 lda #%11111111 sta PF1 lda #%11111111 sta PF2Drawtop8 ; draw top border sta WSYNC dex bne Drawtop8 ldx #175 lda #%11110000 sta PF0 lda #%00000000 sta PF1 lda #%00000000 sta PF2 Drawmiddle ; draw play area txa sec sbc YPos ; check if scanline is in player range cmp #Playerheight bcc InPlayerRange lda #0 ; if not don't draw InPlayerRange sta WSYNC tay lda Player,y ; load correct row of sprite sta GRP0 txa sec sbc YPosA cmp #Alienheight ; check if scanline is in alien range bcc InAlienRange lda #0 ; if not don't drawInAlienRange tay lda Alien,y sta GRP1 ; load correct row of sprite cpx #Missileheight ; check if scanline is missile line bne skipdrawmissile lda #2 sta ENAM0 ; if yes draw missile jmp endmiddleskipdrawmissile lda #0 ; if no don't draw sta ENAM0 endmiddle dex bne Drawmiddle lda #0 sta GRP0 sta GRP1 ldx #8 lda #%11110000 sta PF0 lda #%11111111 sta PF1 lda #%11111111 sta PF2Drawbottom ; draw bottom border sta WSYNC dex bne Drawbottom OverScan lda #2 sta VBLANK lda #32 sta TIM64T ;sta WSYNCcheckright ; check joy right lda #%10000000 bit SWCHA bne checkleft lda #$F0 sta HMP0 sta WSYNC sta HMOVE checkleft ; checkjoy left lda #%01000000 bit SWCHA bne checkfire lda #$10 sta HMP0 sta WSYNC sta HMOVE ;jmp checkup;checkup ; lda #%00100000 ; bit SWCHA ; bne checkdown ;dec YPos;checkdown ; lda #%00010000 ; bit SWCHA ;bne OSwait ;inc YPoscheckfire ; check if fire pressed lda #%10000000 bit INPT4 bne OSwait ; if no go to overscan lda #21 ; if yes move misile height to #21 sta Missileheight lda #2 sta RESMP0 ; if fire presses move missile hpos to player OSwait sta WSYNC lda INTIM bne OSwait inc Missileheight ; missile rising each frame jmp NextFrame org $fffc .word Start .word Start Quote Link to comment Share on other sites More sharing options...
ZackAttack Posted January 15, 2018 Share Posted January 15, 2018 You're using RESMP0 correctly. In fact everything looks correct except this line: cpx #Missileheight ; check if scanline is missile line You've included # so it's comparing X with the immediate value which is the location of the Missileheight variable instead of the value of the variable. Quote Link to comment Share on other sites More sharing options...
easmith Posted January 15, 2018 Author Share Posted January 15, 2018 Thanks, that gets the missile moving up the screen as desired but when fire button is pressed it still disappears Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted January 15, 2018 Share Posted January 15, 2018 Posting your source inline like that is detrimental to getting help. Click the More Reply Options button and you'll find the options to attach your *.asm file. Quote Link to comment Share on other sites More sharing options...
ZackAttack Posted January 15, 2018 Share Posted January 15, 2018 It would be good to include the bin file too so we don't have to build it to see what's happening. Quote Link to comment Share on other sites More sharing options...
easmith Posted January 15, 2018 Author Share Posted January 15, 2018 Sorry rookie mistake will do when back at computer Quote Link to comment Share on other sites More sharing options...
easmith Posted January 15, 2018 Author Share Posted January 15, 2018 ok here are the files shooter.bin shooter2.asm Quote Link to comment Share on other sites More sharing options...
ZackAttack Posted January 15, 2018 Share Posted January 15, 2018 The problem is that you never clear RESMP0. Per the stella programming guide, the missile will be hidden while D1 of RESMP0 is set. Missiles have an additional positioning command. Writing a “1” to D1 of the reset missile-to-player register (RESMP0, RESMP1) disables that missiles’ graphics (turns it off) and repositions it horizontally to the center of its’ associated player. Until a “0” is written to the register, the missiles’ horizontal position is locked to the center of its’ player in preparation to be fired again. Quote Link to comment Share on other sites More sharing options...
easmith Posted January 15, 2018 Author Share Posted January 15, 2018 got it, thanks! corrected bin file attached. on to next step...... shooter2.asm shooter.bin 1 Quote Link to comment Share on other sites More sharing options...
ZackAttack Posted January 16, 2018 Share Posted January 16, 2018 Looks good. You may want to enable RESMP0 when the missile goes off the screen and then disable it when the fire button is pressed. I think that would prevent the missile from restarting from the bottom when the button is pressed mid flight. Quote Link to comment Share on other sites More sharing options...
easmith Posted January 20, 2018 Author Share Posted January 20, 2018 fixed it shooter.bin 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.