Starting guides for GBdev (audio-oriented)

Discussion of programming and development for the original Game Boy and Game Boy Color.
Post Reply
User avatar
koitsu
Posts: 4216
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Starting guides for GBdev (audio-oriented)

Post by koitsu » Wed Jan 23, 2019 4:59 pm

A friend of mine wanted to know if there were any good or recommended starting guides for general GB development, particularly sound emulation.

User avatar
ISSOtm
Posts: 46
Joined: Fri Jan 04, 2019 5:31 pm
Location: France, right of a pile of consoles
Contact:

Re: Starting guides for GBdev (audio-oriented)

Post by ISSOtm » Thu Jan 24, 2019 1:06 am

Wait, a guide for development, or for emulation? Those are entirely separate.
The French Lord of Laziness (and a huge Legend of Zelda fan)
https://github.com/ISSOtm
ASMu is laifu <3

byuu
Posts: 1540
Joined: Mon Mar 27, 2006 5:23 pm
Contact:

Re: Starting guides for GBdev (audio-oriented)

Post by byuu » Thu Jan 24, 2019 1:33 am

I used this documentation to understand how Game Boy audio worked:

http://gbdev.gg8.se/wiki/articles/Sound_Controller

If your friend would like to see code implement the sound controller, this may help, although it's not bit-perfect:

https://gitlab.com/higan/higan/tree/master/higan/gb/apu

If they want to test an implementation, the best I know of are blargg's test ROMs:

http://gbdev.gg8.se/files/roms/blargg-gb-tests/

But just a note that every Game Boy is a little different, and these tests fail on certain models. More about that here:

http://gbdev.gg8.se/wiki/articles/Test_ ... .27s_tests

Overall, the hardware is rather forgiving, and you can get pretty good sound without having to support all the zany edge cases and per-model behaviors.

Pokun
Posts: 1308
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Starting guides for GBdev (audio-oriented)

Post by Pokun » Thu Jan 24, 2019 6:13 am

This tutorial is good to quickly learn how to get up a ROM up and running (which is always the hardest step IMHO):
http://peterwynroberts.com/?p=10
Edit: Oops wrong link. It's this one: http://assemblydigest.tumblr.com/post/7 ... m-in-rgbds

A collection of pretty much everything Game Boy development:
https://github.com/gbdev/awesome-gbdev

I recommend to read the official development documents, and Pan Docs.
Last edited by Pokun on Sun Jan 27, 2019 10:53 am, edited 1 time in total.

User avatar
koitsu
Posts: 4216
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Starting guides for GBdev (audio-oriented)

Post by koitsu » Thu Jan 24, 2019 11:44 am

Thanks folks.

Also, to answer ISSOtm's question: primarily a sound emulation focus (quote: "I mostly just want to get the Tetris music playing or something"), but given some of his other projects/interests pertaining to audio, developing on the GB (for sound-related reasons) would likely be necessary on some level.

User avatar
ISSOtm
Posts: 46
Joined: Fri Jan 04, 2019 5:31 pm
Location: France, right of a pile of consoles
Contact:

Re: Starting guides for GBdev (audio-oriented)

Post by ISSOtm » Thu Jan 24, 2019 4:45 pm

For blargg's test ROMs, an incomplete source code RE effort can be found here.
More (much more!) advanced test ROMs can be found here, although they require emulation of the PCMXX registers.

As for learning how to program, I'm going to shill my own stuff, as I've got very positive feedback on it. It's not complete yet, so there's no mention of the APU, but it's at least enough to get a Hello World running.
By the way, the tutorial Pokun linked is very outdated. `gbhw.inc` has been replaced with hardware.inc, RGBDS has officially deprecated `HOME`, `CODE`, `DATA` and `BSS` sections in favor of `ROM0`, `ROMX`, `ROMX` and `WRAM0`/`WRAMX`, and so on. RGBFIX is used for the header instead of source code macros.
The tutorial is also full of cargo cult - the first four bytes of code in the header need not be this, you can use `di ; jp EntryPoint` for example; the stack should never be put in HRAM, as it provides no benefit and eats space that could otherwise be allocated to fast-access variables. And overall it explains very little.
The French Lord of Laziness (and a huge Legend of Zelda fan)
https://github.com/ISSOtm
ASMu is laifu <3

Pokun
Posts: 1308
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Starting guides for GBdev (audio-oriented)

Post by Pokun » Sun Jan 27, 2019 11:17 am

Sorry I posted the wrong tutorial. I updated the link in my post to the one I used. It was years ago I used it though, so it may also have some cargo cult and is probably also using the old RGBDS assembler. But it was the only tutorial I could find at the time that actually taught how to make a proper ROM in assembly and that works on real hardware. Most other tutorials was incomplete, full of weird stuff or would produce faulty ROMs that only worked in older emulators.
ISSOtm wrote:RGBFIX is used for the header instead of source code macros.
I don't personally use those features in RGBFIX. I need it to fix the checksums only, as generating the rest of the header manually is trivial.
ISSOtm wrote:gbhw.inc has been replaced with hardware.inc
The confusion about what was the latest version of that is what made me stop using it and just use my own (compatible) defines, or just use raw register numbers for certain things.

User avatar
devmas
Posts: 18
Joined: Wed May 20, 2009 6:16 am
Location: New York City

Re: Starting guides for GBdev (audio-oriented)

Post by devmas » Sun Feb 03, 2019 6:35 am

I will be watching this topic very closely in the coming days. I am jumping into GB dev for the first time, and the one big question mark I had after preliminary research was how to efficiently create and play music and sound effects.

I would be interested in knowing on a high level what others' processes are when making music and sounds, I couldn't find much info online at all sadly.

tepples
Posts: 21802
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Starting guides for GBdev (audio-oriented)

Post by tepples » Sun Feb 03, 2019 8:53 am

I haven't yet made music on Game Boy, but the audio driver I made for Libbet and the Magic Floor conceptually resembles my first NES audio driver (Pently generation 1) that could also only play sound effects. The documentation and source code of this driver should help you learn some concepts. Extension to music is pending more experience with structs, which aren't easy to make efficient on an 8080.

Post Reply