PDA

View Full Version : Development: Changing Fire Red intro rival sprites/names and texts depending on players gender


tinix
December 11th, 2011, 12:26 PM
So lately I have been thinking aboout how to edit sprites of rival in the fire red intro depending on the gender of player. After a while of reaserch I managed to do it. Although I dont like a few things about that code it works and doesnt seem to cause any harm to the ROM. So here are the routines

Branching routine to be inserted at 0x131248:


.align 2
.thumb
.thumb_func
; should go at 0x131248
main:
push {r4}
ldr r4, .POINTER
bx r4
.POINTER
.word 0x08900001


Actual code that modifies the behaivour:


.align 2
.thumb
.thumb_func
.main:
pop {r4}
push {r3}
ldr r3, .PLAYER_DATA
ldr r3, [r3]
ldrb r3, [r3, #0x8]
mov r1, #0x60
mov r2, #0x40
cmp r3,#0x0
bne .girl
pop {r3}
push {r3}
ldr r0, .IMAGE_1a
ldr r3, .FUN1
bl .jmp
pop {r3}
ldr r0, .IMAGE_1
ldr r2, .RETURN
bx r2
.girl:
pop {r3}
push {r3}
ldr r0, .IMAGE_2a
ldr r3, .FUN1
bl .jmp
pop {r3}
ldr r0, .IMAGE_2
ldr r2, .RETURN
bx r2
.jmp:
bx r3
.align 2
.PLAYER_DATA:
.word 0x0300500C
.IMAGE_1:
.word 0x084623EC
.IMAGE_2:
.word 0x08460F14
.IMAGE_1a:
.word 0x084623AC
.IMAGE_2a:
.word 0x08460ED4
.RETURN:
.word 0x08131255
.FUN1:
.word 0x080703ED






Next thing Im going to look into are names.
Video:
v/vOWGKptmGxU

Jambo51
December 15th, 2011, 04:49 AM
Is this your first piece of ASM (or close to)?
It could be written better, but very well done on getting it to work.

Things which could definitely be improved:



ldr r4, .BOY
; These two were in dissasembly of original code, I didnt played with them
mov r1, #0x60
mov r2, #0x40
;Comparision
cmp r3,r4
bne girl


Should simply be:


mov r1, #0x60
mov r2, #0x40
cmp r3, #0x0
bne girl



The loading of 0x0 into r4 for comparison is wasteful, when you can simply compare r3 with 0 like I have above, this also nullifies the need for the push of r4 in the code. You only need to load something into the register to compare if the thing you want to compare with is unknown at compile time (the number is known in this case) or if the number you wish to compare is larger than 0xFF. Otherwise, simply use cmp rx, #0xZ to compare register x with byte Z.

The way that bl (or blx as you call it) work with the gba games is annoying:
The way to use it properly is this:



ldr r0, .IMAGE_1a
bl wherever
pop {r3}
//rest of code
ldr r0, .IMAGE_2a
bl wherever
pop {r3}
//rest of code
wherever: push {r3}
ldr r3, .FUN1
bx r3



A pain? Yes. But it works.

Hope this helps, and well done on finding and creating a solution for yourself!

tinix
December 15th, 2011, 06:06 AM
Is this your first piece of ASM (or close to)?
It could be written better, but very well done on getting it to work.

Things which could definitely be improved:



ldr r4, .BOY
; These two were in dissasembly of original code, I didnt played with them
mov r1, #0x60
mov r2, #0x40
;Comparision
cmp r3,r4
bne girl


Should simply be:


mov r1, #0x60
mov r2, #0x40
cmp r3, #0x0
bne girl



The loading of 0x0 into r4 for comparison is wasteful, when you can simply compare r3 with 0 like I have above, this also nullifies the need for the push of r4 in the code. You only need to load something into the register to compare if the thing you want to compare with is unknown at compile time (the number is known in this case) or if the number you wish to compare is larger than 0xFF. Otherwise, simply use cmp rx, #0xZ to compare register x with byte Z.

The way that bl (or blx as you call it) work with the gba games is annoying:
The way to use it properly is this:



ldr r0, .IMAGE_1a
bl wherever
pop {r3}
//rest of code
ldr r0, .IMAGE_2a
bl wherever
pop {r3}
//rest of code
wherever: push {r3}
ldr r3, .FUN1
bx r3



A pain? Yes. But it works.

Hope this helps, and well done on finding and creating a solution for yourself!

Thank you for pointing out these things. It is my first working ARM/THUMB ASM program/hack (played with x86 a bit) I will try to fix those things.

Darthatron
December 15th, 2011, 06:11 AM
Always nice to see new ASM hacks by new people. But maybe you should upload a video or something of it working. :)

Also, I think once you've become a bit better with THUMB, you may be able to just rewrite the whole routine and make it WAY smaller. Maybe even fit in to the old routine and save a bunch of space. :) Good luck!!

tinix
December 15th, 2011, 10:04 AM
I modified the routine according to tips that jambo has given, and also I will soon post a video of it working.

The Author
December 15th, 2011, 02:31 PM
This is EXACTLY what I was looking for!
This will help out a lot.
THANK YOU. :cer_boogie:

diegoisawesome
December 15th, 2011, 04:10 PM
Hey, I already did this a while ago, for my own hack. Nice to see someone else do it, too.
Although mine is more complete...
rLBPEids0TM

tinix
December 15th, 2011, 09:49 PM
Hey, I already did this a while ago, for my own hack. Nice to see someone else do it, too.
Although mine is more complete...
rLBPEids0TM

I plan to change names too, but I didnt lastly have time to look into it.