The PokéCommunity Forums

The PokéCommunity Forums (https://www.pokecommunity.com/index.php)
-   Binary ROM Hacking (https://www.pokecommunity.com/forumdisplay.php?f=284)
-   -   Other Making a personal Gold version [GBC] (https://www.pokecommunity.com/showthread.php?t=341799)

Maniac379 January 4th, 2015 3:54 PM

Making a personal Gold version [GBC]
 
Pokemon gold is hands down my favorite and it is the one I replay the most. There's a few things I'd like to change in it though and I've found a lot of tools to make it happen already but some things seem less conventional. I will say I thoroughly enjoyed liquid crystal.

What I am wishing to do is
1. Edit the movesets level up moves for pokemon
2. 'add' moves into the game (more recent moves)
3. Physical/Special split attribute of attacks

I haven't found tools to do this yet so I'm guessing I'll have to delve more into straight up hex editing which is what I come here for. I'm wondering if I hex edit to change things like this and then try and use some of the specific tools I found could that cause some confusion? Is there room in the rom to add moves to the attack list. It kind of seems like each part of the code is in its own section and is limited by the size of that section? Like I saw there are blank item slots but there seems to be a limit to them. So are attacks similar? Would switching physical attacks to special attacks be a change of a single hex number on the attack or more complicated? I'm guessing I'd hands down have to do this part manually.

My vision is Pokemon gold, updated movesets and variety, increasing the pokemon the spawn, and making the trainers/gym leaders more challenging.

The intent being that I'd be able to play through the game with an increased challenge but much more variety in my team every time I play due to every pokemon being a viable team option.

EDIT:
Also say I start playing the rom so I have a save file up to the point of say a trainer I'm changing. Then I edit the trainer and reload the rom. Will my save file work?

miksy91 January 7th, 2015 7:50 AM

Quote:

Originally Posted by Maniac379 (Post 8565449)
Pokemon gold is hands down my favorite and it is the one I replay the most. There's a few things I'd like to change in it though and I've found a lot of tools to make it happen already but some things seem less conventional. I will say I thoroughly enjoyed liquid crystal.

What I am wishing to do is
1. Edit the movesets level up moves for pokemon
2. 'add' moves into the game (more recent moves)
3. Physical/Special split attribute of attacks

I haven't found tools to do this yet so I'm guessing I'll have to delve more into straight up hex editing which is what I come here for. I'm wondering if I hex edit to change things like this and then try and use some of the specific tools I found could that cause some confusion? Is there room in the rom to add moves to the attack list. It kind of seems like each part of the code is in its own section and is limited by the size of that section? Like I saw there are blank item slots but there seems to be a limit to them. So are attacks similar? Would switching physical attacks to special attacks be a change of a single hex number on the attack or more complicated? I'm guessing I'd hands down have to do this part manually.

My vision is Pokemon gold, updated movesets and variety, increasing the pokemon the spawn, and making the trainers/gym leaders more challenging.

The intent being that I'd be able to play through the game with an increased challenge but much more variety in my team every time I play due to every pokemon being a viable team option.

EDIT:
Also say I start playing the rom so I have a save file up to the point of say a trainer I'm changing. Then I edit the trainer and reload the rom. Will my save file work?

You would have to hex edit and re-code parts of the rom to implement all those features into the game. I'm not sure if there is a game-specific editor for editing the moves pokemon learn by level up but I'm pretty sure there is.

Game-specific tools (like a map editor or any other editor that comes to your mind, for example pksvui) are used for changing the game's code just like a hex editor does (and they mostly, if not always, work with data in 8-bit format (= hexadecimal) so they're kinda like hex editors as well). So basically, yes, you can use all kinds of tools for editing one single rom file.

Implementing P/S split would require telling the game somehow, which attacks are physical and which special and then using that information in some code that calculates the damage done, whether the move you used is physical or special. Totally doable!

Changes to the rom file won't affect your save file :)

Anyway, I could explain more about all this if I looked for more info elsewhere but you can do that yourself too. We've got lots of documentation in hax.iimarck.us. Use the "Search" function there to look for threads explaining this kind of stuff you're looking for help with.

P.S
Adding more attacks to the game is also possible but doing it could turn out really difficult. You should give that idea up, at least for now. Well... it would be sort of "easy" to add a few more attacks but that would quickly use all the "available spots" you have for attacks. Each attack is described with 1-byte value and there are already more than 250 attacks in the game I think. With one byte, you can describe 255 different values so there is really no room for many additional attacks. For adding more, you would have to recode a lot of stuff.

Dr. Seuss January 7th, 2015 8:25 AM

For the P/S split exist a patch to Pokemon Gold, but you need a minium knowledges of Hex editing to edit what moves are Psichycal and what are Special.

Maniac379 January 8th, 2015 8:52 AM

Quote:

Originally Posted by miksy91 (Post 8569520)
You would have to hex edit and re-code parts of the rom to implement all those features into the game. I'm not sure if there is a game-specific editor for editing the moves pokemon learn by level up but I'm pretty sure there is.

Game-specific tools (like a map editor or any other editor that comes to your mind, for example pksvui) are used for changing the game's code just like a hex editor does (and they mostly, if not always, work with data in 8-bit format (= hexadecimal) so they're kinda like hex editors as well). So basically, yes, you can use all kinds of tools for editing one single rom file.

Implementing P/S split would require telling the game somehow, which attacks are physical and which special and then using that information in some code that calculates the damage done, whether the move you used is physical or special. Totally doable!

Changes to the rom file won't affect your save file :)

Anyway, I could explain more about all this if I looked for more info elsewhere but you can do that yourself too. We've got lots of documentation in hax.iimarck.us. Use the "Search" function there to look for threads explaining this kind of stuff you're looking for help with.

P.S
Adding more attacks to the game is also possible but doing it could turn out really difficult. You should give that idea up, at least for now. Well... it would be sort of "easy" to add a few more attacks but that would quickly use all the "available spots" you have for attacks. Each attack is described with 1-byte value and there are already more than 250 attacks in the game I think. With one byte, you can describe 255 different values so there is really no room for many additional attacks. For adding more, you would have to recode a lot of stuff.

Thanks for the link, it looks like it will be quite helpful. So most of the tools I have allow me to change things without hex editing. I'm still looking around for everything and eventually I'll forray into straight up hex editing. I'm having trouble with 'tables' though? I have goldfinger and I had found something that said to copy this reference sheet into a txt document and change it to a .tbl file. That didn't seem to work. I found a download of the file already under .tbl and that works fine and it translates the words in the ROM for me. Also would any other tables be useful? I figure one for attack data but I'm imagining the table I have already translates the names and the other numbers wouldn't be specific enough to translate.

Another question, how does the game determine what moves wild pokemon know? Just wondering while I'm editing movesets.

miksy91 January 12th, 2015 12:51 PM

Quote:

Originally Posted by Maniac379 (Post 8571293)
Thanks for the link, it looks like it will be quite helpful. So most of the tools I have allow me to change things without hex editing. I'm still looking around for everything and eventually I'll forray into straight up hex editing. I'm having trouble with 'tables' though? I have goldfinger and I had found something that said to copy this reference sheet into a txt document and change it to a .tbl file. That didn't seem to work. I found a download of the file already under .tbl and that works fine and it translates the words in the ROM for me. Also would any other tables be useful? I figure one for attack data but I'm imagining the table I have already translates the names and the other numbers wouldn't be specific enough to translate.

Another question, how does the game determine what moves wild pokemon know? Just wondering while I'm editing movesets.

You may have figured this out already but table files are used for "translating" bytes into characters. And that's just their usage really.


You could make a table file for moves also but such table file is not really needed. Just have a text document opened that explains each byte and their meaning (= move name). This kind of document can be gotten from Giegue's Hacking Guide (google this).

A wild pokemon knows the four latest moves that it would learn till it reaches that level it is when encountered.

Maniac379 January 12th, 2015 7:09 PM

You seem like the go-to expert and helpful person on this after all I've found. Your videos have been more helpful to scripting then anything I've read.

So for my first script, I want to change the girl on Route 32 that gives you the item but only on Sunday.

It says her script location is 0x12C24E so I jump to that offset and see code starting with:
5A
47
63
00
09
7C

Now I tried matching up those first 3 numbers with the scripting compendium but it didn't make much sense to me. the 00 09 7C seems like a pointer so I should follow that to another offset right? Now it seems like there's numbers before the 5A that might be relevant to this person or not?

EDIT Addition:
So I figured out all I have to do is change the flag type from what it is to FF FF and this problem is fixed. Now something that concerned me as I was watching your videos and got to the flag type/bit of the Johto map. Everything seems to match up with the numbers as far as items and what not. I.E. the item on route 29 was flag byte AD06 but for the girl that only shows up on Tuesday, I expected to see 64 00 but I did not. Same for the other people that only showed up on certain days, I'm guessing my hacking so far may have messed this part up but I don't know. Anyway though it says there are 2 flags for this girl Tuscany Tuesday a 64 00 and 65 00. So if I change the flag to FF FF...I mean I don't understand for instance how one person has the two flag things. Also if I decompile her script it says 'verbosegiveitem BIGMUSHROOM 1'...but I just went to her in game and she gave me a Pink Bow like she was supposed to.

EDIT Again:
I found where the 64 00 and 65 00 was in the script but now I don't follow the flag that JohtoMap gave her in the first place. I'm guessing it says BIGMUSHROOM because maybe its thinking I'm coding for GBA? I figured out also I have to change the code from when it's not Tuesday to still give the item. Seems simple enough.

Maniac379 January 13th, 2015 12:40 PM

Ok now I'm stuck and no my exact question

I have the script and hex numbers all spelled out here:
#org 0x128E74
'-----------------------------------
6A faceplayer
47 loadfont
31 65 00 checkbit1 0x65
09 A2 4E if true 0x4EA2 ' 0x128EA2
1C 0B 07 checkcode 0xB
02 A2 4E if != 0x2 0x4EA2 ' 0x128EA2
31 64 00 checkbit1 0x64
09 8F 4E if true 0x4E8F ' 0x128E8F
4C DD 51 2writetext 0x51DD ' 0x1291DD
54 keeptextopen
33 64 00 setbit1 0x64
4C 5A 52 2writetext 0x525A ' 0x12925A
54 keeptextopen
9D 68 01 verbosegiveitem BIGMUSHROOM 1
08 A6 4E if false 0x4EA6 ' 0x128EA6
33 65 00 setbit1 0x65
4C 9A 52 2writetext 0x529A ' 0x12929A
53 closetext
49 loadmovesprites
90 end

Now I had tried using pksv to just delete the two lines of code:
1C 0B 07 checkcode 0xB
02 A2 4E if != 0x2 0x4EA2 ' 0x128EA2

Which would presumably remove the check/stop in the game if it's not the correct day for the item. It didn't really work, it worked once or twice but usually crashed the game. So my question is and I just put 00 00 00...00 in place of these 6 hex codes or would I have to move the entire hex codes up 1 by 1 until the 90 stop code and then the rest of the blank space presumably wouldn't matter and put the 00 at the end?

miksy91 January 13th, 2015 1:43 PM

Quote:

Originally Posted by Maniac379 (Post 8577985)
You seem like the go-to expert and helpful person on this after all I've found. Your videos have been more helpful to scripting then anything I've read.

So for my first script, I want to change the girl on Route 32 that gives you the item but only on Sunday.

It says her script location is 0x12C24E so I jump to that offset and see code starting with:
5A
47
63
00
09
7C

Now I tried matching up those first 3 numbers with the scripting compendium but it didn't make much sense to me. the 00 09 7C seems like a pointer so I should follow that to another offset right? Now it seems like there's numbers before the 5A that might be relevant to this person or not?

EDIT Addition:
So I figured out all I have to do is change the flag type from what it is to FF FF and this problem is fixed. Now something that concerned me as I was watching your videos and got to the flag type/bit of the Johto map. Everything seems to match up with the numbers as far as items and what not. I.E. the item on route 29 was flag byte AD06 but for the girl that only shows up on Tuesday, I expected to see 64 00 but I did not. Same for the other people that only showed up on certain days, I'm guessing my hacking so far may have messed this part up but I don't know. Anyway though it says there are 2 flags for this girl Tuscany Tuesday a 64 00 and 65 00. So if I change the flag to FF FF...I mean I don't understand for instance how one person has the two flag things. Also if I decompile her script it says 'verbosegiveitem BIGMUSHROOM 1'...but I just went to her in game and she gave me a Pink Bow like she was supposed to.

EDIT Again:
I found where the 64 00 and 65 00 was in the script but now I don't follow the flag that JohtoMap gave her in the first place. I'm guessing it says BIGMUSHROOM because maybe its thinking I'm coding for GBA? I figured out also I have to change the code from when it's not Tuesday to still give the item. Seems simple enough.

You've got a lot of stuff to be replied to here... Anyway, I'll try to have the patience to deal with it - at least sort of :)

