home *** CD-ROM | disk | FTP | other *** search
- { --- January 4, 1986 ---
-
- DEMONSTRATION OF PROCEDURE HEAP2SCR, which will
- be part of a future release of Boosters.
- Boosters is a collection of assembler-based
- programmer's utilities for Turbo Pascal, some
- of which are used in this demo.
-
- As freeware, Boosters can be found on various
- BBSs or ordered as follows:
-
- $25 - includes all source, many demos, 52-page users
- guide text file.
- $35 - all of the above, plus printed users guide.
-
- Send remittance to: George F. Smith
- 609 Candlewick Lane
- Lilburn, GA 30247
- (404) 923-6879
- }
-
- Type
- AnyString = string[255];
- HeapBuf = ^AnyBuf;
- AnyBuf = Record
- Screen : array[1..4000] of byte;
- end;
- ColumnType = 1..80; { With $R directive active, }
- RowType = 1..25; { keeps video routines in line }
-
- Var
-
- I { the ubiquitous index variable }
- : Integer;
-
- Xheap : ColumnType;
- Yheap : RowType;
- HeapTop : ^Integer; { for marking current top of heap }
-
- Ch { as in read(Kbd,ch) after KeyPressed }
- : Char;
-
- page { screens for SaveScreen, RestoreScreen,
- and MoveBg }
- : array[1..2] of HeapBuf;
-
- S { general string array }
- : AnyString;
-
- Dflag : array[1..5] of boolean;
-
-
-
- Const
- H = 'H'; { Code for horizontal PutStr & GetStr }
- V = 'V'; { " " vertical " " " }
- StartElapsed : Boolean = FALSE;
- { Initial value for etime function }
-
-
- { ---------------
- CENTER a string
- --------------- }
-
- Function CENTER ( A : AnyString;
- N : Integer;
- Pad : Char ) : AnyString;
- { AnyString is type String[255] }
-
- begin
- InLine ($1E/ $8D/$9E/$08/$01/ $8B/$46/$06/ $36/$88/$07/ $43/
- $8A/$4E/$08/ $30/$ED/ $29/$C8/ $77/$05/ $31/$C0/ $EB/$12/$90/
- $D1/$E8/ $50/ $8B/$FB/ $8B/$46/$04/ $8B/$4E/$06/ $16/ $07/
- $FC/ $F3/$AA/ $58/ $01/$C3/ $8B/$FB/ $8D/$76/$09/ $16/ $1F/
- $8A/$4E/$08/ $30/$ED/ $FC/ $F3/$A4/ $1F);
- end { Center };
-
- { ---------------------------------------------------
- PUTSTR - Write a string directly to display memory
- --------------------------------------------------- }
-
- Procedure PutStr ( HV : Char;
- S : AnyString;
- X : ColumnType;
- Y : RowType;
- Att : Byte );
-
- begin
- InLine ($1E/ $BB/$49/$04/ $31/$C0/ $8E/$D8/ $8A/$07/ $3C/$07/ $75/$06/
- $BA/$00/$B0/ $EB/$0C/$90/ $BA/$DA/$03/ $EC/ $24/$08/ $74/$FB/
- $BA/$00/$B8/ $8E/$C2/ $8B/$5E/$08/ $09/$DB/ $74/$0C/ $4B/
- $8B/$46/$06/ $48/ $8A/$F0/ $8A/$D3/ $EB/$05/$90/ $B4/$03/
- $CD/$10/ $8A/$DE/ $30/$FF/ $8B/$C3/ $B1/$07/ $D3/$E0/ $B1/$05/
- $D3/$E3/ $01/$C3/ $8A/$C2/ $30/$E4/ $D1/$E0/ $01/$C3/ $8B/$FB/
- $8A/$4E/$0A/ $30/$ED/ $8D/$76/$0B/ $16/ $1F/ $8A/$66/$04/
- $8B/$96/$0A/$01/ $80/$FA/$76/ $74/$0A/ $80/$FA/$56/ $74/$05/
- $31/$D2/ $EB/$04/$90/ $BA/$9E/$00/ $FC/ $8A/$04/ $AB/ $01/$D7/
- $46/ $E2/$F8/ $09/$D2/ $74/$04/ $81/$EF/$9E/$00/ $8B/$C7/
- $31/$D2/ $BB/$A0/$00/ $F7/$F3/ $D0/$EA/ $8A/$F0/ $B4/$02/
- $CD/$10/ $1F/$5D);
- end { PutStr };
-
- { -------------------------------------------------
- PUTHEAP - Write a string to Page [n] of the heap
- ------------------------------------------------- }
-
- Procedure PutHeap ( PAGE : HeapBuf;
- HV : Char;
- S : AnyString;
- X : ColumnType;
- Y : RowType;
- Att : Byte );
- external 'PutHeap.com';
-
- { -------------------------------
- COPIES characters into a string
- ------------------------------- }
- Function COPIES (C : Char;
- N : Integer ): AnyString;
- { AnyString is Type string[255] }
- begin
- InLine ($16/ $07/ $8B/$4E/$04/ $88/$4E/$08/ $8B/$46/$06/ $8D/$7E/$09/
- $FC/ $F3/$AA );
- end { Copies };
-
- {$IBoxul}
- {$IBoxHeap}
-
- { -----------------------------------
- SAVESCREEN saves the current screen
- ----------------------------------- }
- Procedure SaveScreen ( Page : HeapBuf);
- external 'Saves.com';
-
- { -------------------------------------
- RESTORESCREEN restores a saved screen
- ------------------------------------- }
- Procedure RestoreScreen ( Page : HeapBuf);
- external 'Restores.com';
-
- { --------
- HEAP2SCR:
- --------
- Copies the block defined by (X1,Y1) and (X2,Y2) on a page of
- heap memory to the video display beginning at (X3,Y3).
- Unlike RestoreScreen, Heap2Scr copies only the block defined
- by its upper-left and lower-right coordinates. }
-
- Procedure Heap2Scr ( Page : HeapBuf;
- X1 : ColumnType;
- Y1 : RowType;
- X2 : ColumnType;
- Y2 : RowType;
- X3 : ColumnType;
- Y3 : RowType
- ); external 'B:\Heap2scr.com';
-
-
-
- Procedure ClearFlags;
- begin
- for i := 1 to 5 do
- dflag[i] := false;
- end; { ClearFlags }
-
- BEGIN
-
- Mark ( HeapTop );
- New ( Page[1] );
- New ( Page[2] );
- ClrScr;
- SaveScreen ( page[1] );
- SaveScreen ( page[2] );
-
- PutHeap ( Page[1], h, 'A', 40, 1, 11 );
- PutHeap ( Page[1], h, Center (#17+' B O O S T E R S '+#16,80,' '),
- 1, 2, 11 );
- PutHeap ( Page[1], h, Center('H E A P 2 S C R D E M O',80,' '),
- 1,3, 11 );
- BoxHeap ( Page[1], 1, 4, 80, 6, 3, 14 );
- for i := 1 to 4 do
- begin
- PutHeap ( Page[1], h, #210, 16 * i, 4, 14 );
- PutHeap ( Page[1], h, #186, 16 * i, 5, 14 );
- PutHeap ( Page[1], h, #208, 16 * i, 6, 14 );
- end;
-
- PutHeap ( Page[1], h, Center ( 'NORTHEAST',14,' '), 2, 5, 11 );
- PutHeap ( Page[1], h, Center ( 'SOUTHEAST',14,' '),17, 5, 11 );
- PutHeap ( Page[1], h, Center ( 'MIDWEST', 14,' '),33, 5, 11 );
- PutHeap ( Page[1], h, Center ( 'NORTHWEST',14,' '),49, 5, 11 );
- PutHeap ( Page[1], h, Center ( 'SOUTHWEST',14,' '),65, 5, 11 );
-
- BoxHeap ( Page[1], 20, 18, 60, 24, 1, 11 );
- PutHeap ( Page[1], h, Center('PROCEDURE HEAP2SCR (1/4/86)',39,' '),
- 21, 19, 11 );
- PutHeap ( Page[1], h, Center('A Turbo Pascal external .com routine',39,' '),
- 21, 20, 11 );
- PutHeap ( Page[1], h, Center('that copies blocks from the heap to ',39,' '),
- 21, 21, 11 );
- PutHeap ( Page[1], h, Center('the screen--see README.H2S. ',39,' '),
- 21, 22, 11 );
- PutHeap ( Page[1], h, Center('Arrow, tab keys for menus--Q quits. ',39,' '),
- 21, 23, 11 );
- RestoreScreen ( Page[1] );
-
- { ------------ NORTHEAST CITIES ------------ }
- Boxheap ( Page[2], 1, 1, 16, 10, 3, 14 );
- PutHeap ( Page[2], h, #199, 1, 1, 14 );
- PutHeap ( Page[2], h, #215, 16, 1, 14 );
- PutHeap ( Page[2], h, #175+' BANGOR', 3, 3, 11 );
- PutHeap ( Page[2], h, #175+' PAWTUCKET', 3, 4, 11 );
- PutHeap ( Page[2], h, #175+' HOLYOKE', 3, 5, 11 );
- PutHeap ( Page[2], h, #175+' CONCORD', 3, 6, 11 );
- PutHeap ( Page[2], h, #175+' RIDGEFIELD', 3, 7, 11 );
- PutHeap ( Page[2], h, #175+' HERSHEY', 3, 8, 11 );
-
- { ----------- SOUTHEAST CITIES ----------- }
- Boxheap ( Page[2],20, 1, 36, 10, 3, 14 );
- PutHeap ( Page[2], h, #215, 20, 1, 14 );
- PutHeap ( Page[2], h, #215, 36, 1, 14 );
- PutHeap ( Page[2], h, #175+' CHARLOTTE', 22, 3, 11 );
- PutHeap ( Page[2], h, #175+' SHENANDOAH',22, 4, 11 );
- PutHeap ( Page[2], h, #175+' ELLIJAY', 22, 5, 11 );
- PutHeap ( Page[2], h, #175+' TUSCALOOSA',22, 6, 11 );
- PutHeap ( Page[2], h, #175+' KINGSPORT', 22, 7, 11 );
- PutHeap ( Page[2], h, #175+' TUPELO', 22, 8, 11 );
-
-
- { ----------- MIDWEST CITIES ------------- }
- Boxheap ( Page[2],40, 1, 56, 10, 3, 14 );
- PutHeap ( Page[2], h, #215, 40, 1, 14 );
- PutHeap ( Page[2], h, #215, 56, 1, 14 );
- PutHeap ( Page[2], h, #175+' SAGINAW', 42, 3, 11 );
- PutHeap ( Page[2], h, #175+' DUBUQUE', 42, 4, 11 );
- PutHeap ( Page[2], h, #175+' PEORIA', 42, 5, 11 );
- PutHeap ( Page[2], h, #175+' MANKATO', 42, 6, 11 );
- PutHeap ( Page[2], h, #175+' DODGE CITY',42, 7, 11 );
- PutHeap ( Page[2], h, #175+' JOPLIN', 42, 8, 11 );
-
- { ----------- NORTHWEST CITIES ------------ }
- Boxheap ( Page[2],20,12, 36, 21, 3, 14 );
- PutHeap ( Page[2], h, #215, 20,12, 14 );
- PutHeap ( Page[2], h, #215, 36,12, 14 );
- PutHeap ( Page[2], h, #175+' LARAMIE', 22,14, 11 );
- PutHeap ( Page[2], h, #175+' HELENA', 22,15, 11 );
- PutHeap ( Page[2], h, #175+' YAKIMA', 22,16, 11 );
- PutHeap ( Page[2], h, #175+' EUGENE', 22,17, 11 );
- PutHeap ( Page[2], h, #175+' FARGO', 22,18, 11 );
- PutHeap ( Page[2], h, #175+' DUBOIS', 22,19, 11 );
-
- { ------------ SOUTHWEST CITIES ------------ }
- Boxheap ( Page[2], 1,12, 17, 21, 3, 14 );
- PutHeap ( Page[2], h, #215, 1,12, 14 );
- PutHeap ( Page[2], h, #182, 17,12, 14 );
- PutHeap ( Page[2], h, #175+' TUCUMCARI', 3,14, 11 );
- PutHeap ( Page[2], h, #175+' FLAGSTAFF', 3,15, 11 );
- PutHeap ( Page[2], h, #175+' LUBBOCK', 3,16, 11 );
- PutHeap ( Page[2], h, #175+' MUSKOGEE', 3,17, 11 );
- PutHeap ( Page[2], h, #175+' DURANGO', 3,18, 11 );
- PutHeap ( Page[2], h, #175+' PROVO', 3,19, 11 );
-
-
- ClearFlags;
- GoToXY(1,5);
- repeat
- read(Kbd,ch);
- if (ch = #27) and KeyPressed then { . . . move the cursor }
- begin
- read(Kbd,ch);
- case Ch of
- { SH-TAB } #15 : if (WhereX >= 1) and (WhereX <= 16) then
- GotoXY(65,WhereY)
- else
- if (WhereX > 16) and (WhereX <= 32) then
- GotoXY(02,WhereY)
- else
- if (WhereX > 32) and (WhereX <= 48) then
- GotoXY(17,WhereY)
- else
- if (WhereX > 48) and (WhereX <= 64) then
- GotoXY(33,WhereY)
- else
- if (WhereX > 64) and (WhereX <= 80) then
- GotoXY(49,WhereY);
- { HOME } #71 : GotoXY(2,WhereY);
- { UP } #72 : if WhereY = 1 then
- gotoXY(WhereX,25)
- else
- gotoXY(WhereX,WhereY-1);
- { LEFT } #75 : if WhereX = 1 then
- gotoXY(80, WhereY)
- else
- gotoXY(WhereX-1,WhereY);
- { RIGHT } #77 : if WhereX = 80 then
- gotoXY(1, WhereY)
- else
- gotoXY(WhereX+1,WhereY);
- { END } #79 : GotoXY(65,WhereY);
- { DOWN } #80 : if WhereY = 25 then
- gotoXY(WhereX,1)
- else
- gotoXY(WhereX,WhereY+1);
- end { case };
- end
- else
- begin
- case Ch of
- { TAB } #9 : begin
- if (WhereX >= 1) and (WhereX <= 16) then
- GotoXY(17,WhereY)
- else
- if (WhereX > 16) and (WhereX <= 32) then
- GotoXY(33,WhereY)
- else
- if (WhereX > 32) and (WhereX <= 48) then
- GotoXY(49,WhereY)
- else
- if (WhereX > 48) and (WhereX <= 64) then
- GotoXY(65,WhereY)
- else
- if (WhereX > 64) and (WhereX <= 80) then
- GotoXY(2,WhereY);
- end;
- end; { short case }
- end { begin };
-
- { If cursor on line 5, check to see
- if we need to display a menu from heap. }
-
- if WhereY = 5 then
- begin
- if (WhereX > 1) and (WhereX < 16) then
- begin { . . . Northeast }
- if not dflag[1] then
- begin
- RestoreScreen ( page[1] );
- ClearFlags;
- dflag[1] := true;
- Heap2Scr ( Page[2], 1, 1, 16, 10, 1, 6 );
- end;
- end
- else
- if (WhereX > 16) and (WhereX < 32) then
- begin { . . . Southeast }
- if not dflag[2] then
- begin
- RestoreScreen ( page[1] );
- ClearFlags;
- dflag[2] := true;
- Heap2Scr ( Page[2],20, 1, 36, 10,16, 6 );
- end;
- end
- else
- if (WhereX > 32) and (WhereX < 48) then
- begin { . . . Midwest }
- if not dflag[3] then
- begin
- RestoreScreen ( page[1] );
- ClearFlags;
- dflag[3] := true;
- Heap2Scr ( Page[2],40, 1, 56, 10,32, 6 );
- end;
- end
- else
- if (WhereX > 48) and (WhereX < 64) then
- begin { . . . Northwest }
- if not dflag[4] then
- begin
- RestoreScreen ( page[1] );
- ClearFlags;
- dflag[4] := true;
- Heap2Scr ( Page[2],20,12, 36, 21,48, 6 );
- end;
- end
- else
- if (WhereX > 64) and (WhereX < 80) then
- begin { . . . Southwest }
- if not dflag[5] then
- begin
- RestoreScreen ( page[1] );
- ClearFlags;
- dflag[5] := true;
- Heap2Scr ( Page[2],1,12, 17, 21,64, 6 );
- end;
- end
- else
- begin
- RestoreScreen ( page[1] );
- ClearFlags;
- end
- end;
- until UpCase(Ch) = #81;
-
- Release ( HeapTop );
-
- END { demo of Heap2Scr }.