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 : Introducing the Colour Maximite 2

Page 8 of 25
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8809
 Posted: 10:45am 08 May 2020 Copy link to clipboard Print this post

Quote  I am surprised that there is no facility to seed a random number. It could be useful when trying to get repeatable results for testing (please don't ask for an example right now).

This is really trivial

Try the attached - takes 75 microseconds to run on the CMM2, x is the seed

function pseudo() as float
static integer x=7
static integer a=1103515245
static integer c=12345
static integer m=2^31
x=(a * x + c) mod m
pseudo = x/m
end function

and here is the distribution analysis

Edited 2020-05-08 20:52 by matherp

MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
 Posted: 11:09am 08 May 2020 Copy link to clipboard Print this post

Turbo46 said  Game programming is beyond me I'm afraid but maybe someone could write a step by step tutorial while producing a simple game using some of the clever things the CMM2 can do?

For sure I use some tricks for all my games, but in a tutorial, it will be good to use native commands, for example, I must use SPRITE and not BLIT to make a "pseudo sprite" and use native sound architecture and not PSGMini. I will try to make that tutorial.

The reason that I use BLIT command instead of SPRITE is that my games easily surpass 64 sprite limits, and BLIT is so fast to cut pieces of a selected video page, it's open a new world for the animation. For example, with 24 pages of 320x200x256 plus 2 pages for background and foreground buffer and one for the main page, I have 1500 "sprites" and a parallax scrolling for developing a game.

Maybe I can create an "easy and native" tutorial for games, and another showing a little more advanced tricks.

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1608
 Posted: 11:34am 08 May 2020 Copy link to clipboard Print this post

matherp said  This is really trivial

Oh no it's not! It may say over there to the left that I am a guru but that's definitely not true. I have to accept that your function does what you say but I have no idea how or how to use it to generate a series of pseudo random numbers.

Mauro said  Maybe I can create an "easy and native" tutorial for games,

That is the sort of thing I was thinking of. If you could create a simple game like 'invaders' or 'frogger' and explain the steps as you do it - that would help a lot. That assumes they are 'simple' games.

I remain in awe of both of you and I don't think you realise how superior your knowledge and expertise is compared to a hack like me.

Bill
Keep safe. Live long and prosper.

thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3971
 Posted: 11:45am 08 May 2020 Copy link to clipboard Print this post

(muses)In some ways the very power of the CMM2 is a disadvantage. It multiplies the gap between what the most accomplished can achieve vs. those of us who have more modest talents. The end result is to dissuade the latter from trying in the first place and thus reduces the pool of original ideas.(/muses)
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures

matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8809
 Posted: 11:46am 08 May 2020 Copy link to clipboard Print this post

Quote   have no idea how or how to use it to generate a series of pseudo random numbers.

Just use it like RND() returns a number between 0 and 1. The sequence is determinate. If you need a different sequence then change the initialisation of X in the function - same as using randomize.

The code is exactly what the C call to rand used in the Micromite firmware is doing. Found it on google and easy to program in Basic

It should run on any Micromite - try it.

My code for the distribution

Quote
cls
dim a%(799)
for i%=1 to 800*300
j%=pseudo()*800-0.5 'exactly equivalent to using RND()
a%(j%)=a%(j%)+1
next i%
for i%=0 to 799
line i%,599-a%(i%),i%,599
next i%
do
loop
function pseudo() as float
static integer x=7
static integer a=1103515245
static integer c=12345
static integer m=2^31
x=(a * x + c) mod m
pseudo = x/m
end function

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1608
 Posted: 12:12pm 08 May 2020 Copy link to clipboard Print this post

Thanks Peter, Sorry for being a bit dense. I didn't twig on the use of STATIC and that caused me a bit of confusion.

Tom, I agree with your musing. I was a bit intimidated by the original CMM. How do you think I feel about the new one?

Bill
Keep safe. Live long and prosper.

Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1041
 Posted: 12:23pm 08 May 2020 Copy link to clipboard Print this post

TassyJim said
I do have a CMM2 (bare minimum) connected to the net for testing. As usual, I use ser2net on a RPi as the interface.

Jim

I did wonder if your connector was just for ease of use.

I had a look at ser2ser for the RPi & not really the wiser. Lots of RPi gobbley Gook.

I take it you use a bog standard RPi & config ser2ser with it or something. Be OK if one is RPi literate

PM me if you don't want to post in this thread.

Thanks

Brian
ChopperP

robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2327
 Posted: 12:46pm 08 May 2020 Copy link to clipboard Print this post

matherp said  You are still missing B11 and H4 which are the Nunchuck pins

Vref and VBAT should not be GND. VREF is 3.3 and VBAT is the battery

RESET, PDR_ON and BOOT0 are all system pins and should probably have a colour

E4, E5, E6, F10, H2, H3, H8, G12, D6 and G7 are all reserved to the Display controller

A8 is the test pin and outputs a clock pulse to check the processor is running

hi peter,
i've updated my spreadsheet with the above info

CMM2, CPU module pin usage (v2).zip

this chart is intended ONLY as a visual aid to give a rough idea of how pins are allocated (and how few are left spare). THE LABELS ARE NOT GUARANTEED TO BE CORRECT. all pins tied to any power rail are in black without distinction.

it looks like geoff's schematic misses the nunchuck connector, hence why it was left out before. geoff: may be worth updating the schematic in the constructors pack.

if anyone wants to make a true function chart, they should probably work off the module schematic rather than this chart. as i say, this chart may well contain ERRORS; it was only a quick visual aid i put together from the printed schematics.

as it stands, it looks like there are only a couple dozen unallocated pins, far less than folks were initially thinking:
approx 40 of the 160 pins are consumed by the SRAM and can not be used,
approx 30 are used by the VGA support,
approx 30 are allocated to the I/O connector,
close to 20 are power related.

cheers,
rob   :-)

matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8809
 Posted: 01:49pm 08 May 2020 Copy link to clipboard Print this post

Quote  I was a bit intimidated by the original CMM. How do you think I feel about the new one?

To anyone thinking this. Please do read Geoff's excellent Introduction to programming the CMM2

Yes there are lots of capabilities but at heart it is a simple Basic computer. Even quite complex looking things are really quite easy. For example this is the complete code for the ghost demo

' lets play some music while the demo is running - how about "Hotel California"
' substitute something more to your taste here or comment out
play mp3 "hotel"

'set to 640x400 mode with 2 video layers and 12-bit colour. Page 0 is the bottom layer and page 1 is the top
mode 2,12

'clear the first three framebuffers (pages)
for i=0 to 2:page write i:cls:next i

'load a sprite which is the image of the ghost from a png file.
'The fact it is a png is important as png files encode transparency as well as solid colours

'set that we are going to write to the background layer
page write 0

'load the background image to the background layer - page 0

'The image I am using is only 320x200 so I'm going to resize it to fit the screen
image resize 0,0,320,200,0,0,640,400

'initialise the display position of the ghost
x=100
y=50

'initialise the transparency of the ghost
' transparencies go from 1 (nearly invisible) to 15 (solid colour)
t=8

'set to write to page 2 which is not being displayed
page write 2

' output the ghost on page 2
sprite show 1,x,y,1

i=0

'start the main process loop
do

'do some silly maths to create a random walk of the ghost in both position and
' transparency while keeping it within the display bounds and the transparency
' within useful limits
i=i+1
if i mod 5 = 0 then c=rnd()-0.5
if i mod 3 = 0 then a=rnd()*8-4
if i mod 3 = 0 then b=rnd()*6-3
x=x+a
if x<0 then x=0
if x>MM.HRES-sprite(w,1) then x=mm.hres-sprite(w,1)
y=y+b
if y<0 then y=0
if y>MM.VRES-sprite(h,1) then y=mm.vres-sprite(h,1)
t=t+c
if t<3 then t=3
if t>12 then t=12

'display the sprite in the new position and with the new transparency
sprite transparency 1,t
sprite show 1,x,y,1

'now copy page 2 to the foreground layer during frame blanking
'this ensures that there are no tearing effects in the image

page copy 2 to 1,b

'slow things down a bit, the CMM2 is too fast
pause 100
loop

Image files

Ghost.zip

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1608
 Posted: 08:49pm 08 May 2020 Copy link to clipboard Print this post

matherp said  Please do read Geoff's excellent Introduction to programming the CMM2

I have skimmed though that document and Getting Started With the Micromite before it. I am not intimidated by BASIC per se, I can usually nut something out and end up with the result I want.

It's the graphics that I find hard to follow and that's where I would need my hand held. Unfortunately, graphics is only lightly covered in the manuals (including the original CMM). Games programmers obviously have no problems but I am not a programmer let alone a games programmer.

