Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 10:39 08 May 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 : Conway’s game of life

     Page 3 of 3    
Author Message
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1594
Posted: 07:25am 11 May 2020
Copy link to clipboard 
Print this post

TassyJim said elsewhere:
  Quote  The fastest was TEXT so for graphics with a single colour, a defined font would be a good choice.

But text can be different colours too. I guess that would that slow things down by defining the colour for each charactor if it were done that way?

On that subject: The Introduction to Programming with the Colour Maximite 2 doc says:
  Quote  Using the PIXEL command we can change the pixel at the centre of the screen to yellow with the command:

PIXEL 400, 300, 16776960

Defining colours this way is rather clumsy so MMBasic makes it easy for you with the RGB() function. This has the form RGB(red, green, blue) where red is a number between zero and 255 and similar for green and blue. So you could rewrite the command to turn on the pixel with the yellow colour like thus:

PIXEL 400, 300, RGB(255, 255, 0)

Can the colour of a pixel really be defined that way or was that just to make a point?
Could it also be a constant?
Can other commands use this method of specifying colour instead of RGB()?

Can I use:
CONST PUCE = 13404313
and then:
PIXEL 400, 300, 13404313

Bill
Keep safe. Live long and prosper.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8600
Posted: 07:31am 11 May 2020
Copy link to clipboard 
Print this post

The CMM2 is exactly the same as all the Micromites. Colours are a 24bit number with the bit layout rrrrrrrrggggggggbbbbbbbb. This is then translated by the firmware to match the display RGB888, RGB565, RGB332.

The RGB function is just a simple way of creating that number. It becomes a bit more obvious if you express the number in hex

&HFF0000 is red, &H00FF00 is green, &H0000FF is blue. Therefore, of course, you can use constants or any other way of storing the number
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8600
Posted: 07:44am 11 May 2020
Copy link to clipboard 
Print this post

Note to Jim: make your cells a multiple of 4 pixels wide and start them all at x coordinates exactly divisible by 4 then try the BLIT timings again.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5915
Posted: 07:45am 11 May 2020
Copy link to clipboard 
Print this post

  Turbo46 said  
But text can be different colours too. I guess that would that slow things down by defining the colour for each charactor if it were done that way?

Bill

The text version uses
text x * DIAM, y * DIAM,"O","LT",1,1,col

with 'col' changing depending on the desired state.

I have decided that BLIT with a 'thing' that looks remarkably like the corona virus looks best, as well as fastest.

Jim
VK7JH
MMedit   MMBasic Help
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8600
Posted: 09:54am 11 May 2020
Copy link to clipboard 
Print this post

Jim

If you are playing "what is the fastest?" then use the BOX command with arrays as the parameters. Construct arrays holding the coordinates of the cells and an array holding the colours. Then each generation will just update the colour array. A single call to BOX will write the entire screen. Arrays as parameters to graphics commands have been in all my MMX and Armmite versions but haven't really been picked up on. They make a huge difference in performance as the parsing overhead is nearly completely eliminated.

You can do this with the circle command as well but circles take more processing than rectangular boxes.
Edited 2020-05-11 19:55 by matherp
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3852
Posted: 10:50pm 11 May 2020
Copy link to clipboard 
Print this post

  Turbo46 said  ...but not as we know it


LOL my daughter could manage a pretty good rendition of that song at age 3 after I used to sing it to her whilst changing nappies.

  Quote  I'm impressed with the speed of updates. It looks like you can send the data to the devices with the display unchanged and latch the outputs with a single instruction?


Nope, just an 8 pixel column at a time.

Though if it is possible I'd like to do it how you suggest. At the moment I'm having to send a bunch of no-ops to the Max7219 to select the correct matrix and I'm not sure that should be necessary, I had thought I could send in all the data in order and it would just shift down the chain.

TBH I've had a bit of a 'mare with these cheap Chinese modules, they were presoldered and the header pins are all over the place, and I don't have the skills or tools to desolder through plated holes with any reliability, I ended up having to make the female "mounting" headers on my board just as wonky and leaving some of their headers just hanging. They also seen to pick up interference from the fluorescent lights in my workspace, when I turn the lights on and off the matrices respond. That plus I haven't found a reliable way to reset the Max7219 (other than powercycling the CMM) has made life "fun" and behaviour unpredictable; I spent a week chasing what I thought was a hardware failure only to find a bug in my code

  Quote  Have you seen this post?


