Author Topic: How to create 4 level greyscale in Axe?  (Read 5501 times)

0 Members and 1 Guest are viewing this topic.

Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
How to create 4 level greyscale in Axe?
« on: September 05, 2012, 01:55:52 pm »
Okay, I was looking at all the greyscale tuts for axe, but I still don't get it.  ??? More Specifically, I don't actually get how the sprite is displayed to the screen, and what commands to use. Very very confused.  ??? However I do get the principle of the back and front buffers, L3 and L6 respectively, as well as how the buffers overlap to make the white, light grey, dark grey and black. Can someone help me with how the commands work, and excatly what commands do I need,

Like do I need both DispGraph and DispGraph^r or just one? and so on.
Thanks in Advance!

Offline turiqwalrus

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 840
  • Rating: +51/-2
  • Wheeeeeee~!
    • View Profile
Re: How to create 4 level greyscale in Axe?
« Reply #1 on: September 05, 2012, 02:31:00 pm »
So, DispGraph displays only the front buffer, DispGraphr displays both buffers with 3-level grayscale, and DispGraphrr displays both buffers in 4-level grayscale.

Additionally, the Pt- commands display to the front buffer by default, and the back buffer if you add a r

Adding a r actually draws to the back buffer for most graphics commands ;)

Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
Re: How to create 4 level greyscale in Axe?
« Reply #2 on: September 05, 2012, 02:33:50 pm »
Okay, I'll try it out on my calc and see if I have any other questions, but thanks!
Edit: Tried it out, but it doesn't seem to work out (the pic I'm trying to do is this)


Can you show some sort of miniexample?
« Last Edit: September 05, 2012, 02:44:15 pm by Link »

Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Re: How to create 4 level greyscale in Axe?
« Reply #3 on: September 05, 2012, 02:36:52 pm »
Here is a more in-depth how-to:

The TI-83 series doesn't support grayscale natively, but axe has some functions to alternate checkerboard patters, but that is so fast (and the screen is blurry too), so that it looks for the human eye like it is gray.

Because one buffer can only store data for two colors, you'll need two buffers for 2² = 4 level grayscale. Depending on the pixel combination of both buffers you can get black, dark gray, light gray and white. The easiest way (for me) to remember the combinations is, that the main buffer has a higher "priority" or "level" than the back buffer, so if you change a pixel on the front buffer, it'll cause the result to change more than when you do it on the back buffer.
Here are the combinations for 4 level grayscale:

Front buffer: 
Back buffer:
Result:
off
off
white 
off
on
light gray 
on
off
dark gray 
on
on
black 

In order to display a 4-level sprite, you have to create two 8x8 sprites, one for the front buffer, one for the back buffer. With the table above as reference, you can make your 2 sprites out of the one desired gray sprite.

To display them, you need two Pt-commands:

Code: [Select]
[Hex for Front buffer]→Pic1A  ; you can use other names for pointers if you want
[Hex for Back buffer]→Pic1B
...
ClrDrawrr  ; clears both buffers at the same time
While 1
...
Pt-Off(X,Y,Pic1A)   ; X and Y are the coordinates
Pt-Off(X,Y,Pic1B)r
...
DispGraphClrDrawrr   ; for 4 level you need two radian r's
...
EndIf getkey(15)

For 3 level grayscale you need DispGraphr, for 4-level you need rr. Same when you use the DispGraphClrDraw.

Every time the DspGraphrr is passed, the checkerboard pattern is changed.

That should be it.

Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
Re: How to create 4 level greyscale in Axe?
« Reply #4 on: September 05, 2012, 02:52:38 pm »
Hmm, Thanks, But do you have some sort of working example? Anything small?

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: How to create 4 level greyscale in Axe?
« Reply #5 on: September 05, 2012, 02:53:27 pm »
It's above, just change the hex codes.
I'm not a nerd but I pretend:

Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
Re: How to create 4 level greyscale in Axe?
« Reply #6 on: September 05, 2012, 02:58:31 pm »
It's above, just change the hex codes.
Okay, and I'm guisng to remove the ellipsis? Also why is point off?
« Last Edit: September 05, 2012, 03:01:37 pm by Link »

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: How to create 4 level greyscale in Axe?
« Reply #7 on: September 05, 2012, 03:00:53 pm »
The square brackets? Nope, they should be there.
I'm not a nerd but I pretend:

Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
Re: How to create 4 level greyscale in Axe?
« Reply #8 on: September 05, 2012, 03:02:29 pm »
I meant the "..." also why is it pt-off instead of pt-on?

Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Re: How to create 4 level greyscale in Axe?
« Reply #9 on: September 05, 2012, 03:16:04 pm »
I meant the "..." also why is it pt-off instead of pt-on?

Yeah, remove the dots (you can add other code in there, like movement)
Make sure to initialize X and Y or replace them with constants.

Pt-Off is slightly faster than Pt-On (when X is a multiple of 8 ), so that's why I used that for the example. But doesn't really matter.

Hex:
[FFFFC3C3C3C3FFFF] for front buffer
[FF81BDA5A5BD81FF] for back buffer

That should be a neat little box with all colors!
« Last Edit: September 05, 2012, 03:22:39 pm by MGOS »

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: How to create 4 level greyscale in Axe?
« Reply #10 on: September 05, 2012, 04:21:50 pm »
Pt-Off( overwrites the whatever that it was on the spot
Sig wipe!

Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
Re: How to create 4 level greyscale in Axe?
« Reply #11 on: September 05, 2012, 04:22:49 pm »
I meant the "..." also why is it pt-off instead of pt-on?

Yeah, remove the dots (you can add other code in there, like movement)
Make sure to initialize X and Y or replace them with constants.

Pt-Off is slightly faster than Pt-On (when X is a multiple of 8 ), so that's why I used that for the example. But doesn't really matter.

Hex:
[FFFFC3C3C3C3FFFF] for front buffer
[FF81BDA5A5BD81FF] for back buffer

That should be a neat little box with all colors!
Ooh, thanks, it works now, Time to go see If i can remove flicker now.

Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Re: How to create 4 level greyscale in Axe?
« Reply #12 on: September 05, 2012, 04:27:22 pm »
Ooh, thanks, it works now, Time to go see If i can remove flicker now.
What flicker? There shouldn't be any flickering except when your loop is two slow. Can you post your code?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: How to create 4 level greyscale in Axe?
« Reply #13 on: September 05, 2012, 04:41:50 pm »
It also depends of the calc model, right? For example, newer calcs might be faster or have a crappier LCD driver causing grayscale of some games to not flicker, while others will flicker, or vice-versa.

Removing the entire flicker is impossible without ASM (and even then, it requires a calibration screen like ThePenguin or Hot Dog's grayscale games), though, so while you can make the grayscale looks close to perfection, you'll still always notice a little bit of scanlines.

The loop has to be in sync with the LCD driver speed, which is different on every calc, even accross the same models, so if your loop is too slow or too fast, flicker will be more noticeable.

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: How to create 4 level greyscale in Axe?
« Reply #14 on: September 05, 2012, 06:20:11 pm »
Flicker occurs when the calc program is refreshing the screen either too fast (resonance) or too slow. I've found that if you only have a Dispgraph(r) or (rr) in your loop, Pause 22, Pause 23, or two 768 byte Copy('s are all good options for getting it close to perfect.
In-progress: Graviter (...)