Author Topic: Grayscale  (Read 5070 times)

0 Members and 1 Guest are viewing this topic.

Offline noahbaby94

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 585
  • Rating: +29/-24
    • View Profile
    • My blog
Grayscale
« 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.
That's what she said!!!

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: Grayscale
« Reply #1 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

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
Re: Grayscale
« Reply #2 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

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: Grayscale
« Reply #3 on: February 04, 2009, 01:14:30 am »
moved to calculator help and support

Offline skuller972

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 335
  • Rating: +11/-4
  • BEAST MODE
    • View Profile
Re: Grayscale
« Reply #4 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. ???
Then again, maybe not...
<a href="http://www.nerdtests.com/ft_nt2.php">
<img src="http://www.nerdtests.com/images/badge/nt2/bc7bf8e12353f09e.png" alt="NerdTests.com says I'm a Cool Non-Nerd.  Click here to take the Nerd Test, get nerdy images and jokes, and talk to others on the nerd forum!">
</a>

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: Grayscale
« Reply #5 on: May 27, 2009, 09:07:45 pm »
I hope you aren't planning to revive every old topic on the forums, though

Offline skuller972

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 335
  • Rating: +11/-4
  • BEAST MODE
    • View Profile
Re: Grayscale
« Reply #6 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.
Then again, maybe not...
<a href="http://www.nerdtests.com/ft_nt2.php">
<img src="http://www.nerdtests.com/images/badge/nt2/bc7bf8e12353f09e.png" alt="NerdTests.com says I'm a Cool Non-Nerd.  Click here to take the Nerd Test, get nerdy images and jokes, and talk to others on the nerd forum!">
</a>

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: Grayscale
« Reply #7 on: May 27, 2009, 09:14:08 pm »
ok i am fine as long as there's a reason to revive them

Offline skuller972

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 335
  • Rating: +11/-4
  • BEAST MODE
    • View Profile
Re: Grayscale
« Reply #8 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)
Then again, maybe not...
<a href="http://www.nerdtests.com/ft_nt2.php">
<img src="http://www.nerdtests.com/images/badge/nt2/bc7bf8e12353f09e.png" alt="NerdTests.com says I'm a Cool Non-Nerd.  Click here to take the Nerd Test, get nerdy images and jokes, and talk to others on the nerd forum!">
</a>

Offline nitacku

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 300
  • Rating: +30/-1
  • ni-ta-ku ^_^
    • View Profile
Re: Grayscale
« Reply #9 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

Offline skuller972

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 335
  • Rating: +11/-4
  • BEAST MODE
    • View Profile
Re: Grayscale
« Reply #10 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.
Then again, maybe not...
<a href="http://www.nerdtests.com/ft_nt2.php">
<img src="http://www.nerdtests.com/images/badge/nt2/bc7bf8e12353f09e.png" alt="NerdTests.com says I'm a Cool Non-Nerd.  Click here to take the Nerd Test, get nerdy images and jokes, and talk to others on the nerd forum!">
</a>