Example #1
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();
}
Example #2
0
void 
VC1541::ejectDisk()
{
    if (!hasDisk())
        return;
    
	// Open lid (write protection light barrier will be blocked)
	setWriteProtection(true);

	// Drive will notice the change in its interrupt routine...
	sleepMicrosec((uint64_t)200000);
	
	// Remove disk (write protection light barrier is no longer blocked)
	setWriteProtection(false);
		
    resetDisk();
	c64->putMessage(MSG_VC1541_DISK, 0);
    if (sendSoundMessages)
        c64->putMessage(MSG_VC1541_DISK_SOUND, 0);
}
Example #3
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 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();
}
Example #4
0
void 
VC1541::ejectDisk()
{
    if (!hasDisk())
        return;
    
	// Open lid (this blocks the light barrier)
    setDiskPartiallyInserted(true);

	// Let the drive notice the blocked light barrier in its interrupt routine ...
	sleepMicrosec((uint64_t)200000);

    // Erase disk data and reset write protection flag
    resetDisk();

	// Remove disk (this unblocks the light barrier)
	setDiskPartiallyInserted(false);
		
    // Notify listener
	c64->putMessage(MSG_VC1541_DISK, 0);
    if (sendSoundMessages)
        c64->putMessage(MSG_VC1541_DISK_SOUND, 0);
}