![]() |
Forum Index : Microcontroller and PC projects : CMM2: V5.07.00b12 - Various fixes
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
epsilon![]() Senior Member ![]() Joined: 30/07/2020 Location: BelgiumPosts: 255 |
I spent a day tracking down a mysterious lock-up after making a trivial change in my game engine code. I finally realized I hit the 512 global variables limit. That is a major showstopper. Is there any chance at all to increase this limit? Epsilon CMM2 projects |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10068 |
No: it is fundamental to the hashing lookup mechanism that gives the performance on the CMM2 |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4251 |
Epsilon, I imagine some / many (?) of them are integer constants ? It sounds like you are reaching the stage where you need to consider using a pre-processor to inline them so they don't take up global variable slots. Best wishes, Tom Edited 2021-05-19 19:33 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
epsilon![]() Senior Member ![]() Joined: 30/07/2020 Location: BelgiumPosts: 255 |
Epsilon, I imagine some / many (?) of them are integer constants ? It sounds like you are reaching the stage where you need to consider using a pre-processor to inline them so they don't take up global variable slots. Yes! I was thinking exactly the same thing. I didn't realize that constants would count as globals. Even with the simple #define text replacement feature I should be able to eliminate a ton of constants (and probably gain some performance in the process). That also opens the door to grouping certain related globals (things you would put in a struct in C) into tables indexed by a #define'd 'constant'. I am concerned however that I'm already hitting this limit now, with just the game engine code. I don't even have a game yet... Epsilon CMM2 projects |
||||
toml_12953 Guru ![]() Joined: 13/02/2015 Location: United StatesPosts: 390 |
Epsilon, I imagine some / many (?) of them are integer constants ? It sounds like you are reaching the stage where you need to consider using a pre-processor to inline them so they don't take up global variable slots. Yes! I was thinking exactly the same thing. I didn't realize that constants would count as globals. Even with the simple #define text replacement feature I should be able to eliminate a ton of constants (and probably gain some performance in the process). That also opens the door to grouping certain related globals (things you would put in a struct in C) into tables indexed by a #define'd 'constant'. I am concerned however that I'm already hitting this limit now, with just the game engine code. I don't even have a game yet... Does an array count as one variable or does it count as one for each element? If it's just one variable, then you could have hundreds or even thousands more variables stored as array elements. |
||||
epsilon![]() Senior Member ![]() Joined: 30/07/2020 Location: BelgiumPosts: 255 |
Does an array count as one variable or does it count as one for each element? If it's just one variable, then you could have hundreds or even thousands more variables stored as array elements. An array is one variable. So you're right, I could group all integers into one integer array, all floats into one float array, all integer one-dimensional arrays into one two-dimensional arrays etc. In the extreme, that means just one global per data type (float, int, and strings of various lengths), and data access is done explicitly by array indexing instead of implicitly (by MMBasic interpreter) through hash look-up. Epsilon CMM2 projects |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3312 |
But if you use constants as a way to indicate which array element means what, then you're back in the same situation (constants count as variables) unless you use the preprocessing method to replace the constant names with the constant values. Then if you're debugging, the statement listed upon an error break may just be a slew of numbers--you'd have to refer back to your source to see what intended variables were at fault. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
epsilon![]() Senior Member ![]() Joined: 30/07/2020 Location: BelgiumPosts: 255 |
Yes, the preprocessing method is key to make this work... unless the upper limit for #defines is also 512... I wouldn't actually go as far as grouping variables into arrays unless I really have to. I can free up half the globals space just by replacing my CONSTs with #defines, without much code impact. Epsilon CMM2 projects |
||||
epsilon![]() Senior Member ![]() Joined: 30/07/2020 Location: BelgiumPosts: 255 |
It's much less apparently. I did 127 const to #define replacements and I get this error: > *xd_demo Too many #DEFINE statements Bummer ![]() Epsilon CMM2 projects |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7513 |
You can only have up to 64 #DEFINEs according to the CMM2 manual. That's not made your day, has it? :( Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4251 |
I wonder if there is any intrinsic reason for this limit, Peter ? The transpiler I wrote as part of sptools (https://github.com/thwill1000/sptools/tree/develop-r1b3) can handle 200 replacements and could easily handle more. HOWEVER: 1. It is significantly less convenient than the #define facility as it basically adds a "compile" step to the workflow. 2. I am really only maintaining it to the extent that I personally require, as (with the exception of MMEdit) there seems to be even less interest in tools on TBS than there is in games. If you do end up looking at it then please use the "develop-r1b3" branch and be aware I am currently force-pushing to it; though I will stop that malpractice if anyone else starts using it. I wonder if building a generic game engine on-top of a non compiling/hotspot interpreter is asking a bit much of even the CMM2 ? Are you using a lot of CSUBs to support it ? Best wishes, Tom Edited 2021-05-20 02:21 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
epsilon![]() Senior Member ![]() Joined: 30/07/2020 Location: BelgiumPosts: 255 |
You can only have up to 64 #DEFINEs according to the CMM2 manual. That's not made your day, has it? :( *Epsilon rage quits CMM2* ![]() I wonder if there is any intrinsic reason for this limit, Peter ? That would indeed be the preferred solution. Unfortunately, Peter always gets put on the spot. 2. I am really only maintaining it to the extent that I personally require, as (with the exception of MMEdit) there seems to be even less interest in tools on TBS than there is in games. The NIH is strong in this group. If it's any consolation, as far as I know I'm the only xedit user, but I'm OK with that. If this game-engine comes to fruition, I'll probably be the only user of that as well. It's a niche in a niche. If you do end up looking at it then please use the "develop-r1b3" branch and be aware I am currently force-pushing to it; though I will stop that malpractice if anyone else starts using it. I might use it, if Peter says no. However, I still think there's a lot of value in oneliner macros with arguments. It increases the expressiveness of the code without incurring performance overhead. I don't want to push that as a feature request on you (I save all feature requests for Peter), so I might decide to roll-my-own. More NIH. I wonder if building a generic game engine on-top of a non compiling/hotspot interpreter is asking a bit much of even the CMM2 ? It is. I'm hitting limits left-and-right. But that's when things get interesting ![]() Are you using a lot of CSUBs to support it ? I am. I'm actually seeing the game engine as a kind of middleware component, a bit like Peter's 3D engine in the FW. The code itself doesn't have to be MMBasic, but it allows the user code, i.e. the game code, to be written in MMBasic. If I had full access to the CMM2 platform API in C, I would probably write the entire engine in C. Epsilon CMM2 projects |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7513 |
Would it be too slow to use a CSUB and POKE/PEEK to store data in for when it's needed rather than using variables? At least for some of the least used. Rather like an array, but you could mix everything apart from strings in it. As it's part of the program you don't need to load it from DATA statements either. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4251 |
Can I suggest spinning off a new thread "CMM2: pushing the limits" or some such. I'd do it myself but I'm on my phone so copy and pasting between threads isn't easy. Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10068 |
b34 - 256 #defines http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 3998 |
I know what NIH (*) normally means but it looks to be something else in this thread - please explain! * Not Invented Here (well, sometimes National Institutes of Health) John Edited 2021-05-20 04:50 by JohnS |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4251 |
That's what it means here too. People are writing their own tools or "getting by". A natural result of being a community of makers rather than users. Tom Edited 2021-05-20 04:52 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4251 |
I think this is a new bug for you Peter: 400MHz Colour Maximite 2 MMBasic Version 5.07.00b33 Copyright 2011-2021 Geoff Graham Copyright 2016-2021 Peter Mather > list "bug.bas" Option Explicit On Option Default None Option Base 0 If Mm.CmdLine$ = "fails" Then Print bar$(foo$("hello")) Print bar$() Else Print bar$("*hello*") Print bar$() EndIf Function foo$(s$) foo$ = "*" + s$ + "*" End Function Function bar$(s$) Static a$ = "" If a$ = "" Then a$ = s$ bar$ = a$ End Function > run "bug.bas" *hello* *hello* > run "bug.bas", fails *hello* > As far as I can see both executions should print the same output: *hello* *hello* EDIT: the workaround is to assign the output of foo$() to a variable and pass that into bar$() - but I don't see why that should be necessary. Best wishes, Tom Edited 2021-05-23 21:34 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 4854 |
Dear Peter, I finally got my CMM2, so now the fun starts.. I guess you could call me a late adopter. Installed MM Basic last version 5.07.00b34. The CMM2 works, and up to now I have not seen any real problems, but I have seen some quirks that I would like to share. 1/ when I assembled the kit and installed the system, I used a brand new SD card (32GB sandisk ultra). And the file manager (F1) would give a black screen, nothing else. The Editor would not open. After I put the SD card in a W10 PC and put some files on the SD card all started working. I can imagine that the file manager shows a black screen with a empty SD card (although I would expect the root directory to be visible). But it is very annoying the editor does not open, so you cannot create your first program. 2/ with a correct working SD card following observation: when I power the CMM2 the SD card LED turns ON, and stays ON indicating the SD card is powered. After I open the file manager (F1), and close it again, the LED goes off. Why is the SD card led on all the time at first power up. Should it not be off, or ON reading the directory structure, and then turn off ? Question 3/ The CMM2 has a build in IR sensor connected to PB12. I have an application where the IR sensor is build in a shooting target. Is there an option to use one of the 40 pin connector pins to connect a external IR sensor ? Or is pin PB12 the only pin that can be used ? (if that being the case I need to remove the build in sensor and wire PB12 to one of the 40 pin connector pins in parallel). Thanks you for your answers. Regards, Volhout PicomiteVGA PETSCII ROBOTS |
||||
goc30![]() Guru ![]() Joined: 12/04/2017 Location: FrancePosts: 435 |
Hi peter just 2 questions 1 - I have keyboard+mouse logitech in BT connection. Keyboard work without problems mouse don't work. it is correct, no pb. But if I put "option mouse on", in "files" function or "edit" function, I receive "mouse time-out". Is it because I have a BT mouse?, an in this case, may I have problem when I will connect in a futur, a Ps2 mouse?? 2 - what problem it would pose to have by default, the numeric keyboard active all the time . I have, as all in the world, a 105 keyboard, but without capability to use numeric pad. with all text editor in Windows, I can use num pad, but with CMM2 it is impossible to use correctly my keyboard, . Each time key "numeric" is put out. it's ridiculous and it becomes stressful, not to mention the many "syntax" errors or others bugs, that it generates when you type on the keyboard automatically. in short my question is simple: with 105 keyboard, what do we use the numeric keypad for when the "numeric keypad" function is inactive?? Edited 2021-05-25 10:27 by goc30 |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |