Skip to content

Commit eb4dcf5

Browse files
committed
Add options to set escape timer starting values
1 parent 4a29209 commit eb4dcf5

File tree

7 files changed

+167
-1
lines changed

7 files changed

+167
-1
lines changed

src/defines.asm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@
322322
!ram_cm_dummy_off = !WRAM_MENU_START+$8C
323323
!ram_cm_dummy_num = !WRAM_MENU_START+$8E
324324

325+
!ram_cm_ceres_seconds = !WRAM_MENU_START+$80
326+
!ram_cm_zebes_seconds = !WRAM_MENU_START+$82
327+
325328
!ram_cm_crop_mode = !WRAM_MENU_START+$80
326329
!ram_cm_crop_tile = !WRAM_MENU_START+$82
327330

@@ -528,6 +531,8 @@
528531
!sram_infidoppler_enabled = !SRAM_START+$9A
529532
!sram_random_bubble_sfx = !SRAM_START+$9C
530533
!sram_demo_timer = !SRAM_START+$9E
534+
!sram_ceres_timer = !SRAM_START+$A0
535+
!sram_zebes_timer = !SRAM_START+$A2
531536

532537
; ^ FREE SPACE ^ up to +$EE
533538

@@ -762,6 +767,8 @@
762767
!DOOR_FINISHED_SCROLLING = $0931
763768
!CERES_STATUS = $093F
764769
!TIMER_STATUS = $0943
770+
!TIMER_CENTISECONDS = $0945
771+
!TIMER_SECONDS_MINUTES = $0946
765772
!CURRENT_SAVE_FILE = $0952
766773
!GAMEMODE = $0998
767774
!DOOR_FUNCTION_POINTER = $099C

