void VC1541::insertDisk(D64Archive *a) { assert(a != NULL); ejectDisk(); disk.encodeArchive(a); diskInserted = true; setWriteProtection(false); c64->putMessage(MSG_VC1541_DISK, 1); if (sendSoundMessages) c64->putMessage(MSG_VC1541_DISK_SOUND, 1); }
void VC1541::insertDisk(Archive *a) { assert(a != NULL); D64Archive *d64 = (D64Archive *)a; G64Archive *g64 = (G64Archive *)a; switch (a->getType()) { case D64_CONTAINER: ejectDisk(); disk.encodeArchive(d64); break; case G64_CONTAINER: ejectDisk(); disk.encodeArchive(g64); break; default: warn("Only D64 or G64 archives can be mounted as virtual disk."); return; } diskInserted = true; c64->putMessage(MSG_VC1541_DISK, 1); if (sendSoundMessages) c64->putMessage(MSG_VC1541_DISK_SOUND, 1); // If bit accuracy is disabled, we write-protect the disk disk.setWriteProtection(true); }
// // deviceUpdate() - update the USB devices if necessary. If there was a change // then this returns true, otherwise false. Note that there // isn't any differentiation as to which port changed in // the return value. // bool VDIP::deviceUpdate() { char incoming[32]; portConfig portConfigBuffer; int i; bool changed = false; // mark the two ports so we know when they've been assigned for(i=2; i--; ) { ports[i].flag = false; } // first, get the data for the connected devices - note that only the first // two logical USB ports are checked. If this code supported HUBs, it would // be different, but it doesn't... // Note, too, that each port must be accounted for, or its configuration gets // zero'd out. // for (int i = 0; i < 2; i++) { for (int i = 0; i < 8; i++) { // each xbox controller uses 4 usb devices - plan for two // potential xbox controllers cmd(VDIP_QD,incoming,100,i); // given a configuration buffer, get this port's data mapDevice(i,incoming,&portConfigBuffer); if(portConfigBuffer.port >= 0 && portConfigBuffer.port < 2) { // we have a good assignment if(ports[portConfigBuffer.port].flag == true) { // this port has already been assigned during this update // so ignore the rest of the logical devices. We assume that // the first one is always the command device. continue; } ports[portConfigBuffer.port].flag = true; // mark this port as assigned if(ports[portConfigBuffer.port].port != portConfigBuffer.port || ports[portConfigBuffer.port].type != portConfigBuffer.type || ports[portConfigBuffer.port].usbDev != portConfigBuffer.usbDev || ports[portConfigBuffer.port].vid != portConfigBuffer.vid || ports[portConfigBuffer.port].pid != portConfigBuffer.pid) { // this port HAS CHANGED changed = true; ports[portConfigBuffer.port].port = portConfigBuffer.port; ports[portConfigBuffer.port].usbDev = portConfigBuffer.usbDev; ports[portConfigBuffer.port].type = portConfigBuffer.type; ports[portConfigBuffer.port].vid = portConfigBuffer.vid; ports[portConfigBuffer.port].pid = portConfigBuffer.pid; // check incoming device and call process routines if needed //DEBUG_PORT_CONFIG(&portConfigBuffer); if(portConfigBuffer.type == DEVICE_DISK) { //debugPortConfig(&portConfigBuffer); processDisk(&portConfigBuffer); } if(portConfigBuffer.type == DEVICE_NXT) { processNXT(&portConfigBuffer); } } } } for(i=2; i--; ) { if(!ports[i].flag) { if (ports[i].usbDev >= 0) { // this port must now be empty changed = true; ports[i].usbDev = -1; if(ports[i].type == DEVICE_DISK) { ejectDisk(); } if(ports[i].type == DEVICE_NXT) { ejectNXT(); } } } } return(changed); }
// // deviceUpdate() - update the USB devices if necessary. // void VDIP::deviceUpdate() { char incoming[32]; portConfig portConfigBuffer; int i; // Serial.println("attempting device update"); for(i=2; i--; ) { ports[i].flag = false; } // first, get the data for the connected devices - note that only the first // two logical USB ports are checked. If this code supported HUBs, it would // be different, but it doesn't... // Note, too, that each port must be accounted for, or its configuration gets // zero'd out. for (int i = 0; i < 2; i++) { cmd(VDIP_QD,incoming,100,i); // given a configuration buffer, get this port's data mapDevice(i,incoming,&portConfigBuffer); if(portConfigBuffer.port >= 0 && portConfigBuffer.port < 2) { // we have a good assignment ports[portConfigBuffer.port].flag = true; // mark this port as assigned if(ports[portConfigBuffer.port].port != portConfigBuffer.port || ports[portConfigBuffer.port].type != portConfigBuffer.type || ports[portConfigBuffer.port].usbDev != portConfigBuffer.usbDev) { // this port HAS CHANGED ports[portConfigBuffer.port].port = portConfigBuffer.port; ports[portConfigBuffer.port].usbDev = portConfigBuffer.usbDev; ports[portConfigBuffer.port].type = portConfigBuffer.type; // check incoming device and call process routines if needed //DEBUG_PORT_CONFIG(&portConfigBuffer); if(portConfigBuffer.type == DEVICE_DISK) { //debugPortConfig(&portConfigBuffer); processDisk(&portConfigBuffer); } if(portConfigBuffer.type == DEVICE_NXT) { processNXT(&portConfigBuffer); } } } } for(i=2; i--; ) { if(!ports[i].flag) { if (ports[i].usbDev >= 0) { // this port must now be empty ports[i].usbDev = -1; if(ports[i].type == DEVICE_DISK) { ejectDisk(); } if(ports[i].type == DEVICE_NXT) { ejectNXT(); } } } } // Serial.println("done with device update"); }