What's new

Sega Genesis / Mega Drive

CHR15x94

Local nut
Since the stickied threads cover most of the popular 8-bit systems, I thought it might be neat to open one up that goes a bit further, stepping up to the 16-bit era of consoles. I highly recommend doing an emulator or two before even attempting a Genesis emulator (or any other 16-bit+ console), as the Genesis drives up the complexity quite a bit.

Overview:
The Sega Genesis (or Sega Mega Drive) is the successor to the Sega Master System. It provides backwards compatibility with most Master System software except for an odd feature or two, namely the exception of some video modes that were removed in the Genesis, although these modes were very rarely (if ever) used by licensed software on the SMS. Compatibility is provided through secondary chips, and a similar graphic processor.

Specifications:
Let's just cut to the chase, the system specifications:

Code:
CPUs:  - Morotola 68000         @ 7.67MHz  (main system processor)
       - Z80                    @ 3.58MHz  (co-processor, sound controller, SMS compatibility)
Sound: - Yamaha YM2612          @ 7.67MHz  (sound generator)
       - TI SN76489 PSG         @ 3.58MHz  (secondary sound generator, SMS compatibility)
Video: - VDP [TI TMS9918 based] @ ??       (video generator, based off of SMS VDP)
RAM:   - 64KiB WRAM  (for 68000)
       - 64KiB VRAM  (for VDP)
       - 8KiB WRAM   (for Z80, SMS compatibility)

VDP Video Modes:
As mentioned, the Genesis does not posses all the video modes of the SMS. Video modes 0 - 3 are not supported by the Genesis's VDP. They are original video modes of the TI TMS9918 (chip the VDP is derived from). They are VERY rarely used.

This is more of an assumption than anything, but I believe only a few select unlicensed SMS games make use of video modes 0 - 3, this being that video mode 4 (SMS mode) would have been proprietary, and it's info released under NDA, unlike 0 - 3 which would have had their info publicly available.

So, video modes 0 - 3 are original TI TMS9918 modes and are not supported by the Genesis, only video modes 4 (SMS mode) and 5 (Genesis mode) are supported.

Sound:
There are two sound generators, the Yamaha YM2612, which is the primary sound generator of the Genesis, and the TI SN76489 PSG, which is mainly used for SMS compatibility.

The TI SN76489 PSG has four channels, three tone channels and one white noise channel. The tone channels are programmed by setting a 10-bit value. This value decrements and when it hits 0, a part of a tone is output and the value set to the original value. So, setting the 10-bit value to a larger number will result in the PSG taking longer to update the output tone, resulting in a lower output frequency.

The noise channel is programmed by setting the output noise type (white or periodic) and then selecting the playback frequency. Note that volume is controlled by four attenuators, one for each channel. They specify sound volume.

The PSG is quite simple to program and to emulate. This is why the SMS is often used as an intro to sound emulation. For more info on the PSG, see the gensound.txt in the Emu-Docs link below, or search for Genesis or SMS sound documents online.

- - -

The Yamaha YM2612 is the primary sound generator of the Genesis. It has 6 FM channels, one of which can be used as a PCM channel.

Each channel has an overall frequency (from what I understand, more of an average/middle point frequency). This frequency, as well as the output sound is modified by four 'operators'. Each channel has four operators which can be linked in various ways, which together modify the output. Each operator has it's own frequency (an offset of the overall frequency) and an envelope.

The operators can be chained together in eight different ways, each setup known as an algorithm. The algorithms create different sounds, and can be made to sound like several different instruments by adjusting the algorithm number, frequency and envelope.

The sixth channel can be switched to a PCM channel by enabling the DAC through the 'DAC enable' register. This means channel six will act ONLY as a PCM channel, unless you turn the DAC off. You cannot use PCM and FM simultaneously on the sixth channel.

For those of you who are lost (*cough*), some of the following might help you understand sound engineering's cryptic terms:

My understanding of the YM2612 is a little fuzzy (because my understanding of sound is a little fuzzy :p) and only explains the basics of how it works. This page on SMSPower.org's Genesis section explains it quite well and is where this info is from. It also explains the various registers of the YM2612, and what the various algorithms sound like.

Timings:
Well then, timings for PAL and NTSC consoles (exact):
Code:
PAL:
  Master: @53.2034MHz    (Clock speed for all components derived from this)

  68000:  @7.600485MHz   (Master / 7)
  Z80:    @3.54689MHz    (Master / 15)
  YM2612: @7.600485MHz   (Same as 68K clock)
  PSG:    @3.54689MHz    (Same as Z80 clock)
  VDP:    @?
Code:
NTSC:
  Master: @53.6931MHz

  68000:  @7.670442MHz
  Z80:    @3.57954MHz
  YM2612: @7.670442MHz
  PSG:    @3.57954MHz
  VDP:    @?
This is the master clock I found on several websites. I couldn't find anything more precise, so these clock values are probably off by a few ticks.

Now for the VDP's timings:

Code:
NTSC:
  TODO
Code:
PAL:
  TODO

Memory Maps:
The Genesis has two memory maps, one for the 68000 and one for the Z80. The Z80's map is obviously a bit limited since the address bus is only 16-bits in size, while the 68000's is 24-bits. Anyways, here's the maps for both:
Code:
68000:
  $000000 - $3FFFFF : ROM
  $400000 - $7FFFFF : Unused
  $800000 - $9FFFFF : Unused (used for 32X connectivity)
  $A00000 - $A0FFFF : Z80 address space
  $A10000 - $A1001F : I/O
  $A10020 - $BFFFFF : Internal registers and expansion
  $C00000 - $DFFFFF : VDP
  $E00000 - $FFFFFF : WRAM (68000)
Code:
Z80:
  $0000 - $1FFF : WRAM (Z80)
  $2000 - $3FFF : WRAM mirror (Z80)
  $4000 - $5FFF : YM2612
  $6000 - $60FF : Bank address register
  $6100 - $7EFF : Unused
  $7F00 - $7FFF : VDP
  $8000 - $FFFF : Bank area
Note that most Genesis game cartridge contain only a ROM chip. There is rarely a memory controller/mapper used, although there are a few games that do. For example, writes to the ROM area which is then deciphered by the mapper and treated as a write to SRAM, located in the cartridge.

Useful links:
Emu-Docs.org Genesis page

Conclusion/Closing:
Hopefully some of you find this interesting. I think I'm going to give a Genesis emulator a shot. It's been about a year since I did any serious programming, have been just browsing over other projects and what not. Have been feeling really uninspired.

I used to play on a Genesis all the time when I was younger with friends, was always a great, solid system with lot's of fun games (Sonic the Hedgehog 2 and Golden Axe FTW).

I'm quite busy with school and what not, so I don't always have as much free time. Hope to get started on the emulator within a week. If anyone else wants to work on one, be sure to post your progress here. =]


- CHR15x94
 
Last edited:

Top