shithub: pokecrystal

Download patch

ref: 8019db3ea98ee60d3e6675431e07819b83daf04c
parent: f2550fc3c208508aaba3a9c2f26dcd12d81c6bc5
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Wed Jun 17 06:39:17 EDT 2020

Harmonize engine/{gfx, items, link, math} with pokegold

--- a/engine/gfx/cgb_layouts.asm
+++ b/engine/gfx/cgb_layouts.asm
@@ -261,7 +261,7 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	ldh [hCGBPalUpdate], a
 	ret
 
-.BillsPCOrangePalette:
+BillsPCOrangePalette:
 INCLUDE "gfx/pc/orange.pal"
 
 _CGB_PokedexUnownMode:
@@ -886,10 +886,10 @@
 	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 @@
 	call ApplyPals
 	ret
 
-.Palette:
+.GamefreakLogoOBPalette:
 INCLUDE "gfx/splash/logo.pal"
 
 _CGB_PlayerOrMonFrontpicPals:
@@ -947,7 +947,7 @@
 	ret
 
 _CGB_MysteryGift:
-	ld hl, .Palettes
+	ld hl, .MysteryGiftPalettes
 	ld de, wBGPals1
 	ld bc, 2 palettes
 	ld a, BANK(wBGPals1)
@@ -977,5 +977,22 @@
 	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
--- a/engine/gfx/color.asm
+++ b/engine/gfx/color.asm
@@ -446,23 +446,6 @@
 
 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 @@
 	ret
 
 .LoadSGBBorderPointers:
-	ld hl, SGBBorder
+	ld hl, SGBBorderGFX
 	ld de, SGBBorderMap
 	ret
 
@@ -1198,7 +1181,7 @@
 ; assumed to come after SGBBorderMap
 INCLUDE "gfx/sgb/sgb_border.pal"
 
-SGBBorder:
+SGBBorderGFX:
 INCBIN "gfx/sgb/sgb_border.2bpp"
 
 HPBarPals:
@@ -1237,7 +1220,6 @@
 	add hl, de
 	ld e, l
 	ld d, h
-	; Switch to palettes WRAM bank
 	ldh a, [rSVBK]
 	push af
 	ld a, BANK(wBGPals1)
--- 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
--- a/engine/gfx/load_pics.asm
+++ b/engine/gfx/load_pics.asm
@@ -344,12 +344,12 @@
 	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
--- a/engine/gfx/mon_icons.asm
+++ b/engine/gfx/mon_icons.asm
@@ -41,9 +41,9 @@
 	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
--- a/engine/gfx/sprite_anims.asm
+++ b/engine/gfx/sprite_anims.asm
@@ -66,7 +66,7 @@
 
 	ld hl, SPRITEANIMSTRUCT_YOFFSET
 	add hl, bc
-	ld [hl], $0
+	ld [hl], 0
 	ret
 
 .PartyMonSwitch
@@ -269,8 +269,8 @@
 	ret
 
 .asm_8d3ba
-	ld a, $1
-	ld [wcf64], a
+	ld a, 1
+	ld [wIntroSceneFrameCounter], a
 	call DeinitializeSprite
 	ret
 
@@ -844,7 +844,7 @@
 	ret
 
 .AnonymousJumptable:
-	ld hl, sp+$0
+	ld hl, sp+0
 	ld e, [hl]
 	inc hl
 	ld d, [hl]
@@ -853,7 +853,7 @@
 	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]
--- a/engine/gfx/sprites.asm
+++ b/engine/gfx/sprites.asm
@@ -2,7 +2,7 @@
 	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 @@
 ; 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 @@
 	bit OAM_Y_FLIP, [hl]
 	jr z, .ok
 	; -8 - a
-	add $8
+	add 8
 	xor $ff
 	inc a
 
@@ -334,7 +334,7 @@
 	bit OAM_X_FLIP, [hl]
 	jr z, .ok
 	; -8 - a
-	add $8
+	add 8
 	xor $ff
 	inc a
 
--- a/engine/items/item_effects.asm
+++ b/engine/items/item_effects.asm
@@ -2097,9 +2097,9 @@
 
 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 @@
 	ld [wBattleResult], a
 	jp UseItemText
 
-.asm_f4a6
+.not_wild
 	xor a
 	ld [wItemEffectSucceeded], a
 	ret
--- a/engine/items/tmhm2.asm
+++ b/engine/items/tmhm2.asm
@@ -14,11 +14,11 @@
 	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
--- a/engine/link/mystery_gift_2.asm
+++ b/engine/link/mystery_gift_2.asm
@@ -80,7 +80,7 @@
 
 .tenpercent
 	call Random
-	cp 20 percent - 1 ; 50
+	cp 20 percent - 1
 	jr c, .twopercent
 	call Random
 	and %011
--- a/engine/link/time_capsule.asm
+++ b/engine/link/time_capsule.asm
@@ -117,7 +117,7 @@
 	hlcoord 7, 9
 	ld de, wOTPartySpecies
 .PlaceSpeciesNames:
-	ld c, $0
+	ld c, 0
 .loop
 	ld a, [de]
 	cp -1
--- a/engine/pokedex/pokedex_2.asm
+++ b/engine/pokedex/pokedex_2.asm
@@ -125,7 +125,7 @@
 	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 @@
 	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
--- a/engine/rtc/print_hours_mins.asm
+++ b/engine/rtc/print_hours_mins.asm
@@ -4,7 +4,7 @@
 	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 @@
 	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 @@
 	inc hl
 	ld d, h
 	ld e, l
-	ld hl, sp+$0
+	ld hl, sp+0
 	push de
 	push hl
 	pop de