(:title BIOSes:) (:toc:) !!Overview Some Sega systems include a simple BIOS to handle the boot process, display a bumper screen, display instructions/error screens and provide built-in games - or a subset of these. This page describes the behaviour of the various BIOS software known to exist. !!Master System !!!M404 Prototype BIOS ||border=0 align=right width=1 || Attach:m404biosbumper.gif"M404 Prototype BIOS bumper screen" || || M404 Prototype BIOS bumper screen || This BIOS was dumped from a prototype Master System originally sent to Sega of America. Its functionality is quite different from any other BIOS: * It has a much more impressive bumper screen than other non-Japanese BIOSes * It checks for the string "@@COPYRIGHTSEGA@@" at offset $7fe0 * It checks for the string "@@COPYRIGHT SEGA@@" at offset $7fe0 * It checks if the VBlank handler at offset $0038 matches the code @@jp $00c8@@ * It checks on all three slots, the same as other BIOSes * It does not do any region checking None of this functionality interferes with the operation of other BIOSes' checks of the header at $7ff0, which may or may not have been deliberate. Only two games are known to boot with this BIOS: the Japanese version of [[Games/Fantasy Zone(-SMS)]], and [[Games/Choplifter(-SMS)]]. These are known to be two of the earliest games developed for the Master System. * [[(Attach:)SMS_Prototype_M404_BIOS.zip]] !!!Prototype BIOS v1.0 (1986) This BIOS is found in some [[ForumTopic:13236|prototype/demonstration Master System consoles]] and is very similar to the 1.3 BIOS but lacks: * Animated SEGA / Master System bumper screen; it just appears. This BIOS also contains the sound data for an early version of the Sega two-tone "jingle", but it doesn't sound right/finished. * Sound (the entire sound engine code is there, and is almost exactly the same as in 1.3. It is never called though...) * Snail Maze game (the game songs are all present, and are almost exactly the same as in 1.3, but the rest of the game is not there) * Instruction screen when no game is found. Instead, it displays a simple error screen that just contain the strings "MASTER SYSTEM (c) SEGA 1986", "S/R V1.0", and a blinking "?" If the checksum test fails, there is an extra "CHECK SUM ERROR" string before the "?" Other small differences from 1.3: * The detection code is copied and called earlier, and instead of the fixed wait of ~1.67s in 1.3, there is a variable wait based on the size of the ROM detected: no ROM: ~1.67s, 8KB => 1.55 s, 16KB => 1.43 s, 32KB => 1.19 s, 48KB => 0.95 s, 64+KB => no wait * The ROM detection port is the same as 1.3, except it doesn't read port $dc, and doesn't distinguish between "no ROM" and "invalid region ROM" * No reset button handler * The frame interrupt handler is never called, as the interrupt is never enabled * Data for the SEGA and Master System logos are stored uncompressed (the Phantasy Star Tile Decoder code is not present) * It doesn't store the commonly used VDP routines (WriteVRAMByte, etc.) at the beginning of the ROM to take advantage of the rst opcodes * [[(Attach:)sms_prototype_v1.0-proto-bios-sms.zip]] * [[https://github.com/maxim-zhao/smsbioses/blob/master/1.0/Bios10.asm | bios10.asm]] (Commented disassembly by [[~segmtfault]]) [[#Exp13]] !!!US/European BIOS v1.3 (1986) This BIOS checks to see if any of the available slots ([[CardSlot|card]], [[CartridgeSlot|cartridge]] or [[SMSExpansionPort|expansion]], in that order) have anything attached to them, and boots the first available. This is done using [[port $3E]] to map different slots into memory, and checks to determine if valid data was found in any slot. ||border=0 align=right width=1 || Attach:usbiosbumper.gif"US/European BIOS bumper screen" || || US/European BIOS bumper screen || The first thing it does is display an animated bumper screen, as shown on the right. While this is animating, the Sega two-tone "jingle" is played. This is purely to reinforce the Sega Master System brand. It then checks the slots in turn. For each slot, 16 bytes are copied to RAM and checked if they contain a valid [[ROM header]]. It does this from offsets $7ff0, $3ff0 and $1ff0 in turn. Note that it does not initialise any paging registers: any [[mapper]] must present data at the required addresses in its initial state. In particular, this means that when the header is at $7ff0 (as in all released games), the mapper must initialise slot 1 with bank 1 (if slots/banks are 16KB). It checks to see if the first eight bytes match the ASCII string "@@TMR SEGA@@"; if so, it proceeds to further tests. If no header is found at any of the three locations, the slot is assumed to be empty. The next check is the region: if the high four bits of the last byte of the header do not equal 4, it is rejected with a "SOFTWARE ERROR" message. [[#checksum]]Finally, it checks the checksum using this code: (:source lang=z80:)[@ Checksum: ld a,e ; add (hl) to de add (hl) ld e,a ld a,d adc $00 ld d,a inc hl ; move pointer on and decrement counter dec bc ld a,b ; repeat until counter is zero or c jr nz,Checksum ret @] It sums @@bc@@ bytes from offset @@hl@@ into @@de@@. This is used to checksum different regions of ROM according to the ROM header. A lower region is checked, intended to cover all of the ROM before the header (last 16 bytes); an upper region is then checked (if applicable) assuming a standard Sega [[mapper(s)]]. The lower four bits of the last byte of the header define the regions checked: ||border=1 ||!Value||!Lower region checked||!Upper region checked||!Total size|| || $a || $0000..$1FEF || n/a || 8KB || || $b || $0000..$3FEF || n/a || 16KB || || $c || $0000..$7FEF || n/a || 32KB || || $d || $0000..$BFEF || n/a || 48KB || || $e || $0000..$7FEF || $8000..$0FFFF || 64KB || || $f || $0000..$7FEF || $8000..$1FFFF || 128KB || || $0 || $0000..$7FEF || $8000..$3FFFF || 256KB || || $1 || $0000..$7FEF || $8000..$7FFFF || 512KB || || $2 || $0000..$7FEF || $8000..$FFFFF || 1024KB || || $3..$9 || Not supported |||||| If the calculated value does not match the one in the header, a "SOFTWARE ERROR" message is again shown. Otherwise, the slot is booted. ||border=0 align=right width=1 || Attach:usbiosscreenshot.png"US/European BIOS screenshot" || || US/European BIOS screenshot || The last value written to [[port $3E]] is also saved in RAM location $c000 (the first byte of RAM). This allows software released in more than one format to safely use port $3E, if necessary, by using this value to correctly re-enable the slot it booted from. If all slots are found to be empty, an instructional screen is shown. While it is showing, it is possible to press a key combination ([U]+[1]+[2] on the Player 1 controller; additional buttons may also be pressed and it will still work) to trigger a "secret" Snail Maze game. * [[(Attach:)BIOS13FX.ZIP]] * [[(Attach:)BIOS13.ZIP]] (Hacked BIOS to function as a game ROM) * [[(Attach:)bios13.asm]] (Commented disassembly by [[~Bock]]) * [[https://github.com/maxim-zhao/smsbioses/blob/master/1.3/Bios13.asm | bios13.asm]] (Commented disassembly by [[~segmtfault]]) [[<<]] !!!Uncommon BIOS v2.0 (1987) This BIOS is an uncommon variation of v1.3 which was discovered c. 2014. (cf. discussion [[http://www.smspower.org/forums/15172-SMSBIOSVersion20 | here]] ) The only major difference with v1.3 is the cartridge detection code, which doesn't do any ROM header or checksum verification. Instead it just checks that the first 513 bytes of ROM are not identical. As such, it behaves like a Japanese SMS and allows for booting cartridges that don't read properly (they would crash) or Japanese titles (via a custom made adapter for cartridge, or cards). So this is a cool side effect. Here is the code: (:source lang=z80:)[@ FirstBlockCheck: ld hl, $0000 ld bc, $0201 ld de, ROM_FirstBlockCopy ; copy in RAM the first 513 bytes of the potential ROM location ldir ld a, (ROM_FirstBlockCopy) ; and we are going to compare the 1st byte with the next 512 ld hl, ROM_FirstBlockCopy+1 ; we will consider it a valid ROM if the 513 bytes don't all ld bc, $0200 ; contain the exact same value (so this BIOS can boot Japanese ROMs!) BlockCheckLoop: cpi jr nz, BlockCheckSuccess ; at least one byte of the block doesn't match the first! jp po, BlockCheckLoop ; if we haven't checked all the bytes yet, loop ret ; check failed @] One interesting bug in this code is that the first ROM block is copied in RAM at almost the same address as the RAM copy of the Snail Maze game's tilemap. This causes a visual glitch on the top corners of the maze when run on real hardware ([[http://www.smspower.org/forums/download.php?id=7621| photo 1]] , [[http://www.smspower.org/forums/download.php?id=7620 | photo 2]] ) Other minor differences from v1.3: * The code that starts the game when detected now zeroes the sprite palette * Removed unnecessary di instruction after the call to the detection code in RAM * In the instruction screen tile map, changed "V1.3" to "V2.0" * Removed 6 data bytes that were unused in 1.3 (these were the variable wait times values used in 1.0) * [[https://github.com/maxim-zhao/smsbioses/blob/master/2.0/Bios20.asm | bios20.asm]] (Commented disassembly by [[~segmtfault]]) [[<<]] !!!Japanese BIOS v2.1 (1987) This BIOS is similar to the US BIOS, except that because there was no header requirement for Japanese games, especially with legacy [[Hardware/SG-1000]] software to be supported, this checking has to use a less precise method: it checks to see if there is variation in the data read. It uses this code: (:source lang=z80:)[@ CheckSlot: ld hl,$0000 ; look at ROM from $0000 ld bc,$003c ; loop 256 times, mask $3c ld a,(hl) ; get byte and c ; and with $3c = %00111100 ld e,a ; store in e Loop: ld a,(hl) ; get byte inc l ; pointer++ and c ; and with $3c cp e ; compare to first byte jp nz,$0000 ; if not equal, run slot djnz Loop ; repeat 256 times ret ; Nothing found @] It checks if there is any variation in the middle four bits of the first 256 bytes in each slot and passes execution to the code in that slot if any variation is found. It may be presumed that the hardware ensures that at least these four bits are held constant for all slots when not connected to anything. ||border=0 align=right width=1 || Attach:japanesebiosscreenshot.gif"Japanese BIOS screenshot" || || Japanese BIOS screenshot || If it does not find anything in any of its slots it shows an instructional screen, with the text: >>frame font-size=x-large padding=1em<< 電源をOFFにして, ソフトを入れてください。 >><< Translation: "Turn the power switch to OFF, then please insert some software." It animates the screen while playing the main theme from "Space Harrier" on both the [[PSG]] and the [[YM2413]] simultaneously. This BIOS was also used in the Korean Samsung Gam-Boy console, but since that console does not have a YM2413, the FM portion is silent. ROM part code: MPR-11124 Dumped by Hiroshi. * [[(Attach:)MPR11124.ZIP]] * [[(Attach:)MPR11124.ASM]] (Commented disassembly by [[~Bock]]) !!!US/European BIOS v2.4 with Hang On and Safari Hunt (1988) This BIOS shows the same bumper screen as the US v1.3 BIOS (except the date is changed to 1988). If, at the end of this phase, buttons [U]+[1]+[2] are pressed on controller 1, it runs the same "Snail Maze" secret game as the US/European Master System BIOS v1.3 and 2.0. If not, it checks for valid data on the three slots. This aspect of its operation is almost identical to the US/European Master System BIOS v1.3. However, due to an overzealous optimization in that version (where an opcode's first byte is used as the last byte of the lookup table preceding it), which was overlooked in this version, the $2 checksum range will not be correctly summed. It additionally includes support in the checksum routines to save and restore the current [[Mappers|mapped bank]] (assuming a Sega mapper). If no game is found, instead of showing an information screen, it runs a copy of [[Games/Hang On and Safari Hunt(-SMS)]] built into the BIOS ROM. This game has plenty of unused space for the BIOS routines to be added. ROM part code: MPR-11459A Dumped by Mike Gordon. This is a 128K ROM requiring slot 2 mapping. * [[(Attach:)HSHBIOS.ZIP]] !!!US/European BIOS v3.4 with Hang On (1988) This BIOS functions identically to US/European BIOS v2.4 with Hang On and Safari Hunt, except that its built-in game is [[Games/Hang On(-SMS)]]. This game is small so most of the BIOS ROM is blank. ROM part code: MPR-11458 Dumped by Mike Gordon. This is a 128K ROM requiring slot 2 mapping. * [[(Attach:)HANGBIOS.ZIP]] !!!US/European BIOS v4.4 with Missile Defense 3-D (1988) This BIOS functions almost identically to US/European BIOS v2.4 with Hang On and Safari Hunt, except that its built-in game is [[Games/Missile Defense 3D(-SMS)]]", and it does not feature the "Snail Maze" secret game. It was only included with some the "Super System" packages (including 3-D glasses and a [[light phaser]]); some of these packages instead had another BIOS and [[Games/Missile Defense 3D(-SMS)]] as a separate cartridge. The "Snail Maze" game was probably removed due to lack of space; "Missile Defense 3-D" does not have as much unused space as "Hang On and Safari Hunt". ROM part code: MPR-11460 * [[(Attach:)Missile_Defense_3D_BIOS.ZIP]] !!!US/European BIOS with Alex Kidd in Miracle World (1990) ||border=0 align=right width=1 || Attach:akbiosbumper.png"US/European BIOS with Alex Kidd in Miracle World bumper screen" || || US/European BIOS with Alex Kidd in Miracle World bumper screen || This BIOS features a different bumper screen to previous versions, with just a static Sega logo and no sound. It does not feature the "Snail Maze" secret game. Its checking routines are almost identical to those of the US/European BIOS v4.4. The built-in game is now [[Games/Alex Kidd in Miracle World(-SMS)]]. The $2 checksum range bug is fixed, even though the previously released incompatible BIOSes meant that it could not be used. The removed items ("Master System" logo, animation, music, "Snail Maze" game) meant that the checksumming code was minimised and was more feasible to insert into unused space in game with an almost-full ROM. The game is almost the same as the cartridge version, except that: * The title screen copyright date is 1990 instead of 1986 * The rice cake Alex Kidd eats before each level was changed to a hamburger (to better suit Western audiences) * The jump and punch buttons were reversed (to the more common layout where 2 = jump) This BIOS was used in later VA3 PAL model 1 consoles and most Master System II consoles. It was also used in the Brazilian Master System II, which despite the name is actually a revised model 1. ROM part code: MPR-12808 Dumped by Mike Gordon. This is a 128K ROM requiring slot 2 mapping. * [[(Attach:)AKBIOS.ZIP]] !!!European BIOS with Sonic The Hedgehog (1992) ||border=0 align=right width=1 || Attach:sonicbiosbumper.png"European BIOS with Sonic the Hedgehog bumper screen" || || European BIOS with Sonic the Hedgehog bumper screen || This BIOS displays a slightly different bumper screen to "US/European BIOS with Alex Kidd in Miracle World", and again with no logo animation, music or "Snail Maze" game for the same reasons. the built-in game is now [[Games/Sonic The Hedgehog(-SMS)]]. Its checksumming routines seem to be taken from the US/European Master System BIOS v1.3 - they do not feature any of the later changes, and the $2 checksum range bug is not found. It is worth noting that this BIOS was only featured in Master System II systems. These consoles have no card or expansion slots but it attempts to check them anyway. The game itself is slightly different from the cartridge version - to make room for the BIOS routines, the credits have been removed. ROM part code: MPR-15155 This is a 256K ROM requiring mapping in both slot 1 and slot 2. * [[(Attach:)SONBIOS.ZIP]] !!!Korean Samsung Gam*Boy/Aladdin Boy II BIOS with Alex Kidd in Miracle World The BIOS detection code here has to take a similar approach to the Japanese BIOS, in that it cannot assume there will be a header in the ROM, so there is no checksum or region test. Because it is based on different hardware from the Japanese system (an SMS2 variant), it can take a simpler approach: it assumes that unconnected slots will have their data lines tied high, so it checks if there is any non-@@$FF@@ data in the first 16 bytes of each slot. Similar to the Sonic BIOS, it checks all three slots (card, cartridge and expansion) even though two of them are not implemented in the hardware. * [[(Attach:)Alex_Kidd_in_Miracle_World_KR_BIOS.ZIP]] !!Game Gear ||border=0 align=right width=1 || Attach:ggbiosbumper.png"Game Gear BIOS bumper screen (GG mode)" || || Game Gear BIOS bumper screen \\ (GG mode) || || Attach:ggbiosbumpersms.png"Game Gear BIOS bumper screen (SMS mode)" || || Game Gear BIOS bumper screen \\ (SMS mode) || !!!No BIOS Early Game Gear systems with the VA0 board revision have no BIOS. !!!TMSS Game Gear BIOS This BIOS writes and reads two bytes to and from port $02, in order to detect if it is in GG mode or SMS mode so it can use the correct palette data. In GG mode, this port is for the [[Gear to Gear Cable]], and reading it returns what was written; in SMS mode, its use is uncertain, but it seems from the BIOS that it returns something other than what was written. It then checks the cartridge at offsets $7ff0, $3ff0 and then $1ff0 for the ASCII string "@@TMR SEGA@@". If it is found, it turns on the screen to show a bumper screen with the text "PRODUCED BY OR UNDER LICENSE FROM SEGA ENTERPRISES, LTD." as shown on the right; it then pauses for a few seconds before running the game. If the text is not found, the screen is left turned off and the system is locked up. This is similar behavior to the TradeMark Security System scheme used in most Mega Drive/Genesis consoles. This BIOS was implemented with the VA1 board revision introduced in 1992, but was left disabled on early VA1s with a jumper. By 1993, this jumper was left unpopulated, enabling the BIOS. It is also present on all later Game Gear board revisions. * [[(Attach:)MAJBIOS.ZIP]] * [[(Attach:)majbios.asm]] (Commented disassembly by [[~Bock]]) [[<<]] !!SF-7000 See the [[SF-7000 IPL]]. * [[(Attach:)SF-7000 Initial Program Loader ROM.zip]] !!Other systems All other Sega 8-bit home systems (SG-1000, SC-3000, Mark III) have no BIOS. Some Mega Drive piracy devices have a boot ROM that runs in SMS mode: * [[(Attach:)MDPBIOS.ZIP]] ** Super Magic Drive BIOS v3 ** Dumped by Mike Cukan. ** The BIOS contains the following string: -->[@ *** MAGIC DRIVER V-3 *** PRODUCT MANAGER: LMM, DEBUG ENGINEER: JUS, BIOS PROGRAMMER: JSI, ALL RIGHTS RESERVED, COPYRIGHT 1991 BY JSI, CHINA COACH COMPANY LTD., FRONT FAREAST CORPORATION. 8/17/91 @] * [[(Attach:)SMD31G.ZIP]] ** Super Magic Drive BIOS v3.1G ** Dumped by dhau. ** The BIOS contains the following string: -->[@ *** MAGIC DRIVE V3.1 *** PRODUCT MANAGER: LMM, DEBUG ENGINEER: JUS, BIOS PROGRAMMER: JSI, FRONT FAREAST CORPORATION. @] * [[(Attach:)SMD4_1A.ZIP]] ** Super Magic Drive BIOS v4.1A ** Dumped by Eunos. ** The accompanying text file claims this is for a 24MBit version of the copier. The BIOS contains the following string: -->[@ * MAGIC DRIVE BIOS * COPYRIGHT BY JSI/FRONT FAREAST CO. 93-12-07 @] The Power Base Convertor contains a PAL chip that acts like a very small (42 bits) BIOS. It sets the stack pointer and value at $c000 such that some games can work that would otherwise fail. See [[ForumTopic:14084|this forum topic]] for details. !!Feature Overview Here is a table of the features/behaviours of the various BIOSes: ||border=1 ||!BIOS ||! Snail maze ||! Required string ||! Checks region ||! Checks checksum ||! Slots ||! $2 range bug ||! Header locations || ||!M404 prototype || Attach:Site/Cross.png || COPYRIGHT SEGA || Attach:Site/Cross.png || Attach:Site/Cross.png || Card, Cart, Exp || n/a || $7fe0 || ||!1.0 (Prototype) || Attach:Site/Cross.png || TMR SEGA || Attach:Site/Tick.png || Attach:Site/Tick.png || Card, Cart, Exp || Attach:Site/Cross.png || $7ff0, $3ff0, $1ff0 || ||!1.3 (US/EU) || Attach:Site/Tick.png || TMR SEGA || Attach:Site/Tick.png || Attach:Site/Tick.png || Card, Cart, Exp || Attach:Site/Cross.png || $7ff0, $3ff0, $1ff0 || ||!2.0 (???) || Attach:Site/Tick.png || Attach:Site/Cross.png || Attach:Site/Cross.png || Attach:Site/Cross.png || Card, Cart, Exp || n/a || n/a || ||!2.1 (JP) || Attach:Site/Cross.png || Attach:Site/Cross.png || Attach:Site/Cross.png || Attach:Site/Cross.png || Card, Cart, Exp || n/a || n/a || ||!2.4 (Hang On/Safari Hunt) || Attach:Site/Tick.png || TMR SEGA || Attach:Site/Tick.png || Attach:Site/Tick.png || Card, Cart, Exp || Attach:Site/Tick.png || $7ff0, $3ff0, $1ff0 || ||!3.4 (Hang On) || Attach:Site/Tick.png || TMR SEGA || Attach:Site/Tick.png || Attach:Site/Tick.png || Card, Cart, Exp || Attach:Site/Tick.png || $7ff0, $3ff0, $1ff0 || ||!4.4 (Missile Defense 3-D) || Attach:Site/Cross.png || TMR SEGA || Attach:Site/Tick.png || Attach:Site/Tick.png || Card, Cart, Exp || Attach:Site/Tick.png || $7ff0, $3ff0, $1ff0 || ||!Alex Kidd in Miracle World || Attach:Site/Cross.png || TMR SEGA || Attach:Site/Tick.png || Attach:Site/Tick.png || Card, Cart, Exp || Attach:Site/Cross.png || $7ff0, $3ff0, $1ff0 || ||!Sonic The Hedgehog || Attach:Site/Cross.png || TMR SEGA || Attach:Site/Tick.png || Attach:Site/Tick.png || Card, Cart, Exp || Attach:Site/Cross.png || $7ff0, $3ff0, $1ff0 || ||!Alex Kidd in Miracle World (KR) || Attach:Site/Cross.png || Attach:Site/Cross.png || Attach:Site/Cross.png || Attach:Site/Cross.png || Card, Cart, Exp || n/a || n/a || ||!Game Gear || Attach:Site/Cross.png || TMR SEGA || Attach:Site/Cross.png || Attach:Site/Cross.png || Cart || n/a || $7ff0, $3ff0, $1ff0 ||