Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 04:50 27 Nov 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 : Graphics Programming on the CMM2 -v1.0e

Author Message
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1101
Posted: 11:58pm 04 Aug 2020
Copy link to clipboard 
Print this post

This update to the manual includes additional info from Peter on Quaternions and the FRAMEBUFFER command as well as a Table of Contents with clickable links to the various sections.

If you find any typos or errors, please reply to this post.

For Geoff - this updates the version you have that is included in the CMM2 release pack.

Doug.


Graphics Programming on the CMM2-v1.0E.pdf
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
fiziwig
Newbie

Joined: 09/07/2020
Location: United States
Posts: 22
Posted: 01:28am 05 Aug 2020
Copy link to clipboard 
Print this post

This is great! Thank you. Just what I've been needing.
 
capsikin
Guru

Joined: 30/06/2020
Location: Australia
Posts: 341
Posted: 02:37pm 24 Aug 2020
Copy link to clipboard 
Print this post

  panky said  
If you find any typos or errors, please reply to this post.


One bit that's now out of date:

OPTION MODES UNLOCKED is no longer required or available, from my reading of this thread
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 09:59pm 24 Aug 2020
Copy link to clipboard 
Print this post

Thanks Doug.  I have updated the release zip.
Geoff Graham - http://geoffg.net
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 07:23am 25 Aug 2020
Copy link to clipboard 
Print this post

