Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:47 02 Jul 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 : CMM2 V5.05.06exp: Huge performance improvement - please test

     Page 5 of 8    
Author Message
MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
Posted: 11:59pm 23 Oct 2020
Copy link to clipboard 
Print this post

I have tested the updated DEMOX and it worked perfectly... AND IS EVEN FASTER YET!

Fantastic work, Peter!
 
sc05027
Newbie

Joined: 01/01/2015
Location: Hong Kong
Posts: 10
Posted: 06:33am 24 Oct 2020
Copy link to clipboard 
Print this post

Based on my understanding on this thread, to make a program run faster in this version of MMBasic, it is better to preventing hash collisions between global variable names and between local variable names (not just prevent using same variable names).  So, I wrote a small FNV-1a function to help me identify the hash result, I can use this to help naming variables wiser.  However, I have no idea which case the CMM2 firmware used in identifying variable names, upper case or lower case?  I hope someone who has access to the source code help.  Thanks.

Function FNV1a(varname As string) As integer
 Local integer FNVPrime = 16777619  'source from wiki FNV function
 Local integer FNVoffsetbasis = 2166136261
 Local integer hash = FNVoffsetbasis
 Local integer i
 For i = 1 To Len(varname)
   hash = hash Xor Asc(UCase$(Mid$(varname,i,1)))  'UCase$ / LCase$?
   hash = hash * FNVPrime
 Next
 FNV1a = hash And 511
End Function
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10180
Posted: 07:09am 24 Oct 2020
Copy link to clipboard 
Print this post

  Quote  Based on my understanding on this thread, to make a program run faster in this version of MMBasic, it is better to preventing hash collisions between global variable names and between local variable names


In the latest release local and global variables are separate so you only need to check local to local and global to global
  Quote  However, I have no idea which case the CMM2 firmware used in identifying

variable names, upper case or lower case?

All variables are converted to upper case before hashing

NB you need to round up the length of variables to a multiple of 4 by adding 0 characters to get the hash I use
Edited 2020-10-24 17:28 by matherp
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10180
Posted: 11:45am 24 Oct 2020
Copy link to clipboard 
Print this post

One final tweak - function lookup is now hashed and the maximum number of functions increased to 512. Gives me another 5% or more improvement on most tests


CMM2V1.5.zip


 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4299
Posted: 01:09pm 24 Oct 2020
Copy link to clipboard 
Print this post

Very impressive, the unoptimised version of Z-MIM now reaches 1000 zmips.



I don't suppose there is any chance you'll stop now so that I can smoke test the Welcome Tape against a fixed target ?

Best wishes,

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

Joined: 11/12/2012
Location: United Kingdom
Posts: 10180
Posted: 01:11pm 24 Oct 2020
Copy link to clipboard 
Print this post

  Quote  I don't suppose there is any chance you'll stop now so that I can smoke test the Welcome Tape against a fixed target ?


  Quote  One final tweak
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4299
Posted: 01:16pm 24 Oct 2020
Copy link to clipboard 
Print this post

... bugger, with the new firmware (c.f. RC6) the new "Welcome Tape" menu is crapping out with a "System fault" almost immediately ... watch this space.
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
Posted: 01:17pm 24 Oct 2020
Copy link to clipboard 
Print this post

Peter,

Almost all my games now give me "Unknown command".

Try the last version of Gauntlet on GitHub, you will see:

Error on INTRO.INC line 29: Unknown command

In all situations, is like something in INC files isnīt found.
 
MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
Posted: 01:20pm 24 Oct 2020
Copy link to clipboard 
Print this post

I found the "bug"... The CLEAR command mess up the things.

I removed the CLEAR command and itīs all fixed.
Edited 2020-10-24 23:21 by MauroXavier
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10180
Posted: 01:24pm 24 Oct 2020
Copy link to clipboard 
Print this post

  Quote  Almost all my games now give me "Unknown command".


I've obviously missed something. Leave it with me. Thwill: don't waste any time until I re-post
 
MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
Posted: 01:27pm 24 Oct 2020
Copy link to clipboard 
Print this post

WHAAAT?? GAUNTLET is now perfected in this firmware version, it reached 80 enemies on the screen at 20 FPS with 4 PLAYERS!

This is exactly what I was trying to do, thanks to you now I can go on the development of GAUNTLET with no effort about optimization.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10180
Posted: 01:56pm 24 Oct 2020
Copy link to clipboard 
Print this post

Sorry about that - CLEAR command was causing the problem


CMM2V1.5.zip
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4299
Posted: 02:14pm 24 Oct 2020
Copy link to clipboard 
Print this post

Alas that hasn't helped me ... you call my style weird, the idea of calling CLEAR within a program seems downright bizarre to me.

I think mp3 playback is now crapping out randomly with a "System fault" as the Welcome Tape menu program seems to be dying whilst just sitting in a loop waiting for keyboard input.

I don't suppose you can be persuaded to download:

https://github.com/thwill1000/cmm2-welcome/archive/develop-r0.5.zip

and RUN "/welcome/menu/menu.bas" ?

Tom
Edited 2020-10-25 00:19 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
Posted: 02:45pm 24 Oct 2020
Copy link to clipboard 
Print this post

  thwill said  Alas that hasn't helped me ... you call my style weird, the idea of calling CLEAR within a program seems downright bizarre to me.

Sorry, I never called your style weird, when talking about fun (not work), I think anyone can make a program as wish.

In the previous firmware, when running the DEMOX, in each part of the demo when I used CLEAR command and declared only the variables and arrays used in that part of the demo, the speed gain was IMPRESSIVE! This was one of the tricks to achieving the speed in early firmware.

Now I believe the CLEAR command is not relevant as I removed it on my programs and doesn't show any difference of speed anymore.

In any case, CLEAR can be used when you have a program that declares too many variables and arrays and you really want to "clear all the house" without using ERASE for each declared variables and arrays.

When talking about limited memory systems (MSX BASIC in my time) or split memory type (slow and fast memory types in the same system in a linear address, as the CMM2), isnīt bizarre for me to use the CLEAR command.
Edited 2020-10-25 00:47 by MauroXavier
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4299
Posted: 02:55pm 24 Oct 2020
Copy link to clipboard 
Print this post

  MauroXavier said  Sorry, I never called your style weird ...


No you didn't, that comment was directed at Peter who likes to remark that some of the things that I do are "odd" when commenting on the latest bizarre edge condition bug or feature request that I've reported or made.

No offence,

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

Joined: 11/12/2012
Location: United Kingdom
Posts: 10180
Posted: 03:12pm 24 Oct 2020
Copy link to clipboard 
Print this post

  Quote  I don't suppose you can be persuaded to download:


I had a quick look but there are so many things that may be the issue in the complex way you do things I don't have a hope of finding the issue

we.is_quit_key% = UCase$(k$) = WE.QUIT_KEY$


?

One thing to look at is any use of EXECUTE for other than RUN

Please try and narrow it down

Given that "normal" programs run so much faster the optimisations are not something I'm going to back out
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4299
Posted: 03:21pm 24 Oct 2020
Copy link to clipboard 
Print this post

  matherp said  I had a quick look but there are so many things that may be the issue in the complex way you do things I don't have a hope of finding the issue

we.is_quit_key% = UCase$(k$) = WE.QUIT_KEY$


?


I don't know what you mean, that is just the BASIC equivalent of:
a = b == c

it's just that the BASIC assignment and equals operator are the same

I'm suspect that just some subtle timing change means the mp3 playing is not "pinging the watchdog" sufficiently.

Anyhow I'll move some things around, and I guess there is a good chance the issue will disappear mysteriously.

  Quote  Given that "normal" programs run so much faster the optimisations are not something I'm going to back out


I'm not suggesting you should, but I think your definition of "normal" will have to change as developers increasingly push the system.

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4299
Posted: 03:37pm 24 Oct 2020
Copy link to clipboard 
Print this post

OK, not sure this is the same bug but, "A:/crash.bas"

Function we.wait_for_key$()
 Local k$
 Do While k$ = "" : k$ = Inkey$ : Loop
 we.wait_for_key$ = k$
End Function

Play MP3 "TweakerRaySpaceFlight-160kb.mp3"
Do
 k$ = we.wait_for_key$()
Loop


Download the MP3 file here: https://github.com/thwill1000/cmm2-welcome/raw/develop-r0.5/menu/TweakerRaySpaceFlight-160kb.mp3

1. EDIT "crash.bas"
2. F2
3. System fault

Doesn't happen if you just RUN "crash.bas" from the command line.

Best wishes,

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

Joined: 11/12/2012
Location: United Kingdom
Posts: 10180
Posted: 03:37pm 24 Oct 2020
Copy link to clipboard 
Print this post

  Quote  I'm suspect that just some subtle timing change means the mp3 playing is not "pinging the watchdog" sufficiently.


No its not that. I disabled the watchdog to test that possibility.

I suspect the issue is that something is causing the variable stack, variable hash table or function has table to be corrupted or wrong. Does it run on any of these posts on this thread?
My guess is variable stack and that it is EXECUTE causing the problem
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4299
Posted: 03:44pm 24 Oct 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  I'm suspect that just some subtle timing change means the mp3 playing is not "pinging the watchdog" sufficiently.


No its not that. I disabled the watchdog to test that possibility.

I suspect the issue is that something is causing the variable stack, variable hash table or function has table to be corrupted or wrong. Does it run on any of these posts on this thread?
My guess is variable stack and that it is EXECUTE causing the problem


OK, see my last post, definitely no EXECUTE there, but also may be a different bug.

If you find/fix that bug and I'm still experiencing an issue I'll work back through the experimental releases to see when it first appeared, I assume all the links are still valid, or is it a single link and you just keep updating the target?

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
     Page 5 of 8    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025