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:
mlc2("test")
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:
MLC:
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:
MLC:
#FNCT MAIN
#TEXT .1,.2,"HELLO",3
#DRAW
#FEND
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.

Operators

Variables' values are normally set with the equals sign, by doing something like:
%INT=3+2*7
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:
MLC:
#FNCT MAIN
#IIFF 2=3 & 4=4
%INT=8
#FEND
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:
%INT=3
*PTR:%INT
*PTR=7
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):
Arguments:

[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):

conditional
	numerical
		(valid conditional operators are <, >, =, !, and &)
		%POS+3=%X/8
		@ARRAY(8)>2
		%A=%B&%C=%D
	string
		(valid conditional operators are = and !)
		$STR="TI86"
		$STR1!$STR2
	bitmap
		(valid conditional operators are = and !)
		^SPR.BMP=[BMP1
		^SPR1.BMP!^SPR2.BMP
numerical
		%A=%A+3-%B/7
		%NUM=@ARY(%I+1)-2
		%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
		@ARRAY=3,2,0,89,%NUM,%NUM2+1
		{MAP=[BMP1,[BMP2,[BMP3,[BMP4
	single element
		@ARRAY(1)=7
		{MAP(1,2)=^SPR.BMP
string
		$STR="A test string"
		$STR=$STR+" "+$INP
		$STR=%INT+3
		$STR="Score:"+%SCR
sprite properties
		^SPR1.X=2
		^SPR1.Y=^SPR2.X+%VX
		^SPR.VX=3
		^SPR.VY=0-^SPR.VY
		^SPR.DX=50
		^SPR.DY=^SPR3.X*10
assigning pointers
		*PTR:%INT
		*PTR:@ARRAY
		*PTR:$STR
		*PTR:^SPR
		*PTR:[BMP
		*PTR:{MAP

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:
#SPRT ^SPR,[BMP1
^SRR.X=2
^SPR.Y=3
^SPR.BMP=[BMP2

Page under construction...elaborate on pointers!