- Convert basic programs to text files, or convert text files to basic program format. Windows binaries of the tokenizer and detokenizer added to the resources section.
- New Basic 1.0 version released, several bugs fixed. Visit http://bigfootinformatika.hu/65el02/ for details.
- MCFSTool GUI version added. See “Using the File System Section” or “Resources” for Download
- Experimental BASIC V2.0.120603 released
- BASIC v1.0.12062 released, added pixel graphics and pixeldemo program. TICKS renamed to DELAY
- Latest snapshot basic_120531 released
- Snapshot 120528: ”HELP” command added to show a list of available commands
- Disable Ctrl-C with POKE 2,255 (Enable with POKE 2,0) Tweaks on floating point calculations.
- Installing BASIC in Minecraft Redpower Control
- Getting Started
- Operator Evaluation Rules
- Strings & String Functions
- I/O Special Functions
- IO Expanders
- Using the File System
- Programming Examples
- Useful Tricks
- Known Bugs
- Insert and boot the blue Forth Disk
- When Mine OS has loaded insert a blank floppy into the drive,
- Type SAVE” BASIC” into the terminal, then type DISKID to print out the disk ID of the blank floppy. Take note of the disk ID.
- Minimize the game window and locate the “redpower” folder of your current world save. Macintosh Users: ~/Library/Application Support/minecraft/saves/savename/redpower/ Windows Users: %appdata%/minecraft/saves/savename/redpower/
- Find a file ending with .img which has the DISK ID that you took note of in step 3.
- Download the latest BASIC img from http://bigfootinformatika.hu/65el02/ and rename the file so that it matches the generated img in the redpower folder
- Drag the file into the redpower folder and overwrite the file. If prompted to overwrite the file answer “Yes”.
- Log back into the game and start with a fresh computer, make sure to add at least 1 module of 8k RAM or BASIC won’t run.
- Boot the BASIC yellow floppy disk, if everything went well you should see the start up message after a few seconds.
Congratulations you’ve successfully installed BASIC.
Replacing the default boot loader image for faster booting of BASIC (Optional)
- Download “rpcboot.bin” from http://bigfootinformatika.hu/65el02/
- Navigate to your Minecraft mod folder and locate the Redpower Control Mod Zip File Macintosh Users: ~/Library/Application Support/minecraft/mods/. Windows: %appdata%/minecraft/mods/
- Extract the files in the Zip
- Take the rpcboot.bin file that was downloaded from the site and place it in RedpowerControl-2.0pr5b2/elooram/control/
- If prompted to overwrite an already existing file answer yes
- Select the extracted files and re-compress it into a zip file with the original name, then place it into your mod folder
- If everything went well the new boot code should start up and load ms basic immediately.
Minecraft MS-Basic is a “standard” BASIC with additional string handling capability and I/O commands, as well as the following features.
Minecraft MS-Basic allows multiple statements per line via “:”. Next without a variable can be used for when FOR-NEXT statements are not nested. END statements are not necessary. Question marks can be used instead of “PRINT”. “LET” is optional. No spaces are required in BASIC. These features allow highly efficient memory usage when necessary.
Variables can be two characters long. Longer variables can be used but only the first two characters will be utilized. The first charter must be alphabetic, the second can be alphabetic or numeric. Long variables can not contain words used by BASIC such as NEW,SIN, and so on. Since spaces are not necessary BASIC would interpret a variable such as “ANEW” as a variable A and the command “NEW” and would erase the program.
Legal: A, A1, AZ, BEQ, APPLE, TUESDAY
Illegal: 1A, #B, TOO, RGOTO, NEW 1, FREQUENCY
*Note that variables like AZ1 and AZ2 would be treated the same since BASIC looks only at the first two characters
Lists program from line 100. Control C stops
program listing at end of current line.
|Starts program execution at first line. All vars
Run program from line 200 with variables reset
|NEW||NEW||Deletes current program|
|CONT||CONT||Continues program after Control C or STOP if the program has not been modified. For instance a STOP followed by manually printing out variables and then a CONT is a useful procedure in program debugging.|
|SAVE||SAVE "PROG"||Saves your basic program from memory to disk.|
|LOAD||LOAD "PROG"||Loads your basic program from disk to memory|
|DIR||DIR||Shows the disk directory|
|CLRSCR||CLRSCR||Clears the screen|
|DISKFORMAT||DISKFORMAT "MYDISK"||Creates MCFS(Minecraft file system) on a blank (or occupied :) disk with name MYDISK|
|SAVEBASIC||SAVEBASIC"BASIC"||Saves the basic interpreter to the disk|
|SETBOOT||SETBOOT "BOOTME"||Sets the boot flag for the file|
|HELP||HELP||lists available commands and functions|
|DELETE||DELETE "MYPROGS"||Deletes the file (and also remove the boot flag if it's presented on the file)|
AND, OR, NOT can also be used in Bit manipulation mode for performing Boolean operations of 16 bit 2s complement numbers (-32768 to +32767)
63 AND 16 Result: 16
-1 AND 8 Result: 8
4 OR 2 6 Result: 6
10 OR 10 Result:10
NOT 0 Result: -1
NOT 1 Result: -2
Math statements evaluated from left to right with * and / evaluated before + and -. Parentheses explicitly determine order of evaluation.
Precedence for evaluation:
- By parentheses
- * /
- + -
- =, <>, <, >, <=, >=
In the following examples
V or W is a numeric variable, X is a numeric expression, X$ is a string expression, I or J is a truncated integer
10 DATA 1,3,7
Data for READ statements must be in order to be read. Strings may be read in DATA statements
10 DEF FNA (V)=V*B
User defined function of one argument
110 DIM A (12)
Allocates space for Matrices and sets all matrix variables to zero. Non dimensioned variables default to 10
Terminates program (optional)
10 FOR X=.1 TO 10 STEP .1
30 NEXT X
STEP is needed only if X is not incremented by 1. NEXT X is needed only if FOR NEXT loops are nested if not NEXT alone can be used. Variables and functions can be used in FOR statements.
50 GOTO 100
Jumps to line 100
100 GO SUB 500
500 . . . .
Goes to subroutine, RETURN goes back to next line number after the GOSUB
IF . . . THEN
10 IF X = 5 THEN 5
10 IF X = 5 THEN PRINT X
10 IF X = 5 THEN PRINT X:Y=Z
If the statement is true, then the following will be executed including multiple statements of that line.
IF . . . GOTO
10 IF X=5 GOTO 5
Same as if THEN with line number
ON . . . GOTO
100 ON I GOTO 10, 20, 30
If I=1 then 10
If I=2 then 20
If I=3 then 30
10 PRINT X
20 PRINT “Test”
Prints value of expression. Standard BASIC syntax with , ; ” formats
490 READ V, W
Reads data consecutively from DATA statements in program
10 REM Type some comments here
This is a comment for non executed comments
Restores Intial values of all DATA statements
Stops program execution re-ports a BREAK. Program can be restarted via CONT
SETXY valx, valy
10 SETXY 20, 20
Sets the cursor to the specified coordinates.
10 DELAY 60
Makes the CPU wait 3 seconds (20 ticks per second) before executing the next instruction.
SETPIXEL valx, valy
puts a pixel at location 10,10 on the screen
clears the pixel at location 10,10 on the screen
For X=>0 ABS(X)=X
For X<0 ABS(X)=-X
Returns the absolute value of X
Evaluates X for the largest integer
Generates a random number between 0 and 1
Returns 1 if X >0
Returns 0 if X = 0
Returns -1 if exp <0
Sine of X in radians
Consine of X in radians
Tangent of X in radians
Arctangent of expression in radians
Square root of X
Used in print statements to TAB to specified position
Calls the users machine language subroutine with argument I, See section 13 for details.
E to the power of X where E=2.71828
Gives number of bytes left in workspace (X is dummy)
Gives the natural log of X
Returns carriage position of terminal (I is dummy)
Prints I amount of spaces , can only be used in print statements
Strings can be from 0 to 255 characters long. All Strings variables end in $. e.g. A$, B9$, HELLO$.
Strings can be dimensioned equated, printed, read from Data statements, etc
To print a string without starting a new line use “;” after of a string
e.g. PRINT “HELLO” ;
Returns the ASCII value of first character in string
Returns 1-char string whose char has ASCII code of I
LEFT$ (X$, I)
Gives left most I characters of string X$
Gives right most I character of string X$
MID $ (X$, I, J)
Returns chars from the middle of the string starting at the position specified (I) to the end of the string or for length characters (J)
Returns the length of the string
Converts a numeric expression to a string
Converts the string representation of a number to its numeric value
The following features of Minecraft BASIC are useful primarily for I/O control. The user should be extremely careful with some of these statements and functions since they manipulate the memory of the computer directly. An improper operation with PEEK, POKE, or SYS can cause a system crash, wiping out BASIC and the users program, thus requiring a complete reload of the computer
Returns the decimal value of the specified memory of I/O location. (Decimal)
will load variable X with the values in address 64256 ( 0xFB00)
POKE I, J
Loads memory location I (decimal) with J (decimal). I must be between 0 and 65536 and J must be between 0 and 255.
10 POKE 64256, 255 will load address 0xFB00 with FF(hex)
Read data from the terminal and store result in VAR$
Waits for a character and the result stored in VAL$, works in program mode only
Example: 1 GET A$:IF A$<>”" THEN PRINT ASC(A$)
This will execute machine code at 0×400 (1024 in decimal). Make sure the code ends with an RTS to be able to jump back into basic.
MMUSET I, J
Works like LDA #$J , MMU #$I assembly instructions (yy is 16 bit wide)
E.g. MMUSET0,1 : REM Sets the active redbus device id to 1
Works like MMU #$xx assembly instruction
E.g. MMUGET(129) : REM Reads the redbus window
IO Expander Output Color Values
IO Expander Functions
Reads the actual value from IO expander read buffer.
10 PRINT IOGET(3):
20 REM PRINT THE VALUE OF IO EXPANDER #3 READ BUFFER
Reads the actual value from IO expander output latch.
10 PRINT IOPEEK(4)
20 REM PRINT THE VALUE OF IO EXPANDER #4 OUTPUT LATCH
Sets the IO expander output latch to VAL. SETS THE IO EXPANDER OUTPUT LATCH TO VAL
10 IOSET 3,16
20 REM LIGHTS UP THE YELLOW WIRE CONNECTED TO DEVICE #3
Formatting the Disk
Before being able to load/save programs to disk you need to format it. After loading BASIC load a different floppy into the drive and type DISKFORMAT “NAME” to format it. Everything on the disk will be erased. After the formatting is complete the disk will be ready to use.
To save a program, insert a MCFS formatted disk into the drive and type SAVE “NAMEOFPROGRAM”. To load programs type LOAD “NAMEOFPROGRAM”. Use the DIR command to see the exisiting files on the current disk in drive. To delete a program file type DELETE “NAMEOFPROGRAM”.
Making a Bootable Basic Disk
To make a extra disk that boots into Basic, format a spare floppy, then type SAVEBASIC “BASIC”. The boot flag also needs to be set for the disk to boot into BASIC. Type SETBOOT “BASIC” to set the boot flag.
Using MCFSTool to Manage/Share/Backup Programs
MCFSTool is a command line tool used to operate img files formatted with Minecraft BASIC. With this tool you can extract Basic programs written within minecraft to share with others, or move them between multiple img files. Precompiled Windows and Mac binaries can be downloaded at the resources section. Use the readme.txt on how to use it, or ask for help at the forums.
GUI Frontend for MCFSTool now avaliable: Download (XP,Win7)
Door Password Program:
30 IOSET 3, 0 : REM CLEAR OUTPUT LATCH
40 PRINT "ENTER THE PASSWORD:" : INPUT PASS$
50 IF PASS$ ="PASSWORD" THEN PRINT "ACCESS GRANTED" : GOTO 100
60 PRINT "ACCESS DENIED…"
70 TICKS 100
80 GOTO 20
100 IOSET 3,1 : REM TURN ON THE WHITE WIRE TO OPEN THE DOOR
120 PRINT "DOOR CLOSING IN 5 SECONDS. . ."
130 GOTO 70
Bresenham’s Circle (Very fast circle drawing algorithm)
10 X=20 : Y= 20 : R = 17 : REM SET X, Y POS, AND RADIUS
40 LET F=(R+R)+3
50 LET CX=R
60 LET DX=0
70 IF CX>=DX GOTO 90
80 GOTO 500
90 SETXY X+DX,Y+CX : PRINT CHR$(160)
100 SETXY X+DX,Y-CX : PRINT CHR$(160)
110 SETXY X-DX,Y+CX : PRINT CHR$(160)
120 SETXY X-DX, Y-CX : PRINT CHR$(160)
130 SETXY X+CX, Y+DX : PRINT CHR$(160)
140 SETXY X+CX, Y-DX : PRINT CHR$(160)
150 SETXY X-CX, Y+DX : PRINT CHR$(160)
160 SETXY X-CX, Y-DX : PRINT CHR$(160)
170 IF F>=0 GOTO 185
180 GOTO 200
220 GOTO 70
60 SETXY 10,10 : PRINT X
70 SETXY 15,10 : PRINT Y
80 SETXY 20,10 : PRINT Z
200 IF X=Y AND Y=Z THEN PRINT "JACKPOT!" : END
210 IF X=Y OR Y=Z OR Z=X THEN PRINT "ALMOST!"
220 PRINT "PRESS SPACE" : GET A$
230 IF A$ = CHR$(32) GOTO 10
GETTING A RANDOM NUMBER :
NUMBER = RND(1) * (UPPER LIMIT – LOWER LIMIT) + LOWER LIMIT
Executing Custom Machine Code:
You can either preload machine code into the basic.img file with a hex editor and add 0×500 to get the start address, or poke it in manually within basic. There are two ways you can execute machine code from within basic:
This will execute machine code at 0×400 (1024 in decimal). Make sure the code ends with an RTS to be able to jump back into basic.
USR is still supported, but we recommend you use SYS instead. To use USR find out where your subroutine is in memory, then the start addresses of the user subroutine is poked into addresses 0xD (low bit, decimal 13) and 0xE (high bit, decimal 14). The subroutine must end with an RTS and stack should be the same level on exit when the routine was entered.
The subroutine I created starts at 0x24C0. The address is poked in little endian format.
0xCO = 192, 0×24 = 36
10 POKE 13, 192
20 POKE 14, 36
25 REM Execute the subroutine
Peek & Poke
PEEK(ADDRESS) : get value at memory address
e.g. PRINT PEEK(900)
POKE Address, value : insert value into memory address
e.g. POKE 900, 48
Disable Ctrl – C with POKE 2,255
10 POKE 2,255 : REM Unbreakable infinite loop
20 PRINT “INFINITE LOOP”
30 GOTO 20
Disable CTRL-C with POKE2,255. Re-enable it with POKE2,0
Basic v1.0.120602: Val function returning duplicate numbers when copying variables