home *** CD-ROM | disk | FTP | other *** search
-
- GB Basic V1.21 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.
-
- Each line requires a line number.
-
- &H may be used for entering hex values. (Ex: POKE &HFF00,&HFF)
-
- 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)
-
- LINK x - Link 0 - Don't use game link port.
- Link 1 - Configure port for external terminal.
- Link 2 - Configure port for external keyboard.
-
- Gameboy must be reset or power must be cycled
- for changes to take effect. The last setting is
- saved in battery backed RAM. (External terminal
- won't currently work when SERVOs are enabled
- because of interrupt conflicts.)
-
- 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.
-
- MEMTOP x - Set Last address of RAM for GB Basic to use.
- On power up or reset this defaults to $dfff.
- Lowering this value reserves memory for
- USR for example. NOTE: All variables are
- CLEARed when this instruction is executed.
-
- 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.
-
- REGBC x - Sets value of cpu BC registers for entry
- into USR routine.
-
- REGDE x - Sets value of cpu DE registers for entry
- into USR routine.
-
- 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 and enables the servo
- interrupt routine. SERVO x,y outputs a high
- pulse to servo x for 693+(y*7.6) microseconds
- giving a pulse range of .7 to 2.3 ms. A value of
- y = 0 disables the output pulse of that servo.
- 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 off (y=0) and disabled.
- NOTE: When enabled, servos slow down system about
- 15% due to servo interrupt servicing. Use SERVO 0,0
- to disable all servos once they have been enabled.
- (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.
-
- USR(x) - Call user assembly language program at address x.
- Return value reflects cpu HL registers contents.
-
- 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 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,RUN & 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.
- V1.10 - Fixed bug that would randomly display line numbers
- incorrectly.
- Game link port now supports external terminal I/O.
- Added LINK command to configure game link port.
- V1.08 didn't work on VGB. Haven't figured out why yet.
- V1.20 - MAJOR BUG FIXES.
- Added better handshaking to link port for reliable
- file download using GB Terminal.
- Fixed bug in floating point conversion that would
- randomly mess up many functions due to interrupts.
- Writing to screen is now much more reliable with no
- more random trash displayed on screen.
- SERVO 0,0 now disables all servo output pulses.
- Added MEMTOP, REGBC, REGDE, & USR commands.
- V1.21 Individual servos pulses may now be turned off by
- issuing SERVO x,0. On many servos this lowers battery
- drain when they're not in use.
-