dos33fsprogs/games/sb/asplode.s

492 lines
7.5 KiB
ArmAsm
Raw Normal View History

2023-06-02 20:37:01 +00:00
; Strongbad Zone
;
2023-06-02 19:40:42 +00:00
; Yet Another HR project
;
; by deater (Vince Weaver) <vince@deater.net>
2023-06-06 19:34:11 +00:00
; some notes on the engine from the original
; bullet moving is not 3d in any way, it's just 2D
; there are distinct Y locations with different sized sprites
; X velocity starts at 3
; hitting shield left, subs random 0..5
; hitting shield right, adds random 0..5
; hitting shield center, adds random -0.5 .. 0.5
; bounces off side walls roughly at same X as back walls
; doesn't even try to adjust for Y
; if it hits back wall, it reflects back
; if it misses you, makes small explosion, starts again at far wall
; with same X as it went off screen with
2023-06-02 19:40:42 +00:00
.include "zp.inc"
.include "hardware.inc"
2023-06-03 22:37:14 +00:00
div7_table = $400
mod7_table = $500
hposn_high = $600
hposn_low = $700
2023-06-02 19:40:42 +00:00
2023-06-03 22:37:14 +00:00
strongbadzone_start:
2023-06-02 19:40:42 +00:00
;===================
; set graphics mode
;===================
jsr HOME
bit HIRES
bit FULLGR
bit SET_GR
bit PAGE1
2023-06-02 20:37:01 +00:00
;====================
; set up tables
;====================
2023-06-02 19:40:42 +00:00
2023-06-02 20:37:01 +00:00
lda #$20
sta HGR_PAGE
jsr hgr_make_tables
2023-06-02 19:40:42 +00:00
2023-06-05 20:29:18 +00:00
;==========================
; Load Sound
;===========================
lda SOUND_STATUS
and #SOUND_IN_LC
beq done_load_sound
; read/write RAM, use $d000 bank1
bit $C083
bit $C083
lda #<sound_data
sta ZX0_src
lda #>sound_data
sta ZX0_src+1
lda #$D0
jsr full_decomp
; read ROM/no-write
bit $C082
done_load_sound:
2023-06-02 19:40:42 +00:00
;==========================
; Load Title
;===========================
load_title:
lda #<title_data
sta ZX0_src
lda #>title_data
sta ZX0_src+1
lda #$20
jsr full_decomp
2023-06-02 21:07:04 +00:00
; load to page2 for color cycle
lda #<title_data
sta ZX0_src
lda #>title_data
sta ZX0_src+1
lda #$40
jsr full_decomp
title_cycle_loop:
jsr cycle_colors
inc FRAME
lda KEYPRESS
bpl title_cycle_loop
bit KEYRESET
2023-06-02 19:40:42 +00:00
;===================
2023-06-02 20:37:01 +00:00
; setup game
2023-06-02 19:40:42 +00:00
;===================
;==========================
2023-06-02 20:37:01 +00:00
; Load Background
2023-06-02 19:40:42 +00:00
;===========================
2023-06-02 20:37:01 +00:00
load_background:
2023-06-02 19:40:42 +00:00
; size in ldsizeh:ldsizel (f1/f0)
lda #<comp_data
sta ZX0_src
lda #>comp_data
sta ZX0_src+1
2023-06-05 20:29:18 +00:00
lda #$A0
2023-06-02 19:40:42 +00:00
jsr full_decomp
2023-06-09 20:56:25 +00:00
;===================
; set up variables
2023-06-02 20:37:01 +00:00
lda #16
sta STRONGBAD_X
sta PLAYER_X
2023-06-03 16:48:37 +00:00
lda #1
sta STRONGBAD_DIR
2023-06-04 04:46:01 +00:00
lda #SHIELD_DOWN
sta SHIELD_POSITION
2023-06-04 04:50:59 +00:00
sta SHIELD_COUNT
2023-06-04 04:46:01 +00:00
2023-06-06 19:34:11 +00:00
lda #0
sta BULLET_X_L
sta BULLET_X_VEL
2023-06-09 20:56:25 +00:00
sta HEAD_DAMAGE
2023-06-06 19:34:11 +00:00
2023-06-05 05:48:45 +00:00
lda #20
sta BULLET_X
2023-06-06 19:34:11 +00:00
lda #0
2023-06-05 05:48:45 +00:00
sta BULLET_Y
2023-06-02 20:37:01 +00:00
;==========================
; main loop
;===========================
main_loop:
jsr flip_page
2023-06-03 22:37:14 +00:00
;========================
2023-06-04 04:46:01 +00:00
; copy over background
2023-06-03 22:37:14 +00:00
;========================
2023-06-09 19:43:52 +00:00
reset_loop:
2023-06-03 22:37:14 +00:00
jsr hgr_copy
2023-06-03 16:48:37 +00:00
2023-06-03 22:37:14 +00:00
inc FRAME
2023-06-04 04:50:59 +00:00
;==========================
; adjust shield
;==========================
lda SHIELD_COUNT
beq done_shield_count
dec SHIELD_COUNT
bne done_shield_count
lda #SHIELD_DOWN ; put shield down if timeout
sta SHIELD_POSITION
done_shield_count:
2023-06-03 16:48:37 +00:00
;===========================
; move head
;===========================
lda FRAME
and #$3
bne no_move_head
lda STRONGBAD_X
2023-06-03 22:37:14 +00:00
cmp #21
2023-06-03 16:48:37 +00:00
bcs reverse_head_dir
cmp #12
bcs no_reverse_head_dir
reverse_head_dir:
lda STRONGBAD_DIR
eor #$FF
sta STRONGBAD_DIR
inc STRONGBAD_DIR
no_reverse_head_dir:
clc
lda STRONGBAD_X
adc STRONGBAD_DIR
sta STRONGBAD_X
no_move_head:
2023-06-02 20:37:01 +00:00
;==========================
; draw head
;===========================
2023-06-09 20:56:25 +00:00
ldx HEAD_DAMAGE
lda head_sprites_l,X
2023-06-02 20:37:01 +00:00
sta INL
2023-06-09 20:56:25 +00:00
lda head_sprites_h,X
2023-06-02 20:37:01 +00:00
sta INH
lda STRONGBAD_X
sta SPRITE_X
lda #36
sta SPRITE_Y
2023-06-03 20:00:05 +00:00
jsr hgr_draw_sprite_big
2023-06-02 20:37:01 +00:00
2023-06-05 05:48:45 +00:00
;==========================
; move bullet
;===========================
2023-06-06 19:34:11 +00:00
; 16 bit add
clc
lda BULLET_X_L
adc BULLET_X_VEL
sta BULLET_X_L
lda BULLET_X
adc #0
sta BULLET_X
; TODO: bounce off walls
2023-06-05 05:48:45 +00:00
inc BULLET_Y
lda BULLET_Y
2023-06-06 19:34:11 +00:00
cmp #15
2023-06-05 05:48:45 +00:00
bcc bullet_still_good
; new bullet position
; FIXME: better
2023-06-06 19:34:11 +00:00
lda #0
2023-06-05 05:48:45 +00:00
sta BULLET_Y
bullet_still_good:
;==========================
; draw bullet
;===========================
2023-06-06 19:34:11 +00:00
ldy BULLET_Y
lda bullet_sprite_l,Y
2023-06-05 05:48:45 +00:00
sta INL
2023-06-06 19:34:11 +00:00
lda bullet_sprite_h,Y
2023-06-05 05:48:45 +00:00
sta INH
2023-06-06 19:34:11 +00:00
2023-06-05 05:48:45 +00:00
lda BULLET_X
sta SPRITE_X
2023-06-06 19:34:11 +00:00
lda bullet_sprite_y,Y
2023-06-05 05:48:45 +00:00
sta SPRITE_Y
jsr hgr_draw_sprite_big
2023-06-02 20:37:01 +00:00
;==========================
; draw player
;===========================
2023-06-04 04:46:01 +00:00
ldx SHIELD_POSITION
lda shield_sprites_l,X
2023-06-02 20:37:01 +00:00
sta INL
2023-06-04 04:46:01 +00:00
lda shield_sprites_h,X
2023-06-02 20:37:01 +00:00
sta INH
lda PLAYER_X
sta SPRITE_X
lda #138
sta SPRITE_Y
2023-06-03 20:00:05 +00:00
jsr hgr_draw_sprite_big
2023-06-02 20:37:01 +00:00
check_keypress:
lda KEYPRESS
2023-06-03 16:48:37 +00:00
bpl done_keyboard_check
2023-06-02 20:37:01 +00:00
bit KEYRESET ; clear the keyboard strobe
; clear high bit
and #$7f
2023-06-02 19:40:42 +00:00
2023-06-02 20:37:01 +00:00
; FIXME: adjust for lowercase too
cmp #'Q'
beq done_game
cmp #27 ; escape
beq done_game
cmp #'A' ; shield left
2023-06-04 04:46:01 +00:00
beq shield_left
2023-06-02 20:37:01 +00:00
cmp #'S' ; shield center
2023-06-04 04:46:01 +00:00
beq shield_center
2023-06-02 20:37:01 +00:00
cmp #'D' ; shield right
2023-06-04 04:46:01 +00:00
beq shield_right
2023-06-02 20:37:01 +00:00
2023-06-05 20:29:18 +00:00
cmp #'X'
beq asplode_asplode
2023-06-02 20:37:01 +00:00
cmp #8 ; left
beq move_left
cmp #$15
beq move_right ; right
done_keyboard_check:
2023-06-03 16:48:37 +00:00
jmp main_loop
2023-06-02 20:37:01 +00:00
move_left:
2023-06-03 22:37:14 +00:00
lda PLAYER_X
beq no_more_left
2023-06-02 20:37:01 +00:00
dec PLAYER_X
2023-06-03 22:37:14 +00:00
no_more_left:
2023-06-02 20:37:01 +00:00
jmp main_loop
move_right:
2023-06-03 22:37:14 +00:00
lda PLAYER_X
2023-06-04 04:46:01 +00:00
cmp #28 ; bge
2023-06-03 22:37:14 +00:00
bcs no_more_right
2023-06-02 20:37:01 +00:00
inc PLAYER_X
2023-06-03 22:37:14 +00:00
no_more_right:
2023-06-02 20:37:01 +00:00
jmp main_loop
2023-06-04 04:46:01 +00:00
shield_left:
lda #SHIELD_UP_LEFT
bne adjust_shield
shield_center:
lda #SHIELD_UP_CENTER
bne adjust_shield
shield_right:
lda #SHIELD_UP_RIGHT
adjust_shield:
sta SHIELD_POSITION
2023-06-04 04:50:59 +00:00
lda #5
sta SHIELD_COUNT
2023-06-04 04:46:01 +00:00
jmp main_loop
2023-06-02 20:37:01 +00:00
2023-06-05 20:29:18 +00:00
asplode_asplode:
2023-06-02 20:37:01 +00:00
jsr do_asplode
2023-06-05 20:29:18 +00:00
2023-06-09 19:43:52 +00:00
jmp reset_loop
2023-06-02 20:37:01 +00:00
;==========================
; done game
;==========================
done_game:
2023-06-02 19:40:42 +00:00
lda #0
sta WHICH_LOAD
rts
wait_until_keypress:
lda KEYPRESS ; 4
bpl wait_until_keypress ; 3
bit KEYRESET ; clear the keyboard buffer
rts
2023-06-09 19:43:52 +00:00
.include "asplode_head.s"
;==========
; flip page
;==========
flip_page:
lda DRAW_PAGE
beq draw_page2
draw_page1:
bit PAGE2
lda #0
beq done_flip
draw_page2:
bit PAGE1
lda #$20
done_flip:
sta DRAW_PAGE
rts
2023-06-02 20:37:01 +00:00
.include "hgr_tables.s"
2023-06-02 19:40:42 +00:00
.include "zx02_optim.s"
2023-06-02 20:37:01 +00:00
.include "hgr_sprite_big.s"
2023-06-02 21:07:04 +00:00
.include "cycle_colors.s"
2023-06-03 22:37:14 +00:00
.include "hgr_copy_fast.s"
2023-06-05 20:29:18 +00:00
.include "audio.s"
.include "play_asplode.s"
2023-06-02 20:37:01 +00:00
.include "asplode_graphics/sb_sprites.inc"
2023-06-02 19:40:42 +00:00
title_data:
.incbin "asplode_graphics/sb_title.hgr.zx02"
comp_data:
.incbin "asplode_graphics/sb_zone.hgr.zx02"
2023-06-05 20:29:18 +00:00
sound_data:
.incbin "asplode_sound/asplode.btc.zx02"
2023-06-02 19:40:42 +00:00
2023-06-04 04:46:01 +00:00
shield_sprites_l:
.byte <player_sprite,<shield_left_sprite
.byte <shield_center_sprite,<shield_right_sprite
shield_sprites_h:
.byte >player_sprite,>shield_left_sprite
.byte >shield_center_sprite,>shield_right_sprite
2023-06-06 19:34:11 +00:00
2023-06-09 20:56:25 +00:00
head_sprites_l:
.byte <big_head0_sprite,<big_head1_sprite,<big_head2_sprite
.byte <big_head3_sprite,<big_head4_sprite
head_sprites_h:
.byte >big_head0_sprite,>big_head1_sprite,>big_head2_sprite
.byte >big_head3_sprite,>big_head4_sprite
2023-06-06 19:34:11 +00:00
y_positions:
; 90 to 160 roughly? Let's say 64?
; have 16 positions? 4 each?
; can probably optimize this
bullet_sprite_l:
.byte <bullet0_sprite, <bullet1_sprite, <bullet2_sprite, <bullet3_sprite
.byte <bullet4_sprite, <bullet5_sprite, <bullet6_sprite, <bullet7_sprite
.byte <bullet8_sprite, <bullet9_sprite,<bullet10_sprite,<bullet11_sprite
.byte <bullet12_sprite,<bullet13_sprite,<bullet14_sprite,<bullet15_sprite
bullet_sprite_h:
.byte >bullet0_sprite, >bullet1_sprite, >bullet2_sprite, >bullet3_sprite
.byte >bullet4_sprite, >bullet5_sprite, >bullet6_sprite, >bullet7_sprite
.byte >bullet8_sprite, >bullet9_sprite,>bullet10_sprite,>bullet11_sprite
.byte >bullet12_sprite,>bullet13_sprite,>bullet14_sprite,>bullet15_sprite
bullet_sprite_y:
.byte 90,94,98,102
.byte 106,110,114,118
.byte 122,126,130,134
.byte 138,142,146,150
; original
; 1 = 6
; 2 = 12
; 3 = 18
; 4 = 25
; 5 = 32
; 6 = 38
; 7 = 44
; 8 = 50
; 9 = 57
; 10= 63
; 11= 70
; 12= 77
; 13= 82
; 14= 89
; 15= 95
; 27= 167 (peak)
; 30= 148
; 31= 139
; 9,5 -> 22,14 = 12x9 roughly. 3 times smaller, 4x3? 2x6?