Cleanup time_system.asm

This commit is contained in:
scawful
2024-09-29 21:16:25 -04:00
parent 1b013499f6
commit 76d08711f0

View File

@@ -11,11 +11,12 @@ Hours = $7EE000
Minutes = $7EE001 Minutes = $7EE001
TimeSpeed = $7EE002 TimeSpeed = $7EE002
; HUD Template adjusts timer's color
org !hud_template org !hud_template
db $10, $24, $11, $24 db $10, $24, $11, $24
db $6C, $25 db $6C, $25
db $90, $24, $90, $24 db $90, $24, $90, $24
db $6C,$25,$90,$24,$90,$24 ; HUD Template(adjusts timer's color) db $6C, $25, $90, $24, $90, $24
; Sprite_Main.dont_reset_drag ; Sprite_Main.dont_reset_drag
; Executes every frame to update the clock ; Executes every frame to update the clock
@@ -105,6 +106,9 @@ DrawClockToHud:
; ========================================================= ; =========================================================
Overworld_SetFixedColAndScroll = $0BFE70
Overworld_SetFixedColAndScroll_AltEntry = $0BFE72
RunClock: RunClock:
{ {
LDA $10 ; checks current event in game LDA $10 ; checks current event in game
@@ -147,33 +151,32 @@ RunClock:
RTS RTS
.increase_minutes .increase_minutes
LDA $7EE001 : INC A : STA $7EE001 LDA.l Minutes : INC A : STA.l Minutes
CMP #$3C : BPL .increase_hours ; minutes = #60 ? CMP #$3C : BPL .increase_hours ; minutes = 60 ?
RTS RTS
.increase_hours .increase_hours
LDA #$00 : STA $7EE001 LDA #$00 : STA.l Minutes
LDA $7EE000 : INC A : STA $7EE000 LDA.l Hours : INC A : STA.l Hours
CMP #$18 : BPL .reset_hours ; hours = #24 ? CMP #$18 : BPL .reset_hours ; hours = 24 ?
;check indoors/outdoors ;check indoors/outdoors
LDA $1B : BEQ .outdoors0 LDA $1B : BEQ .outdoors0
RTS RTS
.outdoors0 .outdoors0
JSL rom_to_buff ; update buffer palette JSL RomToPaletteBuffer ; update buffer palette
JSL buff_to_eff ; update effective palette JSL PaletteBufferToEffective ; update effective palette
;rain layer ? ;rain layer ?
LDA $8C : CMP #$9F : BEQ .skip_bg_updt0 LDA $8C : CMP #$9F : BEQ .skip_bg_updt0
LDA $8C : CMP #$9E : BEQ .skip_bg_updt0 ; canopy layer ? LDA $8C : CMP #$9E : BEQ .skip_bg_updt0 ; canopy layer ?
CMP #$97 : BEQ .skip_bg_updt0 ; fog layer? CMP #$97 : BEQ .skip_bg_updt0 ; fog layer?
JSL $0BFE70 ; update background color JSL Overworld_SetFixedColAndScroll ; update background color
BRA .inc_hours_end BRA .inc_hours_end
.skip_bg_updt0 ; prevent the sub layer from disappearing ($1D zeroed) .skip_bg_updt0 ; prevent the sub layer from disappearing ($1D zeroed)
JSL $0BFE72 JSL Overworld_SetFixedColAndScroll_AltEntry
.inc_hours_end .inc_hours_end
RTS RTS
@@ -186,18 +189,16 @@ RunClock:
RTS RTS
.outdoors1 .outdoors1
JSL rom_to_buff JSL RomToPaletteBuffer
JSL buff_to_eff JSL PaletteBufferToEffective
LDA $8C : CMP #$9F : BEQ .skip_bg_updt1 ; rain layer ? LDA $8C : CMP #$9F : BEQ .skip_bg_updt1 ; rain layer ?
LDA $8C : CMP #$9E : BEQ .skip_bg_updt1 ; canopy layer ? LDA $8C : CMP #$9E : BEQ .skip_bg_updt1 ; canopy layer ?
JSL $0BFE70 ; update background color JSL Overworld_SetFixedColAndScroll ; update background color
BRA .reset_end BRA .reset_end
.skip_bg_updt1 ; prevent the sub layer from disappearing ($1D zeroed) .skip_bg_updt1 ; prevent the sub layer from disappearing ($1D zeroed)
JSL Overworld_SetFixedColAndScroll_AltEntry
JSL $0BFE72
.reset_end .reset_end
RTS RTS
} }
@@ -205,17 +206,17 @@ RunClock:
CheckForSongOfTime: CheckForSongOfTime:
{ {
LDA $FE : CMP.b #$02 : BNE + LDA $FE : CMP.b #$02 : BNE +
LDA.b #$00 : STA.l $7EE002 LDA.b #$00 : STA.l TimeSpeed
LDA.l $7EE000 : CMP.b #$06 : BNE ++ LDA.l Hours : CMP.b #$06 : BNE ++
LDA.l $7EE001 : BNE ++ LDA.l Minutes : BNE ++
LDA.b #$3F : STA.l $7EE002 LDA.b #$3F : STA.l TimeSpeed
STZ $FE STZ $FE
++ ++
LDA.l $7EE000 : CMP.b #$12 : BNE ++ LDA.l Hours : CMP.b #$12 : BNE ++
LDA.l $7EE001 : BNE ++ LDA.l Minutes : BNE ++
LDA.b #$3F : STA.l $7EE002 LDA.b #$3F : STA.l TimeSpeed
STZ $FE STZ $FE
++ ++
+ +
@@ -235,12 +236,14 @@ pushpc
!temp_value = $7EE016 !temp_value = $7EE016
!pal_color = $7EE018 !pal_color = $7EE018
Overworld_CopyPalettesToCache = $02C769
org $02FF80 ; free space on bank $02 org $02FF80 ; free space on bank $02
buff_to_eff: PaletteBufferToEffective:
JSR $C769 ; $02:C65F -> palette buffer to effective routine JSR $C769 ; $02:C65F -> palette buffer to effective routine
RTL RTL
rom_to_buff: RomToPaletteBuffer:
JSR $AAF4 ; $02:AAF4 -> change buffer palette of trees,houses,rivers,etc. JSR $AAF4 ; $02:AAF4 -> change buffer palette of trees,houses,rivers,etc.
JSR $C692 ; $02:C692 -> rom to palette buffer for other colors JSR $C692 ; $02:C692 -> rom to palette buffer for other colors
RTL RTL
@@ -439,9 +442,9 @@ GlovesFix:
CheckIfNight: CheckIfNight:
{ {
JSR LoadPeacetimeSprites : BCS + ;JSR LoadPeacetimeSprites : BCS +
RTL ; RTL
+ ;+
LDA.l $7EF3C5 : CMP.b #$02 : BCC .day_time LDA.l $7EF3C5 : CMP.b #$02 : BCC .day_time
LDA $7EE000 : CMP.b #$12 : BCS .night_time LDA $7EE000 : CMP.b #$12 : BCS .night_time
LDA $7EE000 : CMP.b #$06 : BCC .night_time LDA $7EE000 : CMP.b #$06 : BCC .night_time
@@ -475,9 +478,9 @@ ColorBgFix:
CheckIfNight16Bit: CheckIfNight16Bit:
{ {
JSR LoadPeacetimeSprites : BCS + ;JSR LoadPeacetimeSprites : BCS +
RTL ; RTL
+ ;+
; Don't change the spriteset during the intro sequence ; Don't change the spriteset during the intro sequence
LDA.l $7EF3C5 : AND.w #$00FF : CMP.w #$0002 : BCC .day_time LDA.l $7EF3C5 : AND.w #$00FF : CMP.w #$0002 : BCC .day_time
; 0x12 = 18 hours or 6 pm ; 0x12 = 18 hours or 6 pm
@@ -551,7 +554,6 @@ FixDungeonMapColors:
RestoreTimeForDungeonMap: RestoreTimeForDungeonMap:
{ {
; Restore the time
LDA $7EF900 : STA $7EE000 LDA $7EF900 : STA $7EE000
LDA $7EF901 : STA $7EE001 LDA $7EF901 : STA $7EE001
LDA.l $7EC017 LDA.l $7EC017