#include /* module command9 */ #include #include #include #include #include #include #include #include #include #include #include #include #include union REGS inregs,outregs; /***************************************************************************/ sparcmnd(void) /* define spare command outputs */ { char *pointer,string[30]; int cmnd,index,fail=0,i,k,m=0,n=0,nold=0,mold=0,x,dx,y,color; int dur,level; if(inlog()||inhist()||insimu()) { clkey(); goto abort; } if(parse[4]!=CR) { cmnd=atoi(&parse[4]); /* command number */ if(cmnd<1||cmnd>16) goto failed; index=cmnd-1; n=comma(2)-comma(1)-1; /* argument length */ if(n>0) { if(n>10) goto failed; for(i=0;i<=9;i++) cname[i+10*index]=0; strncpy(string,&parse[comma(1)+1],n); /* command */ string[n]=0; strcpy(&cname[0]+10*index,string); } level=parse[comma(2)+1]; /* assertion level */ if((level!='L')&&(level!='H')) goto failed; cname1[index]=level; level=parse[comma(3)+1]; /* boot level */ if((level!='L')&&(level!='H')) goto failed; cname2[index]=level; dur=parse[comma(4)+1]; /* duration */ if(dur<0x30||dur>0x39) goto failed; cname3[index]=dur; clkey(); goto abort; } clear(); /* clear entire screen */ font(1); text(PALEBLUE,40,479,"USER-DEFINED COMMANDS"); txnumber(); text(WHITE,70,420,"NAME"); tex(190,420,"ASSERTION"); tex(340,420,"BOOT LEVEL"); tex(490,420,"DURATION"); rect(DARKGREY,0,80,25,405); for(i=0;i<=15;i++) { y=400-20*i; text(WHITE,5,y,itoa(i+1,numb,10)); /* sequence */ pointer=&cname[0]+10*i; strncpy(string,pointer,10); string[10]=0; text(PALEBLUE,50,y,string); /* command name */ if(cname1[i]=='H') strcpy(string,"HIGH"); else strcpy(string,"LOW"); tex(200,y,string); /* assertion level */ if(cname2[i]=='H') strcpy(string,"HIGH"); else strcpy(string,"LOW"); tex(350,y,string); /* boot level */ pointer=&cname3[0]+i; strncpy(string,pointer,1); string[1]=0; tex(500,y,string); /* duration */ } clkey(); message(WHITE,"USE CURSOR KEYS OR CLICK LEFT TO SELECT, Esc OR CLICK BOTH TO EXIT"); onmouse(); while(!kbhit()) { odapc(); switch(click()) /* mouse button */ { case 1: /* left click */ x=outregs.x.cx; y=479-outregs.x.dx; m=(x-50)/150; if(m>3) m=0; n=(400-y)/20; if((n>15)||(n<0)) n=0; goto exec; case 3: /* both click */ k=ESC; goto abort; } } k=caps(); if(k>128) cursor: switch(k) { case LEFT: --m; if(m==-1) m=3; /* wrap */ break; case RIGHT: ++m; if(m==4) m=0; /* wrap */ break; case UP: --n; if(n==-1) n=15; /* wrap */ break; case DOWN: ++n; if(n==16) n=0; /* wrap */ break; case HOME: n=0; break; case END: n=15; break; default: goto key; } else { key: keyboard[0]=k; if(k<128) prompt(keyboard); goto abort; } exec: offmouse(); x=50+mold*150; y=400-20*nold; rect(BLACK,x,y,x+70,y-10); texcolor(PALEBLUE); switch(mold) { case 0: pointer=&cname[0]+10*nold; strncpy(string,pointer,10); string[10]=0; tex(x,y,string); break; case 1: if(cname1[nold]=='H') strcpy(string,"HIGH"); else strcpy(string,"LOW"); tex(x,y,string); break; case 2: if(cname2[nold]=='H') strcpy(string,"HIGH"); else strcpy(string,"LOW"); tex(x,y,string); break; case 3: pointer=&cname3[0]+nold; strncpy(string,pointer,1); string[1]=0; tex(x,y,string); break; } x=50+m*150; y=400-20*n; dx=70; if(m) dx=30; rect(BLUE,x,y,x+dx,y-10); texcolor(WHITE); switch(m) { case 0: pointer=&cname[0]+10*n; strncpy(string,pointer,10); string[10]=0; tex(x,y,string); break; case 1: if(cname1[n]=='H') strcpy(string,"HIGH"); else strcpy(string,"LOW"); tex(x,y,string); break; case 2: if(cname2[n]=='H') strcpy(string,"HIGH"); else strcpy(string,"LOW"); tex(x,y,string); break; case 3: pointer=&cname3[0]+n; strncpy(string,pointer,1); string[1]=0; tex(x,y,string); break; } nold=n; mold=m; color=LIGHTGREEN; switch(m) { case 0: message(color,"ENTER NAME (10 CHARS MAX)"); break; case 1: message(color,"TOGGLE ASSERTION LEVEL WITH Enter"); break; case 2: message(color,"TOGGLE BOOT LEVEL WITH Enter"); break; case 3: message(color,"ENTER DURATION ('0' to '9' tenths of a second)"); break; } onmouse(); while(!kbhit()) { odapc(); switch(click()) /* mouse button */ { case 1: /* left click */ x=outregs.x.cx; y=479-outregs.x.dx; m=(x-50)/150; if(m>3) m=0; n=(400-y)/20; if((n>15)||(n<0)) n=0; goto exec; case 3: /* both click */ k=ESC; goto abort; } } k=caps(); if(k>128) goto cursor; if(k==ESC) goto abort; if(k!=CR) { keyboard[0]=k; prompt(keyboard); while(console()!=CR); keyboard[10]=0; } if(m) keyboard[1]=0; rect(BLACK,x,y-20,x+150,y); /* erase old value */ switch(m) { case 0: for(i=0;i<=9;i++) cname[i+10*n]=keyboard[i]; text(GREEN,x,y,keyboard); /* display new value */ break; case 1: if(cname1[n]=='L') /* toggle assertion level */ { cname1[n]='H'; strcpy(string,"HIGH"); } else { cname1[n]='L'; strcpy(string,"LOW"); } text(GREEN,x,y,string); break; case 2: if(cname2[n]=='L') /* toggle boot level */ { cname2[n]='H'; strcpy(string,"HIGH"); } else { cname2[n]='L'; strcpy(string,"LOW"); } text(GREEN,x,y,string); break; case 3: cname3[n]=keyboard[0]; text(GREEN,x,y,keyboard); /* display new value */ break; } clkey(); goto cursor; failed: clkey(); illarg(); fail=1; status[12]|=0x01; /* command failed */ abort: savcname(); /* update hard drive */ refresh=1; return(fail); }