This first article is focused on building a very simple ROM for the SEGA Genesis using assembly code. The ROM does a simple graphical effect, flickering the background color. Getting text on the screen is more complicated, so a proper 'Hello World' ROM will have to wait.
The SEGA Genesis had a Motorola 68000 CPU running at 7.6 MHz, a pretty fast processor for its time. It had very limited memory, only 64 KB main RAM and 64 KB Video RAM, half of what a decent home computer of the time would have, but that would be offset by the storage device being ROM cartridges with 512 KB - 8 MB, reducing any load time to almost zero.
The Genesis had a secondary CPU, a Zilog Z80 running at 3.58 MHz with 8 KB RAM. The Z80 was a very popular CPU in the late 70s and early 80s, used in the ZX Spectrum, the MSX computers, the Sega Master System, and in arcade games such as Pac-Man, Galaga, Dig Dug, Xevious, and others.
The Z80 was primarily used for controlling the audio chips, a Yamaha YM2612 FM chip which delivered 6 stereo FM channels and the Texas Instruments SN76489 Programmable Sound Generator (PSG), which has 3 square waves and a noise channel.
For this article, we're going to focus on the Motorola 68000.
The Motorola 68000 is a 16/32-bit processor introduced in 1979. It was very popular in 80s computers, notably:
It was also a popular CPU for arcade games:
For the 1988 Genesis, the MC68000 was an obvious choice, it was already a mainstay in home computers, and SEGA already used it their System 16 arcade hardware, presumably making it much easier to port arcade games to the home market. In fact, the Genesis architecture is very similar to the System 16, which also features a Z80, a Yamaha FM chip, and a standard resolution of around 320x224.
Markey Jester's Motorola 68000 Beginner's Tutorial is useful for learning MC68000 assembly code, the game development language of choice for game programmers.
If you want to test out some 68000 instructions or debug your code, EASy68K is really useful. It's an integrated development environment (IDE) that includes an editor, an assembler, and a debugger. It only emulates a 68000, no Genesis-specific stuff at all.
The only tool needed to create a ROM is an MC68000 assembler. The open source assembler vasm built with Motorola-style syntax works well for this purpose.
Currently, there isn't a Windows binary download of vasm, so it is necessary to build it from source.
It is distributed with a Makefile, which can be built with Visual Studio's nmake
tool. To build it, start the Visual Studio 'Developer Command Prompt' and enter the directory containing the vasm source, and then execute these commands:
makedir obj_win32
nmake -f Makefile.Win32 CPU=m68k SYNTAX=mot
This generates the executable vasmm68k_mot_win32.exe
, which can be used to create a ROM file.
We can test the assembler with a simple program:
move.w #7,d0
A single instruction that sets register D0 to the value 7.
Assemble it using this command:
vasmm68k_mot_win32 -Fbin test.asm -o test.bin
The result is a 4 byte file test.bin
:
Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 00000000 30 3C 00 07 0<..
Generated by HxD