Author Topic: Flickerless Grayscale  (Read 11171 times)

0 Members and 1 Guest are viewing this topic.

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Flickerless Grayscale
« on: May 17, 2010, 01:32:34 pm »
I don't think I'll end up using flickerless grayscale, but what's the idea behind it?  I'm used to the idea of flicker, so I'm curious as to how flickerless is accomplished on the Ti-83+.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Flickerless Grayscale
« Reply #1 on: May 17, 2010, 02:08:59 pm »
Let me use the 3 level grayscale example.

For example you got the following sprite:

Code: [Select]
BBBBBBBB
BBBBBBBB
BBBBBBBB
GGGGGGGG
GGGGGGGG
GGGGGGGG
WWWWWWWW
WWWWWWWW

B=black, G=gray, W=white. For the Gs you would quickly swap them back and forth from white to black. However, because the 83+ LCD is not memory-mapped, flickering will occur. However, what we generally do is make the G part a checkered pattern that is inverted rapidly. An optical illusion will cause our eyes to not notice as much flicker. The flicker will happen, but you'll see some sort of checkered gray pattern that doesn't seems to flicker as much instead, even if each pixel really flickers as much.

For 4 level grayscale, instead of checkered patterns some sort of scanlines needs to be used, and in ASM there's another method involving interlacing

Here's an example screenshot attachment of 3 level grayscale with the LCD blurring eliminated completly
« Last Edit: May 17, 2010, 02:22:21 pm by DJ Omnimaga »
Dream of Omnimaga

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: Flickerless Grayscale
« Reply #2 on: May 17, 2010, 02:22:13 pm »
Making DJ text a little more visual, alternating
10101010
and
01010101
produces greyish to our eyes if is alternated fast enough.
EDIT: DJ shows a screen shot...

For 4 level grayscale the patterns used are:
 .db %11111111
 .db %11111111
 .db %00000000
 .db %11111111
or
 .db %11011011
 .db %10110110
 .db %01101101
 .db %11011011

The first looks better, I think, with scrolling. The second with more still images.
« Last Edit: May 17, 2010, 02:29:45 pm by Galandros »
Hobbing in calculator projects.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Flickerless Grayscale
« Reply #3 on: May 17, 2010, 02:37:41 pm »
Actually, the 4 level grayscale is this pattern:

11011010
10110101
01101011
11010110
10101101
01011011
10110110
01101101

In the one you posted, there are the same number of 0s as 1s in the 3rd and 6th columns making those pixels medium gray instead of dark gray.  This pattern can also be inverted bitwise for light gray.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: Flickerless Grayscale
« Reply #4 on: May 17, 2010, 02:48:47 pm »
I just shamelessly copied of James Montelongo graylib2.inc.

Wow, I can now see how the scanlines are done. :o


Interleaving can be used in assembly to easily access the dark and light layer of 8 pixels quickly before copying to the LCD. It achieves better speed but you have to change your sprites routines and data.
Hobbing in calculator projects.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Flickerless Grayscale
« Reply #5 on: May 25, 2010, 10:40:01 pm »
In any case, never use vertical or horizontal scanlines for grayscale. Firetrack2 by Benryves does the former, and the flicker is really noticeable.
Dream of Omnimaga

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: Flickerless Grayscale
« Reply #6 on: May 26, 2010, 06:58:04 am »
The idea with interlacing is that in 1 byte you can show 75% of the data from the dark layer, and 25% of the light layer at the same time. So instead of showing 1 layer then the other, you can mix them into the same LCD update, which helps reduce flicker.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Flickerless Grayscale
« Reply #7 on: May 26, 2010, 10:31:37 am »
The idea with interlacing is that in 1 byte you can show 75% of the data from the dark layer, and 25% of the light layer at the same time. So instead of showing 1 layer then the other, you can mix them into the same LCD update, which helps reduce flicker.
OMG, i never fully understood that before, but when you explain it that way it's crystal clear! Thanks tr1p1ea! :D

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Flickerless Grayscale
« Reply #8 on: May 26, 2010, 02:02:31 pm »
Really? for the grayscale in the games I've made, I always use 3/8 on for light gray (37.5%) and 5/8 for dark gray (62.5%).  Do other 4 level grayscale games use 1/4 and 3/4 for gray levels?  How would these be interwoven?

I would think it would have to be something like this for best results:
11101110
10111011
11011101
01110111

It seems hard to create this kind of cycle though.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Flickerless Grayscale
« Reply #9 on: May 26, 2010, 02:23:47 pm »
the xLIB method in BASIC is

11011011
10110110
01101101
11011011
10110110
01101101
11011011
10110110

for light gray it is
10010010
00100100
01001001
10010010
00100100
01001001
10010010
00100100

However, this takes more space since each layers are hard-coded into sprite/tiles data and if you have several plain gray tiles in a row in a map, the scanlines might look a little weird
« Last Edit: May 26, 2010, 02:24:36 pm by DJ Omnimaga »
Dream of Omnimaga

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Flickerless Grayscale
« Reply #10 on: May 26, 2010, 02:41:58 pm »
No, it's really supposed to be 1/3 and 2/3. I don't know where people are getting the /4 and /8 from.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Flickerless Grayscale
« Reply #11 on: May 26, 2010, 03:30:24 pm »
I think one of the basic grayscale tutorial used 1/4, 2/4 and 3/4, for 5 level grayscale. For the 2/4 it was a normal 3 level gs checkered pattern
Dream of Omnimaga

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Flickerless Grayscale
« Reply #12 on: May 26, 2010, 03:39:58 pm »
I think one of the basic grayscale tutorial used 1/4, 2/4 and 3/4, for 5 level grayscale. For the 2/4 it was a normal 3 level gs checkered pattern

Makes sense.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline quasi_Phthalo

  • LV3 Member (Next: 100)
  • ***
  • Posts: 90
  • Rating: +1/-1
    • View Profile
Re: Flickerless Grayscale
« Reply #13 on: June 17, 2010, 10:51:45 pm »
what i find as a very annoying dilemma is that with one byte, you can have up to 9 level grayscale:
00000000
00000001
00010001
00100101
01010101
11011010
11101110
11111110
11111111

If you wanted to conserve space and keep one pixel in 3 bits, i.e., 8 pixels in 3 bytes, you have to leave one of the levels out...so, which one?

SirCmpwn

  • Guest
Re: Flickerless Grayscale
« Reply #14 on: June 17, 2010, 11:02:49 pm »
At best, its a 15MHz z80 processor, there is only so much you can push the limits, man.  I admire your resolve, though.