2018-01-02 06:05:14 -08:00
|
|
|
DummyPredef35: ; 8c000
|
|
|
|
DummyPredef36:
|
2017-12-15 17:10:54 -08:00
|
|
|
ret
|
|
|
|
|
2015-12-14 08:12:18 -08:00
|
|
|
UpdateTimeOfDayPal:: ; 8c001
|
2015-10-24 07:34:19 -07:00
|
|
|
call UpdateTime
|
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
|
|
|
|
; 8c011
|
|
|
|
|
|
|
|
|
|
|
|
_TimeOfDayPals:: ; 8c011
|
|
|
|
; 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
|
|
|
|
ld a, [rSVBK]
|
|
|
|
ld b, a
|
2018-01-18 18:48:52 -08:00
|
|
|
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, BANK(wBGPals1)
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [rSVBK], a
|
|
|
|
|
|
|
|
; 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
|
|
|
|
ld [rSVBK], a
|
|
|
|
|
|
|
|
|
|
|
|
; update sgb pals
|
2015-12-22 15:03:00 -08:00
|
|
|
ld b, SCGB_MAPPALS
|
2015-10-24 07:34:19 -07:00
|
|
|
call GetSGBLayout
|
|
|
|
|
|
|
|
|
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
|
|
|
|
ld a, [rSVBK]
|
|
|
|
ld d, a
|
2018-01-18 18:48:52 -08:00
|
|
|
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, BANK(wOBPals1)
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [rSVBK], a
|
|
|
|
|
|
|
|
; 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
|
|
|
|
ld [rSVBK], a
|
|
|
|
|
|
|
|
; 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
|
|
|
|
; 8c070
|
|
|
|
|
|
|
|
|
2018-01-02 09:49:25 -08:00
|
|
|
_UpdateTimePals:: ; 8c070
|
2015-10-24 07:34:19 -07:00
|
|
|
ld c, $9 ; normal
|
|
|
|
call GetTimePalFade
|
|
|
|
call DmgToCgbTimePals
|
|
|
|
ret
|
|
|
|
; 8c079
|
|
|
|
|
2018-01-24 08:17:05 -08:00
|
|
|
FadeInPalettes:: ; 8c079
|
2015-10-24 07:34:19 -07:00
|
|
|
ld c, $12
|
|
|
|
call GetTimePalFade
|
|
|
|
ld b, $4
|
|
|
|
call ConvertTimePalsDecHL
|
|
|
|
ret
|
|
|
|
; 8c084
|
|
|
|
|
2018-01-24 08:17:05 -08:00
|
|
|
FadeOutPalettes:: ; 8c084
|
2015-12-14 17:06:41 -08:00
|
|
|
call FillWhiteBGColor
|
2015-10-24 07:34:19 -07:00
|
|
|
ld c, $9
|
|
|
|
call GetTimePalFade
|
|
|
|
ld b, $4
|
|
|
|
call ConvertTimePalsIncHL
|
|
|
|
ret
|
|
|
|
; 8c092
|
|
|
|
|
2018-01-24 08:17:05 -08:00
|
|
|
BattleTowerFade: ; 8c092
|
2015-12-14 17:06:41 -08:00
|
|
|
call FillWhiteBGColor
|
2015-10-24 07:34:19 -07:00
|
|
|
ld c, $9
|
|
|
|
call GetTimePalFade
|
|
|
|
ld b, $4
|
|
|
|
.asm_8c09c
|
|
|
|
call DmgToCgbTimePals
|
|
|
|
inc hl
|
2016-05-10 09:31:49 -07:00
|
|
|
inc hl
|
|
|
|
inc hl
|
2015-10-24 07:34:19 -07:00
|
|
|
ld c, $7
|
|
|
|
call DelayFrames
|
|
|
|
dec b
|
|
|
|
jr nz, .asm_8c09c
|
|
|
|
ret
|
|
|
|
; 8c0ab
|
|
|
|
|
2018-01-24 08:17:05 -08:00
|
|
|
FadeInQuickly: ; 8c0ab
|
2015-10-24 07:34:19 -07:00
|
|
|
ld c, $0
|
|
|
|
call GetTimePalFade
|
|
|
|
ld b, $4
|
|
|
|
call ConvertTimePalsIncHL
|
|
|
|
ret
|
|
|
|
; 8c0b6
|
|
|
|
|
2018-01-24 08:17:05 -08:00
|
|
|
FadeBlackQuickly: ; 8c0b6
|
2015-10-24 07:34:19 -07:00
|
|
|
ld c, $9
|
|
|
|
call GetTimePalFade
|
|
|
|
ld b, $4
|
|
|
|
call ConvertTimePalsDecHL
|
|
|
|
ret
|
|
|
|
; 8c0c1
|
|
|
|
|
|
|
|
|
2015-12-14 17:06:41 -08:00
|
|
|
FillWhiteBGColor: ; 8c0c1
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, BANK(wBGPals1)
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [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
|
|
|
|
ld [rSVBK], a
|
|
|
|
ret
|
|
|
|
; 8c0e5
|
|
|
|
|
2015-12-14 08:12:18 -08:00
|
|
|
ReplaceTimeOfDayPals: ; 8c0e5
|
2015-10-24 07:34:19 -07:00
|
|
|
ld hl, .BrightnessLevels
|
2015-12-14 17:06:41 -08:00
|
|
|
ld a, [wMapTimeOfDay]
|
2015-10-24 07:34:19 -07:00
|
|
|
cp $4 ; Dark cave, needs Flash
|
|
|
|
jr z, .DarkCave
|
|
|
|
and $7
|
|
|
|
add l
|
|
|
|
ld l, a
|
|
|
|
ld a, $0
|
|
|
|
adc h
|
|
|
|
ld h, a
|
|
|
|
ld a, [hl]
|
2015-12-14 08:12:18 -08:00
|
|
|
ld [wTimeOfDayPalset], a
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
2015-12-14 08:12:18 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DarkCave:
|
2017-12-28 04:15:46 -08:00
|
|
|
ld a, [wStatusFlags]
|
2018-01-22 12:40:43 -08:00
|
|
|
bit STATUSFLAGS_FLASH_F, a
|
2015-10-24 07:34:19 -07:00
|
|
|
jr nz, .UsedFlash
|
2015-12-14 08:12:18 -08:00
|
|
|
ld a, %11111111 ; 3, 3, 3, 3
|
|
|
|
ld [wTimeOfDayPalset], a
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
2015-12-14 08:12:18 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.UsedFlash:
|
2015-12-14 08:12:18 -08:00
|
|
|
ld a, %10101010 ; 2, 2, 2, 2
|
|
|
|
ld [wTimeOfDayPalset], a
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
; 8c10f (23:410f)
|
|
|
|
|
|
|
|
.BrightnessLevels: ; 8c10f
|
2017-12-13 21:36:24 -08:00
|
|
|
dc 3, 2, 1, 0
|
|
|
|
dc 1, 1, 1, 1
|
|
|
|
dc 2, 2, 2, 2
|
|
|
|
dc 0, 0, 0, 0
|
|
|
|
dc 3, 3, 3, 3
|
|
|
|
dc 3, 2, 1, 0
|
|
|
|
dc 3, 2, 1, 0
|
|
|
|
dc 3, 2, 1, 0
|
2015-10-24 07:34:19 -07:00
|
|
|
; 8c117
|
|
|
|
|
|
|
|
GetTimePalette: ; 8c117
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTimeOfDay]
|
2015-10-24 07:34:19 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
ld hl, .TimePalettes
|
|
|
|
add hl, de
|
2016-05-04 08:46:23 -07:00
|
|
|
add hl, de
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2017-06-09 14:01:10 -07:00
|
|
|
jp hl
|
2015-10-24 07:34:19 -07:00
|
|
|
; 8c126
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.TimePalettes:
|
2015-10-24 07:34:19 -07:00
|
|
|
dw .MorningPalette
|
|
|
|
dw .DayPalette
|
|
|
|
dw .NitePalette
|
|
|
|
dw .DarknessPalette
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.MorningPalette:
|
2015-12-14 08:12:18 -08:00
|
|
|
ld a, [wTimeOfDayPalset]
|
2015-10-24 07:34:19 -07:00
|
|
|
and %00000011 ; 0
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DayPalette:
|
2015-12-14 08:12:18 -08:00
|
|
|
ld a, [wTimeOfDayPalset]
|
2015-10-24 07:34:19 -07:00
|
|
|
and %00001100 ; 1
|
|
|
|
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]
|
2015-10-24 07:34:19 -07:00
|
|
|
and %00110000 ; 2
|
|
|
|
swap a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DarknessPalette:
|
2015-12-14 08:12:18 -08:00
|
|
|
ld a, [wTimeOfDayPalset]
|
2015-10-24 07:34:19 -07:00
|
|
|
and %11000000 ; 3
|
|
|
|
rlca
|
|
|
|
rlca
|
|
|
|
ret
|
|
|
|
; 8c14e
|
|
|
|
|
|
|
|
|
|
|
|
DmgToCgbTimePals: ; 8c14e
|
|
|
|
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
|
|
|
|
; 8c15e
|
|
|
|
|
|
|
|
ConvertTimePalsIncHL: ; 8c15e
|
|
|
|
.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
|
|
|
|
; 8c16d
|
|
|
|
|
|
|
|
ConvertTimePalsDecHL: ; 8c16d
|
|
|
|
.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
|
|
|
|
; 8c17c
|
|
|
|
|
|
|
|
|
|
|
|
GetTimePalFade: ; 8c17c
|
|
|
|
; check cgb
|
|
|
|
ld a, [hCGB]
|
|
|
|
and a
|
|
|
|
jr nz, .cgb
|
|
|
|
|
|
|
|
; else: dmg
|
|
|
|
|
|
|
|
; index
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTimeOfDayPal]
|
2015-10-24 07:34:19 -07:00
|
|
|
and %11
|
|
|
|
|
|
|
|
; get fade table
|
|
|
|
push bc
|
|
|
|
ld c, a
|
|
|
|
ld b, $0
|
|
|
|
ld hl, .dmgfades
|
|
|
|
add hl, bc
|
2016-05-04 08:46:23 -07:00
|
|
|
add hl, bc
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
pop bc
|
|
|
|
|
|
|
|
; get place in fade table
|
|
|
|
ld b, $0
|
|
|
|
add hl, bc
|
|
|
|
ret
|
|
|
|
|
|
|
|
.cgb
|
|
|
|
ld hl, .cgbfade
|
|
|
|
ld b, $0
|
|
|
|
add hl, bc
|
|
|
|
ret
|
|
|
|
|
|
|
|
.dmgfades
|
|
|
|
dw .morn
|
|
|
|
dw .day
|
|
|
|
dw .nite
|
|
|
|
dw .darkness
|
|
|
|
|
|
|
|
.morn
|
|
|
|
db %11111111, %11111111, %11111111
|
|
|
|
db %11111110, %11111110, %11111110
|
|
|
|
db %11111001, %11100100, %11100100
|
|
|
|
db %11100100, %11010000, %11010000
|
|
|
|
db %10010000, %10000000, %10000000
|
|
|
|
db %01000000, %01000000, %01000000
|
|
|
|
db %00000000, %00000000, %00000000
|
|
|
|
|
|
|
|
.day
|
2016-04-10 11:42:14 -07:00
|
|
|
db %11111111, %11111111, %11111111
|
|
|
|
db %11111110, %11111110, %11111110
|
2015-10-24 07:34:19 -07:00
|
|
|
db %11111001, %11100100, %11100100
|
|
|
|
db %11100100, %11010000, %11010000
|
|
|
|
db %10010000, %10000000, %10000000
|
|
|
|
db %01000000, %01000000, %01000000
|
|
|
|
db %00000000, %00000000, %00000000
|
|
|
|
|
|
|
|
.nite
|
|
|
|
db %11111111, %11111111, %11111111
|
|
|
|
db %11111110, %11111110, %11111110
|
|
|
|
db %11111001, %11100100, %11100100
|
|
|
|
db %11101001, %11010000, %11010000
|
|
|
|
db %10010000, %10000000, %10000000
|
|
|
|
db %01000000, %01000000, %01000000
|
|
|
|
db %00000000, %00000000, %00000000
|
|
|
|
|
|
|
|
.darkness
|
|
|
|
db %11111111, %11111111, %11111111
|
|
|
|
db %11111110, %11111110, %11111111
|
|
|
|
db %11111110, %11100100, %11111111
|
|
|
|
db %11111101, %11010000, %11111111
|
|
|
|
db %11111101, %10000000, %11111111
|
|
|
|
db %00000000, %01000000, %00000000
|
|
|
|
db %00000000, %00000000, %00000000
|
|
|
|
|
|
|
|
.cgbfade
|
|
|
|
db %11111111, %11111111, %11111111
|
|
|
|
db %11111110, %11111110, %11111110
|
|
|
|
db %11111001, %11111001, %11111001
|
|
|
|
db %11100100, %11100100, %11100100
|
|
|
|
db %10010000, %10010000, %10010000
|
|
|
|
db %01000000, %01000000, %01000000
|
|
|
|
db %00000000, %00000000, %00000000
|
|
|
|
; 8c20f
|