Identify some time-related data

This commit is contained in:
Rangi 2020-08-11 14:12:59 -04:00
parent 64e2cff5c4
commit ed3e70b97c
8 changed files with 36 additions and 30 deletions

View File

@ -32,6 +32,7 @@ MAP_NONE EQU 0
const PALETTE_NITE
const PALETTE_MORN
const PALETTE_DARK
NUM_MAP_PALETTES EQU const_value
; FishGroups indexes (see data/wild/fish.asm)
const_def

View File

@ -123,6 +123,9 @@ DARKNESS EQU 1 << DARKNESS_F
ANYTIME EQU MORN | DAY | NITE
; wTimeOfDayPalset::
DARKNESS_PALSET EQU (DARKNESS_F << 6) | (DARKNESS_F << 4) | (DARKNESS_F << 2) | DARKNESS_F
; wBattleAnimFlags::
const_def
const BATTLEANIM_STOP_F ; 0

View File

@ -270,7 +270,7 @@ StartTrainerBattle_Flash:
.DoFlashAnimation:
ld a, [wTimeOfDayPalset]
cp %11111111 ; dark cave
cp DARKNESS_PALSET
jr z, .done
ld hl, wcf64
ld a, [hl]
@ -651,13 +651,13 @@ StartTrainerBattle_LoadPokeBallGraphics:
jr .nextscene
.cgb
ld hl, .daypals
ld hl, .pals
ld a, [wTimeOfDayPal]
maskbits NUM_DAYTIMES
cp DARKNESS_F
jr nz, .daytime
ld hl, .nightpals
.daytime
jr nz, .not_dark
ld hl, .darkpals
.not_dark
ldh a, [rSVBK]
push af
ld a, BANK(wBGPals1)
@ -702,11 +702,11 @@ StartTrainerBattle_LoadPokeBallGraphics:
pop hl
ret
.daypals
INCLUDE "gfx/overworld/trainer_battle_day.pal"
.pals
INCLUDE "gfx/overworld/trainer_battle.pal"
.nightpals
INCLUDE "gfx/overworld/trainer_battle_nite.pal"
.darkpals
INCLUDE "gfx/overworld/trainer_battle_dark.pal"
.loadpokeballgfx
ld a, [wOtherTrainerClass]

View File

@ -289,7 +289,7 @@ FlashFunction:
pop hl
jr c, .useflash
ld a, [wTimeOfDayPalset]
cp %11111111 ; 3, 3, 3, 3
cp DARKNESS_PALSET
jr nz, .notadarkcave
.useflash
call UseFlash

View File

@ -925,7 +925,7 @@ FlickeringCaveEntrancePalette:
ret nz
; We only want to be here if we're in a dark cave.
ld a, [wTimeOfDayPalset]
cp %11111111 ; 3,3,3,3
cp DARKNESS_PALSET
ret nz
ldh a, [rSVBK]

View File

@ -190,7 +190,7 @@ ReplaceTimeOfDayPals:
ld a, [wMapTimeOfDay]
cp PALETTE_DARK
jr z, .NeedsFlash
and $7
maskbits NUM_MAP_PALETTES
add l
ld l, a
ld a, 0
@ -204,55 +204,57 @@ ReplaceTimeOfDayPals:
ld a, [wStatusFlags]
bit STATUSFLAGS_FLASH_F, a
jr nz, .UsedFlash
ld a, %11111111 ; 3, 3, 3, 3
ld a, DARKNESS_PALSET
ld [wTimeOfDayPalset], a
ret
.UsedFlash:
ld a, %10101010 ; 2, 2, 2, 2
ld a, (NITE_F << 6) | (NITE_F << 4) | (NITE_F << 2) | NITE_F
ld [wTimeOfDayPalset], a
ret
.BrightnessLevels:
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
; actual palettes used when time is
; DARKNESS_F, NITE_F, DAY_F, MORN_F
dc DARKNESS_F, NITE_F, DAY_F, MORN_F ; PALETTE_AUTO
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
dc DARKNESS_F, DARKNESS_F, DARKNESS_F, DARKNESS_F ; PALETTE_DARK
dc DARKNESS_F, NITE_F, DAY_F, MORN_F
dc DARKNESS_F, NITE_F, DAY_F, MORN_F
dc DARKNESS_F, NITE_F, DAY_F, MORN_F
GetTimePalette:
jumptable .TimePalettes, wTimeOfDay
.TimePalettes:
dw .MorningPalette
dw .DayPalette
dw .NitePalette
dw .DarknessPalette
dw .MorningPalette ; MORN_F
dw .DayPalette ; DAY_F
dw .NitePalette ; NITE_F
dw .DarknessPalette ; DARKNESS_F
.MorningPalette:
ld a, [wTimeOfDayPalset]
and %00000011 ; 0
and %00000011
ret
.DayPalette:
ld a, [wTimeOfDayPalset]
and %00001100 ; 1
and %00001100
srl a
srl a
ret
.NitePalette:
ld a, [wTimeOfDayPalset]
and %00110000 ; 2
and %00110000
swap a
ret
.DarknessPalette:
ld a, [wTimeOfDayPalset]
and %11000000 ; 3
and %11000000
rlca
rlca
ret