Skip to content

Remove Redundant TrainerNamePointers

YakiNeen edited this page Dec 29, 2022 · 1 revision

As seen in data/trainers/name_pointers.asm, the function TrainerNamePointers has become redundant in the international releases. This code has the purpose of delete that file.

SaveTrainerName::
-	ld hl, TrainerNamePointers
-	ld a, [wTrainerClass]
-	dec a
-	ld c, a
-	ld b, 0
-	add hl, bc
-	add hl, bc
-	ld a, [hli]
-	ld h, [hl]
-	ld l, a
+       ld hl, wTrainerName 
	ld de, wcd6d
.CopyCharacter
	ld a, [hli]
	ld [de], a
	inc de
	cp "@"
	jr nz, .CopyCharacter
	ret

-INCLUDE "data/trainers/name_pointers.asm"

Now you can delete the data/trainers/name_pointers.asm.

You too can make with this second method to delete the engine/battle/save_trainer_name.asm below, but not necessary if you do the first one.

Go to the function PrintEndBattleText in home/trainers

PrintEndBattleText::
	push hl
	ld hl, wd72d
	bit 7, [hl]
	res 7, [hl]
	pop hl
	ret z
	ldh a, [hLoadedROMBank]
	push af
	ld a, [wEndBattleTextRomBank]
	ldh [hLoadedROMBank], a
	ld [MBC1RomBank], a
	push hl
-	farcall SaveTrainerName
+       call SaveTrainerName
	ld hl, TrainerEndBattleText
	call PrintText
	pop hl
	pop af
	ldh [hLoadedROMBank], a
	ld [MBC1RomBank], a
	farcall FreezeEnemyTrainerSprite
	jp WaitForSoundToFinish

+SaveTrainerName::
+	ld hl, wTrainerName
+	ld de, wcd6d
+.CopyCharacter
+	ld a, [hli]
+	ld [de], a
+	inc de
+	cp "@"
+	jr nz, .CopyCharacter
+	ret

now, removing the engine/battle/save_trainer_name.asm from main.asm

...
SECTION "Battle Engine 3", ROMX

INCLUDE "engine/battle/print_type.asm"
-INCLUDE "engine/battle/save_trainer_name.asm"
INCLUDE "engine/battle/move_effects/focus_energy.asm"


SECTION "Battle Engine 4", ROMX
...
Clone this wiki locally