Skip to content

Commit

Permalink
Minor improvements to BoldText and ChangeTextSound (#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adex-8x authored Aug 1, 2024
1 parent 5c3ff2a commit 56be822
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
.org CallDisplayChar
.area 0x4
bl RepeatRender
.endarea

.org ReturnCharWidth
.area 0x4
bne TryIncreaseBoldCharWidth
.endarea
Original file line number Diff line number Diff line change
@@ -1,42 +1,49 @@
.org 0x023A7080+0xA70
.area 0xAEC-0xA70
.org 0x023A7080+0xA70
.area 0xAF8-0xA70

HookBLetter:
ldr r0,[r13, StackThing]
add r1,=char_BS
bl TagCheck
cmp r0,#0
beq check_BR ; If not [BS], check for [BR].
add r1,=bold
mov r0,#1
strb r0,[r1]
str r0,[bold]
b AfterTagIsFound
check_BR:
ldr r0,[r13, StackThing]
add r1,=char_BR
bl TagCheck
cmp r0,#0
beq TagCodeError ; If neither [BS] nor [BR], this is an invalid tag!
add r1,=bold
mov r0,#0
strb r0,[r1]
str r0,[bold]
b AfterTagIsFound
RepeatRender:
; r7 contains the address to a function that displays a character.
push r14,r0-r3
blx r7
add r0,=bold
ldrb r0,[r0]
ldr r0,[bold]
cmp r0,#0
pop r0-r3
popeq r15
subs r1,r1,#1 ; r1 = X-coordinate of character to display
movmi r1,#0
blx r7
pop r15
TryIncreaseBoldCharWidth:
.if PPMD_GameVer == GameVer_EoS_JP
ldrsh r0,[r0,#0x6] ; Original instruction, sorta
.else
ldrb r0,[r0,#0x2] ; Original instruction, sorta
.endif
ldr r1,[bold]
cmp r1,#0
addne r0,r0,#1
pop r3,r15
.pool
bold:
.byte 0x0
.word 0x0
char_BS:
.asciiz "BS"
char_BR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
.definelabel TagCheck, 0x02020A20
.definelabel TagCodeError, 0x02021BD4
.definelabel AfterTagIsFound, 0x02021C64
.definelabel ReturnCharWidth, 0x02026868
.definelabel StackThing, 0x78
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
.definelabel TagCheck, 0x02020918
.definelabel TagCodeError, 0x02021A60
.definelabel AfterTagIsFound, 0x02021AF0
.definelabel ReturnCharWidth, 0x0202665C
.definelabel StackThing, 0x70
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
.definelabel TagCheck, 0x020208C8
.definelabel TagCodeError, 0x02021A10
.definelabel AfterTagIsFound, 0x02021AA0
.definelabel ReturnCharWidth, 0x02026584
.definelabel StackThing, 0x70
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
.org CaseT
.area 0x4
b HookTLetter
.endarea

.org PlaySeByIdVolumeCallsite
.area 0x4
bl CustomPlaySeByIdVolume
.endarea
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.org 0x023A7080+0xB20
.area 0xB7C-0xB20
.area 0xBA8-0xB20

HookTLetter:
ldr r0,[r13, StackThing]
Expand All @@ -9,20 +9,33 @@ HookTLetter:
beq check_TR ; If not [TS], check for [TR].
ldr r0,[r13, StackThing+4]
bl GetTagParameter
ldr r1,=TextboxSE
str r0,[r1] ; Change the text sound to ID X from [TS:X]
str r0,[new_sound] ; Change the text sound to ID X from [TS:X:Y].
cmp r6,#2
moveq r0,#0x100 ; If there is no second parameter, assume a default volume of 0x100.
ldrne r0,[r13, StackThing+8]
blne GetTagParameter
str r0,[new_volume]
b AfterTagIsFound
check_TR:
ldr r0,[r13, StackThing]
add r1,=char_TR
bl TagCheck
cmp r0,#0
beq TagCodeError ; If neither [TS] nor [TR], this is an invalid tag!
ldr r1,=TextboxSE
ldr r0,=#16133
str r0,[r1] ; Restore the default textbox sound effect.
str r0,[new_sound] ; Restore the default textbox sound effect.
mov r0,#0x100
str r0,[new_volume] ; Restore the default textbox volume.
b AfterTagIsFound
CustomPlaySeByIdVolume:
ldr r0,[new_sound]
ldr r1,[new_volume]
b PlaySeByIdVolume ; Original instruction, sorta
.pool
new_sound:
.word 0x3F05
new_volume:
.word 0x100
char_TS:
.asciiz "TS"
char_TR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
.arm

.definelabel CaseT, 0x0202111C
.definelabel TextboxSE, 0x02017DB8
.definelabel PlaySeByIdVolumeCallsite, 0x02017DAC
.definelabel PlaySeByIdVolume, 0x02018354
.definelabel TagCheck, 0x02020A20
.definelabel GetTagParameter, 0x02020A64
.definelabel TagCodeError, 0x02021BD4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
.arm

.definelabel CaseT, 0x02021014
.definelabel TextboxSE, 0x02017D74
.definelabel PlaySeByIdVolumeCallsite, 0x02017D68
.definelabel PlaySeByIdVolume, 0x02018310
.definelabel TagCheck, 0x02020918
.definelabel GetTagParameter, 0x0202095C
.definelabel TagCodeError, 0x02021A60
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
.arm

.definelabel CaseT, 0x02020FC4
.definelabel TextboxSE, 0x02017D1C
.definelabel PlaySeByIdVolumeCallsite, 0x02017D10
.definelabel PlaySeByIdVolume, 0x020182B8
.definelabel TagCheck, 0x020208C8
.definelabel GetTagParameter, 0x0202090C
.definelabel TagCodeError, 0x02021A10
Expand Down
2 changes: 1 addition & 1 deletion skytemple_files/patch/handler/change_text_sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def name(self) -> str:

@property
def description(self) -> str:
return "Adds new text tags that allow for the textbox sound to be changed. [TS:X] will use the Xth sound effect ID in textboxes. [TR] will revert the sound to default."
return "Adds new text tags that allow for the textbox sound to be changed. [TS:X:Y] will use the Xth sound effect ID in textboxes with a volume of Y. [TR] will revert the sound and volume to their default states, sound effect 16133 and volume 256."

@property
def author(self) -> str:
Expand Down

0 comments on commit 56be822

Please sign in to comment.