-Refactored ReadMemory so that both the core and cart addresses are read.

--Afterwards, the data is reconciled, right now by chucking out the core value if the cart responded.
-WriteMemory now writes to both the core and the cart unconditionally.
--Each case now breaks out of the switch statement in case we want to do more complex things at the end of the function later on.
-All default paths in both functions now throw an exception.
This commit is contained in:
brandman211 2012-07-18 06:19:03 +00:00
parent 1ee1d03aea
commit 198c60af88
1 changed files with 33 additions and 24 deletions

View File

@ -18,63 +18,72 @@ namespace BizHawk.Emulation.Consoles.Intellivision
public ushort ReadMemory(ushort addr)
{
ushort? cart = ReadCart(addr);
if (cart != null)
return (ushort)cart;
ushort core;
switch (addr & 0xF000)
{
case 0x0000:
if (addr >= 0x0100 && addr <= 0x01EF)
return Scratchpad_RAM[addr & 0x00EF];
if (addr >= 0x01F0 && addr <= 0x01FF)
return PSG_Registers[addr & 0x000F];
if (addr >= 0x0200 && addr <= 0x035F)
return System_RAM[addr & 0x015F];
core = Scratchpad_RAM[addr & 0x00EF];
else if (addr >= 0x01F0 && addr <= 0x01FF)
core = PSG_Registers[addr & 0x000F];
else if (addr >= 0x0200 && addr <= 0x035F)
core = System_RAM[addr & 0x015F];
else
throw new NotImplementedException();
break;
case 0x1000:
return Executive_ROM[addr & 0x0FFF];
core = Executive_ROM[addr & 0x0FFF];
break;
case 0x3000:
if (addr >= 0x3000 && addr <= 0x37FF)
return Graphics_ROM[addr & 0x07FF];
if (addr >= 0x3800 && addr <= 0x39FF)
return Graphics_RAM[addr & 0x01FF];
core = Graphics_ROM[addr & 0x07FF];
else if (addr >= 0x3800 && addr <= 0x39FF)
core = Graphics_RAM[addr & 0x01FF];
else
throw new NotImplementedException();
break;
default:
throw new NotImplementedException();
}
throw new NotImplementedException();
if (cart != null)
return (ushort)cart;
return core;
}
public void WriteMemory(ushort addr, ushort value)
{
bool cart = WriteCart(addr, value);
if (cart)
return;
WriteCart(addr, value);
switch (addr & 0xF000)
{
case 0x0000:
if (addr >= 0x0100 && addr <= 0x01EF)
{
Scratchpad_RAM[addr & 0x00EF] = value;
return;
break;
}
if (addr >= 0x01F0 && addr <= 0x01FF)
else if (addr >= 0x01F0 && addr <= 0x01FF)
{
PSG_Registers[addr & 0x000F] = value;
return;
break;
}
if (addr >= 0x0200 && addr <= 0x035F)
else if (addr >= 0x0200 && addr <= 0x035F)
{
System_RAM[addr & 0x015F] = value;
return;
break;
}
break;
else
throw new NotImplementedException();
case 0x3000:
if (addr >= 0x3800 && addr <= 0x39FF)
{
Graphics_RAM[addr & 0x01FF] = value;
return;
break;
}
break;
else
throw new NotImplementedException();
default:
throw new NotImplementedException();
}
throw new NotImplementedException();
}
}
}