Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2012-08-21 20:03:54

haelcher
New member
Registered: 2012-08-21
Post 1/4

Yellow Changing Script Locations

I'm trying to move the Prof. Oak script (the "Wait! Don't go out!" one) from the North exit of Pallet Town to the South Exit.  The script itself should run the same: Prof. Oak stops you, battles Pikachu, then takes you to the lab.  I have no experience with ASM, so how much of this request can be done by hex editing?  And how would I search for this specific script in the hex if it is possible?

I would also like to try a similar thing with the Old Man script in Viridian (at least the "You shall not pass" one), so if that one is easier to explain, help with that one instead.  Thanks!

Offline

#2 2012-08-21 22:29:35

Cartmic
Member
Registered: 2010-10-16
Post 117/156

Re: Yellow Changing Script Locations

There's information on this sort of thing in the correct section of the forum take a poke around. I've done this myself but there a lot more to it than just moving the trigger.

Offline

#3 2012-08-22 02:38:45

Danny-E 33
Administrator
Registered: 2012-06-09
Post 85/1,031

Re: Yellow Changing Script Locations

Hmm, yeah I have been very interested in learning how to tweak the path of the guy in Pewter who takes you to Brock's gym. And I haven't been able to find any documentation on it. Could you share a link perhaps? Thanks :)


Red Hack: Pokémon Prototype

Total number of registered users: 8000+
Total number of active users: ~12

Offline

#4 2012-08-22 03:25:45

Danny-E 33
Administrator
Registered: 2012-06-09
Post 86/1,031

Re: Yellow Changing Script Locations

Well the problem is that RBY doesnt have a scripting engine. All the "script" of a map is just asm work. Which is why it isn't so well documented how to do everything for RBY.


Red Hack: Pokémon Prototype

Total number of registered users: 8000+
Total number of active users: ~12

Offline

#5 2012-08-22 03:38:05

505/701

Re: Yellow Changing Script Locations

What you want is in the disassembly, under PewterCityScripts. Sorry, it’s not commented very well, but with experimentation it isn’t difficult to understand.

#6 2012-08-22 19:31:55

haelcher
New member
Registered: 2012-08-21
Post 2/4

Re: Yellow Changing Script Locations

Well, I've looked a bit into the disassembly and ASM code, and I've solved most, but not all the problems for the Oak script.  Since I'm still new to this, I'll share what I found out hoping you guys will correct any mistakes that you see.

Moving the trigger is easy enough.  Here's the ASM code for the first part of the script (using the BGB debugger)

ROM6:4E26 (I believe this equals offset $18E26 in hex)
ld a,(D746)
bit 0,a
ret nz
ld a,(D360)
cp a,00
ret nz

Values are almost the same as the Red disassembly (I'm assuming the differences are caused by the fact this is a Yellow ROM).  Changing the trigger is as simple as changing the value next to the Compare command to whatever value I want the trigger to have (for the South exit, I'll use 11).  I believe the "D360" represents the players current Y-position, so if you wanted a similar trigger for the east/west exit, you'd have to change "D360" to "D361" to represent the players current x-position, then change the compare command to whatever x-value you wanted for the trigger.

Cartmic wrote:

I've done this myself but there a lot more to it than just moving the trigger.