Your program above is well documented and easy enough to follow so I think people like me need more examples like that. Simple, short, well documented examples of the various screen modes illustrating the use of blit and sprites and so on. A completed game program is usually too much for me to pull apart and understand.

On another note: I was surprised that the CMM2 has only one extra COM port and apparently no CFunctions so a third one cannot be added.

Bill
Keep safe. Live long and prosper.

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1608
 Posted: 08:55pm 08 May 2020 Copy link to clipboard Print this post

Quote  the flavor of BASIC being used is not OPP

OPP?

Bill
Keep safe. Live long and prosper.

Trent Jackson
Newbie

Joined: 04/05/2020
Location: Australia
Posts: 34
 Posted: 08:59pm 08 May 2020 Copy link to clipboard Print this post

Turbo46 said
Quote  the flavor of BASIC being used is not OPP

OPP?

Bill

OOP (Object Orientated Programming) "Current Software Technology"

Trent Jackson

thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3971
 Posted: 10:22pm 08 May 2020 Copy link to clipboard Print this post

Trent Jackson said  OOP (Object Orientated Programming) "Current Software Technology"

Actually the ideas have been been around since the late 60's.

It's a methodology for building large software systems by structuring them as a set of components (objects) that encapsulate both state and behaviour. They communicate with each other by sending messages to (or calling methods / functions on) each other.

For small scale purposes there is nothing you can do with it that you can't do with a procedural language like BASIC and some discipline. Sure it might save you some code and let you pull some fancy tricks, but it also allows you to create reams of incomprehensible drivel ... I call that my day job ;-)

