SMS: initial support for SMS BIOSes. Some future work is pending regarding when to use what bios or no bios. (hooray regions)

This commit is contained in:
beirich 2014-03-05 05:09:20 +00:00
parent 1b3009d849
commit 9a59155177
4 changed files with 61 additions and 38 deletions

View File

@ -103,10 +103,14 @@ namespace BizHawk.Emulation.Common
// SMS // SMS
var sms_us_13 = File("C315672807D8DDB8D91443729405C766DD95CAE7", "sms_us_1.3.sms", "SMS BIOS 1.3 (USA, Europe)"); var sms_us_13 = File("C315672807D8DDB8D91443729405C766DD95CAE7", "sms_us_1.3.sms", "SMS BIOS 1.3 (USA, Europe)");
var sms_jp_21 = File("A8C1B39A2E41137835EDA6A5DE6D46DD9FADBAF2", "sms_jp_2.1.sms", "SMS BIOS 2.1 (Japan)"); var sms_jp_21 = File("A8C1B39A2E41137835EDA6A5DE6D46DD9FADBAF2", "sms_jp_2.1.sms", "SMS BIOS 2.1 (Japan)");
Firmware("SMS", "SMS_US", "SMS Bios (USA)"); var sms_us_1b = File("29091FF60EF4C22B1EE17AA21E0E75BAC6B36474", "sms_us_1.0b.sms", "SMS BIOS 1.0 (USA) (Proto)");
Firmware("SMS", "SMS_JP", "SMS Bios (Japan)"); var sms_m404 = File("4A06C8E66261611DCE0305217C42138B71331701", "sms_m404.sms", "SMS BIOS (USA) (M404) (Proto)");
Option("SMS", "SMS_US", sms_us_13);
Option("SMS", "SMS_JP", sms_jp_21); Firmware("SMS", "SMSBIOS", "SMS Bios");
Option("SMS", "SMSBIOS", sms_us_13);
Option("SMS", "SMSBIOS", sms_jp_21);
Option("SMS", "SMSBIOS", sms_us_1b);
Option("SMS", "SMSBIOS", sms_m404);
} }
//adds a defined firmware ID to the database //adds a defined firmware ID to the database

View File

