Jump to content

User:Shadowboxer2005/Genesis Homebrew Development

From Wikipedia, the free encyclopedia
A Model 1 Sega Genesis, released in North America in 1989.

The Sega Genesis, known internationally as the Sega Mega Drive and the Super Gam*Boy/Super Aladdin Boy in Korea is a 16-bit fourth generation home console released in 1988 in Japan, 1989 in North America and 1990 elsewhere; it is Sega's third console acting as the successor to the SG-1000 and Master System, alongside being the rival to the Super Nintendo Entertainment System, which was released the following year.

In Japan, the system performed poorly against the Super Nintendo and the PC Engine (TurboGrafx-16), but was a large success internationally selling 30 million units and lasting until 1997.

Memory locations

[edit]
Start address End address Description
$000000 $3FFFFF Cartridge ROM/RAM
$400000 $7FFFFF Reserved, used by the Sega CD and 32X
$800000 $9FFFFF Reserved, used by the 32X
$A00000 $A0FFFF Z80 memory
$A10000 $A10001 Version register
$A10002 $A10003 Controller 1 data
$A10004 $A10005 Controller 2 data
$A10006 $A10007 Expansion port data
$A10008 $A10009 Controller 1 control
$A1000A $A1000B Controller 2 control
$A1000C $A1000D Expansion port control
$A1000E $A1000F Controller 1 serial transmit
$A10010 $A10011 Controller 1 serial receive
$A10012 $A10013 Controller 1 serial control
$A10014 $A10015 Controller 2 serial transmit
$A10016 $A10017 Controller 2 serial receive
$A10018 $A10019 Controller 2 serial control
$A1001A $A1001B Expansion port serial transmit
$A1001C $A1001D Expansion port serial receive
$A1001E $A1001F Expansion port serial control
$A10020 $A10FFF Reserved
$A11000 Memory mode register
$A11002 $A110FF Reserved
$A11100 $A11101 Z80 bus request
$A11102 $A111FF Reserved
$A11200 $A11201 Z80 reset
$A11202 $A12FFF Reserved
$A13000 $A130FF TIME registers; used to send signals to the cartridge
$A130F1 SRAM access register
$A130F3 Bank register for address $80000-$FFFFF
$A130F5 Bank register for address $100000-$17FFFF
$A130F7 Bank register for address $180000-$200000
$A130F9 Bank register for address $200001-$27FFFF
$A130FB Bank register for address $280000-$2FFFFF
$A130FD Bank register for address $300000-$37FFFF
$A130FF Bank register for address $380000-$3FFFFF
$A14000 $A14003 TMSS "Sega"
$A14101 TMSS/cartridge register
$A14102 $BFFFFF Reserved
$C00000 $C00001 VDP data port
$C00002 $C00003 VDP data port (mirror)
$C00004 $C00005 VDP control port
$C00006 $C00007 VDP control port (mirror)
$C00008 $C00009 VDP H/V counter
$C0000A $C0000F VDP H/V counter (mirror)
$C00011 PSG output
$C00013 $C00017 PSG output (mirror)
$C0001C $C0001D Debug register
$C0001E $C0001F Debug register (mirror)
$C00020 $FEFFFF Reserved
$FF0000 $FFFFFF 68000 RAM

Table was copied from Sega Mega Drive/Memory map at Sega Retro, which is released under a Creative Commons Attribution 4.0 International license.

Basic Crap

[edit]

TradeMark Security System

[edit]

The TradeMark Security System (TMSS) is a feature not present in earlier models of the Genesis, that essentially prevents both piracy and unlicensed games playing on the system; despite this, Sega chose not to enforce it after losing a 1993 court case with Accolade, meaning any developer could make a game for the system without Sega's knowledge.

Due to $A14000 being reserved on earlier models, using the address could potentially crash the system, so the following code must be used (note that the 'SEGA' portion needs to be at address $100 in the ROM):

         move.b  $A10001,d0
         andi.b  #$0F,d0
         beq.b   version_0
         move.l  #'SEGA',$A14000
version_0:

Video Display Processor (VDP)

[edit]

The Video Display Processor (VDP) is exactly what it sounds like (well, it's actually a chip, not a processor); it processes the graphics, sprites and plane mappings on screen.

Resolution

[edit]

Japanese and North American model machines support three resolutions; the first one is 320x224, which is utilized the most and is the default, the second one is 256x224, which is often used for when more complex graphics are involved, and the final is 320x448, an interlaced display that essentially doubles the screen's y-resolution (although many monitors would just squish it back to 224 pixels; several games would use this for two-player mode).

The European model also supports these resolutions, however due to monitors in Europe having a higher resolution, this means that it is capable of displaying 8 more pixels on the top and bottom, resulting in a full 240p resolution (or 320x480 when interlaced); despite this, very few games took advantage of this higher resolution, which essentially made unoptimised games look "stretched" on a European analog TV.

Colors

[edit]

The Genesis uses a 9-bit RGB (red, green, blue) color palette, meaning that 9-bits are allocated to each specific pixel, and could theoretically allow up to 512 colors (1500 with shadow/highlight mode); however, since the Genesis only allows for 4 color palettes at once (each containing 16 colors), and since the first color for each 'palette line' is transparent, this only allows for 61 colors on screen.

With these limitations in mind, the following image would be possible by using several layering affects, and the color table below shows all the possible colors to be chosen:

The 32X, on the other hand, allows for 15 bits per pixel (15-bit RGB, also known as "High-Color"), with all 32,768 colors being able to be display at once; this results in the image/color table below.

That's not all though; several games on the Genesis managed to display beyond 61 colors at once; this is done by swapping the colors on the vertical interrupts (several games also do this on the horizontal interrupts); as a side effect, this results in some minor VRAM dots appearing where the palette changes occur, alongside some slightly imperfections in the V.I. swap.

Video Random Access Memory (VRAM)

[edit]

Video Random Access Memory (VRAM) is the area in memory graphics and plane mappings are stored; it is only capable of storing 8x8 tiles; although it could technically allow up to $FFFF (65535) tiles at once, $C000 and $E000 are generally reserved for plane mappings.

Graphics Planes

[edit]

The Sega Genesis has three graphics planes:

  • Sprite layer - This is where all the in-game sprites (movable graphics/objects) are displayed; unless programmed, this will be displayed on top of everything, and has 8 possible layers; 0 will cause it to display above all objects, and 7 will cause it to display behind all objects.
  • Plane A layer - Most often used for platforming games for level layouts, and/or text.
  • Plane B layer - Most often used for backgrounds, displays behind everything; although normally static, they can be programmed to scroll at different speeds, thus giving the illusion of depth.

Sprites

[edit]

The Genesis is able to display up to 80 sprites at once, although only a maximum of 20 can be displayed on any given scanline without causing sprite flickering; very few games end up reaching this limit to preserve the framerate.