GB Basic V1.06 Documentation GB Basic is a floating-point BASIC interpreter for GameBoy that allows you to write & execute programs up to 7.5K 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 - Delay from 1 to 65535 milliseconds. 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. 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 now 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.