Another way of putting it is that if you want to do OOP then perhaps a (let's be honest) enthusiasts "toy" that is trying to bring back the warm glow of the 80's microcomputer is not the platform you are looking for.

No offence intended, all abuse gratefully received

Tom
Edited 2020-05-09 08:24 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures

MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
 Posted: 11:21pm 08 May 2020 Copy link to clipboard Print this post

thwill said  For small scale purposes there is nothing you can do with it that you can't do with a procedural language like BASIC and some discipline. Sure it might save you some code and let you pull some fancy tricks, but it also allows you to create reams of incomprehensible drivel ... I call that my day job ;-)

Another way of putting it is that if you want to do OOP then perhaps a (let's be honest) enthusiasts "toy" that is trying to bring back the warm glow of the 80's microcomputer is not the platform you are looking for.

Perfect explanation!

For me, the original CMM gives me an enthusiastic feeling and some limitations that bring me to the '80s with pride. Remembers me something between a ZX Spectrum (Here in Brazil know as TK90) and in some aspects, an MSX1. Obviously technically it's a different machine, but I talking about a feeling, not specs.

Now, with the CMM2, the feeling is totally different, resembling something that's didn't exist in the 80's... It's something between an Amiga 1200, Atari ST, MSX Turbo R... But with an instantaneous boot with my so beloved language: BASIC.

For sure not everybody can understand this, but for many of us that had a computer in the eighties is a good hobby to develop anything on these platforms.

This is what both Colour Maximites is for me: Machines that brings me good "retro feelings"... A toy for "teenagers trapped in an old body".

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1608
 Posted: 12:12am 09 May 2020 Copy link to clipboard Print this post

Quote  I wrote this using Microsoft's. NET framework last decade. It runs best on Win XP and above. It is a 200KB+ text file for the source. It uses polymorphism, heritence and many classes. It is full-blown OOP.

Just a tad off topic. Maybe you should start a new thread?

Bill
Keep safe. Live long and prosper.

MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
 Posted: 12:51am 09 May 2020 Copy link to clipboard Print this post

Trent Jackson said  I love Java and C++. I formally studied these languages at RMIT University and scored HDs throughout.

I have in fact written several decent games using OOP in .NET Visual Basic and C#

OOP just makes sense you know. In fact I would bet that the next one Geoff does will be OOP

I gave up Windows since 2003. For me Microsoft for me dead after DOS.

I'm an old school programmer until now and don't like to use OOP, but I understand it's importance.

I made various games since DOS, using Borland Turbo C and Turbo Pascal with some assembly routines for speed up things (sprites and mode 13 VGA BIOS direct access).

Here are some images of my DOS Games using my "MXMisc" library made in assembly, when I was around 14 years old:

Zombie Arena

Crack Zone

Mario DOS

MXEdit - Sprite editor for MXMisc

MX Racer

And this is a SO developed in Turbo Pascal with inline Assembly. When I developed this I had around 18 years and was my final work for the college.

Some of these I intend to port for Colour Maximite 2, including the OS.

After I jumped to Linux, using C, C++, Python, PHP, Java, Lazarus, and others. Actually, when I develop games in Linux I use Python with PyOpenGL or PyGame and Panda3D. Maybe I upload some videos with the source codes, but one of them I can put a link here only because is a Paper Mario HD and with Nintendo no one joke. I'm started a Pacman Championship clone using Dijkstra's algorithm for ghost 5 years ago, but in the end, I turned it only in a demo for the PyOpenGL and PyGame courses that I taught to underprivileged minors.

Today retro games are only a hobby to calm my nerves, and both Colour Maximites helped me with this!

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1608
 Posted: 02:56am 09 May 2020 Copy link to clipboard Print this post

SPRITES

I've been reading the manuals and I am a little confused. The following are quotes from the manuals:

Colour Maximite 2 User Manual page 42:
The sprite can be a PNG image or an image defined in a text file and can be of any size up to the video horizontal and vertical resolution.

Colour Maximite 2 User Manual page 78:
Loads the file ‘fname\$’ which must be formatted as an original Colour Maximite sprite file. See the original Colour Maximite MMBasic Language Manual for the file format.

MMBasic Language Manual page 70:
A sprite file is similar to a font file except that it contains the definition of sprites which are 16x16 bit graphical objects. The sprite file is just a text file containing ordinary characters which are loaded line by line to build the bitmap of each sprite. Currently the dimensions of each sprite are fixed at 16x16 bits although alternative sizes may be allowed in the future.

The CMM2 manual says that a sprite can be any size and later refers to the original Colour Maximite MMBasic Language Manual which says that a sprite is fixed at 16x16 bits. If a text file sprite can be any size, or even if it is not, I think the sprite text file description should be revised if necessary and included in the new manual. I assume that text file sprites can only be 8 colours also.

Bill
Keep safe. Live long and prosper.

Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3178
 Posted: 05:42am 09 May 2020 Copy link to clipboard Print this post

Turbo46 said  SPRITES
I've been reading the manuals and I am a little confused.

This is going to require Peter to properly answer.

The development of the CMM2 was at a furious pace driven by Peter and in some places the documentation fell behind.  From my understanding a sprite file can be any size but the format of the file was as documented for the original CMM.  But, you are right, it should be properly described in the CMM2 manual (something for the next revision).

Geoff
Geoff Graham - http://geoffg.net

matherp
Guru

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

Functionality to load CMM sprite files is part of the "compatibility" capability of the CMM2 and has a couple of extensions

Sprites can be loaded from Maximite SPRITE files using SPRITE LOAD filename\$.
There is now has an optional parameter available in the first line of the sprite file.
Vertical size is implemented and need not be 16, No. of sprites as before, new parameter is the width of sprites

e.g. (a red mouse pointer)
13,1,19
4
44
4 4
4  4
4   4
4    4
4     4
4      4
4       4
4        4
4         4
4          4
4      444444
4   4  4
4  44  4
4 4  4  4
44   4  4
4  4
4444

SPRITE LOAD loads CMM1 style sprite files. This change allows you to load multiple CMM1 style sprite files by specifying the start sprite number of each file making sure they don’t overlap.

To try it, save the above as "mouse.spr"
Then:

SPRITE SHOW 5,100,100,1

Edited 2020-05-09 17:18 by matherp

Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 319
 Posted: 09:18am 09 May 2020 Copy link to clipboard Print this post

Nice Work Everyone

matherp said
I've done a single PCB version of the CMM2

There are also the gerbers, BOM and component placement files needed to get them manufactured by JLC. This is very cost effective but unfortunately they are currently out of stock of the processor which makes them manufacturing them rather pointless. They can only do surface mount on one side so you still have do solder the SDRAM and some capacitors on the bottom together with the various through-hole components.

The board can be hand-soldered if you are very confident with SMD. I've done 3 and WhiteWizzard has also completed one.

Are the Gerber files for the single PCB version available yet?  Also the solder stencil files would be nice.  I was just about to order PCB's for the version with the WaveShare module and I could add a couple of these to the order.
-Carl

Page 8 of 25