home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************/
- /* */
- /* GALerTest - testprogram for the hardware */
- /* */
- /* Soft- and Hardware copyright (c)1991 */
- /* by Christian Habermann */
- /* Asamstr. 17 */
- /* 85356 Freising */
- /* Germany */
- /* */
- /* used Compiler: SAS-C 6.0 */
- /* */
- /****************************************************************/
-
-
-
- #include <exec/memory.h>
- #include <exec/ports.h>
- #include <exec/types.h>
- #include <intuition/intuition.h>
- #include <libraries/locale.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
-
- #include <proto/locale.h>
- #include <proto/graphics.h>
- #include <proto/intuition.h>
- #include <proto/exec.h>
-
- #include "GALer.h"
- #include "LocGT.h"
-
-
- #ifdef LATTICE
- int CXBRK(void) { return(0); } /* Disable Lattice CTRL/C handling */
- int chkabort(void) { return(0); } /* really */
- #endif
-
-
-
- #define YPOS 30
-
-
-
- void Clear(void);
-
- void Print(UBYTE *text);
-
- void WaitForAction(void);
-
- void closestuff(void);
-
- void openstuff(void);
-
- int GetTimer(void);
-
- void FreeTimer(void);
-
-
-
- struct MsgPort *timeport;
- struct timerequest *timereq;
- struct LocaleBase *LocaleBase;
- struct IntuitionBase *IntuitionBase;
- struct GfxBase *GfxBase;
- struct IntuiMessage *message;
- struct Window *window;
- struct RastPort *rp;
- struct TextFont *txtfont;
- struct TextAttr txtattr;
- struct Catalog *catalog;
-
-
-
- SHORT BorderVectors1a[] = { 0,15,81,15,81,0 };
- SHORT BorderVectors1b[] = { 0,15,0,0,81,0 };
-
- struct Border Border1b = { -1,-1,2,0,JAM1,3,BorderVectors1b,NULL };
- struct Border Border1a = { -1,-1,1,0,JAM1,3,BorderVectors1a,&Border1b };
-
-
-
- struct IntuiText GadIText3 = { 1, 0, JAM2, 4, 4, &txtattr, NULL, NULL };
-
- struct IntuiText GadIText2 = { 1, 0, JAM2, 4, 4, &txtattr, NULL, NULL };
-
- struct IntuiText GadIText1 = { 1, 0, JAM2, 8, 4, &txtattr, NULL, NULL };
-
-
-
- struct Gadget CancelGad = { NULL, 522, 180, 80, 14,
- NULL,
- RELVERIFY,
- BOOLGADGET+REQGADGET,
- (APTR)&Border1a,NULL,
- &GadIText2,NULL,NULL,1,NULL };
-
- struct Gadget ContGad = { &CancelGad, 40, 180, 80, 14,
- NULL,
- RELVERIFY,
- BOOLGADGET+REQGADGET,
- (APTR)&Border1a,NULL,
- &GadIText1,NULL,NULL,0,NULL };
-
-
-
-
- struct NewWindow MyWin = { 0,0,640,200,
- 0,1,
- CLOSEWINDOW|GADGETUP,
- ACTIVATE|WINDOWCLOSE|WINDOWDRAG|WINDOWDEPTH,
- &ContGad,NULL,
- (UBYTE *)"GALerTest (c) 1993 by Christian Habermann",
- NULL,NULL,
- 0,0,0,0,
- WBENCHSCREEN
- };
-
-
-
-
- int prog_volt = 0; /* Dummy for port.o module */
-
- int GALType, outIC1, outIC3, outIC4, outIC5;
-
- int ytxt = YPOS;
-
-
-
-
- void main(void)
- {
-
- int errorIC6, errorIC7;
-
-
- openstuff();
-
- if (GetTimer()) { /* get timer*/
- puts(GetCatalogStr(catalog, MSG_ERR_TIMER, "can't get timer"));
- closestuff();
- exit(FALSE);
- }
-
-
- rp = window -> RPort;
-
- SetAPen(rp, 1L);
- SetFont(rp, txtfont); /* get font */
-
-
-
- InitParPort(); /* set CIAs */
-
- InitGALer();
-
- Print(GetCatalogStr(catalog, MSG_INTRO_TXT,
- "This is a program for testing the hardware V1.2 of the GALer project.\n"
- "You need this program to adjust the trimpots R40-44 too.\n"
- "IMPORTANT: There must be no GAL in the Textool socket now!\n\n"
- "If the hardware works not as the test program demands, then\n"
- "you should cancel 'GALerTest' immediately and try to remove the\n"
- "bug in your hardware.\n\n"
- "Please select the 'Continue' gadget to start the test."
- ));
- WaitForAction();
-
-
- Clear();
- Print(GetCatalogStr(catalog, MSG_TEST1_TXT,
- "Now the LED should be off and all pins of the Textool socket should\n"
- "be set at LOW level (about 0 volt).\n\n"
- "Please select 'Continue'!"
- ));
- EnableOutput();
- WriteByte(0x00,IC3);
- WriteByte(0x00,IC4);
- WriteByte(0x00,IC5);
- WaitForAction();
-
-
- Clear();
- Print(GetCatalogStr(catalog, MSG_TEST2_TXT,
- "Now the LED should be on.\n\n"
- "Please select 'Continue'!"
- ));
- LED(ON);
- WaitForAction();
-
-
- Clear();
- Print(GetCatalogStr(catalog, MSG_TEST3_TXT,
- "Now the LED should be off again.\n\n"
- "Please select 'Continue'!"
- ));
- LED(OFF);
- WaitForAction();
-
-
- Clear();
- Print(GetCatalogStr(catalog, MSG_TEST4_TXT,
- "At pin 24 of the Textool socket should be a HIGH level (about 5 volt).\n\n"
- "Please select 'Continue'!"
- ));
- SetGAL(GAL20V8);
- EnableVcc();
- WaitForAction();
-
-
- Clear();
- Print(GetCatalogStr(catalog, MSG_TEST5_TXT,
- "At pin 22 of the Textool socket should be a HIGH level too.\n\n"
- "Please select 'Continue'!"
- ));
- DisableVcc();
- SetGAL(GAL16V8);
- EnableVcc();
- WaitForAction();
-
-
- Clear();
- Print(GetCatalogStr(catalog, MSG_TEST6_TXT,
- "At all pins should be a HIGH level with exception of pin 12.\n"
- "Pin 12 is GND.\n\n"
- "Please select 'Continue'!"
- ));
- InitGALer();
- EnableOutput();
- WriteByte(0xff,IC3);
- WriteByte(0xff,IC4);
- WriteByte(0xff,IC5);
- WaitForAction();
-
-
- Clear();
- Print(GetCatalogStr(catalog, MSG_TEST7_TXT,
- "At pins 1, 3, 5, 7, 9, 11, 14, 16, 18, 20, 22, 24 should be a HIGH level.\n"
- "All other pins should be LOW.\n\n"
- "Please select 'Continue'!"
- ));
- SetGAL(GAL20V8);
- EnableVcc();
- WriteByte(0x55,IC3);
- WriteByte(0x55,IC4);
- WriteByte(0x55,IC5);
- WaitForAction();
-
-
- Clear();
- Print(GetCatalogStr(catalog, MSG_TEST8_TXT,
- "Now at pins 2, 4, 6, 8, 10, 13, 15, 17, 19, 21, 23 should be a HIGH level.\n"
- "All other pins should be LOW.\n\n"
- "Please select 'Continue'!"
- ));
- DisableVcc();
- WriteByte(0xaa,IC3);
- WriteByte(0xaa,IC4);
- WriteByte(0xaa,IC5);
- WaitForAction();
-
- DisableVcc();
- InitGALer();
- EnableOutput();
- VeditOn();
-
-
- Clear();
- Print(GetCatalogStr(catalog, MSG_TEST9_TXT,
- "***************************************************************************\n"
- "Now you have to adjust the trimpots R40-R44.\n"
- "If this does not work, check IC 9, IC 10, T3, T4.\n\n"
- "Use trimpot R40 to adjust the voltage at pin 2 to exactly 16.5V.\n"
- "Please select 'Continue'!\n\n"
- ));
- SetVolt(0);
- SetGAL(GAL20V8);
- EnableVEdit();
- WaitForAction();
-
-
- Print(GetCatalogStr(catalog, MSG_TEST10_TXT,
- "Use trimpot R41 to adjust the voltage at pin 2 to exactly 15.75V.\n"
- "Please select 'Continue'!\n\n"
- ));
- SetVolt(1);
- WaitForAction();
-
-
- Print(GetCatalogStr(catalog, MSG_TEST11_TXT,
- "Use trimpot R42 to adjust the voltage at pin 2 to exactly 14.5V.\n"
- "Please select 'Continue'!\n\n"
- ));
- SetVolt(2);
- WaitForAction();
- Print("");
-
-
- Print(GetCatalogStr(catalog, MSG_TEST12_TXT,
- "Use trimpot R43 to adjust the voltage at pin 2 to exactly 14.0V.\n"
- "Please select 'Continue'!\n\n"
- ));
- SetVolt(3);
- WaitForAction();
- Print("");
-
-
- Print(GetCatalogStr(catalog, MSG_TEST13_TXT,
- "Use trimpot R44 to adjust the voltage at pin 2 to exactly 12.0V.\n"
- "Please select 'Continue'!\n\n"
- ));
- SetVolt(4);
- WaitForAction();
-
-
- Print(GetCatalogStr(catalog, MSG_TEST14_TXT,
- "O.K., now all voltages are adjusted. Let me do some other tests.\n"
- "Please select 'Continue'!\n"
- "***************************************************************************"
- ));
- WaitForAction();
- Clear();
-
-
- Print(GetCatalogStr(catalog, MSG_TEST15_TXT,
- "Now at pin 4 should be a voltage of 12.0V and pin 2 should be\n"
- "at LOW level. If this does not work, check T1, T2.\n\n"
- "Please select 'Continue'!"
- ));
- DisableVEdit();
- SetGAL(GAL16V8);
- EnableVEdit();
- WaitForAction();
- Clear();
-
-
-
-
- /* check GALer's read functions */
- Print(GetCatalogStr(catalog, MSG_TEST16_TXT,
- "Now I'm trying to read pins 14-22 of the Textool socket...\n"
- ));
- SetGAL(GAL20V8);
- InitGALer();
- EnableVcc();
- EnableOutput();
- /*IC6a testen*/
- errorIC6 = errorIC7 = 0;
- WriteByte(0x40,IC3);
- if (!ReadByte(IC6))
- errorIC6 = 1;
-
- WriteByte(0x00,IC3);
- if (ReadByte(IC6))
- errorIC6 = 1;
- /*IC7 testen*/
- WriteByte(0x00,IC5);
- if (ReadByte(IC7))
- errorIC7 = 1;
-
- WriteByte(0x2A,IC3);
- WriteByte(0x20,IC5);
- if (ReadByte(IC7) != 0xAA)
- errorIC7 = 1;
-
- WriteByte(0x15,IC3);
- WriteByte(0x10,IC5);
- if (ReadByte(IC7) != 0x55)
- errorIC7 = 1;
-
- DisableVcc();
- DisableOutput();
-
- if (errorIC6 || errorIC7) {
-
- Print(GetCatalogStr(catalog, MSG_TEST17_TXT,
- " ERROR!!!\n"
- " There must be an error at the BUSY line, R27, IC8, IC6a, IC6b, IC7\n"
- " or R13. Please check this components.\n\n"
- " Description of error:\n"
- ));
-
- if (errorIC6 && !errorIC7) {
- Print(GetCatalogStr(catalog, MSG_TEST18_TXT,
- " I can't read pin 22 through the BUSY line of the parallel port."
- ));
- }
-
- if (!errorIC6 && errorIC7) {
- Print(GetCatalogStr(catalog, MSG_TEST19_TXT,
- " I can't read pins 14-21 through the BUSY line of the parallel port."
- ));
- }
-
- if (errorIC6 && errorIC7) {
- Print(GetCatalogStr(catalog, MSG_TEST20_TXT,
- " I can't read pins 14-21 and pin 22 through the BUSY line of the\n"
- " parallel port."
- ));
- }
-
- }
- else {
-
- Print(GetCatalogStr(catalog, MSG_TEST21_TXT,
- "O.K., no error found (you have a lot going for you).\n\n"
- "If you have found no errors and if you have adjusted all voltages\n"
- "(12V, 14V, 14.5V, 15.75V and 16.5V), GALer works fine.\n\n"
- "Now you can read/program GALs by using the software called GALer."
- ));
- }
-
- CancelGad.GadgetText = &GadIText3;
- OffGadget(&ContGad, window, NULL);
- RefreshGList(&ContGad, window, NULL, -1);
-
- WaitForAction();
-
-
- RestoreParPort();
-
- FreeTimer();
-
- closestuff();
- }
-
-
-
-
-
- /* get timer
- */
- int GetTimer(void)
- {
-
- timeport = CreatePort(0L,0L);
- if (timeport == NULL)
- return(-1);
-
- timereq=(struct timerequest *)AllocMem(
- (long)sizeof(struct timerequest),MEMF_PUBLIC);
- if (timereq == NULL) {
- DeletePort(timeport);
- return(-1);
- }
-
- timereq->tr_node.io_Message.mn_Node.ln_Type=NT_MESSAGE;
- timereq->tr_node.io_Message.mn_Node.ln_Pri=0;
- timereq->tr_node.io_Message.mn_ReplyPort=timeport;
-
- if (OpenDevice(TIMERNAME, UNIT_MICROHZ, (struct IORequest *)timereq, 0L)) {
- FreeMem(&timereq, (long)sizeof(struct timerequest));
- DeletePort (timeport);
- return(-1);
- }
-
- return(0);
- }
-
-
-
-
- /* free timer
- */
- void FreeTimer(void)
- {
- CloseDevice((struct IORequest *)timereq);
-
- FreeMem(timereq, (long)sizeof(struct timerequest));
-
- DeletePort(timeport);
- }
-
-
-
- /*micro: microsec. to wait
- secs: seconds to wait
- */
- void WaitForTimer(ULONG micro)
- {
-
- timereq->tr_node.io_Command=TR_ADDREQUEST;
- timereq->tr_time.tv_secs=0;
- timereq->tr_time.tv_micro=micro;
-
- DoIO((struct IORequest *)timereq);
-
- }
-
-
-
-
- /* clear window
- */
- void Clear(void)
- {
-
- ytxt = YPOS;
-
- SetAPen(rp, 0L);
-
- RectFill(rp, 10L, 22L, 630L, 170L);
-
- SetAPen(rp, 1L);
-
- }
-
-
-
-
- /* print text
- */
- void Print(UBYTE *text)
- {
- UBYTE *ptr;
- int notready;
-
-
- ptr = text;
-
- notready = 1;
-
- while (notready) {
- /* search CR or end of */
- while ((*ptr != 0x00) && (*ptr != 0x0A)) /* string */
- ptr++;
-
-
- if (ytxt < 160)
- ytxt += 10;
- else
- ScrollRaster(rp,0L,10L,10L,22L,630L,170L);
-
-
- if (*text != 0x0A) {
- Move(rp, 20L, (long)ytxt); /* print string */
- Text(rp, text, (long)(ptr - text));
- }
-
- if (!*ptr)
- notready = 0;
-
- text = ++ptr;
-
- }
-
- }
-
-
-
-
-
- /* wait until gadget is selected
- */
- void WaitForAction(void)
- {
- ULONG class;
- USHORT code,gadID;
-
- for(;;) {
-
- Wait(1L << window->UserPort->mp_SigBit);
-
- if (message = (struct IntuiMessage *)GetMsg(window->UserPort)) {
-
- class = message -> Class;
- code = message -> Code;
-
- if (class == GADGETUP)
- gadID = ((struct Gadget *)message->IAddress)->GadgetID;
-
- ReplyMsg((struct Message *)message);
-
- switch(class) {
-
- case CLOSEWINDOW: closestuff(); /* exit GALerTest */
- FreeTimer();
- RestoreParPort();
- exit(0);
- break;
-
- case GADGETUP: if (!gadID)
- return;
- else { /* cancel selected */
- closestuff();
- FreeTimer();
- RestoreParPort();
- exit (0);
- }
- break;
- }
- }
- }
- }
-
-
-
-
-
- /* close window, libs...
- */
- void closestuff(void)
- {
- if (window) CloseWindow(window);
-
- if (GfxBase) CloseLibrary((struct Library *)GfxBase);
-
- if (IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
-
- if (LocaleBase) CloseLibrary((struct Library *)LocaleBase);
-
- }
-
-
-
-
- /* open window, libs...
- */
- void openstuff(void)
- {
-
- if (!(LocaleBase = (struct LocaleBase *)OpenLibrary("locale.library", 38L))) {
- puts("can't open locale.library version 38");
- exit(FALSE);
- }
-
- catalog = OpenCatalog(NULL, (STRPTR)"GALerTest.catalog", OC_Version, 1, TAG_DONE);
-
-
- if (!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37L))) {
- puts (GetCatalogStr(catalog, MSG_ERR_INTLIB, "can't open intuition.library V37"));
- closestuff();
- exit(FALSE);
- }
-
- if (!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 37L))) {
- puts (GetCatalogStr(catalog, MSG_ERR_GRAPHLIB, "can't open graphics.library V37"));
- closestuff();
- exit(FALSE);
- }
-
-
- txtattr.ta_Name = (STRPTR)"topaz.font"; /* get font */
- txtattr.ta_YSize = 8;
- txtattr.ta_Style = 0;
- txtattr.ta_Flags = 0;
-
- if (!(txtfont = (struct TextFont *)OpenFont(&txtattr))) {
- puts(GetCatalogStr(catalog, MSG_ERR_FONT, "can't get topaz.font 8"));
- closestuff();
- exit(FALSE);
- }
-
-
- /* localize gadgets */
-
- GadIText3.IText = GetCatalogStr(catalog, MSG_END_GAD, " END ");
-
- GadIText2.IText = GetCatalogStr(catalog, MSG_CANCEL_GAD, " Cancel");
-
- GadIText1.IText = GetCatalogStr(catalog, MSG_CONT_GAD, "Continue");
-
-
- if (!(window = (struct Window *)OpenWindow(&MyWin))) {
- puts (GetCatalogStr(catalog, MSG_ERR_WIN, "can't open window"));
- closestuff();
- exit(FALSE);
- }
- }
-
-
-
-
-