@ -17,25 +17,35 @@
const ushort BankSizeMask = 0x3FFF; const ushort BankSizeMask = 0x3FFF;
const ushort RamSizeMask = 0x1FFF; const ushort RamSizeMask = 0x1FFF;
bool BiosMapped { get { return (Port3E & 0x40) == 0x40; } }
byte ReadMemory(ushort address) byte ReadMemory(ushort address)
{ {
byte ret; byte ret;
if (address < 1024)
ret = RomData[address]; if (address < 0xC000)
else if (address < BankSize)
ret = RomData[(RomBank0 * BankSize) + address];
else if (address < BankSize * 2)
ret = RomData[(RomBank1 * BankSize) + (address & BankSizeMask)];
else if (address < BankSize * 3)
{ {
switch (SaveRamBank) if ((Port3E & 0x48) == 0x48) // cart and bios disabled, return empty bus
ret = 0xFF;
else if (BiosMapped && BiosRom != null)
ret = BiosRom[address & 0x1FFF];
else if (address < 1024)
ret = RomData[address];
else if (address < 0x4000)
ret = RomData[(RomBank0 * BankSize) + address];
else if (address < 0x8000)
ret = RomData[(RomBank1 * BankSize) + (address & BankSizeMask)];
else
{ {
case 0: ret = RomData[(RomBank2 * BankSize) + (address & BankSizeMask)]; break; switch (SaveRamBank)
case 1: ret = SaveRAM[address & BankSizeMask]; break; {
case 2: ret = SaveRAM[BankSize + (address & BankSizeMask)]; break; case 0: ret = RomData[(RomBank2 * BankSize) + (address & BankSizeMask)]; break;
default: case 1: ret = SaveRAM[address & BankSizeMask]; break;
ret = SystemRam[address & RamSizeMask]; case 2: ret = SaveRAM[BankSize + (address & BankSizeMask)]; break;
break; default:
ret = SystemRam[address & RamSizeMask];
break;
}
} }
} }
else else
@ -91,22 +101,20 @@
WriteMemory(0xFFFF, 2); WriteMemory(0xFFFF, 2);
} }
// Mapper when loading a BIOS as a ROM // Mapper when loading a BIOS as a ROM (simulating no cart loaded)
bool BiosMapped { get { return (Port3E & 0x08) == 0; } }
byte ReadMemoryBIOS(ushort address) byte ReadMemoryBIOS(ushort address)
{ {
if (BiosMapped == false && address < BankSize * 3) if ((Port3E & 0x08) != 0 && address < 0xC000)
return 0x00; return 0xFF;
if (address < 1024) if (address < 1024)
return RomData[address]; return RomData[address];
if (address < BankSize) if (address < 0x4000)
return RomData[(RomBank0 * BankSize) + address]; return RomData[(RomBank0 * BankSize) + address];
if (address < BankSize * 2) if (address < 0x8000)
return RomData[(RomBank1 * BankSize) + (address & BankSizeMask)]; return RomData[(RomBank1 * BankSize) + (address & BankSizeMask)];
if (address < BankSize * 3) if (address < 0xC000)
return RomData[(RomBank2 * BankSize) + (address & BankSizeMask)]; return RomData[(RomBank2 * BankSize) + (address & BankSizeMask)];
return SystemRam[address & RamSizeMask]; return SystemRam[address & RamSizeMask];

View File

@ -37,6 +37,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
public byte[] SaveRAM = new byte[BankSize * 2]; public byte[] SaveRAM = new byte[BankSize * 2];
public byte SaveRamBank; public byte SaveRamBank;
public byte[] BiosRom;
public byte[] ReadSaveRam() public byte[] ReadSaveRam()
{ {
if (SaveRAM != null) if (SaveRAM != null)
@ -192,11 +194,20 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
if (game["3D"]) if (game["3D"])
IsGame3D = true; IsGame3D = true;
if (game["BIOS"]) if (game["BIOS"])
{ {
Port3E = 0xF7; // Disable cartridge, enable BIOS rom Port3E = 0xF7; // Disable cartridge, enable BIOS rom
InitBiosMapper(); InitBiosMapper();
} }
else
{
BiosRom = comm.CoreFileProvider.GetFirmware("SMS", "SMSBIOS", false);
if (BiosRom != null) // && usebios
{
Port3E = 0xF7;
}
}
SetupMemoryDomains(); SetupMemoryDomains();
} }

View File

@ -54,8 +54,8 @@ B33817AE T Alex Kidd in Miracle World [v1] (FR) [A] SMS Floflo
5BCD77ED T Alex Kidd in Miracle World [v1] (IT) SMS 5BCD77ED T Alex Kidd in Miracle World [v1] (IT) SMS
2C08872B H Alex Kidd in Miracle World [Playpal hack] SMS Alex Kidd in Miracle World [v1]; hacked to make it compatible with the PlayPal/Coleco hardware 2C08872B H Alex Kidd in Miracle World [Playpal hack] SMS Alex Kidd in Miracle World [v1]; hacked to make it compatible with the PlayPal/Coleco hardware
CF4A09EA I Alex Kidd in Miracle World [BIOS] SMS BIOS CF4A09EA I Alex Kidd in Miracle World [BIOS] SMS BIOS
5C4CA816 H Alex Kidd in Miracle World [BIOS] [Game hack] SMS Alex Kidd in Miracle World [BIOS]; hacked to skip the BIOS checks and boot to the game 5C4CA816 H Alex Kidd in Miracle World [BIOS] [Game hack] SMS Alex Kidd in Miracle World [BIOS]; hacked to skip the BIOS checks and boot to the game BIOS
9C5BAD91 I Alex Kidd in Miracle World [BIOS] (KR) SMS 9C5BAD91 I Alex Kidd in Miracle World [BIOS] (KR) SMS BIOS
08C9EC91 Alex Kidd no Miracle World (JP) SMS 08C9EC91 Alex Kidd no Miracle World (JP) SMS
D2417ED7 Alex Kidd in Shinobi World SMS D2417ED7 Alex Kidd in Shinobi World SMS
2CD7DEC7 B Alex Kidd in Shinobi World (bad byte) SMS 2CD7DEC7 B Alex Kidd in Shinobi World (bad byte) SMS
@ -460,7 +460,7 @@ A77F996F F Hang On (BR) [A] (h) SMS
585C448A F Hang On (BR) [B] (h) SMS 585C448A F Hang On (BR) [B] (h) SMS
6F79E4A1 F Hang On (h) SMS 6F79E4A1 F Hang On (h) SMS
5C01ADF9 Hang On (JP) SMS 5C01ADF9 Hang On (JP) SMS
8EDF7AC6 I Hang On [BIOS] SMS 8EDF7AC6 I Hang On [BIOS] SMS BIOS
1C5059F0 Hang On & Astro Warrior (US) SMS 1C5059F0 Hang On & Astro Warrior (US) SMS
E167A561 Hang On & Safari Hunt SMS E167A561 Hang On & Safari Hunt SMS
C5083000 V Hang On & Safari Hunt (bad dump) SMS Blank 16KB from 1C000 to fix C5083000 V Hang On & Safari Hunt (bad dump) SMS Blank 16KB from 1C000 to fix
@ -611,7 +611,7 @@ EBC2BFA1 B Miracle Warriors - Seal of the Dark Lord (bad byte) SMS FM
F14A8546 F Miracle Warriors - Seal of the Dark Lord (h) (f) SMS FM F14A8546 F Miracle Warriors - Seal of the Dark Lord (h) (f) SMS FM
ED9FD67D T Miracle Warriors - Seal Of The Dark Lord (DE) SMS Azelistic; v0.95b FM ED9FD67D T Miracle Warriors - Seal Of The Dark Lord (DE) SMS Azelistic; v0.95b FM
FBE5CFBB Missile Defense 3-D SMS 3D FBE5CFBB Missile Defense 3-D SMS 3D
E79BB689 Missile Defense 3-D [BIOS] SMS 3D E79BB689 Missile Defense 3-D [BIOS] SMS 3D;BIOS
458390E7 H Monica 3 [A] SMS Wonder Boy in Monster World 458390E7 H Monica 3 [A] SMS Wonder Boy in Monster World
693C63D5 H Monica 3 [B] SMS Wonder Boy in Monster World 693C63D5 H Monica 3 [B] SMS Wonder Boy in Monster World
01D67C0B Monica no Castelo do Dragao (BR) SMS FM 01D67C0B Monica no Castelo do Dragao (BR) SMS FM
@ -904,11 +904,11 @@ A0440666 D SMS 3-D Demo SMS Chris Covell
350F7497 D SMS APA Demo [v0.01] SMS Haroldo O. Pinheiro 350F7497 D SMS APA Demo [v0.01] SMS Haroldo O. Pinheiro
E4CD2EDD D SMS APA Demo [v0.02] SMS Haroldo O. Pinheiro E4CD2EDD D SMS APA Demo [v0.02] SMS Haroldo O. Pinheiro
5AD6EDAC H SMS BIOS (US v1.3) [Hack] SMS SMS BIOS (US v1.3) to make it play the snail game when loaded as a ROM 5AD6EDAC H SMS BIOS (US v1.3) [Hack] SMS SMS BIOS (US v1.3) to make it play the snail game when loaded as a ROM
0072ED54 I SMS BIOS (US v1.3) SMS 0072ED54 I SMS BIOS (US v1.3) SMS BIOS
AD31C5FF D SMS Boot Loader SMS Bock; v0.9 AD31C5FF D SMS Boot Loader SMS Bock; v0.9
48D44A13 I SMS Japanese (v2.1) [BIOS] SMS BIOS;FM 48D44A13 I SMS Japanese (v2.1) [BIOS] SMS BIOS;FM
1A15DFCC I SMS Prototype (M404) [BIOS] SMS 1A15DFCC I SMS Prototype (M404) [BIOS] SMS BIOS
EE2C29BA I SMS Store Display Unit [BIOS] (non-functional) SMS Different memory map; v1.3 EE2C29BA I SMS Store Display Unit [BIOS] (non-functional) SMS Different memory map; v1.3 BIOS
97B89878 D SMS Cast SMS Bock 97B89878 D SMS Cast SMS Bock
1E9FCE5F D SMS Chip-8 Interpreter 0.1 SMS Maxim 1E9FCE5F D SMS Chip-8 Interpreter 0.1 SMS Maxim
A0154E51 D SMS Chip-8 Interpreter 0.11 SMS Maxim A0154E51 D SMS Chip-8 Interpreter 0.11 SMS Maxim