Quote:
Originally Posted by miksy91
Just as metapod said, you shouldn't use certain flags in your hack.
If you know where the game writes the data of flags, you can see which flags are automatically set and which not. However, learning to do it may not be easy as one byte contains the data of eight bits.
Bit no. 1 in the byte = 00/01
Bit no. 2 in the byte = 00/02
Bit no. 3 in the byte = 00/04
Bit no. 4 in the byte = 00/08
Bit no. 5 in the byte = 00/10
Bit no. 6 in the byte = 00/20
Bit no. 7 in the byte = 00/40
Bit no. 8 in the byte = 00/80
So if for example bits number 4 and 7 would be set in certain byte and others wouldn't be set, the byte would be:
00 + 00 + 00 + 08 + 00 + 00 + 40 + 00 = 48
It's safe to use most of the other flags than the ones that are already set when you open the game and play till the point when you appear in your room.
To know which flags are set and which not, use VBA's Memory Viewer and go to the location of the flag bits in RAM.
There is documentation about RAM of 1st & 2nd gen pokemon games so you should be able to find it also for the ones of 3rd.
|
Most of this is right, except the flags are DMA protected on most of the 3rd Generation Roms. Ruby and Sapphire have static ram locations, FRLG and Emerald's constantly change. So you won't be able to find the flags that easily. On Fire Red, there's a routine called by warping and changing to the battle screen, which, based on the result of the RNG, writes a ram location to 0x03005008. This ram location is static, and is how the game actually makes use of DMA protected information.
It loads the ram offset stored at 0x03005008, and then works out where the data is located with respect to that base offset. The flags are located at
[03005008] + 0xEE0. You can check this easily as long as you don't change map, as the routine is being called when warping and changing into the battle screen.
Also, just as importantly, the variables and flags and other processes in the rom SHARE MEMORY SPACE. In other words, Flags higher than 0x8FF will start using space assigned to the variables 0x4000 and onwards. 0x4000 is the lowest available variable, while 0x8FF is the highest available flag. Trainerflags are in fact just normal flags, meaning it is very unsafe to extend the trainerbattle table as things stand. Trainerflag 0x1 = Normal Flag 0x501 and so on.
Basically, where possible, try to recycle flags and variables already used in the standard rom.