Listing: 1 (*$N,A-,V-*) 2 IMPLEMENTATION MODULE Ovl117; 3 (* Copyright (C) 1987-1992 Clarion Software Corporation *) 4 5 6 IMPORT Str,FIO,Storage,SYSTEM,Lib; 7 8 PROCEDURE (*$S+ stack check for safety*) Load( n:CARDINAL ); 9 10 TYPE bp=POINTER TO SHORTCARD; ***** ^ not supported yet 11 LONG = ARRAY [0..MAX(CARDINAL)-1] OF BYTE; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 12 13 VAR 14 f:CARDINAL; (* file handle *) 15 s:CARDINAL; (* segment for overlay *) 16 segsize:CARDINAL; (* in paras *) 17 18 header:RECORD 19 Alloc: LONGCARD; (* total size *) ***** ^ undeclared identifier 20 Init: LONGCARD; (* size of initialised part *) ***** ^ undeclared identifier 21 nifix: CARDINAL; (* number of patches in loaded overlay *) 22 nefix: CARDINAL; (* number of patches in other overlays *) 23 resvd: ARRAY[0..3] OF CHAR; (* Can be used for validity check *) ***** ^ not supported yet ***** ^ not supported yet 24 END; ***** ^ not supported yet 25 26 Locseg:CARDINAL; 27 Target:CARDINAL; 28 29 tmp:CARDINAL; 30 atmp:ADDRESS; ***** ^ undeclared identifier 31 count:LONGCARD; ***** ^ undeclared identifier 32 base:CARDINAL; 33 chunk:CARDINAL; 34 dummy:CARDINAL; 35 36 fixbufseg:CARDINAL; 37 fixbufoff:CARDINAL; 38 fixbufcount:CARDINAL; 39 fixbuf:ARRAY [1..5*200H] OF SHORTCARD; ***** ^ not supported yet ***** ^ not supported yet 40 41 Filename:ARRAY[1..50] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 42 Ext:ARRAY[0..3] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 43 44 PROCEDURE chkread( buf:ADDRESS; count:CARDINAL ); ***** ^ undeclared identifier 45 VAR tmp:POINTER TO LONG; ***** ^ not supported yet 46 BEGIN 47 tmp := buf; ***** ^ not supported yet ***** ^ not supported yet 48 IF FIO.RdBin(f, tmp^, count ) <> count THEN HALT END; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 49 END chkread; ***** ^ not supported yet 50 51 BEGIN 52 IF (Seg[n]<>MAX(CARDINAL)) THEN RETURN END ; (* Already loaded *) ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 53 Ext := '.ov '; ***** ^ not supported yet ***** ^ not supported yet 54 Ext[3] := CHAR( ORD('0') + n ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 55 Str.Concat( Filename, Path, Ext ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 56 f := FIO.Open(Filename); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 57 chkread(ADR(header),SIZE(header)); ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 58 59 segsize := CARDINAL( ( header.Alloc + 15 ) DIV 16 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 60 61 Storage.HeapAllocate( Storage.MainHeap, atmp, segsize ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 62 s := SYSTEM.Seg(atmp^); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 63 64 Seg[n] := s; ***** ^ undeclared identifier ***** ^ not supported yet 65 Size[n] := segsize; ***** ^ undeclared identifier ***** ^ not supported yet 66 67 tmp := s; 68 count := header.Init; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 69 70 IF count > 0FFF0H THEN ***** ^ not supported yet 71 chkread( [tmp:0], 0FFF0H ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 72 DEC(count,0FFF0H); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 73 INC(tmp, 0FFFH ); ***** ^ undeclared identifier ***** ^ not supported yet 74 END; 75 76 WHILE count > 0F000H DO ***** ^ not supported yet 77 chkread( [tmp:0], 0F000H ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 78 DEC(count,0F000H); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 79 INC(tmp, 0F00H ); ***** ^ undeclared identifier ***** ^ not supported yet 80 END; 81 82 chkread( [tmp:0], CARDINAL(count) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 83 84 WHILE ( header.nifix <> 0 ) OR ( header.nefix <> 0 ) DO ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 85 fixbufcount := FIO.RdBin( f, fixbuf, SIZE(fixbuf) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 86 fixbufseg := SYSTEM.Seg(fixbuf); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 87 fixbufoff := SYSTEM.Ofs(fixbuf); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 88 REPEAT 89 tmp := VAL(CARDINAL,[fixbufseg:fixbufoff bp]^); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 90 INC(fixbufoff); ***** ^ undeclared identifier ***** ^ not supported yet 91 Locseg := [fixbufseg:fixbufoff]^; ***** ^ not supported yet ***** ^ not supported yet 92 INC(fixbufoff,2); ***** ^ undeclared identifier ***** ^ not supported yet 93 Target := [fixbufseg:fixbufoff]^; ***** ^ not supported yet ***** ^ not supported yet 94 INC(fixbufoff,2); ***** ^ undeclared identifier ***** ^ not supported yet 95 96 base := Seg[ tmp DIV 16 ]; ***** ^ undeclared identifier ***** ^ not supported yet 97 tmp := tmp MOD 16; 98 IF header.nefix <> 0 THEN ***** ^ not supported yet ***** ^ not supported yet 99 DEC(header.nefix); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 100 IF base <> CARDINAL(-1) THEN ***** ^ not supported yet 101 [ Locseg+base : tmp ]^ := Target + s; ***** ^ not supported yet ***** ^ not supported yet 102 END; 103 ELSE 104 DEC(header.nifix); 105 IF base <> CARDINAL(-1) THEN 106 [ Locseg + s : tmp ]^ := Target + base; 107 END; 108 END; 109 DEC(fixbufcount,5); 110 UNTIL fixbufcount = 0; 111 END; 112 113 FIO.Close(f); 114 115 END Load; 116 117 PROCEDURE UnLoad( n:CARDINAL ); 118 VAR a:ADDRESS; 119 BEGIN 120 IF (n<>0) AND ( Seg[n]<>MAX(CARDINAL) ) THEN 121 a := [Seg[n]:0]; 122 Storage.HeapDeallocate( Storage.MainHeap, a, Size[n] ); 123 Seg[n] := MAX(CARDINAL); 124 END ; 125 END UnLoad; 126 127 PROCEDURE (*$S-*) Init; 128 VAR i:CARDINAL; 129 BEGIN 130 FOR i := 0 TO 9 DO 131 Seg[i] := MAX(CARDINAL); 132 END; 133 Seg[0] := Lib.PSP+10H; 134 END Init; 135 136 BEGIN 137 Path := 'OMAIN' ; (* Base mame of overlay files *) 138 Init; 139 END Ovl117. 130 errors