THE FOLLOWING PROCEDURES FOR LOADING SCREEN AND APF FORMAT GRAPHICS ARE IN TML PASCAL! The following variables are global and should be defined at the beginning of your program: {**************************************************************} type FileEntry = record Bytes : Integer; Mode : Integer; end; Var myReply : ReplyRecord; P16Blk : P16ParamBlk; myType : TypeListRec; FilePixels : Longint; srcBuffer : Handle; myFileName : String[15]; tempPort, OffScreen : GrafPtr; OffLoc : LocInfoRec; OffH : Handle; OffRgnH : RgnHandle; {$DSeg One} DirEntry : Array [0..400] of FileEntry; {**************************************************************} The procedure "doStart" is used to set up an offscreen pixel map to store the picture. It can also be used to intialize any global variables needed in your program. {**************************************************************} procedure doStart; Var LocRect : Rect; begin srcBuffer := NewHandle(512, myID, 0, nil); with LocRect do begin top := 0; Left := 0; Bottom := 400; right := 320; end; OffRgnH := NewRgn; SetRectRgn(OffRgnH, 0, 0, 320, 400); OffH := NewHandle(64000, MyId, PageAligned + SpecialMem + FixedBlk + Locked, nil); OpenPort(OffScreen); SetFont(GetSysFont); OffLoc.BoundsRect := LocRect; OffLoc.width := 160; OffLoc.PixelImage := OffH^; OffLoc.portSCB := GetMasterSCB; SetPortLoc(OffLoc); SetPortRect(LocRect); SetBackColor(15); SetForeColor(0); ClipRect(LocRect); PenNormal; SetVisHandle(OffRgnH); end; {**************************************************************} Procedure LoadScreen; var fileno : Integer; begin If FrontWindow <> Nil then CloseWindow(FrontWindow); myFileName := myreply.filename; P16Blk.pathname2 := @myreply.fullpathname; P16Blk.ioBuffer := srcBuffer; P16Open(P16Blk); fileNo := P16Blk.refNum; P16Blk.refNum := fileNo; P16Blk.dataBuffer := OffLoc.PixelImage; P16Blk.requestCount := $FFFFFF; P16Read(P16Blk); P16Blk.refNum := fileNo; P16Close(P16Blk); BlockMove(pointer(Ord4(OffLoc.PixelImage) + $7D00), Pointer($E19D00), $300); end; {**************************************************************} procedure LoadAPF; type FileBlock = record Length : LongInt; Kind : String[4]; Mode : Integer; Pixels : Integer; Palettes : Integer; end; var Block : FileBlock; TempDir : FileEntry; I, FileNo, ScanLines, TotalBytes, number : Integer; ScreenPtr, TempPtr : Ptr; TempLine, ScreenH : Handle; Palette : ColorTable; begin ScreenH := OffH; TempLine := NewHandle(320, MyId, Locked + SpecialMem, nil); TempPtr := TempLine^; myFileName := myreply.filename; P16Blk.pathname2 := @myreply.fullpathname; P16Blk.ioBuffer := srcBuffer; P16Open(P16Blk); fileNo := P16Blk.refNum; P16Blk.refNum := fileNo; P16Blk.dataBuffer := @Block; P16Blk.requestCount := SizeOf(Block); P16Read(P16Blk); For I := 1 to Block.Palettes do begin fileNo := P16Blk.refNum; P16Blk.refNum := fileNo; P16Blk.dataBuffer := @Palette; P16Blk.requestCount := SizeOf(Palette); P16Read(P16Blk); SetColorTable( I - 1, Palette); end; fileNo := P16Blk.refNum; P16Blk.refNum := fileNo; P16Blk.dataBuffer := @ScanLines; P16Blk.requestCount := SizeOf(ScanLines); P16Read(P16Blk); For I := 1 to ScanLines do begin fileNo := P16Blk.refNum; P16Blk.refNum := fileNo; P16Blk.dataBuffer := @TempDir; P16Blk.requestCount := SizeOf(TempDir); P16Read(P16Blk); DirEntry[ I - 1] := TempDir; end; number := 64000; For I := 1 to ScanLines do begin fileNo := P16Blk.refNum; P16Blk.refNum := fileNo; P16Blk.dataBuffer := TempPtr; P16Blk.requestCount := DirEntry[I-1].bytes; P16Read(P16Blk); TotalBytes := UnpackBytes(TempPtr, DirEntry[I-1].bytes, ScreenH, number); end; P16Blk.refNum := fileNo; P16Close(P16Blk); TempPtr := nil; DisposeHandle(TempLine); OffH^ := OffLoc.PixelImage; end; {**************************************************************} function GraphFilter(DirectoryEntry: LongInt): Integer; var Ptr1, Ptr2, Ptr3 : Ptr; FileType, AuxType : Integer; begin Ptr1 := pointer(DirectoryEntry + $1F); Ptr2 := pointer(DirectoryEntry + $20); Ptr3 := pointer(DirectoryEntry + $10); AuxType := Ptr1^ + Ptr2^; FileType := Ptr3^; Case FileType of -64 : If AuxType = $0002 then ChartFilter := 2 else ChartFilter := 1; -63 : If AuxType = $0000 then ChartFilter := 2 else ChartFilter := 1; end; end; {**************************************************************} procedure LoadInfo; var TempWind : WindowPtr; begin TempPort := GetPort; myType.numEntries := $02; myType.Filetype1 := $C0; myType.Filetype2 := $C1; SFGetFile(20,30,'Select Graphics File', @GraphFilter, @myType, myreply); SetPort(TempPort); if myReply.good then begin WaitCursor; if ((myReply.filetype = $C1) and (myReply.AuxFileType = $0000)) then LoadScreen else if ((myReply.filetype = $C0) and (myReply.AuxFileType = $0002)) then LoadAPF; end; InitCursor; end;