Author Topic: Grayscale in Grammer  (Read 6737 times)

0 Members and 1 Guest are viewing this topic.

Offline Xeda112358

  • they/them
  • Project Author
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Grayscale in Grammer
« 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 :)

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Grayscale in Grammer
« Reply #1 on: January 12, 2012, 10:51:34 am »
Very nice! =)

Offline Xeda112358

  • they/them
  • Project Author
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Grayscale in Grammer
« Reply #2 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 :)

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Grayscale in Grammer
« Reply #3 on: January 12, 2012, 12:03:40 pm »
Cool, greyscale! O.o

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!