Game Gear Coding

About a year or so back I got a book that the public library was giving away after a book sale on Z80 assembly. I read it, but never really did anything with that knowledge. The thought was always in the back of my head to eventually apply that and play around with some SEGA Master System/Game Gear coding. Unfortunately time has a way of getting away from you.

The library had a book sale about a month or so back and they had quite a few books. Among the ones I got for a dollar or so each include: 68K Assembly, Z80 Assembly (a much thicker, more complete reference), 100 Z80 projects (hw & software from the looks of it), X86 MS-DOS assembly, C standardize library reference, and a few others. The addition of a couple more Z80 books gave me a bit of a push to look back into SMS/GG coding.

Because this is basically my first time with any kind of assembly, things have been going a bit slow, but steady. I have a basic skeleton at this point that does things like setup the stack pointer, wait for the VDP (Video Display Processor) to come to a sane state (which it isn’t always after power on), put the interrupt at 0x0038 as it should be, bail out/halt the cpu if we’re in PAL mode (just for fun for now), and loop endlessly calling a function to read input from player one. Even though the guys at SMS Power recommend WLA-DX, I decided to go with z80asm which comes with z80pack. It wasn’t easy goings at first because without actually looking at the source to see what the command line parameters mean. Let me show you what the console help looks like:./z80asm
no input file
usage: z80asm -f[b|m|h] -s[n|a] {-x} -v -ofile -l[file] -dsymbol ... file ...

Now, what is -f? what is -s? what about -x, -v, or -l? I edited z80asm’s source to now output this ./z80asm
no input file
usage: z80asm -f[b|m|h] -s[n|a] {-x} -v -ofile -l[file] -dsymbol ... file ...
-f Format: [m]os (default),
[b]inary,
[h]ex
-s Symbol: [blank] unsorted,
[n] symbol table sorted by name,
[a] symbol table sorted by address
-x Dump?
-v Version
-o Output file.[format]
-l List file
-d Define [symbol]
It’s not exactly clear on what everything means, but it’s better than before. The problem I had with my program misbehaving in CrabEmu was actually due to the fact that the output format, by default, is mos binaries (not entirely sure what mos stands for to be honest.) It was an “AHA!” moment when I realized this by looking at the source. I switched to -fb (straight binary) and all of a sudden things are working so much better! I had a few initial bugs because, like I said, it’s the first time I’m really doing assembly coding, and it ended up I miscounted and was off by one bit on the bit I was wanting to look at for the GG display type (NTSC/PAL.) After I fixed that things appear to be working as they should (I don’t have any kind of visual output yet, but stepping through the code, everything looks to be as it should.)

So where do I go from here? Since I think I have a pretty good handle on the initial setup, I think it’s time to move to some VDP code so it can display something useful. After that, it’s onwards to the PSG (Programmable Sound Generator) to have some fun with sound. Input with obviously be in there too, but I feel like I have an understanding on how to handle it. There are still some things which I don’t totally understand yet, like ROM banking, but in time I’m sure I’ll become quite familiar with this system. I’d also like to return to my idea to use SDCC as a compiler for the SMS/GG. It looks like it should be doable, but I’m not sure if I want to invest the time to make it so right away. Another thing which I may have to work on are tools for things like tiles and such. All the graphics tools listed on smspower.org are Windows only it seems.

In the distant future I hope to buy a GG Pro 32M Cart for testing on actual hardware, but at $85 it will be no less than a few months out (giving me plenty of time to get something to actually test.) I hope to have something to show for this by the end of the year. That said, there are other projects which I want to work on that might end up taking precedence. For instance, there’s the S.A.T.U.R.N. coding competition going on currently that I’d really like to have something to submit. I should try to start that this weekend…


2 thoughts on “Game Gear Coding

  • Daniel

    There’s a crazy Chinese company called atgames that makes a clone of the Game Gear and various other systems, officially licensed no less. It has an SD card slot and costs much less than $85.

    Reply
    • losinggeneration Post author

      After a bit of research, it appears that the ATGames consoles are completely incompatible with SMS/GG (and thus homebrew for those two systems isn’t possible.) So basically it sounds like they are just not going to work for me.

      Reply

Speak Your Mind

Your email address will not be published. Required fields are marked *

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>