Tag: Stefan’s BASIC

  • Permacomputer Text Editor Devlog #2

    Permacomputer Text Editor Devlog #2

    The proof-of-concept Tiny BASIC text editor that the people’s permacomputer project sponsors has hit another milestone.

    The text editor has added a primitive edit mode.

    Edit mode allows a simple search and replace functionality. Please be advised that the program will only replace the first match it finds, requiring the user to rather laboriously repeat typing in the fields.

    Ctrl-D (see code, ASCII code number 4) is the keyboard sequence that the user must input in order to complete an edit field. This is somewhat unconventional, but it allows a user to search strings that include newlines.

    The code, however, is a global search of the whole buffer, and is a departure from EDITYPE, which required users to step through the buffer one line at a time.

    Video

    Current Code

    Please note that all indentation is for cosmetic purposes only. Many of these lines, if copied and pasted verbatim from this presentation of the code, will be truncated by default Stefan’s BASIC settings.

    Apple 1 compatibility is primarily turned on to enable string array functionality.

    1 REM PEOPLE'S PERMACOMPUTER EDITOR.
    2 REM INSPIRED BY VIC EDITYPE (1983).
    3 REM
    4 REM DESIGNED FOR THE ARDUINO MEGA 2560.
    5 REM WRITTEN IN STEFAN'S BASIC.
    6 REM
    7 REM PUBLIC DOMAIN DEDICATION.
    8 REM
    9 REM 
    10 SET 22,"Apple1"
    20 DIM T$(48,24)
    30 FOR I=1 TO 24:T$()(I)="":NEXT I
    40 DIM SCRATCH$(48)
    41 DIM SEARCH$(80)
    42 DIM REPLACE$(80)
    43 DIM C6$(80)
    50 NL=1
    60 BKSP=8
    70 CR=13
    80 LF=10
    499 REM FALL INTO HERE
    500 REM MENU
    510 PRINT: PRINT "N=NEW E=EDIT P=PRINT S=SAVE Q=QUIT"
    520 INPUT ">";M$
    530 IF M$="N" GOTO 1000
    540 IF M$="E" GOTO 3000
    550 IF M$="P" GOTO 4000
    555 IF M$="S" GOTO 5000
    560 IF M$="Q" GOTO 9000
    570 GOTO 500
    1000 REM COMPOSE MODE 
    1001 INPUT "TYPE FILE NAME";V$
    1002 GOSUB 9000: REM CLEAR SCREEN
    1003 PRINT "COMPOSE MODE"
    1005 IF NL>24PRINT "LINE LIMIT":  GOTO 500
    1010 PRINT ">";T$()(NL);
    1020 GET C$
    1030 IF C$="" THEN  GOTO 1020
    1040 IF C$="@" THEN  GOTO 500
    1050 IF C$=CHR$(BKSP) AND LEN(T$()(NL))=0 THEN  GOTO 1020
    1060 IF C$=CHR$(BKSP) THEN  GOTO 1600
    1070 IF C$=CHR$(CR) OR C$=CHR$(LF) THEN  GOTO 1500
    1080 IF ASC(C$)<32 GOTO 1020
    1090 PUT C$
    1100 T$()(NL)=T$()(NL)+C$
    1120 C$=""
    1130 IF LEN(T$()(NL))<48 THEN 1020
    1199 REM FALL INTO HERE
    1200 REM WORD WRAP (IF LINE HITS 48)
    1210 S=LEN(T$()(NL))
    1220 IF RIGHT$(T$()(NL),1)=" " THEN  GOTO 1250
    1230 SCRATCH$=T$()(NL+1)
    1232 T$()(NL+1)=RIGHT$(T$()(NL),1)+SCRATCH$
    1240 T$()(NL)=LEFT$(T$()(NL),S-1)
    1245 S=S-1:GOTO 1220
    1250 REM MEMORY CHECKS
    1260 IF T$()(NL)="" THEN T$()(NL)=" "
    1270 IF SIZE <600 THEN PRINT "MEMORY LOW": PRINT
    1280 IF SIZE <500 THEN PRINT "MEMORY CRITICAL":  GOTO 500
    1290 NL=NL+1
    1291 REM ENABLE THE FOLLOWING LINE TO ECHO THE WRAPPED PRECEDING LINE
    1295 REM PRINT:PRINT ">";T$()(NL-1);
    1300 PRINT: PRINT ">";T$()(NL);
    1310 GOTO 1020
    1500 REM NEWLINE
    1505 PUT CR: PUT LF
    1510 NL=NL+1
    1520 IF NL>24 THEN PRINT "BUFFER FULL":  GOTO 500
    1530 GOTO 1010
    1600 REM BACKSPACE (CURRENT LINE ONLY)
    1610 L=LEN(T$()(NL))
    1615 IF L<1 GOTO 1020
    1620 IF L=1 THEN T$()(NL)="":  GOTO 1640
    1625 SCRATCH$=LEFT$(T$()(NL),L-1)
    1630 T$()(NL)=SCRATCH$
    1640 PUT 8: PUT 32: PUT 8
    1650 GOTO 1020
    2999 REM EDIT MODE
    3000 SEARCH$="": REPLACE$=""
    3010 PRINT "EDIT MODE"
    3020 PRINT "@=RETURN TO MENU"
    3030 PRINT "C=CORRECT"
    3040 FOR I=1 TO 24
    3050     PRINT I,T$()(I)
    3060 NEXT I
    3070 GET W$
    3080 IF W$="" THEN  GOTO 3070
    3090 IF W$="@" THEN  GOTO 500
    3100 IF W$="C" THEN  GOTO 3200
    3110 GOTO 3070
    3200 PRINT "ERROR:"
    3210 FOR ERRSTRING=1 TO 80
    3220     GET J$
    3230     IF J$="" THEN  GOTO 3220
    3240     IF J$=CHR$(4) THEN  GOTO 3290
    3250     IF J$=CHR$(BKSP) THEN SEARCH$=LEFT$(SEARCH$,LEN(SEARCH$)-1):  GOTO 3270
    3260     SEARCH$=SEARCH$+J$
    3270     PRINT J$;
    3280 NEXT ERRSTRING
    3290 PRINT: PRINT "CORRECTION: "
    3300 FOR ERRSTRING=1 TO 80
    3310     GET J$
    3320     IF J$="" THEN  GOTO 3310
    3330     IF J$=CHR$(4) THEN  GOTO 3500
    3340     IF J$=CHR$(BKSP) THEN REPLACE$=LEFT$(REPLACE$,LEN(REPLACE$)-1):  GOTO 3360
    3350     REPLACE$=REPLACE$+J$
    3360     PRINT J$;
    3370 NEXT ERRSTRING
    3500 GOSUB 9000: REM CLEAR SCREEN
    3510 PRINT "CORRECTING"
    3520 FOR I=1 TO 24
    3530     FOR J=1 TO LEN(T$()(I))
    3540         O=LEN(SEARCH$)
    3550         IF MID$(T$()(I),J,O)=SEARCH$ THEN OO=LEN(T$()(I))-J+1-O
    3560         IF MID$(T$()(I),J,O)=SEARCH$ THEN C6$=RIGHT$(T$()(I),OO)
    3570         IF MID$(T$()(I),J,O)=SEARCH$ THEN T$()(I)=LEFT$(T$()(I),J-1):  GOTO 3590
    3580         GOTO 3610
    3590         T$()(I)=T$()(I)+REPLACE$+C6$: SEARCH$="": REPLACE$=""
    3600         FOR H=1 TO I: PRINT T$()(H): NEXT H:  GOTO 3020
    3610     NEXT J
    3620 NEXT I
    3630 PRINT "ERROR STRING NOT FOUND": PRINT:  GOTO 3020
    3640 GOTO 3000
    9000 PUT 27: PUT 91: PUT 50: PUT 74: RETURN: REM CLEAR SCREEN

    Important Links

    Git Repo

    https://codeberg.org/vidak/peoples

    Forum Thread Discussion

    https://basiclang.solarpunk.au/d/4-the-peoples-permacomputer-project/15

    VIC EDITYPE Historical Source Code

    http://www.vic20listings.freeolamail.com/book_computevic2.html

  • Permacomputer Text Editor Devlog #1

    Permacomputer Text Editor Devlog #1

    Progress has been made on the text editor that will be shipped on the first model of the people’s permacomputer.

    Please follow the code development here:

    https://codeberg.org/vidak/peoples

    Also, have a look at an earlier, historical editor from which this one was inspired, “VIC EDITYPE”:

    http://www.vic20listings.freeolamail.com/book_computevic2.html

    Forum thread here:

    https://basiclang.solarpunk.au/d/4-the-peoples-permacomputer-project/15

    Current Code:

    1 REM PEOPLE'S PERMACOMPUTER EDITOR.
    2 REM INSPIRED BY VIC EDITYPE (1983).
    3 REM
    4 REM DESIGNED FOR THE ARDUINO MEGA 2560.
    5 REM WRITTEN IN STEFAN'S BASIC.
    6 REM
    7 REM PUBLIC DOMAIN DEDICATION.
    8 REM
    9 REM
    10 SET 22, "Apple1"
    20 DIM T$(48,24)
    30 FOR I=1 TO 24 : T$()(I)="" : NEXT I
    40 DIM SCRATCH$(48)
    50 NL=1
    60 BKSP=8
    70 CR=13
    80 LF=10
       
    499 REM FALL INTO HERE
    500 REM MENU
    510 PRINT:PRINT "N=NEW E=EDIT P=PRINT S=SAVE Q=QUIT"
    520 INPUT ">"; M$
    530 IF M$="N" GOTO 1000
    540 IF M$="E" GOTO 2000
    550 IF M$="P" GOTO 3000
    555 IF M$="S" GOTO 3500
    560 IF M$="Q" GOTO 9000
    570 GOTO 500
    
    1000 REM COMPOSE MODE 
    1001 INPUT "TYPE FILE NAME";V$
    1002 PUT 27 : PUT 91 : PUT 50 : PUT 74:REM CLEAR SCREEN
    1003 PRINT "COMPOSE MODE"
    1005 IF NL>24 PRINT "LINE LIMIT" : GOTO 500
    1010 PRINT ">";T$()(NL);
    1020 GET C$
    1030 IF C$="" THEN GOTO 1020
    1040 IF C$="@" THEN GOTO 500
    1050 IF C$=CHR$(BKSP) AND LEN(T$()(NL))=0 THEN GOTO 1020
    1060 IF C$=CHR$(BKSP) THEN GOTO 1600
    1070 IF C$=CHR$(CR) OR C$=CHR$(LF) THEN GOTO 1500
    1080 IF ASC(C$)<32 GOTO 1020 
    1090 PUT C$
    1100 T$()(NL)=T$()(NL)+C$
    1120 C$=""
    1130 IF LEN(T$()(NL))<48 THEN 1020
         
    1199 REM FALL INTO HERE
    1200 REM WORD WRAP (IF LINE HITS 48)
    1210 S=LEN(T$()(NL))
    1220 IF RIGHT$(T$()(NL),1)=" " THEN GOTO 1250
    1230 SCRATCH$=T$()(NL+1)
    1232 T$()(NL+1)=RIGHT$(T$()(NL),1)+SCRATCH$
    1240 T$()(NL)=LEFT$(T$()(NL),S-1)
    1245 S=S-1:GOTO 1220
    1250 REM MEMORY CHECKS
    1260 IF T$()(NL)="" THEN T$()(NL)=" "
    1270 IF SIZE<600 THEN PRINT "MEMORY LOW":PRINT
    1280 IF SIZE<500 THEN PRINT "MEMORY CRITICAL":GOTO 500
    1290 NL=NL+1
    1295 PRINT:PRINT ">";T$()(NL-1);
    1300 PRINT:PRINT ">";T$()(NL);
    1310 GOTO 1020
    
    1500 REM NEWLINE
    1505 PUT CR : PUT LF
    1510 NL=NL+1
    1520 IF NL>24 THEN PRINT "BUFFER FULL" : GOTO 500
    1530 GOTO 1010
    
    1600 REM BACKSPACE (CURRENT LINE ONLY)
    1610 L=LEN(T$()(NL))
    1615 IF L<1 GOTO 1020
    1620 IF L=1 THEN T$()(NL)="":GOTO 1640
    1625 SCRATCH$=LEFT$(T$()(NL),L-1)
    1630 T$()(NL)=SCRATCH$
    1640 PUT 8 : PUT 32 : PUT 8
    1650 GOTO 1020
  • Project Update October 2026

    Project Update October 2026

    The current points of focus in the project are:

    • Coming up with a text editor you can type into a Tiny BASIC interpreter by hand. Something around 200 to 300 lines of code, and allows, say, a couple of pages of text of free RAM, for the user to do serious work within. Perhaps something in excess of 2K free RAM.
    • The current hardware that the project imagines it will target are:
      1. The Arduino mega, with its 8K total SRAM. This board loads Stefan’s BASIC with ~6.5K free RAM. With a rough yardstick of 80×25 characters being ~ 2K, the text editor must come in at around ~ 4.5K. This configuration is ‘headless’, in the sense that you must communicate with the mega via serial monitor. Please see this post for a text editor in BASIC that may serve as inspiration for a modern clone or recreation.
      2. The LILYGO TTGO VGA32, with configurations of Stefan’s BASIC ranging from 32K user program memory space to an upper limit of 64K. With VGA output capabilities, this is a good “all-in-one” solution to acquiring BASIC. PS2 keyboard required.
      3. A hypothetical implementation of BASIC that the project calls ‘idiomatic BASIC’, which is designed to facilitate a maximum portability of the above mentioned text editor to other, perhaps unintended flavours of BASIC. This may largely look like the approach taken by David Ahl in BASIC Computer Games.
  • SKETCH.BAS

    SKETCH.BAS

    Please find reproduced here a working port of SKETCH for the TRS Model 100 to Stefan’s BASIC for the Arduino micro-controller platform.

    Full code listing:

    https://basiclang.solarpunk.au/d/15-sketchbas

    Please find the archive.org link to the 1984 book here:

    https://archive.org/details/25GamesForYourTrs80Model100/page/n49/mode/1up

    Live Coding Session

    Video File

    Peertube Streaming

    CODE LISTING

    10 REM ***********
    20 REM *         *
    30 REM * Sketch  *
    40 REM *         *
    50 REM ***********
       
    55 REM *** Instructions ***
       
    60 CLS:PRINT:PRINT
    70 PRINT TAB(12)"Instructions?"
    80 PRINT:PRINT TAB(16)"(Y/N)"
    90 GET A$:IF A$="" GOTO 90
    100 IF A$="Y" OR A$="y" THEN GOTO 110 ELSE GOTO 270
    110 CLS:PRINT:PRINT
    120 PRINT TAB(2)"You may use either Sketch or Draft"
    130 PRINT TAB(2)"modes. Sketch uses a moving line to"
    140 PRINT TAB(2)"draw, while Draft draws lines between"
    150 PRINT TAB(2)"two points you specify by hitting ";CHR$(34);"S";CHR$(34);"."
    160 PRINT:PRINT TAB(1)"= Hit any key for Sketch instructions =";
    170 GET A$:IF A$="" GOTO 170
    180 CLS:PRINT
    190 PRINT TAB(12)"==  Sketch =="
    200 PRINT TAB(13)"[Controls:]"
    210 PRINT TAB(2)"Arrow Keys -- Change direction"
    220 PRINT TAB(2)"Number keys -- Slow down cursor"
    230 PRINT TAB(2)CHR$(34);"F";CHR$(34);" -- Return to top speed"
    240 PRINT TAB(2)"Space Bar -- Toggle cursor (ON)-(OFF)"
    250 PRINT:PRINT TAB(11)"== Hit any key =="
    260 GET A$:IF A$="" GOTO 260
        
    265 REM *** Set Delay ***
        
    270 CLS:PRINT:PRINT
    280 PRINT TAB(6)"Enter speed desired:"
    290 PRINT
    300 PRINT TAB(6)"[1] Fast to [9] Slow"
    310 GET A$:IF A$="" GOTO 310
    320 OG=VAL(A$)*10:IF OG<1 GOTO 310
    330 DL=OG
        
    335 REM ***  Choose Sketch or Draw Mode ***
        
    340 CLS:PRINT:PRINT
    350 PRINT TAB(4)"Do you want:"
    360 PRINT:PRINT TAB(6)"[S]ketch mode"
    370 PRINT TAB(6)"[D]raft mode"
    380 GET A$:IF A$="" GOTO 380
    390 IF A$="S" OR A$="s" GOTO 420
    400 IF A$="D" OR A$="d" GOTO 710
    410 GOTO 380
    420 CLS
    430 REM FOR N=1 TO VAL(RIGHT$(TIME$,2))
    440 REM DM=RND(1)
    450 REM NEXT N
    460 X=239:Y=63
    470 X1=INT(RND(X)*X)+1:Y1=INT(RND(X)*Y)+1
    480 COLOR 255: PLOT X1,Y1
        
    485 REM *** Sketch Mode ***
        
    490 GET A$
    500 X1=X1+XD:IF X1>239 THEN X1=239
    510 IF X1<0 THEN X1=0
    520 Y1=Y1+YD:IF Y1>63 THEN Y1=63
    530 IF Y1<0 THEN Y1=0
    540 DELAY DL*10
    550 IF FLAG<>1 GOTO 570
    560 COLOR 255:PLOT X1,Y1:DELAY 100:NEXT N:COLOR 0:PLOT X1,Y1:GOTO 580
    570 COLOR 255:PLOT X1,Y1
    580 IF A$="" GOTO 490
    590 IF VAL(A$)<1 GOTO 610
    600 DL=DL*VAL(A$)
    610 IF A$="F" OR A$="f" THEN DL=OG
    620 A=ASC(A$)
    630 IF A<>32 GOTO 650
    640 IF FLAG=1 THEN FLAG=0 ELSE FLAG=1
        
    650 IF A=4 GOTO 670
    651 IF A=5 GOTO 690
    652 IF A=19 GOTO 680
    653 IF A=24 GOTO 700
    654 GOTO 490
        
    655 REM *** Change direction of Cursor ***
        
    660 REM ON A-27 GOTO 670, 680, 690, 700
    670 YD=0:XD=1:GOTO 490 REM RIGHT
    680 YD=0:XD=-1:GOTO 490 REM LEFT
    690 XD=0:YD=-1:GOTO 490 REM UP
    700 YD=1:XD=0:GOTO 490 REM DOWN
        
    705 REM *** Draft  Mode ***
        
    710 X1=40:Y1=40
    720 CLS
    730 GET A$
    740 X1=X1+XD:IF X1>239 THEN X1=239
    750 IF X1<0 THEN X1=0
    760 Y1=Y1+YD:IF Y1>63 THEN Y1=63
    770 IF Y1<0 THEN Y1=0
    780 DELAY DL*10
    790 COLOR 255:PLOT X1,Y1
    800 DELAY 50
    810 COLOR 0:PLOT X1,Y1
    820 IF A$="" GOTO 730
    830 IF A$="S" or A$="s" GOTO 850
    840 GOTO 990
        
    845 REM *** Set one point ***
        
    850 PO=PO+1
    860 COLOR 255:PLOT X1,Y1
    870 IF PO=1 THEN X2=X1:Y2=Y1:GOTO 730
        
    875 REM ***  Draw Line ***
        
    880 LINE X1,Y1,X2,Y2
    890 PO=0
    900 GET A$:IF A$="" GOTO 900
    910 IF A$="S" OR A$="s" GOTO 950
    920 A=ASC(A$)
    930 IF A<>4 AND A<>5 AND A<>19 AND A<>24 GOTO 900
    940 GOTO 980
    950 PO=1
    960 X2=X1:Y2=Y1
    970 GOTO 900
        
    975 REM *** Change Cursor Direction ***
    
    980 IF A=4 GOTO 990 REM RIGHT
    981 IF A=5 GOTO 1010 REM UP
    982 IF A=19 GOTO 1000 REM LEFT
    983 IF A=24 GOTO 1020 REM DOWN
    984 GOTO 900
    990 YD=0:XD=1:GOTO 730
    1000 YD=0:XD=-1:GOTO 730
    1010 XD=0:YD=-1:GOTO 730
    1020 YD=1:XD=0:GOTO 730
    
  • Watch Me Code A Procedurally Generated Game in BASIC!

    Watch Me Code A Procedurally Generated Game in BASIC!

    “Coding done quick”.

    I sped a ~2 hour stream up by 800% and cut some boring bits out, and this is what i got.

    Experimenting with a large, procedurally generated world.

    —

    mailto:vidak@member.fsf.org

    https://matrix.to/#/@vidak:solarpunk.au

    https://retro.social/@permacomputer

    —

    jan 2026

    https://sr.ht/~vidak/oats-for-my-goats

    https://basiclang.solarpunk.au/d/6-game-oats-for-my-goats