Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:11 02 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 : Color Maximite, MMBASIC 5. Possible?

Author Message
tomxp411
Newbie

Joined: 04/04/2019
Location: United States
Posts: 24
Posted: 10:46pm 05 Apr 2019
Copy link to clipboard 
Print this post

I have (and love) a Color Maximite, along a "stick" and the CG Microboard. They're all great boards, but I'm a little frustrated by the syntax differences between MMBASIC 5 and 4.5

4.5 allows for strings and numbers to share variable names. ie: A$ and A are different variables. This is very important to me, as I attempt to port forward old BASIC programs written back in the CP/M days. (Star Trek, for example, is a mess of spaghetti code and re-used variable names.)

The problem is that the DOS/Windows version of MMBASIC is v5, and so the syntax isn't the same as the version that runs on the Color Maximite - this means that even after I refactor code so that it works on my PC, I have to do it again to optimize it for the Maximite.

I've emailed Geoff about this already, but gotten no reply, so I'm considering taking on this project myself.

What I'd like to do is build Maximite BASIC 5 for the Color Maximite...which seems reasonable to be able to do, but for some reason the Color Maximite is stuck on 4.5

How hard would it be to port back the Minimite BASIC to run on the Color Maximite's PIC? Has anybody done that already?


 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 11:57pm 05 Apr 2019
Copy link to clipboard 
Print this post

Would a DOS V4.5 help?
I couldn't find it on Geoff's website with a quick look so here it is.
2019-04-06_095409_DOS_MMBasic.zip

Using the same variable name for strings and numbers is not a good idea. I would fix that now before you get caught when there IS an update to the Maximite firmware.

Jim
VK7JH
MMedit
 
tomxp411
Newbie

Joined: 04/04/2019
Location: United States
Posts: 24
Posted: 12:10am 06 Apr 2019
Copy link to clipboard 
Print this post

  TassyJim said   Would a DOS V4.5 help?
I couldn't find it on Geoff's website with a quick look so here it is.
2019-04-06_095409_DOS_MMBasic.zip

Using the same variable name for strings and numbers is not a good idea. I would fix that now before you get caught when there IS an update to the Maximite firmware.

Jim


Thank you for the 4.5 DOS version. That's really helpful.

Like I said, I'm porting old BASIC programs from the 70s and 80s, which re-used variables a lot. You're absolutely correct that it's a bad idea, and so one of the things I'm doing is refactoring the code as I go: expanding variable names with things like "Status" instead of "S$", etc.

The frustration is that every time I get a program working on the Maximite, it doesn't work properly on MMBASIC 5. And when I write a program on MMBASIC 5, it has things that don't work on the Maximite. So I use a lot of conditional code to make it work on both platforms, but that's also got its share of frustrations.

I think what I'll end up having to do is save library routines for each system, then load the correct library routine at startup, based on the detected system.
Edited by tomxp411 2019-04-07
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2442
Posted: 12:57am 06 Apr 2019
Copy link to clipboard 
Print this post

i believe that geoff has been working on updating the maximite range with mmbasic 5 - essentially porting the micromite interpreter back to the maximite. however, this has just been mentioned in passing, is a long-term project, and may be overtaken by the availability of newer hardware so don't take this as gospel.

the disallowing of duplicate variable names - A and A$ - was a change introduced in the last couple of years purely to discourage bad programming practices. having said this, the change may well be sufficiently entrenched in the interpreter's code to such a degree that it can not be undone. at the time there was wide support on these forums for the change with just a few of us holding reservations.

at the same time, string names without the $ symbol at the end became allowable, and in some instances the variants could be mixed:

Dim a$ As string

a$="abc"
Print a
Print a$
End

>
>
> RUN
abc
abc
>



cheers,
rob :-)
 
tomxp411
Newbie

Joined: 04/04/2019
Location: United States
Posts: 24
Posted: 06:35pm 08 Apr 2019
Copy link to clipboard 
Print this post

  robert.rozee said  the disallowing of duplicate variable names - A and A$ - was a change introduced in the last couple of years purely to discourage bad programming practices. having said this, the change may well be sufficiently entrenched in the interpreter's code to such a degree that it can not be undone. at the time there was wide support on these forums for the change with just a few of us holding reservations.


Yeah, that's an understandable change, but it makes porting Microsoft BASIC programs a challenge, since variable references all have to be fixed.

What's frustrating me right now is the loss of the FORMAT$ function and the LIBRARY statement.

I can kind of get behind losing FORMAT$, since the STR$ overloads take its place, but removing LIBRARY means I can't export my platform-dependent code to an include file.

Is there a replacement for LIBRARY in MMBASIC 5?
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 08:44pm 08 Apr 2019
Copy link to clipboard 
Print this post