Only in passing. My code is based on an article in EPE by the WhiteWizard where he was bit banging a single module. I converted that to SPI and then worked out how to drive multiple modules, but as alluded to above I don't think I am doing this in the most efficient manner.

I'll dig into that article a bit closer when I have the time, though that code has far too many global variables for me to from easily grok and the SPI function seems significantly different between MMBasic 4.5 and 5.

Best regards,

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

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3852
Posted: 09:27am 17 Aug 2020
Copy link to clipboard 
Print this post

  TassyJim said  ... I have decided that BLIT with a 'thing' that looks remarkably like the corona virus looks best, as well as fastest.


Hi Jim,

This suggests you might have a CMM2 compatible version of Life that isn't posted to the forum. If that is the case is it something you'd be willing to have included in the "Welcome Tape" (distributed under The Unlicense)?

Best wishes,

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

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5915
Posted: 11:40am 17 Aug 2020
Copy link to clipboard 
Print this post

  Quote  Hi Jim,

This suggests you might have a CMM2 compatible version of Life that isn't posted to the forum. If that is the case is it something you'd be willing to have included in the "Welcome Tape" (distributed under The Unlicense)?

https://www.thebackshed.com/forum/ViewTopic.php?TID=12159&P=3#149472

Jim
VK7JH
MMedit   MMBasic Help
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3852
Posted: 11:57am 17 Aug 2020
Copy link to clipboard 
Print this post

  TassyJim said  
  Quote  Hi Jim,

This suggests you might have a CMM2 compatible version of Life that isn't posted to the forum. If that is the case is it something you'd be willing to have included in the "Welcome Tape" (distributed under The Unlicense)?

https://www.thebackshed.com/forum/ViewTopic.php?TID=12159&P=3#149472

Jim


Thanks Jim.
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3852
Posted: 03:10pm 18 Aug 2020
Copy link to clipboard 
Print this post

Wow that's looking really neat Jim, thanks to you (and Bill) for letting me include it on the "Welcome Tape".

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

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1594
Posted: 08:30am 20 Aug 2020
Copy link to clipboard 
Print this post

Sorry but I couldn't resist one small change. Jim has done a great job (as always) but I don't like the different colours for the different stages of 'life' so I added a choice to change to a single colour if you want to.
life2_2.zip

Bill
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3852
Posted: 09:44am 20 Aug 2020
Copy link to clipboard 
Print this post

  Turbo46 said  Sorry but I couldn't resist one small change. Jim has done a great job (as always) but I don't like the different colours for the different stages of 'life' so I added a choice to change to a single colour if you want to.
life2_2.zip

Bill


Did you change the colour for the "dying" cells as well ? I haven't looked at Jim's code in depth, but if it still shares some ancestry with my multi-coloured original then strictly speaking by the rules of Conway's Game of Life those cells should actually not be depicted.

Regards,

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

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5915
Posted: 10:20am 20 Aug 2020
Copy link to clipboard 
Print this post

The option to colour the dying cells was always there for the preset cases.
 ' seeds are pairs of x,y cells ending in -1 then 0 or 1 for coloured dying cells


I agree that it is not part of the original game which is why I made the colour dark.

Jim
VK7JH
MMedit   MMBasic Help
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3852
Posted: 10:35am 20 Aug 2020
Copy link to clipboard 
Print this post

  thwill said  ... my multi-coloured original ...


To be clear, I added multi-coloured cells to Bill's original.

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

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1594
Posted: 11:11am 20 Aug 2020
Copy link to clipboard 
Print this post

  Tom said  Did you change the colour for the "dying" cells as well ?

Yes. I just extended the menu to: do nothing and leave as is or make all displayed cells either yellow green or blue. Also explains what the different colours mean.

Bill
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3852
Posted: 11:06am 01 Sep 2020
Copy link to clipboard 
Print this post

The implementation included in v0.2 of the Welcome Tape can be found here:

   https://github.com/thwill1000/cmm2-welcome/blob/d04f287dbd7387dda69669ffdb408215fb9b4f78/life/life.bas

I made some changes of my own, respecting Bill's wish to include the option of the original visualisation as well as the enhanced 3 colour version, but doing it in a different way.

You can see a diff here:

   https://github.com/thwill1000/cmm2-welcome/commit/2ba8b552ac7341844b147eb20bb3f1d35e05e2a7#diff-1b45274fc998432c32f93c02f365c7a2

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
     Page 3 of 3    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024