CMM2 graphics questions
| Author | Message | ||||
| LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 582 |
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 |
||||