2018-06-24 07:09:41 -07:00
|
|
|
DummyPredef35:
|
2018-01-02 06:05:14 -08:00
|
|
|
DummyPredef36:
|
2017-12-15 17:10:54 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
UpdateTimeOfDayPal::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTimeOfDay]
|
|
|
|
ld [wCurTimeOfDay], a
|
2015-10-24 07:34:19 -07:00
|
|
|
call GetTimePalette
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTimeOfDayPal], a
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_TimeOfDayPals::
|
2015-10-24 07:34:19 -07:00
|
|
|
; return carry if pals are changed
|
|
|
|
|
|
|
|
; forced pals?
|
2015-12-14 08:12:18 -08:00
|
|
|
ld hl, wTimeOfDayPalFlags
|
2015-10-24 07:34:19 -07:00
|
|
|
bit 7, [hl]
|
|
|
|
jr nz, .dontchange
|
|
|
|
|
|
|
|
; do we need to bother updating?
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTimeOfDay]
|
|
|
|
ld hl, wCurTimeOfDay
|
2015-10-24 07:34:19 -07:00
|
|
|
cp [hl]
|
|
|
|
jr z, .dontchange
|
|
|
|
|
|
|
|
; if so, the time of day has changed
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTimeOfDay]
|
|
|
|
ld [wCurTimeOfDay], a
|
2015-10-24 07:34:19 -07:00
|
|
|
|
|
|
|
; get palette id
|
|
|
|
call GetTimePalette
|
|
|
|
|
|
|
|
; same palette as before?
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wTimeOfDayPal
|
2015-10-24 07:34:19 -07:00
|
|
|
cp [hl]
|
|
|
|
jr z, .dontchange
|
|
|
|
|
|
|
|
; update palette id
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTimeOfDayPal], a
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2017-12-26 17:33:41 -08:00
|
|
|
; save bg palette 7
|
2018-01-01 06:08:21 -08:00
|
|
|
ld hl, wBGPals1 palette PAL_BG_TEXT
|
2015-10-24 07:34:19 -07:00
|
|
|
|
|
|
|
; save wram bank
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rSVBK]
|
2015-10-24 07:34:19 -07:00
|
|
|
ld b, a
|
2018-01-18 18:48:52 -08:00
|
|
|
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, BANK(wBGPals1)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2015-10-24 07:34:19 -07:00
|
|
|
|
|
|
|
; push palette
|
2017-12-26 17:33:41 -08:00
|
|
|
ld c, NUM_PAL_COLORS
|
2015-10-24 07:34:19 -07:00
|
|
|
.push
|
|
|
|
ld d, [hl]
|
|
|
|
inc hl
|
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
push de
|
|
|
|
dec c
|
|
|
|
jr nz, .push
|
|
|
|
|
|
|
|
; restore wram bank
|
|
|
|
ld a, b
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2023-07-27 11:32:15 -07:00
|
|
|
; update cgb pals
|
2023-07-26 08:01:20 -07:00
|
|
|
ld b, CGB_MAPPALS
|
|
|
|
call GetCGBLayout
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2017-12-26 17:33:41 -08:00
|
|
|
; restore bg palette 7
|
2018-01-01 06:08:21 -08:00
|
|
|
ld hl, wOBPals1 - 1 ; last byte in wBGPals1
|
2015-10-24 07:34:19 -07:00
|
|
|
|
|
|
|
; save wram bank
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rSVBK]
|
2015-10-24 07:34:19 -07:00
|
|
|
ld d, a
|
2018-01-18 18:48:52 -08:00
|
|
|
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, BANK(wOBPals1)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2015-10-24 07:34:19 -07:00
|
|
|
|
|
|
|
; pop palette
|
2017-12-26 17:33:41 -08:00
|
|
|
ld e, NUM_PAL_COLORS
|
2015-10-24 07:34:19 -07:00
|
|
|
.pop
|
|
|
|
pop bc
|
|
|
|
ld [hl], c
|
|
|
|
dec hl
|
|
|
|
ld [hl], b
|
|
|
|
dec hl
|
|
|
|
dec e
|
|
|
|
jr nz, .pop
|
|
|
|
|
|
|
|
; restore wram bank
|
|
|
|
ld a, d
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2015-10-24 07:34:19 -07:00
|
|
|
|
|
|
|
; update palettes
|
2018-01-02 09:49:25 -08:00
|
|
|
call _UpdateTimePals
|
2015-10-24 07:34:19 -07:00
|
|
|
call DelayFrame
|
|
|
|
|
|
|
|
; successful change
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.dontchange
|
|
|
|
; no change occurred
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_UpdateTimePals::
|
2015-10-24 07:34:19 -07:00
|
|
|
ld c, $9 ; normal
|
|
|
|
call GetTimePalFade
|
|
|
|
call DmgToCgbTimePals
|
|
|
|
ret
|
|
|
|
|
2024-02-10 15:16:00 -08:00
|
|
|
FadeInFromWhite::
|
2023-08-04 14:54:53 -07:00
|
|
|
; fades from white to normal palettes in four steps
|
|
|
|
; all palettes use white color of Pal0 before step 3
|
|
|
|
call BackupWhiteColorFromBGPals1
|
|
|
|
call FillWhiteBGColor
|
2015-10-24 07:34:19 -07:00
|
|
|
ld c, $12
|
|
|
|
call GetTimePalFade
|
2023-08-04 14:54:53 -07:00
|
|
|
ld b, $2
|
|
|
|
call ConvertTimePalsDecHL
|
|
|
|
call RestoreWhiteColorToBGPals1
|
|
|
|
ld c, $c
|
|
|
|
call GetTimePalFade
|
|
|
|
ld b, $2
|
2015-10-24 07:34:19 -07:00
|
|
|
call ConvertTimePalsDecHL
|
|
|
|
ret
|
|
|
|
|
2024-02-10 15:16:00 -08:00
|
|
|
FadeOutToWhite::
|
2023-08-04 14:54:53 -07:00
|
|
|
; fades from normal palettes to white in four steps
|
|
|
|
; all palettes use white color of Pal0 after step 2
|
2015-10-24 07:34:19 -07:00
|
|
|
ld c, $9
|
|
|
|
call GetTimePalFade
|
2023-08-04 14:54:53 -07:00
|
|
|
ld b, $2
|
2015-10-24 07:34:19 -07:00
|
|
|
call ConvertTimePalsIncHL
|
2015-12-14 17:06:41 -08:00
|
|
|
call FillWhiteBGColor
|
2023-08-04 14:54:53 -07:00
|
|
|
ld c, $f
|
2015-10-24 07:34:19 -07:00
|
|
|
call GetTimePalFade
|
2023-08-04 14:54:53 -07:00
|
|
|
ld b, $2
|
|
|
|
call ConvertTimePalsIncHL
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2024-02-10 15:16:00 -08:00
|
|
|
FadeInFromBlack:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld c, $0
|
|
|
|
call GetTimePalFade
|
|
|
|
ld b, $4
|
|
|
|
call ConvertTimePalsIncHL
|
|
|
|
ret
|
|
|
|
|
2024-02-10 15:16:00 -08:00
|
|
|
FadeOutToBlack:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld c, $9
|
|
|
|
call GetTimePalFade
|
|
|
|
ld b, $4
|
|
|
|
call ConvertTimePalsDecHL
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
FillWhiteBGColor:
|
2023-08-04 14:54:53 -07:00
|
|
|
; copy white palette of wBGPals1 Pal0 into white palette of wBGPals1 Pal1-Pal6
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rSVBK]
|
2015-10-24 07:34:19 -07:00
|
|
|
push af
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, BANK(wBGPals1)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2015-12-14 17:06:41 -08:00
|
|
|
|
2018-01-01 06:08:21 -08:00
|
|
|
ld hl, wBGPals1
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld e, a
|
|
|
|
ld a, [hli]
|
|
|
|
ld d, a
|
2018-01-01 06:08:21 -08:00
|
|
|
ld hl, wBGPals1 + 1 palettes
|
2015-12-14 17:06:41 -08:00
|
|
|
ld c, 6
|
|
|
|
.loop
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, e
|
|
|
|
ld [hli], a
|
|
|
|
ld a, d
|
|
|
|
ld [hli], a
|
|
|
|
rept 6
|
|
|
|
inc hl
|
|
|
|
endr
|
|
|
|
dec c
|
2015-12-14 17:06:41 -08:00
|
|
|
jr nz, .loop
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2023-08-04 14:54:53 -07:00
|
|
|
BackupWhiteColorFromBGPals1:
|
|
|
|
ldh a, [rSVBK]
|
|
|
|
push af
|
|
|
|
ld a, BANK(wBGPals1)
|
|
|
|
ldh [rSVBK], a
|
|
|
|
|
|
|
|
ld hl, wBGPals1
|
|
|
|
ld de, wBGPalsRegularWhiteColors
|
|
|
|
ld c, 8
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
rept PALETTE_SIZE - 1 * PAL_COLOR_SIZE
|
|
|
|
inc hl
|
|
|
|
endr
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
pop af
|
|
|
|
ldh [rSVBK], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
RestoreWhiteColorToBGPals1:
|
|
|
|
ldh a, [rSVBK]
|
|
|
|
push af
|
|
|
|
ld a, BANK(wBGPals1)
|
|
|
|
ldh [rSVBK], a
|
|
|
|
|
|
|
|
ld hl, wBGPalsRegularWhiteColors
|
|
|
|
ld de, wBGPals1
|
|
|
|
ld c, 8
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
rept PALETTE_SIZE - 1 * PAL_COLOR_SIZE
|
|
|
|
inc de
|
|
|
|
endr
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
pop af
|
|
|
|
ldh [rSVBK], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ReplaceTimeOfDayPals:
|
2023-07-31 03:27:53 -07:00
|
|
|
ld a, [wMapTimeOfDay]
|
|
|
|
bit IN_DARKNESS_F, a
|
|
|
|
jr z, .not_dark
|
|
|
|
ld a, [wStatusFlags]
|
|
|
|
bit STATUSFLAGS_FLASH_F, a
|
|
|
|
jr nz, .not_dark
|
|
|
|
ld a, DARKNESS_PALSET
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.not_dark:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld hl, .BrightnessLevels
|
2015-12-14 17:06:41 -08:00
|
|
|
ld a, [wMapTimeOfDay]
|
2020-08-11 11:12:59 -07:00
|
|
|
maskbits NUM_MAP_PALETTES
|
2015-10-24 07:34:19 -07:00
|
|
|
add l
|
|
|
|
ld l, a
|
2020-06-17 08:29:00 -07:00
|
|
|
ld a, 0
|
2015-10-24 07:34:19 -07:00
|
|
|
adc h
|
|
|
|
ld h, a
|
|
|
|
ld a, [hl]
|
2023-07-31 03:27:53 -07:00
|
|
|
.done
|
2015-12-14 08:12:18 -08:00
|
|
|
ld [wTimeOfDayPalset], a
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.BrightnessLevels:
|
2020-08-11 11:12:59 -07:00
|
|
|
; actual palettes used when time is
|
2023-07-31 03:27:53 -07:00
|
|
|
; EVE_F, NITE_F, DAY_F, MORN_F
|
|
|
|
dc EVE_F, NITE_F, DAY_F, MORN_F ; PALETTE_AUTO
|
2020-08-11 11:12:59 -07:00
|
|
|
dc DAY_F, DAY_F, DAY_F, DAY_F ; PALETTE_DAY
|
|
|
|
dc NITE_F, NITE_F, NITE_F, NITE_F ; PALETTE_NITE
|
|
|
|
dc MORN_F, MORN_F, MORN_F, MORN_F ; PALETTE_MORN
|
2023-07-31 03:27:53 -07:00
|
|
|
dc EVE_F, EVE_F, EVE_F, EVE_F ; PALETTE_EVE
|
|
|
|
dc EVE_F, NITE_F, DAY_F, MORN_F
|
|
|
|
dc EVE_F, NITE_F, DAY_F, MORN_F
|
|
|
|
dc EVE_F, NITE_F, DAY_F, MORN_F
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetTimePalette:
|
2020-07-01 10:13:49 -07:00
|
|
|
jumptable .TimePalettes, wTimeOfDay
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.TimePalettes:
|
2020-08-11 11:12:59 -07:00
|
|
|
dw .MorningPalette ; MORN_F
|
|
|
|
dw .DayPalette ; DAY_F
|
|
|
|
dw .NitePalette ; NITE_F
|
2023-07-31 03:27:53 -07:00
|
|
|
dw .EveningPalette ; EVE_F
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MorningPalette:
|
2015-12-14 08:12:18 -08:00
|
|
|
ld a, [wTimeOfDayPalset]
|
2020-08-11 11:12:59 -07:00
|
|
|
and %00000011
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DayPalette:
|
2015-12-14 08:12:18 -08:00
|
|
|
ld a, [wTimeOfDayPalset]
|
2020-08-11 11:12:59 -07:00
|
|
|
and %00001100
|
2015-10-24 07:34:19 -07:00
|
|
|
srl a
|
|
|
|
srl a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.NitePalette:
|
2015-12-14 08:12:18 -08:00
|
|
|
ld a, [wTimeOfDayPalset]
|
2020-08-11 11:12:59 -07:00
|
|
|
and %00110000
|
2015-10-24 07:34:19 -07:00
|
|
|
swap a
|
|
|
|
ret
|
|
|
|
|
2023-07-31 03:27:53 -07:00
|
|
|
.EveningPalette:
|
2015-12-14 08:12:18 -08:00
|
|
|
ld a, [wTimeOfDayPalset]
|
2020-08-11 11:12:59 -07:00
|
|
|
and %11000000
|
2015-10-24 07:34:19 -07:00
|
|
|
rlca
|
|
|
|
rlca
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DmgToCgbTimePals:
|
2015-10-24 07:34:19 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
ld a, [hli]
|
|
|
|
call DmgToCgbBGPals
|
|
|
|
ld a, [hli]
|
|
|
|
ld e, a
|
|
|
|
ld a, [hli]
|
|
|
|
ld d, a
|
|
|
|
call DmgToCgbObjPals
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ConvertTimePalsIncHL:
|
2015-10-24 07:34:19 -07:00
|
|
|
.loop
|
|
|
|
call DmgToCgbTimePals
|
|
|
|
inc hl
|
2016-05-10 09:31:49 -07:00
|
|
|
inc hl
|
|
|
|
inc hl
|
2015-12-14 17:06:41 -08:00
|
|
|
ld c, 2
|
2015-10-24 07:34:19 -07:00
|
|
|
call DelayFrames
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ConvertTimePalsDecHL:
|
2015-10-24 07:34:19 -07:00
|
|
|
.loop
|
|
|
|
call DmgToCgbTimePals
|
|
|
|
dec hl
|
2016-05-10 09:31:49 -07:00
|
|
|
dec hl
|
|
|
|
dec hl
|
2015-12-14 17:06:41 -08:00
|
|
|
ld c, 2
|
2015-10-24 07:34:19 -07:00
|
|
|
call DelayFrames
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetTimePalFade:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld hl, .cgbfade
|
2020-06-17 08:29:00 -07:00
|
|
|
ld b, 0
|
2015-10-24 07:34:19 -07:00
|
|
|
add hl, bc
|
|
|
|
ret
|
|
|
|
|
|
|
|
.cgbfade
|
2018-09-09 15:15:54 -07:00
|
|
|
dc 3,3,3,3, 3,3,3,3, 3,3,3,3
|
|
|
|
dc 3,3,3,2, 3,3,3,2, 3,3,3,2
|
|
|
|
dc 3,3,2,1, 3,3,2,1, 3,3,2,1
|
|
|
|
dc 3,2,1,0, 3,2,1,0, 3,2,1,0
|
|
|
|
dc 2,1,0,0, 2,1,0,0, 2,1,0,0
|
|
|
|
dc 1,0,0,0, 1,0,0,0, 1,0,0,0
|
|
|
|
dc 0,0,0,0, 0,0,0,0, 0,0,0,0
|