Skip to content

Commit

Permalink
Use an empty name to identify when the head part should be used to de…
Browse files Browse the repository at this point in the history
…termine the name (for enemies and allies), properly fixes #238
  • Loading branch information
VariantXYZ committed Jun 2, 2024
1 parent e6d982b commit 6c19153
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 31 deletions.
26 changes: 11 additions & 15 deletions game/src/battle/enemy.asm
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,12 @@ BattleLoadEnemyDataInit:: ; This copies the name, which happens again later...
push de
call WrapBufferTextFromList
pop de
push de

; Instead of loading the enemy name, we'll just use the head part, so omit copying it
ld hl, $40
add hl, de
ld d, h
ld e, l
ld hl, W_NewListItemBufferArea
ld bc, $9
call memcpy
pop de
ld [hl], $CB

ld hl, $c5bc
ld b, $00
ld a, [$c4ee]
Expand Down Expand Up @@ -152,15 +149,12 @@ BattleLoadEnemyDataName:: ; 29285 (a:5285)
push de
call WrapBufferTextFromList
pop de
push de
; Instead of loading the enemy name, we'll just use the head part, so omit copying it
ld hl, $40
add hl, de
ld d, h
ld e, l
ld hl, W_NewListItemBufferArea
ld bc, $9
call memcpy
pop de
ld [hl], $CB

ld hl, $200
add hl, de
ld d, h
Expand Down Expand Up @@ -208,4 +202,6 @@ BattleLoadEnemyDataMisc::
dec a
ld [$c4f0], a
jr nz, .next_participant
ret
ret

padend $530c
10 changes: 1 addition & 9 deletions game/src/battle/include/buffer_text_macros.asm
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,7 @@ LoadParticipantNameIntoBUF02Cont_\1::
; If the length is 0, fall back on the head part (probably ally)
ld a, [hli]
cp $CB
jr z, .useHeadPart
; Check if the length fits
ld b, $08
.checkLengthLoop
ld a, [hli]
cp $CB
jr z, .player
dec b
jr nz, .checkLengthLoop
jr nz, .player
.useHeadPart
xor a
Expand Down
13 changes: 6 additions & 7 deletions game/src/battle/status.asm
Original file line number Diff line number Diff line change
Expand Up @@ -889,18 +889,17 @@ DisplayMedarotNamesForBattleStatus::
ret

HelperGetMedarotNameFromHead:
; This will be reused for multiplayer as well, so check if the length might fit
ld b, $09
; A bit of a hack, but check if the loaded name exists and fits
; This must cover the multiplayer, NPC ally, and NPC enemy use-cases
ld hl, $40
add hl, de
push hl
.loop
; If the length is 0, use the head part
ld a, [hli]
cp $CB
jr z, .player
dec b
jr nz, .loop
jr nz, .player

.useHeadPart
pop hl
; The enemy bot names are based on the head part (loaded in 0A:519c)
Expand Down

0 comments on commit 6c19153

Please sign in to comment.