
               GB Basic V1.08 Documentation

 GB Basic is a floating-point BASIC interpreter for GameBoy that
allows you to write & execute programs up to 7.4K bytes in size.
Currently string variables are not supported, but may be in the
future.

 Long variable names are not supported. Variable names may be
a letter or a letter and a number.

The following commands are supported:

ABS(x)           -       Return the absolute value of x.

AUTO             -       Enable Auto load & run program on reset.
                         (Note: Use AUTO command last since SAVE
                          disables auto mode.)

CLEAR            -       Clear all variables.

CLS              -       Clear the screen

COLOR x          -       Set drawing color to x. 0=Black, 1=Dark Gray,
                         2=Light Gray, 3=White, & 4=XOR. (Defaults
                         to XOR on program execution.)

COS(x)           -       Return the cosine of x given in radians.

DIM              -       Only single dimension arrays are currently
                         supported. If not explicitly defined by a
                         DIM statement, it is assumed to be a size
                         of 10 upon first reference.

DATA x,...       -       Data in program.
        
DELAY x          -       Delay from 10ms to 655 seconds.
                         (Delay length = x * 10ms)

END              -       End program.

FOR/NEXT         -       Program loop.       

FREE             -       Display remaining amount of free memory.

GOSUB            -       Execute a subroutine.

GOTO             -       Goto specific line.

IF/THEN          -       Conditional execution.

INPUT            -       Input data from user.

INT(x)           -       Returns the integer of x.

KEYPAD(x)        -       If x=0, the following bits are returned
                         if that button is pressed.
                           128 - Start    8 - Down
                            64 - Select   4 - Up
                            32 - B        2 - Left
                            16 - A        1 - Right
                         If x>0, then x is ANDed with the bits
                         above. If the result = zero, 0 is returned.
                         If result <> zero, a 1 is returned.

LET              -       Assign a value to a variable. (Optional)

LINE x1,y1,x2,y2 -       Draw a line on the screen using COLOR.
                         (0<=x<=127,0<=y<=119)

LIST [x][-][x]   -       List lines of the program. Starting and/or
                         ending line numbers are optional.

LOAD             -       Load program from battery-backed RAM.

LOCATE           -       Position cursor with coordinates Y,X.

PEEK(x)          -       Return value of a memory location x.

POINT x,y        -       Draw a point on the screen using COLOR.
                         (0<=x<=127,0<=y<=119)

POKE x,y         -       Write value y to a memory location x.

PRINT            -       Print to screen.

READ             -       Read data contained in DATA statements.

REM              -       Remark. Also ' is supported.

RENUM            -       Renumber program.

RESTORE          -       Set DATA pointer to a specific line number. If
                         no line number present, beginning of program.

RETURN           -       Return from subroutine.

RND(x)           -       Returns a random number between 0 and 1.
                         x is ignored.

RUN              -       Execute program.

SAVE             -       Save program to battery-backed RAM.

SCREEN x         -       If x=0, set text mode. If x=1, set graphics mode.

SERVO x,y        -       Controls the position of up to 8 memory-mapped
                         servos. SERVO 0,a defines the memory address of
                         the servos output port. SERVO x,y outputs a high
                         pulse to servo x for 700+(y*7.6) microseconds
                         giving a pulse range of .7 to 2.3 ms. This pulse
                         is sent out every 20 ms. Servos may be set before
                         issuing SERVO 0,a to enable them. On reset, servos
                         default to midway setting (y=105) and disabled.
                         NOTE: When enabled, servos slow down system about
                         15% due to servicing.(1<=x<=8,0<=y<=210)

SGN(x)           -       Returns 1 if x > or = 0. Else returns value -1.

SIN(x)           -       Return the sine of x given in radians.

SOUND x,y        -       Generate a sound of frequency x for y milliseconds.
                         If y=65535, sound will stay on infinitely. If y=0,
                         sound is turned off.

SQR(x)           -       Returns the square root of x.

STEP             -       Used with FOR for specifying increment.

STOP             -       Same as end but displays line number last executed.

TAB(x)           -       Used with PRINT command for moving cursor to
                         column x.

TAN(x)           -       Returns the tangent of x given in radians.


Revision History
----------------

V1.0  - Original release
V1.01 - Rearranged on-screen keyboard.
        Reassigned key controls.
        Fixed exponent display problem.
V1.02 - Completed RENUM routine.
        Added restore [line#] ability.
        Added pointer at $80 to key table to allow others
         to modify this table for different external keyboards.
        Added hex entry of numbers using prefix &h.
V1.03 - Fixed 'cursor disappear' when arrow buttons pressed.
        Greatly speeded up CLS command.
        Added SCREEN, POINT, & LINE routines.
        Break now works for lines that GOTO themselves.
        Rearranged on-screen keyboard again for faster entry.
V1.04 - Select & Start are BOTH now required to break.
        This was done to allow individual buttons to be pressed
        and read with the new KEYPAD command.
        Added COLOR command.
V1.05 - Added AUTO command.
        Credit screen disappears after 10 seconds.
V1.06 - Fixed bugs in LIST options. Up & down buttons now
        speed up or slow down LIST command. Pressing break
        now halts LIST command.
        Added SOUND command.
V1.07 - Added SERVO command.
        Changed DELAY increments from 1ms to 10ms
         in order to implement SERVO command.
        Select Button is now a caps lock.
        Credit screen now disappears after 4 seconds.
        Carat symbol added to onscreen menu.
        FOR,GOTO,INPUT,LIST,NEXT,PRINT,RENUM, & THEN
         now can be entered by first letter followed by period.
V1.08 - Shift & Caps Lock now supported on external keyboard.
        CLS now redraws onscreen menu properly in text mode.
        Basic commands can now be entered in lower or upper case.
        DELAY added to 'first letter' list above.
