Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 01:13 29 Mar 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 : Mazist - my first forray into CMM2 basic

Author Message
Goksteroo
Senior Member

Joined: 15/03/2021
Location: Australia
Posts: 110
Posted: 03:03pm 13 Apr 2021
Copy link to clipboard 
Print this post

MAZIST v0.9 - A maze generation and solving programme for the CMM2

I originally wrote a maze generation programme on the Atari ST. It was also based on David Ahl's routines in 'More Basic Computer Games' but modified to be graphically based and mouse controlled. I used STOS - a beautiful Basic language with easy music & sprite routines built in - to write that and it was released as shareware under the Undersoft label.

Before I had the Atari I had an Amstrad 464, and later a 6128. Loved these machines and programmed quite a bit in basic and taught myself some z80 machine code as well. In 2020 I was looking for something to stimulate my retired brain so I re-wrote the program in Amstrad basic but it was painfully slow - 5 minutes for a 69x49 maze. So I got my mind exercise by converting the basic to z80 machine code and a this version was released as Masist2 on the CPC.

I heard about the CMM2 on 8Bit Guy's You Tube channel and it looked very interesting and in March this year I finally brought one. My first instinct was to write a program I'm familiar with but with more bells and whistles - hence a maze program based on David Ahl's routines. It's been a good exercise in introducing me to the CMM2 and its version of basic.

This version is not finished! It certainly is functional for what it is meant to do but there is more work to do. I should add more sound and/or music, maybe more graphic bells and whistles, and I need to fully utilize CMM2's Basic commands in the Maze routines as they are pretty old school, but they work. This just seemed a like a longer term job now that I have a working program.

On the good size... mazes can be from 10x10 to 99x69 and are generated very quickly. The solve routines also run very quickly. Up to 9 mazes can be saved for later solving. Trails can be marked on the maze and these are saved with your saved maze as a means to aid solving a maze in several sessions.

A maze solve routine will step through the maze and find the only solution if you are stuck.

Enjoy, and feel free to send any advice, hints, criticisms my way - I have broad shoulders and am a learner as far as modern Basic goes.

Geoff
mazist.zip
 
bar1010
Senior Member

Joined: 10/08/2020
Location: United States
Posts: 195
Posted: 07:23pm 13 Apr 2021
Copy link to clipboard 
Print this post

  Goksteroo said  MAZIST v0.9 - A maze generation and solving programme for the CMM2

I originally wrote a maze generation programme on the Atari ST. It was also based on David Ahl's routines in 'More Basic Computer Games' but modified to be graphically based and mouse controlled. I used STOS - a beautiful Basic language with easy music & sprite routines built in - to write that and it was released as shareware under the Undersoft label.

Before I had the Atari I had an Amstrad 464, and later a 6128. Loved these machines and programmed quite a bit in basic and taught myself some z80 machine code as well. In 2020 I was looking for something to stimulate my retired brain so I re-wrote the program in Amstrad basic but it was painfully slow - 5 minutes for a 69x49 maze. So I got my mind exercise by converting the basic to z80 machine code and a this version was released as Masist2 on the CPC.

I heard about the CMM2 on 8Bit Guy's You Tube channel and it looked very interesting and in March this year I finally brought one. My first instinct was to write a program I'm familiar with but with more bells and whistles - hence a maze program based on David Ahl's routines. It's been a good exercise in introducing me to the CMM2 and its version of basic.

This version is not finished! It certainly is functional for what it is meant to do but there is more work to do. I should add more sound and/or music, maybe more graphic bells and whistles, and I need to fully utilize CMM2's Basic commands in the Maze routines as they are pretty old school, but they work. This just seemed a like a longer term job now that I have a working program.

On the good size... mazes can be from 10x10 to 99x69 and are generated very quickly. The solve routines also run very quickly. Up to 9 mazes can be saved for later solving. Trails can be marked on the maze and these are saved with your saved maze as a means to aid solving a maze in several sessions.

A maze solve routine will step through the maze and find the only solution if you are stuck.

Enjoy, and feel free to send any advice, hints, criticisms my way - I have broad shoulders and am a learner as far as modern Basic goes.

Geoff
mazist.zip


This is a nice game.
It is a little bit difficult to see as the passageways are quite small, although a lot of maze can be
displayed on screen.  A zoom in/out option would be interesting.  Would like to see an option to create mazes which span multiple screens.  Multi-level mazes with up and down ladders is another idea.
The ability to navigate the maze in 3D would be a pleasant addition.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 2989
Posted: 02:16am 15 Apr 2021
Copy link to clipboard 
Print this post

This looks very interesting. Is there a way to make it work from the PC keyboard? I'm not generally where my VGA monitor and USB keyboard are, so I use the CMM2 plugged into a laptop with the power and serial console, and a VGA-to-HDMI-to-USB3 hookup for video on my laptop with Windows Camera.

From the laptop, I can browse the files and start the program, but then it's unresponsive to the laptop keyboard (unless I'm just not understanding, which is quite possible).
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5867
Posted: 02:28am 15 Apr 2021
Copy link to clipboard 
Print this post

  lizby said  
From the laptop, I can browse the files and start the program, but then it's unresponsive to the laptop keyboard (unless I'm just not understanding, which is quite possible).

The program uses KEYDOWN() to read the keyboard and that only works for an attached keyboard so no go from the PC

Jim
VK7JH
MMedit   MMBasic Help
 
Goksteroo
Senior Member

Joined: 15/03/2021
Location: Australia
Posts: 110
Posted: 11:46am 15 Apr 2021
Copy link to clipboard 
Print this post

Thanks for the feedback. Didn't even think about a zoom as I use a 27" monitor.
A zoom function shouldn't be that difficult to implement - it's a matter of what type of zoom to use.

  Quote  The program uses KEYDOWN() to read the keyboard and that only works for an attached keyboard so no go from the PC

So if I used INKEY$ instead it would work with any keyboard?

Geoff
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3807
Posted: 11:58am 15 Apr 2021
Copy link to clipboard 
Print this post

  Goksteroo said  So if I used INKEY$ instead it would work with any keyboard?


Yes.

KEYDOWN is more flexible but will only read from a USB keyboard directly attached to the CMM2 (or a suitable Wireless USB keyboard).

INKEY$ will in addition read from the serial console input, but can't handle multiple simultaneous keypresses (except obvious things like Shift).

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

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1081
Posted: 04:26pm 15 Apr 2021
Copy link to clipboard 
Print this post

Nicely polished program!

If you were feeling really enterprising, a zoom as in the old Apple // game Dung Beetles would look cool.

Also, could the solver optionally be slowed down and made visual so we can watch it explore its way to the solution?
Visit Vegipete's *Mite Library for cool programs.
 
bar1010
Senior Member

Joined: 10/08/2020
Location: United States
Posts: 195
Posted: 10:22pm 19 Apr 2021
Copy link to clipboard 
Print this post

 
Goksteroo
Senior Member

Joined: 15/03/2021
Location: Australia
Posts: 110
Posted: 11:34pm 22 Apr 2021
Copy link to clipboard 
Print this post

I've now added a zoom mode that can be turned on/off as needed. Also changed the Mouse Solve routine where you can either watch the 'mouse' find its way through the maze or just get the solution as currently used. Just got some code tidying up to do and to make sure new code hasn't messed anything up. I'll post the update soon.
Geoff
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 2989
Posted: 02:33pm 23 Apr 2021
Copy link to clipboard 
Print this post

  Goksteroo said  I've now added a zoom mode that can be turned on/off as needed. Also changed the Mouse Solve routine where you can either watch the 'mouse' find its way through the maze or just get the solution as currently used. Just got some code tidying up to do and to make sure new code hasn't messed anything up. I'll post the update soon.

Looking forward to it. Unfortunately, what it means is that I have made a fork with the code I'm uploading here. What this does is

1) allow control on the CMM2 with either plugged-in keyboard or the PC console

2) allow it to run on the Armmite F4 with the IPS/OTM8009A 800*480 LCD.

3) allow changing of the "node" size from 4 to 4, 6, or 8. The node size is the size of the square block of pixels making up one of the two node types--barrier (green) or pathway (black).

Here's what it looks like on the F4:


An 8-pixel node size version--selection screen and solved:




6-pixel node size version--selection screen and solved:


"


4-pixel node size version--selection screen and solved:





The trickiest part of the port was incorporating the node size (variable sz) into the x and y coordinates for each drawing of a node.

For making the program work on the F4 and on the CMM2 with either keyboard or PC console, I replaced all the KEYDOWN functions with _KEYDOWN and provided a FUNCTION _KEYDOWN which looks for the Escape sequence for arrows and pgup/pgdn which the console and F4 use. I didn't implement ALT+(arrow) or CTRL+(arrow).

One happy discovery was that the MAP function available on the CMM2 could, for most uses in this program, be replace with an array named "map" on the F4, with no changes to syntax for most CMM2 map commands. For instance, "Colour map(cLtGreen)" works perfectly well on the F4 when map() is an array.

This does mean, however, the cool color flashing with MAP on the CMM2 signaling success is not available on the F4--where all the pixels would have to be redrawn--on the CMM2, the  VGA refresh provides the magic with MAP.

GUI CURSOR is not available on the F4, but is easily replaced with "box sx,sy,sZ,sz,,rgb(red),rgb(red)" (or black). No GUI CURSOR magic is used in this program, so if compatibility with other micromites is desired, it should be replaced with the box command.

"PRINT @" is not available on the F4, so I had to provide alternatives with TEXT. If PRINT @ were implemented on the F4, it would have to imply print to the LCD, not to the TeraTerm (or other) console, so possibly not worth the hassle.

I briefly backtested without encountering errors on the CMM2 with VGA-to-HDMI-to-USB3 on my PC.

This was a fun project, and more complicated than I had imagined. Hope the forking doesn't cause too much grief.

Zipped program and BMPs attached. Hope I didn't omit anything.

mazist_F4.zip

F4 on FruitOfTheShed
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3641
Posted: 03:43pm 23 Apr 2021
Copy link to clipboard 
Print this post

  lizby said  F4 on FruitOfTheShed

Looks to be an odd thing on that FOTS page: it correctly points to a VET6 F4 but the page shows it as a VGT6.

John
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 2989
Posted: 03:59pm 23 Apr 2021
Copy link to clipboard 
Print this post

  JohnS said  [Looks to be an odd thing on that FOTS page: it correctly points to a VET6 F4 but the page shows it as a VGT6.

Fixed now, if I understood what you meant.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3641
Posted: 05:52pm 23 Apr 2021
Copy link to clipboard 
Print this post

Yes, looks OK now, thanks.

John
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1081
Posted: 06:28pm 24 Apr 2021
Copy link to clipboard 
Print this post

I decided to convert my One-Page-Wonder contest entry into 3D maze engine.
Here is the result.
The engine is intended for mazes that are only passages - rooms won't render very sensibly. Also, wall and passage segments are equal sized. Think of the maze as solid packed level of cubes (the walls) with cubes removed to form the passages.

The zip contains two extra files from Geoff's (Goksteroo's) original:

ME3D_00.inc
MazistPF00.bas

The *.inc file contains the engine itself. Three routines are of particular interest.
This file should be #INCLUDEd early as it DIM's a bunch of variable.
"vp3d_init" initializes some stuff and should be called early.
"vp3d_visit" actual serves up the maze, handles player actions and returns when the exit is reached.
"vp3d_ReadMaze" is at the end of the *.inc file and serves to translate the maze from the calling program's format to the format used internally. This routine is called internally only. Change this as required for your own projects.

"MazistPF00.bas" is Geoff's original program with 3 lines added for the 3D engine:
lines 8, 70 and 226. (I don't think I did anything else.)

The maze can contain items of interest. A single item is included to show the format, although it isn't actually placed in the maze. Also, there is a timer based stub, which could be used make items move or change or whatever. These features likely require more documentation...
Visit Vegipete's *Mite Library for cool programs.
 
Goksteroo
Senior Member

Joined: 15/03/2021
Location: Australia
Posts: 110
Posted: 01:39am 25 Apr 2021
Copy link to clipboard 
Print this post

Lizby and Vegipete.... wow guys - I'm impressed with the work you've done with my little program.

Lizby - I have no knowledge of the Armmite F4 and its Basic and its features or limitations. The new Zoom function uses the FrameBuffer to hold a double sized maze that is blitted to the main screen so I'm not sure if that can be easily converted. I've just had to deal with how to display the areas blitted from off the FrameBuffer (eg origin is negative or x>1600 or y<1200) smoothly and not transparent - my solution works so now I need to tidy up the code (I'm an old school Basic programmer and my programming method seems to be... get it working first, then make it 'tidy', then make it MM Basic efficient/friendly).

Vegipete - very, very nice routine. I can see this developing into a different game altogether using the 3D routine along with a randomly generated maze. Dungeon maze type game with monsters and treasures, etc, etc. My only negative comment would be... it'd take me days and a ton of coffee and/or valium to wander around a 99x69 maze to find the exit!! Could the walls be made shorter and more of the maze drawn in the distant to give some clues as to the mazes structure, or an 2D plan of the area immediately around the player be displayed?

Geoff
 
Goksteroo
Senior Member

Joined: 15/03/2021
Location: Australia
Posts: 110
Posted: 01:59pm 26 Apr 2021
Copy link to clipboard 
Print this post

Here is the latest version of Mazist - v0.99

New functions:

Zoom Mode - an area around the player's position in the maze is zoomed in (double size) for those with small monitors/poor eyesight/are kids. Press Z to turn zoom on/off during a maze save. I've done this by using the framebuffer to hold a double sized maze and blit an area around the player to the display page.

Mouse Solve - can now be as fast [F] or with Mouse Movements during the solve [M]. The speed of mouse solve is controlled with the MouseSpeed constant and is reasonably long so the mouse movements can be seen. If taking too long, quit to fast mode by pressing [Q].

Enjoy

mazist.zip
 
Print this page


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

© JAQ Software 2024