You might like to update the test card program to cover the new modes.
 ' test card for CMM2
 ' TassyJim August 2020
 
 OPTION EXPLICIT
 OPTION DEFAULT NONE
 DIM INTEGER wd, ht, wbox, sh, x, w, n, nn, m, cd, maxMode, keepMode
 DIM FLOAT a, defaultMode
 DIM k$, imgtitle$, fname$, imgRes$
 DIM INTEGER c(8)
 c(0) = RGB(BLACK)
 c(1) = RGB(YELLOW)
 c(2) = RGB(CYAN)
 c(3) = RGB(GREEN)
 c(4) = RGB(MAGENTA)
 c(5) = RGB(RED)
 c(6) = RGB(BLUE)
 c(7) = RGB(WHITE)
 c(8) = RGB(64,64,64)
 
 maxMode = 9
 cd = 8
 a = 1
 defaultMode = MM.INFO(MODE)
 CLS
 
 DO
   IF m = 0 THEN
     MODE 1,8
     CLS
     TEXT 400,100, "Video mode test",cm,5,1
     TEXT 400,180, "Ratio = aspect ratio used in the circle command",cm,1,1
     TEXT 400,220, "Q to quit, P to save page as a BMP",cm,3,1
     TEXT 400,260, "Up Down arrow to change resolution",cm,3,1
     TEXT 400,300, "Left Right arrow to change colour depth",cm,3,1
     TEXT 400,340, "+ - to change circle aspect ratio",cm,3,1
   ELSE
     IF keepmode THEN ' only change resolution if needed
       keepmode = 0
     ELSE
       MODE m,cd
     ENDIF
     wd = MM.HRES : ht = MM.VRES
     nn = INT(wd/80)
     imgtitle$ =" MODE "+STR$(MM.INFO(MODE))+" Ratio "+STR$(a,1,3)+" "
     imgRes$ = " "+STR$(MM.HRES)+" x "+STR$(MM.VRES)+" "
     wbox = wd / 8
     PAGE WRITE 1 ' no flicker during write
     CLS
     ' primary colours
     FOR x = 0 TO 7
       BOX x*wbox,ht/4,wbox,ht/2,0,c(x), c(x)
     NEXT x
     ' full gradient for each primary colour and greyscale
     FOR x = 0 TO wd-1
       sh = 255*x/wd
       
       LINE x,0,x,ht/12,1,RGB(sh,0,0)
       LINE x,ht/12,x,ht/6,1,RGB(0,sh,0)
       LINE x,ht/6,x,ht/4,1,RGB(0,0,sh)
       
       LINE x,ht*9/12,x,ht*10/12,1,RGB(0,sh,sh)
       LINE x,ht*10/12,x,ht*11/12,1,RGB(sh,0,sh)
       LINE x,ht*11/12,x,ht,1,RGB(sh,sh,0)
       
       LINE x,ht/2,x,ht*3/4,1,RGB(sh,sh,sh) ' greyscale
     NEXT x
     ' circle to check aspect ratio
     CIRCLE wd/2,ht/2, ht*15/32,3,a,c(7)
     sh = 0
     x = wd/2 - 55*nn/2
     ' black white bars to check monitor bandwidth
     FOR w = 10 TO 1 STEP -1
       FOR n = 1 TO nn
         sh = 255 - sh
         LINE x,ht*3/8,x,ht*5/8,w,RGB(sh,sh,sh)
         x = x + w
       NEXT n
     NEXT w
     ' white and red border to check that image fits on monitor
     BOX 0,0,wd,ht,3,c(7)
     BOX 1,1,wd-2,ht-2,1,c(5)
     ' title
     IF wd > 600 THEN
       TEXT wd/2,ht/2, imgtitle$,cm,4,1
       TEXT wd/2,ht/2+25, imgRes$,cm,4,1
     ELSE
       TEXT wd/2,ht/2, imgtitle$,cm,1,1
       TEXT wd/2,ht/2+25, imgRes$,cm,1,1
     ENDIF
     ' show the new image
     PAGE COPY 1 TO 0 ,B
   ENDIF
   ' wait for keypress
   DO
     k$ = INKEY$
   LOOP UNTIL k$<>""
   '
   SELECT CASE k$
     CASE "Q","q"
       EXIT DO
     CASE "P","p"
       fname$ = MID$(imgtitle$,2)+".bmp"
       TIMER = 0
       SAVE IMAGE fname$
       PAGE WRITE 0
       TEXT wd/2,ht/2,"Saved as "+fname$+" in "+STR$(TIMER/1000,3,2)+" Sec" ,cm,1,1
       DO
         k$ = INKEY$
       LOOP UNTIL k$<>""
     CASE CHR$(128) ' up arrow
       m = m - 1
       IF m < 1 THEN m = maxMode
     CASE CHR$(129) ' down arrow
       m = m + 1
       IF m > maxMode THEN m = 1
     CASE CHR$(131) ' right arrow res up
       cd = cd + 4
       IF cd > 16 THEN cd = 8
       IF m = 9 AND cd = 12 THEN cd = 16 ' skip 12 bit for mode 9
     CASE CHR$(130) ' left arrow  res down
       cd = cd - 4
       IF cd < 8 THEN cd = 16
       IF m = 9 AND cd = 12 THEN cd = 8 ' skip 12 bit for mode 9
     CASE "+" ' ratio plus
       IF a < 1.4 THEN a = a + 0.01
       keepmode = 1
     CASE "-" ' ratio minus
       IF a > 0.75 THEN a = a - 0.01
       keepmode = 1
     CASE ELSE ' same as down arrow
       m = m + 1
       IF m > maxMode THEN m = 1
   END SELECT
 LOOP
 setmode defaultMode ' restore original mode before ending program
 PAGE WRITE 0
 CLS
 
END
 
SUB setmode dotMode AS FLOAT
 LOCAL INTEGER mm, md
 ' use float returned by mm.info(mode) to set MODE
 mm = INT(dotmode)
 md = (dotmode - mm)*100
 IF md > 20 THEN md = md/10
 MODE mm, md
END SUB
 


Jim
VK7JH
MMedit   MMBasic Help
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 847
Posted: 03:47am 07 Sep 2020
Copy link to clipboard 
Print this post

Hi Doug,
a great idea, and effort, to immortalise Peter's words into a document and great to have it as part of the documentation.
One suggestion if I may? Can you possibly omit the word "Page" (or use "Pge") from the footer of future versions. This would make searching for "PAGE" sooooo much easier.
Thanks again,

Andrew
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1101
Posted: 04:00am 07 Sep 2020
Copy link to clipboard 
Print this post

Thanks Jim and Andrew,

