Table of Contents

MG's Apple ][ EhBASIC Port

I, as others before me, have been working on porting EhBASIC, by the late Lee Davison, to the Apple II. It's actually extremely easy to get it up and running in a minimalist fashion.

What I have wanted (since childhood) is an easy to use/hack BASIC that I have the source code for, that is aware of things like MouseText, the ProDOS MLI, the Pascal 1.1 slot protocol, and other amenities. I wanted I/O to be a first-class citizen in the language, not a somewhat dirty hack that relied on the I/O hooks and literally PRINTing commands to the operating system.

For those of us for whom it was our first programming language, we still love Applesoft. That being said, Apple's biggest updates to Applesoft since 1978 were support for lower-case entry and allowing the delete key on newer keyboards to be used as a backspace. There was pretty much nothing else that changed despite the evolving capabilities of the Apple II machines.


Startup screen.

Some useful commands.

Woz's signature. Credit.

Design Criteria

In short, my design criteria for a “new traditional” BASIC for the Apple II were:

I don't quite have the skills to program a full BASIC interpreter, so EhBASIC was a natural fit for expansion due to its generous non-commercial license, well-commented and easy to understand source code, and ease of expansion.

Implementation Details

What is Done

Loader

The loader code is complete and features the following:

ProDOS Support

Pascal I/O Support

Text / Graphics Support

Other New BASIC Commands and Functions

ERRNO(1) Values
# Error
0 Success
1 NEXT without FOR
2 Syntax
3 RETURN without GOSUB
4 Out of Data
5 Function Call
6 Overflow
7 Out of Memory
8 Undefined Statement
9 Array Bounds
10 Double Dimensioned Array
11 Divide by Zero
12 Illegal Direct
13 Type Mismatch
14 String Too Long
15 String Too Complex
16 Continue Error
17 Undefined Function
18 LOOP without DO
19 Undefined Variable
20 Undimensioned Array
21 Unimplemented function
22 Illegal Argument
23 I/O Error
24 No Device Connected
25 ProDOS Error (ERRNO(3) contains ProDOS error number)
26 File Type Mismatch

Other features

What is Planned, but Not Done

Many optimizations of my initial implementations of functionality are needed!

Differences from standard 6502 EhBASIC

Not covered by the above:

What Will Not Be Implemented

Preview Releases

No source code yet, sorry. I do have a mirror of the repository I started with located here.. Importantly, you should read the README and the EhBASIC manual.

Warning: I will be adding more tokens, and this will cause you problems as certain tokens need to be in certain positions. Don't do anything serious with these preview releases.

Files:

ca. 02/12/2018 12:00 PST

Gzip-compressed .po file Derived from EhBASIC.

ShrinkIt archive Derived from EhBASIC.

Example Programs

Get the ProDOS Prefix into a Variable

In a low-level fashion, until I implement a better way:

10 a$=""+"   ":REM the + is so EhBASIC won't store the string in program space
20 POKE SADD(a$),1:REM otherwise these pokes do bad things
30 DOKE SADD(a$)+1,$300:REM we'll use $300 as a buffer
40 P8CALL $c7,SADD(a$):REM call ProDOS GET_PREFIX
50 pf$=B2P$($300):REM convert result
60 PRINT "The prefix is ";pf$

Get volume in slot 6, drive 1 into a Variable

10 a$=""+"    "
20 POKE SADD(a$),2:REM 2 params
30 POKE SADD(a$)+1,$60:REM unit #
40 DOKE SADD(a$)+2,$300:REM buffer (16 bytes)
50 P8CALL $c5,SADD(a$):REM ON_LINE
60 v$=B2P$($300,$f):REM convert string, only need lower 4 bits for length
70 PRINT "Volume in slot 6, drive 1 is ";v$

Woz Signature

10 HGR:HCOLOR=3:READ A,B:FOR I=1 TO 9:READ X,Y:HPLOT A,B TO X,Y:A=X:B=Y:NEXT I
15 READ A,B:FOR I=1 TO 16:READ X,Y:HPLOT A,B TO X,Y:A=X:B=Y:NEXT I
20 DATA 75,50,69,57,76,62,71,88,53,118,87,71,130,31,76,111,116,66,143,44,132,82,
123,83,108,95,104,104,112,107,130,94,133,80,154
25 DATA 73,146,89,158,88,162,94,139,141,122,160,119,156,139,126,194,85,232,64

Credit.

Lo-res Heart

I forgot where I found this. If I find out, I will credit it here.

1 GR:COLOR=1:O=5:P=35:Y=2:FOR I=1 TO 4:READ X,Z:HLIN X+O,Z+O AT Y:HLIN P-Z,P-X AT Y:Y=Y+1:NEXT I
2 FOR I=1 TO 30:READ X:HLIN X+O,P-X AT Y:Y=Y+1:NEXT I:COLOR=15:HLIN 9,12 AT 5:VLIN 4,7 AT 10:HLIN 24,26 AT 5:VLIN 4,6 AT 25
32 DATA 5,11,4,12,3,13,2,13,2,1,1,1,1,0,0,0,0,1,1,1,1,2,2,2,3,4,5,5,6,6,7,8,9,10,11,12,13,14,15,16,17,18

Hi-res Sine Wave

Don't remember where this one came from, either.

10 HGR:HCOLOR=3:LX=0:LY=80:FOR I=0 TO 279:A=SIN(I/8)*70+80:PRINT I,A:HPLOT I,A TO LX,LY:LX=I:LY=A:NEXT

Moire

My own variant of Brian's Theme.

100 GET a:HGR0
105 oc=c
110 X=INT(RND(0)*280):Y=INT(RND(0)*192)
115 c=INT(RND(0)*7)+1
120 IF c=oc THEN 110
125 HCOLOR=c
130 s=INT(RND(0)*4)+3
140 FOR i=0 TO 279 STEP s:HPLOT i,0 TO X,Y TO 279-i,191
145 NEXT
150 FOR i=0 TO 191 STEP s:HPLOT 0,191-i TO X,Y TO 279,i
155 NEXT
170 GET a
180 IF a=0 THEN GOTO 105
190 TEXT:HOME