mirror of
https://github.com/deater/tb1.git
synced 2024-06-07 05:29:28 +00:00
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 $7233 ; Complement of checksum
|
||||||
.word $5e0c ; Unsigned 16-bit sum of ROM
|
.word $8dcc ; Unsigned 16-bit sum of ROM
|
||||||
|
|
|
@ -31,6 +31,11 @@ joypad1_held_h = $0d
|
||||||
sprite_l = $10
|
sprite_l = $10
|
||||||
sprite_h = $11
|
sprite_h = $11
|
||||||
|
|
||||||
|
SPRITE_HIGH_LOOKUP = $20
|
||||||
|
SHL2 = $21
|
||||||
|
SHL3 = $22
|
||||||
|
SHL4 = $23
|
||||||
|
|
||||||
HISCORE_1 = $cb
|
HISCORE_1 = $cb
|
||||||
HISCORE_2 = $cc
|
HISCORE_2 = $cc
|
||||||
HISCORE_3 = $cd
|
HISCORE_3 = $cd
|
||||||
|
@ -352,6 +357,20 @@ level1_setup_video:
|
||||||
|
|
||||||
jsr svmw_fade_in
|
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
|
; setup the high score
|
||||||
;=====================
|
;=====================
|
||||||
|
@ -1775,10 +1794,22 @@ done_with_boss:
|
||||||
; Missiles are 8,9,10,11 in sprite table
|
; Missiles are 8,9,10,11 in sprite table
|
||||||
|
|
||||||
|
|
||||||
; ldy #$0 ; point to missile[0]
|
ldy #$8 ; point to missile[0]
|
||||||
move_missiles:
|
move_missiles:
|
||||||
; lda (MISSILE_PL),Y ; get missile[y]
|
jsr is_sprite_active
|
||||||
; beq loop_move_missiles ; if missile.out==0 skip
|
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 ; move to missile.y
|
||||||
; iny
|
; iny
|
||||||
|
@ -1856,50 +1887,12 @@ done_missile_collision:
|
||||||
; jmp loop_move_at_y
|
; jmp loop_move_at_y
|
||||||
|
|
||||||
loop_move_missiles:
|
loop_move_missiles:
|
||||||
; iny
|
iny
|
||||||
; iny
|
cpy #(8+NUM_MISSILES) ; have we checked all missiles?
|
||||||
loop_move_at_y:
|
bne move_missiles ; if not, loop
|
||||||
; iny
|
|
||||||
; cpy #NUM_MISSILES*3 ; have we checked all missiles?
|
|
||||||
; bne move_missiles ; if not, loop
|
|
||||||
|
|
||||||
done_move_missiles:
|
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
|
; handle joypad input
|
||||||
;===============================
|
;===============================
|
||||||
|
@ -1946,35 +1939,37 @@ key_A:
|
||||||
bit #$80
|
bit #$80
|
||||||
beq game_unknown
|
beq game_unknown
|
||||||
|
|
||||||
; ldy #$0 ; point to missile[y]
|
ldy #$8 ; point to missile[y]
|
||||||
fire_missiles:
|
fire_missiles:
|
||||||
; lda (MISSILE_PL),Y ; get missile[y].out
|
jsr is_sprite_active
|
||||||
; bne end_fire_loop ; if not out, skip ahead
|
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
|
lda #8
|
||||||
clc
|
clc
|
||||||
adc shipx ; missile[y].x=shipx+8
|
adc shipx ; missile[y].x=shipx+8
|
||||||
sta $0220
|
sta $0200,Y ; $220 + 4*(Y-8)
|
||||||
; iny ; point to missile[y].y
|
|
||||||
lda #190 ; set to 190
|
|
||||||
sta $0221
|
|
||||||
|
|
||||||
lda $0402
|
lda #190 ; set to 190
|
||||||
and #.LOBYTE(~$1)
|
sta $0201,Y
|
||||||
sta $0402
|
|
||||||
|
|
||||||
; jmp done_fire_missiles
|
|
||||||
|
|
||||||
;end_fire_loop:
|
ply
|
||||||
; iny
|
jsr activate_sprite
|
||||||
; iny
|
|
||||||
; iny
|
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:
|
done_fire_missiles:
|
||||||
|
|
||||||
jmp move_ship
|
jmp move_ship
|
||||||
|
@ -2448,7 +2443,7 @@ update_shields:
|
||||||
|
|
||||||
lda SHIELDS
|
lda SHIELDS
|
||||||
bne normal_shields
|
bne normal_shields
|
||||||
|
|
||||||
|
|
||||||
flash_shields:
|
flash_shields:
|
||||||
lda #$7f
|
lda #$7f
|
||||||
|
@ -2457,29 +2452,29 @@ flash_shields:
|
||||||
iny
|
iny
|
||||||
cpy #$7
|
cpy #$7
|
||||||
bne flash_shields
|
bne flash_shields
|
||||||
jmp shields_line
|
jmp shields_line
|
||||||
|
|
||||||
normal_shields:
|
normal_shields:
|
||||||
lda #$80
|
lda #$80
|
||||||
ora (STRINGL),Y
|
ora (STRINGL),Y
|
||||||
sta (STRINGL),Y
|
sta (STRINGL),Y
|
||||||
iny
|
iny
|
||||||
cpy #$7
|
cpy #$7
|
||||||
bne normal_shields
|
bne normal_shields
|
||||||
|
|
||||||
shields_line:
|
shields_line:
|
||||||
|
|
||||||
ldy #$A
|
ldy #$A
|
||||||
ldx #$0
|
ldx #$0
|
||||||
shield_line_loop:
|
shield_line_loop:
|
||||||
|
|
||||||
cpx SHIELDS
|
cpx SHIELDS
|
||||||
bmi shield_box
|
bmi shield_box
|
||||||
lda #'_'+128
|
lda #'_'+128
|
||||||
jmp shield_char
|
jmp shield_char
|
||||||
shield_box:
|
shield_box:
|
||||||
lda #' '
|
lda #' '
|
||||||
shield_char:
|
shield_char:
|
||||||
sta (STRINGL),Y
|
sta (STRINGL),Y
|
||||||
iny
|
iny
|
||||||
iny
|
iny
|
||||||
|
|
|
@ -271,3 +271,90 @@ found_keypress:
|
||||||
|
|
||||||
plp ; restore status
|
plp ; restore status
|
||||||
rts
|
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
Block a user