MSU1: Allow resuming any track

This commit is contained in:
Bonta
2021-06-12 19:09:24 +02:00
parent 34bb99b7d0
commit ce7396ae35
2 changed files with 23 additions and 5 deletions

21
msu.asm
View File

@@ -165,6 +165,21 @@ IsOverworldTrack:
SEC : RTS
;--------------------------------------------------------------------------------
;================================================================================
; Check if the track in A should be resumed
;--------------------------------------------------------------------------------
IsResumableTrack:
PHA
LDA MSUResumeType : BEQ +
PLA
JSR IsOverworldTrack
RTS
+
PLA
SEC
RTS
;--------------------------------------------------------------------------------
;================================================================================
; Extended OST/SPC fallback, decide which track to actually play
;--------------------------------------------------------------------------------
@@ -497,13 +512,13 @@ MSUInit:
MSUStopPlaying:
PHA : XBA : PHA
LDA !MSU_LOADED_TRACK
JSR IsOverworldTrack : BCC + ; dont save if this isnt an overworld track
JSR IsResumableTrack : BCC +
; dont save if we already saved recently
REP #$20
LDA !MSU_RESUME_TRACK : AND #$00FF : BEQ ++
LDA !NMI_COUNTER : !SUB !MSU_RESUME_TIME : PHA
LDA !NMI_COUNTER+2 : SBC !MSU_RESUME_TIME+2 : BNE +++
PLA : CMP MSUResumeDelay : !BLT .too_early
PLA : CMP MSUResumeTimer : !BLT .too_early
BRA ++
+++
PLA
@@ -661,7 +676,7 @@ MSUMain:
REP #$20
LDA !NMI_COUNTER : !SUB !MSU_RESUME_TIME : PHA
LDA !NMI_COUNTER+2 : SBC !MSU_RESUME_TIME+2 : BNE ++
PLA : CMP MSUResumeDelay : !BGE +++
PLA : CMP MSUResumeTimer : !BGE +++
SEP #$20 : BRA .done_resume
++
PLA

View File

@@ -993,10 +993,13 @@ org $30821B ; PC 0x18021B
FastFanfare:
db $00 ; $00 = Normal fanfare (default) $01 = Fast fanfare
org $30821C ; PC 0x18021C
MSUResumeDelay:
MSUResumeType:
db $01 ; Type of tracks to resume #$00 = Everything - #$01 = Overworld (default)
org $30821D ; PC 0x18021D
MSUResumeTimer:
dw $0708 ; Number of frames on a different track until we no longer resume (0x708 = 1800 = ~30s)
;--------------------------------------------------------------------------------
; 0x18021E - 0x18021F (unused)
; 0x18021F - 0x18021F (unused)
;================================================================================
; $308220 (0x180220) - $30823F (0x18023F)
; Plandomizer Author Name (ASCII) - Leave unused chars as 0