home *** CD-ROM | disk | FTP | other *** search
- PROCEDURE Make_Path( VAR ps : Path_Name ; VAR cs : Path_Chars ) ;
- VAR
- i : Integer ;
- BEGIN
- FOR i := 1 TO Length( ps ) DO
- BEGIN
- cs[i] := ps[i] ;
- END ;
- cs[ length(ps)+1 ] := Chr(0) ;
- END;
-
- { Open an existing file. }
- FUNCTION f_open( VAR name : Path_Chars ; mode : Integer ) : Integer ;
- GEMDOS( $3d ) ;
- { Mode - 0=read only, 1=write only, 2=reading and writing }
-
- { Close an open file. }
- FUNCTION f_close( handle : Integer ) : Integer ;
- GEMDOS( $3e ) ;
-
- { Read bytes from a file. }
- FUNCTION f_read( handle : Integer ; count : Long_Integer ; VAR buf : Pic_Dat
- ) : Long_Integer ;
- GEMDOS( $3f ) ;
-
- FUNCTION Physbase : S_Ptr; { xbios routine returns address of screen }
- Xbios( 2 );
-
- PROCEDURE Sav_scn; { proc saves screen to buf }
- {$P-} { turn pointer checking off }
- begin
- Scn_ptr := Physbase; { get addr of screen in memory }
- Scn_buf := Scn_Ptr^; { do assignment, copy entire array }
- end;
- {$P=} { restore pointer checking to old state }
-
- PROCEDURE Rest_scn; { restore screen from buf }
- {$P-} { turn pointer checking off }
- begin
- Scn_ptr := Physbase; { get addr of screen in memory }
- Scn_ptr^ := Scn_buf; { assign, copy array }
- end;
- {$P=} { set pointer checking to old state }
-
- PROCEDURE S_Load;
- VAR
- A1, A2, Alert : Str255 ;
- junk, IO_Handle : Integer ;
- I, K : Integer; { temporary variable }
- K_Byte : Byte ;
- Temp : Long_Integer; { one disk file value }
- Name : Path_Chars ;
- BEGIN
- Make_Path( F_Name, Name );
- IO_Handle := F_Open( Name,2 ) ;
- IF IO_Handle >= 0 THEN
- BEGIN
- Temp := F_Read( IO_Handle,32034,Pic_Buf) ;
- END
- ELSE BEGIN
- Alert :='';
- A1 := 'I could not find data|files DCLOCK.RSC| DCLOCK.RSC must ';
- A2 := 'be|on the same drive and path|as this program!' ;
- Alert := concat( '[2][',A1,A2,'][ *NUTS* ]' );
- Junk := Do_Alert( Alert, 0 ) ;
- END;
- Junk := F_Close( IO_Handle ) ;
- END; { of S_Load }
-
- PROCEDURE U_Copy( Count : Integer ) ;
- VAR
- I, J : Integer ;
- BEGIN
- I := 0 ;
- REPEAT
- J := SHL( I,1 ) ;
- Scn_Buf[ Scn_Buf_Ptr ] := Pic_Buf[ Dat_Ptr + J ] ;
- Scn_Buf[ Scn_Buf_Ptr + 1 ] := Pic_Buf[ Dat_Ptr + J + 1 ] ;
- Scn_Buf_Ptr := Scn_Buf_Ptr + 160 ;
- IF Scn_Buf_Ptr > 32000 THEN
- BEGIN
- Scn_Buf_Ptr := Scn_Buf_Ptr - 31992 ;
- IF Scn_Buf_Ptr > 160 THEN Scn_Buf_Ptr := Scn_Buf_Ptr - 158 ;
- END;
- I := I + 1 ;
- UNTIL I = (Count) ;
- END; { of U_Copy }
-
- PROCEDURE Rep_Copy( Count : Integer ) ;
- VAR
- I : Integer ;
- BEGIN
- FOR I := 1 TO Count DO
- BEGIN
- Scn_Buf[ Scn_Buf_Ptr ] := Pic_Buf[ Dat_Ptr ] ;
- Scn_Buf[ Scn_Buf_Ptr + 1 ] := Pic_Buf[ Dat_Ptr + 1 ] ;
- Scn_Buf_Ptr := Scn_Buf_Ptr + 160 ;
- IF Scn_Buf_Ptr > 32000 THEN
- BEGIN
- Scn_Buf_Ptr := Scn_Buf_Ptr - 31992 ;
- IF Scn_Buf_Ptr > 160 THEN Scn_Buf_Ptr := Scn_Buf_Ptr - 158 ;
- END;
- END;
- END; { of Rep_Copy }
-
-
- PROCEDURE Un_Tiny ;
- { this procedure works with the globle variable - Pic_Buf - which contains the
- raw tiny fomat file data read from a disk file. this procedure un-compacts
- data in this file and stores in the globle variable - Scn_Buf - which then
- can be move to screen memory with the procedure Rest_Scn. }
- { this procedure also makes calls to U_Copy and Rep_Copy }
- { Pic_Buf a place to read picture file data into }
- { Scn_buf a place to stash the screen }
-
- VAR
- Junk : Integer ; { for trow away data return by function call }
- I, J, K : Integer ; { loop and temp color data }
- Ctl_Cnt : Integer; { # of control data bytes }
- Dat_Cnt : Integer; { # of pixil data bytes }
- Ctl_Ptr : Integer ; { position of next control data }
- Ctl_End : Integer ; { end position of control data }
- Dat_End : Integer ; { end position of pixil data }
- Temp_Rez : Byte ; { read first data value into this variable }
- Temp_Ptr : Integer ; { pionter into Pic_Buf }
- Rep_Cnt : Integer ; { counter for repeat of pixil data }
- U_Cnt : Integer ; { counter for Unique pixil data }
- BEGIN
- Scn_Buf_Ptr := 1 ;
- Temp_Rez := Pic_Buf[ 1 ] ;
- { calculate picture file resolution and and if rotation data bytes }
- IF Temp_Rez > 2 THEN Pic_Rez := Temp_Rez - 3 ELSE Pic_Rez := Temp_Rez ;
- If ( Pic_Rez = 0 ) OR ( Pic_Rez = 1 ) THEN { low or med resolution }
- BEGIN
- IF Temp_Rez > 2 THEN { find where color data is and copy }
- BEGIN
- FOR I := 0 TO 15 DO
- BEGIN
- K := SHL( Pic_Buf[ (SHL(I,1)+6) ],8 ) ; { get color data }
- Kolor_Reg[ I ] := K + ( Pic_Buf[ (SHL(I,1)+7) ] ) ;
- END;
- END ELSE
- BEGIN
- FOR I := 0 TO 15 DO
- BEGIN
- K := SHL( Pic_Buf[ (SHL(I,1)+2) ],8 ) ; { get color data }
- Kolor_Reg[ I ] := K + ( Pic_Buf[ (SHL(I,1)+3) ] ) ;
- END;
- END;
- Temp_Ptr := 34 ; { piont to ctl_cnt data in Pic_Buf array }
- IF Temp_Rez > 2 THEN Temp_Ptr := 38 ;
- { find number of control bytes }
- Ctl_Cnt := SHL( Pic_Buf[ Temp_Ptr ],8 ) + Pic_Buf[ Temp_Ptr + 1 ] ;
- { find number of pixil data bytes * 2 }
- Dat_Cnt := SHL( Pic_Buf[ Temp_Ptr + 2 ],8 ) + Pic_Buf[ Temp_Ptr + 3 ] ;
- { set control pointer to start of control and pixil data in array }
- Ctl_Ptr := Temp_Ptr + 4 ;
- Dat_Ptr := Ctl_Ptr + Ctl_Cnt ;
- { find end of the 2 data groups, control and pixil }
- Ctl_End := Ctl_Ptr + Ctl_Cnt - 1 ;
- Dat_End := SHL( Dat_Cnt,1 ) + Ctl_End ;
-
- REPEAT
-
- { if control byte is 0 then repeat data times next 2 control bytes }
- IF Pic_Buf[ Ctl_Ptr ] = 0 THEN
- BEGIN
- Temp_Ptr := Ctl_Ptr + 3 ; { find next Ctl_Ptr for next time through }
- { clculate number of repeats }
- Rep_Cnt :=(SHL(Pic_Buf[(Ctl_Ptr+1)],8 ))+( Pic_Buf[(Ctl_Ptr+2)]) ;
- Rep_Copy( Rep_Cnt ) ;
- Dat_Ptr := Dat_Ptr + 2 ;
- END ;
-
- { if control byte is 1<btye<128 then repeat data that many times }
- IF ( Pic_Buf[ Ctl_Ptr ] > 1 ) AND ( Pic_Buf[ Ctl_Ptr ] < 128 ) THEN
- BEGIN
- Temp_Ptr := Ctl_Ptr + 1 ; { find next Ctl_Ptr for next time through }
- Rep_Cnt := Pic_Buf[ Ctl_Ptr ] ;
- Rep_Copy( Rep_Cnt ) ;
- Dat_Ptr := Dat_Ptr + 2 ;
- END;
-
- { If control byte is = 1 then copy consecutive unique data bytes }
- IF Pic_Buf[ Ctl_Ptr ] = 1 THEN
- BEGIN
- Temp_Ptr := Ctl_Ptr + 3 ; { find next Ctl_Ptr for next time through }
- { clculate number of unique bytes }
- U_Cnt :=(SHL(Pic_Buf[(Ctl_Ptr+1)],8))+( Pic_Buf[(Ctl_Ptr+2)]) ;
- U_Copy( U_Cnt ) ;
- Dat_Ptr := Dat_Ptr + U_Cnt * 2 ;
- END;
-
- { if control byte is > 127 copy that many unique data bytes }
- IF ( Pic_Buf[ Ctl_Ptr ] > 127 ) THEN
- BEGIN
- Temp_Ptr := Ctl_Ptr + 1 ; { find next Ctl_Ptr for next time through }
- { clculate number of unique bytes }
- U_Cnt := ( 256 - Pic_Buf[ Ctl_Ptr ] ) ; { make byte positive }
- U_Copy( U_Cnt ) ;
- Dat_Ptr := Dat_Ptr + (SHL(U_Cnt,1)) ;
- END;
- Ctl_Ptr := Temp_Ptr ;
-
- UNTIL ( Ctl_Ptr > Ctl_End ) OR ( Dat_Ptr > Dat_End ) ;
- END;
- END; { of Un_Tiny }
-