6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 12:18 pm

All times are UTC




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Which BASIC?
PostPosted: Tue Jul 04, 2017 8:17 am 
Offline

Joined: Wed Nov 18, 2015 8:36 am
Posts: 102
Location: UK
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


Last edited by dolomiah on Tue Jul 04, 2017 10:11 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Which BASIC?
PostPosted: Tue Jul 04, 2017 8:26 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Linky: https://hackaday.io/project/5789-6502-homebrew-computer


Top
 Profile  
Reply with quote  
 Post subject: Re: Which BASIC?
PostPosted: Tue Jul 04, 2017 7:42 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: Which BASIC?
PostPosted: Tue Jul 04, 2017 8:00 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Which BASIC?
PostPosted: Tue Jul 04, 2017 8:35 pm 
Offline
User avatar

Joined: Sat Jun 17, 2017 9:58 am
Posts: 16
Location: England, United Kingdom
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Which BASIC?
PostPosted: Wed Jul 05, 2017 10:16 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron