shithub: pokecrystal

Download patch

ref: 6220200f0f223a4077fcc716c105c01f3e1d3691
parent: 4a323cf591f27c928acc295f0044ff1608ebada1
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Sun Nov 1 07:36:38 EST 2020

Identify some more labels, and make some more consistent

--- a/data/text/common_2.asm
+++ b/data/text/common_2.asm
@@ -114,20 +114,20 @@
 	text " EXP. Points!"
 	prompt
 
-Text_GoMon::
+_GoMonText::
 	text "Go! @"
 	text_end
 
-Text_DoItMon::
+_DoItMonText::
 	text "Do it! @"
 	text_end
 
-Text_GoForItMon::
+_GoForItMonText::
 	text "Go for it,"
 	line "@"
 	text_end
 
-Text_YourFoesWeakGetmMon::
+_YourFoesWeakGetmMonText::
 	text "Your foe's weak!"
 	line "Get'm, @"
 	text_end
@@ -137,7 +137,7 @@
 	text "!"
 	done
 
-Text_BattleMonNickComma::
+_BattleMonNickCommaText::
 	text_ram wBattleMonNick
 	text ",@"
 	text_end
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -7616,7 +7616,7 @@
 	and a
 	jr z, .not_linked
 
-	ld hl, JumpText_GoMon ; If we're in a LinkBattle print just "Go <PlayerMon>"
+	ld hl, GoMonText ; If we're in a LinkBattle print just "Go <PlayerMon>"
 
 	ld a, [wBattleHasJustStarted] ; unless this (unidentified) variable is set
 	and a
@@ -7627,7 +7627,7 @@
 	ld hl, wEnemyMonHP
 	ld a, [hli]
 	or [hl]
-	ld hl, JumpText_GoMon
+	ld hl, GoMonText
 	jr z, .skip_to_textbox
 
 	; compute enemy helth remaining as a percentage
@@ -7656,41 +7656,41 @@
 	call Divide
 
 	ldh a, [hQuotient + 3]
-	ld hl, JumpText_GoMon
+	ld hl, GoMonText
 	cp 70
 	jr nc, .skip_to_textbox
 
-	ld hl, JumpText_DoItMon
+	ld hl, DoItMonText
 	cp 40
 	jr nc, .skip_to_textbox
 
-	ld hl, JumpText_GoForItMon
+	ld hl, GoForItMonText
 	cp 10
 	jr nc, .skip_to_textbox
 
-	ld hl, JumpText_YourFoesWeakGetmMon
+	ld hl, YourFoesWeakGetmMonText
 .skip_to_textbox
 	jp BattleTextbox
 
-JumpText_GoMon:
-	text_far Text_GoMon
+GoMonText:
+	text_far _GoMonText
 	text_asm
-	jr Function_TextJump_BattleMonNick01
+	jr PrepareBattleMonNicknameText
 
-JumpText_DoItMon:
-	text_far Text_DoItMon
+DoItMonText:
+	text_far _DoItMonText
 	text_asm
-	jr Function_TextJump_BattleMonNick01
+	jr PrepareBattleMonNicknameText
 
-JumpText_GoForItMon:
-	text_far Text_GoForItMon
+GoForItMonText:
+	text_far _GoForItMonText
 	text_asm
-	jr Function_TextJump_BattleMonNick01
+	jr PrepareBattleMonNicknameText
 
-JumpText_YourFoesWeakGetmMon:
-	text_far Text_YourFoesWeakGetmMon
+YourFoesWeakGetmMonText:
+	text_far _YourFoesWeakGetmMonText
 	text_asm
-Function_TextJump_BattleMonNick01:
+PrepareBattleMonNicknameText:
 	ld hl, BattleMonNicknameText
 	ret
 
@@ -7703,7 +7703,7 @@
 	jp BattleTextbox
 
 .WithdrawMonText:
-	text_far Text_BattleMonNickComma
+	text_far _BattleMonNickCommaText
 	text_asm
 ; Print text to withdraw mon
 ; depending on HP the message is different
--- a/engine/battle/read_trainer_party.asm
+++ b/engine/battle/read_trainer_party.asm
@@ -380,7 +380,8 @@
 	pop de
 	ret
 
-Function39990: ; unreferenced
+IncompleteCopyNameFunction: ; unreferenced
+; Copy of CopyTrainerName but without "call CopyBytes"
 	ld de, wStringBuffer1
 	push de
 	ld bc, NAME_LENGTH
--- a/engine/events/battle_tower/battle_tower.asm
+++ b/engine/events/battle_tower/battle_tower.asm
@@ -1531,7 +1531,7 @@
 	ret
 
 LoadOpponentTrainerAndPokemonWithOTSprite:
-	farcall Function_LoadOpponentTrainerAndPokemons
+	farcall LoadOpponentTrainerAndPokemon
 	ldh a, [rSVBK]
 	push af
 	ld a, BANK(wBT_OTTrainerClass)
--- a/engine/events/battle_tower/load_trainer.asm
+++ b/engine/events/battle_tower/load_trainer.asm
@@ -1,4 +1,4 @@
-Function_LoadOpponentTrainerAndPokemons:
+LoadOpponentTrainerAndPokemon:
 	ldh a, [rSVBK]
 	push af
 	ld a, BANK(wBT_OTTrainer)
@@ -68,7 +68,7 @@
 	ld bc, NAME_LENGTH
 	call CopyBytes
 
-	call Function_LoadRandomBattleTowerMon
+	call LoadRandomBattleTowerMon
 	pop af
 
 	ld hl, BattleTowerTrainerData
@@ -91,7 +91,7 @@
 
 	ret
 
-Function_LoadRandomBattleTowerMon:
+LoadRandomBattleTowerMon:
 	ld c, BATTLETOWER_PARTY_LENGTH
 .loop
 	push bc
--- a/engine/events/battle_tower/rules.asm
+++ b/engine/events/battle_tower/rules.asm
@@ -42,10 +42,10 @@
 	dw .TextPointers
 
 .Functions:
-	dw Function_PartyCountEq3
-	dw Function_PartySpeciesAreUnique
-	dw Function_PartyItemsAreUnique
-	dw Function_HasPartyAnEgg
+	dw CheckBTRule_PartyCountEq3
+	dw CheckBTRule_PartySpeciesAreUnique
+	dw CheckBTRule_PartyItemsAreUnique
+	dw CheckBTRule_HasPartyAnEgg
 
 .TextPointers:
 	dw ExcuseMeYoureNotReadyText
@@ -203,7 +203,7 @@
 	cp BATTLETOWER_PARTY_LENGTH
 	ret
 
-Function_PartyCountEq3:
+CheckBTRule_PartyCountEq3:
 	ld a, [wPartyCount]
 	cp BATTLETOWER_PARTY_LENGTH
 	ret z
@@ -210,12 +210,12 @@
 	scf
 	ret
 
-Function_PartySpeciesAreUnique:
+CheckBTRule_PartySpeciesAreUnique:
 	ld hl, wPartyMon1Species
-	call VerifyUniqueness
+	call CheckPartyValueIsUnique
 	ret
 
-VerifyUniqueness:
+CheckPartyValueIsUnique:
 	ld de, wPartyCount
 	ld a, [de]
 	inc de
@@ -276,12 +276,12 @@
 	pop bc
 	ret
 
-Function_PartyItemsAreUnique:
+CheckBTRule_PartyItemsAreUnique:
 	ld hl, wPartyMon1Item
-	call VerifyUniqueness
+	call CheckPartyValueIsUnique
 	ret
 
-Function_HasPartyAnEgg:
+CheckBTRule_HasPartyAnEgg:
 	ld hl, wPartyCount
 	ld a, [hli]
 	ld c, a
--- a/engine/games/unown_puzzle.asm
+++ b/engine/games/unown_puzzle.asm
@@ -171,7 +171,7 @@
 UnownPuzzleJumptable:
 	jumptable .Jumptable, wJumptableIndex
 
-.Jumptable:
+.Jumptable: ; redundant one-entry jumptable
 	dw .Function
 
 .Function:
--- a/engine/gfx/crystal_layouts.asm
+++ b/engine/gfx/crystal_layouts.asm
@@ -150,11 +150,11 @@
 	ld a, [wd002]
 	bit 6, a
 	jr z, .asm_49464
-	call Function49480
+	call .Function49480
 	jr .done
 
 .asm_49464
-	call Function49496
+	call .Function49496
 .done
 	farcall ApplyAttrmap
 	farcall ApplyPals
@@ -165,7 +165,7 @@
 .TextPalette:
 INCLUDE "gfx/mystery_gift/mobile_text.pal"
 
-Function49480:
+.Function49480:
 	hlcoord 0, 0, wAttrmap
 	lb bc, 4, SCREEN_WIDTH
 	ld a, $7
@@ -177,7 +177,7 @@
 	ld [hl], a
 	ret
 
-Function49496:
+.Function49496:
 	hlcoord 0, 0, wAttrmap
 	lb bc, 2, SCREEN_WIDTH
 	ld a, $7
--- a/engine/gfx/player_gfx.asm
+++ b/engine/gfx/player_gfx.asm
@@ -1,11 +1,10 @@
-Function88248: ; unreferenced
+BetaLoadPlayerTrainerClass: ; unreferenced
 	ld c, CAL
 	ld a, [wPlayerGender]
 	bit PLAYERGENDER_FEMALE_F, a
-	jr z, .okay
-	ld c, KAREN
-
-.okay
+	jr z, .got_class
+	ld c, KAREN ; not KRIS?
+.got_class
 	ld a, c
 	ld [wTrainerClass], a
 	ret
@@ -59,9 +58,9 @@
 	ld hl, ChrisNameMenuHeader
 	ld a, [wPlayerGender]
 	bit PLAYERGENDER_FEMALE_F, a
-	jr z, .GotGender
+	jr z, .got_header
 	ld hl, KrisNameMenuHeader
-.GotGender:
+.got_header
 	call LoadMenuHeader
 	call VerticalMenu
 	ld a, [wMenuCursorY]
@@ -77,29 +76,21 @@
 	ld de, MalePlayerNameArray
 	ld a, [wPlayerGender]
 	bit PLAYERGENDER_FEMALE_F, a
-	jr z, .done
+	jr z, .got_array
 	ld de, FemalePlayerNameArray
-
-.done
+.got_array
 	call InitName
 	ret
 
 GetPlayerIcon:
-; Get the player icon corresponding to gender
-
-; Male
 	ld de, ChrisSpriteGFX
 	ld b, BANK(ChrisSpriteGFX)
-
 	ld a, [wPlayerGender]
 	bit PLAYERGENDER_FEMALE_F, a
-	jr z, .done
-
-; Female
+	jr z, .got_gfx
 	ld de, KrisSpriteGFX
 	ld b, BANK(KrisSpriteGFX)
-
-.done
+.got_gfx
 	ret
 
 GetCardPic:
@@ -106,9 +97,9 @@
 	ld hl, ChrisCardPic
 	ld a, [wPlayerGender]
 	bit PLAYERGENDER_FEMALE_F, a
-	jr z, .GotClass
+	jr z, .got_pic
 	ld hl, KrisCardPic
-.GotClass:
+.got_pic
 	ld de, vTiles2 tile $00
 	ld bc, $23 tiles
 	ld a, BANK(ChrisCardPic) ; aka BANK(KrisCardPic)
@@ -148,26 +139,29 @@
 	call WaitBGMap
 	xor a
 	ldh [hBGMapMode], a
-	ld e, 0
+
+; Get class
+	ld e, CHRIS
 	ld a, [wPlayerGender]
 	bit PLAYERGENDER_FEMALE_F, a
-	jr z, .GotClass
-	ld e, 1
-
-.GotClass:
+	jr z, .got_class
+	ld e, KRIS
+.got_class
 	ld a, e
 	ld [wTrainerClass], a
+
+; Load pic
 	ld de, ChrisPic
 	ld a, [wPlayerGender]
 	bit PLAYERGENDER_FEMALE_F, a
-	jr z, .GotPic
+	jr z, .got_pic
 	ld de, KrisPic
-
-.GotPic:
+.got_pic
 	ld hl, vTiles2
 	ld b, BANK(ChrisPic) ; aka BANK(KrisPic)
 	ld c, 7 * 7
 	call Get2bpp
+
 	call WaitBGMap
 	ld a, $1
 	ldh [hBGMapMode], a
@@ -180,9 +174,9 @@
 	ld e, CHRIS
 	ld a, [wPlayerGender]
 	bit PLAYERGENDER_FEMALE_F, a
-	jr z, .GotClass
+	jr z, .got_class
 	ld e, KRIS
-.GotClass:
+.got_class
 	ld a, e
 	ld [wTrainerClass], a
 
@@ -190,9 +184,9 @@
 	ld de, ChrisPic
 	ld a, [wPlayerGender]
 	bit PLAYERGENDER_FEMALE_F, a
-	jr z, .GotPic
+	jr z, .got_pic
 	ld de, KrisPic
-.GotPic:
+.got_pic
 	ld hl, vTiles2
 	ld b, BANK(ChrisPic) ; aka BANK(KrisPic)
 	ld c, 7 * 7 ; dimensions
--- a/engine/link/link.asm
+++ b/engine/link/link.asm
@@ -1249,7 +1249,7 @@
 .not_d_up
 	bit D_DOWN_F, a
 	jp z, LinkTradePartiesMenuMasterLoop
-	jp LinkTradeCheckCancel
+	jp LinkTradeOTPartymonMenuCheckCancel
 
 LinkTrade_PlayerPartyMenu:
 	farcall InitMG_Mobile_LinkTradePalMap
@@ -1323,7 +1323,7 @@
 	ld [hl], " "
 	pop bc
 	pop hl
-	jp Function28ade
+	jp LinkTradePartymonMenuCheckCancel
 
 LinkTradePartiesMenuMasterLoop:
 	ld a, [wMonType]
@@ -1501,11 +1501,12 @@
 	text_far _LinkAbnormalMonText
 	text_end
 
-LinkTradeCheckCancel:
+LinkTradeOTPartymonMenuCheckCancel:
 	ld a, [wMenuCursorY]
 	cp 1
 	jp nz, LinkTradePartiesMenuMasterLoop
 	call HideCursor
+
 	push hl
 	push bc
 	ld bc, NAME_LENGTH
@@ -1513,7 +1514,9 @@
 	ld [hl], " "
 	pop bc
 	pop hl
-Function28ade:
+	; fallthrough
+
+LinkTradePartymonMenuCheckCancel:
 .loop1
 	ld a, "▶"
 	ldcoord_a 9, 17
@@ -1548,6 +1551,8 @@
 	ld a, [wOtherPlayerLinkMode]
 	cp $f
 	jr nz, .loop1
+	; fallthrough
+
 ExitLinkCommunications:
 	call RotateThreePalettesRight
 	call ClearScreen
--- a/engine/link/link_trade.asm
+++ b/engine/link/link_trade.asm
@@ -8,20 +8,23 @@
 	call Get2bpp
 	ret
 
-Function16d42e:
-	ld hl, Tilemap_MobileTradeBorderFullscreen
+LoadMobileTradeBorderTilemap:
+	ld hl, MobileTradeBorderTilemap
 	decoord 0, 0
 	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
 	call CopyBytes
 	ret
 
-Function16d43b: ; unreferenced
+TestMobileTradeBorderTilemap: ; unreferenced
+; Loads the mobile trade border graphics and tilemap,
+; with a placeholder SCGB_DIPLOMA layout, and exits
+; after pressing A or B. Possibly used for testing.
 	call LoadStandardMenuHeader
 	call ClearBGPalettes
 	call ClearTilemap
 	call ClearSprites
 	farcall __LoadTradeScreenBorderGFX ; useless to farcall
-	farcall Function16d42e ; useless to farcall
+	farcall LoadMobileTradeBorderTilemap ; useless to farcall
 	ld b, SCGB_DIPLOMA
 	call GetSGBLayout
 	call SetPalettes
@@ -30,13 +33,13 @@
 	call Call_ExitMenu
 	ret
 
-Tilemap_MobileTradeBorderFullscreen:
-INCBIN "gfx/trade/border_mobile_fullscreen.tilemap"
+MobileTradeBorderTilemap:
+INCBIN "gfx/trade/border_mobile.tilemap"
 
-Tilemap_CableTradeBorderTop:
+CableTradeBorderTopTilemap:
 INCBIN "gfx/trade/border_cable_top.tilemap"
 
-Tilemap_CableTradeBorderBottom:
+CableTradeBorderBottomTilemap:
 INCBIN "gfx/trade/border_cable_bottom.tilemap"
 
 _LinkTextbox:
@@ -111,7 +114,7 @@
 
 InitTradeSpeciesList:
 	call _LoadTradeScreenBorderGFX
-	call Function16d6ae
+	call LoadCableTradeBorderTilemap
 	farcall InitMG_Mobile_LinkTradePalMap
 	farcall PlaceTradePartnerNamesAndParty
 	hlcoord 10, 17
@@ -137,13 +140,13 @@
 	farcall _LoadTradeRoomBGPals
 	ret
 
-Function16d6ae:
-	call Function16d42e
-	ld hl, Tilemap_CableTradeBorderTop
+LoadCableTradeBorderTilemap:
+	call LoadMobileTradeBorderTilemap
+	ld hl, CableTradeBorderTopTilemap
 	decoord 0, 0
 	ld bc, 2 * SCREEN_WIDTH
 	call CopyBytes
-	ld hl, Tilemap_CableTradeBorderBottom
+	ld hl, CableTradeBorderBottomTilemap
 	decoord 0, 16
 	ld bc, 2 * SCREEN_WIDTH
 	call CopyBytes
--- a/engine/menus/intro_menu.asm
+++ b/engine/menus/intro_menu.asm
@@ -1049,7 +1049,8 @@
 	scf
 	ret
 
-Function6292: ; unreferenced
+UnusedTitlePerspectiveScroll: ; unreferenced
+; Similar behavior to Intro_PerspectiveScrollBG.
 	ldh a, [hVBlankCounter]
 	and $7
 	ret nz
--- a/engine/menus/save.asm
+++ b/engine/menus/save.asm
@@ -391,24 +391,19 @@
 	jp CloseSRAM
 
 Function14d18: ; unreferenced
-	ld a, BANK(s4_a007)
+	ld a, BANK(s4_a007) ; MBC30 bank used by JP Crystal; inaccessible by MBC3
 	call OpenSRAM
 	ld hl, .Data
 	ld de, s4_a007
-	ld bc, .DataEnd - .Data
+	ld bc, 4 * 12
 	call CopyBytes
 	jp CloseSRAM
 
 .Data:
-	db $0d, $02, $00, $05, $00, $00
-	db $22, $02, $01, $05, $00, $00
-	db $03, $04, $05, $08, $03, $05
-	db $0e, $06, $03, $02, $00, $00
-	db $39, $07, $07, $04, $00, $05
-	db $04, $07, $01, $05, $00, $00
-	db $0f, $05, $14, $07, $05, $05
-	db $11, $0c, $0c, $06, $06, $04
-.DataEnd
+	db $0d, $02, $00, $05, $00, $00, $22, $02, $01, $05, $00, $00
+	db $03, $04, $05, $08, $03, $05, $0e, $06, $03, $02, $00, $00
+	db $39, $07, $07, $04, $00, $05, $04, $07, $01, $05, $00, $00
+	db $0f, $05, $14, $07, $05, $05, $11, $0c, $0c, $06, $06, $04
 
 EraseBattleTowerStatus:
 	ld a, BANK(sBattleTowerChallengeState)
--- a/engine/movie/unused_title.asm
+++ b/engine/movie/unused_title.asm
@@ -154,13 +154,15 @@
 	dbsprite 13, 11,  0,  0, $4c, 1
 	dbsprite 14, 11,  0,  0, $4e, 1
 
-Function10ed51: ; unreferenced
+TestCrystalTitleScreen: ; unreferenced
+; Runs the title screen until A is pressed.
+; Possibly used for testing.
 	call _TitleScreen
 .loop
 	call JoyTextDelay
 	ldh a, [hJoyLast]
 	ld b, a
-	and 1
+	and A_BUTTON
 	jr nz, .done
 	call SuicuneFrameIterator
 	call DelayFrame
--- a/engine/pokemon/mon_stats.asm
+++ b/engine/pokemon/mon_stats.asm
@@ -323,7 +323,11 @@
 	jr nz, .load_loop
 	ret
 
-Function50cd0: ; unreferenced
+BrokenPlacePPUnits: ; unreferenced
+; Probably would have these parameters:
+; hl = starting coordinate
+; de = SCREEN_WIDTH or SCREEN_WIDTH * 2
+; c = the number of moves (1-4)
 .loop
 	ld [hl], $32 ; typo for P?
 	inc hl
--- /dev/null
+++ b/gfx/trade/border_mobile.tilemap
@@ -1,0 +1,1 @@
+?@














EEEEEEEE














EEEEEEBC/$%&/>??????????@89:;<=DE
\ No newline at end of file
--- a/gfx/trade/border_mobile_fullscreen.tilemap
+++ /dev/null
@@ -1,1 +1,0 @@
-?@














EEEEEEEE














EEEEEEBC/$%&/>??????????@89:;<=DE
\ No newline at end of file
--- a/mobile/fixed_words.asm
+++ b/mobile/fixed_words.asm
@@ -339,7 +339,7 @@
 
 Function11c254:
 	push af
-	ld a, $4
+	ld a, BANK(s4_a007)
 	call OpenSRAM
 	ld hl, s4_a007
 	pop af
@@ -349,7 +349,7 @@
 	sla a
 	add c
 	ld c, a
-	ld b, $0
+	ld b, 0
 	add hl, bc
 	ld de, wcd36
 	ld bc, 12
@@ -1762,7 +1762,7 @@
 	ld a, [hl]
 	and a
 	jr nz, .asm_11cbd4
-	ld a, $4
+	ld a, BANK(s4_a007)
 	call OpenSRAM
 	ld hl, s4_a007
 	ld a, [wMenuCursorY]
@@ -1773,10 +1773,10 @@
 	sla a
 	add c
 	ld c, a
-	ld b, $0
+	ld b, 0
 	add hl, bc
 	ld de, wcd36
-	ld c, $c
+	ld c, 12
 .asm_11cba2
 	ld a, [de]
 	ld [hli], a
--- a/mobile/mobile_40.asm
+++ b/mobile/mobile_40.asm
@@ -6496,7 +6496,7 @@
 	db "CANCEL@"
 
 Function102e4f:
-	farcall Function16d42e
+	farcall LoadMobileTradeBorderTilemap
 	farcall _InitMG_Mobile_LinkTradePalMap
 	ld de, wPlayerName
 	hlcoord 4, 0