Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: Hot_Dog on May 17, 2010, 01:32:34 pm

Title: Flickerless Grayscale
Post by: Hot_Dog 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+.
Title: Re: Flickerless Grayscale
Post by: DJ Omnimaga 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
Title: Re: Flickerless Grayscale
Post by: Galandros 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.
Title: Re: Flickerless Grayscale
Post by: Quigibo 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.
Title: Re: Flickerless Grayscale
Post by: Galandros 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.
Title: Re: Flickerless Grayscale
Post by: DJ Omnimaga 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.
Title: Re: Flickerless Grayscale
Post by: tr1p1ea 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.
Title: Re: Flickerless Grayscale
Post by: TIfanx1999 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
Title: Re: Flickerless Grayscale
Post by: Quigibo 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.
Title: Re: Flickerless Grayscale
Post by: DJ Omnimaga 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
Title: Re: Flickerless Grayscale
Post by: calc84maniac 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.
Title: Re: Flickerless Grayscale
Post by: DJ Omnimaga 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
Title: Re: Flickerless Grayscale
Post by: meishe91 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.
Title: Re: Flickerless Grayscale
Post by: quasi_Phthalo 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?
Title: Re: Flickerless Grayscale
Post by: SirCmpwn 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.
Title: Re: Flickerless Grayscale
Post by: DJ Omnimaga on June 17, 2010, 11:58:39 pm
Mhmm interesting, it would be nice to see some more experiments with multiple levels of grayscale
Title: Re: Flickerless Grayscale
Post by: quasi_Phthalo on June 21, 2010, 05:17:03 pm
what about during self-test, when it goes through those different patterns on the screen? unless my eyes deceive me, there is that weird thing where it phases from dots to horizontal lines. i don't know about you, but that looks actually flickerless grey to me. (unless the contrast is down then?)
Title: Re: Flickerless Grayscale
Post by: DJ Omnimaga on June 21, 2010, 11:13:13 pm
it isn't grayscale, it's the contrast being down in some cases or the crappy calc LCD causing contrast to go down when there are alternate rows of pixels turned on/off (which probably uses a lot of power for odd reasons. It's 10x worse on the regular 83+)

http://ourl.ca/2774
Title: Re: Flickerless Grayscale
Post by: ztrumpet on June 22, 2010, 07:59:35 pm
DJ, I think that happens on all the calcs.  I notice it a lot on my 84+se. =/
Title: Re: Flickerless Grayscale
Post by: DJ Omnimaga on June 23, 2010, 01:38:20 am
I personally never noticed it much on my 83+SE. It happened, but to a much lesser extent.