![]() |
Forum Index : Microcontroller and PC projects : CMM2: Am I misunderstanding MAP?
Author | Message | ||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7937 |
I can see that it's a way to map colours into 8-bit mode, but is there anything to gain over simply having colours in an array. e.g. col(2)=rgb(255,0,0) then using col(2) as the colour? I feel like I must be missing something. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
In 8-bit mode there are 256 colours available which I have setup using a RGB332 approach (3 bits red, 3 bits green, 2 bits blue). Say you wanted a greyscale image, you could use map to create a full set of 256 grey shades. |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7937 |
Ah, so you can use MAP(700) meaning 7 red, 0 green, 0 blue in RGB332, but it might act as RGB(0,255,0) or whatever. The actual number in MAP() is meaningless as a colour, it's simply an 8-bit pointer. I hadn't grasped that... Thanks. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1593 |
Hi Mixtel90, I would think the Mandelbrot code is a good example. Regards Michael causality ≠ correlation ≠ coincidence |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Or try this one: ' Set up an array to hold the colour mappings we are going to use DIM INTEGER cmap(6) 'Clear the screen CLS 'Set up 6 colours in the array cmap(1)=RGB(RED) cmap(2)=RGB(GREEN) cmap(3)=RGB(BLUE) cmap(4)=RGB(YELLOW) cmap(5)=RGB(MAGENTA) cmap(6)=RGB(CYAN) ' Do an initial update of the CLUT to set up our colours mapclut 'Display an outer circle in white CIRCLE MM.HRES/2,MM.VRES/2,MM.VRES/2-1,0,,RGB(WHITE),RGB(WHITE) ' Now draw a simple colour pie chart using our new colours with the ARC command ARC MM.HRES/2,MM.VRES/2,0,MM.VRES/2-10,0,60,MAP(1) ARC MM.HRES/2,MM.VRES/2,0,MM.VRES/2-10,60,120,MAP(2) ARC MM.HRES/2,MM.VRES/2,0,MM.VRES/2-10,120,180,MAP(3) ARC MM.HRES/2,MM.VRES/2,0,MM.VRES/2-10,180,240,MAP(4) ARC MM.HRES/2,MM.VRES/2,0,MM.VRES/2-10,240,300,MAP(5) ARC MM.HRES/2,MM.VRES/2,0,MM.VRES/2-10,300,360,MAP(6) ' Start a never ending loop DO ' each time round the loop move the colours in our array one place to the left ' Use array element 0 to store the first element that is going to be at the end cmap(0)=cmap(1) cmap(1)=cmap(2) cmap(2)=cmap(3) cmap(3)=cmap(4) cmap(4)=cmap(5) cmap(5)=cmap(6) cmap(6)=cmap(0) ' reset the colour map mapclut ' pause so we can see the change PAUSE 200 LOOP ' This subroutine updates the colour map for the colours we are using ' set map positions 1 to 6 to the new colours ' then apply the change SUB mapclut MAP(1)=cmap(1) MAP(2)=cmap(2) MAP(3)=cmap(3) MAP(4)=cmap(4) MAP(5)=cmap(5) MAP(6)=cmap(6) MAP set END SUB Map allows you to draw a screen then change all the instances of one colour to something different 'instantly' Jim VK7JH MMedit |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |