public static sbyte MReadByte(int address) { address &= 0xffffff; sbyte result = 0; if (address >= 0 && address <= 0x1ffff) { result = (sbyte)(mainbiosrom[address]); } else if (address >= 0x100000 && address <= 0x3fffff) { if (address < 0x100000 + Memory.mainrom.Length) { result = (sbyte)(Memory.mainrom[address - 0x100000]); } else { result = 0; } } else if (address >= 0x800000 && address <= 0x81ffff) { result = (sbyte)Memory.mainram[address - 0x800000]; } else if (address >= 0x900000 && address <= 0x903fff) { result = (sbyte)pgm_bg_videoram[address - 0x900000]; } else if (address >= 0x904000 && address <= 0x905fff) { result = (sbyte)pgm_tx_videoram[address - 0x904000]; } else if (address >= 0x907000 && address <= 0x9077ff) { result = (sbyte)pgm_rowscrollram[address - 0x907000]; } else if (address >= 0xa00000 && address <= 0xa011ff) { int offset = (address - 0xa00000) / 2; if ((address % 2) == 0) { result = (sbyte)(Generic.paletteram16[offset] >> 8); } else if ((address % 2) == 1) { result = (sbyte)(Generic.paletteram16[offset]); } } else if (address >= 0xb00000 && address <= 0xb0ffff) { result = (sbyte)pgm_videoregs[address - 0xb00000]; } else if (address >= 0xc00002 && address <= 0xc00003) { result = (sbyte)Sound.latched_value[0]; } else if (address >= 0xc00004 && address <= 0xc00005) { result = (sbyte)Sound.latched_value[1]; } else if (address >= 0xc00006 && address <= 0xc00007) { result = (sbyte)PGM.pgm_calendar_r(); } else if (address >= 0xc0000c && address <= 0xc0000d) { result = (sbyte)Sound.latched_value[2]; } else if (address >= 0xc08000 && address <= 0xc08001) { result = (sbyte)short0; } else if (address >= 0xc08002 && address <= 0xc08003) { result = (sbyte)short1; } else if (address >= 0xc08004 && address <= 0xc08005) { result = (sbyte)short2; } else if (address >= 0xc08006 && address <= 0xc08007) { result = (sbyte)short3; } else if (address >= 0xc10000 && address <= 0xc1ffff) { result = (sbyte)z80_ram_r(address - 0xc10000); } return(result); }
public static short MReadWord(int address) { address &= 0xffffff; short result = 0; if (address >= 0 && address + 1 <= 0x1ffff) { result = (short)(mainbiosrom[address] * 0x100 + mainbiosrom[address + 1]); } else if (address >= 0x100000 && address + 1 <= 0x3fffff) { if (address + 1 < 0x100000 + Memory.mainrom.Length) { result = (short)(Memory.mainrom[address - 0x100000] * 0x100 + Memory.mainrom[address - 0x100000 + 1]); } else { result = 0; } } else if (address >= 0x800000 && address + 1 <= 0x81ffff) { result = (short)(Memory.mainram[address - 0x800000] * 0x100 + Memory.mainram[address - 0x800000 + 1]); } else if (address >= 0x900000 && address + 1 <= 0x903fff) { result = (short)(pgm_bg_videoram[address - 0x900000] * 0x100 + pgm_bg_videoram[address - 0x900000 + 1]); } else if (address >= 0x904000 && address + 1 <= 0x905fff) { result = (short)(pgm_tx_videoram[address - 0x904000] * 0x100 + pgm_tx_videoram[address - 0x904000 + 1]); } else if (address >= 0x907000 && address + 1 <= 0x9077ff) { result = (short)(pgm_rowscrollram[address - 0x907000] * 0x100 + pgm_rowscrollram[address - 0x907000 + 1]); } else if (address >= 0xa00000 && address + 1 <= 0xa011ff) { int offset = (address - 0xa0000) / 2; result = (short)Generic.paletteram16[offset]; } else if (address >= 0xb00000 && address + 1 <= 0xb0ffff) { result = (short)(pgm_videoregs[address - 0xb00000] * 0x100 + pgm_videoregs[address - 0xb00000 + 1]); } else if (address >= 0xc00002 && address + 1 <= 0xc00003) { result = (short)Sound.latched_value[0]; } else if (address >= 0xc00004 && address + 1 <= 0xc00005) { result = (short)Sound.latched_value[1]; } else if (address >= 0xc00006 && address + 1 <= 0xc00007) { result = (short)PGM.pgm_calendar_r(); } else if (address >= 0xc0000c && address + 1 <= 0xc0000d) { result = (short)Sound.latched_value[2]; } else if (address >= 0xc08000 && address + 1 <= 0xc08001) { result = short0; } else if (address >= 0xc08002 && address + 1 <= 0xc08003) { result = short1; } else if (address >= 0xc08004 && address + 1 <= 0xc08005) { result = short2; } else if (address >= 0xc08006 && address + 1 <= 0xc08007) { result = short3; } else if (address >= 0xc10000 && address + 1 <= 0xc1ffff) { result = (short)(z80_ram_r(address - 0xc10000) * 0x100 + z80_ram_r(address - 0xc10000 + 1)); } return(result); }