WimBasic

Today's Extended Basic Level II extension for VIC20 featuring SuperNumbers (tm)

Autostart function

When the WimBasic extension starts 'cold', it tries to find a file by the name of WBSTART from device #8. When found, it  loads and runs it, using the DOS <up-arrow> command.

This allows for customization, i.e. automatically starting any other program.

Interactive scrolling

Scrolling during LIST, FIND, DUMP, MATRIX, HELP, DOS-command ">$": Press CTRL to slow down scrolling, press C= to stop scrolling, press and release CTRL to resume scrolling.

During tracing the program execution can be slowed down using the CTRL and the C= keys.

 

Also, when a program listing is on the screen, the cursor up and down keys scroll back and forth through the program. After a RUN/STOP-RESTORE, this scrolling is disabled. It can be re-enabled through a KEY ON command.

Joystick support

The default vector for USR() points to a routine that reads the joystick and returns the direction(s) as a value. "up" returns -22, "down" returns 22, "left" returns -1 and "right" returns 1. No direction returns 0 and a combination of directions returns the appropriate value. The fire button does not return a value.

When USR() is needed for your own routine, save the default vector first (X=DEEK(1)).

Handling errors in WimBasic

When the program runs and an error occurs, WimBasic first checks if an ON ERROR GOTO is active. If so, the variable EC is given the value of the errorcode and variable EL is given the value of line where the error occured. Processing then continues at the linenumber that was specfied in ON ERROR GOTO. The errorstatus is dismissed when a RESUME is executed.

If ON ERROR GOTO is not active, the line that contains the error is listed, with the cursor at the position where the error occurred and the program stops. 

Error codes

   1     TOO MANY FILES
   2     FILE OPEN
   3     FILE NOT OPEN
   4     FILE NOT FOUND
   5     DEVICE NOT PRESENT
   6     NOT INPUT FILE
   7     NOT OUTPUT FILE
   8     MISSING FILE NAME
   9     ILLEGAL DEVICE NUMBER
 10     NEXT WITHOUT FOR
 11     SYNTAX
 12     RETURN WITHOUT GOSUB
 13     OUT OF DATA
 14     ILLEGAL QUANTITY
 15     OVERFLOW
 16     OUT OF MEMORY
 17     UNDEF'D STATEMENT
 18     BAD SUBSCRIPT
 19     REDIM'D ARRAY
 20     DIVISION BY ZERO
 21     ILLEGAL DIRECT
 22     TYPE MISMATCH
 23     STRING TOO LONG
 24     FILE DATA
 25     FORMULA TOO COMPLEX
 26     CAN'T CONTINUE
 27     UNDEF'D FUNCTION
 28     VERIFY
 29     LOAD
 30     BREAK  
 31     RESUME WITHOUT
 32     FORMAT
 33     UNMATCHED STRUCTURE

Functionkeys definitions table

f1 "LIST"

f2 "AUTO"

f3 "DUMP(backarrow)"

f4 "MATRIX(backarrow)"

f5 "RUN(backarrow)"

f6 "GOTO"

f7 "FIND"

f8 "MEM(backarrow)" 

 

Speed

I did some speed testing on my PAL VIC-20 with the 65C02 version of WimBasic. The benchmark was a Basic program that calculates factorials in all significant decimals. For 69!, this number consists of 99 decimals. The program holds a FOR-NEXT, appended with an IF..GOTO loop, both inside another FOR-NEXT.

Pure Basic, without the extension, this takes 4395 jiffies (= 4395/60 seconds = 73.25 seconds)

The same program, within WimBasic, takes 4477 jiffies (= 4477/60 seconds = 74.62 seconds = 1.8% slower)

Now, using all possible WimBasic improvements (SuperNumbers, DIVMOD, hex inline), this takes 2427 jiffies (= 2427/60 seconds = 40.45 seconds = 45% faster !)

Changing the IF.. GOTO. into WHILE-WEND, it takes 2421 jiffies (even faster and improved programming!)

Changing both the FOR-NEXT loops into WHILE-WEND (and applying SuperNumbers of course), the program took 2812 jiffies (= 46.87 seconds). Still 36% faster than pure Basic, but 9% slower than the fastest solution.

Comparison to vanilla CBM Basic on VIC20

 WimBasic CBM Basic
 speed improvement factor
 HEX$()  equivalent routine 29.10
 INSTR (worst case)
 equivalent routine (worst case)
 5.00
 SQR() SQR() 4.17
 datasette (turbo)
 datasette (regular) 4.00
 DEEK(X) PEEK(X)+256*PEEK(X+1) 2.95
 ODD(X) X/2 > INT(X/2) 2.83
 STRING$() equivalent routine
 2.83
 SWAP X%,Y%
 T%=X%:X%=Y%:Y%=T% 2.50
 SWAP X,Y
 T=X:X=Y:Y=T 2.21
 XOR(X,Y) X AND NOT Y OR Y AND NOT X
 2.18
 DIVMOD X,Y
 DQ=INT(X/Y):DR=X-DQ*Y 2.08
 MIN(V,W,X,Y,Z)
 equivalent routine
 2.04
 ROUND(X) INT(X+.5) 1.80
 MIN(X,Y) R=Y:IF X<Y THEN R=X 1.78
 SuperNumbers regular float 1.20
 FRAC(X) X-INT(X) 1.16
 RND(X) INT(RND(1)*X)+1 1.16
 ROUND(X,7) INT(X*1E7+.5)/1E7 1.02