PICOBASIC v0.3

A Tiny BASIC Interpreter Running inside PICO-8


INTRO

PICOBASIC is a cartridge that implements the BASIC programming language - with additions for graphics -, plus some extras like an editor and a command mode to manage your programs.

It’s retro computing inside a fantasy console. A meta 8-bit experience!

GOALS

The goal of this is to learn how an interpreted language works, as well as to carry out a fun project that allows me to keep developing my skills in Lua with PICO-8.

Also, want to give people a way to easily create and run simple programs in BASIC when they have no programming experience in Lua.

CURRENT STATUS

Now, project is functional but i need to implement basic things like arrays, better error diagnosis, expanded editor features like syntax highlighting, import and export code, etc...

You can find code here:  https://github.com/rudahee/picoBASIC

FEATURES

Program Instructions

PRINT
write text to the terminal
LET
assign a value to a variable
INPUT
read a value from the user
REM
add comments to your code

Flow Control

IF THEN
execute code conditionally
FOR NEXT STEP
repeat code a number of times
RETURN
return from a subroutine
GOTO
jump to a line number
GOSUB
call a subroutine
END
finish the program or subroutine

Math Functions

ABS
absolute value
INT
integer part of a number
LEN
length of a string
MID$
extract substring from a string
STR$
convert number to string
VAL
convert string to number
REM
add comments to your code

Graphics Functions

CLS
clear the screen
PSET
set a pixel on the screen
CIRC
draw a circle
RECT
draw a rectangle
TEXT
draw text on the screen
WAIT
pause the program for a short time
BTN
check if a button is pressed

EXAMPLE PROGRAMS

Example 1: Hello World

        10 print "Give me your name: "
        20 input name$
        30 print "Hello, " + name$ + "!"
    

Example 2: Growing Circle

        10 cls 0
        20 for i=0 to 64 step 4
        30 circ 64,64,i,7
        40 wait
        50 next i
        60 goto 10
    

Example 3: A Simple Game

        10 
        20 bx=64
        30 by=20
        40 bdx=1
        50 bdy=1
        60 px=54
        70 score=0
        80 spd=1
        100 cls 1
        110 if btn(0)=0 then goto 130
        120 px=px-3
        130 if btn(1)=0 then goto 150
        140 px=px+3
        150 if px<0 then px=0
        160 if px>107 then px=107
        170 bx=bx+bdx
        180 by=by+bdy
        190 if bx<2 then bdx=0-bdx
        200 if bx>125 then bdx=0-bdx
        210 if by<2 then bdy=0-bdy
        220 if by<115 then goto 280
        230 if bx>px+20 then goto 350
        250 bdy=0-bdy
        260 score=score+1
        270 if score<5 then goto 280
        275 if score<10 then goto 278
        276 spd=3
        277 goto 280
        278 spd=2
        280 rect px,117,px+20,121,7
        290 circ bx,by,2,10
        300 line 0,6,127,6,5
        310 text "score:"+str$(score),2,0,11
        320 text "spd:"+str$(spd),90,0,6
        330 wait
        340 goto 100
        350 cls 0
        360 print "game over"
        370 print "score:"+str$(score)
        380 if score>9 then goto 420
        390 print "keep playing!"
        400 input
        410 goto 440
        420 print "great!"
        430 input
        420 wait
        430 wait
        440 wait
        450 end
    
Updated 4 hours ago
Published 3 days ago
StatusReleased
PlatformsHTML5
Release date 3 days ago
AuthorRuDaHee
Made withPICO-8
Tags8-Bit, basic, lua, PICO-8, utils
Code licenseGNU General Public License v3.0 (GPL)
Average sessionAbout a half-hour
LanguagesEnglish
InputsKeyboard, Mouse

Download

Download
picobasic_linux.zip 761 kB
Download
picobasic_osx.zip 7.4 MB
Download
picobasic_raspi.zip 2.2 MB
Download
picobasic_windows.zip 995 kB
Download
picobasic.p8.png 15 kB
Download
picobasic.p8.rom 32 kB

Development log

Leave a comment

Log in with itch.io to leave a comment.