ref: ed3e70b97c41c950afd2824c267f220f4620a8a7
parent: 64e2cff5c46aaf8cdf8fceb5877901962235ebfc
author: Rangi <[email protected]>
date: Tue Aug 11 10:12:59 EDT 2020
Identify some time-related data
--- a/constants/map_data_constants.asm
+++ b/constants/map_data_constants.asm
@@ -32,6 +32,7 @@
const PALETTE_NITE
const PALETTE_MORN
const PALETTE_DARK
+NUM_MAP_PALETTES EQU const_value
; FishGroups indexes (see data/wild/fish.asm)
const_def
--- a/constants/wram_constants.asm
+++ b/constants/wram_constants.asm
@@ -123,6 +123,9 @@
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
--- a/engine/battle/battle_transition.asm
+++ b/engine/battle/battle_transition.asm
@@ -270,7 +270,7 @@
.DoFlashAnimation:
ld a, [wTimeOfDayPalset]
- cp %11111111 ; dark cave
+ cp DARKNESS_PALSET
jr z, .done
ld hl, wcf64
ld a, [hl]
@@ -651,13 +651,13 @@
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 @@
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]
--- a/engine/events/overworld.asm
+++ b/engine/events/overworld.asm
@@ -289,7 +289,7 @@
pop hl
jr c, .useflash
ld a, [wTimeOfDayPalset]
- cp %11111111 ; 3, 3, 3, 3
+ cp DARKNESS_PALSET
jr nz, .notadarkcave
.useflash
call UseFlash
--- a/engine/tilesets/tileset_anims.asm
+++ b/engine/tilesets/tileset_anims.asm
@@ -925,7 +925,7 @@
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]
--- a/engine/tilesets/timeofday_pals.asm
+++ b/engine/tilesets/timeofday_pals.asm
@@ -190,7 +190,7 @@
ld a, [wMapTimeOfDay]
cp PALETTE_DARK
jr z, .NeedsFlash
- and $7
+ maskbits NUM_MAP_PALETTES
add l
ld l, a
ld a, 0
@@ -204,42 +204,44 @@
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
@@ -246,13 +248,13 @@
.NitePalette:
ld a, [wTimeOfDayPalset]
- and %00110000 ; 2
+ and %00110000
swap a
ret
.DarknessPalette:
ld a, [wTimeOfDayPalset]
- and %11000000 ; 3
+ and %11000000
rlca
rlca
ret
--- /dev/null
+++ b/gfx/overworld/trainer_battle.pal
@@ -1,0 +1,4 @@
+ RGB 31, 18, 29
+ RGB 31, 11, 15
+ RGB 31, 05, 05
+ RGB 07, 07, 07
--- /dev/null
+++ b/gfx/overworld/trainer_battle_dark.pal
@@ -1,0 +1,4 @@
+ RGB 31, 18, 29
+ RGB 31, 05, 05
+ RGB 31, 05, 05
+ RGB 31, 05, 05
--- a/gfx/overworld/trainer_battle_day.pal
+++ /dev/null
@@ -1,4 +1,0 @@
- RGB 31, 18, 29
- RGB 31, 11, 15
- RGB 31, 05, 05
- RGB 07, 07, 07
--- a/gfx/overworld/trainer_battle_nite.pal
+++ /dev/null
@@ -1,4 +1,0 @@
- RGB 31, 18, 29
- RGB 31, 05, 05
- RGB 31, 05, 05
- RGB 31, 05, 05