Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2014-12-16 18:33:50

daw
New member
Registered: 2013-01-31
Post 3/4

Better running shoes

Hi, I want to show you my own script, which I use in my hack.
With this you can use running shoes without any bugs. Bike works properly too.

There is the code (for pkmn crystal):

At 0x801ae type zeros up to 0x801b3 and then write here a call.

CD XX YY (xx yy - 2 byte pointer to your script in the same bank)

Now go to this adress and start typing your script:

FA 3E D0 - ld a,($D03E) - let's game know, that you're pushing "B"
CB 57 - bit 2,a
E6 02 - and $02
20 07 - jr nz, $07 - If so, skip $7 bytes
3E 01 - ld a,$01 - walk
CD 5F 42 - call do step (call from erased data)
37 - scf
C9 - ret
3E 02 - ld a,$02 - run
CD 5F 42 - call do step
37 - scf
C9 - ret

You can also use modified version, that will prevent you from running inside a building:

Just type that code right before the main script

FA 9A D1 - ld a,($D19A) - check map type ( indoor, route etc.)
FE 03 - cp $03 - indoor
28 11 - jr z, $11 - if yes, skip $11
FE 06 - cp $06 - passage
28 0D - jr z, $0D - if yes, skip $0D
FE 07 - cp $07 - indoor 2
28 09 - jr z, $09 - if yes, skip $09

If someone will use it, just give me a credit.
Thanks!

Offline

#2 2014-12-16 21:55:48

Chamber_
Member
Registered: 2013-12-31
Post 93/119

Re: Better running shoes

Nice routine.

I also did mine but for Pokemon Gold.

$101AE
call @extension
scf
ret


org 04:7E03//$13E03
@extension

call $2D63//GetMapPermission
cp a,04//Cave
jr z,@next
cp a,06//Indoor
jr z,@next

call $23CD//CheckOutdoorMap
jr nz,@Walk

@next
ld a,[$CF29]//let's game know, that you're pushing "B" ; D03E crystal
bit 2,a
and a,$02
jr z,@Walk

ld a,$02//STEP_BIKE ; run
call $425F//DoStep
ret

@Walk
ld a,$01//STEP_WALK
call $425F//DoStep
ret

Offline

#3 2014-12-17 14:59:04

daw
New member
Registered: 2013-01-31
Post 4/4

Re: Better running shoes

Thanks!
Nice to see your work.

Offline

#4 2014-12-17 22:09:03

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 2,933/3,578

Re: Better running shoes

Nice to see you guys have come up with a way to do this without overriding the bike. From what I can tell, this simply tricks the stepping routine into thinking you are on the bike if you are holding "B" without forcing the bike value in Ram, so it avoids all the weird errors that the old routine had. Pretty nifty. I will probably add this to Christmas, since that way I can have the running shoes everyone wants and not mess up the areas I've included that require the Mach Bike.

Offline

#5 2014-12-23 10:23:07

stag019
Idea Killer
Registered: 2011-01-05
Post 608/630

Re: Better running shoes

The first time I saw this thread (just reading the title) I thought it was another spam bot. Now I'm starting to wonder if it's threads like these talking about adding running shoes into Pokemon that's making the spam bots talk a lot about shoes and Nike and whatnot. :P


You can try to hide yourself in this world of pretend; when the paper's crumpled up, it can't be perfect again.

Offline

#6 2016-01-10 11:52:02

wolfboyft
Member
Registered: 2015-09-26
Post 15/15

Re: Better running shoes

Where .walk is 20:41ae, or non-relative ROM address 0x801ae.
This is my pokecrystal version.

.walk
    ld a, [CurInput]
    bit 2, a
    and 2
    ld a, STEP_WALK
    jr z, .doStep
    ld a, STEP_BIKE
.doStep
    call DoStep
    scf
    ret

Last edited by wolfboyft (2016-01-10 13:46:23)

Offline

#7 2016-05-18 12:35:30

Adam
Member
Registered: 2016-05-07
Post 2/93

Re: Better running shoes

Hey guys,

