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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
Update_Blinking_Counter:
LD A, $mem_blinking_animation_counter
DEC A
CP $ff
RET Z
LD $mem_blinking_animation_counter, A
RET
Update_Animation_Steps:
LD A, $mem_map_loading_flags
BIT 3, A
JR Z, =.update_mode
LD A, $mem_map_loading_flags
SET 0, A
LD $mem_map_loading_flags, A
LD A, $mem_moving_animation_step
INC A
AND $0f
LD $mem_moving_animation_step, A
CP $00
JR NZ, =.end
LD A, $00
LD $mem_bunny_animation, A
LD A, $mem_map_loading_flags
RES 3, A
SET 1, A
LD $mem_map_loading_flags, A
.update_mode:
; We need to make sure that the mode doesn't change to a mode with objects update while a dialogue box refresh is currently being done
LD A, $mem_current_mode
BIT 7, A
JR Z, =.set_current_mode
LD A, $mem_display_flag
AND 0b00010100
CP $00
JR NZ, =.end
.set_current_mode:
LD A, $mem_requested_mode
LD $mem_current_mode, A
CALL =Update_VBlank_Handler
.end:
LD A, $mem_moving_animation_step
CP $00
RET NZ
LD A, $mem_bunny_health
CP $00
RET NZ
.Dead_mode:
LD A, $mem_current_mode
CP $enum_dead_mode
RET Z
LD A, $00
LD $mem_bunny_direction, A
LD A, $02
LD $mem_bunny_animation, A
.LOAD_MUSIC =_music_GameOver
CALL =Start_Music
LD A, $enum_dead_mode
LD $mem_requested_mode, A
LD $mem_current_mode, A
CALL =Update_VBlank_Handler
LD HL, $dialogue_first_line
LD BC, $12
CALL =bzero
LD HL, $dialogue_third_line
LD BC, $12
CALL =bzero
LD HL, $dialogue_first_line
.LOAD_BANK_OF =Game_Over_1_Txt
LD BC, ptr(=Game_Over_1_Txt)
CALL =Print_str
LD HL, $dialogue_third_line
.LOAD_BANK_OF =Game_Over_2_Txt
LD BC, ptr(=Game_Over_2_Txt)
CALL =Print_str
LD A, 0b00100111
LD $mem_display_flag, A
RET
STAT_Entrypoint:
PUSH AF
PUSH DE
.SET_WINDOW_LCDC_E
LD A, $reg_lyc
CP $0a
JR Z, =.End_Top_Bar
CP $67
JR Z, =.Start_dialogue
.Thin_font:
LD A, $palette_thin_font
LD $reg_bg_palette, A
JR =.skip_dialogue
.Start_dialogue:
LD A, $mem_display_flag
BIT 0, A
JR Z, =.skip_dialogue
.ENABLE_DIALOGUE
LD A, $mem_display_flag
BIT 1, A
JR Z, =.Thin_font
LD A, $palette_bold_font
LD $reg_bg_palette, A
LD A, $77
LD $reg_lyc, A
.RESET_INTERRUPTS
POP DE
POP AF
RETI
.skip_dialogue:
.DISABLE_LYC_INTERRUPT
POP DE
POP AF
RETI
.End_Top_Bar:
.DISABLE_DIALOGUE
LD A, $67
LD $reg_lyc, A
.RESET_INTERRUPTS
POP DE
POP AF
RETI
Dungeon_VBLANK_Entrypoint:
.SET_WINDOW_LCDC_E
LD A, $mem_dungeon_flags
BIT 3, A
JR NZ, =.top_bar.enable
.DISABLE_TOP_BAR
LD A, $67
LD $reg_lyc, A
JR =.top_bar.end
.top_bar.enable:
.ENABLE_TOP_BAR
LD A, $0a
LD $reg_lyc, A
.top_bar.end:
CALL $OAM_DMA_Transfer_routine
LD HL, $9d60
LD A, $mem_bunny_health
CALL =Print_8bit
LD HL, $9d64
LD A, $mem_bunny_mana
CALL =Print_8bit
CALL =Display_Prepared_Blocks
CALL =Display_Object
; LYC
.ENABLE_LYC_INTERRUPT
.RESET_INTERRUPTS
EI
CALL =Pad_Button_Check
CALL =Load_Additional_Block
LD A, $mem_current_mode
CP $enum_dungeon_mode
JR NZ, =Skip_Dungeon_Update
CALL =Entities_Actions
CALL =Object_Interactions_Check
CALL =Maybe_Respawn_Entity
CALL =Prepare_Scrolling_Map
Skip_Dungeon_Update:
LD A, $mem_current_mode
CALL =Animation_Wait_Mode
CALL =Update_Blinking_Counter
CALL =Check_Open_Menu_button
CALL =Update_Animation_Steps
LD HL, $mem_entities_list
CALL =Center_viewport_around_entity
LD A, $00
LD $mem_oam_buffer_low, A
CALL =Display_Animation_List
CALL =Display_Entities
LD A, $mem_bunny_status_tile
LD ($9d6f), A
LD A, $mem_loop_frame_timer
INC A
LD $mem_loop_frame_timer, A
CALL =Play_Music
CALL =Play_Sound_Effect
.ENABLE_VBLANK_INTERRUPTS
RETI
|