{************ Global Constants and Variables ******************} type FileEntry = record Bytes : Integer; Mode : Integer; end; FileBlock = record Length : LongInt; Kind : String[4]; Mode : Integer; Pixels : Integer; Palettes : Integer; end; MyParamBlk = record Pathname1 : StringPtr; Access : Integer; FileType : Integer; AuxType : LongInt; StorageType : Integer; end; var LocRect : Rect; Block : FileBlock; FileData : MyParamBlk; myReply : ReplyRecord; P16Blk : P16ParamBlk; myType : TypeListRec; srcBuffer : Handle; myFileName : String[15]; tempPort, OffScreen : GrafPtr; OffLoc : LocInfoRec; OffH, PWStorage : Handle; OffRgnH : RgnHandle; ScanLines, GraphType, PWSize : Integer; {**************************************************************} procedure SaveScreen; var Fileno : Integer; begin P16Blk.PathName1 := @MyReply.FullPathname; P16Blk.Access := FileData.Access; P16Blk.FileType := FileData.Filetype; P16Blk.AuxType := FileData.AuxType; P16Blk.StorageType := FileData.StorageType; P16Blk.CreateDate := 0; P16Blk.ModDate := 0; P16Create(P16Blk); P16Blk.pathname2 := @myreply.fullpathname; P16Blk.ioBuffer := srcBuffer; P16Open(P16Blk); fileNo := P16Blk.refNum; P16Blk.refNum := fileNo; P16Blk.dataBuffer := OffLoc.PixelImage; P16Blk.requestCount := $008000; P16Write(P16Blk); P16Blk.refNum := fileNo; P16Close(P16Blk); end; {**************************************************************} Procedure LoadScreen; var fileno : Integer; begin myFileName := myreply.filename; P16Blk.Pathname1 := @MyReply.FullPathname; P16GetFileInfo(P16Blk); FileData.access := P16Blk.access; FileData.FileType := P16Blk.Filetype; FileData.AuxType := P16Blk.Auxtype; FileData.StorageType := P16Blk.StorageType; 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); ScanLines := 200; GraphType := 1; end; {**************************************************************} procedure SaveAPF; var TempDir : FileEntry; I, FileNo, Packing, number, No : Integer; ScreenPtr, TempPtr : Ptr; TempLine, ScreenH : Handle; Palette : ColorTable; begin ScreenH := OffH; TempLine := NewHandle(64000, MyId, Locked + SpecialMem, nil); TempPtr := TempLine^; myFileName := myreply.filename; P16Blk.PathName1 := @MyReply.FullPathname; P16Blk.Access := FileData.Access; P16Blk.FileType := FileData.Filetype; P16Blk.AuxType := FileData.AuxType; P16Blk.StorageType := FileData.StorageType; P16Blk.CreateDate := 0; P16Blk.ModDate := 0; P16Create(P16Blk); P16Blk.pathname2 := @myreply.fullpathname; P16Blk.ioBuffer := srcBuffer; P16Open(P16Blk); fileNo := P16Blk.refNum; P16Blk.refNum := fileNo; P16Blk.dataBuffer := @Block; P16Blk.requestCount := SizeOf(Block); P16Write(P16Blk); For I := 1 to Block.Palettes do begin GetColorTable( I - 1, Palette); P16Blk.refNum := fileNo; P16Blk.dataBuffer := @Palette; P16Blk.requestCount := SizeOf(Palette); P16Write(P16Blk); end; P16Blk.refNum := fileNo; P16Blk.dataBuffer := @ScanLines; P16Blk.requestCount := SizeOf(ScanLines); P16Write(P16Blk); No := 160; Number := 64000; For I := 1 to ScanLines do begin DirEntry[I-1].bytes := PackBytes(ScreenH, No, TempPtr, Number); No := 160; TempPtr := Pointer(Ord4(TempPtr) + DirEntry[I-1].bytes); end; No := 0; For I := 1 to ScanLines do begin TempDir := DirEntry[ I - 1]; P16Blk.refNum := fileNo; P16Blk.dataBuffer := @TempDir; P16Blk.requestCount := SizeOf(TempDir); P16Write(P16Blk); No := No + DirEntry[I - 1].bytes; end; TempPtr := TempLine^; For I := 1 to ScanLines do begin P16Blk.refNum := fileNo; P16Blk.dataBuffer := TempPtr; P16Blk.requestCount := DirEntry[I - 1].bytes; P16Write(P16Blk); TempPtr := Pointer(Ord4(TempPtr) + DirEntry[I-1].bytes); end; P16Blk.refNum := fileNo; P16Close(P16Blk); TempPtr := nil; DisposeHandle(TempLine); OffH^ := OffLoc.PixelImage; end; {**************************************************************} procedure LoadAPF; var TempDir : FileEntry; I, FileNo, Packing, 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.Pathname1 := @MyReply.FullPathname; P16GetFileInfo(P16Blk); FileData.access := P16Blk.access; FileData.FileType := P16Blk.Filetype; FileData.AuxType := P16Blk.Auxtype; FileData.StorageType := P16Blk.StorageType; 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 P16Blk.refNum := fileNo; P16Blk.dataBuffer := @Palette; P16Blk.requestCount := SizeOf(Palette); P16Read(P16Blk); SetColorTable( I - 1, Palette); end; P16Blk.refNum := fileNo; P16Blk.dataBuffer := @ScanLines; P16Blk.requestCount := SizeOf(ScanLines); P16Read(P16Blk); For I := 1 to ScanLines do begin P16Blk.refNum := fileNo; P16Blk.dataBuffer := @TempDir; P16Blk.requestCount := SizeOf(TempDir); P16Read(P16Blk); DirEntry[ I - 1] := TempDir; end; For I := 1 to ScanLines do begin P16Blk.refNum := fileNo; P16Blk.dataBuffer := TempPtr; P16Blk.requestCount := DirEntry[I-1].bytes; P16Read(P16Blk); number := 64000; Packing := UnpackBytes(TempPtr, DirEntry[I-1].bytes, ScreenH, number); end; P16Blk.refNum := fileNo; P16Close(P16Blk); TempPtr := nil; DisposeHandle(TempLine); OffH^ := OffLoc.PixelImage; GraphType := 2; end; {**************************************************************} procedure SavePW; var Fileno, Number, No : Integer; Temp : Handle; TempPtr : Ptr; begin Temp := NewHandle(64000, MyId, SpecialMem, nil); No := 64000; Number := PWSize; BlockMove(OffLoc.PixelImage, Temp^, 64000); TempPtr := Pointer(Ord4(PWStorage^) + $222); PWSize := PackBytes(Temp, Number, TempPtr, No); P16Blk.PathName1 := @MyReply.FullPathname; P16Blk.Access := FileData.Access; P16Blk.FileType := FileData.Filetype; P16Blk.AuxType := FileData.AuxType; P16Blk.StorageType := FileData.StorageType; P16Blk.CreateDate := 0; P16Blk.ModDate := 0; P16Create(P16Blk); P16Blk.pathname2 := @myreply.fullpathname; P16Blk.ioBuffer := srcBuffer; P16Open(P16Blk); fileNo := P16Blk.refNum; P16Blk.refNum := fileNo; P16Blk.dataBuffer := PWStorage^; P16Blk.requestCount := PWSize + $222; P16Write(P16Blk); P16Blk.refNum := fileNo; P16Close(P16Blk); DisposeHandle(Temp); end; {**************************************************************} Procedure LoadPW; var fileno, Number : Integer; Palette : ColorTable; Temp, ScreenH : Handle; begin ScreenH := OffH; Temp := NewHandle(64000, MyId, SpecialMem, Nil); myFileName := myreply.filename; P16Blk.Pathname1 := @MyReply.FullPathname; P16GetFileInfo(P16Blk); FileData.access := P16Blk.access; FileData.FileType := P16Blk.Filetype; FileData.AuxType := P16Blk.Auxtype; FileData.StorageType := P16Blk.StorageType; P16Blk.pathname2 := @myreply.fullpathname; P16Blk.ioBuffer := srcBuffer; P16Open(P16Blk); fileNo := P16Blk.refNum; P16Blk.refNum := fileNo; P16Blk.dataBuffer := PWStorage^; P16Blk.requestCount := $FFFFFFFF; P16Read(P16Blk); BlockMove(PWStorage^, @Palette, $20); SetColorTable(0, Palette); BlockMove(Pointer(Ord4(PWStorage^) + $222), Temp^, P16Blk.TransferCount); Number := 64000; PWSize := UnPackBytes(Temp^, P16Blk.TransferCount, ScreenH, Number); P16Blk.refNum := fileNo; P16Close(P16Blk); ScanLines := PWSize div 160; DisposeHandle(Temp); OffH^ := OffLoc.PixelImage; GraphType := 3; end; {**************************************************************} function ChartFilter; var Ptr1, Ptr2, Ptr3 : Ptr; FileType, AuxType : Integer; begin Ptr3 := pointer(DirEntry + $10); Ptr1 := pointer(DirEntry + $1F); Ptr2 := pointer(DirEntry + $20); FileType := Ptr3^; AuxType := Ptr1^ + Ptr2^; Case FileType of -64 : If ((AuxType = $0002) or (AuxType = $0)) then ChartFilter := 2 else ChartFilter := 1; -63 : If AuxType = $0000 then ChartFilter := 2 else ChartFilter := 1; end; end; {**************************************************************} procedure LoadIt; var TempWind : WindowPtr; begin TempPort := GetPort; myType.numEntries := $02; myType.Filetype1 := $C0; myType.Filetype2 := $C1; SFGetFile(20,30,'Select Graphic', @ChartFilter, @myType, myReply); SetPort(TempPort); if myReply.good then begin WaitCursor; if ((myReply.filetype = $C1) and (myReply.AuxFileType = $0000)) then LoadScreen; if ((myReply.filetype = $C0) and (myReply.AuxFileType = $0000)) then LoadPW; if ((myReply.filetype = $C0) and (myReply.AuxFileType = $0002)) then LoadAPF; PtrToHand(OffLoc.PixelImage, OrigStore, 64000); end; InitCursor; end; {**************************************************************} Procedure SaveIt; Begin TempPort := GetPort; SFPutFile(20,30, 'Save Graphic', MyFileName, 15, myReply); SetPort(TempPort); if myReply.good then begin WaitCursor; Case GraphType of 1 : SaveScreen; 2 : SaveAPF; 3 : SavePW; end; InitCursor; end; end; {**************************************************************} procedure doStart; begin srcBuffer := NewHandle(512, myID, 0, nil); PWStorage := NewHandle(64000, MyId, SpecialMem, nil); GraphType := 0; 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;