MLC Documentation

Home ~ General Information ~ The Basics ~ Command Reference ~ Screenshots ~ Downloads

The Basics

Running MLC Programs

For MLC programs to be run, the MLC interpreter is required. As of now, MLC programs on the TI-89/TI-92+/Voyage 200 using the MLC 68k interpreter can only be run by entering "mlc2(progName)" in the home screen or in a TI-BASIC program. For example, to run an MLC program I had named "test", I would do:
I think all other MLC interpreters use an intuitive graphical shell.

The MLC 68K and MLC TI-86 interpreters offer in-program menus which are triggered by pressing the ON key. From there you can turn off the calculator (turning of your calculator might be buggy on the TI-86, and my crash your calculator), adjust contrast and speed, and exit the program.

Structure of MLC Programs

MLC programs are stored as text files on the Ti-89, TI-92+, and Voyage 200 (and thus are edited with the Text Editor application). They're stored as TI-BASIC program files on the TI-86. MLC programs always begin with the following:
Each line of a MLC program either begins with a command or variable declaration. Commands are prefixed with a "#" and variable names, except pictures, are always prefixed with a certain character (see Variable Types and the VAT). The hidden buffer (see double buffering) and the visible screen are cleared before MLC programs are run, so you don't have to worry about that. Here is an example MLC program:
#TEXT .1,.2,"HELLO",3
The preceding program writes the text "HELLO" in black text to the x-coordinate 1 and y-coordinate 2 in the hidden buffer (an x-coordinate of zero is to the left of the screen, and a y-coorinate of zero is at the top of the screen). The DRAW command then copies the contents of the hidden buffer to the (visible) screen, and FEND ends the MAIN function (note: all MLC programs must have a MAIN function, which is where execution starts).

Also, some MLC interpreters allow you to use the entire screen for drawning, while others restrict you to a width of 96 pixels and a height of 64 pixels in an attempt to be more compatible with a future TI-83+ MLC interpreter. In general, you should try to only use the 96x64 area. In the future, we may use pseudo constants like W and H (width and height) which whose values would be determined by the current MLC interpreter being used, so programmers can make use of larger screens and still have their programs work on smaller screens.

In addition, variable and function names can be at most 5 characters long. The names of MLC programs can only be up to 7 characters long.


Variables' values are normally set with the equals sign, by doing something like:
Pointers are assigned by using the : operator. See Variable Types and the VAT for details.

MLC also supports mathematical operators, as you can see, but MLC doesn't follow the standard order of operations - it evalutes them from left to right. For example, the previous code would make %INT equal 35 and not 17 because the plus sign is evaluated before the multiplication sign. Here are all of MLC's mathematical operators: Logical operators are supported in MLC as well and can be used with the IIFF command. Here's what they are: *These are only valid for mathematical expressions, like 2+3.

The & operator is used to compare two things at once, and IIFF only evaluates the entire expression as true and executes the next line of code if both comparisons are true. For example:
#IIFF 2=3 & 4=4
In the previous code, the line "%INT=8" will not be executed because although 4 equals 4, 2 does not equal 3. And, of course, strings can only be compared against strings (like $STR and "HI"), bitmaps can only be compared against bitmaps (like {MAP(1,2), [BITM, or ^SPR.BMP), and mathematical expressions can only be compared against each other. For more information about conditional statements, see the Variable Types and the VAT section and the IIFF command.

Double Buffering

MLC uses a hidden buffer to store all data rendered by MLC commands. This enables MLC programs to all have double-buffering enabled by default. Double-buffering is a technique that may be helpful in certain situations, in particularly, such as when the user doesn't want to draw the data piece by piece, but rather display it all at the same time. The contents of the hidden buffer in MLC can be copied by using the DRAW command.

Grayscale and Color Codes

MLC allows for four-level grayscale. 0 means white, 1 means light gray, 2 means dark gray, 3 means black, and 4 means inverted (white pixels on the hidden buffer become black, light gray becomes dark gray, dark gray becomes light gray, and black becomes white). The RECT command allows you to use 5 to mean transparent/invisible for it's last two arguments.

Variable Types and the VAT

The variable types in MLC 68K are (and what they are prefixed with): Pictures don't have a prefix when being accessed because data is recalled and stored to them through the commands RCLP and STOP. You can have at most 110 non-sprite variables, 125 functions, 15 sprites, 40 8x8 bitmaps, and 1 picture. Array indexes start at 0 and strings can hold up to 35 characters. These limits were determined by the original MLC TI-86 interpreter.

Pointers can be used like the following:
The above example would make %INT equal 7. You can't have pointers to array elements (like @ARRAY(1)) or sprite properties (like ^SPRT.X). Pointers assigned to strings can't be used in the conditional expression after an IIFF command on MLC for the TI-86, and possible on other versions of MLC, so you should avoid doing that.

In addition, literal numbers (like 1,2, etc.) are prefixed with a dot (except on MLC on the TI-86, which uses no prefix at the moment...hopefully this is something the MLC IDE's program generator will be able to take care of) and literal strings start and end with double-quotation marks.

Here is a section of a file for the original MLC TI-86 interpreter (note: literal numbers are not prefixed in the following explanation for MLC on the TI-86 - you should prefix literal numbers on other platforms though):

[number]: Any numerical expression, can involve variables, numbers, sprite properties, the 4 basic operators, and the modulus operator ('|')
[int name]: The name of an integer variable, preceded by a % (array elements are also allowed for most commands - for example, "#PIXT 0,5,@COLOR(%X)"
[string name]: The name of a string variable, preceded by a '$'
[array name]: The name of an array variable, preceded by a '@'
[bitmap name]: The name of a bitmap defined in a data section, preceded with a '['
[sprite name]: The name of a sprite object, preceded with a '^'
[pointer name]: The name of a pointer, preceded with a '*'
[map name]: The name of a tilemap, preceded with a '{'
[color]: The color for a graphics operation: 0 is white, 1 is light gray, 2 is dark gray, 3 is black, 4 is inverted, and 5 is transparent (only allowed in rectangles)
[keycode]: A number representing a key: 10*row+col (on TI calcs, 4th row is skipped)
[conditional expression]: For example: "%A+2<73"  Separate expression segments can be separated with '&', and the expression will only be true if each segment is true - for example: "%A<%B&%B<%C&%C<%D"

Valid expressions (examples):

		(valid conditional operators are <, >, =, !, and &)
		(valid conditional operators are = and !)
		(valid conditional operators are = and !)
		%INT+ (increments %INT)
		%INT- (decrements %INT)
		%INT+=2 (same as %INT=%INT+2)
		%INT-=2 (same as %INT=%INT-2)
		%INT/=4 (same as %INT=%INT/4)
		%INT*=4 (same as %INT=%INT*4)
array / tilemap
	full definition
	single element
		$STR="A test string"
		$STR=$STR+" "+$INP
sprite properties
assigning pointers

Bitmaps vs Sprites

Sprites are declared using the SPRT command, and have three properties - and x coordinate, a y coordinate, and a bitmap. Bitmaps are just data to form an image, which are stored in the DATA section and individually created with the BITM command. You should use sprites if you want to take advantage of DISP for conveniently drawing all existing sprites at once or MLC's collision-detection commands like CLSN and CMAP.

The properties of sprites can be set like the following:

Page under construction...elaborate on pointers!