Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: noahbaby94 on January 29, 2009, 05:40:05 pm

Title: Grayscale
Post by: noahbaby94 on January 29, 2009, 05:40:05 pm
Does someone care to explain grayscale with xlib to me? I mean real slow so that someone can easily get it.
Title: Re: Grayscale
Post by: DJ Omnimaga on January 29, 2009, 07:05:57 pm
I don't know much how nitacku does it, he would need to explain if he even visits the forums at all, but it's about switching pixels from white to black very quickly and make sure that not all pixels switch at the same time. I generally recommend 3 level grayscale when it comes to BASIC, since it's less flickery on slower models. The following tutorial is outdated but it shows how 3 level grayscale tiles should be done http://www.omnimaga.org/index.php?action=downloads;sa=view;down=166

Basically you got a picture of the tile where the gray area is a checkered pattern made of white and black pixels, and another picture where only the gray areas are present, as black pixels. Let's say pic1 is the black/white areas and the checkered pattern for the gray area and that pic2 is the gray areas only in black. Your code will look like this:

real(3,1,0,0
While 1
*line of code*
real(3,2,3,1
*line of code*
real(3,2,3,1
*line of code*
real(3,2,3,1
*line of code*
real(3,2,3,1
*line of code*
real(3,2,3,1
[...]
End

Lines of code can be anything providing it's not something that takes a while to process, like a Goto or a line containing more than 1 rand instruction or storing a big string. You need a real(3,2,3,1 command after every line of code, except that if you got something like A+1->A:B+1->B I would recommend putting none between both, because it may be faster than the LCD can handle, causing more flicker. Also if you need to display other sprites it's ok, just make sure there's a real(3,2,3,1 between every real(1 lines of code. To erase them just xor them with the same sprite or do a real(3,1,0,0 command before displaying them again (if it kills the grayscale just add a real(3,2,3,1 before the real(3,1,0,0 or get rid of the one alerady there)

This might also help
http://tibasicdev.wikidot.com/xlib-tutorial#toc6

Reuben used this method. In fact the prgm contained in my old gs tutorial from 2004 is Reuben Walking engine in a very early stage of developpment
Title: Re: Grayscale
Post by: kalan_vod on January 29, 2009, 10:06:32 pm
If you make something if GS, you could keep it all in a loop:

Code: [Select]
:real(3,1,0,0
:Repeat Ans
:real(3,2,3,1
:getkey->K
:real(3,2,3,1 ;might not need this one, but most likely will
:End

The issue with doing it this way is that it is not consistant, as if you would place it through your code like kevin..So if done the way I posted above, you could add the code every other like (like kevin) and have a loop like mine. Just try it out and post your code, we will try to lend a hand.

@kevin: time for you to make a new GS xLIB/GS Celtic tutorial! haha
Title: Re: Grayscale
Post by: DJ Omnimaga on February 04, 2009, 01:14:30 am
moved to calculator help and support
Title: Re: Grayscale
Post by: skuller972 on May 27, 2009, 09:05:45 pm
once again, another old topic (im just going through all of the topics before i joined)... I just like literally five minutes ago made my first ever grayscale on xlib, it was a floppy disk with a grayscale background and a gray slidy thing, and when i ran it, the grayscale was fine! but the picture was backwards. ???
Title: Re: Grayscale
Post by: DJ Omnimaga on May 27, 2009, 09:07:45 pm
I hope you aren't planning to revive every old topic on the forums, though
Title: Re: Grayscale
Post by: skuller972 on May 27, 2009, 09:10:31 pm
lol nope just the interesting ones. all the rest are boringish and dont deserve my posts. lol not really i just dont feel like reviving them. but these are the ones that i want to post for.
Title: Re: Grayscale
Post by: DJ Omnimaga on May 27, 2009, 09:14:08 pm
ok i am fine as long as there's a reason to revive them
Title: Re: Grayscale
Post by: skuller972 on May 27, 2009, 09:19:26 pm
so, do you know why my grayscale xlib sprite is backwards? i used:
Code: [Select]
PROGRAM:A0
:Repeat 0
:real(1,0,0,2,16,1,0,0
:real(1,0,0,2,16,2,0,0
:End

and pic 1 was a floppy disk with every other pixel for grayscale on, and pic 2 was the grayscale pixels opposite, so it was checkered on each one the opposite of the other (i learned that from z80 heaven the grayscale section, even though this is basic ;D)
Title: Re: Grayscale
Post by: nitacku on May 27, 2009, 10:36:29 pm
Those xlib commands are not complete and there should only be 1 command in the loop.

Try this instead:

real(1,0,0,2,16,1,0,0,0,0,0
Repeat 0
real(1,0,0,2,16,2,0,0,3,0
End
Title: Re: Grayscale
Post by: skuller972 on May 28, 2009, 06:30:08 am
thanks its working now. i didn't think of that. but i still dont know why it flipped.