GLIR - API Reference

Utilities

GLIR_Start:
.include "src/GLIR.s"

Args:
 a0 = Number of rows to set the screen to
 a1 = Number of cols to set the screen to

Returns:
 N/A

Sets up the display in order to provide a stable environment. Call GLIR_End
when program is finished to return to as many default and stable settings as
possible. Unfortunately screen size changes are not code-reversible, so
GLIR_End will only return the screen to the hardcoded value of 24x80.
GLIR_End:
.include "src/GLIR.s"

Args:
 N/A

Returns:
 N/A

Reverts to default as many settings as possible. Meant to end a program that
was started with GLIR_Start. The default terminal window in xfce4-terminal is
24x80, so this is the assumed default we want to return to.
GLIR_RestoreSettings:
.include "src/GLIR.s"

Args:
 N/A

Returns:
 N/A

Prints the escape sequence that restores all default color settings to the
terminal.
GLIR_ClearScreen:
.include "src/GLIR.s"

Args:
 N/A

Returns:
 N/A

Print the escape sequence that clears the screen.
GLIR_SetColor:
.include "src/GLIR.s"

Args:
 a0 = Color code (see index or wiki)
 a1 = 0 if setting background, 1 if setting foreground

Returns:
 N/A

Prints the escape sequence that sets the color of the text to the color
specified.

xfce4-terminal supports 256 color lookup table assignment; see the index or
wiki for a list of color codes.
Sleep:
.include "src/Utilities/Sleep.s"

Args:
 a0 = the number of milliseconds to sleep

Returns:
 N/A

Waits the specified number of milliseconds (very roughly) by doing nothing.

This is a simple busywait implementation of sleep for RARS made in the event
that the sleep syscall cannot be used (ie. if you are using threads).

Printing

GLIR_PrintString:
.include "src/GLIR.s"

Args:
 a0 = Address of string to print
 a1 = Integer value 0-999, row to print to
 a2 = Integer value 0-999, col to print to

Returns:
 N/A

Prints the specified null-terminated string according to the printing
preferences of your terminal (standard terminals print left to right, top to
bottom). Prints starting at the specified location of the string and continues
until the end of the string. Is not screen aware; passing paramaters that
would print a character off screen has undefined effects on your terminal
window. For most terminals the cursor will wrap around to the next row and
continue printing. If you have hit the bottom of the terminal window, the
xfce4-terminal window default behavior is to scroll the window down. This can
offset your screen without you knowing and is dangerous since it is
undetectable. The most likely useage of this subroutine is to print
characters. The reason that it is a string that is printed is to support the
printing of escape character sequences around the character so that fancy
effects are supported. Some other terminals may treat the boundaries of the
terminal window different. For example, some may not wrap or scroll. It is up
to the user to test their terminal window for its default behaviour. Built for
xfce4-terminal. Position (0, 0) is defined as the top left of the terminal.

Uses TERM_ROW and TERM_COL to determine if the target tile is outside of the
boundary of the terminal screen, in which case it does nothing.
GLIR_BatchPrint:
.include "src/GLIR.s"

Args:
 a0 = Address of batch list to print

Register Usage:
 s1 = Scanner for the list
 s2 = Store row info
 s3 = Store column info
 s4 = Store print code info
 s5 = Temporary color info storage accross calls
 s6 = Temporary color info storage accross calls

Returns:
 N/A

A batch is a list of print jobs. The print jobs are in the format below, and
will be printed from start to finish. This subroutine does some basic
optimization of color printing (eg. color changing codes are not printed if
they do not need to be), but if the list constantly changes color and is not
sorted by color, you may notice flickering.

List format (each job contains the following words in order together):
half words unsigned:   [row] [col]
bytes unsigned:     [printing code] [fg color] [bg color] [empty]
word:         [address of string to print]
total = 3 words

The batch must be ended with the halfword sentinel: 0xFFFF

Valid Printing codes:
0 = skip printing
1 = standard print, default terminal settings
2 = print using foreground color
3 = print using background color
4 = print using all colors

xfce4-terminal supports 256 color lookup table assignment; see the index or
wiki for a list of color codes.

The payload of each job in the list is the address of a string.
Escape sequences for prettier or bolded printing supported by your terminal
can be included in the strings. However, including such escape sequences can
effect not just this print, but also future prints for other GLIR subroutines.
GLIR_PrintLine:
.include "src/GLIR.s"

Args:
 a0 = Row1
 a1 = Col1
 a2 = Row2
 a3 = Col2
 a4 = Color to print with (see index or wiki)
 a5 = Address of null-terminated string to print with; if 0 then uses
    the unicode full block char (█) as default

Returns:
 N/A

Prints a line onto the screen between points (Row1, Col1) and (Row2, Col2).

The reason that it is a string that is printed is to support the printing of
escape character sequences around the character so that fancy effects are
supported. Printing more than one character when not using escape sequences
will have undefined behaviour.
GLIR_PrintTriangle:
.include "src/GLIR.s"

Args:
 a0 = Row1
 a1 = Col1
 a2 = Row2
 a3 = Col2
 a4 = Row3
 a5 = Col3
 a6 = Color to print with (see index or wiki)
 a7 = Address of null-terminated string to print with; if 0 then uses
    the unicode full block char (█) as default

Returns:
 N/A

Prints a triangle onto the screen connected by the points (Row1, Col1),
(Row2, Col2), (Row3, Col3).

The reason that it is a string that is printed is to support the printing of
escape character sequences around the character so that fancy effects are
supported. Printing more than one character when not using escape sequences
will have undefined behaviour.
GLIR_PrintRect:
.include "src/GLIR.s"

Args:
 a0 = Row of top left corner
 a1 = Col of top left corner
 a2 = Signed height of the rectangle
 a3 = Signed width of the rectangle
 a4 = Color to print with (see index or wiki)
 a5 = Address of null-terminated string to print with; if 0 then uses
    the unicode full block char (█) as default

Returns:
 N/A

Prints a rectangle using the (Row, Col) point as the top left corner having
width and height as specified. Supports negative widths and heights.
Specifying a height and width of 0 will print a rectangle one cell high by
one cell wide.

The reason that it is a string that is printed is to support the printing of
escape character sequences around the character so that fancy effects are
supported. Printing more than one character when not using escape sequences
will have undefined behaviour.
GLIR_PrintCircle:
.include "src/GLIR.s"

Args:
 a0 = Row to print at
 a1 = Col to print at
 a2 = Radius of the circle to print
 a3 = Byte code [printing code] [fg color] [bg color] [empty]
    bits       [0:7]     [8:15]  [16:23] [24:31]
    determining how to print the circle pixels, compatible with
    GLIR_BatchPrint
 a4 = Address of null-terminated string to print with; if 0 then uses
    the unicode full block char (█) as default

Returns:
 N/A

Prints a circle onto the screen using the midpoint circle algorithm and the
character PrintCircle_Char.

Valid Printing codes:
0 = skip printing
1 = standard print, default terminal settings
2 = print using foreground color
3 = print using background color
4 = print using all colors

xfce4-terminal supports 256 color lookup table assignment; see the index or
wiki for a list of color codes.

The reason that it is a string that is printed is to support the printing of
escape character sequences around the character so that fancy effects are
supported. Printing more than one character when not using escape sequences
will have undefined behaviour.

The tuple describing a position on the grid is (R, C) and not (C, R).
Terminals were designed to print text top to bottom, left to right. Their
underlying control structures are built on this assumption. Thus the row
number comes before the column number. The origin (0, 0) is at the top left of
the xfce4-terminal window. Below is an ascii diagram of the notation used in
the comments of the subroutine. The numbers 1,2,3,4 correspond to the
quadrants referred to in this subroutines block comments.

                        (0,0)
                        /--------------------------------------> Col
                        |            |
                        |            |
                        |           ███
                        |         ██ | ██
                        |        █   |   █
                        |       █    |    █
                        |      █  2  |  1  █
                        |      █     |     █
                        |     █      |      █
                        | ----█------+------█----
                        |     █      |      █
                        |      █     |     █
                        |      █  3  |  4  █
                        |       █    |    █
                        |        █   |   █
                        |         ██ | ██
                        |           ███
                        |            |
                        |            |
                        v
                        Row