Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Link on September 05, 2012, 01:55:52 pm

Title: How to create 4 level greyscale in Axe?
Post by: Link 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!
Title: Re: How to create 4 level greyscale in Axe?
Post by: turiqwalrus 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 ;)
Title: Re: How to create 4 level greyscale in Axe?
Post by: Link 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)
(http://img201.imageshack.us/img201/2097/4leveltree.png)

Can you show some sort of miniexample?
Title: Re: How to create 4 level greyscale in Axe?
Post by: MGOS 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.
Title: Re: How to create 4 level greyscale in Axe?
Post by: Link on September 05, 2012, 02:52:38 pm
Hmm, Thanks, But do you have some sort of working example? Anything small?
Title: Re: How to create 4 level greyscale in Axe?
Post by: aeTIos on September 05, 2012, 02:53:27 pm
It's above, just change the hex codes.
Title: Re: How to create 4 level greyscale in Axe?
Post by: Link 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?
Title: Re: How to create 4 level greyscale in Axe?
Post by: aeTIos on September 05, 2012, 03:00:53 pm
The square brackets? Nope, they should be there.
Title: Re: How to create 4 level greyscale in Axe?
Post by: Link on September 05, 2012, 03:02:29 pm
I meant the "..." also why is it pt-off instead of pt-on?
Title: Re: How to create 4 level greyscale in Axe?
Post by: MGOS 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!
Title: Re: How to create 4 level greyscale in Axe?
Post by: Yeong on September 05, 2012, 04:21:50 pm
Pt-Off( overwrites the whatever that it was on the spot
Title: Re: How to create 4 level greyscale in Axe?
Post by: Link 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.
Title: Re: How to create 4 level greyscale in Axe?
Post by: MGOS 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?
Title: Re: How to create 4 level greyscale in Axe?
Post by: DJ Omnimaga 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.
Title: Re: How to create 4 level greyscale in Axe?
Post by: leafy 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.
Title: Re: How to create 4 level greyscale in Axe?
Post by: Link on September 05, 2012, 07:01:00 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?
Its the above provided one, its just like diagonal scanlines and that seem to move horizontally.
Title: Re: How to create 4 level greyscale in Axe?
Post by: parserp on September 05, 2012, 07:04:08 pm
Unfortunately, you have to mess around with pauses (or interrupts :P) in order to get the greyscale as flickerless as possible.
A more detailed description can be found here. (http://www.omnimaga.org/index.php?action=articles;sa=view;article=82)
Title: Re: How to create 4 level greyscale in Axe?
Post by: Link on September 05, 2012, 07:58:21 pm
Unfortunately, you have to mess around with pauses (or interrupts :P) in order to get the greyscale as flickerless as possible.
A more detailed description can be found here. (http://www.omnimaga.org/index.php?action=articles;sa=view;article=82)
Hmm, thanks, I might do a calibration screen though.