MZXak 2 Reference Guide
By Akwende
MZXak 2 is an Enhanced Version of MZXs3.2. It offers an extended set of instructions via Function Counters. It should be noted that MZXak 2 is NOT compatable with MZXak 1. This was due to a combination of factors mainly that several of MZXak counters were removed or their functionality was changed.
Function Counter- A counter that has some type of special functionality, and which may or may not function like a traditional counter. Some 'counters' are not even counters but rather are solely functional and store no information.
Dependency - A counter that the Function Counter uses to derive some of it's functionaliy. Often the counters are traditional counters that have no special use their own.
Access - There are 3 modes of access, Read-Only (R), Write-Only (W) , or Read and Write(R/W). A counter that is read-only can only be used to get a value (setting will have no effect). A counter that is write-only can only be used to write a value (trying to get a value will be indeterministic). A Read and Write counter is just that same mode a traditional counter however it's functionality may not be the same with reads and writes.
Size - There are several sizes of countes. Traditional counters are 16bit so they can store -32768 to 32767. There are also some 8bit countes (most are local) which can only store 0-255 (unsigned only). A few counters are limited to other sizes based on their functionality. Example color_VALUE counters are 6bit since they set the different color aspects which can only be 0-63. Must of the time you don't need to worry to much about sizes other than 8bit and 16bit.
General Lib
Function Counter |
Dependency |
Description |
Access |
Size |
Example |
MZXAKVERSION |
NONE | Used to activate MZXAK functions | R/W | *** | set "MZXAKVERSION" to 2 |
MAX_COMMANDS | NONE | The number of commands executed per cycle | R/W | 16bit | set "MAX_COMMANDS" to 100 |
MZX_SPEED | NONE | The speed that mzx runs (1-9) | R/W | 16bit | set "MZX_SPEED" to 5 |
SMZX_MODE | NONE | Sets SMZX graphcis mode | R/W(0,1) | 1 bit | set "SMZX_MODE" to 1 |
RED_VALUE | CURRENT_COLOR | Sets and gets the red aspect (0-63) | R/W | 6 bit | set "rcolor" to "RED_VALUE" |
GREEN_VALUE | CURRENT_COLOR | Sets and gets the green aspect (0-63) | R/W | 6 bit | set "GREEN_VALUE" to "rcolor" |
BLUE_VALUE | CURRENT_COLOR | Sets and gets the blue aspect (0-63) | R/W | 6 bit | set "BLUE_VALUE" to "RED_VALUE" |
File Lib
Function Counter |
Dependency |
Description |
Access |
Size |
Example |
FILE_ROPEN |
filename | Opens a file for reading, not a counter | W | NULL | set "filename.ext" to "FILE_ROPEN" |
FILE_WOPEN | filename | Opens a file for writing, not a counter | W | NULL | set "filename.ext" to "FILE_WOPEN" |
FILE_APPEND | filename | Opens a file for appending, not a counter | W | NULL | set "filename.ext" to "FILE_APPEND" |
FILE_RPOS | FILE_ROPEN | Position to read in a page | R/W | 16 bit | inc "FILE_RPOS" by 1 |
FILE_RPAGE | FILE_ROPEN | Page in file, a file is split into 64k pages | R/W | 16 bit | set "FILE_RPAGE" by 1 |
FILE_READ | FILE_ROPEN | Reads a byte from a file | R | 8 bit | set "getByte" to "FILE_READ" |
FILE_WPOS | FILE_WOPEN or FILE_APPEND | Position to write in a page | R/W | 16 bit | dec "FILE_WPOS" by 1 |
FILE_WPAGE | FILE_WOPEN or FILE_APPEND | Page in file, a file is split into 64k pages | R/W | 16 bit | set "currentPage" to "FILE_WPAGE" |
FILE_WRITE | FILE_WOPEN or FILE_APPEND | Writes a byte to a file | W | 8 bit | set "FILE_WRITE" to 42 |
Charset Lib
Function Counter |
Dependency |
Description |
Access |
Size |
Example |
CHAR_READ |
RCHAR, RCHAR_ROW | Reads a row in a character | R | 8 bit | set "value" to "CHAR_READ" |
CHAR_WRITE | WCHAR, WCHAR_ROW | Writes a row in a character | W | 8 bit | set "CHAR_WRITE" to "value" |
PIXEL_READ | PIXEL_X, PIXEL_Y | Reads a pixel from the charset | R | 1 bit | set "bit" to "PIXEL_READ" |
PIXEL_WRITE | PIXEL_X, PIXEL_Y | Writes a pixel from the charset | R/W | 1 bit | set "PIXEL_WRITE" by 1 |
Board Lib
Function Counter |
Dependency |
Description |
Access |
Size |
Example |
BOARD_CHAR |
BOARD_X, BOARD_Y | Reads a row in a character | R | 8 bit | set "character" to "BOARD_CHAR" |
BOARD_COLOR | BOARD_X, BOARD_Y | Writes a row in a character | R | 8 bit | set "color" to "BOARD_COLOR" |
OVERLAY_CHAR | OVERLAY_X, OVERLAY_Y | Reads a pixel from the charset | R | 8 bit | set "character" to "OVERLAY_CHAR" |
OVERLAY_COLOR | OVERLAY_X, OVERLAY_Y | Writes a pixel from the charset | R | 8 bit | set "color" to "OVERLAY_COLOR" |
Function Counter |
Dependency |
Description |
Access |
Size |
Example |
B_TYPE |
NONE | Local Counter, BULLETTYPE memory* | R/W | 8 bit | set "B_TYPE" to 128 |
THISCHAR | NONE | Character of Robot | R | 8 bit | set "myID" to "THISID" |
THISCOLOR | NONE | Color of Robot | R | 8 bit | set "myChar" to "THISCHAR" |
THISID | NONE | Internal ID of Robot | R | 8 bit | set "myColor" to "THISCOLOR" |
THISTARGET | NONE | Local Counter, used for TARGET_ counters | R/W | 8 bit | set "THISTARGET" to "GET_ID" |
LOCAL2 | NONE (don't shoot or touch) | Local Counter, uses TouchedDir & ShotDir mem** | R/W | 16 bit | set "LOCAL" to 25000 |
TOUCH_DIR | NONE (don't touch) | Local Counter uses TouchedDir memory ** | R/W | 8 bit | set "TOUCH_DIR" to 25 |
SHOT_DIR | NONE (don't shoot) | Local Counter uses ShotDir memory** | R/W | 8 bit | set "SHOT_DIR" to 250 |
Math Lib
Function Counter |
Dependency |
Description |
Access |
Size |
Example |
COS_VALUE |
ANGLE, RADIUS | Calculates RADIUS * cos(ANGLE) | R | NULL | set "x" to "COS_VALUE" |
SIN_VALUE | ANGLE, RADIUS | Calculates RADIUS * sin(ANGLE) | R | NULL | set "y" to "SIN_VALUE" |
ABS_VALUE | NONE | Color of Robot | R/W | 16 bit | set "ABS_VALUE" to -10000 |
SQRT_VALUE | NONE | Internal ID of Robot | R/W | 16 bit | set "SQRT_VALUE" to 100 |
POW_VALUE | BASE, EXPONENT | Local Counter, used for TARGET_ counters | R | NULL | set "twoCubed" to "POW_VALUE" |
Time Lib
Function Counter |
Dependency |
Description |
Access |
Size |
Example |
DATE_DAY |
NONE | Returns the Day of the Month (0-31) | R | NULL | set "currentDay" to "DATE_DAY" |
DATE_MONTH | NONE | Returns the Month of the Year (0-12) | R | NULL | set "currentMonth" to "DATE_MONTH" |
DATE_YEAR | NONE | Returns the Year (0-2016) | R | NULL | set "currentYear" to "DATE_YEAR" |
TIME_SECONDS | NONE | Returns the seconds of your system clock | R | NULL | set "secs" to "TIME_SECONDS" |
TIME_MINUTES | NONE | Returns the minutes of your system clock | R | NULL | set "mins" to "TIME_MINUTES" |
TIME_HOURS | NONE | Returns the hours of your system clock | R | NULL | set "hours" to "TIME_HOURS" |
Target Lib
Function Counter |
Dependency |
Description |
Access |
Size |
Example |
GET_ID |
BOARD_X, BOARD_Y | Gets the ID of the robot at BOARD_X, BOARD_Y | R | 8 bit | set "THISTARGET" to "GET_ID" |
TARGET_X | THISTARGET | Returns X pos of target (can use rel commands) | R | 16 bit | set "tx" to "TARGET_X" |
TARGET_Y | THISTARGET | Returns Y pos of target (can use rel commands) | R | 16 bit | set "ty" to "TARGET_Y" |
TARGET_DIST | THISTARGET | Returns Distance of target (can use rel commands) | R | 16 bit | set "dist" to "TARGET_DIST" |