Jump to content
IGNORED

help with missile graphic


easmith

Recommended Posts

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 $80
YPos .byte
YPosA .byte
Missileheight .byte
Playerheight equ 9
Alienheight equ 10
seg Code
org $f000
Player
.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 #$ff
ZeroZP 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 HMCLR
Posloopplayer
sbc #15
bcs Posloopplayer
eor #7
asl
asl
asl
sta HMP0
sta RESP0
lda #75 ; place alien hor
sec
sta WSYNC
sta HMCLR
PosloopAlien
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 PF2
Drawtop8 ; 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 draw
InAlienRange

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 endmiddle
skipdrawmissile

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 PF2
Drawbottom ; draw bottom border
sta WSYNC
dex
bne Drawbottom
OverScan

lda #2
sta VBLANK
lda #32
sta TIM64T
;sta WSYNC
checkright ; 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 YPos
checkfire ; 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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...