Intellivision implement System Bus memory domain
This commit is contained in:
parent
5a5c067a9d
commit
fbfe28ed76
|
@ -59,7 +59,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
return Rom.Length;
|
||||
}
|
||||
|
||||
public ushort? ReadCart(ushort addr)
|
||||
public ushort? ReadCart(ushort addr, bool peek)
|
||||
{
|
||||
switch (mapper)
|
||||
{
|
||||
|
@ -213,7 +213,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
return null;
|
||||
}
|
||||
|
||||
public bool WriteCart(ushort addr, ushort value)
|
||||
public bool WriteCart(ushort addr, ushort value, bool poke)
|
||||
{
|
||||
switch (mapper)
|
||||
{
|
||||
|
|
|
@ -5,8 +5,8 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
public interface ICart
|
||||
{
|
||||
int Parse(byte[] Rom);
|
||||
ushort? ReadCart(ushort addr);
|
||||
bool WriteCart(ushort addr, ushort value);
|
||||
ushort? ReadCart(ushort addr, bool peek);
|
||||
bool WriteCart(ushort addr, ushort value, bool poke);
|
||||
|
||||
void SyncState(Serializer ser);
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
return offset;
|
||||
}
|
||||
|
||||
public ushort? ReadCart(ushort addr)
|
||||
public ushort? ReadCart(ushort addr, bool peek)
|
||||
{
|
||||
int range = addr / 2048;
|
||||
bool[] attributes = MemoryAttributes[range];
|
||||
|
@ -167,7 +167,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
return null;
|
||||
}
|
||||
|
||||
public bool WriteCart(ushort addr, ushort value)
|
||||
public bool WriteCart(ushort addr, ushort value, bool poke)
|
||||
{
|
||||
int range = addr / 2048;
|
||||
bool[] attributes = MemoryAttributes[range];
|
||||
|
|
|
@ -46,11 +46,19 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
),
|
||||
new MemoryDomainDelegate(
|
||||
"Executive Rom",
|
||||
SystemRam.Length * 2,
|
||||
ExecutiveRom.Length * 2,
|
||||
MemoryDomain.Endian.Little,
|
||||
addr => ReadByteFromShortArray(addr, ExecutiveRom),
|
||||
(addr, value) => WriteByteToShortArray(addr, value, ExecutiveRom),
|
||||
1
|
||||
),
|
||||
new MemoryDomainDelegate(
|
||||
"System Bus",
|
||||
0X20000,
|
||||
MemoryDomain.Endian.Little,
|
||||
addr => PeekSystemBus(addr),
|
||||
(addr, value) => PokeSystemBus(addr, value),
|
||||
1
|
||||
)
|
||||
};
|
||||
|
||||
|
@ -58,8 +66,38 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains);
|
||||
}
|
||||
|
||||
// TODO: move these to a common library and maybe add an endian parameter
|
||||
// Little endian
|
||||
private byte PeekSystemBus(long addr)
|
||||
{
|
||||
if (addr % 2 == 0)
|
||||
{
|
||||
long index = addr / 2;
|
||||
return (byte)(ReadMemory((ushort)index, true) >> 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
long index = (addr - 1) / 2;
|
||||
return (byte)(ReadMemory((ushort)index, true) & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
private void PokeSystemBus(long addr, byte value)
|
||||
{
|
||||
if (addr % 2 == 0)
|
||||
{
|
||||
long index = addr / 2;
|
||||
int temp = (ReadMemory((ushort)index, true) >> 8);
|
||||
WriteMemory((ushort)index, (ushort)(temp & (value << 8)), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
long index = (addr - 1) / 2;
|
||||
int temp = ((ReadMemory((ushort)index, true) & 0xFF)<<8);
|
||||
WriteMemory((ushort)index, (ushort)(temp & value), true);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: move these to a common library and maybe add an endian parameter
|
||||
// Little endian
|
||||
private byte ReadByteFromShortArray(long addr, ushort[] array)
|
||||
{
|
||||
if (addr % 2 == 0)
|
||||
|
|
|
@ -12,11 +12,11 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
public byte[] GraphicsRom = new byte[2048];
|
||||
public byte[] GraphicsRam = new byte[512];
|
||||
|
||||
public ushort ReadMemory(ushort addr)
|
||||
public ushort ReadMemory(ushort addr, bool peek)
|
||||
{
|
||||
ushort? cart = _cart.ReadCart(addr);
|
||||
ushort? stic = _stic.ReadSTIC(addr);
|
||||
ushort? psg = _psg.ReadPSG(addr);
|
||||
ushort? cart = _cart.ReadCart(addr, peek);
|
||||
ushort? stic = _stic.ReadSTIC(addr, peek);
|
||||
ushort? psg = _psg.ReadPSG(addr, peek);
|
||||
ushort? core = null;
|
||||
|
||||
switch (addr & 0xF000)
|
||||
|
@ -43,12 +43,14 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
//controllers
|
||||
if (addr==0x01FE)
|
||||
{
|
||||
islag = false;
|
||||
if (!peek)
|
||||
islag = false;
|
||||
return _psg.Register[14];
|
||||
}
|
||||
if (addr == 0x01FF)
|
||||
{
|
||||
islag = false;
|
||||
if (!peek)
|
||||
islag = false;
|
||||
return _psg.Register[15];
|
||||
}
|
||||
break;
|
||||
|
@ -207,11 +209,11 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
return UNMAPPED;
|
||||
}
|
||||
|
||||
public bool WriteMemory(ushort addr, ushort value)
|
||||
public bool WriteMemory(ushort addr, ushort value, bool poke)
|
||||
{
|
||||
bool cart = _cart.WriteCart(addr, value);
|
||||
bool stic = _stic.WriteSTIC(addr, value);
|
||||
bool psg = _psg.WritePSG(addr, value);
|
||||
bool cart = _cart.WriteCart(addr, value, poke);
|
||||
bool stic = _stic.WriteSTIC(addr, value, poke);
|
||||
bool psg = _psg.WritePSG(addr, value, poke);
|
||||
switch (addr & 0xF000)
|
||||
{
|
||||
case 0x0000:
|
||||
|
|
|
@ -95,8 +95,8 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
public int noise_per;
|
||||
public int noise=0x1;
|
||||
|
||||
public Func<ushort, ushort> ReadMemory;
|
||||
public Func<ushort, ushort, bool> WriteMemory;
|
||||
public Func<ushort, bool, ushort> ReadMemory;
|
||||
public Func<ushort, ushort, bool, bool> WriteMemory;
|
||||
|
||||
public void SyncState(Serializer ser)
|
||||
{
|
||||
|
@ -125,7 +125,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
ser.EndSection();
|
||||
}
|
||||
|
||||
public ushort? ReadPSG(ushort addr)
|
||||
public ushort? ReadPSG(ushort addr, bool peek)
|
||||
{
|
||||
if (addr >= 0x01F0 && addr <= 0x01FF)
|
||||
{
|
||||
|
@ -185,7 +185,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
env_vol_C = (Register[13] >> 4) & 0x3;
|
||||
}
|
||||
|
||||
public bool WritePSG(ushort addr, ushort value)
|
||||
public bool WritePSG(ushort addr, ushort value, bool poke)
|
||||
{
|
||||
if (addr >= 0x01F0 && addr <= 0x01FF)
|
||||
{
|
||||
|
|
|
@ -19,8 +19,8 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
public int TotalExecutedCycles;
|
||||
public int PendingCycles;
|
||||
|
||||
public Func<ushort, ushort> ReadMemory;
|
||||
public Func<ushort, ushort, bool> WriteMemory;
|
||||
public Func<ushort, bool, ushort> ReadMemory;
|
||||
public Func<ushort, ushort, bool, bool> WriteMemory;
|
||||
|
||||
private static int BORDER_OFFSET=176*8;
|
||||
|
||||
|
@ -88,7 +88,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
|
||||
for (int i=0;i<64;i++)
|
||||
{
|
||||
write_reg(i, 0);
|
||||
write_reg(i, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
}
|
||||
|
||||
// mask off appropriate STIC bits and write to register
|
||||
private void write_reg(int reg, ushort value)
|
||||
private void write_reg(int reg, ushort value, bool poke)
|
||||
{
|
||||
|
||||
if (reg < 0x8)
|
||||
|
@ -159,29 +159,29 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
}
|
||||
Register[reg] = value;
|
||||
|
||||
if (reg==0x21)
|
||||
if (reg==0x21 && !poke)
|
||||
{
|
||||
Fgbg = true;
|
||||
}
|
||||
if (reg==0x20)
|
||||
if (reg==0x20 && !poke)
|
||||
{
|
||||
active_display = true;
|
||||
}
|
||||
|
||||
if (reg==0x2C)
|
||||
if (reg==0x2C && !poke)
|
||||
{
|
||||
Update_Border();
|
||||
}
|
||||
}
|
||||
|
||||
public ushort? ReadSTIC(ushort addr)
|
||||
public ushort? ReadSTIC(ushort addr, bool peek)
|
||||
{
|
||||
switch (addr & 0xF000)
|
||||
{
|
||||
case 0x0000:
|
||||
if (addr <= 0x003F && (in_vb_1 | !active_display))
|
||||
{
|
||||
if (addr == 0x0021)
|
||||
if (addr == 0x0021 && !peek)
|
||||
{
|
||||
Fgbg = false;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
case 0x4000:
|
||||
if ((addr <= 0x403F) && (in_vb_1 | !active_display))
|
||||
{
|
||||
if (addr == 0x4021)
|
||||
if (addr == 0x4021 && !peek)
|
||||
{
|
||||
Fgbg = false;
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
case 0x8000:
|
||||
if ((addr <= 0x803F) && (in_vb_1 | !active_display))
|
||||
{
|
||||
if (addr == 0x8021)
|
||||
if (addr == 0x8021 && !peek)
|
||||
{
|
||||
Fgbg = false;
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
case 0xC000:
|
||||
if ((addr <= 0xC03F) && (in_vb_1 | !active_display))
|
||||
{
|
||||
if (addr == 0xC021)
|
||||
if (addr == 0xC021 && !peek)
|
||||
{
|
||||
Fgbg = false;
|
||||
}
|
||||
|
@ -223,35 +223,35 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
return null;
|
||||
}
|
||||
|
||||
public bool WriteSTIC(ushort addr, ushort value)
|
||||
public bool WriteSTIC(ushort addr, ushort value, bool poke)
|
||||
{
|
||||
switch (addr & 0xF000)
|
||||
{
|
||||
case 0x0000:
|
||||
if (addr <= 0x003F && (in_vb_1 | !active_display))
|
||||
{
|
||||
write_reg(addr, value);
|
||||
write_reg(addr, value, poke);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 0x4000:
|
||||
if (addr <= 0x403F && (in_vb_1 | !active_display))
|
||||
{
|
||||
write_reg(addr-0x4000, value);
|
||||
write_reg(addr-0x4000, value, poke);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 0x8000:
|
||||
if (addr <= 0x803F && (in_vb_1 | !active_display))
|
||||
{
|
||||
write_reg(addr-0x8000, value);
|
||||
write_reg(addr-0x8000, value, poke);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 0xC000:
|
||||
if (addr <= 0xC03F && (in_vb_1 | !active_display))
|
||||
{
|
||||
write_reg(addr-0xC000, value);
|
||||
write_reg(addr-0xC000, value, poke);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
@ -312,7 +312,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
{
|
||||
int buffer_offset = (card_row * 159 * 8) + (card_col * 8);
|
||||
// The cards are stored sequentially in the System RAM.
|
||||
ushort card = ReadMemory((ushort)(0x0200 + (card_row * 20) + card_col));
|
||||
ushort card = ReadMemory((ushort)(0x0200 + (card_row * 20) + card_col), false);
|
||||
// Parse data from the card.
|
||||
bool gram = ((card & 0x0800) != 0);
|
||||
int card_num = card >> 3;
|
||||
|
@ -433,11 +433,11 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
byte row;
|
||||
if (gram)
|
||||
{
|
||||
row = (byte)ReadMemory((ushort)(0x3800 + row_mem));
|
||||
row = (byte)ReadMemory((ushort)(0x3800 + row_mem), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
row = (byte)ReadMemory((ushort)(0x3000 + row_mem));
|
||||
row = (byte)ReadMemory((ushort)(0x3000 + row_mem), false);
|
||||
}
|
||||
for (int pict_col = 0; pict_col < 8; pict_col++)
|
||||
{
|
||||
|
@ -595,11 +595,11 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
{
|
||||
if (gram)
|
||||
{
|
||||
row = (byte)ReadMemory((ushort)(0x3800 + 8 * card + j));
|
||||
row = (byte)ReadMemory((ushort)(0x3800 + 8 * card + j), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
row = (byte)ReadMemory((ushort)(0x3000 + 8 * card + j));
|
||||
row = (byte)ReadMemory((ushort)(0x3000 + 8 * card + j), false);
|
||||
}
|
||||
|
||||
mobs[j] = row;
|
||||
|
@ -612,11 +612,11 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
{
|
||||
if (gram)
|
||||
{
|
||||
row = (byte)ReadMemory((ushort)(0x3800 + 8 * (card + 1) + j));
|
||||
row = (byte)ReadMemory((ushort)(0x3800 + 8 * (card + 1) + j), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
row = (byte)ReadMemory((ushort)(0x3000 + 8 * (card + 1) + j));
|
||||
row = (byte)ReadMemory((ushort)(0x3000 + 8 * (card + 1) + j), false);
|
||||
}
|
||||
|
||||
y_mobs[j] = row;
|
||||
|
|
Loading…
Reference in New Issue