Borland Turbo Pascal v7

This commit is contained in:
davidly 2024-07-02 08:21:37 -07:00
parent 7a44dc7526
commit 7addaf4bad
273 changed files with 121074 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,285 @@
/***********************************************************************
Brief editor emulation for Borland/Turbo Pascal IDE.
This file contains a Turbo Editor Macro Language (TEML) script
which emulates the Brief programmer's editor in the Borland/Turbo Pascal
IDE. A complete description of the TEML language and the Turbo Editor
Macro Compiler (TEMC) can be found in the file "TEMC.DOC".
The TEMC compiler can be invoked from the DOS command line as
follows:
temc [-c] brief.tem <IDE configuration file><.CMD><.TP>
The optional -c switch can also be specified as /c, and can appear in
any argument position on the command line. If you use this option,
any existing command table in your configuration file is thrown away
before the script file is merged with those already defined. The
configuration file extension must be specified as TEMC will modify both DOS
and Windows IDEs config files. Specify .CMD or .TP extentions for Windows
or DOS IDE, respectively. If the .CMD file does not exist, it will be
created. The .TP file must exist, or an error is displayed.
Most of the simple Brief commands have been fully implemented. Most
of the complex commands have been either partially implemented or not
implemented at all. Below is a list of the commands that have been
fully or partially implemented.
IDE Binding Brief Command Comments
----------- --------------- -------------------------
F10 Command Activates system menu
Ins Paste Scrap Pastes current clipboard selection
Del Delete Deletes current character only
PgDn Page Down
PgUp Page Up
UpAr Cursor Up
DnAr Cursor Down
Star Undo
Plus Copy to Scrap Copies block to clipboard
Minus Cut to Scrap Cuts block to clipboard
Ctrl-D Scroll Down
Ctrl-E Scroll Up
Ctrl-G Routines Activates the search menu
Find function can be selected here
Ctrl-N Next Error
Ctrl-P Error list Moves to previous error
Ctrl-K Delete To BOL Deletes to beginning of line
Ctrl-U Redo
Ctrl-W Toggle Backup Activates Options menu
Backup files can be toggled here
Ctrl-F5 Case Sensitivity Selects search dialog box
Case sensitivity can be toggled here
Ctrl-F6 Toggle Regular Exp. Selects search dialog box
Regular expressions can be toggled here
Ctrl-bksp Delete Prev Word
Alt-A Drop anchor Sets beginning of block
Alt-B Buffer List Lists ALL open windows
Alt-G Goto line Activates the search menu
Goto line can be selected here
Alt-H Help Context sensitive help
Alt-I Toggle Insert
Alt-J+0 Goto BookMark(0) Only marks 0-5 are supported
Alt-J+1 Goto BookMark(1) :
Alt-J+2 Goto BookMark(2) :
Alt-J+3 Goto BookMark(3) :
Alt-J+4 Goto BookMark(4) :
Alt-J+5 Goto BookMark(5) by this macro file
Alt-K Delete To EOL
Alt-L Mark Line
Alt-M Mark Sets beginning of block
Alt-N Next Buffer Cycles to next open window
Alt-P Print Block
Alt-Q Quote Insert literal character
Alt-U Undo
Alt-V Version Activates system menu
About can be selected here
Alt-X Quit
Alt-Z DOS Shell Activates the file menu
OS Shell can be selected here
Alt-F2 Zoom Window
IDE does not support inc. search
Alt-F6 Translate Backwards Prompts for replace string
Option to go backward can be selected
****************************************************************/
/******* Macros ********/
MACRO MacScrollUp
ScrollScreenUp;
FixCursorPos;
END;
MACRO MacScrollDown
ScrollScreenDown;
FixCursorPos;
END;
MACRO MacPageUp
FixScreenPos;
PageScreenDown;
FixCursorPos;
END;
MACRO MacPageDown
FixScreenPos;
PageScreenUp;
FixCursorPos;
END;
MACRO MacDeleteLine
DeleteLine;
LeftOfLine;
END;
MACRO MacTopOfScreen
SetPrevPos;
TopOfScreen;
END;
MACRO MacBottomOfScreen
SetPrevPos;
BottomOfScreen;
END;
MACRO MacHomeCursor
SetPrevPos;
HomeCursor;
END;
MACRO MacEndCursor
SetPrevPos;
EndCursor;
END;
MACRO MacOpenLine
RightOfLine;
LiteralChar(13);
END;
MACRO MacSetBlockBeg
HideBlock;
SetBlockBeg;
END;
MACRO MacSetBlockEnd
HideBlock;
SetBlockEnd;
HighlightBlock;
END;
MACRO MacMarkLine
HideBlock;
SetTempPos;
RightOfLine;
CursorCharRight;
SetBlockEnd;
CursorCharLeft;
LeftOfLine;
SetBlockBeg;
HighlightBlock;
MoveToTempPos;
END;
MACRO MacMarkWord
HideBlock;
SetTempPos;
CursorRight;
WordLeft;
RightOfWord;
SetBlockEnd;
WordLeft;
SetBlockBeg;
HighlightBlock;
MoveToTempPos;
END;
MACRO MacMoveToBlockBeg
SetPrevPos;
MoveToBlockBeg;
CenterFixScreenPos;
END;
MACRO MacMoveToBlockEnd
SetPrevPos;
MoveToBlockEnd;
CenterFixScreenPos;
END;
MACRO MacMoveToPrevPos
SwapPrevPos;
CenterFixScreenPos;
END;
MACRO MacCopyBlock
CopyBlock;
HideBlock;
CenterFixScreenPos;
END;
MACRO MacMoveBlock
MoveBlock;
HighlightBlock;
CenterFixScreenPos;
END;
MACRO MacBreakLine
LiteralChar(13);
CursorCharLeft;
END;
MACRO MacDeleteNextWord
WordRight;
MacMarkWord;
DeleteBlock;
CenterFixScreenPos;
END;
MACRO MacDeletePrevWord
WordLeft;
MacMarkWord;
DeleteBlock;
CenterFixScreenPos;
END;
MACRO MacDeleteToBOL
SetPrevPos;
LeftOfLine;
SetBlockBeg;
MoveToPrevPos;
SetBlockEnd;
DeleteBlock;
CenterFixScreenPos;
END;
/******* Brief Key Bindings ******/
F10 : Menu;
Ins : ClipPaste;
Del : DeleteChar;
PgDn : MacPageDown;
PgUp : MacPageUp;
UpAr : CursorUp;
DnAr : CursorDown;
Star : Undo;
Plus : ClipCopy;
Minus : ClipCut;
Ctrl-D : MacScrollDown;
Ctrl-E : MacScrollUp;
Ctrl-G : SearchMenu;
Ctrl-N : NextError;
Ctrl-P : PrevError;
Ctrl-K : MacDeleteToBOL;
Ctrl-U : Redo;
Ctrl-W : OptionsMenu;
Ctrl-F5 : GetFindString;
Ctrl-F6 : GetFindString;
Ctrl-bksp : MacDeletePrevWord;
Alt-A : SetBlockBeg;
Alt-B : WindowList;
Alt-G : SearchMenu;
Alt-H : Help;
Alt-I : ToggleInsert;
Alt-J+0 : MoveToMark(0);
Alt-J+1 : MoveToMark(1);
Alt-J+2 : MoveToMark(2);
Alt-J+3 : MoveToMark(3);
Alt-J+4 : MoveToMark(4);
Alt-J+5 : MoveToMark(5);
Alt-K : DeleteToEOL;
Alt-L : MacMarkLine;
Alt-M : SetBlockBeg;
Alt-N : NextWindow;
Alt-P : PrintBlock;
Alt-Q : LiteralChar;
Alt-U : Undo;
Alt-X : Quit;
Alt-Z : FileMenu;
Alt-F2 : ZoomWindow;
Alt-F6 : GetFindString;


View File

@ -0,0 +1,393 @@
Script DEFAULTS;
/***********************************************************************
Default editor bindings for Borland/Turbo Pascal IDE.
This file contains a Turbo Editor Macro Language (TEML) script which
is the default editor bindings for the Borland/Turbo Pascal IDEs as
shipped. A complete description of the TEML language and the Turbo Editor
Macro Compiler (TEMC) can be found in the file "TEMC.DOC".
The TEMC compiler can be invoked from the DOS command line at
follows:
temc [-c] defaults.tem <IDE configuration file><.CMD><.TP>
The optional -c switch can also be specified as /c, and can appear in
any argument position on the command line. If you use this option,
any existing command table in your configuration file is thrown away
before the script file is merged with those already defined. The
configuration file extension must be specified as TEMC will modify both DOS
and Windows IDEs config files. Specify .CMD or .TP extentions for Windows
or DOS IDE, respectively. If the .CMD file does not exist, it will be
created. The .TP file must exist, or an error is displayed.
/* macro definitions for anything which isn't an editor primitive */
MACRO MacScrollUp
ScrollScreenUp;FixCursorPos;
END;
MACRO MacScrollDown
ScrollScreenDown;FixCursorPos;
END;
MACRO MacPageUp
SetPrevPos;FixScreenPos;PageUp;FixCursorPos;
END;
MACRO MacPageDown
SetPrevPos;FixScreenPos;PageDown;FixCursorPos;
END;
MACRO MacWordLeft
SetPrevPos;WordLeft;
END;
MACRO MacWordRight
SetPrevPos;WordRight;
END;
MACRO MacDeleteLine
DeleteLine;LeftOfLine;
END;
MACRO MacLeftOfLine
SetPrevPos;LeftOfLine;
END;
MACRO MacRightOfLine
SetPrevPos;RightOfLine;
END;
MACRO MacTopOfScreen
SetPrevPos;TopOfScreen;
END;
MACRO MacBottomOfScreen
SetPrevPos;BottomOfScreen;
END;
MACRO MacHomeCursor
SetPrevPos;HomeCursor;
END;
MACRO MacEndCursor
SetPrevPos;EndCursor;
END;
MACRO MacOpenLine
SetPrevPos;RightOfLine;LiteralChar(13);
END;
MACRO MacInsertStar
InsertText("*");
END;
MACRO MacInsertMinus
InsertText("-");
END;
MACRO MacInsertPlus
InsertText("+");
END;
MACRO MacMarkCursorSwitchedRight
ExtendBlockBeg;CursorSwitchedRight;ExtendBlockEnd;HighlightBlock;
END;
MACRO MacMarkCursorSwitchedLeft
ExtendBlockBeg;CursorSwitchedLeft;ExtendBlockEnd;HighlightBlock;
END;
MACRO MacMarkCursorUp
ExtendBlockBeg;CursorUp;ExtendBlockEnd;HighlightBlock;
END;
MACRO MacMarkCursorDown
ExtendBlockBeg;CursorDown;ExtendBlockEnd;HighlightBlock;
END;
MACRO MacMarkPageUp
ExtendBlockBeg;PageUp;FixCursorPos;ExtendBlockEnd;HighlightBlock;
END;
MACRO MacMarkPageDown
ExtendBlockBeg;PageDown;FixCursorPos;ExtendBlockEnd;HighlightBlock;
END;
MACRO MacMarkWordLeft
ExtendBlockBeg;WordLeft;ExtendBlockEnd;HighlightBlock;
END;
MACRO MacMarkWordRight
ExtendBlockBeg;WordRight;ExtendBlockEnd;HighlightBlock;
END;
MACRO MacMarkLeftOfLine
ExtendBlockBeg;LeftOfLine;ExtendBlockEnd;HighlightBlock;
END;
MACRO MacMarkRightOfLine
ExtendBlockBeg;RightOfLine;ExtendBlockEnd;HighlightBlock;
END;
MACRO MacMarkTopOfScreen
ExtendBlockBeg;TopOfScreen;ExtendBlockEnd;HighlightBlock;
END;
MACRO MacMarkBottomOfScreen
ExtendBlockBeg;BottomOfScreen;ExtendBlockEnd;HighlightBlock;
END;
MACRO MacMarkHomeCursor
ExtendBlockBeg;HomeCursor;ExtendBlockEnd;HighlightBlock;
END;
MACRO MacMarkEndCursor
ExtendBlockBeg;EndCursor;ExtendBlockEnd;HighlightBlock;
END;
MACRO MacSetBlockBeg
HideBlock;SetBlockBeg;HighlightBlock;
END;
MACRO MacSetBlockEnd
HideBlock;SetBlockEnd;HighlightBlock;
END;
MACRO MacMarkLine
HideBlock;SetTempPos;RightOfLine;
CursorCharRight;SetBlockEnd;
CursorCharLeft;LeftOfLine;SetBlockBeg;
HighlightBlock;MoveToTempPos;
END;
MACRO MacMarkWord
HideBlock;SetTempPos;CursorRight;WordLeft;
RightOfWord;SetBlockEnd;WordLeft;
SetBlockBeg;HighlightBlock;MoveToTempPos;
END;
MACRO MacMoveToBlockBeg
SetPrevPos;MoveToBlockBeg;CenterFixScreenPos;
END;
MACRO MacMoveToBlockEnd
SetPrevPos;MoveToBlockEnd;CenterFixScreenPos;
END;
MACRO MacMoveToPrevPos
SwapPrevPos;CenterFixScreenPos;
END;
MACRO MacCopyBlock
CopyBlock;HighlightBlock;CenterFixScreenPos;
END;
MACRO MacMoveBlock
MoveBlock;HighlightBlock;CenterFixScreenPos;
END;
MACRO MacDeleteBlock
DeleteBlock;CenterFixScreenPos;HideBlock;
END;
MACRO MacBreakLine
LiteralChar(13);CursorCharLeft;
END;
MACRO MacGoto0
SetPrevPos;MoveToMark(0); CenterFixScreenPos;
END;
MACRO MacGoto1
SetPrevPos;MoveToMark(1); CenterFixScreenPos;
END;
MACRO MacGoto2
SetPrevPos;MoveToMark(2); CenterFixScreenPos;
END;
MACRO MacGoto3
SetPrevPos;MoveToMark(3); CenterFixScreenPos;
END;
MACRO MacGoto4
SetPrevPos;MoveToMark(4); CenterFixScreenPos;
END;
MACRO MacGoto5
SetPrevPos;MoveToMark(5); CenterFixScreenPos;
END;
MACRO MacGoto6
SetPrevPos;MoveToMark(6); CenterFixScreenPos;
END;
MACRO MacGoto7
SetPrevPos;MoveToMark(7); CenterFixScreenPos;
END;
MACRO MacGoto8
SetPrevPos;MoveToMark(8); CenterFixScreenPos;
END;
MACRO MacGoto9
SetPrevPos;MoveToMark(9); CenterFixScreenPos;
END;
MACRO MacMatchPairForward
SetPrevPos;MatchPairForward;
END;
MACRO MacMatchPairBackward
SetPrevPos;MatchPairBackward;
END;
MACRO MacGetFindString
SetPrevPos;GetFindString;
END;
MACRO MacRepeatSearch
SetPrevPos;RepeatSearch;
END;
MACRO MacReplace
SetPrevPos;Replace;
END;
/**** key bindings ******/
Esc : NullCmd;
ctrl-A : MacWordLeft;
ctrl-C : MacPageDown;
ctrl-D : CursorSwitchedRight;
ctrl-E : CursorUp;
ctrl-F : MacWordRight;
ctrl-G : DeleteChar;
ctrl-H : BackspaceDelete;
ctrl-I : SmartTab;
ctrl-L : MacRepeatSearch;
ctrl-N : MacBreakLine;
ctrl-P : LiteralChar;
ctrl-R : MacPageUp;
ctrl-S : CursorSwitchedLeft;
ctrl-T : DeleteWord;
ctrl-V : ToggleInsert;
ctrl-W : MacScrollDown;
ctrl-X : CursorDown;
ctrl-Y : MacDeleteLine;
ctrl-Z : MacScrollUp;
/* ---- Function and special keys */
/* the following three keys refer to the ones on the numeric keypad */
star: MacInsertStar;
minus: MacInsertMinus;
plus: MacInsertPlus;
bksp : BackspaceDelete;
shift-bksp : BackspaceDelete;
lfar : CursorSwitchedLeft;
rgar : CursorSwitchedRight;
upar : CursorUp;
dnar : CursorDown;
pgup : MacPageUp;
pgdn : MacPageDown;
end : MacRightOfLine;
home : MacLeftOfLine;
ins : ToggleInsert;
del : DeleteChar;
ctrl-lfar : WordLeft;
ctrl-rgar : WordRight;
ctrl-end : MacBottomOfScreen;
ctrl-home : MacTopOfScreen;
ctrl-pgdn : MacEndCursor;
ctrl-pgup : MacHomeCursor;
shift-tab : BackSpaceDelete;
tab : SmartTab;
ctrl-enter : OpenFileAtCursor;
shift-lfar : MacMarkCursorSwitchedLeft;
shift-rgar : MacMarkCursorSwitchedRight;
shift-upar : MacMarkCursorUp;
shift-dnar : MacMarkCursorDown;
shift-pgup : MacMarkPageUp;
shift-pgdn : MacMarkPageDown;
shift-end : MacMarkRightOfLine;
shift-home : MacMarkLeftOfLine;
/* ---- Control K sequences ------------------ */
ctrl-K+^B : MacSetBlockBeg;
ctrl-K+^C : MacCopyBlock;
ctrl-K+^D : Menu;
ctrl-K+^H : ToggleHideBlock;
ctrl-K+^I : IndentBlock;
ctrl-K+^K : MacSetBlockEnd;
ctrl-K+^L : MacMarkLine;
ctrl-K+^P : PrintBlock;
ctrl-K+^Q : Menu;
ctrl-K+^R : ReadBlock;
ctrl-K+^S : SaveFile;
ctrl-K+^T : MacMarkWord;
ctrl-K+^U : OutdentBlock;
ctrl-K+^V : MacMoveBlock;
ctrl-K+^W : WriteBlock;
ctrl-K+^Y : MacDeleteBlock;
ctrl-K+0 : SetMark(0);
ctrl-K+1 : SetMark(1);
ctrl-K+2 : SetMark(2);
ctrl-K+3 : SetMark(3);
ctrl-K+4 : SetMark(4);
ctrl-K+5 : SetMark(5);
ctrl-K+6 : SetMark(6);
ctrl-K+7 : SetMark(7);
ctrl-K+8 : SetMark(8);
ctrl-K+9 : SetMark(9);
/* ---- Control Q sequences ------------------ */
ctrl-Q+^A : MacReplace;
ctrl-Q+^B : MacMoveToBlockBeg;
ctrl-Q+^C : MacEndCursor;
ctrl-Q+^D : RightOfLine;
ctrl-Q+^E : MacTopOfScreen;
ctrl-Q+^F : MacGetFindString;
ctrl-Q+^K : MacMoveToBlockEnd;
ctrl-Q+^P : MacMoveToPrevPos;
ctrl-Q+^R : MacHomeCursor;
ctrl-Q+^S : LeftOfLine;
ctrl-Q+^W : LastError;
ctrl-Q+^X : MacBottomOfScreen;
ctrl-Q+^Y : DeleteToEol;
ctrl-Q+0 : MacGoto0;
ctrl-Q+1 : MacGoto1;
ctrl-Q+2 : MacGoto2;
ctrl-Q+3 : MacGoto3;
ctrl-Q+4 : MacGoto4;
ctrl-Q+5 : MacGoto5;
ctrl-Q+6 : MacGoto6;
ctrl-Q+7 : MacGoto7;
ctrl-Q+8 : MacGoto8;
ctrl-Q+9 : MacGoto9;
ctrl-Q+[ : MacMatchPairForward;
ctrl-Q+] : MacMatchPairBackward;
/* ---- Control O sequences ------------------ */
ctrl-O+^F : ToggleOptimalFillMode;
ctrl-O+^I : ToggleAutoIndent;
ctrl-O+^O : AddOptions;
ctrl-O+^R : ToggleCursorThroughTabMode;
ctrl-O+^T : ToggleTabbingMode;
ctrl-O+^U : ToggleAutoOutdent;


View File

@ -0,0 +1,107 @@
/***********************************************************************
MS-DOS 5.0 Editor emulation for the Borland/Turbo Pascal IDE.
This file contains a Turbo Editor Macro Language (TEML)
script which emulates the MS-DOS Editor in the Borland/Turbo Pascal IDE.
A complete description of the TEML language and the Turbo Editor Macro
Compiler (TEMC) can be found in the file "TEMC.DOC".
The TEMC compiler can be invoked from the DOS command line as
follows:
temc [-c] dosedit.tem <IDE configuration file><.CMD><.TP>
The optional -c switch can also be specified as /c, and can appear in
any argument position on the command line. If you use this option,
any existing command table in your configuration file is thrown away
before the script file is merged with those already defined. The
configuration file extension must be specified as TEMC will modify both DOS
and Windows IDEs config files. Specify .CMD or .TP extentions for Windows
or DOS IDE, respectively. If the .CMD file does not exist, it will be
created. The .TP file must exist, or an error is displayed.
Most of the simple editor commands have been fully implemented. Most
of the complex commands have been either partially implemented or not
implemented at all. Below is a list of the commands that have been
fully or partially implemented.
IDE Binding MS-DOS Editor Command Comments
----------- --------------------- -------------------------
Backspace BackspaceDelete
Ctrl-H BackspaceDelete
Del DeleteChar
Ctrl-G DeleteChar
Ctrl-T DeleteWord In DOS editor cursor must
be under first letter
Ins ToggleInsert
Ctrl-V ToggleInsert
Ctrl-LfAr WordLeft
Ctrl-RtAr WordRight
Home LeftOfLine
End RightOfLine
Ctrl-Q+E TopOfScreen
Ctrl-Q+X BottomOfScreen
Ctrl-W CursorUp
Ctrl-Z CursorDown
PgUp MacPageUp
PgDw MacPageUp
Ctrl-Home HomeCursor
Ctrl-Q+R HomeCursor
Ctrl-End EndCursor
Ctrl-Q+C EndCursor
**************************************************************************/
/****** Macros *************************/
MACRO MoveToNextLine
CursorDown;
LeftOfLine;
END;
MACRO MacPageUp
FixScreenPos;PageScreenUp;FixCursorPos;
END;
MACRO MacPageDown
FixScreenPos;PageScreenDown;FixCursorPos;
END;
/****** DOS EDIT Key Bindings **********/
BkSp: BackspaceDelete;
Ctrl-H: BackspaceDelete;
Del: DeleteChar;
Ctrl-G: DeleteChar;
Ctrl-T: DeleteWord;
Ins: ToggleInsert;
Ctrl-V: ToggleInsert;
Ctrl-LfAr: WordLeft;
Ctrl-RgAr: WordRight;
Home: LeftOfLine;
End: RightOfLine;
Ctrl-Q+^E: TopOfScreen;
Ctrl-Q+^X: BottomOfScreen;
Ctrl-W: CursorUp;
Ctrl-Z: CursorDown;
PgUp: MacPageUp;
PgDn: MacPageDown;
Ctrl-Home: HomeCursor;
Ctrl-Q+R: HomeCursor;
Ctrl-End: EndCursor;
Ctrl-Q+C: EndCursor;


View File

@ -0,0 +1,27 @@
type
regpack = record
ax,bx,cx,dx,bp,si,di,ds,es,flags: integer;
end;
procedure get_time( var tt : timetype );
var
recpack: registers;
ahigh: byte;
begin
ahigh := $2c;
with recpack do
begin
ax := ahigh shl 8;
end;
intr( $21, recpack );
with recpack do
begin
tt.h := cx shr 8;
tt.m := cx mod 256;
tt.s := dx shr 8;
tt.l := dx mod 256;
end;
end;

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,42 @@
program e;
const
DIGITS = 200;
type
arrayType = array[ 0..DIGITS ] of integer;
var
high, n, x : integer;
a : arrayType;
begin
high := DIGITS;
x := 0;
n := high - 1;
while n > 0 do begin
a[ n ] := 1;
n := n - 1;
end;
a[ 1 ] := 2;
a[ 0 ] := 0;
while high > 9 do begin
high := high - 1;
n := high;
while 0 <> n do begin
a[ n ] := x MOD n;
x := 10 * a[ n - 1 ] + x DIV n;
n := n - 1;
end;
Write( x );
end;
writeln;
writeln( 'done' );
end.


View File

