The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking
Reload this Page Help Thread ASM & Disassembly

Notices
For all updates, view the main page.

Binary ROM Hacking Need a helping hand or just want to talk about binary ROM hacks? Get comments and answers to any ROM Hacking-related problems, questions or thoughts you have here.

Ad Content
Closed Thread
 
Thread Tools
  #301   Link to this post, but load the entire thread.  
Old May 20th, 2015 (3:23 PM).
Joexv's Avatar
Joexv Joexv is offline
ManMadeOfGouda
joexv.github.io
 
Join Date: Oct 2012
Location: Oregon
Age: 25
Gender: Male
Nature: Sassy
Posts: 1,035
Quick question. Is there a fast method on moving an entire table to ram? Or would a simple halfword move loop be the best option? Length of 38 bytes btw.
__________________
New living flesh vessel who dis?
  #302   Link to this post, but load the entire thread.  
Old May 20th, 2015 (5:06 PM).
esperance's Avatar
esperance esperance is offline
 
Join Date: Mar 2010
Location: OH
Age: 26
Gender: Male
Nature: Relaxed
Posts: 3,830
Quote:
Originally Posted by joexv View Post
Quick question. Is there a fast method on moving an entire table to ram? Or would a simple halfword move loop be the best option? Length of 38 bytes btw.
Why do you need to? It would probably be easier to just calculate the offset of an individual entry and load from the ROM, no?
__________________
What are you so afraid of?
  #303   Link to this post, but load the entire thread.  
Old May 20th, 2015 (5:13 PM).
Joexv's Avatar
Joexv Joexv is offline
ManMadeOfGouda
joexv.github.io
 
Join Date: Oct 2012
Location: Oregon
Age: 25
Gender: Male
Nature: Sassy
Posts: 1,035
Quote:
Originally Posted by Lost Heart View Post
Why do you need to? It would probably be easier to just calculate the offset of an individual entry and load from the ROM, no?
Well cause I saw THIS, and what he does is simply set the trainers pokemon intro ram and instead of the trainer data being pointed to somewhere in the ROM he points it to RAM. And I thought, why not do the same for wild Pokemon? And since idk where in RAM the wildpokemon table is read from, I could just do what he does, but with a different table.

If theres an easier way to do this I would love to know.:)
__________________
New living flesh vessel who dis?
  #304   Link to this post, but load the entire thread.  
Old May 20th, 2015 (5:28 PM).
esperance's Avatar
esperance esperance is offline
 
Join Date: Mar 2010
Location: OH
Age: 26
Gender: Male
Nature: Relaxed
Posts: 3,830
Quote:
Originally Posted by joexv View Post
Well cause I saw THIS, and what he does is simply set the trainers pokemon intro ram and instead of the trainer data being pointed to somewhere in the ROM he points it to RAM. And I thought, why not do the same for wild Pokemon? And since idk where in RAM the wildpokemon table is read from, I could just do what he does, but with a different table.

If theres an easier way to do this I would love to know.:)
It would probably just be easier to create somewhere in the ROM, and then just supply the correct pointer, right? I can understand wanting to load the data from the RAM because it sounds like it would be easier to randomize that way, but consider this: if you're wanting random wild Pokemon generation, you'll still want to limit it some right (like no legendaries)? So, you could just create a table of pointers to different encounter data, and get a random pointer from said table to get the data. You could modify the wild loading routine so that it checks for a specific flag and if so goes to this table of potential encounter sets. It would allow for more control on your end of what you may encounter, despite taking a bit more work. But that's all my opinion, and I'm certainly no authority on ASM or anything.
__________________
What are you so afraid of?
  #305   Link to this post, but load the entire thread.  
Old May 20th, 2015 (5:32 PM).
Joexv's Avatar
Joexv Joexv is offline
ManMadeOfGouda
joexv.github.io
 
Join Date: Oct 2012
Location: Oregon
Age: 25
Gender: Male
Nature: Sassy
Posts: 1,035
Quote:
Originally Posted by Lost Heart View Post
It would probably just be easier to create somewhere in the ROM, and then just supply the correct pointer, right? I can understand wanting to load the data from the RAM because it sounds like it would be easier to randomize that way, but consider this: if you're wanting random wild Pokemon generation, you'll still want to limit it some right (like no legendaries)? So, you could just create a table of pointers to different encounter data, and get a random pointer from said table to get the data. You could modify the wild loading routine so that it checks for a specific flag and if so goes to this table of potential encounter sets. It would allow for more control on your end of what you may encounter, despite taking a bit more work. But that's all my opinion, and I'm certainly no authority on ASM or anything.
Yea that makes sense, but I dont want randomization, I just want specific tables, that way I wont have to make a new map for everytime I need to change the wild data. And I have no idea how I would go about editing that sorta thing.:)
__________________
New living flesh vessel who dis?
  #306   Link to this post, but load the entire thread.  
