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-07-04 20:04:12

drludos
Member
Registered: 2017-05-11
Posts: 52

Using GBT Player with a 32kb rom?

Hi everyone,

I'm still working on my tiny #bitbitjam4 game (made with GBDK), and I've reached the "sound effects and music stage".

Regarding music, I've managed to tie the wonderful GBT Player to my game.
Doing so bumps my tiny game from a 32kb rom (only ~16 kb used, if not less, by code+graphics+sound effects) to a 64kb one.

I've been toying with the compiler options, and even when I explicitly set the mod2gbt to use bank1, I can't get the game to compile with GBT Player on a 32kb rom / 2 banks only.

As the asm source of the GBT Player seems quite "huge" (around 30kb of ASM code), I've been wondering:

Is it even possible to use GBT Player on a 32kb rom? Or does the GBT Player itself fill more than 1 bank by itself, forcing us to use at least a 64kb rom to use it?

Thanks for your help!


Download ROMs of my games: https://drludos.itch.io/
Support my work and get access to beta and prototypes: https://www.patreon.com/drludos

Offline

 

#2 2017-07-05 15:56:46

AntonioND
Member
Registered: 2014-06-17
Posts: 134
Website

Re: Using GBT Player with a 32kb rom?

I've just checked my last game to see the real size of GBT. It uses 487 bytes of ROM[0], 1607 of ROM[1] and 65 of WRAM[0]. And this is the latest RGBDS version, which is bigger than the GBDK one. I suppose that what is making your code grow is the song itself, but it shouldn't be too big either.

The size of the source code is irrelevant.

Are you sure you are using the correct version of GBDK? I remember that one of them didn't place "const" arrays in ROM, and that made the code huge.

Offline

 

#3 2017-07-05 21:22:42

drludos
Member
Registered: 2017-05-11
Posts: 52

Re: Using GBT Player with a 32kb rom?

Hi Antonio, thanks for your reply.

As I guess that GBT Player is geared towards 64kb+ roms (because most "real" games are at least 64kb), is there any step to "configure" it to a 32kb Rom, besides declaring that the song will be stored in "Bank1" when converting it with mod2gbt?

For example, in the make.bat file how should the final line (the one that collapse all the .o files into the gb rom) be used?

The one from your example will always compile to a 64kb rom (working):
"lcc -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG -Wl-yt1 -Wl-yo4 -Wl-ya0 -o bitbitjam4.gb bitbitjam4.o output.o gbt_player.o gbt_player_bank1.o"

I've tried to remove all the additional parameters to see if it reverted it back to 32kb:
"lcc -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG -o bitbitjam4.gb bitbitjam4.o output.o gbt_player.o gbt_player_bank1.o"

This one output a 32kb rom indeed, but it's non fonctional: BGB is throwing errors about the rom size and the game doesn't run.

As it's my first GB game, I may be doing some things wrong (the lcc parameters are still mysterious to me).

For now, I just tried to add GBT Player to my game and make it play the "template song".

I'm using the latest GBDK (2.96a I guess), downloaded from sourceforge, alongside with the GBT "legacy" version from your github repo.

Thanks a lot for your help!


Download ROMs of my games: https://drludos.itch.io/
Support my work and get access to beta and prototypes: https://www.patreon.com/drludos

Offline

 

#4 2017-07-06 18:10:02

AntonioND
Member
Registered: 2014-06-17
Posts: 134
Website

Re: Using GBT Player with a 32kb rom?

Of course it can be used with 32 KB ROMs. This game uses the latest version of GBT and is only 32 KB in size (and it has 5 songs): https://github.com/AntonioND/geometrix

Can you paste a ROM, symfile, code or something? It's impossible to guess what your problem is.

Offline

 

#5 2017-07-06 20:48:24

drludos
Member
Registered: 2017-05-11
Posts: 52

Re: Using GBT Player with a 32kb rom?

Thanks for your help.

Here is a zip with my source and the gbt player component I use, alongside with the make.bat file
http://test.ludoscience.com/sheepitup/gbtest.zip

