Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:38 19 Feb 2026 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 : How about this for a Christmas surprise?

     Page 3 of 4    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10965
Posted: 08:19am 23 Dec 2025
Copy link to clipboard 
Print this post

  Quote  There is a bug with play mp3 again (in latest version and offical release). When executed it does a reboot + strange behavior.


Sorry. The developer is now on holiday until the 28th. One thing you could investigate is if the issue still happens if you disconnect the ps2 keyboard and operate from a remote usb console.
Can anyone replicate with the same firmware and/or the HDMIUSB firmware?
Edited 2025-12-23 18:28 by matherp
 
Amnesie
Guru

Joined: 30/06/2020
Location: Germany
Posts: 746
Posted: 10:34am 23 Dec 2025
Copy link to clipboard 
Print this post

Hi Peter,

no problem take all the time you need    I tested your latest firmware:

  Quote  PicoMiteRP2350V6.01.00EXP.zip
Edited 2025-12-23 05:40 by matherp


with the HDMI USB version (my PCB allows bridging VSYS and USB to use an USB Hub)


The problem is the same, you can see for yourself, I shot another video in which you also can see the version and OPTION LIST - this time I used the default resolution of
640. As said, there are absolutly no problems with the RC25 version. I nuked the flash every time to be sure.

But on "PicoMiteRP2350V6.01.00EXP" there is definitly something wrong:

Video with HDMI usb version

EDIT I:
I also tested the official release (https://geoffg.net/picomite.html) again:
HDMI Version (USB and PS/2) got problems when RESOLUTION is 720, when set
to default RESOLUTION 640, no problems with "PLAY MP3" - I hope this helps.
But yes, also the official release has this bug.


EDIT II:
It is even more complicated: At first it works with default resolution on the official release, but ONCE set to RESOLUTION 720 "PLAY mp3" crashes the system.
Setting RESOLUTION back to 640 doesn't help anymore. A OPTION RESET doesn't help either. Only re-flashing the firmware helps and not setting resolution higher than 640. Once set to 720 all the problems with playback mp3 will occur.


So version RC25 is the most stable with no problems at all.

Have a wonderful holiday!!

Greetings
Daniel
Edited 2025-12-23 21:23 by Amnesie
 
ville56
Guru

Joined: 08/06/2022
Location: Austria
Posts: 395
Posted: 11:51am 23 Dec 2025
Copy link to clipboard 
Print this post

  Quote  Can anyone replicate with the same firmware and/or the HDMIUSB firmware?


yes, same here, immediate crash and reboot on play mp3 wth HDMIUSB V6.01.00EXP. I will experiment with other environments later.

the current env is:
> option list
PicoMiteHDMI MMBasic USB RP2350B Edition V6.01.00EXP
OPTION SERIAL CONSOLE COM2,GP20,GP21
OPTION FLASH SIZE 16777216
OPTION COLOURCODE ON
OPTION KEYBOARD GR
OPTION PICO OFF
OPTION RESOLUTION 640x480 @ 252000KHz
OPTION HDMI PINS  1, 3, 7, 5
OPTION SDCARD GP22, GP6, GP7, GP4
OPTION AUDIO GP26,GP27', ON PWM CHANNEL 5
OPTION MODBUFF ENABLE  192
OPTION PLATFORM OLIMEX USB
Edited 2025-12-23 21:52 by ville56
                                                                 
73 de OE1HGA, Gerald
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2492
Posted: 11:59am 23 Dec 2025
Copy link to clipboard 
Print this post

hi toml_12953,

  toml_12953 said  
  robert.rozee said  hi Peter,
   all very PASCAL like    

have just scanned through the thread, it looks like you haven't yet implemented anything like the pascal WITH statement:
[...]
(the use of DO in the context of mmbasic is probably superfluous)

the use of WITH saves on a great deal of duplicated typing and hence consumed flash program space.


It looks like Peter was going for Microsoft BASIC compatibility. If so, then in that case, you'd type
[...]


   just because microsoft erred in not implementing something like WITH ... DO to simplify the syntax, that is no reason for us to repeat the same omission. i'm sure there are many places where mmbasic deviates from microsoft basic - and for very good reason!


cheers,
rob   :-)
Edited 2025-12-23 22:01 by robert.rozee
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8568
Posted: 12:06pm 23 Dec 2025
Copy link to clipboard 
Print this post

But... MMPascal is something different.  :(
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 546
Posted: 01:11pm 23 Dec 2025
Copy link to clipboard 
Print this post

  Amnesie said  Hello Peter,

There is a bug with play mp3 again (in latest version and offical release). When executed it does a reboot + strange behavior.

EDIT: There is ALSO a problem in the latest offical release, please see the attached video, since the problem with play mp3 isn't constant!

Greetings
Daniel


I can't make play mp3 fail no matter what I do. I use an LCD as console and have a Pimoroni Pico 2 as my CPU with PSRAM active. I'm using PicoMite 6.01.00 (not EXP)
Edited 2025-12-23 23:11 by toml_12953
 
Amnesie
Guru

Joined: 30/06/2020
Location: Germany
Posts: 746
Posted: 02:44pm 23 Dec 2025
Copy link to clipboard 
Print this post

  toml_12953 said  
  Amnesie said  Hello Peter,

There is a bug with play mp3 again (in latest version and offical release). When executed it does a reboot + strange behavior.

EDIT: There is ALSO a problem in the latest offical release, please see the attached video, since the problem with play mp3 isn't constant!

Greetings
Daniel


I can't make play mp3 fail no matter what I do. I use an LCD as console and have a Pimoroni Pico 2 as my CPU with PSRAM active. I'm using PicoMite 6.01.00 (not EXP)


The problem occurs in HDMI versions (PS/2 and USB).
 
bfwolf
Senior Member

Joined: 03/01/2025
Location: Germany
Posts: 166
Posted: 06:07pm 25 Dec 2025
Copy link to clipboard 
Print this post

First of all: Merry Christmas to everyone!

And then @Peter: Wow! Brilliant!

I stumbled across this thread quite by accident when I saw this
https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=18342#248656
...and thought: "Huh? Did I miss something?"

If I remember correctly, the topic of "Structs" came up in the spring – so it kept you busy and you were "working on it in secret"?

I have a few more questions:

- Is the size of structs constant even if they contain strings? At least if the maximum length of the strings was specified in the definition by the "LENGTH <n>" clause?

- Is it possible to determine the size of structs (memory requirements) at runtime? Something like `sizeof(type)` in C? Perhaps it could be done with the `STRUCT()` function, for example, with `STRUCT(SIZEOF, typename)`?

That would be great because then you could calculate the offset of a record formed by a struct within a file for the `SEEK` command.

- Does PEEK(VARADDR var) also work with structs?

Thank you so much for your wonderful work!

Enjoy your time off!

Regards, bfwolf
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 546
Posted: 08:24pm 25 Dec 2025
Copy link to clipboard 
Print this post

  bfwolf said  
That would be great because then you could calculate the offset of a record formed by a struct within a file for the `SEEK` command.


With Random files, you have fixed length records so it's easy to get to the record you want if you create an index hash table. With STRUCT(FIND... you don't even have to do that yourself if you don't mind a linear search. Personally, I'd SORT the records on the search field then do a binary search to get the record I want.
Edited 2025-12-26 06:31 by toml_12953
 
bfwolf
Senior Member

Joined: 03/01/2025
Location: Germany
Posts: 166
Posted: 08:39pm 25 Dec 2025
Copy link to clipboard 
Print this post

  toml_12953 said  
  bfwolf said  
That would be great because then you could calculate the offset of a record formed by a struct within a file for the `SEEK` command.


With Random files, you have fixed length records so it's easy to get to the record you want if you create an index hash table.


That was exactly what my question was about.

I wanted to know if structs (the new user defined types) can be mapped 1:1 to fixed-length records in random files.

An index can be created in a separate file, just as dBase did. This avoids constantly reordering on the flash filesystem.

Addendum: I assumed above that the data set could become so large that it couldn't be held entirely in RAM. At best, a portion of it could be stored in a cache.
Edited 2025-12-26 06:44 by bfwolf
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 546
Posted: 11:32pm 25 Dec 2025
Copy link to clipboard 
Print this post

  bfwolf said  
  toml_12953 said  
  bfwolf said  
That would be great because then you could calculate the offset of a record formed by a struct within a file for the `SEEK` command.


With Random files, you have fixed length records so it's easy to get to the record you want if you create an index hash table.


That was exactly what my question was about.

I wanted to know if structs (the new user defined types) can be mapped 1:1 to fixed-length records in random files.

An index can be created in a separate file, just as dBase did. This avoids constantly reordering on the flash filesystem.

Addendum: I assumed above that the data set could become so large that it couldn't be held entirely in RAM. At best, a portion of it could be stored in a cache.


Why not store it in a random file on an SD card? Sure access will be somewhat slower but you can have many GB of data.
 
bfwolf
Senior Member

Joined: 03/01/2025
Location: Germany
Posts: 166
Posted: 09:41am 26 Dec 2025
Copy link to clipboard 
Print this post

  toml_12953 said  Why not store it in a random file on an SD card? Sure access will be somewhat slower but you can have many GB of data.


That was exactly what I wanted to imply with my question. If structs have a fixed length, which can be queried using, for example, STRUCT(SIZEOF,typename), their contents can be written to random files, positioned arbitrarily on a struct copy stored in the file using SEEK, and the data can also be read back into the struct in RAM. The positioning would then be achievable with SEEK #f, n*STRUCT(SIZEOF,typename).
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 562
Posted: 09:43am 26 Dec 2025
Copy link to clipboard 
Print this post

Peter

This is amazing for us that like to develop games. It will help a lot to organize the Knightmare game state. I hope this feature will reach the CMM2 and the MMBW versions.

Thank you for the surprise
Merry Christmas
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10965
Posted: 10:08am 26 Dec 2025
Copy link to clipboard 
Print this post

If you want to know if struts are fixed length why not experiment and find out? If you want to know how long they are count the bytes used in the definition. Then why not try saving a few records to disk and check the disk size as you add records. This is a new experimental capability. Play with it. See what works. Find any bugs. By all means make suggestions but do this after you have explored what is there.
 
karlelch

Guru

Joined: 30/10/2014
Location: Germany
Posts: 314
Posted: 11:09am 26 Dec 2025
Copy link to clipboard 
Print this post

  matherp said  If you want to know if struts are fixed length why not experiment and find out? If you want to know how long they are count the bytes used in the definition. Then why not try saving a few records to disk and check the disk size as you add records. This is a new experimental capability. Play with it. See what works. Find any bugs. By all means make suggestions but do this after you have explored what is there.

Go, children, play outside, the weather is nice  
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 546
Posted: 03:49pm 26 Dec 2025
Copy link to clipboard 
Print this post

  bfwolf said  
  toml_12953 said  Why not store it in a random file on an SD card? Sure access will be somewhat slower but you can have many GB of data.


That was exactly what I wanted to imply with my question. If structs have a fixed length, which can be queried using, for example, STRUCT(SIZEOF,typename), their contents can be written to random files, positioned arbitrarily on a struct copy stored in the file using SEEK, and the data can also be read back into the struct in RAM. The positioning would then be achievable with SEEK #f, n*STRUCT(SIZEOF,typename).


It looks like you'll have to keep track of the size of a record yourself. Since you define the record only once at the beginning of the program, and you know how much space each element takes, you manually add the lengths to get the length of the entire structure. Then you can store the length in a variable.

TYPE MyType
  LastName as STRING * 20
  FirstName as STRING * 10
  DOB as STRING * 10
  HourlySalary as FLOAT
  HoursPerWeek as INTEGER
END TYPE

DIM EmployeeRec as MyType

StrucLength = 20 + 10 + 10 + 8 + 8

 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10965
Posted: 03:59pm 26 Dec 2025
Copy link to clipboard 
Print this post

I'm not saying I won't add a function to return the length of a struct in the future. The point I'm trying to make is that you can experiment with what is there rather than needing everything perfect immediately. The release is marked EXP - experimental. There may be major issues there that I haven't thought about and that may render whole idea unworkable. The only way to know is for people to use it which will help flush out the bugs and limitations.
 
bfwolf
Senior Member

Joined: 03/01/2025
Location: Germany
Posts: 166
Posted: 05:30pm 26 Dec 2025
Copy link to clipboard 
Print this post

  matherp said  If you want to know if struts are fixed length why not experiment and find out? If you want to know how long they are count the bytes used in the definition. Then why not try saving a few records to disk and check the disk size as you add records. This is a new experimental capability. Play with it. See what works. Find any bugs. By all means make suggestions but do this after you have explored what is there.


  matherp said  I'm not saying I won't add a function to return the length of a struct in the future. The point I'm trying to make is that you can experiment with what is there rather than needing everything perfect immediately. The release is marked EXP - experimental. There may be major issues there that I haven't thought about and that may render whole idea unworkable. The only way to know is for people to use it which will help flush out the bugs and limitations.


OK, I did..
Here are the results of my experiments:

Option Base 1
Option Explicit

Type TPoint
 x As integer
 y As integer
End Type

Type TCircle
 x As integer
 y As integer
 r As integer
End Type

Type TPerson
 name As string Length 10
 surname As string Length 10
 phone As integer
End Type

Dim points(4) As TPoint = (1,2, 3,4, 5,6, 7,8)
Dim circles(2) As TCircle = (1,2,9, 4,5,18)
Dim people(2) As TPerson = ("Marther", "Peter", 1234, "Graham", "Geoff", 5678)

Dim i As integer

Open "a:/fpoints.bin" For Random As #1
Open "a:/fpeople.bin" For Random As #2
Open "a:/fcircles.bin" For Random As #3

For i=1 To 4
 Struct Save #1, points(i)
Next i

For i=1 To 2
 Struct Save #2, people(i)
Next i

For i=1 To 2
 Struct Save #3, circles(i)
Next i

Close #1
Close #2
Close #3

Open "a:/fpoin_2.bin" For Random As #1
Open "a:/fpeop_2.bin" For Random As #2
Open "a:/fcircl_2.bin" For Random As #3

For i=1 To 2
 Struct Save #1, points(i)
Next i

For i=1 To 1
 Struct Save #2, people(i)
Next i

For i=1 To 1
 Struct Save #3, circles(i)
Next i

Close #1
Close #2
Close #3


> files
A:/
  <DIR>  .
  <DIR>  ..
00:00 01-01-2024          4  bootcount
01:43 01-01-2024         48  fcircl_2.bin
01:43 01-01-2024         96  fcircles.bin
01:43 01-01-2024         64  fpeop_2.bin
01:43 01-01-2024        128  fpeople.bin
01:43 01-01-2024        128  fpoin_2.bin
01:43 01-01-2024        256  fpoints.bin
05:36 01-01-2024       1093  structs.bas
2 directories, 8 files, 14467072 bytes free
>


Conclusions:
- The memory requrements of a struct in a file are fixed per struct-instance, when written with 'STRUCT SAVE'.
- The structs need more space in the file, when written with 'STRUCT SAVE', than the sum of bytes of the struct-members.
- It seems that 'STRUCT SAVE' stores information about the struct type in addition to the member data bytes?
- So, if we want to store the struct in the file in a way that minimizes data usage, we need to save the struct member-by-member using 'PRINT #fn, memb$' and read back using 'memb$=INPUT$(mlen%,#fn)'. No problem at all but a little bit less performant.

This isn't meant as criticism, just what I observed during the experiment.

What confuses me is this:
Two instances of the struct TPoint (consisting of two integer members) require 128 bytes in the file "fpoin_2.bin", while two instances of the struct TCircle (consisting of three integer members) only require 96 bytes in the file "fcircles.bin"?

Many thx again!

Addendum:
Yes, Peter, I noticed the "experimental" and see the implementation as a great Christmas present! And that you're still gathering ideas.
Edited 2025-12-27 03:43 by bfwolf
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10965
Posted: 06:12pm 26 Dec 2025
Copy link to clipboard 
Print this post

I think if you do the maths, struct save is saving the dimm'd variable rather than a specific row of the array. So points has 4x2x8 bytes = 64 bytes and in file fpoints.bin you are saving 4 times = 256 bytes. Looks like a bug. Points(1) should save just the one line and points() should save the full array. This is precisely why user testing is so valuable. The test script didn't test this variant. Thanks
Edited 2025-12-27 04:14 by matherp
 
bfwolf
Senior Member

Joined: 03/01/2025
Location: Germany
Posts: 166
Posted: 08:06pm 26 Dec 2025
Copy link to clipboard 
Print this post

  matherp said  I think if you do the maths, struct save is saving the dimm'd variable rather than a specific row of the array. So points has 4x2x8 bytes = 64 bytes and in file fpoints.bin you are saving 4 times = 256 bytes. Looks like a bug. Points(1) should save just the one line and points() should save the full array. This is precisely why user testing is so valuable. The test script didn't test this variant. Thanks


I'm happy, if I can help you!

Your answer helped me understand what was going on, and I adjusted my small test program accordingly:
(I changed the file names to reflect the loop counts)

Option Base 1
Option Explicit

Type TPoint
 x As integer
 y As integer
End Type

Type TCircle
 x As integer
 y As integer
 r As integer
End Type

Type TPerson
 name As string Length 10
 surname As string Length 10
 phone As integer
End Type

Dim points(4) As TPoint = (1,2, 3,4, 5,6, 7,8)
Dim circles(2) As TCircle = (1,2,9, 4,5,18)
Dim people(2) As TPerson = ("Marther", "Peter", 1234, "Graham", "Geoff", 5678)

Dim i As integer

Open "a:/fpoints_4.bin" For Random As #1
Open "a:/fpeople_2.bin" For Random As #2
Open "a:/fcircles_2.bin" For Random As #3

For i=1 To 4
 Struct Save #1, points(i)
Next i

For i=1 To 2
 Struct Save #2, people(i)
Next i

For i=1 To 2
 Struct Save #3, circles(i)
Next i

Close #1
Close #2
Close #3

Open "a:/fpoints_2.bin" For Random As #1
Open "a:/fpeople_1.bin" For Random As #2
Open "a:/fcircles_1.bin" For Random As #3

For i=1 To 2
 Struct Save #1, points(i)
Next i

'For i=1 To 1
 i=1
 Struct Save #2, people(i)
'Next i

'For i=1 To 1
 i=1
 Struct Save #3, circles(i)
'Next i

Close #1
Close #2
Close #3

Open "a:/fpoints.bin" For Random As #1
Open "a:/fpeople.bin" For Random As #2
Open "a:/fcircles.bin" For Random As #3

Struct Save #1, points()
Struct Save #2, people()
Struct Save #3, circles()

Close #1
Close #2
Close #3


Results:
> files
A:/
  <DIR>  .
  <DIR>  ..
00:00 01-01-2024          4  bootcount
07:31 01-01-2024         48  fcircles.bin
07:31 01-01-2024         48  fcircles_1.bin
07:31 01-01-2024         96  fcircles_2.bin
07:31 01-01-2024         64  fpeople.bin
07:31 01-01-2024         64  fpeople_1.bin
07:31 01-01-2024        128  fpeople_2.bin
07:31 01-01-2024         64  fpoints.bin
07:31 01-01-2024        128  fpoints_2.bin
07:31 01-01-2024        256  fpoints_4.bin
05:36 01-01-2024       1093  structs.bas
2 directories, 11 files, 14467072 bytes free


My conclusions:

- When I write 'Struct Save #1, points()', the entire array is saved and occupies (4*(8+8))=64 bytes.

- When I write 'Struct Save #1, points(i)' four times in a loop, (4*(4*(8+8)))=256 bytes are written because the index i is ignored, and instead, the entire array is written four times. That's the bug you mentioned, right?

- When I write 'Struct Save #2, people()', the entire array is saved and occupies (2*(12+12+8))=64 bytes.

- So, a 'name As string Length 10' actually occupies 12 bytes. Presumably because a length byte is prepended? What would the 12th byte be? Is it for padding due to struct alignment in C?

So you're storing the data 'compressed' in a struct, just as it would be in C?

When I saw the predefined syntax for struct initialization — for example, 'Dim points(4) As TPoint = (1,2, 3,4, 5,6, 7,8)' — it occurred to me whether it wouldn't make sense to allow grouping using additional parentheses? For example, 'Dim points(4) As TPoint = ((1,2), (3,4), (5,6), (7,8))'. Perhaps these could simply be ignored, or even used to fill missing members in the initialization lists with 0 or an empty string?
Just an idea...


Thanks!
 
     Page 3 of 4    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026