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
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)");
Firmware("SMS", "SMS_US", "SMS Bios (USA)");
Firmware("SMS", "SMS_JP", "SMS Bios (Japan)");
Option("SMS", "SMS_US", sms_us_13);
Option("SMS", "SMS_JP", sms_jp_21);
var sms_us_1b = File("29091FF60EF4C22B1EE17AA21E0E75BAC6B36474", "sms_us_1.0b.sms", "SMS BIOS 1.0 (USA) (Proto)");
var sms_m404 = File("4A06C8E66261611DCE0305217C42138B71331701", "sms_m404.sms", "SMS BIOS (USA) (M404) (Proto)");
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

View File

@ -17,25 +17,35 @@
const ushort BankSizeMask = 0x3FFF;
const ushort RamSizeMask = 0x1FFF;
bool BiosMapped { get { return (Port3E & 0x40) == 0x40; } }
byte ReadMemory(ushort address)
{
byte ret;
if (address < 1024)
ret = RomData[address];
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)
if (address < 0xC000)
{
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;
case 1: ret = SaveRAM[address & BankSizeMask]; break;
case 2: ret = SaveRAM[BankSize + (address & BankSizeMask)]; break;
default:
ret = SystemRam[address & RamSizeMask];
break;
switch (SaveRamBank)
{
case 0: ret = RomData[(RomBank2 * BankSize) + (address & BankSizeMask)]; break;
case 1: ret = SaveRAM[address & BankSizeMask]; break;
case 2: ret = SaveRAM[BankSize + (address & BankSizeMask)]; break;
default:
ret = SystemRam[address & RamSizeMask];
break;
}
}
}
else
@ -91,22 +101,20 @@
WriteMemory(0xFFFF, 2);
}
// Mapper when loading a BIOS as a ROM
bool BiosMapped { get { return (Port3E & 0x08) == 0; } }
// Mapper when loading a BIOS as a ROM (simulating no cart loaded)
byte ReadMemoryBIOS(ushort address)
{
if (BiosMapped == false && address < BankSize * 3)
return 0x00;
if ((Port3E & 0x08) != 0 && address < 0xC000)
return 0xFF;
if (address < 1024)
return RomData[address];
if (address < BankSize)
if (address < 0x4000)
return RomData[(RomBank0 * BankSize) + address];
if (address < BankSize * 2)
if (address < 0x8000)
return RomData[(RomBank1 * BankSize) + (address & BankSizeMask)];
if (address < BankSize * 3)
if (address < 0xC000)
return RomData[(RomBank2 * BankSize) + (address & BankSizeMask)];
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 SaveRamBank;
public byte[] BiosRom;
public byte[] ReadSaveRam()
{
if (SaveRAM != null)
@ -192,11 +194,20 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
if (game["3D"])
IsGame3D = true;
if (game["BIOS"])
{
Port3E = 0xF7; // Disable cartridge, enable BIOS rom
InitBiosMapper();
}
if (game["BIOS"])
{
Port3E = 0xF7; // Disable cartridge, enable BIOS rom
InitBiosMapper();
}
else
{
BiosRom = comm.CoreFileProvider.GetFirmware("SMS", "SMSBIOS", false);
if (BiosRom != null) // && usebios
{
Port3E = 0xF7;
}
}
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
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
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
9C5BAD91 I Alex Kidd in Miracle World [BIOS] (KR) SMS
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 BIOS
08C9EC91 Alex Kidd no Miracle World (JP) SMS
D2417ED7 Alex Kidd in Shinobi World 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
6F79E4A1 F Hang On (h) 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
E167A561 Hang On & Safari Hunt SMS
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
ED9FD67D T Miracle Warriors - Seal Of The Dark Lord (DE) SMS Azelistic; v0.95b FM
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
693C63D5 H Monica 3 [B] SMS Wonder Boy in Monster World
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
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
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
48D44A13 I SMS Japanese (v2.1) [BIOS] SMS BIOS;FM
1A15DFCC I SMS Prototype (M404) [BIOS] SMS
EE2C29BA I SMS Store Display Unit [BIOS] (non-functional) SMS Different memory map; v1.3
1A15DFCC I SMS Prototype (M404) [BIOS] SMS BIOS
EE2C29BA I SMS Store Display Unit [BIOS] (non-functional) SMS Different memory map; v1.3 BIOS
97B89878 D SMS Cast SMS Bock
1E9FCE5F D SMS Chip-8 Interpreter 0.1 SMS Maxim
A0154E51 D SMS Chip-8 Interpreter 0.11 SMS Maxim