sinclair.basic
Class ZX81SysVars

java.lang.Object
  extended bysinclair.basic.ZX81SysVars

public class ZX81SysVars
extends java.lang.Object

This class provides utilities to access ZX81 system variables.

From the ZX81 manual:

   1       16384   ERR_NR  1 less than report code.
   X1      16385   FLAGS   Various flags to control Basic. 
   X2      16386   ERR_SP  Address of first item on machine stack (after GOSUB returns). 
   2       16388   RAMTOP  Address of first byte above BASIC system area. 
                           You can poke this to make NEW reserve space above that 
                           area (see chapter 26) or to fool CLS into setting up a 
                           minimal display file (chapter 27). Poking RAMTOP has no 
                           effect until one of these two is executed. 
   N1      16390   MODE    Specifies K, L, F or G cursor. 
   N2      16391   PPC     Line number of statement currently being executed. 
                           Poking this has no lasting effect except in the last line of the program. 
   S1      16393   VERSN   0 identifies ZX81 Basic in saved programs. 
   S2      16394   E_PPC   Number of cuurent line (with cursor). 
   SX2     16396   D_FILE  Address of display file. 
   S2      16398   DF_CC   Address of print position in display file. 
   SX2     16400   VARS    Address of variables area. 
   SN2     16402   DEST    Address of variable in assignment. 
   SX2     16404   E_LINE  Address of line being typed. 
   SX2     16406   CH_ADD  Address of the next character to be interpreted: 
                           the character after the argument of PEEK, or the 
                           NEWLINE at the end of a POKE statement. 
   S2      16408   X_PTR   Address of character preceding the S marker. 
   SX2     16410   STKBOT  Address of calculator stack. 
   SX2     16412   STKEND  Address of start of spare space. 
   SN1     16414   BREG    Calculator's B register. 
   SN2     16415   MEM     Address of area used for calculator's memory.
                           (Usually MEMBOT, but not always.) 
   S1      16417   Unused. 
   SX1     16418   DF_SZ   The number of lines (including one blank line) 
                           in the lower part of the screen. 
   S2      16419   S_TOP   The number of the top program line in automatic listings. 
   SN2     16421   LAST_K  Shows which keys pressed. 
   SN1     16423           Debounce status of keyboard. 
   SN1     16424   MARGIN  Number of blank lines above or below picture: 
                           55 in Britain, 31 in America. 
   SX2     16425   NXTLIN  Address of next program line to be executed. 
   S2      16427   OLDPPC  Line number to which CONT jumps. 
   SN1     16429   FLAGX   Various Flags. 
   SN2     16430   STRLEN  Length of string type destination in assignment. 
   SN2     16432   T_ADDR  Address of next item in syntax table (very unlikely to be useful). 
   S2      16434   SEED    The seed for RND. This is the variable that is set by RAND. 
   S2      16436   FRAMES  Counts the frames displayed on the television. 
                           Bit 15 is 1. Bits 0 to 14 are decremented for each frame set to the
                           television. This can be used for timing, but PAUSE also uses it. 
                           PAUSE resets to 0 bit 15, & puts in bits 0 to 14 the length of the 
                           pause. When these have been counted down to zero, the pause stops. 
                           If the pause stops because of a key depression, bit 15 is set to 1 again. 
   S1      16438   COORDS  x-coordinate of last point plotted. 
   S1      16439           y-coordinate of last point plotted. 
   S1      16440   PR_CC   Less significant byte of address of next position for LPRINT to print as (in PRBUFF). 
   SX1     16441   S_POSN  Column number for print position. 
   SX1     16442           Line number for print position. 
   S1      16443   CDFLAG  Various flags. Bit 7 is on (1) during compute & display mode. 
   S33     16444   PRBUFF  Printer Buffer. 33rd character = newline. 
   SN30    16477   MEMBOT  Calculator's memory area; used to store numbers that cannot conveniently 
                           be put on the calculator stack. 
   S2      16507   unused. 
 

Author:
hldswrth

Field Summary
static int BREG
          Calculator's B register.
static int CDFLAG
          Various flags.
static int CH_ADD
          Address of the next character to be interpreted.
static int COORDS
          X-coordinate of last point plotted.
static int COORDY
          Y-coordinate of last point plotted.
static int D_FILE
          Address of display file.
static int DEBOUN
          Debounce status of keyboard.
static int DEST
          Address of variable in assignment.
static int DF_CC
          Address of print position in display file.
static int DF_SZ
          The number of lines (including one blank line) in the lower part of the screen.
static int E_LINE
          Address of line being typed.
static int E_PPC
          Number of cuurent line (with cursor).
static int END
          The end of system variables.
static int ERR_NR
          1 less than report code.
static int ERR_SP
          Address of first item on machine stack (after GOSUB returns).
static int FLAGS
          Various flags to control Basic.
static int FLAGX
          Various Flags.
static int FRAMES
          Counts the frames displayed on the television.
static int LAST_K
          Shows which keys pressed.
static int MARGIN
          Number of blank lines above or below picture.
static int MEM
          Address of area used for calculator's memory.
static int MEMBOT
          Calculator's memory area.
static int MODE
          Specifies K, L, F or G cursor.
static int NXTLIN
          Address of next program line to be executed.
static int OLDPPC
          Line number to which CONT jumps.
static int PPC
          Line number of statement currently being executed.
static int PR_CC
          Less significant byte of address of next position for LPRINT to print as (in PRBUFF).
static int PRBUFF
          Printer Buffer.
static int RAMTOP
          Address of first byte above BASIC system area.
static int S_POSL
          Line number for print position.
static int S_POSN
          Column number for print position.
static int S_TOP
          The number of the top program line in automatic listings.
static int SAVE_START
          The address of the system variable area that a save starts at.
static int SEED
          The seed for RND.
static int START
          The address of the first system variable.
static int STKBOT
          Address of calculator stack.
static int STKEND
          Address of start of spare space.
static int STRLEN
          Length of string type destination in assignment.
static int T_ADDR
          Address of next item in syntax table (very unlikely to be useful).
static int UN1
          Unused.
static int UN2
          Unused.
static int VARS
          Address of variables area.
static int VERSN
          Identifies ZX81 Basic in saved programs.
static int X_PTR
          Address of character preceding the S marker.
 
Constructor Summary
ZX81SysVars()
           
 
Method Summary
static void dumpSystemVariables(byte[] memory, int start, int firstVar, java.lang.StringBuffer buff)
          Dump the system variables in the given area of memory.
static int getVariableValue(byte[] memory, int varAddr, int varSize)
          Obtain the value of a system variable.
static int getVariableValue(byte[] memory, int start, int firstVar, int varAddr, int varSize)
          Obtain the value of a system variable.
static int getVariableValueOffset(byte[] memory, int varAddr, int varSize)
          Obtain the value of a system variable, offset into the given array.
static int getVariableValueOffset(byte[] memory, int start, int firstVar, int varAddr, int varSize)
          Obtain the value of a system variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

START

public static final int START
The address of the first system variable.

See Also:
Constant Field Values

ERR_NR

public static final int ERR_NR
1 less than report code.

See Also:
Constant Field Values

FLAGS

public static final int FLAGS
Various flags to control Basic.

See Also:
Constant Field Values

ERR_SP

public static final int ERR_SP
Address of first item on machine stack (after GOSUB returns).

See Also:
Constant Field Values

RAMTOP

public static final int RAMTOP
Address of first byte above BASIC system area.

You can poke this to make NEW reserve space above that area (see chapter 26) or to fool CLS into setting up a minimal display file (chapter 27). Poking RAMTOP has no effect until one of these two is executed.

See Also:
Constant Field Values

MODE

public static final int MODE
Specifies K, L, F or G cursor.

See Also:
Constant Field Values

PPC

public static final int PPC
Line number of statement currently being executed.

Poking this has no lasting effect except in the last line of the program.

See Also:
Constant Field Values

VERSN

public static final int VERSN
Identifies ZX81 Basic in saved programs.

See Also:
Constant Field Values

E_PPC

public static final int E_PPC
Number of cuurent line (with cursor).

See Also:
Constant Field Values

D_FILE

public static final int D_FILE
Address of display file.

See Also:
Constant Field Values

DF_CC

public static final int DF_CC
Address of print position in display file.

See Also:
Constant Field Values

VARS

public static final int VARS
Address of variables area.

See Also:
Constant Field Values

DEST

public static final int DEST
Address of variable in assignment.

See Also:
Constant Field Values

E_LINE

public static final int E_LINE
Address of line being typed.

See Also:
Constant Field Values

CH_ADD

public static final int CH_ADD
Address of the next character to be interpreted.

The character after the argument of PEEK, or the NEWLINE at the end of a POKE statement.

See Also:
Constant Field Values

X_PTR

public static final int X_PTR
Address of character preceding the S marker.

See Also:
Constant Field Values

STKBOT

public static final int STKBOT
Address of calculator stack.

See Also:
Constant Field Values

STKEND

public static final int STKEND
Address of start of spare space.

See Also:
Constant Field Values

BREG

public static final int BREG
Calculator's B register.

See Also:
Constant Field Values

MEM

public static final int MEM
Address of area used for calculator's memory.

(Usually MEMBOT, but not always.)

See Also:
Constant Field Values

UN1

public static final int UN1
Unused.

See Also:
Constant Field Values

DF_SZ

