Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2016-05-21 17:11:38

Adam
Member
Registered: 2016-05-07
Post 8/73

Kurt's Scripting in Pokemon Crystal

I started talking about this in another topic on the back of the running shoes query. As it is now just about this thing, I've created a new topic as not to muddy the other one.

I've managed to include the GS Ball as a reward for a new post-post-game event in my Crystal Hack. The problem now is getting kurt to recognise it. I've found what I need to change and what to change it to (Change the byte at xDA89 to 40). This only works in game though through the memory viewer. If I alter the rom file using TranslHextion, it does not recognise it. It seems to overwrite this byte once the game starts. Is there a way around this?

I've tried opening up another rom file, which includes the GS Event (Pokemon Emu edition) and can't seem to find anything around the offsets kurt is linked to. However, he has the original event with the woman in the poke centre, so it may be completely different [and irrelevant] in his.

I've literally spent all day messing around with this to no avail, so hopefully someone here can help.

Thanks!

Offline

#2 2016-05-21 17:48:18

Crystal_
Member
From: Spain
Registered: 2012-09-16
Post 375/411
Website

Re: Kurt's Scripting in Pokemon Crystal

You have to set the flag EVENT_CAN_GIVE_GS_BALL_TO_KURT so that Kurt can recognize it. This is what the special event in the Goldenrod Pokemon center does. Kurt's script will check that flag before checking if you're carrying a GS Ball. That flag is probably bit 6 of DA89 as you're saying.

https://github.com/pret/pokecrystal/blo … se.asm#L96
https://github.com/pret/pokecrystal/blo … 1F.asm#L18

Last edited by Crystal_ (2016-05-21 17:48:33)

Offline

#3 2016-05-21 18:07:14

Adam
Member
Registered: 2016-05-07
Post 9/73

Re: Kurt's Scripting in Pokemon Crystal

Is there a way of doing it without Assembly? I tried loading assembly but it wouldn't import my rom (with the changes I have made). If I amend that byte in HEX, it just overwrites it as the game loads.

Thanks

Offline

#4 2016-05-21 22:53:23

Crystal_
Member
From: Spain
Registered: 2012-09-16
Post 376/411
Website

Re: Kurt's Scripting in Pokemon Crystal

Add setbit1 $00be to your custom gs ball script, and then Kurt should recognize the gs ball if you talk to him. I think that instruction would translate to 33 BE 00 in hexadecimal.

Offline

#5 2016-05-22 06:52:31

Adam
Member
Registered: 2016-05-07
Post 10/73

Re: Kurt's Scripting in Pokemon Crystal

Thanks. I'm using Hex as PKSV seems to be corrupting the test in the game when I used it (for some reason).

Where would I input the bytes into the hex editor? I tried entering it into DA89 and it just breaks the game whenever I go into battle (and sometimes with other events)

Last edited by Adam (2016-05-22 09:38:31)

Offline

#6 2016-05-22 09:34:40

Crystal_
Member
From: Spain
Registered: 2012-09-16
Post 377/411
Website

Re: Kurt's Scripting in Pokemon Crystal

DA72 is the start of the event flags in Pokemon Crystal. Since every byte can hold 8 flags you would do (DA89 / DA72) * 8 and get B8. Since the flag is bit 6 of DA89 you would finally do B8 + 6 and get BE, so what you want to pass to the setbit command is BE 00.

Offline

#7 2016-05-22 10:16:18

Adam
Member
Registered: 2016-05-07
Post 11/73

Re: Kurt's Scripting in Pokemon Crystal

Crystal_ wrote:

DA72 is the start of the event flags in Pokemon Crystal. Since every byte can hold 8 flags you would do (DA89 / DA72) * 8 and get B8. Since the flag is bit 6 of DA89 you would finally do B8 + 6 and get BE, so what you want to pass to the setbit command is BE 00.

OK, I think I'm lost here. Sorry. I understand how you came to the BE 00 with your calcs, but I'm still not sure where to change the bytes.

xDA72 is the start of the event flags, so I would need to go there to change it? As it is changing the 6th byte of xDA89, I would need to change the bytes to BE 00.

So presumably these two byes (highlighted yellow) would need to be altered, correct?

kurt.png

My save file has reset following some other changes I have made so I want to confirm what I'm doing first, since I will need to start the game again from the start to be able to test it :)

Offline

#8 2016-05-22 11:35:23

Crystal_
Member
From: Spain
Registered: 2012-09-16
Post 378/411
Website

Re: Kurt's Scripting in Pokemon Crystal

Edits in RAM aren't permanent (RAM is anything past 8000 in the memory viewer). Sure, you may set the flag in the save file and then hand that save to whoever plays your hack but I bet that's not what you want.

Instead, you want to create an script that when activated, sets the flag in RAM. Just like Elm gives you a Pokemon when talked to the first time, you'd want someone (or something) to set that flag for you when talked to. That requires a ROM hack in order to alter whatever script you want to have set the flag.

You have to patch 33 BE 00 (setbit $00BE) to an script, so that when that script is triggered, the flag (which maps to RAM address DA89) becomes set and Kurt can recognize your GS ball properly when his script checks the state of that flag.

Offline

#9 2016-05-22 15:36:29

Tauwasser
Member
Registered: 2010-10-16
Post 446/447

Re: Kurt's Scripting in Pokemon Crystal

You're showing us a hex editor screenshot being in your ROM file rather than save file. The save file address is going to be different, because the flags are stored at another location in SRAM and restored on loading your save game.

Offline

#10 2016-05-23 08:24:43

Adam
Member
Registered: 2016-05-07
Post 12/73

Re: Kurt's Scripting in Pokemon Crystal

Well, it works (thanks!), but the problem is with PKSVUI. Whenever I compile the script, it comes up with various unknown command errors. In game, these results in garbled text for the sage. It seems to be drawing the text boxes at random, sometime repeating and other times throwing in "?". See below for what I mean. Below shows the script, the error, and the garbled text in-game)

bugs.png

I have tried redownloading the program and still get the error. It actually inputs the script fine but then messes with the other stuff :/ Same thing happened when I tried to insert the giveitem command using PKSV (had to use hex to do it in the end).

Offline

#11 2016-05-23 08:48:35

Miksy91
Member
Registered: 2010-10-16
Post 2,259/2,305

Re: Kurt's Scripting in Pokemon Crystal

Strange that you're getting errors just as that. I haven't personally used pksv with Crystal though, so it might not work.

Nevertheless, you can't simply input that script command (which is actually "setbit1 0xBE") anywhere you like since there is no room for extra bytes. What you can however do is to replace one existing 3-byte command (for example, one of the existing setbit1 -commands) with 2call @routine and at @routine, you can write the setbit1 -command you replaced and setbit1 0xBE for the effect to take place.
This can be done easily with a hex editor like seen here: https://hax.iimarck.us/files/scriptingcodes_eng.htm

You can for example replace setbit1 0x14 with 2call command by searching for "33 14 00" and re-writing it with "00 xx yy" where xx yy is the pointer to the called routine. There you can write "33 14 00 33 BE 00 90" (or 91 instead of 90 if that is the "end" code in Crystal). Then try de-compiling the script with pksv and see if it should work properly.

Last edited by Miksy91 (2016-05-23 08:49:38)

Offline

#12 2016-05-23 09:08:09

Adam
Member
Registered: 2016-05-07
Post 13/73

Re: Kurt's Scripting in Pokemon Crystal

I'll give thata  try after work. Thanks Miksy.

I have tried decompiling and compiling after making no changes and it still has errors so maybe it isn't compatible. The program did allege that it was compatible with Crystal though :/

Offline

#13 2016-05-23 11:08:22

Miksy91
Member
Registered: 2010-10-16
Post 2,260/2,305

Re: Kurt's Scripting in Pokemon Crystal

Well I tested it out myself too. Apparently pksv for some reason "breaks" the text data when you compile a script with it when text data is shown under those "#orgs" below. If they're not shown, the script data will probably compile correctly although it shows lots of error messages when compiling (= those unknown command 'commandName') for me as well.

But I'd edit the script with a hex editor myself if I were you. If you need to do more script editing afterwards, you can use pksv, but you need to be certain, what it is doing. I personally checked with a tool called 'IPS Peek' what happened when I compiled this same script after editing it. I replaced the setbit1 0x14 command with 2call 0x7FF0 and moved setbit1 0x14 into the subscript I called. The subscript compiled correctly and the ending byte was 91.
When I compiled the script, the original text data was shown in pksv, and it re-wrote that strangely so that pksv apparently put another 00-byte in the beginning of each text string and thus "messed things up". In other words, if you feel like using pksv for script editing in Crystal, make sure you at least do not compile text strings with it. This can be done by simply removing the text string lines and just compiling the stuff you want to edit at the moment. Even so, there is no guarantee the program won't break something else although in this situation I tried, it seemed to work otherwise just fine.

Last edited by Miksy91 (2016-05-23 11:12:44)

Offline

#14 2016-05-23 18:58:54

Adam
Member
Registered: 2016-05-07
Post 14/73

Re: Kurt's Scripting in Pokemon Crystal

Yeah, I decided to use hex editor. It was pretty easy to do, following your instructions. I found some space that looked free and stuck it there. It worked a treat.

That's the last thing I needed to do really to finish. I just need to hire someone out now to upload my sprites using TLP. I can't find the sprites I need to change so it's just easier to pay someone else to stick my sprites in :p