Those bytes you have written here (5A, 47, 63, 00, 09, 7C) don't really match with the script data that is written in that offset. What really is there is: 6A 47 31 63 00 09 7C 42...

which is

faceplayer
loadfont
checkbit1 0x63
if true 0x427C ' 0x12C27C

and there is nothing exceptional about this part of script code here. The person just faces you, the font is loaded and text box is displayed (with loadfont). Then it checks the value of bit number 0x0063 starting at table in address $D7B7 in ram. If the value is 1 (= true), jump to address 0x12C27C.

The flag/bit number attached to a person event is a thing that is checked every time the map is loaded. If that flag/bit number is turned on (= has value 1), the person event "disappears" before the map is loaded completely. If the value is then again 0, the person event will remain shown after the map is loaded completely (and the player can start walking).
Basically, whenever you enter a map through a
1. Map connection, or
2. Warp

some code is run "behind the scenes" that checks each person event and should they be displayed in the map or not. Person event is shown if its bit number is either FF FF ,or the value of the bit number is 0 (like I described above). If the bit number attached to that person has value 1, the person event "disappears".

That "BIGMUSHROOM" as parameter of script code verbosegiveitem is an issue of GBA games and pksv not supporting that script code properly for GSC. As an example of using verbosegiveitem in scripts, you can just replace the text version of "BIGMUSHROOM" with the byte value of Pink Bow (which is 0x68). Try it! Compile the script by replacing BIGMUSHROOM with 0x68 and it ought to work. And even if you compile it with BIGMUSHROOM as a parameter, pksv will write byte 0x68 in its place so no problems there.