public static final int DF_SZ
The number of lines (including one blank line) in the lower part of the screen.

See Also:
Constant Field Values

S_TOP

public static final int S_TOP
The number of the top program line in automatic listings.

See Also:
Constant Field Values

LAST_K

public static final int LAST_K
Shows which keys pressed.

See Also:
Constant Field Values

DEBOUN

public static final int DEBOUN
Debounce status of keyboard.

See Also:
Constant Field Values

MARGIN

public static final int MARGIN
Number of blank lines above or below picture.

55 in Britain, 31 in America.

See Also:
Constant Field Values

NXTLIN

public static final int NXTLIN
Address of next program line to be executed.

See Also:
Constant Field Values

OLDPPC

public static final int OLDPPC
Line number to which CONT jumps.

See Also:
Constant Field Values

FLAGX

public static final int FLAGX
Various Flags.

See Also:
Constant Field Values

STRLEN

public static final int STRLEN
Length of string type destination in assignment.

See Also:
Constant Field Values

T_ADDR

public static final int T_ADDR
Address of next item in syntax table (very unlikely to be useful).

See Also:
Constant Field Values

SEED

public static final int SEED
The seed for RND. This is the variable that is set by RAND.

See Also:
Constant Field Values

FRAMES

public static final int FRAMES
Counts the frames displayed on the television.

Bit 15 is 1. Bits 0 to 14 are decremented for each frame set to the television. This can be used for timing, but PAUSE also uses it. PAUSE resets to 0 bit 15, & puts in bits 0 to 14 the length of the pause. When these have been counted down to zero, the pause stops. If the pause stops because of a key depression, bit 15 is set to 1 again.

See Also:
Constant Field Values

COORDS

public static final int COORDS
X-coordinate of last point plotted.

See Also:
Constant Field Values

COORDY

public static final int COORDY
Y-coordinate of last point plotted.

See Also:
Constant Field Values

PR_CC

public static final int PR_CC
Less significant byte of address of next position for LPRINT to print as (in PRBUFF).

See Also:
Constant Field Values

S_POSN

public static final int S_POSN
Column number for print position.

See Also:
Constant Field Values

S_POSL

public static final int S_POSL
Line number for print position.

See Also:
Constant Field Values

CDFLAG

public static final int CDFLAG
Various flags. Bit 7 is on (1) during compute & display mode.

See Also:
Constant Field Values

PRBUFF

public static final int PRBUFF
Printer Buffer.

33rd character = newline.

See Also:
Constant Field Values

MEMBOT

public static final int MEMBOT
Calculator's memory area.

Used to store numbers that cannot conveniently be put on the calculator stack.

See Also:
Constant Field Values

UN2

public static final int UN2
Unused.

See Also:
Constant Field Values

END

public static final int END
The end of system variables.

See Also:
Constant Field Values

SAVE_START

public static final int SAVE_START
The address of the system variable area that a save starts at.

See Also:
Constant Field Values
Constructor Detail

ZX81SysVars

public ZX81SysVars()
Method Detail

dumpSystemVariables

public static void dumpSystemVariables(byte[] memory,
                                       int start,
                                       int firstVar,
                                       java.lang.StringBuffer buff)
Dump the system variables in the given area of memory.

Parameters:
memory - The memory containing the values.
start - The start index in memort to dump.
firstVar - The first variable to process.
buff - The buffer to contain the result.

getVariableValueOffset

public static int getVariableValueOffset(byte[] memory,
                                         int varAddr,
                                         int varSize)
Obtain the value of a system variable, offset into the given array.

Parameters:
memory - The memory containing the values.
varAddr - The address of the variable.
varSize - The size of the variable.
Returns:
The value of the variable.

getVariableValueOffset

public static int getVariableValueOffset(byte[] memory,
                                         int start,
                                         int firstVar,
                                         int varAddr,
                                         int varSize)
Obtain the value of a system variable.

Parameters:
memory - The memory containing the values.
start - The start index in memory to dump.
firstVar - The first variable to process.
varAddr - The address of the variable.
varSize - The size of the variable.
Returns:
The value of the variable.

getVariableValue

public static int getVariableValue(byte[] memory,
                                   int varAddr,
                                   int varSize)
Obtain the value of a system variable.

Parameters:
memory - The memory containing the values.
varAddr - The address of the variable.
varSize - The size of the variable.
Returns:
The value of the variable.

getVariableValue

public static int getVariableValue(byte[] memory,
                                   int start,
                                   int firstVar,
                                   int varAddr,
                                   int varSize)
Obtain the value of a system variable.

Parameters:
memory - The memory containing the values.
start - The start index in memory to dump.
firstVar - The first variable to process.
varAddr - The address of the variable.
varSize - The size of the variable.
Returns:
The value of the variable.