static BYTE sid_read_chip(WORD addr, int chipno) { int val = -1; addr &= 0x1f; machine_handle_pending_alarms(0); #ifdef HAVE_MOUSE if (chipno == 0 && (addr == 0x19 || addr == 0x1a)) { if ((maincpu_clk ^ pot_cycle) & ~511) { pot_cycle = maincpu_clk & ~511; /* simplistic 512 cycle sampling */ if (_mouse_enabled) { val_pot_x = mouse_get_x(); val_pot_y = mouse_get_y(); } else if (lightpen_enabled) { val_pot_x = lightpen_read_button_x(); val_pot_y = lightpen_read_button_y(); } else { val_pot_x = 0xff; val_pot_y = 0xff; } } val = (addr == 0x19) ? val_pot_x : val_pot_y; } else #endif { if (machine_class == VICE_MACHINE_C64SC || machine_class == VICE_MACHINE_SCPU64) { /* On x64sc, the read/write calls both happen before incrementing the clock, so don't mess with maincpu_clk here. */ val = sid_read_func(addr, chipno); } else { /* Account for that read functions in VICE are called _before_ incrementing the clock. */ maincpu_clk++; val = sid_read_func(addr, chipno); maincpu_clk--; } } /* Fallback when sound is switched off. */ if (val < 0) { if (addr == 0x19 || addr == 0x1a) { val = 0xff; } else { if (addr == 0x1b || addr == 0x1c) { val = maincpu_clk % 256; } else { val = 0; } } } lastsidread = val; return val; }
BYTE vic_read(WORD addr) { addr &= 0xf; switch (addr) { case 3: return ((VIC_RASTER_Y(maincpu_clk + vic.cycle_offset) & 1) << 7) | (vic.regs[3] & ~0x80); case 4: return VIC_RASTER_Y(maincpu_clk + vic.cycle_offset) >> 1; case 6: return vic.light_pen.x; case 7: return vic.light_pen.y; #ifdef HAVE_MOUSE case 8: if (_mouse_enabled) { return mouse_get_x(); } else if (lightpen_enabled) { return lightpen_read_button_x(); } else { return 0xff; } break; case 9: if (_mouse_enabled) { return mouse_get_y(); } else if (lightpen_enabled) { return lightpen_read_button_y(); } else { return 0xff; } break; #else case 8: case 9: return 0xff; #endif default: return vic.regs[addr]; } }