#include"RDiskCP.h"staticlongRDiskCPMacDev(){inti;// Check signature and return 0 if doesn't match
for(i=0;i<sizeof(RDiskSig)-1;i++){if(RDiskSigAddr[i]!=RDiskSig[i]){// If signature doesn't match,
// fail if not holding R key
if(!((*((char*)0x175))&0x80)){return0;}}}return1;// Otherwise return 1 if signature matches
}staticvoidRDiskCPUpdate(DialogPtrcpDialog,shortnumItems){GrafPtrsavePort;Handleh;Rectr;shorttype;charstartup,ram;// Get startup and ram from PRAM
RDiskCPReadXPRam(1,4,&startup);RDiskCPReadXPRam(1,5,&ram);// Save GrafPort and set port to dialog before updating items
GetPort(&savePort);SetPort(cpDialog);GetDItem(cpDialog,BootCheckbox+numItems,&type,&h,&r);SetCtlValue((ControlHandle)h,startup&0x01?1:0);GetDItem(cpDialog,MountCheckbox+numItems,&type,&h,&r);SetCtlValue((ControlHandle)h,startup&0x02&&!(startup&0x01)?1:0);HiliteControl((ControlHandle)h,startup&0x01?255:0);GetDItem(cpDialog,RAMCheckbox+numItems,&type,&h,&r);SetCtlValue((ControlHandle)h,startup&0x03&&ram&0x01?1:0);HiliteControl((ControlHandle)h,startup&0x03?0:255);// Restore old GrafPort
SetPort(savePort);}staticvoidRDiskCPHitDev(shortmessage,shortitem,shortnumItems,shortcpPrivateVal,EventRecord*theEvent,void*cdevStorageValue,DialogPtrcpDialog){charstartup,ram;RDiskCPReadXPRam(1,4,&startup);RDiskCPReadXPRam(1,5,&ram);switch(item-numItems){caseBootCheckbox:if(startup&0x01){startup&=0x0F&~0x01;}else{startup=startup&0x0F|0x01;}break;caseMountCheckbox:if(!(startup&0x01)){if(startup&0x02){startup&=0x0F&~0x02;}else{startup=startup&0x0F|0x02;}}break;caseRAMCheckbox:if(startup&0x03){if(ram&0x01){ram=0x00;}else{ram=0x01;}}break;};RDiskCPWriteXPRam(1,4,&startup);RDiskCPWriteXPRam(1,5,&ram);RDiskCPUpdate(cpDialog,numItems);}pascallongmain(shortmessage,shortitem,shortnumItems,shortcpPrivateVal,EventRecord*theEvent,void*cdevStorageValue,DialogPtrcpDialog){longret=(long)cdevStorageValue;// Switch to our A4 world
EnterCodeResource();// Handle message
switch(message){caseinitDev:if(RDiskSigAddr[sizeof(RDiskSig)+4]==0x57){Str15ramSize;ramSize[0]=2;ramSize[1]=RDiskSigAddr[sizeof(RDiskSig)+5];ramSize[2]=RDiskSigAddr[sizeof(RDiskSig)+6];ParamText(ramSize,0,0,0);}else{ParamText("\p16",0,0,0);}casecloseDev:ret=cdevUnset;break;casemacDev:ret=RDiskCPMacDev();break;caseupdateDev:caseactivDev:casedeactivDev:RDiskCPUpdate(cpDialog,numItems);break;casehitDev:RDiskCPHitDev(message,item,numItems,cpPrivateVal,theEvent,cdevStorageValue,cpDialog);break;};// Restore old A4 world and return result
ExitCodeResource();returnret;}