Page 2 of 2

Re: Which BASIC?

Posted: Tue Jul 04, 2017 8:17 am
by dolomiah
I noticed that Garth mentioned my project (thanks Garth), so here's a quick summary of where I am at.

First off, although I was kind of indicating it's not BASIC, it really is! The major difference with most regular dialects is that line numbers are only to store program statements in a required execution sequence. However they are not used for any other purpose - the language doesn't support the use of line numbers at all so all looping and conditional execution is through structured blocks, for example:
- if ... then ... else .. endif
- repeat ... until ...
- while ... wend
- for ... next

Everything is a subroutine and execution starts by invoking a subroutine by name (there is no concept of just executing from the first line number). For example:
def_hello()
println "Hello World"
enddef

A big area of plus of this language for cbmeeks is that my homebrew is using the TMS9918a and AY-3-8910 too - so the language has built in commands to utilise the sound and video capabilities. For example:
- vpoke, vpeek for VRAM access
- various sprite commands (e.g spritepos, spritecol, spritepat)
- various sound commands (e.g. sound, play, music)

The code is portable to an extent, for example I/O is abstracted so a simple putchar and getchar is used for most things. But due to the graphics and sound commands, it will rely on other machine specific routines for accessing the video and sound.

However, unneeded commands can be stripped out easily to both reduce footprint and machine specific extensions. Currently the entire language with OS fits in to just over 15KB. I think the core language (without graphics and sound extensions) would fit easily in to 8KB (haven't tried though).

This small a footprint for a structured and modern dialect of BASIC comes with some limitations though:
- Integer only maths: 16 bits unsigned as well! I know this may seem very restrictive without even the concept of negative numbers, but as Garth points out, much can be achieved with scaled integers
- Max 2 dimensions for arrays. Strings are 1-D arrays of chars, so that leaves only one other dimension for them
- Order of precedence is a little unusual, not properly BODMAS (!). Order can always be overcome with brackets of course.

I have put up a couple of demos on hackaday of programs written entirely in dflat (that's what I have called my language!). A fairly usable version of Tetris is one of the demos and shows that the limitations are really not that big a deal for writing 80s style computer games!

I'm currently doing some plumbing to the code - a little space optimisation so I can fit in Hi-res (256x192 - wow) graphics support. I will put out a full dump of source code on my hackaday space in the next few days.

More than happy for folks to use, adapt and improve by the way, and suggestions always welcome.

Cheers, Dolo

Re: Which BASIC?

Posted: Tue Jul 04, 2017 8:26 am
by BigEd

Re: Which BASIC?

Posted: Tue Jul 04, 2017 7:42 pm
by whartung
What other BASICs are out there than EHBasic and the MS versions? I guess there's TinyBASIC.

Do we have a basic candidate list that can be worked from?

Re: Which BASIC?

Posted: Tue Jul 04, 2017 8:00 pm
by BigEd
There's Acorn's BBC Basic too. I think it's a really good Basic, but it requires an OS, and it's 16k.

It's fast, and has
  • 5 byte floats
    4 byte integers
    some support for structured programs (REPEAT...UNTIL, PROC and FN definitions, LOCAL variables)
    boolean operations on integers
    an embedded 6502 assembler
    SOUND commands interact with the OS for sounds
    MOVE DRAW and PLOT commands interact with the OS for graphics
(There's more, but that's off the top of my head)

There were versions of BBC Basic for Z80 too, and today there are free versions for Windows, x86 Linux, Mac, Raspberry Pi, and Android.

Re: Which BASIC?

Posted: Tue Jul 04, 2017 8:35 pm
by Elminster
BigEd wrote:
There's Acorn's BBC Basic too. I think it's a really good Basic, but it requires an OS, and it's 16k.
+1 for BBC BASIC. But then I am biased as I have spent about 3 months writing TELNET in BBC BASIC which, is hovering around 40k RAM at the moment and growing.

Plus if you go for the extra ROM for Adv BASIC (if you like using ROM space) you get WHILE, CASE, Proper multi statement IF's etc.

Re: Which BASIC?

Posted: Wed Jul 05, 2017 10:16 am
by BigEd
whartung wrote:
What other BASICs are out there than EHBasic and the MS versions? I guess there's TinyBASIC.
That's three... and mentioned upthread we have BBC Basic (and HiBasic and BAS128) and the modern dflat.

According to our "Five Basics" mos6502 post archived here, there's also
  • Woz' integer Basic for the Apple I
    Shepardson's Basic for the Atari
    Advan Basic for the Atari (compiled)
    U-Basic for Atari
    Turbo-Basic XL for Atari
    Hudson Soft's HuBasic for the NES/Famicom
and maybe others too.

There are also modern Basics written in C which could possibly be ported to 6502. You'd need a small one. Maybe
https://github.com/paladin-t/my_basic
or
https://github.com/adamdunkels/ubasic
or see this list
Small Basic Interpreters

Edit: added links and made more self-contained
Edit: fixup some link rot