The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Creative Discussions > Emulation & ROM Hacking > Research & Development
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Research & Development Got a well-founded knack with ROM hacking? Love reverse-engineering the Pokémon games? Or perhaps you love your assembly language. This is the spot for polling and gathering your ideas, and then implementing them! Share your hypothesis, get ideas from others, and collaborate to create!
New threads in this forum are to be approved by a moderator before they are displayed. The thread revival limit does not apply here.


Reply
 
Thread Tools
  #1    
Old December 11th, 2011, 12:26 PM
tinix's Avatar
tinix
PearlShipper & C Programmer
 
Join Date: Feb 2010
Location: Bratislava, Slovakia
Age: 16
Gender: Male
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:
Spoiler:

Code:
.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:
Spoiler:

Code:
.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:
__________________
Pokémon games i own:
Pokémon Diamond
Pokémon Platinum
Pokémon Ranger: Shadows of Almia
Pokémon HeartGold Version

75% of Pokemon gamers use cheats and specially made codes to make their pokemon battle-worthy. If you are one of the 25% percent that level their Pokemon up legally, put this in your signature.
-Started by SkittyLover77



Last edited by tinix; December 15th, 2011 at 10:21 AM.
Reply With Quote
  #2    
Old December 15th, 2011, 04:49 AM
Jambo51's Avatar
Jambo51
Glory To Arstotzka
 
Join Date: Jun 2009
Gender: Male
Nature: Quiet
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:

Spoiler:

Code:
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:

Code:
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:

Spoiler:

Code:
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!
__________________
Hey guys, please check out my recreations of the gen 1 and 2 music on my custom engine at my SoundCloud! - Here!

Last edited by Jambo51; December 15th, 2011 at 05:01 AM.
Reply With Quote
  #3    
Old December 15th, 2011, 06:06 AM
tinix's Avatar
tinix
PearlShipper & C Programmer
 
Join Date: Feb 2010
Location: Bratislava, Slovakia
Age: 16
Gender: Male
Quote:
Originally Posted by Jambo51 View Post
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:

Spoiler:

Code:
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:

Code:
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:

Spoiler:

Code:
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.
__________________
Pokémon games i own:
Pokémon Diamond
Pokémon Platinum
Pokémon Ranger: Shadows of Almia
Pokémon HeartGold Version

75% of Pokemon gamers use cheats and specially made codes to make their pokemon battle-worthy. If you are one of the 25% percent that level their Pokemon up legally, put this in your signature.
-Started by SkittyLover77


Reply With Quote
  #4    
Old December 15th, 2011, 06:11 AM
Darthatron's Avatar
Darthatron
巨大なトロール。
 
Join Date: Jan 2006
Location: Melbourne, Australia
Age: 22
Gender: Male
Nature: Modest
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!!
__________________
あなた は しきしゃ です
わたし は ばか です
Reply With Quote
  #5    
Old December 15th, 2011, 10:04 AM
tinix's Avatar
tinix
PearlShipper & C Programmer
 
Join Date: Feb 2010
Location: Bratislava, Slovakia
Age: 16
Gender: Male
I modified the routine according to tips that jambo has given, and also I will soon post a video of it working.
__________________
Pokémon games i own:
Pokémon Diamond
Pokémon Platinum
Pokémon Ranger: Shadows of Almia
Pokémon HeartGold Version

75% of Pokemon gamers use cheats and specially made codes to make their pokemon battle-worthy. If you are one of the 25% percent that level their Pokemon up legally, put this in your signature.
-Started by SkittyLover77


Reply With Quote
  #6    
Old December 15th, 2011, 02:31 PM
The Author's Avatar
The Author
The Hero of Knothole Glade
 
Join Date: Sep 2011
Location: Knothole Glade
Age: 16
Gender: Male
Nature: Quiet
This is EXACTLY what I was looking for!
This will help out a lot.
THANK YOU. :cer_boogie:
__________________
The Disciple
The Poet
The Leader
The Musician
The Transcendentalist

The Author
The Philosopher
The Architect
The Psychologist
The Artist
Reply With Quote
  #7    
Old December 15th, 2011, 04:10 PM
diegoisawesome's Avatar
diegoisawesome
Not the Script Help Thread
 
Join Date: Dec 2007
Location: Goldenrod City, Johto
Age: 17
Gender: Male
Nature: Quirky
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...
__________________


My other resources:
My Website
diegoisawesome's MEGA-HUGE XSE Scripting Tutorial
diegoisawesome's Miscellaneous Finds
The Ruins of Alph Puzzles
Reply With Quote
  #8    
Old December 15th, 2011, 09:49 PM
tinix's Avatar
tinix
PearlShipper & C Programmer
 
Join Date: Feb 2010
Location: Bratislava, Slovakia
Age: 16
Gender: Male
Quote:
Originally Posted by diegoisawesome View Post
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...
I plan to change names too, but I didnt lastly have time to look into it.
__________________
Pokémon games i own:
Pokémon Diamond
Pokémon Platinum
Pokémon Ranger: Shadows of Almia
Pokémon HeartGold Version

75% of Pokemon gamers use cheats and specially made codes to make their pokemon battle-worthy. If you are one of the 25% percent that level their Pokemon up legally, put this in your signature.
-Started by SkittyLover77


Reply With Quote
Reply
Quick Reply

Sponsored Links


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 09:52 PM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.