devkitPro / libgba

C Library for Nintendo GBA
http://devkitpro.org/viewforum.php?f=5
Other
192 stars 26 forks source link

Sound channel 3 is referred to as Triangle channel, but it isn't #7

Open hippydave opened 3 years ago

hippydave commented 3 years ago

https://github.com/devkitPro/libgba/blob/a7b03d614aa5d31b1dd36f4f21fb8d4286017f94/include/gba_sound.h#L298

Sound channel 3 is a programmable wave table, but is referred to in the header as a triangle channel. Pinobatch says: "It's because when I wrote the header that that header was based on, I had recent experience with the Nintendo Entertainment System and I started by using the wavetable channel to replicate the capability of the NES triangle channel until I realized that the GBA internal speaker's 800 Hz high pass characteristic wouldn't let the typical applications of the NES triangle wave through"

I don't know if this is being kept as a fun historical quirk, or if nobody's actually thought about it.

WinterMute commented 3 years ago

Quite a few things in the libgba headers are entirely legacy defines because of the fragmented nature of gba homebrew at the time. Many GBA projects were built with hand rolled tools and headers which varied a great deal and encouraging people towards homogenising an enviromment to foster greater collaboration involved pulling in a whole bunch of things that make no particular sense almost 2 decades later.

Further up the file you'll find defines based on later documentation (https://github.com/devkitPro/libgba/blob/master/include/gba_sound.h#L116-L118) The bogus triangle stuff can probably just be removed. It remains only because nobody has given the matter any thought.

hippydave commented 3 years ago

Thanks for the reply, so it was to provide compatibility, that makes sense. I know the REG names at the top are the more standard ones, but the defines lower down provide useful named values that can be or'd and passed to the registers, which makes code more readable than just using numbers. If any updates are planned it could be nice to adapt and modernise some of those.