Skeetendo

’Cause all games were better on the GBC

You are not logged in.

  • Index
  • → Help/Question
  • → Create new trainers? [And other scripts] // updated: [2013-01-24]

#76 2013-07-17 05:38:24

Miksy91
Member
Registered: 2010-10-16
Post 1,818/2,306

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

I don't think there are any warp, signpost or trigger event limitations (expect for max. 255) for any map. This is because I think their data is read from ROM. However, people events are stored in RAM so the amount of people events in each map is limited. I think there can be 14 people events in each map, but not totally sure about the correct number.

In that trainer data there, you're missing the script pointer to the script data interpreted after the battle. "00 00 + [Script Pointer]". The trainer data actually ends here with the script pointer. So you can locate the script data interpreted after the battle anywhere you like.

There, you could indeed write 47 4C [pointer] 53 49 90, or just 52 [pointer] if you don't want anything else expect for the trainer talking to you after the battle and saying something.

Offline

#77 2013-07-17 19:15:04

Skurbert
Member
Registered: 2012-12-16
Post 47/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Great! I fully understand now :-) Yes, 14 seems to be the number, try to add more in JohtoMap and they won't show up at all when you play the game.

What usually confuses me is the pointers for every script. I usually solve it on my own by looking at the adress and calculate it, which gives a number that resembles the pointer in hex. But sometimes the pointers are stored elsewhere and are hard to find. I don't know. Some scripts in the game seems impossible to "decrypt" while others are a tad easier.

I'll mess around with some scripts and try to learn more, so for now I say: I'll be back! :D

Offline

#78 2013-07-17 21:51:07

Miksy91
Member
Registered: 2010-10-16
Post 1,819/2,306

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

I also remember having hard time understanding the pointers at first.
But after I had played around with them more, it started to be more natural to repoint data, and calculating pointers without using any specific tool as help (like a calculator).

But all the pointers work exactly the same way. You rotate the bytes of the pointer around, form a hexadecimal value out of those, subtract 0x4000 of that value and add the result to the offset where the current rom bank starts.

Offline

#79 2013-07-19 17:44:10

Skurbert
Member
Registered: 2012-12-16
Post 48/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Well it's not that I can't calculate, it's rather a lazyness from my side to use the pointer calculator :P

What I mean is for example when I look at a script. 47 and 4C can be a commando. But it can also be a pointer number! You see a lot of text and there is a conversation. Check. You see the 53 4C and 90, you know that is the script numbers. Check. But for some reason you can't find the pointers.

This is what I mean, if I try to "copy" an existing script (like the one with the hidden rare candy) I must find out:

* What is the pointer?
* What is the bit nr?
* What is the script numbers?
* Are there any other pointers that needs repointing?

Etc...

Sorry if I wasn't clear enough :D

Offline

#80 2013-07-19 18:22:55

Miksy91
Member
Registered: 2010-10-16
Post 1,827/2,306

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Well, everything associated to an event is its data, and script.
I don't really see what kind of a problem you're having though - perhaps there's no problem at all.

Maybe you should just work around with event data a bit more and see how things work out with it.

Warps don't have any additional scripts attached to them, each warp is just a 5-byte structure determining where it is located and where it leads. After warp data ends, starts the trigger event data. For each trigger event, there is data of its "Flag", so in other words, when the trigger event will activate and when not. Apart from the flag, trigger events also have coordinate bytes like warps, and beside them, a script pointer to tell what kind of a script to load when the trigger event is activated.

After trigger event data, there is signpost event data. Sigposts are 5-byte structures which consist of coordinates, their function and script pointer. Script pointer just tells where to load data attached to that specific signpost. Function byte tells what kind of data is loaded from that offset where script pointer points to.

And after signpost data, there is people event data. People events are 13-byte structures that consist of a bit more stuff than signposts for instance. You can set their coordinates, facing values, movement permissions and function (normal event, item or flag) which just like for signposts, tells what kind of data to load when its script is executed. And script pointer points to this data to be executed.
And finally, people events have a bit number attached to them. If the bit that refers to this specific person's bit number is set to 1, this person event is made hidden whenever the player enters this map where this person event is.

But yeah, I guess you're somehow confused with Function bytes and how they work and that's pretty much it. Just take a look at the compendium and do some experimenting and you're good to go.

Offline

#81 2013-07-19 18:58:59

Skurbert
Member
Registered: 2012-12-16
Post 49/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Well, I know how to do a script with HIRO talks to another character. And I know how to do signposts. Warps doesn't need hex because of the function in JohtoMap. The Compendium has been very helpfull at times, I managed to set up a simple shop in a house for instance. I wrote down every code so I have them in notepad and can easily set up an event with a NPC talking to HIRO. But Yes, that's about it. When I want to add something more, like I want the NPC to walk out of the room, or want him to vanish into thin air, then I get into trouble. "Am I gonna add a new pointer? A new script number?", I fiddle around a lot and often overthinking a lot, so at times I get stuck and works on something else instead (Like adding a new trainer or a sign for another place).

Maybe this is my weakness; Maths were never my strong side, yet many says you REALLY have to know maths to program. Perhaps I'm a crazy idiot even trying to do this? :P But I won't give up! I learn more, and I learn quickly! And I won't stop until Kanto is finished!

ALSO: To add: Yes! Bit Numbers and flag! I know what you mean and I know how it works too. For example, Blue has a specific Bit Number. I added more trainers to the Viridian Gym and set the same BIT NR as Blue. What happens? Like Blue, they did only show up when you have talked to Blue. Voila!

I Want to ask you, Miksy, have you ever managed to add a new room or area to one of your hacks? Was it very hard and frustrating to repoint and move everything forward? I guess there's to little space to make room for pointers so one has to move every little byte forward and then repoint? I get the impression that this is very hard to do, not to mention all the map cordinance that has to be done. What was the most hardest thing to do, adding a new area or a complete new room?

Last edited by Skurbert (2013-07-19 19:10:43)

Offline

#82 2013-07-19 20:41:26

Miksy91
Member
Registered: 2010-10-16
Post 1,830/2,306

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

So far, the only reason behind the fact that I haven't expanded the amount of maps hardcoded in the game is because I haven't had a need to. But I guess I could play around with the asm routines loading the Map Header pointers and such.

Maths is indeed required in programming, but you won't need math that much. Actually, scripting events doesn't require maths at all! A whole different thing is when you try to do something complicated that involves asm hacks.

I personally see nothing frustrating about repointing and building data from scratch. I guess it just comes naturally, hahha :D

(So the only things I have been doing is simply building all the areas from scratch although the base map has been one of the maps in Gold/Silver.)

Offline

#83 2013-07-20 22:23:11

Skurbert
Member
Registered: 2012-12-16
Post 50/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Okay, well but it takes a while to do it if you really wanted to?

Phew, a sign of relief! I won't go into ASM-hacking anyway so that won't be a problem at all.

I can imagine! :D For me, building data/scripts/events can be done with the help of the Compendium, but usually I need help. Now for instance. I can't get the hidden item to work. I will illustrate through a picture so you can tell what I'm doing wrong this time:

Dx83ipH.png

Like you said, the first two were bit numbers. So I used my own which is C6 F1, and that bit number is NOT used by any other events in the game. Yet, it still won't work.

Last edited by Skurbert (2013-07-20 22:25:37)

Offline

#84 2013-07-21 14:27:26

Miksy91
Member
Registered: 2010-10-16
Post 1,832/2,306

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Skurbert wrote:

Okay, well but it takes a while to do it if you really wanted to?

I don't think it'd be much of a hassle really. Just re-organizing some stuff and it oughta work.


You've got two problems in that example of yours. The first problem that makes the freezing is the "Function" byte used by the signpost event. The second problem is the selected bit number.

To make it give you Rare Candy, you have to modify the properties of the signpost event with a hex editor. The third byte in its structure is the Function byte.

Signposts:

[Y position][X position][Function][Script pointer (2byte)]

■ Function: 

(insert stuff explaining Function bytes 00 to 06 here...)

07 = If bit of BitTable1 is not set, then item is given.
Script pointer to [Bit-Nr. (2byte)][Item no.]

The second problem here is the used Bit Number. Bit numbers are used for referring to specific addresses in ram. Instead of thinking about the ram as bytes, we could think of it as bits. 8 bits form one byte.

I talked about this same issue with Riverside in some other topic so go and check that out.
Once you understand more, you can possibly guess why a 2-byte value like C6 F1 won't work as a "legit" bit number.

Offline

#85 2013-07-21 20:00:14

Skurbert
Member
Registered: 2012-12-16
Post 51/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Miksy91 wrote:
Skurbert wrote:

Okay, well but it takes a while to do it if you really wanted to?

I don't think it'd be much of a hassle really. Just re-organizing some stuff and it oughta work.


You've got two problems in that example of yours. The first problem that makes the freezing is the "Function" byte used by the signpost event. The second problem is the selected bit number.

To make it give you Rare Candy, you have to modify the properties of the signpost event with a hex editor. The third byte in its structure is the Function byte.

Signposts:

[Y position][X position][Function][Script pointer (2byte)]

■ Function: 

(insert stuff explaining Function bytes 00 to 06 here...)

07 = If bit of BitTable1 is not set, then item is given.
Script pointer to [Bit-Nr. (2byte)][Item no.]

The second problem here is the used Bit Number. Bit numbers are used for referring to specific addresses in ram. Instead of thinking about the ram as bytes, we could think of it as bits. 8 bits form one byte.

I talked about this same issue with Riverside in some other topic so go and check that out.
Once you understand more, you can possibly guess why a 2-byte value like C6 F1 won't work as a "legit" bit number.

Ah yes! I Got it!

That means, since we can only have 16x16 alternatives per 1-Byte: 256 is the maximum hidden number of items. Right? And 512 is the max amount of trainers with a unic BitNr?

What a shame! By logic, the reason why this is the case was propably due to the fact they needed more trainers to fill in kanto and 256 bit numbers were not enough. So they extended to 2-bytes. Right?

And since Hidden Items were not prioritated, they only needed 1-Byte to cover the Bit Nr. So the Cinnabar Island Rare Candy is "FE" which means it could be one of the last hidden items added into the game.

Is this limit hardcoded? Is it impossible to change from 1-Byte to 2-Byte? (I can imagine the answer.. :P)

Oh well, sad. That means no more hidden items can be added to the game then. Argh! Just when i figured out how to do it! :D But thanks anyway.

Offline

#86 2013-07-21 20:47:25

Miksy91
Member
Registered: 2010-10-16
Post 1,834/2,306

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

The bit number used by the hidden item in Cinnabar City is FE 00. The bit number that points to the next bit in ram is FF 00 and the one after that 00 01. Then, 01 01, 02 01, 03 01 and so on. This "confusing" way of presenting most of the data inside the rom is little-endian format. In big endian, the bit numbers would be 00 FE, 00 FF, 01 00, 01 01, 01 02 and so on, but you can't write them in the rom like that.

There are literally 65536 different bit numbers you can use (since there are 65536 different 2-byte values), but only ~1500 could be used freely for sure. Bit numbers point to certain bit in ram memory. What I mean by this is that since all kinds of data is stored in ram, you can point to any other data through bit number values as well. There is a certain 0x100 byte area in ram that is reserved for flags (= "has this event gone through yet or not"). Bit number 00 00 points to the first bit in this 0x100 byte (= 0x800 bit) area and FF 07 to the last bit (= 0x800th bit) of this ram area.

That 0x100 byte area was just an assumption. In G/S, it's mostly like that but I'm not sure about Crystal.

But well, what you gotta know is that you can use only small bit numbers where the second byte is at max. 07. Also, knowing how to calculate where bit numbers refer to does truly come in handy as well. Not sure what kind of pointers to give since personally, I get rid of all original events for my own hack and can be bit numbers pretty freely because of that. But since you're keeping most stuff in, things get more complicated and it's harder to find room for bit numbers to use.

Last edited by Miksy91 (2013-07-21 20:49:56)

Offline

#87 2013-07-21 22:55:50

Skurbert
Member
Registered: 2012-12-16
Post 52/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

65536, that sounds better! :P

But.. wait, I thought you meant a single byte, "FF" not "FF 00". Ok, so there's hope after all!

So you mean they use another system for this rather than the trainers? Because it is POSSIBLE to use "C6 F1" as a bit number on a trainer (I tried, it WORKED!) but in this case, you can't. These type of rules confuses me all the time. Either is it rom banks "you can't use a script from another rom bank" or there is some pointer that has to be used from another place, etc.

And this rule I don't understand. You try to write it down, but It can't get a grip of it. Do you mean the bit number is acting like a pointer to RAM?

When I added a new trainer the bit number after 09 of course had to be 0A, but that was only one byte. So this is a different case.

I'm lost! :D

Offline

#88 2013-07-23 07:27:59

Miksy91
Member
Registered: 2010-10-16
Post 1,835/2,306

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Skurbert wrote:

Do you mean the bit number is acting like a pointer to RAM?

Yeah, you could say that.

In Pokemon Gold and Silver, there is a 0x100 byte area reserved for flags starting at D7B7. The first bit number, 00 00, points to the first bit in ram address D7B7. The second bit number, 01 00, to the second bit in ram address D7B7, and so on. One byte is formed with 8 bits.
Thus, the ninth bit number, 08 00, points to the first bit in ram address D7B8.

And for example bit number FE 00 would then modify the byte at:
0xD7B7 + 0x00FE / 0x8 = D7D6

So, this bit number affects the value in D7D6, and specifically, the seventh bit in that address.
What this means is that when bit number FE 00 is set (assuming it was unset before), the value in D7D6 is increased by 0x40 (= 0100 0000 in binary). Notice a fact that in this binary number, 0100 0000, the seventh bit from right is 1 and all the other bits are 0.

Anyway, now you could probably guess why for example it wouldn't be a good idea to use bit number C6 F1.
Since changing that bit value would affect the byte at:

0xD7B7 + 0xF1C6 / 0x8 = 0xF5EF

This happens to be part of Echo Ram which is located between 0xE000 and 0xFEFF in GB/C games I think. Writing anything there won't "do any good". In fact, I'm not even sure what writing there would really affect. Either the data of the bit number would only be stored there temporarily, or since this part of ram echoes the Work Ram (0xC000-0xDEFF ?), the change might get "copied" to 0xD5EF modifying something else.

Last edited by Miksy91 (2013-07-23 07:28:28)

Offline

#89 2013-07-23 12:27:57

Crystal_
Member
From: Spain
Registered: 2012-09-16
Post 83/415
Website

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

This comes off the top of my head but I suppose you could re-use the bit number that determines if of some rocket grunts have already been battled or not, provided you are going to use that flag when the rockets have already disappeared in the storyline. I suppose for example you could make Bugsy clear/set any amount of the bit numbers of the rockets at slowpoke well and make use of them in the future, though I'm not sure.

Offline

#90 2013-07-26 09:26:29

Skurbert
Member
Registered: 2012-12-16
Post 53/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

OK - I'll mess around and see what comes out of it.

Regarding C6 F1 - I can't use it att all? Not even on a trainer?? I use CBM's document (with list of pointers) to see if it's in there. So I thought "Yeah, C6 F1 is not in there, so let's use it!".

And yes, the bit numbers are really fun to test around with, for example the guy blocking the underground path on route 6 and another one north of Saffron. They can be moved so they block the entrance to Saffron instead. Also possible to add another of these guys (with the same bit number) at the end of route 11, forcing the player to:

* Solve the power plant quest.
* Go through the rock tunnel to reach Lavender town.

So what do you guys want? An open Kanto region or a more "forced" linear region? Maybe I should start an idea thread about this instead? Because the subject is rather large. And I'm not sure myself how I want to fill out Kanto (except for more trainer, items and buildings, etc). Pewter museum, Cerulean Cave and Seafoam islands is not enough: In the R/B/Y game we had a huge tower in Saffron filled with trainers, a hidden lair in the game corner and also the pokemon tower of ghosts. All these extended the gameplay a LOT and has to be replaced somewhat. But where and what? That's the big question!

Offline

#91 2013-09-28 19:44:39

Skurbert
Member
Registered: 2012-12-16
Post 55/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Ok, I've finished a lot since, but there's still much to do.

I have two questions:

1. Is it possible to 'copy' the Move-Tutor" in Crystal to Silver by simply comparing the ROMs side by side and insert all the code at the same adress? Some insights on this would be very helpful.

2. I learned from Mateo's guide how to repoint stuff (Pallet Town, etc.), it helped me when I ran out of space from level datas.
But Is it as easy to change a ROM BANK?

For Example: "Kanto - ROUTE 3" uses "Event script bank: 50" and that Bank is FULL. I want to repoint it to some Empty Rom Bank. How do I do this and is it even worth bothering with? (I want to add more trainers to this area, but can't, since the bank is full...)

Thanks!!



EDIT: U-oh... Some things have been repointed in Crystal, because the codes are not equal in the same rom banks. The "Move Tutor" is located at "$199292", which is empty in Silver. But some codes colide with other codes so you can't copy the code without repointing hell a lot. I'll investigate this further.....

Last edited by Skurbert (2013-09-28 20:31:04)

Offline

#92 2013-09-28 21:07:11

Miksy91
Member
Registered: 2010-10-16
Post 1,909/2,306

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

1. This kind of a task is probably more difficult than you realize, but then again, it might not be. If some "special" opens the menu and related to it, makes it possible to teach one of those (TM!) moves, you could possibly succeed by locating the routine that special calls, and copying it over to Silver (and changing some values that determine where the menu and so forth are loaded from). This then again isn't much of a task really if you know the basics behind z80 assembly.
2. Yes, it's simple. Just go to the Secondary Map Header with a hex editor, and change the Script/Event bank byte there.

Last edited by Miksy91 (2013-09-28 21:07:52)

Offline

#93 2013-09-28 21:38:44

Skurbert
Member
Registered: 2012-12-16
Post 57/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Thanks again!!! :-)

Offline

#94 2013-10-20 10:36:22

Skurbert
Member
Registered: 2012-12-16
Post 58/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

I just wanna drop in and say:

1. I successfully repointed "ROUTE 3".

2. I finally figured out how to script Hidden Items (It took ages and was extremely frustrating, but very rewarding at the same time).

3. Safari Zone has been opened, which leads to....

4. ... I figured out how to create a Pokemon Battle-event by using Mateo's script for his Articuno. You can therefore meet wild Pokèmon's in the grass and scattered ones placed on the map.

Much Much Much to do... But I'm improving!

Offline

#95 2013-11-04 19:20:34

Skurbert
Member
Registered: 2012-12-16
Post 64/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

I successfully added a switch to one of the garbage cans in Vermilion City-gym and through a block-changing script opening a door. This, all through trial-and-error and The Scripting Compendium as a guide. So now I'm doing the same principle with a new secret hideout: Defeat a guy and he opens the door.

I want to insert new tiles/blocks with graphics to Kanto, since it's pretty lackluster. How should I start? Any insights on where to start and what utilities I should use would be greatly appreciated.

Offline

  • Index
  • → Help/Question
  • → Create new trainers? [And other scripts] // updated: [2013-01-24]

Board footer

Powered by FluxBB