I've made some additional test with the compiler parameters, and the problem really lies in the number of bank.

If i use the "-Wl-yo4" switch to set 4 banks, everything works fine. If I set "-Wl-yo2" to reduce it to two bank (or if I remove the parameter), I get the following error:
"ERROR: only 1 32kb segment with 2 bank"

Then the .gb file isn't created (it's a 0kb file) and so BGB can't run it.


Download ROMs of my games: https://drludos.itch.io/
Support my work and get access to beta and prototypes: https://www.patreon.com/drludos

Offline

 

#6 2017-07-06 23:02:33

ssjason123
Member
Registered: 2017-03-21
Posts: 45

Re: Using GBT Player with a 32kb rom?

I tried to play with it a bit. It doesn't seem to like the bank pragma or the _CODE1 area segments when using the default non-banked (2 segment) memory bank controller. Just the declaration of another area segment kicks off the error. Removing the pragma from output.c and changing the .area _CODE1 to .area _CODE in the gbt_player_bank1.s seems to compile everything ok. No sound though. You might be able to look into re-building the compiler to remove the banking error if you need more control over the code placement.

EDIT: Turns out I had sound disabled in BGB. It plays correctly with the pragma removed and the .area changed.

Last edited by ssjason123 (2017-07-06 23:44:48)

Offline

 

#7 2017-07-07 04:31:11

AntonioND
Member
Registered: 2014-06-17
Posts: 134
Website

Re: Using GBT Player with a 32kb rom?

I'm 100% sure that the problem is your compiler. Some versions of GBDK don't store "const" data in the ROM, they store it in the RAM and copy it when booting. This means that an array that would need just a few hundreds of bytes ends up taking KBs.

I don't know which version of GBDK works fine, though. Maybe you could check the tutorial of the ZGB library and download that version.

Some code of GBT is in bank 1 to leave more space of bank 0 for the rest of the game. You can change it to bank 0, but I wouldn't do it.

Offline

 

#8 2017-07-07 06:33:13

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

Re: Using GBT Player with a 32kb rom?

Trying to make a 32kb ROM means you're essentially running without any memory controller, hence no banks. That's why it doesn't like _CODE1 : because there's no bank 1 :p
Just the space where bank 0 usually resides  (0000-3FFF) and the space where other ROM banks reside (4000-7FFF).


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

 

#9 2017-07-07 09:49:51

drludos
Member
Registered: 2017-05-11
Posts: 52

Re: Using GBT Player with a 32kb rom?

Hi Everyone,

Thanks a lot for your help and you explanations, now it's working great!

As @ssjason123 explained, removing both the pragma and the .area _CODE1 made it compile successfully, and playing music too! You're wonderful, my project will have music now smile.

Thanks @ISSOtm for the explanation about why this wasn't working: I always though that a 32kb ROM was actually a "Bank0+Bank1" rom. I didn't knew that the lack of a MBC means that the game doesn't know what a "bank" is smile.

@Antonio: I do use the latest GBDK version, coming directly from Zalo ZGB tutorial (actually, it's in this tutorial that I discovered the wonderful gbt player). Thanks a lot for the time you took to help me, even if I use an outdated GBT Player for GBDK compatibility (if one day I learn ASM, I'll be able to try my hand at the latest version smile)

Thanks again a lot for your help, I couldn't have figured this out without you all!

Now, I'll try to compose something for the game before the bitbitjam4 deadline, but this will be useful for all my (hopefully) next games too smile.

Last edited by drludos (2017-07-07 09:50:42)


Download ROMs of my games: https://drludos.itch.io/
Support my work and get access to beta and prototypes: https://www.patreon.com/drludos

Offline

 

#10 2017-07-07 14:28:23

AntonioND
Member
Registered: 2014-06-17
Posts: 134
Website

Re: Using GBT Player with a 32kb rom?

Ok, that's a weird problem... But well, I guess it's what happens when using a really old toolchain like this one. xD

I'm glad it finally worked!

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson