Re: Which BASIC?
Posted: Tue Jul 04, 2017 8:17 am
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
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