Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:08 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: How to extend the BASIC library?

     Page 1 of 2    
Author Message
gevik

Newbie

Joined: 04/07/2020
Location: Netherlands
Posts: 10
Posted: 10:13am 17 Sep 2020
Copy link to clipboard 
Print this post

Hi,

I got my CMM2 last week and it has been fun playing with the machine in these lockdown times.

I would like to experiment adding custom libraries to the BASIC interpreter. I am thinking about adding functionality for creating TUI's (Text Based User Interface). Something similar to TurboVision of the 80s and 90s.

At the moment I am looking for any information regarding the development process of adding custom C functions to the CMM2's firmware. Do I have to compile and deploy my changes on the firmware each time I make a change? (I hope not!). Or is there a development environment with an emulator/debugger.

Greatly appreciated if anyone can shed some light on this.

Regards,
Gevik
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 10:31am 17 Sep 2020
Copy link to clipboard 
Print this post

Hi "gevik",

That's not how it works

If you literally extended the firmware then the restrictions on the license by which you get access to the firmware source means that you cannot distribute the result of your efforts. In any case there is no room in the MMBasic symbol table for you to add new functions into the language itself.

Instead you provide "libraries" as .inc files (for use with #Include) in which you include global variables, constants, Subs (BASIC) and Functions (BASIC), you can also include CSUBs.

CSUBs contain the hex-encoded representation of subroutines that have been written in C (or in theory assembler) and then compiled into position independent code on a Windows/Linux PC. There is an MMBasic utility that then processes these to create the hex-encoded representation.

See http://www.thebackshed.com/forum/ViewTopic.php?TID=12289 for details.

There is no specific "development environment", "debugger" or "emulator" for developing CSUBs ... welcome to the 1980s - is any consumer PC even capable of emulating at reasonable speed a 480 MHz ARM microcontroller ?

Happy hacking,

Tom
Edited 2020-09-17 20:39 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4044
Posted: 10:42am 17 Sep 2020
Copy link to clipboard 
Print this post

That said, those who like, say, gdb, and such as debug via JTAG (perhaps using OpenOCD), could likely debug (presumably C code) that way.

Unless Peter already does something similar the above will require some hand-to-hand combat...

(Other tools are available of course.)

John
 
gevik

Newbie

Joined: 04/07/2020
Location: Netherlands
Posts: 10
Posted: 11:37am 17 Sep 2020
Copy link to clipboard 
Print this post

Thank you for your answers:

This means that CSUBS are the way to go for now. I found the mandelbolt example on github. So I will have to take a look at that for and of cource the thread mentioned above. https://github.com/thwill1000/cmm2-welcome/tree/master/mandelbrot-explorer


I have just downloaded the MMBasic source to go check out the parser and see if I can learn about the internals.
 
mkopack73
Senior Member

Joined: 03/07/2020
Location: United States
Posts: 261
Posted: 12:12pm 17 Sep 2020
Copy link to clipboard 
Print this post

I also suggest you take a look at this document I’ve been putting together. There are a number of things you should consider if making a library that you want to be maximally useful people.  There’s also a section specifically on good practices for library authors in it.  

https://docs.google.com/document/d/1dkQcLM2FRTiNELj5P3neeFih0oN2tOOxC2jy3BBH5Po/edit?usp=sharing
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1427
Posted: 03:48pm 17 Sep 2020
Copy link to clipboard 
Print this post

  gevik said  
I would like to experiment adding custom libraries to the BASIC interpreter. I am thinking about adding functionality for creating TUI's (Text Based User Interface). Something similar to TurboVision of the 80s and 90s.


I'm very fond of this idea. A TUI would be a good feature of the CMM2. It would have been great if TUI could have been a keyword and the functionality included in the firmware, but there are no remaining tokens. But it is still very doable as a CSUB.

I know that games and whatnot use the great graphics capabilities of this fine machine and that a text interface may seem like a step back. But a well-written TUI would be great for education and utilities.

I've tried to find on-line resources for... ready for this?... Visual Basic for DOS to see what that development environment had to offer. I was hoping to find a pdf of the VB for DOS book. It would have all of the elements such as input fields, labels, buttons, checkmark boxes, message boxes, etc. (Note that the default font of the CMM2 has all of the box-draw characters.)

A TUI CSUB would grant the programmer the ability to be able to interact with the program user in a way that is several steps better than just a single INPUT command line entry at-a-time.






Micromites and Maximites! - Beginning Maximite
 
mkopack73
Senior Member

Joined: 03/07/2020
Location: United States
Posts: 261
Posted: 04:08pm 17 Sep 2020
Copy link to clipboard 
Print this post

Yeah I had thought about something like this as well.. It WON'T be an easy thing to implement but certainly could be a useful library!
 
William33
Newbie

Joined: 27/07/2020
Location: Germany
Posts: 9
Posted: 07:43pm 17 Sep 2020
Copy link to clipboard 
Print this post

Sorry, but would it useful without a mouse?
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 07:52pm 17 Sep 2020
Copy link to clipboard 
Print this post

I've also thought about this. I have a QBASIC.EXE from 1993, but it won't run on 64-bit win10. I have an older laptop now at a repair shop. When I get it back I'll see if it can run it.

I think the user interface is windowed text, but as far as I remember, it doesn't give you the ability to build windowed text programs.

Regarding the lack of tokens, I know it's contrary to design intent, but since the MATH token is already overloaded, for an individual's modification of the MMBASIC source code, I don't know why you couldn't in theory, for instance, use:
MATH TUI SOMECOMMAND SOMEPARAMETERS

But talk about retro . . .
Edited 2020-09-18 05:57 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
RetroJoe

Senior Member

Joined: 06/08/2020
Location: Canada
Posts: 290
Posted: 08:04pm 17 Sep 2020
Copy link to clipboard 
Print this post

  William33 said  Sorry, but would it useful without a mouse?


Those old TUIs were designed to work without a mouse.

You either tabbed or arrowed around until you reached the target widget, or you used a shortcut key - note in the first screenshot every screen item has a unique letter in red or yellow, which is the keystroke associated with it.

Typical Windows BIOS configuration screens are an artifact of this keyboard-only UI method.
Edited 2020-09-18 06:22 by jpusztai
Enjoy Every Sandwich / Joe P.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4044
Posted: 09:30pm 17 Sep 2020
Copy link to clipboard 
Print this post

  lizby said  I have a QBASIC.EXE from 1993, but it won't run on 64-bit win10.

If Win10 can do VMs then it should run.

It runs OK on Linux under DOSBOX, for example.

John
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1427
Posted: 10:42pm 17 Sep 2020
Copy link to clipboard 
Print this post

  lizby said  I've also thought about this. I have a QBASIC.EXE from 1993, but it won't run on 64-bit win10. I have an older laptop now at a repair shop. When I get it back I'll see if it can run it.

I think the user interface is windowed text, but as far as I remember, it doesn't give you the ability to build windowed text programs.

Regarding the lack of tokens, I know it's contrary to design intent, but since the MATH token is already overloaded, for an individual's modification of the MMBASIC source code, I don't know why you couldn't in theory, for instance, use:
MATH TUI SOMECOMMAND SOMEPARAMETERS

But talk about retro . . .


If one slot were open:

TUI BUTTON x, y, z
TUI RADIO x, y, z
TUI MESSAGE x, y, z

But a CSUB or a set of CSUBs could do nearly the same thing.
Micromites and Maximites! - Beginning Maximite
 
Womble

Senior Member

Joined: 09/07/2020
Location: United Kingdom
Posts: 267
Posted: 01:20am 18 Sep 2020
Copy link to clipboard 
Print this post

  JohnS said  
  lizby said  I have a QBASIC.EXE from 1993, but it won't run on 64-bit win10.

If Win10 can do VMs then it should run.

It runs OK on Linux under DOSBOX, for example.

John

QBASIC.EXE runs fine under DOSBox 0.74-3 on my Windows 10x64 (v.2004) machines.  So does TurboC which has a similar IDE.  I have been using it to check out some of my ancient code with a view to porting some stuff across to the CMM2.
Edited 2020-09-18 11:21 by Womble
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 06:31am 18 Sep 2020
Copy link to clipboard 
Print this post

I don't know how the token table works, or how overloaded tokens like 'math' work, but the 'end' and 'exit' commands would be candidates for overloading to free up slots. Someone (other than Peter ;-) with the source might be entertained by studying possibilities...
Visit Vegipete's *Mite Library for cool programs.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 06:54am 18 Sep 2020
Copy link to clipboard 
Print this post

  Quote  but the 'end' and 'exit' commands would be candidates for overloading to free up slots.

It is utterly pointless to "study" things which are going to break existing programs. It ain't going to happen
 
gevik

Newbie

Joined: 04/07/2020
Location: Netherlands
Posts: 10
Posted: 07:29am 18 Sep 2020
Copy link to clipboard 
Print this post

Could someone please elaborate on the symbol table limitations? Where should I look in MMBasic's source code. Is there a documentation on this. Please pardon my newbie question. Just trying to learn more here.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 08:01am 18 Sep 2020
Copy link to clipboard 
Print this post

  Quote  Could someone please elaborate on the symbol table limitations? Where should I look in MMBasic's source code. Is there a documentation on this. Please pardon my newbie question. Just trying to learn more here.

There are 127 slots for commands and 127 slots for Functions and operators. This is fundamental to the way MMbasic works. It isn't going to change - don't waste your time looking for a "solution". This would require a major re-write which isn't going to happen
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 11:27am 18 Sep 2020
Copy link to clipboard 
Print this post

  Womble said  
  JohnS said  It runs OK on Linux under DOSBOX, for example.

QBASIC.EXE runs fine under DOSBox 0.74-3 on my Windows 10x64 (v.2004) machines.  So does TurboC which has a similar IDE.  I have been using it to check out some of my ancient code with a view to porting some stuff across to the CMM2.

I'd never heard of DOSBOX. Have now installed it and run QBASIC.EXE. Thanks.

Also enabled me to run TurboC--TCC.EXE dated 1988. Oh the thrills.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
RetroJoe

Senior Member

Joined: 06/08/2020
Location: Canada
Posts: 290
Posted: 12:29pm 18 Sep 2020
Copy link to clipboard 
Print this post

  lizby said   Also enabled me to run TurboC--TCC.EXE dated 1988. Oh the thrills.


Apropos this TUI thread, and various other ones about MMBasic’s text editor, I have very fond memories of the TurboPascal package and its built-in editor. I ended up using that Turbo editor to edit everything - it was vastly superior to any of the “default” CP/M and DOS editors at the time.

Feels like a DOSBOX kinda weekend coming up :)
Enjoy Every Sandwich / Joe P.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 12:41pm 18 Sep 2020
Copy link to clipboard 
Print this post

Ok, now we're talking crazy. What would a MMBasic CSUB 8080/Z80+8086 emulator look like on the CMM2?

Now I'll just crawl back under my rock.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
     Page 1 of 2    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025