Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2010-12-29 11:35:30

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

Pokemon G/S Flags

Care to explain this document a bit more ?
http://datacrystal.romhacking.net/wiki/ … Gold_Flags

I have hard time understanding it.
The problem is, I can't see the analogy between BitTable commands and the flag system.

For example, in my hack I used BitTable commands 0A06, 2020, 2021, 2022, 2023, 2024 and 2026.
Where would that data be stored ? Besides, can I use any other expect the ones: 0000, 0800, 1000 etc. safely (or in other words, does the game overwrite some other data with those bittable commands I used) ?

And, if I made the game set bit 1000, would the game write 01 to 0xD7B9 ?

Edit:
I think I'm starting to get this, somehow...
It seems the game uses flags of types XXYY, YY=00, 01, 02,...,07.
So, are all the flags between 0000 and 8B07 (last item ball in the list) safely usable ?
It seems that for instance XX01, XX04 and XX05 would give you a lot of bit commands (if they're unused) :)

Last edited by Miksy91 (2010-12-29 13:06:54)

Offline

#2 2010-12-29 17:37:48

90/703

Re: Pokemon G/S Flags

The flag IDs are 16‐bit, little‐endian numbers. So the bytes YYXX in the game actually represent flag XXYY. The Datacrystal page doesn’t flip the bytes, and as a result is a little confusing (IMO).

Miksy91 wrote:

For example, in my hack I used BitTable commands 0A06, 2020, 2021, 2022, 2023, 2024 and 2026.
Where would that data be stored ? Besides, can I use any other expect the ones: 0000, 0800, 1000 etc. safely (or in other words, does the game overwrite some other data with those bittable commands I used) ?

Those numbers look a little large. You may be going past the end of the bit table and overwriting other data in RAM. (I don’t know the size of the table though, so this might not be the case. But the table listed at Datacrystal has 0x800 flags in it.)

The safest thing to do would be to choose a bit and delete any scripts using that bit. Then you can be confident that nothing will be amiss. For example, bit 0021 represents whether or not you picked up the Pink Bow in the Radio Tower. Deleting the scripts of the person who gives it to you will free up that bit for your own purposes.

Miksy91 wrote:

And, if I made the game set bit 1000, would the game write 01 to 0xD7B9 ?

It would set the rightmost bit of the value at 0xD7B9. If it contained 0x80, you would get 0x81; if it contained 0xF4, you would get 0xF5.

#3 2010-12-29 18:52:07

Tauwasser
Member
Registered: 2010-10-16
Post 62/452

Re: Pokemon G/S Flags

There are about 0x0800 bits. I used to have a complete overview of all bits that people events use, yet can't find it right now. I think the highest numbers used for trainer fights were in the 0x0700-hundreds, so I guess they just figures 0x0100 bytes = 0x0800 bits = good enough.
With flags above that, you will definitely run into problems. You will overwrite other stuff, and some of that modifies data might not make its way to save ram, so you might lose that info.

Actually, the datacrystal page seems wrong. If 0xD7B7 has bits 0x0000 thru 0x0007 (which is true) as explained in the beginning of the page, 0xD7B8 should be 0x0008 thru 0x000F, not 0x0800... It seems the author was confused between BE and LE while writing the guide. Basically, you can compute these offsets just like the game does. ⌊BitNo / 0x08⌋ =: offset in bytes. BitNo AND 0x07 =: bit to check, set, reset. Add offset to D7B7 and then check the bit you calculated.

cYa,

Tauwasser

Offline

#4 2010-12-29 19:00:30

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

Re: Pokemon G/S Flags

I get it, at least most of it.

So, the bits are 0x0001, 0x0002..., 0x078A, 0x078B (and there should be free space till 0x07FF).

Do you think the flags between 0x0100 and 0x0290 are unused ?
There would be lots of free positions for new flags.
But yeah, it might be the best to just use bits that I don't need to use in my own hack that are used in the original game.
Then again, I believe I may end up using more bit commands that there is "space" for.

Besides, by unused, I also meant that they really are flags and the game designers haven't decided to put up some random data in there...

Other area with possibly lots of free space would be between 0x0320 and 0x05FF (why try to mess up by using bits between 0x0600 and 0x0603).


EDIT:
Oh, and I was pretty certain using those bits would change some other ram data so I'll be changing them to safer values :)
Probably going to make them something such as 0x0150, 0x0151...

Last edited by Miksy91 (2010-12-29 19:09:47)

Offline

#5 2010-12-29 19:13:45

91/703

Re: Pokemon G/S Flags

The table at Datacrystal looks very incomplete. I would make doubly sure flags are unused before trusting the list.

#6 2010-12-29 19:45:40

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

Re: Pokemon G/S Flags

What would be the best way to do that ?
Play through some part of the game and check always after a little while if the bytes have changed or not ?


Also, I'm starting to get a little better at this.
Just calculated that the bits, I used, changed the ram data at offset 0xDBBB.

--> Should change a letter of the sixth pokemon in your party :D


EDIT:
Could I actually use the bits that would modify the blank space that begins at 0xDD5C ?
At least, that space should be blank but no way to be sure though (memory viewer shows it is but it may depend on the occasion and Koolboyman hasn't listed anything of that part to his RAM Map).
There should be like 0x200 bytes to be spared in there (if you feel like using data between 0xDD60 and 0xDEFF).

Last edited by Miksy91 (2010-12-29 20:38:21)

Offline

#7 2010-12-29 20:30:32

92/703

Re: Pokemon G/S Flags

Miksy91 wrote:

What would be the best way to do that ?
Play through some part of the game and check always after a little while if the bytes have changed or not ?

To get a general idea of what flags are used, you could do a playthrough. But that would be very general, and it would only show that some flags are used, not that some flags are never used.

To make sure a flag isn’t used, just search for the script commands for writing and reading that specific bit. If you get no results, it probably isn’t used. If there are results, you can easily check and make sure they’re scripts, and then either remove them or edit them to your liking.

#8 2010-12-30 12:49:43

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

Re: Pokemon G/S Flags

By the way, I decided that I could go and look for some used bits in the game.
For example, Mary's script in Radio Tower uses these both bits: 4800 (not in the list) and 2100.

A better flag document could be made afterwards :)

Last edited by Miksy91 (2010-12-30 12:49:58)

Offline

#9 2010-12-30 16:11:35

Tauwasser
Member
Registered: 2010-10-16
Post 63/452

Re: Pokemon G/S Flags

It's not really menaingful to have these flags documented, as most people would like to start from scratch anyway. There are some for the furniture that are of possible interest and some for the healing script in PokéCenters. Basically, people would seldomly change these, because it requires ASM knowledge. Everything else could be made up on the go.

cYa,

Tauwasser

Offline

#10 2010-12-30 18:11:46

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

Re: Pokemon G/S Flags

Also how about some flags that appear to be turned on by default instead of being off when the game starts? Such as the ones hiding the guide gent in his house and the locations of the farfetch'd in ilex forest? I may be completely wrong and these are set by a script I overlooked, but it would seem like they are worth documenting to prevent people the headache of wondering why the game things their events have already run before they get to them if they used those flags.

Offline

#11 2012-03-19 05:06:33

Vitharix
Member
Registered: 2011-12-29
Post 28/396

Re: Pokemon G/S Flags

I'm having a tough time with a script i'm working on.
Here is a simplified version of it:

6A 47 4C xx xx 53 49 69 zz zz 33 10 00 90

So the flag is set after the person's text and movement, but how does one write a script that makes this person hidden when the map reloads?
I'm guessing it starts like this:
31 10 00 09
I just can't imagine why the person would be hidden because I wrote a script that says it should. It seems like it ought to be a script that runs when the map reloads, i'm just not sure how to achieve that.

Offline

#12 2012-03-19 06:33:03

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

Re: Pokemon G/S Flags

vitharix wrote:

I'm having a tough time with a script i'm working on.
Here is a simplified version of it:

6A 47 4C xx xx 53 49 69 zz zz 33 10 00 90

So the flag is set after the person's text and movement, but how does one write a script that makes this person hidden when the map reloads?
I'm guessing it starts like this:
31 10 00 09
I just can't imagine why the person would be hidden because I wrote a script that says it should. It seems like it ought to be a script that runs when the map reloads, i'm just not sure how to achieve that.

Just change the [Bit No] of that person to 10 00.

*If you used 6D [person no] instead, the person would get hidden and flag set at the same time although I don't think that's what you're asking for.

Last edited by Miksy91 (2012-03-19 06:36:50)

Offline

#13 2012-03-19 08:35:55

Vitharix
Member
Registered: 2011-12-29
Post 29/396

Re: Pokemon G/S Flags

Yeah, it's hard to explain! And my knowledge of script structure and flags is not vast.

I changed the Flag Bit (using Johtomap) to A (the flag i'm using is 0x10) and the person was hidden before the bit was set... So in the morning i'll set the bit to make him appear in another script, and see if that works.

Offline

#14 2012-03-19 09:16:42

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

Re: Pokemon G/S Flags

Then, you're having the person's [bit no] as 0A 00 (if the "next digit" of flag number is 0) and what you do with 33 10 00 is that you set flag number 10 00 on.

Offline

#15 2012-03-19 12:20:49

Vitharix
Member
Registered: 2011-12-29
Post 30/396

Re: Pokemon G/S Flags

I got mixed up; I was thinking that I had to convert the Flag Bit number to decimal, like you have to in Goldmap. Well, that should help a bit.

Offline

#16 2013-03-24 08:15:26

Jack
New member
Registered: 2013-03-24
Post 1/3

Re: Pokemon G/S Flags

Hey guys,

I'm pretty new (3 days since I cracked my first rom open on translhextion :) and I know it's been a while here, but I ran into the exact same problem. Hope somebody can lend me a hand. This is my script:

31 [flag] 09 xx 6D [Person] 90

And at xx I have a code to battle a lvl30 Celebi and which should disappear when the battle is done: (I basically used the same code from mateo's "Intro to Scripting" thread)

83 FB 00 67 FF 1E 03 09 5C FB 1E 5E 5F 33 [flag] 6D 02 90

In johtomap I set the flag of the event with the same [flag] used in the script.

So what happens is: I trigger the event and the battle goes OK and the event disappears as expected, but when I reload the map the event is back there.. and disappears when I trigger it.

How can I set this event to not appear anymore after the first battle is done?

Thanks a lot in advance for anyone who sees this! =)

Offline

#17 2013-03-24 09:18:45

RED
Member
From: Japan
Registered: 2012-09-03
Post 229/521

Re: Pokemon G/S Flags

Putting "disappear" script, you will never have to use "set bit".

Also did you put the flag bit in correctly?
Eg.
Flag index = f3
flag bit = 6

so you need to set bit 0x6f3


わたし の なまえ わ レン レン  でづ

Offline

#18 2013-03-24 15:21:11

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

Re: Pokemon G/S Flags

Like RED said, having the event set a bit and disappear the event is not necessary, "disappear" command sets the bit the Bit Number already refers to.
What you're doing wrong is most likely using a bit number between range of "0 0" and "7 0" (the way Johtomap's Flag Index and Flag Bit boxes show them) or the bit number being used if FF FF.

FF FF doesn't refer to a ram address at all, bit numbers between "0 0" and "7 0" all refer to ram address D7B7. Byte 00 is written to D7B7 everytime a map loaded through a map connection / warp so when you return to the map again, the values those bit numbers refer to are reseted, and events using them as their flags will be shown.

Basically, changing the bit number to something else will fix the problem. But it shouldn't be made too high (use bit numbers smaller than <= 07FF (or in Johtomap, values up to "FF 7" will do)).

Offline

#19 2013-03-24 21:15:23

Jack
New member
Registered: 2013-03-24
Post 2/3

Re: Pokemon G/S Flags

Hey everyone!

Thank you very much for the heads up! I changed the bits number and it worked!

Now I will play around datacrystal a bit to see if I can make the pokemon appear only with certain conditions, so I will try to use the flags that the system has, like for lugia and ho-oh.

Cheers!

Offline

#20 2013-03-24 21:23:41

RED
Member
From: Japan
Registered: 2012-09-03
Post 230/521

Re: Pokemon G/S Flags

Good to know that you did it, also if you want to make a person appear again you can use "appear" script if you are in the same map and "clear bit" if you are not in the same map.


わたし の なまえ わ レン レン  でづ

Offline

#21 2015-02-21 10:36:04

Rocket Grunt
Member
Registered: 2014-12-27
Post 36/75

Re: Pokemon G/S Flags

Actually is it possible to add new flags that are not existed originally?
For example, making a flag 0x078C (8C07)


Today I won't steal Pokemon

Offline

#22 2015-08-26 22:27:20

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

Re: Pokemon G/S Flags

It's really frustrating when you use a flag that's not on the "List of flags"-list, only to find out it collidess with some flag that hasn't been written down on the list. One example are the stone blocks at Route 19. But I have found other flags too that haven't been listed. Some flags also seem a bit "buggy", because the trainers rematch you and stuff. I guess I'll have to make a complete speedrun everytime I test the game...

Same crap with the items you pick up. Some of them reappear when you re-enter the area, while other times, they don't. I'm getting a bit paranoid about this, lol.

Keep track of the flags, folks!

Offline

#23 2015-08-27 09:54:51

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

Re: Pokemon G/S Flags

There is empty space starting at ram address $DEC0. Bit table in ram starts at offset $D7B7 so that flag 0x0000 (in bytes, 00 00) points to the first bit in offset D7B7, 0x0001 to the second bit in that offset and flag 0x0007 to the eight bit in that offset. Then 0x0008 (in bytes, 08 00) points to the first bit in offset D7B8 and so on.

Practically, flags are just pointers to bits in ram. It happens to be so that you can also point to the ram area starting at $DEC0 if you like - if you use high enough values for the flag. You should be able to calculate the flag number for the first bit in $DEC0 like this:

(0xDEC0 - 0xD7B7) * 0x8 = 0x3848 (48 38 as bytes in rom because of them being stored in little-endian)

And the other flags pointing to the "same ram address" (second to eight bit in DECO) are just values between 0x3849 and 0x384F.
There is empty space starting at $DEC0 until the space reserved for the stack starts at $DF00. In other words, there are 0x40 (=64) bytes there which means you could have at most 64 * 8 new flags if you like.
I have used this ram area in Dark Energy for new stuff (name of an additional character, several counters for different stuff, storing Battle Points of Battle Room (which is a feature from the hack), found items for a digging sidequest etc.), so if you like to use it for flags, you can but it's also convenient to leave room for other stuff there too.

Last edited by Miksy91 (2015-08-27 10:03:37)

Offline

#24 2015-08-30 00:09:39

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

Re: Pokemon G/S Flags

Thanks, Miksy, I'll check that out. I completely missed out and thought It would be possible to have a total of 65536 flags.

Offline

#25 2015-08-30 19:17:29

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

Re: Pokemon G/S Flags

Skurbert wrote:

Thanks, Miksy, I'll check that out. I completely missed out and thought It would be possible to have a total of 65536 flags.

You're welcome :)
And in case you haven't been doing so, use memory viewer often to check that your flags indeed affect that part of ram area you want, and don't accidentally point somewhere else instead. As an example, if you happened to use 0x4838 instead of 0x3848 for your flag, it would affect parts of ram at E000+ where you're not supposed to write anything. Though I'm not familiar with how the ram area between E000 and FEFF works myself.

In case you for example should know that "now all flags between 0x3848 and 0x384F are set in the game" and address DEC0 holds some other value than FF, you have either messed up with the bit numbers or haven't activated all of them yet.

Last edited by Miksy91 (2015-08-30 19:18:46)

Offline

Board footer

Powered by FluxBB