Logic to manage PAL_OW_MISC (#3)

This commit is contained in:
xCrystal 2024-01-03 17:24:26 +01:00
parent ce4ca85494
commit 16e7328439
9 changed files with 101 additions and 17 deletions

View File

@ -74,3 +74,12 @@ DIE_SIZE EQU DIE_WIDTH * DIE_HEIGHT
DIE_NUMBER_WIDTH EQU 2 DIE_NUMBER_WIDTH EQU 2
DIE_NUMBER_HEIGHT EQU 2 DIE_NUMBER_HEIGHT EQU 2
DIE_NUMBER_SIZE EQU DIE_NUMBER_WIDTH * DIE_NUMBER_HEIGHT DIE_NUMBER_SIZE EQU DIE_NUMBER_WIDTH * DIE_NUMBER_HEIGHT
; PAL_OW_MISC groups (high nybble of wCurOverworldMiscPal)
const_def 0, $10
const PAL_OW_MISC_BOARD_MENU_ITEMS
const PAL_OW_MISC_BOARD_DICE
const PAL_OW_MISC_BOARD_COINS
DEF NUM_PAL_OW_MISC_PAL_GROUPS EQU const_value / $10
PAL_OW_MISC_PAL_GROUP_MASK EQU %11110000

View File

@ -72,7 +72,7 @@
- **refreshscreen**: RefreshScreen - **refreshscreen**: RefreshScreen
- **reloadmappart**: LoadScreenTilemapAndAttrmapPals + GetMovementPermissions + HDMATransferTilemapAndAttrmap_OverworldEffect + UpdateSprites. Similar to refreshscreen, but does not reanchor. On the other hand, it refreshes movement permissions. Often used after a block change or field move, which can affect collisions. - **reloadmappart**: LoadScreenTilemapAndAttrmapPals + GetMovementPermissions + HDMATransferTilemapAndAttrmap_OverworldEffect + UpdateSprites. Similar to refreshscreen, but does not reanchor. On the other hand, it refreshes movement permissions. Often used after a block change or field move, which can affect collisions.
## Board behavior ## Changes
### RAM addresses ### RAM addresses
@ -96,6 +96,7 @@
- Addresses within *wPlayerData* ~ *wPlayerDataEnd*: preserved on save. Includes: - Addresses within *wPlayerData* ~ *wPlayerDataEnd*: preserved on save. Includes:
- **wUnlockedLevels**: flag array that tracks progression regarding which levels have been unlocked. - **wUnlockedLevels**: flag array that tracks progression regarding which levels have been unlocked.
- **wUnlockedTechniques**: flag array that tracks progression regarding which techniques have been unlocked. - **wUnlockedTechniques**: flag array that tracks progression regarding which techniques have been unlocked.
- **wCurOverworldMiscPal**
- These addresses share memory region with string buffers from *wStringBuffer3* onwards. They are placed in memory in the following order. - These addresses share memory region with string buffers from *wStringBuffer3* onwards. They are placed in memory in the following order.
- **wTempSpaceStruct**: Temporary scope. Same structure as *wCurSpaceStruct* - **wTempSpaceStruct**: Temporary scope. Same structure as *wCurSpaceStruct*

View File

@ -201,21 +201,12 @@ DrawBoardMenuTilesAndClearPriorityAttr:
jp FillBoxWithByte jp FillBoxWithByte
ApplyBoardMenuSpritePalette: ApplyBoardMenuSpritePalette:
ld hl, BoardMenuItemPals
ld a, [wBoardMenuCursorPosition] ld a, [wBoardMenuCursorPosition]
ld bc, PALETTE_SIZE or PAL_OW_MISC_BOARD_MENU_ITEMS
call AddNTimes ld [wCurOverworldMiscPal], a
; write to wOBPals2 directly as well to avoid calling ApplyPals and overwriting other overworld pals ; write to wOBPals2 directly as well to avoid calling ApplyPals and overwriting other overworld pals
; writing to wOBPals1 is still necessary to make fading animations consistent ; writing to wOBPals1 is still necessary to make fading animations consistent
ld de, wOBPals1 palette PAL_OW_MISC farcall LoadOverworldMiscObjPal_ToObPals1And2
ld bc, PALETTE_SIZE
ld a, BANK(wOBPals1)
call FarCopyWRAM
ld hl, wOBPals1 palette PAL_OW_MISC
ld de, wOBPals2 palette PAL_OW_MISC
ld bc, PALETTE_SIZE
ld a, BANK(wOBPals1)
call FarCopyWRAM
ld a, TRUE ld a, TRUE
ldh [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
@ -487,6 +478,3 @@ BoardMenu_CloseSubmenu:
farcall FadeInPalettesFromWhite farcall FadeInPalettesFromWhite
call EnableSpriteUpdates call EnableSpriteUpdates
ret ret
BoardMenuItemPals:
INCLUDE "gfx/board/menu.pal"

View File

@ -321,6 +321,8 @@ UnionSpaceScript::
ret ret
PrintGainCoins: PrintGainCoins:
ld a, PAL_OW_MISC_BOARD_COINS | 0
ld [wCurOverworldMiscPal], a
ld hl, wStringBuffer1 ld hl, wStringBuffer1
ld a, "<COIN>" ld a, "<COIN>"
ld [hli], a ld [hli], a
@ -329,6 +331,8 @@ PrintGainCoins:
jr PrintGainOrLoseCoins jr PrintGainOrLoseCoins
PrintLoseCoins: PrintLoseCoins:
ld a, PAL_OW_MISC_BOARD_COINS | 1
ld [wCurOverworldMiscPal], a
ld hl, wStringBuffer1 ld hl, wStringBuffer1
ld a, "<COIN>" ld a, "<COIN>"
ld [hli], a ld [hli], a
@ -338,7 +342,12 @@ PrintLoseCoins:
PrintGainOrLoseCoins: PrintGainOrLoseCoins:
push hl push hl
farcall LoadOverworldMiscObjPal_ToObPals2
ld a, TRUE
ldh [hCGBPalUpdate], a
pop hl
; fill string space with "@" to ensure that it is terminated with at least one "@" ; fill string space with "@" to ensure that it is terminated with at least one "@"
push hl
ld a, "@" ld a, "@"
ld c, MAX_DELTA_COINS_DIGITS + 1 ld c, MAX_DELTA_COINS_DIGITS + 1
.loop .loop

View File

@ -699,7 +699,8 @@ LoadMapPals:
ld de, wOBPals1 ld de, wOBPals1
ld hl, MapObjectDarknessPals ld hl, MapObjectDarknessPals
ld bc, 7 palettes ; all but PAL_OW_MISC ld bc, 7 palettes ; all but PAL_OW_MISC
jp FarCopyWRAM call FarCopyWRAM
jp LoadOverworldMiscObjPal_ToObPals1 ; PAL_OW_MISC
.not_darkness .not_darkness
ld a, [wTimeOfDayPal] ld a, [wTimeOfDayPal]
@ -711,6 +712,7 @@ LoadMapPals:
ld bc, 7 palettes ; all but PAL_OW_MISC ld bc, 7 palettes ; all but PAL_OW_MISC
ld a, BANK(wOBPals1) ld a, BANK(wOBPals1)
call FarCopyWRAM call FarCopyWRAM
call LoadOverworldMiscObjPal_ToObPals1 ; PAL_OW_MISC
ld a, [wEnvironment] ld a, [wEnvironment]
cp INDOOR_ENVIRONMENT cp INDOOR_ENVIRONMENT
@ -763,6 +765,53 @@ LoadDarknessPalette:
ld bc, 8 palettes ld bc, 8 palettes
jp FarCopyWRAM jp FarCopyWRAM
LoadOverworldMiscObjPal_ToObPals1:
call GetOverworldMiscObjPal
ld de, wOBPals1 palette PAL_OW_MISC
ld bc, PALETTE_SIZE
ld a, BANK(wOBPals1)
jp FarCopyWRAM
LoadOverworldMiscObjPal_ToObPals2:
call GetOverworldMiscObjPal
ld de, wOBPals2 palette PAL_OW_MISC
ld bc, PALETTE_SIZE
ld a, BANK(wOBPals1)
jp FarCopyWRAM
LoadOverworldMiscObjPal_ToObPals1And2:
call LoadOverworldMiscObjPal_ToObPals1
ld hl, wOBPals1 palette PAL_OW_MISC
ld de, wOBPals2 palette PAL_OW_MISC
ld bc, PALETTE_SIZE
ld a, BANK(wOBPals1)
jp FarCopyWRAM
GetOverworldMiscObjPal:
ld a, [wCurOverworldMiscPal]
and PAL_OW_MISC_PAL_GROUP_MASK
swap a
ld hl, .OverworldMiscPalGroups
ld bc, .pal_group_2 - .pal_group_1
call AddNTimes
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wCurOverworldMiscPal]
and ~PAL_OW_MISC_PAL_GROUP_MASK
ld bc, PALETTE_SIZE
call AddNTimes
ret
.OverworldMiscPalGroups:
table_width 2, .OverworldMiscPalGroups
.pal_group_1
dw BoardMenuItemsPals
.pal_group_2
dw BoardDicePals
dw BoardCoinsPals
assert_table_length NUM_PAL_OW_MISC_PAL_GROUPS
INCLUDE "data/maps/environment_colors.asm" INCLUDE "data/maps/environment_colors.asm"
PartyMenuBGMobilePalette: PartyMenuBGMobilePalette:
@ -783,6 +832,15 @@ INCLUDE "gfx/overworld/npc_sprites_darkness.pal"
MapObjectPals:: MapObjectPals::
INCLUDE "gfx/overworld/npc_sprites.pal" INCLUDE "gfx/overworld/npc_sprites.pal"
BoardMenuItemsPals:
INCLUDE "gfx/board/menu.pal"
BoardDicePals:
INCLUDE "gfx/board/dice.pal"
BoardCoinsPals:
INCLUDE "gfx/board/coins.pal"
RoofPals: RoofPals:
table_width PAL_COLOR_SIZE * 4 * 2, RoofPals table_width PAL_COLOR_SIZE * 4 * 2, RoofPals
INCLUDE "gfx/tilesets/roofs.pal" INCLUDE "gfx/tilesets/roofs.pal"

View File

@ -173,6 +173,7 @@ StartMap:
ld [hli], a ; wPrevWarp ld [hli], a ; wPrevWarp
ld [hli], a ; wPrevMapGroup ld [hli], a ; wPrevMapGroup
ld [hl], a ; wPrevMapNumber ld [hl], a ; wPrevMapNumber
ld [wCurOverworldMiscPal], a
ld a, BANK(wDisabledSpacesBackups) ld a, BANK(wDisabledSpacesBackups)
ld [rSVBK], a ld [rSVBK], a

11
gfx/board/coins.pal Executable file
View File

@ -0,0 +1,11 @@
; gain coins
RGB 31, 31, 31
RGB 19, 23, 31
RGB 27, 17, 03
RGB 00, 00, 00
; lose coins
RGB 31, 31, 31
RGB 31, 20, 18
RGB 27, 17, 03
RGB 00, 00, 00

5
gfx/board/dice.pal Executable file
View File

@ -0,0 +1,5 @@
; die 1
RGB 31, 31, 31
RGB 10, 10, 31
RGB 00, 00, 21
RGB 00, 00, 00

View File

@ -2521,6 +2521,8 @@ wRepelEffect:: db ; If a Repel is in use, it contains the nr of steps it's still
wBikeStep:: dw wBikeStep:: dw
wKurtApricornQuantity:: db wKurtApricornQuantity:: db
wCurOverworldMiscPal:: db
wPlayerDataEnd:: wPlayerDataEnd::
wCurMapData:: wCurMapData::