29482-\[ASM]_Change_Trainer_Sprite_of_Trainer_Card
#0
Andrea 25004
Hello guys, in this guide I will explain the change of the sprite in the trainer card in the rom of RUBY USA.
As we all know we can have 2 sprites:
Male & Female Player. Using the offset WBTO 02024EAC (overwriting 0 or 1) you can change the sex of the pg and the resulting sprite, unfortunately, are only two sprites mentioned before.
First, go to offset 080937E6 this byte to hijack the routine:
C0 46 00 48 00 47 XX+1 XX XX 08
XX XX XX 08 mean pointer of your routine +1 (THUMB MODE).
This is ASM ROUTINE i use:
.THUMB
.ALIGN 2
BL sub_8093DAC
PUSH {R0-R2}
LDR R2, = 0x0202E8C4@var 8000
LDRH R2, [R2]
LSL R2, #3
MOV R1, #0x31
LSL R1, #7
MOV R0, #3
LSL R0, #0x19
ADD R1, R0
LDR R0, = 0x081EC53C@table rom sprite trainer
ADD R0, R2
LDR R0, [R0]
SWI 0x12
LDR R0, = 0x081EC7D4@table rom sprite pal
ADD R0, R2
LDR R0, [R0]
LDR R1, = 0x0202EF68
SWI 0x12
LDR R1, = 0x0202EB68
SWI 0x12
POP {R0-R2}@pop registri
POP {R0}@torno alla routine principale
BX R0

sub_8093DAC:
LDR R0, = 0x08093DAD
BX R0

binary routine:
00 F0 17 F8 07 B4 0C 4A 12 88 D2 00 31 21 C9 01 03 20 40 06 09 18 09 48 80 18 00 68 12 DF 08 48 80 18 00 68 07 49 12 DF 07 49 12 DF 07 BC 01 BC 00 47 06 48 00 47 00 00 C4 E8 02 02 3C C5 1E 08 D4 C7 1E 08 68 EF 02 02 68 EB 02 02 AD 3D 09 08

Let me explain how work:
the routine save var 8000 value and mul it *8 because the table of trainer sprite and pal sprite are made with:
XX XX XX 08 YY YY YY YY
where the first four byte mean the pointer of image/pal and other 4 byte.
after i add offset of table to the previous result, i load 0x06001880 in R1 (start offset of trainer sprite)and i use SWI to decompress image.
when you load palette it's necessary to load pal in the direct pal in the ram and the pal of fadescreen to don't have flash of pal when you close TC menu (0x0202EF68, 0x0202EB68)
this is the script for change your sprite:
#dynamic 0x800000
#org @inizio
setvar 0x8000 0xNumber_Sprite
callasm 0xOffset routine +1
end

The total sprite in the rom are 52 (HEX). if you set var 8000 with value (greater than 52) and call routine you might have an error when you open the menu of trainer card ;)
This is the finale result :D

if you have problem write in the comment, hope you like it :D