From 8019db3ea98ee60d3e6675431e07819b83daf04c Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 17 Jun 2020 10:39:17 -0400 Subject: [PATCH] Harmonize engine/{gfx, items, link, math} with pokegold --- engine/gfx/cgb_layouts.asm | 53 ++++++++++++++++++++++----------- engine/gfx/color.asm | 22 ++------------ engine/gfx/load_font.asm | 15 ++++------ engine/gfx/load_pics.asm | 4 +-- engine/gfx/mon_icons.asm | 4 +-- engine/gfx/sprite_anims.asm | 10 +++---- engine/gfx/sprites.asm | 8 ++--- engine/items/item_effects.asm | 8 ++--- engine/items/tmhm2.asm | 4 +-- engine/link/mystery_gift_2.asm | 2 +- engine/link/time_capsule.asm | 2 +- engine/pokedex/pokedex_2.asm | 4 +-- engine/rtc/print_hours_mins.asm | 6 ++-- 13 files changed, 69 insertions(+), 73 deletions(-) diff --git a/engine/gfx/cgb_layouts.asm b/engine/gfx/cgb_layouts.asm index a41456fd6..70cb5325a 100644 --- a/engine/gfx/cgb_layouts.asm +++ b/engine/gfx/cgb_layouts.asm @@ -261,7 +261,7 @@ _CGB_Pokedex: ld a, [wCurPartySpecies] cp $ff jr nz, .is_pokemon - ld hl, .PokedexQuestionMarkPalette + ld hl, PokedexQuestionMarkPalette call LoadHLPaletteIntoDE ; green question mark palette jr .got_palette @@ -275,7 +275,7 @@ _CGB_Pokedex: ld a, $1 ; green question mark palette call FillBoxCGB call InitPartyMenuOBPals - ld hl, .PokedexCursorPalette + ld hl, PokedexCursorPalette ld de, wOBPals1 palette 7 ; green cursor palette ld bc, 1 palettes ld a, BANK(wOBPals1) @@ -286,10 +286,10 @@ _CGB_Pokedex: ldh [hCGBPalUpdate], a ret -.PokedexQuestionMarkPalette: +PokedexQuestionMarkPalette: INCLUDE "gfx/pokedex/question_mark.pal" -.PokedexCursorPalette: +PokedexCursorPalette: INCLUDE "gfx/pokedex/cursor.pal" _CGB_BillsPC: @@ -300,15 +300,15 @@ _CGB_BillsPC: ld a, [wCurPartySpecies] cp $ff jr nz, .GetMonPalette - ld hl, .BillsPCOrangePalette + ld hl, BillsPCOrangePalette call LoadHLPaletteIntoDE - jr .Resume + jr .GotPalette .GetMonPalette: ld bc, wTempMonDVs call GetPlayerOrMonPalettePointer call LoadPalette_White_Col1_Col2_Black -.Resume: +.GotPalette: call WipeAttrmap hlcoord 1, 4, wAttrmap lb bc, 7, 7 @@ -321,16 +321,16 @@ _CGB_BillsPC: ldh [hCGBPalUpdate], a ret -.Function9009: - ld hl, .BillsPCOrangePalette +Function9009: + ld hl, BillsPCOrangePalette call LoadHLPaletteIntoDE - jr .asm_901a + jr .GotPalette -.unused +.GetMonPalette: ld bc, wTempMonDVs call GetPlayerOrMonPalettePointer call LoadPalette_White_Col1_Col2_Black -.asm_901a +.GotPalette: call WipeAttrmap hlcoord 1, 1, wAttrmap lb bc, 7, 7 @@ -343,7 +343,7 @@ _CGB_BillsPC: ldh [hCGBPalUpdate], a ret -.BillsPCOrangePalette: +BillsPCOrangePalette: INCLUDE "gfx/pc/orange.pal" _CGB_PokedexUnownMode: @@ -886,10 +886,10 @@ _CGB_GamefreakLogo: ld a, PREDEFPAL_GAMEFREAK_LOGO_BG call GetPredefPal call LoadHLPaletteIntoDE - ld hl, .Palette + ld hl, .GamefreakLogoOBPalette ld de, wOBPals1 call LoadHLPaletteIntoDE - ld hl, .Palette + ld hl, .GamefreakLogoOBPalette ld de, wOBPals1 palette 1 call LoadHLPaletteIntoDE call WipeAttrmap @@ -897,7 +897,7 @@ _CGB_GamefreakLogo: call ApplyPals ret -.Palette: +.GamefreakLogoOBPalette: INCLUDE "gfx/splash/logo.pal" _CGB_PlayerOrMonFrontpicPals: @@ -947,7 +947,7 @@ _CGB_TrainerOrMonFrontpicPals: ret _CGB_MysteryGift: - ld hl, .Palettes + ld hl, .MysteryGiftPalettes ld de, wBGPals1 ld bc, 2 palettes ld a, BANK(wBGPals1) @@ -977,5 +977,22 @@ _CGB_MysteryGift: call ApplyAttrmap ret -.Palettes: +.MysteryGiftPalettes: INCLUDE "gfx/mystery_gift/mystery_gift.pal" + +Unreferenced_GS_CGB_MysteryGift: + ld hl, .MysteryGiftPalette + ld de, wBGPals1 + ld bc, 1 palettes + ld a, BANK(wBGPals1) + call FarCopyWRAM + call ApplyPals + call WipeAttrmap + call ApplyAttrmap + ret + +.MysteryGiftPalette: + RGB 31, 31, 31 + RGB 09, 31, 31 + RGB 10, 12, 31 + RGB 00, 03, 19 diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm index 0051d4162..cef6381ec 100644 --- a/engine/gfx/color.asm +++ b/engine/gfx/color.asm @@ -446,23 +446,6 @@ INCLUDE "gfx/mail/mail.pal" INCLUDE "engine/gfx/cgb_layouts.asm" -Unreferenced_Function95f0: - ld hl, .Palette - ld de, wBGPals1 - ld bc, 1 palettes - ld a, BANK(wBGPals1) - call FarCopyWRAM - call ApplyPals - call WipeAttrmap - call ApplyAttrmap - ret - -.Palette: - RGB 31, 31, 31 - RGB 09, 31, 31 - RGB 10, 12, 31 - RGB 00, 03, 19 - CopyFourPalettes: ld de, wBGPals1 ld c, 4 @@ -992,7 +975,7 @@ PushSGBBorder: ret .LoadSGBBorderPointers: - ld hl, SGBBorder + ld hl, SGBBorderGFX ld de, SGBBorderMap ret @@ -1198,7 +1181,7 @@ SGBBorderPalettes: ; assumed to come after SGBBorderMap INCLUDE "gfx/sgb/sgb_border.pal" -SGBBorder: +SGBBorderGFX: INCBIN "gfx/sgb/sgb_border.2bpp" HPBarPals: @@ -1237,7 +1220,6 @@ LoadMapPals: add hl, de ld e, l ld d, h - ; Switch to palettes WRAM bank ldh a, [rSVBK] push af ld a, BANK(wBGPals1) diff --git a/engine/gfx/load_font.asm b/engine/gfx/load_font.asm index bd5e29d52..a83083581 100644 --- a/engine/gfx/load_font.asm +++ b/engine/gfx/load_font.asm @@ -1,22 +1,19 @@ INCLUDE "gfx/font.asm" -; This and the following two functions are unreferenced. -; Debug, perhaps? -Unreferenced_fb434: - db 0 +Unused_EnableHDMA: + db FALSE -Unreferenced_Functionfb435: - ld a, [Unreferenced_fb434] +Unreferenced_Get1bppOptionalHDMA: + ld a, [Unused_EnableHDMA] and a jp nz, Get1bppViaHDMA jp Get1bpp -Unreferenced_Functionfb43f: - ld a, [Unreferenced_fb434] +Unreferenced_Get2bppOptionalHDMA: + ld a, [Unused_EnableHDMA] and a jp nz, Get2bppViaHDMA jp Get2bpp -; End unreferenced block _LoadStandardFont:: ld de, Font diff --git a/engine/gfx/load_pics.asm b/engine/gfx/load_pics.asm index a784d20e9..bf656b48d 100644 --- a/engine/gfx/load_pics.asm +++ b/engine/gfx/load_pics.asm @@ -344,12 +344,12 @@ GetTrainerPic: pop af ldh [rSVBK], a call WaitBGMap - ld a, $1 + ld a, 1 ldh [hBGMapMode], a ret DecompressGet2bpp: -; Decompress lz data from b:hl to scratch space at 6:d000, then copy it to address de. +; Decompress lz data from b:hl to wDecompressScratch, then copy it to address de. ldh a, [rSVBK] push af diff --git a/engine/gfx/mon_icons.asm b/engine/gfx/mon_icons.asm index 68e9b1b84..6c7f14e3a 100644 --- a/engine/gfx/mon_icons.asm +++ b/engine/gfx/mon_icons.asm @@ -41,9 +41,9 @@ LoadMenuMonIcon: dw Trade_LoadMonIconGFX ; MONICON_TRADE dw Mobile_InitAnimatedMonIcon ; MONICON_MOBILE1 dw Mobile_InitPartyMenuBGPal71 ; MONICON_MOBILE2 - dw .GetPartyMenuMonIcon ; MONICON_UNUSED + dw Unused_GetPartyMenuMonIcon ; MONICON_UNUSED -.GetPartyMenuMonIcon: +Unused_GetPartyMenuMonIcon: call InitPartyMenuIcon call .GetPartyMonItemGFX call SetPartyMonIconAnimSpeed diff --git a/engine/gfx/sprite_anims.asm b/engine/gfx/sprite_anims.asm index 54752029c..bb6aecf26 100644 --- a/engine/gfx/sprite_anims.asm +++ b/engine/gfx/sprite_anims.asm @@ -66,7 +66,7 @@ DoAnimFrame: ld hl, SPRITEANIMSTRUCT_YOFFSET add hl, bc - ld [hl], $0 + ld [hl], 0 ret .PartyMonSwitch @@ -269,8 +269,8 @@ DoAnimFrame: ret .asm_8d3ba - ld a, $1 - ld [wcf64], a + ld a, 1 + ld [wIntroSceneFrameCounter], a call DeinitializeSprite ret @@ -844,7 +844,7 @@ DoAnimFrame: ret .AnonymousJumptable: - ld hl, sp+$0 + ld hl, sp+0 ld e, [hl] inc hl ld d, [hl] @@ -853,7 +853,7 @@ DoAnimFrame: ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX add hl, bc ld l, [hl] - ld h, $0 + ld h, 0 add hl, hl add hl, de ld a, [hli] diff --git a/engine/gfx/sprites.asm b/engine/gfx/sprites.asm index 81a8da5e7..e070cb9f0 100644 --- a/engine/gfx/sprites.asm +++ b/engine/gfx/sprites.asm @@ -2,7 +2,7 @@ ClearSpriteAnims: ld hl, wSpriteAnimDict ld bc, wSpriteAnimsEnd - wSpriteAnimDict .loop - ld [hl], $0 + ld [hl], 0 inc hl dec bc ld a, c @@ -209,7 +209,7 @@ DeinitializeSprite: ; Clear the index field of the struct in bc. ld hl, SPRITEANIMSTRUCT_INDEX add hl, bc - ld [hl], $0 + ld [hl], 0 ret DeinitializeAllSprites: @@ -319,7 +319,7 @@ AddOrSubtractY: bit OAM_Y_FLIP, [hl] jr z, .ok ; -8 - a - add $8 + add 8 xor $ff inc a @@ -334,7 +334,7 @@ AddOrSubtractX: bit OAM_X_FLIP, [hl] jr z, .ok ; -8 - a - add $8 + add 8 xor $ff inc a diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm index b92181d91..82f3f9fc7 100644 --- a/engine/items/item_effects.asm +++ b/engine/items/item_effects.asm @@ -2097,9 +2097,9 @@ XAccuracyEffect: PokeDollEffect: ld a, [wBattleMode] - dec a - jr nz, .asm_f4a6 - inc a + dec a ; WILD_BATTLE? + jr nz, .not_wild + inc a ; TRUE ld [wForcedSwitch], a ld a, [wBattleResult] and BATTLERESULT_BITMASK @@ -2107,7 +2107,7 @@ PokeDollEffect: ld [wBattleResult], a jp UseItemText -.asm_f4a6 +.not_wild xor a ld [wItemEffectSucceeded], a ret diff --git a/engine/items/tmhm2.asm b/engine/items/tmhm2.asm index 057d0b346..0c2ef8dee 100644 --- a/engine/items/tmhm2.asm +++ b/engine/items/tmhm2.asm @@ -14,11 +14,11 @@ CanLearnTMHMMove: and a jr z, .end cp b - jr z, .asm_11659 + jr z, .found inc c jr .loop -.asm_11659 +.found pop hl ld b, CHECK_FLAG push de diff --git a/engine/link/mystery_gift_2.asm b/engine/link/mystery_gift_2.asm index 404350396..75bb8aa49 100644 --- a/engine/link/mystery_gift_2.asm +++ b/engine/link/mystery_gift_2.asm @@ -80,7 +80,7 @@ PrepMysteryGiftDataToSend: .tenpercent call Random - cp 20 percent - 1 ; 50 + cp 20 percent - 1 jr c, .twopercent call Random and %011 diff --git a/engine/link/time_capsule.asm b/engine/link/time_capsule.asm index f1a93f90c..ff7e83ca6 100644 --- a/engine/link/time_capsule.asm +++ b/engine/link/time_capsule.asm @@ -117,7 +117,7 @@ PlaceTradePartnerNamesAndParty: hlcoord 7, 9 ld de, wOTPartySpecies .PlaceSpeciesNames: - ld c, $0 + ld c, 0 .loop ld a, [de] cp -1 diff --git a/engine/pokedex/pokedex_2.asm b/engine/pokedex/pokedex_2.asm index 56b191a08..2757d26fc 100644 --- a/engine/pokedex/pokedex_2.asm +++ b/engine/pokedex/pokedex_2.asm @@ -125,7 +125,7 @@ DisplayDexEntry: push hl push de ; Print the height, with two of the four digits in front of the decimal point - ld hl, sp+$0 + ld hl, sp+0 ld d, h ld e, l hlcoord 12, 7 @@ -151,7 +151,7 @@ DisplayDexEntry: jr z, .skip_weight push de ; Print the weight, with four of the five digits in front of the decimal point - ld hl, sp+$0 + ld hl, sp+0 ld d, h ld e, l hlcoord 11, 9 diff --git a/engine/rtc/print_hours_mins.asm b/engine/rtc/print_hours_mins.asm index f4abc0c1b..6dd8daf18 100644 --- a/engine/rtc/print_hours_mins.asm +++ b/engine/rtc/print_hours_mins.asm @@ -4,7 +4,7 @@ Unreferenced_Function1dd6a9: ld c, a push bc push de - ld hl, sp+$2 + ld hl, sp+2 ld d, h ld e, l pop hl @@ -30,7 +30,7 @@ PrintHoursMins: ld b, a ; Crazy stuff happening with the stack push bc - ld hl, sp+$1 + ld hl, sp+1 push de push hl pop de @@ -42,7 +42,7 @@ PrintHoursMins: inc hl ld d, h ld e, l - ld hl, sp+$0 + ld hl, sp+0 push de push hl pop de