For the FORMAT function, this is what I used before STR$ got a facelift:
  Quote  FUNCTION uFormat$(x,p)
' given a number (x) and the required number of decimal places (p)
' returns formatted string. Negative and zero p is permitted
LOCAL f$
f$=
STR$(CINT(x*10^p))
IF LEN(f$)<=p THEN
f$=
STRING$(p+1-LEN(f$), "0")+f$
ENDIF
IF p>0 THEN
uFormat$=
LEFT$(f$,LEN(f$)-p)+"."+RIGHT$(f$,p)
ELSEIF p = 0 THEN
uFormat$=f$
ELSE
uFormat$=f$+
STRING$(ABS(p),"0")
ENDIF
END FUNCTION


STR$ does enough now.

LIBRARY is still use in some current devices.
You have to check what device you are coding for.
If the device has plenty of available memory, LIBRARY is not needed.

Jim
VK7JH
MMedit
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1114
Posted: 12:06am 09 Apr 2019
Copy link to clipboard 
Print this post

As Peter M has said in a recent post, here,
the ArmMite H7 makes an ideal platform for games and could be an upwards path from the Colour Maximite. Doesn't have VGA unfortunately. Advantages are a (relatively) cheap pre-built module in the NUCLEO-H743ZI and with the addition of Peter's backpack, it makes a very powerfull, low cost option.

If VGA is important/essential then the Micromite Extreme series (100 and 144 pin varients) might be the way to go. Using either of these options means that the DOS MMBasic and MMXBasic are pretty much in step other than no I/O for the DOS varient.

WhiteWizard on the Backshed here supplied my 144 pin Extreme pre-built and it works a treat. Shade expensive (no offence WW, I know there is a lot of work building these ), but a really good and powerfull option to move up from the Colour Maximite (IMHO).

panky.

... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
tomxp411
Newbie

Joined: 04/04/2019
Location: United States
Posts: 24
Posted: 05:17pm 09 Apr 2019
Copy link to clipboard 
Print this post

  TassyJim said  STR$ does enough now.

LIBRARY is still use in some current devices.
You have to check what device you are coding for.
If the device has plenty of available memory, LIBRARY is not needed.

Jim


you're missing the point... I'm not using LIBRARY to save memory. I want to use LIBRARY to export platform-dependent code to external modules, so I can port the code to the Color Maximite without needing to write conditional code in all of my I/O routines.

For example, I'm working on a clone of Mike Mayfield's 1971 Star Trek game. I want to use drawing commands to display the map on the Maximite, but I want o use text to display the map on DOS or the Micromite systems. However, n order to do that, I have to write two completely different programs, or I have to wrap every output function in a platform check.

Instead, what I'd like to do is have a single IF/THEN/ELSE block at the top of the program to include the correct functions for each platform.

Since I can't actually do that, I'll have to settle for creating a make system that concatenates several different files to build a BAS file for each platform. That will work, but it's frustrating.

As much as I love the Maximite ecosystem, this kind of fragmentation is a problem.

Edited by tomxp411 2019-04-11
 
tomxp411
Newbie

Joined: 04/04/2019
Location: United States
Posts: 24
Posted: 05:45pm 09 Apr 2019
Copy link to clipboard 
Print this post

  panky said   As Peter M has said in a recent post, here,
the ArmMite H7 makes an ideal platform for games and could be an upwards path from the Colour Maximite. Doesn't have VGA unfortunately. Advantages are a (relatively) cheap pre-built module in the NUCLEO-H743ZI and with the addition of Peter's backpack, it makes a very powerfull, low cost option.

If VGA is important/essential then the Micromite Extreme series (100 and 144 pin varients) might be the way to go. Using either of these options means that the DOS MMBasic and MMXBasic are pretty much in step other than no I/O for the DOS varient.

WhiteWizard on the Backshed here supplied my 144 pin Extreme pre-built and it works a treat. Shade expensive (no offence WW, I know there is a lot of work building these ), but a really good and powerfull option to move up from the Colour Maximite (IMHO).

panky.


Thanks. I'll look into that.

Honestly, as much as I like the Maximite computer, I'm considering a move back to a software-only solution that can run on Windows and Linux. In the long term, I'll probably end up building my own interpreter from the ground up, using something like SDL for graphics.

Something that would be really cool would be a bare metal port of MMBASIC for the Raspberry Pi. I've played with the Pi Linux version, and it's good, but there are some issues I'd need to address before I could do what I have in mind.

Long term, I want to build a programming system for schools and colleges that would teach someone to program from the ground up. I'd start with an 8-bit style environment (like MMBASIC) and take the person through all of the basic (no pun intended) lessons needed to learn programming.

Edited by tomxp411 2019-04-11
 
tomxp411
Newbie

Joined: 04/04/2019
Location: United States
Posts: 24
Posted: 01:13am 10 Apr 2019
Copy link to clipboard 
Print this post

So it turns out a MAKE script is fairly straightforward.

This solves the worst of my problems for now: I can break the platform dependent and common code into separate files.

Here it is, if anyone is interested:

2019-04-10_111353_make.zip


'
' Make script for Maximite and Micromite platform compatibility.
' Requires DOS MMBASIC. This will not run on the Color Maximite.
'
Option BASE 1
Option EXPLICIT

'
' Platforms
' To add a new platform, add it to this list. Then
' add a new Source colum, with the files for that version.
'
Dim Integer Platform.Count = 2
Dim String Platform(Platform.Count) Length 20
Platform(1)="Colour Maximite"
Platform(2)="DOS"

Dim String Target(Platform.Count) Length 12
Target(1)="TrekMax.bas"
Target(2)="TrekDOS.bas"

'
' Included files
' These files will be included, in order.
' List each file that will be assembled to make the final ouput
'
' Source holds the names of each source file that will be
' used to build your final target.
' array is (platform, file)
'
Dim Integer Source.Count=3
Dim string Source(Platform.Count, Source.Count) Length 50
'Maximite sources
Source(1,1)="Trek Intro.bas"
Source(1,2)="Trek UI Max.bas"
Source(1,3)="Trek Main.bas"
'DOS sources
Source(2,1)="Trek Intro.bas"
Source(2,2)="Trek UI DOS.bas"
Source(2,3)="Trek Main.bas"

Dim Integer p
Dim Integer f
Dim Integer fOut = 1
Dim Integer fIn = 2
Dim string L,LL

