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 2021-05-05 08:15:32

radiosity
New member
Registered: 2021-02-01
Posts: 5

Use of LCC with GBDK to multibank switching

I have written my first game for Gameboy using GBDK 2020 and LCC. I have found several problems to manipulate differents banks of the ROM memory using LCC. The solution:

- Force to LCC to compile the code in bank 0, using "-Wf-bo0"  parameter.
- Don't use bank 1 to the data. The code needs bank 1 too (bank 0 and bank 1 = First 32K of ROM).
- Load the game data from bank 2 onwards.

This is all.

Regards.

Last edited by radiosity (2021-05-05 08:17:23)

Offline

 

#2 2021-05-05 09:57:40

toxa
Member
Registered: 2020-02-13
Posts: 307

Re: Use of LCC with GBDK to multibank switching

probably you tried to solve nonexistent problems. look into gbdk-2020 examples, there are several that show how to handle banked code and data.

Offline

 

#3 2021-05-18 01:12:19

radiosity
New member
Registered: 2021-02-01
Posts: 5

Re: Use of LCC with GBDK to multibank switching

toxa wrote:

probably you tried to solve nonexistent problems. look into gbdk-2020 examples, there are several that show how to handle banked code and data.

Trust me, look at those examples, but most of them used the SDCC compiler. I used LCC. In the next proyects I will use SDCC compiler.

Last edited by radiosity (2021-05-18 01:14:21)

Offline

 

#4 2021-05-18 06:03:10

toxa
Member
Registered: 2020-02-13
Posts: 307

Re: Use of LCC with GBDK to multibank switching

none of GBDK-2020 examples use SDCC directly, they all use LCC frontend: https://github.com/gbdk-2020/gbdk-2020/ … xamples/gb

banks* examples demonstrate using of banks.

also:

radiosity wrote:

- Don't use bank 1 to the data. The code needs bank 1 too (bank 0 and bank 1 = First 32K of ROM).

this simply means that you have a wrong program design. you must avoid overflowing non-banked code from bank0 into bank1 if you use bank switching.

i suggest always use LCC frontend, that simplifies everything.

Last edited by toxa (2021-05-18 06:07:34)

Offline

 

#5 2021-05-18 11:50:45

radiosity
New member
Registered: 2021-02-01
Posts: 5

Re: Use of LCC with GBDK to multibank switching

toxa wrote:

none of GBDK-2020 examples use SDCC directly, they all use LCC frontend: https://github.com/gbdk-2020/gbdk-2020/ … xamples/gb

Those examples, according to the notes themselves, is a bit old.
The method that I use is really the same as in those examples. Well, it only works for short code. When you exceed the first 16K of code (bank 0) you will see how you start to "trample" the data you have in bank 1. In fact, what I put in the first post works perfect for me, but thanks for your information, mate.

Offline

 

#6 2021-05-18 18:58:32

toxa
Member
Registered: 2020-02-13
Posts: 307

Re: Use of LCC with GBDK to multibank switching

as i told before, you must not overflow code from bank0 into bank1. because that makes random code land into bank1 (or even one half of the function land into bank0 while the other half in bank1) and if you try to switch bank from that code you simply crash. you have no control which code will be pushed out in bank1 that way, those can be library functions or whatever else stuff. code starts to be unpredictable.

Last edited by toxa (2021-05-18 19:04:27)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson