Day and Night cycle based on JaSP
This commit is contained in:
@@ -1,148 +1,155 @@
|
|||||||
;----------------[ Time system ]----------------
|
;----------------[ Time system ]----------------
|
||||||
|
;@xkas
|
||||||
|
lorom
|
||||||
|
|
||||||
; tiles locations on HUD (status bar)
|
; tiles locations on HUD
|
||||||
!hud_min_low = $7EC79E
|
!hud_min_low = $7EC798
|
||||||
!hud_min_high = $7EC79C
|
!hud_min_high = $7EC796
|
||||||
!hud_hours_low = $7EC798
|
!hud_hours_low = $7EC792
|
||||||
!hud_hours_high = $7EC796
|
!hud_hours_high = $7EC790
|
||||||
!hud_template = $0DFF07
|
!hud_template = $0DFF07
|
||||||
|
|
||||||
org !hud_template
|
org !hud_template
|
||||||
db $10,$24,$11,$24,$12,$24,$90,$24,$90,$24,$13,$24,$90,$24,$90,$24 ; HUD Template(adjusts timer's color)
|
db $10,$24,$11,$24
|
||||||
|
db $6C,$25
|
||||||
|
db $90,$24,$90,$24
|
||||||
|
db $6C,$25,$90,$24,$90,$24 ; HUD Template(adjusts timer's color)
|
||||||
|
|
||||||
org $068361
|
org $068361
|
||||||
jsl $1CFF30
|
JSL $1CFF30
|
||||||
;originally JSL $09B06E, executed every frame
|
;originally JSL $09B06E, executed every frame
|
||||||
|
|
||||||
org $1CFF30
|
org $1CFF30
|
||||||
jsr counter_preroutine
|
JSR counter_preroutine
|
||||||
ldx #$00
|
LDX #$00
|
||||||
debut:
|
debut:
|
||||||
ldy #$00
|
LDY #$00
|
||||||
lda $7EE000,x
|
LDA $7EE000,x
|
||||||
|
|
||||||
debut2:
|
debut2:
|
||||||
cmp #$0A
|
CMP #$0A
|
||||||
bmi draw
|
BMI draw
|
||||||
sbc #$0A
|
SBC #$0A
|
||||||
iny
|
INY
|
||||||
bra debut2
|
BRA debut2
|
||||||
|
|
||||||
draw:
|
draw:
|
||||||
adc #$90
|
adc #$90
|
||||||
cpx #$01
|
CPX #$01
|
||||||
beq minutes_low
|
BEQ minutes_low
|
||||||
sta !hud_hours_low
|
STA !hud_hours_low
|
||||||
bra 04
|
BRA 04
|
||||||
|
|
||||||
minutes_low:
|
minutes_low:
|
||||||
sta !hud_min_low
|
STA !hud_min_low
|
||||||
tya
|
tya
|
||||||
clc
|
clc
|
||||||
adc #$90
|
adc #$90
|
||||||
cpx #$01
|
CPX #$01
|
||||||
beq minutes_high
|
BEQ minutes_high
|
||||||
sta !hud_hours_high
|
STA !hud_hours_high
|
||||||
bra 04
|
BRA 04
|
||||||
|
|
||||||
minutes_high:
|
minutes_high:
|
||||||
sta !hud_min_high
|
STA !hud_min_high
|
||||||
inx
|
INX
|
||||||
cpx #$02
|
CPX #$02
|
||||||
bmi debut
|
BMI debut
|
||||||
jsl $09B06E
|
JSL $09B06E
|
||||||
rtl
|
rtl
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
|
|
||||||
counter_preroutine:
|
counter_preroutine:
|
||||||
lda $10 ;checks current event in game
|
LDA $10 ;checks current event in game
|
||||||
cmp #$07 ;dungeon/building?
|
CMP #$07 ;dungeon/building?
|
||||||
beq counter_increasing
|
BEQ counter_increasing
|
||||||
cmp #$09 ;overworld?
|
CMP #$09 ;overworld?
|
||||||
beq overworld
|
BEQ overworld
|
||||||
cmp #$0B
|
CMP #$0B
|
||||||
beq overworld ;sub-area ? (under the bridge; zora domain...)
|
BEQ overworld ;sub-area ? (under the bridge; zora domain...)
|
||||||
cmp #$0E ;dialog box?
|
CMP #$0E ;dialog box?
|
||||||
beq dialog
|
BEQ dialog
|
||||||
rts
|
RTS
|
||||||
|
|
||||||
overworld:
|
overworld:
|
||||||
lda $11
|
LDA $11
|
||||||
cmp #$23 ;hdma transfer? (warping)
|
CMP #$23 ;hdma transfer? (warping)
|
||||||
bne mosaic
|
bne mosaic
|
||||||
mosaic:
|
mosaic:
|
||||||
cmp #$0D ;mosaic ?
|
CMP #$0D ;mosaic ?
|
||||||
bmi counter_increasing
|
BMI counter_increasing
|
||||||
rts
|
rts
|
||||||
|
|
||||||
dialog:
|
dialog:
|
||||||
lda $11 ;which kind of dialog? (to prevent the counter from increasing if save menu or item menu openned)
|
LDA $11 ;which kind of dialog? (to prevent the counter from increasing if save menu or item menu openned)
|
||||||
cmp #$02 ;NPC/signs speech
|
CMP #$02 ;NPC/signs speech
|
||||||
beq counter_increasing
|
BEQ counter_increasing
|
||||||
rts
|
rts
|
||||||
|
|
||||||
counter_increasing:
|
counter_increasing:
|
||||||
lda $1A
|
; time speed (1,3,5,7,F,1F,3F,7F,FF)
|
||||||
and #$1F ;change value (1,3,5,7,F,1F,3F,7F,FF) to have different time speed, #$3F is almost 1 sec = 1 game minute
|
; #$3F is almost 1 sec = 1 game minute
|
||||||
beq increase_minutes
|
LDA $1A : AND #$05
|
||||||
|
BEQ increase_minutes
|
||||||
end:
|
end:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
increase_minutes:
|
increase_minutes:
|
||||||
lda $7EE001
|
LDA $7EE001
|
||||||
inc a
|
INC A
|
||||||
sta $7EE001
|
STA $7EE001
|
||||||
cmp #$3C ; minutes = #60 ?
|
CMP #$3C ; minutes = #60 ?
|
||||||
bpl increase_hours
|
BPL increase_hours
|
||||||
rts
|
RTS
|
||||||
|
|
||||||
increase_hours:
|
increase_hours:
|
||||||
lda #$00
|
LDA #$00
|
||||||
sta $7EE001
|
STA $7EE001
|
||||||
lda $7EE000
|
LDA $7EE000
|
||||||
inc a
|
INC A
|
||||||
sta $7EE000
|
STA $7EE000
|
||||||
cmp #$18 ; hours = #24 ?
|
CMP #$18 ; hours = #24 ?
|
||||||
bpl reset_hours
|
BPL reset_hours
|
||||||
|
|
||||||
|
LDA $1B ;check indoors/outdoors
|
||||||
|
BEQ outdoors0
|
||||||
|
RTS
|
||||||
|
|
||||||
lda $1B ;check indoors/outdoors
|
|
||||||
beq outdoors0
|
|
||||||
rts
|
|
||||||
outdoors0:
|
outdoors0:
|
||||||
jsl rom_to_buff ;update buffer palette
|
JSL rom_to_buff ;update buffer palette
|
||||||
jsl buff_to_eff ;update effective palette
|
JSL buff_to_eff ;update effective palette
|
||||||
lda $8C
|
LDA $8C
|
||||||
cmp #$9F ;rain layer ?
|
CMP #$9F ;rain layer ?
|
||||||
beq skip_bg_updt0
|
BEQ skip_bg_updt0
|
||||||
jsl $0BFE70 ;update background color
|
JSL $0BFE70 ;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 $0BFE72
|
||||||
inc_hours_end:
|
inc_hours_end:
|
||||||
rts
|
RTS
|
||||||
|
|
||||||
reset_hours:
|
reset_hours:
|
||||||
lda #$00
|
LDA #$00
|
||||||
sta $7EE000
|
STA $7EE000
|
||||||
|
|
||||||
lda $1B ;check indoors/outdoors
|
LDA $1B ;check indoors/outdoors
|
||||||
beq outdoors1
|
BEQ outdoors1
|
||||||
rts
|
RTS
|
||||||
outdoors1:
|
outdoors1:
|
||||||
jsl rom_to_buff
|
JSL rom_to_buff
|
||||||
jsl buff_to_eff
|
JSL buff_to_eff
|
||||||
lda $8C
|
LDA $8C
|
||||||
cmp #$9F ;rain layer ?
|
CMP #$9F ;rain layer ?
|
||||||
beq skip_bg_updt1
|
BEQ skip_bg_updt1
|
||||||
jsl $0BFE70 ;update background color
|
JSL $0BFE70 ;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 $0BFE72
|
JSL $0BFE72
|
||||||
reset_end:
|
reset_end:
|
||||||
rts
|
RTS
|
||||||
|
|
||||||
;-----------------------------------------------
|
;-----------------------------------------------
|
||||||
;----[ Day / Night system * palette effect ]----
|
;----[ Day / Night system * palette effect ]----
|
||||||
@@ -154,17 +161,16 @@ reset_end:
|
|||||||
|
|
||||||
!temp_value = $7EE016
|
!temp_value = $7EE016
|
||||||
!pal_color = $7EE018
|
!pal_color = $7EE018
|
||||||
!x_reg = $08
|
|
||||||
|
|
||||||
org $02FF70 ; free space on bank $02
|
|
||||||
|
|
||||||
|
org $02FF80 ; free space on bank $02
|
||||||
buff_to_eff:
|
buff_to_eff:
|
||||||
jsr $C769 ; $02:C65F -> palette buffer to effective routine
|
JSR $C769 ; $02:C65F -> palette buffer to effective routine
|
||||||
rtl
|
RTL
|
||||||
|
|
||||||
rom_to_buff:
|
rom_to_buff:
|
||||||
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
|
||||||
|
|
||||||
; part of rom pal to buffer routine
|
; part of rom pal to buffer routine
|
||||||
;$1B/EF61 9F 00 C3 7E STA $7EC300,x[$7E:C422]
|
;$1B/EF61 9F 00 C3 7E STA $7EC300,x[$7E:C422]
|
||||||
@@ -172,55 +178,56 @@ rom_to_buff:
|
|||||||
;$1B/EF84 9F 00 C3 7E STA $7EC300,x[$7E:C4B2]
|
;$1B/EF84 9F 00 C3 7E STA $7EC300,x[$7E:C4B2]
|
||||||
|
|
||||||
org $1BEF3D
|
org $1BEF3D
|
||||||
jsl new_palette_load
|
JSL LoadDayNightPaletteEffect
|
||||||
|
|
||||||
org $1BEF61
|
org $1BEF61
|
||||||
jsl new_palette_load
|
JSL LoadDayNightPaletteEffect
|
||||||
|
|
||||||
org $1BEF84
|
org $1BEF84
|
||||||
jsl new_palette_load
|
JSL LoadDayNightPaletteEffect
|
||||||
|
|
||||||
org $1EEE25 ; free space
|
org $0EEE25 ; free space
|
||||||
|
LoadDayNightPaletteEffect:
|
||||||
|
{
|
||||||
|
STA !pal_color
|
||||||
|
|
||||||
new_palette_load:
|
CPX #$0041
|
||||||
|
BPL title_check
|
||||||
|
STA $7EC300,X
|
||||||
|
RTL
|
||||||
|
|
||||||
sta !pal_color
|
|
||||||
|
|
||||||
cpx #$0041
|
|
||||||
bpl title_check
|
|
||||||
sta $7EC300,x
|
|
||||||
rtl
|
|
||||||
title_check:
|
title_check:
|
||||||
lda $10
|
LDA $10
|
||||||
and #$00FF
|
AND #$00FF
|
||||||
cmp #$0002 ; title or file select screen ?
|
CMP #$0002 ; title or file select screen ?
|
||||||
bpl outin_check
|
BPL outin_check
|
||||||
lda !pal_color
|
LDA !pal_color
|
||||||
sta $7EC300,x
|
STA $7EC300,X
|
||||||
rtl
|
RTL
|
||||||
|
|
||||||
outin_check:
|
outin_check:
|
||||||
lda $1B
|
LDA $1B : AND #$00FF : BEQ outdoors2
|
||||||
and #$00FF
|
LDA !pal_color
|
||||||
beq outdoors2
|
STA $7EC300,X
|
||||||
lda !pal_color
|
RTL
|
||||||
sta $7EC300,x
|
|
||||||
rtl
|
|
||||||
|
|
||||||
outdoors2:
|
outdoors2:
|
||||||
phx
|
PHX
|
||||||
jsl color_sub_effect
|
JSL ColorSubEffect
|
||||||
plx
|
PLX
|
||||||
sta $7EC300,x
|
STA $7EC300,X
|
||||||
rtl
|
RTL
|
||||||
|
}
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
|
|
||||||
color_sub_effect:
|
ColorSubEffect:
|
||||||
lda $7EE000 ; lda #hours
|
{
|
||||||
and #$00FF
|
LDA $7EE000 ; LDA #hours
|
||||||
clc
|
AND #$00FF
|
||||||
adc $7EE000 ; #hours * 2
|
CLC
|
||||||
and #$00FF
|
ADC $7EE000 ; #hours * 2
|
||||||
tax
|
AND #$00FF
|
||||||
|
TAX
|
||||||
|
|
||||||
do_blue:
|
do_blue:
|
||||||
LDA !pal_color
|
LDA !pal_color
|
||||||
@@ -232,8 +239,10 @@ do_blue:
|
|||||||
AND #$7C00 ; mask out everything except the blue bits
|
AND #$7C00 ; mask out everything except the blue bits
|
||||||
CMP !temp_value ; overflow ?
|
CMP !temp_value ; overflow ?
|
||||||
BEQ no_blue_sign_change
|
BEQ no_blue_sign_change
|
||||||
|
|
||||||
blue_sign_change:
|
blue_sign_change:
|
||||||
LDA #$0400 ; lda smallest blue value
|
LDA #$0400 ; LDA smallest blue value
|
||||||
|
|
||||||
no_blue_sign_change:
|
no_blue_sign_change:
|
||||||
STA !blue_value
|
STA !blue_value
|
||||||
|
|
||||||
@@ -247,8 +256,9 @@ do_green:
|
|||||||
AND #$03E0 ; mask out everything except the green bits
|
AND #$03E0 ; mask out everything except the green bits
|
||||||
CMP !temp_value ; overflow ?
|
CMP !temp_value ; overflow ?
|
||||||
BEQ no_green_sign_change
|
BEQ no_green_sign_change
|
||||||
|
|
||||||
green_sign_change:
|
green_sign_change:
|
||||||
LDA #$0020 ; lda smallest green value
|
LDA #$0020 ; LDA smallest green value
|
||||||
no_green_sign_change:
|
no_green_sign_change:
|
||||||
STA !green_value
|
STA !green_value
|
||||||
|
|
||||||
@@ -262,8 +272,10 @@ do_red:
|
|||||||
AND #$001F ; mask out everything except the red bits
|
AND #$001F ; mask out everything except the red bits
|
||||||
CMP !temp_value ; overflow ?
|
CMP !temp_value ; overflow ?
|
||||||
BEQ no_red_sign_change
|
BEQ no_red_sign_change
|
||||||
|
|
||||||
red_sign_change:
|
red_sign_change:
|
||||||
LDA #$0001 ; lda smallest red value
|
LDA #$0001 ; LDA smallest red value
|
||||||
|
|
||||||
no_red_sign_change:
|
no_red_sign_change:
|
||||||
STA !red_value
|
STA !red_value
|
||||||
|
|
||||||
@@ -271,8 +283,8 @@ no_red_sign_change:
|
|||||||
ORA !green_value
|
ORA !green_value
|
||||||
ORA !red_value
|
ORA !red_value
|
||||||
|
|
||||||
rtl
|
RTL
|
||||||
|
}
|
||||||
|
|
||||||
; color_sub_tables : 24 * 2 bytes each = 48 bytes (2 bytes = 1 color sub for each hour)
|
; color_sub_tables : 24 * 2 bytes each = 48 bytes (2 bytes = 1 color sub for each hour)
|
||||||
|
|
||||||
@@ -300,41 +312,49 @@ red_table:
|
|||||||
dw $0000, $0000, $0000, $0002
|
dw $0000, $0000, $0000, $0002
|
||||||
dw $0004, $0006, $0008, $0008
|
dw $0004, $0006, $0008, $0008
|
||||||
|
|
||||||
background_fix:
|
BackgroundFix:
|
||||||
beq no_effect ;branch if A=#$0000 (transparent bg)
|
{
|
||||||
jsl color_sub_effect
|
BEQ .no_effect ;BRAnch if A=#$0000 (transparent bg)
|
||||||
|
JSL ColorSubEffect
|
||||||
|
|
||||||
no_effect:
|
.no_effect:
|
||||||
sta $7EC500
|
STA $7EC500
|
||||||
sta $7EC300
|
STA $7EC300
|
||||||
sta $7EC540
|
STA $7EC540
|
||||||
sta $7EC340
|
STA $7EC340
|
||||||
rtl
|
rtl
|
||||||
|
}
|
||||||
|
|
||||||
subareas_fix:
|
SubAreasFix:
|
||||||
sta !pal_color
|
{
|
||||||
phx
|
STA !pal_color
|
||||||
jsl color_sub_effect
|
PHX
|
||||||
plx
|
JSL ColorSubEffect
|
||||||
|
PLX
|
||||||
STA $7EC300
|
STA $7EC300
|
||||||
STA $7EC340
|
STA $7EC340
|
||||||
rtl
|
rtl
|
||||||
|
}
|
||||||
|
|
||||||
gloves_fix:
|
|
||||||
sta !pal_color
|
|
||||||
lda $1B
|
|
||||||
and #$00FF
|
|
||||||
beq outdoors3
|
|
||||||
lda !pal_color
|
|
||||||
STA $7EC4FA
|
|
||||||
rtl
|
|
||||||
|
|
||||||
outdoors3:
|
GlovesFix:
|
||||||
phx
|
{
|
||||||
jsl color_sub_effect
|
STA !pal_color
|
||||||
plx
|
LDA $1B
|
||||||
|
AND #$00FF
|
||||||
|
BEQ .outdoors3
|
||||||
|
LDA !pal_color
|
||||||
STA $7EC4FA
|
STA $7EC4FA
|
||||||
rtl
|
RTL
|
||||||
|
|
||||||
|
.outdoors3:
|
||||||
|
PHX
|
||||||
|
JSL ColorSubEffect
|
||||||
|
PLX
|
||||||
|
STA $7EC4FA
|
||||||
|
RTL
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
; $0BFE70 -> background color loading routine
|
; $0BFE70 -> background color loading routine
|
||||||
;Background color write fix - 16 bytes
|
;Background color write fix - 16 bytes
|
||||||
@@ -344,8 +364,8 @@ outdoors3:
|
|||||||
;$0B/FEC2 8F 40 C3 7E STA $7EC340
|
;$0B/FEC2 8F 40 C3 7E STA $7EC340
|
||||||
|
|
||||||
org $0BFEB6
|
org $0BFEB6
|
||||||
sta !pal_color
|
STA !pal_color
|
||||||
jsl background_fix
|
JSL BackgroundFix
|
||||||
nop #8
|
nop #8
|
||||||
|
|
||||||
; Subareas background color fix (under the bridge; zora...)
|
; Subareas background color fix (under the bridge; zora...)
|
||||||
@@ -353,7 +373,7 @@ org $0BFEB6
|
|||||||
;$0E/D605 8F 40 C3 7E STA $7EC340[$7E:C340]
|
;$0E/D605 8F 40 C3 7E STA $7EC340[$7E:C340]
|
||||||
|
|
||||||
org $0ED601
|
org $0ED601
|
||||||
jsl subareas_fix
|
JSL SubAreasFix
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
|
|
||||||
@@ -373,20 +393,4 @@ org $0ED601
|
|||||||
;$1B/EE39 6B RTL
|
;$1B/EE39 6B RTL
|
||||||
|
|
||||||
org $1BEE2D
|
org $1BEE2D
|
||||||
jsl gloves_fix
|
JSL GlovesFix
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user