src/gamemenu.asm

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ GameMenu:
1313
dw #$FFFF
1414
dw #game_cutscenes
1515
dw #game_demo_wait_timer
16+
dw #game_ceres_escape_timer
17+
dw #game_zebes_escape_timer
1618
dw #game_fast_doors_toggle
1719
dw #game_fast_elevators
1820
dw #$FFFF
@@ -50,6 +52,68 @@ game_cutscenes:
5052
game_demo_wait_timer:
5153
%cm_numfield_word("Demo Timer (frames)", !sram_demo_timer, 1, 9999, 1, 20, #0)
5254

55+
game_ceres_escape_timer:
56+
%cm_numfield_word("Ceres Timer (seconds)", !ram_cm_ceres_seconds, 1, 5999, 1, 20, .routine)
57+
.routine
58+
LDA !ram_cm_ceres_seconds : STA $4204
59+
%a8()
60+
LDA.b #$0A : STA $4206
61+
%a16()
62+
PEA $0000 : PLA ; wait for CPU math
63+
LDA $4216 : STA !sram_ceres_timer
64+
LDA $4214 : BEQ .end
65+
STA $4204
66+
%a8()
67+
LDA.b #$06 : STA $4206
68+
%a16()
69+
PEA $0000 : PLA ; wait for CPU math
70+
LDA $4216 : ASL #4
71+
ORA !sram_ceres_timer : STA !sram_ceres_timer
72+
LDA $4214 : BEQ .end
73+
STA $4204
74+
%a8()
75+
LDA.b #$0A : STA $4206
76+
%a16()
77+
PEA $0000 : PLA ; wait for CPU math
78+
LDA $4216 : XBA
79+
ORA !sram_ceres_timer : STA !sram_ceres_timer
80+
LDA $4214 : BEQ .end
81+
XBA : ASL #4
82+
ORA !sram_ceres_timer : STA !sram_ceres_timer
83+
.end
84+
RTL
85+
86+
game_zebes_escape_timer:
87+
%cm_numfield_word("Zebes Timer (seconds)", !ram_cm_zebes_seconds, 1, 5999, 1, 20, .routine)
88+
.routine
89+
LDA !ram_cm_zebes_seconds : STA $4204
90+
%a8()
91+
LDA.b #$0A : STA $4206
92+
%a16()
93+
PEA $0000 : PLA ; wait for CPU math
94+
LDA $4216 : STA !sram_zebes_timer
95+
LDA $4214 : BEQ .end
96+
STA $4204
97+
%a8()
98+
LDA.b #$06 : STA $4206
99+
%a16()
100+
PEA $0000 : PLA ; wait for CPU math
101+
LDA $4216 : ASL #4
102+
ORA !sram_zebes_timer : STA !sram_zebes_timer
103+
LDA $4214 : BEQ .end
104+
%a8()
105+
STA $4204
106+
LDA.b #$0A : STA $4206
107+
%a16()
108+
PEA $0000 : PLA ; wait for CPU math
109+
LDA $4216 : XBA
110+
ORA !sram_zebes_timer : STA !sram_zebes_timer
111+
LDA $4214 : BEQ .end
112+
XBA : ASL #4
113+
ORA !sram_zebes_timer : STA !sram_zebes_timer
114+
.end
115+
RTL
116+
53117
game_fast_doors_toggle:
54118
%cm_toggle("Fast Doors", !sram_fast_doors, #$01, #0)
55119

src/gamemode.asm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,15 @@ endif
304304
CLC : JMP skip_pause
305305

306306
.reveal_damage
307+
if !FEATURE_VANILLAHUD
308+
else
307309
LDA !sram_display_mode : CMP !IH_MODE_COUNTDAMAGE_INDEX : BEQ .unreveal_damage
308310
STA !ram_display_backup
309311
LDA !IH_MODE_COUNTDAMAGE_INDEX : STA !sram_display_mode
310312
; set ram_HUD_check to some value that cannot match the damage counter
311313
; conveniently the current value of A will work
312314
STA !ram_HUD_check
315+
endif
313316
%sfxconfirm()
314317
; CLC to continue normal gameplay after reveal damage
315318
LDA !sram_ctrl_reveal_damage

src/infohud.asm

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ org $8095FC ; hijack, end of NMI routine to update realtime frames
1515
org $809609 ; inc counter if NMI lag branch
1616
INC !REALTIME_LAG_COUNTER
1717

18+
org $809DFD
19+
hook_start_escape_timers:
20+
dw #ih_set_ceres_timer
21+
dw #ih_set_zebes_timer
22+
1823
if !FEATURE_VANILLAHUD
1924
else
2025
org $809B48 ; hijack, HUD routine (game timer by Quote58)
@@ -2103,6 +2108,30 @@ endif
21032108
JMP $9B51
21042109
}
21052110

2111+
ih_set_ceres_timer:
2112+
{
2113+
JSL $809E93
2114+
LDA !sram_ceres_timer
2115+
JSL $809E8C
2116+
LDA #$8003
2117+
STA !TIMER_STATUS
2118+
CLC
2119+
RTS
2120+
}
2121+
2122+
ih_set_zebes_timer:
2123+
{
2124+
JSL $809E93
2125+
LDA !sram_zebes_timer
2126+
JSL $809E8C
2127+
LDA #$8003
2128+
STA !TIMER_STATUS
2129+
CLC
2130+
RTS
2131+
}
2132+
2133+
if !FEATURE_VANILLAHUD
2134+
else
21062135
NumberGFXTable:
21072136
dw #$0C09, #$0C00, #$0C01, #$0C02, #$0C03, #$0C04, #$0C05, #$0C06, #$0C07, #$0C08
21082137
dw #$0C70, #$0C71, #$0C72, #$0C73, #$0C74, #$0C75, #$0C78, #$0C79, #$0C7A, #$0C7B
@@ -2144,6 +2173,7 @@ HexToNumberGFX2:
21442173
dw #$0C09, #$0C00, #$0C01, #$0C02, #$0C03, #$0C04, #$0C05, #$0C06, #$0C07, #$0C08
21452174
dw #$0C09, #$0C00, #$0C01, #$0C02, #$0C03, #$0C04, #$0C05, #$0C06, #$0C07, #$0C08
21462175
dw #$0C09, #$0C00, #$0C01, #$0C02, #$0C03, #$0C04, #$0C05, #$0C06, #$0C07, #$0C08
2176+
endif
21472177

21482178
%endfree(80)
21492179

src/init.asm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ endif
215215
STA !sram_loadstate_rando_supers
216216
STA !sram_loadstate_rando_powerbombs
217217
LDA #$0384 : STA !sram_demo_timer
218+
LDA #$0100 : STA !sram_ceres_timer
219+
LDA #$0300 : STA !sram_zebes_timer
218220

219221
LDA !SRAM_VERSION : STA !sram_initialized
220222
RTS

src/mainmenu.asm

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,61 @@ action_brb_mainmenu:
2929
; Set reasonable cycle time values
3030
LDA #$000A : STA !ram_cm_brb_set_cycle
3131
LDA #$0258 : STA !ram_cm_brb_cycle_time
32+
JMP action_mainmenu
33+
}
34+
35+
action_game_mainmenu:
36+
{
37+
; Each hexadecimal nibble represents a decimal
38+
; Convert to plain number to allow user to set it
39+
40+
; Start with most significant nibble, divide by 512, multiply by 75
41+
LDA !sram_ceres_timer : AND #$F000 : XBA : LSR
42+
%a8()
43+
STA $4202 : LDA #$4B : STA $4203
44+
%a16()
45+
PEA $0000 : PLA ; wait for CPU math
46+
LDA $4216 : STA !ram_cm_ceres_seconds
47+
LDA !sram_zebes_timer : AND #$F000 : XBA : LSR
48+
%a8()
49+
STA $4202 : LDA #$4B : STA $4203
50+
%a16()
51+
PEA $0000 : PLA ; wait for CPU math
52+
LDA $4216 : STA !ram_cm_zebes_seconds
53+
54+
; Next nibble, divide by 256, multiply by 60
55+
LDA !sram_ceres_timer : AND #$0F00 : XBA
56+
%a8()
57+
STA $4202 : LDA #$3C : STA $4203
58+
%a16()
59+
PEA $0000 : PLA ; wait for CPU math
60+
LDA $4216 : CLC : ADC !ram_cm_ceres_seconds : STA !ram_cm_ceres_seconds
61+
LDA !sram_zebes_timer : AND #$0F00 : XBA
62+
%a8()
63+
STA $4202 : LDA #$3C : STA $4203
64+
%a16()
65+
PEA $0000 : PLA ; wait for CPU math
66+
LDA $4216 : CLC : ADC !ram_cm_zebes_seconds : STA !ram_cm_zebes_seconds
67+
68+
; Next nibble, divide by 8, multiply by 5
69+
LDA !sram_ceres_timer : AND #$00F0 : LSR #3
70+
%a8()
71+
STA $4202 : LDA #$05 : STA $4203
72+
%a16()
73+
PEA $0000 : PLA ; wait for CPU math
74+
LDA $4216 : CLC : ADC !ram_cm_ceres_seconds : STA !ram_cm_ceres_seconds
75+
LDA !sram_zebes_timer : AND #$00F0 : LSR #3
76+
%a8()
77+
STA $4202 : LDA #$05 : STA $4203
78+
%a16()
79+
PEA $0000 : PLA ; wait for CPU math
80+
LDA $4216 : CLC : ADC !ram_cm_zebes_seconds : STA !ram_cm_zebes_seconds
81+
82+
; Least significant nibble
83+
LDA !sram_ceres_timer : AND #$000F
84+
ORA !ram_cm_ceres_seconds : STA !ram_cm_ceres_seconds
85+
LDA !sram_zebes_timer : AND #$000F
86+
ORA !ram_cm_zebes_seconds : STA !ram_cm_zebes_seconds
3287
BRA action_mainmenu
3388
}
3489

