mirror of https://github.com/deater/tb1.git
snes: firing missiles sort of works
they wrap around top of screen so you can never fire more than 2 total. It's a start though.
This commit is contained in:
parent
b35021a073
commit
131b79cabf
|
@ -1,2 +1,2 @@
|
|||
.word $a1f3 ; Complement of checksum
|
||||
.word $5e0c ; Unsigned 16-bit sum of ROM
|
||||
.word $7233 ; Complement of checksum
|
||||
.word $8dcc ; Unsigned 16-bit sum of ROM
|
||||
|
|
|
@ -31,6 +31,11 @@ joypad1_held_h = $0d
|
|||
sprite_l = $10
|
||||
sprite_h = $11
|
||||
|
||||
SPRITE_HIGH_LOOKUP = $20
|
||||
SHL2 = $21
|
||||
SHL3 = $22
|
||||
SHL4 = $23
|
||||
|
||||
HISCORE_1 = $cb
|
||||
HISCORE_2 = $cc
|
||||
HISCORE_3 = $cd
|
||||
|
@ -352,6 +357,20 @@ level1_setup_video:
|
|||
|
||||
jsr svmw_fade_in
|
||||
|
||||
|
||||
;===========================
|
||||
; init lookup tables
|
||||
;===========================
|
||||
|
||||
lda #$01
|
||||
sta SPRITE_HIGH_LOOKUP
|
||||
lda #$04
|
||||
sta SHL2
|
||||
lda #$10
|
||||
sta SHL3
|
||||
lda #$40
|
||||
sta SHL4
|
||||
|
||||
;====================
|
||||
; setup the high score
|
||||
;=====================
|
||||
|
@ -1775,10 +1794,22 @@ done_with_boss:
|
|||
; Missiles are 8,9,10,11 in sprite table
|
||||
|
||||
|
||||
; ldy #$0 ; point to missile[0]
|
||||
ldy #$8 ; point to missile[0]
|
||||
move_missiles:
|
||||
; lda (MISSILE_PL),Y ; get missile[y]
|
||||
; beq loop_move_missiles ; if missile.out==0 skip
|
||||
jsr is_sprite_active
|
||||
bcc loop_move_missiles ; if not active, skip
|
||||
|
||||
phy
|
||||
tya
|
||||
asl
|
||||
asl
|
||||
tay
|
||||
|
||||
lda $0201,Y
|
||||
dea
|
||||
sta $0201,Y
|
||||
|
||||
ply
|
||||
|
||||
; iny ; move to missile.y
|
||||
; iny
|
||||
|
@ -1856,50 +1887,12 @@ done_missile_collision:
|
|||
; jmp loop_move_at_y
|
||||
|
||||
loop_move_missiles:
|
||||
; iny
|
||||
; iny
|
||||
loop_move_at_y:
|
||||
; iny
|
||||
; cpy #NUM_MISSILES*3 ; have we checked all missiles?
|
||||
; bne move_missiles ; if not, loop
|
||||
iny
|
||||
cpy #(8+NUM_MISSILES) ; have we checked all missiles?
|
||||
bne move_missiles ; if not, loop
|
||||
|
||||
done_move_missiles:
|
||||
|
||||
; ldy #$0 ; point to missiles[0]
|
||||
draw_missiles:
|
||||
; lda (MISSILE_PL),Y ; get missile[y]
|
||||
; beq loop_draw_missiles ; if missile.out==0 skip
|
||||
|
||||
; iny ; point to missile.x
|
||||
; lda (MISSILE_PL),Y ; load it
|
||||
; sta CH
|
||||
; iny ; point to missile.y
|
||||
; lda (MISSILE_PL),Y ; load it
|
||||
; sta CV
|
||||
|
||||
; sty YSAV1 ; save Y
|
||||
|
||||
; lda #>missile_sprite ; point to the missile sprite
|
||||
; sta STRINGH
|
||||
; lda #<missile_sprite
|
||||
; sta STRINGL
|
||||
; jsr blit ; blit the missile sprite
|
||||
|
||||
; ldy YSAV1 ; restore Y
|
||||
|
||||
; jmp loop_draw_missiles_noadd
|
||||
|
||||
loop_draw_missiles:
|
||||
; iny
|
||||
; iny
|
||||
|
||||
loop_draw_missiles_noadd:
|
||||
; iny
|
||||
|
||||
; cpy #NUM_MISSILES*3 ; have we looped through them all?
|
||||
; bne draw_missiles ; if not, loop
|
||||
|
||||
|
||||
;===============================
|
||||
; handle joypad input
|
||||
;===============================
|
||||
|
@ -1946,35 +1939,37 @@ key_A:
|
|||
bit #$80
|
||||
beq game_unknown
|
||||
|
||||
; ldy #$0 ; point to missile[y]
|
||||
ldy #$8 ; point to missile[y]
|
||||
fire_missiles:
|
||||
; lda (MISSILE_PL),Y ; get missile[y].out
|
||||
; bne end_fire_loop ; if not out, skip ahead
|
||||
jsr is_sprite_active
|
||||
bcs end_fire_loop ; if active, skip to next
|
||||
|
||||
phy
|
||||
tya
|
||||
asl
|
||||
asl
|
||||
tay
|
||||
|
||||
; lda #$1 ; set missile[y].out=1
|
||||
; sta (MISSILE_PL),Y
|
||||
; iny ; point to missile[y].x
|
||||
lda #8
|
||||
clc
|
||||
adc shipx ; missile[y].x=shipx+8
|
||||
sta $0220
|
||||
; iny ; point to missile[y].y
|
||||
lda #190 ; set to 190
|
||||
sta $0221
|
||||
adc shipx ; missile[y].x=shipx+8
|
||||
sta $0200,Y ; $220 + 4*(Y-8)
|
||||
|
||||
lda $0402
|
||||
and #.LOBYTE(~$1)
|
||||
sta $0402
|
||||
lda #190 ; set to 190
|
||||
sta $0201,Y
|
||||
|
||||
; jmp done_fire_missiles
|
||||
|
||||
;end_fire_loop:
|
||||
; iny
|
||||
; iny
|
||||
; iny
|
||||
ply
|
||||
jsr activate_sprite
|
||||
|
||||
bra done_fire_missiles ; done firing missile
|
||||
|
||||
end_fire_loop:
|
||||
iny ; point to next missile
|
||||
|
||||
cpy #(8+NUM_MISSILES) ; see if we have more missiles
|
||||
bne fire_missiles ; if so, loop
|
||||
|
||||
; cpy #NUM_MISSILES*3 ; see if we have more missiles
|
||||
; bne fire_missiles ; if so, loop
|
||||
done_fire_missiles:
|
||||
|
||||
jmp move_ship
|
||||
|
@ -2448,7 +2443,7 @@ update_shields:
|
|||
|
||||
lda SHIELDS
|
||||
bne normal_shields
|
||||
|
||||
|
||||
|
||||
flash_shields:
|
||||
lda #$7f
|
||||
|
@ -2457,29 +2452,29 @@ flash_shields:
|
|||
iny
|
||||
cpy #$7
|
||||
bne flash_shields
|
||||
jmp shields_line
|
||||
jmp shields_line
|
||||
|
||||
normal_shields:
|
||||
normal_shields:
|
||||
lda #$80
|
||||
ora (STRINGL),Y
|
||||
sta (STRINGL),Y
|
||||
iny
|
||||
cpy #$7
|
||||
bne normal_shields
|
||||
|
||||
|
||||
shields_line:
|
||||
|
||||
ldy #$A
|
||||
ldx #$0
|
||||
shield_line_loop:
|
||||
|
||||
shield_line_loop:
|
||||
|
||||
cpx SHIELDS
|
||||
bmi shield_box
|
||||
lda #'_'+128
|
||||
jmp shield_char
|
||||
shield_box:
|
||||
lda #' '
|
||||
shield_char:
|
||||
shield_char:
|
||||
sta (STRINGL),Y
|
||||
iny
|
||||
iny
|
||||
|
|
|
@ -271,3 +271,90 @@ found_keypress:
|
|||
|
||||
plp ; restore status
|
||||
rts
|
||||
|
||||
;===========================
|
||||
;===========================
|
||||
; is_sprite_active
|
||||
;===========================
|
||||
;===========================
|
||||
; assumes high sprite table at $0400
|
||||
; sets carry if active
|
||||
; clears carry if not
|
||||
; sprite number in X
|
||||
is_sprite_active:
|
||||
|
||||
; php
|
||||
phx
|
||||
phy
|
||||
|
||||
lda #$0
|
||||
xba
|
||||
|
||||
tyx
|
||||
|
||||
; address=$0400 + Y/4
|
||||
txa
|
||||
lsr
|
||||
lsr
|
||||
tay
|
||||
|
||||
txa
|
||||
and #$3
|
||||
tax
|
||||
lda SPRITE_HIGH_LOOKUP,X
|
||||
|
||||
and $0400,Y ; sprite on screen when bit is 0
|
||||
beq sprite_is_active
|
||||
|
||||
clc
|
||||
bra done_sprite_is_active
|
||||
|
||||
sprite_is_active:
|
||||
sec
|
||||
|
||||
done_sprite_is_active:
|
||||
ply
|
||||
plx
|
||||
; plp
|
||||
rts
|
||||
|
||||
|
||||
;===========================
|
||||
;===========================
|
||||
; activate_sprite
|
||||
;===========================
|
||||
;===========================
|
||||
; assumes high sprite table at $0400
|
||||
; sets carry if active
|
||||
; clears carry if not
|
||||
; sprite number in X
|
||||
activate_sprite:
|
||||
|
||||
php
|
||||
phx
|
||||
phy
|
||||
|
||||
lda #$0
|
||||
xba
|
||||
|
||||
tyx
|
||||
|
||||
; address=$0400 + Y/4
|
||||
txa
|
||||
lsr
|
||||
lsr
|
||||
tay
|
||||
|
||||
txa
|
||||
and #$3
|
||||
tax
|
||||
lda SPRITE_HIGH_LOOKUP,X
|
||||
eor #$ff
|
||||
|
||||
and $0400,Y ; sprite on screen when bit is 0
|
||||
sta $0400,Y
|
||||
|
||||
ply
|
||||
plx
|
||||
plp
|
||||
rts
|
||||
|
|
Loading…
Reference in New Issue