@ -0,0 +1,410 @@
Script EPSILON;
/***********************************************************************
Epsilon editor emulation for Borland/Turbo Pascal IDE.
This file contains a Turbo Editor Macro Language (TEML)
script which emulates the Epsilon programmer's editor in the Borland/Turbo
Pascal IDE. A complete description of the TEML language and the Turbo
Editor Macro Compiler (TEMC) can be found in the file "TEMC.DOC".
The TEMC compiler can be invoked from the DOS command line at
follows:
temc [-c] epsilon.tem <IDE configuration file><.CMD><.TP>
The optional -c switch can also be specified as /c, and can appear in
any argument position on the command line. If you use this option,
any existing command table in your configuration file is thrown away
before the script file is merged with those already defined. The
configuration file extension must be specified as TEMC will modify both DOS
and Windows IDEs config files. Specify .CMD or .TP extentions for Windows
or DOS IDE, respectively. If the .CMD file does not exist, it will be
created. The .TP file must exist, or an error is displayed.
Most of the simple Epsilon commands have been fully implemented. Most
of the complex command have been either partially implemented or not
implemented at all. The TEML macros names correspond to the names in
the Espilon default macro set. Below is a list of the commands that
have been fully or partially implemented.
IDE Binding Epsilon Command Comments
----------- --------------- -------------------------
Ctrl-B backward_character
Ctrl-H backward_delete_character
Alt-B backward_word
Ctrl-A beginning_of_line
Home beginning_of_window
Ctrl-L center_window
Ctrl-D delete_character
Ctrl-N down_line
Tab do_c_indent
Ctrl-E end_of_line
End end_of_window
Ctrl-X+Ctrl-X exchange_point_and_mark
Ctrl-X+Ctrl-C Quit;
Ctrl-X+Ctrl-Z exit_level Leaves editor - Enables Menus
Ctrl-X+Ctrl-F find_file
Ctrl-F forward_character
Ctrl-Home goto_beginning
Ctrl-End goto_end
Ctrl-X+@i insert_file
Ctrl-K kill_line Uses Block-copy - Allowing yanking
Ctrl-W kill_region
Ctrl-X+0 kill_window
Ctrl-X+Ctrl-N next_error
Ctrl-V next_page
Ctrl-O open_line
Alt-V previous_page
Ctrl-Q quoted_insert
Ctrl-X+@r redo
Ctrl-S+Ctrl-S RepeatSearch
Ctrl-X+@u undo
Ctrl-X+Ctrl-S save_file
Alt-Z scroll_down
Ctrl-Z scroll_up
Ctrl-X+Ctrl-M set_mark
Ctrl-S string_search
Ctrl-P up_line
Ctrl-X+@w write_region
Ctrl-Y yank
Alt-Y yank_pop Displays the Clipboard
********************************************************************/
/*******************************************************************
TEML SCRIPTS TO EMULATE EPSILON FROM THE BORLAND PASCAL IDE
*******************************************************************/
macro backward_character
CursorSwitchedLeft;
end;
macro backward_delete_character
BackSpaceDelete;
end;
macro backward_word
WordLeft;
end;
macro beginning_of_line
LeftOfLine;
end;
macro beginning_of_window
TopOfScreen;
end;
macro center_window
SetTempPos;
ScrollScreenUp;
CenterFixScreenPos;
ScrollScreenDown;
CenterFixScreenPos;
PageScreenUp;
CenterFixScreenPos;
PageScreenDown;
CenterFixScreenPos;
MoveToTempPos;
end;
macro delete_character
DeleteChar;
end;
macro do_c_indent
LiteralChar( 9 );
end;
macro down_line
CursorDown;
end;
macro end_of_line
RightOfLine;
end;
macro end_of_window
BottomOfScreen;
end;
macro exchange_point_and_mark
SwapPrevPos;
CenterFixScreenPos;
end;
macro exit_level
Quit;
end;
macro find_delimiter
MatchPairForward;
end;
macro find_file
OpenFile;
end;
macro forward_character
CursorSwitchedRight;
end;
macro forward_level
MatchPairForward;
end;
macro goto_beginning
HomeCursor;
end;
macro goto_end
EndCursor;
end;
macro insert_file
SetPrevPos;
HideBlock;
ReadBlock;
end;
/* The kill_line Macro does not use the built-in DeleteToEOL TEML macro */
/* but rather makes a highlighted block out the line, cuts the block into */
/* the clipboard, thereby allowing 'yank'ing of deleted lines. This method*/
/* however, requires that delete_character be used when empty lines ( lines*/
/* containing only a LineFeed character ) are to be deleted... */
macro kill_line
SetTempPos;
SetBlockBeg;
end_of_line;
SetBlockEnd;
MoveToTempPos;
HighlightBlock;
ClipCut;
end;
macro kill_region
SwapPrevPos;
SetBlockBeg;
SwapPrevPos;
SetBlockEnd;
HighlightBlock;
ClipCut;
end;
macro kill_window
CloseWindow;
end;
macro next_error
NextError;
end;
macro next_page
PageDown;
end;
macro next_window
NextWindow;
end;
macro open_line
LiteralChar( 13 );
CursorSwitchedLeft;
end;
macro previous_page
PageUp;
end;
macro query_replace
Replace;
end;
macro quoted_insert
LiteralChar;
end;
macro save_file
SaveFile;
end;
macro scroll_down
ScrollScreenDown;
FixCursorPos;
end;
macro scroll_up
ScrollScreenUp;
FixCursorPos;
end;
macro set_mark
HideBlock;
SetPrevPos;
end;
macro string_search
SearchMenu;
end;
macro up_line
CursorUp;
end;
macro write_region
HideBlock;
SwapPrevPos;
SetBlockBeg;
SwapPrevPos;
SetBlockEnd;
HighlightBlock;
WriteBlock;
end;
macro yank
HideBlock;
ClipPaste;
end;
macro yank_pop
ClipShow;
end;
Ctrl-B :backward_character;
Ctrl-H :backward_delete_character;
Alt-B :backward_word;
Ctrl-A :beginning_of_line;
Home :beginning_of_window;
Ctrl-L :center_window;
Ctrl-D :delete_character;
Ctrl-N :down_line;
Tab :do_c_indent;
Ctrl-E :end_of_line;
End :end_of_window;
Ctrl-X+Ctrl-X :exchange_point_and_mark;
Ctrl-X+Ctrl-C :Quit;
Ctrl-X+Ctrl-Z :exit_level;
Ctrl-X+Ctrl-F :find_file;
Ctrl-F :forward_character;
Ctrl-Home :goto_beginning;
Ctrl-End :goto_end;
Ctrl-X+@i :insert_file;
Ctrl-K :kill_line;
Ctrl-W :kill_region;
Ctrl-X+0 :kill_window;
Ctrl-X+@m :make;
/* The following is a non-Epsilon MACRO which can be usefully combined with */
/* the insert_file macro to compensate for the fact that TEML's ReadBlock */
/* internal MACRO leaves point at the beginning of the block just read. */
/* Epsilon leaves point at the end of the block inserted. This MACRO allows*/
/* one to quickly move to the end of the block inserted... */
Ctrl-X+Ctrl-K :Begin
MoveToBlockEnd;
center_window;
HideBlock;
End;
Ctrl-X+Ctrl-N :next_error;
Ctrl-V :next_page;
Ctrl-O :open_line;
Alt-V :previous_page;
Ctrl-Q :quoted_insert;
Ctrl-X+@r :redo;
Ctrl-S+Ctrl-S :RepeatSearch;
Ctrl-X+@u :undo;
Ctrl-X+Ctrl-S :save_file;
Alt-Z :scroll_down;
Ctrl-Z :scroll_up;
Ctrl-X+Ctrl-M :set_mark;
Ctrl-S :string_search;
Ctrl-P :up_line;
Ctrl-X+@w :write_region;
Ctrl-Y :yank;
Alt-Y :yank_pop;


Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,67 @@
program Grep2Msg;
{$I-,S-}
var
LineNo, E: Word;
Line: String;
InputBuffer: array[0..4095] of Char;
OutputBuffer: array[0..4095] of Char;
procedure WriteHeader;
begin
Write('BI#PIP#OK'#0);
end;
procedure WriteNewFile(const FileName: String);
begin
Write(#0, FileName, #0);
end;
procedure WriteMessage(Line, Col: Word; const Message: String);
begin
Write(#1, Chr(Lo(Line)), Chr(Hi(Line)), Chr(Lo(Col)), Chr(Hi(Col)),
Message, #0);
end;
procedure WriteEnd;
begin
Write(#127);
end;
function TrimLeft(S:String): String;
var
i: Integer;
n: String;
begin
i := 1;
while (i <= Length(s)) and (s[i] = #32) do Inc(i);
if i <= Length(s) then
begin
Move(s[i], n[1], Length(s) - i + 1);
n[0] := Char(Length(s) - i + 1);
end
else n[0] := #0;
TrimLeft := n;
end;
begin
SetTextBuf(Input, InputBuffer);
SetTextBuf(Output, OutputBuffer);
WriteHeader;
while not Eof do
begin
ReadLn(Line);
if Line <> '' then
begin
if Copy(Line, 1, 5) = 'File ' then
WriteNewFile(Copy(Line, 6, Length(Line) - 6))
else
begin
Val(Copy(Line, 1, Pos(' ', Line) - 1), LineNo, E);
if E = 0 then WriteMessage(LineNo, 1, TrimLeft(Copy(Line, 9, 132)));
end;
end;
end;
WriteEnd;
end.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,497 @@
{************************************************}
{ }
{ Printer output filter exammple }
{ Copyright (c) 1992 by Borland International }
{ }
{************************************************}
program PrinterOutputFilter;
{ Printer filters read input from the IDE by way of StdIn (by using Read
or ReadLn). It then converts the syntax highlight codes inserted into
the text into appropriate printer command codes. This converted text is
then output Lst (which defaults to LPT1).
The syntax highlight codes are in the form of <ESC>#, where '#' is an
ASCII digit from 1($31) to 8($38). The last code sent remains in effect
until another code is found. The following is a list of the codes and
what type of text they represent:
1 - Whitespace (space, tab)
2 - Comment
3 - Reserved word (begin, end, procedure, etc...)
4 - Identifier (Writeln, Reset, etc...)
5 - Symbol (;, :, ., etc...)
6 - String ('string', #32, #$30)
7 - Number (24, $56)
8 - Assembler (asm mov ax,5 end;)
The following printers are supported:
EPSON and compatibles
HP LaserJet II, III, IIP, IID, IIID, IIISi and compatibles
(Italics are available on IIIx, IIP)
ADOBE(R) PostScript(R)
ASCII (simply strips the highlight codes before sending to Lst)
Command line options:
/EPSON - Output EPSON printer codes
/HP - Output HP LaserJet codes
/PS - Output PostScript
/ASCII - Strip highlight codes (Default)
/Lxx - Lines per page (Default 55)
/Txx - Tabsize (Default 8)
/O[file] - Output to file or device (Default LPT1)
}
{$M 2048, 0, 0}
{$I-,S-,X+}
const
MaxAttributes = 8;
type
TPCharArray = array[0..16380] of PChar;
PPCharArray = ^TPCharArray;
PPrinterCodes = ^TPrinterCodes;
TPrinterCodes = record
{ Number of preamble strings in the Preamble array. }
PreambleCount: Byte;
{ Pointer to an array of PChars that define the preamble sequence for
this printer. Sent at the start of a print job. }
Preamble: PPCharArray;
{ Pointer to an array of PChars that define the code sequences for
changing the current attribute. }
CodeArray: PPCharArray;
{ Array of indexes into the CodeArray corresponing to attributes
supported for this printer. }
Attributes: array[0..MaxAttributes - 1] of Byte;
{ Codes sent at the start of a page. }
StartPage: PChar;
{ Codes sent at the end of a page. }
EndPage: PChar;
{ Codes sent at the end of a line. }
EndLine: PChar;
{ Codes sent at the end of the print job. }
Postamble: PChar;
end;
const
{ EPSON Printer code definition }
EpsonItalic = #27'4';
EpsonNoItalic = #27'5';
EpsonBold = #27'E';
EpsonNoBold = #27'F';
EpsonULine = #27'-'#1;
EpsonNoULine = #27'-'#0;
EpsonCodeArray: array[0..7] of PChar = (
EpsonBold,
EpsonNoBold,
EpsonItalic,
EpsonNoItalic,
EpsonULine,
EpsonNoULine,
EpsonBold + EpsonItalic,
EpsonNoBold + EpsonNoItalic);
EpsonCodes: TPrinterCodes = (
PreambleCount: 0;
Preamble: nil;
CodeArray: @EpsonCodeArray;
Attributes: (
0, { Whitespace }
2, { Comment }
1, { Reserved word }
0, { Identifier }
0, { Symbol }
4, { String }
0, { Number }
1); { Assembler }
StartPage: '';
EndPage: #12;
EndLine: #13#10;
Postamble: ''
);
{ HP LaserJet code definition }
HPInit = #27'E'#27'(10U'#27'&k0S'#27'(s3T';
HPItalic = #27'(s1S';
HPNoItalic = #27'(s0S';
HPBold = #27'(s3B';
HPNoBold = #27'(s0B';
HPULine = #27'&dD';
HPNoULine = #27'&d@';
HPCodeArray: array[0..7] of PChar = (
HPBold,
HPNoBold,
HPItalic,
HPNoItalic,
HPULine,
HPNoULine,
HPBold + HPItalic,
HPNoBold + HPNoItalic);
LaserJetPreamble: PChar = HPInit;
LaserJetCodes: TPrinterCodes = (
PreambleCount: 1;
Preamble: @LaserJetPreamble;
CodeArray: @HPCodeArray;
Attributes: (
0, { Whitespace }
2, { Comment }
1, { Reserved word }
0, { Identifier }
0, { Symbol }
4, { String }
0, { Number }
1); { Assembler }
StartPage: '';
EndPage: #12;
EndLine: #13#10;
Postamble: #12
);
{ Raw ASCII definition }
AsciiCodes: TPrinterCodes = (
PreambleCount: 0;
Preamble: nil;
CodeArray: nil;
Attributes: (
0, { Whitespace }
0, { Comment }
0, { Reserved word }
0, { Identifier }
0, { Symbol }
0, { String }
0, { Number }
0); { Assembler }
StartPage: '';
EndPage: #12;
EndLine: #13#10;
Postamble: ''
);
{ PostScript code definition }
PSPreamble0 = #4'%!PS-Adobe-3.0'#13#10+
'initgraphics'#13#10;
PSPreamble1 = '/fnr /Courier findfont 10 scalefont def'#13#10;
PSPreamble2 = '/fni /Courier-Oblique findfont 10 scalefont def'#13#10;
PSPreamble3 = '/fnb /Courier-Bold findfont 10 scalefont def'#13#10;
PSPreamble4 = '/fnbi /Courier-BoldOblique findfont 10 scalefont def'#13#10;
PSPreamble5 = '/newl {20 currentpoint exch pop 12 sub moveto} def'#13#10+
'/newp {20 765 moveto} def'#13#10+
'fnr setfont'#13#10;
PSNormal = 'fnr setfont'#13#10;
PSItalic = 'fni setfont'#13#10;
PSBold = 'fnb setfont'#13#10;
PSBoldItalic = 'fnbi setfont'#13#10;
PSCodeArray: array[0..5] of PChar = (
PSBold,
PSNormal,
PSItalic,
PSNormal,
PSBoldItalic,
PSNormal);
PSPreamble: array[0..5] of PChar = (
PSPreamble0,
PSPreamble1,
PSPreamble2,
PSPreamble3,
PSPreamble4,
PSPreamble5);
PSCodes: TPrinterCodes = (
PreambleCount: High(PSPreamble) - Low(PSPreamble) + 1;
Preamble: @PSPreamble;
CodeArray: @PSCodeArray;
Attributes: (
0, { Whitespace }
2, { Comment }
1, { Reserved word }
0, { Identifier }
0, { Symbol }
3, { String }
0, { Number }
1); { Assembler }
StartPage: 'newp'#13#10;
EndPage: 'showpage'#13#10;
EndLine: 'newl'#13#10;
Postamble: #4
);
{ Special case printer modes. This facilitates indicating a special case
printer such as PostScript }
pmNormal = $0001;
pmPostScript = $0002;
PrintMode: Word = pmNormal;
LinesPerPage: Word = 55;
ToFile: Boolean = False;
TabSize: Word = 8;
var
C, LineCount, TabCount: Integer;
Line, OutputLine: String;
InputBuffer: array[0..4095] of Char;
PrinterCodes: PPrinterCodes;
CurCode, NewCode: Byte;
AKey: Word;
Lst: Text;
procedure UpStr(var S: String);
var
I: Integer;
begin
for I := 1 to Length(S) do S[I] := UpCase(S[I]);
end;
{ Checks whether or not the Text file is a device. If so, it is forced to
"raw" mode }
procedure SetDeviceRaw(var T: Text); assembler;
asm
LES DI,T
MOV BX,WORD PTR ES:[DI]
MOV AX,4400H
INT 21H
TEST DX,0080H
JZ @@1
OR DL,20H
MOV DH,DH
MOV AX,4401H
INT 21H
@@1:
end;
{ Process the command line. If any new printers are to be supported, simply
add a command line switch here. }
procedure ProcessCommandLine;
var
Param: String;
I: Integer;
function ParamVal(var P: String; Default: Word): Word;
var
N, E: Integer;
begin
Delete(P, 1, 1);
Val(P, N, E);
if E = 0 then
ParamVal := N
else
ParamVal := Default;
end;
begin
PrinterCodes := @AsciiCodes;
for I := 1 to ParamCount do
begin
Param := ParamStr(I);
if (Length(Param) >= 2) and ((Param[1] = '/') or (Param[1] = '-')) then
begin
Delete(Param, 1, 1);
UpStr(Param);
if Param = 'EPSON' then
PrinterCodes := @EpsonCodes
else if Param = 'HP' then
PrinterCodes := @LaserJetCodes
else if Param = 'ASCII' then
PrinterCodes := @AsciiCodes
else if Param = 'PS' then
begin
PrinterCodes := @PSCodes;
PrintMode := pmPostScript;
end
else if Param[1] = 'L' then
LinesPerPage := ParamVal(Param, LinesPerPage)
else if Param[1] = 'T' then
TabSize := ParamVal(Param, TabSize)
else if Param[1] = 'O' then
begin
Delete(Param, 1, 1);
Assign(Lst, Param);
Rewrite(Lst);
ToFile := True;
SetDeviceRaw(Lst);
end;
end;
end;
if not ToFile then
begin
Assign(Lst, 'LPT1');
Rewrite(Lst);
SetDeviceRaw(Lst);
end;
end;
{ Flush the currently assembled string to the output }
procedure PurgeOutputBuf;
begin
if OutputLine = '' then Exit;
case PrintMode of
pmNormal: Write(Lst, OutputLine);
pmPostScript:
begin
Write(Lst, '(');
Write(Lst, OutputLine);
Write(Lst, ') show'#13#10);
end;
end;
OutputLine := '';
if IOResult <> 0 then Halt(1);
end;
{ Add the chracter to the output string. Process special case characters
and tabs, purging the output buffer when nessesary }
procedure AddToOutputBuf(AChar: Char);
var
I: Integer;
begin
case AChar of
'(',')','\':
begin
case PrintMode of
pmPostScript:
begin
if Length(OutputLine) > 253 then
PurgeOutputBuf;
Inc(OutputLine[0]);
OutputLine[Length(OutputLine)] := '\';
end;
end;
end;
#9:
begin
if Length(OutputLine) > (255 - TabSize) then
PurgeOutputBuf;
for I := 1 to TabSize - (TabCount mod TabSize) do
begin
Inc(OutputLine[0]);
OutputLine[Length(OutputLine)] := ' ';
end;
Inc(TabCount, TabSize - (TabCount mod TabSize));
Exit;
end;
end;
if Length(OutputLine) > 254 then
PurgeOutputBuf;
Inc(OutputLine[0]);
OutputLine[Length(OutputLine)] := AChar;
Inc(TabCount);
end;
{ End the current page and start a new one }
procedure NewPage(const PCodes: TPrinterCodes);
begin
PurgeOutputBuf;
Write(Lst, PCodes.EndPage);
Write(Lst, PCodes.StartPage);
LineCount := 0;
TabCount := 0;
end;
{ End the current line }
procedure NewLine(const PCodes: TPrinterCodes);
begin
PurgeOutputBuf;
Write(Lst, PCodes.EndLine);
Inc(LineCount);
TabCount := 0;
if LineCount > LinesPerPage then
NewPage(PCodes);
end;
{ Check for the presence of a keypressed and return it if available }
function GetKey(var Key: Word): Boolean; assembler;
asm
MOV AH,1
INT 16H
MOV AL,0
JE @@1
XOR AH,AH
INT 16H
LES DI,Key
MOV WORD PTR ES:[DI],AX
MOV AL,1
@@1:
end;
begin
SetTextBuf(Input, InputBuffer);
ProcessCommandLine;
LineCount := 0;
with PrinterCodes^ do
begin
if PreambleCount > 0 then
for C := 0 to PreambleCount - 1 do
Write(Lst, Preamble^[C]);
if IOResult <> 0 then Halt(1);
LineCount := 0;
CurCode := $FF;
TabCount := 0;
Write(Lst, StartPage);
Line := '';
while True do
begin
if (Line = '') and Eof then
begin
PurgeOutputBuf;
Break;
end;
ReadLn(Line);
if GetKey(AKey) and (AKey = $011B) then
Halt(1);
C := 1;
while C <= length(Line) do
begin
case Line[C] of
#27:
if (Line[C + 1] >= '1') and (Line[C + 1] <= '8') then
begin
NewCode := Attributes[Byte(Line[C + 1]) - $31];
if NewCode <> CurCode then
begin
PurgeOutputBuf;
if (CurCode > 0) and (CurCode < MaxAttributes) then
Write(Lst, CodeArray^[(CurCode - 1) * 2 + 1]);
if (NewCode > 0) and (NewCOde < MaxAttributes) then
Write(Lst, CodeArray^[(NewCode - 1) * 2]);
CurCode := NewCode;
end;
Inc(C);
end;
#12: NewPage(PrinterCodes^);
else
AddToOutputBuf(Line[C]);
end;
Inc(C);
end;
NewLine(PrinterCodes^);
end;
if LineCount > 0 then
Write(Lst, EndPage);
Write(Lst, Postamble);
end;
Close(Lst);
end.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,31 @@
program sieve;
const
size = 8190;
type
flagType = array[ 0..size ] of boolean;
var
i, k, prime, count, iter : integer;
flags : flagType;
begin
for iter := 1 to 10 do begin
count := 0;
for i := 0 to size do flags[ i ] := true;
for i := 0 to size do begin
if flags[ i ] then begin
prime := i + i + 3;
k := i + prime;
while k <= size do begin
flags[ k ] := false;
k := k + prime;
end;
count := count + 1;
end;
end;
end;
writeln( 'count of primes: ', count );
end.

Binary file not shown.

View File

@ -0,0 +1,2 @@
/fD:\TP\BIN\TURBO.TPH
/fD:\TP\BIN\TVISION.TPH

Binary file not shown.

View File

@ -0,0 +1,66 @@
type
timetype = record h, m, s, l : integer; end;
procedure time_difference( var tStart, tEnd, tDiff : timetype );
var
startSecond, startMinute, startHour : integer;
begin { time_difference }
startSecond := tStart.s;
startMinute := tStart.m;
startHour := tStart.h;
tDiff.l := tEnd.l - tStart.l;
if ( tDiff.l < 0 ) then
begin
tDiff.l := tDiff.l + 100;
startSecond := startSecond + 1;
end;
tDiff.s := tEnd.s - startSecond;
if ( tDiff.s < 0 ) then
begin
tDiff.s := tDiff.s + 60;
startMinute := startMinute + 1;
end;
tDiff.m := tEnd.m - startMinute;
if ( tDiff.m < 0 ) then
begin
tDiff.m := tDiff.m + 60;
startHour := startHour + 1;
end;
tDiff.h := tEnd.h - startHour;
if ( tDiff.h < 0 ) then
tDiff.h := tDiff.h + 12;
end;
procedure print_time_part( num : integer );
begin
if ( num < 10 ) then write( '0' );
write( num );
end;
procedure print_time( var t: timetype );
begin
print_time_part( t.h );
write( ':' );
print_time_part( t.m );
write( ':' );
print_time_part( t.s );
write( '.' );
print_time_part( t.l );
end;
procedure print_elapsed_time( var timeStart, timeEnd: timetype );
var
timeDiff: timetype;
begin
time_difference( timeStart, timeEnd, timeDiff );
write( 'elapsed time: ' );
print_time( timeDiff );
writeln;
end;


View File

@ -0,0 +1 @@
/UD:\TP\UNITS

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,389 @@
{ App to prove you can't win at Tic-Tac-Toe }
{ use of byte instead of integer should be faster, but it's not }
program ttt;
uses Dos;
{$I timeutil.pas}
{$I dos_gt.pas}
type TScoreFunc = function : integer;
const
scoreWin = 6;
scoreTie = 5;
scoreLose = 4;
scoreMax = 9;
scoreMin = 2;
scoreInvalid = 0;
pieceBlank = 0;
pieceX = 1;
pieceO = 2;
iterations = 1;
type
boardType = array[ 0..8 ] of integer;
funcArrayType = array[ 0..8 ] of pointer;
var
{ update evaluated after each run because longint operations are slow }
evaluated: longint;
moves: integer;
board: boardType;
timeStart, timeEnd: timetype;
scoreFuncs : funcArrayType;
procedure dumpBoard;
var
i : integer;
begin
Write( '{' );
for i := 0 to 8 do
Write( board[i] );
Write( '}' );
end;
function func0 : integer;
var x : integer;
begin
x := board[0];
if ( ( ( x = board[1] ) and ( x = board[2] ) ) or
( ( x = board[3] ) and ( x = board[6] ) ) or
( ( x = board[4] ) and ( x = board[8] ) ) ) then
func0 := x
else
func0 := pieceBlank;
end;
function func1 : integer;
var x : integer;
begin
x := board[1];
if ( ( ( x = board[0] ) and ( x = board[2] ) ) or
( ( x = board[4] ) and ( x = board[7] ) ) ) then
func1 := x
else
func1 := pieceBlank;
end;
function func2 : integer;
var x : integer;
begin
x := board[2];
if ( ( ( x = board[0] ) and ( x = board[1] ) ) or
( ( x = board[5] ) and ( x = board[8] ) ) or
( ( x = board[4] ) and ( x = board[6] ) ) ) then
func2 := x
else
func2 := pieceBlank;
end;
function func3 : integer;
var x : integer;
begin
x := board[3];
if ( ( ( x = board[4] ) and ( x = board[5] ) ) or
( ( x = board[0] ) and ( x = board[6] ) ) ) then
func3 := x
else
func3 := pieceBlank;
end;
function func4 : integer;
var x : integer;
begin
x := board[4];
if ( ( ( x = board[0] ) and ( x = board[8] ) ) or
( ( x = board[2] ) and ( x = board[6] ) ) or
( ( x = board[1] ) and ( x = board[7] ) ) or
( ( x = board[3] ) and ( x = board[5] ) ) ) then
func4 := x
else
func4 := pieceBlank;
end;
function func5 : integer;
var x : integer;
begin
x := board[5];
if ( ( ( x = board[3] ) and ( x = board[4] ) ) or
( ( x = board[2] ) and ( x = board[8] ) ) ) then
func5 := x
else
func5 := pieceBlank;
end;
function func6 : integer;
var x : integer;
begin
x := board[6];
if ( ( ( x = board[7] ) and ( x = board[8] ) ) or
( ( x = board[0] ) and ( x = board[3] ) ) or
( ( x = board[4] ) and ( x = board[2] ) ) ) then
func6 := x
else
func6 := pieceBlank;
end;
function func7 : integer;
var x : integer;
begin
x := board[7];
if ( ( ( x = board[6] ) and ( x = board[8] ) ) or
( ( x = board[1] ) and ( x = board[4] ) ) ) then
func7 := x
else
func7 := pieceBlank;
end;
function func8 : integer;
var x : integer;
begin
x := board[8];
if ( ( ( x = board[6] ) and ( x = board[7] ) ) or
( ( x = board[2] ) and ( x = board[5] ) ) or
( ( x = board[0] ) and ( x = board[4] ) ) ) then
func8 := x
else
func8 := pieceBlank;
end;
function lookForWinner : integer;
var
t, p : integer;
begin
{dumpBoard;}
p := pieceBlank;
t := board[ 0 ];
if pieceBlank <> t then
begin
if ( ( ( t = board[1] ) and ( t = board[2] ) ) or
( ( t = board[3] ) and ( t = board[6] ) ) ) then
p := t;
end;
if pieceBlank = p then
begin
t := board[1];
if ( t = board[4] ) and ( t = board[7] ) then
p := t
else
begin
t := board[2];
if ( t = board[5] ) and ( t = board[8] ) then
p := t
else
begin
t := board[3];
if ( t = board[4] ) and ( t = board[5] ) then
p := t
else
begin
t := board[6];
if ( t = board[7] ) and ( t = board[8] ) then
p := t
else
begin
t := board[4];
if ( ( ( t = board[0] ) and ( t = board[8] ) ) or
( ( t = board[2] ) and ( t = board[6] ) ) ) then
p := t
end;
end;
end;
end;
end;
lookForWinner := p;
end;
function winner2( move: integer ) : integer;
var
x : integer;
begin
case move of
0: begin
x := board[ 0 ];
if not ( ( ( x = board[1] ) and ( x = board[2] ) ) or
( ( x = board[3] ) and ( x = board[6] ) ) or
( ( x = board[4] ) and ( x = board[8] ) ) )
then x := PieceBlank;
end;
1: begin
x := board[ 1 ];
if not ( ( ( x = board[0] ) and ( x = board[2] ) ) or
( ( x = board[4] ) and ( x = board[7] ) ) )
then x := PieceBlank;
end;
2: begin
x := board[ 2 ];
if not ( ( ( x = board[0] ) and ( x = board[1] ) ) or
( ( x = board[5] ) and ( x = board[8] ) ) or
( ( x = board[4] ) and ( x = board[6] ) ) )
then x := PieceBlank;
end;
3: begin
x := board[ 3 ];
if not ( ( ( x = board[4] ) and ( x = board[5] ) ) or
( ( x = board[0] ) and ( x = board[6] ) ) )
then x := PieceBlank;
end;
4: begin
x := board[ 4 ];
if not ( ( ( x = board[0] ) and ( x = board[8] ) ) or
( ( x = board[2] ) and ( x = board[6] ) ) or
( ( x = board[1] ) and ( x = board[7] ) ) or
( ( x = board[3] ) and ( x = board[5] ) ) )
then x := PieceBlank;
end;
5: begin
x := board[ 5 ];
if not ( ( ( x = board[3] ) and ( x = board[4] ) ) or
( ( x = board[2] ) and ( x = board[8] ) ) )
then x := PieceBlank;
end;
6: begin
x := board[ 6 ];
if not ( ( ( x = board[7] ) and ( x = board[8] ) ) or
( ( x = board[0] ) and ( x = board[3] ) ) or
( ( x = board[4] ) and ( x = board[2] ) ) )
then x := PieceBlank;
end;
7: begin
x := board[ 7 ];
if not ( ( ( x = board[6] ) and ( x = board[8] ) ) or
( ( x = board[1] ) and ( x = board[4] ) ) )
then x := PieceBlank;
end;
8: begin
x := board[ 8 ];
if not ( ( ( x = board[6] ) and ( x = board[7] ) ) or
( ( x = board[2] ) and ( x = board[5] ) ) or
( ( x = board[0] ) and ( x = board[4] ) ) )
then x := PieceBlank;
end;
end;
winner2 := x;
end;
function minmax( alpha: integer; beta: integer; depth: integer; move : integer ): integer;
var
p, value, pieceMove, score : integer;
begin
moves := moves + 1;
value := scoreInvalid;
if depth >= 4 then
begin
{ p := winner2( move ); }
p := TScoreFunc( scoreFuncs[ move ] );
{ p := LookForWinner; this is 10% slower than using function pointers }
if p <> pieceBlank then
begin
if p = pieceX then
value := scoreWin
else
value := scoreLose
end
else if depth = 8 then
value := scoreTie;
end;
if value = scoreInvalid then
begin
if Odd( depth ) then
begin
value := scoreMin;
pieceMove := pieceX;
end
else
begin
value := scoreMax;
pieceMove := pieceO;
end;
p := 0;
repeat
if board[ p ] = pieceBlank then
begin
board[ p ] := pieceMove;
score := minmax( alpha, beta, depth + 1, p );
board[ p ] := pieceBlank;
if Odd( depth ) then
begin
if ( score > value ) then
begin
value := score;
if ( value = scoreWin ) or ( value >= beta ) then p := 10
else if ( value > alpha ) then alpha := value;
end;
end
else
begin
if ( score < value ) then
begin
value := score;
if ( value = scoreLose ) or ( value <= alpha ) then p := 10
else if ( value < beta ) then beta := value;
end;
end;
end;
p := p + 1;
until p > 8;
end;
minmax := value;
end;
procedure runit( move : integer );
var score : integer;
begin
board[move] := pieceX;
score := minmax( scoreMin, scoreMax, 0, move );
board[move] := pieceBlank;
end;
var
i, errpos, loops: integer;
begin
loops := Iterations;
if 0 <> Length( ParamStr( 1 ) ) then
Val( ParamStr( 1 ), loops, errpos );
for i := 0 to 8 do
board[i] := pieceBlank;
scoreFuncs[0] := @func0;
scoreFuncs[1] := @func1;
scoreFuncs[2] := @func2;
scoreFuncs[3] := @func3;
scoreFuncs[4] := @func4;
scoreFuncs[5] := @func5;
scoreFuncs[6] := @func6;
scoreFuncs[7] := @func7;
scoreFuncs[8] := @func8;
evaluated := 0;
get_time( timeStart );
for i := 1 to loops do
begin
moves := 0;
runit( 0 );
runit( 1 );
runit( 4 );
evaluated := evaluated + moves;
end;
get_time( timeEnd );
print_elapsed_time( timeStart, timeEnd );
WriteLn( 'moves evaluated: ', evaluated );
WriteLn( 'iterations: ', loops );
end.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
ntvdm -r:.. -c tpc %1.pas /$S- /GD

View File

@ -0,0 +1,3 @@
../../ntvdm -u -t TPC.EXE $1.PAS -\$S- -GD

View File

@ -0,0 +1,135 @@
dosmon log is at 1a20009
byte count: 744
seek base 0 = beginning, offset 0
seek base 0 = beginning, offset 90224
seek base 0 = beginning, offset 325268
seek base 0 = beginning, offset 90232
seek base 0 = beginning, offset 93836
seek base 0 = beginning, offset 97821
seek base 0 = beginning, offset 106156
seek base 0 = beginning, offset 110007
seek base 0 = beginning, offset 114272
seek base 0 = beginning, offset 128449
seek base 0 = beginning, offset 137842
seek base 0 = beginning, offset 190451
seek base 0 = beginning, offset 191179
seek base 0 = beginning, offset 200424
seek base 0 = beginning, offset 211368
seek base 0 = beginning, offset 212999
seek base 0 = beginning, offset 213417
seek base 0 = beginning, offset 222140
seek base 0 = beginning, offset 222983
seek base 0 = beginning, offset 224812
seek base 0 = beginning, offset 237405
seek base 0 = beginning, offset 243635
seek base 0 = beginning, offset 244014
seek base 0 = beginning, offset 244619
seek base 0 = beginning, offset 246840
seek base 0 = beginning, offset 248135
seek base 0 = beginning, offset 249134
seek base 0 = beginning, offset 250085
seek base 0 = beginning, offset 251425
seek base 0 = beginning, offset 262945
seek base 0 = beginning, offset 269199
seek base 0 = beginning, offset 273021
seek base 0 = beginning, offset 277275
seek base 0 = beginning, offset 283144
seek base 0 = beginning, offset 284119
seek base 0 = beginning, offset 284700
seek base 0 = beginning, offset 290889
seek base 0 = beginning, offset 290973
seek base 0 = beginning, offset 291835
seek base 0 = beginning, offset 292535
seek base 0 = beginning, offset 293782
seek base 0 = beginning, offset 294192
seek base 0 = beginning, offset 297985
seek base 0 = beginning, offset 299163
seek base 0 = beginning, offset 308372
seek base 0 = beginning, offset 316537
seek base 0 = beginning, offset 320620
seek base 0 = beginning, offset 322021
seek base 0 = beginning, offset 322936
seek base 0 = beginning, offset 323211
seek base 0 = beginning, offset 325268
seek base 0 = beginning, offset 326251
seek base 0 = beginning, offset 328790
seek base 0 = beginning, offset 330207
seek base 0 = beginning, offset 333087
seek base 0 = beginning, offset 346728
seek base 0 = beginning, offset 347198
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 0
seek base 1 = current, offset 0
seek base 0 = beginning, offset 0
seek base 1 = current, offset -1016
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 8
seek base 1 = current, offset 0
seek base 0 = beginning, offset 90224
seek base 1 = current, offset -1016
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 90232
seek base 1 = current, offset 0
seek base 0 = beginning, offset 347803
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -1012
seek base 0 = beginning, offset 402492
seek base 1 = current, offset 0
seek base 1 = current, offset -8
seek base 0 = beginning, offset 347803
seek base 1 = current, offset -607
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -981
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 43
seek base 1 = current, offset 0
seek base 0 = beginning, offset 43
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -1012
seek base 0 = beginning, offset 3911
seek base 1 = current, offset 0
seek base 1 = current, offset -8
seek base 0 = beginning, offset 55
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -123
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -536
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 37
seek base 1 = current, offset 0
seek base 0 = beginning, offset 37
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -101

View File

@ -0,0 +1,186 @@
dosmon log is at 17b50009
byte count: 1044
seek base 0 = beginning, offset 0
seek base 0 = beginning, offset 90224
seek base 0 = beginning, offset 325268
seek base 0 = beginning, offset 90232
seek base 0 = beginning, offset 213417
seek base 0 = beginning, offset 347198
seek base 0 = beginning, offset 326251
seek base 0 = beginning, offset 222140
seek base 0 = beginning, offset 251425
seek base 0 = beginning, offset 200424
seek base 0 = beginning, offset 292535
seek base 0 = beginning, offset 328790
seek base 0 = beginning, offset 93836
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 0
seek base 1 = current, offset 0
seek base 0 = beginning, offset 0
seek base 1 = current, offset -1016
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 8
seek base 1 = current, offset 0
seek base 0 = beginning, offset 90224
seek base 1 = current, offset -1016
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 90232
seek base 1 = current, offset 0
seek base 0 = beginning, offset 347803
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -1012
seek base 0 = beginning, offset 402492
seek base 1 = current, offset 0
seek base 1 = current, offset -8
seek base 0 = beginning, offset 361680
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -1020
seek base 0 = beginning, offset 385798
seek base 0 = beginning, offset 323211
seek base 0 = beginning, offset 346728
seek base 0 = beginning, offset 283144
seek base 0 = beginning, offset 284119
seek base 1 = current, offset 0
seek base 1 = current, offset -416
seek base 0 = beginning, offset 368796
seek base 1 = current, offset 0
seek base 1 = current, offset -1018
seek base 0 = beginning, offset 368630
seek base 0 = beginning, offset 284700
seek base 0 = beginning, offset 273021
seek base 1 = current, offset 0
seek base 1 = current, offset -1014
seek base 0 = beginning, offset 400466
seek base 0 = beginning, offset 262945
seek base 1 = current, offset 0
seek base 1 = current, offset -704
seek base 0 = beginning, offset 369359
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -981
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 43
seek base 1 = current, offset 0
seek base 0 = beginning, offset 43
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -1012
seek base 0 = beginning, offset 3911
seek base 1 = current, offset 0
seek base 1 = current, offset -8
seek base 0 = beginning, offset 55
seek base 0 = beginning, offset 128449
seek base 0 = beginning, offset 191179
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 0 = beginning, offset 269199
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -123
seek base 0 = beginning, offset 330207
seek base 1 = current, offset 0
seek base 1 = current, offset -1015
seek base 0 = beginning, offset 350192
seek base 1 = current, offset 0
seek base 1 = current, offset -1016
seek base 0 = beginning, offset 347815
seek base 0 = beginning, offset 322936
seek base 0 = beginning, offset 290973
seek base 1 = current, offset 0
seek base 1 = current, offset -695
seek base 0 = beginning, offset 368802
seek base 1 = current, offset 0
seek base 1 = current, offset -1014
seek base 0 = beginning, offset 402127
seek base 0 = beginning, offset 320620
seek base 0 = beginning, offset 97821
seek base 0 = beginning, offset 110007
seek base 0 = beginning, offset 294192
seek base 0 = beginning, offset 114272
seek base 0 = beginning, offset 273021
seek base 0 = beginning, offset 262945
seek base 0 = beginning, offset 297985
seek base 0 = beginning, offset 322021
seek base 1 = current, offset 0
seek base 1 = current, offset -659
seek base 0 = beginning, offset 361723
seek base 0 = beginning, offset 137842
seek base 0 = beginning, offset 190451
seek base 1 = current, offset 0
seek base 1 = current, offset -567
seek base 0 = beginning, offset 369359
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -536
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 37
seek base 1 = current, offset 0
seek base 0 = beginning, offset 37
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 0 = beginning, offset 191179
seek base 0 = beginning, offset 262945
seek base 0 = beginning, offset 322936
seek base 1 = current, offset 0
seek base 1 = current, offset -913
seek base 0 = beginning, offset 369359
seek base 0 = beginning, offset 90232
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 0 = beginning, offset 292535
seek base 0 = beginning, offset 322021
seek base 1 = current, offset 0
seek base 0 = beginning, offset 128449
seek base 0 = beginning, offset 93836
seek base 0 = beginning, offset 97821
seek base 0 = beginning, offset 323211
seek base 0 = beginning, offset 110007
seek base 0 = beginning, offset 294192
seek base 0 = beginning, offset 114272
seek base 0 = beginning, offset 273021
seek base 0 = beginning, offset 297985
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -101
seek base 0 = beginning, offset 213417
seek base 1 = current, offset 0
seek base 1 = current, offset -913
seek base 0 = beginning, offset 368618
seek base 0 = beginning, offset 200424
seek base 1 = current, offset 0
seek base 1 = current, offset -1017
seek base 0 = beginning, offset 369944
seek base 0 = beginning, offset 322936
seek base 1 = current, offset 0
seek base 1 = current, offset -848
seek base 0 = beginning, offset 373115
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -380
seek base 0 = beginning, offset 398100
seek base 0 = beginning, offset 222983
seek base 0 = beginning, offset 333087
seek base 0 = beginning, offset 269199

View File

@ -0,0 +1 @@
2100186f50000f09011b0f0950005000500050001c0d39200e0821001f732e0020642e00326d1c0d21002d78

View File

@ -0,0 +1,305 @@
dosmon log is at 1a20009
byte count: 1639
seek base 0 = beginning, offset 0
read handle 5 count 8
seek base 0 = beginning, offset 90224
read handle 5 count 8
seek base 0 = beginning, offset 325268
read handle 5 count 955
read handle 5 count 28
seek base 0 = beginning, offset 90232
read handle 5 count 3348
read handle 5 count 256
seek base 0 = beginning, offset 93836
read handle 5 count 3823
read handle 5 count 162
seek base 0 = beginning, offset 97821
read handle 5 count 7701
read handle 5 count 634
seek base 0 = beginning, offset 106156
read handle 5 count 3535
read handle 5 count 316
seek base 0 = beginning, offset 110007
read handle 5 count 4043
read handle 5 count 222
seek base 0 = beginning, offset 114272
read handle 5 count 12903
read handle 5 count 1274
seek base 0 = beginning, offset 128449
read handle 5 count 9029
read handle 5 count 364
seek base 0 = beginning, offset 137842
read handle 5 count 52529
read handle 5 count 80
seek base 0 = beginning, offset 190451
read handle 5 count 702
read handle 5 count 26
seek base 0 = beginning, offset 191179
read handle 5 count 8913
read handle 5 count 332
seek base 0 = beginning, offset 200424
read handle 5 count 10394
read handle 5 count 550
seek base 0 = beginning, offset 211368
read handle 5 count 1631
seek base 0 = beginning, offset 212999
read handle 5 count 378
read handle 5 count 40
seek base 0 = beginning, offset 213417
read handle 5 count 8129
read handle 5 count 594
seek base 0 = beginning, offset 222140
read handle 5 count 705
read handle 5 count 138
seek base 0 = beginning, offset 222983
read handle 5 count 1739
read handle 5 count 90
seek base 0 = beginning, offset 224812
read handle 5 count 12415
read handle 5 count 178
seek base 0 = beginning, offset 237405
read handle 5 count 6112
read handle 5 count 118
seek base 0 = beginning, offset 243635
read handle 5 count 353
read handle 5 count 26
seek base 0 = beginning, offset 244014
read handle 5 count 579
read handle 5 count 26
seek base 0 = beginning, offset 244619
read handle 5 count 2105
read handle 5 count 116
seek base 0 = beginning, offset 246840
read handle 5 count 1219
read handle 5 count 76
seek base 0 = beginning, offset 248135
read handle 5 count 969
read handle 5 count 30
seek base 0 = beginning, offset 249134
read handle 5 count 901
read handle 5 count 50
seek base 0 = beginning, offset 250085
read handle 5 count 1282
read handle 5 count 58
seek base 0 = beginning, offset 251425
read handle 5 count 10816
read handle 5 count 704
seek base 0 = beginning, offset 262945
read handle 5 count 5950
read handle 5 count 304
seek base 0 = beginning, offset 269199
read handle 5 count 3704
read handle 5 count 118
seek base 0 = beginning, offset 273021
read handle 5 count 4080
read handle 5 count 174
seek base 0 = beginning, offset 277275
read handle 5 count 5631
read handle 5 count 238
seek base 0 = beginning, offset 283144
read handle 5 count 911
read handle 5 count 64
seek base 0 = beginning, offset 284119
read handle 5 count 567
read handle 5 count 14
seek base 0 = beginning, offset 284700
read handle 5 count 5991
read handle 5 count 198
seek base 0 = beginning, offset 290889
read handle 5 count 84
seek base 0 = beginning, offset 290973
read handle 5 count 822
read handle 5 count 40
seek base 0 = beginning, offset 291835
read handle 5 count 684
read handle 5 count 16
seek base 0 = beginning, offset 292535
read handle 5 count 1169
read handle 5 count 78
seek base 0 = beginning, offset 293782
read handle 5 count 402
read handle 5 count 8
seek base 0 = beginning, offset 294192
read handle 5 count 3669
read handle 5 count 124
seek base 0 = beginning, offset 297985
read handle 5 count 1082
read handle 5 count 96
seek base 0 = beginning, offset 299163
read handle 5 count 9169
read handle 5 count 40
seek base 0 = beginning, offset 308372
read handle 5 count 8153
read handle 5 count 12
seek base 0 = beginning, offset 316537
read handle 5 count 4061
read handle 5 count 22
seek base 0 = beginning, offset 320620
read handle 5 count 1355
read handle 5 count 46
seek base 0 = beginning, offset 322021
read handle 5 count 887
read handle 5 count 28
seek base 0 = beginning, offset 322936
read handle 5 count 253
read handle 5 count 22
seek base 0 = beginning, offset 323211
read handle 5 count 2031
read handle 5 count 26
seek base 0 = beginning, offset 325268
read handle 5 count 955
read handle 5 count 28
seek base 0 = beginning, offset 326251
read handle 5 count 2515
read handle 5 count 24
seek base 0 = beginning, offset 328790
read handle 5 count 1411
read handle 5 count 6
seek base 0 = beginning, offset 330207
read handle 5 count 2764
read handle 5 count 116
seek base 0 = beginning, offset 333087
read handle 5 count 13133
read handle 5 count 508
seek base 0 = beginning, offset 346728
read handle 5 count 464
read handle 5 count 6
seek base 0 = beginning, offset 347198
read handle 5 count 595
read handle 5 count 10
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 0
seek base 1 = current, offset 0
seek base 0 = beginning, offset 0
read handle 5 count 1024
seek base 1 = current, offset -1016
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 8
seek base 1 = current, offset 0
seek base 0 = beginning, offset 90224
read handle 5 count 1024
seek base 1 = current, offset -1016
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 90232
seek base 1 = current, offset 0
seek base 0 = beginning, offset 347803
read handle 5 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -1012
seek base 0 = beginning, offset 402492
read handle 5 count 1024
read handle 5 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset -8
seek base 0 = beginning, offset 347803
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
seek base 1 = current, offset -607
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 0
read handle 6 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset -981
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 43
seek base 1 = current, offset 0
seek base 0 = beginning, offset 43
read handle 6 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -1012
seek base 0 = beginning, offset 3911
read handle 6 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset -8
seek base 0 = beginning, offset 55
read handle 6 count 1024
seek base 1 = current, offset 0
read handle 6 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset 0
read handle 6 count 1024
read handle 6 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -123
read handle 6 count 65520
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 0
read handle 6 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset -536
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 37
seek base 1 = current, offset 0
seek base 0 = beginning, offset 37
read handle 6 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -101

View File

@ -0,0 +1,340 @@
dosmon log is at 17b50009
byte count: 1864
read handle 0 count 512
seek base 0 = beginning, offset 0
read handle 5 count 8
seek base 0 = beginning, offset 90224
read handle 5 count 8
seek base 0 = beginning, offset 325268
read handle 5 count 955
read handle 5 count 28
seek base 0 = beginning, offset 90232
read handle 5 count 3348
read handle 5 count 256
seek base 0 = beginning, offset 213417
read handle 5 count 8129
read handle 5 count 594
seek base 0 = beginning, offset 347198
read handle 5 count 595
read handle 5 count 10
seek base 0 = beginning, offset 326251
read handle 5 count 2515
read handle 5 count 24
seek base 0 = beginning, offset 222140
read handle 5 count 705
read handle 5 count 138
seek base 0 = beginning, offset 251425
read handle 5 count 10816
read handle 5 count 704
seek base 0 = beginning, offset 200424
read handle 5 count 10394
read handle 5 count 550
seek base 0 = beginning, offset 292535
read handle 5 count 1169
read handle 5 count 78
seek base 0 = beginning, offset 328790
read handle 5 count 1411
read handle 5 count 6
seek base 0 = beginning, offset 93836
read handle 5 count 3823
read handle 5 count 162
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 0
seek base 1 = current, offset 0
seek base 0 = beginning, offset 0
read handle 5 count 1024
seek base 1 = current, offset -1016
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 8
seek base 1 = current, offset 0
seek base 0 = beginning, offset 90224
read handle 5 count 1024
seek base 1 = current, offset -1016
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 90232
seek base 1 = current, offset 0
seek base 0 = beginning, offset 347803
read handle 5 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -1012
seek base 0 = beginning, offset 402492
read handle 5 count 1024
read handle 5 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset -8
seek base 0 = beginning, offset 361680
read handle 5 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -1020
seek base 0 = beginning, offset 385798
read handle 5 count 1024
seek base 0 = beginning, offset 323211
read handle 5 count 2031
read handle 5 count 26
seek base 0 = beginning, offset 346728
read handle 5 count 464
read handle 5 count 6
seek base 0 = beginning, offset 283144
read handle 5 count 911
read handle 5 count 64
seek base 0 = beginning, offset 284119
read handle 5 count 567
read handle 5 count 14
seek base 1 = current, offset 0
seek base 1 = current, offset -416
seek base 0 = beginning, offset 368796
read handle 5 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset -1018
seek base 0 = beginning, offset 368630
read handle 5 count 1024
seek base 0 = beginning, offset 284700
read handle 5 count 5991
read handle 5 count 198
seek base 0 = beginning, offset 273021
read handle 5 count 4080
read handle 5 count 174
seek base 1 = current, offset 0
seek base 1 = current, offset -1014
seek base 0 = beginning, offset 400466
read handle 5 count 1024
seek base 0 = beginning, offset 262945
read handle 5 count 5950
read handle 5 count 304
read handle 5 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset -704
seek base 0 = beginning, offset 369359
read handle 5 count 1024
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 0
read handle 7 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset -981
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 43
seek base 1 = current, offset 0
seek base 0 = beginning, offset 43
read handle 7 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -1012
seek base 0 = beginning, offset 3911
read handle 7 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset -8
seek base 0 = beginning, offset 55
read handle 7 count 1024
seek base 0 = beginning, offset 128449
read handle 5 count 9029
read handle 5 count 364
seek base 0 = beginning, offset 191179
read handle 5 count 8913
read handle 5 count 332
seek base 1 = current, offset 0
read handle 7 count 1024
seek base 1 = current, offset 0
seek base 0 = beginning, offset 269199
read handle 5 count 3704
read handle 5 count 118
seek base 1 = current, offset 0
read handle 7 count 1024
read handle 7 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -123
seek base 0 = beginning, offset 330207
read handle 5 count 2764
read handle 5 count 116
seek base 1 = current, offset 0
seek base 1 = current, offset -1015
seek base 0 = beginning, offset 350192
read handle 5 count 1024
read handle 5 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset -1016
seek base 0 = beginning, offset 347815
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
seek base 0 = beginning, offset 322936
read handle 5 count 253
read handle 5 count 22
seek base 0 = beginning, offset 290973
read handle 5 count 822
read handle 5 count 40
seek base 1 = current, offset 0
seek base 1 = current, offset -695
seek base 0 = beginning, offset 368802
read handle 5 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset -1014
seek base 0 = beginning, offset 402127
read handle 5 count 1024
seek base 0 = beginning, offset 320620
read handle 5 count 1355
read handle 5 count 46
seek base 0 = beginning, offset 97821
read handle 5 count 7701
read handle 5 count 634
seek base 0 = beginning, offset 110007
read handle 5 count 4043
read handle 5 count 222
seek base 0 = beginning, offset 294192
read handle 5 count 3669
read handle 5 count 124
seek base 0 = beginning, offset 114272
read handle 5 count 12903
read handle 5 count 1274
seek base 0 = beginning, offset 273021
read handle 5 count 4080
read handle 5 count 174
seek base 0 = beginning, offset 262945
read handle 5 count 5950
read handle 5 count 304
seek base 0 = beginning, offset 297985
read handle 5 count 1082
read handle 5 count 96
seek base 0 = beginning, offset 322021
read handle 5 count 887
read handle 5 count 28
seek base 1 = current, offset 0
seek base 1 = current, offset -659
seek base 0 = beginning, offset 361723
read handle 5 count 1024
seek base 0 = beginning, offset 137842
read handle 5 count 52529
read handle 5 count 80
seek base 0 = beginning, offset 190451
read handle 5 count 702
read handle 5 count 26
read handle 7 count 65520
seek base 1 = current, offset 0
seek base 1 = current, offset -567
seek base 0 = beginning, offset 369359
read handle 5 count 1024
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 0
read handle 7 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset -536
seek base 1 = current, offset 0
seek base 2 = end, offset 0
seek base 0 = beginning, offset 37
seek base 1 = current, offset 0
seek base 0 = beginning, offset 37
read handle 7 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 0 = beginning, offset 191179
read handle 5 count 8913
read handle 5 count 332
seek base 0 = beginning, offset 262945
read handle 5 count 5950
read handle 5 count 304
seek base 0 = beginning, offset 322936
read handle 5 count 253
read handle 5 count 22
seek base 1 = current, offset 0
seek base 1 = current, offset -913
seek base 0 = beginning, offset 369359
read handle 5 count 1024
seek base 0 = beginning, offset 90232
read handle 5 count 3348
read handle 5 count 256
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 0 = beginning, offset 292535
read handle 5 count 1169
read handle 5 count 78
seek base 0 = beginning, offset 322021
read handle 5 count 887
read handle 5 count 28
seek base 1 = current, offset 0
seek base 0 = beginning, offset 128449
read handle 5 count 9029
read handle 5 count 364
seek base 0 = beginning, offset 93836
read handle 5 count 3823
read handle 5 count 162
seek base 0 = beginning, offset 97821
read handle 5 count 7701
read handle 5 count 634
seek base 0 = beginning, offset 323211
read handle 5 count 2031
read handle 5 count 26
seek base 0 = beginning, offset 110007
read handle 5 count 4043
read handle 5 count 222
seek base 0 = beginning, offset 294192
read handle 5 count 3669
read handle 5 count 124
seek base 0 = beginning, offset 114272
read handle 5 count 12903
read handle 5 count 1274
seek base 0 = beginning, offset 273021
read handle 5 count 4080
read handle 5 count 174
seek base 0 = beginning, offset 297985
read handle 5 count 1082
read handle 5 count 96
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -101
seek base 0 = beginning, offset 213417
read handle 5 count 8129
read handle 5 count 594
seek base 1 = current, offset 0
seek base 1 = current, offset -913
seek base 0 = beginning, offset 368618
read handle 5 count 1024
seek base 0 = beginning, offset 200424
read handle 5 count 10394
read handle 5 count 550
seek base 1 = current, offset 0
seek base 1 = current, offset -1017
seek base 0 = beginning, offset 369944
read handle 5 count 1024
seek base 0 = beginning, offset 322936
read handle 5 count 253
read handle 5 count 22
seek base 1 = current, offset 0
seek base 1 = current, offset -848
seek base 0 = beginning, offset 373115
read handle 5 count 1024
seek base 1 = current, offset 0
seek base 1 = current, offset 0
seek base 1 = current, offset -380
seek base 0 = beginning, offset 398100
read handle 5 count 1024
seek base 0 = beginning, offset 222983
read handle 5 count 1739
read handle 5 count 90
seek base 0 = beginning, offset 333087
read handle 5 count 13133
read handle 5 count 508
seek base 0 = beginning, offset 269199
read handle 5 count 3704
read handle 5 count 118
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 5 count 1024
read handle 0 count 512

View File

@ -0,0 +1 @@
2100186f50000f09011b0f0950005000500050001c0d39200e0821001f732e0020642e00326d1c0d21002d78

View File

@ -0,0 +1,95 @@
{*******************************************************}
{ }
{ Turbo Pascal Version 7.0 }
{ CRT Interface Unit }
{ }
{ Copyright (C) 1988,92 Borland International }
{ }
{*******************************************************}
unit Crt;
{$D-,I-,S-}
interface
const
{ CRT modes }
BW40 = 0; { 40x25 B/W on Color Adapter }
CO40 = 1; { 40x25 Color on Color Adapter }
BW80 = 2; { 80x25 B/W on Color Adapter }
CO80 = 3; { 80x25 Color on Color Adapter }
Mono = 7; { 80x25 on Monochrome Adapter }
Font8x8 = 256; { Add-in for ROM font }
{ Mode constants for 3.0 compatibility }
C40 = CO40;
C80 = CO80;
{ Foreground and background color constants }
Black = 0;
Blue = 1;
Green = 2;
Cyan = 3;
Red = 4;
Magenta = 5;
Brown = 6;
LightGray = 7;
{ Foreground color constants }
DarkGray = 8;
LightBlue = 9;
LightGreen = 10;
LightCyan = 11;
LightRed = 12;
LightMagenta = 13;
Yellow = 14;
White = 15;
{ Add-in for blinking }
Blink = 128;
var
{ Interface variables }
CheckBreak: Boolean; { Enable Ctrl-Break }
CheckEOF: Boolean; { Enable Ctrl-Z }
DirectVideo: Boolean; { Enable direct video addressing }
CheckSnow: Boolean; { Enable snow filtering }
LastMode: Word; { Current text mode }
TextAttr: Byte; { Current text attribute }
WindMin: Word; { Window upper left coordinates }
WindMax: Word; { Window lower right coordinates }
{ Interface procedures }
procedure AssignCrt(var F: Text);
function KeyPressed: Boolean;
function ReadKey: Char;
procedure TextMode(Mode: Integer);
procedure Window(X1,Y1,X2,Y2: Byte);
procedure GotoXY(X,Y: Byte);
function WhereX: Byte;
function WhereY: Byte;
procedure ClrScr;
procedure ClrEol;
procedure InsLine;
procedure DelLine;
procedure TextColor(Color: Byte);
procedure TextBackground(Color: Byte);
procedure LowVideo;
procedure HighVideo;
procedure NormVideo;
procedure Delay(MS: Word);
procedure Sound(Hz: Word);
procedure NoSound;

View File

@ -0,0 +1,528 @@
{*******************************************************}
{ }
{ Turbo Pascal Version 7.0 }
{ Turbo Vision Unit }
{ }
{ Copyright (c) 1991,92 Borland International }
{ }
{*******************************************************}
unit Dialogs;
{$O+,F+,X+,I-,S-}
interface
uses Objects, Drivers, Views, Validate;
const
{ Color palettes }
CGrayDialog = #32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47 +
#48#49#50#51#52#53#54#55#56#57#58#59#60#61#62#63;
CBlueDialog = #64#65#66#67#68#69#70#71#72#73#74#75#76#77#78#79 +
#80#81#82#83#84#85#86#87#88#89#90#91#92#92#94#95;
CCyanDialog = #96#97#98#99#100#101#102#103#104#105#106#107#108 +
#109#110#111#112#113#114#115#116#117#118#119#120 +
#121#122#123#124#125#126#127;
CDialog = CGrayDialog;
CStaticText = #6;
CLabel = #7#8#9#9;
CButton = #10#11#12#13#14#14#14#15;
CCluster = #16#17#18#18#31;
CInputLine = #19#19#20#21;
CHistory = #22#23;
CHistoryWindow = #19#19#21#24#25#19#20;
CHistoryViewer = #6#6#7#6#6;
{ TDialog palette entires }
dpBlueDialog = 1;
dpCyanDialog = 2;
dpGrayDialog = 3;
{ TButton flags }
bfNormal = $00;
bfDefault = $01;
bfLeftJust = $02;
bfBroadcast = $04;
{ TMultiCheckboxes flags }
{ hiword = number of bits }
{ loword = bit mask }
cfOneBit = $0101;
cfTwoBits = $0203;
cfFourBits = $040F;
cfEightBits = $08FF;
type
{ TDialog object }
{ Palette layout }
{ 1 = Frame passive }
{ 2 = Frame active }
{ 3 = Frame icon }
{ 4 = ScrollBar page area }
{ 5 = ScrollBar controls }
{ 6 = StaticText }
{ 7 = Label normal }
{ 8 = Label selected }
{ 9 = Label shortcut }
{ 10 = Button normal }
{ 11 = Button default }
{ 12 = Button selected }
{ 13 = Button disabled }
{ 14 = Button shortcut }
{ 15 = Button shadow }
{ 16 = Cluster normal }
{ 17 = Cluster selected }
{ 18 = Cluster shortcut }
{ 19 = InputLine normal text }
{ 20 = InputLine selected text }
{ 21 = InputLine arrows }
{ 22 = History arrow }
{ 23 = History sides }
{ 24 = HistoryWindow scrollbar page area }
{ 25 = HistoryWindow scrollbar controls }
{ 26 = ListViewer normal }
{ 27 = ListViewer focused }
{ 28 = ListViewer selected }
{ 29 = ListViewer divider }
{ 30 = InfoPane }
{ 31 = Reserved }
{ 32 = Reserved }
PDialog = ^TDialog;
TDialog = object(TWindow)
constructor Init(var Bounds: TRect; ATitle: TTitleStr);
constructor Load(var S: TStream);
function GetPalette: PPalette; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
function Valid(Command: Word): Boolean; virtual;
end;
{ TSItem }
PSItem = ^TSItem;
TSItem = record
Value: PString;
Next: PSItem;
end;
{ TInputLine object }
{ Palette layout }
{ 1 = Passive }
{ 2 = Active }
{ 3 = Selected }
{ 4 = Arrows }
PInputLine = ^TInputLine;
TInputLine = object(TView)
Data: PString;
MaxLen: Integer;
CurPos: Integer;
FirstPos: Integer;
SelStart: Integer;
SelEnd: Integer;
Validator: PValidator;
constructor Init(var Bounds: TRect; AMaxLen: Integer);
constructor Load(var S: TStream);
destructor Done; virtual;
function DataSize: Word; virtual;
procedure Draw; virtual;
procedure GetData(var Rec); virtual;
function GetPalette: PPalette; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
procedure SelectAll(Enable: Boolean);
procedure SetData(var Rec); virtual;
procedure SetState(AState: Word; Enable: Boolean); virtual;
procedure SetValidator(AValid: PValidator);
procedure Store(var S: TStream);
function Valid(Command: Word): Boolean; virtual;
end;
{ TButton object }
{ Palette layout }
{ 1 = Normal text }
{ 2 = Default text }
{ 3 = Selected text }
{ 4 = Disabled text }
{ 5 = Normal shortcut }
{ 6 = Default shortcut }
{ 7 = Selected shortcut }
{ 8 = Shadow }
PButton = ^TButton;
TButton = object(TView)
Title: PString;
Command: Word;
Flags: Byte;
AmDefault: Boolean;
constructor Init(var Bounds: TRect; ATitle: TTitleStr; ACommand: Word;
AFlags: Word);
constructor Load(var S: TStream);
destructor Done; virtual;
procedure Draw; virtual;
procedure DrawState(Down: Boolean);
function GetPalette: PPalette; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
procedure MakeDefault(Enable: Boolean);
procedure Press; virtual;
procedure SetState(AState: Word; Enable: Boolean); virtual;
procedure Store(var S: TStream);
end;
{ TCluster }
{ Palette layout }
{ 1 = Normal text }
{ 2 = Selected text }
{ 3 = Normal shortcut }
{ 4 = Selected shortcut }
{ 5 = Disabled text }
PCluster = ^TCluster;
TCluster = object(TView)
Value: LongInt;
Sel: Integer;
EnableMask: LongInt;
Strings: TStringCollection;
constructor Init(var Bounds: TRect; AStrings: PSItem);
constructor Load(var S: TStream);
destructor Done; virtual;
function ButtonState(Item: Integer): Boolean;
function DataSize: Word; virtual;
procedure DrawBox(const Icon: String; Marker: Char);
procedure DrawMultiBox(const Icon, Marker: String);
procedure GetData(var Rec); virtual;
function GetHelpCtx: Word; virtual;
function GetPalette: PPalette; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
function Mark(Item: Integer): Boolean; virtual;
function MultiMark(Item: Integer): Byte; virtual;
procedure Press(Item: Integer); virtual;
procedure MovedTo(Item: Integer); virtual;
procedure SetButtonState(AMask: Longint; Enable: Boolean);
procedure SetData(var Rec); virtual;
procedure SetState(AState: Word; Enable: Boolean); virtual;
procedure Store(var S: TStream);
end;
{ TRadioButtons }
{ Palette layout }
{ 1 = Normal text }
{ 2 = Selected text }
{ 3 = Normal shortcut }
{ 4 = Selected shortcut }
PRadioButtons = ^TRadioButtons;
TRadioButtons = object(TCluster)
procedure Draw; virtual;
function Mark(Item: Integer): Boolean; virtual;
procedure MovedTo(Item: Integer); virtual;
procedure Press(Item: Integer); virtual;
procedure SetData(var Rec); virtual;
end;
{ TCheckBoxes }
{ Palette layout }
{ 1 = Normal text }
{ 2 = Selected text }
{ 3 = Normal shortcut }
{ 4 = Selected shortcut }
PCheckBoxes = ^TCheckBoxes;
TCheckBoxes = object(TCluster)
procedure Draw; virtual;
function Mark(Item: Integer): Boolean; virtual;
procedure Press(Item: Integer); virtual;
end;
{ TMultiCheckBoxes }
{ Palette layout }
{ 1 = Normal text }
{ 2 = Selected text }
{ 3 = Normal shortcut }
{ 4 = Selected shortcut }
PMultiCheckBoxes = ^TMultiCheckBoxes;
TMultiCheckBoxes = object(TCluster)
SelRange: Byte;
Flags: Word;
States: PString;
constructor Init(var Bounds: TRect; AStrings: PSItem;
ASelRange: Byte; AFlags: Word; const AStates: String);
constructor Load(var S: TStream);
destructor Done; virtual;
function DataSize: Word; virtual;
procedure Draw; virtual;
procedure GetData(var Rec); virtual;
function MultiMark(Item: Integer): Byte; virtual;
procedure Press(Item: Integer); virtual;
procedure SetData(var Rec); virtual;
procedure Store(var S: TStream);
end;
{ TListBox }
{ Palette layout }
{ 1 = Active }
{ 2 = Inactive }
{ 3 = Focused }
{ 4 = Selected }
{ 5 = Divider }
PListBox = ^TListBox;
TListBox = object(TListViewer)
List: PCollection;
constructor Init(var Bounds: TRect; ANumCols: Word;
AScrollBar: PScrollBar);
constructor Load(var S: TStream);
function DataSize: Word; virtual;
procedure GetData(var Rec); virtual;
function GetText(Item: Integer; MaxLen: Integer): String; virtual;
procedure NewList(AList: PCollection); virtual;
procedure SetData(var Rec); virtual;
procedure Store(var S: TStream);
end;
{ TStaticText }
{ Palette layout }
{ 1 = Text }
PStaticText = ^TStaticText;
TStaticText = object(TView)
Text: PString;
constructor Init(var Bounds: TRect; const AText: String);
constructor Load(var S: TStream);
destructor Done; virtual;
procedure Draw; virtual;
function GetPalette: PPalette; virtual;
procedure GetText(var S: String); virtual;
procedure Store(var S: TStream);
end;
{ TParamText }
{ Palette layout }
{ 1 = Text }
PParamText = ^TParamText;
TParamText = object(TStaticText)
ParamCount: Integer;
ParamList: Pointer;
constructor Init(var Bounds: TRect; const AText: String;
AParamCount: Integer);
constructor Load(var S: TStream);
function DataSize: Word; virtual;
procedure GetText(var S: String); virtual;
procedure SetData(var Rec); virtual;
procedure Store(var S: TStream);
end;
{ TLabel }
{ Palette layout }
{ 1 = Normal text }
{ 2 = Selected text }
{ 3 = Normal shortcut }
{ 4 = Selected shortcut }
PLabel = ^TLabel;
TLabel = object(TStaticText)
Link: PView;
Light: Boolean;
constructor Init(var Bounds: TRect; const AText: String; ALink: PView);
constructor Load(var S: TStream);
procedure Draw; virtual;
function GetPalette: PPalette; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
procedure Store(var S: TStream);
end;
{ THistoryViewer }
{ Palette layout }
{ 1 = Active }
{ 2 = Inactive }
{ 3 = Focused }
{ 4 = Selected }
{ 5 = Divider }
PHistoryViewer = ^THistoryViewer;
THistoryViewer = object(TListViewer)
HistoryId: Word;
constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar;
AHistoryId: Word);
function GetPalette: PPalette; virtual;
function GetText(Item: Integer; MaxLen: Integer): String; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
function HistoryWidth: Integer;
end;
{ THistoryWindow }
{ Palette layout }
{ 1 = Frame passive }
{ 2 = Frame active }
{ 3 = Frame icon }
{ 4 = ScrollBar page area }
{ 5 = ScrollBar controls }
{ 6 = HistoryViewer normal text }
{ 7 = HistoryViewer selected text }
PHistoryWindow = ^THistoryWindow;
THistoryWindow = object(TWindow)
Viewer: PListViewer;
constructor Init(var Bounds: TRect; HistoryId: Word);
function GetPalette: PPalette; virtual;
function GetSelection: String; virtual;
procedure InitViewer(HistoryId: Word); virtual;
end;
{ THistory }
{ Palette layout }
{ 1 = Arrow }
{ 2 = Sides }
PHistory = ^THistory;
THistory = object(TView)
Link: PInputLine;
HistoryId: Word;
constructor Init(var Bounds: TRect; ALink: PInputLine; AHistoryId: Word);
constructor Load(var S: TStream);
procedure Draw; virtual;
function GetPalette: PPalette; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
function InitHistoryWindow(var Bounds: TRect): PHistoryWindow; virtual;
procedure RecordHistory(const S: String); virtual;
procedure Store(var S: TStream);
end;
{ SItem routines }
function NewSItem(const Str: String; ANext: PSItem): PSItem;
{ Dialogs registration procedure }
procedure RegisterDialogs;
{ Stream Registration Records }
const
RDialog: TStreamRec = (
ObjType: 10;
VmtLink: Ofs(TypeOf(TDialog)^);
Load: @TDialog.Load;
Store: @TDialog.Store
);
const
RInputLine: TStreamRec = (
ObjType: 11;
VmtLink: Ofs(TypeOf(TInputLine)^);
Load: @TInputLine.Load;
Store: @TInputLine.Store
);
const
RButton: TStreamRec = (
ObjType: 12;
VmtLink: Ofs(TypeOf(TButton)^);
Load: @TButton.Load;
Store: @TButton.Store
);
const
RCluster: TStreamRec = (
ObjType: 13;
VmtLink: Ofs(TypeOf(TCluster)^);
Load: @TCluster.Load;
Store: @TCluster.Store
);
const
RRadioButtons: TStreamRec = (
ObjType: 14;
VmtLink: Ofs(TypeOf(TRadioButtons)^);
Load: @TRadioButtons.Load;
Store: @TRadioButtons.Store
);
const
RCheckBoxes: TStreamRec = (
ObjType: 15;
VmtLink: Ofs(TypeOf(TCheckBoxes)^);
Load: @TCheckBoxes.Load;
Store: @TCheckBoxes.Store
);
const
RMultiCheckBoxes: TStreamRec = (
ObjType: 27;
VmtLink: Ofs(TypeOf(TMultiCheckBoxes)^);
Load: @TMultiCheckBoxes.Load;
Store: @TMultiCheckBoxes.Store
);
const
RListBox: TStreamRec = (
ObjType: 16;
VmtLink: Ofs(TypeOf(TListBox)^);
Load: @TListBox.Load;
Store: @TListBox.Store
);
const
RStaticText: TStreamRec = (
ObjType: 17;
VmtLink: Ofs(TypeOf(TStaticText)^);
Load: @TStaticText.Load;
Store: @TStaticText.Store
);
const
RLabel: TStreamRec = (
ObjType: 18;
VmtLink: Ofs(TypeOf(TLabel)^);
Load: @TLabel.Load;
Store: @TLabel.Store
);
const
RHistory: TStreamRec = (
ObjType: 19;
VmtLink: Ofs(TypeOf(THistory)^);
Load: @THistory.Load;
Store: @THistory.Store
);
const
RParamText: TStreamRec = (
ObjType: 20;
VmtLink: Ofs(TypeOf(TParamText)^);
Load: @TParamText.Load;
Store: @TParamText.Store
);
const
{ Dialog broadcast commands }
cmRecordHistory = 60;

View File

@ -0,0 +1,337 @@
{*******************************************************}
{ }
{ Turbo Pascal Version 7.0 }
{ DOS Interface Unit }
{ }
{ Copyright (C) 1988,92 Borland International }
{ }
{*******************************************************}
unit Dos;
{$D-,I-,S-,O+}
interface
const
{ Flags bit masks }
FCarry = $0001;
FParity = $0004;
FAuxiliary = $0010;
FZero = $0040;
FSign = $0080;
FOverflow = $0800;
{ File mode magic numbers }
fmClosed = $D7B0;
fmInput = $D7B1;
fmOutput = $D7B2;
fmInOut = $D7B3;
{ File attribute constants }
ReadOnly = $01;
Hidden = $02;
SysFile = $04;
VolumeID = $08;
Directory = $10;
Archive = $20;
AnyFile = $3F;
type
{ String types }
ComStr = string[127]; { Command line string }
PathStr = string[79]; { File pathname string }
DirStr = string[67]; { Drive and directory string }
NameStr = string[8]; { File name string }
ExtStr = string[4]; { File extension string }
{ Registers record used by Intr and MsDos }
Registers = record
case Integer of
0: (AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags: Word);
1: (AL,AH,BL,BH,CL,CH,DL,DH: Byte);
end;
{ Typed-file and untyped-file record }
FileRec = record
Handle: Word;
Mode: Word;
RecSize: Word;
Private: array[1..26] of Byte;
UserData: array[1..16] of Byte;
Name: array[0..79] of Char;
end;
{ Textfile record }
TextBuf = array[0..127] of Char;
TextRec = record
Handle: Word;
Mode: Word;
BufSize: Word;
Private: Word;
BufPos: Word;
BufEnd: Word;
BufPtr: ^TextBuf;
OpenFunc: Pointer;
InOutFunc: Pointer;
FlushFunc: Pointer;
CloseFunc: Pointer;
UserData: array[1..16] of Byte;
Name: array[0..79] of Char;
Buffer: TextBuf;
end;
{ Search record used by FindFirst and FindNext }
SearchRec = record
Fill: array[1..21] of Byte;
Attr: Byte;
Time: Longint;
Size: Longint;
Name: string[12];
end;
{ Date and time record used by PackTime and UnpackTime }
DateTime = record
Year,Month,Day,Hour,Min,Sec: Word;
end;
var
{ Error status variable }
DosError: Integer;
{ DosVersion returns the DOS version number. The low byte of }
{ the result is the major version number, and the high byte is }
{ the minor version number. For example, DOS 3.20 returns 3 in }
{ the low byte, and 20 in the high byte. }
function DosVersion: Word;
{ Intr executes a specified software interrupt with a specified }
{ Registers package. }
procedure Intr(IntNo: Byte; var Regs: Registers);
{ MsDos invokes the DOS function call handler with a specified }
{ Registers package. }
procedure MsDos(var Regs: Registers);
{ GetDate returns the current date set in the operating system. }
{ Ranges of the values returned are: Year 1980-2099, Month }
{ 1-12, Day 1-31 and DayOfWeek 0-6 (0 corresponds to Sunday). }
procedure GetDate(var Year,Month,Day,DayOfWeek: Word);
{ SetDate sets the current date in the operating system. Valid }
{ parameter ranges are: Year 1980-2099, Month 1-12 and Day }
{ 1-31. If the date is not valid, the function call is ignored. }
procedure SetDate(Year,Month,Day: Word);
{ GetTime returns the current time set in the operating system. }
{ Ranges of the values returned are: Hour 0-23, Minute 0-59, }
{ Second 0-59 and Sec100 (hundredths of seconds) 0-99. }
procedure GetTime(var Hour,Minute,Second,Sec100: Word);
{ SetTime sets the time in the operating system. Valid }
{ parameter ranges are: Hour 0-23, Minute 0-59, Second 0-59 and }
{ Sec100 (hundredths of seconds) 0-99. If the time is not }
{ valid, the function call is ignored. }
procedure SetTime(Hour,Minute,Second,Sec100: Word);
{ GetCBreak returns the state of Ctrl-Break checking in DOS. }
{ When off (False), DOS only checks for Ctrl-Break during I/O }
{ to console, printer, or communication devices. When on }
{ (True), checks are made at every system call. }
procedure GetCBreak(var Break: Boolean);
{ SetCBreak sets the state of Ctrl-Break checking in DOS. }
procedure SetCBreak(Break: Boolean);
{ GetVerify returns the state of the verify flag in DOS. When }
{ off (False), disk writes are not verified. When on (True), }
{ all disk writes are verified to insure proper writing. }
procedure GetVerify(var Verify: Boolean);
{ SetVerify sets the state of the verify flag in DOS. }
procedure SetVerify(Verify: Boolean);
{ DiskFree returns the number of free bytes on the specified }
{ drive number (0=Default,1=A,2=B,..). DiskFree returns -1 if }
{ the drive number is invalid. }
function DiskFree(Drive: Byte): Longint;
{ DiskSize returns the size in bytes of the specified drive }
{ number (0=Default,1=A,2=B,..). DiskSize returns -1 if the }
{ drive number is invalid. }
function DiskSize(Drive: Byte): Longint;
{ GetFAttr returns the attributes of a file. F must be a file }
{ variable (typed, untyped or textfile) which has been assigned }
{ a name. The attributes are examined by ANDing with the }
{ attribute masks defined as constants above. Errors are }
{ reported in DosError. }
procedure GetFAttr(var F; var Attr: Word);
{ SetFAttr sets the attributes of a file. F must be a file }
{ variable (typed, untyped or textfile) which has been assigned }
{ a name. The attribute value is formed by adding (or ORing) }
{ the appropriate attribute masks defined as constants above. }
{ Errors are reported in DosError. }
procedure SetFAttr(var F; Attr: Word);
{ GetFTime returns the date and time a file was last written. }
{ F must be a file variable (typed, untyped or textfile) which }
{ has been assigned and opened. The Time parameter may be }
{ unpacked throgh a call to UnpackTime. Errors are reported in }
{ DosError. }
procedure GetFTime(var F; var Time: Longint);
{ SetFTime sets the date and time a file was last written. }
{ F must be a file variable (typed, untyped or textfile) which }
{ has been assigned and opened. The Time parameter may be }
{ created through a call to PackTime. Errors are reported in }
{ DosError. }
procedure SetFTime(var F; Time: Longint);
{ FindFirst searches the specified (or current) directory for }
{ the first entry that matches the specified filename and }
{ attributes. The result is returned in the specified search }
{ record. Errors (and no files found) are reported in DosError. }
procedure FindFirst(Path: PathStr; Attr: Word; var F: SearchRec);
{ FindNext returs the next entry that matches the name and }
{ attributes specified in a previous call to FindFirst. The }
{ search record must be one passed to FindFirst. Errors (and no }
{ more files) are reported in DosError. }
procedure FindNext(var F: SearchRec);
{ UnpackTime converts a 4-byte packed date/time returned by }
{ FindFirst, FindNext or GetFTime into a DateTime record. }
procedure UnpackTime(P: Longint; var T: DateTime);
{ PackTime converts a DateTime record into a 4-byte packed }
{ date/time used by SetFTime. }
procedure PackTime(var T: DateTime; var P: Longint);
{ GetIntVec returns the address stored in the specified }
{ interrupt vector. }
procedure GetIntVec(IntNo: Byte; var Vector: Pointer);
{ SetIntVec sets the address in the interrupt vector table for }
{ the specified interrupt. }
procedure SetIntVec(IntNo: Byte; Vector: Pointer);
{ FSearch searches for the file given by Path in the list of }
{ directories given by DirList. The directory paths in DirList }
{ must be separated by semicolons. The search always starts }
{ with the current directory of the current drive. The returned }
{ value is a concatenation of one of the directory paths and }
{ the file name, or an empty string if the file could not be }
{ located. }
function FSearch(Path: PathStr; DirList: String): PathStr;
{ FExpand expands the file name in Path into a fully qualified }
{ file name. The resulting name consists of a drive letter, a }
{ colon, a root relative directory path, and a file name. }
{ Embedded '.' and '..' directory references are removed. }
function FExpand(Path: PathStr): PathStr;
{ FSplit splits the file name specified by Path into its three }
{ components. Dir is set to the drive and directory path with }
{ any leading and trailing backslashes, Name is set to the file }
{ name, and Ext is set to the extension with a preceding dot. }
{ Each of the component strings may possibly be empty, if Path }
{ contains no such component. }
procedure FSplit(Path: PathStr; var Dir: DirStr;
var Name: NameStr; var Ext: ExtStr);
{ EnvCount returns the number of strings contained in the DOS }
{ environment. }
function EnvCount: Integer;
{ EnvStr returns a specified environment string. The returned }
{ string is of the form "VAR=VALUE". The index of the first }
{ string is one. If Index is less than one or greater than }
{ EnvCount, EnvStr returns an empty string. }
function EnvStr(Index: Integer): String;
{ GetEnv returns the value of a specified environment variable. }
{ The variable name can be in upper or lower case, but it must }
{ not include the '=' character. If the specified environment }
{ variable does not exist, GetEnv returns an empty string. }
function GetEnv(EnvVar: String): String;
{ SwapVectors swaps the contents of the SaveIntXX pointers in }
{ the System unit with the current contents of the interrupt }
{ vectors. SwapVectors is typically called just before and just }
{ after a call to Exec. This insures that the Exec'd process }
{ does not use any interrupt handlers installed by the current }
{ process, and vice versa. }
procedure SwapVectors;
{ Keep (or Terminate Stay Resident) terminates the program and }
{ makes it stay in memory. The entire program stays in memory, }
{ including data segment, stack segment, and heap. The ExitCode }
{ corresponds to the one passed to the Halt standard procedure. }
procedure Keep(ExitCode: Word);
{ Exec executes another program. The program is specified by }
{ the Path parameter, and the command line is specified by the }
{ CmdLine parameter. To execute a DOS internal command, run }
{ COMMAND.COM, e.g. "Exec('\COMMAND.COM','/C DIR *.PAS');". }
{ Note the /C in front of the command. Errors are reported in }
{ DosError. When compiling a program that uses Exec, be sure }
{ to specify a maximum heap size as there will otherwise not be }
{ enough memory. }
procedure Exec(Path: PathStr; ComLine: ComStr);
{ DosExitCode returns the exit code of a sub-process. The low }
{ byte is the code sent by the terminating process. The high }
{ byte is zero for normal termination, 1 if terminated by }
{ Ctrl-C, 2 if terminated due to a device error, or 3 if }
{ terminated by the Keep procedure (function call 31 hex). }
function DosExitCode: Word;

View File

@ -0,0 +1,240 @@
{*******************************************************}
{ }
{ Turbo Pascal Version 7.0 }
{ Turbo Vision Unit }
{ }
{ Copyright (c) 1991,92 Borland International }
{ }
{*******************************************************}
unit Drivers;
{$X+,I-,S-}
interface
uses Objects;
{ ******** EVENT MANAGER ******** }
const
{ Event codes }
evMouseDown = $0001;
evMouseUp = $0002;
evMouseMove = $0004;
evMouseAuto = $0008;
evKeyDown = $0010;
evCommand = $0100;
evBroadcast = $0200;
{ Event masks }
evNothing = $0000;
evMouse = $000F;
evKeyboard = $0010;
evMessage = $FF00;
{ Extended key codes }
kbEsc = $011B; kbAltSpace = $0200; kbCtrlIns = $0400;
kbShiftIns = $0500; kbCtrlDel = $0600; kbShiftDel = $0700;
kbBack = $0E08; kbCtrlBack = $0E7F; kbShiftTab = $0F00;
kbTab = $0F09; kbAltQ = $1000; kbAltW = $1100;
kbAltE = $1200; kbAltR = $1300; kbAltT = $1400;
kbAltY = $1500; kbAltU = $1600; kbAltI = $1700;
kbAltO = $1800; kbAltP = $1900; kbCtrlEnter = $1C0A;
kbEnter = $1C0D; kbAltA = $1E00; kbAltS = $1F00;
kbAltD = $2000; kbAltF = $2100; kbAltG = $2200;
kbAltH = $2300; kbAltJ = $2400; kbAltK = $2500;
kbAltL = $2600; kbAltZ = $2C00; kbAltX = $2D00;
kbAltC = $2E00; kbAltV = $2F00; kbAltB = $3000;
kbAltN = $3100; kbAltM = $3200; kbF1 = $3B00;
kbF2 = $3C00; kbF3 = $3D00; kbF4 = $3E00;
kbF5 = $3F00; kbF6 = $4000; kbF7 = $4100;
kbF8 = $4200; kbF9 = $4300; kbF10 = $4400;
kbHome = $4700; kbUp = $4800; kbPgUp = $4900;
kbGrayMinus = $4A2D; kbLeft = $4B00; kbRight = $4D00;
kbGrayPlus = $4E2B; kbEnd = $4F00; kbDown = $5000;
kbPgDn = $5100; kbIns = $5200; kbDel = $5300;
kbShiftF1 = $5400; kbShiftF2 = $5500; kbShiftF3 = $5600;
kbShiftF4 = $5700; kbShiftF5 = $5800; kbShiftF6 = $5900;
kbShiftF7 = $5A00; kbShiftF8 = $5B00; kbShiftF9 = $5C00;
kbShiftF10 = $5D00; kbCtrlF1 = $5E00; kbCtrlF2 = $5F00;
kbCtrlF3 = $6000; kbCtrlF4 = $6100; kbCtrlF5 = $6200;
kbCtrlF6 = $6300; kbCtrlF7 = $6400; kbCtrlF8 = $6500;
kbCtrlF9 = $6600; kbCtrlF10 = $6700; kbAltF1 = $6800;
kbAltF2 = $6900; kbAltF3 = $6A00; kbAltF4 = $6B00;
kbAltF5 = $6C00; kbAltF6 = $6D00; kbAltF7 = $6E00;
kbAltF8 = $6F00; kbAltF9 = $7000; kbAltF10 = $7100;
kbCtrlPrtSc = $7200; kbCtrlLeft = $7300; kbCtrlRight = $7400;
kbCtrlEnd = $7500; kbCtrlPgDn = $7600; kbCtrlHome = $7700;
kbAlt1 = $7800; kbAlt2 = $7900; kbAlt3 = $7A00;
kbAlt4 = $7B00; kbAlt5 = $7C00; kbAlt6 = $7D00;
kbAlt7 = $7E00; kbAlt8 = $7F00; kbAlt9 = $8000;
kbAlt0 = $8100; kbAltMinus = $8200; kbAltEqual = $8300;
kbCtrlPgUp = $8400; kbAltBack = $0800; kbNoKey = $0000;
{ Keyboard state and shift masks }
kbRightShift = $0001;
kbLeftShift = $0002;
kbCtrlShift = $0004;
kbAltShift = $0008;
kbScrollState = $0010;
kbNumState = $0020;
kbCapsState = $0040;
kbInsState = $0080;
{ Mouse button state masks }
mbLeftButton = $01;
mbRightButton = $02;
type
{ Event record }
PEvent = ^TEvent;
TEvent = record
What: Word;
case Word of
evNothing: ();
evMouse: (
Buttons: Byte;
Double: Boolean;
Where: TPoint);
evKeyDown: (
case Integer of
0: (KeyCode: Word);
1: (CharCode: Char;
ScanCode: Byte));
evMessage: (
Command: Word;
case Word of
0: (InfoPtr: Pointer);
1: (InfoLong: Longint);
2: (InfoWord: Word);
3: (InfoInt: Integer);
4: (InfoByte: Byte);
5: (InfoChar: Char));
end;
const
{ Initialized variables }
ButtonCount: Byte = 0;
MouseEvents: Boolean = False;
MouseReverse: Boolean = False;
DoubleDelay: Word = 8;
RepeatDelay: Word = 8;
var
{ Uninitialized variables }
MouseIntFlag: Byte;
MouseButtons: Byte;
MouseWhere: TPoint;
{ Event manager routines }
procedure InitEvents;
procedure DoneEvents;
procedure ShowMouse;
procedure HideMouse;
procedure GetMouseEvent(var Event: TEvent);
procedure GetKeyEvent(var Event: TEvent);
function GetShiftState: Byte;
{ ******** SCREEN MANAGER ******** }
const
{ Screen modes }
smBW80 = $0002;
smCO80 = $0003;
smMono = $0007;
smFont8x8 = $0100;
const
{ Initialized variables }
StartupMode: Word = $FFFF;
var
{ Uninitialized variables }
ScreenMode: Word;
ScreenWidth: Byte;
ScreenHeight: Byte;
HiResScreen: Boolean;
CheckSnow: Boolean;
ScreenBuffer: Pointer;
CursorLines: Word;
{ Screen manager routines }
procedure InitVideo;
procedure DoneVideo;
procedure SetVideoMode(Mode: Word);
procedure ClearScreen;
{ ******** SYSTEM ERROR HANDLER ******** }
type
{ System error handler function type }
TSysErrorFunc = function(ErrorCode: Integer; Drive: Byte): Integer;
{ Default system error handler routine }
function SystemError(ErrorCode: Integer; Drive: Byte): Integer;
const
{ Initialized variables }
SysErrorFunc: TSysErrorFunc = SystemError;
SysColorAttr: Word = $4E4F;
SysMonoAttr: Word = $7070;
CtrlBreakHit: Boolean = False;
SaveCtrlBreak: Boolean = False;
SysErrActive: Boolean = False;
{ System error handler routines }
procedure InitSysError;
procedure DoneSysError;
{ ******** UTILITY ROUTINES ******** }
{ Keyboard support routines }
function GetAltChar(KeyCode: Word): Char;
function GetAltCode(Ch: Char): Word;
function GetCtrlChar(KeyCode: Word): Char;
function GetCtrlCode(Ch: Char): Word;
function CtrlToArrow(KeyCode: Word): Word;
{ String routines }
procedure FormatStr(var Result: String; const Format: String; var Params);
procedure PrintStr(const S: String);
{ Buffer move routines }
procedure MoveBuf(var Dest; var Source; Attr: Byte; Count: Word);
procedure MoveChar(var Dest; C: Char; Attr: Byte; Count: Word);
procedure MoveCStr(var Dest; const Str: String; Attrs: Word);
procedure MoveStr(var Dest; const Str: String; Attr: Byte);
function CStrLen(const S: String): Integer;

View File

@ -0,0 +1,340 @@
{*******************************************************}
{ }
{ Turbo Pascal Version 7.0 }
{ Graph Interface Unit }
{ }
{ Copyright (C) 1987,92 Borland International }
{ }
{*******************************************************}
unit Graph;
interface
const
{ GraphResult error return codes: }
grOk = 0;
grNoInitGraph = -1;
grNotDetected = -2;
grFileNotFound = -3;
grInvalidDriver = -4;
grNoLoadMem = -5;
grNoScanMem = -6;
grNoFloodMem = -7;
grFontNotFound = -8;
grNoFontMem = -9;
grInvalidMode = -10;
grError = -11; { generic error }
grIOerror = -12;
grInvalidFont = -13;
grInvalidFontNum = -14;
grInvalidVersion = -18;
{ define graphics drivers }
CurrentDriver = -128; { passed to GetModeRange }
Detect = 0; { requests autodetection }
CGA = 1;
MCGA = 2;
EGA = 3;
EGA64 = 4;
EGAMono = 5;
IBM8514 = 6;
HercMono = 7;
ATT400 = 8;
VGA = 9;
PC3270 = 10;
{ graphics modes for each driver }
CGAC0 = 0; { 320x200 palette 0: LightGreen, LightRed, Yellow; 1 page }
CGAC1 = 1; { 320x200 palette 1: LightCyan, LightMagenta, White; 1 page }
CGAC2 = 2; { 320x200 palette 2: Green, Red, Brown; 1 page }
CGAC3 = 3; { 320x200 palette 3: Cyan, Magenta, LightGray; 1 page }
CGAHi = 4; { 640x200 1 page }
MCGAC0 = 0; { 320x200 palette 0: LightGreen, LightRed, Yellow; 1 page }
MCGAC1 = 1; { 320x200 palette 1: LightCyan, LightMagenta, White; 1 page }
MCGAC2 = 2; { 320x200 palette 2: Green, Red, Brown; 1 page }
MCGAC3 = 3; { 320x200 palette 3: Cyan, Magenta, LightGray; 1 page }
MCGAMed = 4; { 640x200 1 page }
MCGAHi = 5; { 640x480 1 page }
EGALo = 0; { 640x200 16 color 4 page }
EGAHi = 1; { 640x350 16 color 2 page }
EGA64Lo = 0; { 640x200 16 color 1 page }
EGA64Hi = 1; { 640x350 4 color 1 page }
EGAMonoHi = 3; { 640x350 64K on card, 1 page; 256K on card, 2 page }
HercMonoHi = 0; { 720x348 2 page }
ATT400C0 = 0; { 320x200 palette 0: LightGreen, LightRed, Yellow; 1 page }
ATT400C1 = 1; { 320x200 palette 1: LightCyan, LightMagenta, White; 1 page }
ATT400C2 = 2; { 320x200 palette 2: Green, Red, Brown; 1 page }
ATT400C3 = 3; { 320x200 palette 3: Cyan, Magenta, LightGray; 1 page }
ATT400Med = 4; { 640x200 1 page }
ATT400Hi = 5; { 640x400 1 page }
VGALo = 0; { 640x200 16 color 4 page }
VGAMed = 1; { 640x350 16 color 2 page }
VGAHi = 2; { 640x480 16 color 1 page }
PC3270Hi = 0; { 720x350 1 page }
IBM8514LO = 0; { 640x480 256 colors }
IBM8514HI = 1; { 1024x768 256 colors }
{ Colors for SetPalette and SetAllPalette: }
Black = 0;
Blue = 1;
Green = 2;
Cyan = 3;
Red = 4;
Magenta = 5;
Brown = 6;
LightGray = 7;
DarkGray = 8;
LightBlue = 9;
LightGreen = 10;
LightCyan = 11;
LightRed = 12;
LightMagenta = 13;
Yellow = 14;
White = 15;
{ colors for 8514 to set standard EGA colors w/o knowing their values }
EGABlack = 0; { dark colors }
EGABlue = 1;
EGAGreen = 2;
EGACyan = 3;
EGARed = 4;
EGAMagenta = 5;
EGABrown = 20;
EGALightgray = 7;
EGADarkgray = 56; { light colors }
EGALightblue = 57;
EGALightgreen = 58;
EGALightcyan = 59;
EGALightred = 60;
EGALightmagenta = 61;
EGAYellow = 62;
EGAWhite = 63;
{ Line styles and widths for Get/SetLineStyle: }
SolidLn = 0;
DottedLn = 1;
CenterLn = 2;
DashedLn = 3;
UserBitLn = 4; { User-defined line style }
NormWidth = 1;
ThickWidth = 3;
{ Set/GetTextStyle constants: }
DefaultFont = 0; { 8x8 bit mapped font }
TriplexFont = 1; { "Stroked" fonts }
SmallFont = 2;
SansSerifFont = 3;
GothicFont = 4;
HorizDir = 0; { left to right }
VertDir = 1; { bottom to top }
UserCharSize = 0; { user-defined char size }
{ Clipping constants: }
ClipOn = true;
ClipOff = false;
{ Bar3D constants: }
TopOn = true;
TopOff = false;
{ Fill patterns for Get/SetFillStyle: }
EmptyFill = 0; { fills area in background color }
SolidFill = 1; { fills area in solid fill color }
LineFill = 2; { --- fill }
LtSlashFill = 3; { /// fill }
SlashFill = 4; { /// fill with thick lines }
BkSlashFill = 5; { \\\ fill with thick lines }
LtBkSlashFill = 6; { \\\ fill }
HatchFill = 7; { light hatch fill }
XHatchFill = 8; { heavy cross hatch fill }
InterleaveFill = 9; { interleaving line fill }
WideDotFill = 10; { Widely spaced dot fill }
CloseDotFill = 11; { Closely spaced dot fill }
UserFill = 12; { user defined fill }
{ BitBlt operators for PutImage: }
NormalPut = 0; { MOV } { left for 1.0 compatibility }
CopyPut = 0; { MOV }
XORPut = 1; { XOR }
OrPut = 2; { OR }
AndPut = 3; { AND }
NotPut = 4; { NOT }
{ Horizontal and vertical justification for SetTextJustify: }
LeftText = 0;
CenterText = 1;
RightText = 2;
BottomText = 0;
{ CenterText = 1; already defined above }
TopText = 2;
const
MaxColors = 15;
type
PaletteType = record
Size : byte;
Colors : array[0..MaxColors] of shortint;
end;
LineSettingsType = record
LineStyle : word;
Pattern : word;
Thickness : word;
end;
TextSettingsType = record
Font : word;
Direction : word;
CharSize : word;
Horiz : word;
Vert : word;
end;
FillSettingsType = record { Pre-defined fill style }
Pattern : word;
Color : word;
end;
FillPatternType = array[1..8] of byte; { User defined fill style }
PointType = record
X, Y : integer;
end;
ViewPortType = record
x1, y1, x2, y2 : integer;
Clip : boolean;
end;
ArcCoordsType = record
X, Y : integer;
Xstart, Ystart : integer;
Xend, Yend : integer;
end;
var
GraphGetMemPtr : Pointer; { allows user to steal heap allocation }
GraphFreeMemPtr : Pointer; { allows user to steal heap de-allocation }
{ *** high-level error handling *** }
function GraphErrorMsg(ErrorCode : integer) : String;
function GraphResult : integer;
{ *** detection, initialization and crt mode routines *** }
procedure DetectGraph(var GraphDriver, GraphMode : integer);
function GetDriverName : string;
procedure InitGraph(var GraphDriver : integer;
var GraphMode : integer;
PathToDriver : String);
function RegisterBGIfont(Font : pointer) : integer;
function RegisterBGIdriver(Driver : pointer) : integer;
function InstallUserDriver(DriverFileName : string;
AutoDetectPtr : pointer) : integer;
function InstallUserFont(FontFileName : string) : integer;
procedure SetGraphBufSize(BufSize : word);
function GetMaxMode : integer;
procedure GetModeRange(GraphDriver : integer; var LoMode, HiMode : integer);
function GetModeName(GraphMode : integer) : string;
procedure SetGraphMode(Mode : integer);
function GetGraphMode : integer;
procedure GraphDefaults;
procedure RestoreCrtMode;
procedure CloseGraph;
function GetX : integer;
function GetY : integer;
function GetMaxX : integer;
function GetMaxY : integer;
{ *** Screen, viewport, page routines *** }
procedure ClearDevice;
procedure SetViewPort(x1, y1, x2, y2 : integer; Clip : boolean);
procedure GetViewSettings(var ViewPort : ViewPortType);
procedure ClearViewPort;
procedure SetVisualPage(Page : word);
procedure SetActivePage(Page : word);
{ *** point-oriented routines *** }
procedure PutPixel(X, Y : integer; Pixel : word);
function GetPixel(X, Y : integer) : word;
{ *** line-oriented routines *** }
procedure SetWriteMode(WriteMode : integer);
procedure LineTo(X, Y : integer);
procedure LineRel(Dx, Dy : integer);
procedure MoveTo(X, Y : integer);
procedure MoveRel(Dx, Dy : integer);
procedure Line(x1, y1, x2, y2 : integer);
procedure GetLineSettings(var LineInfo : LineSettingsType);
procedure SetLineStyle(LineStyle : word;
Pattern : word;
Thickness : word);
{ *** polygon, fills and figures *** }
procedure Rectangle(x1, y1, x2, y2 : integer);
procedure Bar(x1, y1, x2, y2 : integer);
procedure Bar3D(x1, y1, x2, y2 : integer; Depth : word; Top : boolean);
procedure DrawPoly(NumPoints : word; var PolyPoints);
procedure FillPoly(NumPoints : word; var PolyPoints);
procedure GetFillSettings(var FillInfo : FillSettingsType);
procedure GetFillPattern(var FillPattern : FillPatternType);
procedure SetFillStyle(Pattern : word; Color : word);
procedure SetFillPattern(Pattern : FillPatternType; Color : word);
procedure FloodFill(X, Y : integer; Border : word);
{ *** arc, circle, and other curves *** }
procedure Arc(X, Y : integer; StAngle, EndAngle, Radius : word);
procedure GetArcCoords(var ArcCoords : ArcCoordsType);
procedure Circle(X, Y : integer; Radius : word);
procedure Ellipse(X, Y : integer;
StAngle, EndAngle : word;
XRadius, YRadius : word);
procedure FillEllipse(X, Y : integer;
XRadius, YRadius : word);
procedure GetAspectRatio(var Xasp, Yasp : word);
procedure SetAspectRatio(Xasp, Yasp : word);
procedure PieSlice(X, Y : integer; StAngle, EndAngle, Radius : word);
procedure Sector(X, Y : Integer;
StAngle, EndAngle,
XRadius, YRadius : word);
{ *** color and palette routines *** }
procedure SetBkColor(ColorNum : word);
procedure SetColor(Color : word);
function GetBkColor : word;
function GetColor : word;
procedure SetAllPalette(var Palette);
procedure SetPalette(ColorNum : word; Color : shortint);
procedure GetPalette(var Palette : PaletteType);
function GetPaletteSize : integer;
procedure GetDefaultPalette(var Palette : PaletteType);
function GetMaxColor : word;
procedure SetRGBPalette(ColorNum, RedValue, GreenValue, BlueValue : integer);
{ *** bit-image routines *** }
function ImageSize(x1, y1, x2, y2 : integer) : word;
procedure GetImage(x1, y1, x2, y2 : integer; var BitMap);
procedure PutImage(X, Y : integer; var BitMap; BitBlt : word);
{ *** text routines *** }
procedure GetTextSettings(var TextInfo : TextSettingsType);
procedure OutText(TextString : string);
procedure OutTextXY(X, Y : integer; TextString : string);
procedure SetTextJustify(Horiz, Vert : word);
procedure SetTextStyle(Font, Direction : word; CharSize : word);
procedure SetUserCharSize(MultX, DivX, MultY, DivY : word);
function TextHeight(TextString : string) : word;
function TextWidth(TextString : string) : word;

View File

@ -0,0 +1,45 @@
{*******************************************************}
{ }
{ Turbo Pascal Version 7.0 }
{ Turbo Vision Unit }
{ }
{ Copyright (c) 1991,92 Borland International }
{ }
{*******************************************************}
unit HistList;
{$O+,F+,X+,I-,S-}
{****************************************************************************
History buffer structure:
Byte Byte String Byte Byte String
+-------------------------+-------------------------+--...--+
| 0 | Id | History string | 0 | Id | History string | |
+-------------------------+-------------------------+--...--+
***************************************************************************}
interface
uses Objects;
const
HistoryBlock: Pointer = nil;
HistorySize: Word = 1024;
HistoryUsed: Word = 0;
procedure HistoryAdd(Id: Byte; const Str: String);
function HistoryCount(Id: Byte): Word;
function HistoryStr(Id: Byte; Index: Integer): String;
procedure ClearHistory;
procedure InitHistory;
procedure DoneHistory;
procedure StoreHistory(var S: TStream);
procedure LoadHistory(var S: TStream);

View File

@ -0,0 +1,358 @@
Turbo Vision 2.0 Programming Guide
==================================
This file contains information on material added to Turbo Vision
2.0 after the Programming Guide had gone to press and also
corrections to a few errors in the manual. We strongly suggest
that you mark these corrections and changes in your manual for
future reference.
=============================================================
Changes and additions to Chapter 19, "Turbo Vision Reference"
=============================================================
=============================================================
CreateFindDialog function Editors
=============================================================
Declaration function CreateFindDialog: PDialog;
Function Constructs and returns a pointer to the
standard text search dialog box used by
StdEditorDialog. If you want to customize
the simpler editor dialog boxes but still
use the standard text search interface,
your editor dialog box function should
execute the dialog box returned by
CreateFindDialog for a Dialog parameter
of edFind.
See also EditorDialog variable, edXXXX constants,
StdEditorDialog function
=============================================================
CreateReplaceDialog function Editors
=============================================================
Declaration function CreateReplaceDialog: PDialog;
Function Constructs and returns a pointer to the
standard text search-and-replace dialog
box used by StdEditorDialog. If you want
to customize the simpler editor dialog
boxes but still use the standard text
search interface, your editor dialog box
function should execute the dialog box
returned by CreateReplaceDialog for a
Dialog parameter of edReplace.
See also EditorDialog variable, edXXXX constants,
StdEditorDialog function
=============================================================
FailSysErrors variable Drivers
=============================================================
Declaration FailSysErrors: Boolean = False;
If True, causes the system error handler
to behave as if the user had responded to
a system error message by pressing Esc.
Normally, the system error handler
displays a message on the last line of
the screen and waits for user input.
Setting FailSysErrors to True causes the
system error handler to bypass the
message and user prompt, and just return
as if the DOS call that produced the
error failed.
See also SysErrorFunc variable
=============================================================
GetCtrlChar function Drivers
=============================================================
Declaration function GetCtrlChar(KeyCode: Word):
Char;
Function Returns the character, Ch, for which
Ctrl+Ch produces the 2-byte scan code
given by the argument KeyCode. Gives the
reverse mapping to GetCtrlCode.
See also GetCtrlCode
=============================================================
GetCtrlCode function Drivers
=============================================================
Declaration function GetCtrlCode(Ch: Char): Word;
Function Returns the 2-byte scan code (keycode)
corresponding to Ctrl+Ch. This function
gives the reverse mapping to GetCtrlChar.
See also GetCtrlChar
=============================================================
GetShiftState function Drivers
=============================================================
Declaration function GetShiftState: Byte;
Function Returns a byte containing the current
Shift key state, as reported by DOS. The
return value contains a combination of
the kbXXXX constants for shift states.
You should call GetShiftState instead of
checking the ShiftState variable
directly. ShiftState is not guaranteed to
be valid in protected mode, but
GetShiftState returns the correct value
in either real or protected mode.
See also kbXXXX constants
=============================================================
RegisterMenus procedure Menus
=============================================================
Declaration procedure RegisterMenus;
Function Calls RegisterType for each of the object
types defined in the Menus unit:
TMenuBar, TMenuBox, TMenuPopup, and
TStatusLine. After calling RegisterMenus,
your application can read or write any of
those types with streams.
See also RegisterType procedure
=============================================================
RegisterViews procedure Views
=============================================================
Declaration procedure RegisterViews;
Function Calls RegisterType for each of the object
types defined in the Views unit: TView,
TFrame, TScrollBar, TScroller,
TListViewer, TGroup, and TWindow. After
calling RegisterViews, your application
can read or write any of those types with
streams.
See also RegisterType procedure
=============================================================
ShiftState variable Drivers
=============================================================
Although this variable exists to maintain
compatibility with version 1.0, you
should not check ShiftState directly.
Rather, you should call GetShiftState,
which returns a valid set of shift state
flags in either real or protected mode.
=============================================================
TDesktop App
=============================================================
TDesktop has two additional methods not
documented.
Methods =========================================
Load constructor Load(var S: TStream);
Constructs and loads a desktop object
from the stream S by first calling the
Load constructor inherited from TGroup,
then calling GetSubViewPtr to set up the
Background field, then reading the
TileColumnsFirst field.
See also: TGroup.Load,
TGroup.GetSubViewPtr
Store procedure Store(var S: TStream);
Writes the desktop object to the stream S
by first calling the Store method
inherited from TGroup, then calling
PutSubViewPtr to store the Background
field, then writing the value of
TileColumnsFirst.
See also: TGroup.Store,
TGroup.PutSubViewPtr
=============================================================
TMemoryStream Objects
=============================================================
TMemoryStream implements a stream in heap
memory.
The mechanics of using memory streams are
simple. You construct a memory stream,
specifying its initial size and a block
size. The memory stream allocates as many
blocks on the heap as needed to meet the
initial size. Bytes stored on the stream
are not guaranteed to be in contiguous
memory locations unless the stream
consists of a single block.
Once you construct the stream, you use it
like any other. Writing beyond the end of
the stream causes the stream to grow in
increments of the initial block size, up
to a maximum of 16,384 blocks.
Changing the size of a memory stream by
enlarging or truncating could seriously
fragment your heap. Try to set the
initial size and block size of the stream
to reasonable values to minimize
individual allocations.
Fields =========================================
BlockSize BlockSize: Integer;
The size of each block allocated to the
memory stream.
CurSeg CurSeg: Integer;
Holds the segment part of the address of
the block that contains the current
stream position.
Position Position: Longint;
The position of the stream in bytes. The
first position is 0.
SegCount SegCount: Integer;
The number of blocks currently allocated
to the memory stream.
SegList SegList: PWordArray;
Contains the list of segment parts used
by each allocated block. The entries
0..SegCount-1 contain valid segments.
Size Size: Longint;
The size of the stream in bytes.
Methods =========================================
Init constructor Init(ALimit: Longint;
ABlockSize: Word);
Constructs a memory stream object by
first calling the Init constructor
inherited from TStream, then allocates
enough blocks of size ABlockSize to
collectively contain ALimit bytes. Sets
BlockSize to ABlockSize.
See also: TStream.Init
Done destructor Done; virtual;
Disposes of the memory stream object by
disposing of the memory allocated to the
stream, then calling the Done destructor
inherited from TStream.
See also: TStream.Done
GetPos function GetPos: Longint; virtual;
Returns the stream's current position.
The first position is 0.
GetSize function GetSize: Longint; virtual;
Returns the size of the stream in bytes.
Read procedure Read(var Buf; Count: Word);
virtual;
Reads Count bytes from the stream,
starting at the current position, into
the buffer Buf.
Seek procedure Seek(Pos: Longint); virtual;
Sets the current position to Pos bytes
from the start of the stream. The first
position is 0.
Truncate procedure Truncate; virtual;
Deletes all data on the stream from the
current position to the end. Sets the
current position to the new end of the
stream.
Write procedure Write(var Buf; Count: Word);
virtual;
Writes Count bytes from the buffer Buf to
the stream, starting at the current
position.
=============================================================
TStringList Objects
=============================================================
In the example code in the Load
constructor description, TBufStream
should be PBufStream.
=============================================================
TStrListMaker Objects
=============================================================
In the example code in the description of
how to use the string list maker,
TBufStream should be PBufStream.

View File

@ -0,0 +1,38 @@
{*******************************************************}
{ }
{ Turbo Pascal Version 7.0 }
{ Turbo Vision Unit }
{ }
{ Copyright (c) 1991,92 Borland International }
{ }
{*******************************************************}
unit Memory;
{$O+,F+,X+,I-,S-}
interface
const
MaxHeapSize: Word = 655360 div 16; { 640K }
LowMemSize: Word = 4096 div 16; { 4K }
MaxBufMem: Word = 65536 div 16; { 64K }
procedure InitMemory;
procedure DoneMemory;
procedure InitDosMem;
procedure DoneDosMem;
function LowMemory: Boolean;
function MemAlloc(Size: Word): Pointer;
function MemAllocSeg(Size: Word): Pointer;
procedure NewCache(var P: Pointer; Size: Word);
procedure DisposeCache(P: Pointer);
procedure NewBuffer(var P: Pointer; Size: Word);
procedure DisposeBuffer(P: Pointer);
function GetBufferSize(P: Pointer): Word;
function SetBufferSize(P: Pointer; Size: Word): Boolean;
procedure GetBufMem(var P: Pointer; Size: Word);
procedure FreeBufMem(P: Pointer);
procedure SetMemTop(MemTop: Pointer);

View File

@ -0,0 +1,236 @@
{*******************************************************}
{ }
{ Turbo Pascal Version 7.0 }
{ Turbo Vision Unit }
{ }
{ Copyright (c) 1991,92 Borland International }
{ }
{*******************************************************}
unit Menus;
{$O+,F+,X+,I-,S-}
interface
uses Objects, Drivers, Views;
const
{ Color palettes }
CMenuView = #2#3#4#5#6#7;
CStatusLine = #2#3#4#5#6#7;
type
{ TMenu types }
TMenuStr = string[31];
PMenu = ^TMenu;
PMenuItem = ^TMenuItem;
TMenuItem = record
Next: PMenuItem;
Name: PString;
Command: Word;
Disabled: Boolean;
KeyCode: Word;
HelpCtx: Word;
case Integer of
0: (Param: PString);
1: (SubMenu: PMenu);
end;
TMenu = record
Items: PMenuItem;
Default: PMenuItem;
end;
{ TMenuView object }
{ Palette layout }
{ 1 = Normal text }
{ 2 = Disabled text }
{ 3 = Shortcut text }
{ 4 = Normal selection }
{ 5 = Disabled selection }
{ 6 = Shortcut selection }
PMenuView = ^TMenuView;
TMenuView = object(TView)
ParentMenu: PMenuView;
Menu: PMenu;
Current: PMenuItem;
constructor Init(var Bounds: TRect);
constructor Load(var S: TStream);
function Execute: Word; virtual;
function FindItem(Ch: Char): PMenuItem;
procedure GetItemRect(Item: PMenuItem; var R: TRect); virtual;
function GetHelpCtx: Word; virtual;
function GetPalette: PPalette; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
function HotKey(KeyCode: Word): PMenuItem;
function NewSubView(var Bounds: TRect; AMenu: PMenu;
AParentMenu: PMenuView): PMenuView; virtual;
procedure Store(var S: TStream);
end;
{ TMenuBar object }
{ Palette layout }
{ 1 = Normal text }
{ 2 = Disabled text }
{ 3 = Shortcut text }
{ 4 = Normal selection }
{ 5 = Disabled selection }
{ 6 = Shortcut selection }
PMenuBar = ^TMenuBar;
TMenuBar = object(TMenuView)
constructor Init(var Bounds: TRect; AMenu: PMenu);
destructor Done; virtual;
procedure Draw; virtual;
procedure GetItemRect(Item: PMenuItem; var R: TRect); virtual;
end;
{ TMenuBox object }
{ Palette layout }
{ 1 = Normal text }
{ 2 = Disabled text }
{ 3 = Shortcut text }
{ 4 = Normal selection }
{ 5 = Disabled selection }
{ 6 = Shortcut selection }
PMenuBox = ^TMenuBox;
TMenuBox = object(TMenuView)
constructor Init(var Bounds: TRect; AMenu: PMenu;
AParentMenu: PMenuView);
procedure Draw; virtual;
procedure GetItemRect(Item: PMenuItem; var R: TRect); virtual;
end;
{ TMenuPopup object }
{ Palette layout }
{ 1 = Normal text }
{ 2 = Disabled text }
{ 3 = Shortcut text }
{ 4 = Normal selection }
{ 5 = Disabled selection }
{ 6 = Shortcut selection }
PMenuPopup = ^TMenuPopup;
TMenuPopup = object(TMenuBox)
constructor Init(var Bounds: TRect; AMenu: PMenu);
procedure HandleEvent(var Event: TEvent); virtual;
end;
{ TStatusItem }
PStatusItem = ^TStatusItem;
TStatusItem = record
Next: PStatusItem;
Text: PString;
KeyCode: Word;
Command: Word;
end;
{ TStatusDef }
PStatusDef = ^TStatusDef;
TStatusDef = record
Next: PStatusDef;
Min, Max: Word;
Items: PStatusItem;
end;
{ TStatusLine }
{ Palette layout }
{ 1 = Normal text }
{ 2 = Disabled text }
{ 3 = Shortcut text }
{ 4 = Normal selection }
{ 5 = Disabled selection }
{ 6 = Shortcut selection }
PStatusLine = ^TStatusLine;
TStatusLine = object(TView)
Items: PStatusItem;
Defs: PStatusDef;
constructor Init(var Bounds: TRect; ADefs: PStatusDef);
constructor Load(var S: TStream);
destructor Done; virtual;
procedure Draw; virtual;
function GetPalette: PPalette; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
function Hint(AHelpCtx: Word): String; virtual;
procedure Store(var S: TStream);
procedure Update; virtual;
end;
{ TMenuItem routines }
function NewItem(Name, Param: TMenuStr; KeyCode: Word; Command: Word;
AHelpCtx: Word; Next: PMenuItem): PMenuItem;
function NewLine(Next: PMenuItem): PMenuItem;
function NewSubMenu(Name: TMenuStr; AHelpCtx: Word; SubMenu: PMenu;
Next: PMenuItem): PMenuItem;
{ TMenu routines }
function NewMenu(Items: PMenuItem): PMenu;
procedure DisposeMenu(Menu: PMenu);
{ TStatusLine routines }
function NewStatusDef(AMin, AMax: Word; AItems: PStatusItem;
ANext: PStatusDef): PStatusDef;
function NewStatusKey(const AText: String; AKeyCode: Word; ACommand: Word;
ANext: PStatusItem): PStatusItem;
{ Menus registration procedure }
procedure RegisterMenus;
{ Stream registration records }
const
RMenuBar: TStreamRec = (
ObjType: 40;
VmtLink: Ofs(TypeOf(TMenuBar)^);
Load: @TMenuBar.Load;
Store: @TMenuBar.Store
);
const
RMenuBox: TStreamRec = (
ObjType: 41;
VmtLink: Ofs(TypeOf(TMenuBox)^);
Load: @TMenuBox.Load;
Store: @TMenuBox.Store
);
const
RStatusLine: TStreamRec = (
ObjType: 42;
VmtLink: Ofs(TypeOf(TStatusLine)^);
Load: @TStatusLine.Load;
Store: @TStatusLine.Store
);
const
RMenuPopup: TStreamRec = (
ObjType: 43;
VmtLink: Ofs(TypeOf(TMenuPopup)^);
Load: @TMenuPopup.Load;
Store: @TMenuPopup.Store
);

View File

@ -0,0 +1,383 @@
{*******************************************************}
{ }
{ Turbo Pascal Version 7.0 }
{ Standard Objects Unit }
{ }
{ Copyright (c) 1991,92 Borland International }
{ }
{*******************************************************}
unit Objects;
{$O+,F+,X+,I-,S-}
interface
const
{ TStream access modes }
stCreate = $3C00; { Create new file }
stOpenRead = $3D00; { Read access only }
stOpenWrite = $3D01; { Write access only }
stOpen = $3D02; { Read and write access }
{ TStream error codes }
stOk = 0; { No error }
stError = -1; { Access error }
stInitError = -2; { Cannot initialize stream }
stReadError = -3; { Read beyond end of stream }
stWriteError = -4; { Cannot expand stream }
stGetError = -5; { Get of unregistered object type }
stPutError = -6; { Put of unregistered object type }
{ Maximum TCollection size }
MaxCollectionSize = 65520 div SizeOf(Pointer);
{ TCollection error codes }
coIndexError = -1; { Index out of range }
coOverflow = -2; { Overflow }
{ VMT header size }
vmtHeaderSize = 8;
type
{ Type conversion records }
WordRec = record
Lo, Hi: Byte;
end;
LongRec = record
Lo, Hi: Word;
end;
PtrRec = record
Ofs, Seg: Word;
end;
{ String pointers }
PString = ^String;
{ Character set type }
PCharSet = ^TCharSet;
TCharSet = set of Char;
{ General arrays }
PByteArray = ^TByteArray;
TByteArray = array[0..32767] of Byte;
PWordArray = ^TWordArray;
TWordArray = array[0..16383] of Word;
{ TObject base object }
PObject = ^TObject;
TObject = object
constructor Init;
procedure Free;
destructor Done; virtual;
end;
{ TStreamRec }
PStreamRec = ^TStreamRec;
TStreamRec = record
ObjType: Word;
VmtLink: Word;
Load: Pointer;
Store: Pointer;
Next: Word;
end;
{ TStream }
PStream = ^TStream;
TStream = object(TObject)
Status: Integer;
ErrorInfo: Integer;
procedure CopyFrom(var S: TStream; Count: Longint);
procedure Error(Code, Info: Integer); virtual;
procedure Flush; virtual;
function Get: PObject;
function GetPos: Longint; virtual;
function GetSize: Longint; virtual;
procedure Put(P: PObject);
procedure Read(var Buf; Count: Word); virtual;
function ReadStr: PString;
procedure Reset;
procedure Seek(Pos: Longint); virtual;
procedure Truncate; virtual;
procedure Write(var Buf; Count: Word); virtual;
procedure WriteStr(P: PString);
end;
{ DOS file name string }
FNameStr = string[79];
{ TDosStream }
PDosStream = ^TDosStream;
TDosStream = object(TStream)
Handle: Word;
constructor Init(FileName: FNameStr; Mode: Word);
destructor Done; virtual;
function GetPos: Longint; virtual;
function GetSize: Longint; virtual;
procedure Read(var Buf; Count: Word); virtual;
procedure Seek(Pos: Longint); virtual;
procedure Truncate; virtual;
procedure Write(var Buf; Count: Word); virtual;
end;
{ TBufStream }
PBufStream = ^TBufStream;
TBufStream = object(TDosStream)
Buffer: Pointer;
BufSize: Word;
BufPtr: Word;
BufEnd: Word;
constructor Init(FileName: FNameStr; Mode, Size: Word);
destructor Done; virtual;
procedure Flush; virtual;
function GetPos: Longint; virtual;
function GetSize: Longint; virtual;
procedure Read(var Buf; Count: Word); virtual;
procedure Seek(Pos: Longint); virtual;
procedure Truncate; virtual;
procedure Write(var Buf; Count: Word); virtual;
end;
{ TEmsStream }
PEmsStream = ^TEmsStream;
TEmsStream = object(TStream)
Handle: Word;
PageCount: Word;
Size: Longint;
Position: Longint;
constructor Init(MinSize, MaxSize: Longint);
destructor Done; virtual;
function GetPos: Longint; virtual;
function GetSize: Longint; virtual;
procedure Read(var Buf; Count: Word); virtual;
procedure Seek(Pos: Longint); virtual;
procedure Truncate; virtual;
procedure Write(var Buf; Count: Word); virtual;
end;
{ TCollection types }
PItemList = ^TItemList;
TItemList = array[0..MaxCollectionSize - 1] of Pointer;
{ TCollection object }
PCollection = ^TCollection;
TCollection = object(TObject)
Items: PItemList;
Count: Integer;
Limit: Integer;
Delta: Integer;
constructor Init(ALimit, ADelta: Integer);
constructor Load(var S: TStream);
destructor Done; virtual;
function At(Index: Integer): Pointer;
procedure AtDelete(Index: Integer);
procedure AtFree(Index: Integer);
procedure AtInsert(Index: Integer; Item: Pointer);
procedure AtPut(Index: Integer; Item: Pointer);
procedure Delete(Item: Pointer);
procedure DeleteAll;
procedure Error(Code, Info: Integer); virtual;
function FirstThat(Test: Pointer): Pointer;
procedure ForEach(Action: Pointer);
procedure Free(Item: Pointer);
procedure FreeAll;
procedure FreeItem(Item: Pointer); virtual;
function GetItem(var S: TStream): Pointer; virtual;
function IndexOf(Item: Pointer): Integer; virtual;
procedure Insert(Item: Pointer); virtual;
function LastThat(Test: Pointer): Pointer;
procedure Pack;
procedure PutItem(var S: TStream; Item: Pointer); virtual;
procedure SetLimit(ALimit: Integer); virtual;
procedure Store(var S: TStream);
end;
{ TSortedCollection object }
PSortedCollection = ^TSortedCollection;
TSortedCollection = object(TCollection)
Duplicates: Boolean;
constructor Load(var S: TStream);
function Compare(Key1, Key2: Pointer): Integer; virtual;
function IndexOf(Item: Pointer): Integer; virtual;
procedure Insert(Item: Pointer); virtual;
function KeyOf(Item: Pointer): Pointer; virtual;
function Search(Key: Pointer; var Index: Integer): Boolean; virtual;
procedure Store(var S: TStream);
end;
{ TStringCollection object }
PStringCollection = ^TStringCollection;
TStringCollection = object(TSortedCollection)
function Compare(Key1, Key2: Pointer): Integer; virtual;
procedure FreeItem(Item: Pointer); virtual;
function GetItem(var S: TStream): Pointer; virtual;
procedure PutItem(var S: TStream; Item: Pointer); virtual;
end;
{ TResourceCollection object }
PResourceCollection = ^TResourceCollection;
TResourceCollection = object(TStringCollection)
procedure FreeItem(Item: Pointer); virtual;
function GetItem(var S: TStream): Pointer; virtual;
function KeyOf(Item: Pointer): Pointer; virtual;
procedure PutItem(var S: TStream; Item: Pointer); virtual;
end;
{ TResourceFile object }
PResourceFile = ^TResourceFile;
TResourceFile = object(TObject)
Stream: PStream;
Modified: Boolean;
constructor Init(AStream: PStream);
destructor Done; virtual;
function Count: Integer;
procedure Delete(Key: String);
procedure Flush;
function Get(Key: String): PObject;
function KeyAt(I: Integer): String;
procedure Put(Item: PObject; Key: String);
function SwitchTo(AStream: PStream; Pack: Boolean): PStream;
end;
{ TStringList object }
TStrIndexRec = record
Key, Count, Offset: Word;
end;
PStrIndex = ^TStrIndex;
TStrIndex = array[0..9999] of TStrIndexRec;
PStringList = ^TStringList;
TStringList = object(TObject)
constructor Load(var S: TStream);
destructor Done; virtual;
function Get(Key: Word): String;
end;
{ TStrListMaker object }
PStrListMaker = ^TStrListMaker;
TStrListMaker = object(TObject)
constructor Init(AStrSize, AIndexSize: Word);
destructor Done; virtual;
procedure Put(Key: Word; S: String);
procedure Store(var S: TStream);
end;
{ TPoint object }
TPoint = object
X, Y: Integer;
end;
{ Rectangle object }
TRect = object
A, B: TPoint;
procedure Assign(XA, YA, XB, YB: Integer);
procedure Copy(R: TRect);
procedure Move(ADX, ADY: Integer);
procedure Grow(ADX, ADY: Integer);
procedure Intersect(R: TRect);
procedure Union(R: TRect);
function Contains(P: TPoint): Boolean;
function Equals(R: TRect): Boolean;
function Empty: Boolean;
end;
{ Dynamic string handling routines }
function NewStr(const S: String): PString;
procedure DisposeStr(P: PString);
{ Longint routines }
function LongMul(X, Y: Integer): Longint;
inline($5A/$58/$F7/$EA);
function LongDiv(X: Longint; Y: Integer): Integer;
inline($59/$58/$5A/$F7/$F9);
{ Stream routines }
procedure RegisterType(var S: TStreamRec);
{ Abstract notification procedure }
procedure Abstract;
{ Objects registration procedure }
procedure RegisterObjects;
const
{ Stream error procedure }
StreamError: Pointer = nil;
{ EMS stream state variables }
EmsCurHandle: Word = $FFFF;
EmsCurPage: Word = $FFFF;
{ Stream registration records }
const
RCollection: TStreamRec = (
ObjType: 50;
VmtLink: Ofs(TypeOf(TCollection)^);
Load: @TCollection.Load;
Store: @TCollection.Store);
const
RStringCollection: TStreamRec = (
ObjType: 51;
VmtLink: Ofs(TypeOf(TStringCollection)^);
Load: @TStringCollection.Load;
Store: @TStringCollection.Store);
const
RStringList: TStreamRec = (
ObjType: 52;
VmtLink: Ofs(TypeOf(TStringList)^);
Load: @TStringList.Load;
Store: nil);
const
RStrListMaker: TStreamRec = (
ObjType: 52;
VmtLink: Ofs(TypeOf(TStrListMaker)^);
Load: nil;
Store: @TStrListMaker.Store);

View File

@ -0,0 +1,47 @@
{*******************************************************}
{ }
{ Turbo Pascal Version 7.0 }
{ Overlay Interface Unit }
{ }
{ Copyright (C) 1988,92 Borland International }
{ }
{*******************************************************}
unit Overlay;
{$D-,I-,S-}
interface
const
ovrOk = 0;
ovrError = -1;
ovrNotFound = -2;
ovrNoMemory = -3;
ovrIOError = -4;
ovrNoEMSDriver = -5;
ovrNoEMSMemory = -6;
const
OvrResult: Integer = 0;
OvrEmsPages: Word = 0;
OvrTrapCount: Word = 0;
OvrLoadCount: Word = 0;
OvrFileMode: Byte = 0;
type
OvrReadFunc = function(OvrSeg: Word): Integer;
var
OvrReadBuf: OvrReadFunc;
procedure OvrInit(FileName: String);
procedure OvrInitEMS;
procedure OvrSetBuf(Size: LongInt);
function OvrGetBuf: LongInt;
procedure OvrSetRetry(Size: LongInt);
function OvrGetRetry: LongInt;
procedure OvrClearBuf;

View File

@ -0,0 +1,19 @@
{*******************************************************}
{ }
{ Turbo Pascal Version 7.0 }
{ Printer Interface Unit }
{ }
{ Copyright (C) 1988,92 Borland International }
{ }
{*******************************************************}
unit Printer;
{$D-,I-,S-}
interface
var
Lst: Text;

View File

@ -0,0 +1,67 @@
{*******************************************************}
{ }
{ Turbo Pascal Version 7.0 }
{ System Unit }
{ }
{ Copyright (C) 1988,92 Borland International }
{ }
{*******************************************************}
unit System;
interface
const
OvrCodeList: Word = 0; { Overlay code segment list }
OvrHeapSize: Word = 0; { Initial overlay buffer size }
OvrDebugPtr: Pointer = nil; { Overlay debugger hook }
OvrHeapOrg: Word = 0; { Overlay buffer origin }
OvrHeapPtr: Word = 0; { Overlay buffer pointer }
OvrHeapEnd: Word = 0; { Overlay buffer end }
OvrLoadList: Word = 0; { Loaded overlays list }
OvrDosHandle: Word = 0; { Overlay DOS handle }
OvrEmsHandle: Word = $FFFF; { Overlay EMS handle }
HeapOrg: Pointer = nil; { Heap origin }
HeapPtr: Pointer = nil; { Heap pointer }
HeapEnd: Pointer = nil; { Heap end }
FreeList: Pointer = nil; { Free list pointer }
FreeZero: Pointer = nil; { Must be zero }
HeapError: Pointer = nil; { Heap error function }
ExitProc: Pointer = nil; { Exit procedure }
ExitCode: Integer = 0; { Exit code }
ErrorAddr: Pointer = nil; { Runtime error address }
PrefixSeg: Word = 0; { Program segment prefix }
StackLimit: Word = 0; { Stack pointer low limit }
InOutRes: Integer = 0; { I/O result buffer }
RandSeed: Longint = 0; { Random seed }
FileMode: Byte = 2; { File open mode }
Test8087: Byte = 0; { 8087 test result }
var
Input: Text; { Input standard file }
Output: Text; { Output standard file }
SaveInt00: Pointer; { Saved interrupt $00 }
SaveInt02: Pointer; { Saved interrupt $02 }
SaveInt09: Pointer; { Saved interrupt $09 }
SaveInt1B: Pointer; { Saved interrupt $1B }
SaveInt21: Pointer; { Saved interrupt $21 }
SaveInt23: Pointer; { Saved interrupt $23 }
SaveInt24: Pointer; { Saved interrupt $24 }
SaveInt34: Pointer; { Saved interrupt $34 }
SaveInt35: Pointer; { Saved interrupt $35 }
SaveInt36: Pointer; { Saved interrupt $36 }
SaveInt37: Pointer; { Saved interrupt $37 }
SaveInt38: Pointer; { Saved interrupt $38 }
SaveInt39: Pointer; { Saved interrupt $39 }
SaveInt3A: Pointer; { Saved interrupt $3A }
SaveInt3B: Pointer; { Saved interrupt $3B }
SaveInt3C: Pointer; { Saved interrupt $3C }
SaveInt3D: Pointer; { Saved interrupt $3D }
SaveInt3E: Pointer; { Saved interrupt $3E }
SaveInt3F: Pointer; { Saved interrupt $3F }
SaveInt75: Pointer; { Saved interrupt $75 }
implementation

View File

@ -0,0 +1,702 @@
===========================================================================
===========================================================================
TEMC.DOC
===========================================================================
Turbo Editor macros
===========================================================================
TEMC.EXE is an editor macro compiler for the IDE. It
processes a script file that defines editor macros and
key bindings, and produces a configuration file that is
read by the IDE to define the effects of keyboard
commands in the editor.
The file DEFAULTS.TEM contains the default macro
definitions and key bindings built into the IDE editor.
It serves as an example script, as well as a base from
which to customize the editor. Several other .TEM files
are also provided for your convenience.
===========================================================================
TEMC command line
===========================================================================
TEMC is invoked from the DOS command line. Type
temc [-c] <script file>[.TEM] <config file><.TP>
The script file extension is assumed to be .TEM if not
otherwise specified. The configuration file extension
must be .TP.
TEMC requires that you have an existing .TP file, which
will be used to store the new key bindings from your
script. You must specify the name of your .TP file
when invoking TEMC.
The optional -c switch can also be specified as /c, and
can appear in any argument position on the command
line. If you use this option, any existing command
table in your configuration file is thrown away before
TEMC processes the script file. When -c is not used,
the key bindings in the script file are merged with
those already defined in the configuration file.
You can use DEFAULTS.TEM to re-create exactly the
default settings of the editor command set. This
file is included as both a sample script file and as
the default command table. You can copy it and modify
it for your own use.
===========================================================================
Syntax
===========================================================================
The syntax to define a macro is
MACRO <macroname>
<command1>;
[ <command2>; ... ]
END;
<macroname> can consist of anything that is a legal C
symbol, and <command> can be either the name of another
predefined macro or a predefined TEMC editor command. A
list of editor commands and what they do follows.
When you define your macro, the following points are
valid:
1. A statement defines either a named macro or a key
binding.
2. Spaces and new lines are optional.
3. Comments are in C-style /* ... */ pairs.
4. Unlike C, TEMC's language is case insensitive.
5. Some of the predefined editor commands have a syntax
that looks like a C function call with one argument.
For example,
SetMark(5);
Depending on the command, the argument is either a
decimal integer constant, a character constant, or a
string literal. All are specified using C syntax.
Here's an example of a macro definition from
DEFAULTS.TEM:
MACRO MacScrollUp
ScrollScreenUp; FixCursorPos;
END;
The syntax to define a key binding is
<key-sequence>: <command>;
or
<key-sequence>: BEGIN <command1>; [ <command2>; ... ]
END;
The <key-sequence> is either a key (a character
optionally preceded by Ctrl or Alt), or a series of
keys separated by a plus sign (+). Note that the
specification of the key characters themselves is case
sensitive. For example, Ctrl+k B is different than
Ctrl+k b, even though the latter is the same as Ctrl+K b.
White space is allowed between the key-sequence and the
colon, and each <command> can be either the name of a
previously defined macro, or one of the predefined
editor commands listed in Table 1.1.
===========================================================================
Key codes
===========================================================================
The IDE editor makes use of an extended character set
that includes key combinations not normally available
to DOS programs. Key codes can be specified in a script
through any combination of the symbols "Ctrl+", "Shift+",
"Alt+" and a character.
Some keys cannot be entered directly into a TEMC
script. Those keys can be referred to by their names,
as described in the following table.
Any key in a sequence--except the first key--can be
preceded by one of the characters ^ or @. The caret (^)
indicates that any combination of case and "Ctrl" can
be used to type the key; that is, lowercase, uppercase,
or control characters. The @ sign is used to indicate
that case is insignificant for the following character,
although "Ctrl" is not accepted. For example,
* Ctrl+k b specifies a Ctrl+K followed by a lowercase b.
* Ctrl+k ^b specifies a Ctrl+K followed by any of b, B,
or Ctrl+B.
* Ctrl+k @B specifies Ctrl+K followed by either b or B.
Named keys
Key are specified as letters, numbers, or characters,
optionally preceded by one or more of Ctrl+, Alt+ or
Shift+. The following names specify keys that cannot be
typed as themselves in the TEMC syntax.
-------------------------------------------------------
Key name Notes
-------------------------------------------------------
Home
End
PgUp
PgDn
LfAr Left arrow
RgAr Right arrow
UpAr Up arrow
DnAr Down arrow
Ins
Del
Enter
Return Same as Enter
BkSp Backspace
Tab
BkTab No longer available, use Shift+Tab
Esc
Star * key on the numeric keypad
Minus - key on the numeric keypad
Plus + key on the numeric keypad
Space Spacebar
PrtSc
F1 to F10 Function keys
===========================================================================
Predefined editor commands
===========================================================================
TEMC lets you use built-in editor commands and user-
defined macros as commands within macros interchangeably
as long as you don't create any loops by having two
macros calling each other, even via intermediate macros.
Note that some commands cause an escape from the editor
to the surrounding IDE, for example, by bringing up a
dialog box. Your macro will "pause" until control returns
to the editor.
A list of all predefined TEMC editor commands is shown
next. Commands that cause an escape from the editor
follow.
TEMC editor commands
-------------------------------------------------------
Command name What the editor does
-------------------------------------------------------
BackspaceDelete Deletes character before
the cursor.
BottomOfScreen Moves cursor to the bottom
line of the current window,
leaving column unchanged.
CenterFixScreenPos Adjusts the screen display
to ensure the cursor is
visible. If any adjustment
is necessary, adjust the
display so the cursor is
close to being centered in
the window.
CopyBlock If there is a valid and
highlighted (selected)
text block, then at the
cursor location, inserts a
copy of the characters that
are selected and makes that
the new selected text
location.
CursorCharLeft Moves cursor left over one
character. This command
will skip over tab
characters and move to the
end of the previous line.
CursorCharRight Moves cursor right over one
character. This command
will skip over tab
characters and advance to
the beginning of the next
line.
CursorDown Moves cursor down one row.
CursorLeft Moves cursor left one
screen column.
CursorRight Moves cursor right one
screen column.
CursorSwitchedLeft Like CursorLeft, but pays
attention to cursor through
tab option setting (see
SetCursorThroughTabMode).
CursorSwitchedRight Like CursorRight, but pays
attention to cursor
through tab option setting
(see SetCursorThroughTabMode).
CursorUp Moves cursor up one row.
DeleteBlock If there is a valid and
highlighted (selected) text
block, deletes the
characters that are in it.
DeleteChar Deletes the character at
the current cursor
location.
DeleteLine Deletes the current line.
DeleteToEOL Deletes all characters in
the current line, leaving a
zero-length line.
DeleteWord Deletes from cursor to
beginning of next word.
EndCursor Moves cursor to end of file
buffer.
ExtendBlockBeg Initiates a series of
commands that will select a
block of text between the
initial and ending
positions of the cursor.
ExtendBlockEnd Ends a series of commands
begun by ExtendBlockBeg.
FixCursorPos Ensures that the cursor
value specifies a row
between 1 and the number of
lines in the buffer, a
column greater than 0. If
the cursor through tab
option is not set, the
cursor is not placed in the
middle of a tab character
(see SetCursorThroughTabMode).
FixScreenPos Adjusts the screen display
to ensure the cursor is
visible.
FullPaintScreen Redraws the entire window,
making no assumptions about
what is onscreen.
HideBlock Sets a flag indicating that
the selected text should
not be highlighted.
HighlightBlock Sets a flag indicating that
if the beginning and end
selected text markers are
valid, the selected text
should be highlighted.
HomeCursor Moves cursor to beginning
of the file buffer.
IndentBlock Inserts a space at the
beginning of each line in
the highlighted (selected)
text.
InsertText Inserts the literal
"string" in the buffer at
the current cursor
location. Use the syntax
InsertText(string) to call
this command.
LeftOfLine Moves cursor to beginning
of the current line.
LiteralChar Inserts the character at
the current cursor
location, without doing any
special processing for
newline, tab characters,
etc. Use the syntax
LiteralChar(c), where c is
a character or integer
value.
MarkBufModified Sets a flag indicating that
the contents of the buffer
are different than what is
in the corresponding disk
file.
MarkBufUnModified Clears a flag, thus
indicating that the
contents of the buffer can
be assumed to be identical
to what is in the disk
file.
MatchPairBackward Same as MatchPairForward
except if the cursor is on
a ' or ", searches backward
for the matching character.
MatchPairForward If the cursor is on one of
the characters (, ), {, },
[, ], or on the first
character of one of the
pairs /* or */, searches in
the appropriate direction
for the closest instance of
the matching delimiter. If
the cursor is on the
character ' or ", searches
forward for the matching
character. If a match is
found, places the cursor
there.
MoveBlock Like CopyBlock, but also
deletes the original
selected text.
MoveToBlockBeg Moves cursor to the
location marked as the
beginning of the selected
text.
MoveToBlockEnd Moves cursor to the
location marked as the end
of the selected text.
MoveToMark Moves the cursor to the
location saved with
SetMark(n) command. Use the
syntax MoveToMark(n), where
n is a one-digit number, 0-9.
MoveToPrevPos Moves the cursor to the
location specified by the
"previous position marker."
MoveToTempPos Moves the cursor to the
saved temporary marker.
NullCmd No operation. Calls the
editor, but performs no
function. Can be used to
cause a keystroke to have
no effect.
OutdentBlock Deletes a leading space, if
any, from the beginning of
each line in the
highlighted (selected)
text.
PageDown Moves cursor down by number
of lines in the window.
PageScreenDown Scrolls screen down by
numer of lines in the
window, leaving cursor
position unchanged.
PageScreenUp Scrolls screen up by numer
of lines in the window,
leaving cursor position
unchanged.
PageUp Moves cursor up by number
of lines in the window.
PaintScreen Redraws the entire window,
assuming that the screen
still correctly displays
what the editor last drew
on it.
ReDo Performs an Redo operation.
Exactly what happens
depends on the option
settings.
RightOfLine Moves cursor to end of
current line.
RightOfWord Moves cursor to the next
column that follows the end
of a word.
ScrollScreenDown Scrolls screen down one
line, leaving cursor
position unchanged.
ScrollScreenUp Scrolls screen up one line,
leaving cursor position
unchanged.
SetAutoIndent Sets the Auto Indent option
On.
SetAutoOutdent Sets the Backspace
Unindents option On.
SetBlockBeg Sets the beginning of the
selected text to be the
character at the current
cursor location.
SetBlockEnd Sets the end of the
selected text to be the
character at the current
cursor location.
SetCursorThroughTabMode Sets the Cursor Through
Tabs option On.
SetInsertMode Sets Insert/Overwrite
option to Insert.
SetMark Sets a marker to point to
the character at the
current cursor location, so
a later MoveToMark(n)
command can restore the
cursor. Use the syntax
SetMark(n), where n is a
one digit number, 0-9.
SetOptimalFillMode Sets Optimal Fill option On.
SetPrevPos Sets a marker (the previous
position marker) to point
to the character at the
current cursor location.
This marker location
changes only by a call to
SetPrevPos or SwapPrevPos.
SetTabbingMode Sets Use Tab Char option On.
SetTempPos Saves the cursor location
in a temporary marker that
can be used by some
internal editor commands.
This is not a practical
application in user-defined
macros. Use SetMark instead.
SmartRefreshScreen Redraws the window,
skipping any portions that
the editor is sure are
unmodified since the last
redraw.
SmartTab Inserts space or tab
characters in accordance
with the current settings
of the Use Tab Char option,
Tab Width.
SwapPrevPos Exchanges the values of the
cursor and the "previous
position marker."
ToggleAutoIndent Toggles the state of the
Auto Indent option.
ToggleAutoOutdent Toggles the state of the
Backspace Unindents option.
ToggleCursorThroughTabMode Toggles the state of the
Cursor Through Tabs option.
ToggleHideBlock Toggles the state of the
highlight (selected) text
flag (see HighlightBlock).
ToggleInsert Toggles state of
Insert/Overwrite option.
ToggleOptimalFillMode Toggles state of Optimal
Fill option.
ToggleTabbingMode Toggles state of Use Tab
Char option.
TopOfScreen Moves cursor to the top
line currently displayed in
the window, leaving column
unchanged.
UnDo Performs an Undo operation.
Exactly what happens
depends on the option
settings.
WordLeft Moves cursor to beginning
of previous word, or to end
of previous line, whichever
is first.
WordRight Moves cursor to beginning
of next word, or to the end
of a line, whichever is
first.
-------------------------------------------------------
The following commands cause an exit from the editor,
for example, by bringing up a dialog box. The macro
resumes when the editor window regains the focus.
The keys listed next to some of the commands below are
the ones used by default.
-------------------------------------------------------
ChangeDirectory Opens a dialog box for changing the
current directory.
ChangeModeFlags Used after a command such as
ToggleInsert which changes the
state of an editor option switch.
Causes the IDE to update various
menu items.
ClipCopy Copys selected text to Clipboard
(Ctrl+Ins).
ClipCut Cuts selected text to Clipboard
(Shift+Del).
ClipPaste Pastes Clipboard into buffer at
cursor (Shift+Ins).
ClipShow Shows Clipboard (no hot key
defined).
CloseWindow Closes editor window (Alt+F3).
CompileFile Compiles current buffer (Alt+F9).
CompileMenu Selects Compile menu (Alt+C).
CompilerOptions Inserts compiler options string
at the top of file (Ctrl+O O).
EditMenu Selects Edit menu (Alt+E).
FileMenu Selects File menu (Alt+F).
GetFindString Opens a dialog box for the Search
operation. (Alt+S F)
GotoWindow1 Selects window #1 (Alt+1).
GotoWindow2 Selects window #2 (Alt+2).
GotoWindow3 Selects window #3 (Alt+3).
GotoWindow4 Selects window #4 (Alt+4).
GotoWindow5 Selects window #5 (Alt+5).
GotoWindow6 Selects window #6 (Alt+6).
GotoWindow7 Selects window #7 (Alt+7).
GotoWindow8 Selects window #8 (Alt+8).
GotoWindow9 Selects window #9 (Alt+9).
Help Opens the Help window (F1).
HelpMenu Selects Help menu (Alt+H).
HelpIndex Display the Help system's index
(Shift+F1).
LastHelp Opens previous help window (Alt+F1).
Make Makes project (F9).
Menu Highlights top menu bar.
Modify Evaluates expression/modify
variable (Ctrl+F4).
NextWindow Selects next window in IDE (F6).
OpenFile Opens dialog box for File Open (F3).
CompileMenu Selects Compile menu (Alt+C).
OptionsMenu Selects Options menu (Alt+O).
PrintBlock Writes selected text to the
printer.
Quit Exits the IDE (Alt+X).
ReadBlock Opens dialog box requesting a file
name to be read into the buffer at
the cursor location and marked as
selected text.
RepeatSearch Searches again, using previous
parameters.
Replace Opens an dialog box for the Replace
operation.
RunMenu Selects Run menu (Alt+R).
RunProgram Makes and runs current executable
(Ctrl+F9).
SaveFile Saves current editor buffer (F2).
SaveFileAs Opens dialog for File SaveAs.
SearchMenu Selects Search menu (Alt+S).
WindowList Displays window list (Alt+0).
WindowMenu Selects Window menu (Alt+W).
WindowCascade Cascades windows (Shift+F5).
WindowTile Tiles windows (Shift+F4).
WordHelp Context sensitive help (Ctrl+F1).
WriteBlock Opens dialog box requesting a file
name to which the selected text
will be written.
ZoomWindow Zooms/unzooms current window (F5).
===========================================================================
===========================================================================

View File

@ -0,0 +1,57 @@
{*******************************************************}
{ }
{ Turbo Pascal Version 7.0 }
{ Turbo Vision Unit }
{ }
{ Copyright (c) 1991,92 Borland International }
{ }
{*******************************************************}
unit TextView;
{$O+,F+,X+,I-,S-}
interface
uses Objects, Drivers, Views, Dos;
type
{ TTextDevice }
PTextDevice = ^TTextDevice;
TTextDevice = object(TScroller)
Dummy: Word;
function StrRead(var S: TextBuf): Byte; virtual;
procedure StrWrite(var S: TextBuf; Count: Byte); virtual;
end;
{ TTerminal }
PTerminalBuffer = ^TTerminalBuffer;
TTerminalBuffer = array[0..65534] of Char;
PTerminal = ^TTerminal;
TTerminal = object(TTextDevice)
BufSize: Word;
Buffer: PTerminalBuffer;
QueFront, QueBack: Word;
constructor Init(var Bounds:TRect; AHScrollBar, AVScrollBar: PScrollBar;
ABufSize: Word);
destructor Done; virtual;
procedure BufDec(var Val: Word);
procedure BufInc(var Val: Word);
function CalcWidth: Integer;
function CanInsert(Amount: Word): Boolean;
procedure Draw; virtual;
function NextLine(Pos:Word): Word;
function PrevLines(Pos:Word; Lines: Word): Word;
function StrRead(var S: TextBuf): Byte; virtual;
procedure StrWrite(var S: TextBuf; Count: Byte); virtual;
function QueEmpty: Boolean;
end;
procedure AssignDevice(var T: Text; Screen: PTextDevice);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,583 @@
{*******************************************************}
{ }
{ Turbo Pascal Version 7.0 }
{ Turbo Vision Unit }
{ }
{ Copyright (c) 1991,92 Borland International }
{ }
{*******************************************************}
unit Views;
{$O+,F+,X+,I-,S-}
interface
uses Objects, Drivers, Memory;
const
{ TView State masks }
sfVisible = $0001;
sfCursorVis = $0002;
sfCursorIns = $0004;
sfShadow = $0008;
sfActive = $0010;
sfSelected = $0020;
sfFocused = $0040;
sfDragging = $0080;
sfDisabled = $0100;
sfModal = $0200;
sfDefault = $0400;
sfExposed = $0800;
{ TView Option masks }
ofSelectable = $0001;
ofTopSelect = $0002;
ofFirstClick = $0004;
ofFramed = $0008;
ofPreProcess = $0010;
ofPostProcess = $0020;
ofBuffered = $0040;
ofTileable = $0080;
ofCenterX = $0100;
ofCenterY = $0200;
ofCentered = $0300;
ofValidate = $0400;
ofVersion = $3000;
ofVersion10 = $0000;
ofVersion20 = $1000;
{ TView GrowMode masks }
gfGrowLoX = $01;
gfGrowLoY = $02;
gfGrowHiX = $04;
gfGrowHiY = $08;
gfGrowAll = $0F;
gfGrowRel = $10;
{ TView DragMode masks }
dmDragMove = $01;
dmDragGrow = $02;
dmLimitLoX = $10;
dmLimitLoY = $20;
dmLimitHiX = $40;
dmLimitHiY = $80;
dmLimitAll = $F0;
{ TView Help context codes }
hcNoContext = 0;
hcDragging = 1;
{ TScrollBar part codes }
sbLeftArrow = 0;
sbRightArrow = 1;
sbPageLeft = 2;
sbPageRight = 3;
sbUpArrow = 4;
sbDownArrow = 5;
sbPageUp = 6;
sbPageDown = 7;
sbIndicator = 8;
{ TScrollBar options for TWindow.StandardScrollBar }
sbHorizontal = $0000;
sbVertical = $0001;
sbHandleKeyboard = $0002;
{ TWindow Flags masks }
wfMove = $01;
wfGrow = $02;
wfClose = $04;
wfZoom = $08;
{ TWindow number constants }
wnNoNumber = 0;
{ TWindow palette entries }
wpBlueWindow = 0;
wpCyanWindow = 1;
wpGrayWindow = 2;
{ Standard command codes }
cmValid = 0;
cmQuit = 1;
cmError = 2;
cmMenu = 3;
cmClose = 4;
cmZoom = 5;
cmResize = 6;
cmNext = 7;
cmPrev = 8;
cmHelp = 9;
{ Application command codes }
cmCut = 20;
cmCopy = 21;
cmPaste = 22;
cmUndo = 23;
cmClear = 24;
cmTile = 25;
cmCascade = 26;
{ TDialog standard commands }
cmOK = 10;
cmCancel = 11;
cmYes = 12;
cmNo = 13;
cmDefault = 14;
{ Standard messages }
cmReceivedFocus = 50;
cmReleasedFocus = 51;
cmCommandSetChanged = 52;
{ TScrollBar messages }
cmScrollBarChanged = 53;
cmScrollBarClicked = 54;
{ TWindow select messages }
cmSelectWindowNum = 55;
{ TListViewer messages }
cmListItemSelected = 56;
{ Color palettes }
CFrame = #1#1#2#2#3;
CScrollBar = #4#5#5;
CScroller = #6#7;
CListViewer = #26#26#27#28#29;
CBlueWindow = #8#9#10#11#12#13#14#15;
CCyanWindow = #16#17#18#19#20#21#22#23;
CGrayWindow = #24#25#26#27#28#29#30#31;
{ TDrawBuffer maximum view width }
MaxViewWidth = 132;
type
{ Command sets }
PCommandSet = ^TCommandSet;
TCommandSet = set of Byte;
{ Color palette type }
PPalette = ^TPalette;
TPalette = String;
{ TDrawBuffer, buffer used by draw methods }
TDrawBuffer = array[0..MaxViewWidth - 1] of Word;
{ TView object Pointer }
PView = ^TView;
{ TGroup object Pointer }
PGroup = ^TGroup;
{ TView object }
TView = object(TObject)
Owner: PGroup;
Next: PView;
Origin: TPoint;
Size: TPoint;
Cursor: TPoint;
GrowMode: Byte;
DragMode: Byte;
HelpCtx: Word;
State: Word;
Options: Word;
EventMask: Word;
constructor Init(var Bounds: TRect);
constructor Load(var S: TStream);
destructor Done; virtual;
procedure Awaken; virtual;
procedure BlockCursor;
procedure CalcBounds(var Bounds: TRect; Delta: TPoint); virtual;
procedure ChangeBounds(var Bounds: TRect); virtual;
procedure ClearEvent(var Event: TEvent);
function CommandEnabled(Command: Word): Boolean;
function DataSize: Word; virtual;
procedure DisableCommands(Commands: TCommandSet);
procedure DragView(Event: TEvent; Mode: Byte;
var Limits: TRect; MinSize, MaxSize: TPoint);
procedure Draw; virtual;
procedure DrawView;
procedure EnableCommands(Commands: TCommandSet);
procedure EndModal(Command: Word); virtual;
function EventAvail: Boolean;
function Execute: Word; virtual;
function Exposed: Boolean;
function Focus: Boolean;
procedure GetBounds(var Bounds: TRect);
procedure GetClipRect(var Clip: TRect);
function GetColor(Color: Word): Word;
procedure GetCommands(var Commands: TCommandSet);
procedure GetData(var Rec); virtual;
procedure GetEvent(var Event: TEvent); virtual;
procedure GetExtent(var Extent: TRect);
function GetHelpCtx: Word; virtual;
function GetPalette: PPalette; virtual;
procedure GetPeerViewPtr(var S: TStream; var P);
function GetState(AState: Word): Boolean;
procedure GrowTo(X, Y: Integer);
procedure HandleEvent(var Event: TEvent); virtual;
procedure Hide;
procedure HideCursor;
procedure KeyEvent(var Event: TEvent);
procedure Locate(var Bounds: TRect);
procedure MakeFirst;
procedure MakeGlobal(Source: TPoint; var Dest: TPoint);
procedure MakeLocal(Source: TPoint; var Dest: TPoint);
function MouseEvent(var Event: TEvent; Mask: Word): Boolean;
function MouseInView(Mouse: TPoint): Boolean;
procedure MoveTo(X, Y: Integer);
function NextView: PView;
procedure NormalCursor;
function Prev: PView;
function PrevView: PView;
procedure PutEvent(var Event: TEvent); virtual;
procedure PutInFrontOf(Target: PView);
procedure PutPeerViewPtr(var S: TStream; P: PView);
procedure Select;
procedure SetBounds(var Bounds: TRect);
procedure SetCommands(Commands: TCommandSet);
procedure SetCmdState(Commands: TCommandSet; Enable: Boolean);
procedure SetCursor(X, Y: Integer);
procedure SetData(var Rec); virtual;
procedure SetState(AState: Word; Enable: Boolean); virtual;
procedure Show;
procedure ShowCursor;
procedure SizeLimits(var Min, Max: TPoint); virtual;
procedure Store(var S: TStream);
function TopView: PView;
function Valid(Command: Word): Boolean; virtual;
procedure WriteBuf(X, Y, W, H: Integer; var Buf);
procedure WriteChar(X, Y: Integer; C: Char; Color: Byte;
Count: Integer);
procedure WriteLine(X, Y, W, H: Integer; var Buf);
procedure WriteStr(X, Y: Integer; Str: String; Color: Byte);
end;
{ TFrame types }
TTitleStr = string[80];
{ TFrame object }
{ Palette layout }
{ 1 = Passive frame }
{ 2 = Passive title }
{ 3 = Active frame }
{ 4 = Active title }
{ 5 = Icons }
PFrame = ^TFrame;
TFrame = object(TView)
constructor Init(var Bounds: TRect);
procedure Draw; virtual;
function GetPalette: PPalette; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
procedure SetState(AState: Word; Enable: Boolean); virtual;
end;
{ ScrollBar characters }
TScrollChars = array[0..4] of Char;
{ TScrollBar object }
{ Palette layout }
{ 1 = Page areas }
{ 2 = Arrows }
{ 3 = Indicator }
PScrollBar = ^TScrollBar;
TScrollBar = object(TView)
Value: Integer;
Min: Integer;
Max: Integer;
PgStep: Integer;
ArStep: Integer;
constructor Init(var Bounds: TRect);
constructor Load(var S: TStream);
procedure Draw; virtual;
function GetPalette: PPalette; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
procedure ScrollDraw; virtual;
function ScrollStep(Part: Integer): Integer; virtual;
procedure SetParams(AValue, AMin, AMax, APgStep, AArStep: Integer);
procedure SetRange(AMin, AMax: Integer);
procedure SetStep(APgStep, AArStep: Integer);
procedure SetValue(AValue: Integer);
procedure Store(var S: TStream);
end;
{ TScroller object }
{ Palette layout }
{ 1 = Normal text }
{ 2 = Selected text }
PScroller = ^TScroller;
TScroller = object(TView)
HScrollBar: PScrollBar;
VScrollBar: PScrollBar;
Delta: TPoint;
Limit: TPoint;
constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
constructor Load(var S: TStream);
procedure ChangeBounds(var Bounds: TRect); virtual;
function GetPalette: PPalette; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
procedure ScrollDraw; virtual;
procedure ScrollTo(X, Y: Integer);
procedure SetLimit(X, Y: Integer);
procedure SetState(AState: Word; Enable: Boolean); virtual;
procedure Store(var S: TStream);
end;
{ TListViewer }
{ Palette layout }
{ 1 = Active }
{ 2 = Inactive }
{ 3 = Focused }
{ 4 = Selected }
{ 5 = Divider }
PListViewer = ^TListViewer;
TListViewer = object(TView)
HScrollBar: PScrollBar;
VScrollBar: PScrollBar;
NumCols: Integer;
TopItem: Integer;
Focused: Integer;
Range: Integer;
constructor Init(var Bounds: TRect; ANumCols: Word;
AHScrollBar, AVScrollBar: PScrollBar);
constructor Load(var S: TStream);
procedure ChangeBounds(var Bounds: TRect); virtual;
procedure Draw; virtual;
procedure FocusItem(Item: Integer); virtual;
function GetPalette: PPalette; virtual;
function GetText(Item: Integer; MaxLen: Integer): String; virtual;
function IsSelected(Item: Integer): Boolean; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
procedure SelectItem(Item: Integer); virtual;
procedure SetRange(ARange: Integer);
procedure SetState(AState: Word; Enable: Boolean); virtual;
procedure Store(var S: TStream);
end;
{ Video buffer }
PVideoBuf = ^TVideoBuf;
TVideoBuf = array[0..3999] of Word;
{ Selection modes }
SelectMode = (NormalSelect, EnterSelect, LeaveSelect);
{ TGroup object }
TGroup = object(TView)
Last: PView;
Current: PView;
Phase: (phFocused, phPreProcess, phPostProcess);
Buffer: PVideoBuf;
constructor Init(var Bounds: TRect);
constructor Load(var S: TStream);
destructor Done; virtual;
procedure Awaken; virtual;
procedure ChangeBounds(var Bounds: TRect); virtual;
function DataSize: Word; virtual;
procedure Delete(P: PView);
procedure Draw; virtual;
procedure EndModal(Command: Word); virtual;
procedure EventError(var Event: TEvent); virtual;
function ExecView(P: PView): Word;
function Execute: Word; virtual;
function First: PView;
function FirstThat(P: Pointer): PView;
function FocusNext(Forwards: Boolean): Boolean;
procedure ForEach(P: Pointer);
procedure GetData(var Rec); virtual;
function GetHelpCtx: Word; virtual;
procedure GetSubViewPtr(var S: TStream; var P);
procedure HandleEvent(var Event: TEvent); virtual;
procedure Insert(P: PView);
procedure InsertBefore(P, Target: PView);
procedure Lock;
procedure PutSubViewPtr(var S: TStream; P: PView);
procedure Redraw;
procedure SelectNext(Forwards: Boolean);
procedure SetData(var Rec); virtual;
procedure SetState(AState: Word; Enable: Boolean); virtual;
procedure Store(var S: TStream);
procedure Unlock;
function Valid(Command: Word): Boolean; virtual;
end;
{ TWindow object }
{ Palette layout }
{ 1 = Frame passive }
{ 2 = Frame active }
{ 3 = Frame icon }
{ 4 = ScrollBar page area }
{ 5 = ScrollBar controls }
{ 6 = Scroller normal text }
{ 7 = Scroller selected text }
{ 8 = Reserved }
PWindow = ^TWindow;
TWindow = object(TGroup)
Flags: Byte;
ZoomRect: TRect;
Number: Integer;
Palette: Integer;
Frame: PFrame;
Title: PString;
constructor Init(var Bounds: TRect; ATitle: TTitleStr; ANumber: Integer);
constructor Load(var S: TStream);
destructor Done; virtual;
procedure Close; virtual;
function GetPalette: PPalette; virtual;
function GetTitle(MaxSize: Integer): TTitleStr; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
procedure InitFrame; virtual;
procedure SetState(AState: Word; Enable: Boolean); virtual;
procedure SizeLimits(var Min, Max: TPoint); virtual;
function StandardScrollBar(AOptions: Word): PScrollBar;
procedure Store(var S: TStream);
procedure Zoom; virtual;
end;
{ Message dispatch function }
function Message(Receiver: PView; What, Command: Word;
InfoPtr: Pointer): Pointer;
{ Views registration procedure }
procedure RegisterViews;
const
{ Event masks }
PositionalEvents: Word = evMouse;
FocusedEvents: Word = evKeyboard + evCommand;
{ Minimum window size }
MinWinSize: TPoint = (X: 16; Y: 6);
{ Shadow definitions }
ShadowSize: TPoint = (X: 2; Y: 1);
ShadowAttr: Byte = $08;
{ Markers control }
ShowMarkers: Boolean = False;
{ MapColor error return value }
ErrorAttr: Byte = $CF;
{ Stream Registration Records }
const
RView: TStreamRec = (
ObjType: 1;
VmtLink: Ofs(TypeOf(TView)^);
Load: @TView.Load;
Store: @TView.Store
);
const
RFrame: TStreamRec = (
ObjType: 2;
VmtLink: Ofs(TypeOf(TFrame)^);
Load: @TFrame.Load;
Store: @TFrame.Store
);
const
RScrollBar: TStreamRec = (
ObjType: 3;
VmtLink: Ofs(TypeOf(TScrollBar)^);
Load: @TScrollBar.Load;
Store: @TScrollBar.Store
);
const
RScroller: TStreamRec = (
ObjType: 4;
VmtLink: Ofs(TypeOf(TScroller)^);
Load: @TScroller.Load;
Store: @TScroller.Store
);
const
RListViewer: TStreamRec = (
ObjType: 5;
VmtLink: Ofs(TypeOf(TListViewer)^);
Load: @TListViewer.Load;
Store: @TLIstViewer.Store
);
const
RGroup: TStreamRec = (
ObjType: 6;
VmtLink: Ofs(TypeOf(TGroup)^);
Load: @TGroup.Load;
Store: @TGroup.Store
);
const
RWindow: TStreamRec = (
ObjType: 7;
VmtLink: Ofs(TypeOf(TWindow)^);
Load: @TWindow.Load;
Store: @TWindow.Store
);
{ Characters used for drawing selected and default items in }
{ monochrome color sets }
SpecialChars: array[0..5] of Char = (#175, #174, #26, #27, ' ', ' ');
{ True if the command set has changed since being set to false }
CommandSetChanged: Boolean = False;

View File

@ -0,0 +1,379 @@
{************************************************}
{ }
{ Turbo Art Demo Program }
{ Copyright (c) 1992 by Borland International }
{ }
{************************************************}
program Arty;
{
This program is a demonstration of the Borland Graphics Interface (BGI)
Runtime Commands for ARTY
-------------------------
<B> - changes background color
<C> - changes drawcolor
<ESC> - exits program
Any other key pauses, then regenerates the drawing
Note: If a /H command-line parameter is specified, the highest
resolution mode will be used (if possible).
}
uses
Crt, Graph;
const
Memory = 100;
Windows = 4;
type
ResolutionPreference = (Lower, Higher);
ColorList = array [1..Windows] of integer;
var
Xmax,
Ymax,
ViewXmax,
ViewYmax : integer;
Line: array [1..Memory] of record
LX1,LY1: integer;
LX2,LY2: integer;
LColor : ColorList;
end;
X1,X2,Y1,Y2,
CurrentLine,
ColorCount,
IncrementCount,
DeltaX1,DeltaY1,DeltaX2,DeltaY2: integer;
Colors: ColorList;
Ch: char;
BackColor:integer;
GraphDriver, GraphMode : integer;
MaxColors : word;
MaxDelta : integer;
ChangeColors: Boolean;
procedure Frame;
begin
SetViewPort(0, 0, Xmax, Ymax-(TextHeight('M')+4)-1,ClipOn);
SetColor(MaxColors);
Rectangle(0, 0, Xmax-1, (Ymax-(TextHeight('M')+4)-1)-1);
SetViewPort(1, 1, Xmax-2, (Ymax-(TextHeight('M')+4)-1)-2,ClipOn);
end { Frame };
procedure FullPort;
{ Set the view port to the entire screen }
begin
SetViewPort(0, 0, Xmax, Ymax, ClipOn);
end; { FullPort }
procedure MessageFrame(Msg:string);
begin
FullPort;
SetColor(MaxColors);
SetTextStyle(DefaultFont, HorizDir, 1);
SetTextJustify(CenterText, TopText);
SetLineStyle(SolidLn, 0, NormWidth);
SetFillStyle(EmptyFill, 0);
Bar(0, Ymax-(TextHeight('M')+4), Xmax, Ymax);
Rectangle(0, Ymax-(TextHeight('M')+4), Xmax, Ymax);
OutTextXY(Xmax div 2, Ymax-(TextHeight('M')+2), Msg);
{ Go back to the main window }
Frame;
end { MessageFrame };
procedure WaitToGo;
var
Ch : char;
begin
MessageFrame('Press any key to continue... Esc aborts');
repeat until KeyPressed;
Ch := ReadKey;
if Ch = #27 then begin
CloseGraph;
Writeln('All done.');
Halt(1);
end
else
ClearViewPort;
MessageFrame('Press a key to stop action, Esc quits.');
end; { WaitToGo }
procedure TestGraphError(GraphErr: integer);
begin
if GraphErr <> grOk then begin
Writeln('Graphics error: ', GraphErrorMsg(GraphErr));
repeat until keypressed;
ch := readkey;
Halt(1);
end;
end;
procedure Init;
var
Err, I: integer;
StartX, StartY: integer;
Resolution: ResolutionPreference;
s: string;
begin
Resolution := Lower;
if paramcount > 0 then begin
s := paramstr(1);
if s[1] = '/' then
if upcase(s[2]) = 'H' then
Resolution := Higher;
end;
CurrentLine := 1;
ColorCount := 0;
IncrementCount := 0;
Ch := ' ';
GraphDriver := Detect;
DetectGraph(GraphDriver, GraphMode);
TestGraphError(GraphResult);
case GraphDriver of
CGA : begin
MaxDelta := 7;
GraphDriver := CGA;
GraphMode := CGAC1;
end;
MCGA : begin
MaxDelta := 7;
case GraphMode of
MCGAMed, MCGAHi: GraphMode := MCGAC1;
end;
end;
EGA : begin
MaxDelta := 16;
If Resolution = Lower then
GraphMode := EGALo
else
GraphMode := EGAHi;
end;
EGA64 : begin
MaxDelta := 16;
If Resolution = Lower then
GraphMode := EGA64Lo
else
GraphMode := EGA64Hi;
end;
HercMono : MaxDelta := 16;
EGAMono : MaxDelta := 16;
PC3270 : begin
MaxDelta := 7;
GraphDriver := CGA;
GraphMode := CGAC1;
end;
ATT400 : case GraphMode of
ATT400C1,
ATT400C2,
ATT400Med,
ATT400Hi :
begin
MaxDelta := 7;
GraphMode := ATT400C1;
end;
end;
VGA : begin
MaxDelta := 16;
end;
end;
InitGraph(GraphDriver, GraphMode, '');
TestGraphError(GraphResult);
SetTextStyle(DefaultFont, HorizDir, 1);
SetTextJustify(CenterText, TopText);
MaxColors := GetMaxColor;
BackColor := 0;
ChangeColors := TRUE;
Xmax := GetMaxX;
Ymax := GetMaxY;
ViewXmax := Xmax-2;
ViewYmax := (Ymax-(TextHeight('M')+4)-1)-2;
StartX := Xmax div 2;
StartY := Ymax div 2;
for I := 1 to Memory do with Line[I] do begin
LX1 := StartX; LX2 := StartX;
LY1 := StartY; LY2 := StartY;
end;
X1 := StartX;
X2 := StartX;
Y1 := StartY;
Y2 := StartY;
end; {init}
procedure AdjustX(var X,DeltaX: integer);
var
TestX: integer;
begin
TestX := X+DeltaX;
if (TestX<1) or (TestX>ViewXmax) then begin
TestX := X;
DeltaX := -DeltaX;
end;
X := TestX;
end;
procedure AdjustY(var Y,DeltaY: integer);
var
TestY: integer;
begin
TestY := Y+DeltaY;
if (TestY<1) or (TestY>ViewYmax) then begin
TestY := Y;
DeltaY := -DeltaY;
end;
Y := TestY;
end;
procedure SelectNewColors;
begin
if not ChangeColors then exit;
Colors[1] := Random(MaxColors)+1;
Colors[2] := Random(MaxColors)+1;
Colors[3] := Random(MaxColors)+1;
Colors[4] := Random(MaxColors)+1;
ColorCount := 3*(1+Random(5));
end;
procedure SelectNewDeltaValues;
begin
DeltaX1 := Random(MaxDelta)-(MaxDelta Div 2);
DeltaX2 := Random(MaxDelta)-(MaxDelta Div 2);
DeltaY1 := Random(MaxDelta)-(MaxDelta Div 2);
DeltaY2 := Random(MaxDelta)-(MaxDelta Div 2);
IncrementCount := 2*(1+Random(4));
end;
procedure SaveCurrentLine(CurrentColors: ColorList);
begin
with Line[CurrentLine] do
begin
LX1 := X1;
LY1 := Y1;
LX2 := X2;
LY2 := Y2;
LColor := CurrentColors;
end;
end;
procedure Draw(x1,y1,x2,y2,color:word);
begin
SetColor(color);
Graph.Line(x1,y1,x2,y2);
end;
procedure Regenerate;
var
I: integer;
begin
Frame;
for I := 1 to Memory do with Line[I] do begin
Draw(LX1,LY1,LX2,LY2,LColor[1]);
Draw(ViewXmax-LX1,LY1,ViewXmax-LX2,LY2,LColor[2]);
Draw(LX1,ViewYmax-LY1,LX2,ViewYmax-LY2,LColor[3]);
Draw(ViewXmax-LX1,ViewYmax-LY1,ViewXmax-LX2,ViewYmax-LY2,LColor[4]);
end;
WaitToGo;
Frame;
end;
procedure Updateline;
begin
Inc(CurrentLine);
if CurrentLine > Memory then CurrentLine := 1;
Dec(ColorCount);
Dec(IncrementCount);
end;
procedure CheckForUserInput;
begin
if KeyPressed then begin
Ch := ReadKey;
if Upcase(Ch) = 'B' then begin
if BackColor > MaxColors then BackColor := 0 else Inc(BackColor);
SetBkColor(BackColor);
end
else
if Upcase(Ch) = 'C' then begin
if ChangeColors then ChangeColors := FALSE else ChangeColors := TRUE;
ColorCount := 0;
end
else if Ch<>#27 then Regenerate;
end;
end;
procedure DrawCurrentLine;
var c1,c2,c3,c4: integer;
begin
c1 := Colors[1];
c2 := Colors[2];
c3 := Colors[3];
c4 := Colors[4];
if MaxColors = 1 then begin
c2 := c1; c3 := c1; c4 := c1;
end;
Draw(X1,Y1,X2,Y2,c1);
Draw(ViewXmax-X1,Y1,ViewXmax-X2,Y2,c2);
Draw(X1,ViewYmax-Y1,X2,ViewYmax-Y2,c3);
if MaxColors = 3 then c4 := Random(3)+1; { alternate colors }
Draw(ViewXmax-X1,ViewYmax-Y1,ViewXmax-X2,ViewYmax-Y2,c4);
SaveCurrentLine(Colors);
end;
procedure EraseCurrentLine;
begin
with Line[CurrentLine] do begin
Draw(LX1,LY1,LX2,LY2,0);
Draw(ViewXmax-LX1,LY1,ViewXmax-LX2,LY2,0);
Draw(LX1,ViewYmax-LY1,LX2,ViewYmax-LY2,0);
Draw(ViewXmax-LX1,ViewYmax-LY1,ViewXmax-LX2,ViewYmax-LY2,0);
end;
end;
procedure DoArt;
begin
SelectNewColors;
repeat
EraseCurrentLine;
if ColorCount = 0 then SelectNewColors;
if IncrementCount=0 then SelectNewDeltaValues;
AdjustX(X1,DeltaX1); AdjustX(X2,DeltaX2);
AdjustY(Y1,DeltaY1); AdjustY(Y2,DeltaY2);
if Random(5)=3 then begin
x1 := (x1+x2) div 2; { shorten the lines }
y2 := (y1+y2) div 2;
end;
DrawCurrentLine;
Updateline;
CheckForUserInput;
until Ch=#27;
end;
begin
Init;
Frame;
MessageFrame('Press a key to stop action, Esc quits.');
DoArt;
CloseGraph;
RestoreCrtMode;
Writeln('The End.');
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,41 @@
{************************************************}
{ }
{ BGI Demo Program }
{ Copyright (c) 1992 by Borland International }
{ }
{************************************************}
unit BGIDriv;
{
Sample unit to accompany BGILINK.PAS. This unit links the BGI graphics
driver into a single TPU file. This makes it easy to link the driver files
directly into an .EXE file. See BGILINK.PAS for more information.
}
interface
procedure ATTDriverProc;
procedure CgaDriverProc;
procedure EgaVgaDriverProc;
procedure HercDriverProc;
procedure PC3270DriverProc;
implementation
procedure ATTDriverProc; external;
{$L ATT.OBJ }
procedure CgaDriverProc; external;
{$L CGA.OBJ }
procedure EgaVgaDriverProc; external;
{$L EGAVGA.OBJ }
procedure HercDriverProc; external;
{$L HERC.OBJ }
procedure PC3270DriverProc; external;
{$L PC3270.OBJ }
end.

View File

@ -0,0 +1,36 @@
{************************************************}
{ }
{ BGI Demo Program }
{ Copyright (c) 1992 by Borland International }
{ }
{************************************************}
unit BGIFont;
{ Sample unit to accompany BGILINK.PAS. This unit links all the BGI graphics
fonts into a single TPU file. This makes it easy to incorporate the font
files directly into an .EXE file. See BGILINK.PAS for more information.
}
interface
procedure GothicFontProc;
procedure SansSerifFontProc;
procedure SmallFontProc;
procedure TriplexFontProc;
implementation
procedure GothicFontProc; external;
{$L GOTH.OBJ }
procedure SansSerifFontProc; external;
{$L SANS.OBJ }
procedure SmallFontProc; external;
{$L LITT.OBJ }
procedure TriplexFontProc; external;
{$L TRIP.OBJ }
end.

View File

@ -0,0 +1,34 @@
# Build sample program that uses BGIFONT.TPU and BGIDRIV.TPU
# Change the following macro to point to your \BGI directory:
BGI = ..\..\bgi
bgilink.exe: bgidriv.tpu bgifont.tpu
tpc /m bgilink
# Build unit with all fonts linked in
bgifont.tpu: bgifont.pas goth.obj litt.obj sans.obj trip.obj
tpc bgifont
goth.obj: $(BGI)\goth.chr
binobj $(BGI)\goth.chr goth GothicFontProc
litt.obj: $(BGI)\litt.chr
binobj $(BGI)\litt.chr litt SmallFontProc
sans.obj: $(BGI)\sans.chr
binobj $(BGI)\sans.chr sans SansSerifFontProc
trip.obj: $(BGI)\trip.chr
binobj $(BGI)\trip.chr trip TriplexFontProc
# Build unit with all drivers linked in
bgidriv.tpu: bgidriv.pas cga.obj egavga.obj herc.obj pc3270.obj att.obj
tpc bgidriv
cga.obj: $(BGI)\cga.bgi
binobj $(BGI)\cga.bgi cga CGADriverProc
egavga.obj: $(BGI)\egavga.bgi
binobj $(BGI)\egavga.bgi egavga EGAVGADriverProc
herc.obj: $(BGI)\herc.bgi
binobj $(BGI)\herc.bgi herc HercDriverProc
pc3270.obj: $(BGI)\pc3270.bgi
binobj $(BGI)\pc3270.bgi pc3270 PC3270DriverProc
att.obj: $(BGI)\att.bgi
binobj $(BGI)\att.bgi att ATTDriverProc

View File

@ -0,0 +1,130 @@
{************************************************}
{ }
{ BGI Demo Program }
{ Copyright (c) 1992 by Borland International }
{ }
{************************************************}
program BgiLink;
{ This program demonstrates how to link graphics driver and font files
into an EXE file. BGI graphic's drivers and fonts are kept in
separate disk files so they may be dynamically loaded at runtime.
However, sometimes it is preferable to place all auxiliary files
directly into an .EXE. This program, along with its make file
(BGILINK.MAK) and two units (BGIDRIV.PAS and BGIFONT.PAS) links all
the drivers and fonts directly into BGILINK.EXE.
Have these 3 programs in the current drive or directory, or
have them available via a path:
MAKE.EXE - Make utility that will build BGILINK.EXE
BINOBJ.EXE - utility program to convert any file into an .OBJ file
Place in the current drive or directory the following files:
BGILINK.PAS - this sample program
BGIDRIV.PAS - Pascal unit that will link in all BGI drivers
BGIFONT.PAS - Pascal unit that will link in all BGI fonts
*.CHR - BGI font files
*.BGI - BGI driver files
BGILINK.MAK - "make" file that builds BGIDRIV.TPU, BGIFONT.TPU, and
finally BGILINK.EXE
DIRECTIONS:
1. Run MAKE on the BGILINK.MAK file by typing the following command
at a DOS prompt:
make -fBGIlink.mak
Using BINOBJ.EXE, this will first build .OBJ files out of the driver
files (*.BGI) and then call Turbo Pascal to compile BGIDRIV.PAS.
Next, the font files (*.CHR) will be converted to .OBJs and
BGIFONT.PAS will be compiled. Finally, BGILINK.PAS will be compiled
(it uses BGIDRIV.TPU and BGIFONT.TPU).
2. Run BGILINK.EXE. It contains all the drivers and all the fonts, so it
will run on any system with a graphics card supported by the Graph
unit (CGA, EGA, EGA 64 K, EGA monochrome, Hercules monochrome,
VGA, MCGA, IBM 3270 PC and AT&T 6400).
EXPLANATION
BGILINK.PAS uses BGIDRIV.TPU and BGIFONT.TPU in its uses statement:
uses BGIDriv, BGIFont;
Then, it "registers" the drivers it intends to use (in this case,
all of them, so it will run on any graphics card). Then it registers
all of the fonts it will use (again all of them, just for demonstration
purposes) and finally it does some very modest graphics.
You can easily modify BGILINK.PAS for your own use by commenting out
the calls to RegisterBGIdriver and RegisterBGIfont for drivers and
fonts that your program doesn't use.
For a detailed explanation of registering and linking drivers and fonts,
refer to the RegisterBGIdriver and RegisterBGIfont descriptions in
the printed documentation.
}
uses Graph, { library of graphics routines }
BGIDriv, { all the BGI drivers }
BGIFont; { all the BGI fonts }
var
GraphDriver, GraphMode, Error : integer;
procedure Abort(Msg : string);
begin
Writeln(Msg, ': ', GraphErrorMsg(GraphResult));
Halt(1);
end;
begin
{ Register all the drivers }
if RegisterBGIdriver(@CGADriverProc) < 0 then
Abort('CGA');
if RegisterBGIdriver(@EGAVGADriverProc) < 0 then
Abort('EGA/VGA');
if RegisterBGIdriver(@HercDriverProc) < 0 then
Abort('Herc');
if RegisterBGIdriver(@ATTDriverProc) < 0 then
Abort('AT&T');
if RegisterBGIdriver(@PC3270DriverProc) < 0 then
Abort('PC 3270');
{ Register all the fonts }
if RegisterBGIfont(@GothicFontProc) < 0 then
Abort('Gothic');
if RegisterBGIfont(@SansSerifFontProc) < 0 then
Abort('SansSerif');
if RegisterBGIfont(@SmallFontProc) < 0 then
Abort('Small');
if RegisterBGIfont(@TriplexFontProc) < 0 then
Abort('Triplex');
GraphDriver := Detect; { autodetect the hardware }
InitGraph(GraphDriver, GraphMode, ''); { activate graphics }
if GraphResult <> grOk then { any errors? }
begin
Writeln('Graphics init error: ', GraphErrorMsg(GraphDriver));
Halt(1);
end;
MoveTo(5, 5);
OutText('Drivers and fonts were ');
MoveTo(5, 20);
SetTextStyle(GothicFont, HorizDir, 4);
OutText('Built ');
SetTextStyle(SmallFont, HorizDir, 4);
OutText('into ');
SetTextStyle(TriplexFont, HorizDir, 4);
OutText('EXE ');
SetTextStyle(SansSerifFont, HorizDir, 4);
OutText('file!');
Rectangle(0, 0, GetX, GetY + TextHeight('file!') + 1);
Readln;
CloseGraph;
end.

View File

@ -0,0 +1,333 @@
{************************************************}
{ }
{ Breakout Demo Program }
{ Copyright (c) 1992 by Borland International }
{ }
{************************************************}
unit Bounds;
{
See BREAKOUT.PAS.
Contains the Paddle object type and the object types that
define the boundaries of the playfield.
This unit is part of the BREAKOUT.PAS example.
}
interface
uses Screen, Bricks, Count, Crt;
type
ObstaclePtr = ^Obstacle;
{ An ObstacleList is a list of instances of objects derived from the
object Obstacle. In order to use all these instances polymorphically,
All their virtual functions have to have corresponding virtual functions
in Obstacle, even if they are never used. }
Obstacle = object(Location)
Width : Integer;
Trap : Boolean;
NextPtr : ObstaclePtr;
constructor Init(InitX, InitY, InitWidth : Integer; SetTrap : Boolean);
destructor Done; virtual;
function Collide(var B : Ball) : Boolean; virtual;
function IsTrap : Boolean; virtual;
function GetValue : Integer; virtual;
end;
ObstacleList = object
Head : Obstacle;
Tail : ObstaclePtr;
constructor Init;
destructor Done; virtual;
procedure Append(NewObstacle : ObstaclePtr);
procedure Show;
procedure Hide;
function CheckCollisions(var B : Ball; var Score : Counter) : Boolean;
end;
Paddle = object(Obstacle)
Color : Integer;
constructor Init(InitX, InitY, InitColor : Integer);
destructor Done; virtual;
procedure Show; virtual;
procedure Hide; virtual;
procedure MoveTo(NewX, NewY : Integer); virtual;
function Collide(var B : Ball) : Boolean; virtual;
end;
{ There are no instances of the object Boundary. It's here to provide
a common basis for the next four objects. }
Boundary = object(Obstacle)
constructor Init(InitX, InitY, InitWidth : Integer; SetTrap : Boolean);
end;
LeftBound = object(Boundary)
constructor Init(InitX, InitY, InitWidth : Integer; SetTrap : Boolean);
function Collide(var B : Ball) : Boolean; virtual;
end;
UpperBound = object(Boundary)
constructor Init(InitX, InitY, InitWidth : Integer; SetTrap : Boolean);
function Collide(var B : Ball) : Boolean; virtual;
end;
RightBound = object(Boundary)
constructor Init(InitX, InitY, InitWidth : Integer; SetTrap : Boolean);
function Collide(var B : Ball) : Boolean; virtual;
end;
LowerBound = object(Boundary)
constructor Init(InitX, InitY, InitWidth : Integer; SetTrap : Boolean);
function Collide(var B : Ball) : Boolean; virtual;
end;
implementation
constructor Obstacle.Init(InitX, InitY, InitWidth : Integer;
SetTrap : Boolean);
begin
Location.Init(InitX, InitY);
Width := InitWidth;
Trap := SetTrap;
NextPtr := nil;
end;
destructor Obstacle.Done;
begin
end;
function Obstacle.Collide(var B : Ball) : Boolean;
begin
Collide := True;
end;
function Obstacle.IsTrap : Boolean;
begin
IsTrap := Trap;
end;
function Obstacle.GetValue : Integer;
begin
GetValue := 0;
end;
constructor ObstacleList.Init;
begin
Head.Init(0, 0, 0, False);
Tail := @Head;
end;
destructor ObstacleList.Done;
var
Temp1, Temp2 : ObstaclePtr;
begin
Temp1 := Head.NextPtr;
while Temp1 <> nil do
begin
Temp2 := Temp1;
Temp1 := Temp1^.NextPtr;
Temp2^.Done;
end;
end;
procedure ObstacleList.Append(NewObstacle : ObstaclePtr);
begin
Tail^.NextPtr := NewObstacle;
Tail := NewObstacle;
end;
procedure ObstacleList.Show;
var
Current : ObstaclePtr;
begin
Current := Head.NextPtr;
while Current <> nil do
begin
Current^.Show;
Current := Current^.NextPtr;
end;
end;
procedure ObstacleList.Hide;
var
Current : ObstaclePtr;
begin
Current := Head.NextPtr;
while Current <> nil do
begin
Current^.Hide;
Current := Current^.NextPtr;
end;
end;
{ This function is a little more complex than I like. It checks
whether a collision occurs, and updates the score if one does. }
function ObstacleList.CheckCollisions(var B : Ball;
var Score : Counter) : Boolean;
var
Current : ObstaclePtr;
begin
CheckCollisions := False;
Current := Head.NextPtr;
while Current <> nil do
begin
if Current^.Collide(B) then
begin
Score.Add(Current^.GetValue);
if Current^.IsTrap then
CheckCollisions := True;
end;
Current := Current^.NextPtr;
end;
end;
constructor Paddle.Init(InitX, InitY, InitColor : Integer);
begin
Obstacle.Init(InitX, InitY, 5, False);
Color := InitColor;
end;
destructor Paddle.Done;
begin
Obstacle.Done;
end;
procedure Paddle.Show;
var
Str : String[10];
begin
FillChar(Str[1], Width, Chr(223));
Str[0] := Chr(Width);
Location.Show;
TextColor(Color);
GoToXY(X, Y);
Write(Str);
end;
procedure Paddle.Hide;
begin
Location.Hide;
GoToXY(X, Y);
Write('' : Width);
end;
{ The motion of Paddle is restricted to the 80-character screen }
procedure Paddle.MoveTo(NewX, NewY : Integer);
begin
Hide;
if NewX < 1 then
X := 1
else if NewX > 81 - Width then
X := 81 - Width
else
X := NewX;
Y := NewY;
Show;
end;
{ If the ball hits the paddle we have to change the ball's direction.
Also, to keep the overall logic simpler, if the paddle is at the
edge of the screen and the ball would miss the paddle and go off the
edge, we call it a hit. If we don't do this here, we get into some
complications with bouncing off the sides of the screen }
function Paddle.Collide(var B : Ball) : Boolean;
var
NewX, NewY : Integer;
begin
NewX := B.NextX;
NewY := B.NextY;
Collide := False;
if (NewY = Y) then
if ((NewX >= X) and (NewX < X + Width)) or
((NewX < 1) and (X = 1)) or
((NewX > 80) and (X + Width = 81)) then
begin
B.ReverseY;
{$IFDEF Test} { If the paddle is following the ball, we have to put
in some random behavior so it doesn't get boring. }
B.ChangeXVel(Integer(Random(2))*2-1);
{$ELSE}
B.ChangeXVel(B.GetX - X - 2);
{$ENDIF}
Collide := True;
end;
end;
constructor Boundary.Init(InitX, InitY, InitWidth : Integer;
SetTrap : Boolean);
begin
Obstacle.Init(InitX, InitY, InitWidth, SetTrap);
end;
constructor LeftBound.Init(InitX, InitY, InitWidth : Integer;
SetTrap : Boolean);
begin
Boundary.Init(InitX, InitY, InitWidth, SetTrap);
end;
function LeftBound.Collide(var B : Ball) : Boolean;
begin
Collide := False;
if (B.NextX <= X) and (B.NextY >= Y) and (B.NextY <= Y + Width) then
begin
B.ReverseX;
Collide := True;
end;
end;
constructor UpperBound.Init(InitX, InitY, InitWidth : Integer;
SetTrap : Boolean);
begin
Boundary.Init(InitX, InitY, InitWidth, SetTrap);
end;
function UpperBound.Collide(var B : Ball) : Boolean;
begin
Collide := False;
if (B.NextY <= Y) and (B.NextX >= X) and (B.NextX <= X + Width) then
begin
B.ReverseY;
Collide := True;
end;
end;
constructor RightBound.Init(InitX, InitY, InitWidth : Integer;
SetTrap : Boolean);
begin
Boundary.Init(InitX, InitY, InitWidth, SetTrap);
end;
function RightBound.Collide(var B : Ball) : Boolean;
begin
Collide := False;
if (B.NextX >= X) and (B.NextY >= Y) and (B.NextY <= Y + Width) then
begin
B.ReverseX;
Collide := True;
end;
end;
constructor LowerBound.Init(InitX, InitY, InitWidth : Integer;
SetTrap : Boolean);
begin
Boundary.Init(InitX, InitY, InitWidth, SetTrap);
end;
function LowerBound.Collide(var B : Ball) : Boolean;
begin
Collide := False;
if (B.NextY >= Y) and (B.NextX >= X) and (B.NextX <= X + Width) then
begin
B.ReverseY;
Collide := True;
end;
end;
end.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,305 @@
{************************************************}
{ }
{ Breakout Demo Program }
{ Copyright (c) 1992 by Borland International }
{ }
{************************************************}
program Breakout;
{
This is a version of the classic arcade game, Breakout.
SCREEN.PAS
COUNT.PAS
BRICKS.PAS
BOUNDS.PAS
WALLS.PAS
BREAKOUT.PAS
To build an executable file, compile from the command line with:
tpc /m breakout
or load BREAKOUT.PAS into the integrated development
environment and press F9.
When testing the program, you may want to force the paddle to
follow the ball, so you'll never miss. The program contains
conditional compilation directives to produce this version, and
you can build it from the command line with:
tpc /DTest breakout
or load BREAKOUT.PAS into the integrated development
environment, select Alt-O/C/Alt-C, type 'Test' (without the quotes,
of course) followed by the Enter key, then select Alt-C/B to
rebuild the executable file.
}
uses Screen, Count, Bricks, Bounds, Walls, Crt, Dos;
var
ss : SaveScreen;
w : Wall;
b : Ball;
p : Paddle;
Speed : LimitCounter;
Left : LeftBound;
Top : UpperBound;
Right : RightBound;
Bottom : LowerBound;
Obstacles : ObstacleList;
PaddleMsg,
SpeedMsg,
StartMsg,
QuitMsg,
PauseMsg1,
PauseMsg2,
TypeMsg : TextString;
Score : Counter;
Highest : Counter;
Balls : DownCounter;
X : Integer;
Finished : Boolean;
FirstGame : Boolean;
TypeInc,
ch : Char;
procedure Startup;
begin
{ First set up the screen and the cursor }
ss.Init;
TextBackground(BLACK);
ClrScr;
{ Create the boundaries of the playfield }
Left.Init(0, 0, 27, False);
Top.Init(0, 0, 82, False);
Right.Init(81, 0, 27, False);
Bottom.Init(0, 24, 82, True);
{ Initialize the score displays }
Score.Init(0, 65, 24, 'Score', 15);
Score.Show;
Highest.Init(0, 60, 25, 'High Score', 14);
Highest.Show;
{ Set up the various menu messages }
PauseMsg1.Init(31, 18, 'Paused. Press any', 15);
PauseMsg2.Init(31, 19, ' key to continue.', 15);
SpeedMsg.Init(5, 23, #24 + #25 + ' to change speed', 14);
StartMsg.Init(5, 24, #17 + #196 + #217 + ' to begin game', 14);
PaddleMsg.Init(5, 24, #27 + #26 + ' to move paddle', 14);
QuitMsg.Init(5, 25, 'ESC to quit', 14);
QuitMsg.Show;
{ Set up the information messages }
Balls.Init(5, 40, 24, -1, 'Balls', 15);
Balls.Show;
Speed.Init(1, 40, 25, 1, 10, 'Speed', 14);
Speed.Show;
{ Build the wall }
w.Init(1, 1, 16, 10);
w.Show;
{ Need to initialize these, even though we're going to move them later }
b.Init(10, 22, 1, -1, YELLOW);
p.Init(8, 23, WHITE);
{ Put the various obstacles into a list. We don't really need
to do this, but it makes changing things around much easier }
Obstacles.Init;
Obstacles.Append(@p);
Obstacles.Append(@w);
Obstacles.Append(@Left);
Obstacles.Append(@Top);
Obstacles.Append(@Right);
Obstacles.Append(@Bottom);
TypeMsg.Init(22, 12, 'Increase typematic rate? (y/n) ', WHITE);
TypeMsg.Show;
repeat
TypeInc := UpCase(ReadKey);
until (TypeInc = 'Y') or (TypeInc = 'N');
TypeMsg.Hide;
if TypeInc = 'Y' then
ss.Speedup;
ss.SetCursor($2000);
Randomize;
FirstGame := True;
end;
procedure NewGame;
begin
Balls.Reset;
Score.Reset;
if not FirstGame then
w.Reset;
X := Random(78) + 3;
b.MoveTo(X, 22);
p.MoveTo(X-2, 23);
b.Show;
p.Show;
Balls.Decrement;
FirstGame := False;
end;
{ This procedure handles keystrokes between games.
It returns False if the user presses ESC, otherwise it returns True. }
function MainMenu : Boolean;
var
Done : Boolean;
begin
MainMenu := True;
Done := False;
SpeedMsg.Show;
StartMsg.Show;
while not Done do
begin
ch := ReadKey;
case ch of
Chr(27) :
begin
MainMenu := False;
Done := True;
end;
#13 : Done := True;
#0 :
begin
ch := ReadKey;
if Ord(ch) = 72 then
Speed.Increment
else if Ord(ch) = 80 then
Speed.Decrement;
end;
end;
end;
SpeedMsg.Hide;
StartMsg.Hide;
end;
{ This procedure handles keystrokes while the game is in progress }
procedure ProcessKeyStroke;
{ Pause the game }
procedure Pause;
begin
PauseMsg1.Show;
PauseMsg2.Show;
ch := ReadKey;
if KeyPressed then
ch := ReadKey; { Swallow extended keystrokes }
PauseMsg1.Hide;
PauseMsg2.Hide;
b.Show;
end;
begin
ch := ReadKey;
case ch of
Chr(27) : Finished := True;
Chr(0) :
begin
ch := ReadKey;
{$IFNDEF Test}
case Ord(ch) of
75: p.MoveTo(p.GetX - 1, p.GetY); { Left Arrow }
77: p.MoveTo(p.GetX + 1, p.GetY); { Right Arrow }
else
Pause;
end;
{$ELSE}
Pause;
{$ENDIF}
end
else
Pause;
end;
end;
{ This procedure checks for collisions with any of the obstacles
and updates the screen accordingly. }
procedure Update;
var
Offset : Integer;
begin
if Obstacles.CheckCollisions(b, Score) then
begin
b.MoveY;
p.MoveTo(b.GetX - 2, p.GetY);
sound(150);
Delay(300);
nosound;
Balls.Decrement;
while KeyPressed do
ch := ReadKey;
end;
b.MoveX;
b.MoveY;
{$IFDEF Test}
p.MoveTo(b.NextX -2, p.GetY);
{$ENDIF}
end;
{ This procedure cleans up when we're exiting from the program }
procedure ShutDown;
begin
b.Hide;
Obstacles.Hide;
Balls.Hide;
Score.Hide;
Obstacles.Done;
ss.Restore;
if TypeInc = 'Y' then
ss.Slowdown;
ClrScr;
end;
{ This procedure plays a game. The main loop allows up to ten keystrokes,
then moves the ball and checks for collisions }
procedure Play;
var
KeyLoops : Integer;
begin
NewGame;
{$IFNDEF Test}
PaddleMsg.Show;
{$ENDIF}
Finished := False;
KeyLoops := 0;
repeat
if KeyPressed then
ProcessKeyStroke;
Inc(KeyLoops);
if (KeyLoops = 10) and not Finished then
begin
KeyLoops := 0;
UpDate;
end;
Delay(12 - Speed.GetValue);
until Finished or Balls.Last;
PaddleMsg.Hide;
end;
begin
Startup;
while MainMenu do
begin
Play;
Balls.Reset;
b.Hide;
p.Hide;
if Score.GetValue > Highest.GetValue then
Highest.SetValue(Score.GetValue);
end;
ShutDown;
end.

View File

@ -0,0 +1,155 @@
{************************************************}
{ }
{ Breakout Demo Program }
{ Copyright (c) 1992 by Borland International }
{ }
{************************************************}
unit Bricks;
{
See BREAKOUT.PAS.
This unit contains the Ball object and the object types that
end up as bricks on the screen.
}
interface
uses Screen, Count;
type
Block = object(Location)
Color : Integer;
Width : Integer;
BChar : Char;
constructor Init(InitX, InitY, InitColor, InitWidth : Integer;
InitChr : Char);
procedure Show; virtual;
procedure Hide; virtual;
end;
Ball = object(Block)
XVel : Integer;
YVel : Integer;
constructor Init(InitX, InitY, InitXVel, InitYVel, InitColor : Integer);
function NextX : Integer;
function NextY : Integer;
procedure MoveX;
procedure MoveY;
procedure ReverseX;
procedure ReverseY;
procedure ChangeXVel(Delta : Integer);
end;
Brick = object(Block)
Value : Integer;
constructor Init(InitX, InitY, InitColor, InitValue : Integer);
function GetValue : Integer;
end;
implementation
uses Crt;
constructor Block.Init(InitX, InitY, InitColor, InitWidth : Integer;
InitChr : Char);
begin
Location.Init(InitX, InitY);
Color := InitColor;
Width := InitWidth;
BChar := InitChr;
end;
procedure Block.Show;
var
Str : String[10];
begin
FillChar(Str[1], Width, BChar);
Str[0] := Chr(Width);
Location.Show;
TextColor(Color);
GoToXY(X, Y);
Write(Str);
end;
procedure Block.Hide;
begin
Location.Hide;
GoToXY(X, Y);
Write('' : Width);
end;
constructor Brick.Init(InitX, InitY, InitColor, InitValue : Integer);
var
BlockChar : Char;
begin
BlockChar := Chr($B2);
if (LastMode = Mono) and Odd(InitX + InitY) then
BlockChar := Chr($B0);
Block.Init(InitX, InitY, InitColor, 5, BlockChar);
Value := InitValue;
end;
function Brick.GetValue : Integer;
begin
GetValue := Value;
end;
constructor Ball.Init(InitX, InitY, InitXVel, InitYVel, InitColor : Integer);
begin
Block.Init(InitX, InitY, InitColor, 1, Chr(15));
XVel := InitXVel;
YVel := InitYVel;
end;
function Ball.NextX : Integer;
begin
NextX := X + XVel;
end;
function Ball.NextY : Integer;
begin
NextY := Y + YVel;
end;
procedure Ball.MoveX;
begin
Hide;
X := NextX;
Show;
end;
procedure Ball.MoveY;
begin
Hide;
Y := NextY;
Show;
end;
procedure Ball.ReverseX;
begin
XVel := -XVel;
end;
procedure Ball.ReverseY;
begin
YVel := -YVel;
end;
{ This procedure introduces the variations in horizontal velocity for
the ball. Horizontal velocity ranges from -2 to 2. If you hit the
ball with the edge of the paddle, you'll get a large change in
horizontal velocity. }
procedure Ball.ChangeXVel(Delta : Integer);
begin
Inc(XVel, Delta);
if XVel < -2 then
XVel := -2
else if XVel > 2 then
XVel := 2
else if XVel = 0 then
XVel := Integer(Random(2))*2 - 1;
end;
end.

Binary file not shown.

View File

@ -0,0 +1,243 @@
{************************************************}
{ }
{ Breakout Demo Program }
{ Copyright (c) 1992 by Borland International }
{ }
{************************************************}
unit Count;
{
See BREAKOUT.PAS.
This unit provides several text display object types, most of
which are coupled with various types of counters.
}
interface
uses Screen;
const
StrSize = 40;
type
TextStr = String[StrSize];
TextPtr = ^TextStr;
TextString = object(Location)
Text : TextPtr;
Attr : Byte;
constructor Init(InitX, InitY : Integer;
InitText : TextStr;
InitAttr : Byte);
procedure Show; virtual;
procedure Hide; virtual;
end;
Counter = object(TextString)
Value : Integer;
BaseValue : Integer;
constructor Init(InitValue, InitX, InitY : Integer;
InitName : TextStr;
InitAttr : Byte);
procedure Show; virtual;
procedure Hide; virtual;
procedure ShowVal; virtual;
procedure HideVal; virtual;
procedure SetValue(NewValue : Integer);
procedure Reset;
procedure Increment;
procedure Decrement;
procedure Add(Incr : Integer);
function Equal(TestValue : Integer) : Boolean;
function GetValue : Integer;
end;
DownCounter = object(Counter)
Minimum : Integer;
constructor Init(InitValue, InitX, InitY, InitMin : Integer;
InitName : TextStr;
InitAttr : Byte);
procedure Decrement;
procedure Add(Incr : Integer);
function Last : Boolean;
end;
LimitCounter = object(DownCounter)
Maximum : Integer;
constructor Init(InitValue, InitX, InitY, InitMin, InitMax : Integer;
InitName : TextStr;
InitAttr : Byte);
procedure Increment;
procedure Add(Incr : Integer);
end;
implementation
uses Crt;
constructor TextString.Init(InitX, InitY : Integer;
InitText : TextStr;
InitAttr : Byte);
begin
Location.Init(InitX, InitY);
Attr := InitAttr;
GetMem(Text, Length(InitText) + 1);
Move(InitText, Text^, Length(InitText) + 1);
end;
procedure TextString.Show;
begin
Visible := True;
GoToXY(X, Y);
TextColor(Attr);
Write(Text^);
end;
procedure TextString.Hide;
begin
Visible := False;
GoToXY(X, Y);
TextAttr := Attr;
Write('' : Length(Text^));
end;
constructor Counter.Init(InitValue, InitX, InitY : Integer;
InitName : TextStr;
InitAttr : Byte);
begin
TextString.Init(InitX, InitY, InitName, InitAttr);
BaseValue := InitValue;
Value := InitValue;
end;
procedure Counter.Show;
begin
Visible := True;
GoToXY(X, Y);
TextColor(Attr);
Write(Text^, ': ', Value);
end;
procedure Counter.Hide;
begin
Visible := False;
GoToXY(X, Y);
TextAttr := Attr;
Write('' : Length(Text^) + 7);
end;
procedure Counter.ShowVal;
begin
Visible := True;
GoToXY(X + Length(Text^) + 2, Y);
TextColor(Attr);
Write(Value);
end;
procedure Counter.HideVal;
begin
Visible := False;
GoToXY(X + Length(Text^) + 2, Y);
TextAttr := Attr;
Write('' : 5);
end;
procedure Counter.SetValue(NewValue : Integer);
var
Vis : Boolean;
begin
Vis := Visible;
if Vis then
HideVal;
Value := NewValue;
if Vis then
ShowVal;
end;
procedure Counter.Increment;
begin
SetValue(Value + 1);
end;
procedure Counter.Decrement;
begin
SetValue(Value - 1);
end;
procedure Counter.Add(Incr : Integer);
begin
SetValue(Value + Incr);
end;
procedure Counter.Reset;
begin
SetValue(BaseValue);
end;
function Counter.Equal(TestValue : Integer) : Boolean;
begin
Equal := (Value = TestValue);
end;
function Counter.GetValue : Integer;
begin
GetValue := Value;
end;
constructor DownCounter.Init(InitValue, InitX, InitY, InitMin : Integer;
InitName : TextStr;
InitAttr : Byte);
begin
Counter.Init(InitValue, InitX, InitY, InitName, InitAttr);
Minimum := InitMin;
end;
procedure DownCounter.Decrement;
begin
if Value > Minimum then
Counter.Decrement;
end;
procedure DownCounter.Add(Incr : Integer);
var
Temp : Integer;
begin
Temp := GetValue + Incr;
if Temp >= Minimum then
SetValue(Temp);
end;
function DownCounter.Last : Boolean;
begin
Last := (Value = Minimum);
end;
constructor LimitCounter.Init(InitValue,
InitX,
InitY,
InitMin,
InitMax : Integer;
InitName : TextStr;
InitAttr : Byte);
begin
DownCounter.Init(InitValue, InitX, InitY, InitMin, InitName, InitAttr);
Maximum := InitMax;
end;
procedure LimitCounter.Increment;
begin
if Value < Maximum then
Counter.Increment;
end;
procedure LimitCounter.Add(Incr : Integer);
var
Temp : Integer;
begin
Temp := Value + Incr;
if (Temp <= Maximum) and (Temp >= Minimum) then
SetValue(Temp);
end;
end.

Binary file not shown.

View File

@ -0,0 +1,204 @@
{************************************************}
{ }
{ Breakout Demo Program }
{ Copyright (c) 1992 by Borland International }
{ }
{************************************************}
unit Screen;
{
See BREAKOUT.PAS.
This unit provides several objects for dealing with the screen.
}
interface
uses Crt, Dos;
type
Location = object
X, Y : Integer;
Visible : Boolean;
constructor Init(InitX, InitY : Integer);
procedure Relocate(NewX, NewY : Integer);
procedure MoveTo(NewX, NewY : Integer); virtual;
procedure Show; virtual;
procedure Hide; virtual;
function GetX : Integer;
function GetY : Integer;
function IsVisible : Boolean;
end;
Cursor = object(Location)
OldCursor : Integer;
TempCursor : Integer;
constructor Init;
procedure Show; virtual;
procedure Hide; virtual;
procedure SetCursor(NewCursor : Integer);
function GetCursor : Integer;
procedure MoveTo(NewX, NewY : Integer); virtual;
procedure Save;
procedure Restore;
procedure Speedup;
procedure Slowdown;
end;
SaveScreen = object(Cursor)
OldAttr : Byte;
constructor Init;
procedure Save;
procedure Restore;
end;
implementation
procedure SetCursorSpeed(NewSpeed : Word);
begin
Port[$60] := $F3;
Delay(200);
Port[$60] := NewSpeed;
end;
constructor Location.Init(InitX, InitY : Integer);
begin
X := InitX;
Y := InitY;
Visible := False;
end;
procedure Location.Relocate(NewX, NewY : Integer);
begin
X := NewX;
Y := NewY;
end;
procedure Location.MoveTo(NewX, NewY : Integer);
var
Vis : Boolean;
begin
Vis := Visible;
if Vis then Hide;
X := NewX;
Y := NewY;
if Vis then Show;
end;
procedure Location.Show;
begin
Visible := True;
end;
procedure Location.Hide;
begin
Visible := False;
end;
function Location.GetX : Integer;
begin
GetX := X;
end;
function Location.GetY : Integer;
begin
GetY := Y;
end;
function Location.IsVisible;
begin
IsVisible := Visible;
end;
constructor Cursor.Init;
begin
Location.Init(WhereX, WhereY);
OldCursor := GetCursor;
Location.Show;
end;
procedure Cursor.Show;
begin
SetCursor(TempCursor);
end;
procedure Cursor.Hide;
begin
TempCursor := GetCursor;
SetCursor($2000);
end;
function Cursor.GetCursor : Integer;
var
Reg : Registers;
begin
with Reg do
begin
AH := 3;
BH := 0;
Intr($10, Reg);
GetCursor := CX;
end;
end;
procedure Cursor.SetCursor(NewCursor : Integer);
var
Reg : Registers;
begin
with Reg do
begin
AH := 1;
BH := 0;
CX := NewCursor;
Intr($10, Reg);
end;
end;
procedure Cursor.MoveTo(NewX, NewY : Integer);
begin
Location.Relocate(NewX, NewY);
GoToXY(NewX, NewY);
end;
procedure Cursor.Save;
begin
Location.Relocate(WhereX, WhereY);
OldCursor := GetCursor;
end;
procedure Cursor.Restore;
begin
SetCursor(OldCursor);
GoToXY(X, Y);
end;
procedure Cursor.Speedup;
begin
SetCursorSpeed(0);
end;
procedure Cursor.Slowdown;
begin
SetCursorSpeed($2C);
end;
constructor SaveScreen.Init;
begin
Cursor.Init;
OldAttr := TextAttr;
end;
procedure SaveScreen.Save;
begin
Cursor.Save;
OldAttr := TextAttr;
end;
procedure SaveScreen.Restore;
begin
Cursor.Restore;
TextAttr := OldAttr;
ClrScr;
end;
end.

Binary file not shown.

View File

@ -0,0 +1,209 @@
{************************************************}
{ }
{ Breakout Demo Program }
{ Copyright (c) 1992 by Borland International }
{ }
{************************************************}
unit Walls;
{
See BREAKOUT.PAS.
This unit defines the Wall object type.
It's a fairly complex object, because it plays such a
pivotal role in the game.
}
interface
uses Screen, Bricks, Bounds, Crt;
type
BrickPtr = ^Brick;
BW = array[1..1000] of Brick;
WallPtr = ^BW;
Wall = object(Obstacle)
BrickWall : WallPtr;
Height : Integer;
NumLeft : Integer;
Value : Integer;
NCells : Integer;
constructor Init(InitX, InitY, InitWidth, InitHeight : Integer);
destructor Done; virtual;
procedure Show; virtual;
procedure Hide; virtual;
function Collide(var B : Ball) : Boolean; virtual;
function GetValue : Integer; virtual;
procedure Reset;
end;
implementation
function RandomColor(MaxColors : Integer) : Integer;
var
C : Integer;
begin
C := Random(MaxColors);
while C = (TextAttr SHR 4) do
C := Random(MaxColors);
RandomColor := C;
end;
procedure Beep;
begin
Sound(100);
Delay(20);
NoSound;
end;
{ A wall is an array of bricks. Its constructor actually builds a
conformant array, so we don't have to hardcode the size of the
wall. }
constructor Wall.Init(InitX, InitY, InitWidth, InitHeight : Integer);
begin
Obstacle.Init(InitX, InitY, InitWidth, False);
Height := InitHeight;
NCells := Width*5;
GetMem(BrickWall, Width*Height*SizeOf(Brick));
Reset;
end;
destructor Wall.Done;
begin
FreeMem(BrickWall, Width*Height*SizeOf(Block));
end;
{ This procedure could be made simpler, but you wouldn't get the slick
effect you see when the wall is built. }
procedure Wall.Show;
var
CurCol : Integer;
Count : Integer;
CurBlock : Integer;
begin
Visible := True;
NumLeft := Width*Height;
for CurCol := 1 to Width + Height - 1 do
for Count := 0 to Height - 1 do
begin
CurBlock := CurCol + Count*(Width-1);
if (CurCol - Count >= 1) and (CurCol - Count <= Width) then
begin
BrickWall^[CurBlock].Show;
Delay(5);
end;
end;
GoToXY(X + (5*Width DIV 2) - 7, Y);
TextColor(WHITE);
Write('Turbo Breakout');
end;
procedure Wall.Hide;
var
CurCol : Integer;
Count : Integer;
CurBlock : Integer;
begin
Visible := False;
for CurCol := 1 to Width + Height - 1 do
for Count := 0 to Height - 1 do
begin
CurBlock := CurCol + Count*(Width-1);
if (CurCol - Count >= 1) and (CurCol - Count <= Width) then
begin
if BrickWall^[CurBlock].IsVisible then
begin
BrickWall^[CurBlock].Hide;
Delay(5);
end;
end;
end;
end;
function Wall.Collide(var B : Ball) : Boolean;
var
CollideV, CollideH : Boolean;
{ To check for a collision with a brick, first we check if the ball is in
the area where the wall is located, then we see if there's a brick that's
still visible at the ball's position. If so, we destroy the brick, grab
its value, and beep. }
function CheckCollide(XPos, YPos : Integer) : Boolean;
var
ThisBrick : BrickPtr;
begin
CheckCollide := False;
if (YPos < Y) or (YPos > Y + Height - 1) or
(XPos < X) or (XPos > X + NCells - 1) then
Exit;
ThisBrick := @BrickWall^[1 + ((XPos-1) DIV 5) + Width*(YPos - 1)];
if ThisBrick^.IsVisible then
begin
CheckCollide := True;
Inc(Value, ThisBrick^.GetValue);
ThisBrick^.Hide;
Dec(NumLeft);
Beep;
if NumLeft = 0 then
Show;
end
end;
{ When checking for a collision with the wall, we have to watch out
for special cases involving corners. }
begin
Collide := False;
Value := 0;
CollideV := CheckCollide(B.X, B.NextY);
CollideH := CheckCollide(B.NextX, B.Y);
if CollideV then
begin
Collide := True;
B.ReverseY;
end;
if CollideH then
begin
Collide := True;
B.ReverseX;
end;
if not CollideV and not CollideH then
if CheckCollide(B.NextX, B.NextY) then
begin
Collide := True;
B.ReverseX;
B.ReverseY;
end;
end;
function Wall.GetValue : Integer;
begin
GetValue := Value;
end;
procedure Wall.Reset;
var
CurRow : Integer;
CurCol : Integer;
MaxColors : Integer;
begin
if LastMode = Mono then
MaxColors := 4
else
MaxColors := 16;
NumLeft := Width*Height;
for CurRow := 0 to Height - 1 do
for CurCol := 0 to Width - 1 do
BrickWall^[CurRow*Width+CurCol+1].Init(X + CurCol*5,
Y + CurRow,
RandomColor(MaxColors),
Height - Y - CurRow + 1);
if Visible then
Show;
end;
end.

Binary file not shown.

View File

@ -0,0 +1,150 @@
{************************************************}
{ }
{ CRT Unit Demo }
{ Copyright (c) 1985,90 by Borland International }
{ }
{************************************************}
program CrtDemo;
{ Example program that uses the Crt unit. Uses the following routines
from the Crt unit:
ClrScr
DelLine
GoToXY
InsLine
KeyPressed
ReadKey
TextBackground
TextColor
TextMode
WhereX
WhereY
Window
Write
WriteLn;
Also uses LastMode and WindMax variables from Crt unit.
1. Init routine:
- Save original video mode. On an EGA or VGA, use the 8x8 font
(43 lines on an EGA, 50 on VGA).
- Setup LastRow to preserve last line on screen for messages
(preserves last 2 lines in 40-column mode). Setup LastCol.
- Initialize the random number generator.
2. MakeWindow routine:
- Puts up random-sized, random-colored windows on screen.
3. Program body:
- Call Init
- Loop until Contrl-C is typed:
- Echo keystrokes (Turbo Pascal windows automatically wrap
and scroll).
- Support special keys:
<Ins> inserts a line at the cursor
<Del> deletes a line at the cursor
<Up>,
<Dn>,
<Right>,
<Left> position the cursor in the window
<Alt-R> generate random text until a key is pressed
<Alt-W> creates another random window
<ESC> exits the program
}
uses Crt;
var
OrigMode,LastCol,LastRow: Word;
Ch: Char;
Done: Boolean;
procedure Initialize;
{ Initialize the video mode, LastCol, LastRow, and the random number }
{ generator. Paint the help line. }
begin
CheckBreak:=False; { turn off Contrl-C checking }
OrigMode:=LastMode; { Remember original video mode }
TextMode(Lo(LastMode)+Font8x8); { use 43 or 50 lines on EGA/VGA }
LastCol:=Lo(WindMax)+1; { get last column, row }
LastRow:=Hi(WindMax)+1;
GoToXY(1,LastRow); { put message line on screen }
TextBackground(Black);
TextColor(White);
Write(' Ins-InsLine ',
'Del-DelLine ',
#27#24#25#26'-Cursor ',
'Alt-W-Window ',
'Alt-R-Random ',
'Esc-Exit');
Dec(LastRow,80 div LastCol); { don't write on message line }
Randomize; { init random number generator }
end; { Init }
procedure MakeWindow;
{ Make a random window, with random background and foreground colors }
var
X,Y,Width,Height: Word;
begin
Width:=Random(LastCol-2)+2; { random window size }
Height:=Random(LastRow-2)+2;
X:=Random(LastCol-Width)+1; { random position on screen }
Y:=Random(LastRow-Height)+1;
Window(X,Y,X+Width,Y+Height);
if OrigMode = Mono then
begin
TextBackground(White);
TextColor(Black);
ClrScr;
Window(X+1,Y+1,X+Width-1,Y+Height-1);
TextBackground(Black);
TextColor(White);
ClrScr;
end
else
begin
TextBackground(Random(8));
TextColor(Random(7)+9);
end;
ClrScr;
end; { MakeWindow }
procedure RandomText;
{ Generate random text until a key is pressed. Filter out }
{ control characters. }
begin
repeat
Write(Chr(Random(256-32)+32));
until KeyPressed;
end; { RandomText }
begin { program body }
Initialize;
MakeWindow;
Done:=False;
repeat
Ch:=ReadKey;
case Ch of
#0: { Function keys }
begin
Ch:=ReadKey;
case Ch of
#17: MakeWindow; { Alt-W }
#19: RandomText; { Alt-R }
#45: Done:=True; { Alt-X }
#72: GotoXY(WhereX,WhereY-1); { Up }
#75: GotoXY(WhereX-1,WhereY); { Left }
#77: GotoXY(WhereX+1,WhereY); { Right }
#80: GotoXY(WhereX,WhereY+1); { Down }
#82: InsLine; { Ins }
#83: DelLine; { Del }
end;
end;
#3: Done:=True; { Ctrl-C }
#13: WriteLn; { Enter }
#27: Done:=True; { Esc }
else
Write(Ch);
end;
until Done;
TextMode(OrigMode);
end.

View File

@ -0,0 +1,243 @@
{************************************************}
{ }
{ Turbo Directory Demo }
{ Copyright (c) 1985,90 by Borland International }
{ }
{************************************************}
program DirDemo;
{ Demonstration program that shows how to use:
o Directory routines from DOS unit
o Procedural types (used by QuickSort)
Usage:
dirdemo [options] [directory mask]
Options:
-W Wide display
-N Sort by file name
-S Sort by file size
-T Sort by file date and time
Directory mask:
Path, Filename, wildcards, etc.
}
{$I-,S-}
{$M 8192,8192,655360}
uses Dos;
const
MaxDirSize = 512;
MonthStr: array[1..12] of string[3] = (
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
type
DirPtr = ^DirRec;
DirRec = record
Attr: Byte;
Time: Longint;
Size: Longint;
Name: string[12];
end;
DirList = array[0..MaxDirSize - 1] of DirPtr;
LessFunc = function(X, Y: DirPtr): Boolean;
var
WideDir: Boolean;
Count: Integer;
Less: LessFunc;
Path: PathStr;
Dir: DirList;
function NumStr(N, D: Integer): String;
begin
NumStr[0] := Chr(D);
while D > 0 do
begin
NumStr[D] := Chr(N mod 10 + Ord('0'));
N := N div 10;
Dec(D);
end;
end;
{$F+}
function LessName(X, Y: DirPtr): Boolean;
begin
LessName := X^.Name < Y^.Name;
end;
function LessSize(X, Y: DirPtr): Boolean;
begin
LessSize := X^.Size < Y^.Size;
end;
function LessTime(X, Y: DirPtr): Boolean;
begin
LessTime := X^.Time > Y^.Time;
end;
{$F-}
procedure QuickSort(L, R: Integer);
var
I, J: Integer;
X, Y: DirPtr;
begin
I := L;
J := R;
X := Dir[(L + R) div 2];
repeat
while Less(Dir[I], X) do Inc(I);
while Less(X, Dir[J]) do Dec(J);
if I <= J then
begin
Y := Dir[I];
Dir[I] := Dir[J];
Dir[J] := Y;
Inc(I);
Dec(J);
end;
until I > J;
if L < J then QuickSort(L, J);
if I < R then QuickSort(I, R);
end;
procedure GetCommand;
var
I,J: Integer;
Attr: Word;
S: PathStr;
D: DirStr;
N: NameStr;
E: ExtStr;
F: File;
begin
WideDir := False;
@Less := nil;
Path := '';
for I := 1 to ParamCount do
begin
S := ParamStr(I);
if S[1] = '-' then
for J := 2 to Length(S) do
case UpCase(S[J]) of
'N': Less := LessName;
'S': Less := LessSize;
'T': Less := LessTime;
'W': WideDir := True;
else
WriteLn('Invalid option: ', S[J]);
Halt(1);
end
else
Path := S;
end;
Path := FExpand(Path);
if Path[Length(Path)] <> '\' then
begin
Assign(F, Path);
GetFAttr(F, Attr);
if (DosError = 0) and (Attr and Directory <> 0) then
Path := Path + '\';
end;
FSplit(Path, D, N, E);
if N = '' then N := '*';
if E = '' then E := '.*';
Path := D + N + E;
end;
procedure FindFiles;
var
F: SearchRec;
begin
Count := 0;
FindFirst(Path, ReadOnly + Directory + Archive, F);
while (DosError = 0) and (Count < MaxDirSize) do
begin
GetMem(Dir[Count], Length(F.Name) + 10);
Move(F.Attr, Dir[Count]^, Length(F.Name) + 10);
Inc(Count);
FindNext(F);
end;
end;
procedure SortFiles;
begin
if (Count <> 0) and (@Less <> nil) then
QuickSort(0, Count - 1);
end;
procedure PrintFiles;
var
I, P: Integer;
Total: Longint;
T: DateTime;
N: NameStr;
E: ExtStr;
begin
WriteLn('Directory of ', Path);
if Count = 0 then
begin
WriteLn('No matching files');
Exit;
end;
Total := 0;
for I := 0 to Count-1 do
with Dir[I]^ do
begin
P := Pos('.', Name);
if P > 1 then
begin
N := Copy(Name, 1, P - 1);
E := Copy(Name, P + 1, 3);
end else
begin
N := Name;
E := '';
end;
Write(N, ' ': 9 - Length(N), E, ' ': 4 - Length(E));
if WideDir then
begin
if Attr and Directory <> 0 then
Write(' DIR')
else
Write((Size + 1023) shr 10: 3, 'k');
if I and 3 <> 3 then
Write(' ': 3)
else
WriteLn;
end else
begin
if Attr and Directory <> 0 then
Write('<DIR> ')
else
Write(Size: 8);
UnpackTime(Time, T);
WriteLn(T.Day: 4, '-',
MonthStr[T.Month], '-',
NumStr(T.Year mod 100, 2),
T.Hour: 4, ':',
NumStr(T.Min, 2));
end;
Inc(Total, Size);
end;
if WideDir and (Count and 3 <> 0) then WriteLn;
WriteLn(Count, ' files, ', Total, ' bytes, ',
DiskFree(Ord(Path[1])-64), ' bytes free');
end;
begin
GetCommand;
FindFiles;
SortFiles;
PrintFiles;
end.

Some files were not shown because too many files have changed in this diff Show More