Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2017-08-11 23:19:20

chris
Member
From: USA
Registered: 2016-11-27
Posts: 66
Website

How do I bankswitch?

I can't find any detailed information on how to make a game larger than 32k. Can anyone help or direct me towards any?


Frank the Fruit Fly: The Game Boy game I'm working on: http://www.atari2600land.com/gameboy/ftff.html

Offline

 

#2 2017-08-13 00:33:08

Tauwasser
Member
Registered: 2010-10-23
Posts: 68

Re: How do I bankswitch?

There are quite a few threads about bank switching in general and using GBDK in particular. First, do you use GBDK or rgbds? In case of GBDK, the example directory contains some example bank switching code, which is unfortunately outdate, see this thread. For RGBDS, you can check out the GitHub documentation, which is sparse, but useful.

Offline

 

#3 2017-08-13 04:20:30

chris
Member
From: USA
Registered: 2016-11-27
Posts: 66
Website

Re: How do I bankswitch?

I'm using GBDK. I don't really know what to do. What code do I put in my game? What should I type in when I compile? What I was planning to do was make a 1MB game instead of a 32k game.

Last edited by chris (2017-08-13 04:24:44)


Frank the Fruit Fly: The Game Boy game I'm working on: http://www.atari2600land.com/gameboy/ftff.html

Offline

 

#4 2017-08-13 05:04:15

chris
Member
From: USA
Registered: 2016-11-27
Posts: 66
Website

Re: How do I bankswitch?

OK, I have a 64k ROM, how do I double it?


Frank the Fruit Fly: The Game Boy game I'm working on: http://www.atari2600land.com/gameboy/ftff.html

Offline

 

#5 2017-08-13 06:34:38

chris
Member
From: USA
Registered: 2016-11-27
Posts: 66
Website

Re: How do I bankswitch?

I didn't do it correctly because it doesn't work on a real Game Boy. Help!


Frank the Fruit Fly: The Game Boy game I'm working on: http://www.atari2600land.com/gameboy/ftff.html

Offline

 

#6 2017-08-13 06:38:34

ISSOtm
Member
From: Somewhere in Echo RAM
Registered: 2017-04-18
Posts: 39
Website

Re: How do I bankswitch?

You might be better reading how bankswitching works on the GB. I'll try giving you a crash course here.

Since the ROM is larger than what the GB can access, inside all >32k cartridges is a chip that allows ROM banking. Most cartridges (AFAIK) use a type of chip known as the MBC (Memory Bank Controller), Nintendo's official chip.
There are a couple chips, some of them are documented here.

I don't know how you do this with GBDK, but you should pick
- Which chip you want (usually : MBC3 if planning to use RTC features, MBC5 otherwise)
- How many banks you will use (see this chart

... and then write to the appropriate memory location to perform the bankswitch.


The French Lord Of Laziness.
Legend of Zelda and Undertale fan, I also tend to break Pokémon R/B/Y a little too much.

Twitter | Me on GCL | Discord : ISSOtm#9015 | Skype : isso.tm (I don't login anymore)

Offline

 

#7 2017-08-13 10:31:18

chris
Member
From: USA
Registered: 2016-11-27
Posts: 66
Website

Re: How do I bankswitch?

I got the 64k ROM working good now, but how do I make it 128k (1 MB)? I want to tell it to use 8 banks.
How will I know when I run out of room and need to use a different bank?


Frank the Fruit Fly: The Game Boy game I'm working on: http://www.atari2600land.com/gameboy/ftff.html

Offline

 

#8 2017-08-14 09:20:29

chris
Member
From: USA
Registered: 2016-11-27
Posts: 66
Website

Re: How do I bankswitch?

So I got a 128k file, but I use 8 ROM banks and 4 RAM banks. It told me 8 RAM banks wasn't usable. I don't know what a RAM bank is. I know RAM stands for "random access memory," and ROM stands for "read-only memory," but I don't know why it's called Random access. What is random about it?

Code:

bin\lcc -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG -c -o test.o ftff20.c
bin\lcc -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG -Wf-bo1 -Wf-ba1 -c -o bank_1.o bank_1.c
bin\lcc -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG -Wf-bo2 -Wf-ba2 -c -o bank_2.o bank_2.c
bin\lcc -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG -Wf-bo3 -Wf-ba3 -c -o bank_3.o bank_3.c

bin\lcc -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG -Wf-bo1 -Wf-ba1 -c -o bank_3.o bank_3.c
bin\lcc -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG -Wf-bo2 -Wf-ba2 -c -o bank_3.o bank_3.c
bin\lcc -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG -Wf-bo3 -Wf-ba3 -c -o bank_3.o bank_3.c
bin\lcc -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG -Wf-bo3 -Wf-ba3 -c -o bank_3.o bank_3.c

bin\lcc -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG -Wl-yt5 -Wl-yo8 -Wl-ya4 -o ftff21.gb test.o bank_1.o bank_2.o bank_3.o bank_3.o bank_3.o bank_3.o bank_3.o 

pause

Frank the Fruit Fly: The Game Boy game I'm working on: http://www.atari2600land.com/gameboy/ftff.html

Offline

 

#9 2017-08-14 21:39:23

ISSOtm
Member
From: Somewhere in Echo RAM
Registered: 2017-04-18
Posts: 39
Website

Re: How do I bankswitch?

RAM banks, in this case, refer to SRAM banks : the number of banks of RAM that are present in the (emulated) cartridge that contains your game.
There are only a select number of SRAM banks you can use, which is further restricted by which MBC you're using.

As for why RAM is "random", Wikipedia is your friend.


The French Lord Of Laziness.
Legend of Zelda and Undertale fan, I also tend to break Pokémon R/B/Y a little too much.

Twitter | Me on GCL | Discord : ISSOtm#9015 | Skype : isso.tm (I don't login anymore)

Offline

 

#10 2017-08-18 16:12:19

chris
Member
From: USA
Registered: 2016-11-27
Posts: 66
Website

Re: How do I bankswitch?

How will I know I've used up a bank and need to start a new one?


Frank the Fruit Fly: The Game Boy game I'm working on: http://www.atari2600land.com/gameboy/ftff.html

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson