public byte ReadReg(int addr) { switch (addr) { case 0x4000: case 0x4001: case 0x4002: case 0x4003: case 0x4004: case 0x4005: case 0x4006: case 0x4007: case 0x4008: case 0x4009: case 0x400A: case 0x400B: case 0x400C: case 0x400D: case 0x400E: case 0x400F: case 0x4010: case 0x4011: case 0x4012: case 0x4013: return(apu.ReadReg(addr)); case 0x4014: /*OAM DMA*/ break; case 0x4015: return(apu.ReadReg(addr)); case 0x4016: case 0x4017: return(read_joyport(addr)); default: //Console.WriteLine("read register: {0:x4}", addr); break; } return(0xFF); }
public byte ReadReg(int addr) { byte ret_spec; switch (addr) { case 0x4000: case 0x4001: case 0x4002: case 0x4003: case 0x4004: case 0x4005: case 0x4006: case 0x4007: case 0x4008: case 0x4009: case 0x400A: case 0x400B: case 0x400C: case 0x400D: case 0x400E: case 0x400F: case 0x4010: case 0x4011: case 0x4012: case 0x4013: return(DB); //return apu.ReadReg(addr); case 0x4014: /*OAM DMA*/ break; case 0x4015: return((byte)((byte)(apu.ReadReg(addr) & 0xDF) + (byte)(DB & 0x20))); case 0x4016: if (_isVS) { byte ret = 0; ret = read_joyport(0x4016); ret &= 1; ret = (byte)(ret | (VS_service << 2) | (VS_dips[0] << 3) | (VS_dips[1] << 4) | (VS_coin_inserted << 5) | (VS_ROM_control << 7)); return(ret); } else { // special hardware glitch case ret_spec = read_joyport(addr); if (do_the_reread && ppu.region == PPU.Region.NTSC) { ret_spec = read_joyport(addr); do_the_reread = false; } return(ret_spec); } case 0x4017: if (_isVS) { byte ret = 0; ret = read_joyport(0x4017); ret &= 1; ret = (byte)(ret | (VS_dips[2] << 2) | (VS_dips[3] << 3) | (VS_dips[4] << 4) | (VS_dips[5] << 5) | (VS_dips[6] << 6) | (VS_dips[7] << 7)); return(ret); } else { // special hardware glitch case ret_spec = read_joyport(addr); if (do_the_reread && ppu.region == PPU.Region.NTSC) { ret_spec = read_joyport(addr); do_the_reread = false; } return(ret_spec); } default: //Console.WriteLine("read register: {0:x4}", addr); break; } return(DB); }
public byte ReadReg(int addr) { byte ret_spec; switch (addr) { case 0x4000: case 0x4001: case 0x4002: case 0x4003: case 0x4004: case 0x4005: case 0x4006: case 0x4007: case 0x4008: case 0x4009: case 0x400A: case 0x400B: case 0x400C: case 0x400D: case 0x400E: case 0x400F: case 0x4010: case 0x4011: case 0x4012: case 0x4013: return(DB); //return apu.ReadReg(addr); case 0x4014: /*OAM DMA*/ break; case 0x4015: return((byte)((byte)(apu.ReadReg(addr) & 0xDF) + (byte)(DB & 0x20))); case 0x4016: if (_isVS) { byte ret = 0; ret = read_joyport(0x4016); ret &= 1; ret = (byte)(ret | (VS_service << 2) | (VS_dips[0] << 3) | (VS_dips[1] << 4) | (VS_coin_inserted << 5) | (VS_ROM_control << 7)); return(ret); } else { // special hardware glitch case ret_spec = read_joyport(addr); //if (reread_trigger && (do_the_reread_cont_1 == 0)) { Console.WriteLine("same 1 " + (apu.dmc.sample_address - 1)); } if ((do_the_reread_cont_1 > 0) && ppu.region == PPU.Region.NTSC) { ret_spec = read_joyport(addr); do_the_reread_cont_1--; if (do_the_reread_cont_1 > 0) { ret_spec = read_joyport(addr); } //Console.WriteLine("DMC glitch player 1 " + cpu.TotalExecutedCycles + " addr " + (apu.dmc.sample_address - 1)); } return(ret_spec); } case 0x4017: if (_isVS) { byte ret = 0; ret = read_joyport(0x4017); ret &= 1; ret = (byte)(ret | (VS_dips[2] << 2) | (VS_dips[3] << 3) | (VS_dips[4] << 4) | (VS_dips[5] << 5) | (VS_dips[6] << 6) | (VS_dips[7] << 7)); return(ret); } else { // special hardware glitch case ret_spec = read_joyport(addr); //if (reread_trigger && (do_the_reread_cont_2 == 0)) { Console.WriteLine("same 2 " + (apu.dmc.sample_address - 1)); } if ((do_the_reread_cont_2 > 0) && ppu.region == PPU.Region.NTSC) { ret_spec = read_joyport(addr); do_the_reread_cont_2--; if (do_the_reread_cont_2 > 0) { ret_spec = read_joyport(addr); } //Console.WriteLine("DMC glitch player 2 " + cpu.TotalExecutedCycles + " addr " + (apu.dmc.sample_address - 1)); } return(ret_spec); } default: //Console.WriteLine("read register: {0:x4}", addr); break; } return(DB); }
public byte ReadReg(int addr) { byte ret_spec; switch (addr) { case 0x4000: case 0x4001: case 0x4002: case 0x4003: case 0x4004: case 0x4005: case 0x4006: case 0x4007: case 0x4008: case 0x4009: case 0x400A: case 0x400B: case 0x400C: case 0x400D: case 0x400E: case 0x400F: case 0x4010: case 0x4011: case 0x4012: case 0x4013: return(DB); //return apu.ReadReg(addr); case 0x4014: /*OAM DMA*/ break; case 0x4015: return((byte)((byte)(apu.ReadReg(addr) & 0xDF) + (byte)(DB & 0x20))); case 0x4016: { // special hardware glitch case ret_spec = read_joyport(addr); if (do_the_reread) { ret_spec = read_joyport(addr); do_the_reread = false; } return(ret_spec); } case 0x4017: { if (_iskeyboard) { // eventually this will be the keyboard function, but for now it is a place holder (no keys pressed) return(0x1E); } else { return(read_joyport(addr)); } } default: //Console.WriteLine("read register: {0:x4}", addr); break; } return(DB); }