Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:58 15 Nov 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 : MMB4W: Framebuffer creation wiping out my global array

Author Message
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 527
Posted: 06:16am 13 Nov 2025
Copy link to clipboard 
Print this post

I've encountered an interesting problem. My global array g_values is being cleared after the framebuffer creation command. It runs with no issues on the first execution, but if I try to run it again, the global array is wiped out after the framebuffer creation. The problem does not happen if I use the framebuffer close instruction at the end of the program.

Off course this is a simple example. In a real app with a infinite do/loop, it is very common during development, to break the app with ctrl+c, which causes the program not cleaning open resources or closing the framebuffer, which triggers the issue.

Is this the expected behavior? Maybe is it happening with me because I'm running MMB4W on wine?


option explicit
option base 0
option angle degrees
option default float

dim g_values(10)=(0,1,2,3,4,5,6,7,8,9,10)

? "Before framebuffer create"
? g_values(0)
? g_values(1)
? g_values(2)

framebuffer create mm.hres, mm.vres

? "After framebuffer create"
? g_values(0)
? g_values(1)
? g_values(2)


Output:


Edited 2025-11-13 16:16 by LeoNicolas
 
Supertech

Regular Member

Joined: 13/11/2016
Location: Australia
Posts: 54
Posted: 06:44am 13 Nov 2025
Copy link to clipboard 
Print this post

Interesting. I am running a project under RP2040 V6.00.03 some time now.
However this particular result seems very similar re Array loosing data.

Mine is a bit different but results the same.
Unable to paste, but is simple.
1. I have a single array holding 15, 10 length text words. Eg. Cond$(16)... but empty of say "Heating", "Cool" etc. I also have a condn() integer array that stores 0 or 1 for latter use.

2. I use one sub, n = 0 to 15 to preload these texts. Works fine.

3. Now this next sub matches the 2. Preloads like this,
Sub collect_conditions
For n = 0 to 15
If TU sensor > xyz then condn(n) = 1 else condn(n) = 0
If.....
If....
Next n
End sub

Within for..next the condn(n) loads perfect, just like string one does. BUT past next n, the condn(n) whole data array is blanked all back to zeros! Both arrays are global. Explicit active.
Your post has reminded me as it may be related? Thank you. Im not good with names
 
Supertech

Regular Member

Joined: 13/11/2016
Location: Australia
Posts: 54
Posted: 06:50am 13 Nov 2025
Copy link to clipboard 
Print this post

Thanks Leo
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4142
Posted: 08:13am 13 Nov 2025
Copy link to clipboard 
Print this post

  Supertech said  Interesting. I am running a project under RP2040 V6.00.03 some time now.
However this particular result seems very similar re Array loosing data.

Does it rely on any particular Pico features (I/O etc)?

I'm wondering if it could be tested on other MMBasic variants e.g. MMB4W, MMB4L?

Peter inevitably would like the smallest example - which may be the Pico one of course.

John
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5464
Posted: 09:30am 13 Nov 2025
Copy link to clipboard 
Print this post

Hi Leo,

On pico we have observed several issues when framebuffer is not created first. In some cases we get a nice error message. But in the transition from V5.09.00 to V6.00.03 I had to adjust several programs that defined framebuffers after array definitions, to bring the framebuffer definition first.

This was especially needed in games that work on both Game*Mite and PicoVGA. The LCD on the Game*Mite requires the use of FRAMEBUFFER F, but VGA does not.

Regards,

Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10582
Posted: 10:56am 13 Nov 2025
Copy link to clipboard 
Print this post

It is a mmb2W specific issue. As a workaround type FRAMEBUFFER CLOSE at the command prompt before re-running the program
Edited 2025-11-13 21:03 by matherp
 
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