For p=1 To Platform.Count
Print "Create "; Target(p)
Open Target(p) For Output As #fOut
For f=1 To Source.Count
Print " Reading "; Source(p,f);"...";
Open Source(p,f) For Input As #fIn
Do While Not Eof(#fIn)
Line Input #fIn, L
if not (LL="" and L="") then
Print #fOut, L
endif
LL=L
Loop
Close #fIn
Print "Done"
Next
Close #fOut
Print " Closed ";Target(p)
Next
Print "Make Complete"
quit
Edited by tomxp411 2019-04-11
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 04:09am 10 Apr 2019
Copy link to clipboard 
Print this post

That's a neat solution to your problem. I was thinking that it would be good to have a variable number of source files ie: 3 for one version and 4 for the other.

That could be achieved by adding a dummy file with just one comment line?

Bear in mind that Geoff has said:

  Geoff said  I am planning an upgrade of the Maximite to V5 of MMBasic


Bill

PS Thanks for putting the program in the Library.


Keep safe. Live long and prosper.
 
tomxp411
Newbie

Joined: 04/04/2019
Location: United States
Posts: 24
Posted: 06:36am 10 Apr 2019
Copy link to clipboard 
Print this post

  Turbo46 said   That's a neat solution to your problem. I was thinking that it would be good to have a variable number of source files ie: 3 for one version and 4 for the other.


That's an interesting thought. The approach I took with this version was quick & dirty... what I really want to do is use preprocessor directives in the source, like this:

[code]
#if SYSTEM="DOS"
#include "textutil dos.bas"
#elseif SYSTEM="Maximite"
#include "textutil maximite.bas"
#include "graphutil maximite.bas"
#endif
[/code]


So instead of baking the build into the MAKE script, I'd bake it into the master BAS file, and the build script would be generic and usable for any compatible BAS file.

Long term, that could also allow for DEBUG builds and other fun stuff.
Edited by tomxp411 2019-04-11
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 08:12am 10 Apr 2019
Copy link to clipboard 
Print this post

  tomxp411 said  what I really want to do is use preprocessor directives in the source, like this:


#if SYSTEM="DOS"
#include "textutil dos.bas"
#elseif SYSTEM="Maximite"
#include "textutil maximite.bas"
#include "graphutil maximite.bas"
#endif


That's also an interesting thought. I also thought that something similar would be a useful addition to MMEdit. Not just for the purpose you describe but for similar programs that have different I/O requirements or to include things like functions or subroutines without having to use copy and paste.

Jim has said that elsewhere that he needs a more powerful compiler to add things like function folding and so on so I guess it's unlikely.

@Jim: If you are listening, you could add a 'new compiler fund' on your web site. I'll chip in.

Bill
Keep safe. Live long and prosper.
 
tomxp411
Newbie

Joined: 04/04/2019
Location: United States
Posts: 24
Posted: 06:55am 11 Apr 2019
Copy link to clipboard 
Print this post

  Quote  Jim has said that elsewhere that he needs a more powerful compiler to add things like function folding and so on so I guess it's unlikely.

@Jim: If you are listening, you could add a 'new compiler fund' on your web site. I'll chip in.


Visual Studio 2019 Community is free, and it works great; even though I have access to the highest tier of MSDN for work, I still use Community for personal projects.

Edited by tomxp411 2019-04-12
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 08:06am 11 Apr 2019
Copy link to clipboard 
Print this post

I have the compiler thank you. That is not the reason for my delays.

I realise that I had left a section out of the help file when I changed the format.
MMEdit does have an INCLUDE ability. No one used it so I haven't done anything with it for a while.

This is from the old help file:
  Quote  To make it easier to reuse code, you can add your library files using two methods.
In the Edit menu, you can Insert a file at the current location (actually after the current line) or at the end of the file.
The second method requires INCLUDE directives.
In the main code a comment line with either ‘$INCLUDE:’ (Quick Basic style) or ‘#INCLUDE’ (C style) with indicate where the include file is to be placed.
Running ‘merge include files’ from the ‘Program’ menu will insert the library files into the main file. A comment line will be inserted at the end of the include file so you know what code was added. The original include directive has another comment (‘) added to prevent subsequent merges from adding a second copy of the include file.
An include file can have its own includes.
In both cases, the added code is now part of the main file.

The following code:

Newdate$= date$
mainloop:
DOW (Newdate$, weekday, day$) ' returns day of week as number and string
splitdate (Newdate$, day, month, year)
toJD (day, month, year, jd) ' returns Julien Day Number
print today$;" "weekday;" ";day$ ;" - JD number: ";format$(jd,"%12.0f")

input "New Date", Newdate$
if Newdate$<>"" then goto mainloop

end
'$INCLUDE: date.bas

Will become:

Newdate$= date$
mainloop:
DOW (Newdate$, weekday, day$) ' returns day of week as number and string
splitdate (Newdate$, day, month, year)
toJD (day, month, year, jd) ' returns Julien Day Number
print today$;" "weekday;" ";day$ ;" - JD number: ";format$(jd,"%12.0f")

input "New Date", Newdate$
if Newdate$<>"" then goto mainloop

end
''$INCLUDE: date.bas
' given date as string, returns day, month, year
sub splitdate (currentdate$, d, m, y)
d= val(mid$(currentdate$,1,2))
m= val(mid$(currentdate$,4,2))
y= val(mid$(currentdate$,7,4))
end sub

'given day, month, year
'dayz=days since 1/1/1900 - agrees with Excel after 1/3/1900
sub toMSday (d, m, y, dayz, dayofyear)
dayofyear= d+int((m-1)*30.57+0.5)
if m>2 then
dayofyear= dayofyear-1
if (y mod 4)>0 then dayofyear= dayofyear-1
endif
dayz= int((y-1900)*365.25-0.25)+dayofyear+1
end sub

' given date as string, returns day of week as number and string
sub DOW (currentdate$,weekday, day$)
local d, m, y, dayz
splitdate (currentdate$, d, m, y)
toMSday (d, m, y, dayz, dayofyear)
weekday= abs((dayz-1) mod 7)
day$=mid$("SunMonTueWedThuFriSatSun",weekday*3+1,3)
end sub

' input day, month, year - returns julien day number
sub toJD ( d, m, y, jd)
ff = fix((m-14)/12)
jd = fix((1461*(y+4800+ff))/4)+fix((367*(m-2-12*ff))/12)-fix((3*(fix(y+4900+ff)/100))/4)+d-32075
end sub

'input julien day - returns day, month, year
sub fromJD (jd, d, m, y)
local l, n, i, j
l = jd + 68569
n = fix(( 4 * l ) / 146097)
l = l - fix(( 146097 * n + 3 ) / 4)
i = fix(( 4000 * ( l + 1 ) ) / 1461001)
l = l - fix(( 1461 * i ) / 4 )+ 31
j = fix(( 80 * l ) / 2447)
d = l - fix(( 2447 * j ) / 80)
l = fix(j / 11)
m = j + 2 - ( 12 * l )
y = 100 * ( n - 49 ) + i + l
end sub

'End INCLUDE

Everything between ''$INCLUDE: date.bas and 'End INCLUDE
was in the file date.bas

'$INCLUDE: date.bas and '$INCLUDE date.bas are identical.

Include files can be either in the code source folder or preferably in a separate ‘include’ folder.


You can also use the power of Notepad++ if you want something better.

Jim
VK7JH
MMedit
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025