I'm trying to start scripting for my pokemon hack. I only have a couple of scripts to write and figured the running shoes would be the easiest to implement.  I have typed up the script and it does not recognise the commands when I try to compile it.

I have tried the OP's script in PKSV and Wolfboy's, but to no avail. I assume I am doing something wrong.

Untitled_2.png

Sorry if my error seems very newbish, but I am pretty new to this and having some difficulty with Crystal hacking. I've got to grips with some basic hex editing (at least parts of it), but other parts and scripting are still unown territory for me at the moment :/

Also, I notice that I can't seem to find the pointer for this script. I need to put those two bytes into the code, as per the original instructions. Presumably this is generated after a successful compile?

Offline

#8 2016-05-18 13:04:00

Crystal_
Member
From: Spain
Registered: 2012-09-16
Post 373/450
Website

Re: Better running shoes

That's not the scripting language, it's just assembly. I don't think PKSV can compile and write assembly code to the rom.

Anyway, if you're hacking Pokemon Crystal you should totally switch to working over the pokecrystal disassembly, especially if you're attepting things like these. You'll be able to patch your code wherever it goes and then build the modified rom easily.

Offline

#9 2016-05-18 13:34:00

Adam
Member
Registered: 2016-05-07
Post 3/93

Re: Better running shoes

Oh ok, that makes things more difficult. Am I able to unpack my existing work into disassembly or would I need to start from scratch? I've done a lot so far and don't really have any inclination to start over.

All I need to do is alter a giveitem script in the game, implement running shoes, and change a few sprites and then I'm done. Doing everything again through disassembly doesn't sound too appealing at this point :p

Is there any way to implement the running shoes a different way, perhaps through the hex editor?

Thanks for your reply.

Offline

#10 2016-05-18 13:51:40

Crystal_
Member
From: Spain
Registered: 2012-09-16
Post 374/450
Website

Re: Better running shoes

If you're going to call it done after doing those three things then yeah, there's no point porting it to a disassembly project at this point. How easy would it be? Depends on what you've done. If it's just map edits or other data changes like wild or trainer pokemon or pokemon base stats data then it's as simple as adding your hacked rom to the directory and include your changes directly from the rom instead of using the original data. But if you've been working on a lot of misc things here and there and especially if you haven't been keeping track of everything then it's probably too late to make it worthwile.

Anyway, the best alternative to insert asm is probably the bgb debugger. You're going to have to insert dirty jumps here and there to patch your new additions but if you're not going to do complex things then you won't have to bother much about maintainability/scalability. Been there and it was annoying.

Last edited by Crystal_ (2016-05-18 13:52:24)

Offline

#11 2016-05-18 13:58:14

Adam
Member
Registered: 2016-05-07
Post 4/93

Re: Better running shoes

Thanks, I'll give it a shot. I don't suppose there are any guides for the disassembly lying about that you are aware of? I've seen bits and bats but not much seems to be comprehensive enough.

The changes I have been making hopefully shouldn't affect the transfer. My hack is more of an enhancement of the original game, balancing things better but also adding in some new stuff and remixing other things. Hopefully those shouldn't conflict. I'll be backing up my file anyway so I suppose there's no harm in giving it a shot. If everything messes up because it doesn't sit well with what I've done then so be it.

Thanks again for your help. Most things I have found are for either the Advance games or for Gold, so this project has certainly proved harder than I hoped. It's only my love of Crystal that has kept me going :p

Offline

#12 2016-05-18 16:07:03

Miksy91
Member
Registered: 2010-10-16
Post 2,255/2,339

Re: Better running shoes

Adam wrote:

All I need to do is alter a giveitem script in the game, implement running shoes, and change a few sprites and then I'm done. Doing everything again through disassembly doesn't sound too appealing at this point :p

Is there any way to implement the running shoes a different way, perhaps through the hex editor?

Doing all of this by working with the rom file should be pretty simple actually.

You can change the giveitem script with PKSV, implement running shoes with bgb or Gameboy ASM Editor (I personally haven't managed to re-write instructions with bgb for some reason) and change a couple of sprites with Tile Layer Pro for instance.

I took a quick look at Pokemon Crystal rom file, and I strongly believe the routine starting at 20:4000 (in Crystal) matches the routine starting at 04:4000 (in Gold or Silver). To implement the Running Shoes, you can change the first call code at 20:4000 with Koolboyman's routine that you were probably trying to write with it. At the end of the subroutine that you call starting at 20:4000, you need to execute the original call command (= call 4017).
Also, I was trying to look for code by KBM but couldn't find it easily so stopped looking. Anyway, I did run into this: https://hax.iimarck.us/topic/1723/

As you can see there, the music will (most likely) function incorrectly after a battle if you (literally) run into a wild pokemon or hold B button when meeting up with a trainer. I fixed this in Dark Energy by modifying those so called "map loading processes".

Offline

#13 2016-05-18 19:16:27

Adam
Member
Registered: 2016-05-07
Post 5/93

Re: Better running shoes

Thanks Miksy,

I'm not entirely sure I understand what to change with the running shoes in the ASM editor as I've never done that before. The bug you mentioned though seems to make it a bad idea. I thought that the code the OP created would avoid anything like that (since he stated "With this you can use running shoes without any bugs."). If that's not the case, I may skip it.

I looked into amending the give item script in PKSV and I can't find it. I tried looking for the script there but there was nothing. The trainer I want is at offset x184FD9 (according to CrystalMap). If I decompile this offset in PKSV it brings up:

#org 0x184FD9
'-----------------------------------
coinstotext 0x6
3callasm 0xFF0006
#raw 0xFF
return

Following the offsets leads to this:

#org 0xC300
'-----------------------------------
3call 0xDDEA3C ' 0xFFFFFFFF
#raw 0xC2
#raw 0xCD
#raw 0xE1
givepokeitem 0x3EC9 ' 0xFFFFFFFF
2call 0xCBCD ' 0xFFFFFFFF
givepokeitem 0xE2FA ' 0xFFFFFFFF
#raw 0xAB
#raw 0xEA
if == 0xD1 0x13E ' 0xFFFFFFFF
#raw 0xEA
jumpstd 0x21D1

However items 3EC9 and E2FA don't seem to correspond to the item codes listed here:
https://www.reddit.com/r/ROMhacksLibrar … tem_codes/

Presumably GSC have different item codes. Either that or I am looking in the wrong place.

I don't suppose you have any idea where the giveitem code for this trainer would be located? I haven't altered this trainer's position or event data, only the pokemon, his trainer name, and his dialogue. Further alterations [outside the giveitem] weren't necessary. Also is there a reference guide to the items codes for GSC somewhere? Presumably the item codes don't correspond with the link above.

I apologise again for my questions as I fully realise that I seem like really amateurish at the moment. It's not for lack of trying though. I've spent most of today (in addition to the many other days) looking through the programs and searching for solutions to the giveitem issue, but with no luck. I really wish I was better at this. Hopefully after when I move onto a FR hack it'll be easier. There seems to be loads of tools, tutorials, videos, etc for that!

Offline

#14 2016-05-18 19:37:32

Miksy91
Member
Registered: 2010-10-16
Post 2,256/2,339

Re: Better running shoes

Adam wrote:

Thanks Miksy,

I'm not entirely sure I understand what to change with the running shoes in the ASM editor as I've never done that before. The bug you mentioned though seems to make it a bad idea. I thought that the code the OP created would avoid anything like that (since he stated "With this you can use running shoes without any bugs."). If that's not the case, I may skip it.

I didn't read the earlier discussion in this thread. I did it indeed differently, but you can try using daw's method which will probably work as he said it would.
So simply write what he told to write there. The hex codes of all those instructions are also listed, so practically you don't even have to use an asm editor for the job (although that would help understanding what you're actually writing there).

Adam wrote:

I looked into amending the give item script in PKSV and I can't find it. I tried looking for the script there but there was nothing. The trainer I want is at offset x184FD9 (according to CrystalMap). If I decompile this offset in PKSV it brings up:

#org 0x184FD9
'-----------------------------------
coinstotext 0x6
3callasm 0xFF0006
#raw 0xFF
return

Following the offsets leads to this:

#org 0xC300
'-----------------------------------
3call 0xDDEA3C ' 0xFFFFFFFF
#raw 0xC2
#raw 0xCD
#raw 0xE1
givepokeitem 0x3EC9 ' 0xFFFFFFFF
2call 0xCBCD ' 0xFFFFFFFF
givepokeitem 0xE2FA ' 0xFFFFFFFF
#raw 0xAB
#raw 0xEA
if == 0xD1 0x13E ' 0xFFFFFFFF
#raw 0xEA
jumpstd 0x21D1

However items 3EC9 and E2FA don't seem to correspond to the item codes listed here:
https://www.reddit.com/r/ROMhacksLibrar … tem_codes/

Presumably GSC have different item codes. Either that or I am looking in the wrong place.

I don't suppose you have any idea where the giveitem code for this trainer would be located?

GSC item hex codes can be found here: http://www.angelfire.com/oh4/giegue/gmg2hpgr2c.txt

To edit the script that is executed after the battle ends, check the "trainer script structure" here: https://hax.iimarck.us/files/scriptingc … ventaufbau

That is simple hex code and thus it won't show up correctly when you open pksv to look for "normal script" data starting at that address. So use a hex editor to see where the script that is executed after the battle is located. As you can see, at the end of "trainer script structure", we have "[2byte pointer to script if won/talked to again]" which tells where the script data is located that is executed after the battle ends. This pointer now leads to an address where we have script data that you can edit properly with pksv. The script data is most likely located right after the pointer, but it could be anywhere in the same rom bank.

Edit:
Okay... So you are not trying to edit a trainer event but the Elder of Sprout Tower instead, right? That address 0x184FD9 tells you, where the properties of that person (=Elder) event are located in the rom. In other words, those properties include stuff such as palette, picture number, (x,y) position, sight range (if normal trainer), what kind of an event (person / item ball / trainer) and such. This person event is a normal person (and not a trainer) because it doesn't react like a trainer that would see you, get that !-sign on its head, play challenge music before the battle and such. Anyway, because it's a normal person event, its script pointer (which is also part of the properties of this person) leads to normal script data that you can edit with pksv.

If you open hex editor and go to that address (0x184FD9), you will run into bytes A6 49 at 0x184FE2. That is the script pointer and thus the script data is located at 0x1849A6. There you see "verbosegiveitem 0xF7 0x1" code which is used for giving you item no. 0xF7 which stands for HM Flash (like can be seen from Giegue's Guide).

Adam wrote:

I apologise again for my questions as I fully realise that I seem like really amateurish at the moment. It's not for lack of trying though. I've spent most of today (in addition to the many other days) looking through the programs and searching for solutions to the giveitem issue, but with no luck. I really wish I was better at this. Hopefully after when I move onto a FR hack it'll be easier. There seems to be loads of tools, tutorials, videos, etc for that!

GSC hacking is pretty easy too once you get used to it. :)

Last edited by Miksy91 (2016-05-18 19:55:13)

Offline

#15 2016-05-20 10:42:27

Adam
Member
Registered: 2016-05-07
Post 6/93

Re: Better running shoes

Miksy91 wrote:
Adam wrote:

Thanks Miksy,

I'm not entirely sure I understand what to change with the running shoes in the ASM editor as I've never done that before. The bug you mentioned though seems to make it a bad idea. I thought that the code the OP created would avoid anything like that (since he stated "With this you can use running shoes without any bugs."). If that's not the case, I may skip it.

I didn't read the earlier discussion in this thread. I did it indeed differently, but you can try using daw's method which will probably work as he said it would.
So simply write what he told to write there. The hex codes of all those instructions are also listed, so practically you don't even have to use an asm editor for the job (although that would help understanding what you're actually writing there).

Starting at 20:4000, I tried editing the routine as per daw and partway through it doesn't recognise some of the commands. Below shows what I could do, the other things were refused by ASM.

asm.png

Miksy91 wrote:
Adam wrote:

I looked into amending the give item script in PKSV and I can't find it. I tried looking for the script there but there was nothing. The trainer I want is at offset x184FD9 (according to CrystalMap). If I decompile this offset in PKSV it brings up:
...
...

Presumably GSC have different item codes. Either that or I am looking in the wrong place.

I don't suppose you have any idea where the giveitem code for this trainer would be located?

GSC item hex codes can be found here: http://www.angelfire.com/oh4/giegue/gmg2hpgr2c.txt

...
...

Edit:
Okay... So you are not trying to edit a trainer event but the Elder of Sprout Tower instead, right? That address 0x184FD9 tells you, where the properties of that person (=Elder) event are located in the rom. In other words, those properties include stuff such as palette, picture number, (x,y) position, sight range (if normal trainer), what kind of an event (person / item ball / trainer) and such. This person event is a normal person (and not a trainer) because it doesn't react like a trainer that would see you, get that !-sign on its head, play challenge music before the battle and such. Anyway, because it's a normal person event, its script pointer (which is also part of the properties of this person) leads to normal script data that you can edit with pksv.

If you open hex editor and go to that address (0x184FD9), you will run into bytes A6 49 at 0x184FE2. That is the script pointer and thus the script data is located at 0x1849A6. There you see "verbosegiveitem 0xF7 0x1" code which is used for giving you item no. 0xF7 which stands for HM Flash (like can be seen from Giegue's Guide).

Ah that makes sense. I didn't realise that the NPCs without the ! are not counted as trainer battles even if you fight them. That explains why it looks so different to the others when I go to their scripts. Also your explanation of how each of the offsets are connected has helped the hex codes click into place. It now makes a lot more sense!

EDIT: Bulbapedia has an index number of items, so presumably the correct index is 73 (listed as unknown on the doc you gave me). I used PKSV and decompiled the relevant offset, making the change as necessary. However, when I tried to compile the rom I was met with many "unknown command" errors. These were errors relating to the other parts of the code (such as faceplayer) and not what I had changed.  :/ However, it did seem to save. I tried it out and the text was all messed up for the Sage (I can probably fix that later so no major issue), and he gave me the GS ball. Kurt didn't seem to recognise it though which is a little irritating. I'm not sure if I need to put in extra code, or whether I need to wait until I've obtained the first three badges. I believe the three badges was the original requirement for the event. I'll blast through the badges and see if it works or not. Hopefully it does.

EDIT2: Is there a different way to implement the change? I think those errors from PKSV have corrupted the rom. When I speak to the sage his text and the text from other sages (perhaps even all of them!) seem to merge together and create a mess! The text seems fine on the rom, but when I talk to him it starts with "??" followed by the many other random sage dialogues. The end result ends up being garbled :/




Thanks again for your help. As I mentioned above, this time your answer has clicked something with me so has been really, really useful!

Also I got Disassembly up and running but when I tried making the rom it didn't keep the changes I had made previously. That makes it pretty much a no go. It seems as if I'm almost there anyway without it so I suppose it's no major loss!

Last edited by Adam (2016-05-20 12:07:00)

Offline

#16 2016-05-20 12:56:18

Miksy91
Member
Registered: 2010-10-16
Post 2,257/2,339

Re: Better running shoes

Well first of all, what comes to the running shoes routine, you can't write that code starting at offset 20:4000.
What you need to do is to call a routine somewhere inside the same rom bank where there is free space for inserting it. By re-writing the original code starting at 20:4000 with routine for running shoes, you're breaking some in-game functionality for sure.

And at the end of that running shoes routine, you want the game to execute the call command that was originally in address 20:4000 in unmodified Crystal rom.


What comes to the problems with this script, I'm not sure why pksv would break the script like that if you compiled it normally after editing the item given by that sage. Nevertheless, if that's the only thing you want to change, you may simply use a hex editor and search for those byte "F7" starting at 0x1849A6, make sure you run into the byte that stands for the item number (the first search entry probably does) and just re-write that byte with 73 if that's what you're meaning to do. Apart from that, you probably need to set the sixth or seventh bit in address $DA89 for making Kurt accept the GS Ball which can be found out by taking a look at the description of this video: https://www.youtube.com/watch?v=Gd_O9IaQ4MA

There they say you're supposed to enter gameshark code 01C089DA which stands for setting the two highest bits (to value 1) in address DA89. You can try which one of those bits must be set for making Kurt accept the ball by simply modifying the value in DA89 with Memory Viewer and trying to talk with him.

Anyway, since both the routine at start of rom bank 20, and the script of the Elder are messed up, you probably want to copy paste datas of those parts from an unmodified Crystal rom file to your hacked rom file, see both of them look fine, and try again. If you have a backup before doing either one of these things, even better. Just use that one then.

And good to hear you found my earlier comments useful! :)

