home *** CD-ROM | disk | FTP | other *** search
- {**********************************************************************}
- {* *}
- {* M A K E _ Z A P : A p p l y S p e c i f i e d Z a p *}
- {* *}
- {* S e p a r a t e O u t I n t o MakeZap.200 *}
- {**********************************************************************}
-
- {---- ---- ---- ---- ----- ---- ---- ---- ---- ----- ---- ---- ----- --}
- { F i n d _ Z a p : P o s i t i o n t o H e a d e r }
- {--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --}
- Procedure Find_Zap(Header :ParmString; Var Return_Code :integer);
- Var
- TempHdr : String[80];
- TempString : String[80];
-
- Begin { Find_Zap }
- Assign(Zap_File,Zap_Filename); { Find Correct Zap posn}
- {$I-}Reset(Zap_File);{$I+}
- Return_Code := IOresult;
- If (Return_Code <> 0) then
- Pause(Zap_Filename+' Error: '+Char(Return_Code));
-
- TempHdr := Header+' '+Version_Key[Version].Name; {Concatenate Version }
- While (TempHdr[Length(TempHdr)] = ' ') {Name to search string}
- do {and deblank from end}
- TempHdr[0] := Pred(TempHdr[0]); {Show search string }
- {within delimiters }
- Write(' Searching for Header ');
- NormVideo; Writeln(Chr(16),TempHdr,Chr(17)); LowVideo;
- Return_Code := 1;
-
- x := wherex; y :=wherey;
- Repeat { Until Keyword header found }
- Readln(Zap_file,TempString); { Look For zap identifier }
- GotoXY(x,y); { Show the lines we're skipping.}
- Write(Chr(16),TempString,Chr(17));
- If Tempstring[0] > TempHdr[0] then { Equilize string lengths for }
- Tempstring[0] := TempHdr[0] ; { Filestring = Keyword compare }
- Until (TempString = TempHdr) or (Eof(Zap_File));
-
- If TempString = TempHdr then { Set a return code for either }
- begin { Success or Failure and give }
- Return_Code := 0; { human some mortal indication }
- Writeln;Writeln(' Positioned to Zap');
- end
- else begin
- Writeln;Pause(' Zap not found');
- Return_Code := 1;
- end
- End { Find_Zap };
-
-
- {-------------------------------------------------------------------}
- { M a i n P r o c e d u r e }
- {--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---}
- { Open Zap file, Position to Header, read the data and apply the zap}
- { Data as follows: }
- { Character Header identifier }
- { $address length $hex $hex $hex $hex $hex . . . . . . . . . . . . }
- { : }
- { : }
- { $0 End of Zap for this identifier }
- {-------------------------------------------------------------------}
- Procedure Make_Zap (Zap_Index : Zaptypes; Var Return_Code :integer);
-
- Var
- Zap_Address,
- Zap_Length :integer ;
- Zap_Data :array[1..80] of byte;
- x,y :integer;
-
- Begin { Make_Zap }
-
- Find_Zap(Zap_Headers[Zap_Index], Return_Code); { Search for the Header}
- x:=WhereX; y:=WhereY;
-
- If ( Return_Code = 0 ) then { When we find the Zap Keyword in }
- Repeat { Until Address = 0 } { Ascii zap file, fetch the zap }
- Read(Zap_File,Zap_Address); { address and number of zap bytes } { Get Zap address }
- x:=x Mod 20 +1; GotoXY(x,y); { on the Line. }
- Write(' Working...'); { While making the zap, keep the }
- If Zap_Address <> 0 then { User content with a turtle title}
- Begin
- Read(Zap_File,Zap_Length); { Read Zap byte count }
- For I := 1 to Zap_Length Do { Read the Zap Data }
- Read(Zap_File, Zap_Data[I] );
- Readln(Zap_File); { Skip any comments }
- Seek(ComOut_File,Zap_Address-$100); { Seek to Zap Address}
- For I := 1 to Zap_Length Do
- Write(ComOut_File,Zap_Data[I]); { Write the Zap Data }
- End { Zap_Address <> 0 }
- Until (Zap_Address = 0);
- Close(Zap_File); Writeln;
- End; { Make_Zap }
- {....................................................................}