Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2017-11-11 11:58:23

RadonUsedMimic
Member
From: Texas
Registered: 2016-11-22
Post 31/127
Website

[PokéRed] Flags and Banks

This is for a little experiment, but I would like to know more on these two subjects.

Flags: I know it adds in to certain parts of the game, but how can I set a flag after the game is finished? I would like players to get a second chance if they accidentally defeated Artcuno, Zapdos and Moltres (After you beat the Elite Four and Blue). Also, how can I get two Pokémon to appear (not in the same area or next to eachother) after you catch all 3? Any help would be appreciated. Thanks!

Banks: If I were to assign Yellow Version's front sprites, which I have done before, and I know they're not small enough to fit in the bank, How can I tell the bank to hold more data? Can I expand the bank? Thanks!

(P.S. If you all are wonderin' if this is going into PokéBundle to ruin the game and not stay faithful to the original games, its not. I've got other plans. Lets just say I might "extend" my knowledge after I figure out how this works.)


Caramba! I hate it when there’s a lot of hair on the floor! Here, I’ll go clean up!
Woo! Feels good when the floor is clean, doesn’t it? Let’s groove.

Offline

#2 2017-11-12 07:25:35

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,041/1,119

Re: [PokéRed] Flags and Banks

Regarding flags, if you want the three birds to reappear after beating the Elite Four, you would need to add a line like this to scripts/halloffameroom.asm in HallofFameRoomScript2:

ResetEvents EVENT_BEAT_ARTICUNO, EVENT_BEAT_ZAPDOS, EVENT_BEAT_MOLTRES

If you want the player to only have 2 chances and not infinite chances, then you need to create a new permanent flag that gets set in scripts/halloffameroom.asm when you beat the Elite Four.
Then only reset the three bird events if the new flag was not already set.
You can use any of the unused event flags to do this.

If you want 2 new overworld Pokemon to appear when all 3 birds are owned, then that requires modifications in several places.
You have to create object data for these 2 new overworld Pokemon in the map's object files in the data/mapObjects/ folder and create their trainer headers in the scripts/ folder.
This also means you have to create an even flag for each new overworld Pokemon in constants/event_constants.asm

You need to create 2 new hide/show constants in constants/hide_show_constants.asm
You need to add the 2 new overworld Pokemon to each of those map's hide/show data in data/hide_show_data.asm and make them hidden by default. (for both of these files, it's best to put the new data/constants at the end of the existing lists to keep compatibility with old save files)

Then you need to modify scripts/seafoamislands5.asm scripts/powerplant.asm and scripts/victoryroad2.asm and add code that runs after the battle with the bird happens, and which checks if the Pokedex owned flags are set for all 3 birds.
If all 3 flags are set, then call "ShowObject" twice for both of the new overworld Pokemon, and give the hide/show id from constants/hide_show_constants.asm as the arguments.
(you would need to take a slightly different approach if you wanted to allow these 2 overworld Pokemon to appear if the birds were obtained though trading instead)


Regarding banks, you cannot create a bank that holds more data. Each bank in ROM is exactly $4000 bytes.
This is because the Gameboy's address space ($0000 to $FFFF) is a specific size, and each region of memory in the address space has a specific purpose.
The first $8000 bytes always hold a copy of 2 banks from ROM.
Addresses from $0000 to $3FFF are always a copy of ROM bank 0.
Addresses from $4000 to $7FFF area always a single, whole copy of a non-0 ROM bank.
After address $7FFF those areas of RAM serve a specific purpose and cannot be used to hold a longer ROM bank.

More specifically, this is because when the CPU tries reading from an address from $0000 to $7FFF, a component called the Memory Bank Controller (MBC) returns the correct byte from the cartridge based on the currently loaded ROM bank.
But if the CPU tries reading from addresses $8000 to $9FFF, then the correct byte will be returned from the video RAM chip.
You cannot force ROM banks to extend beyond address $7FFF.

If you have a problem with a bank running out of space when you try building, you need to reorganize the data.

Offline

#3 2017-11-12 16:09:54

RadonUsedMimic
Member
From: Texas
Registered: 2016-11-22
Post 32/127
Website

Re: [PokéRed] Flags and Banks

Thanks!

Although I'm a little curious. If I were to replace the birds with three completely different Pokémon for the second chance to capture them, what would I do?

Also, lets say I add in some new Pokémon, and put the pointers in main.asm. If the bank were to run out of data, can I create an entirely new bank?


Caramba! I hate it when there’s a lot of hair on the floor! Here, I’ll go clean up!
Woo! Feels good when the floor is clean, doesn’t it? Let’s groove.

Offline

#4 2017-11-12 17:36:27

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,042/1,119

Re: [PokéRed] Flags and Banks

To have them reappear as 3 different Pokemon, I would make 3 new hide/show objects, event flags, map objects, and trainer headers for 3 brand new oveworld Pokemon and just make them have the same maps and coordinates as the 3 birds.
Then have their hide/show flags set to hidden at first and then use "ShowObject" on those 3 Pokemon instead of the "ResetEvents" macro I referred to earlier.

Yes, you can create brand new banks (therefore making the ROM bigger than 1 MB) but it's easier to use an empty bank.
Luckily there are many banks in the already-present $40 banks that are entirely empty.
From bank $2D to bank $3F are all unused (almost one third of the whole ROM) and you can put whatever you want in these banks with very little extra effort.
In main.asm (or wherever you want to create a new section for an empty bank) just put a line like this:

SECTION "New Stuff",ROMX,BANK[$2D]

Offline

#5 2017-11-12 22:24:10

RadonUsedMimic
Member
From: Texas
Registered: 2016-11-22
Post 33/127
Website

Re: [PokéRed] Flags and Banks

Thanks for the info! I'll experiment with this and see what I can do.


Caramba! I hate it when there’s a lot of hair on the floor! Here, I’ll go clean up!
Woo! Feels good when the floor is clean, doesn’t it? Let’s groove.

Offline

Board footer

Powered by FluxBB