
#include"stdio.h"
#include"conio.h"
#include"dos.h"
#include"process.h"
#include"alloc.h"
#include"dir.h"
#include"stdlib.h"
#define CGA 1
#define ENTER 13
#define ESC 27
#define YES 1
#define NO 0
#define NO_SHADOW 0
#define HALF_SHADOW -1
char far *vid_mem;
const char *filespec="NONAME.SNG";
char filename[17],*disparea;
int ascii,scan,xgrid,xgridpres=0,ygridpres=0,xgridprev=0,ygridprev=0,ygrid,button=0,pickfileno,notedisp,noteval,saved=YES,load=0,select=0,copy=0,cut=0,mouseinit=0;
int pnoteval=2,dull=0;
float notes=0,volume=1.0,fromnote=0,tonote=0, pitch=0.1;
FILE *filpoint;
struct saptanotes
{
unsigned int valnote;
unsigned int persist;
unsigned int pause;
};
struct saptanotes note;
int octave[13]={130,141,146,159,164,170,174,196,213,220,234,244,260};
char *swara[]={"Sa ","Re ","Re ","Ga ","Ga ","Ma ","Ma ","Pa ","Dha","Dha","Ni ","Ni ","Sa "};
char *mainmenu[]={" ^Record "," ^Edit "," ^Settings "," ^Play "," ^Help "};
char *recordmenu[]={" %New"," %Open"," %Save F2 "," Save %As "," %Close Alt-C "," E%Xit Alt-X "};
char *recorddull[]={" New"," Open"," Save F2 "," Save As "," Close Alt-C "," EXit Alt-X "};
char *settmenu[]={" %Volume "," Pe%Rsistence "," P%Ause "," %Higher Set Alt-U "," Lo%Wer Set Alt-W "};
char *settdull[]={" Volume "," PeRsistence "," PAuse "," Higher Set Alt-U "," LoWer Set Alt-W "};
char *editmenu[]={" %Select "," %Copy "," %Paste "," C%Lear "," Cu%T "," %Merge Alt-M "};
char *editdull[]={" Select "," Copy "," Paste "," CLear "," CuT "," Merge Alt-M "};
char *playmenu[]={" %Load "," Play %Forward "," Play %Backward "," Play %Continous "};
char *playdull[]={" Load "," Play Forward "," Play Backward "," Play Continous "};
// char *helpmenu[]={" %Contents "," %Index Shift-F1 "," %Help on Help "," %About Shift-F10 "};
char *helpmenu[]={" %About Shift-F10 "};
char *msgmenu[]={"Record Management","Editor Operations","Set note qualities","Play Records","Access Help"};
char *mesgmenu[]={
"","","","","","","",
"Create a new Record", "Open a Record",
"Save a Record", "Save a Record under a new name",
"Close an Active Window", "Exit Sapta-Swara",
"Select notes for Edit operation", "Copy the selected notes",
"Insert the selected notes at given position", "Delete the selected notes",
"Remove the selected notes", "Merge two Records",
"Set the Volume", "Set the Persistance of a note",
"Set the delay between two notes", "Upper set of 13 notes",
"Lower set of 13 notes", "",
"Load an existing Record for Play", "Play a single Record forwards",
"Play a single Record backwards", "Play continously upto 20 Records",
"Set the Volume", "",
"Show version and copyright information",
"Show table of contents for online Help", "Show Index for online Help",
"How to use online Help", "Show version and copyright information"
};
char *messgs[]={"^<^E^S^C^> Quit ^F^1 Help",
"Enter name of record for continous play", "Continous Play of Records",
"Delete the selected number of notes", "Select the notes for edit operation",
"Enter source record name for merge operation", "Enter destination record name for merge operation",
"Merging two records", "Deleting notes",
"Play Record Volume", "Enter record name for play operation",
"Accept the settings in this dialog box", "Close dialog box without making any changes",
"Close the dialog box", "Add records to the continous play stack",
"^<^E^s^c^> Close Help"};
char *errormsg[]={" Error! ",
"Record does not exist", " Error! Record should ",
"start with a character", "Record name should be less",
"than 9 characters long", "in Edit operation",
"Record creation error", "Record reading error",
"Record appending error", "Memory allocation error",
"Record deleting error", "Record renaming error",
"Load record in Play mode", "before Play operation",
"Close record first", "before Edit operation",
"Open record in Edit mode", "Select notes from record",
"before Copy operation", "before Cut operation",
"before Clear operation", "before Paste operation",
"before Merge operation", "Specify correct note value",
"before Play continous operation", "before Pause operation",
"before Persist operation", "before Pitch operation",
"before Set operation", "before Volume operation"
};
char *indx[]={
/* 1 */ "", "#A", "", "About",
/* 2 */ "", "#C", "", "Clear", "Close", "Contents", "Copy", "Cut",
/* 3 */ "", "#E", "", "Edit", "Exit",
/* 4 */ "", "#H", "", "Help", "Help on Help", "Higher Set", "Hotkeys",
/* 5 */ "", "#I", "", "Index",
/* 6 */ "", "#K", "", "Keyboard",
/* 7 */ "", "#L", "", "Lower Set", "Load",
/* 8 */ "", "#M", "", "Merge",
/* 9 */ "", "#N", "", "New",
/*10 */ "", "#O", "", "Open",
/*11 */ "", "#P", "", "Paste", "Pause", "Persistence", "Pitch", "Play", "Play Backward", "Play Continuous", "Play Forward",
/*12 */ "", "#R", "", "Record",
/*13 */ "", "#S", "", "Sapta-Swara", "Save", "Save As", "Select", "Settings", "Sound",
/*14 */ "", "#V", "", "Volume",
};
int indxpos[]={
/* 1 */ 0,0,0,55,
/* 2 */ 0,0,0,23,14,50,21,24,
/* 3 */ 0,0,0,2,15,
/* 4 */ 0,0,0,5,52,33,0,
/* 5 */ 0,0,0,51,
/* 6 */ 0,0,0,60,
/* 7 */ 0,0,0,34,40,
/* 8 */ 0,0,0,25,
/* 9 */ 0,0,0,10,
/*10 */ 0,0,0,11,
/*11 */ 0,0,0,22,32,31,30,4,42,43,41,
/*12 */ 0,0,0,1,
/*13 */ 0,0,0,61,12,13,20,3,70,
/*14 */ 0,0,0,44,
};
char *hotkeyindx=
"@@@A@@@C@@@@@@@E@@@@H@@@@@@I@@@K@@@L@@@@M@@@N@@@O@@@P@@@@@@@@@@R@@@S@@@@@@@@V@";
void initmouse()
{
union REGS i,o;
i.x.ax=0;
int86(0x33,&i,&o);
mouseinit=o.x.ax;
}
void hidemsptr()
{
union REGS i,o;
i.x.ax=2;
int86(0x33,&i,&o);
}
void getkey()
{
union REGS i,o,in,out;
int j,v=0,count;
if(mouseinit!=0)
{
in.x.ax=3;
int86(0x33,&in,&out);
button=out.x.bx;
xgrid=out.x.cx;
ygrid=out.x.dx;
}
while(v==0)
{
if(button==1)
{
v=1;
}
else if(kbhit())
{
i.h.ah=0;
int86(22,&i,&o);
ascii=o.h.al;
scan=o.h.ah;
v=1;
}
else if(mouseinit!=0)
{
in.x.ax=3;
int86(0x33,&in,&out);
button=out.x.bx;
xgrid=out.x.cx;
ygrid=out.x.dx;
// gotoxy(40,20);
// printf("%3d-%3d-%3d-%3d-%3d",ascii,scan,*button,*xgrid,*ygrid);
// printf("%3d-%3d-%3d-%3d-%3d",ascii,scan,button,xgrid,ygrid);
// getch();
// getmousepos(&button,&xgrid,&ygrid);
}
}
}
void getkey1()
{
union REGS i,o,in,out;
if(kbhit())
{
i.h.ah=0;
int86(22,&i,&o);
ascii=o.h.al;
scan=o.h.ah;
}
else if(mouseinit!=0)
{
in.x.ax=3;
int86(0x33,&in,&out);
button=out.x.bx;
xgrid=out.x.cx;
ygrid=out.x.dx;
// gotoxy(40,20);
// printf("%3d-%3d-%3d-%3d-%3d",ascii,scan,*button,*xgrid,*ygrid);
// printf("%3d-%3d-%3d-%3d-%3d",ascii,scan,button,xgrid,ygrid);
// getch();
// getmousepos(&button,&xgrid,&ygrid);
}
}
void showms_ptr()
{
union REGS i,o;
i.x.ax=1;
int86(0x33,&i,&o);
}
void writechar(r,c,ch,attb)
int r,c,attb;
char ch;
{
char far *v;
v=vid_mem+r*160+c*2;
*v=ch;
v++;
*v=attb;
}
void writestring(s,r,c,attb)
int r,c,attb;
char *s;
{
while(*s!='\0')
{
if(*s=='^')
{
s++;
if(attb==32)
writechar(r,c,*s,164);
else
writechar(r,c,*s,116);
}
else
{
if(*s=='$')
{
s++;
writechar(r,c,*s,62);
}
else if(*s=='%')
{
s++;
if(attb==112)
writechar(r,c,*s,116);
else
writechar(r,c,*s,36);
}
else if(*s=='#')
{
s++;
writechar(r,c,*s,52);
}
else if(*s=='~')
{
s++;
writechar(r,c,*s,59);
}
else
writechar(r,c,*s,attb);
}
c++;
s++;
}
}
void savevideo(sr,sc,er,ec,buffer)
int sr,sc,er,ec;
char *buffer;
{
char far *v;
int i,j;
for(i=sr; i<=er; i++)
{
for(j=sc; j<=ec; j++)
{
v=vid_mem+i*160+j*2;
*buffer=*v;
v++;
buffer++;
*buffer=*v;
buffer++;
}
}
}
void restorevideo(sr,sc,er,ec,buffer)
int sr,sc,er,ec;
char *buffer;
{
char far *v;
int i,j;
for(i=sr; i<=er; i++)
{
for(j=sc; j<=ec; j++)
{
v=vid_mem+i*160+j*2;
*v=*buffer;
v++;
buffer++;
*v=*buffer;
buffer++;
}
}
}
void size(ssl,esl)
int ssl,esl;
{
union REGS i,o;
i.h.ah=1;
i.h.ch=ssl;
i.h.cl=esl;
i.h.bh=0;
int86(16,&i,&o);
}
void error_exit()
{
writestring("Memory Allocation Error! Press any key...",22,14,112);
fflush(stdin);
getch();
exit(2);
}
void drawbox(sr,sc,er,ec,attr)
int sr,sc,er,ec,attr;
{
int i;
for(i=sc+1; icount)
choice=1;
menubox(sr+choice,sc+1,sr+choice,ec-4,32,NO_SHADOW);
writestring(menu[choice-1],sr+choice,sc+1,32);
switch(helpnumber)
{
case 2:
if(dulln==1)
{
if(choice!=1 && notedisp!=0 && load!=1 && choice!=6)
{
menubox(sr+choice,sc+1,sr+choice,ec-4,8,NO_SHADOW);
writestring(editdull[choice-1],sr+choice,sc+1,8);
}
else if(load==0 && notedisp==0 && choice!=6)
{
menubox(sr+choice,sc+1,sr+choice,ec-4,8,NO_SHADOW);
writestring(editdull[choice-1],sr+choice,sc+1,8);
}
else if(load!=0)
{
menubox(sr+choice,sc+1,sr+choice,ec-4,8,NO_SHADOW);
writestring(editdull[choice-1],sr+choice,sc+1,8);
}
}
break;
case 3:
if(dulln==1 && choice!=1)
{
menubox(sr+choice,sc+1,sr+choice,ec-4,8,NO_SHADOW);
writestring(settdull[choice-1],sr+choice,sc+1,8);
}
break;
case 4:
if(dulln==1 && choice!=1 && choice!=4)
{
menubox(sr+choice,sc+1,sr+choice,ec-4,8,NO_SHADOW);
writestring(playdull[choice-1],sr+choice,sc+1,8);
}
else if(dulln==1 && choice==4 && load==1)
{
menubox(sr+choice,sc+1,sr+choice,ec-4,8,NO_SHADOW);
writestring(playdull[choice-1],sr+choice,sc+1,8);
}
break;
}
//this if for statusline
menubox(24,0,24,79,112,NO_SHADOW);
writestring(messgs[0],24,1,112);
writestring(k,24,21,112);
writestring(mesgmenu[(helpnumber)*6+(choice)],24,23,112);
}
else if(button==1 && (xgrid>=xmin && xgrid<=xmax && ygrid>=ymin && ygrid<=ymax) && ascii==0)
{
if(mouseinit!=0)
hidemsptr();
if(ygrid==ymin && ygrid<=ymax)
return(1);
else if((ygrid==(ymin+8)) && ygrid<=ymax)
return(2);
else if((ygrid==(ymin+16)) && ygrid<=ymax)
return(3);
else if((ygrid==(ymin+24)) && ygrid<=ymax)
return(4);
else if((ygrid==(ymin+32)) && ygrid<=ymax)
return(5);
else if((ygrid==(ymin+40)) && ygrid<=ymax)
return(6);
else if((ygrid==(ymin+48)) && ygrid<=ymax)
return(7);
}
else if(button==0 && (xgrid>=xmin && xgrid<=xmax && ygrid>=ymin && ygrid<=ymax) && ascii==0)
{
int choicealt=0;
if(ygridprev!=ygridpres)
{
if(ygrid==ymin && ygrid<=ymax)
choicealt=1;
else if((ygrid==(ymin+8)) && ygrid<=ymax)
choicealt=2;
else if((ygrid==(ymin+16)) && ygrid<=ymax)
choicealt=3;
else if((ygrid==(ymin+24)) && ygrid<=ymax)
choicealt=4;
else if((ygrid==(ymin+32)) && ygrid<=ymax)
choicealt=5;
else if((ygrid==(ymin+40)) && ygrid<=ymax)
choicealt=6;
else if((ygrid==(ymin+48)) && ygrid<=ymax)
choicealt=7;
if(choicealt>0)
{
if(mouseinit!=0)
hidemsptr();
menubox(sr+choice,sc+1,sr+choice,ec-4,112,NO_SHADOW);
writestring(menu[choice-1],sr+choice,sc+1,112);
// this is for going down the menu items
switch(helpnumber)
{
case 2:
if(dulln==1)
{
if(choice!=1 && notedisp==1 && load!=1 && choice!=6)
writestring(editdull[choice-1],sr+choice,sc+1,120);
else if(load==0 && notedisp==0 && choice!=6)
writestring(editdull[choice-1],sr+choice,sc+1,120);
else if(load!=0 && choice!=6)
writestring(editdull[choice-1],sr+choice,sc+1,120);
}
break;
case 3:
if(dulln==1 && choice!=1)
writestring(settdull[choice-1],sr+choice,sc+1,120);
break;
case 4:
if(dulln==1 && choice!=1 && choice!=4)
writestring(playdull[choice-1],sr+choice,sc+1,120);
break;
}
choice=choicealt;
menubox(sr+choice,sc+1,sr+choice,ec-4,32,NO_SHADOW);
writestring(menu[choice-1],sr+choice,sc+1,32);
// this is for status line
menubox(24,0,24,79,112,NO_SHADOW);
writestring(messgs[0],24,1,112);
writestring(k,24,21,112);
writestring(mesgmenu[helpnumber*6+choice],24,23,112);
// this is for dulling bar of the items
switch(helpnumber)
{
case 2:
if(dulln==1)
{
if(choice!=1 && notedisp!=0 && load!=1 && choice!=6)
{
menubox(sr+choice,sc+1,sr+choice,ec-4,8,NO_SHADOW);
writestring(editdull[choice-1],sr+choice,sc+1,8);
}
else if(load==0 && notedisp==0 && choice!=6)
{
menubox(sr+choice,sc+1,sr+choice,ec-4,8,NO_SHADOW);
writestring(editdull[choice-1],sr+choice,sc+1,8);
}
else if(load!=0 && choice!=6)
{
menubox(sr+choice,sc+1,sr+choice,ec-4,8,NO_SHADOW);
writestring(editdull[choice-1],sr+choice,sc+1,8);
}
}
break;
case 3:
if(dulln==1 && choice!=1)
{
menubox(sr+choice,sc+1,sr+choice,ec-4,8,NO_SHADOW);
writestring(settdull[choice-1],sr+choice,sc+1,8);
}
break;
case 4:
if(dulln==1 && choice!=1 && choice!=4)
{
menubox(sr+choice,sc+1,sr+choice,ec-4,8,NO_SHADOW);
writestring(playdull[choice-1],sr+choice,sc+1,8);
}
else if(dulln==1 && choice==4 && load==1)
{
menubox(sr+choice,sc+1,sr+choice,ec-4,8,NO_SHADOW);
writestring(playdull[choice-1],sr+choice,sc+1,8);
}
break;
}
}
}
ygridprev=ygridpres;
xgridprev=ygridpres;
}
else if(ygrid==0 && ascii==0)
{
// if(mouseinit!=0)
// hidemsptr();
if(xgridprev!=xgridpres)
{
if(xgrid>=24 && xgrid<=64 && helpnumber!=1)
return(24);
else if(xgrid>=128 && xgrid<=152 && helpnumber!=2)
return(128);
else if(xgrid>=216 && xgrid<=272 && helpnumber!=3)
return(216);
else if(xgrid>=336 && xgrid<=360 && helpnumber!=4)
return(336);
else if(xgrid>=424 && xgrid<=448 && helpnumber!=5)
return(424);
xgridprev=xgridpres;
}
}
else if(button==1 && (ygrid==0 || ygrid>0))
return(0);
else
{
if(ascii==13)
return(choice);
if(ascii==ESC)
{
if(mouseinit!=0)
hidemsptr();
displaymenuh(mainmenu,5);
return(ESC);
}
hotkeychoice=1;
ascii=toupper(ascii);
while(*hotkeys!='\0')
{
if(*hotkeys==ascii)
return(hotkeychoice);
else
{
hotkeys++;
hotkeychoice++;
}
}
hotkeys=hotkeys-len;
}
}
}
/* pops up menu vertically */
popupmenuv(menu,count,sr,sc,hotkeys,helpnumber,xmin,xmax,ymin,ymax,dulln)
int count,sr,sc,helpnumber,xmin,xmax,ymin,ymax,dulln;
char **menu,*hotkeys;
{
int er,i,ec,l,len=0,area,choice;
char *p;
size(32,0);
/* calculate ending row for menu*/
er=sr+count+2;
for(i=0; ilen)
len=l;
}
ec=sc+len+5;
area=(er-sr+1)*(ec-sc+1)*2;
p=malloc(area);
if(p==NULL)
{
// errormesg();
}
if(mouseinit!=0)
hidemsptr();
savevideo(sr,sc,er,ec,p);
menubox(sr,sc+1,er,ec,112,15);
drawsbox(sr,sc+2,er-1,ec-3,112);
displaymenuv(menu,count,sr+1,sc+3);
switch(helpnumber)
{
int color,start,stop;
case 2:
color=120;
if(dulln==1)
{
if(notedisp!=0 && load==0)
{
start=1;
stop=4;
displaydull(editdull,start,stop,sr+2,sc+3,color);
}
else if(notedisp==0 && load==0)
{
start=1;
stop=4;
displaydull(editdull,start,stop,sr+2,sc+3,color);
}
else if(load==1)
{
start=0;
stop=4;
displaydull(editdull,start,stop,sr+1,sc+3,color);
}
}
break;
case 3:
start=1;
color=120;
stop=4;
if(dulln==1)
displaydull(settdull,start,stop,sr+2,sc+3,color);
break;
case 4:
color=120;
if(load!=1)
{
start=2;
stop=3;
}
if(dulln==1)
displaydull(playdull,start,stop,sr+2,sc+3,color);
break;
}
if(mouseinit!=0)
showms_ptr();
choice=getresponsev(menu,hotkeys,sr,sc+2,count,helpnumber,xmin,xmax,ymin,ymax,ec);
if(mouseinit!=0)
hidemsptr();
restorevideo(sr,sc,er,ec,p);
if(mouseinit!=0)
showms_ptr();
free(p);
return(choice);
}
/* Receives user's choice for the horizontal menu displayed */
getresponseh(menu,hotkeys,count)
char *hotkeys, **menu;
int count;
{
int choice=1,hotkeychoice,len,col;
char k[1];
size(32,0);
col=2;
len=strlen(hotkeys);
if(mouseinit!=0)
hidemsptr();
writestring(menu[choice-1],0,col,32);
menubox(24,0,24,79,112,NO_SHADOW);
writestring(messgs[0],24,1,112);
sprintf(k,"%c",179);
writestring(k,24,21,112);
writestring(msgmenu[choice-1],24,23,112);
while(1)
{
if(mouseinit!=0)
showms_ptr();
ascii=0;
scan=0;
getkey1();
xgridpres=xgrid;
ygridpres=ygrid;
if(ascii==0 && button==0 && scan!=0)
{
if(mouseinit!=0)
hidemsptr();
switch(scan)
{
case 77:/* right arrow key */
/* make highlighted item normal */
writestring(menu[choice-1],0,col,112);
col+=strlen(menu[choice-1])+4;
choice++;
break;
case 75:/* left arrow key*/
/* make highlighted item normal */
writestring(menu[choice-1],0,col,112);
col-=(strlen(menu[choice-2])+4);
choice--;
break;
case 59:/* function key F1 for help */
displayhelp(choice);
menubox(24,0,24,79,112,NO_SHADOW);
writestring(messgs[0],24,1,112);
writestring(k,24,21,112);
writestring(msgmenu[choice-1],24,23,112);
break;
case 80:// down arrow key
return(choice);
}
/* if highlighted bar is on the first item and left arrow key is hit*/
if(choice==0)
{
choice=count;
col=52;
}
/* if highlighted bar is on the last item and right arrow key is hit*/
if(choice>count)
{
choice=1;
col=2;
}
/* highlight the appropriate menu item */
writestring(menu[choice-1],0,col,32);
/* show the appropriate messages */
menubox(24,0,24,79,112,NO_SHADOW);
writestring(messgs[0],24,1,112);
writestring(k,24,21,112);
writestring(msgmenu[choice-1],24,23,112);
}
else if(ascii==0 && button==1 && ygrid==0)
{
if(xgrid>=24 && xgrid<=64)
{
hidemsptr();
writestring(menu[choice-1],0,col,112);
choice=1;
return(choice);
}
else if(xgrid>=128 && xgrid<=152)
{
hidemsptr();
writestring(menu[choice-1],0,col,112);
choice=2;
return(choice);
}
else if(xgrid>=216 && xgrid<=272)
{
hidemsptr();
writestring(menu[choice-1],0,col,112);
choice=3;
return(choice);
}
else if(xgrid>=336 && xgrid<=360)
{
hidemsptr();
writestring(menu[choice-1],0,col,112);
choice=4;
return(choice);
}
else if(xgrid>=424 && xgrid<=448)
{
hidemsptr();
writestring(menu[choice-1],0,col,112);
choice=5;
return(choice);
}
}
else if(ascii==0 && button==0 && ygrid==0)
{
if(xgridprev!=xgridpres)
{
if(mouseinit!=0)
hidemsptr();
if(xgrid>=24 && xgrid<=64 && choice!=1)
{
writestring(menu[choice-1],0,col,112);
choice=1;
col=2;
}
else if(xgrid>=128 && xgrid<=152 && choice!=2)
{
writestring(menu[choice-1],0,col,112);
choice=2;
col=15;
}
else if(xgrid>=216 && xgrid<=272 && choice!=3)
{
writestring(menu[choice-1],0,col,112);
choice=3;
col=26;
}
else if(xgrid>=336 && xgrid<=360 && choice!=4)
{
writestring(menu[choice-1],0,col,112);
choice=4;
col=41;
}
else if(xgrid>=424 && xgrid<=448 && choice!=5)
{
writestring(menu[choice-1],0,col,112);
choice=5;
col=52;
}
/* highlight the appropriate menu item */
writestring(menu[choice-1],0,col,32);
/* show the appropriate messages */
menubox(24,0,24,79,112,NO_SHADOW);
writestring(messgs[0],24,1,112);
writestring(k,24,21,112);
writestring(msgmenu[choice-1],24,23,112);
}
xgridprev=xgridpres;
}
else
{
if(ascii==13)/* Enter key */
{
return(choice);
}
if(ascii==ESC)/* Esc key*/
{
if(mouseinit!=0)
hidemsptr();
/* make highlighted item normal*/
writestring(menu[choice-1],0,col,112);
if(mouseinit!=0)
showms_ptr();
return(ESC);
}
hotkeychoice=1;
ascii=toupper(ascii);
/* check whether hot key has been pressed */
while(*hotkeys!='\0')
{
if(*hotkeys==ascii)
{
writestring(menu[choice-1],0,col,112);
return(hotkeychoice);
}
else
{
hotkeys++;
hotkeychoice++;
}
}
/* reset variable to point to the first hot key character */
hotkeys=hotkeys-len;
}
}
}
void status_line()
{
menubox(24,0,24,79,112,NO_SHADOW);
writestring(" ^F^1 Help ^F^1^0 Menu ^A^l^t^-^R^ Record ^A^l^t^-^X Exit",24,1,112);
}
void messgline(m1)
int m1;
{
char k[1];
menubox(24,0,24,79,112,NO_SHADOW);
if(m1==15)
{
writestring(messgs[15],24,1,112);
}
else
{
writestring(messgs[0],24,1,112);
sprintf(k,"%c",179);
writestring(k,24,21,112);
writestring(messgs[m1],24,23,112);
}
}
void errormesg(e1,e2)
int e1,e2;
{
int earea,len;
char *erp;
size(32,0);
earea=(12-5+1)*(56-19+1)*2;
erp=malloc(earea);
if(erp==NULL)
{
error_exit();
}
if(mouseinit!=0)
hidemsptr();
savevideo(5,19,12,56,erp);
menubox(5,19,12,56,112,7);
drawbox(5,19,11,55,112);
messgline(11);
writestring(" Error Message ",5,30,127);
len=strlen(errormsg[e1]);
writestring(errormsg[e1],7,37-len/2,116);
len=strlen(errormsg[e2]);
writestring(errormsg[e2],8,37-len/2,116);
menubox(9,33,10,42,32,HALF_SHADOW);
writestring("O",9,36,46);
writestring("K",9,37,47);
if(mouseinit!=0)
showms_ptr();
while(1)
{
if(mouseinit!=0)
showms_ptr();
ascii=0;
scan=0;
button=0;
getkey1();
ascii=toupper(ascii);
if((button==1) && ((xgrid>=264) && (xgrid<=320)) && (ygrid==72))
{
menubox(9,33,10,42,112,NO_SHADOW);
menubox(9,34,9,41,32,NO_SHADOW);
writestring("OK",9,37,46);
delay(300);
break;
}
else if(ascii=='O' || ascii=='o' || ascii==27 || ascii==13)
{
break;
}
}
if(mouseinit!=0)
hidemsptr();
restorevideo(5,19,12,56,erp);
free(erp);
status_line();
if(mouseinit!=0)
showms_ptr();
}
void write_fname(char *filname)
{
int len;
char drive[2],fname[9],ext[3],lname[15];
strcpy(lname," ");
size(32,0);
strupr(filname);
strcat(lname,filname);
strcat(lname," ");
len=strlen(lname);
lname[len+1]='\0';
menubox(7,21,7,56,112,NO_SHADOW);
writestring(lname,7,39-len/2,31);
}
void workscreen()
{
size(32,0);
menubox(1,0,23,79,27,NO_SHADOW);
drawbox(1,0,23,79,31);
menubox(24,0,24,79,112,NO_SHADOW);
status_line();
size(30,0);
}
message(str1,str2)
char *str1,*str2;
{
int area,len,tab=1;
char *strp;
size(32,0);
area=(12-5+1)*(56-19+1)*2;
strp=malloc(area);
if(strp==NULL)
error_exit();
if(mouseinit!=0)
hidemsptr();
savevideo(5,19,12,56,strp);
menubox(5,21,12,56,112,7);
drawbox(5,21,11,54,112);
writestring(" Message ",5,34,127);
len=strlen(str1);
writestring(str1,7,19+18-(len/2),112);
len=strlen(str2);
writestring(str2,8,19+18-(len/2),112);
menubox(9,26,10,32,32,HALF_SHADOW);
writestring("Y",9,27,46);
writestring("es",9,28,47);
menubox(9,40,10,45,32,HALF_SHADOW);
writestring("N",9,41,46);
writestring("o",9,42,32);
if(mouseinit!=0)
showms_ptr();
while(1)
{
if(mouseinit!=0)
showms_ptr();
getkey();
ascii=toupper(ascii);
if(button==1 && ygrid==72)
if(xgrid>=208 && xgrid<=240)
{
ascii='Y';
break;
}
else if(xgrid>=320 && xgrid<=344)
{
ascii='N';
break;
}
if(ascii=='Y' || ascii=='N' || ascii==27 )
break;
else if(ascii==13)
{
if(tab==1)
{
ascii='Y';
break;
}
else if(tab==2)
{
ascii='N';
break;
}
}
else if(ascii==9)
{
tab++;
if(tab>2)
tab=1;
if(tab==1)
{
if(mouseinit!=0)
hidemsptr();
menubox(9,26,10,32,32,HALF_SHADOW);
writestring("Y",9,27,46);
writestring("es",9,28,47);
menubox(9,40,10,45,32,HALF_SHADOW);
writestring("N",9,41,46);
writestring("o",9,42,32);
}
else if(tab==2)
{
if(mouseinit!=0)
hidemsptr();
menubox(9,26,10,32,32,HALF_SHADOW);
writestring("Y",9,27,46);
writestring("es",9,28,32);
menubox(9,40,10,45,32,HALF_SHADOW);
writestring("N",9,41,46);
writestring("o",9,42,47);
}
}
}
restorevideo(5,19,12,56,strp);
free(strp);
if(mouseinit!=0)
showms_ptr();
return(ascii);
}
void errormessg(str1,str2)
char *str1,*str2;
{
int earea,len;
char *erp;
size(32,0);
earea=(12-5+1)*(56-19+1)*2;
erp=malloc(earea);
if(erp==NULL)
error_exit();
if(mouseinit!=0)
hidemsptr();
savevideo(5,19,12,56,erp);
menubox(5,19,12,56,112,7);
drawbox(5,19,11,55,112);
writestring(" Error Message ",5,30,112);
len=strlen(str1);
writestring(str1,7,37-len/2,116);
len=strlen(str2);
writestring(str2,8,37-len/2,116);
menubox(9,33,10,42,32,HALF_SHADOW);
writestring("O",9,36,46);
writestring("K",9,37,47);
if(mouseinit!=0)
showms_ptr();
while(1)
{
if(mouseinit!=0)
showms_ptr();
getkey();
ascii=toupper(ascii);
if((button==1) && ((xgrid>=264) && (xgrid<=320)) && (ygrid==72))
{
menubox(9,33,10,42,112,NO_SHADOW);
menubox(9,34,9,41,32,NO_SHADOW);
writestring("OK",9,37,46);
delay(300);
break;
}
else if(ascii=='O' || ascii=='o' || ascii==27 || ascii==13)
break;
}
if(mouseinit!=0)
hidemsptr();
restorevideo(5,19,12,56,erp);
free(erp);
if(mouseinit!=0)
showms_ptr();
}