MAD-PASCAL 1.6.3
Tebe/Madteam (2020-01-04)
INTRODUCTION
Mad-Pascal (MP) is a 32-bit Turbo Pascal compiler for Atari XE/XL. By design, it is compatible with the Free Pascal Compiler (FPC) (the -MDelphi switch should be active), which means the possibility of obtaining executable code for XE/XL, PC and every other platform for which FPC exists. MP is not a port of FPC; it has been written based on of SUB-Pascal (2009), XD-Pascal (2010), the author of which is Vasiliy Tereshkov (vtereshkov@mail.ru).
A program that works on Atari might have problems on PC if, for example, the pointers have not been initialized with the address of a variable and the program attempts to write to the address $0000 (memory protection fault). The strengths of MP include fast and convenient possibility of inclusion of inline assembly. A program using inline ASM does not work on platforms other than XE/XL. MP uses 64KB of primary memory; TMemoryStream provides usage of extended memory.
Variable allocation is static; there is no dynamic memory management. Parameters are passed to functions by value, variable or constant.The available features are:
To compile the sources of Mad-Pascal, one may use Delphi, provided they happen to have installed Delphi 7.0 or a later version.
A more cross-platform way is to use the Free Pascal Compiler (FPC), which can be downloaded from http://www.freepascal.org/
Launch the installer and choose the directory for the installation of FP. It is crucial not to use the exclamation mark '!' or other nonstandard characters in the directory name. If it fails to compile any file, most probably, it is the fault of a nonstandard pathname. The command-line launching the compilation may look as follows (letter case in parameter names matters):fpc -Mdelphi -v -O3 mp.dpr
USAGE
Syntax: mp source [switches] -d:address diagnostic mode -define:symbol defines a symbol -ipath:<x> additional search path -code:$address program launch address -data:$address memory address of variables and arrays -stack:$address address of stack (64 bytes) -zpage:$address address of variables in the zero page (24 bytes)
The default extension of output file is *.A65, assembled using the Mad-Assembler (additionally the search path is set using -i:base), for example:
mads source.a65 -x -i:baseThe -x switch (Exclude unreferenced procedures) allows for the generation of shortest output code for the 6502.
3 = bad parameters, compiling not started 2 = error occurred 0 = no errorsWarning diagnostics do not affect the exit code.
SYNTAX
In MP, '//' is used to mark a one-line comment and { } or (* *) mark a multiline comment.
// this is a comment inc(a); // this also is a comment (* comment *) (* comment *) { this is a comment }
absolute and array asm begin case const div do downto else end file for function if implementation interface main mod not of or procedure program record repeat shl shr stack string then to type unit until uses var while xorReserved constants:
pi true false
Expressions
Expression-100 -2437325 1743
$100 $e430 $000001
%0001001010 %000000001 %001000
'a' 'fds' 'W' #65#32#65 #$9b
+ Addition - Subtraction * Multiplication / Division DIV Integer division MOD RemainderLogical operators
NOT Bitwise negation (unary) AND Bitwise and OR Bitwise or XOR Bitwise xor SHL Bitwise shift to the left SHR Bitwise shift to the rightBoolean operators
NOT logical negation (unary) AND logical and OR logical or XOR logical xorRelational operators
= Equal <> Not equal < Less than > Greater than <= Less than or equal >= Greater than or equal
COMPILER DIRECTIVES
Compiler directivesCompiler directives are of form:
{$define test} const {$ifdef test} a=1; {$else} a=2; {$endif}From the assembly level access to defined $DEFINE directives is only possible through MAIN.@DEFINES.label
{$f $70} // fastmul at $7000
Alternative procedures for fast multiplication of the BYTE, SHORTINT, WORD, SMALLINT and SHORTREAL types. The procedures occupy 2KB and are located starting from the address PAGE*256.
{i+} IOCHECK ON default {i-} IOCHECK OFF
For {$i+} in case of I/O transmission errors (RESET, REWRITE, BLOCKREAD, BLOCKWRITE, CLOSE) the ran program is stopped and an error diagnostic 'ERROR xxx’ is generated. Disabling IOCHECK {$i-} is of use for file existence checking, for example:
function FileExists(name: TString): Boolean; var f: file; begin {$I-} // io check off Assign (f, name); Reset (f); Result:=(IoResult<128) and (length(name)>0); Close (f); {$I+} // io check end;In PROCEDURE and FUNCTION blocks, the IOCHECK directive is of local scope, after finishing the compilation of such block the previous value of IOCHECK, defined outside of such block, is restored.
Directive for inclusion of a string with current compilation date.
Directive for inclusion of a string with current compilation time.
Directive to attach the text contained in the file.
Directive to indicate additional search paths for libraries (unit).
RCDATA | any data type |
RCASM | an assembly file that will be attached and assembled |
DOSFILE | Atari DOS header file, the loading address of such a file should be the same as RCLABEL |
RELOC | a relocatable file in MadAssembler format, the file will be relocated to the address indicated by RCLABEL |
RMT | Raster Music Tracker module file, the file will be relocated to the address indicated by RCLABEL |
MPT | the Music ProTracker module file, the file will be relocated to the indicated address RCLABEL |
CMC | Chaos Music Composer module file, the file will be relocated to the address indicated by RCLABEL |
RMTPLAY | player for the RMT module, with the *.FEAT file passed as the RCFILE and the player mode 0..3 passed as the PAR0
0 => compile RMTplayer for 4 tracks mono 1 => compile RMTplayer for 8 tracks stereo 2 => compile RMTplayer for 4 tracks stereo L1 R2 R3 L4 3 => compile RMTplayer for 4 tracks stereo L1 L2 R3 R4 |
MPTPLAY | player for MPT module |
CMCPLAY | player for CMC module |
XBMP | Windows Bitmap file (8 BitsPerPixel) loaded into VBXE memory to the indicated address RCLABEL from PAR0 color index in VBXE color palette no. 1 |
Example: bmp1 RCDATA 'pic.mic' msx MPT ‘failure.mpt' play RMTPLAY ‘module.feat' 1 bmp XBMP 'pic.bmp' 80
CONSTANTS
Ordinary constantsThe character '=' is used for the CONST constant declarations. The use of operators +, -, *, /, not, and, or, div, mod, ord, chr, sizeof, pi is allowed.
Const e = 2.7182818; { Real type constant } f : single = 3.14; { Single type constant } a = 2; { Ordinal BYTE type constant } c = '4'; { Character type constant } s = 'atari'; { String type constant } sc = chr(32); ls = SizeOf(cardinal); x: word = 5; { forcing the type of constant }
TYPES
Type | Range | Size in bytes |
BYTE | 0 .. 255 | 1 |
SHORTINT | -128 .. 127 | 1 |
WORD | 0 .. 65535 | 2 |
SMALLINT | -32768 .. 32767 | 2 |
CARDINAL | 0 .. 4294967295 | 4 |
LONGWORD | 0 .. 4294967295 | 4 |
DWORD | 0 .. 4294967295 | 4 |
UINT32 | 0 .. 4294967295 | 4 |
INTEGER | -2147483648 .. 2147483647 | 4 |
LONGINT | -2147483648 .. 2147483647 | 4 |
Name | Size | Ord(True) |
BOOLEAN | 1 | 1 |
The enumeration type in MP has been implemented in its basic form, i.e.:
Type Days = (monday,tuesday,wednesday,thursday,friday, saturday,sunday); Joy = (right_down = 5, right_up, right, left_down = 9, left_up, left, down = 13, up, none);
The enumeration type is stored only in the memory of the MP compiler, no information about the enumeration type fields will be stored in the result file. It is permissible to use the ORD, SIZEOF and casts on the enumeration type.
var d: Days; d:=friday; writeln(ord(d)); writeln(ord(sunday)); writeln(sizeof(days)); writeln(sizeof(monday)); d:=days(20); case d of sunday: writeln('sunday'); end;
Currently, the MP compiler does not check the correctness of enumeration types for IF ELSE operations.
Type | Range | Size in bytes |
SHORTREAL (Q8.8) | -128..127 | 2 |
REAL (Q24.8) | -8388607..8388608 | 4 |
SINGLE (IEEE-754) | 1.5E-45 .. 3.4E38 | 4 |
FLOAT (IEEE-754) | 1.5E-45 .. 3.4E38 | 4 |
Type | Range | Size in bytes |
CHAR | ATASCII (0 .. 255) | 1 |
STRING | 1 .. 255 | 256 |
PCHAR | 0 .. 65535 | 2 |
The STRING string is represented as an array with a possible maximum size [0..255]. The first byte of such an array [0] is the string length from the range 0..255. The actual character string begins from the byte [1..].
A pointer to the CHAR type represents the PCHAR string. The terminator of the PCHAR string is the #0 character.
It is allowed to use additional characters after the final apostrophe, such as '*', '~'. The character '*' means a string in the inverse; the tilde '~' means a string in ANTIC codes.
Another way to modify the output characters is to use the system variable TextAttr, each character output to the screen is increased by the value TextAttr (default = 0).
a: string = 'Atari'*; // a character string in the inverse b: string = 'Spectrum'~; // a character string in ANTIC codes c: char = 'X'~*; // a character in inverted ANTIC codes
Type | Range | Size in bytes |
POINTER | 0 .. 65535 | 2 |
Indicators in MP can be typed and without a specific type, e.g.:
a: ^word; // a typed pointer to a word b: pointer; // an untyped pointer
An uninitialized pointer will most often have the address of $0000, you should make sure that before you use it, you will have initialized it with the address of the appropriate variable, e.g.:
a := @tmp; // pointer A is assigned the address of the TMP variable
If you don't do this, if you run such a program on a PC, you may cause a memory protection fault 'Access Violation'.
Increasing the pointer using INC increases it by the size of the type it indicates. Decreasing the pointer using DEC reduces it by the size of the type it indicates. If the type is unspecified, the default step for increase/decrease is 1.Tables in MP are only static, one-dimensional or two-dimensional with an initial index =0, e.g:
var tb: array [0..100] of word; var tb2: array [0..15, 0..31] of Boolean;
For an initial index other than zero, an error 'Error Array lower bound is not zero' is generated.
In the memory the array is represented by the pointer (POINTER), the pointer is the address of the array in memory (WORD). The quickest way to refer to the table from the assembler level is to use the prefix ‘ADR’, e.g.:asm { lda adr.tb,y ; direct reference to the TB array lda tb ; reference to the TB array pointer };
The compiler generates code for the arrays depending on their declaration:
array [0..255] of byte array [0..127] of word array [0..63] of cardinal |
When the number of bytes occupied by the array does not exceed 256 bytes, the fastest code referring directly to the address of the array (prefix ADR.) is generated without the pointer. It is not possible to change the address for such an array.
ldy #118 lda adr.tb,y |
array [0..0] of type | When the number of elements of an array is '1' it is treated specifically. The code generated refers to the array through the pointer. It is possible to set a new address for such a table.
lda TB add I tay lda TB+1 adc #$00 sta bp+1 lda (bp),y |
array [0..255+1] of byte array [0..127+1] of word array [0..63+1] of cardinal |
When the number of bytes occupied by the array exceeds 256 bytes, the generated code refers to the array via an pointer. When the number of bytes occupied by the array exceeds 256 bytes, the generated code refers to the array through a pointer.
lda TB add I tay lda TB+1 adc #$00 sta bp+1 lda (bp),y |
In the memory the record is represented by a pointer (POINTER).
type
TPoint = record x,y: byte end;
var px: TPoint;
By default, records in MP are of type PACKED.
If you want to maintain FPC compatibility, you should additionally precede the word 'record' with the word 'packed'.
Without this, the size of the memory that the record takes varies, it occupies less memory on Atari XE/XL, potentially several bytes more on the PC
type TPoint = packed record x,y: byte end; var px: TPoint;Access to record fields from the assembly:
mwa px bp2 ldy #px.x-DATAORIGIN lda (bp2),y
Objects are records with additional methods. In the memory, the object is represented by a pointer (POINTER).
type
TRMT = Object
player: pointer;
modul: pointer;
procedure Init(a: byte); assembler;
procedure Play; assembler;
procedure Stop; assembler;
end;
The FILE type represents the file handle and defines the record size.
type ftype = array [0..63] of cardinal; var f: file; // default record =128 bytes f: file of byte; // 1 byte record f: file of ftype; // 256 byte record (ftype = 64 * 4)In the XE/XL memory, the FILE holder is represented by a pointer (POINTER) to an array of structure (size 12 bytes):
.struct s@file pfname .word ; pointer to string with filename record .word ; record size chanel .byte ; channel *$10 eof .byte ; EOF status buffer .word ; load/write buffer nrecord .word ; number of records for load/write numread .word ; pointer to variable, length of loaded data .ends
For procedures and functions, the FILE type can only be passed as a variable (VAR).
CONDITIONAL INSTRUCTIONS
Currently, Mad Pascal only accepts types with a length of 1 byte for the CASE variable: SHORTINT, BYTE, CHAR, BOOLEAN
case a of // for a variable A of type CHAR 'A'..'Z': begin end; '0'..'9': begin end; '+','*': begin end; end;
IF conditional instructions can be nested. This is used for more complex conditions.
ITERATIVE INSTRUCTIONS
FOR variable := { initial value } TO { final value } DO { instructions to execute } FOR variable := { final value } DOWNTO { initial value } DO { instructions to execute }This instruction is used to organize calculations which are performed a predetermined number of times. The control variable shall be an identifier of the ordinal type and both expressions shall be consistent in terms of assignment with the control variable type. During the TO loop execution, the control variable is assigned the subsequent value in the given type, in the DOWNTO loop, the preceding one. It is prohibited to "manually" change the value of a control variable. In case of such an attempt, MP does not signal an error.
The compiler makes sure that there is no endless loop so that you can use such a loop without a doubt:
for i:=0 to 255 do writeln(i); // for a variable I of type BYTE
while { warunek } do { instrukcja do wykonania }This construct is used to organize calculations that will be performed as long as the expression after the word WHILE is true. Such a loop may not be executed even once.
while BlitterBusy do; // waiting for the VBXE blitter to finishLimitations for WHILE instructions:
while i<=255 do inc(i); // endless loop if I is of type BYTE
repeat { instructions to execute } until { termination condition }This statement cyclically executes other statements between REPEAT and UNTIL until the expression after UNTIL takes the value of TRUE.
The effect of the REPEAT loop is very similar to that of the WHILE loop. This loop can also be performed a huge number of times. The only difference is that in the REPEAT loop the end condition is only checked after the instruction is executed. This means that the REPEAT loop will always be done at least once. Only after this iteration will the program check if the loop can be terminated. In the case of the WHILE loop, the condition is checked immediately before it is executed, which may result in the loop never being executed.
i:=0; repeat inc(i); until i=0; // the loop will repeat 256 times
PROCEDURES AND FUNCTIONS
MP allows up to 8 parameters to be transferred to the procedure. There are three ways to pass parameters - by value, constant (CONST) and variable (VAR). It is possible to use the OVERLOAD modifier to overload procedures.
Available procedure modifiers: OVERLOAD, ASSEMBLER, FORWARD, REGISTER, INTERRUPT.It is possible to recurse procedures, provided that the procedure parameters will be passed by value and will be of a simple - ordinal type. The record or pointer type will not be properly allocated in memory.
MP allows you to transfer up to 8 parameters to the function. There are three ways to pass parameters - by value, constant (CONST) and variable (VAR). We return the result of the function by assigning it to the function name or using the automatically declared RESULT variable, e.g:
function add(a,b: word): cardinal; begin Result := a+b; end; function mul(a,b: word): cardinal; begin mul := a*b; end;Available function modifiers: OVERLOAD, ASSEMBLER, FORWARD, REGISTER, INTERRUPT (not recommended for functions).
It is possible to recurse functions, provided that the function parameters will be passed by value and will be of a simple - ordinal type. The record or pointer type will not be properly allocated in memory.
FUNCTION AND PROCEDURE MODIFIERS
procedure color(a: byte); assembler; asm { mva a 712 }; end;
procedure sum(var i: integer; a,b: integer); overload; begin i := a+b; end; procedure sum(var i: integer; a,b,c: integer); overload; begin i := a+b+c; end; function fsum(a,b: word): cardinal; assembler; overload; asm { adw a b result }; end; function fsum(a,b: real): real; overload; begin Result := a+b; end;
procedure name [(formal-parameter-list)]; forward; ... ... ... procedure name; begin end;
procedure name (a,b,c: cardinal); register; // a = edx // b = ecx // c = eax
procedure dli; interrupt; asm { pha lda #$c8 sta wsync sta $d01a pla }; end; // the RTI instruction gets inserted automatically
UNITS
Unitsunit test; interface type TUInt24 = record byte0: byte; byte1: byte; byte2: byte; end; const LoRes = 1; MedRes = 2; HiRes = 3; procedure Print(a: string); implementation uses test2; procedure Print(a: string); begin writeln(a); end; end.
BASE LIBRARY
In Mad-Pascal's 'LIB' directory you will find the base modules (unit) needed for compilation, such as SYSTEM, CRT, GRAPH, SYSUTILS, MATH, DOS. In the program, they are selected by the USES instruction, e.g:uses crt, sysutils;By default, the SYSTEM module is added to the USES list and compiled first.
[ Constants ]
M_PI_2 = 6.283285; // pi * 2 D_PI_2 = 1.570796; // pi / 2 D_PI_180 = 0.017453; // pi / 180 mGTIA = 0; mVBXE = $80; WINDOW = $10; NARROW = $20; VBXE_XDLADR = $0000; // XDLIST VBXE_MAPADR = $1000; // COLOR MAP ADDRESS VBXE_BCBADR = $0100; // BLITTER LIST ADDRESS VBXE_OVRADR = $5000; // OVERLAY ADDRESS VBXE_WINDOW = $B000; // 4K WINDOW $B000..$BFFF iDLI = 0; iVBL = 1; CH_DELCHR = $FE; CH_ENTER = $9B; CH_ESC = $1B; CH_CURS_UP = 28; CH_CURS_DOWN = 29; CH_CURS_LEFT = 30; CH_CURS_RIGHT = 31; CH_TAB = $7F; CH_EOL = $9B; CH_CLR = $7D; CH_BEL = $FD; CH_DEL = $7E; CH_DELLINE = $9C; CH_INSLINE = $9D; COLOR_BLACK = $00; COLOR_WHITE = $0e; COLOR_RED = $32; COLOR_CYAN = $96; COLOR_VIOLET = $68; COLOR_GREEN = $c4; COLOR_BLUE = $74; COLOR_YELLOW = $ee; COLOR_ORANGE = $4a; COLOR_BROWN = $e4; COLOR_LIGHTRED = $3c; COLOR_GRAY1 = $04; COLOR_GRAY2 = $06; COLOR_GRAY3 = $0a; COLOR_LIGHTGREEN = $cc; COLOR_LIGHTBLUE = $7c;
[ Types ]
TPoint | TPoint = record x,y: SmallInt end;;
Coordinates definition (x,y). |
TRect | TRect = record left, top, right, bottom: smallint end;
Definition of the position and size of a quadrilateral with parameters (left, top) - left upper corner, (right, bottom) - right lower corner. |
TString | TString = string[32];
Definition of a short character string used for file name transfer etc. |
[ Variables ]
IOResult | IOResult: byte;
Error code (>127) for the most recent I/O operation. |
ScreenWidth | ScreenWidth: word = 40;
A variable that stores the current screen width. The default value is 40 for the editor screen. |
ScreenHeight | ScreenHeight: word = 24;
A variable that stores the current screen height. The default value is 24 for the editor screen. |
[ Procedures and functions ]
Abs | function Abs(x: real): real; function Abs(x: integer): integer; This function calculates the absolute value of the given number. The absolute value of a non-negative number is the same number, and a negative number is the opposite. The function returns a result of the integer type when given an integral argument. |
ArcTan | function ArcTan(x: real): real;
The ArcTan function (arcus tangens) returns an angle whose tangent is x. |
Assign | procedure Assign(var F:File; FileName:string)
The procedure assigns file variable F to a file named FileName. To refer to a file, always use the Assign procedure first. In further operations, files are identified by a file variable, not by name. |
BinStr | function BinStr(Value: cardinal; Digits: byte): TString;
The BinStr function returns a character string with a binary representation of the value. Digits specifies the length of the string, which can be up to 32 characters. |
Concat | function Concat(a,b: string): string; assembler function Concat(a: string; b: char): string; assembler; function Concat(a: char; b: string): string; assembler; function Concat(a,b: char): string; The function combines two text strings into a new character string. |
Blockread Blockwrite |
procedure BlockRead(var f: file; var Buf; Count: word; var Result: word); procedure BlockWrite(var f: file; var Buf; Count: word; var Result: word); The BlockRead procedure reads from the file to the Buf variable no more than Count bytes and places in the Result variable the number of actually read bytes (which may be less than expected e.g. due to the actual file length). The BlockWrite procedure works the same way, only writes to file. |
Chr | function Chr(X: Byte): Char;
The function returns a character (Char) with the corresponding ATASCII code given in the parameter. Chr(65); // Returns the character A Chr(90); // Returns the character Z Chr(32); // Returns the space characterAlternatively, with the Chr function, to get the right character we can use its ATASCII code before it # Writeln(#65); // The A character Writeln(#65#32#65); // Writes ‘A Z’ |
Cos | function Cos(x: real): real;
Cosine of angle (x in radians). |
Close | procedure Close(var f: file);
Procedure for closing an open file of any type. Any file opened with Reset or Rewrite should be closed with Close. |
Dec | procedure Dec(var X [, N: int]);
The procedure reduces the value of parameter X by 1 or the value of parameter N. The value of parameter X can be of the CHAR, BYTE, WORD, CARDINAL type. The DEC procedure generates the optimal code, it is recommended for use in loops instead of the subtraction (-) operator.dec(tmp); dec(tmp[2]); |
DeleteFile | function DeleteFile(FileName: string): Boolean;
The function allows you to delete a file from the disk named FileName, returns TRUE when the operation was successful, FALSE in case of an error (usually due to write protection or wrong file name). |
DPeek | function DPeek(a: word): word;
The function returns a word from address A. |
DPoke | procedure DPoke(a: word; value: word);
The procedure saves the word Value at address A. |
Eof | function Eof(var f: file): Boolean;
The function returns a True logical value if the end of the file is reached. |
Exit | When the Exit procedure is called, the program block in which the call was made leaves immediately. It can be used to exit the loop, exit the procedure/function or main program. |
Exp | function Exp(x: real): real;
A function that raises the number e (=2.71) to the power given by the argument. |
FilePos | function FilePos(var f: file): cardinal;
The function returns the current file position. The file cannot be textual and must be open (e.g. with the Reset command). Bits 0...15 of the returned value is the disc sector number, bits 16...23 is the sector position [0...255]. This is similar to the NOTE instruction. |
FileSize | function FileSize(var f: file): cardinal;
The function returns the file length in bytes (Sparta DOS X). The file cannot be textual and must be open (e.g. with the Reset command). |
FillChar | procedure FillChar(a: pointer; count: word; value: char);
The procedure fills the buffer specified in parameter X with identical characters or bytes. The Value parameter must specify the data, while Count must specify the amount of data to be assigned to the buffer. var Buffer : array[0..100] of Char; begin FillChar(Buffer, SizeOf(Buffer), 'A'); end. |
Frac | function Frac(x: real): real;
Returns the fractional part of the number x as a real number. |
GetIntVec | procedure GetIntVec(intno: Byte; var vector: pointer);
The procedure reads the interrupt vector address according to the INTNO code. The currently permitted codes are:
|
Halt | procedure halt;
The call will exit the program immediately. You can (optionally) specify an error code, in MP it is ignored. |
Hi | function Hi(x): byte
Function that returns the upper byte of parameter X. |
HexStr | function HexStr(Value: cardinal; Digits: byte): TString;
The HexStr function returns a character string with the hexadecimal representation of Value. Digits specify the length of the string, which can be up to 32 characters. |
Inc | procedure Inc(var X [, N: int]);
The procedure increases the value of parameter X by 1 or the value of parameter N. The value of parameter X can be of the CHAR, BYTE, WORD or CARDINAL type. The INC procedure generates the optimal code, it is recommended for use in loops, instead of the addition operator (+).inc(tmp); inc(tmp[2]); |
Int | function Int(x: real): real;
The function returns the integral part of an argument that is a real number. |
IOResult | var IOResult: byte;
The IOResult variable stores the last I/O operation error. I/O error codes |
Ln | function Ln(x: real): real;
Function computing the natural logarithm (base e) from a given number. The function argument must be positive! |
Lo | function Lo(x): byte;
Function that returns the lower byte of parameter X. |
LowerCase | function LowerCase(a: char): char;
The function changing the uppercase characters 'A'...'Z' to the corresponding lowercase characters 'a'...'z'. |
Move | procedure Move(source, dest: pointer; count: word);
The procedure is used to copy data from the source (parameter Source) to the buffer marked as destination (parameter Dest). The amount of data copied is determined by the Count parameter. |
OctStr | function OctStr(Value: cardinal; Digits: byte): TString;
The OctStr function returns a character string with an octal representation of Value. Digits specify the length of the string, which can be up to 32 characters. |
Odd | function Odd(x: cardinal): Boolean; function Odd(x: integer): Boolean; Odd returns True if the number specified in the X parameter is odd, False if it is even. |
Ord | function Ord(X);
This function is the opposite of Chr. From the character given as a parameter it returns its code in ATASCII. Ord('A'); // Returns 65 Ord('Z'); // Returns 90 Ord(' '); // Returns 32 |
ParamCount | function ParamCount: byte;
The ParamCount function returns the number of available arguments (Sparta Dos X, BWDos), i.e. the maximum index for the ParamStr function. ParamCount specifies the number of parameters transferred to the program from the command line. |
ParamStr | function ParamStr(Index: byte): TString;
The ParamStr function returns program parameters (Sparta Dos X, BWDos). Index is the number of a parameter, i.e. a string of characters separated by a space. If you run the TEST.EXE program in this way:
|
Pause | procedure Pause; procedure Pause(n: word); Pauses the program for N * 1.50s |
Peek | function Peek(a: word): byte;
Returns a byte from address A. |
Point | function Point(AX, AY: smallint): TPoint;
Based on AX and AY parameters a TPoint record is created. |
PointsEqual | function PointsEqual(const P1, P2: TPoint): Boolean;
The function checks whether the coordinate values specified in parameters P1 and P2 are equal. In this case, the function returns the True value. |
Poke | procedure Poke(a: word; value: byte);
The procedure saves the Value byte to address A. |
Pi | Returns the value of the pi number. |
Pred | function Pred(X: TOrdinal): TOrdinal;
The predecessor of element X. |
Random | function Random: Real; assembler;
The function returns a random value from the interval <0 .. 1> function Random(range: byte): byte; assembler;The function returns a random value from the interval <0 ... range-1>, in case of Range=0 returns a random value from the interval <0 .. 255 > function Random(range: smallint): smallint;The function returns a random value from the interval <0 ... range-1> |
ReadConfig | function ReadConfig(devnum: byte): cardinal;
DEVNUM station status readout. The result is four bytes of DVSTAT ($02EA..$02ED).
Byte 0 ($02ea): Bit 0:Indicates the last command frame had an error. Bit 1:Checksum, indicates that there was a checksum error in the last command or data frame Bit 2:Indicates that the last operation by the drive was in error. Bit 3:Indicates a write protected diskette. 1=Write protect Bit 4:Indicates the drive motor is on. 1=motor on Bit 5:A one indicates MFM format (double density) Bit 6:Not used Bit 7:Indicates Density and a Half if 1 Byte 1 ($02eb): Bit 0:FDC Busy should always be a 1 Bit 1:FDC Data Request should always be 1 Bit 2:FDC Lost data should always be 1 Bit 3:FDC CRC error, a 0 indicates the last sector read had a CRC error Bit 4:FDC Record not found, a 0 indicates last sector not found Bit 5:FDC record type, a 0 indicates deleted data mark Bit 6:FDC write protect, indicates write protected disk Bit 7:FDC door is open, 0 indicates door is open Byte 2 ($2ec): Timeout value for doing a format. Byte 3 ($2ed): not used, should be zero |
ReadSector | procedure ReadSector(devnum: byte; sector: word; var buf);
Read the SECTOR sector of the floppy disk in the DEVNUM drive and save it in the BUF buffer. |
Rect | function Rect(ALeft, ATop, ARight, ABottom: smallint): TRect;
A TRect record is created from the parameters. |
RenameFile | function RenameFile(OldName, NewName: string): Boolean;
The function allows to change the OldName file name to the new NewName, returns TRUE when the operation is successful, FALSE in case of an error (usually due to write protection or wrong file name). RenameFile('D:OLDNAME.TMP', 'NEWNAME.TMP'); |
Reset | procedure Reset(var f: file; l: Word);
Opens an existing file with the name passed to F by the Assign command. Optionally, we can specify the record size in bytes L, the default is 128. |
Rewrite | procedure Rewrite(var f: file; l: Word);
Creates and opens a new file. F is the name given by the Assign command. Optionally, we can specify the record size in bytes L, the default is 128. |
Round | function Round(x: real): integer;
The Round function rounds the given real number to the nearest integer. |
Seek | procedure Seek(var f: file; N: cardinal);
Sets the position in the file to N. N should be the value returned by FilePos. This is equivalent to the POINT instruction. |
SetLength | procedure SetLength(var S: string; Len: byte);
Sets the length of the string S to LEN. |
SetIntVec | procedure SetIntVec(intno: Byte; vector: pointer);
The procedure sets the interrupt vector address according to the INTNO code. The currently permitted codes are:
|
Sin | function Sin(x: real): real;
Angle sine (x in radians). |
Succ | function Succ(X: TOrdinal): TOrdinal;
The successor to element X. |
Space | function Space(Len: Byte): ^char;
The function generates a new LEN-character string filled with space characters. |
SizeOf | function SizeOf(X: AnyType): byte;
Function returns the size of the specified variable (or type) in bytes. |
Str | procedure Str(var X: TNumericType; var S: string);
The procedure converts the number X into a string of S characters. |
StringOfChar | procedure StringOfChar(ch: Char; len: byte): ^char;
The function generates a new LEN character string filled with CH characters. |
Sqr | function Sqr(x: real): real; function Sqr(x: integer): integer; Function that calculates the square of a given number. |
Sqrt | function Sqrt(x: real): real; function Sqrt(x: single): single; function Sqrt(x: integer): single; The function that calculates the square root of a given number. |
Trunc | function Trunc(x: real): integer;
The function returns the integer part of the real number as a whole number. |
UpCase | function UpCase(a: char): char;
The function changing the lowercase characters 'a'...'z' to the corresponding uppercase characters 'A'...'Z'. |
Val | procedure Val(const S: string; var V; var Code: Byte);
The procedure converts a sequence of S characters into a number V. Code will take the value 0 if there were no wrong characters, otherwise it will take the index of the character that caused the conversion error. |
WriteSector | procedure WriteSector(devnum: byte; sector: word; var buf);
Record the SECTOR sector of the floppy disk in DEVNUM station based on the BUF buffer. |
[ Constants ]
CN_START_SELECT_OPTION = 0; CN_SELECT_OPTION = 1; CN_START_OPTION = 2; CN_OPTION = 3; CN_START_SELECT = 4; CN_SELECT = 5; CN_START = 6; CN_NONE = 7;
[ Variables ]
Consol | Consol: byte absolute $d01f;
The variable 'Consol' returns the code of the console key(s) pressed. |
TextAttr | TextAttr: byte = 0;
The variable 'TextAttr' stores the value that is added to each character displayed, e.g. TextAttr = $80 will cause the characters to be displayed in reverse. |
WhereX | WhereX: byte absolute $54;
The variable 'WhereX' stores the current horizontal cursor position. |
WhereY | WhereY: byte absolute $55;
The variable 'WhereY' stores the current vertical cursor position. |
[ Procedures and functions ]
ClrEol | procedure ClrEol;
The procedure clears the line from the current cursor position to the right of the screen edge. The cursor position does not change. |
ClrScr | procedure ClrScr;
The procedure clears the editor screen, executes the CH_CLR character code. |
CursorOff | procedure CursorOff;
The procedure disables the cursor. |
CursorOn | procedure CursorOn;
The procedure enables the cursor. |
Delay | procedure Delay(MS: Word);
The procedure waits a set number of milliseconds MS. Delay(1000) generates a delay of approximately one second. |
DelLine | procedure DelLine;
The procedure deletes the line at the current cursor position, executes the CH_DELLINE character code |
GotoXY | procedure GotoXY(x, y: byte);
The procedure sets a new cursor position. |
InsLine | procedure InsLine;
The procedure inserts an empty line at the current cursor position, executes the CH_INSLINE character code |
Keypressed | function Keypressed: Boolean;
The function returns TRUE when a key is pressed, otherwise it returns FALSE. |
NoSound | procedure NoSound;
The procedure mutes the channels of both POKEY-i ($D200, $D210) |
ReadKey | function ReadKey: char;
The function returns the code of the keypad key pressed. |
Sound | procedure Sound(Chan,Freq,Dist,Vol: byte);
The procedure plays sound on the POKEY CHAN channel (0..3, 4..7), FREQ frequency (0..255), DIST filters (0..7), VOL volume (0..15). |
TextBackground | procedure TextBackground(a: byte);
The procedure sets a new character background color (works best with VBXE enabled). |
TextColor | procedure TextColor(a: byte);
The procedure sets a new character color (works best with VBXE enabled). |
[ Constants ]
{ graphic drivers } D1bit = 11; D2bit = 12; D4bit = 13; D6bit = 14; // 64 colors Half-brite mode - Amiga D8bit = 15; D12bit = 16; // 4096 color modes HAM mode - Amiga m640x480 = 8 + 16; { error 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; grIOerror = -12; grInvalidFont = -13; grInvalidFontNum= -14; grInvalidVersion= -18;
[ Variables ]
GraphResult | GraphResult : byte;
|
[ Procedures and functions ]
Bar | procedure Bar(x1, y1, x2, y2: Smallint);
Rectangle, e.g. for bar graphs. |
Bar3D | procedure Bar3D(x1, y1, x2, y2: smallint; depth: word; top: boolean);
A three-dimensional pole. |
Circle | procedure Circle(x0,y0,radius: word);
A circle. |
ClipLine | procedure ClipLine(x1, y1, x2, y2: smallint);
|
Ellipse | procedure Ellipse(x0, y0, a, b: word);
An ellipse. |
FillEllipse | procedure FillEllipse(x0, y0, a, b: word);
A filled ellipse. |
FillRect | procedure FillRect(Rect: TRect);
A filled rectangle. |
FloodFill | procedure FloodFill(x, y: smallint; color: byte);
Flood-filling an enclosed screen area. |
GetColor | function GetColor: byte; assembler;
Returns the current drawing color. |
GetMaxX | function GetMaxX: word;
Returns the highest value of the X coordinate on the screen. |
GetMaxY | function GetMaxY: word;
Returns the highest value of the Y coordinate on the screen. |
GetPixel | function GetPixel(x,y: smallint): byte;
Returns the colour of the point on the screen. |
GetX | function GetX: smallint;
Returns the current X coordinate of the graphical cursor. |
GetY | function GetY: smallint;
Returns the current Y coordinate of the graphical cursor. |
InitGraph | procedure InitGraph(mode: byte); procedure InitGraph(driver, mode: byte; pth: TString); Initiates graphic mode. |
Line | procedure Line(x0, y0, x1, y1: smallint);
A straight line. |
LineTo | procedure LineTo(x, y: smallint);
A straight line from the current cursor position to the given point. |
MoveRel | procedure MoveRel(Dx, Dy: smallint);
Moves the graphical cursor. |
MoveTo | procedure MoveTo(x, y: smallint);
Moves the graphical cursor to the given point. |
PutPixel | procedure PutPixel(x,y: smallint); procedure PutPixel(x,y: smallint; color: byte); Light a point on the screen. |
Rectangle | procedure Rectangle(x1, y1, x2, y2: smallint); procedure Rectangle(Rect: TRect); A rectangle. |
SetBkColor | procedure SetBkColor(color: byte);
Sets the background color. |
SetClipRect | procedure SetClipRect(x0,y0,x1,y1: smallint); procedure SetClipRect(Rect: TRect);
|
SetColor | procedure SetColor(color: byte);
Set the color of the pen. |
SetColorMapEntry | procedure SetColorMapEntry; procedure SetColorMapEntry(a,b,c: byte);
|
SetColorMapDimensions | procedure SetColorMapDimensions(w,h: byte);
|
[ Constants ]
faReadOnly = $01; faHidden = $02; faSysFile = $04; faVolumeID = $08; faDirectory = $10; faArchive = $20; faAnyFile = $3f;
[ Types ]
TSearchRec |
TSearchRec = record Attr: Byte; Name: TString; FindHandle: Pointer; end;
|
[ Procedures and functions ]
AnsiUpperCase | function AnsiUpperCase(const a: string): string;
The function converts characters from the A string to uppercase. |
Beep | procedure Beep;
The buzzer signal. |
Click | procedure Click;
Keyboard signal. |
DeleteFile | function DeleteFile(var FileName: TString): Boolean;
The function deletes the file specified in the FileName parameter, returns TRUE when the operation is successful. |
ExtractFileExt | function ExtractFileExt(const FileName: string): TString;
Based on the file name or full path to the file (specified in FileName parameter), the function returns an extension (preceded by a dot - e.g. .txt). |
FileExists | function FileExists(const FileName: string): Boolean;
The function checks whether the file specified in the FileName parameter exists (True) or does not (False). |
FindFirst | function FindFirst(const FileMask: TString; Attributes: Byte; var SearchResult: TSearchRec): byte;
FindFirst finds files that match the FileMask pattern and have the attributes specified in Attributes. If files matching the template are found, the first one is returned in the SerchResult variable. |
FindNext | function FindNext(var f: TSearchRec): byte;
The function moves to the next record found previously using FindFirst. The parameter must indicate the record that was previously used in the FindFirst function. |
FindClose | procedure FindClose(var f: TSearchRec);
The procedure releases resources (memory) allocated by the FindFirst function. This procedure should be called each time the search is completed. |
GetTickCount | function GetTickCount: cardinal;
GetTickCount returns a 24-bit timer (PEEK(RTCLOK+2) + PEEK(RTCLOK+1)*256 + PEEK(RTCLOK)*65536). This is useful for time measurement. |
IntToHex | function IntToHex(Value: cardinal; Digits: byte): TString;
The function converts a numeric value to its hexadecimal string equivalent. |
IntToStr | function IntToStr(a: integer): ^char;
The function is used to convert an integer given in the parameter into a string form. |
RenameFile | function RenameFile(var OldName,NewName: TString): Boolean;
RenameFile attempts to rename the file (specified in OldName parameter) to NewName. If the operation is successful, the function will return True; otherwise, False. It may happen that the function cannot change its name (e.g. when the application does not have the right to do so) - then the function will return False. |
StrToFloat | function StrToFloat(var s: TString): real;
The function converts the string to a Real-type floating point. |
StrToInt | function StrToInt(const S: char): byte; function StrToInt (const S: TString): integer; The function is used to convert the text stored in the S variable to integer if possible. |
The memory map for VBXE is defined in the SYSTEM module
VBXE_XDLADR = $0000; // XDLIST VBXE_MAPADR = $1000; // COLOR MAP ADDRESS VBXE_BCBADR = $0100; // BLITTER LIST ADDRESS VBXE_OVRADR = $5000; // OVERLAY ADDRESS VBXE_WINDOW = $B000; // 4K WINDOW $B000..$BFFF
[ Constants ]
LoRes = 1; MedRes = 2; HiRes = 3;
[ Types ]
TUInt24 |
record byte0: byte; byte1: byte; byte2: byte; end; |
24-bit type used to define VBXE memory addresses. |
TXDL |
record xdlc_: word; rptl_: byte; xdlc: word; rptl: byte; ov_adr: TUInt24; ov_step: word; mp_adr: TUInt24; mp_step: word; mp_hscrol: byte; mp_vscrol: byte; mp_width: byte; mp_height: byte; ov_width: byte; ov_prior: byte; end; |
TXDL type used for GetXDL and SetXDL procedures. Allows you to modify the program for VBXE used by MadPascal. |
TBCB |
record src_adr: TUInt24; src_step_y: smallint; src_step_x: shortint; dst_adr: TUInt24; dst_step_y: smallint; dst_step_x: shortint; blt_width: word; blt_height: byte; blt_and_mask: byte; blt_xor_mask: byte; blt_collision_mask: byte; blt_zoom: byte; pattern_feature: byte; blt_control: byte; end; |
Type TBCB (21 bytes), Blitter Code Block. Definition of program block type for VBXE Blitter. |
TVBXEMemoryStream |
Object Position: cardinal; Size: cardinal; // 0..Size-1 procedure Create; procedure Clear; procedure SetBank; procedure ReadBuffer(var Buffer; Count: word); procedure WriteBuffer(var Buffer; Count: word); function ReadByte: Byte; function ReadWord: Word; function ReadDWord: Cardinal; procedure WriteByte(b: Byte); procedure WriteWord(w: Word); procedure WriteDWord(d: Cardinal); end; |
The TVBXEMemoryStream object allows linear access to VBXE memory. |
[ Procedures and functions ]
BlitterBusy | function BlitterBusy: Boolean; assembler;
The function returns TRUE if the VBXE blitter is busy executing a blitter program. |
ColorMapOff | procedure ColorMapOff; assembler;
Disabling the color map in XDLIST for VBXE. |
ColorMapOn | procedure ColorMapOn; assembler;
Enabling color map in XDLIST for VBXE. |
DstBCB | procedure DstBCB(var a: TBCB; dst: cardinal);
Procedure to change the destination address (dst_adr) in the blitter A program. |
GetXDL | procedure GetXDL(var a: txdl); register; assembler;
The procedure rewrites the XDLIST program from the VBXE_XDLADR address in VBXE memory to variable A. |
IniBCB | procedure IniBCB(var a: TBCB; src,dst: cardinal; w0, w1: smallint; w: word; h: byte; ctrl: byte);
The INIBCB procedure allows to initiate the memory for the blitter program at address A. Additional parameters define the address from which the SRC data will be copied, the destination address of the copied DST data, the width of the source data window W0, the target data window W1, the size of the result window, its width W, its height H, and define the final parameters of the blitter program block CTRL (the set bit 3 of CTRL commands the blitter to read the next program and execute it). |
OverlayOff | procedure OverlayOff; assembler;
Disable overlay mode in XDLIST. |
RunBCB | procedure RunBCB(var a: TBCB); assembler;
Starting the VBXE blitter based on program address A. |
SetHorizontalRes | procedure SetHorizontalRes(a: byte); assembler; procedure SetHRes(a: byte); assembler; Establish overlay mode in XDLIST (LoRes: 160x240x256c, MedRes: 320x240x256c, HiRes: 640x240x16c). |
VBXEMemoryBank | procedure VBXEMemoryBank(b: byte); assembler;
Enabling the 4K VBXE bank in the XE/XL memory window $B000..$BCFF |
SetXDL | procedure SetXDL(var a: txdl); register; assembler;
The procedure rewrites program A to the address VBXE_XDLADR in VBXE memory. |
SrcBCB | procedure SrcBCB(var a: TBCB; src: cardinal);
Procedure to change the source address (src_adr) in blitter A. |
VBXEControl | procedure VBXEControl(a: byte); assembler;
The procedure sets the value of FX_VIDEO_CONTROL. |
VBXEOff | procedure VBXEOff
Shutdown and reset VBXE. |
[ Procedures and functions ]
ArcCos | function ArcCos(x: real): real;
Arcus cosinus is the opposite of Cos (cosinus). The value of the X parameter must belong to the interval sealed on both sides <-1; 1>. The value returned by the function is the angle from the interval <0; 2*pi> expressed in the arc (radians). |
ArcSin | function ArcSin(x: real): real;
The ArcSin function is used to calculate the mathematical function of the arcus sinus from the number X. It is the opposite of the sine function, i.e. sin(arcsin(x)) = x. |
ArcTan2 | function ArcTan2(y, x: real) : real;
The function calculates arcus tangens (inverse of tangens) from Y/X and returns the value in radians. |
Ceil | function Ceil(a: real): smallint;
The function returns the smallest integer greater or equal to the integer specified in the parameter. |
CycleToRad | function CycleToRad(cycle : real) : real;
The CycleToRad function converts the value of the angle expressed in cycles (rotations) to the angle expressed in radians. |
DegNormalize | function DegNormalize(deg : real) : real;
|
DegToGrad | function DegToGrad(deg : real) : real;
The DegToGrad function converts the value of the angle expressed in degrees to the angle expressed in gradians. |
DegToRad | function DegToRad(deg : real) : real;
The DegToRad function converts the value of the angle expressed in degrees to the angle expressed in an arc, or radians. |
DivMod | procedure DivMod(Dividend: integer; Divisor: Word; var r, Remainder: Word); procedure DivMod(Dividend: integer; Divisor: Word; var r, Remainder: smallint);
|
EnsureRange | function EnsureRange(const AValue, AMin, AMax: byte): Integer; function EnsureRange(const AValue, AMin, AMax: Integer): Integer;
|
Floor | function Floor(a: real): smallint;
The function returns the nearest integer less than or equal to the parameter. |
FMod | function FMod(a, b: real): real;
The FMod function returns the remainder from the division of two real numbers. |
GradToDeg | function GradToDeg(grad : real) : real;
The GradToDeg function converts the value of the angle expressed in gradians to the angle expressed in degrees. |
GradToRad | function GradToRad(grad : real) : real;
The GradToRad function converts the value of the angle expressed in gradians to the angle expressed in radians. |
InRange | function InRange(const AValue, AMin, AMax: byte): Boolean; function InRange(const AValue, AMin, AMax: Integer): Boolean;
|
IsNan | function IsNan(const d : Single): Boolean;
The function checks whether the value of parameter D is a valid number. |
Log2 | function log2(x : single): single;
The function returns the base two logarithm for a positive real parameter X. |
Log10 | function log10(x : single): single;
The function returns the base ten logarithm for a positive real parameter X. |
LogN | function logN(n,x : single): single;
The function returns the base N>0 logarithm for a positive real parameter X. |
Max | function Max(a, b: real): real; function Max(a, b: integer): integer; The overloaded function compares the values of two parameters: A and B, and returns the one that's greater. |
Min | function Min(a, b: real): real; function Min(a, b: integer): integer; The overloaded function compares the values of the two parameters A and B, and returns the value of the one that is smaller. |
Power | function Power(base : real; const exponent : shortint): real; power(base : integer; const exponent : shortint): integer; The function raises the number A to any power N, power can be a fraction. |
RadToCycle | function RadToCycle(rad : real) : real;
The RadToCycle function converts the value of the angle expressed in radians into an angle expressed in cycles (rotations). |
RadToDeg | function RadToDeg(rad : real) : real;
The RadToDeg function converts the value of the angle expressed in radians to the angle expressed in degrees (deg). |
RadToGrad | function RadToGrad(rad : real) : real;
RadToGrad converts the value of the angle expressed in radians to the angle expressed in gradians. |
RandG | function RandG(mean, stddev : single) : single;
RandG represents a pseudo-random number generator with a Gauss distribution around the mean value Mean. The StdDev parameter is the standard deviation of generated numbers from the mean value. |
RandomRange | function RandomRange(const aFrom, aTo: smallint): smallint;
The function returns a random number from the AFrom - ATo range (including ATo). |
RandomRangeF | function RandomRangeF(const min, max: single): single;
|
Tan | function Tan(x: Real): Real;
The function returns the tangent value of the angle specified in parameter X. |