Newsgroups: comp.sys.apple2.programmer Path: news.weeg.uiowa.edu!news.uiowa.edu!hobbes.physics.uiowa.edu!math.ohio-state.edu!howland.reston.ans.net!europa.eng.gtefsd.com!library.ucla.edu!news.ucdavis.edu!hyperion!mock From: mock@hyperion.cs.ucdavis.edu (Kenrick Mock) Subject: Re: TransWarp GS - how to get/set speed? Message-ID: Sender: usenet@ucdavis.edu (News Administrator) Organization: University of California, Davis References: Date: Sun, 10 Oct 1993 18:23:45 GMT X-Original-Newsgroups: comp.sys.apple2.programmer Lines: 230 In article , Ian Brumby wrote: >I'm after code (asm) or info on how to: > >* Detect that there is a TransWarp GS in the system >* Find out the speed of the TWGS >* Set the speed of the TWGS (between Fast/TransWarp) > Here is some old C code that I have for a transwarp Cdev which does the things you are asking about: /* TWGS CDev v2.4 */ #pragma optimize -1 #include "2/Cinclude/types.h" /* APW v1.1 C headers */ #include "2/Cinclude/intmath.h" #include "2/Cinclude/event.h" #include "2/Cinclude/misctool.h" #include "2/Cinclude/quickdraw.h" #include "2/Cinclude/control.h" #define MachineCDEV 1 #define BootCDEV 2 #define Reserved 3 #define InitCDEV 4 #define CloseCDEV 5 #define EventsCDEV 6 #define CreateCDEV 7 #define AboutCDEV 8 #define RectCDEV 9 #define HitCDEV 10 #define RunCDEV 11 #define TWGSID 0xbcff00 #define GetNumISpeed 0xbcff14 #define GetMaxSpeed 0xbcff10 #define GetCurSpeed 0xbcff20 #define SetCurSpeed 0xbcff24 #define GetCurISpeed 0xbcff28 #define SetCurISpeed 0xbcff2c #define GetTWConfig 0xbcff3c #pragma databank 1 #pragma toolcall 1 CtlRecHndl MyCtlRec; int curSpd, showSpd, tw, change, curFreq, maxSpd; char Freq[5], /* 4 plus length byte for PString */ showFreq[] = "0.000 Mhz"; WindowPtr mywinptr; GrafPortPtr oldport; void do_about(winptr); void do_create(winptr); void do_hit(ctlHndl,ctrlID); void do_init(winptr); long TWGS_installed(void); void do_run(void); void calc_speed(void); pascal Long TWGSCDEV(message, data1, data2) int message; long data1, data2; { int i; long result; switch (message) { case MachineCDEV: /* Should disable CDev if no TWGS installed */ /* I don't know how this is enabled, but... */ result = TWGS_installed(); return result; break; case BootCDEV: if (TWGS_installed()) { asm { /* Set to TransWarp at boot time */ jsl GetMaxSpeed jsl SetCurSpeed } } /* end of if */ for (i=0;i<10000;i++); /* show my icon at boot */ return; break; case InitCDEV: do_init(data1); return; break; case CloseCDEV: return;break; case EventsCDEV: return;break; case CreateCDEV: do_create(data1); return; break; case AboutCDEV: do_about(data1); return; break; case RectCDEV: return;break; case HitCDEV: do_hit(data1, data2); return; break; case RunCDEV: do_run(); return; break; } /* end of switch message */ return result; } /* end of TWGSCDEV */ #pragma databank 0 #pragma toolcall 0 void do_about(winptr) /* Draw Help Text */ WindowPtr winptr; { NewControl2(winptr,2,1L); /* resource 0x1 */ } /* end of do_about */ void do_create(winptr) /* Draw Popup Menu */ WindowPtr winptr; { if (TWGS_installed()) MyCtlRec = NewControl2(winptr,2,2L); /* resource 0x2 */ else NewControl2(winptr,2,3L); /* resource 0x3 */ } /* end of do_create */ void do_hit(ctlHndl,ctrlID) /* Change Speed because the Menu was selected */ CtlRecHndl ctlHndl; long ctrlID; { if (ctrlID == 2) { change = GetCtlValue(ctlHndl); switch (change) { case 1: asm { /* Set Speed to Normal */ ldx #0 jsl SetCurISpeed } break; case 2: asm { /* Set Speed to Fast */ ldx #1 jsl SetCurISpeed } break; case 3: asm { /* Set Speed to TransWarp */ jsl GetMaxSpeed jsl SetCurSpeed } break; } /* end of switch change */ calc_speed(); /* update Mhz display */ } /* end of if ctrlID == 2 */ } /* end of do_hit */ void do_init(winptr) /* Adjust menu to correct Speed */ WindowPtr winptr; { mywinptr = winptr; if (TWGS_installed()){ asm { jsl GetCurISpeed ;Index? stx curSpd jsl GetTWConfig ;Cheating, but it beats the Firmware sta tw } /* end of asm */ switch (curSpd) { /* Set correct menu item */ case 0: showSpd = 1;break; case 1: if (tw & 0x4) { showSpd =3; break; } else showSpd = 2;break; default: showSpd =3;break; } /* end of switch curSpd */ SetCtlValue(showSpd,MyCtlRec); } /* end of if TWGS_installed */ } /* end of do_init */ long TWGS_installed(void) { long installed; installed = 0; asm { lda >TWGSID cmp #0x5754 ;"WT" TW reversed bne NotTWGS lda >TWGSID+2 cmp #0x5347 ;"SG" GS reversed bne NotTWGS sta installed NotTWGS: nop } /* end of asm */ return installed; } /* end of TWGS_installed */ void do_run(void) { if (TWGS_installed()) { do_init(mywinptr); /* Set popup menu to current speed */ oldport = GetPort(); /* Get CDev window */ SetPort(mywinptr); calc_speed(); SetPort(oldport); /* Go back to original window */ } /* End of if TWGS_installed */ } /* End of do_run */ void calc_speed(void) { asm { jsl GetMaxSpeed sta maxSpd jsl GetTWConfig ;Cheating, but it beats the Firmware sta tw jsl GetCurSpeed ;Frequency? sta curFreq } if ((curFreq == 2600) && (tw & 0x4)) curFreq = maxSpd; Int2Dec(curFreq, Freq, 4, 0); showFreq[0] = Freq[0]; showFreq[2] = Freq[1]; showFreq[3] = Freq[2]; showFreq[4] = Freq[3]; MoveTo(150,30); DrawCString(showFreq); /* Show selected speed in Mhz */ } /* End of calc_speed */