|
Forum Index : Microcontroller and PC projects : CMM2 graphics questions
| Author | Message | ||||
| Macer_D Newbie Joined: 25/04/2026 Location: United KingdomPosts: 5 |
Hi all, thank you for your responses to my questions about the paint program. I have two more questions I would like to ask with regards to the CMM2. Firstly, is there an extension for a PC paint program like libresprite or gimp that would allow me to draw using the 12 bit rgba scheme that is on the CMM2? And secondly, how do sprites work on the CMM2? Is there a good resource for that I could consult? Thank you. |
||||
| LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 577 |
The CMM2 user manual has detailed explanation about sprites and other commands and functions. https://geoffg.net/Downloads/Maximite/Colour_Maximite_2_User_Manual.pdf The CMM2 graphics manual expands this material. 2021-04-05_114624_Graphics Programming on the CMM2-v3f.pdf Usually I edit my images on Gimp and export them as PNG selecting the appropriate pixel format |
||||
| hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 188 |
Earlier I posted questions about my paint program on my cmm2 (gen2). I hope, the questions are no to silly or annoying. this is a link to youtube with 4 of my movies that show the screen memory error. https://www.youtube.com/@heinrichhubbert8474 or to the movies... this is the basic sourcecode 2026-04-27_215913_hg.bas.zip is it my bug or what is the reason for the memory/screen mistakes? perhaps you or disco4now could read this. many thanks. Edited 2026-05-04 20:50 by hhtg1968 |
||||
| LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 577 |
I can try to figure out what is happening. I will reply black to you soon |
||||
| PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 1893 |
I experienced similar Reported here But I found that a different resolution was better for my needs and the flicker didn't occur. |
||||
| disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 1121 |
That would be good. I previously ran the code and can see the artifacts he is seeing. I did not really get anywhere to resolve it. There is a memory leak with CURSOR ON/OFF that is fixed in latest CMM2 betas. I was suspicious that the GUI controls and the drawing code where both trying to update the cursor. Edited 2026-05-05 09:37 by disco4now F4 H7FotSF4xGT |
||||
| hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 188 |
i wait with tension... i think that disco4now could be right with his thought... |
||||
| LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 577 |
I only can work on it on the weekend. I'm curious to know what is causing the issue. Are you using double buffer? |
||||
| hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 188 |
double buffer? |
||||
| LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 577 |
Yes You can draw the elements on a memory page and blit them to page 0 or 1 depending on the screen mode you are using. This technique removes the flickering From my game Knightmare: page write 0 blit 0,TILE_SIZEx2, SCREEN_OFFSET,0, SCREEN_WIDTH,SCREEN_HEIGHT, SCREEN_BUFFER page write 1 blit 0,TILE_SIZEx2, SCREEN_OFFSET,0, SCREEN_WIDTH,SCREEN_HEIGHT, SPRITES_BUFFER In my case, it's a little more complex because I have a ton of sprites moving, and they were creating a lot of artifacts. I decided to use the two visible pages (zero and one) to render the screen elements and the sprites. I compose the frame in memory, by using two non visible pages, and I blit these two memory pages to the page 0 and 1, that are visible. |
||||
| hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 188 |
I think I will need some time to follow your thoughts... do you (LeoNicolas) know the reason for the artefacts? |
||||
| LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 577 |
I made some changes. It looks good. Let me know if it is working for you hg.bas.zip |
||||
| hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 188 |
many thanks... i think i can test it in a few days... |
||||
| hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 188 |
@LeoNicolas: my first check of the changed code (without running): gui commands are not used (only gui cursor...). perhaps this is the solution... i will "create" the graphical menus "by hand". so i did it on other systems (i have a self constructed and built z80-system (8bit 64k ram!) with my own operatings system). the mmbasic gui system leads to run some code in the backround with refreshing the menu texts or objects and so on. so i thounght earlier that this could lead to errors, because i do not exactly know what the gui commands do... many thanks... |
||||
| LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 577 |
I didn't change anything regarding commands or gui. My updates were only on the render logic, creating a double buffering and removing flickering and artifacts. I drew lines, circles and rectangles and I didn't see any artifacts or flickering. Let me know if you had the same result when running the modified code on you machine. |
||||
| hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 188 |
yes and many thanks again. one question do you know the reason for the flickering? is there an issue in the gui commands? |
||||
| LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 577 |
It is not an issue with the gui commands. It happens because you were drawing directly to the page 0, which is the screen buffer. The screen buffer is the chunk of memory constantly read by the hardware to render screen. I think these are the causes: Scanning Out of Sync: The display hardware refreshes the screen many times per second (usually 60Hz). It reads the memory line-by-line. If your MMBasic code is halfway through drawing a large circle while the hardware is scanning that same area, the monitor will display half of the old frame and half of the new one. This causes artifacts, specially with moving objects, and flickering Slow Execution: MMBasic is an interpreted language. While fast, it isn't fast enough to update thousands of pixels in the tiny window of time between screen refreshes. Flicker: If you CLS (clear screen) and then draw your objects on Page 0, there will be a brief moment where the screen is blank. The hardware often catches this blank state, resulting in a persistent, annoying flicker. Some solutions 1) Draw everything you need for a frame in another page (page 2 or 3, etc), and blit it to the page 0 during the video blanking period using PAGE COPY (see PAGE COPY n TO m [,when] [,t] in the manual, specially the when parameter) 2) Use FRAMEBUFFER: FRAMEBUFFER WINDOW x,y, page [,I or B], where the B parameters forces the copy only during video blanking From the MMBasic manual: VGA Resolution, Colour Depth and Pages The video output to the VGA monitor is controlled by the MODE command. With this you can select various resolutions from 1280x720, 800x600 pixels (the normal default on startup) to 240x216 and various colour depths from 16-bits to 8-bits. For the 8-bit colour mode each individual colour can be specified from a 16-bit pallet using the MAP command. Particularly useful is the 12-bit colour mode which supports 4096 colours with an additional 4-bit alpha channel allowing 16 levels of transparency. This mode has provision for two image layers plus a background colour. Images on the top layer will cover the lower layer except where the alpha channel is set to allow transparency thereby allowing various degrees of the lower layer and/or background to show through. In addition there are many extra video pages that are available to the programmer for building images. These pages can then be copied at high speed during the video blanking period to the main display page providing an instantaneous display update without any tearing artefacts. This is managed by the PAGE WRITE command which specifies the video page to be used for the output of subsequent graphics commands and the PAGE COPY command which will copy one page to another. When drawing to the main page being displayed on the monitor the programmer can use the GETSCANLINE function to report on the line that is currently being drawn on the VGA monitor. Using this to time updates to the screen can avoid screen glitches caused by updates while the screen is being updated. A similar outcome can be achieved using an optional feature of the MODE command which will call a user defined subroutine at the start of the VGA frame blanking. This and other features of the graphics subsystem are explained in detail in a tutorial presented on the BackShed forum: https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=12125 . A PDF version is included in the Colour Maximite 2 firmware zip file. ps: the 12 bits pixel depth uses page 0 and page 1 as screen buffer. Check the MMBasic Graphics manual |
||||
| hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 188 |
@ LeoNicolas: many many thanks for your energy to help me. you wrote: "Scanning Out of Sync: The display hardware refreshes the screen many times per second (usually 60Hz). It reads the memory line-by-line. If your MMBasic code is halfway through drawing a large circle while the hardware is scanning that same area, the monitor will display half of the old frame and half of the new one. This causes artifacts, specially with moving objects, and flickering Slow Execution: MMBasic is an interpreted language. While fast, it isn't fast enough to update thousands of pixels in the tiny window of time between screen refreshes." yes and ok. in this situation i comprehend mistakes of reading and showing screen memory content; i do not understand (until now) that there remain "wrong bytes" in the screen memory because the systems routine that "give" the data to the vga output only reads (from screen memory) so the screen memory content must be (or stay) correct after a while. but i will think further and again. your solution in my program does not flicker. so i will go this way and test. again: many many thanks. until now i do not read your text completely but i hope to have time during the next week end. |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |