View Single Post
Old September 23rd, 2012 (10:38 AM).
Chaos Rush's Avatar
Chaos Rush Chaos Rush is offline
im sexy and i know it
Join Date: May 2007
Location: Taylor Swift
Gender: Male
Nature: Adamant
Posts: 1,296
Originally Posted by Jambo51 View Post
Second up, this is the battle string loader hack I made. It intercepts the "failed" part of the loader. That is, it branches out from what the loader would otherwise consider to be a bad number to load from and skip.

.align 2
.global battlestringloaderhack
mov r0, #0xC2
lsl r0, r0, #0x1
cmp r0, r6
bne normalcode
ldr r0, ramlocation
ldr r7, [r0, #0x0]
cmp r7, #0x0
beq alternative
mov r0, #0xA
lsl r0, r0, #0x18
cmp r7, r0
bge alternative
mov r0, #0x8
lsl r0, r0, #0x18
cmp r7, r0
blt alternative
b continue
alternative: mov r6, #0xC
ldr r1, returntwo
bx r1
continue: ldr r0, returnone
bx r0
normalcode: ldr r1, otherramloc
mov r0, #0xFF
strb r0, [r1, #0x0]
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
ramlocation: .word 0x0203C020
returntwo: .word 0x080D77D1
returnone: .word 0x080D77DD
otherramloc: .word 0x0202298C

As you can see, it has checks to try and catch a "bad" location given in the RAM location I set aside for the new functionality. All it can catch, sadly, is if you leave the RAM location empty, or if you try to use an invalid ROM location. The rest, I have to leave to the user.

I've written the routine such that it supports 32MB ROMs as well, so you don't have to worry about that either.

To insert the actual routine, navigate to 0xD77BE and change the code to 03 49 08 47, then go to 0xD77CC and change the pointer to the insert location of the routine, plus 1 for THUMB mode of course.

Now, using it. It's as easy as this: Using the storebyte command of the battle script functionality (0x2E), store the bytes of the ROM pointer in little endian ordering, into the RAM address 0x0203C020. Then, you call the battle string printer as such:
10 84 01 39 40 00
The routines will take care of the rest!
For some reason it's not working correctly. It just freezes the game.

This is what I've done:
1. Insert the routine at 0x71EA35
2. Change the bytes like you said at 0xD77BE
3. Change the bytes at 0xD77CC so that it points to 0x71EA36
4. Inserted a text string at 0x71EA85
5. For my battle script, it goes like:
02 03 09 0A 48 01 03 00 2E DE 3F 02 02 14 89 C1 00 69 1D 08 12 40 00 2E 20 C0 03 02 85 2E 21 C0 03 02 EA 2E 22 C0 03 02 71 2E 23 C0 03 02 08 10 84 01 39 40 00 3D
And yes, I have made sure that I've assigned my custom attack to the custom battle script. It executes the animation, and I checked in VBA's Memory Viewer that it correctly updates the Attack Stat modifier like what I wrote in my custom script, and it even does the stat change animation like I made it so, but it doesn't display my custom message, instead it just freezes after that. The part that I bolded is the code that should display the custom text.

My projects:
Untitled Pokémon fangame (pictured above) | Final Fantasy II NES retranslation | Mother 1/EarthBound Beginnings Color Restoration for GBA
Non-Pokémon hacks I support:
Sonic Classic Heroes
Sonic 3 Complete
Reply With Quote