@@ -290,7 +345,7 @@ mm_goto_layout:
290345
%cm_jsl("Room Layout", #action_layout_mainmenu, #LayoutMenu)
291346

292347
mm_goto_gamemenu:
293-
%cm_mainmenu("Game Options", #GameMenu)
348+
%cm_jsl("Game Options", #action_game_mainmenu, #GameMenu)
294349

295350
mm_goto_rngmenu:
296351
%cm_jsl("RNG Control", #action_rng_mainmenu, #RngMenu)

src/symbols.asm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ ram_cm_dummy_on = !ram_cm_dummy_on ; !WRAM_MENU_START+$8A
320320
ram_cm_dummy_off = !ram_cm_dummy_off ; !WRAM_MENU_START+$8C
321321
ram_cm_dummy_num = !ram_cm_dummy_num ; !WRAM_MENU_START+$8E
322322

323+
ram_cm_ceres_seconds = !ram_cm_ceres_seconds ; !WRAM_MENU_START+$80
324+
ram_cm_zebes_seconds = !ram_cm_zebes_seconds ; !WRAM_MENU_START+$82
325+
323326
ram_cm_crop_mode = !ram_cm_crop_mode ; !WRAM_MENU_START+$80
324327
ram_cm_crop_tile = !ram_cm_crop_tile ; !WRAM_MENU_START+$82
325328

@@ -510,6 +513,8 @@ sram_superhud_top = !sram_superhud_top ; !SRAM_START+$98
510513
sram_infidoppler_enabled = !sram_infidoppler_enabled ; !SRAM_START+$9A
511514
sram_random_bubble_sfx = !sram_random_bubble_sfx ; !SRAM_START+$9C
512515
sram_demo_timer = !sram_demo_timer ; !SRAM_START+$9E
516+
sram_ceres_timer = !sram_ceres_timer ; !SRAM_START+$A0
517+
sram_zebes_timer = !sram_zebes_timer ; !SRAM_START+$A2
513518

514519
; ^ FREE SPACE ^ up to +$EE
515520

0 commit comments

Comments
 (0)