SIDWrapper::SIDWrapper() { setDescription("SIDWrapper"); oldsid = new OldSID(); resid = new ReSID(); // Register sub components VirtualComponent *subcomponents[] = { oldsid, resid, NULL }; registerSubComponents(subcomponents, sizeof(subcomponents)); // Register snapshot items SnapshotItem items[] = { // Configuration items { &useReSID, sizeof(useReSID), KEEP_ON_RESET }, // Internal state { &latchedDataBus, sizeof(latchedDataBus), CLEAR_ON_RESET }, { &cycles, sizeof(cycles), CLEAR_ON_RESET }, { NULL, 0, 0 }}; registerSnapshotItems(items, sizeof(items)); useReSID = true; }
Datasette::Datasette() { setDescription("Datasette"); debug(3, "Creating virtual datasette at address %p\n", this); // Register snapshot items SnapshotItem items[] = { // Tape properties (will survive reset) { &size, sizeof(size), KEEP_ON_RESET }, { &type, sizeof(type), KEEP_ON_RESET }, { &durationInCycles, sizeof(durationInCycles), KEEP_ON_RESET }, // Internal state (will be cleared on reset) { &head, sizeof(head), CLEAR_ON_RESET }, { &headInCycles, sizeof(headInCycles), CLEAR_ON_RESET }, { &headInSeconds, sizeof(headInSeconds), CLEAR_ON_RESET }, { &nextRisingEdge, sizeof(nextRisingEdge), CLEAR_ON_RESET }, { &nextFallingEdge, sizeof(nextFallingEdge), CLEAR_ON_RESET }, { &playKey, sizeof(playKey), CLEAR_ON_RESET }, { &motor, sizeof(motor), CLEAR_ON_RESET }, { NULL, 0, 0 }}; registerSnapshotItems(items, sizeof(items)); // Initialize all values that are not initialized in reset() data = NULL; size = 0; type = 0; durationInCycles = 0; }
IEC::IEC() { name = "IEC"; debug(2, " Creating IEC bus at address %p...\n", this); // Register snapshot items SnapshotItem items[] = { { &driveConnected, sizeof(driveConnected), CLEAR_ON_RESET }, { &atnLine, sizeof(atnLine), CLEAR_ON_RESET }, { &oldAtnLine, sizeof(oldAtnLine), CLEAR_ON_RESET }, { &clockLine, sizeof(clockLine), CLEAR_ON_RESET }, { &oldClockLine, sizeof(oldClockLine), CLEAR_ON_RESET }, { &dataLine, sizeof(dataLine), CLEAR_ON_RESET }, { &oldDataLine, sizeof(oldDataLine), CLEAR_ON_RESET }, { &deviceAtnPin, sizeof(deviceAtnPin), CLEAR_ON_RESET }, { &deviceAtnIsOutput, sizeof(deviceAtnIsOutput), CLEAR_ON_RESET }, { &deviceDataPin, sizeof(deviceDataPin), CLEAR_ON_RESET }, { &deviceDataIsOutput, sizeof(deviceDataIsOutput), CLEAR_ON_RESET }, { &deviceClockPin, sizeof(deviceClockPin), CLEAR_ON_RESET }, { &deviceClockIsOutput, sizeof(deviceClockIsOutput), CLEAR_ON_RESET }, { &ciaDataPin, sizeof(ciaDataPin), CLEAR_ON_RESET }, { &ciaDataIsOutput, sizeof(ciaDataIsOutput), CLEAR_ON_RESET }, { &ciaClockPin, sizeof(ciaClockPin), CLEAR_ON_RESET }, { &ciaClockIsOutput, sizeof(ciaClockIsOutput), CLEAR_ON_RESET }, { &ciaAtnPin, sizeof(ciaAtnPin), CLEAR_ON_RESET }, { &ciaAtnIsOutput, sizeof(ciaAtnIsOutput), CLEAR_ON_RESET }, { &busActivity, sizeof(busActivity), CLEAR_ON_RESET }, { NULL, 0, 0 }}; registerSnapshotItems(items, sizeof(items)); }
C64::C64() { setDescription("C64"); debug(1, "Creating virtual C64 at address %p\n", this); p = NULL; warp = false; alwaysWarp = false; warpLoad = false; // Register sub components VirtualComponent *subcomponents[] = { &cpu, &mem, &vic, &sid, &cia1, &cia2, &iec, &expansionport, &floppy, &datasette, &keyboard, &joystickA, &joystickB, NULL }; registerSubComponents(subcomponents, sizeof(subcomponents)); setC64(this); // Register snapshot items SnapshotItem items[] = { { &warp, sizeof(warp), CLEAR_ON_RESET }, { &alwaysWarp, sizeof(alwaysWarp), CLEAR_ON_RESET }, { &warpLoad, sizeof(warpLoad), KEEP_ON_RESET }, { &cycle, sizeof(cycle), CLEAR_ON_RESET }, { &frame, sizeof(frame), CLEAR_ON_RESET }, { &rasterline, sizeof(rasterline), CLEAR_ON_RESET }, { &rasterlineCycle, sizeof(rasterlineCycle), CLEAR_ON_RESET }, { NULL, 0, 0 }}; registerSnapshotItems(items, sizeof(items)); // Configure machine type and reset setPAL(); reset(); // Initialie mach timer info mach_timebase_info(&timebase); // Initialize snapshot ringbuffer (BackInTime feature) for (unsigned i = 0; i < BACK_IN_TIME_BUFFER_SIZE; i++) backInTimeHistory[i] = new Snapshot(); backInTimeWritePtr = 0; }
VC1541::VC1541() { name = "1541"; debug(2, "Creating virtual VC1541 at address %p\n", this); // Create sub components mem = new VC1541Memory(); cpu = new CPU(); cpu->setName("1541CPU"); cpu->chipModel = CPU::MOS6502; // Register sub components VirtualComponent *subcomponents[] = { mem, cpu, &via1, &via2, &disk, NULL }; registerSubComponents(subcomponents, sizeof(subcomponents)); // Register snapshot items SnapshotItem items[] = { // Configuration items { &bitAccuracy, sizeof(bitAccuracy), KEEP_ON_RESET }, { &sendSoundMessages, sizeof(sendSoundMessages), KEEP_ON_RESET }, // Internal state { &bitReadyTimer, sizeof(bitReadyTimer), CLEAR_ON_RESET }, { &byteReadyCounter, sizeof(byteReadyCounter), CLEAR_ON_RESET }, { &rotating, sizeof(rotating), CLEAR_ON_RESET }, { &redLED, sizeof(redLED), CLEAR_ON_RESET }, { &diskPartiallyInserted, sizeof(diskPartiallyInserted), CLEAR_ON_RESET }, { &halftrack, sizeof(halftrack), CLEAR_ON_RESET }, { &bitoffset, sizeof(bitoffset), CLEAR_ON_RESET }, { &zone, sizeof(zone), CLEAR_ON_RESET }, { &read_shiftreg, sizeof(read_shiftreg), CLEAR_ON_RESET }, { &write_shiftreg, sizeof(write_shiftreg), CLEAR_ON_RESET }, { &sync, sizeof(sync), CLEAR_ON_RESET }, // Disk properties (will survive reset) { &diskInserted, sizeof(diskInserted), KEEP_ON_RESET }, { NULL, 0, 0 }}; registerSnapshotItems(items, sizeof(items)); sendSoundMessages = true; resetDisk(); }
VC1541::VC1541() { name = "1541"; debug(2, "Creating virtual VC1541 at address %p\n", this); // Create sub components mem = new VC1541Memory(); cpu = new CPU(); cpu->setName("1541CPU"); cpu->chipModel = CPU::MOS6502; // Register snapshot items SnapshotItem items[] = { // Configuration { &bitAccuracy, sizeof(bitAccuracy) }, // Internal state { &bitReadyTimer, sizeof(bitAccuracy) }, { &byteReadyCounter, sizeof(byteReadyCounter) }, { &rotating, sizeof(rotating) }, { &redLED, sizeof(redLED) }, { &diskInserted, sizeof(diskInserted) }, { &writeProtected, sizeof(writeProtected) }, { &sendSoundMessages, sizeof(sendSoundMessages) }, // Read/Write logic { &halftrack, sizeof(halftrack) }, { &bitoffset, sizeof(bitoffset) }, { &zone, sizeof(zone) }, { &read_shiftreg, sizeof(read_shiftreg) }, { &write_shiftreg, sizeof(write_shiftreg) }, { &sync, sizeof(sync) }, { NULL, 0 } }; registerSnapshotItems(items, sizeof(items)); sendSoundMessages = true; resetDisk(); }
ReSID::ReSID() { name = "ReSID"; debug(2, " Creating ReSID at address %p...\n", this); sid = new SID(); // Register snapshot items SnapshotItem items[] = { // Configuration items { &chipModel, sizeof(chipModel), KEEP_ON_RESET }, { &sampleRate, sizeof(sampleRate), KEEP_ON_RESET }, { &samplingMethod, sizeof(samplingMethod), KEEP_ON_RESET }, { &cpuFrequency, sizeof(cpuFrequency), KEEP_ON_RESET }, { &audioFilter, sizeof(audioFilter), KEEP_ON_RESET }, { &externalAudioFilter, sizeof(externalAudioFilter), KEEP_ON_RESET }, { &volume, sizeof(volume), KEEP_ON_RESET }, { &targetVolume, sizeof(targetVolume), KEEP_ON_RESET }, // ReSID state { st.sid_register, sizeof(st.sid_register), KEEP_ON_RESET }, { &st.bus_value, sizeof(st.bus_value), KEEP_ON_RESET }, { &st.bus_value_ttl, sizeof(st.bus_value_ttl), KEEP_ON_RESET }, { &st.accumulator[0], sizeof(st.accumulator[0]), KEEP_ON_RESET }, { &st.accumulator[1], sizeof(st.accumulator[1]), KEEP_ON_RESET }, { &st.accumulator[2], sizeof(st.accumulator[2]), KEEP_ON_RESET }, { &st.shift_register[0], sizeof(&st.shift_register[0]), KEEP_ON_RESET }, { &st.shift_register[1], sizeof(&st.shift_register[1]), KEEP_ON_RESET }, { &st.shift_register[2], sizeof(&st.shift_register[2]), KEEP_ON_RESET }, { &st.rate_counter[0], sizeof(st.rate_counter[0]), KEEP_ON_RESET }, { &st.rate_counter[1], sizeof(st.rate_counter[1]), KEEP_ON_RESET }, { &st.rate_counter[2], sizeof(st.rate_counter[2]), KEEP_ON_RESET }, { &st.rate_counter_period[0], sizeof(st.rate_counter_period[0]), KEEP_ON_RESET }, { &st.rate_counter_period[1], sizeof(st.rate_counter_period[1]), KEEP_ON_RESET }, { &st.rate_counter_period[2], sizeof(st.rate_counter_period[2]), KEEP_ON_RESET }, { &st.exponential_counter[0], sizeof(st.exponential_counter[0]), KEEP_ON_RESET }, { &st.exponential_counter[1], sizeof(st.exponential_counter[1]), KEEP_ON_RESET }, { &st.exponential_counter[2], sizeof(st.exponential_counter[2]), KEEP_ON_RESET }, { &st.exponential_counter_period[0],sizeof(st.exponential_counter_period[0]), KEEP_ON_RESET }, { &st.exponential_counter_period[1],sizeof(st.exponential_counter_period[1]), KEEP_ON_RESET }, { &st.exponential_counter_period[2],sizeof(st.exponential_counter_period[2]), KEEP_ON_RESET }, { &st.envelope_counter[0], sizeof(st.envelope_counter[0]), KEEP_ON_RESET }, { &st.envelope_counter[1], sizeof(st.envelope_counter[1]), KEEP_ON_RESET }, { &st.envelope_counter[2], sizeof(st.envelope_counter[2]), KEEP_ON_RESET }, { &st.envelope_state[0], sizeof(st.envelope_state[0]), KEEP_ON_RESET }, { &st.envelope_state[1], sizeof(st.envelope_state[1]), KEEP_ON_RESET }, { &st.envelope_state[2], sizeof(st.envelope_state[2]), KEEP_ON_RESET }, { &st.hold_zero[0], sizeof(st.hold_zero[0]), KEEP_ON_RESET }, { &st.hold_zero[1], sizeof(st.hold_zero[1]), KEEP_ON_RESET }, { &st.hold_zero[2], sizeof(st.hold_zero[2]), KEEP_ON_RESET }, { NULL, 0, 0 }}; registerSnapshotItems(items, sizeof(items)); // Set default values setChipModel(MOS6581); cpuFrequency = PAL_CYCLES_PER_FRAME * PAL_REFRESH_RATE; samplingMethod = SAMPLE_FAST; sampleRate = 44100; sid->set_sampling_parameters(cpuFrequency, samplingMethod, sampleRate); setAudioFilter(false); setExternalAudioFilter(false); volume = 100000; targetVolume = 100000; }
C64::C64() { name = "C64"; debug(1, "Creating virtual C64\n"); p = NULL; warp = false; alwaysWarp = false; warpLoad = false; // Create components cpu = new CPU(); mem = new C64Memory(); vic = new VIC(); sid = new SIDWrapper(); cia1 = new CIA1(); cia2 = new CIA2(); iec = new IEC(); expansionport = new ExpansionPort(); floppy = new VC1541(); keyboard = new Keyboard(); joystick1 = new Joystick(); joystick2 = new Joystick(); // Register sub components VirtualComponent *subcomponents[] = { cpu, mem, vic, sid, cia1, cia2, iec, expansionport, floppy, &datasette, keyboard, joystick1, joystick2, NULL }; registerSubComponents(subcomponents, sizeof(subcomponents)); setC64(this); // Register snapshot items SnapshotItem items[] = { { &warpLoad, sizeof(warpLoad), KEEP_ON_RESET }, { &alwaysWarp, sizeof(alwaysWarp), CLEAR_ON_RESET }, { &warp, sizeof(warp), CLEAR_ON_RESET }, { &cycles, sizeof(cycles), CLEAR_ON_RESET }, { &frame, sizeof(frame), CLEAR_ON_RESET }, { &rasterline, sizeof(rasterline), CLEAR_ON_RESET }, { &rasterlineCycle, sizeof(rasterlineCycle), CLEAR_ON_RESET }, { NULL, 0, 0 }}; registerSnapshotItems(items, sizeof(items)); // Configure machine type and reset setPAL(); reset(); // Initialie mach timer info mach_timebase_info(&timebase); // Initialize snapshot ringbuffer (BackInTime feature) for (unsigned i = 0; i < BACK_IN_TIME_BUFFER_SIZE; i++) backInTimeHistory[i] = new Snapshot(); backInTimeWritePtr = 0; }
CPU::CPU() { setDescription("CPU"); debug(3, " Creating CPU at address %p...\n", this); // Chip model chipModel = MOS6510; // Establish callback for each instruction registerInstructions(); // Clear all breakpoint tags for (int i = 0; i < 65536; i++) { breakpoint[i] = NO_BREAKPOINT; } // Register snapshot items SnapshotItem items[] = { // Lifetime items { &chipModel, sizeof(chipModel), KEEP_ON_RESET }, // Internal state { &A, sizeof(A), CLEAR_ON_RESET }, { &X, sizeof(X), CLEAR_ON_RESET }, { &Y, sizeof(Y), CLEAR_ON_RESET }, { &PC, sizeof(PC), CLEAR_ON_RESET }, { &PC_at_cycle_0, sizeof(PC_at_cycle_0), CLEAR_ON_RESET }, { &SP, sizeof(SP), CLEAR_ON_RESET }, { &N, sizeof(N), CLEAR_ON_RESET }, { &V, sizeof(V), CLEAR_ON_RESET }, { &B, sizeof(B), CLEAR_ON_RESET }, { &D, sizeof(D), CLEAR_ON_RESET }, { &I, sizeof(I), CLEAR_ON_RESET }, { &Z, sizeof(Z), CLEAR_ON_RESET }, { &C, sizeof(C), CLEAR_ON_RESET }, { &opcode, sizeof(opcode), CLEAR_ON_RESET }, { &addr_lo, sizeof(addr_lo), CLEAR_ON_RESET }, { &addr_hi, sizeof(addr_hi), CLEAR_ON_RESET }, { &ptr, sizeof(ptr), CLEAR_ON_RESET }, { &pc_lo, sizeof(pc_lo), CLEAR_ON_RESET }, { &pc_hi, sizeof(pc_hi), CLEAR_ON_RESET }, { &overflow, sizeof(overflow), CLEAR_ON_RESET }, { &data, sizeof(data), CLEAR_ON_RESET }, { &port, sizeof(port), KEEP_ON_RESET }, // Reset in C64Memory::reset { &port_direction, sizeof(port_direction), KEEP_ON_RESET }, // Reset in C64Memory::reset { &external_port_bits, sizeof(external_port_bits), CLEAR_ON_RESET }, { &rdyLine, sizeof(rdyLine), CLEAR_ON_RESET }, { &irqLine, sizeof(irqLine), CLEAR_ON_RESET }, { &nmiLine, sizeof(nmiLine), CLEAR_ON_RESET }, { &nmiEdge, sizeof(nmiEdge), CLEAR_ON_RESET }, { &interruptsPending, sizeof(interruptsPending), CLEAR_ON_RESET }, { &nextPossibleIrqCycle, sizeof(nextPossibleIrqCycle), CLEAR_ON_RESET }, { &nextPossibleNmiCycle, sizeof(nextPossibleNmiCycle), CLEAR_ON_RESET }, { &errorState, sizeof(errorState), CLEAR_ON_RESET }, { &callStack, sizeof(callStack), CLEAR_ON_RESET | WORD_FORMAT }, { &callStackPointer, sizeof(callStackPointer), CLEAR_ON_RESET }, { &oldI, sizeof(oldI), CLEAR_ON_RESET }, { NULL, 0, 0 }}; registerSnapshotItems(items, sizeof(items)); }