But yeah - what comes to Tuscany there, her "functionality" is implemented with 3 separate bit numbers / flags. One controls whether she can be seen or not (0x758 or how Johtomap displays it, 58 7), another one (0x63) is for giving the item and making her say "FRIEDA: Hiya! What\nday do you like?\pI love Friday. No\ndoubt about it!\pDon't you think\nit's great too?\e" after you talk to her again. There is still another bit number that is quite irrelevant really...

Bit number 0x62 controls the case when she doesn't introduce her to you again if you don't have room for the poison barb in your item pocket. That's all that it does really. In case the script was missing the check for bit 0x62, she would repeat saying "FRIEDA: Yahoo!\nIt's Friday!\pI'm FRIEDA of\nFriday!\pNice to meet you!\e" everytime you approach her again (after the script was "quit" because of you not having enough space in item pocket for poison barb).

Interesting to see they did build that case in there though. As far as I have seen it, Gamefreak was pretty lazy with implementing most scripts well.

And then to the next question... ;)


In GBA pokemon games, I believe there is a "NOP" scripting code as well which means "no instruction performed". We don't have such script code for GSC. In other words, you can't put any kind of filler data in between script code (like 00 00 00...) because those bytes are script codes as well. By having 3 consecutive 00 bytes there, the game actually uses a 2-byte pointer call to the first byte of the rom data.

00 = 2byte pointer points to script; when pointed script ends --> return to old script

The reason it even works is because of the fact that rom bank 0 (data between 0x0 and 0x3FFF in ROM) is always accessable with 2-byte pointers between 00 00 and FF 3F. And when it executes this call -code within the script, the game will crash, no doubt about that. You could check what it calls by simply loading script data from rom address 0x0. That there looks like rubbish because it's not supposed to be executed as script data of course.


So to take stuff out in between some script codes, you should just move the following script codes ahead (or use a jump code to the address where you want the script to continue). Notice that when you do this and compile the script, the editor will leave original leftover script data after the script you just compiled (because the new compiled script is shorter than the original one). You can delete that leftover data with a hex editor by marking it with byte 00s if you like.

Maniac379 January 14th, 2015 8:52 AM

I've gotten that part taken care of! I moved all of the code bytes ahead one by one in each section since I didn't know what the jump code meant. I'm assuming since I changed their appearance flag code to FF I've also just freed up 7 flags I could use down the road if I want to make something new as well

Now I've been trying to add running shoes for the past two hours.

I can't post links yet I'll try and message them
I got this version to work easily enough: [Gold/Silver Running Shoes Pokecommunity]
But I'd like to use this version as it seems better: [Better running shoes Skeetando]

Now the one I want to use, I tried following what it said to do but it didn't work, realizing it was for crystal and not gold I tried to interpret the response assembly language for awhile. From what I could tell I changed the info as to the pointer of where the game says you're pushing b. I think I need to put the initial pointer code in a different offset though because it doesn't work. So I tried taking the pointer code from the first version (pokecommunity link) and then copying the other code after it but it doesn't seem to work either. I tried different variations. I believe my problem is I'm putting it in the wrong spot or the differing banks are messing with the pointers.

I feel fairly familiar with Hex editing/JohtoMap but I'm having a lot more trouble finding information for using an assembly program (and finding one)

I'm thinking this:
$101AE
call @next
37 scf
C9 ret

@next
FA 29 CF ld a,[$CF29]//let's game know, that you're pushing "B" ; D03E crystal
CB 57 bit 2,a
E6 02 and a,$02
20 06 jr z,@Walk
3E 02 ld a,$02//STEP_BIKE ; run
CD 5F 42 call $425F//DoStep
C9 ret
3E 01 ld a,$01//STEP_WALK
CD 5F 42 call $425F//DoStep
C9 ret

but there doesn't seem to be empty space in the same rom bank as $101AE so is it possible to call a different rom bank, all the calls seem to be 2 byte in this assembly language. In the Rom bank I see spurts of 00 or FF's but it doesn't seem empty

Thanks Miksy

EDIT:
Found this for hex <=> assembly:
http://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html
http://marc.rawer.de/Gameboy/Docs/GBCPU_Instr.html

Kinda posting this stuff as I go along to try and help anyone else who might google this stuff

Are the hex numbers in specific banks (processor?) used for different numbers and thats say why 20 is a jump code there and not a give money? I'm looking again at the script for the guy who posted running shoes gold version and I'm unsure how the calls pointers and org pointers are arranged. It says call @extension...which isn't an offset...presumably its the org number above @extension later but the other @next has no such thing

miksy91 January 15th, 2015 11:50 AM

Quote:

Originally Posted by Maniac379 (Post 8579795)
I've gotten that part taken care of! I moved all of the code bytes ahead one by one in each section since I didn't know what the jump code meant. I'm assuming since I changed their appearance flag code to FF I've also just freed up 7 flags I could use down the road if I want to make something new as well

Yeah, you can use flags freely that are unused now because you removed them.


Quote:

Originally Posted by Maniac379 (Post 8579795)
Now I've been trying to add running shoes for the past two hours.

I can't post links yet I'll try and message them
I got this version to work easily enough: [Gold/Silver Running Shoes Pokecommunity]
But I'd like to use this version as it seems better: [Better running shoes Skeetando]

Now the one I want to use, I tried following what it said to do but it didn't work, realizing it was for crystal and not gold I tried to interpret the response assembly language for awhile. From what I could tell I changed the info as to the pointer of where the game says you're pushing b. I think I need to put the initial pointer code in a different offset though because it doesn't work. So I tried taking the pointer code from the first version (pokecommunity link) and then copying the other code after it but it doesn't seem to work either. I tried different variations. I believe my problem is I'm putting it in the wrong spot or the differing banks are messing with the pointers.

I feel fairly familiar with Hex editing/JohtoMap but I'm having a lot more trouble finding information for using an assembly program (and finding one)

I'm thinking this:
$101AE
call @next
37 scf
C9 ret

@next
FA 29 CF ld a,[$CF29]//let's game know, that you're pushing "B" ; D03E crystal
CB 57 bit 2,a
E6 02 and a,$02
20 06 jr z,@Walk
3E 02 ld a,$02//STEP_BIKE ; run
CD 5F 42 call $425F//DoStep
C9 ret
3E 01 ld a,$01//STEP_WALK
CD 5F 42 call $425F//DoStep
C9 ret

but there doesn't seem to be empty space in the same rom bank as $101AE so is it possible to call a different rom bank, all the calls seem to be 2 byte in this assembly language. In the Rom bank I see spurts of 00 or FF's but it doesn't seem empty

You can probably use the routine Chamber_ wrote unless you want to implement it on your own for some reason.
There is lots of room in that rom bank since it starts at 0x10000 and ends at 0x13FFF. In case you don't have enough room there / you want to fill in some other data as well, you can use a "3-byte call". There is an asm routine that can be accessed by filling register a with rom bank, hl with pointer value (for example, a = 10, hl = 405A would lead into address 10:405A = 0x10 * 0x4000 + 0x405A - 0x4000 = 0x4005A). This asm routine is written starting at rom address $8 (yep, it's at the start of the rom data and that's for a reason). You can access it directly with asm instruction rst $8.

So in case you find some in-game asm routine doing the following;
ld a, $1b_value
ld hl, $2b_value
rst $8

That's basically a 3-byte call to address a:hl. For saving values of registers a and hl for later usage, you've got to push them onto stack (instructions "push af" and "push hl").

Every asm instruction is 1-byte long but some of them have parameters that are either 1-byte or 2-byte long. For example ld a, $0F is a 1-byte instruction (ld) that was 1-byte parameter 0x0F. And "ld hl, 2b_value" has also 1-byte opcode with 2-byte parameter (= two 1-byte parameters!) that is attached as values to registers h and l.

There are no such things as "3-byte pointers" in Gameboy. Each pointer is 2-byte long. The reason why we don't have 3-byte pointers is because no asm instruction can even have a 3-byte parameter, the parameter can be only 1 or 2 bytes long.
Then again, by merging lots of asm instructions together in an efficient way, we can access code from other rom banks by either jumping there (= "3-byte jump) or by calling routines(= "3-byte call"). While "calls" in pksv language end with script code "end" or "return", Gameboy asm language, the instruction that tells the current subroutine ends is "ret" (or "reti").

Quote:

Originally Posted by Maniac379 (Post 8579795)
Thanks Miksy

EDIT:
Found this for hex <=> assembly:
http://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html
http://marc.rawer.de/Gameboy/Docs/GBCPU_Instr.html

Kinda posting this stuff as I go along to try and help anyone else who might google this stuff

Are the hex numbers in specific banks (processor?) used for different numbers and thats say why 20 is a jump code there and not a give money? I'm looking again at the script for the guy who posted running shoes gold version and I'm unsure how the calls pointers and org pointers are arranged. It says call @extension...which isn't an offset...presumably its the org number above @extension later but the other @next has no such thing

The reason Chamber_ wrote offsets like that is because it doesn't really matter where you store that information (or routine) as long as it is called from somewhere. So @extension and @next are rom addresses there in his routine which you can choose freely (as long as they can be called with 2-byte pointer calls within the same bank). In his own code, he has probably decided to use address 04:7E03 as "@extension" but you can choose that address freely yourself.

Also, pksv script codes and gameboy asm code is no way related. To tell you the truth, those script codes are actually "manipulated" with asm routines that exist "beneath" them. It's kinda like this;

Let's say we have the following script;

#org 0x123456
6A - faceplayer
47 - loadfont
4C - 2writetext 0x7470 ' 0x123470 ' "Hello!"
53 - closetext
49 - loadmovesprites
90 - end

We have some asm routine beneath that controls the execution of this script. The routine first looks for, what byte is stored in rom address 0x123456, and loads that somewhere, for example to register a (a = 6A). Then from some "call table" (table consisting of pointers for each script code in order from 00 to A3), it checks the value of entry number 0x6A (= 6Bth entry in that table because 1st is 00, 2nd 01, 3rd 02 and so on). That "value" could be a "3-byte pointer" (that is handled somehow to access a routine from another bank!). Now it uses this 3-byte pointer and calls the routine behind it and finds an asm routine that is used to execute the asm code making this talked-to person face player. After all this is done, we step-by-step, return to "executing more script code" by looking for byte value at address 0x123457 (where we have byte 47 that resembles "loadfont" and "do stuff" with it). And if you're wondering what happens when we eventually get to load value 4C ("2writetext"), it happens to check somehow (could be done in MANY different ways), "Should we load more data? (= Does value 4C have parameters? Yes. Two.)"

I don't think the game actually works like this, but it surely could and I would have implemented scripting system like this myself if I was the one to program these games. So there is probably an other kind of routine "beneath the script" but anyhow, we have some asm code that controls execution of the script. It's kinda like how computers are used execute Java programs with so called "Java Virtual Machine". Here we have a similar "virtual machine" too which is built as a huge program with gameboy asm instructions (and this controls the execution of script).

P.S
Google the following tools. They will definitely help out because you don't need to know each instruction - byte combination by heart.
Gameboy Assembler Plus, bgb (emulator with debugger), Gameboy Assembly Editor

Maniac379 January 16th, 2015 10:37 AM

I was able to change both of the following using gameboy assembly editor and goldfinger :)

Shiny Encounter Rate 1/254
--------------------------
offset 0x9052
ld l,c ; 69
ld h,b ; 60
ld a,[hli] ; 2A
and a,$CC ; E6 CC
cp $CC ; FE CC
jr nz,+$09 ; 20 09
ld a,[hl] ; 7E
and a,$CC ; E6 CC
cp $CC ; FE CC
jr nz,+$02 ; 20 02
scf ; 37
ret ; C9
and a ; A7
ret ; C9

//Rest of data was changed to 00 in the section
//Changes pokemon to be shiny if all DV's are 12 or higher
//To make Gyarados still shiny, changed his DV's

offset 0F:67EE
//if battle type is 07, make shiny
cp a,$07
jr nz,.next\@
ld b,$FF
ld c,$FF
jr .SetDVs\@


Running Shoes w/ B
--------------------
Offset 101B0

CD 03 7E call @extension
37 scf
C9 ret

org 04:7E03//$13E03

FA 29 CF ld a,[$CF29]//let's game know, that you're pushing "B" ; D03E crystal
CB 57 bit 2,a
E6 02 and a,$02
28 08 jr z,$7E14
3E 02 ld a,$02//STEP_BIKE ; run
CD 5F 42 call $425F//DoStep
C9 ret
3E 01 ld a,$01//STEP_WALK
CD 5F 42 call $425F//DoStep
37 ret

Maniac379 January 16th, 2015 10:50 AM

Quote:

Originally Posted by miksy91 (Post 8581036)
Yeah, you can use flags freely that are unused now because you removed them.

I'm picturing I can now use these flags to add events to a map without having to rewrite over somebody already in the map. I'll need to change what the flags do I suppose, I'll table this for now.

Quote:

Originally Posted by miksy91 (Post 8581036)
You can probably use the routine Chamber_ wrote unless you want to implement it on your own for some reason.
There is lots of room in that rom bank since it starts at 0x10000 and ends at 0x13FFF. In case you don't have enough room there / you want to fill in some other data as well, you can use a "3-byte call". There is an asm routine that can be accessed by filling register a with rom bank, hl with pointer value (for example, a = 10, hl = 405A would lead into address 10:405A = 0x10 * 0x4000 + 0x405A - 0x4000 = 0x4005A). This asm routine is written starting at rom address $8 (yep, it's at the start of the rom data and that's for a reason). You can access it directly with asm instruction rst $8.

So in case you find some in-game asm routine doing the following;
ld a, $1b_value
ld hl, $2b_value
rst $8

That's basically a 3-byte call to address a:hl. For saving values of registers a and hl for later usage, you've got to push them onto stack (instructions "push af" and "push hl").

Every asm instruction is 1-byte long but some of them have parameters that are either 1-byte or 2-byte long. For example ld a, $0F is a 1-byte instruction (ld) that was 1-byte parameter 0x0F. And "ld hl, 2b_value" has also 1-byte opcode with 2-byte parameter (= two 1-byte parameters!) that is attached as values to registers h and l.

There are no such things as "3-byte pointers" in Gameboy. Each pointer is 2-byte long. The reason why we don't have 3-byte pointers is because no asm instruction can even have a 3-byte parameter, the parameter can be only 1 or 2 bytes long.
Then again, by merging lots of asm instructions together in an efficient way, we can access code from other rom banks by either jumping there (= "3-byte jump) or by calling routines(= "3-byte call"). While "calls" in pksv language end with script code "end" or "return", Gameboy asm language, the instruction that tells the current subroutine ends is "ret" (or "reti").

Let me see if I understand this. There are no direct pointers to get to a different ROM bank but there is one built in at the beginning of every ROM bank at $8? So instead of a pointer calling a pointer function and going to the bank its kind of like a pointer to the beginning of the ROM which then the asm assembly redirects it to the desired bank? A pointer in a pointer type of thing?

Now I'm looking to get into more heavier editing on my own, it looks like resources are drying up a bit. My first question is I understand goldfinger hex editing and the GBasm edit program. I don't quite follow the way JohtoMap decompiling/compiling (confused on the two) rewrites the data. Seeing as how when I first tried to rewrite Tuscany's script by removing the lines of code it didn't work in JothoMap/Pokesav but it worked when I manually hex editted the code out and rearranged it all.

I'm also confused as to how and what GameBoy Assembler Plus and the debugger emulator do.

I've been reading a lot about disassembles and see things about a full crystal disassembly. This seems like another can of worms, I'll also table this for now.

So right now I'm thinking of A) Physical/Special Split and B) Heavily changing move names/effects

A) I found this thread on skeet "[Red] Problem with Physical/Special Routine" but it's for Red, I'm imagining if I found the right offset(how?) In Gold I could do something similar. But really if I want to get into editing codes like this, how would I find the proper offsets?

B) Similarly with A I would need to understand the offset of the effects table more, presumably I would want to add any effects. Also everything I Read on attack data, none of the bytes of information seem to refer to the attack name i.e. "Pound", I would need to edit that ext to. Tabling this, focusing on the previous non-tabled questions.

[I'm quite happy how far I've gotten still :) and done some things in the code itself without programs, now how to write and place my own without using other work :)]

As always thanks, sorry I couldn't wait until Sunday but I'll be out of town after this till thin ha

Maniac379 January 16th, 2015 10:52 AM

Quote:

Originally Posted by Ruki Makino (Post 8569571)
For the P/S split exist a patch to Pokemon Gold, but you need a minium knowledges of Hex editing to edit what moves are Psichycal and what are Special.

I'd say I could manage it now if you could direct me to something on the matter, I found a decent thread on skeet "[Red] Problem with Physical/Special Routine" but it's for Red not Gold

:)

miksy91 January 16th, 2015 12:36 PM

Quote:

Originally Posted by Maniac379 (Post 8582292)
Let me see if I understand this. There are no direct pointers to get to a different ROM bank but there is one built in at the beginning of every ROM bank at $8? So instead of a pointer calling a pointer function and going to the bank its kind of like a pointer to the beginning of the ROM which then the asm assembly redirects it to the desired bank? A pointer in a pointer type of thing?

You'll probably understand it one day but I won't bother explaining the whole functionality here since it's kinda confusing although the code for calling data from different rom banks isn't that large.

But basically, calling data from offset a:hl (a = rom bank, hl = pointer/address) works by call $0008 or rst $8 which is a 1-byte asm instruction accessing that same address 0x8 at the start of the rom.

As you can see at address $8, we have jump to $2E27 there. There we have 21 bytes of asm code ending at $2E47 with ret instruction. When this "ret" is executed, the "3-byte call" ends and the asm code from the point where "a:hl" was called, continues agains. If you take a look at the code there, we call address 00:0010 with "rst $10" a couple of times. There we have instruction "ld [$2000], a" which actually switches the accessable, variable rom bank to what is stored in a (and this is the main part about calling data from a:hl).

A bit more info about that process here (under 2000-3FFF - ROM Bank Number (Write Only) ):
http://gbdev.gg8.se/wiki/articles/MBC3

Quote:

Originally Posted by Maniac379 (Post 8582292)
Now I'm looking to get into more heavier editing on my own, it looks like resources are drying up a bit. My first question is I understand goldfinger hex editing and the GBasm edit program. I don't quite follow the way JohtoMap decompiling/compiling (confused on the two) rewrites the data. Seeing as how when I first tried to rewrite Tuscany's script by removing the lines of code it didn't work in JothoMap/Pokesav but it worked when I manually hex editted the code out and rearranged it all.