Thanks a lot for your help guys. These final things I needed to do caused me a bit of a headache (because I'm new to all this), and I couldn't have done it without you two!

Offline

#15 2016-05-24 05:10:24

Miksy91
Member
Registered: 2010-10-16
Post 2,261/2,305

Re: Kurt's Scripting in Pokemon Crystal

Adam wrote:

Yeah, I decided to use hex editor. It was pretty easy to do, following your instructions. I found some space that looked free and stuck it there. It worked a treat.

:)

Adam wrote:

That's the last thing I needed to do really to finish. I just need to hire someone out now to upload my sprites using TLP. I can't find the sprites I need to change so it's just easier to pay someone else to stick my sprites in :p

What do you need help with exactly? Battle sprites insertion?

Adam wrote:

Thanks a lot for your help guys. These final things I needed to do caused me a bit of a headache (because I'm new to all this), and I couldn't have done it without you two!

You're welcome.

Offline

#16 2016-05-24 06:43:54

Adam
Member
Registered: 2016-05-07
Post 15/73

Re: Kurt's Scripting in Pokemon Crystal

Yeah, I want to replace the sprites for the Rocket Execs and possibly also for the Cerulean grunt too, if possible (may not be without changing all grunts. I can live without this one though).

I can't even find the battle sprites in TLP and as mentioned before, when I run the disassembly it seems to lose the stuff I've done.

Considering FR has a tool for switching sprites (which is really easy), I don't think it's worth the hassle trying to get to grips with TLP. I spent a couple of days messing around with it to no avail. It's easier just to hire someone to do it!

Anyway, don't worry about it. I'm sure i'll find someone!

Offline

#17 2016-05-24 11:15:47

Miksy91
Member
Registered: 2010-10-16
Post 2,262/2,305

Re: Kurt's Scripting in Pokemon Crystal

All the battle sprites in the game are actually in compressed format, and they cannot be edited with TLP. This is basically the same thing as what can be done with zip-files for instance. You can for example have a text file of size 1.5MB, and when you compress it inside a zip-file, the size of the zip-file could easily turn out under 1MB. The text file is now basically compressed, and it can be de-compressed with some de-compression routine that is run when you tell the zip-file to Extract the contents inside it. A similar thing is done with all battle sprites in GSC because if they were in uncompressed format in the rom, they would take a lot more space.

Take a look at this part of disassembly:
https://github.com/pret/pokecrystal/blo … s.asm#L310

This routine is used for finding the image of the trainer you battle against, and it calls a few other routines for eventually de-compressing the image. If you pay attention to what is going on there, you'll notice that it loads the BANK byte in register a on line 329, and hl with pointer to the trainer image pointers on line 319. If you open pokemon Crystal rom file with Gameboy ASM Editor and go to address 0x5120d where this routine starts, you'll notice that the bank byte loaded into a is 4A and the pointer loaded into hl is 4000. This means that the graphics of trainers are gotten from address 0x4A * 0x4000 + (0x4000 -
0x4000) = 0x128000. I would assume that there we have a pointer table of 3-byte pointers to the trainer images where each entry is form [Bank][Pointer (2b)]. The second entry for instance which is "21 4F 5A" for example tells to load the image of trainer nr. 02 (= Whitney) from address 0x85A4F. And if you take a look with TLP what you see there, you can indeed see data that looks like graphics of some sort, but it looks like a mess. That's simply because it's compressed graphics data.

Now what you gotta do is to insert the sprite of Rocket Executive in the game by compressing it in the same time (, so that it can be de-compressed in the game correctly as well). AgiXp is a tool that can achieve this. It unfortunately "doesn't want to support" Crystal although I believe the sprite de-compression routine in Gold, Silver and Crystal is exactly the same. AgiXp can be used for inserting battle graphics into Gold or Silver rom though. This practically means that you can use that tool for inserting the graphics data into Gold or Silver rom, and then with the use of a hex editor, copy paste the inserted graphics data into your Crystal hack rom file. Once you have copy pasted graphics data somewhere (where there is free space for it), you want to look for the entry of Rocket Executive in that trainer graphics entry list. The entry of Rocket Executive (Male) is in address

0x128000 + (0x33 - 0x1) * 0x3 = 0x128099

where 0x33 is the "trainer group" that stands for Rocket Executive (Male), and if you want to replace the sprite of female executive instead, you just replace that 0x33 with its trainer group. There you simply adjust the entry/pointer to point to the graphics wherever you happened to copy paste them.

Shouldn't be too difficult to do :) One problem you may run into though is not getting AgiXp to run. If this is the case, try asking someone for inserting the graphics for you.

P.S
If you want to make the grunt at Cerulean to use a different battle sprite, you would have to hack that routine starting at 0x5120D.

Last edited by Miksy91 (2016-05-24 11:20:36)

Offline

Board footer

Powered by FluxBB