Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 00:28 21 Apr 2024 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: V5.06.00b4: More "fun" functionality for testing

     Page 1 of 3    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8570
Posted: 06:43pm 23 Nov 2020
Copy link to clipboard 
Print this post

V5.06.00b4

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip


This beta should fix the problems identified in MATH SET, PAGE_AND in addition there is some new "stuff" which you are invited to test and use.

HELP changes

Pressing F12 in the middle of a word will now load the whole word into the help system. So you don't need to be at the beginning of a command or function name to find the help for it.
When you exit help in the editor the command at the top is copied into a buffer. You can use F11 to paste this into your program. It just inserts this at the cursor so typically you would point to a blank line and press F11. Then you can replace the syntax example with your data and, assuming the help text is correct, know you have the syntax correct.

SORT changes

The syntax for SORT is now

SORT array() [,indexarray] [,flags] [,startposition] [,elementstosort]


The new parameters should have no impact on existing code which will default them to run as before.

flag values are:

bit0:  0 (default if omitted) normal sort - 1 reverse sort
bit1:  0 (default) case dependent - 1 sort is case independent


startposition defines which element in the array to start the sort. Default is 0 (OPTION BASE 0) or 1 (OPTION BASE 1)

elementstosort defines how many elements in the array should be sorted. Default is all elements after the startposition


CHOICE function

CHOICE(condition, ExpressionIfTrue, ExpressionIfFalse)


This new function allows you to do simple either or selections much more efficiently and faster than using IF THEN ELSE ENDIF clauses

The condition is anything that will resolve to nonzero (true) or zero (false)
The expressions are anything that you could normally assign to a variable or use in a command

e.g.
print choice(1, "hello","bye") will print "Hello"
print choice(0, "hello","bye") will print "Bye"
a=1:b=1:print choice(a=b, "hello","bye") will print "Hello"

Finally:
You can use MM.INFO(DIRECTORY) as an alternative to the function cwd$. There is one small difference in that the pathname in MM.INFO(DIRECTORY) will always end with the '/' character
Edited 2020-11-24 04:45 by matherp
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3833
Posted: 06:49pm 23 Nov 2020
Copy link to clipboard 
Print this post

Thank you Peter

<does a happy dance>

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
elk1984

Senior Member

Joined: 11/07/2020
Location: United Kingdom
Posts: 227
Posted: 07:25pm 23 Nov 2020
Copy link to clipboard 
Print this post

Fantastic stuff. Thanks Peter!
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3833
Posted: 07:25pm 23 Nov 2020
Copy link to clipboard 
Print this post

Hi Peter,

Hmm, because we have to provide parameter N before we provide N+1 we potentially have to allocate a (large) redundant index() array for SORT(). I don't suppose it does, or can support a dummy value, e.g.
SORT a$(),0,&b11,lb%,num%


Also for user-friendliness should you consider using letters for the flags, c.f. the flag that controls the behaviour of DIR$() ?

Thanks for the enhancements,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8570
Posted: 07:29pm 23 Nov 2020
Copy link to clipboard 
Print this post

You can miss out any of the optional parameters

SORT a$(),,2,,10 is perfectly valid
Edited 2020-11-24 05:30 by matherp
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3833
Posted: 07:41pm 23 Nov 2020
Copy link to clipboard 
Print this post

  matherp said  You can miss out any of the optional parameters

SORT a$(),,2,,10 is perfectly valid


Ah, lovely.
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5886
Posted: 08:12pm 23 Nov 2020
Copy link to clipboard 
Print this post

No splash screen image on startup.
The usual text does go out the serial and the space is there where the logo etc should be.
Or is black the new black?

Jim
VK7JH
MMedit   MMBasic Help
 
Sasquatch

Senior Member

Joined: 08/05/2020
Location: United States
Posts: 296
Posted: 08:24pm 23 Nov 2020
Copy link to clipboard 
Print this post

Thanks!

Page_AND etc. Working great in 16bit modes, however now throws error complaining about parameters in Mode 1,12
-Carl
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5886
Posted: 09:08pm 23 Nov 2020
Copy link to clipboard 
Print this post

exiting out of the commandline HELP gives an assortment of errors.

Unknown command

> help
?


Invalid character: *

>
VK7JH
MMedit   MMBasic Help
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8570
Posted: 10:55pm 23 Nov 2020
Copy link to clipboard 
Print this post

  Quote  however now throws error complaining about parameters in Mode 1,12


This is correct. You can't use page 0 as an input in any mode or or page 1 as an input in 12-bit mode to AND, OR, or XOR as they are the display pages. This will be in the documentation. They can be used as the output of course.

  Quote  No splash screen image on startup.


me trying to clear all video pages to meet previous comment but in the wrong place - easy fix

  Quote  exiting out of the commandline HELP gives an assortment of errors.


Also easy fix - should test better  
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5886
Posted: 05:22am 24 Nov 2020
Copy link to clipboard 
Print this post

There is something strange with SORT
If I include index zero, the index array is correct but if I try and start the sort at 1, the sorted array is OK but the index array is "strange"

 OPTION EXPLICIT
 OPTION DEFAULT NONE
 DIM INTEGER maxFiles = 500 ' adjust to suit expected maximum
 DIM fList$(maxFiles) LENGTH 60' file names for sorting
 DIM fSort$(maxFiles) LENGTH 60
 DIM fIndex%(maxFiles)
 DIM INTEGER mf, z
 DIM f$
 
 mf = 1
 f$ = DIR$("*", ALL)
 DO WHILE f$ <> ""
   IF MM.INFO$(FILESIZE f$)=-2 THEN ' it is a directory
     fList$(mf) = " "+f$+" <DIR>"' the leading space keeps directories sorted first
   ELSE
     fList$(mf) = f$
   ENDIF
   mf = mf + 1
   IF mf > maxFiles THEN EXIT DO
   f$ = DIR$()
 LOOP
 
 mf = mf -1 ' we now know the number of entries
 
 ' print the unsorted list
 PRINT
 FOR z = 1 TO mf
   PRINT STR$(z,4);" ";fList$(z)
 NEXT z
 
 ' make a copy to use in the sort
 FOR z = 1 TO mf
   fSort$(z)= fList$(z)
 NEXT z
 'SORT fSort$(), fIndex%(),&b10,0, mf+1 ' this one works
 SORT fSort$(), fIndex%(),&b10,1, mf ' this one gives strange fIndex%()
 
 ' print the sorted list and the original data using the index array
 PRINT
 FOR z = 1 TO mf
   PRINT STR$(fIndex%(z),4);" "; fSort$(z);"     ";fList$(fIndex%(z))
 NEXT z
END


Jim
VK7JH
MMedit   MMBasic Help
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8570
Posted: 08:02am 24 Nov 2020
Copy link to clipboard 
Print this post

Thanks Jim

I wasn't correctly passing the start index into the sort - will post b5 when I've tested all the fixes
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8570
Posted: 10:00am 24 Nov 2020
Copy link to clipboard 
Print this post

V5.06.00b5 posted

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

Should fix the HELP and SORT bugs identified above

also now allows any pages to be used for PAGE AND_PIXELS etc.
Edited 2020-11-24 20:02 by matherp
 
markboston36
Regular Member

Joined: 27/10/2020
Location: United States
Posts: 76
Posted: 04:26pm 24 Nov 2020
Copy link to clipboard 
Print this post

i need to get on the ball and learn this so i can use all of these fancy new things.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5886
Posted: 09:13pm 24 Nov 2020
Copy link to clipboard 
Print this post

  matherp said  V5.06.00b5 posted

Should fix the HELP and SORT bugs identified above

Close but no cigar.

Fixed for string arrays but still has a problem with integer arrays when starting from an index other than zero.
 OPTION EXPLICIT
 OPTION DEFAULT NONE
 DIM INTEGER maxFiles = 500 ' adjust to suit expected maximum
 DIM fList$(maxFiles) LENGTH 60' file names for sorting
 DIM fSize%(maxFiles) ' file sizes
 dim fSort$(maxFiles) LENGTH 60
 DIM fsortSize%(maxFiles)
 dim fIndex%(maxFiles)
 DIM INTEGER mf, z
 DIM f$
 
 mf = 1
 f$ = DIR$("*", ALL)
 DO WHILE f$ <> ""
   fSize%(mf)=MM.INFO$(FILESIZE f$)
   IF fSize%(mf) = -2 THEN ' it is a directory
     fList$(mf) = " "+f$+" <DIR>"' the leading space keeps directories sorted first
   ELSE
     fList$(mf) = f$
   ENDIF
   mf = mf + 1
   IF mf > maxFiles THEN EXIT DO
   f$ = DIR$()
 LOOP
 
 mf = mf -1 ' we now know the number of entries
 
 ' print the unsorted list
 PRINT
 FOR z = 1 TO mf
   PRINT STR$(z,4);" ";fList$(z)
 NEXT z
 
 ' sort by file size using numbers instead of strings
 math add fSize%(), 0, fSortSize%()
 
 '  SORT fSortSize%(), fIndex%(),&b10,0, mf+1 ' this one works
 SORT fSortSize%(), fIndex%(),&b10,1, mf ' this one has problems
 ' print the sorted list
 PRINT
 FOR z = 0 TO mf
   PRINT STR$(fIndex%(z),4);" "; STR$(fSize%(fIndex%(z)),10,0);"  "; fList$(fIndex%(z))
 NEXT z


Jim
VK7JH
MMedit   MMBasic Help
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8570
Posted: 10:45pm 24 Nov 2020
Copy link to clipboard 
Print this post

Jim

This code doesn't run - gives a string length error

Can you come up with a simple example without involving strings if you think integer arrays are incorrect
Edited 2020-11-25 08:50 by matherp
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5886
Posted: 11:01pm 24 Nov 2020
Copy link to clipboard 
Print this post

  matherp said  Jim

This code doesn't run - gives a string length error


I assume you have file names longer than 60 characters.
Try removing the 'length 60' of the two arrays

Or this:
 OPTION EXPLICIT
 OPTION DEFAULT NONE
 DIM INTEGER maxFiles = 500 ' adjust to suit expected maximum
 DIM fSize%(maxFiles) ' file sizes
 DIM fsortSize%(maxFiles)
 dim fIndex%(maxFiles)
 DIM INTEGER mf, z
 DIM f$
 
 mf = 1
 f$ = DIR$("*", ALL)
 DO WHILE f$ <> ""
   fSize%(mf)=MM.INFO$(FILESIZE f$)
   mf = mf + 1
   IF mf > maxFiles THEN EXIT DO
   f$ = DIR$()
 LOOP
 
 mf = mf -1 ' we now know the number of entries
 
 ' print the unsorted list
 PRINT
 FOR z = 1 TO mf
   PRINT STR$(z,4);" ";fSize%(z)
 NEXT z
 
 ' sort by file size using numbers instead of strings
 math add fSize%(), 0, fSortSize%()
 
 'SORT fSortSize%(), fIndex%(),&b10,0, mf+1 ' this one works
 SORT fSortSize%(), fIndex%(),&b10,1, mf ' this one has problems
 
 ' print the sorted list (including index aero)
 PRINT
 FOR z = 0 TO mf
   PRINT STR$(fIndex%(z),4);" "; fSize%(fIndex%(z))
 NEXT z


Jim
Edited 2020-11-25 09:07 by TassyJim
VK7JH
MMedit   MMBasic Help
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 441
Posted: 06:15am 25 Nov 2020
Copy link to clipboard 
Print this post

The MATH Q_VECTOR command signature in the manual is wrong.
The manual specifies this signature:

MATH Q_VECTOR inV(), outVQ()

and the correct is:

MATH Q_VECTOR x,y,z,outVQ()
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3833
Posted: 08:27pm 25 Nov 2020
Copy link to clipboard 
Print this post

A new bug to "blow your mind", at least it did mine.

As usual the code below is a stripped down version of something moderately sane:

Colour Maximite 2
MMBasic Version 5.06.00b5
Copyright 2011-2020 Geoff Graham
Copyright 2016-2020 Peter Mather

> list "bug.bas"
repeat()
End

Sub repeat()
 Local i$
'  Local j$
 Print "Hello"
 Pause 2000
 Run "bug.bas"
End Sub


Run whilst looking at the VGA display.

It should display:
Hello
Hello
Hello
Hello
...


It did this on beta 2, but in beta 5 it clears the screen between each invocation but doesn't reset the y position, so instead the text "Hello" slowly migrates down the screen.

I'm not sure if it is intended but please don't start clearing PAGE 0 automatically before/after program invocations, that will make writing programs that extend the capabilities of the BASIC console and work on the VGA display impossible.

But this isn't even the bug that blows my mind, now uncomment the Local j$ and run again, still looking at the VGA display.

The display now flashes / re-synchs / blanks, whatever the technical term is, between each program invocation and it did this in beta 2 as well.

Best wishes,

Tom
Edited 2020-11-26 06:28 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1082
Posted: 09:20pm 25 Nov 2020
Copy link to clipboard 
Print this post

  thwill said  I'm not sure if it is intended but please don't start clearing PAGE 0 automatically before/after program invocations, that will make writing programs that extend the capabilities of the BASIC console and work on the VGA display impossible.

I would extend that and say, please don't clear ANY pages when a program is run. If a programmer needs a cleared page, it is the programmer's responsibility to do the clearing. Yes, my 3D maze program shows corrupted graphics when run after another program that used higher pages, but that is not the job of the firmware to fix.

As Tom says, there could be many reasons to want pre-existing data to persist between separate programs.
Visit Vegipete's *Mite Library for cool programs.
 
     Page 1 of 3    
Print this page
© JAQ Software 2024