Last edited by Miksy91 (2016-05-20 12:57:23)

Offline

#17 2016-05-20 13:25:34

Adam
Member
Registered: 2016-05-07
Post 7/93

Re: Better running shoes

Yeah, I have a backup and that works fine. I didn't save the ASM code because I knew it would be wrong regardless, so there was little point. I'm pretty clear with what I need to do now based on your further clarification so everything should be fine. I'm off to work now so can't really test at the moment.

I'll edit this post later if I have an issue, but it should be ok. One final thing though while you are here (saves making a new post). I have edited the title screen, but want to repoint the music on the title screen. There is some unused music on the rom already that is pretty cool, so I know what I want to change it to. I'm just not sure where the music pointer is. Is it in the same place as the pointer for the sprites (somewhere around 0x6200 off the top of my head...)?

Thanks again. Hopefully I'll be pretty much done now :D

Offline

#18 2016-05-20 15:58:20

Miksy91
Member
Registered: 2010-10-16
Post 2,258/2,339

Re: Better running shoes

Adam wrote:

I'll edit this post later if I have an issue, but it should be ok. One final thing though while you are here (saves making a new post). I have edited the title screen, but want to repoint the music on the title screen. There is some unused music on the rom already that is pretty cool, so I know what I want to change it to. I'm just not sure where the music pointer is. Is it in the same place as the pointer for the sprites (somewhere around 0x6200 off the top of my head...)?

Thanks again. Hopefully I'll be pretty much done now :D

There is probably no music pointer, but rather just a byte which tells which music to load the same way as the Primary Map Headers have one byte for determining the music to load for each map. That byte is just an index, and if it's value is let's say, 'k', that means the will probably load the music by using some pointer table for music datas, and picking up the 'k'th pointer from that list. This is how pokemon work too: each pokemon is referred by an index which is used to determine, which pointer to use from a list / an array.

Anyway, I'd assume the music byte is listed along with all kinds of other information that is loaded for the title screen in bank 0x1. I remember playing around with this with Silver a long time ago, and I think I was editing a single byte to change the music played at the title screen. I don't have the offset listed in any hacking document file in my pc, but I think the byte was located somewhere close to 0x6000 or so. This address could be way different for Crystal though unless they share the same intro code. But what you could do would be trying to use the disassembly to find the location with it. Once you have found this, you should be able to figure out, how to use that knowledge to find the actual rom address where the music byte is located. I can give two (strong) hints in finding the music byte in the rom (by first knowing where it is located in the disassembly):

1. Every asm instruction can be written as 1-byte value that may have one or two 1-byte parameters.
2. You can use hex editor's search function to search for data without knowing all the bytes to search for. The following is for example something I picked up from disassembly (where the address of PlayBattleAnim was actually mentioned), and you can for example find where this data is located in the rom with the following kind of a process.

PlayBattleAnim:

    ld a, [rSVBK]
    push af

    ld a, 5
    ld [rSVBK], a

    call _PlayBattleAnim

    pop af
    ld [rSVBK], a
    ret

You could search for this data by looking for "FA - - F5 3E 05" where FA - - is the "ld a, [addr]" instruction with unknown address, F5 stands for "push af", and 3E 05 for "ld a, 5".

Last edited by Miksy91 (2016-05-20 16:01:17)

Offline

Board footer

Powered by FluxBB