Added RAMBoard support = RAM at 0x8000

Changed Address decoding code to be clearer
This commit is contained in:
penfold42 2018-05-28 14:46:57 +10:00
parent d0d497d2ce
commit e81960a295

View file

@ -203,19 +203,40 @@ DWORD get_fattime() { return 0; } // If you have hardware RTC return a correct v
u8 read6502(u16 address)
{
u8 value;
if (address & 0x8000) // address line 15 selects the ROM
if (address & 0x8000)
{
value = roms.Read(address);
switch (address & 0xe000) // keep bits 15,14,13
{
case 0x8000: // 0x8000-0x9fff
value = s_u8Memory[address]; // 74LS42 outputs low on pin 1 or pin 2
break;
case 0xa000: // 0xa000-0xbfff
case 0xc000: // 0xc000-0xdfff
case 0xe000: // 0xe000-0xffff
value = roms.Read(address);
break;
}
}
else
{
// Address lines 15, 12, 11 and 10 are fed into a 74LS42 for decoding
u16 addressLines15_12_11_10 = (address & 0x1c00) >> 10;
addressLines15_12_11_10 |= (address & 0x8000) >> (15 - 3);
if (addressLines15_12_11_10 == 0 || addressLines15_12_11_10 == 1) value = s_u8Memory[address & 0x7ff]; // 74LS42 outputs low on pin 1 or pin 2
else if (addressLines15_12_11_10 == 6) value = pi1541.VIA[0].Read(address); // 74LS42 outputs low on pin 7
else if (addressLines15_12_11_10 == 7) value = pi1541.VIA[1].Read(address); // 74LS42 outputs low on pin 9
else value = address >> 8; // Empty address bus
u16 addressLines12_11_10 = (address & 0x1c00) >> 10;
switch (addressLines12_11_10)
{
case 0:
case 1:
value = s_u8Memory[address & 0x7ff]; // 74LS42 outputs low on pin 1 or pin 2
break;
case 6:
value = pi1541.VIA[0].Read(address); // 74LS42 outputs low on pin 7
break;
case 7:
value = pi1541.VIA[1].Read(address); // 74LS42 outputs low on pin 9
break;
default:
value = address >> 8; // Empty address bus
break;
}
}
return value;
}
@ -258,12 +279,39 @@ u8 peek6502(u16 address)
void write6502(u16 address, const u8 value)
{
if (address & 0x8000) return; // address line 15 selects the ROM
u16 addressLines15_12_11_10 = (address & 0x1c00) >> 10;
addressLines15_12_11_10 |= (address & 0x8000) >> (15 - 3);
if (addressLines15_12_11_10 == 0 || addressLines15_12_11_10 == 1) s_u8Memory[address & 0x7ff] = value; // 74LS42 outputs low on pin 1 or pin 2
else if (addressLines15_12_11_10 == 6) pi1541.VIA[0].Write(address, value); // 74LS42 outputs low on pin 7
else if (addressLines15_12_11_10 == 7) pi1541.VIA[1].Write(address, value); // 74LS42 outputs low on pin 9
if (address & 0x8000)
{
switch (address & 0xe000) // keep bits 15,14,13
{
case 0x8000: // 0x8000-0x9fff
s_u8Memory[address] = value; // 74LS42 outputs low on pin 1 or pin 2
break;
case 0xa000: // 0xa000-0xbfff
case 0xc000: // 0xc000-0xdfff
case 0xe000: // 0xe000-0xffff
return;
}
}
else
{
// Address lines 15, 12, 11 and 10 are fed into a 74LS42 for decoding
u16 addressLines12_11_10 = (address & 0x1c00) >> 10;
switch (addressLines12_11_10)
{
case 0:
case 1:
s_u8Memory[address & 0x7ff] = value; // 74LS42 outputs low on pin 1 or pin 2
break;
case 6:
pi1541.VIA[0].Write(address, value); // 74LS42 outputs low on pin 7
break;
case 7:
pi1541.VIA[1].Write(address, value); // 74LS42 outputs low on pin 9
break;
default:
break;
}
}
}
void write6502ExtraRAM(u16 address, const u8 value)