Gameboy project week 4: A test/”welcome” ROM

January 28th, 2013

This week’s was supposed to be a MIDI controllable version of Shitwave, and while that’s done, I found out it was a bit less exciting than I was hoping for, so I want to try to come up with some new ideas for that. However, I found a new project to do over the weekend. beware, the author of BGB (Gameboy emulator and debugger) mentioned that he wanted to include a ROM with the emulator (not specifically mentioning me) that a new user of the emulator could use to test the emulator, without having to go to a different site to find a ROM. These are his criteria for this ROM:

  • Should show some form of graphics, and ideally show some form of animation.
  • Should play sounds.
  • Should show the user which buttons are currently pressed.

All these things are potentially useful in case the emulator (or the configuration of the emulator) is not working correctly for some reason.

For this week’s project I’m also including the source code. I pondered whether to do this or not for a couple of reasons. One reason is code vanity. When you release the source code for something, it lets other people judge the code. I would describe my programming style as casual and chaotic. This means that in a lot of cases I make things up as I go along. This means that sometimes I do things in ways that are “wrong”, or only works under certain circumstances, or are unnecessarily tedious. Another risk with releasing the source code is that people will invariably ask you for help in private communication. There’s not necessarily anything wrong with that per se (unless the question is stupid) and I try to answer questions I get in my inbox, but it may not be the most efficient way to get an answer. You may want to try my Gameboy development forum or perhaps more realistically if you want people to see your question, NESDev’s Gameboy subforum. Or #gbdev on EFNet if you use IRC.

The program

The program in its current form shows the BGB icon, BGB in a big font and the text “press buttons to test”.

There’s a starfield in the background with 24 indiidual stars, made up of sprites. The stars travel from right to left and can travel at three different speeds (1, 2 or 3 pixels per frame) and there are two types of stars. Their Y positions are determined by an LFSR random number generator.

When you press one or more buttons, an indication is shown on the screen. A note is also played. I wanted to get this function right. The scale used for the notes is a mixolydian scale (or, major scale with a flat 7th) because plain major scales are boring. The note are played duophonically by alternating between the two pulse channels, so you can play two note chords. And the program also alternates between playing the actual note and playing it slightly detuned. This gives a slightly phasey sound when playing the some note multiple times, which in my opinion sounds better.

There’s also a melody played on the wave channel, which pseudorandomly generated by the same random number generator which is used for the stars. It plays notes from the same scale, but if you want you can turn it off by pressing select+start, say if you want to actually use this ROM for playing melodies.

The ROM also has an easter egg, which you might be able to find.

The ROM currently says BGB, but if you want, I can customize it for you to show your own logo, if you want to use it as the standard ROM to come with cartridges you sell. (The usual suspects, you know who you are.)
Read on…

Gameboy project week 3: A simple MIDI ROM

January 20th, 2013

nitromidi1 is a very simple Gameboy MIDI ROM. It can be used with an Arduinoboy or Nanoloop USB MIDI adapter. It’s not meant to be all that practically useful atm. Rather, I created it to have all the plumbing in place for future MIDI software.

It currently responds to the following things:

  • MIDI channel 1 only.
  • Gameboy pulse channel 1 only.
  • Note ons. (But currently not note offs!)
  • The typical “panic” button. (Channel mode messages $7B, all notes off and $78, all sound off.)
  • The pitch wheel, currently with a fixed range of +/-7 semitones.
  • CC 71/$47 which controls the pulse width of the wave.
  • CC 72/$48 which is a combined attack/release control, ie. the second nibble of the envelope byte. The control scans from short decay to long decay to constant volume output to slow rise to fast rise. In other word, the following envelope values mapped onto a knob: 1-7,8,F-9.
    As noted above, it doesn’t respond to note offs, so be careful with rising envelopes!
  • It has no GUI except a lines pattern indicating CPU usage. This is literally
    made by changing the background palette when the CPU is busy.

Have fun, and report any bugs/anomalies/feature requests.

Download nitromidi1

Mystery ROM explanation

January 16th, 2013

^ The ROM in action.

So, what about the mystery ROM? If you try to run the ROM in an emulator, it will do nothing. If you try to run the ROM on actual hardware, preferably a DMG, you might hear the faint sound of the first couple of bars of the Super Mario Bros overworld theme if you hold up the speaker to your ear. But what is the relevance of this?
Read on…

Gameboy project week 2: Mystery ROM!

January 13th, 2013

This week’s project is a mystery ROM. It’s a ROM that does nothing. Or maybe it does something, but it’s so subtle that you may not be able to detect it. Or if you think you do, maybe it’s you imagination?

Download the mystery ROM and see if you can figure out anything about it…

Edit: Explanation of what the ROM does.

Gameboy project week 1: More than four shades of green

January 6th, 2013

I’m hereby announcing 2013 as the “one Gameboy project per week” year. This an idea I came up with during a discussion with Seb (little-scale) where I jokingly suggested it as an alternative to the usual “one song per week” type challenges. So, my challenge is to try to do some kind of Gameboy-related project each week. Some of them will be more practically useful projects, like music/noise making ROMs, while others, like this week, will be research projects that I’m doing out of my own curiosity. This week’s project was actually meant to be a different project, but I postponed doing it, and had to settle for a smaller project to have a finished project at the end of the week. (Off to a bad start already. :p )
There’s a big risk this whole project will fail somewhere along the way. If not for lack of motivation (most likely) then because of lack of ideas.

Read on…