Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 12:49 19 Apr 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 : Colour MM Mode 4 video tricks overscan and extra colours!

Author Message
ceptimus
Senior Member

Joined: 05/07/2019
Location: United Kingdom
Posts: 130
Posted: 03:29pm 14 Aug 2019
Copy link to clipboard 
Print this post

While playing with my Colour Maximite, experimenting with pokes to the video RAM, I found some arcane effects that might actually be useful!

In Mode 4 (240 x 216 pixel, eight colours) the RVIDEO, GVIDEO, and BVIDEO buffers are laid out in a slightly strange order.  Most of this is just down to the PIC32 chip storing data as 32-bit integers in little endian format, but there are six bytes per raster (horizontal row of pixels) that aren't normally displayed on the screen at all.

So if we want to poke, say a red pixel to the top left hand corner of the screen, we do:
Mode 4
Cls
Poke RVIDEO,1,128

128 is the most significant (leftmost) pixel in the byte and we're poking to an offset of one (why? See below!).  If we want to turn the first 8 pixels red, we do:
Poke RVIDEO,1,255

But why an offset of one?  Why not zero?  Let's try it and see:
Cls:Poke RVIDEO,0,255

Now we see that pixels at locations 8 to 15 are red!

Now we skip offsets 2 and 3 (more later) and try offset 7 - this turns the next eight pixels 16 to 23 red.  The layout of offsets for the top row goes:
1 0 7 6 5 4 11 10 9 8 15 14 13 12 ...  27 26 25 24 31 30 29 28

...and the second row of offsets begins:
37 36 43 42 41 40 ...
...where each offset is just 36 greater than for the row of pixels directly above.

The green and blue video buffers, GVIDEO and BVIDEO work just the same.

So what about the unused offsets of 2,3,32,33,34,35 for the first row, and a similar group of 6 offsets for each subsequent row? This is where it gets interesting.

Disclaimer: I've tried this on several different LCD monitors and an old-school CRT monitor, all with no ill-effects, and I don't see how it could possibly damage the Maximite, but proceed at your own risk!  If you get stuck with a blank screen then Cls followed by enter should restore things (or Ctrl-C, Cls enter if a program is still running).

If we poke the least significant bit at offsets 2,38,74,... we can switch on an extra column of pixels not normally visible on the screen. To prove it, let's draw a blue vertical line down the extreme left edge of the screen using the normal MMBasic graphics command and then add a column of red pixels with a screen y-value of -1

In Mode 4, typing in a "for, poke, next" line is wider than the screen, so use the editor to type in this short program:

Mode 4:Cls
Line(0,0)-(0,215),1
Pause 1000
B=1
For i=2 To 7742 Step 36
 Poke RVIDEO,i,B
Next

...and you should see the magic!

On my old CRT monitor, I can get a whole extra sixteen pixels at locations -15 to -1 this way.  Try changing B=1 to B=170 and see what you get (170 in binary is 10101010 so gives an alternating on-off pixel pattern)... But it doesn't work on my LCD monitors, the second off-screen pixel (B=2) gives a faint grey line, and the next 6 don't do anything.

Only if you can see the 10101010 pattern, then alter the for loop to for i=3 to 7743 Step 36 and see if you can get pixels -15 to -8 working.

Now, what happens on an LCD monitor is even more interesting:  setting bits 0, 1, 2, 3 of the bytes at offsets 3,39,75, ... progressively dims the colour for the video buffer (red, green, or blue) that we're poking.  So if we have white text on the screen, we can poke the RVIDEO buffer to progressively change the text towards cyan, or the BVIDEO buffer to change it towards yellow, and so on.  Poking all three video buffers lets us do some fancy colour cycling using normally impossible colours for a Maximite, or a "fade to grey" effect.

It's a bit long to type in so I've attached a demo program if you want to try it.

FADE.zip

If you do try the above pokes and the demo program, please report back what you see (if anything).  Remember, I accept no liability if you blow up your monitor (but I don't think that will happen).  
Edited 2019-08-15 01:37 by ceptimus
 
MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
Posted: 01:44am 15 Aug 2019
Copy link to clipboard 
Print this post

Unfortunately doesn't worked in my old AOC 17" 4:3 LCD monitor... I don't saw any effect, only a bit of granulation.

Snif ... I had so much hope that it could give an additional level of brightness like a ZX Spectrum.
 
ceptimus
Senior Member

Joined: 05/07/2019
Location: United Kingdom
Posts: 130
Posted: 09:17am 15 Aug 2019
Copy link to clipboard 
Print this post

Thanks for trying it and reporting back.  Here's what it looks like on one of my monitors - an acer KA220HQ.  https://youtu.be/fLmJ44u5JBo
 
MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
Posted: 10:49am 15 Aug 2019
Copy link to clipboard 
Print this post

What wonderful effect! Would so cool if it worked in any monitor, it would open great possibilities...
 
Print this page


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

© JAQ Software 2024