home *** CD-ROM | disk | FTP | other *** search
- {**************************************************************************
-
- BNKTB
- ROL Bank File ToolBox
-
- Date: 4/4/91
- Version: 1
-
- ***************************************************************************
-
- Copyright (c) 1991, Zackzon Labs.
-
- Author: Anthony Rumble
-
- ==========
- Addresses:
- ==========
- InterNet: c9106510@cc.newcastle.edu
- SIGNet: 28:2200/108
-
- Snail Mail:
- 32 Woolwich Rd.
- Hunters Hill, NSW, 2110
- Australia
-
- -------------------------------------------------------------------------
- HISTORY
- -------------------------------------------------------------------------
- 1.0 - Works fine so far
- *************************************************************************}
- unit bnktb; {BNK ToolBox}
-
- interface
-
- uses misc;
-
- const
- max_size=78;
-
- type
- Instrument = array[1..26] of integer;
-
- header_record = record
- vers_Major:byte;
- vers_Minor:byte;
- signature:array[1..6] of char; {= ADLIB-}
- Num_list_used:word;
- num_list:word;
- offset_names:longint;
- offset_data:longint;
- filler:byte;
- end;
-
- inst_name_record = record
- index:word;
- isused:byte;
- name:array[1..8] of char;
- bytenull:byte;
- end;
-
- inst_data_record = record
- mode:byte;
- voice_no:byte;
- modr:array[1..13] of shortint;
- car:array[1..13] of shortint;
- wave_mod:byte;
- wave_car:byte;
- end;
-
- var
- bnkF:file;
- inr:inst_name_record;
- idr:inst_data_record;
- headr:header_record;
- numread:word;
- recno:longint;
- x, err:integer;
- tname:string;
- ofst:longint;
- lastinst:string;
- lastdata:instrument;
- bnk_file_name:string;
-
- function load_bnk(nme:string;var ins:instrument):boolean;
-
- implementation
-
- {****************************************************************************
- LOAD_BNK
- ----------------------------------------------------------------------------
- Loads an instrument into the string INS of name nme from the
- bnk file name of BNK_FILE_NAME variable.. Which is by default 'STANDARD.BNK'
- ****************************************************************************}
- function load_bnk(nme:string;var ins:instrument):boolean;
- begin
- {Check if the last instriment loaded is the same}
- {This is to speed things up}
- nme:=upper(nme);
- if nme<>upper(lastinst) then
- begin
- assign(bnkF, bnk_file_name);
- {$I-}
- reset(bnkF,1);
- {$I+}
- err:=IORESULT;
- load_bnk:=false;
- if err<>0 then exit;
- recno:=0;
- {Read the Header}
- blockread(bnkF, headr, sizeof(headr), numread);
- {Seek to the start of the Inst Names}
- seek(bnkf, headr.offset_names);
- {Search for the Instrument name}
- repeat;
- inc(recno);
- blockread(bnkF, inr, sizeof(inr), numread);
- with inr do
- begin
- tname:='';
- for x:=1 to 8 do
- begin
- if name[x]<>#00 then tname:=tname+name[x];
- end;
- if upper(tname)=nme then
- begin
- ofst:=headr.offset_data;
- ofst:=ofst+(sizeof(idr)*inr.index);
- seek(bnkf, ofst);
- blockread(bnkF, idr, sizeof(idr), numread);
- close(bnkF);
- for x:=1 to 13 do
- begin
- ins[x]:=idr.modr[x];
- end;
- for x:=1 to 13 do
- begin
- ins[x+13]:=idr.car[x];
- end;
- load_bnk:=true;
- lastinst:=upper(tname);
- lastdata:=ins;
- exit;
- end;
- end;
- until ((eof(bnkF)) or (recno >= headr.num_list_used));
- end else ins:=lastdata;
- end;
-
- begin
- lastinst:='';
- bnk_file_name:='standard.bnk';
- end.