wwwBASIC

Update on wwwBASIC,
now with DONKEYs

Septemeber 22, 2018

Brad Nelson / @flagxor

Recap

  • Ed Thelen's Nike Hercules Simulation
  • "guaranteed to be virus free"
  • Why not run on the Web?
  • Compile to JavaScript
  • Run the code as-is
  • BASIC as a scoped problem
  • Inspire my next Web Forth

Nike Hercules Simulation

Open-sourcing

  • Open sourced as Google project
  • github.com/google/wwwbasic
  • Runs Ed's program, some samples
  • But there's a lot more BASIC out there...

DONKEY.BAS


940 REM The IBM Personal Computer Donkey
950 REM Version 1.10 (C)Copyright IBM Corp 1981, 1982
960 REM Licensed Material - Program Property of IBM
          

DONKEY.BAS

DONKEY.BAS

  • Demo for BASIC on IBM PC
  • Written by Bill Gates & Neil Konzen
  • In a locked room
  • That was over 100 degrees

DONKEY.BAS BASICA Compat

  • Line Numbers
  • DATA, READ, RESTORE
  • => ?!?!
  • DEF SEG, PEEK, POKE
  • DRAW
  • PLAY (caveat)
  • GET / PUT
  • PAINT
  • WIDTH 40
  • Font

DONKEY.BAS - Code Mystery #1


975 DEF SEG: POKE 106,0
          

Code Mystery #1 (SAMPLES.BAS)


210 LOCATE 7,3,0:PRINT  "A - MUSIC    (32k)"
220 LOCATE 8,3,0:PRINT  "B - ART      (32k-Color/Graphics)"
230 LOCATE 9,3,0:PRINT  "C - MORTGAGE (48k)"
240 LOCATE 10,3,0:PRINT "D - CIRCLE   (BASICA-Color/Graphics)"
250 LOCATE 11,3,0:PRINT "E - DONKEY   (BASICA-Color/Graphics)"
251 LOCATE 12,3,0:PRINT "F - PIECHART (BASICA-Color/Graphics)"
252 LOCATE 13,3,0:PRINT "G - BALL     (BASICA-Color/Graphics)"
253 LOCATE 14,3,0:PRINT "H - COLORBAR (32k)"
254 LOCATE 15,3,0:PRINT "I - CALENDAR (32k)"
255 LOCATE 16,3,0:PRINT "J - SPACE    (BASICA-Color/Graphics)"
256 LOCATE 17,3,0:PRINT "ESC KEY - EXIT"
260 LOCATE 19,3,0:PRINT "ENTER LETTER OF PROGRAM"
262 LOCATE 21,3,0:PRINT "NOTE: All of the above programs"
263 LOCATE 22,3,0:PRINT "      require 48k if using BASICA"975 DEF SEG: POKE 106,0
270 POKE 106,0 'CLEAR KYBD BUFFER
          

DONKEY.BAS - Code Mystery #2


1160 DEF SEG=0
1170 IF (PEEK(&H410) AND &H30)<>&H30 THEN DEF SEG:GOTO 1291
          

DONKEY.BAS - Code Mystery #2


1160 DEF SEG=0
1170 IF (PEEK(&H410) AND &H30)<>&H30 THEN DEF SEG:GOTO 1291
1180 WIDTH 80:CLS:LOCATE 3,1
1190 PRINT "HOLD IT!"
1200 PRINT "YOU'RE NOT USING THE COLOR/GRAPHICS MONITOR ADAPTER!"
1210 PRINT "THIS PROGRAM USES GRAPHICS AND REQUIRES THAT ADAPTER."
1220 PRINT "PRESS THE SPACE BAR TO CONTINUE."
1230 DEF SEG
          

DONKEY.BAS - Code Mystery #2

  • 0x0410 (word) packed bit flags for detected hardware
  • Fortunately PEEK(0) → 0 works

DRAW


1800 DRAW"BM12,1r3m+1,3d2R1ND2u1r2d4l2u1l1"
1810 DRAW"d7R1nd2u2r3d6l3u2l1d3m-1,1l3"
1820 DRAW"m-1,-1u3l1d2l3u6r3d2nd2r1u7l1d1l2"
          

DRAW

  • Mini-language for drawing
  • Memory efficient
  • Un Dn Ln Rn | Cn | Mx,y | Sn
  • B - Move but don't draw
  • N - Move but go back after

A Donkey


SCREEN 1
1950 DRAW"S08"
1960 DRAW "BM14,18"
1970 DRAW"M+2,-4R8M+1,-1U1M+1,+1M+2,-1
1980 DRAW"M-1,1M+1,3M-1,1M-1,-2M-1,2"
1990 DRAW"D3L1U3M-1,1D2L1U2L3D2L1U2M-1,-1"
2000 DRAW"D3L1U5M-2,3U1"
          

A Donkey

PAINT

  • Flood fill
  • PAINT(x,y), attrib [,border] [,background]
  • Not quite like MSPaint
  • Later versions support patterns in strings

A Painted Donkey


SCREEN 1
1950 DRAW"S08"
1960 DRAW "BM14,18"
1970 DRAW"M+2,-4R8M+1,-1U1M+1,+1M+2,-1
1980 DRAW"M-1,1M+1,3M-1,1M-1,-2M-1,2"
1990 DRAW"D3L1U3M-1,1D2L1U2L3D2L1U2M-1,-1"
2000 DRAW"D3L1U5M-2,3U1"
2010 PAINT (21,14),3
          

A Painted Donkey

GET / PUT


1470 DIM DNK%(300)
...
2040 GET (13,0)-(45,25),DNK%
          

GET / PUT


1740 IF Y=>3 THEN PUT (DX,Y),DNK%,PSET
          

GET / PUT


1510 DIM B%(300)
1520 FOR I=2 TO 300:B%(I)=-16384+192:NEXT
1530 B%(0)=2:B%(1)=193
...
1760 IF Y AND 3 THEN PUT (140,6),B%
          

GET / PUT

WIDTH 40 + Line Art

  • The "other" text mode
  • 40x25
  • Used for title screen

Font

Discovered by the Press!

9/16 - Hacker News

9/18 - Boing Boing

9/18 - Hackaday

Community

  • Open source community shows up
  • QB64
  • Interest in GORILLA.BAS + NIBBLES.BAS
  • 12 PRs (as of 9/22)
  • 7 Team members (as of 9/22)
  • Fixes, docs fixes, great ideas
  • Logistics of github
  • NPM Package
  • Logo
  • ACE Editor

NPM Package

  • NPM - Node.js Package Manager
  • package.json - manifest for a project
  • npm install -S wwwbasic

Logo

  • Ask and you shall receive...

wwwBASIC Logo - metaa

wwwBASIC Logo - why-does-ie-still-exist

wwwBASIC Logo - why-does-ie-still-exist

wwwBASIC Logo - anilkilic

wwwBASIC Logo - anilkilic

wwwBASIC Logo - anilkilic

wwwBASIC Logo - anilkilic

Editor

  • unitycoder - has anyone added ace editor syntax highlight/definitions for this yet?
    https://ace.c9.io/

    would be nice to have online code playground for this..
  • Interactivity key to Haiku Forth success
  • Ace Editor for cloud9 IDE
  • No BASIC syntax file, but has FORTRAN!

Editor

Editor

What's Next?

  • Better Documentation
  • Better Tests
  • QBasic Compat
  • FUNCTION, SUB, DEF FN
  • TYPES (working partially)
  • GORILLA.BAS ---
  • NIBBLES.BAS ---

wwwBASIC and slides at:
github.com/flagxor

Thank you