When you click "Compile" with pksv, it writes the script code in those addresses with "#org" prefix. After this compiling is done, if you have any other program (like Johtomap) opened, they still have the original data loaded in them (without this script being compiled in them!). So if you do more stuff with Johtomap and click save then, the changes made by pksv disappear.

So first make changes with Johtomap if needed, then open pksv and write script data with it, and then reload the rom with Johtomap to continue editing with that. Same with pksv - remember to reload the rom everytime with "Decompile" if you had used some other tool to edit the rom while pksv was opened.

Quote:

Originally Posted by Maniac379 (Post 8582292)
I'm also confused as to how and what GameBoy Assembler Plus and the debugger emulator do.

You can use Gameboy Assembler Plus to write "asm script" that is compiled in the rom as bytes just like pksv compiles script as bytes. Writing asm code with this is significantly faster than by using Gameboy Assembly Editor which can change one instruction at a time (and already that takes a couple of seconds).

Debugger can be used to follow execution of code and that's a neat tool for figuring out, where to place data of your own to change functionalities of how something works in the game. Besides that, you can use it to execute your own asm code instruction by instruction to figure out more easily, what's going wrong if you have a bug in your code. That was for example helpful to me when I was coding the functionality of giving BP instead of money for Battle Simulator opponents in Dark Energy.

Quote:

Originally Posted by Maniac379 (Post 8582292)
I've been reading a lot about disassembles and see things about a full crystal disassembly. This seems like another can of worms, I'll also table this for now.

Disassembly can surely make things easier. I don't consider that as much rom hacking than by editing things straight but yeah... I would have used that myself plenty of times as well if I could have. :)
If you do everything with disassembly, there are lots of things you won't get so familiar with but disassembly is more like general programming than hacking rom files and so much more user-friendly. It can spare time and make implementing several things easier. I have done my own hack without it because we don't have a disassembly for Gold or Silver.

Quote:

Originally Posted by Maniac379 (Post 8582292)
So right now I'm thinking of A) Physical/Special Split and B) Heavily changing move names/effects

A) I found this thread on skeet "[Red] Problem with Physical/Special Routine" but it's for Red, I'm imagining if I found the right offset(how?) In Gold I could do something similar. But really if I want to get into editing codes like this, how would I find the proper offsets?

Debugging and knowing how to code properly is a good way to start ;)

Well, you could get some info from Koolboyman and possibly others. Mateo has also included P/S split in his Christmas hack...I think? Not sure about that really.

But I believe everybody has followed Koolboyman's coding behind implementing it. How did he figure out how to do it then? He knows how assembly works, how to build stuff with it, used disassembly and debugging as help to find out where to insert his own routine which he wrote. There is nothing "supernatural" about this though :) With some research, I could have done this too but I have never been interested in adding P/S split anyway and probably won't include that for my own hack. Not to mention Koolboyman is still better than me though :)

Quote:

Originally Posted by Maniac379 (Post 8582292)
B) Similarly with A I would need to understand the offset of the effects table more, presumably I would want to add any effects. Also everything I Read on attack data, none of the bytes of information seem to refer to the attack name i.e. "Pound", I would need to edit that ext to. Tabling this, focusing on the previous non-tabled questions.

This is pretty basic stuff. You can get it done without my help as well so I won't bother giving help here :P :D

Quote:

Originally Posted by Maniac379 (Post 8582292)
I'm quite happy how far I've gotten still :) and done some things in the code itself without programs, now how to write and place my own without using other work :)]

As always thanks, sorry I couldn't wait until Sunday but I'll be out of town after this till thin ha

Sure, no problem :)
I never intended to help you this much since I haven't really been "tutoring" others but I don't mind at all though. Especially since you took the effort to learn.

Maniac379 March 6th, 2016 1:28 PM

I just wanted to say in case anyone ever uses this later that my running shoes script above wasn't 100%. I have since debugged it, essentially it's the same as the one posted on skeetendo for better running shoes with only the offset changed from the crystal to gold numbers.

Running Shoes w/ B
--------------------
Offset 101B0

CD 03 7E call @extension
37 scf
C9 ret

org 04:7E03//$13E03

FA 29 CF ld a,[$CF29]//let's game know, that you're pushing "B" ; D03E crystal
CB 57 bit 2,a
E6 02 and a,$02
20 07 jr z,$7E14
3E 01 ld a,$02//STEP_BIKE ; walk
CD 5F 42 call $425F//DoStep
37 scf
C9 ret
3E 02 ld a,$01//STEP_run
CD 5F 42 call $425F//DoStep
37 scf
C9 ret

JawaadYousuf May 11th, 2019 6:06 PM

Hello can you please send or post the link for the version of gold you have made please i'm tired of finding one so can you please send me the link to your's


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


Like our Facebook Page Follow us on Twitter © 2002 - 2018 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 - 2016 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.

Acknowledgements
Use of PokéCommunity Assets
vB Optimise by DragonByte Technologies Ltd © 2023.