From 28ee10d23aac261b398106592f0463f82e37174f Mon Sep 17 00:00:00 2001 From: SoupPotato Date: Mon, 27 May 2024 20:39:39 +0100 Subject: [PATCH 01/11] First attempt at Dynamic Objects and Pals --- constants/map_object_constants.asm | 4 +- data/maps/outdoor_sprites.asm | 369 ----------------------------- engine/gfx/color.asm | 53 ++++- engine/menus/intro_menu.asm | 2 + engine/overworld/dynamic_pals.asm | 132 +++++++++++ engine/overworld/events.asm | 1 + engine/overworld/overworld.asm | 188 ++++----------- engine/overworld/player_object.asm | 2 +- engine/overworld/scripting.asm | 2 + home/map_objects.asm | 53 +++-- macros/ram.asm | 3 +- main.asm | 5 + ram/wram.asm | 8 +- 13 files changed, 268 insertions(+), 554 deletions(-) delete mode 100644 data/maps/outdoor_sprites.asm create mode 100644 engine/overworld/dynamic_pals.asm diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm index 4970659c9..45b277a2b 100644 --- a/constants/map_object_constants.asm +++ b/constants/map_object_constants.asm @@ -33,9 +33,11 @@ DEF OBJECT_1D rb ; 1d DEF OBJECT_1E rb ; 1e DEF OBJECT_JUMP_HEIGHT rb ; 1f DEF OBJECT_RANGE rb ; 20 - rb_skip 7 +DEF OBJECT_PAL_INDEX rb ; 21 + rb_skip 6 DEF OBJECT_LENGTH EQU _RS DEF NUM_OBJECT_STRUCTS EQU 13 ; see wObjectStructs +DEF FIRST_VRAM1_OBJECT_STRUCT EQU 10 ; object_struct OBJECT_DIRECTION values DEF OW_DOWN EQU DOWN << 2 diff --git a/data/maps/outdoor_sprites.asm b/data/maps/outdoor_sprites.asm deleted file mode 100644 index f63bb0f67..000000000 --- a/data/maps/outdoor_sprites.asm +++ /dev/null @@ -1,369 +0,0 @@ -; Valid sprite IDs for each map group. -; Maps with environment ROUTE or TOWN can only use these sprites. - -OutdoorSprites: -; entries correspond to MAPGROUP_* constants - table_width 2, OutdoorSprites - dw OlivineGroupSprites - dw MahoganyGroupSprites - dw DungeonsGroupSprites - dw EcruteakGroupSprites - dw BlackthornGroupSprites - dw CinnabarGroupSprites - dw CeruleanGroupSprites - dw AzaleaGroupSprites - dw LakeOfRageGroupSprites - dw VioletGroupSprites - dw GoldenrodGroupSprites - dw VermilionGroupSprites - dw PalletGroupSprites - dw PewterGroupSprites - dw FastShipGroupSprites - dw IndigoGroupSprites - dw FuchsiaGroupSprites - dw LavenderGroupSprites - dw SilverGroupSprites - dw CableClubGroupSprites - dw CeladonGroupSprites - dw CianwoodGroupSprites - dw ViridianGroupSprites - dw NewBarkGroupSprites - dw SaffronGroupSprites - dw CherrygroveGroupSprites - dw SafariZoneGateGroupSprites - dw SafariZoneGroupSprites - assert_table_length NUM_MAP_GROUPS - -; Route1 and ViridianCity are connected -; Route2North and PewterCity are connected -; PalletTown and Route21 are connected -PewterGroupSprites: -; Route3, PewterCity - db SPRITE_TEACHER - db SPRITE_FISHER - db SPRITE_YOUNGSTER - db SPRITE_COOLTRAINER_M - db SPRITE_GRAMPS - db SPRITE_BUG_CATCHER - db SPRITE_COOLTRAINER_F - db SPRITE_BLACK_BELT - db SPRITE_POKEFAN_M - ; max 9 of 9 walking sprites - db SPRITE_POKE_BALL - db SPRITE_BERRY - db SPRITE_APRICORN - db 0 ; end -ViridianGroupSprites: -; Route2South, Route22, ViridianCity -PalletGroupSprites: -; Route1, PalletTown -CinnabarGroupSprites: -; Route19, Route20, Route21, CinnabarIsland - db SPRITE_TEACHER - db SPRITE_FISHER - db SPRITE_YOUNGSTER - db SPRITE_GRAMPS - db SPRITE_BUG_CATCHER - db SPRITE_LASS - db SPRITE_COOLTRAINER_F - db SPRITE_SWIMMER_GIRL - db SPRITE_SWIMMER_GUY - ; max 9 of 9 walking sprites - db SPRITE_BLUE - db SPRITE_COOLTRAINER_M - db SPRITE_POKE_BALL - db SPRITE_BERRY - db SPRITE_APRICORN - db SPRITE_ROCK - db 0 ; end - -; CeruleanCity and Route5 are connected -CeruleanGroupSprites: -; Route4, Route9, Route10North, Route24, Route25, CeruleanCity -SaffronGroupSprites: -; Route5, SaffronCity - db SPRITE_COOLTRAINER_M - db SPRITE_SUPER_NERD - db SPRITE_COOLTRAINER_F - db SPRITE_FISHER - db SPRITE_YOUNGSTER - db SPRITE_LASS - db SPRITE_POKEFAN_M - db SPRITE_ROCKET - db SPRITE_MISTY - ; max 9 of 9 walking sprites - db SPRITE_POKE_BALL - db SPRITE_SLOWBRO - db SPRITE_ZAPDOS - db 0 ; end - -VermilionGroupSprites: -; Route6, Route11, VermilionCity - db SPRITE_POKEFAN_M - db SPRITE_YOUNGSTER - db SPRITE_TEACHER - db SPRITE_SUPER_NERD - db SPRITE_FISHER - db SPRITE_LASS - ; 6 of max 9 walking sprites - db SPRITE_GRAMPS - db SPRITE_BIG_SNORLAX - db SPRITE_MACHOP - db SPRITE_TWIN - db SPRITE_POKE_BALL - db SPRITE_BERRY - db SPRITE_APRICORN - db 0 ; end - -CeladonGroupSprites: -; Route7, Route16, Route17, CeladonCity - db SPRITE_FISHER - db SPRITE_TEACHER - db SPRITE_GRAMPS - db SPRITE_YOUNGSTER - db SPRITE_LASS - db SPRITE_BIKER - ; 6 of max 9 walking sprites - db SPRITE_POLIWRATH - db SPRITE_POKE_BALL - db SPRITE_BERRY - db 0 ; end - -; Route12 and Route13 are connected -LavenderGroupSprites: -; Route8, Route12, Route10South, LavenderTown -FuchsiaGroupSprites: -; Route13, Route14, Route15, Route18, FuchsiaCity - db SPRITE_POKEFAN_M - db SPRITE_POKEFAN_F - db SPRITE_YOUNGSTER - db SPRITE_FISHER - db SPRITE_TEACHER - db SPRITE_SUPER_NERD - db SPRITE_BIKER - db SPRITE_GENTLEMAN - db SPRITE_LASS - ; 9 of max 9 walking sprites - db SPRITE_GRAMPS - db SPRITE_ZAPDOS - db SPRITE_TWIN - db SPRITE_POKE_BALL - db SPRITE_BERRY - db SPRITE_APRICORN - db 0 ; end - -IndigoGroupSprites: -; Route23 - ; 0 of max 9 walking sprites - db 0 ; end - -; Route29 and CherrygroveCity are connected -NewBarkGroupSprites: -; Route26, Route27, Route29, NewBarkTown -CherrygroveGroupSprites: -; Route30, Route31, CherrygroveCity - db SPRITE_RIVAL - db SPRITE_TEACHER - db SPRITE_FISHER - db SPRITE_COOLTRAINER_M - db SPRITE_YOUNGSTER - db SPRITE_GRAMPS - db SPRITE_BUG_CATCHER - db SPRITE_COOLTRAINER_F - ; max 8 of 9 walking sprites - db SPRITE_PIDGEY - db SPRITE_RATTATA_UP - db SPRITE_POKE_BALL - db SPRITE_BERRY - db SPRITE_APRICORN - db 0 ; end - -; Route37 and EcruteakCity are connected -VioletGroupSprites: -; Route32, Route35, Route36, Route37, VioletCity -EcruteakGroupSprites: -; EcruteakCity - db SPRITE_FISHER - db SPRITE_LASS - db SPRITE_OFFICER - db SPRITE_GRAMPS - db SPRITE_YOUNGSTER - db SPRITE_COOLTRAINER_M - db SPRITE_BUG_CATCHER - db SPRITE_SUPER_NERD - ; 8 of max 9 walking sprites - db SPRITE_TWIN - db SPRITE_SUDOWOODO - db SPRITE_POKE_BALL - db SPRITE_BERRY - db SPRITE_APRICORN - db SPRITE_SUICUNE - db 0 ; end - -AzaleaGroupSprites: -; Route33, AzaleaTown - db SPRITE_GRAMPS - db SPRITE_YOUNGSTER - db SPRITE_POKEFAN_M - db SPRITE_TEACHER - db SPRITE_ROCKET - db SPRITE_LASS - db SPRITE_RIVAL - ; 7 of max 9 walking sprites - db SPRITE_BERRY - db SPRITE_APRICORN - db SPRITE_SLOWPOKE - db SPRITE_KURT - db 0 ; end - -GoldenrodGroupSprites: -; Route34, GoldenrodCity - db SPRITE_GRAMPS - db SPRITE_YOUNGSTER - db SPRITE_OFFICER - db SPRITE_POKEFAN_M - db SPRITE_COOLTRAINER_F - db SPRITE_ROCKET - db SPRITE_LASS - ; 7 of max 9 walking sprites - db SPRITE_DAY_CARE_MON_1 - db SPRITE_DAY_CARE_MON_2 - db SPRITE_POKE_BALL - db 0 ; end - -; OlivineCity and Route40 are connected -OlivineGroupSprites: -; Route38, Route39, OlivineCity -CianwoodGroupSprites: -; Route40, Route41, CianwoodCity, BattleTowerOutside - db SPRITE_RIVAL - db SPRITE_POKEFAN_M - db SPRITE_LASS - db SPRITE_SWIMMER_GIRL - db SPRITE_SAILOR - db SPRITE_POKEFAN_F - db SPRITE_SUPER_NERD - db SPRITE_SWIMMER_GUY - db SPRITE_GENTLEMAN - ; 9 of max 9 walking sprites - db SPRITE_BEAUTY - db SPRITE_MILTANK - db SPRITE_BERRY - db SPRITE_APRICORN - db SPRITE_ROCK - db SPRITE_YOUNGSTER ; non-walking version of SPRITE_YOUNGSTER - db SPRITE_SUICUNE - db 0 ; end - -MahoganyGroupSprites: -; Route42, Route44, MahoganyTown - db SPRITE_GRAMPS - db SPRITE_YOUNGSTER - db SPRITE_LASS - db SPRITE_SUPER_NERD - db SPRITE_COOLTRAINER_M - db SPRITE_POKEFAN_M - db SPRITE_COOLTRAINER_F - db SPRITE_FISHER - ; 8 of max 9 walking sprites - db SPRITE_BERRY - db SPRITE_APRICORN - db SPRITE_POKE_BALL - db SPRITE_SUICUNE - db 0 ; end - -LakeOfRageGroupSprites: -; Route43, LakeOfRage - db SPRITE_LANCE - db SPRITE_GRAMPS - db SPRITE_SUPER_NERD - db SPRITE_COOLTRAINER_F - db SPRITE_FISHER - db SPRITE_COOLTRAINER_M - db SPRITE_LASS - db SPRITE_YOUNGSTER - ; 8 of max 9 walking sprites - db SPRITE_GYARADOS - db SPRITE_BERRY - db SPRITE_APRICORN - db SPRITE_POKE_BALL - db 0 ; end - -BlackthornGroupSprites: -; Route45, Route46, BlackthornCity - db SPRITE_GRAMPS - db SPRITE_YOUNGSTER - db SPRITE_LASS - db SPRITE_SUPER_NERD - db SPRITE_COOLTRAINER_M - db SPRITE_POKEFAN_M - db SPRITE_BLACK_BELT - db SPRITE_COOLTRAINER_F - ; 8 of max 9 walking sprites - db SPRITE_BERRY - db SPRITE_APRICORN - db SPRITE_POKE_BALL - db 0 ; end - -SilverGroupSprites: -; Route28, SilverCaveOutside - ; 0 of max 9 walking sprites - db 0 ; end - -DungeonsGroupSprites: -; NationalPark, NationalParkBugContest, RuinsOfAlphOutside - db SPRITE_LASS - db SPRITE_POKEFAN_F - db SPRITE_TEACHER - db SPRITE_YOUNGSTER - db SPRITE_POKEFAN_M - db SPRITE_COOLTRAINER_M - db SPRITE_FISHER - db SPRITE_SCIENTIST - db SPRITE_BUG_CATCHER - ; 8 of max 9 walking sprites - db SPRITE_GAMEBOY_KID - db SPRITE_PERSIAN - db SPRITE_POKE_BALL - db 0 ; end - -FastShipGroupSprites: -; OlivinePort, VermilionPort, MountMoonSquare, TinTowerRoof - db SPRITE_SAILOR - db SPRITE_FISHING_GURU - db SPRITE_SUPER_NERD - db SPRITE_COOLTRAINER_F - db SPRITE_YOUNGSTER - ; 5 of max 9 walking sprites - db SPRITE_HO_OH - db SPRITE_CLEFAIRY_MOVE - db SPRITE_ROCK - db 0 ; end - -CableClubGroupSprites: -; (no outdoor maps) - ; 0 of max 9 walking sprites - db 0 ; end - -SafariZoneGateGroupSprites: -SafariZoneGroupSprites: -; Route47, Route48, SafariZoneGate, CliffEdgeCave, CliffEdgeGate - db SPRITE_TWIN - db SPRITE_SUPER_NERD - db SPRITE_YOUNGSTER - db SPRITE_LASS - db SPRITE_POKEFAN_M - db SPRITE_JIGGLYPUFF - db SPRITE_KANGASKHAN - db SPRITE_BUTTERFREE - db SPRITE_TEACHER - ; 7 of max 9 walking sprites - db SPRITE_SLOWPOKE - db SPRITE_GENTLEMAN - db SPRITE_POKEFAN_F - db SPRITE_GRAMPS - db SPRITE_COOLTRAINER_M - db SPRITE_COOLTRAINER_F - db SPRITE_BEAUTY - db SPRITE_POKE_BALL - db SPRITE_OLD_LINK_RECEPTIONIST diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm index d667c8c24..bdae0afec 100644 --- a/engine/gfx/color.asm +++ b/engine/gfx/color.asm @@ -1305,18 +1305,15 @@ LoadMapPals: ldh [rSVBK], a .got_pals - ld a, [wTimeOfDayPal] - maskbits NUM_DAYTIMES - ld bc, 8 palettes - ld hl, MapObjectPals - call AddNTimes - ld de, wOBPals1 - ld bc, 8 palettes - ld a, BANK(wOBPals1) - call FarCopyWRAM - - farcall LoadSpecialMapOBPalette - farcall LoadSpecialNPCPalette +; ld a, [wTimeOfDayPal] +; maskbits NUM_DAYTIMES +; ld bc, 8 palettes +; ld hl, MapObjectPals +; call AddNTimes +; ld de, wOBPals1 +; ld bc, 8 palettes +; ld a, BANK(wOBPals1) +; call FarCopyWRAM ld a, [wEnvironment] cp TOWN @@ -1416,6 +1413,38 @@ LoadMapPals: call FarCopyWRAM ret +CopySpritePal:: + push af + push bc + push hl + push de + ld a, [wTimeOfDayPal] + maskbits NUM_DAYTIMES + ld bc, 8 palettes + ld hl, MapObjectPals + call AddNTimes + ld a, [wNeededPalIndex] +; dec a + ld c, a +; push hl +; farcall _GetSpritePalette +; pop hl + ld bc, 1 palettes + call AddNTimes +; ld de, wOBPals2 + ld bc, 1 palettes + pop de + ld a, BANK(wOBPals1) + call FarCopyWRAM + call ApplyPals + ld a, TRUE + ldh [hCGBPalUpdate], a +.done + pop af + pop bc + pop hl + ret + INCLUDE "data/maps/environment_colors.asm" PartyMenuBGMobilePalette: diff --git a/engine/menus/intro_menu.asm b/engine/menus/intro_menu.asm index 76aee28b8..9341cf14b 100644 --- a/engine/menus/intro_menu.asm +++ b/engine/menus/intro_menu.asm @@ -62,6 +62,7 @@ NewGame: xor a ld [wDebugFlags], a call ResetWRAM + farcall ClearSavedObjPals call NewGame_ClearTilemapEtc call PlayerProfileSetup call OakSpeech @@ -332,6 +333,7 @@ Continue: call Continue_MobileAdapterMenu call CloseWindow call ClearTilemap + farcall ClearSavedObjPals ld c, 20 call DelayFrames farcall JumpRoamMons diff --git a/engine/overworld/dynamic_pals.asm b/engine/overworld/dynamic_pals.asm new file mode 100644 index 000000000..b63b60ede --- /dev/null +++ b/engine/overworld/dynamic_pals.asm @@ -0,0 +1,132 @@ +CheckForUsedObjPals:: + push hl + push bc + push de + ldh a, [rSVBK] + push af + ld a, BANK(wObjectStructs) + ldh [rSVBK], a + + xor a + ld [wUsedObjectPals], a + + ld de, wObjectStructs + ld b, NUM_OBJECT_STRUCTS + +.loop + ld hl, OBJECT_SPRITE + add hl, de + ld a, [hl] + and a + jr z, .no_sprite_skip + ld hl, OBJECT_PAL_INDEX + add hl, de + ld a, [hl] + ld [wNeededPalIndex], a + call MarkUsedPal + ld hl, OBJECT_PALETTE + add hl, de + ld [hl], a +.no_sprite_skip + dec b + jr z, .done + ld hl, OBJECT_LENGTH + add hl, de + ld d, h + ld e, l + jr .loop + +.done +; ld a, TRUE +; ldh [hCGBPalUpdate], a + pop af + ld [rSVBK], a + pop de + pop bc + pop hl + ret + +MarkUsedPal: + push hl + push bc + push de + + ; Check if pal is already loaded + ld b, 8 + ld c, 0 + ld hl, wLoadedObjPal0 +.loop + cp [hl] + jr z, .mark_in_use + inc hl + inc c + dec b + jr nz, .loop + + ld b, a + push bc + + ; Pal is not already loaded, find a empty pal slot. + ld b, 0 + ld c, 8 + ld hl, wUsedObjectPals + ld a, 1 + ld d, a +.search_again + ld a, d + and [hl] + jr z, .found_empty + ld a, d + rla + ld d, a + inc b + dec c + jr nz, .search_again +.found_empty + ld a, b + pop bc + + ld c, a + ld a, b + ld b, 0 + ld hl, wLoadedObjPal0 + add hl, bc + ld [hl], a + + push bc + ld a, c + ld bc, 1 palettes + ld hl, wOBPals1 + call AddNTimes + ld d, h + ld e, l + farcall CopySpritePal + pop bc + +.mark_in_use + push bc + ld hl, wUsedObjectPals + inc c + ld a, 1 +.loop3 + dec c + jr z, .load_hl + rla + jr .loop3 +.load_hl + or [hl] + ld [hl], a + pop bc + ld a, c + +.done + pop de + pop bc + pop hl + ret + +ClearSavedObjPals:: + ld hl, wUsedObjectPals + ld bc, wNeededPalIndex - wUsedObjectPals + ld a, -1 + jp ByteFill \ No newline at end of file diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm index 386997155..5e789a1e7 100644 --- a/engine/overworld/events.asm +++ b/engine/overworld/events.asm @@ -148,6 +148,7 @@ HandleMap: cp MAPSTATUS_HANDLE ret nz + farcall CheckForUsedObjPals call HandleMapObjects call NextOverworldFrame call HandleMapBackground diff --git a/engine/overworld/overworld.asm b/engine/overworld/overworld.asm index 026e344c4..409a7a24b 100644 --- a/engine/overworld/overworld.asm +++ b/engine/overworld/overworld.asm @@ -37,21 +37,6 @@ _ClearSprites: ; mobile ld [wSpriteFlags], a ret -RefreshSprites:: - call .Refresh - call LoadUsedSpritesGFX - ret - -.Refresh: - xor a - ld bc, wUsedSpritesEnd - wUsedSprites - ld hl, wUsedSprites - call ByteFill - call GetPlayerSprite - call AddMapSprites - call LoadAndSortSprites - ret - GetPlayerSprite: ; Get Chris or Kris's sprite. ld hl, ChrisStateSprites @@ -91,50 +76,56 @@ GetPlayerSprite: INCLUDE "data/sprites/player_sprites.asm" -AddMapSprites: - call GetMapEnvironment - call CheckOutdoorMap - jr z, .outdoor - call AddIndoorSprites - ret - -.outdoor - call AddOutdoorSprites +RefreshSprites:: + push hl + push de + push bc + call GetPlayerSprite + xor a + ld [hUsedSpriteIndex], a + call ReloadSpriteIndex + call LoadMiscTiles + pop bc + pop de + pop hl ret -AddIndoorSprites: - ld hl, wMap1ObjectSprite - ld a, 1 +ReloadSpriteIndex:: +; Reloads sprites using hUsedSpriteIndex. +; Used to reload variable sprites + ld hl, wObjectStructs + ld de, OBJECT_LENGTH + push bc + ld a, [hUsedSpriteIndex] + ld b, a + xor a .loop - push af + ld [hObjectStructIndex], a ld a, [hl] - call AddSpriteGFX - ld de, MAPOBJECT_LENGTH + and a + jr z, .done + bit 7, b + jr z, .continue + cp b + jr nz, .done +.continue + push hl + call GetSpriteVTile + pop hl + push hl + inc hl + inc hl + ld [hl], a + pop hl +.done add hl, de - pop af + ld a, [hObjectStructIndex] inc a - cp NUM_OBJECTS + cp NUM_OBJECT_STRUCTS jr nz, .loop + pop bc ret -AddOutdoorSprites: - ld a, [wMapGroup] - dec a - ld c, a - ld b, 0 - ld hl, OutdoorSprites - add hl, bc - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a -.loop - ld a, [hli] - and a - ret z - call AddSpriteGFX - jr .loop - LoadUsedSpritesGFX: ld a, MAPCALLBACK_SPRITES call RunMapCallback @@ -164,7 +155,7 @@ SafeGetSprite: pop hl ret -GetSprite: +GetSprite:: call GetMonSprite ret c @@ -300,11 +291,6 @@ _GetSpritePalette:: ld c, a ret -LoadAndSortSprites: - call LoadSpriteGFX - call ArrangeUsedSprites - ret - AddSpriteGFX: ; Add any new sprite ids to a list of graphics to be loaded. ; Return carry if the list is full. @@ -343,89 +329,6 @@ AddSpriteGFX: and a ret -LoadSpriteGFX: - - ld hl, wUsedSprites - ld b, SPRITE_GFX_LIST_CAPACITY -.loop - ld a, [hli] - and a - jr z, .done - push hl - call .LoadSprite - pop hl - ld [hli], a - dec b - jr nz, .loop - -.done - ret - -.LoadSprite: - push bc - call GetSprite - pop bc - ld a, l - ret - -ArrangeUsedSprites: -; Get the length of each sprite and space them out in VRAM. -; Crystal introduces a second table in VRAM bank 0. - - ld hl, wUsedSprites - ld c, SPRITE_GFX_LIST_CAPACITY - ld b, 0 -.FirstTableLength: -; Keep going until the end of the list. - ld a, [hli] - and a - jr z, .quit - - ld a, [hl] - call GetSpriteLength - -; Spill over into the second table after $80 tiles. - add b - cp $80 - jr z, .loop - jr nc, .SecondTable - -.loop - ld [hl], b - inc hl - ld b, a - -; Assumes the next table will be reached before c hits 0. - dec c - jr nz, .FirstTableLength - -.SecondTable: -; The second tile table starts at tile $80. - ld b, $80 - dec hl -.SecondTableLength: -; Keep going until the end of the list. - ld a, [hli] - and a - jr z, .quit - - ld a, [hl] - call GetSpriteLength - -; There are only two tables, so don't go any further than that. - add b - jr c, .quit - - ld [hl], b - ld b, a - inc hl - - dec c - jr nz, .SecondTableLength - -.quit - ret - GetSpriteLength: ; Return the length of sprite type a in tiles. @@ -447,7 +350,7 @@ GetSpriteLength: ld a, 4 ret -GetUsedSprites: +GetUsedSprites:: ld hl, wUsedSprites ld c, SPRITE_GFX_LIST_CAPACITY @@ -483,7 +386,7 @@ GetUsedSprites: .done ret -GetUsedSprite: +GetUsedSprite:: ldh a, [hUsedSpriteIndex] call SafeGetSprite ldh a, [hUsedSpriteTile] @@ -557,6 +460,7 @@ endr call Get2bpp pop af ldh [rVBK], a + ;farcall CopySpritePal ret LoadEmote:: @@ -592,6 +496,4 @@ INCLUDE "data/sprites/emotes.asm" INCLUDE "data/sprites/sprite_mons.asm" -INCLUDE "data/maps/outdoor_sprites.asm" - INCLUDE "data/sprites/sprites.asm" diff --git a/engine/overworld/player_object.asm b/engine/overworld/player_object.asm index 4dda7f662..aa7caf636 100644 --- a/engine/overworld/player_object.asm +++ b/engine/overworld/player_object.asm @@ -421,7 +421,7 @@ CopyTempObjectToObjectStruct: call CopySpriteMovementData ld a, [wTempObjectCopyPalette] - ld hl, OBJECT_PALETTE + ld hl, OBJECT_PAL_INDEX add hl, de or [hl] ld [hl], a diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm index 193dc6f66..55a0b9ada 100644 --- a/engine/overworld/scripting.asm +++ b/engine/overworld/scripting.asm @@ -958,10 +958,12 @@ Script_variablesprite: call GetScriptByte ld e, a ld d, 0 + ld [hUsedSpriteIndex], a ld hl, wVariableSprites add hl, de call GetScriptByte ld [hl], a + farcall ReloadSpriteIndex ret Script_appear: diff --git a/home/map_objects.asm b/home/map_objects.asm index b2129e1cb..20eb8e441 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -16,36 +16,37 @@ GetSpritePalette:: GetSpriteVTile:: push hl + push de push bc - ld hl, wUsedSprites + 2 - ld c, SPRITE_GFX_LIST_CAPACITY - 1 + ld [hUsedSpriteIndex], a + farcall GetSprite + ld hl, wSpriteFlags + res 5, [hl] + ld a, [hObjectStructIndex] + cp FIRST_VRAM1_OBJECT_STRUCT + jr c, .continue + set 5, [hl] + sub FIRST_VRAM1_OBJECT_STRUCT +.continue + add a, a + add a, a + ld b, a + add a, b + add a, b + ld [hUsedSpriteTile], a + push af + farcall GetUsedSprite + pop af ld b, a - ldh a, [hMapObjectIndex] - cp 0 - jr z, .nope - ld a, b -.loop - cp [hl] - jr z, .found - inc hl - inc hl - dec c - jr nz, .loop - ld a, [wUsedSprites + 1] - scf - jr .done - -.nope - ld a, [wUsedSprites + 1] - jr .done - -.found - inc hl xor a - ld a, [hl] - -.done + ld a, b + ld hl, wSpriteFlags + bit 5, [hl] + jr z, .using_vbk1 + or $80 +.using_vbk1 pop bc + pop de pop hl ret diff --git a/macros/ram.asm b/macros/ram.asm index a7b670860..67f7599f9 100644 --- a/macros/ram.asm +++ b/macros/ram.asm @@ -368,7 +368,8 @@ MACRO object_struct \1Field1e:: ds 1 \1JumpHeight:: db \1Range:: db - ds 7 +\1PalIndex:: db + ds 6 \1StructEnd:: ENDM diff --git a/main.asm b/main.asm index 2a4ee3d3f..a9a074eef 100644 --- a/main.asm +++ b/main.asm @@ -775,6 +775,11 @@ SECTION "Crystal Events", ROMX INCLUDE "engine/events/battle_tower/load_trainer.asm" INCLUDE "engine/events/odd_egg.asm" + +SECTION "Dynamic Pals", ROMX + +INCLUDE "engine/overworld/dynamic_pals.asm" + ; Regular SECTION "Regular Mode", ROMX diff --git a/ram/wram.asm b/ram/wram.asm index e1f8bbc35..d61244844 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -3004,7 +3004,13 @@ endr wStoneTableAddress:: dw - ds 24 +wUsedObjectPals:: db +for n, 8 +wLoadedObjPal{d:n}:: db +endr + +wNeededPalIndex:: db + ds 14 wBerryPocketCursor:: db From c734c32b26cf7e7db72e17c4e8feaa559260ba8b Mon Sep 17 00:00:00 2001 From: vulcandth Date: Tue, 28 May 2024 17:55:12 -0500 Subject: [PATCH 02/11] Revert "First attempt at Dynamic Objects and Pals" This reverts commit 28ee10d23aac261b398106592f0463f82e37174f. --- constants/map_object_constants.asm | 4 +- data/maps/outdoor_sprites.asm | 369 +++++++++++++++++++++++++++++ engine/gfx/color.asm | 53 +---- engine/menus/intro_menu.asm | 2 - engine/overworld/dynamic_pals.asm | 132 ----------- engine/overworld/events.asm | 1 - engine/overworld/overworld.asm | 188 +++++++++++---- engine/overworld/player_object.asm | 2 +- engine/overworld/scripting.asm | 2 - home/map_objects.asm | 53 ++--- macros/ram.asm | 3 +- main.asm | 5 - ram/wram.asm | 8 +- 13 files changed, 554 insertions(+), 268 deletions(-) create mode 100644 data/maps/outdoor_sprites.asm delete mode 100644 engine/overworld/dynamic_pals.asm diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm index 45b277a2b..4970659c9 100644 --- a/constants/map_object_constants.asm +++ b/constants/map_object_constants.asm @@ -33,11 +33,9 @@ DEF OBJECT_1D rb ; 1d DEF OBJECT_1E rb ; 1e DEF OBJECT_JUMP_HEIGHT rb ; 1f DEF OBJECT_RANGE rb ; 20 -DEF OBJECT_PAL_INDEX rb ; 21 - rb_skip 6 + rb_skip 7 DEF OBJECT_LENGTH EQU _RS DEF NUM_OBJECT_STRUCTS EQU 13 ; see wObjectStructs -DEF FIRST_VRAM1_OBJECT_STRUCT EQU 10 ; object_struct OBJECT_DIRECTION values DEF OW_DOWN EQU DOWN << 2 diff --git a/data/maps/outdoor_sprites.asm b/data/maps/outdoor_sprites.asm new file mode 100644 index 000000000..f63bb0f67 --- /dev/null +++ b/data/maps/outdoor_sprites.asm @@ -0,0 +1,369 @@ +; Valid sprite IDs for each map group. +; Maps with environment ROUTE or TOWN can only use these sprites. + +OutdoorSprites: +; entries correspond to MAPGROUP_* constants + table_width 2, OutdoorSprites + dw OlivineGroupSprites + dw MahoganyGroupSprites + dw DungeonsGroupSprites + dw EcruteakGroupSprites + dw BlackthornGroupSprites + dw CinnabarGroupSprites + dw CeruleanGroupSprites + dw AzaleaGroupSprites + dw LakeOfRageGroupSprites + dw VioletGroupSprites + dw GoldenrodGroupSprites + dw VermilionGroupSprites + dw PalletGroupSprites + dw PewterGroupSprites + dw FastShipGroupSprites + dw IndigoGroupSprites + dw FuchsiaGroupSprites + dw LavenderGroupSprites + dw SilverGroupSprites + dw CableClubGroupSprites + dw CeladonGroupSprites + dw CianwoodGroupSprites + dw ViridianGroupSprites + dw NewBarkGroupSprites + dw SaffronGroupSprites + dw CherrygroveGroupSprites + dw SafariZoneGateGroupSprites + dw SafariZoneGroupSprites + assert_table_length NUM_MAP_GROUPS + +; Route1 and ViridianCity are connected +; Route2North and PewterCity are connected +; PalletTown and Route21 are connected +PewterGroupSprites: +; Route3, PewterCity + db SPRITE_TEACHER + db SPRITE_FISHER + db SPRITE_YOUNGSTER + db SPRITE_COOLTRAINER_M + db SPRITE_GRAMPS + db SPRITE_BUG_CATCHER + db SPRITE_COOLTRAINER_F + db SPRITE_BLACK_BELT + db SPRITE_POKEFAN_M + ; max 9 of 9 walking sprites + db SPRITE_POKE_BALL + db SPRITE_BERRY + db SPRITE_APRICORN + db 0 ; end +ViridianGroupSprites: +; Route2South, Route22, ViridianCity +PalletGroupSprites: +; Route1, PalletTown +CinnabarGroupSprites: +; Route19, Route20, Route21, CinnabarIsland + db SPRITE_TEACHER + db SPRITE_FISHER + db SPRITE_YOUNGSTER + db SPRITE_GRAMPS + db SPRITE_BUG_CATCHER + db SPRITE_LASS + db SPRITE_COOLTRAINER_F + db SPRITE_SWIMMER_GIRL + db SPRITE_SWIMMER_GUY + ; max 9 of 9 walking sprites + db SPRITE_BLUE + db SPRITE_COOLTRAINER_M + db SPRITE_POKE_BALL + db SPRITE_BERRY + db SPRITE_APRICORN + db SPRITE_ROCK + db 0 ; end + +; CeruleanCity and Route5 are connected +CeruleanGroupSprites: +; Route4, Route9, Route10North, Route24, Route25, CeruleanCity +SaffronGroupSprites: +; Route5, SaffronCity + db SPRITE_COOLTRAINER_M + db SPRITE_SUPER_NERD + db SPRITE_COOLTRAINER_F + db SPRITE_FISHER + db SPRITE_YOUNGSTER + db SPRITE_LASS + db SPRITE_POKEFAN_M + db SPRITE_ROCKET + db SPRITE_MISTY + ; max 9 of 9 walking sprites + db SPRITE_POKE_BALL + db SPRITE_SLOWBRO + db SPRITE_ZAPDOS + db 0 ; end + +VermilionGroupSprites: +; Route6, Route11, VermilionCity + db SPRITE_POKEFAN_M + db SPRITE_YOUNGSTER + db SPRITE_TEACHER + db SPRITE_SUPER_NERD + db SPRITE_FISHER + db SPRITE_LASS + ; 6 of max 9 walking sprites + db SPRITE_GRAMPS + db SPRITE_BIG_SNORLAX + db SPRITE_MACHOP + db SPRITE_TWIN + db SPRITE_POKE_BALL + db SPRITE_BERRY + db SPRITE_APRICORN + db 0 ; end + +CeladonGroupSprites: +; Route7, Route16, Route17, CeladonCity + db SPRITE_FISHER + db SPRITE_TEACHER + db SPRITE_GRAMPS + db SPRITE_YOUNGSTER + db SPRITE_LASS + db SPRITE_BIKER + ; 6 of max 9 walking sprites + db SPRITE_POLIWRATH + db SPRITE_POKE_BALL + db SPRITE_BERRY + db 0 ; end + +; Route12 and Route13 are connected +LavenderGroupSprites: +; Route8, Route12, Route10South, LavenderTown +FuchsiaGroupSprites: +; Route13, Route14, Route15, Route18, FuchsiaCity + db SPRITE_POKEFAN_M + db SPRITE_POKEFAN_F + db SPRITE_YOUNGSTER + db SPRITE_FISHER + db SPRITE_TEACHER + db SPRITE_SUPER_NERD + db SPRITE_BIKER + db SPRITE_GENTLEMAN + db SPRITE_LASS + ; 9 of max 9 walking sprites + db SPRITE_GRAMPS + db SPRITE_ZAPDOS + db SPRITE_TWIN + db SPRITE_POKE_BALL + db SPRITE_BERRY + db SPRITE_APRICORN + db 0 ; end + +IndigoGroupSprites: +; Route23 + ; 0 of max 9 walking sprites + db 0 ; end + +; Route29 and CherrygroveCity are connected +NewBarkGroupSprites: +; Route26, Route27, Route29, NewBarkTown +CherrygroveGroupSprites: +; Route30, Route31, CherrygroveCity + db SPRITE_RIVAL + db SPRITE_TEACHER + db SPRITE_FISHER + db SPRITE_COOLTRAINER_M + db SPRITE_YOUNGSTER + db SPRITE_GRAMPS + db SPRITE_BUG_CATCHER + db SPRITE_COOLTRAINER_F + ; max 8 of 9 walking sprites + db SPRITE_PIDGEY + db SPRITE_RATTATA_UP + db SPRITE_POKE_BALL + db SPRITE_BERRY + db SPRITE_APRICORN + db 0 ; end + +; Route37 and EcruteakCity are connected +VioletGroupSprites: +; Route32, Route35, Route36, Route37, VioletCity +EcruteakGroupSprites: +; EcruteakCity + db SPRITE_FISHER + db SPRITE_LASS + db SPRITE_OFFICER + db SPRITE_GRAMPS + db SPRITE_YOUNGSTER + db SPRITE_COOLTRAINER_M + db SPRITE_BUG_CATCHER + db SPRITE_SUPER_NERD + ; 8 of max 9 walking sprites + db SPRITE_TWIN + db SPRITE_SUDOWOODO + db SPRITE_POKE_BALL + db SPRITE_BERRY + db SPRITE_APRICORN + db SPRITE_SUICUNE + db 0 ; end + +AzaleaGroupSprites: +; Route33, AzaleaTown + db SPRITE_GRAMPS + db SPRITE_YOUNGSTER + db SPRITE_POKEFAN_M + db SPRITE_TEACHER + db SPRITE_ROCKET + db SPRITE_LASS + db SPRITE_RIVAL + ; 7 of max 9 walking sprites + db SPRITE_BERRY + db SPRITE_APRICORN + db SPRITE_SLOWPOKE + db SPRITE_KURT + db 0 ; end + +GoldenrodGroupSprites: +; Route34, GoldenrodCity + db SPRITE_GRAMPS + db SPRITE_YOUNGSTER + db SPRITE_OFFICER + db SPRITE_POKEFAN_M + db SPRITE_COOLTRAINER_F + db SPRITE_ROCKET + db SPRITE_LASS + ; 7 of max 9 walking sprites + db SPRITE_DAY_CARE_MON_1 + db SPRITE_DAY_CARE_MON_2 + db SPRITE_POKE_BALL + db 0 ; end + +; OlivineCity and Route40 are connected +OlivineGroupSprites: +; Route38, Route39, OlivineCity +CianwoodGroupSprites: +; Route40, Route41, CianwoodCity, BattleTowerOutside + db SPRITE_RIVAL + db SPRITE_POKEFAN_M + db SPRITE_LASS + db SPRITE_SWIMMER_GIRL + db SPRITE_SAILOR + db SPRITE_POKEFAN_F + db SPRITE_SUPER_NERD + db SPRITE_SWIMMER_GUY + db SPRITE_GENTLEMAN + ; 9 of max 9 walking sprites + db SPRITE_BEAUTY + db SPRITE_MILTANK + db SPRITE_BERRY + db SPRITE_APRICORN + db SPRITE_ROCK + db SPRITE_YOUNGSTER ; non-walking version of SPRITE_YOUNGSTER + db SPRITE_SUICUNE + db 0 ; end + +MahoganyGroupSprites: +; Route42, Route44, MahoganyTown + db SPRITE_GRAMPS + db SPRITE_YOUNGSTER + db SPRITE_LASS + db SPRITE_SUPER_NERD + db SPRITE_COOLTRAINER_M + db SPRITE_POKEFAN_M + db SPRITE_COOLTRAINER_F + db SPRITE_FISHER + ; 8 of max 9 walking sprites + db SPRITE_BERRY + db SPRITE_APRICORN + db SPRITE_POKE_BALL + db SPRITE_SUICUNE + db 0 ; end + +LakeOfRageGroupSprites: +; Route43, LakeOfRage + db SPRITE_LANCE + db SPRITE_GRAMPS + db SPRITE_SUPER_NERD + db SPRITE_COOLTRAINER_F + db SPRITE_FISHER + db SPRITE_COOLTRAINER_M + db SPRITE_LASS + db SPRITE_YOUNGSTER + ; 8 of max 9 walking sprites + db SPRITE_GYARADOS + db SPRITE_BERRY + db SPRITE_APRICORN + db SPRITE_POKE_BALL + db 0 ; end + +BlackthornGroupSprites: +; Route45, Route46, BlackthornCity + db SPRITE_GRAMPS + db SPRITE_YOUNGSTER + db SPRITE_LASS + db SPRITE_SUPER_NERD + db SPRITE_COOLTRAINER_M + db SPRITE_POKEFAN_M + db SPRITE_BLACK_BELT + db SPRITE_COOLTRAINER_F + ; 8 of max 9 walking sprites + db SPRITE_BERRY + db SPRITE_APRICORN + db SPRITE_POKE_BALL + db 0 ; end + +SilverGroupSprites: +; Route28, SilverCaveOutside + ; 0 of max 9 walking sprites + db 0 ; end + +DungeonsGroupSprites: +; NationalPark, NationalParkBugContest, RuinsOfAlphOutside + db SPRITE_LASS + db SPRITE_POKEFAN_F + db SPRITE_TEACHER + db SPRITE_YOUNGSTER + db SPRITE_POKEFAN_M + db SPRITE_COOLTRAINER_M + db SPRITE_FISHER + db SPRITE_SCIENTIST + db SPRITE_BUG_CATCHER + ; 8 of max 9 walking sprites + db SPRITE_GAMEBOY_KID + db SPRITE_PERSIAN + db SPRITE_POKE_BALL + db 0 ; end + +FastShipGroupSprites: +; OlivinePort, VermilionPort, MountMoonSquare, TinTowerRoof + db SPRITE_SAILOR + db SPRITE_FISHING_GURU + db SPRITE_SUPER_NERD + db SPRITE_COOLTRAINER_F + db SPRITE_YOUNGSTER + ; 5 of max 9 walking sprites + db SPRITE_HO_OH + db SPRITE_CLEFAIRY_MOVE + db SPRITE_ROCK + db 0 ; end + +CableClubGroupSprites: +; (no outdoor maps) + ; 0 of max 9 walking sprites + db 0 ; end + +SafariZoneGateGroupSprites: +SafariZoneGroupSprites: +; Route47, Route48, SafariZoneGate, CliffEdgeCave, CliffEdgeGate + db SPRITE_TWIN + db SPRITE_SUPER_NERD + db SPRITE_YOUNGSTER + db SPRITE_LASS + db SPRITE_POKEFAN_M + db SPRITE_JIGGLYPUFF + db SPRITE_KANGASKHAN + db SPRITE_BUTTERFREE + db SPRITE_TEACHER + ; 7 of max 9 walking sprites + db SPRITE_SLOWPOKE + db SPRITE_GENTLEMAN + db SPRITE_POKEFAN_F + db SPRITE_GRAMPS + db SPRITE_COOLTRAINER_M + db SPRITE_COOLTRAINER_F + db SPRITE_BEAUTY + db SPRITE_POKE_BALL + db SPRITE_OLD_LINK_RECEPTIONIST diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm index bdae0afec..d667c8c24 100644 --- a/engine/gfx/color.asm +++ b/engine/gfx/color.asm @@ -1305,15 +1305,18 @@ LoadMapPals: ldh [rSVBK], a .got_pals -; ld a, [wTimeOfDayPal] -; maskbits NUM_DAYTIMES -; ld bc, 8 palettes -; ld hl, MapObjectPals -; call AddNTimes -; ld de, wOBPals1 -; ld bc, 8 palettes -; ld a, BANK(wOBPals1) -; call FarCopyWRAM + ld a, [wTimeOfDayPal] + maskbits NUM_DAYTIMES + ld bc, 8 palettes + ld hl, MapObjectPals + call AddNTimes + ld de, wOBPals1 + ld bc, 8 palettes + ld a, BANK(wOBPals1) + call FarCopyWRAM + + farcall LoadSpecialMapOBPalette + farcall LoadSpecialNPCPalette ld a, [wEnvironment] cp TOWN @@ -1413,38 +1416,6 @@ LoadMapPals: call FarCopyWRAM ret -CopySpritePal:: - push af - push bc - push hl - push de - ld a, [wTimeOfDayPal] - maskbits NUM_DAYTIMES - ld bc, 8 palettes - ld hl, MapObjectPals - call AddNTimes - ld a, [wNeededPalIndex] -; dec a - ld c, a -; push hl -; farcall _GetSpritePalette -; pop hl - ld bc, 1 palettes - call AddNTimes -; ld de, wOBPals2 - ld bc, 1 palettes - pop de - ld a, BANK(wOBPals1) - call FarCopyWRAM - call ApplyPals - ld a, TRUE - ldh [hCGBPalUpdate], a -.done - pop af - pop bc - pop hl - ret - INCLUDE "data/maps/environment_colors.asm" PartyMenuBGMobilePalette: diff --git a/engine/menus/intro_menu.asm b/engine/menus/intro_menu.asm index 9341cf14b..76aee28b8 100644 --- a/engine/menus/intro_menu.asm +++ b/engine/menus/intro_menu.asm @@ -62,7 +62,6 @@ NewGame: xor a ld [wDebugFlags], a call ResetWRAM - farcall ClearSavedObjPals call NewGame_ClearTilemapEtc call PlayerProfileSetup call OakSpeech @@ -333,7 +332,6 @@ Continue: call Continue_MobileAdapterMenu call CloseWindow call ClearTilemap - farcall ClearSavedObjPals ld c, 20 call DelayFrames farcall JumpRoamMons diff --git a/engine/overworld/dynamic_pals.asm b/engine/overworld/dynamic_pals.asm deleted file mode 100644 index b63b60ede..000000000 --- a/engine/overworld/dynamic_pals.asm +++ /dev/null @@ -1,132 +0,0 @@ -CheckForUsedObjPals:: - push hl - push bc - push de - ldh a, [rSVBK] - push af - ld a, BANK(wObjectStructs) - ldh [rSVBK], a - - xor a - ld [wUsedObjectPals], a - - ld de, wObjectStructs - ld b, NUM_OBJECT_STRUCTS - -.loop - ld hl, OBJECT_SPRITE - add hl, de - ld a, [hl] - and a - jr z, .no_sprite_skip - ld hl, OBJECT_PAL_INDEX - add hl, de - ld a, [hl] - ld [wNeededPalIndex], a - call MarkUsedPal - ld hl, OBJECT_PALETTE - add hl, de - ld [hl], a -.no_sprite_skip - dec b - jr z, .done - ld hl, OBJECT_LENGTH - add hl, de - ld d, h - ld e, l - jr .loop - -.done -; ld a, TRUE -; ldh [hCGBPalUpdate], a - pop af - ld [rSVBK], a - pop de - pop bc - pop hl - ret - -MarkUsedPal: - push hl - push bc - push de - - ; Check if pal is already loaded - ld b, 8 - ld c, 0 - ld hl, wLoadedObjPal0 -.loop - cp [hl] - jr z, .mark_in_use - inc hl - inc c - dec b - jr nz, .loop - - ld b, a - push bc - - ; Pal is not already loaded, find a empty pal slot. - ld b, 0 - ld c, 8 - ld hl, wUsedObjectPals - ld a, 1 - ld d, a -.search_again - ld a, d - and [hl] - jr z, .found_empty - ld a, d - rla - ld d, a - inc b - dec c - jr nz, .search_again -.found_empty - ld a, b - pop bc - - ld c, a - ld a, b - ld b, 0 - ld hl, wLoadedObjPal0 - add hl, bc - ld [hl], a - - push bc - ld a, c - ld bc, 1 palettes - ld hl, wOBPals1 - call AddNTimes - ld d, h - ld e, l - farcall CopySpritePal - pop bc - -.mark_in_use - push bc - ld hl, wUsedObjectPals - inc c - ld a, 1 -.loop3 - dec c - jr z, .load_hl - rla - jr .loop3 -.load_hl - or [hl] - ld [hl], a - pop bc - ld a, c - -.done - pop de - pop bc - pop hl - ret - -ClearSavedObjPals:: - ld hl, wUsedObjectPals - ld bc, wNeededPalIndex - wUsedObjectPals - ld a, -1 - jp ByteFill \ No newline at end of file diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm index 5e789a1e7..386997155 100644 --- a/engine/overworld/events.asm +++ b/engine/overworld/events.asm @@ -148,7 +148,6 @@ HandleMap: cp MAPSTATUS_HANDLE ret nz - farcall CheckForUsedObjPals call HandleMapObjects call NextOverworldFrame call HandleMapBackground diff --git a/engine/overworld/overworld.asm b/engine/overworld/overworld.asm index 409a7a24b..026e344c4 100644 --- a/engine/overworld/overworld.asm +++ b/engine/overworld/overworld.asm @@ -37,6 +37,21 @@ _ClearSprites: ; mobile ld [wSpriteFlags], a ret +RefreshSprites:: + call .Refresh + call LoadUsedSpritesGFX + ret + +.Refresh: + xor a + ld bc, wUsedSpritesEnd - wUsedSprites + ld hl, wUsedSprites + call ByteFill + call GetPlayerSprite + call AddMapSprites + call LoadAndSortSprites + ret + GetPlayerSprite: ; Get Chris or Kris's sprite. ld hl, ChrisStateSprites @@ -76,56 +91,50 @@ GetPlayerSprite: INCLUDE "data/sprites/player_sprites.asm" -RefreshSprites:: - push hl - push de - push bc - call GetPlayerSprite - xor a - ld [hUsedSpriteIndex], a - call ReloadSpriteIndex - call LoadMiscTiles - pop bc - pop de - pop hl +AddMapSprites: + call GetMapEnvironment + call CheckOutdoorMap + jr z, .outdoor + call AddIndoorSprites ret -ReloadSpriteIndex:: -; Reloads sprites using hUsedSpriteIndex. -; Used to reload variable sprites - ld hl, wObjectStructs - ld de, OBJECT_LENGTH - push bc - ld a, [hUsedSpriteIndex] - ld b, a - xor a +.outdoor + call AddOutdoorSprites + ret + +AddIndoorSprites: + ld hl, wMap1ObjectSprite + ld a, 1 .loop - ld [hObjectStructIndex], a + push af ld a, [hl] - and a - jr z, .done - bit 7, b - jr z, .continue - cp b - jr nz, .done -.continue - push hl - call GetSpriteVTile - pop hl - push hl - inc hl - inc hl - ld [hl], a - pop hl -.done + call AddSpriteGFX + ld de, MAPOBJECT_LENGTH add hl, de - ld a, [hObjectStructIndex] + pop af inc a - cp NUM_OBJECT_STRUCTS + cp NUM_OBJECTS jr nz, .loop - pop bc ret +AddOutdoorSprites: + ld a, [wMapGroup] + dec a + ld c, a + ld b, 0 + ld hl, OutdoorSprites + add hl, bc + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a +.loop + ld a, [hli] + and a + ret z + call AddSpriteGFX + jr .loop + LoadUsedSpritesGFX: ld a, MAPCALLBACK_SPRITES call RunMapCallback @@ -155,7 +164,7 @@ SafeGetSprite: pop hl ret -GetSprite:: +GetSprite: call GetMonSprite ret c @@ -291,6 +300,11 @@ _GetSpritePalette:: ld c, a ret +LoadAndSortSprites: + call LoadSpriteGFX + call ArrangeUsedSprites + ret + AddSpriteGFX: ; Add any new sprite ids to a list of graphics to be loaded. ; Return carry if the list is full. @@ -329,6 +343,89 @@ AddSpriteGFX: and a ret +LoadSpriteGFX: + + ld hl, wUsedSprites + ld b, SPRITE_GFX_LIST_CAPACITY +.loop + ld a, [hli] + and a + jr z, .done + push hl + call .LoadSprite + pop hl + ld [hli], a + dec b + jr nz, .loop + +.done + ret + +.LoadSprite: + push bc + call GetSprite + pop bc + ld a, l + ret + +ArrangeUsedSprites: +; Get the length of each sprite and space them out in VRAM. +; Crystal introduces a second table in VRAM bank 0. + + ld hl, wUsedSprites + ld c, SPRITE_GFX_LIST_CAPACITY + ld b, 0 +.FirstTableLength: +; Keep going until the end of the list. + ld a, [hli] + and a + jr z, .quit + + ld a, [hl] + call GetSpriteLength + +; Spill over into the second table after $80 tiles. + add b + cp $80 + jr z, .loop + jr nc, .SecondTable + +.loop + ld [hl], b + inc hl + ld b, a + +; Assumes the next table will be reached before c hits 0. + dec c + jr nz, .FirstTableLength + +.SecondTable: +; The second tile table starts at tile $80. + ld b, $80 + dec hl +.SecondTableLength: +; Keep going until the end of the list. + ld a, [hli] + and a + jr z, .quit + + ld a, [hl] + call GetSpriteLength + +; There are only two tables, so don't go any further than that. + add b + jr c, .quit + + ld [hl], b + ld b, a + inc hl + + dec c + jr nz, .SecondTableLength + +.quit + ret + GetSpriteLength: ; Return the length of sprite type a in tiles. @@ -350,7 +447,7 @@ GetSpriteLength: ld a, 4 ret -GetUsedSprites:: +GetUsedSprites: ld hl, wUsedSprites ld c, SPRITE_GFX_LIST_CAPACITY @@ -386,7 +483,7 @@ GetUsedSprites:: .done ret -GetUsedSprite:: +GetUsedSprite: ldh a, [hUsedSpriteIndex] call SafeGetSprite ldh a, [hUsedSpriteTile] @@ -460,7 +557,6 @@ endr call Get2bpp pop af ldh [rVBK], a - ;farcall CopySpritePal ret LoadEmote:: @@ -496,4 +592,6 @@ INCLUDE "data/sprites/emotes.asm" INCLUDE "data/sprites/sprite_mons.asm" +INCLUDE "data/maps/outdoor_sprites.asm" + INCLUDE "data/sprites/sprites.asm" diff --git a/engine/overworld/player_object.asm b/engine/overworld/player_object.asm index aa7caf636..4dda7f662 100644 --- a/engine/overworld/player_object.asm +++ b/engine/overworld/player_object.asm @@ -421,7 +421,7 @@ CopyTempObjectToObjectStruct: call CopySpriteMovementData ld a, [wTempObjectCopyPalette] - ld hl, OBJECT_PAL_INDEX + ld hl, OBJECT_PALETTE add hl, de or [hl] ld [hl], a diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm index 55a0b9ada..193dc6f66 100644 --- a/engine/overworld/scripting.asm +++ b/engine/overworld/scripting.asm @@ -958,12 +958,10 @@ Script_variablesprite: call GetScriptByte ld e, a ld d, 0 - ld [hUsedSpriteIndex], a ld hl, wVariableSprites add hl, de call GetScriptByte ld [hl], a - farcall ReloadSpriteIndex ret Script_appear: diff --git a/home/map_objects.asm b/home/map_objects.asm index 20eb8e441..b2129e1cb 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -16,37 +16,36 @@ GetSpritePalette:: GetSpriteVTile:: push hl - push de push bc - ld [hUsedSpriteIndex], a - farcall GetSprite - ld hl, wSpriteFlags - res 5, [hl] - ld a, [hObjectStructIndex] - cp FIRST_VRAM1_OBJECT_STRUCT - jr c, .continue - set 5, [hl] - sub FIRST_VRAM1_OBJECT_STRUCT -.continue - add a, a - add a, a + ld hl, wUsedSprites + 2 + ld c, SPRITE_GFX_LIST_CAPACITY - 1 ld b, a - add a, b - add a, b - ld [hUsedSpriteTile], a - push af - farcall GetUsedSprite - pop af - ld b, a - xor a + ldh a, [hMapObjectIndex] + cp 0 + jr z, .nope ld a, b - ld hl, wSpriteFlags - bit 5, [hl] - jr z, .using_vbk1 - or $80 -.using_vbk1 +.loop + cp [hl] + jr z, .found + inc hl + inc hl + dec c + jr nz, .loop + ld a, [wUsedSprites + 1] + scf + jr .done + +.nope + ld a, [wUsedSprites + 1] + jr .done + +.found + inc hl + xor a + ld a, [hl] + +.done pop bc - pop de pop hl ret diff --git a/macros/ram.asm b/macros/ram.asm index 67f7599f9..a7b670860 100644 --- a/macros/ram.asm +++ b/macros/ram.asm @@ -368,8 +368,7 @@ MACRO object_struct \1Field1e:: ds 1 \1JumpHeight:: db \1Range:: db -\1PalIndex:: db - ds 6 + ds 7 \1StructEnd:: ENDM diff --git a/main.asm b/main.asm index a9a074eef..2a4ee3d3f 100644 --- a/main.asm +++ b/main.asm @@ -775,11 +775,6 @@ SECTION "Crystal Events", ROMX INCLUDE "engine/events/battle_tower/load_trainer.asm" INCLUDE "engine/events/odd_egg.asm" - -SECTION "Dynamic Pals", ROMX - -INCLUDE "engine/overworld/dynamic_pals.asm" - ; Regular SECTION "Regular Mode", ROMX diff --git a/ram/wram.asm b/ram/wram.asm index d61244844..e1f8bbc35 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -3004,13 +3004,7 @@ endr wStoneTableAddress:: dw -wUsedObjectPals:: db -for n, 8 -wLoadedObjPal{d:n}:: db -endr - -wNeededPalIndex:: db - ds 14 + ds 24 wBerryPocketCursor:: db From 2a7f3d67abf80498010023974dad52f1cd5ccec0 Mon Sep 17 00:00:00 2001 From: vulcandth Date: Sat, 12 Nov 2022 21:14:44 -0600 Subject: [PATCH 03/11] Dynamic Sprite Reload Co-Authored-By: Fredrik Ljungdahl --- constants/map_object_constants.asm | 1 + data/maps/outdoor_sprites.asm | 369 ----------------------------- engine/overworld/overworld.asm | 185 ++++----------- engine/overworld/scripting.asm | 2 + home/map_objects.asm | 53 +++-- 5 files changed, 73 insertions(+), 537 deletions(-) delete mode 100644 data/maps/outdoor_sprites.asm diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm index 4970659c9..aaa9751c6 100644 --- a/constants/map_object_constants.asm +++ b/constants/map_object_constants.asm @@ -36,6 +36,7 @@ DEF OBJECT_RANGE rb ; 20 rb_skip 7 DEF OBJECT_LENGTH EQU _RS DEF NUM_OBJECT_STRUCTS EQU 13 ; see wObjectStructs +DEF FIRST_VRAM1_OBJECT_STRUCT EQU 10 ; object_struct OBJECT_DIRECTION values DEF OW_DOWN EQU DOWN << 2 diff --git a/data/maps/outdoor_sprites.asm b/data/maps/outdoor_sprites.asm deleted file mode 100644 index f63bb0f67..000000000 --- a/data/maps/outdoor_sprites.asm +++ /dev/null @@ -1,369 +0,0 @@ -; Valid sprite IDs for each map group. -; Maps with environment ROUTE or TOWN can only use these sprites. - -OutdoorSprites: -; entries correspond to MAPGROUP_* constants - table_width 2, OutdoorSprites - dw OlivineGroupSprites - dw MahoganyGroupSprites - dw DungeonsGroupSprites - dw EcruteakGroupSprites - dw BlackthornGroupSprites - dw CinnabarGroupSprites - dw CeruleanGroupSprites - dw AzaleaGroupSprites - dw LakeOfRageGroupSprites - dw VioletGroupSprites - dw GoldenrodGroupSprites - dw VermilionGroupSprites - dw PalletGroupSprites - dw PewterGroupSprites - dw FastShipGroupSprites - dw IndigoGroupSprites - dw FuchsiaGroupSprites - dw LavenderGroupSprites - dw SilverGroupSprites - dw CableClubGroupSprites - dw CeladonGroupSprites - dw CianwoodGroupSprites - dw ViridianGroupSprites - dw NewBarkGroupSprites - dw SaffronGroupSprites - dw CherrygroveGroupSprites - dw SafariZoneGateGroupSprites - dw SafariZoneGroupSprites - assert_table_length NUM_MAP_GROUPS - -; Route1 and ViridianCity are connected -; Route2North and PewterCity are connected -; PalletTown and Route21 are connected -PewterGroupSprites: -; Route3, PewterCity - db SPRITE_TEACHER - db SPRITE_FISHER - db SPRITE_YOUNGSTER - db SPRITE_COOLTRAINER_M - db SPRITE_GRAMPS - db SPRITE_BUG_CATCHER - db SPRITE_COOLTRAINER_F - db SPRITE_BLACK_BELT - db SPRITE_POKEFAN_M - ; max 9 of 9 walking sprites - db SPRITE_POKE_BALL - db SPRITE_BERRY - db SPRITE_APRICORN - db 0 ; end -ViridianGroupSprites: -; Route2South, Route22, ViridianCity -PalletGroupSprites: -; Route1, PalletTown -CinnabarGroupSprites: -; Route19, Route20, Route21, CinnabarIsland - db SPRITE_TEACHER - db SPRITE_FISHER - db SPRITE_YOUNGSTER - db SPRITE_GRAMPS - db SPRITE_BUG_CATCHER - db SPRITE_LASS - db SPRITE_COOLTRAINER_F - db SPRITE_SWIMMER_GIRL - db SPRITE_SWIMMER_GUY - ; max 9 of 9 walking sprites - db SPRITE_BLUE - db SPRITE_COOLTRAINER_M - db SPRITE_POKE_BALL - db SPRITE_BERRY - db SPRITE_APRICORN - db SPRITE_ROCK - db 0 ; end - -; CeruleanCity and Route5 are connected -CeruleanGroupSprites: -; Route4, Route9, Route10North, Route24, Route25, CeruleanCity -SaffronGroupSprites: -; Route5, SaffronCity - db SPRITE_COOLTRAINER_M - db SPRITE_SUPER_NERD - db SPRITE_COOLTRAINER_F - db SPRITE_FISHER - db SPRITE_YOUNGSTER - db SPRITE_LASS - db SPRITE_POKEFAN_M - db SPRITE_ROCKET - db SPRITE_MISTY - ; max 9 of 9 walking sprites - db SPRITE_POKE_BALL - db SPRITE_SLOWBRO - db SPRITE_ZAPDOS - db 0 ; end - -VermilionGroupSprites: -; Route6, Route11, VermilionCity - db SPRITE_POKEFAN_M - db SPRITE_YOUNGSTER - db SPRITE_TEACHER - db SPRITE_SUPER_NERD - db SPRITE_FISHER - db SPRITE_LASS - ; 6 of max 9 walking sprites - db SPRITE_GRAMPS - db SPRITE_BIG_SNORLAX - db SPRITE_MACHOP - db SPRITE_TWIN - db SPRITE_POKE_BALL - db SPRITE_BERRY - db SPRITE_APRICORN - db 0 ; end - -CeladonGroupSprites: -; Route7, Route16, Route17, CeladonCity - db SPRITE_FISHER - db SPRITE_TEACHER - db SPRITE_GRAMPS - db SPRITE_YOUNGSTER - db SPRITE_LASS - db SPRITE_BIKER - ; 6 of max 9 walking sprites - db SPRITE_POLIWRATH - db SPRITE_POKE_BALL - db SPRITE_BERRY - db 0 ; end - -; Route12 and Route13 are connected -LavenderGroupSprites: -; Route8, Route12, Route10South, LavenderTown -FuchsiaGroupSprites: -; Route13, Route14, Route15, Route18, FuchsiaCity - db SPRITE_POKEFAN_M - db SPRITE_POKEFAN_F - db SPRITE_YOUNGSTER - db SPRITE_FISHER - db SPRITE_TEACHER - db SPRITE_SUPER_NERD - db SPRITE_BIKER - db SPRITE_GENTLEMAN - db SPRITE_LASS - ; 9 of max 9 walking sprites - db SPRITE_GRAMPS - db SPRITE_ZAPDOS - db SPRITE_TWIN - db SPRITE_POKE_BALL - db SPRITE_BERRY - db SPRITE_APRICORN - db 0 ; end - -IndigoGroupSprites: -; Route23 - ; 0 of max 9 walking sprites - db 0 ; end - -; Route29 and CherrygroveCity are connected -NewBarkGroupSprites: -; Route26, Route27, Route29, NewBarkTown -CherrygroveGroupSprites: -; Route30, Route31, CherrygroveCity - db SPRITE_RIVAL - db SPRITE_TEACHER - db SPRITE_FISHER - db SPRITE_COOLTRAINER_M - db SPRITE_YOUNGSTER - db SPRITE_GRAMPS - db SPRITE_BUG_CATCHER - db SPRITE_COOLTRAINER_F - ; max 8 of 9 walking sprites - db SPRITE_PIDGEY - db SPRITE_RATTATA_UP - db SPRITE_POKE_BALL - db SPRITE_BERRY - db SPRITE_APRICORN - db 0 ; end - -; Route37 and EcruteakCity are connected -VioletGroupSprites: -; Route32, Route35, Route36, Route37, VioletCity -EcruteakGroupSprites: -; EcruteakCity - db SPRITE_FISHER - db SPRITE_LASS - db SPRITE_OFFICER - db SPRITE_GRAMPS - db SPRITE_YOUNGSTER - db SPRITE_COOLTRAINER_M - db SPRITE_BUG_CATCHER - db SPRITE_SUPER_NERD - ; 8 of max 9 walking sprites - db SPRITE_TWIN - db SPRITE_SUDOWOODO - db SPRITE_POKE_BALL - db SPRITE_BERRY - db SPRITE_APRICORN - db SPRITE_SUICUNE - db 0 ; end - -AzaleaGroupSprites: -; Route33, AzaleaTown - db SPRITE_GRAMPS - db SPRITE_YOUNGSTER - db SPRITE_POKEFAN_M - db SPRITE_TEACHER - db SPRITE_ROCKET - db SPRITE_LASS - db SPRITE_RIVAL - ; 7 of max 9 walking sprites - db SPRITE_BERRY - db SPRITE_APRICORN - db SPRITE_SLOWPOKE - db SPRITE_KURT - db 0 ; end - -GoldenrodGroupSprites: -; Route34, GoldenrodCity - db SPRITE_GRAMPS - db SPRITE_YOUNGSTER - db SPRITE_OFFICER - db SPRITE_POKEFAN_M - db SPRITE_COOLTRAINER_F - db SPRITE_ROCKET - db SPRITE_LASS - ; 7 of max 9 walking sprites - db SPRITE_DAY_CARE_MON_1 - db SPRITE_DAY_CARE_MON_2 - db SPRITE_POKE_BALL - db 0 ; end - -; OlivineCity and Route40 are connected -OlivineGroupSprites: -; Route38, Route39, OlivineCity -CianwoodGroupSprites: -; Route40, Route41, CianwoodCity, BattleTowerOutside - db SPRITE_RIVAL - db SPRITE_POKEFAN_M - db SPRITE_LASS - db SPRITE_SWIMMER_GIRL - db SPRITE_SAILOR - db SPRITE_POKEFAN_F - db SPRITE_SUPER_NERD - db SPRITE_SWIMMER_GUY - db SPRITE_GENTLEMAN - ; 9 of max 9 walking sprites - db SPRITE_BEAUTY - db SPRITE_MILTANK - db SPRITE_BERRY - db SPRITE_APRICORN - db SPRITE_ROCK - db SPRITE_YOUNGSTER ; non-walking version of SPRITE_YOUNGSTER - db SPRITE_SUICUNE - db 0 ; end - -MahoganyGroupSprites: -; Route42, Route44, MahoganyTown - db SPRITE_GRAMPS - db SPRITE_YOUNGSTER - db SPRITE_LASS - db SPRITE_SUPER_NERD - db SPRITE_COOLTRAINER_M - db SPRITE_POKEFAN_M - db SPRITE_COOLTRAINER_F - db SPRITE_FISHER - ; 8 of max 9 walking sprites - db SPRITE_BERRY - db SPRITE_APRICORN - db SPRITE_POKE_BALL - db SPRITE_SUICUNE - db 0 ; end - -LakeOfRageGroupSprites: -; Route43, LakeOfRage - db SPRITE_LANCE - db SPRITE_GRAMPS - db SPRITE_SUPER_NERD - db SPRITE_COOLTRAINER_F - db SPRITE_FISHER - db SPRITE_COOLTRAINER_M - db SPRITE_LASS - db SPRITE_YOUNGSTER - ; 8 of max 9 walking sprites - db SPRITE_GYARADOS - db SPRITE_BERRY - db SPRITE_APRICORN - db SPRITE_POKE_BALL - db 0 ; end - -BlackthornGroupSprites: -; Route45, Route46, BlackthornCity - db SPRITE_GRAMPS - db SPRITE_YOUNGSTER - db SPRITE_LASS - db SPRITE_SUPER_NERD - db SPRITE_COOLTRAINER_M - db SPRITE_POKEFAN_M - db SPRITE_BLACK_BELT - db SPRITE_COOLTRAINER_F - ; 8 of max 9 walking sprites - db SPRITE_BERRY - db SPRITE_APRICORN - db SPRITE_POKE_BALL - db 0 ; end - -SilverGroupSprites: -; Route28, SilverCaveOutside - ; 0 of max 9 walking sprites - db 0 ; end - -DungeonsGroupSprites: -; NationalPark, NationalParkBugContest, RuinsOfAlphOutside - db SPRITE_LASS - db SPRITE_POKEFAN_F - db SPRITE_TEACHER - db SPRITE_YOUNGSTER - db SPRITE_POKEFAN_M - db SPRITE_COOLTRAINER_M - db SPRITE_FISHER - db SPRITE_SCIENTIST - db SPRITE_BUG_CATCHER - ; 8 of max 9 walking sprites - db SPRITE_GAMEBOY_KID - db SPRITE_PERSIAN - db SPRITE_POKE_BALL - db 0 ; end - -FastShipGroupSprites: -; OlivinePort, VermilionPort, MountMoonSquare, TinTowerRoof - db SPRITE_SAILOR - db SPRITE_FISHING_GURU - db SPRITE_SUPER_NERD - db SPRITE_COOLTRAINER_F - db SPRITE_YOUNGSTER - ; 5 of max 9 walking sprites - db SPRITE_HO_OH - db SPRITE_CLEFAIRY_MOVE - db SPRITE_ROCK - db 0 ; end - -CableClubGroupSprites: -; (no outdoor maps) - ; 0 of max 9 walking sprites - db 0 ; end - -SafariZoneGateGroupSprites: -SafariZoneGroupSprites: -; Route47, Route48, SafariZoneGate, CliffEdgeCave, CliffEdgeGate - db SPRITE_TWIN - db SPRITE_SUPER_NERD - db SPRITE_YOUNGSTER - db SPRITE_LASS - db SPRITE_POKEFAN_M - db SPRITE_JIGGLYPUFF - db SPRITE_KANGASKHAN - db SPRITE_BUTTERFREE - db SPRITE_TEACHER - ; 7 of max 9 walking sprites - db SPRITE_SLOWPOKE - db SPRITE_GENTLEMAN - db SPRITE_POKEFAN_F - db SPRITE_GRAMPS - db SPRITE_COOLTRAINER_M - db SPRITE_COOLTRAINER_F - db SPRITE_BEAUTY - db SPRITE_POKE_BALL - db SPRITE_OLD_LINK_RECEPTIONIST diff --git a/engine/overworld/overworld.asm b/engine/overworld/overworld.asm index 026e344c4..d96f6e385 100644 --- a/engine/overworld/overworld.asm +++ b/engine/overworld/overworld.asm @@ -37,21 +37,6 @@ _ClearSprites: ; mobile ld [wSpriteFlags], a ret -RefreshSprites:: - call .Refresh - call LoadUsedSpritesGFX - ret - -.Refresh: - xor a - ld bc, wUsedSpritesEnd - wUsedSprites - ld hl, wUsedSprites - call ByteFill - call GetPlayerSprite - call AddMapSprites - call LoadAndSortSprites - ret - GetPlayerSprite: ; Get Chris or Kris's sprite. ld hl, ChrisStateSprites @@ -91,50 +76,56 @@ GetPlayerSprite: INCLUDE "data/sprites/player_sprites.asm" -AddMapSprites: - call GetMapEnvironment - call CheckOutdoorMap - jr z, .outdoor - call AddIndoorSprites - ret - -.outdoor - call AddOutdoorSprites +RefreshSprites:: + push hl + push de + push bc + call GetPlayerSprite + xor a + ld [hUsedSpriteIndex], a + call ReloadSpriteIndex + call LoadMiscTiles + pop bc + pop de + pop hl ret -AddIndoorSprites: - ld hl, wMap1ObjectSprite - ld a, 1 +ReloadSpriteIndex:: +; Reloads sprites using hUsedSpriteIndex. +; Used to reload variable sprites + ld hl, wObjectStructs + ld de, OBJECT_LENGTH + push bc + ld a, [hUsedSpriteIndex] + ld b, a + xor a .loop - push af + ld [hObjectStructIndex], a ld a, [hl] - call AddSpriteGFX - ld de, MAPOBJECT_LENGTH + and a + jr z, .done + bit 7, b + jr z, .continue + cp b + jr nz, .done +.continue + push hl + call GetSpriteVTile + pop hl + push hl + inc hl + inc hl + ld [hl], a + pop hl +.done add hl, de - pop af + ld a, [hObjectStructIndex] inc a - cp NUM_OBJECTS + cp NUM_OBJECT_STRUCTS jr nz, .loop + pop bc ret -AddOutdoorSprites: - ld a, [wMapGroup] - dec a - ld c, a - ld b, 0 - ld hl, OutdoorSprites - add hl, bc - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a -.loop - ld a, [hli] - and a - ret z - call AddSpriteGFX - jr .loop - LoadUsedSpritesGFX: ld a, MAPCALLBACK_SPRITES call RunMapCallback @@ -164,7 +155,7 @@ SafeGetSprite: pop hl ret -GetSprite: +GetSprite:: call GetMonSprite ret c @@ -300,11 +291,6 @@ _GetSpritePalette:: ld c, a ret -LoadAndSortSprites: - call LoadSpriteGFX - call ArrangeUsedSprites - ret - AddSpriteGFX: ; Add any new sprite ids to a list of graphics to be loaded. ; Return carry if the list is full. @@ -343,89 +329,6 @@ AddSpriteGFX: and a ret -LoadSpriteGFX: - - ld hl, wUsedSprites - ld b, SPRITE_GFX_LIST_CAPACITY -.loop - ld a, [hli] - and a - jr z, .done - push hl - call .LoadSprite - pop hl - ld [hli], a - dec b - jr nz, .loop - -.done - ret - -.LoadSprite: - push bc - call GetSprite - pop bc - ld a, l - ret - -ArrangeUsedSprites: -; Get the length of each sprite and space them out in VRAM. -; Crystal introduces a second table in VRAM bank 0. - - ld hl, wUsedSprites - ld c, SPRITE_GFX_LIST_CAPACITY - ld b, 0 -.FirstTableLength: -; Keep going until the end of the list. - ld a, [hli] - and a - jr z, .quit - - ld a, [hl] - call GetSpriteLength - -; Spill over into the second table after $80 tiles. - add b - cp $80 - jr z, .loop - jr nc, .SecondTable - -.loop - ld [hl], b - inc hl - ld b, a - -; Assumes the next table will be reached before c hits 0. - dec c - jr nz, .FirstTableLength - -.SecondTable: -; The second tile table starts at tile $80. - ld b, $80 - dec hl -.SecondTableLength: -; Keep going until the end of the list. - ld a, [hli] - and a - jr z, .quit - - ld a, [hl] - call GetSpriteLength - -; There are only two tables, so don't go any further than that. - add b - jr c, .quit - - ld [hl], b - ld b, a - inc hl - - dec c - jr nz, .SecondTableLength - -.quit - ret - GetSpriteLength: ; Return the length of sprite type a in tiles. @@ -483,7 +386,7 @@ GetUsedSprites: .done ret -GetUsedSprite: +GetUsedSprite:: ldh a, [hUsedSpriteIndex] call SafeGetSprite ldh a, [hUsedSpriteTile] @@ -592,6 +495,4 @@ INCLUDE "data/sprites/emotes.asm" INCLUDE "data/sprites/sprite_mons.asm" -INCLUDE "data/maps/outdoor_sprites.asm" - INCLUDE "data/sprites/sprites.asm" diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm index 193dc6f66..55a0b9ada 100644 --- a/engine/overworld/scripting.asm +++ b/engine/overworld/scripting.asm @@ -958,10 +958,12 @@ Script_variablesprite: call GetScriptByte ld e, a ld d, 0 + ld [hUsedSpriteIndex], a ld hl, wVariableSprites add hl, de call GetScriptByte ld [hl], a + farcall ReloadSpriteIndex ret Script_appear: diff --git a/home/map_objects.asm b/home/map_objects.asm index b2129e1cb..20eb8e441 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -16,36 +16,37 @@ GetSpritePalette:: GetSpriteVTile:: push hl + push de push bc - ld hl, wUsedSprites + 2 - ld c, SPRITE_GFX_LIST_CAPACITY - 1 + ld [hUsedSpriteIndex], a + farcall GetSprite + ld hl, wSpriteFlags + res 5, [hl] + ld a, [hObjectStructIndex] + cp FIRST_VRAM1_OBJECT_STRUCT + jr c, .continue + set 5, [hl] + sub FIRST_VRAM1_OBJECT_STRUCT +.continue + add a, a + add a, a + ld b, a + add a, b + add a, b + ld [hUsedSpriteTile], a + push af + farcall GetUsedSprite + pop af ld b, a - ldh a, [hMapObjectIndex] - cp 0 - jr z, .nope - ld a, b -.loop - cp [hl] - jr z, .found - inc hl - inc hl - dec c - jr nz, .loop - ld a, [wUsedSprites + 1] - scf - jr .done - -.nope - ld a, [wUsedSprites + 1] - jr .done - -.found - inc hl xor a - ld a, [hl] - -.done + ld a, b + ld hl, wSpriteFlags + bit 5, [hl] + jr z, .using_vbk1 + or $80 +.using_vbk1 pop bc + pop de pop hl ret From 69bfce27b0697dee9e4e3866bb8ba1eb08404472 Mon Sep 17 00:00:00 2001 From: vulcandth Date: Tue, 27 Dec 2022 13:16:06 -0600 Subject: [PATCH 04/11] Port Improved Dynamic Pal System This is an improved version vulcandth developed for Polished Crystal; porting to CSE. Co-Authored-By: Rangi <35663410+Rangi42@users.noreply.github.com> --- constants/map_object_constants.asm | 12 +- constants/sprite_anim_constants.asm | 216 +++++++++++------------ constants/sprite_data_constants.asm | 70 ++++++-- constants/wram_constants.asm | 7 + data/maps/setup_script_pointers.asm | 2 + data/maps/setup_scripts.asm | 12 ++ data/sprite_anims/framesets.asm | 20 +-- data/sprite_anims/oam.asm | 72 ++++---- data/sprite_anims/objects.asm | 6 +- data/sprites/sprites.asm | 2 +- engine/battle/battle_transition.asm | 3 + engine/events/celebi.asm | 4 + engine/events/field_moves.asm | 2 + engine/events/heal_machine_anim.asm | 32 ++-- engine/events/magnet_train.asm | 21 +-- engine/events/overworld.asm | 7 +- engine/events/specials.asm | 4 +- engine/gfx/color.asm | 29 +-- engine/gfx/dynamic_pals.asm | 171 ++++++++++++++++++ engine/gfx/mon_icons.asm | 9 + engine/gfx/sprite_palettes.asm | 104 +++++++++++ engine/menus/intro_menu.asm | 2 + engine/overworld/events.asm | 1 - engine/overworld/map_objects.asm | 34 +--- engine/overworld/overworld.asm | 1 + engine/overworld/player_object.asm | 18 +- gfx/battle_anims/unused_battle_anims.pal | 30 ---- gfx/overworld/npc_single_object.pal | 7 + gfx/overworld/npc_sprites.pal | 88 ++++++--- gfx/overworld/npc_sprites_darkness.pal | 32 +++- home/header.asm | 3 +- home/map_objects.asm | 42 ----- home/menu.asm | 1 + home/trainers.asm | 1 - macros/legacy.asm | 3 - macros/ram.asm | 7 +- macros/scripts/maps.asm | 5 +- main.asm | 6 + maps/BurnedTowerB1F.asm | 6 +- maps/CopycatsHouse2F.asm | 6 + ram/wram.asm | 17 +- 41 files changed, 710 insertions(+), 405 deletions(-) create mode 100644 engine/gfx/dynamic_pals.asm create mode 100644 engine/gfx/sprite_palettes.asm delete mode 100644 gfx/battle_anims/unused_battle_anims.pal create mode 100644 gfx/overworld/npc_single_object.pal diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm index aaa9751c6..7bba05737 100644 --- a/constants/map_object_constants.asm +++ b/constants/map_object_constants.asm @@ -33,7 +33,8 @@ DEF OBJECT_1D rb ; 1d DEF OBJECT_1E rb ; 1e DEF OBJECT_JUMP_HEIGHT rb ; 1f DEF OBJECT_RANGE rb ; 20 - rb_skip 7 +DEF OBJECT_PAL_INDEX rb ; 21 + rb_skip 6 DEF OBJECT_LENGTH EQU _RS DEF NUM_OBJECT_STRUCTS EQU 13 ; see wObjectStructs DEF FIRST_VRAM1_OBJECT_STRUCT EQU 10 @@ -106,12 +107,8 @@ DEF MAPOBJECT_Y_COORD rb ; 2 DEF MAPOBJECT_X_COORD rb ; 3 DEF MAPOBJECT_MOVEMENT rb ; 4 DEF MAPOBJECT_RADIUS rb ; 5 -DEF MAPOBJECT_HOUR_1 rb ; 6 -DEF MAPOBJECT_HOUR_2 rb ; 7 -rsset MAPOBJECT_HOUR_2 +DEF MAPOBJECT_PALETTE rb ; 6 DEF MAPOBJECT_TIMEOFDAY rb ; 7 -DEF MAPOBJECT_PALETTE rb ; 8 -rsset MAPOBJECT_PALETTE DEF MAPOBJECT_TYPE rb ; 8 DEF MAPOBJECT_SIGHT_RANGE rb ; 9 DEF MAPOBJECT_SCRIPT_POINTER rw ; a @@ -121,9 +118,6 @@ DEF MAPOBJECT_LENGTH EQU _RS DEF NUM_OBJECTS EQU 16 DEF PLAYER_OBJECT EQU 0 -DEF MAPOBJECT_PALETTE_MASK EQU %11110000 -DEF MAPOBJECT_TYPE_MASK EQU %00001111 - ; SpriteMovementData struct members (see data/sprites/map_objects.asm) rsreset DEF SPRITEMOVEATTR_MOVEMENT rb ; 0 diff --git a/constants/sprite_anim_constants.asm b/constants/sprite_anim_constants.asm index 830cf7dee..b4fe1cb42 100644 --- a/constants/sprite_anim_constants.asm +++ b/constants/sprite_anim_constants.asm @@ -56,7 +56,7 @@ DEF NUM_SPRITEANIMDICT_ENTRIES EQU 10 const SPRITE_ANIM_OBJ_TRADEMON_BUBBLE ; 12 const SPRITE_ANIM_OBJ_EVOLUTION_BALL_OF_LIGHT ; 13 const SPRITE_ANIM_OBJ_RADIO_TUNING_KNOB ; 14 - const SPRITE_ANIM_OBJ_MAGNET_TRAIN_RED ; 15 + const SPRITE_ANIM_OBJ_MAGNET_TRAIN ; 15 const SPRITE_ANIM_OBJ_LEAF ; 16 const SPRITE_ANIM_OBJ_CUT_TREE ; 17 const SPRITE_ANIM_OBJ_FLY_LEAF ; 18 @@ -66,30 +66,29 @@ DEF NUM_SPRITEANIMDICT_ENTRIES EQU 10 const SPRITE_ANIM_OBJ_EGG_HATCH ; 1c const SPRITE_ANIM_OBJ_EZCHAT_CURSOR ; 1d const SPRITE_ANIM_OBJ_BLUE_WALK ; 1e - const SPRITE_ANIM_OBJ_MAGNET_TRAIN_BLUE ; 1f - const SPRITE_ANIM_OBJ_MOBILE_TRADE_SENT_BALL ; 20 - const SPRITE_ANIM_OBJ_MOBILE_TRADE_OT_BALL ; 21 - const SPRITE_ANIM_OBJ_MOBILE_TRADE_CABLE_BULGE ; 22 - const SPRITE_ANIM_OBJ_MOBILE_TRADE_SENT_PULSE ; 23 - const SPRITE_ANIM_OBJ_MOBILE_TRADE_OT_PULSE ; 24 - const SPRITE_ANIM_OBJ_MOBILE_TRADE_PING ; 25 - const SPRITE_ANIM_OBJ_INTRO_SUICUNE ; 26 - const SPRITE_ANIM_OBJ_INTRO_PICHU ; 27 - const SPRITE_ANIM_OBJ_INTRO_WOOPER ; 28 - const SPRITE_ANIM_OBJ_INTRO_UNOWN ; 29 - const SPRITE_ANIM_OBJ_INTRO_UNOWN_F ; 2a - const SPRITE_ANIM_OBJ_INTRO_SUICUNE_AWAY ; 2b - const SPRITE_ANIM_OBJ_CELEBI ; 2c - const SPRITE_ANIM_OBJ_PC_CURSOR ; 2d - const SPRITE_ANIM_OBJ_PC_QUICK ; 2e - const SPRITE_ANIM_OBJ_PC_MODE ; 2f - const SPRITE_ANIM_OBJ_PC_MODE2 ; 30 - const SPRITE_ANIM_OBJ_PC_PACK ; 31 - const SPRITE_ANIM_OBJ_PAGER_MON_RED ; 32 - const SPRITE_ANIM_OBJ_PAGER_MON_BLUE ; 33 - const SPRITE_ANIM_OBJ_PAGER_MON_GREEN ; 34 - const SPRITE_ANIM_OBJ_PAGER_MON_BROWN ; 35 - const SPRITE_ANIM_OBJ_PAGER_MON_GREY ; 36 + const SPRITE_ANIM_OBJ_MOBILE_TRADE_SENT_BALL ; 1f + const SPRITE_ANIM_OBJ_MOBILE_TRADE_OT_BALL ; 20 + const SPRITE_ANIM_OBJ_MOBILE_TRADE_CABLE_BULGE ; 21 + const SPRITE_ANIM_OBJ_MOBILE_TRADE_SENT_PULSE ; 22 + const SPRITE_ANIM_OBJ_MOBILE_TRADE_OT_PULSE ; 23 + const SPRITE_ANIM_OBJ_MOBILE_TRADE_PING ; 24 + const SPRITE_ANIM_OBJ_INTRO_SUICUNE ; 25 + const SPRITE_ANIM_OBJ_INTRO_PICHU ; 26 + const SPRITE_ANIM_OBJ_INTRO_WOOPER ; 27 + const SPRITE_ANIM_OBJ_INTRO_UNOWN ; 28 + const SPRITE_ANIM_OBJ_INTRO_UNOWN_F ; 29 + const SPRITE_ANIM_OBJ_INTRO_SUICUNE_AWAY ; 2a + const SPRITE_ANIM_OBJ_CELEBI ; 2b + const SPRITE_ANIM_OBJ_PC_CURSOR ; 2c + const SPRITE_ANIM_OBJ_PC_QUICK ; 2d + const SPRITE_ANIM_OBJ_PC_MODE ; 2e + const SPRITE_ANIM_OBJ_PC_MODE2 ; 2f + const SPRITE_ANIM_OBJ_PC_PACK ; 30 + const SPRITE_ANIM_OBJ_PAGER_MON_RED ; 31 + const SPRITE_ANIM_OBJ_PAGER_MON_BLUE ; 32 + const SPRITE_ANIM_OBJ_PAGER_MON_GREEN ; 33 + const SPRITE_ANIM_OBJ_PAGER_MON_BROWN ; 34 + const SPRITE_ANIM_OBJ_PAGER_MON_GREY ; 35 DEF NUM_SPRITE_ANIM_OBJS EQU const_value ; DoSpriteAnimFrame.Jumptable indexes (see engine/sprite_anims/functions.asm) @@ -165,7 +164,7 @@ DEF NUM_SPRITE_ANIM_FUNCS EQU const_value const SPRITE_ANIM_FRAMESET_TRADEMON_BUBBLE ; 18 const SPRITE_ANIM_FRAMESET_EVOLUTION_BALL_OF_LIGHT ; 19 const SPRITE_ANIM_FRAMESET_RADIO_TUNING_KNOB ; 1a - const SPRITE_ANIM_FRAMESET_MAGNET_TRAIN_RED ; 1b + const SPRITE_ANIM_FRAMESET_MAGNET_TRAIN ; 1b const SPRITE_ANIM_FRAMESET_UNUSED_1C ; 1c const SPRITE_ANIM_FRAMESET_LEAF ; 1d const SPRITE_ANIM_FRAMESET_CUT_TREE ; 1e @@ -184,37 +183,36 @@ DEF NUM_SPRITE_ANIM_FUNCS EQU const_value const SPRITE_ANIM_FRAMESET_EZCHAT_CURSOR_6 ; 2b const SPRITE_ANIM_FRAMESET_EZCHAT_CURSOR_7 ; 2c const SPRITE_ANIM_FRAMESET_BLUE_WALK ; 2d - const SPRITE_ANIM_FRAMESET_MAGNET_TRAIN_BLUE ; 2e - const SPRITE_ANIM_FRAMESET_MOBILE_TRADE_SENT_BALL ; 2f - const SPRITE_ANIM_FRAMESET_MOBILE_TRADE_OT_BALL ; 30 - const SPRITE_ANIM_FRAMESET_MOBILE_TRADE_CABLE_BULGE ; 31 - const SPRITE_ANIM_FRAMESET_MOBILE_TRADE_SENT_PULSE ; 32 - const SPRITE_ANIM_FRAMESET_MOBILE_TRADE_OT_PULSE ; 33 - const SPRITE_ANIM_FRAMESET_MOBILE_TRADE_PING ; 34 - const SPRITE_ANIM_FRAMESET_INTRO_SUICUNE ; 35 - const SPRITE_ANIM_FRAMESET_INTRO_SUICUNE_2 ; 36 - const SPRITE_ANIM_FRAMESET_INTRO_PICHU ; 37 - const SPRITE_ANIM_FRAMESET_INTRO_WOOPER ; 38 - const SPRITE_ANIM_FRAMESET_INTRO_UNOWN_1 ; 39 - const SPRITE_ANIM_FRAMESET_INTRO_UNOWN_2 ; 3a - const SPRITE_ANIM_FRAMESET_INTRO_UNOWN_3 ; 3b - const SPRITE_ANIM_FRAMESET_INTRO_UNOWN_4 ; 3c - const SPRITE_ANIM_FRAMESET_INTRO_UNOWN_F_2 ; 3d - const SPRITE_ANIM_FRAMESET_INTRO_SUICUNE_AWAY ; 3e - const SPRITE_ANIM_FRAMESET_INTRO_UNOWN_F ; 3f - const SPRITE_ANIM_FRAMESET_CELEBI_LEFT ; 40 - const SPRITE_ANIM_FRAMESET_CELEBI_RIGHT ; 41 - const SPRITE_ANIM_FRAMESET_PC_CURSOR ; 42 - const SPRITE_ANIM_FRAMESET_PC_CURSOR_ITEM ; 43 - const SPRITE_ANIM_FRAMESET_PC_QUICK ; 44 - const SPRITE_ANIM_FRAMESET_PC_MODE ; 45 - const SPRITE_ANIM_FRAMESET_PC_MODE2 ; 46 - const SPRITE_ANIM_FRAMESET_PC_PACK ; 47 - const SPRITE_ANIM_FRAMESET_PAGER_MON_RED ; 48 - const SPRITE_ANIM_FRAMESET_PAGER_MON_BLUE ; 49 - const SPRITE_ANIM_FRAMESET_PAGER_MON_GREEN ; 4a - const SPRITE_ANIM_FRAMESET_PAGER_MON_BROWN ; 4b - const SPRITE_ANIM_FRAMESET_PAGER_MON_GREY ; 4c + const SPRITE_ANIM_FRAMESET_MOBILE_TRADE_SENT_BALL ; 2e + const SPRITE_ANIM_FRAMESET_MOBILE_TRADE_OT_BALL ; 2f + const SPRITE_ANIM_FRAMESET_MOBILE_TRADE_CABLE_BULGE ; 30 + const SPRITE_ANIM_FRAMESET_MOBILE_TRADE_SENT_PULSE ; 31 + const SPRITE_ANIM_FRAMESET_MOBILE_TRADE_OT_PULSE ; 32 + const SPRITE_ANIM_FRAMESET_MOBILE_TRADE_PING ; 33 + const SPRITE_ANIM_FRAMESET_INTRO_SUICUNE ; 34 + const SPRITE_ANIM_FRAMESET_INTRO_SUICUNE_2 ; 35 + const SPRITE_ANIM_FRAMESET_INTRO_PICHU ; 36 + const SPRITE_ANIM_FRAMESET_INTRO_WOOPER ; 37 + const SPRITE_ANIM_FRAMESET_INTRO_UNOWN_1 ; 38 + const SPRITE_ANIM_FRAMESET_INTRO_UNOWN_2 ; 39 + const SPRITE_ANIM_FRAMESET_INTRO_UNOWN_3 ; 3a + const SPRITE_ANIM_FRAMESET_INTRO_UNOWN_4 ; 3b + const SPRITE_ANIM_FRAMESET_INTRO_UNOWN_F_2 ; 3c + const SPRITE_ANIM_FRAMESET_INTRO_SUICUNE_AWAY ; 3d + const SPRITE_ANIM_FRAMESET_INTRO_UNOWN_F ; 3e + const SPRITE_ANIM_FRAMESET_CELEBI_LEFT ; 3f + const SPRITE_ANIM_FRAMESET_CELEBI_RIGHT ; 40 + const SPRITE_ANIM_FRAMESET_PC_CURSOR ; 41 + const SPRITE_ANIM_FRAMESET_PC_CURSOR_ITEM ; 42 + const SPRITE_ANIM_FRAMESET_PC_QUICK ; 43 + const SPRITE_ANIM_FRAMESET_PC_MODE ; 44 + const SPRITE_ANIM_FRAMESET_PC_MODE2 ; 45 + const SPRITE_ANIM_FRAMESET_PC_PACK ; 46 + const SPRITE_ANIM_FRAMESET_PAGER_MON_RED ; 47 + const SPRITE_ANIM_FRAMESET_PAGER_MON_BLUE ; 48 + const SPRITE_ANIM_FRAMESET_PAGER_MON_GREEN ; 49 + const SPRITE_ANIM_FRAMESET_PAGER_MON_BROWN ; 4a + const SPRITE_ANIM_FRAMESET_PAGER_MON_GREY ; 4b DEF NUM_SPRITE_ANIM_FRAMESETS EQU const_value ; SpriteAnimOAMData indexes (see data/sprite_anims/oam.asm) @@ -284,8 +282,8 @@ DEF NUM_SPRITE_ANIM_FRAMESETS EQU const_value const SPRITE_ANIM_OAMSET_PARTY_MON_WITH_MAIL_2 ; 3e const SPRITE_ANIM_OAMSET_PARTY_MON_WITH_ITEM_1 ; 3f const SPRITE_ANIM_OAMSET_PARTY_MON_WITH_ITEM_2 ; 40 - const SPRITE_ANIM_OAMSET_MAGNET_TRAIN_RED_1 ; 41 - const SPRITE_ANIM_OAMSET_MAGNET_TRAIN_RED_2 ; 42 + const SPRITE_ANIM_OAMSET_MAGNET_TRAIN_1 ; 41 + const SPRITE_ANIM_OAMSET_MAGNET_TRAIN_2 ; 42 const SPRITE_ANIM_OAMSET_UNUSED_43 ; 43 const SPRITE_ANIM_OAMSET_UNUSED_44 ; 44 const SPRITE_ANIM_OAMSET_UNUSED_45 ; 45 @@ -320,57 +318,55 @@ DEF NUM_SPRITE_ANIM_FRAMESETS EQU const_value const SPRITE_ANIM_OAMSET_EZCHAT_CURSOR_7 ; 62 const SPRITE_ANIM_OAMSET_BLUE_WALK_1 ; 63 const SPRITE_ANIM_OAMSET_BLUE_WALK_2 ; 64 - const SPRITE_ANIM_OAMSET_MAGNET_TRAIN_BLUE_1 ; 65 - const SPRITE_ANIM_OAMSET_MAGNET_TRAIN_BLUE_2 ; 66 - const SPRITE_ANIM_OAMSET_MOBILE_TRADE_CABLE_BULGE_1 ; 67 - const SPRITE_ANIM_OAMSET_MOBILE_TRADE_CABLE_BULGE_2 ; 68 - const SPRITE_ANIM_OAMSET_MOBILE_TRADE_PING_1 ; 69 - const SPRITE_ANIM_OAMSET_MOBILE_TRADE_PING_2 ; 6a - const SPRITE_ANIM_OAMSET_MOBILE_TRADE_PING_3 ; 6b - const SPRITE_ANIM_OAMSET_MOBILE_TRADE_SENT_PULSE ; 6c - const SPRITE_ANIM_OAMSET_MOBILE_TRADE_OT_PULSE ; 6d - const SPRITE_ANIM_OAMSET_INTRO_SUICUNE_1 ; 6e - const SPRITE_ANIM_OAMSET_INTRO_SUICUNE_2 ; 6f - const SPRITE_ANIM_OAMSET_INTRO_SUICUNE_3 ; 70 - const SPRITE_ANIM_OAMSET_INTRO_SUICUNE_4 ; 71 - const SPRITE_ANIM_OAMSET_INTRO_PICHU_1 ; 72 - const SPRITE_ANIM_OAMSET_INTRO_PICHU_2 ; 73 - const SPRITE_ANIM_OAMSET_INTRO_PICHU_3 ; 74 - const SPRITE_ANIM_OAMSET_INTRO_WOOPER ; 75 - const SPRITE_ANIM_OAMSET_INTRO_UNOWN_1 ; 76 - const SPRITE_ANIM_OAMSET_INTRO_UNOWN_2 ; 77 - const SPRITE_ANIM_OAMSET_INTRO_UNOWN_3 ; 78 - const SPRITE_ANIM_OAMSET_INTRO_UNOWN_F_2_1 ; 79 - const SPRITE_ANIM_OAMSET_INTRO_UNOWN_F_2_2 ; 7a - const SPRITE_ANIM_OAMSET_INTRO_UNOWN_F_2_3 ; 7b - const SPRITE_ANIM_OAMSET_INTRO_UNOWN_F_2_4 ; 7c - const SPRITE_ANIM_OAMSET_INTRO_UNOWN_F_2_5 ; 7d - const SPRITE_ANIM_OAMSET_INTRO_SUICUNE_AWAY ; 7e - const SPRITE_ANIM_OAMSET_CELEBI_1 ; 7f - const SPRITE_ANIM_OAMSET_CELEBI_2 ; 80 - const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_1 ; 81 - const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_2 ; 82 - const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_3 ; 83 - const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_4 ; 84 - const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_5 ; 85 - const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_6 ; 86 - const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_7 ; 87 - const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_8 ; 88 - const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_9 ; 89 - const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_10 ; 8a - const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_11 ; 8b - const SPRITE_ANIM_OAMSET_PARTY_MON_1 ; 8c - const SPRITE_ANIM_OAMSET_PARTY_MON_2 ; 8d - const SPRITE_ANIM_OAMSET_PC_CURSOR ; 8e - const SPRITE_ANIM_OAMSET_PC_CURSOR_ITEM ; 8f - const SPRITE_ANIM_OAMSET_PC_QUICK ; 90 - const SPRITE_ANIM_OAMSET_PC_MODE ; 91 - const SPRITE_ANIM_OAMSET_PC_MODE2 ; 92 - const SPRITE_ANIM_OAMSET_PC_PACK ; 93 - const SPRITE_ANIM_OAMSET_BROWN_WALK_1 ; 94 - const SPRITE_ANIM_OAMSET_BROWN_WALK_2 ; 95 - const SPRITE_ANIM_OAMSET_GREY_WALK_1 ; 96 - const SPRITE_ANIM_OAMSET_GREY_WALK_2 ; 97 + const SPRITE_ANIM_OAMSET_MOBILE_TRADE_CABLE_BULGE_1 ; 65 + const SPRITE_ANIM_OAMSET_MOBILE_TRADE_CABLE_BULGE_2 ; 66 + const SPRITE_ANIM_OAMSET_MOBILE_TRADE_PING_1 ; 67 + const SPRITE_ANIM_OAMSET_MOBILE_TRADE_PING_2 ; 68 + const SPRITE_ANIM_OAMSET_MOBILE_TRADE_PING_3 ; 69 + const SPRITE_ANIM_OAMSET_MOBILE_TRADE_SENT_PULSE ; 6a + const SPRITE_ANIM_OAMSET_MOBILE_TRADE_OT_PULSE ; 6b + const SPRITE_ANIM_OAMSET_INTRO_SUICUNE_1 ; 6c + const SPRITE_ANIM_OAMSET_INTRO_SUICUNE_2 ; 6d + const SPRITE_ANIM_OAMSET_INTRO_SUICUNE_3 ; 6e + const SPRITE_ANIM_OAMSET_INTRO_SUICUNE_4 ; 6f + const SPRITE_ANIM_OAMSET_INTRO_PICHU_1 ; 70 + const SPRITE_ANIM_OAMSET_INTRO_PICHU_2 ; 71 + const SPRITE_ANIM_OAMSET_INTRO_PICHU_3 ; 72 + const SPRITE_ANIM_OAMSET_INTRO_WOOPER ; 73 + const SPRITE_ANIM_OAMSET_INTRO_UNOWN_1 ; 74 + const SPRITE_ANIM_OAMSET_INTRO_UNOWN_2 ; 75 + const SPRITE_ANIM_OAMSET_INTRO_UNOWN_3 ; 76 + const SPRITE_ANIM_OAMSET_INTRO_UNOWN_F_2_1 ; 77 + const SPRITE_ANIM_OAMSET_INTRO_UNOWN_F_2_2 ; 78 + const SPRITE_ANIM_OAMSET_INTRO_UNOWN_F_2_3 ; 79 + const SPRITE_ANIM_OAMSET_INTRO_UNOWN_F_2_4 ; 7a + const SPRITE_ANIM_OAMSET_INTRO_UNOWN_F_2_5 ; 7b + const SPRITE_ANIM_OAMSET_INTRO_SUICUNE_AWAY ; 7c + const SPRITE_ANIM_OAMSET_CELEBI_1 ; 7d + const SPRITE_ANIM_OAMSET_CELEBI_2 ; 7e + const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_1 ; 7f + const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_2 ; 80 + const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_3 ; 81 + const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_4 ; 82 + const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_5 ; 83 + const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_6 ; 84 + const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_7 ; 85 + const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_8 ; 86 + const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_9 ; 87 + const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_10 ; 88 + const SPRITE_ANIM_OAMSET_GAMEFREAK_LOGO_11 ; 89 + const SPRITE_ANIM_OAMSET_PARTY_MON_1 ; 8a + const SPRITE_ANIM_OAMSET_PARTY_MON_2 ; 8b + const SPRITE_ANIM_OAMSET_PC_CURSOR ; 8c + const SPRITE_ANIM_OAMSET_PC_CURSOR_ITEM ; 8d + const SPRITE_ANIM_OAMSET_PC_QUICK ; 8e + const SPRITE_ANIM_OAMSET_PC_MODE ; 8f + const SPRITE_ANIM_OAMSET_PC_MODE2 ; 90 + const SPRITE_ANIM_OAMSET_PC_PACK ; 91 + const SPRITE_ANIM_OAMSET_BROWN_WALK_1 ; 92 + const SPRITE_ANIM_OAMSET_BROWN_WALK_2 ; 93 + const SPRITE_ANIM_OAMSET_GREY_WALK_1 ; 94 + const SPRITE_ANIM_OAMSET_GREY_WALK_2 ; 95 DEF NUM_SPRITE_ANIM_OAMSETS EQU const_value assert NUM_SPRITE_ANIM_OAMSETS <= FIRST_OAM_CMD, \ diff --git a/constants/sprite_data_constants.asm b/constants/sprite_data_constants.asm index a7dc809b5..7b06ac239 100644 --- a/constants/sprite_data_constants.asm +++ b/constants/sprite_data_constants.asm @@ -13,25 +13,57 @@ DEF NUM_SPRITEDATA_FIELDS EQU _RS const STANDING_SPRITE ; 2 const STILL_SPRITE ; 3 +; object_events that set a pal value will override the sprite's default palette +DEF PAL_NPC_DEFAULT EQU 0 + +MACRO ow_npc_pal_const + const PAL_OW_\1 + DEF PAL_NPC_\1 EQU PAL_OW_\1 + 1 +ENDM + ; sprite palettes +; MapObjectPals indexes (see gfx/overworld/npc_sprites.pal) const_def - const PAL_OW_RED ; 0 - const PAL_OW_BLUE ; 1 - const PAL_OW_GREEN ; 2 - const PAL_OW_BROWN ; 3 - const PAL_OW_PINK ; 4 - const PAL_OW_EMOTE ; 5 - const PAL_OW_TREE ; 6 - const PAL_OW_ROCK ; 7 + ow_npc_pal_const RED ; 00 + ow_npc_pal_const BLUE ; 01 + ow_npc_pal_const GREEN ; 02 + ow_npc_pal_const BROWN ; 03 + ow_npc_pal_const PURPLE ; 04 + ow_npc_pal_const GRAY ; 05 + ow_npc_pal_const PINK ; 06 + ow_npc_pal_const TEAL ; 07 + ow_npc_pal_const YELLOW ; 08 + ow_npc_pal_const ORANGE ; 09 + ow_npc_pal_const AZURE ; 0a + ow_npc_pal_const WHITE ; 0b + ow_npc_pal_const BLACK ; 0c + ow_npc_pal_const POKE_BALL ; 0d (red) + ow_npc_pal_const DECO_ITEM ; 0e (blue) + ow_npc_pal_const KEY_ITEM ; 0f (green) + ow_npc_pal_const TREE ; 10 +DEF NUM_OW_TIME_OF_DAY_PALS EQU const_value + ow_npc_pal_const EMOTE_GRAY ; 11 + ow_npc_pal_const EMOTE_BLACK ; 12 + ow_npc_pal_const EMOTE_GREEN ; 13 + ow_npc_pal_const EMOTE_PURPLE ; 14 + ow_npc_pal_const EMOTE_RED ; 15 + ow_npc_pal_const EMOTE_ORANGE ; 16 + ow_npc_pal_const EMOTE_BLUE ; 17 +DEF NUM_OW_INDIVIDUAL_PALS EQU const_value - NUM_OW_TIME_OF_DAY_PALS +DEF FIRST_COPY_BG_PAL EQU const_value + ow_npc_pal_const COPY_BG_GRAY ; 18 + ow_npc_pal_const COPY_BG_RED ; 19 + ow_npc_pal_const COPY_BG_GREEN ; 1a + ow_npc_pal_const COPY_BG_WATER ; 1b + ow_npc_pal_const COPY_BG_YELLOW ; 1c + ow_npc_pal_const COPY_BG_BROWN ; 1d + ow_npc_pal_const COPY_BG_ROOF ; 1e + ow_npc_pal_const COPY_BG_TEXT ; 1f +DEF NUM_OW_BG_COPY_PALS EQU const_value - NUM_OW_INDIVIDUAL_PALS +DEF NUM_OW_PALS EQU const_value -; object_events set bit 3 so as not to use the sprite's default palette -; MapObjectPals indexes (see gfx/overworld/npc_sprites.pal) - const_def 1 << 3 - const PAL_NPC_RED ; 8 - const PAL_NPC_BLUE ; 9 - const PAL_NPC_GREEN ; a - const PAL_NPC_BROWN ; b - const PAL_NPC_PINK ; c - const PAL_NPC_EMOTE ; d - const PAL_NPC_TREE ; e - const PAL_NPC_ROCK ; f +DEF PAL_OW_ROCK EQU PAL_OW_BROWN +DEF PAL_NPC_ROCK EQU PAL_NPC_BROWN +DEF PAL_OW_GREY EQU PAL_OW_GRAY +DEF PAL_NPC_SILVER EQU PAL_NPC_GRAY +DEF PAL_OW_SILVER EQU PAL_OW_GRAY diff --git a/constants/wram_constants.asm b/constants/wram_constants.asm index c9883af02..b47bd7b99 100644 --- a/constants/wram_constants.asm +++ b/constants/wram_constants.asm @@ -391,3 +391,10 @@ DEF DAYCARELADY_ACTIVE_F EQU 7 const UNLOCKED_UNOWNS_S_TO_W_F const UNLOCKED_UNOWNS_X_TO_Z_F DEF NUM_UNLOCKED_UNOWN_SETS EQU const_value + +; wPalFlags + const_def + const NO_DYN_PAL_APPLY_F ; 0 + const SCAN_OBJECTS_FIRST_F ; 1 + const USE_DAYTIME_PAL_F ; 2 + const DISABLE_DYN_PAL_F ; 3 diff --git a/data/maps/setup_script_pointers.asm b/data/maps/setup_script_pointers.asm index b32be8d8f..407bef4e2 100644 --- a/data/maps/setup_script_pointers.asm +++ b/data/maps/setup_script_pointers.asm @@ -50,3 +50,5 @@ MapSetupCommands: add_mapsetup ApplyMapPalettes ; 2b add_mapsetup EnableTextAcceleration ; 2c add_mapsetup InitMapNameSign ; 2d + add_mapsetup DisableDynPalUpdates ; 2e + add_mapsetup EnableDynPalUpdates ; 2f diff --git a/data/maps/setup_scripts.asm b/data/maps/setup_scripts.asm index 5ad24be6e..6106830be 100644 --- a/data/maps/setup_scripts.asm +++ b/data/maps/setup_scripts.asm @@ -27,6 +27,7 @@ MapSetupScript_Fly: mapsetup JumpRoamMons MapSetupScript_Warp: mapsetup DisableLCD + mapsetup DisableDynPalUpdates mapsetup InitSound mapsetup EnterMapSpawnPoint mapsetup LoadMapAttributes @@ -41,6 +42,7 @@ MapSetupScript_Warp: mapsetup LoadMapObjects mapsetup EnableLCD mapsetup LoadMapPalettes + mapsetup EnableDynPalUpdates mapsetup SpawnInFacingDown mapsetup RefreshMapSprites mapsetup PlayMapMusicBike @@ -60,12 +62,14 @@ MapSetupScript_BadWarp: mapsetup LoadBlockData mapsetup BufferScreen mapsetup DisableLCD + mapsetup DisableDynPalUpdates mapsetup LoadMapGraphics mapsetup LoadMapTimeOfDay mapsetup FadeOutMapMusic mapsetup EnableLCD mapsetup LoadMapObjects mapsetup LoadMapPalettes + mapsetup EnableDynPalUpdates mapsetup SpawnInFacingDown mapsetup RefreshMapSprites mapsetup FadeToMapMusic @@ -106,12 +110,14 @@ MapSetupScript_Train: mapsetup LoadBlockData mapsetup BufferScreen mapsetup DisableLCD + mapsetup DisableDynPalUpdates mapsetup LoadMapGraphics mapsetup LoadMapTimeOfDay mapsetup FadeOutMapMusic mapsetup EnableLCD mapsetup LoadMapObjects mapsetup LoadMapPalettes + mapsetup EnableDynPalUpdates mapsetup RefreshMapSprites mapsetup FadeToMapMusic mapsetup FadeInPalettes @@ -124,6 +130,7 @@ MapSetupScript_ReloadMap: mapsetup FadeMapMusicAndPalettes mapsetup ClearBGPalettes mapsetup DisableLCD + mapsetup DisableDynPalUpdates mapsetup InitSound mapsetup LoadBlockData mapsetup LoadConnectionBlockData @@ -131,6 +138,7 @@ MapSetupScript_ReloadMap: mapsetup LoadMapTimeOfDay mapsetup EnableLCD mapsetup LoadMapPalettes + mapsetup EnableDynPalUpdates mapsetup RefreshMapSprites mapsetup ForceMapMusic mapsetup FadeInPalettes @@ -141,6 +149,7 @@ MapSetupScript_ReloadMap: MapSetupScript_LinkReturn: mapsetup FadeMapMusicAndPalettes mapsetup DisableLCD + mapsetup DisableDynPalUpdates mapsetup InitSound mapsetup HandleNewMap mapsetup LoadBlockData @@ -149,6 +158,7 @@ MapSetupScript_LinkReturn: mapsetup LoadMapTimeOfDay mapsetup EnableLCD mapsetup LoadMapPalettes + mapsetup EnableDynPalUpdates mapsetup RefreshMapSprites mapsetup PlayMapMusicBike mapsetup FadeInPalettes @@ -159,6 +169,7 @@ MapSetupScript_LinkReturn: MapSetupScript_Continue: mapsetup DisableLCD + mapsetup DisableDynPalUpdates mapsetup InitSound mapsetup LoadMapAttributes_SkipObjects mapsetup GetMapScreenCoords @@ -170,6 +181,7 @@ MapSetupScript_Continue: mapsetup LoadMapTimeOfDay mapsetup EnableLCD mapsetup LoadMapPalettes + mapsetup EnableDynPalUpdates mapsetup RefreshMapSprites mapsetup PlayMapMusicBike mapsetup FadeInPalettes diff --git a/data/sprite_anims/framesets.asm b/data/sprite_anims/framesets.asm index 302bdfe0d..600d668c1 100644 --- a/data/sprite_anims/framesets.asm +++ b/data/sprite_anims/framesets.asm @@ -28,7 +28,7 @@ SpriteAnimFrameData: dw .Frameset_TrademonBubble dw .Frameset_EvolutionBallOfLight dw .Frameset_RadioTuningKnob - dw .Frameset_MagnetTrainRed + dw .Frameset_MagnetTrain dw .Frameset_Unused1C dw .Frameset_Leaf dw .Frameset_CutTree @@ -47,7 +47,6 @@ SpriteAnimFrameData: dw .Frameset_EZChatCursor6 dw .Frameset_EZChatCursor7 dw .Frameset_BlueWalk - dw .Frameset_MagnetTrainBlue dw .Frameset_MobileTradeSentBall dw .Frameset_MobileTradeOTBall dw .Frameset_MobileTradeCableBulge @@ -129,13 +128,6 @@ SpriteAnimFrameData: oamframe SPRITE_ANIM_OAMSET_BLUE_WALK_2, 8, OAM_X_FLIP oamrestart -.Frameset_MagnetTrainBlue: - oamframe SPRITE_ANIM_OAMSET_MAGNET_TRAIN_BLUE_1, 8 - oamframe SPRITE_ANIM_OAMSET_MAGNET_TRAIN_BLUE_2, 8 - oamframe SPRITE_ANIM_OAMSET_MAGNET_TRAIN_BLUE_1, 8 - oamframe SPRITE_ANIM_OAMSET_MAGNET_TRAIN_BLUE_2, 8, OAM_X_FLIP - oamrestart - .Frameset_GSTitleTrail: oamframe SPRITE_ANIM_OAMSET_GS_TITLE_TRAIL_1, 1 oamframe SPRITE_ANIM_OAMSET_GS_TITLE_TRAIL_2, 1 @@ -252,11 +244,11 @@ SpriteAnimFrameData: oamframe SPRITE_ANIM_OAMSET_RADIO_TUNING_KNOB, 32 oamend -.Frameset_MagnetTrainRed: - oamframe SPRITE_ANIM_OAMSET_MAGNET_TRAIN_RED_1, 8 - oamframe SPRITE_ANIM_OAMSET_MAGNET_TRAIN_RED_2, 8 - oamframe SPRITE_ANIM_OAMSET_MAGNET_TRAIN_RED_1, 8 - oamframe SPRITE_ANIM_OAMSET_MAGNET_TRAIN_RED_2, 8, OAM_X_FLIP +.Frameset_MagnetTrain: + oamframe SPRITE_ANIM_OAMSET_MAGNET_TRAIN_1, 8 + oamframe SPRITE_ANIM_OAMSET_MAGNET_TRAIN_2, 8 + oamframe SPRITE_ANIM_OAMSET_MAGNET_TRAIN_1, 8 + oamframe SPRITE_ANIM_OAMSET_MAGNET_TRAIN_2, 8, OAM_X_FLIP oamrestart .Frameset_Unknown1: ; unreferenced diff --git a/data/sprite_anims/oam.asm b/data/sprite_anims/oam.asm index 99ebc6ca0..150a7e083 100644 --- a/data/sprite_anims/oam.asm +++ b/data/sprite_anims/oam.asm @@ -56,24 +56,24 @@ SpriteAnimOAMData: spriteanimoam $3a, .OAMData_1x1_Palette0 ; SPRITE_ANIM_OAMSET_SLOTS_EGG spriteanimoam $00, .OAMData_RedWalk ; SPRITE_ANIM_OAMSET_STILL_CURSOR spriteanimoam $00, .OAMData_TradePokeBall1 ; SPRITE_ANIM_OAMSET_TRADE_POKE_BALL_1 - spriteanimoam $02, .OAMData_MagnetTrainRed ; SPRITE_ANIM_OAMSET_TRADE_POKE_BALL_2 + spriteanimoam $02, .OAMData_MagnetTrain ; SPRITE_ANIM_OAMSET_TRADE_POKE_BALL_2 spriteanimoam $06, .OAMData_TradePoofBubble ; SPRITE_ANIM_OAMSET_TRADE_POOF_1 spriteanimoam $0a, .OAMData_TradePoofBubble ; SPRITE_ANIM_OAMSET_TRADE_POOF_2 spriteanimoam $0e, .OAMData_TradePoofBubble ; SPRITE_ANIM_OAMSET_TRADE_POOF_3 spriteanimoam $12, .OAMData_TradeTubeBulge ; SPRITE_ANIM_OAMSET_TRADE_TUBE_BULGE_1 spriteanimoam $13, .OAMData_TradeTubeBulge ; SPRITE_ANIM_OAMSET_TRADE_TUBE_BULGE_2 - spriteanimoam $00, .OAMData_RedWalk ; SPRITE_ANIM_OAMSET_TRADEMON_ICON_1 - spriteanimoam $04, .OAMData_RedWalk ; SPRITE_ANIM_OAMSET_TRADEMON_ICON_2 + spriteanimoam $00, .OAMData_TradeMonIcon ; SPRITE_ANIM_OAMSET_TRADEMON_ICON_1 + spriteanimoam $04, .OAMData_TradeMonIcon ; SPRITE_ANIM_OAMSET_TRADEMON_ICON_2 spriteanimoam $10, .OAMData_TradePoofBubble ; SPRITE_ANIM_OAMSET_TRADEMON_BUBBLE - spriteanimoam $00, .OAMData_MagnetTrainRed ; SPRITE_ANIM_OAMSET_EVOLUTION_BALL_OF_LIGHT_1 + spriteanimoam $00, .OAMData_MagnetTrain ; SPRITE_ANIM_OAMSET_EVOLUTION_BALL_OF_LIGHT_1 spriteanimoam $04, .OAMData_1x1_Palette0 ; SPRITE_ANIM_OAMSET_EVOLUTION_BALL_OF_LIGHT_2 spriteanimoam $00, .OAMData_RadioTuningKnob ; SPRITE_ANIM_OAMSET_RADIO_TUNING_KNOB spriteanimoam $00, .OAMData_PartyMonWithMail1 ; SPRITE_ANIM_OAMSET_PARTY_MON_WITH_MAIL_1 spriteanimoam $00, .OAMData_PartyMonWithMail2 ; SPRITE_ANIM_OAMSET_PARTY_MON_WITH_MAIL_2 spriteanimoam $00, .OAMData_PartyMonWithItem1 ; SPRITE_ANIM_OAMSET_PARTY_MON_WITH_ITEM_1 spriteanimoam $00, .OAMData_PartyMonWithItem2 ; SPRITE_ANIM_OAMSET_PARTY_MON_WITH_ITEM_2 - spriteanimoam $00, .OAMData_MagnetTrainRed ; SPRITE_ANIM_OAMSET_MAGNET_TRAIN_RED_1 - spriteanimoam $04, .OAMData_MagnetTrainRed ; SPRITE_ANIM_OAMSET_MAGNET_TRAIN_RED_2 + spriteanimoam $00, .OAMData_MagnetTrain ; SPRITE_ANIM_OAMSET_MAGNET_TRAIN_RED_1 + spriteanimoam $04, .OAMData_MagnetTrain ; SPRITE_ANIM_OAMSET_MAGNET_TRAIN_RED_2 spriteanimoam $00, .OAMData_Unused43_4A ; SPRITE_ANIM_OAMSET_UNUSED_43 spriteanimoam $30, .OAMData_Unused43_4A ; SPRITE_ANIM_OAMSET_UNUSED_44 spriteanimoam $03, .OAMData_Unused43_4A ; SPRITE_ANIM_OAMSET_UNUSED_45 @@ -108,8 +108,6 @@ SpriteAnimOAMData: spriteanimoam $00, .OAMData_EZChatCursor7 ; SPRITE_ANIM_OAMSET_EZCHAT_CURSOR_7 spriteanimoam $00, .OAMData_BlueWalk ; SPRITE_ANIM_OAMSET_BLUE_WALK_1 spriteanimoam $04, .OAMData_BlueWalk ; SPRITE_ANIM_OAMSET_BLUE_WALK_2 - spriteanimoam $00, .OAMData_MagnetTrainBlue ; SPRITE_ANIM_OAMSET_MAGNET_TRAIN_BLUE_1 - spriteanimoam $04, .OAMData_MagnetTrainBlue ; SPRITE_ANIM_OAMSET_MAGNET_TRAIN_BLUE_2 spriteanimoam $20, .OAMData_MobileTradeCableBulge ; SPRITE_ANIM_OAMSET_MOBILE_TRADE_CABLE_BULGE_1 spriteanimoam $21, .OAMData_MobileTradeCableBulge ; SPRITE_ANIM_OAMSET_MOBILE_TRADE_CABLE_BULGE_2 spriteanimoam $22, .OAMData_MobileTradePing1 ; SPRITE_ANIM_OAMSET_MOBILE_TRADE_PING_1 @@ -370,7 +368,14 @@ SpriteAnimOAMData: dbsprite -1, 0, 0, 0, $02, PAL_OW_RED dbsprite 0, 0, 0, 0, $03, PAL_OW_RED -.OAMData_MagnetTrainRed: +.OAMData_TradeMonIcon: + db 4 + dsprite -1, 0, -1, 0, $00, $1 + dsprite -1, 0, 0, 0, $01, $1 + dsprite 0, 0, -1, 0, $02, $1 + dsprite 0, 0, 0, 0, $03, $1 + +.OAMData_MagnetTrain: db 4 dbsprite -1, -1, 0, 0, $00, PAL_OW_RED | PRIORITY dbsprite 0, -1, 0, 0, $01, PAL_OW_RED | PRIORITY @@ -468,14 +473,14 @@ SpriteAnimOAMData: .OAMData_Leaf: db 1 - dbsprite -1, -1, 4, 4, $00, PAL_OW_TREE + dbsprite -1, -1, 4, 4, $00, $7 .OAMData_Tree: db 4 - dbsprite -1, -1, 0, 0, $00, PAL_OW_TREE - dbsprite 0, -1, 0, 0, $01, PAL_OW_TREE - dbsprite -1, 0, 0, 0, $02, PAL_OW_TREE - dbsprite 0, 0, 0, 0, $03, PAL_OW_TREE + dbsprite -1, -1, 0, 0, $00, $7 + dbsprite 0, -1, 0, 0, $01, $7 + dbsprite -1, 0, 0, 0, $02, $7 + dbsprite 0, 0, 0, 0, $03, $7 .OAMData_TextEntryCursor: db 4 @@ -593,24 +598,24 @@ SpriteAnimOAMData: .OAMData_CutTree2: db 4 - dbsprite -2, -1, 6, 0, $00, PAL_OW_TREE - dbsprite 0, -1, 2, 0, $01, PAL_OW_TREE - dbsprite -2, 0, 6, 0, $02, PAL_OW_TREE - dbsprite 0, 0, 2, 0, $03, PAL_OW_TREE + dbsprite -2, -1, 6, 0, $00, $7 + dbsprite 0, -1, 2, 0, $01, $7 + dbsprite -2, 0, 6, 0, $02, $7 + dbsprite 0, 0, 2, 0, $03, $7 .OAMData_CutTree3: db 4 - dbsprite -2, -1, 4, 0, $00, PAL_OW_TREE - dbsprite 0, -1, 4, 0, $01, PAL_OW_TREE - dbsprite -2, 0, 4, 0, $02, PAL_OW_TREE - dbsprite 0, 0, 4, 0, $03, PAL_OW_TREE + dbsprite -2, -1, 4, 0, $00, $7 + dbsprite 0, -1, 4, 0, $01, $7 + dbsprite -2, 0, 4, 0, $02, $7 + dbsprite 0, 0, 4, 0, $03, $7 .OAMData_CutTree4: db 4 - dbsprite -2, -1, 0, 0, $00, PAL_OW_TREE - dbsprite 1, -1, 0, 0, $01, PAL_OW_TREE - dbsprite -2, 0, 0, 0, $02, PAL_OW_TREE - dbsprite 1, 0, 0, 0, $03, PAL_OW_TREE + dbsprite -2, -1, 0, 0, $00, $7 + dbsprite 1, -1, 0, 0, $01, $7 + dbsprite -2, 0, 0, 0, $02, $7 + dbsprite 1, 0, 0, 0, $03, $7 .OAMData_GSIntroHoOhLugia1: db 19 @@ -773,13 +778,6 @@ SpriteAnimOAMData: dbsprite -1, 0, 0, 0, $02, PAL_OW_BLUE dbsprite 0, 0, 0, 0, $03, PAL_OW_BLUE -.OAMData_MagnetTrainBlue: - db 4 - dbsprite -1, -1, 0, 0, $00, PAL_OW_BLUE | PRIORITY - dbsprite 0, -1, 0, 0, $01, PAL_OW_BLUE | PRIORITY - dbsprite -1, 0, 0, 0, $02, PAL_OW_BLUE | PRIORITY - dbsprite 0, 0, 0, 0, $03, PAL_OW_BLUE | PRIORITY - .OAMData_MobileTradeCableBulge: db 1 dbsprite -1, -1, 4, 4, $00, 2 @@ -1109,10 +1107,10 @@ SpriteAnimOAMData: .OAMData_Celebi: db 4 - dbsprite -1, -1, 0, 0, $00, PAL_OW_GREEN - dbsprite 0, -1, 0, 0, $01, PAL_OW_GREEN - dbsprite -1, 0, 0, 0, $02, PAL_OW_GREEN - dbsprite 0, 0, 0, 0, $03, PAL_OW_GREEN + dbsprite -1, -1, 0, 0, $00, $7 + dbsprite 0, -1, 0, 0, $01, $7 + dbsprite -1, 0, 0, 0, $02, $7 + dbsprite 0, 0, 0, 0, $03, $7 .OAMData_GameFreakLogo1_3: db 9 diff --git a/data/sprite_anims/objects.asm b/data/sprite_anims/objects.asm index 53b84b3e1..0117e57db 100644 --- a/data/sprite_anims/objects.asm +++ b/data/sprite_anims/objects.asm @@ -44,8 +44,8 @@ SpriteAnimObjects: db SPRITE_ANIM_FRAMESET_EVOLUTION_BALL_OF_LIGHT, SPRITE_ANIM_FUNC_REVEAL_NEW_MON, SPRITE_ANIM_DICT_DEFAULT ; SPRITE_ANIM_OBJ_RADIO_TUNING_KNOB db SPRITE_ANIM_FRAMESET_RADIO_TUNING_KNOB, SPRITE_ANIM_FUNC_RADIO_TUNING_KNOB, SPRITE_ANIM_DICT_DEFAULT -; SPRITE_ANIM_OBJ_MAGNET_TRAIN_RED - db SPRITE_ANIM_FRAMESET_MAGNET_TRAIN_RED, SPRITE_ANIM_FUNC_NULL, SPRITE_ANIM_DICT_DEFAULT +; SPRITE_ANIM_OBJ_MAGNET_TRAIN + db SPRITE_ANIM_FRAMESET_MAGNET_TRAIN, SPRITE_ANIM_FUNC_NULL, SPRITE_ANIM_DICT_DEFAULT ; SPRITE_ANIM_OBJ_LEAF db SPRITE_ANIM_FRAMESET_LEAF, SPRITE_ANIM_FUNC_CUT_LEAVES, SPRITE_ANIM_DICT_DEFAULT ; SPRITE_ANIM_OBJ_CUT_TREE @@ -64,8 +64,6 @@ SpriteAnimObjects: db SPRITE_ANIM_FRAMESET_EZCHAT_CURSOR_1, SPRITE_ANIM_FUNC_EZCHAT_CURSOR, SPRITE_ANIM_DICT_DEFAULT ; SPRITE_ANIM_OBJ_BLUE_WALK db SPRITE_ANIM_FRAMESET_BLUE_WALK, SPRITE_ANIM_FUNC_NULL, SPRITE_ANIM_DICT_DEFAULT -; SPRITE_ANIM_OBJ_MAGNET_TRAIN_BLUE - db SPRITE_ANIM_FRAMESET_MAGNET_TRAIN_BLUE, SPRITE_ANIM_FUNC_NULL, SPRITE_ANIM_DICT_DEFAULT ; SPRITE_ANIM_OBJ_MOBILE_TRADE_SENT_BALL db SPRITE_ANIM_FRAMESET_MOBILE_TRADE_SENT_BALL, SPRITE_ANIM_FUNC_NULL, SPRITE_ANIM_DICT_DEFAULT ; SPRITE_ANIM_OBJ_MOBILE_TRADE_OT_BALL diff --git a/data/sprites/sprites.asm b/data/sprites/sprites.asm index 028d4b669..1c9d6d31d 100644 --- a/data/sprites/sprites.asm +++ b/data/sprites/sprites.asm @@ -101,7 +101,7 @@ OverworldSprites: overworld_sprite FamicomSpriteGFX, 4, STILL_SPRITE, PAL_OW_RED overworld_sprite BerrySpriteGFX, 4, STILL_SPRITE, PAL_OW_TREE overworld_sprite GoldTrophySpriteGFX, 4, STILL_SPRITE, PAL_OW_BROWN - overworld_sprite SilverTrophySpriteGFX, 4, STILL_SPRITE, PAL_OW_SILVER + overworld_sprite SilverTrophySpriteGFX, 4, STILL_SPRITE, PAL_OW_EMOTE_GRAY overworld_sprite KrisSpriteGFX, 12, WALKING_SPRITE, PAL_OW_BLUE overworld_sprite KrisBikeSpriteGFX, 12, WALKING_SPRITE, PAL_OW_BLUE overworld_sprite KurtOutsideSpriteGFX, 12, STANDING_SPRITE, PAL_OW_BROWN diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm index fdf89b608..d357a61c7 100644 --- a/engine/battle/battle_transition.asm +++ b/engine/battle/battle_transition.asm @@ -700,6 +700,8 @@ StartTrainerBattle_LoadPokeBallGraphics: call CopyBytes pop af ldh [rSVBK], a + farcall ClearSavedObjPals + farcall CheckForUsedObjPals ld a, TRUE ldh [hCGBPalUpdate], a call DelayFrame @@ -709,6 +711,7 @@ StartTrainerBattle_LoadPokeBallGraphics: call StartTrainerBattle_NextScene ret +; todo: verify the following (dyn pal) .copypals ld de, wBGPals1 palette PAL_BG_TEXT call .copy diff --git a/engine/events/celebi.asm b/engine/events/celebi.asm index 49e30deb5..074059ff1 100644 --- a/engine/events/celebi.asm +++ b/engine/events/celebi.asm @@ -12,6 +12,10 @@ CelebiShrineEvent: push af xor a ld [wVramState], a + + ld a, PAL_OW_GREEN + farcall CopySpritePalToOBPal7 + call LoadCelebiGFX depixel 0, 10, 7, 0 ld a, SPRITE_ANIM_OBJ_CELEBI diff --git a/engine/events/field_moves.asm b/engine/events/field_moves.asm index 2e7f83683..548b041cf 100644 --- a/engine/events/field_moves.asm +++ b/engine/events/field_moves.asm @@ -22,6 +22,7 @@ BlindingFlash: ret ShakeHeadbuttTree: + farcall CopyBGGreenToOBPal7 farcall ClearSpriteAnims ld de, HeadbuttTreeKantoGFX ; tree frames @@ -400,6 +401,7 @@ endr FlyFunction_InitGFX: callfar ClearSpriteAnims + call SetOWFlyMonColor ld de, CutGrassGFX ld hl, vTiles0 tile FIELDMOVE_GRASS lb bc, BANK(CutGrassGFX), 4 diff --git a/engine/events/heal_machine_anim.asm b/engine/events/heal_machine_anim.asm index a6f049646..d5dcd7561 100644 --- a/engine/events/heal_machine_anim.asm +++ b/engine/events/heal_machine_anim.asm @@ -134,25 +134,25 @@ ENDM ret .PC_ElmsLab_OAM: - dbsprite 4, 4, 2, 0, $7c, PAL_OW_TREE | OBP_NUM - dbsprite 4, 4, 6, 0, $7c, PAL_OW_TREE | OBP_NUM - dbsprite 4, 4, 0, 6, $7d, PAL_OW_TREE | OBP_NUM - dbsprite 5, 4, 0, 6, $7d, PAL_OW_TREE | OBP_NUM | X_FLIP - dbsprite 4, 5, 0, 3, $7d, PAL_OW_TREE | OBP_NUM - dbsprite 5, 5, 0, 3, $7d, PAL_OW_TREE | OBP_NUM | X_FLIP - dbsprite 4, 6, 0, 0, $7d, PAL_OW_TREE | OBP_NUM - dbsprite 5, 6, 0, 0, $7d, PAL_OW_TREE | OBP_NUM | X_FLIP + dbsprite 4, 4, 2, 0, $7c, 7 | OBP_NUM + dbsprite 4, 4, 6, 0, $7c, 7 | OBP_NUM + dbsprite 4, 4, 0, 6, $7d, 7 | OBP_NUM + dbsprite 5, 4, 0, 6, $7d, 7 | OBP_NUM | X_FLIP + dbsprite 4, 5, 0, 3, $7d, 7 | OBP_NUM + dbsprite 5, 5, 0, 3, $7d, 7 | OBP_NUM | X_FLIP + dbsprite 4, 6, 0, 0, $7d, 7 | OBP_NUM + dbsprite 5, 6, 0, 0, $7d, 7 | OBP_NUM | X_FLIP .HealMachineGFX: INCBIN "gfx/overworld/heal_machine.2bpp" .HOF_OAM: - dbsprite 10, 7, 1, 4, $7d, PAL_OW_TREE | OBP_NUM - dbsprite 10, 7, 6, 4, $7d, PAL_OW_TREE | OBP_NUM - dbsprite 9, 7, 5, 3, $7d, PAL_OW_TREE | OBP_NUM - dbsprite 11, 7, 2, 3, $7d, PAL_OW_TREE | OBP_NUM - dbsprite 9, 7, 1, 1, $7d, PAL_OW_TREE | OBP_NUM - dbsprite 11, 7, 5, 1, $7d, PAL_OW_TREE | OBP_NUM + dbsprite 10, 7, 1, 4, $7d, 7 | OBP_NUM + dbsprite 10, 7, 6, 4, $7d, 7 | OBP_NUM + dbsprite 9, 7, 5, 3, $7d, 7 | OBP_NUM + dbsprite 11, 7, 2, 3, $7d, 7 | OBP_NUM + dbsprite 9, 7, 1, 1, $7d, 7 | OBP_NUM + dbsprite 11, 7, 5, 1, $7d, 7 | OBP_NUM .LoadPalettes: call IsCGB @@ -163,7 +163,7 @@ INCBIN "gfx/overworld/heal_machine.2bpp" .cgb ld hl, .palettes - ld de, wOBPals2 palette PAL_OW_TREE + ld de, wOBPals2 palette 7 ld bc, 1 palettes ld a, BANK(wOBPals2) call FarCopyWRAM @@ -200,7 +200,7 @@ INCLUDE "gfx/overworld/heal_machine.pal" ld a, BANK(wOBPals2) ldh [rSVBK], a - ld hl, wOBPals2 palette PAL_OW_TREE + ld hl, wOBPals2 palette 7 ld a, [hli] ld e, a ld a, [hli] diff --git a/engine/events/magnet_train.asm b/engine/events/magnet_train.asm index a9a0f7900..0f4f31d55 100644 --- a/engine/events/magnet_train.asm +++ b/engine/events/magnet_train.asm @@ -293,22 +293,12 @@ MagnetTrain_Jumptable: ret .InitPlayerSpriteAnim: + ld hl, wPalFlags + set USE_DAYTIME_PAL_F, [hl] ld d, (8 + 2) * TILE_WIDTH + 5 ld a, [wMagnetTrainPlayerSpriteInitX] ld e, a - ld b, SPRITE_ANIM_OBJ_MAGNET_TRAIN_RED - ldh a, [rSVBK] - push af - ld a, BANK(wPlayerGender) - ldh [rSVBK], a - ld a, [wPlayerGender] - bit PLAYERGENDER_FEMALE_F, a - jr z, .got_gender - ld b, SPRITE_ANIM_OBJ_MAGNET_TRAIN_BLUE -.got_gender - pop af - ldh [rSVBK], a - ld a, b + ld a, SPRITE_ANIM_OBJ_MAGNET_TRAIN call InitSpriteAnimStruct ld hl, SPRITEANIMSTRUCT_TILE_ID add hl, bc @@ -379,10 +369,11 @@ MagnetTrain_Jumptable: ret .PrepareToFinishAnim: - call .Next - ret + jr .Next .TrainArrived: + ld hl, wPalFlags + res USE_DAYTIME_PAL_F, [hl] ld a, $80 ld [wJumptableIndex], a ld de, SFX_TRAIN_ARRIVED diff --git a/engine/events/overworld.asm b/engine/events/overworld.asm index 139f78af0..adeabef7d 100644 --- a/engine/events/overworld.asm +++ b/engine/events/overworld.asm @@ -214,6 +214,7 @@ Script_Cut: end CutDownTreeOrGrass: + farcall CopyBGGreenToOBPal7 ld hl, wCutWhirlpoolOverworldBlockAddr ld a, [hli] ld h, [hl] @@ -616,6 +617,7 @@ FlyFunction: waitbutton closetext callasm HideSprites + callasm CopyBGGreenToOBPal7 special UpdateTimePals callasm FlyFromAnim farscall Script_AbortBugContest @@ -623,15 +625,16 @@ FlyFunction: callasm SkipUpdateMapSprites loadvar VAR_MOVEMENT, PLAYER_NORMAL newloadmap MAPSETUP_FLY + callasm CopyBGGreenToOBPal7 callasm FlyToAnim special WaitSFX callasm .ReturnFromFly end .ReturnFromFly: - ld e, PAL_OW_RED - farcall SetFirstOBJPalette farcall RespawnPlayer + farcall ClearSavedObjPals + farcall CheckForUsedObjPals call DelayFrame call UpdatePlayerSprite farcall LoadOverworldFont diff --git a/engine/events/specials.asm b/engine/events/specials.asm index fc9350a10..541636d5f 100644 --- a/engine/events/specials.asm +++ b/engine/events/specials.asm @@ -20,8 +20,8 @@ UnusedDummySpecial: SetPlayerPalette: ld a, [wScriptVar] - ld d, a - farcall _SetPlayerPalette + ld [wPlayerPalIndex], a + farcall CheckForUsedObjPals ret GameCornerPrizeMonCheckDex: diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm index d667c8c24..8e4cd36b9 100644 --- a/engine/gfx/color.asm +++ b/engine/gfx/color.asm @@ -1305,15 +1305,24 @@ LoadMapPals: ldh [rSVBK], a .got_pals - ld a, [wTimeOfDayPal] - maskbits NUM_DAYTIMES + ldh a, [rSVBK] + push af + ld a, BANK(wOBPals1) + ldh [rSVBK], a + ld hl, wOBPals1 ld bc, 8 palettes - ld hl, MapObjectPals - call AddNTimes - ld de, wOBPals1 + ld a, $ff + call ByteFill + ld hl, wOBPals2 ld bc, 8 palettes - ld a, BANK(wOBPals1) - call FarCopyWRAM + ld a, $ff + call ByteFill + pop af + ldh [rSVBK], a + farcall ClearSavedObjPals + ld hl, wPalFlags + set NO_DYN_PAL_APPLY_F, [hl] + farcall CheckForUsedObjPals farcall LoadSpecialMapOBPalette farcall LoadSpecialNPCPalette @@ -1440,9 +1449,6 @@ BillsPC_WhitePalette: TilesetBGPalette: INCLUDE "gfx/tilesets/bg_tiles.pal" -MapObjectPals:: -INCLUDE "gfx/overworld/npc_sprites.pal" - RoofPals: table_width PAL_COLOR_SIZE * 3 * 2, RoofPals INCLUDE "gfx/tilesets/roofs.pal" @@ -1454,9 +1460,6 @@ INCLUDE "gfx/diploma/diploma.pal" PartyMenuOBPals: INCLUDE "gfx/stats/party_menu_ob.pal" -UnusedBattleObjectPals: ; unreferenced -INCLUDE "gfx/battle_anims/unused_battle_anims.pal" - UnusedGSTitleBGPals: INCLUDE "gfx/title/unused_gs_bg.pal" diff --git a/engine/gfx/dynamic_pals.asm b/engine/gfx/dynamic_pals.asm new file mode 100644 index 000000000..4cb731eda --- /dev/null +++ b/engine/gfx/dynamic_pals.asm @@ -0,0 +1,171 @@ +ClearSavedObjPals:: + xor a + ld [wUsedObjectPals], a + ld hl, wUsedObjectPals + ld bc, wNeededPalIndex - wUsedObjectPals + ld a, -1 + jp ByteFill + +DisableDynPalUpdates:: + ld hl, wPalFlags + set DISABLE_DYN_PAL_F, [hl] + ret + +EnableDynPalUpdates:: + ld hl, wPalFlags + res DISABLE_DYN_PAL_F, [hl] + ; fallthrough to manually run CheckForUsedObjPals + +CheckForUsedObjPals:: + push hl + push de + push bc + push af + + ld hl, wPalFlags + bit DISABLE_DYN_PAL_F, [hl] + jmp nz, PopAFBCDEHL + + ; reset all wUsedObjectPals bits + xor a + ld [wUsedObjectPals], a + + ; Scan for active objects first and mark those pals still in use. + ld hl, wPalFlags + set SCAN_OBJECTS_FIRST_F, [hl] + call ScanObjectStructPals + + ; Scan for active objects that still need pals loaded + ld hl, wPalFlags + res SCAN_OBJECTS_FIRST_F, [hl] + call ScanObjectStructPals + + ; If this flag was set, it's time to reset it + ld hl, wPalFlags + res NO_DYN_PAL_APPLY_F, [hl] + jmp PopAFBCDEHL + +ScanObjectStructPals: + ld de, wObjectStructs + ld b, NUM_OBJECT_STRUCTS + +.loop + ; Check if the object has a sprite + ld hl, OBJECT_SPRITE + add hl, de + ld a, [hl] + and a + jr z, .skip + + ; Look up the object's requested color palette + ld hl, OBJECT_PAL_INDEX + add hl, de + ld a, [hl] + ld [wNeededPalIndex], a + + ; Mark the palette in use and/or load the palette + call MarkUsedPal + ; Then load the return into OBJECT_PALETTE, which corresponds + ; to OBJ 0 - OBJ 7 + and PALETTE_MASK + ld c, a + ld hl, OBJECT_PALETTE + add hl, de + ld a, [hl] + and ~PALETTE_MASK + or c + ld [hl], a + +.skip + dec b + ret z + + ld hl, OBJECT_LENGTH + add hl, de + ld d, h + ld e, l + jr .loop + +MarkUsedPal: + push hl + push de + push bc + + ; Check if pal is already loaded + lb bc, 8, 0 + ld hl, wLoadedObjPal0 +.loaded_loop + cp [hl] + jr z, .mark_in_use + inc hl + inc c + dec b + jr nz, .loaded_loop + + ; If this is the first pass, we do not want to + ; load any pals yet, just mark the still active pals + ld hl, wPalFlags + bit SCAN_OBJECTS_FIRST_F, [hl] + jr nz, .done + + ld b, a + push bc + + ; Pal is not already loaded, find a empty pal slot + lb bc, 0, 8 + ld hl, wUsedObjectPals + ld a, 1 + ld d, a +.search_again + ld a, d + and [hl] + jr z, .found_empty + ld a, d + rla + ld d, a + inc b + dec c + jr nz, .search_again +.found_empty + ld a, b + pop bc + + ; Save and remember what pal is loaded where + ld c, a + ld a, b + ld b, 0 + ld hl, wLoadedObjPal0 + add hl, bc + ld [hl], a + + ; Copy the needed pal + push bc + ld a, c + ld bc, 1 palettes + ld hl, wOBPals1 + call AddNTimes + ld d, h + ld e, l + call CopySpritePal + pop bc + + ; Set the corresponding bit in wUsedObjectPals + ; A set bit corresponds to a used pal slot +.mark_in_use + push bc + ld hl, wUsedObjectPals + inc c + ld a, 1 +.used_loop + dec c + jr z, .found_used + rla + jr .used_loop +.found_used + or [hl] + ld [hl], a + pop bc + ld a, c + +.done + jmp PopBCDEHL diff --git a/engine/gfx/mon_icons.asm b/engine/gfx/mon_icons.asm index 37dd6912c..4f243011c 100644 --- a/engine/gfx/mon_icons.asm +++ b/engine/gfx/mon_icons.asm @@ -485,6 +485,15 @@ FlyFunction_GetMonIcon: ; hardcoded to pidgeot pop de ld a, e call GetIcon_a +SetOWFlyMonColor: + ld a, PIDGEOT + ld [wCurPartySpecies], a + call GetMenuMonIconPalette_PredeterminedShininess + add a + add a + add a + ld e, a + farcall SetFirstOBJPalette ret GetMemIconGFX: diff --git a/engine/gfx/sprite_palettes.asm b/engine/gfx/sprite_palettes.asm new file mode 100644 index 000000000..eb5162735 --- /dev/null +++ b/engine/gfx/sprite_palettes.asm @@ -0,0 +1,104 @@ +CopyBGGreenToOBPal7: +; Some overworld effects (Fly leaves, Cut leaves, Cut trees, Headbutt trees) +; have hard-coded OB palette 7 in their OAM data. + ld a, PAL_OW_COPY_BG_GREEN + ; fallthrough +CopySpritePalToOBPal7: + ld [wNeededPalIndex], a + ld [wLoadedObjPal7], a + ld de, wOBPals1 palette 7 + ; fallthrough +CopySpritePal:: + push af + push bc + push hl + push de + ld a, [wNeededPalIndex] + sub FIRST_COPY_BG_PAL + jr c, .not_copy_bg + ld hl, wBGPals1 + ld bc, 1 palettes + call AddNTimes + jr .got_pal + +.not_copy_bg + ; check darkness + push hl + push de + call GetMapTimeOfDay + pop de + pop hl + or ~IN_DARKNESS + inc a + jr nz, .not_darkness + ld a, [wStatusFlags] + bit 2, a ; Flash + jr nz, .not_darkness + ld a, [wNeededPalIndex] + cp NUM_OW_TIME_OF_DAY_PALS + jr nc, .not_darkness + ld hl, DarknessOBPalette + ld bc, 1 palettes + call AddNTimes + jr .got_pal + +.not_darkness + ld a, [wNeededPalIndex] + cp NUM_OW_TIME_OF_DAY_PALS + jr c, .time_of_day_pal + ld hl, SingleObjectPals - NUM_OW_TIME_OF_DAY_PALS palettes + ld bc, 1 palettes + call AddNTimes + jr .got_pal + +.time_of_day_pal + ld hl, MapObjectPals + ld bc, 1 palettes + call AddNTimes +.check_daytimes + ld a, [wPalFlags] + bit USE_DAYTIME_PAL_F, a + ld a, DAY + jr nz, .daytime + ld a, [wTimeOfDayPal] +.daytime + maskbits NUM_DAYTIMES + ld bc, NUM_OW_TIME_OF_DAY_PALS palettes + call AddNTimes +.got_pal + pop de + ld bc, 1 palettes + call FarCopyColorWRAM + ld hl, wPalFlags + bit NO_DYN_PAL_APPLY_F, [hl] + jr nz, .skip_apply + call ApplyOBPals + ld a, TRUE + ldh [hCGBPalUpdate], a +.skip_apply + pop af + pop bc + pop hl + ret + +ApplyOBPals: + ld hl, wOBPals1 + ld de, wOBPals2 + ld bc, 8 palettes + ld a, BANK(wGBCPalettes) + jmp FarCopyColorWRAM + +MapObjectPals: + table_width 1 palettes, MapObjectPals +INCLUDE "gfx/overworld/npc_sprites.pal" + assert_table_length NUM_OW_TIME_OF_DAY_PALS * NUM_DAYTIMES ; morn, day, nite, eve + +SingleObjectPals: + table_width 1 palettes, SingleObjectPals +INCLUDE "gfx/overworld/npc_single_object.pal" + assert_table_length NUM_OW_INDIVIDUAL_PALS + +DarknessOBPalette: + table_width 1 palettes, DarknessOBPalette +INCLUDE "gfx/overworld/npc_sprites_darkness.pal" + assert_table_length NUM_OW_TIME_OF_DAY_PALS + NUM_OW_INDIVIDUAL_PALS \ No newline at end of file diff --git a/engine/menus/intro_menu.asm b/engine/menus/intro_menu.asm index 76aee28b8..9341cf14b 100644 --- a/engine/menus/intro_menu.asm +++ b/engine/menus/intro_menu.asm @@ -62,6 +62,7 @@ NewGame: xor a ld [wDebugFlags], a call ResetWRAM + farcall ClearSavedObjPals call NewGame_ClearTilemapEtc call PlayerProfileSetup call OakSpeech @@ -332,6 +333,7 @@ Continue: call Continue_MobileAdapterMenu call CloseWindow call ClearTilemap + farcall ClearSavedObjPals ld c, 20 call DelayFrames farcall JumpRoamMons diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm index 386997155..1c83793ee 100644 --- a/engine/overworld/events.asm +++ b/engine/overworld/events.asm @@ -547,7 +547,6 @@ TryObjectEvent: ld hl, MAPOBJECT_TYPE add hl, bc ld a, [hl] - and MAPOBJECT_TYPE_MASK push bc ld de, 3 diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm index c7578375e..cc0f49c08 100644 --- a/engine/overworld/map_objects.asm +++ b/engine/overworld/map_objects.asm @@ -24,6 +24,7 @@ DeleteMapObject:: ld [hl], -1 .ok pop bc + farcall CheckForUsedObjPals ret HandleObjectStep: @@ -2033,7 +2034,7 @@ SpawnShadow: .ShadowObject: ; vtile, palette, movement - db $00, PAL_OW_EMOTE, SPRITEMOVEDATA_SHADOW + db $00, PAL_OW_EMOTE_GRAY, SPRITEMOVEDATA_SHADOW SpawnStrengthBoulderDust: push bc @@ -2045,7 +2046,7 @@ SpawnStrengthBoulderDust: .BoulderDustObject: ; vtile, palette, movement - db $00, PAL_OW_EMOTE, SPRITEMOVEDATA_BOULDERDUST + db $00, PAL_OW_EMOTE_GRAY, SPRITEMOVEDATA_BOULDERDUST SpawnEmote: push bc @@ -2057,7 +2058,7 @@ SpawnEmote: .EmoteObject: ; vtile, palette, movement - db $00, PAL_OW_EMOTE, SPRITEMOVEDATA_EMOTE + db $00, PAL_OW_EMOTE_BLACK, SPRITEMOVEDATA_EMOTE ShakeGrass: push bc @@ -2069,7 +2070,7 @@ ShakeGrass: .GrassObject: ; vtile, palette, movement - db $00, PAL_OW_TREE, SPRITEMOVEDATA_GRASS + db $00, PAL_OW_COPY_BG_GREEN, SPRITEMOVEDATA_GRASS ShakeScreen: push bc @@ -2084,7 +2085,7 @@ ShakeScreen: .ScreenShakeObject: ; vtile, palette, movement - db $00, PAL_OW_EMOTE, SPRITEMOVEDATA_SCREENSHAKE + db $00, PAL_OW_EMOTE_GRAY, SPRITEMOVEDATA_SCREENSHAKE DespawnEmote: push bc @@ -2511,29 +2512,6 @@ _ContinueSpawnFacing: call SetSpriteDirection ret -_SetPlayerPalette: - ld a, d - and 1 << 7 - ret z - ld bc, 0 ; debug? - ld hl, OBJECT_DIRECTION - add hl, bc - ld a, [hl] - or d - ld [hl], a - ld a, d - swap a - and PALETTE_MASK - ld d, a - ld bc, wPlayerStruct - ld hl, OBJECT_PALETTE - add hl, bc - ld a, [hl] - and ~PALETTE_MASK - or d - ld [hl], a - ret - StartFollow:: push bc ld a, b diff --git a/engine/overworld/overworld.asm b/engine/overworld/overworld.asm index d96f6e385..b4f504073 100644 --- a/engine/overworld/overworld.asm +++ b/engine/overworld/overworld.asm @@ -460,6 +460,7 @@ endr call Get2bpp pop af ldh [rVBK], a + ;farcall CopySpritePal ret LoadEmote:: diff --git a/engine/overworld/player_object.asm b/engine/overworld/player_object.asm index 4dda7f662..11b705a35 100644 --- a/engine/overworld/player_object.asm +++ b/engine/overworld/player_object.asm @@ -29,16 +29,20 @@ SpawnPlayer: call GetMapObject ld hl, MAPOBJECT_PALETTE add hl, bc - ln e, PAL_NPC_RED, OBJECTTYPE_SCRIPT + lb de, PAL_NPC_RED, OBJECTTYPE_SCRIPT ld a, [wPlayerSpriteSetupFlags] bit PLAYERSPRITESETUP_FEMALE_TO_MALE_F, a jr nz, .ok ld a, [wPlayerGender] bit PLAYERGENDER_FEMALE_F, a jr z, .ok - ln e, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT + assert PAL_NPC_RED + 1 == PAL_NPC_BLUE + inc d .ok + ld [hl], d + ld hl, MAPOBJECT_TYPE + add hl, bc ld [hl], e ld a, PLAYER_OBJECT ldh [hMapObjectIndex], a @@ -160,6 +164,7 @@ CopyObjectStruct:: ld hl, OBJECT_FLAGS2 add hl, de set 5, [hl] + farcall CheckForUsedObjPals ret CopyMapObjectToObjectStruct: @@ -191,10 +196,9 @@ CopyMapObjectToObjectStruct: ld hl, MAPOBJECT_PALETTE add hl, bc ld a, [hl] - and MAPOBJECT_PALETTE_MASK + and a jr z, .skip_color_override - swap a - and PALETTE_MASK + dec a ld [wTempObjectCopyPalette], a .skip_color_override @@ -421,9 +425,8 @@ CopyTempObjectToObjectStruct: call CopySpriteMovementData ld a, [wTempObjectCopyPalette] - ld hl, OBJECT_PALETTE + ld hl, OBJECT_PAL_INDEX add hl, de - or [hl] ld [hl], a ld a, [wTempObjectCopyY] @@ -458,6 +461,7 @@ CopyTempObjectToObjectStruct: add hl, de ld [hl], a + farcall CheckForUsedObjPals and a ret diff --git a/gfx/battle_anims/unused_battle_anims.pal b/gfx/battle_anims/unused_battle_anims.pal deleted file mode 100644 index 4ef48dd0d..000000000 --- a/gfx/battle_anims/unused_battle_anims.pal +++ /dev/null @@ -1,30 +0,0 @@ -; gray - RGB 31, 31, 31 - RGB 21, 21, 21 - RGB 13, 13, 13 - RGB 07, 07, 07 -; yellow - RGB 31, 31, 31 - RGB 31, 31, 07 - RGB 31, 16, 01 - RGB 07, 07, 07 -; red - RGB 31, 31, 31 - RGB 31, 19, 24 - RGB 30, 10, 06 - RGB 07, 07, 07 -; green - RGB 31, 31, 31 - RGB 12, 25, 01 - RGB 05, 14, 00 - RGB 07, 07, 07 -; blue - RGB 31, 31, 31 - RGB 08, 12, 31 - RGB 01, 04, 31 - RGB 07, 07, 07 -; brown - RGB 31, 31, 31 - RGB 24, 18, 07 - RGB 20, 15, 03 - RGB 07, 07, 07 diff --git a/gfx/overworld/npc_single_object.pal b/gfx/overworld/npc_single_object.pal new file mode 100644 index 000000000..c2f8d0a3c --- /dev/null +++ b/gfx/overworld/npc_single_object.pal @@ -0,0 +1,7 @@ + RGB 31,31,31, 31,31,31, 13,13,13, 00,00,00 ; emote gray + RGB 31,31,31, 31,31,31, 00,00,00, 00,00,00 ; emote black + RGB 31,31,31, 31,31,31, 02,23,02, 00,00,00 ; emote green + RGB 31,31,31, 31,31,31, 23,02,23, 00,00,00 ; emote purple + RGB 31,31,31, 31,31,31, 31,00,00, 00,00,00 ; emote red + RGB 31,31,31, 31,31,31, 31,16,01, 00,00,00 ; emote orange + RGB 31,31,31, 31,31,31, 00,00,31, 00,00,00 ; emote blue diff --git a/gfx/overworld/npc_sprites.pal b/gfx/overworld/npc_sprites.pal index 1ddf4117f..0c280ca4a 100644 --- a/gfx/overworld/npc_sprites.pal +++ b/gfx/overworld/npc_sprites.pal @@ -1,39 +1,75 @@ ; morn - RGB 28,31,16, 31,19,10, 31,07,01, 00,00,00 ; red - RGB 28,31,16, 31,19,10, 10,09,31, 00,00,00 ; blue - RGB 28,31,16, 31,19,10, 04,19,00, 00,00,00 ; green - RGB 28,31,16, 31,19,10, 15,10,03, 00,00,00 ; brown - RGB 28,31,16, 31,19,10, 27,07,16, 00,00,00 ; pink - RGB 31,31,31, 31,31,31, 10,10,10, 00,00,00 ; silver + RGB 28,31,16, 31,22,10, 31,07,01, 00,00,00 ; red + RGB 28,31,16, 31,22,10, 10,09,31, 00,00,00 ; blue + RGB 28,31,16, 31,22,10, 07,23,03, 00,00,00 ; green + RGB 28,31,16, 31,22,10, 15,10,03, 00,00,00 ; brown + RGB 28,31,16, 31,22,10, 18,04,18, 00,00,00 ; purple + RGB 28,31,16, 31,22,10, 13,13,13, 00,00,00 ; gray + RGB 28,31,16, 31,22,10, 31,10,11, 00,00,00 ; pink + RGB 28,31,16, 31,22,10, 03,23,21, 00,00,00 ; teal + RGB 28,31,16, 31,22,10, 25,25,00, 00,00,00 ; yellow + RGB 28,31,16, 31,22,10, 31,13,00, 00,00,00 ; orange + RGB 28,31,16, 31,22,10, 04,18,31, 00,00,00 ; azure + RGB 28,31,16, 28,31,16, 20,20,20, 00,00,00 ; white + RGB 28,31,16, 31,22,10, 10,10,10, 00,00,00 ; black + RGB 28,31,16, 28,31,16, 31,07,01, 00,00,00 ; poke ball + RGB 28,31,16, 28,31,16, 10,09,31, 00,00,00 ; deco item + RGB 28,31,16, 28,31,16, 07,23,03, 00,00,00 ; key item RGB 22,31,10, 12,25,01, 05,14,00, 07,07,07 ; tree - RGB 28,31,16, 24,18,07, 20,15,03, 07,07,07 ; rock ; day RGB 27,31,27, 31,19,10, 31,07,01, 00,00,00 ; red RGB 27,31,27, 31,19,10, 10,09,31, 00,00,00 ; blue - RGB 27,31,27, 31,19,10, 04,19,00, 00,00,00 ; green + RGB 27,31,27, 31,19,10, 07,23,03, 00,00,00 ; green RGB 27,31,27, 31,19,10, 15,10,03, 00,00,00 ; brown - RGB 27,31,27, 31,19,10, 27,07,16, 00,00,00 ; pink - RGB 31,31,31, 31,31,31, 10,10,10, 00,00,00 ; silver + RGB 27,31,27, 31,19,10, 18,04,18, 00,00,00 ; purple + RGB 27,31,27, 31,19,10, 13,13,13, 00,00,00 ; gray + RGB 27,31,27, 31,19,10, 31,10,11, 00,00,00 ; pink + RGB 27,31,27, 31,19,10, 03,23,21, 00,00,00 ; teal + RGB 27,31,27, 31,19,10, 25,25,00, 00,00,00 ; yellow + RGB 27,31,27, 31,19,10, 31,13,00, 00,00,00 ; orange + RGB 27,31,27, 31,19,10, 04,18,31, 00,00,00 ; azure + RGB 27,31,27, 27,31,27, 20,20,20, 00,00,00 ; white + RGB 27,31,27, 31,19,10, 10,10,10, 00,00,00 ; black + RGB 27,31,27, 27,31,27, 31,07,01, 00,00,00 ; poke ball + RGB 27,31,27, 27,31,27, 10,09,31, 00,00,00 ; deco item + RGB 27,31,27, 27,31,27, 07,23,03, 00,00,00 ; key item RGB 22,31,10, 12,25,01, 05,14,00, 07,07,07 ; tree - RGB 27,31,27, 24,18,07, 20,15,03, 07,07,07 ; rock ; nite - RGB 15,14,24, 31,19,10, 31,07,01, 00,00,00 ; red - RGB 15,14,24, 31,19,10, 10,09,31, 00,00,00 ; blue - RGB 15,14,24, 31,19,10, 04,19,00, 00,00,00 ; green - RGB 15,14,24, 31,19,10, 15,10,03, 00,00,00 ; brown - RGB 15,14,24, 31,19,10, 27,07,16, 00,00,00 ; pink - RGB 31,31,31, 31,31,31, 10,10,10, 00,00,00 ; silver + RGB 15,14,24, 16,09,09, 17,03,00, 00,00,00 ; red + RGB 15,14,24, 16,09,09, 05,04,27, 00,00,00 ; blue + RGB 15,14,24, 16,09,09, 03,10,02, 00,00,00 ; green + RGB 15,14,24, 16,09,09, 08,04,02, 00,00,00 ; brown + RGB 15,14,24, 16,09,09, 10,01,16, 00,00,00 ; purple + RGB 15,14,24, 16,09,09, 07,07,10, 00,00,00 ; gray + RGB 15,14,24, 16,09,09, 17,07,08, 00,00,00 ; pink + RGB 15,14,24, 16,09,09, 02,12,16, 00,00,00 ; teal + RGB 15,14,24, 16,09,09, 12,12,00, 00,00,00 ; yellow + RGB 15,14,24, 16,09,09, 17,08,00, 00,00,00 ; orange + RGB 15,14,24, 16,09,09, 02,09,27, 00,00,00 ; azure + RGB 15,14,24, 15,14,24, 10,10,15, 00,00,00 ; white + RGB 15,14,24, 16,09,09, 05,05,08, 00,00,00 ; black + RGB 15,14,24, 15,14,24, 17,03,00, 00,00,00 ; poke ball + RGB 15,14,24, 15,14,24, 05,04,27, 00,00,00 ; deco item + RGB 15,14,24, 15,14,24, 03,10,02, 00,00,00 ; key item RGB 15,14,24, 08,13,19, 00,11,13, 00,00,00 ; tree - RGB 15,14,24, 12,09,15, 08,04,05, 00,00,00 ; rock ; eve - RGB 29,21,14, 31,19,10, 31,07,01, 00,00,00 ; red - RGB 29,21,14, 31,19,10, 10,09,31, 00,00,00 ; blue - RGB 29,21,14, 31,19,10, 04,19,00, 00,00,00 ; green - RGB 29,21,14, 31,19,10, 15,10,03, 00,00,00 ; brown - RGB 29,21,14, 31,19,10, 27,07,16, 00,00,00 ; pink - RGB 31,31,31, 31,31,31, 10,10,10, 00,00,00 ; silver - RGB 23,23,08, 11,19,01, 05,10,00, 06,05,05 ; tree - RGB 29,21,14, 21,13,05, 16,09,01, 06,05,05 ; rock + RGB 31,21,14, 31,19,10, 31,07,01, 00,00,00 ; red + RGB 31,21,14, 31,19,10, 10,09,31, 00,00,00 ; blue + RGB 31,21,14, 31,19,10, 07,23,03, 00,00,00 ; green + RGB 31,21,14, 31,19,10, 15,10,03, 00,00,00 ; brown + RGB 31,21,14, 31,19,10, 18,04,18, 00,00,00 ; purple + RGB 31,21,14, 31,19,10, 13,13,13, 00,00,00 ; gray + RGB 31,21,14, 31,19,10, 31,10,11, 00,00,00 ; pink + RGB 31,21,14, 31,19,10, 03,23,21, 00,00,00 ; teal + RGB 31,21,14, 31,21,14, 25,25,00, 00,00,00 ; yellow + RGB 31,21,14, 31,22,10, 31,13,00, 00,00,00 ; orange + RGB 31,21,14, 31,22,10, 04,18,31, 00,00,00 ; azure + RGB 31,21,14, 31,21,14, 20,20,20, 00,00,00 ; white + RGB 31,21,14, 31,22,10, 10,10,10, 00,00,00 ; black + RGB 31,21,14, 31,21,14, 31,07,01, 00,00,00 ; poke ball + RGB 31,21,14, 31,21,14, 10,09,31, 00,00,00 ; deco item + RGB 31,21,14, 31,21,14, 07,23,03, 00,00,00 ; key item + RGB 19,23,08, 10,19,01, 04,10,00, 06,05,05 ; tree diff --git a/gfx/overworld/npc_sprites_darkness.pal b/gfx/overworld/npc_sprites_darkness.pal index b77b656a0..55150de68 100644 --- a/gfx/overworld/npc_sprites_darkness.pal +++ b/gfx/overworld/npc_sprites_darkness.pal @@ -1,10 +1,24 @@ -; dark - RGB 01,01,02, 31,19,10, 31,07,01, 00,00,00 ; red - RGB 01,01,02, 31,19,10, 10,09,31, 00,00,00 ; blue - RGB 01,01,02, 31,19,10, 04,19,00, 00,00,00 ; green - RGB 01,01,02, 31,19,10, 15,10,03, 00,00,00 ; brown - RGB 01,01,02, 31,19,10, 30,10,06, 00,00,00 ; pink - RGB 31,31,31, 31,31,31, 13,13,13, 00,00,00 ; silver + RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; red + RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; blue + RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; green + RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; brown + RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; purple + RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; gray + RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; pink + RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; teal + RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; yellow + RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; orange + RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; azure + RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; white + RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; black + RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; poke ball + RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; deco item + RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; key item RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; tree - RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; rock - \ No newline at end of file + RGB 31,31,31, 31,31,31, 13,13,13, 00,00,00 ; emote gray + RGB 31,31,31, 31,31,31, 00,00,00, 00,00,00 ; emote black + RGB 31,31,31, 31,31,31, 02,23,02, 00,00,00 ; emote green + RGB 31,31,31, 31,31,31, 23,02,23, 00,00,00 ; emote purple + RGB 31,31,31, 31,31,31, 31,00,00, 00,00,00 ; emote red + RGB 31,31,31, 31,31,31, 31,16,01, 00,00,00 ; emote orange + RGB 31,31,31, 31,31,31, 00,00,31, 00,00,00 ; emote blue diff --git a/home/header.asm b/home/header.asm index 8a5a3776c..37cfe98ba 100644 --- a/home/header.asm +++ b/home/header.asm @@ -44,7 +44,8 @@ JumpTable:: SECTION "rst38", ROM0[$0038] rst $38 - +PopAFBCDEHL:: + pop af PopBCDEHL:: pop bc pop de diff --git a/home/map_objects.asm b/home/map_objects.asm index 20eb8e441..704797d4a 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -227,11 +227,6 @@ CheckObjectVisibility:: ret CheckObjectTime:: - ld hl, MAPOBJECT_HOUR_1 - add hl, bc - ld a, [hl] - cp -1 - jr nz, .check_hour ld hl, MAPOBJECT_TIMEOFDAY add hl, bc ld a, [hl] @@ -264,43 +259,6 @@ CheckObjectTime:: db NITE db EVE -.check_hour - ld hl, MAPOBJECT_HOUR_1 - add hl, bc - ld d, [hl] - ld hl, MAPOBJECT_HOUR_2 - add hl, bc - ld e, [hl] - ld hl, hHours - ld a, d - cp e - jr z, .yes - jr c, .check_timeofday - ld a, [hl] - cp d - jr nc, .yes - cp e - jr c, .yes - jr z, .yes - jr .no - -.check_timeofday - ld a, e - cp [hl] - jr c, .no - ld a, [hl] - cp d - jr nc, .yes - jr .no - -.yes - and a - ret - -.no - scf - ret - UnmaskCopyMapObjectStruct:: ldh [hMapObjectIndex], a call UnmaskObject diff --git a/home/menu.asm b/home/menu.asm index 33ed2ec32..2a8661d06 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -70,6 +70,7 @@ PushWindow:: ExitMenu:: push af callfar _ExitMenu + farcall ClearSavedObjPals pop af ret diff --git a/home/trainers.asm b/home/trainers.asm index cf449e4fd..fc37bb89b 100644 --- a/home/trainers.asm +++ b/home/trainers.asm @@ -34,7 +34,6 @@ _CheckTrainerBattle:: ld hl, MAPOBJECT_TYPE add hl, de ld a, [hl] - and MAPOBJECT_TYPE_MASK cp OBJECTTYPE_TRAINER jr nz, .next diff --git a/macros/legacy.asm b/macros/legacy.asm index 68310da68..f3dcb6164 100644 --- a/macros/legacy.asm +++ b/macros/legacy.asm @@ -402,6 +402,3 @@ DEF happinesschecknpc EQUS "HappinessCheckScript" ; constants/sprite_constants.asm DEF SPRITE_BUENA EQUS "SPRITE_BEAUTY" - -DEF PAL_NPC_SILVER EQUS "PAL_NPC_EMOTE" -DEF PAL_OW_SILVER EQUS "PAL_OW_EMOTE" diff --git a/macros/ram.asm b/macros/ram.asm index a7b670860..2527b4eeb 100644 --- a/macros/ram.asm +++ b/macros/ram.asm @@ -368,7 +368,8 @@ MACRO object_struct \1Field1e:: ds 1 \1JumpHeight:: db \1Range:: db - ds 7 +\1PalIndex:: db + ds 6 \1StructEnd:: ENDM @@ -379,10 +380,8 @@ MACRO map_object \1ObjectXCoord:: db \1ObjectMovement:: db \1ObjectRadius:: db -\1ObjectHour1:: db -\1ObjectHour2:: +\1ObjectPalette:: db \1ObjectTimeOfDay:: db -\1ObjectPalette:: \1ObjectType:: db \1ObjectSightRange:: db \1ObjectScript:: dw diff --git a/macros/scripts/maps.asm b/macros/scripts/maps.asm index 1181ba543..125126a35 100644 --- a/macros/scripts/maps.asm +++ b/macros/scripts/maps.asm @@ -103,6 +103,7 @@ MACRO def_object_events ENDM MACRO object_event +; TODO: Remove unused argument \7 (Old HOUR_1) ;\1: x: left to right, starts at 0 ;\2: y: top to bottom, starts at 0 ;\3: sprite: a SPRITE_* constant @@ -121,8 +122,8 @@ MACRO object_event ;\<13>: event flag: an EVENT_* constant, or -1 to always appear db \3, \2 + 4, \1 + 4, \4 dn \6, \5 - db \7, \8 - dn \9, \<10> + db \9, \8 + db \<10> db \<11> dw \<12>, \<13> ; the dummy PlayerObjectTemplate object_event has no def_object_events diff --git a/main.asm b/main.asm index 2a4ee3d3f..77c5f2540 100644 --- a/main.asm +++ b/main.asm @@ -816,6 +816,12 @@ SECTION "VWF", ROMX INCLUDE "engine/gfx/vwf.asm" +SECTION "Dynamic Pals System", ROMX + +INCLUDE "engine/gfx/sprite_palettes.asm" +INCLUDE "engine/gfx/dynamic_pals.asm" + + SECTION "Stadium 2 Checksums", ROMX[$7DE0], BANK[$7F] ; The end of the ROM is taken up by checksums of the content, apparently used diff --git a/maps/BurnedTowerB1F.asm b/maps/BurnedTowerB1F.asm index 8a4e2558e..d5b91dd39 100644 --- a/maps/BurnedTowerB1F.asm +++ b/maps/BurnedTowerB1F.asm @@ -258,9 +258,9 @@ BurnedTowerB1F_MapEvents: object_event 7, 3, SPRITE_RAIKOU, SPRITEMOVEDATA_POKEMON, 0, 0, -1, -1, PAL_NPC_BROWN, OBJECTTYPE_SCRIPT, 0, ObjectEvent, EVENT_BURNED_TOWER_B1F_BEASTS_1 object_event 12, 3, SPRITE_ENTEI, SPRITEMOVEDATA_POKEMON, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, ObjectEvent, EVENT_BURNED_TOWER_B1F_BEASTS_1 object_event 10, 4, SPRITE_SUICUNE, SPRITEMOVEDATA_POKEMON, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT, 0, ObjectEvent, EVENT_BURNED_TOWER_B1F_BEASTS_1 - object_event 7, 3, SPRITE_RAIKOU, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_EMOTE, OBJECTTYPE_SCRIPT, 0, ObjectEvent, EVENT_BURNED_TOWER_B1F_BEASTS_2 - object_event 12, 3, SPRITE_ENTEI, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_EMOTE, OBJECTTYPE_SCRIPT, 0, ObjectEvent, EVENT_BURNED_TOWER_B1F_BEASTS_2 - object_event 10, 4, SPRITE_SUICUNE, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_EMOTE, OBJECTTYPE_SCRIPT, 0, ObjectEvent, EVENT_BURNED_TOWER_B1F_BEASTS_2 + object_event 7, 3, SPRITE_RAIKOU, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_SILVER, OBJECTTYPE_SCRIPT, 0, ObjectEvent, EVENT_BURNED_TOWER_B1F_BEASTS_2 + object_event 12, 3, SPRITE_ENTEI, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_SILVER, OBJECTTYPE_SCRIPT, 0, ObjectEvent, EVENT_BURNED_TOWER_B1F_BEASTS_2 + object_event 10, 4, SPRITE_SUICUNE, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_SILVER, OBJECTTYPE_SCRIPT, 0, ObjectEvent, EVENT_BURNED_TOWER_B1F_BEASTS_2 object_event 16, 4, SPRITE_POKE_BALL, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_ITEMBALL, 0, BurnedTowerB1FTMEndure, EVENT_BURNED_TOWER_B1F_TM_ENDURE object_event 10, 12, SPRITE_SUPER_NERD, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT, 0, BurnedTowerB1FEusine, EVENT_EUSINE_IN_BURNED_TOWER object_event 6, 13, SPRITE_ROCK, SPRITEMOVEDATA_SMASHABLE_ROCK, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, BurnedTowerB1FRock, -1 diff --git a/maps/CopycatsHouse2F.asm b/maps/CopycatsHouse2F.asm index 378c9a6a8..19a788d19 100644 --- a/maps/CopycatsHouse2F.asm +++ b/maps/CopycatsHouse2F.asm @@ -36,12 +36,14 @@ Copycat: iftrue .Default_Female_1 applymovement COPYCATSHOUSE2F_COPYCAT1, CopycatSpinAroundMovementData faceplayer + loadmem wObject1Palette, 0 variablesprite SPRITE_COPYCAT, SPRITE_CHRIS sjump .Default_Merge_1 .Default_Female_1: applymovement COPYCATSHOUSE2F_COPYCAT2, CopycatSpinAroundMovementData faceplayer + loadmem wObject1Palette, 0 variablesprite SPRITE_COPYCAT, SPRITE_KRIS .Default_Merge_1: special LoadUsedSpritesGFX @@ -67,6 +69,7 @@ Copycat: applymovement COPYCATSHOUSE2F_COPYCAT2, CopycatSpinAroundMovementData .Default_Merge_3a: faceplayer + loadmem wObject1Palette, 1 variablesprite SPRITE_COPYCAT, SPRITE_LASS special LoadUsedSpritesGFX opentext @@ -96,6 +99,7 @@ Copycat: applymovement COPYCATSHOUSE2F_COPYCAT2, CopycatSpinAroundMovementData .Default_Merge_3b: faceplayer + loadmem wObject1Palette, 1 variablesprite SPRITE_COPYCAT, SPRITE_LASS special LoadUsedSpritesGFX opentext @@ -132,12 +136,14 @@ Copycat: iftrue .GotPass_Female_1 applymovement COPYCATSHOUSE2F_COPYCAT1, CopycatSpinAroundMovementData faceplayer + loadmem wObject1Palette, 0 variablesprite SPRITE_COPYCAT, SPRITE_CHRIS sjump .GotPass_Merge_1 .GotPass_Female_1: applymovement COPYCATSHOUSE2F_COPYCAT2, CopycatSpinAroundMovementData faceplayer + loadmem wObject1Palette, 0 variablesprite SPRITE_COPYCAT, SPRITE_KRIS .GotPass_Merge_1: special LoadUsedSpritesGFX diff --git a/ram/wram.asm b/ram/wram.asm index e1f8bbc35..d24a6c337 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -131,7 +131,9 @@ wUnusedScriptByte:: db wMapTimeOfDay:: db - ds 3 +wPalFlags:: db + + ds 2 wPrinterConnectionOpen:: db wPrinterOpcode:: db @@ -2969,8 +2971,6 @@ wStartSecond:: db wRTC:: ds 4 - ds 4 - wDST:: ; bit 7: dst db @@ -3004,8 +3004,13 @@ endr wStoneTableAddress:: dw - ds 24 - + ds 14 + +wUsedObjectPals:: db +for n, 8 +wLoadedObjPal{d:n}:: db +endr +wNeededPalIndex:: db wBerryPocketCursor:: db wBerryPocketScrollPosition:: db @@ -3104,7 +3109,7 @@ wPlayerState:: db wHallOfFameCount:: db ds 1 wTradeFlags:: flag_array NUM_NPC_TRADES - ds 1 +wEmotePal:: db wMooMooBerries:: db wUndergroundSwitchPositions:: db wFarfetchdPosition:: db From f367da7a32c7312d9c8b90a50ea73f3928f3893d Mon Sep 17 00:00:00 2001 From: vulcandth Date: Tue, 30 Jan 2024 20:15:58 -0600 Subject: [PATCH 05/11] Some Dynamic Pal Improvements --- data/maps/setup_scripts.asm | 2 ++ engine/battle/battle_transition.asm | 1 + engine/events/overworld.asm | 1 + engine/gfx/color.asm | 3 --- engine/gfx/dynamic_pals.asm | 29 +++++++++++++++++++++++++++-- engine/menus/start_menu.asm | 8 +++----- home/map.asm | 8 ++++++++ home/menu.asm | 1 - 8 files changed, 42 insertions(+), 11 deletions(-) diff --git a/data/maps/setup_scripts.asm b/data/maps/setup_scripts.asm index 6106830be..1195b52c3 100644 --- a/data/maps/setup_scripts.asm +++ b/data/maps/setup_scripts.asm @@ -90,6 +90,7 @@ MapSetupScript_Connection: mapsetup LoadMapObjects mapsetup FadeToMapMusic mapsetup LoadMapPalettes + mapsetup EnableDynPalUpdates mapsetup InitMapNameSign mapsetup ApplyMapPalettes mapsetup LoadWildMonData @@ -117,6 +118,7 @@ MapSetupScript_Train: mapsetup EnableLCD mapsetup LoadMapObjects mapsetup LoadMapPalettes + mapsetup RefreshMapSprites mapsetup EnableDynPalUpdates mapsetup RefreshMapSprites mapsetup FadeToMapMusic diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm index d357a61c7..976003bf4 100644 --- a/engine/battle/battle_transition.asm +++ b/engine/battle/battle_transition.asm @@ -702,6 +702,7 @@ StartTrainerBattle_LoadPokeBallGraphics: ldh [rSVBK], a farcall ClearSavedObjPals farcall CheckForUsedObjPals + farcall _UpdateSprites ld a, TRUE ldh [hCGBPalUpdate], a call DelayFrame diff --git a/engine/events/overworld.asm b/engine/events/overworld.asm index adeabef7d..84cfa7036 100644 --- a/engine/events/overworld.asm +++ b/engine/events/overworld.asm @@ -617,6 +617,7 @@ FlyFunction: waitbutton closetext callasm HideSprites + callasm ClearSavedObjPals callasm CopyBGGreenToOBPal7 special UpdateTimePals callasm FlyFromAnim diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm index 8e4cd36b9..086a52c98 100644 --- a/engine/gfx/color.asm +++ b/engine/gfx/color.asm @@ -1320,9 +1320,6 @@ LoadMapPals: pop af ldh [rSVBK], a farcall ClearSavedObjPals - ld hl, wPalFlags - set NO_DYN_PAL_APPLY_F, [hl] - farcall CheckForUsedObjPals farcall LoadSpecialMapOBPalette farcall LoadSpecialNPCPalette diff --git a/engine/gfx/dynamic_pals.asm b/engine/gfx/dynamic_pals.asm index 4cb731eda..50d9d7440 100644 --- a/engine/gfx/dynamic_pals.asm +++ b/engine/gfx/dynamic_pals.asm @@ -1,19 +1,32 @@ ClearSavedObjPals:: + ldh a, [rSVBK] + push af + ld a, BANK(wUsedObjectPals) + ldh [rSVBK], a + xor a ld [wUsedObjectPals], a ld hl, wUsedObjectPals ld bc, wNeededPalIndex - wUsedObjectPals ld a, -1 - jp ByteFill + call ByteFill + + pop af + ldh [rSVBK], a + ret DisableDynPalUpdates:: + push hl ld hl, wPalFlags set DISABLE_DYN_PAL_F, [hl] + pop hl ret EnableDynPalUpdates:: + push hl ld hl, wPalFlags res DISABLE_DYN_PAL_F, [hl] + pop hl ; fallthrough to manually run CheckForUsedObjPals CheckForUsedObjPals:: @@ -22,9 +35,14 @@ CheckForUsedObjPals:: push bc push af + ldh a, [rSVBK] + push af + ld a, BANK(wUsedObjectPals) + ldh [rSVBK], a + ld hl, wPalFlags bit DISABLE_DYN_PAL_F, [hl] - jmp nz, PopAFBCDEHL + jr nz, .done ; reset all wUsedObjectPals bits xor a @@ -43,6 +61,9 @@ CheckForUsedObjPals:: ; If this flag was set, it's time to reset it ld hl, wPalFlags res NO_DYN_PAL_APPLY_F, [hl] +.done + pop af + ldh [rSVBK], a jmp PopAFBCDEHL ScanObjectStructPals: @@ -67,6 +88,7 @@ ScanObjectStructPals: call MarkUsedPal ; Then load the return into OBJECT_PALETTE, which corresponds ; to OBJ 0 - OBJ 7 + jr nc, .skip and PALETTE_MASK ld c, a ld hl, OBJECT_PALETTE @@ -106,6 +128,8 @@ MarkUsedPal: ; load any pals yet, just mark the still active pals ld hl, wPalFlags bit SCAN_OBJECTS_FIRST_F, [hl] + scf + ccf jr nz, .done ld b, a @@ -167,5 +191,6 @@ MarkUsedPal: pop bc ld a, c + scf .done jmp PopBCDEHL diff --git a/engine/menus/start_menu.asm b/engine/menus/start_menu.asm index 06ce0ef89..fd5936a91 100644 --- a/engine/menus/start_menu.asm +++ b/engine/menus/start_menu.asm @@ -143,10 +143,8 @@ StartMenu:: jr .ReturnEnd2 .ReturnRedraw: - call .Clear - jp .Reopen - -.Clear: + farcall ClearSavedObjPals + farcall DisableDynPalUpdates call ClearBGPalettes call Call_ExitMenu call ReloadTilesetAndPalettes @@ -157,7 +155,7 @@ StartMenu:: call UpdateSprites call GSReloadPalettes call FinishExitMenu - ret + jp .Reopen .MenuHeader: db MENU_BACKUP_TILES ; flags diff --git a/home/map.asm b/home/map.asm index f6bef5110..014c75ba4 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1901,6 +1901,8 @@ FadeToMenu:: ret CloseSubmenu:: + farcall ClearSavedObjPals + farcall DisableDynPalUpdates call ClearBGPalettes call ReloadTilesetAndPalettes call UpdateSprites @@ -1909,6 +1911,8 @@ CloseSubmenu:: jr FinishExitMenu ExitAllMenus:: + farcall ClearSavedObjPals + farcall DisableDynPalUpdates call ClearBGPalettes call Call_ExitMenu call ReloadTilesetAndPalettes @@ -1920,6 +1924,7 @@ FinishExitMenu:: farcall LoadOW_BGPal7 call WaitBGMap2 farcall FadeInPalettes + farcall EnableDynPalUpdates call EnableSpriteUpdates ret @@ -1929,6 +1934,8 @@ ReturnToMapWithSpeechTextbox:: ld [wSpriteUpdatesEnabled], a call ClearBGPalettes call ClearSprites + farcall ClearSavedObjPals + farcall DisableDynPalUpdates call ReloadTilesetAndPalettes hlcoord 0, 12 lb bc, 4, 18 @@ -1941,6 +1948,7 @@ ReturnToMapWithSpeechTextbox:: call GetSGBLayout farcall LoadOW_BGPal7 call UpdateTimePals + farcall EnableDynPalUpdates call DelayFrame ld a, $1 ldh [hMapAnims], a diff --git a/home/menu.asm b/home/menu.asm index 2a8661d06..33ed2ec32 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -70,7 +70,6 @@ PushWindow:: ExitMenu:: push af callfar _ExitMenu - farcall ClearSavedObjPals pop af ret From 70b5ac225eb2bbf9b4a1234b379d9b72fb79c75d Mon Sep 17 00:00:00 2001 From: vulcandth Date: Fri, 16 Feb 2024 20:49:58 -0600 Subject: [PATCH 06/11] Various Dynamic Pal Fixes * Fix TimeOfDay pal transitions * Fix DynPal comap with pal fade * Fix DynPal Flash in Darkness and FadeInPalettes * Fix for FastShip CaptainsCabin scene transition resolves #18 --- data/events/special_pointers.asm | 1 + data/maps/setup_script_pointers.asm | 1 + data/maps/setup_scripts.asm | 13 ++++++------- engine/events/field_moves.asm | 2 +- engine/events/pokepic.asm | 1 + engine/events/sacred_ash.asm | 9 ++++----- engine/gfx/dynamic_pals.asm | 8 ++++++++ engine/gfx/mon_icons.asm | 2 ++ engine/tilesets/timeofday_pals.asm | 4 ++++ home/map.asm | 3 +-- home/palettes.asm | 15 +++++++++++++++ maps/BattleTowerBattleRoom.asm | 2 +- maps/BluesHouse.asm | 3 ++- maps/FastShipCabins_SE_SSE_CaptainsCabin.asm | 6 +++++- maps/GoldenrodUnderground.asm | 6 ++++-- maps/OlivineLighthouse6F.asm | 9 ++++++--- maps/TeamRocketBaseB1F.asm | 9 ++++++--- maps/TeamRocketBaseB2F.asm | 3 ++- 18 files changed, 70 insertions(+), 27 deletions(-) diff --git a/data/events/special_pointers.asm b/data/events/special_pointers.asm index fddada163..f935d64e2 100644 --- a/data/events/special_pointers.asm +++ b/data/events/special_pointers.asm @@ -184,3 +184,4 @@ SpecialsPointers:: add_special GiveSafariBalls add_special RespawnOneOffs add_special MoveReminder + add_special FadeInPalettes_EnableDynNoApply diff --git a/data/maps/setup_script_pointers.asm b/data/maps/setup_script_pointers.asm index 407bef4e2..7afdbea92 100644 --- a/data/maps/setup_script_pointers.asm +++ b/data/maps/setup_script_pointers.asm @@ -52,3 +52,4 @@ MapSetupCommands: add_mapsetup InitMapNameSign ; 2d add_mapsetup DisableDynPalUpdates ; 2e add_mapsetup EnableDynPalUpdates ; 2f + add_mapsetup EnableDynPalUpdatesNoApply ; 30 diff --git a/data/maps/setup_scripts.asm b/data/maps/setup_scripts.asm index 1195b52c3..e94a8336b 100644 --- a/data/maps/setup_scripts.asm +++ b/data/maps/setup_scripts.asm @@ -42,8 +42,8 @@ MapSetupScript_Warp: mapsetup LoadMapObjects mapsetup EnableLCD mapsetup LoadMapPalettes - mapsetup EnableDynPalUpdates mapsetup SpawnInFacingDown + mapsetup EnableDynPalUpdatesNoApply mapsetup RefreshMapSprites mapsetup PlayMapMusicBike mapsetup FadeInToMusic @@ -69,8 +69,8 @@ MapSetupScript_BadWarp: mapsetup EnableLCD mapsetup LoadMapObjects mapsetup LoadMapPalettes - mapsetup EnableDynPalUpdates mapsetup SpawnInFacingDown + mapsetup EnableDynPalUpdatesNoApply mapsetup RefreshMapSprites mapsetup FadeToMapMusic mapsetup FadeInPalettes @@ -118,8 +118,7 @@ MapSetupScript_Train: mapsetup EnableLCD mapsetup LoadMapObjects mapsetup LoadMapPalettes - mapsetup RefreshMapSprites - mapsetup EnableDynPalUpdates + mapsetup EnableDynPalUpdatesNoApply mapsetup RefreshMapSprites mapsetup FadeToMapMusic mapsetup FadeInPalettes @@ -140,7 +139,7 @@ MapSetupScript_ReloadMap: mapsetup LoadMapTimeOfDay mapsetup EnableLCD mapsetup LoadMapPalettes - mapsetup EnableDynPalUpdates + mapsetup EnableDynPalUpdatesNoApply mapsetup RefreshMapSprites mapsetup ForceMapMusic mapsetup FadeInPalettes @@ -160,7 +159,7 @@ MapSetupScript_LinkReturn: mapsetup LoadMapTimeOfDay mapsetup EnableLCD mapsetup LoadMapPalettes - mapsetup EnableDynPalUpdates + mapsetup EnableDynPalUpdatesNoApply mapsetup RefreshMapSprites mapsetup PlayMapMusicBike mapsetup FadeInPalettes @@ -183,7 +182,7 @@ MapSetupScript_Continue: mapsetup LoadMapTimeOfDay mapsetup EnableLCD mapsetup LoadMapPalettes - mapsetup EnableDynPalUpdates + mapsetup EnableDynPalUpdatesNoApply mapsetup RefreshMapSprites mapsetup PlayMapMusicBike mapsetup FadeInPalettes diff --git a/engine/events/field_moves.asm b/engine/events/field_moves.asm index 548b041cf..854cce561 100644 --- a/engine/events/field_moves.asm +++ b/engine/events/field_moves.asm @@ -18,7 +18,7 @@ BlindingFlash: ld b, SCGB_MAPPALS call GetSGBLayout farcall LoadOW_BGPal7 - farcall FadeInPalettes + farcall FadeInPalettes_EnableDynNoApply ret ShakeHeadbuttTree: diff --git a/engine/events/pokepic.asm b/engine/events/pokepic.asm index 0e4504cc7..dc9de2f30 100644 --- a/engine/events/pokepic.asm +++ b/engine/events/pokepic.asm @@ -65,6 +65,7 @@ ClosePokepic:: call OverworldTextModeSwitch call ApplyTilemap call UpdateSprites + farcall EnableDynPalUpdates call LoadStandardFont ret diff --git a/engine/events/sacred_ash.asm b/engine/events/sacred_ash.asm index d105b2fb7..37d655bce 100644 --- a/engine/events/sacred_ash.asm +++ b/engine/events/sacred_ash.asm @@ -49,12 +49,11 @@ SacredAshScript: special HealParty reloadmappart playsound SFX_WARP_TO +rept 3 special FadeOutPalettes - special FadeInPalettes - special FadeOutPalettes - special FadeInPalettes - special FadeOutPalettes - special FadeInPalettes + special LoadMapPalettes + special FadeInPalettes_EnableDynNoApply +endr waitsfx writetext .UseSacredAshText playsound SFX_CAUGHT_MON diff --git a/engine/gfx/dynamic_pals.asm b/engine/gfx/dynamic_pals.asm index 50d9d7440..ab4fbc5a8 100644 --- a/engine/gfx/dynamic_pals.asm +++ b/engine/gfx/dynamic_pals.asm @@ -22,6 +22,14 @@ DisableDynPalUpdates:: pop hl ret +EnableDynPalUpdatesNoApply:: + push hl + ld hl, wPalFlags + set NO_DYN_PAL_APPLY_F, [hl] + res DISABLE_DYN_PAL_F, [hl] + pop hl + jr CheckForUsedObjPals + EnableDynPalUpdates:: push hl ld hl, wPalFlags diff --git a/engine/gfx/mon_icons.asm b/engine/gfx/mon_icons.asm index 4f243011c..2cac5e166 100644 --- a/engine/gfx/mon_icons.asm +++ b/engine/gfx/mon_icons.asm @@ -485,6 +485,8 @@ FlyFunction_GetMonIcon: ; hardcoded to pidgeot pop de ld a, e call GetIcon_a + ret + SetOWFlyMonColor: ld a, PIDGEOT ld [wCurPartySpecies], a diff --git a/engine/tilesets/timeofday_pals.asm b/engine/tilesets/timeofday_pals.asm index 2e5c5c7de..059a70783 100644 --- a/engine/tilesets/timeofday_pals.asm +++ b/engine/tilesets/timeofday_pals.asm @@ -94,6 +94,7 @@ _TimeOfDayPals:: ldh [rSVBK], a ; update palettes + farcall CheckForUsedObjPals call _UpdateTimePals call DelayFrame @@ -112,6 +113,9 @@ _UpdateTimePals:: call DmgToCgbTimePals ret +FadeInPalettes_EnableDynNoApply:: + farcall EnableDynPalUpdatesNoApply + ; fallthrough FadeInPalettes:: ld c, $12 call GetTimePalFade diff --git a/home/map.asm b/home/map.asm index 014c75ba4..f73047282 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1923,8 +1923,7 @@ FinishExitMenu:: call GetSGBLayout farcall LoadOW_BGPal7 call WaitBGMap2 - farcall FadeInPalettes - farcall EnableDynPalUpdates + farcall FadeInPalettes_EnableDynNoApply call EnableSpriteUpdates ret diff --git a/home/palettes.asm b/home/palettes.asm index de742b732..8bc8867f3 100644 --- a/home/palettes.asm +++ b/home/palettes.asm @@ -331,3 +331,18 @@ SwapTextboxPalettes:: ScrollBGMapPalettes:: homecall _ScrollBGMapPalettes ret + +SetBlackObjectPals:: + ldh a, [rSVBK] + push af + ld a, BANK(wOBPals2) + ldh [rSVBK], a + ld hl, wOBPals2 + ld bc, 8 palettes + xor a + call ByteFill + pop af + ldh [rSVBK], a + ld a, 1 + ldh [hCGBPalUpdate], a + jp DelayFrame diff --git a/maps/BattleTowerBattleRoom.asm b/maps/BattleTowerBattleRoom.asm index 1cf4438c1..a65a1707b 100644 --- a/maps/BattleTowerBattleRoom.asm +++ b/maps/BattleTowerBattleRoom.asm @@ -50,7 +50,7 @@ Script_BattleRoomLoop: special FadeOutPalettes special LoadMapPalettes pause 60 - special FadeInPalettes + special FadeInPalettes_EnableDynNoApply special RestartMapMusic opentext writetext Text_NextUpOpponentNo diff --git a/maps/BluesHouse.asm b/maps/BluesHouse.asm index 55a38d1d5..cfcf071c5 100644 --- a/maps/BluesHouse.asm +++ b/maps/BluesHouse.asm @@ -32,9 +32,10 @@ DaisyScript: waitbutton closetext special FadeOutPalettes + special LoadMapPalettes playmusic MUSIC_HEAL pause 60 - special FadeInPalettes + special FadeInPalettes_EnableDynNoApply special RestartMapMusic opentext writetext GroomedMonLooksContentText diff --git a/maps/FastShipCabins_SE_SSE_CaptainsCabin.asm b/maps/FastShipCabins_SE_SSE_CaptainsCabin.asm index d962f6f7c..f0786f0ed 100644 --- a/maps/FastShipCabins_SE_SSE_CaptainsCabin.asm +++ b/maps/FastShipCabins_SE_SSE_CaptainsCabin.asm @@ -48,13 +48,17 @@ SSAquaGranddaughterBefore: closetext special FadeBlackQuickly special ReloadSpritesNoPalettes + callasm DisableDynPalUpdates disappear FASTSHIPCABINS_SE_SSE_CAPTAINSCABIN_TWIN2 applymovement PLAYER, SSAquaCaptainsCabinWarpsToGrandpasCabinMovement moveobject FASTSHIPCABINS_SE_SSE_CAPTAINSCABIN_TWIN1, 3, 19 appear FASTSHIPCABINS_SE_SSE_CAPTAINSCABIN_TWIN1 turnobject PLAYER, UP turnobject FASTSHIPCABINS_SE_SSE_CAPTAINSCABIN_TWIN1, UP - special FadeInQuickly + loadmem wObject1Palette, 1 + callasm SetBlackObjectPals + turnobject FASTSHIPCABINS_SE_SSE_CAPTAINSCABIN_GENTLEMAN, RIGHT + callasm FadeInPalettes_EnableDynNoApply turnobject FASTSHIPCABINS_SE_SSE_CAPTAINSCABIN_GENTLEMAN, DOWN showemote EMOTE_SHOCK, FASTSHIPCABINS_SE_SSE_CAPTAINSCABIN_GENTLEMAN, 15 applymovement FASTSHIPCABINS_SE_SSE_CAPTAINSCABIN_TWIN1, SSAquaGranddaughterEntersCabinMovement diff --git a/maps/GoldenrodUnderground.asm b/maps/GoldenrodUnderground.asm index 5014bd5c3..c5a414207 100644 --- a/maps/GoldenrodUnderground.asm +++ b/maps/GoldenrodUnderground.asm @@ -234,9 +234,10 @@ OlderHaircutBrotherScript: waitbutton closetext special FadeOutPalettes + special LoadMapPalettes playmusic MUSIC_HEAL pause 60 - special FadeInPalettes + special FadeInPalettes_EnableDynNoApply special RestartMapMusic opentext writetext GoldenrodUndergroundOlderHaircutBrotherAllDoneText @@ -317,9 +318,10 @@ YoungerHaircutBrotherScript: waitbutton closetext special FadeOutPalettes + special LoadMapPalettes playmusic MUSIC_HEAL pause 60 - special FadeInPalettes + special FadeInPalettes_EnableDynNoApply special RestartMapMusic opentext writetext GoldenrodUndergroundYoungerHaircutBrotherAllDoneText diff --git a/maps/OlivineLighthouse6F.asm b/maps/OlivineLighthouse6F.asm index ba8e9c153..1b236b246 100644 --- a/maps/OlivineLighthouse6F.asm +++ b/maps/OlivineLighthouse6F.asm @@ -50,7 +50,8 @@ OlivineLighthouseJasmine: special RestartMapMusic cry AMPHAROS special FadeOutPalettes - special FadeInPalettes + special LoadMapPalettes + special FadeInPalettes_EnableDynNoApply opentext writetext AmphyPaluPaluluText waitbutton @@ -120,9 +121,11 @@ OlivineLighthouseAmphy: waitbutton closetext special FadeOutPalettes - special FadeInPalettes + special LoadMapPalettes + special FadeInPalettes_EnableDynNoApply special FadeOutPalettes - special FadeInPalettes + special LoadMapPalettes + special FadeInPalettes_EnableDynNoApply end OlivineLighthouse6FSuperPotion: diff --git a/maps/TeamRocketBaseB1F.asm b/maps/TeamRocketBaseB1F.asm index bcfcc0e04..072c4aa6a 100644 --- a/maps/TeamRocketBaseB1F.asm +++ b/maps/TeamRocketBaseB1F.asm @@ -447,8 +447,9 @@ ExplodingTrap22: VoltorbExplodingTrap: special FadeOutPalettes + special LoadMapPalettes cry VOLTORB - special FadeInPalettes + special FadeInPalettes_EnableDynNoApply setlasttalked -1 loadvar VAR_BATTLETYPE, BATTLETYPE_TRAP loadwildmon VOLTORB, 23 @@ -457,8 +458,9 @@ VoltorbExplodingTrap: GeodudeExplodingTrap: special FadeOutPalettes + special LoadMapPalettes cry GEODUDE - special FadeInPalettes + special FadeInPalettes_EnableDynNoApply setlasttalked -1 loadvar VAR_BATTLETYPE, BATTLETYPE_TRAP loadwildmon GEODUDE, 21 @@ -467,8 +469,9 @@ GeodudeExplodingTrap: KoffingExplodingTrap: special FadeOutPalettes + special LoadMapPalettes cry KOFFING - special FadeInPalettes + special FadeInPalettes_EnableDynNoApply setlasttalked -1 loadvar VAR_BATTLETYPE, BATTLETYPE_TRAP loadwildmon KOFFING, 21 diff --git a/maps/TeamRocketBaseB2F.asm b/maps/TeamRocketBaseB2F.asm index b977d4b74..35f6aa383 100644 --- a/maps/TeamRocketBaseB2F.asm +++ b/maps/TeamRocketBaseB2F.asm @@ -165,10 +165,11 @@ LanceHealsCommon: waitbutton closetext special FadeOutPalettes + special LoadMapPalettes special StubbedTrainerRankings_Healings playsound SFX_FULL_HEAL special HealParty - special FadeInPalettes + special FadeInPalettes_EnableDynNoApply opentext writetext LanceHealsText2 waitbutton From 9085130cf11175fd10f65e9281309474c0514e56 Mon Sep 17 00:00:00 2001 From: vulcandth Date: Tue, 28 May 2024 19:14:13 -0500 Subject: [PATCH 07/11] Dyn Pals (Don't break saves) --- ram/wram.asm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ram/wram.asm b/ram/wram.asm index d24a6c337..62ce8bbe2 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -2971,6 +2971,8 @@ wStartSecond:: db wRTC:: ds 4 + ds 4 + wDST:: ; bit 7: dst db From fc5c23cf41be075282eb41bc4c9fb97d4340c645 Mon Sep 17 00:00:00 2001 From: vulcandth Date: Tue, 28 May 2024 20:17:12 -0500 Subject: [PATCH 08/11] Fix PagerPals --- constants/sprite_anim_constants.asm | 2 ++ data/sprite_anims/framesets.asm | 4 ++-- data/sprite_anims/oam.asm | 9 +++++++++ engine/gfx/cgb_layouts.asm | 3 +++ engine/gfx/sprite_palettes.asm | 11 +++++++++++ 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/constants/sprite_anim_constants.asm b/constants/sprite_anim_constants.asm index b4fe1cb42..8b7f78974 100644 --- a/constants/sprite_anim_constants.asm +++ b/constants/sprite_anim_constants.asm @@ -367,6 +367,8 @@ DEF NUM_SPRITE_ANIM_FRAMESETS EQU const_value const SPRITE_ANIM_OAMSET_BROWN_WALK_2 ; 93 const SPRITE_ANIM_OAMSET_GREY_WALK_1 ; 94 const SPRITE_ANIM_OAMSET_GREY_WALK_2 ; 95 + const SPRITE_ANIM_OAMSET_GREEN_WALK_1 ; 96 + const SPRITE_ANIM_OAMSET_GREEN_WALK_2 ; 97 DEF NUM_SPRITE_ANIM_OAMSETS EQU const_value assert NUM_SPRITE_ANIM_OAMSETS <= FIRST_OAM_CMD, \ diff --git a/data/sprite_anims/framesets.asm b/data/sprite_anims/framesets.asm index 600d668c1..3934eb69d 100644 --- a/data/sprite_anims/framesets.asm +++ b/data/sprite_anims/framesets.asm @@ -533,8 +533,8 @@ SpriteAnimFrameData: dorestart .Frameset_PagerMonGreen: - frame SPRITE_ANIM_OAMSET_CELEBI_1, 8 - frame SPRITE_ANIM_OAMSET_CELEBI_2, 8 + frame SPRITE_ANIM_OAMSET_GREEN_WALK_1, 8 + frame SPRITE_ANIM_OAMSET_GREEN_WALK_2, 8 dorestart .Frameset_PagerMonBrown: diff --git a/data/sprite_anims/oam.asm b/data/sprite_anims/oam.asm index 150a7e083..6e2ebc119 100644 --- a/data/sprite_anims/oam.asm +++ b/data/sprite_anims/oam.asm @@ -157,6 +157,8 @@ SpriteAnimOAMData: spriteanimoam $04, .OAMData_BrownWalk ; SPRITE_ANIM_OAMSET_BROWN_WALK_2 spriteanimoam $00, .OAMData_GreyWalk ; SPRITE_ANIM_OAMSET_GREY_WALK_1 spriteanimoam $04, .OAMData_GreyWalk ; SPRITE_ANIM_OAMSET_GREY_WALK_2 + spriteanimoam $00, .OAMData_GreenWalk ; SPRITE_ANIM_OAMSET_GREEN_WALK_1 + spriteanimoam $04, .OAMData_GreenWalk ; SPRITE_ANIM_OAMSET_GREEN_WALK_2 assert_table_length NUM_SPRITE_ANIM_OAMSETS .OAMData_1x1_Palette0: @@ -1213,3 +1215,10 @@ SpriteAnimOAMData: dsprite -1, 0, 0, 0, $01, PAL_OW_SILVER dsprite 0, 0, -1, 0, $02, PAL_OW_SILVER dsprite 0, 0, 0, 0, $03, PAL_OW_SILVER + +.OAMData_GreenWalk: + db 4 + dsprite -1, 0, -1, 0, $00, PAL_OW_GREEN + dsprite -1, 0, 0, 0, $01, PAL_OW_GREEN + dsprite 0, 0, -1, 0, $02, PAL_OW_GREEN + dsprite 0, 0, 0, 0, $03, PAL_OW_GREEN \ No newline at end of file diff --git a/engine/gfx/cgb_layouts.asm b/engine/gfx/cgb_layouts.asm index 1bc820113..3c335d45f 100644 --- a/engine/gfx/cgb_layouts.asm +++ b/engine/gfx/cgb_layouts.asm @@ -244,6 +244,9 @@ _CGB_PokegearPals: ld bc, 7 palettes ld a, BANK(wBGPals1) call FarCopyWRAM + + farcall CopyGenericPals + call ApplyPals ld a, TRUE ldh [hCGBPalUpdate], a diff --git a/engine/gfx/sprite_palettes.asm b/engine/gfx/sprite_palettes.asm index eb5162735..5d5317445 100644 --- a/engine/gfx/sprite_palettes.asm +++ b/engine/gfx/sprite_palettes.asm @@ -81,6 +81,17 @@ CopySpritePal:: pop hl ret +CopyGenericPals:: + ld hl, MapObjectPals + ld a, 1 + ld bc, NUM_OW_TIME_OF_DAY_PALS palettes + call AddNTimes + ld de, wOBPals1 + ld bc, 8 palettes + ld a, BANK(wOBPals2) + call FarCopyWRAM + ret + ApplyOBPals: ld hl, wOBPals1 ld de, wOBPals2 From 44689632aa41496970355c29c8013d2cdfd56050 Mon Sep 17 00:00:00 2001 From: vulcandth Date: Tue, 28 May 2024 20:19:41 -0500 Subject: [PATCH 09/11] Force always daytime OB pals --- engine/gfx/sprite_palettes.asm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/gfx/sprite_palettes.asm b/engine/gfx/sprite_palettes.asm index 5d5317445..fe2b64b8f 100644 --- a/engine/gfx/sprite_palettes.asm +++ b/engine/gfx/sprite_palettes.asm @@ -58,8 +58,9 @@ CopySpritePal:: .check_daytimes ld a, [wPalFlags] bit USE_DAYTIME_PAL_F, a - ld a, DAY + ld a, 1 jr nz, .daytime + jr .daytime ; always daytime pals for this hack, remove to change. ld a, [wTimeOfDayPal] .daytime maskbits NUM_DAYTIMES From 4de26728de2a31bf4c41f40c1668b5ecd44fb4f0 Mon Sep 17 00:00:00 2001 From: SoupPotato Date: Wed, 29 May 2024 02:53:31 +0100 Subject: [PATCH 10/11] Corrected OW pals --- data/sprites/sprites.asm | 10 ++++---- gfx/overworld/npc_sprites.pal | 10 ++++---- gfx/overworld/npc_sprites_darkness.pal | 34 +++++++++++++------------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/data/sprites/sprites.asm b/data/sprites/sprites.asm index 1c9d6d31d..7174e8d69 100644 --- a/data/sprites/sprites.asm +++ b/data/sprites/sprites.asm @@ -109,12 +109,12 @@ OverworldSprites: overworld_sprite EnteiSpriteGFX, 4, STILL_SPRITE, PAL_OW_RED overworld_sprite RaikouSpriteGFX, 4, STILL_SPRITE, PAL_OW_RED overworld_sprite ApricornSpriteGFX, 4, STILL_SPRITE, PAL_OW_TREE - overworld_sprite RattataUpSpriteGFX, 12, WALKING_SPRITE, PAL_OW_BLUE + overworld_sprite RattataUpSpriteGFX, 12, WALKING_SPRITE, PAL_OW_PURPLE overworld_sprite PidgeyMoveSpriteGFX, 12, WALKING_SPRITE, PAL_OW_BROWN - overworld_sprite SlowpokeNoTailSpriteGFX, 4, STILL_SPRITE, PAL_OW_RED + overworld_sprite SlowpokeNoTailSpriteGFX, 4, STILL_SPRITE, PAL_OW_PINK overworld_sprite FarfetchdMoveSpriteGFX, 12, WALKING_SPRITE, PAL_OW_BROWN overworld_sprite FossilSpriteGFX, 4, STILL_SPRITE, PAL_OW_BROWN - overworld_sprite OldAmberSpriteGFX, 4, STILL_SPRITE, PAL_OW_BROWN - overworld_sprite AmphySickSpriteGFX, 12, WALKING_SPRITE, PAL_OW_BROWN - overworld_sprite ClefairyMoveSpriteGFX, 12, WALKING_SPRITE, PAL_OW_RED + overworld_sprite OldAmberSpriteGFX, 4, STILL_SPRITE, PAL_OW_YELLOW + overworld_sprite AmphySickSpriteGFX, 12, WALKING_SPRITE, PAL_OW_YELLOW + overworld_sprite ClefairyMoveSpriteGFX, 12, WALKING_SPRITE, PAL_OW_PINK assert_table_length NUM_OVERWORLD_SPRITES diff --git a/gfx/overworld/npc_sprites.pal b/gfx/overworld/npc_sprites.pal index 0c280ca4a..bc2722324 100644 --- a/gfx/overworld/npc_sprites.pal +++ b/gfx/overworld/npc_sprites.pal @@ -20,13 +20,13 @@ ; day RGB 27,31,27, 31,19,10, 31,07,01, 00,00,00 ; red RGB 27,31,27, 31,19,10, 10,09,31, 00,00,00 ; blue - RGB 27,31,27, 31,19,10, 07,23,03, 00,00,00 ; green + RGB 27,31,27, 31,19,10, 04,19,00, 00,00,00 ; green RGB 27,31,27, 31,19,10, 15,10,03, 00,00,00 ; brown - RGB 27,31,27, 31,19,10, 18,04,18, 00,00,00 ; purple - RGB 27,31,27, 31,19,10, 13,13,13, 00,00,00 ; gray - RGB 27,31,27, 31,19,10, 31,10,11, 00,00,00 ; pink + RGB 27,31,27, 31,19,10, 17,08,28, 00,00,00 ; purple + RGB 27,31,27, 31,19,10, 11,14,15, 00,00,00 ; gray + RGB 27,31,27, 31,19,10, 27,07,16, 00,00,00 ; pink RGB 27,31,27, 31,19,10, 03,23,21, 00,00,00 ; teal - RGB 27,31,27, 31,19,10, 25,25,00, 00,00,00 ; yellow + RGB 27,31,27, 30,27,08, 29,17,00, 00,00,00 ; yellow RGB 27,31,27, 31,19,10, 31,13,00, 00,00,00 ; orange RGB 27,31,27, 31,19,10, 04,18,31, 00,00,00 ; azure RGB 27,31,27, 27,31,27, 20,20,20, 00,00,00 ; white diff --git a/gfx/overworld/npc_sprites_darkness.pal b/gfx/overworld/npc_sprites_darkness.pal index 55150de68..6ec855ad4 100644 --- a/gfx/overworld/npc_sprites_darkness.pal +++ b/gfx/overworld/npc_sprites_darkness.pal @@ -1,20 +1,20 @@ - RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; red - RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; blue - RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; green - RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; brown - RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; purple - RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; gray - RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; pink - RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; teal - RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; yellow - RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; orange - RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; azure - RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; white - RGB 01,01,02, 04,04,04, 02,02,02, 00,00,00 ; black - RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; poke ball - RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; deco item - RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; key item - RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; tree + RGB 27,31,27, 31,19,10, 31,07,01, 00,00,00 ; red + RGB 27,31,27, 31,19,10, 10,09,31, 00,00,00 ; blue + RGB 27,31,27, 31,19,10, 04,19,00, 00,00,00 ; green + RGB 27,31,27, 31,19,10, 15,10,03, 00,00,00 ; brown + RGB 27,31,27, 31,19,10, 17,08,28, 00,00,00 ; purple + RGB 27,31,27, 31,19,10, 11,14,15, 00,00,00 ; gray + RGB 27,31,27, 31,19,10, 27,07,16, 00,00,00 ; pink + RGB 27,31,27, 31,19,10, 03,23,21, 00,00,00 ; teal + RGB 27,31,27, 30,27,08, 29,17,00, 00,00,00 ; yellow + RGB 27,31,27, 31,19,10, 31,13,00, 00,00,00 ; orange + RGB 27,31,27, 31,19,10, 04,18,31, 00,00,00 ; azure + RGB 27,31,27, 27,31,27, 20,20,20, 00,00,00 ; white + RGB 27,31,27, 31,19,10, 10,10,10, 00,00,00 ; black + RGB 27,31,27, 27,31,27, 31,07,01, 00,00,00 ; poke ball + RGB 27,31,27, 27,31,27, 10,09,31, 00,00,00 ; deco item + RGB 27,31,27, 27,31,27, 07,23,03, 00,00,00 ; key item + RGB 22,31,10, 12,25,01, 05,14,00, 07,07,07 ; tree RGB 31,31,31, 31,31,31, 13,13,13, 00,00,00 ; emote gray RGB 31,31,31, 31,31,31, 00,00,00, 00,00,00 ; emote black RGB 31,31,31, 31,31,31, 02,23,02, 00,00,00 ; emote green From f46362bd51510d908c7ccc1d5c53f362f7e35efb Mon Sep 17 00:00:00 2001 From: vulcandth Date: Tue, 28 May 2024 20:55:43 -0500 Subject: [PATCH 11/11] Remove old pal code --- engine/gfx/color.asm | 3 - engine/tilesets/tileset_palettes.asm | 123 --------------------------- 2 files changed, 126 deletions(-) diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm index 086a52c98..3286ac191 100644 --- a/engine/gfx/color.asm +++ b/engine/gfx/color.asm @@ -1321,9 +1321,6 @@ LoadMapPals: ldh [rSVBK], a farcall ClearSavedObjPals - farcall LoadSpecialMapOBPalette - farcall LoadSpecialNPCPalette - ld a, [wEnvironment] cp TOWN jr z, .outside diff --git a/engine/tilesets/tileset_palettes.asm b/engine/tilesets/tileset_palettes.asm index 7f37982dc..db1023f38 100644 --- a/engine/tilesets/tileset_palettes.asm +++ b/engine/tilesets/tileset_palettes.asm @@ -174,102 +174,6 @@ MapSpecificPalettes: scf ret -LoadSpecialMapOBPalette: - ld hl, MapSpecificOBPalettes - jp SearchPaletteRoutine - -MapSpecificOBPalettes: - _use_palette_routine_for_map ROUTE_30, .PurpleOverRockOBPalette - _use_palette_routine_for_map VIOLET_CITY, .YellowOverRockOBPalette - _use_palette_routine_for_map AZALEA_TOWN, .WhiteOverRockOBPalette - _use_palette_routine_for_map ROUTE_38, .WhiteOverRockOBPalette - _use_palette_routine_for_map ROUTE_42, .YellowOverRockOBPalette - _use_palette_routine_for_map ROUTE_44, .YellowOverRockOBPalette - _use_palette_routine_for_map ROUTE_46, .YellowOverRockOBPalette - _use_palette_routine_for_map PEWTER_CITY, .WhiteOverRockOBPalette - _use_palette_routine_for_map PEWTER_NIDORAN_SPEECH_HOUSE, .PurpleOverRockOBPalette - _use_palette_routine_for_map ROUTE_8, .PurpleOverRockYellowOverPinkOBPalette - _use_palette_routine_for_map FUCHSIA_CITY, .YellowOverRockOBPalette - _use_palette_routine_for_map OLIVINE_LIGHTHOUSE_6F, .YellowOverRockOBPalette - _use_palette_routine_for_map VIRIDIAN_NICKNAME_SPEECH_HOUSE, .PurpleOverRockOBPalette - _use_palette_routine_for_map INDIGO_PLATEAU_POKECENTER_1F, .YellowOverRockOBPalette - _use_palette_routine_for_map VERMILION_CITY, .GrayOverRockOBPalette - _use_palette_routine_for_map GOLDENROD_DEPT_STORE_B1F, .GrayOverRockOBPalette - _use_palette_routine_for_map DANCE_THEATER, .GrayOverRockOBPalette - _use_palette_routine_for_map ROUTE_10_SOUTH, .YellowOverRockOBPalette - _use_palette_routine_for_map CERULEAN_CAVE_B1F, .PurpleOverPinkOBPalette - _use_palette_routine_for_map MR_FUJIS_HOUSE, .PurpleOverRockYellowOverPinkOBPalette - _use_palette_routine_for_map SAFARI_ZONE_AREA_2, .SandOverTreeOBPalette - _use_palette_routine_for_map SAFARI_ZONE_AREA_3, .SwampOverTreeOBPalette - _use_palette_routine_for_map PEWTER_MUSEUM_1F, .YellowOverRockOBPalette - _use_palette_routine_for_map PEWTER_MUSEUM_2F, .YellowOverRockOBPalette - db -1 ; terminator - -.PurpleOverRockOBPalette: - ld a, [wTimeOfDayPal] - maskbits NUM_DAYTIMES - ld bc, 8 palettes - ld hl, PurpleOverRock - jr .finish - -.YellowOverRockOBPalette: - ld a, [wTimeOfDayPal] - maskbits NUM_DAYTIMES - ld bc, 8 palettes - ld hl, YellowOverRock - jr .finish - -.WhiteOverRockOBPalette: - ld a, [wTimeOfDayPal] - maskbits NUM_DAYTIMES - ld bc, 8 palettes - ld hl, WhiteOverRock - jr .finish - -.PurpleOverRockYellowOverPinkOBPalette - ld a, [wTimeOfDayPal] - maskbits NUM_DAYTIMES - ld bc, 8 palettes - ld hl, PurpleOverRockYellowOverPink - jr .finish - -.GrayOverRockOBPalette - ld a, [wTimeOfDayPal] - maskbits NUM_DAYTIMES - ld bc, 8 palettes - ld hl, GrayOverRock - jr .finish - -.PurpleOverPinkOBPalette: - ld a, [wTimeOfDayPal] - maskbits NUM_DAYTIMES - ld bc, 8 palettes - ld hl, PurpleOverPink - jr .finish - -.SandOverTreeOBPalette: - ld a, [wTimeOfDayPal] - maskbits NUM_DAYTIMES - ld bc, 8 palettes - ld hl, SandOverTree - jr .finish - -.SwampOverTreeOBPalette - ld a, [wTimeOfDayPal] - maskbits NUM_DAYTIMES - ld bc, 8 palettes - ld hl, SwampOverTree - jr .finish - -.finish - call AddNTimes - ld de, wOBPals1 - ld bc, 8 palettes - ld a, BANK(wOBPals1) - call FarCopyWRAM - scf - ret - LoadMuseumPalette: ld a, BANK(wBGPals1) ld de, wBGPals1 @@ -375,33 +279,6 @@ LoadMansionPalette: MansionPalette2: INCLUDE "gfx/tilesets/mansion_2.pal" -LoadSpecialNPCPalette: - call GetMapTimeOfDay - bit IN_DARKNESS_F, a - jr z, .do_nothing - ld a, [wStatusFlags] - bit STATUSFLAGS_FLASH_F, a - jr nz, .do_nothing - -;darkness - call LoadNPCDarknessPalette - scf - ret - -.do_nothing - and a - ret - -LoadNPCDarknessPalette: - ld a, BANK(wOBPals1) - ld de, wOBPals1 - ld hl, NPCDarknessPalette - ld bc, 8 palettes - jp FarCopyWRAM - -NPCDarknessPalette: -INCLUDE "gfx/overworld/npc_sprites_darkness.pal" - INCLUDE "gfx/overworld/npc_sprites_special.pal" INCLUDE "gfx/tilesets/bg_tiles_special_pals.pal"