Old May 20th, 2015 (5:34 PM).
esperance's Avatar
esperance esperance is offline
 
Join Date: Mar 2010
Location: OH
Age: 26
Gender: Male
Nature: Relaxed
Posts: 3,830
Quote:
Originally Posted by joexv View Post
Yea that makes sense, but I dont want randomization, I just want specific tables, that way I wont have to make a new map for everytime I need to change the wild data. And I have no idea how I would go about editing that sorta thing.:)
Then like I said, just modify the loader so that if a var/flag is set it will know to read a unique data set as opposed to the map's default. No need to waste RAM after all. Or, just go in with a hex editor and modify the wild data for each applicable map to point to a single data set.
__________________
What are you so afraid of?
  #307   Link to this post, but load the entire thread.  
Old May 20th, 2015 (5:45 PM).
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924
Quote:
Originally Posted by Lost Heart View Post
Then like I said, just modify the loader so that if a var/flag is set it will know to read a unique data set as opposed to the map's default. No need to waste RAM after all. Or, just go in with a hex editor and modify the wild data for each applicable map to point to a single data set.
Yeah, this is pretty much it. Don't ever waste RAM space if you don't need to. I would make the table in ROM then have a switching variable to switch between the tables.

Some clarification on how Pokemon wild data is made, it's derived using the level and species. It uses the generic Pokemon generation routine (which is why the shiny routines, custom move routines all affect wild Pokemon and trainer Pokemon). These values are indeed fetched based on maps via a table.
__________________
...
  #308   Link to this post, but load the entire thread.  
Old May 20th, 2015 (5:50 PM).
Joexv's Avatar
Joexv Joexv is offline
ManMadeOfGouda
joexv.github.io
 
Join Date: Oct 2012
Location: Oregon
Age: 25
Gender: Male
Nature: Sassy
Posts: 1,035
Quote:
Originally Posted by FBI agent View Post
Yeah, this is pretty much it. Don't ever waste RAM space if you don't need to. I would make the table in ROM then have a switching variable to switch between the tables.

Some clarification on how Pokemon wild data is made, it's derived using the level and species. It uses the generic Pokemon generation routine (which is why the shiny routines, custom move routines all affect wild Pokemon and trainer Pokemon). These values are indeed fetched based on maps via a table.
Ok, but if I'm to do that I would need to know where the offset is determined, which I do not. And since this is for Emerald idk if theres been much of any research into it.
__________________
New living flesh vessel who dis?
  #309   Link to this post, but load the entire thread.  
Old May 20th, 2015 (6:18 PM).
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924
Quote:
Originally Posted by joexv View Post
Ok, but if I'm to do that I would need to know where the offset is determined, which I do not. And since this is for Emerald idk if theres been much of any research into it.
Start by setting a break point at the table. The table's location should be available to you via A-map. I'm unsure about Emerald's locations, I don't have an Emerald ROM.
__________________
...
  #310   Link to this post, but load the entire thread.  
Old May 20th, 2015 (6:36 PM).
esperance's Avatar
esperance esperance is offline
 
Join Date: Mar 2010
Location: OH
Age: 26
Gender: Male
Nature: Relaxed
Posts: 3,830
Quote:
Originally Posted by joexv View Post
Ok, but if I'm to do that I would need to know where the offset is determined, which I do not. And since this is for Emerald idk if theres been much of any research into it.
You could also check out Jambo51's work on Day/Night wild Pokemon switching. There should be stuff on Emerald, which should provide a starting point for research.
__________________
What are you so afraid of?
  #311   Link to this post, but load the entire thread.  
Old May 21st, 2015 (1:45 PM). Edited May 21st, 2015 by kleenexfeu.
kleenexfeu kleenexfeu is offline
 
Join Date: Aug 2013
Gender: Male
Posts: 218
Hi, I tried to recreate the Bad Dreams ability in Emerald (the version doesn't really matter). I have a freeze when a pokémon is effectively asleep and there's a Bad Dream in battle.

I explained why I did this or that instruction, what I'm trying to do, being to most accurate possible, if anyone would like to take a look into that.

The place where I hooked is where the check for poisonning damages is done (which seemed to be appropriate to me, the effect being the same = -1/8 life).

I don't post directly here because the routine is pretty long, so it would be easier here : http://hastebin.com/xexiwavuwi.hs If anything seems wrong, if you have any clue, don't hesitate please :)



EDIT : Nevermind, there was stupid error and I found another way to do that anyway.
__________________
Arceus and Giratina Forms
Dynamic Pokémon Data
  #312   Link to this post, but load the entire thread.  
Old May 22nd, 2015 (11:03 PM).
MisterJoJo MisterJoJo is offline
 
Join Date: Feb 2014
Posts: 9
I'm back. I used the DNS of prime-dialga and linked it to my own time offset. Everything is working but currently im saving the time in the RAM at 02FFFF60 and this data is gone after reseting the game. So my question is if there is some free space of data where i can write to and is saved by saving the game?
  #313   Link to this post, but load the entire thread.  
Old May 22nd, 2015 (11:52 PM).
Touched's Avatar
Touched Touched is offline
Resident ASMAGICIAN
 
Join Date: Jul 2014
Gender: Male
Posts: 625
Quote:
Originally Posted by MisterJoJo View Post
I'm back. I used the DNS of prime-dialga and linked it to my own time offset. Everything is working but currently im saving the time in the RAM at 02FFFF60 and this data is gone after reseting the game. So my question is if there is some free space of data where i can write to and is saved by saving the game?
Yes - use one of the save blocks. But you would have to modify those routines so that they read from your new RAM location. Save blocks are DMA-protected so you need a pointer to a pointer to the block (fun). I believe HackMew's ASM tutorial is an example of how to use the player data save block. Also, I don't know if the source is available for those routines; if not, you're going to have to RE it.
__________________

A Pokemon that is discriminated!
Support squirtle and make it everyone's favourite.
  #314   Link to this post, but load the entire thread.  
Old May 23rd, 2015 (12:02 AM). Edited May 23rd, 2015 by MisterJoJo.
MisterJoJo MisterJoJo is offline
 
Join Date: Feb 2014
Posts: 9
Quote:
Originally Posted by Touched View Post
Yes - use one of the save blocks. But you would have to modify those routines so that they read from your new RAM location. Save blocks are DMA-protected so you need a pointer to a pointer to the block (fun). I believe HackMew's ASM tutorial is an example of how to use the player data save block. Also, I don't know if the source is available for those routines; if not, you're going to have to RE it.
Is there a post about the save blocks (where they are) ? I will look in to this. Bypassing the DMA-protection would that mean:
ldr r0, .firstoffset #containing second offset
ldr r0, [r0]
ldr r0, [r0]

EDIT: I found it in HackMew's tutorial. Finally I know what DMA protection means. Thanks for giving me the link.
  #315   Link to this post, but load the entire thread.  
Old May 23rd, 2015 (1:15 AM).
Touched's Avatar
Touched Touched is offline
Resident ASMAGICIAN
 
Join Date: Jul 2014
Gender: Male
Posts: 625
Quote:
Originally Posted by MisterJoJo View Post
Is there a post about the save blocks (where they are) ? I will look in to this. Bypassing the DMA-protection would that mean:
ldr r0, .firstoffset #containing second offset
ldr r0, [r0]
ldr r0, [r0]

EDIT: I found it in HackMew's tutorial. Finally I know what DMA protection means. Thanks for giving me the link.
I don't know about a post, but it's in the IDBs (as long as you're working on FireRed or Emerald). You don't need the second "ldr r0, [r0]" unless you're loading the first word of the saveblock. You load the address of the pointer with "ldr r0, .firstoffset" then you get the pointer out of that with the first "ldr r0, [r0]". With the pointer you can then load/write tthe saveblock structure. There are 3 save blocks, so you shouldn't have trouble finding space.

Also, you said you're using 02FFFF60 currently? How is that possible :/
__________________

A Pokemon that is discriminated!
Support squirtle and make it everyone's favourite.
  #316   Link to this post, but load the entire thread.  
Old May 23rd, 2015 (2:00 AM).
MisterJoJo MisterJoJo is offline
 
Join Date: Feb 2014
Posts: 9
Quote:
Originally Posted by Touched View Post
I don't know about a post, but it's in the IDBs (as long as you're working on FireRed or Emerald). You don't need the second "ldr r0, [r0]" unless you're loading the first word of the saveblock. You load the address of the pointer with "ldr r0, .firstoffset" then you get the pointer out of that with the first "ldr r0, [r0]". With the pointer you can then load/write tthe saveblock structure. There are 3 save blocks, so you shouldn't have trouble finding space.

Also, you said you're using 02FFFF60 currently? How is that possible :/
Everything should work now. I installed one of JPANS Memory extensions and ported it for my language (German). I'm going to use the 0203e000 adress now.
I don't know how that is possibly ... I know everybody says that you can only use specific RAM adresses, but I can only say ... It worked. Writing and reading from the location was no problem. I was thinking like: maybe that adress at the end isn't used yet.
  #317   Link to this post, but load the entire thread.  
Old May 23rd, 2015 (2:29 AM).
Touched's Avatar
Touched Touched is offline
Resident ASMAGICIAN
 
Join Date: Jul 2014
Gender: Male
Posts: 625
Quote:
Originally Posted by MisterJoJo View Post
Everything should work now. I installed one of JPANS Memory extensions and ported it for my language (German). I'm going to use the 0203e000 adress now.
I don't know how that is possibly ... I know everybody says that you can only use specific RAM adresses, but I can only say ... It worked. Writing and reading from the location was no problem. I was thinking like: maybe that adress at the end isn't used yet.
The RAM for a 02XXXXXX segment ends at 0203FFFF. After that there are mirrors of the same space. You probably wrote to one of the mirrors, so it ended up in the on-board RAM anyway. You shouldn't do this is it is unpredictable.
__________________

A Pokemon that is discriminated!
Support squirtle and make it everyone's favourite.
  #318   Link to this post, but load the entire thread.  
Old May 23rd, 2015 (2:32 AM).
MisterJoJo MisterJoJo is offline
 
Join Date: Feb 2014
Posts: 9
Quote:
Originally Posted by Touched View Post
The RAM for a 02XXXXXX segment ends at 0203FFFF. After that there are mirrors of the same space. You probably wrote to one of the mirrors, so it ended up in the on-board RAM anyway. You shouldn't do this is it is unpredictable.
I thought it was save because there was nothing ever written to it. I'm using the save extension RAM now anyways.
  #319   Link to this post, but load the entire thread.  
Old June 5th, 2015 (12:46 AM).
Lance32497's Avatar
Lance32497 Lance32497 is offline
LanceKoijer of Pokemon_Addicts
 
Join Date: Aug 2014
Location: Criscanto town-Ginoa Region xD
Gender: Male
Nature: Adamant
Posts: 792
I'm trying to create an ASM where, the value(half word) stored in Variable 8000 and 8001 will be written in offset 0x08800000
i tried loading the halfword of Var 8000 and 8001 and stored it in 0x08800000 and 0x08800002 but I couldn't make it correct, nothing happened in offset 0x08800000

here's my routine
Spoiler:

.text
.align 2
.thumb
.thumb_func

main:
push {r0-r2, lr}
ldr r0, VAR
ldr r1, ADDRESS
ldrh r0, [r0]
ldrh r1, [r1]
strh r0, [r1]
ldrh r1, [r0, #0x02]
strh r0, [r0, #0x02]
pop {pc}

.align 2
VAR: .word 0x020370B8
ADDRESS: .word 0x08800000
__________________
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
  #320   Link to this post, but load the entire thread.  
Old June 5th, 2015 (1:16 AM).
Q-orca Q-orca is offline
 
Join Date: Sep 2014
Gender: Male
Posts: 23
Quote:
Originally Posted by Lance32497 View Post
*stuff
There are 3 problems with your code.
1. 08xxxxxx is ROM address (Read Only Memory). Consult GBATEK for available RAM address.
2. Assuming you have the correct RAM address,
Spoiler:

ldr r0, VAR
ldr r1, ADDRESS
ldrh r0, [r0]
strh r0, [r1]

3. The number of pushed register should be the same as popped register. Getting out of the routine can be done with bx or pop pc. This is my example:
Spoiler:

push {r0-r1,lr}
ldr r0, VAR
ldr r1, ADDRESS
ldrh r0, [r0]
strh r0, [r1]
pop {r0-r1,pc}
  #321   Link to this post, but load the entire thread.  
Old June 7th, 2015 (5:26 AM).
Lance32497's Avatar
Lance32497 Lance32497 is offline
LanceKoijer of Pokemon_Addicts
 
Join Date: Aug 2014
Location: Criscanto town-Ginoa Region xD
Gender: Male
Nature: Adamant
Posts: 792
Hello guys, I want to ask this,
str stores the value of a certain register into a register
while add adds a byte in a certain register

so let's say r0 has 0x020370b8
ldr r0, =(0x020370B8)
ldr r1, =(0x0880EE4A)
ldrb r1, [r1]
ldrb r0, [r0]
strb r0, [r1]

so it means that by doing that, 0x020370B8 has 0x4A

while
ldr r0, =(0x020370B8)
ldrb r0, [r0]
add r0, r0, #0x5

so it means that by doing that, r0 is now 0x020370BD

correct me if I'm wrong
__________________
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
  #322   Link to this post, but load the entire thread.  
Old June 7th, 2015 (5:31 AM).
daniilS's Avatar
daniilS daniilS is offline
busy trying to do stuff not done yet
 
Join Date: Aug 2013
Age: 23
Gender: Male
Posts: 409
Quote:
Originally Posted by Lance32497 View Post
Hello guys, I want to ask this,
str stores the value of a certain register into a register
while add adds a byte in a certain register

so let's say r0 has 0x020370b8
ldr r0, =(0x020370B8)
ldr r1, =(0x0880EE4A)
ldrb r1, [r1]
ldrb r0, [r0]
strb r0, [r1]

so it means that by doing that, 0x020370B8 has 0x4A

while
ldr r0, =(0x020370B8)
ldrb r0, [r0]
add r0, r0, #0x5

so it means that by doing that, r0 is now 0x020370BD

correct me if I'm wrong
nnnnnope.
ldrb loads a byte from an address into a certain register. and stop trying to write to the rom, it's not gonna work.
__________________
  #323   Link to this post, but load the entire thread.  
Old June 7th, 2015 (5:36 AM). Edited June 7th, 2015 by kleenexfeu.
kleenexfeu kleenexfeu is offline
 
Join Date: Aug 2013
Gender: Male
Posts: 218
Quote:
Originally Posted by Lance32497 View Post
Hello guys, I want to ask this,
str stores the value of a certain register into a register
while add adds a byte in a certain register

so let's say r0 has 0x020370b8
ldr r0, =(0x020370B8)
ldr r1, =(0x0880EE4A) Here you load a ROM address, as mentioned above it means "Read Only Memory". You cannot right something in here. Just let you know.
ldrb r1, [r1] Here you load a byte in r1, so r1 doesn't contain a pointer anymore. Actually pointer are just numbers, but it would look like "000000XX" which point to nothing relevant AFAIK.
ldrb r0, [r0]
strb r0, [r1] So here you write a byte at the address "000000XX", which I don't even know if it's possible.

so it means that by doing that, 0x020370B8 has 0x4A Actually you didn't change what was wrote at 0x020370B8 as I explained.

while
ldr r0, =(0x020370B8)
ldrb r0, [r0] again, you load a byte into r0, so let's suppose at 0x020370B8 there was 0x24 wrote, r0 contain now 0x24.
add r0, r0, #0x5 By adding 0x5 it hold now 0x29

so it means that by doing that, r0 is now 0x020370BD And not that

correct me if I'm wrong
Responses in bold.

Ninja-ed, thanks daniilS.
  #324   Link to this post, but load the entire thread.  
Old June 7th, 2015 (5:49 AM).
Lance32497's Avatar
Lance32497 Lance32497 is offline
LanceKoijer of Pokemon_Addicts
 
Join Date: Aug 2014
Location: Criscanto town-Ginoa Region xD
Gender: Male
Nature: Adamant
Posts: 792
Aahhhh, thanks for response, I really need to read carefully ASM tutorials 24/7..
thanks for letting me know,
__________________
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
  #325   Link to this post, but load the entire thread.  
Old June 7th, 2015 (8:55 PM).
Lance32497's Avatar
Lance32497 Lance32497 is offline
LanceKoijer of Pokemon_Addicts
 
Join Date: Aug 2014
Location: Criscanto town-Ginoa Region xD
Gender: Male
Nature: Adamant
Posts: 792
Hello guys, I'm trying to build a routine that lets the Var 8000 edit thePokémon data substructures(Bulbapedia term)
.... I had read the entire site but I can't find the RAM Address of that Pokemon Data substructure
__________________
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Closed Thread

Quick Reply

Join the conversation!

Create an account to post a reply in this thread, participate in other discussions, and more!

Create a PokéCommunity Account
Ad Content

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

Forum Jump


All times are GMT -8. The time now is 9:24 AM.