home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Elysian Archive
/
AmigaElysianArchive.iso
/
sound
/
midi
/
k1ed_v5_.lha
/
src
/
k1.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-10-31
|
28KB
|
1,119 lines
#include <libraries/arpbase.h>
#include <arpfunctions.h>
#include <arp_prag.h>
#include "inc.h"
#include "defs.h"
#include "gad.h"
#include "zz_pointer.h"
#include <exec/ports.h>
#include <exec/execbase.h>
#include <devicetoolkits/input.h>
#include <deviceToolKits/proto/Input.h>
#include <deviceToolKits/InputBase.h>
typedef void (*VoidFunc)();
DTInput_t Unit0;
struct Interrupt handler_setup;
struct InputEvent event_copy;
int found_key;
int event_count;
long col[4];
APTR GetA4();
void ManxHandler();
#asm
xdef _ManxHandler
xdef _GetA4
xref _ehandler
_GetA4:
move.l a4,d0
rts
_ManxHandler:
movem.l d2-d7/a2-a6,-(sp)
move.l a1,a4
move.l a0,-(sp)
jsr _ehandler
addq.l #4,sp
movem.l (sp)+,d2-d7/a2-a6
rts
#endasm
APTR ehandler(struct InputEvent *events)
{
struct InputEvent *ep, *laste;
event_count++;
for (ep = events, laste = NULL; ep != NULL; ep = ep->ie_NextEvent)
{
if ((ep->ie_Class == IECLASS_RAWKEY) && (ep->ie_Code == 0x41) && (ep->ie_Qualifier & IEQUALIFIER_RSHIFT))
{
if (laste == NULL) events = ep->ie_NextEvent;
else laste->ie_NextEvent = ep->ie_NextEvent;
if (SCREEN==NULL)
{
struct Screen *sr=IntuitionBase->FirstScreen;
MoveScreen(sr,-(sr->LeftEdge),-(sr->TopEdge));
WBenchToFront();
WindowToFront(win);
Forbid();
BeginRefresh(win);
RefreshWindowFrame(win);
EndRefresh(win,code);
Permit();
}
else
{
MoveScreen(scr,-(scr->LeftEdge),-(scr->TopEdge));
ScreenToFront(scr);
}
event_copy = *ep;
goto Ende;
}
else laste = ep;
Ende: ;
}
return ((APTR) events);
}
struct ExtendedColorRequester colstruct;
extern struct ExecBase *SysBase;
void main(int argc, char **argv);
void DisplayBank(void);
void DisplayMulti(void);
void CheckWbCall(int argc, char **argv);
void Colours();
void InitializeAll(int);
void SingleCopyTo(int);
void SingleSwapWith(int);
void MultiCopyTo(int);
void MultiSwapWith(int);
void Quit(void);
void SaveOldColours(void);
void SetColours(void);
void SetOldColours(void);
void GetColours(void);
void Help(void);
int initsing[88]=
{ 83, 105, 110, 103, 108, 101, 32, 75, 45, 49, 40, 0, 80, 50, 62, 2, 50,
0, 50, 0, 50, 50, 12, 50, 50, 50, 50, 84, 84, 84, 84, 28, 29, 28, 29, 14,
14, 14, 14, 100, 100, 100, 100, 0, 0, 0, 0, 10, 10, 10, 10, 20, 20, 20,
20, 100, 100, 100, 100, 20, 20, 20, 20, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 104 };
int initmul[76]=
{ 77, 85, 76, 84, 73, 32, 75, 45, 49, 32, 99, 0, 1, 2, 3, 4, 5, 6, 7, 0, 0,
0, 0, 0, 0, 0, 0, 127, 127, 127, 127, 127, 127, 127, 127, 16, 16, 16, 16,
16, 16, 16, 16, 64, 64, 64, 64, 64, 64, 64, 64, 24, 24, 24, 24, 24, 24, 24,
24, 50, 50, 50, 50, 50, 50, 50, 50, 100, 100, 100, 100, 100, 100, 100, 100, 0 };
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void main(int argc,char **argv)
{
int i;
long code,volume;
struct ArpBase *ArpBase;
struct Gadget *gad;
long status;
multi=0;
strcpy(bankdir,"kawai:banks");
strcpy(sounddir,"kawai:sounds");
strcpy(multidir,"kawai:multi");
strcpy(dumpdir,"kawai:dump");
if (!strcmp(getenv("K1-LIB"),"TRUE"))
{
BOOL ergeb;
IntuitionBase=(struct IntuitionBase *) OpenLibrary("intuition.library",0);
ergeb=BoolRequest("K1 Librarian is already running","Go on","Leave");
if (ergeb==FALSE)
{
CloseLibrary(IntuitionBase);
exit(5);
}
}
OpenStuff();
SaveOldColours();
GetColours();
setenv("K1-LIB","TRUE");
CheckWbCall(argc,argv);
Gadget1SInfo.VertPot=65535/2;
if (SysBase->VBlankFrequency != 0x32) /* auf PAL testen */
{
WBLACE=1;
SCREEN=1;
}
if (SCREEN == NULL) SetColours();
else Make_Screen();
ReqStruct.numlines=23;
ReqStruct.numcolumns=30;
ReqStruct.Flags = FRQCACHINGM+(SCREEN != NULL ? FRQNODRAGM : NULL);
ReqStruct.dirnamescolor = 2;
ReqStruct.devicenamescolor = 2;
ArpBase=(struct ArpBase *) OpenLibrary("arp.library",0);
if (ArpBase != NULL)
{
Assign("K1_Sounds",sounddir);
Assign("K1_Banks",bankdir);
Assign("K1_Multis",multidir);
Assign("K1_Dumps",dumpdir);
CloseLibrary(ArpBase);
}
strcpy(bankdir,"K1_Banks:");
strcpy(sounddir,"K1_Sounds:");
strcpy(multidir,"K1_Multis:");
strcpy(dumpdir,"K1_Dumps:");
Make_Window();
MASTERCHANNEL=WaitForK1();
if (MASTERCHANNEL == -1)
{
if (!MyReq("Can't find Kawai K1, where is it ?","Go on","Leave")) CloseStuff();
}
if(DEFAULTDUMP == 0 && GETDUMP != 0) GetDump();
if(DEFAULTDUMP != 0) LoadDump(DEFDUMPNAME);
if(INITIALIZE != 0) InitializeAll(0);
Display();
if ((Unit0 = DTInputCreate(&status)) == NULL) Error("Can't create input enviroment");
event_count = 0;
handler_setup.is_Node.ln_Pri = 127;
handler_setup.is_Node.ln_Name=(char *)"YET K1-II's Input Handler";
handler_setup.is_Code = (VoidFunc) ManxHandler;
handler_setup.is_Data = (APTR) GetA4();
if ((status = DTInputAddHandler(Unit0,&handler_setup)) != 0) Error("Can't install input handler");
start:
MODWIN
SetTitle("KAWAI K1-II Librarian V "VERSION" Written by Andreas Jung in 1990-92");
WaitPort(win->UserPort);
while(mesg = (struct IntuiMessage *) GetMsg(win->UserPort))
{
switch(mesg->Class)
{
case ACTIVEWINDOW:
{
ReplyMsg((struct Message *)mesg);
if (SCREEN==NULL) SetColours();
break;
}
case INACTIVEWINDOW:
{
ReplyMsg((struct Message *)mesg);
if (SCREEN==NULL) SetOldColours();
break;
}
case GADGETDOWN:
{
ReplyMsg((struct Message *)mesg);
while(Gadget1.Activation & SELECTED || Gadget1.Flags & SELECTED)
{
volume=Gadget1SInfo.VertPot;
TransmitVolume((65535-volume)*127/65535);
}
break;
}
case GADGETUP:
{
ReplyMsg((struct Message *)mesg);
volume=Gadget1SInfo.VertPot;
TransmitVolume((65535-volume)*127/65535);
break;
}
case CLOSEWINDOW:
{
ReplyMsg((struct Message *) mesg);
Quit();
break;
}
case NEWSIZE:
{
ReplyMsg((struct Message *) mesg);
Forbid();
BeginRefresh(win);
Display();
RefreshWindowFrame(win);
EndRefresh(win,code);
Permit();
break;
}
case MOUSEBUTTONS:
{
int x,y,select=-1,soundnr;
code=mesg->Code;
x=mesg->MouseX;
y=mesg->MouseY;
ReplyMsg((struct Message *) mesg);
if (code==SELECTDOWN)
{
if (Check(x,y,15,615,28,189) && multi==0) /* Openrequester */
{
if (x>15 && x<315) soundnr=(y-28)/10*2+((x<165) ? 0 : 1);
if (x>315 && x<615) soundnr=32+(y-28)/10*2+((x<465) ? 0: 1);
select=OpenSingleRequester(x,y);
if (select==0) SingleEd(soundnr);
if (select==1) { LoadSound(soundnr);
TransmitSingleSound(soundnr); }
if (select==2) SaveSound(soundnr);
if (select==3) TransmitSingleSound(soundnr);
if (select==4) SingleCopyTo(soundnr);
if (select==5) SingleSwapWith(soundnr);
if (select==6) TransmitSingleSound(soundnr);
goto Ende;
}
if (Check(x,y,15,315,28,189) && multi==1)
{
soundnr=(y-28)/10*2+((x<165) ? 0 : 1);
select=OpenMultiRequester(x,y);
if (select==0) MultiEd(soundnr);
if (select==1) TransmitSingleMulti(soundnr);
if (select==2) MultiCopyTo(soundnr);
if (select==3) MultiSwapWith(soundnr);
goto Ende;
}
if (Check(x,y,15,615,190,235) && multi==0)
{
int xp=-1,yp=-1;
xp=(x-15)/120;
yp=(y-190)/15;
if (xp==0 && yp==0) LoadBank(0);
if (xp==1 && yp==0) LoadBank(1);
if (xp==2 && yp==0) SaveBank(0);
if (xp==3 && yp==0) SaveBank(1);
if (xp==4 && yp==0) About();
if (xp==0 && yp==1) GetBank(0);
if (xp==1 && yp==1) GetBank(1);
if (xp==2 && yp==1) TransmitCurrentBank(0);
if (xp==3 && yp==1) TransmitCurrentBank(1);
if (xp==4 && yp==1) Iconify();
if (xp==0 && yp==2) SaveAllSounds(0);
if (xp==1 && yp==2) SaveAllSounds(1);
if (xp==2 && yp==2) TransmitBank(0);
if (xp==3 && yp==2) TransmitBank(1);
if (xp==4 && yp==2) Quit();
Display();
goto Ende;
}
if (Check(x,y,15,615,190,235) && multi==1)
{
int xp=-1,yp=-1;
xp=(x-15)/120;
yp=(y-190)/15;
if (xp==0 && yp==0) LoadMulti();
if (xp==1 && yp==0) SaveMulti();
if (xp==2 && yp==0) LoadDump(0);
if (xp==3 && yp==0) SaveDump();
if (xp==4 && yp==0) About();
if (xp==0 && yp==1) GetMulti();
if (xp==1 && yp==1) SendMulti();
if (xp==2 && yp==1) GetDump();
if (xp==3 && yp==1) SendDump();
if (xp==4 && yp==1) Iconify();
if (xp==0 && yp==2) Colours();
if (xp==1 && yp==2) InitializeAll(1);
if (xp==2 && yp==2) /* Change Screen */
{
if (SCREEN==0)
{
SCREEN=1;
Forbid();
SetOldColours();
CloseWindow(win);
Make_Screen();
Make_Window();
Permit();
Display();
goto start;
}
else
{
struct Screen *sr=IntuitionBase->FirstScreen;
SCREEN=0;
Forbid();
CloseWindow(win);
CloseScreen(scr);
Make_Window();
SetColours();
Display();
MoveScreen(sr,-(sr->LeftEdge),-(sr->TopEdge));
WBenchToFront();
WindowToFront(win);
Permit();
goto start;
}
}
if (xp==3 && yp==2) Controllers();
if (xp==4 && yp==2) Quit();
Display();
goto Ende;
}
if (Check(x,y,380,530,28,38) && multi==1) /* Masterchannel */
{
struct GetLongStruct longstruct;
longstruct.titlebar = "Masterchannel";
longstruct.defaultval = MASTERCHANNEL+1;
longstruct.minlimit = 0;
longstruct.maxlimit = 16;
longstruct.window = win;
longstruct.versionnumber = REQVERSION;
longstruct.flags = 0;
longstruct.rfu2 = 0;
if (GetLong(&longstruct)) MASTERCHANNEL=longstruct.result - 1;
Display();
goto Ende;
}
if (Check(x,y,380,530,38,48) && multi==1) /* Scan Masterchannel */
{
MASTERCHANNEL=WaitForK1();
Display();
goto Ende;
}
if (Check(x,y,380,530,48,58) && multi==1) /* Extern -> Intern */
{
ExternToIntern();
goto Ende;
}
if (Check(x,y,380,530,58,68) && multi==1) /* Intern -> Extern */
{
InternToExtern();
goto Ende;
}
if (Check(x,y,380,530,68,78) && multi==1) /* Intern -> Extern */
{
SwapInternExtern();
goto Ende;
}
if (Check(x,y,380,530,98,108) && multi==1) /* Taskpriority */
{
struct GetLongStruct longstruct;
long pri;
pri=SetTaskPri(FindTask(0),0);
if (pri>128) pri=pri-256;
SetTaskPri(FindTask(0),pri);
longstruct.titlebar = "K1-Editor priority";
longstruct.defaultval = pri;
longstruct.minlimit = -127;
longstruct.maxlimit = 128;
longstruct.window = win;
longstruct.versionnumber = REQVERSION;
longstruct.flags = 0;
longstruct.rfu2 = 0;
if (GetLong(&longstruct)) SetTaskPri(FindTask(NULL),longstruct.result);
Display();
goto Ende;
}
if (Check(x,y,15,615,235,250)) /* Effektesection */
{
ProgChange(96+(x-15)/(600/16));
goto Ende;
}
if (Check(x,y,563,613,14,24)) /* Multi */
{
if (multi==0) multi=1;
else multi=0;
SetAPen(win->RPort,0);
SetBPen(win->RPort,0);
SetOPen(win->RPort,0);
RectFill(win->RPort,10,11,616,250);
Display();
}
Ende: break;
} /* of if SELECTDOWN */
if (code == MENUDOWN)
{
if (Check(x,y,15,615,28,189) && multi==0)
{
if (x>15 && x<315) soundnr=(y-28)/10*2+((x<165)?0:1);
if (x>315 && x<615) soundnr=32+(y-28)/10*2+((x<465)?0:1);
TransmitSingleSound(soundnr);
}
if (Check(x,y,15,315,28,189) && multi==1)
{
if (x>15 && x<315) soundnr=(y-28)/10*2+((x<165)?0:1);
TransmitSingleMulti(soundnr);
}
break;
} /* of if MENUDOWN */
} /* of case MOUSEBUTTONS */
default: break;
}
}
goto start;
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void DisplayBank(void)
{
int i,n;
char name[11],string[80];
SetAPen(win->RPort,1);
for (n=0;n<=31;n+=2)
{
Line(win,15,28+n*5,615,28+n*5);
for (i=0;i<=9;i++) name[i]=s[0][n][i] != 0 ? s[0][n][i] : 32;
name[10]='\0';
sprintf(string,"(%c %d) %s ",65+n/8,n%8+1,name);
Print(win,20,36+n*5,string);
for (i=0;i<=9;i++) name[i]=s[0][n+1][i] !=0 ? s[0][n+1][i] : 32;
name[10]='\0';
sprintf(string,"(%c %d) %s ",65+n/8,n%8+2,name);
Print(win,170,36+n*5,string);
for (i=0;i<=9;i++) name[i]=s[1][n][i] != 0 ? s[1][n][i] : 32;
name[10]='\0';
sprintf(string,"(%c %d) %s ",32+65+n/8,n%8+1,name);
Print(win,320,36+n*5,string);
for (i=0;i<=9;i++) name[i]=s[1][n+1][i] != 0 ? s[1][n+1][i] : 32;
name[10]='\0';
sprintf(string,"(%c %d) %s ",32+65+n/8,n%8+2,name);
Print(win,470,36+n*5,string);
}
Line(win,15,28+n*5,615,28+n*5);
Line(win,15,28,15,28+n*5);
Line(win,165,28,165,28+n*5);
Line(win,315,28,315,28+n*5);
Line(win,465,28,465,28+n*5);
Line(win,615,28,615,28+n*5);
for (n=0;n<=3;n++) Line(win,15,190+n*15,615,190+n*15);
for (n=15;n<=615;n+=(615-15)/5) Line(win,n,190,n,235);
i=1;
for (n=0;n<=16;n++)
{
Line(win,15+n*600/16,235,15+n*600/16,250);
if (i<=16)
{
sprintf(name,"%d",i++);
Print(win,15+11+n*600/16+(i<10 ? 5 : 0) ,245,name);
}
}
Line(win,15,250,615,250);
Print(win,20+120*0,200,"Load bank 1");
Print(win,20+120*1,200,"Load bank 2");
Print(win,20+120*2,200,"Save bank 1");
Print(win,20+120*3,200,"Save bank 2");
Print(win,20+120*4,200,"About");
Print(win,20+120*0,215,"Get bank 1");
Print(win,20+120*1,215,"Get bank 2");
Print(win,20+120*2,215,"Send bank 1");
Print(win,20+120*3,215,"Send bank 2");
Print(win,20+120*4,215,"Iconify");
Print(win,20+120*0,230,"Save sounds 1");
Print(win,20+120*1,230,"Save sounds 2");
Print(win,20+120*2,230,"Load/Send as 1");
Print(win,20+120*3,230,"Load/Send as 2");
Print(win,20+120*4,230,"Quit");
Print(win,569,22,"MULTI");
MakeDBox(win,563,14,613,24);
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void DisplayMulti(void)
{
int i,n;
char name[15],string[80];
SetAPen(win->RPort,1);
for (n=0;n<=31;n+=2)
{
Line(win,15,28+n*5,315,28+n*5);
for (i=0;i<=9;i++) name[i]=m[n][i] != 0 ? m[n][i] : 32;
name[10]='\0';
sprintf(string,"(%c %d) %s ",65+n/8,n%8+1,name);
Print(win,20,36+n*5,string);
Line(win,15,28+n*5,315,28+n*5);
for (i=0;i<=9;i++) name[i]=m[n+1][i] != 0 ? m[n+1][i] : 32;
name[10]='\0';
sprintf(string,"(%c %d) %s ",65+n/8,n%8+2,name);
Print(win,170,36+n*5,string);
}
Line(win,15,28+n*5,315,28+n*5);
Line(win,15,28,15,28+n*5);
Line(win,165,28,165,28+n*5);
Line(win,315,28,315,28+n*5);
for (n=0;n<=3;n++) Line(win,15,190+n*15,615,190+n*15);
for (n=15;n<=615;n+=(615-15)/5) Line(win,n,190,n,235);
i=1;
for (n=0;n<=16;n++)
{
Line(win,15+n*600/16,235,15+n*600/16,250);
if (i<=16)
{
sprintf(string,"%d",i++);
Print(win,15+11+n*600/16+(i<10 ? 5 : 0) ,245,string);
}
}
Line(win,15,250,615,250);
Print(win,20+120*0,200,"Load multi");
Print(win,20+120*1,200,"Save multi");
Print(win,20+120*2,200,"Load dump");
Print(win,20+120*3,200,"Save dump");
Print(win,20+120*4,200,"About");
Print(win,20+120*0,215,"Get multi");
Print(win,20+120*1,215,"Send multi");
Print(win,20+120*2,215,"Get dump");
Print(win,20+120*3,215,"Send dump");
Print(win,20+120*4,215,"Iconify");
Print(win,20+120*0,230,"Colours");
Print(win,20+120*1,230,"Init all");
Print(win,20+120*2,230,SCREEN==0 ? "Use screen" : "Use workbench");
Print(win,20+120*3,230,"Controllers");
Print(win,20+120*4,230,"Quit");
Print(win,569,22,"BANKS");
MakeDBox(win,563,14,613,24);
NumBox(380,28,150,"Masterchannel:",MASTERCHANNEL+1);
MakeBox(win,380,38,530,48);
Print(win,392,46,"Scan Masterchan.");
MakeBox(win,380,48,530,58);
Print(win,392,56,"Extern -> Intern");
DrawBox(win->RPort,380,58,530,68);
Print(win,392,66,"Intern -> Extern");
DrawBox(win->RPort,380,68,530,78);
Print(win,388,76,"Intern <-> Extern");
{
long pri;
char str[5];
pri=SetTaskPri(FindTask(0),0);
if (pri>128) pri=pri-256;
SetTaskPri(FindTask(0),pri);
DrawBox(win->RPort,380,98,530,108);
Print(win,392,106,"Priority:");
sprintf(str,"%4d",pri);
Print(win,495,106,str);
}
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void CheckWbCall(int argc, char **argv)
{
struct DiskObject *pdo = NULL;
char *cp = NULL;
SCREEN=0;
WBLACE=0;
if (argc==0)
{
if(pdo = GetDiskObject( ((struct WBStartup *)argv)->sm_ArgList->wa_Name) )
{
if(cp = FindToolType(pdo->do_ToolTypes, "SCREEN"))
if(MatchToolValue(cp, "ON")) SCREEN = 1;
if(cp = FindToolType(pdo->do_ToolTypes, "LACE"))
if(MatchToolValue(cp, "ON")) WBLACE = 1;
if(cp = FindToolType(pdo->do_ToolTypes, "GETDUMP"))
if(MatchToolValue(cp, "ON")) GETDUMP = 1;
if(cp = FindToolType(pdo->do_ToolTypes, "INITIALIZE"))
if(MatchToolValue(cp, "ON")) INITIALIZE= 1;
if(cp = FindToolType(pdo->do_ToolTypes, "BANKDIR"))
strcpy(bankdir,cp);
if(cp = FindToolType(pdo->do_ToolTypes, "SOUNDDIR"))
strcpy(sounddir,cp);
if(cp = FindToolType(pdo->do_ToolTypes, "MULTIDIR"))
strcpy(multidir,cp);
if(cp = FindToolType(pdo->do_ToolTypes, "DUMPDIR"))
strcpy(dumpdir,cp);
if(cp = FindToolType(pdo->do_ToolTypes, "DEFAULTDUMP"))
{
strcpy(DEFDUMPNAME,cp);
DEFAULTDUMP=1;
}
}
if(pdo) FreeDiskObject(pdo);
}
if (argc==2 && argv[1][0]=='?')
{
MyReq(
" K1-II - Librarian V "VERSION"\n"
"\n"
" (C) in 1990-92 by\n"
" Andreas Jung\n"
" Klosterstraße 21\n"
" D-6602 Dudweiler\n"
" Federal Republic of Germany\n"
"\n"
"Available options 'S' - Use custom screen\n"
"from CLI: 'L' - Use interlace screen\n"
" 'G' - Get single- and multipatch dump \n"
" 'I' - Initialize all patches\n",NULL,"Leave");
CloseStuff();
}
else
{
int i;
for (i=1;i<argc;i++)
{
if (tolower(argv[i][0])=='s') { SCREEN=1; }
if (tolower(argv[i][0])=='l') { WBLACE=1; SCREEN=1; }
if (tolower(argv[i][0])=='g') { GETDUMP=1;}
if (tolower(argv[i][0])=='i') { INITIALIZE=1;}
}
}
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void Colours(void)
{
FILE *fp,*fopen();
if (SCREEN==0) scr=IntuitionBase->ActiveScreen;
colstruct.defcolor=0;
colstruct.window=win;
if (ExtendedColorRequester(&colstruct) != 65535)
{
fp=fopen("DEVS:K1-LibColours","w");
if (fp!=NULL)
{
fprintf(fp, "%ld %ld %ld %ld\n",
GetRGB4(scr->ViewPort.ColorMap, 0),
GetRGB4(scr->ViewPort.ColorMap, 1),
GetRGB4(scr->ViewPort.ColorMap, 2),
GetRGB4(scr->ViewPort.ColorMap, 3) );
fclose(fp);
}
GetColours();
}
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void InitializeAll(int bool)
{
int i,j,k;
SetTitle("Initialize all patches");
if (bool==1)
{
if (MyReq(" Are you really shure ???\nEverything will be erased !"," Yes ","Oh no"))
{
ZZ_POINTER(win);
for (k=0;k<=1;k++)
for (i=0;i<=31;i++)
for(j=0;j<=87;j++) s[k][i][j]=initsing[j];
for (i=0;i<=31;i++)
for(j=0;j<=75;j++) m[i][j]=initmul[j];
CLEAR_POINTER(win);
}
Display();
}
else
{
ZZ_POINTER(win);
for (k=0;k<=1;k++)
for (i=0;i<=31;i++)
for(j=0;j<=87;j++) s[k][i][j]=initsing[j];
for (i=0;i<=31;i++)
for(j=0;j<=75;j++) m[i][j]=initmul[j];
CLEAR_POINTER(win);
}
bankname[0][0]=NULL;
bankname[1][0]=NULL;
multiname[0]=NULL;
Display();
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void SingleCopyTo(int nr)
{
int i,x,y,soundnr;
SetTitle("Select position to copy to");
MODWIN
Loop: ;
WaitPort(win->UserPort);
mesg=(struct IntuiMessage *) GetMsg(win->UserPort);
x=mesg->MouseX;
y=mesg->MouseY;
if (mesg->Class==MOUSEBUTTONS && mesg->Code==SELECTDOWN)
{
ReplyMsg((struct Message *)mesg);
if (Check(x,y,15,615,28,189) && multi==0)
{
if (x>15 && x<315) soundnr=(y-28)/10*2+((x<165)?0:1);
if (x>315 && x<615) soundnr=32+(y-28)/10*2+((x<465)?0:1);
for (i=0;i<=87;i++) s[soundnr/32][soundnr%32][i]=s[nr/32][nr%32][i];
TransmitSingleSound(soundnr);
multi=0;
Display();
}
else goto Loop;
}
else
{
ReplyMsg((struct Message *)mesg);
goto Loop;
}
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void SingleSwapWith(int nr)
{
int i,x,y,soundnr;
SetTitle("Select position to swap with");
MODWIN
Loop: ;
WaitPort(win->UserPort);
mesg=(struct IntuiMessage *) GetMsg(win->UserPort);
x=mesg->MouseX;
y=mesg->MouseY;
if (mesg->Class==MOUSEBUTTONS && mesg->Code==SELECTDOWN)
{
ReplyMsg((struct Message *)mesg);
if (Check(x,y,15,615,28,189) && multi==0)
{
if (x>15 && x<315) soundnr=(y-28)/10*2+((x<165)?0:1);
if (x>315 && x<615) soundnr=32+(y-28)/10*2+((x<465)?0:1);
for (i=0;i<=87;i++)
{
int h;
h=s[soundnr/32][soundnr%32][i];
s[soundnr/32][soundnr%32][i]=s[nr/32][nr%32][i];
s[nr/32][nr%32][i]=h;
}
TransmitSingleSound(soundnr);
TransmitSingleSound(nr);
multi=0;
Display();
}
else goto Loop;
}
else
{
ReplyMsg((struct Message *)mesg);
goto Loop;
}
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void MultiCopyTo(int nr)
{
int i,x,y,soundnr;
SetTitle("Select position to copy to");
MODWIN
Loop: ;
WaitPort(win->UserPort);
mesg=(struct IntuiMessage *) GetMsg(win->UserPort);
x=mesg->MouseX;
y=mesg->MouseY;
if (mesg->Class==MOUSEBUTTONS && mesg->Code==SELECTDOWN)
{
ReplyMsg((struct Message *)mesg);
if (Check(x,y,15,315,28,189) && multi==1)
{
if (x>15 && x<315) soundnr=(y-28)/10*2+((x<165)?0:1);
for (i=0;i<=75;i++) m[soundnr][i]=m[nr][i];
TransmitSingleMulti(soundnr);
multi=1;
Display();
}
else goto Loop;
}
else
{
ReplyMsg((struct Message *)mesg);
goto Loop;
}
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void MultiSwapWith(int nr)
{
int i,x,y,soundnr;
SetTitle("Select position to swap with");
MODWIN
Loop: ;
WaitPort(win->UserPort);
mesg=(struct IntuiMessage *) GetMsg(win->UserPort);
x=mesg->MouseX;
y=mesg->MouseY;
if (mesg->Class==MOUSEBUTTONS && mesg->Code==SELECTDOWN)
{
ReplyMsg((struct Message *)mesg);
if (Check(x,y,15,315,28,189) && multi==1)
{
if (x>15 && x<315) soundnr=(y-28)/10*2+((x<165)?0:1);
for (i=0;i<=75;i++)
{
int h;
h=m[soundnr][i];
m[soundnr][i]=m[nr][i];
m[nr][i]=h;
}
TransmitSingleMulti(soundnr);
TransmitSingleMulti(nr);
multi=1;
Display();
}
else goto Loop;
}
else
{
ReplyMsg((struct Message *)mesg);
goto Loop;
}
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void Quit(void)
{
if (MyReq("Do really want to quit ?"," Yes ","Oh no")==TRUE) CloseStuff();
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void GetColours(void)
{
struct Screen *scr;
FILE *fp,*fopen();
long a,b,c,d;
struct IntuitionBase *IntuitionBase;
IntuitionBase=(struct IntuitionBase *) OpenLibrary("intuition.library",0);
scr=IntuitionBase->ActiveScreen;
fp=fopen("DEVS:K1-LibColours","r");
if (fp != NULL)
{
fscanf(fp, "%ld%ld%ld%ld", &col[0], &col[1], &col[2], &col[3]);
fclose(fp);
}
else Colours();
CloseLibrary(IntuitionBase);
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void SaveOldColours(void)
{
struct Screen *scr;
IntuitionBase=(struct IntuitionBase *) OpenLibrary("intuition.library",0);
GfxBase=(struct GfxBase *) OpenLibrary("graphics.library",0);
scr=IntuitionBase->ActiveScreen;
oldcol[0]=GetRGB4(scr->ViewPort.ColorMap, 0);
oldcol[1]=GetRGB4(scr->ViewPort.ColorMap, 1);
oldcol[2]=GetRGB4(scr->ViewPort.ColorMap, 2);
oldcol[3]=GetRGB4(scr->ViewPort.ColorMap, 3);
CloseLibrary(IntuitionBase);
CloseLibrary(GfxBase);
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void SetColours(void)
{
struct Screen *scr;
struct IntuitionBase *IntuitionBase;
IntuitionBase=(struct IntuitionBase *) OpenLibrary("intuition.library",0);
scr=IntuitionBase->ActiveScreen;
SetRGB4(&scr->ViewPort, 0, (col[0] & 0xf00) >> 8, (col[0] & 0x0f0) >> 4, col[0] & 0x00f );
SetRGB4(&scr->ViewPort, 1, (col[1] & 0xf00) >> 8, (col[1] & 0x0f0) >> 4, col[1] & 0x00f );
SetRGB4(&scr->ViewPort, 2, (col[2] & 0xf00) >> 8, (col[2] & 0x0f0) >> 4, col[2] & 0x00f );
SetRGB4(&scr->ViewPort, 3, (col[3] & 0xf00) >> 8, (col[3] & 0x0f0) >> 4, col[3] & 0x00f );
CloseLibrary(IntuitionBase);
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void SetOldColours(void)
{
struct Screen *scr;
long a,b,c,d;
a=oldcol[0];
b=oldcol[1];
c=oldcol[2];
d=oldcol[3];
scr=IntuitionBase->FirstScreen;
SetRGB4(&scr->ViewPort, 0, (a & 0xf00) >> 8, (a & 0x0f0) >> 4, a & 0x00f );
SetRGB4(&scr->ViewPort, 1, (b & 0xf00) >> 8, (b & 0x0f0) >> 4, b & 0x00f );
SetRGB4(&scr->ViewPort, 2, (c & 0xf00) >> 8, (c & 0x0f0) >> 4, c & 0x00f );
SetRGB4(&scr->ViewPort, 3, (d & 0xf00) >> 8, (d & 0x0f0) >> 4, d & 0x00f );
}