-
Notifications
You must be signed in to change notification settings - Fork 0
/
player_main.dasm
183 lines (165 loc) · 3.77 KB
/
player_main.dasm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
oam_ram_rudy EQU $0204
; CONST
player_dead_tile EQM $c0
iframe_attract_length EQM $08
iframe_game_length EQM $04
player_game_reset: subroutine
lda #$00
sta ftw
; clearing 18 bytes of game data
; see zp_vars.asm for details! ;D
ldx #$20
.clear_loop
sta phase_state,x
dex
bpl .clear_loop
; XXX testing phase behaviours
;lda #3
;sta phase_level
;lda #$3f
;sta phase_current
jsr phase_palette_load
jsr timer_reset
lda #$d0
sta player_x_hi
sta player_demo_x
lda #$70
sta player_y_hi
sta player_demo_y
lda #$ff
sta player_health
; set player stats
lda #$03
sta player_lives
ldx game_difficulty
lda player_gun_strength_per_difficulty,x
sta player_gun_str
lda #$0f
sta player_autofire_s
rts
player_update_colors: subroutine
; dashboard is bg_3
; player is spr_0
lda player_color0
sta pal_spr_0_3
; darken dash bg color
sec
sbc #$10
sta pal_bg_3_1
; do the rest of player colours
lda player_color1
sta pal_bg_3_2
sta pal_spr_0_2
lda player_color2
sta pal_bg_3_3
sta pal_spr_0_1
rts
player_take_damage: subroutine
; make sure iframes are not enable
lda state_iframes
beq .not_iframes
rts
.not_iframes
lda shroom_counter
beq .apply_damage
rts
.apply_damage
; set damage display counter
lda #$10
sta player_damage_flash
; XXX enemy hits won't trigger iframes if turbo gun?
; check if turbo gun is enabled
lda player_controls
and #BUTTON_A
bne .skip_iframes
; set iframes
lda state_iframe_length
sta state_iframes
.skip_iframes
; damage amount in player_damage
lda player_health
sec
sbc player_damage
bcc .player_dead
beq .player_dead
sta player_health
rts
.player_dead
; player can be saved by mask shield!
lda orbit_shield_speed
beq .player_really_dead
; disable shield
lda #$00
sta orbit_shield_speed
; drift off screen to the right
lda #1
sta bullet_x_vel
lda #$ff
sta player_health
rts
.player_really_dead
; player_health 00 means DEATH
lda #$00
sta player_health
rts
set_player_sprite: subroutine
lda state_render_addr
cmp #state_render_jump_table_offset+1
bne .not_menu_screens
.is_menu_screens
; sprite (menus)
lda #$8e
sta oam_ram_rudy+1
lda #$8f
sta oam_ram_rudy+5
bne .sprite_set
.not_menu_screens
; sprite (game)
lda #$4a
sta oam_ram_rudy+1
lda #$4b
sta oam_ram_rudy+5
.sprite_set
; x pos
lda player_x_hi
sta $207
clc
adc #$08
sta $20b
; y pos
lda player_y_hi
sta $204
sta $208
; attributes
lda #$00
sta $206
sta $20a
lda player_health
bne .not_dead
.is_dead
lda #player_dead_tile
sta oam_ram_rudy+5
sta oam_ram_rudy+1
rts
.not_dead
; check and decrement iframe counter
lda state_iframes
beq .not_iframes
dec state_iframes
.not_iframes
; check and decrement iframe counter
lda player_damage_flash
beq .not_flashing
dec player_damage_flash
; flash rudy based on iframe counter
lsr
and #$01
bne .not_flashing
; iframes
lda #$4c
sta oam_ram_rudy+1
lda #$4d
sta oam_ram_rudy+5
rts
.not_flashing
rts