Yeah, I understood that that was probably the case when I asked, but I was hopeful that the entire script could be found easily in hex.  And I found that at least Oak's movements can.  It follows a series of two-byte sequences [Direction of movement][Number of steps] and is eventually terminated with FF when the movement is over.  The direction byte is determined by the small table below.  With some searching, I believe the paths of the two guys in Pewter city that take you to the museum and the Gym both have their paths defined in the same way.  The script for Oak's movement starts at $1A5EE (possibly a little earlier, haven't checked the few preceding bytes yet).

Directions:
00-South
40-North
80-West
C0-East

However, I am still facing a problem where the player does not follow my new path and instead remains on the old path, ditching the character he was supposed to be following.  I had thought there was a simple "follow me" command but apparently there isn't.  I'm still looking into it, but right now haven't turned up much on that regard.  Please let me know if I did something wrong here so I don't mess up anything later.  Thanks for all the help guys!

Offline

#7 2012-09-07 09:04:11

Sawakita
Administrator
Registered: 2010-10-16
Post 292/364

Re: Yellow Changing Script Locations

Hi, just noticed this thread.
Here is an excerpt from a reply I wrote several months ago to a PM I received (these notes are for R/B, so all the addresses and some of the data won't match, but they should give you a general idea of how the Oak's "follow-me" script is arranged):

Sawakita wrote:

The movement info is loaded in RAM, starting at CC97 (ends with FF); also consider that in the part where Oak drags you to the Lab, there are two movement info: one for Oak and one for the Hiro (that should be loaded in RAM starting at CCD3, if I recall right). Original ROM location of the second part of movement (from North-Pallet to Lab) are stored as a sort of RLE:
groups of 2 bytes, where the first is movement value and the second is number of times to be repeated.

Oak's movement:
- $1A4DC (pointer is at $1A4BA):
00 05 = 5 times south
80 01 = 1 time west
00 05 = 5 times south
C0 03 = 3 times east (if you moved the door one step right you should replace this with C0 04)
40 01 = 1 time north
E0 01 = stand still (?)
FF = end of data

Hiro's movement
- $1A4E9 (pointer is at $1A4C7):
these are written backwards (I didn't take the time to check why) and mov.values are different (probably because this script also requires the camera to move and follow the two guys)
40 02 = 2 times north
10 03 = 3 times east (if you moved the door one step right you should replace this with 10 04)
80 05 = 5 times south
20 01 = 1 time west
80 06 = 6 times south
FF = end of data

Basically both the leader and the follower have an independent path, arranged in a way that makes them walk one after the other. The player's path arrangement has a different implementation than the normal "move-NPC script" because, from my understanding (and pale remembrance!), the player is moved by simulating key-presses.

So, in a nutshell, what you want to do is find the player's run-length-encoded backward-written path, and replace it with your new one.

Offline

#8 2012-09-08 02:44:40

Danny-E 33
Administrator
Registered: 2012-06-09
Post 112/1,031

Re: Yellow Changing Script Locations

Wow, this is very interesting..

So I imagine the guy from Pewter has similar script. He has his path code, and the player has his path code backwards? Any chance you could help me with some offsets? I know Pewter's script is at 0x19237, but I've never been able to understand what I'm looking at anytime I try to understand a map's script. I really have trouble knowing when one script event stops and the next one begins, cause I don't know what I'm looking at. Any advice?

Also, how come at the end of the player's path in Pallet Town (or the beginning of his code) it says he walks two spaces north when he really only walks one?

And would you mind clearly defining the term run-length-encoded, please?
Thanks :)


Red Hack: Pokémon Prototype

Total number of registered users: 8000+
Total number of active users: ~12

Offline

#9 2012-09-08 02:56:45

512/701

Re: Yellow Changing Script Locations

Danny-E 33 wrote:

And would you mind clearly defining the term run-length-encoded, please?
Thanks :)

RLE is a simple form of compression that condenses repeating bytes to only their count.

E.g., “05 05 05 08 02 02 02 02 02 02 07 07 07 07 07 07 07 07” could be encoded as “05 three times, 08 one time, 02 six times, 07 eight times, or “03 05 01 08 06 02 08 07”. Notice the space savings.

#10 2012-09-08 03:08:09

Danny-E 33
Administrator
Registered: 2012-06-09
Post 113/1,031

Re: Yellow Changing Script Locations

Ohhhh, that makes alot of sense. I've heard that term from Cartmic when talkin about the Town Map data and now it makes sense. Thanks :)


Red Hack: Pokémon Prototype

Total number of registered users: 8000+
Total number of active users: ~12

Offline

#11 2012-09-08 09:19:21

Sawakita
Administrator
Registered: 2010-10-16
Post 293/364

Re: Yellow Changing Script Locations

Danny-E 33 wrote:

Wow, this is very interesting..

So I imagine the guy from Pewter has similar script. He has his path code, and the player has his path code backwards? Any chance you could help me with some offsets? I know Pewter's script is at 0x19237, but I've never been able to understand what I'm looking at anytime I try to understand a map's script. I really have trouble knowing when one script event stops and the next one begins, cause I don't know what I'm looking at. Any advice?

Have you tried checking the disassembly? If that script (or a similar one) is disassembled, it might help you clear doubts out, even if no comments were provided because the structure of scripts and data is more visible. Also, stepping through the script in a debugger should also clear things out (don't go through all the code, just try to remain in the "main script" routine and step-over the calls to bank 0's subroutines). It should especially help keeping an eye on write/read accesses to RAM addresses 0xCC97 (and following bytes) and 0xCCD2 (and following bytes), that are where the NPC's path and the player's are respectively loaded at run-time.

Danny-E 33 wrote:

Also, how come at the end of the player's path in Pallet Town (or the beginning of his code) it says he walks two spaces north when he really only walks one?

I gave a very quick look (so I might have missed something) at the code flow with BGB and it seems that the last step value (0x40) is not even read and used.

Offline

Board footer

Powered by FluxBB