I am working on the 5.05.05 version now and will incorporate your inputs.

Doug.
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
chris
Regular Member

Joined: 24/08/2020
Location: United Kingdom
Posts: 56
Posted: 09:22am 07 Sep 2020
Copy link to clipboard 
Print this post

What is the difference between the FRAMEBUFFER and pages. Naively, I thought pages were the abstraction of the FRAMEBUFFER (make changes on page 1, blit to page 0).

For example, in the "Graphics Programming on the CMM2 PDF", there is a snippet of code that refers to pages as framebuffers.


'clear the first three framebuffers (pages)


I am not at all a proficient graphics programmer, and this is my very first rodeo, so if someone could explain in simple language what to use PAGE 0, FRAMEBUFFER, and PAGE 1 .. n for then it would be much appreciated.

I think PAGE 0 is special and it is the the page that is asynchronously rendered to the screen so if you are writing during a screen refresh then you have glitches, so I just assumed that you prepare your frame in one of the other pages, then blit it to page zero on an interrupt.

I really really don't know what I'm doing, so please be kind.
 
Nimue

Guru

Joined: 06/08/2020
Location: United Kingdom
Posts: 367
Posted: 09:56am 07 Sep 2020
Copy link to clipboard 
Print this post

  chris said  What is the difference between the FRAMEBUFFER and pages. Naively, I thought pages were the abstraction of the FRAMEBUFFER (make changes on page 1, blit to page 0).

For example, in the "Graphics Programming on the CMM2 PDF", there is a snippet of code that refers to pages as framebuffers.


'clear the first three framebuffers (pages)


I am not at all a proficient graphics programmer, and this is my very first rodeo, so if someone could explain in simple language what to use PAGE 0, FRAMEBUFFER, and PAGE 1 .. n for then it would be much appreciated.

I think PAGE 0 is special and it is the the page that is asynchronously rendered to the screen so if you are writing during a screen refresh then you have glitches, so I just assumed that you prepare your frame in one of the other pages, then blit it to page zero on an interrupt.

I really really don't know what I'm doing, so please be kind.


Oh my -- you asked the question I wanted to, but felt I should already know the answer to.   Q:  Is there an "essential" guide to this (probably from the 1980's) that is worth a read?
Entropy is not what it used to be
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9120
Posted: 10:45am 07 Sep 2020
Copy link to clipboard 
Print this post

The graphics guide was written before the "framebuffer" was included in the firmware. Pages are 1:1 memory areas that are the equivalent size to what is displayed on the monitor so you can copy one page to another with PAGE COPY. Video pages use dedicated RAM out of a pool of 3.5Mbytes.

The framebuffer is an area of memory that can be up to 1600x1200 pixels in size irrespective of the current mode. The memory for the framebuffer is taken from the 5Mb of variable memory.

Rather than PAGE COPY you use FRAMEBUFFER WINDOW to move data from the framebuffer to main memory. This allows you to have a playing field bigger than the display and window what is displayed on the screen to different part of the field with a single command.
There are other things you can do with the framebuffer as detailed in the manual (check out BACKUP and RESTORE).

An simple example of using the framebuffer is shown here

This a concept I created for the CMM2 so you won't find it documented elsewhere
Edited 2020-09-07 20:46 by matherp
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1101
Posted: 03:55am 09 Sep 2020
Copy link to clipboard 
Print this post

I have updated the Graphics Programming manual to version 2.0a to include the new features from MMBasic 5.05.05.

I have also added an introductory section on colour - I am sure I will get a sharpish rap on the knuckles from Peter if there are errors or omissions    


Graphics Programming on the CMM2-v2.0a.pdf

Please do not hesitate to let me know of any errors, omissions or suggestions for improvement.

Doug.
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 04:48am 09 Sep 2020
Copy link to clipboard 
Print this post

Updated the CMM2 download (https://geoffg.net/Downloads/Maximite/Colour_Maximite_2_MMBasic.zip ).
Thanks.

Geoff
Geoff Graham - http://geoffg.net
 
Print this page


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

© JAQ Software 2024