Omnimaga

Omnimaga => Completed => Our Projects => Grammer => Topic started by: Xeda112358 on January 11, 2012, 11:49:10 am

Title: Grayscale in Grammer
Post by: Xeda112358 on January 11, 2012, 11:49:10 am
I finally learned how to do grayscale properly and now I want to pass on that knowledge for Grammer programmers. This has been possible with Grammer for a while, I just never understood the theory behind making it flickerless and beautiful looking. So here goes:

For three level grayscale, we have it very easy. You have a gray buffer and a black buffer In the gray buffer, you set any gray pixels to on and leave the rest alone. In the black buffer, you set the black pixels on and leave the rest alone. Now you need to display it and this is where it gets fun.

Normally, you would have flicker and if you have ever attempted and failed grayscale like me, you know what I am talking about. So how do you get around this? You set any gray pixels on an alternating cycle. How is this achieved? You use a checkerboard pattern and use AND logic on the buffer. So every other cycle, a gray pixel is displayed, but you want to display black pixels every cycle. So you OR the black buffer with that buffer, too. So here is an example using a tilemap:
Code: [Select]
!E→E                               ;This makes E alternate between 0 and 1. This tells us the cycle we are on.
Fill(+2                              ;This uses one of the checkerboard patterns. It alternates with E
Pt-Change(0,M,G,W,X,Y,1   ;Draws a tilemap using the gray tileset with AND logic
Pt-Change(0,M,B,W,X,Y,3    ;Draws the same tilemap with the blcak tileset with OR logic
DispGraph                         ;Now display
As long as you display it enough, this will make rather beautiful 3 level grayscale. I am currently working on other levels of grayscale as well as additions for grayscale drawing (possibly).

Anyways, here are some programs to play with. I would show a screenie, but WabbitEmu cannot capture it nearly as well as it looks on an actual calculator.

EDIT: Posted a pic and that is pretty accurate with how it look on an actual calc :)
Title: Re: Grayscale in Grammer
Post by: TIfanx1999 on January 12, 2012, 10:51:34 am
Very nice! =)
Title: Re: Grayscale in Grammer
Post by: Xeda112358 on January 12, 2012, 11:52:58 am
Thanks :) And I now have a command for grayscale sprites and tilemaps o.o That should help folks, I think :)
Title: Re: Grayscale in Grammer
Post by: Sorunome on January 12, 2012, 12:03:40 pm
Cool, greyscale! O.o