Author Topic: Flickerless 4 Level GrayScale  (Read 6643 times)

0 Members and 1 Guest are viewing this topic.

Offline nitacku

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 300
  • Rating: +30/-1
  • ni-ta-ku ^_^
    • View Profile
Flickerless 4 Level GrayScale
« on: January 23, 2008, 05:47:00 am »
Updated!

Here is a little project that I created during the restless hours of the night.
It will take a series of 3 pics and automatically render them into 4 new pics which can be used to create flickerless 4 level grayscale in Basic.

Since the pictures are only XORed onto the screen, text, sprites, and pretty much anything can be displayed without being overwritten by the grayscale. While asm relies on the timing of interrupts to create grayscale, this method dithers the pictures in such a way that simple XORing them in order creates grayscale, thus eliminating the need to time the updates of the screen.

Thee code to create the 4 level GrayScale is simple:

real(3.pic1,3
Repeat Ans
real(3,pic2,3
real(3,pic3,3
real(3,pic4,3
End

Since the method is simple, it is fast enough to be used in Basic programs.
Creating the pics is simple as well.
The first layer represents the Black and White
The second layer represents the Dark Gray
And the third layer represents the Light Gray

I've attached some example pics that could be used to create the grayscale
And of course the GrayScale creator is attached as well.

Attachments:

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
Flickerless 4 Level GrayScale
« Reply #1 on: January 23, 2008, 03:01:00 pm »
Great work, this is about the same method I used in my 5 lvl GS demo. CDI also had made a 4 lvl GS demo, but is more effective than mine (less time consuming to show fewer colors). Kevin had made a GS game with xLIB (he also made it with omnicalc, which this tut is helpful), not to forget his Reuben games!. CDI also made a GS minesweeper, I hope you can make something wonderful from your demo!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Flickerless 4 Level GrayScale
« Reply #2 on: January 23, 2008, 07:26:00 pm »
wow this is great! IU  ddint knew you would do it so fast! ANd I feel so stupid now, because I was sure the only way to do it was to create the scanlines pixel by pixel by detecting if its on or off in pic 1 and on or off in pic 2, but you separated all gs layers so its much easier and faster. :)

To be honest I think this technique is the most effective (altough memory hungry) because it only need to loop between 3 frames to achieve grayscale. In both CDI/kalan methods it had to go through 4 frames to achieve grayscale: In frame 1 lightgray was not displayed and darkgray was black, in frame 2 lightgray was displayed and dark gray as well. In frame 3 it was the same thing than frame 1 and in frame 4 it was the same than frame 2 but the checkered pattern was at a different location. This caused the grayscale to still flickers badly, and the contrast between light gray and dark gray were way too high. However this method was practical for 5 level grayscale, you just had to add a constantly moving and never dissapearing checkered pattern for middle gray.

In my method, it just XORs scanlines to make them move in a certain direction and since it go through 3 layers only it flicker less badly. You even have to slow it down on the 83+SE because it is so fast that it get out of sync with the slow LCD driver. Basically my method shows scanlines that are similar to the ones in Desolate and Lost Legends.

The only downsides of my method is that
-you need 4 pictures. The starting one can be deleted right after map display but dont forget to recreate it if you need to show text for example andwant to redisplay the screen for example
-Idk if kalan/cdi method do this too, but in mine, since it cycle through  3 XOR pics, make sure that at the end of your program loop the 1st layer is displayed, so it loops properly through them when the WHile/for loop of your game is finished.
-Sprites are a pain to make, because it's tricky to draw the scanlines properly. It's often trial and error and it can take one hour to draw one 8x8 tile. The shortest amount of time I took to make one by hand was 15 minutes. So this is why Nitacku wrote an automatic grayscale ditherer.
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Liazon

  • Guest
Flickerless 4 Level GrayScale
« Reply #3 on: January 23, 2008, 09:22:00 pm »
all i can say is nice, cuz I know gs is hard in basic

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Flickerless 4 Level GrayScale
« Reply #4 on: January 23, 2008, 09:27:00 pm »
right now the hardest part is to make it switch layers at a constant speed. It is hard because some BASIC commands are way too fast so the LCD can't handle that many display changes in so small amount of time.

The best way is to have it show less layers per loops but then it look like crap on the regular 83+. The next way is to show  more (like two every commands), but then the game is very slow on the 83+. If you make it go both fast and look nice on 83+ then it look like crap on the SE
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Flickerless 4 Level GrayScale
« Reply #5 on: January 24, 2008, 12:45:00 pm »


Emulators doesn't do justice
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Liazon

  • Guest
Flickerless 4 Level GrayScale
« Reply #6 on: January 24, 2008, 06:42:00 pm »
actually, I kinda like the color changes.  it kinda looks as if it's glowing fire light or something.  or glowing gold.

Offline dinhotheone

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 410
  • Rating: +2/-1
    • View Profile
Flickerless 4 Level GrayScale
« Reply #7 on: January 24, 2008, 10:40:00 pm »
for a second i thought this was a lib so you can make it 4 level in a game....its still pretty sick tho

Offline nitacku

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 300
  • Rating: +30/-1
  • ni-ta-ku ^_^
    • View Profile
Flickerless 4 Level GrayScale
« Reply #8 on: January 24, 2008, 11:24:00 pm »
Yeah, the emulator really doesn't do a very good job with recreating the grayscale.
On a real calc, the grayscale is flickerless, at least it is on my 84+SE.

Seriously, try it out. The grayscale creator is really cool :P You'll like the results.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Flickerless 4 Level GrayScale
« Reply #9 on: January 24, 2008, 11:58:00 pm »
Quote
for a second i thought this was a lib so you can make it 4 level in a game....its still pretty sick tho
mhmm dinho actually it is. You can add this grayscale in game. In 2005 I had a demo of a 4 level grayscale walking engine (that did nothing but walking tho) using a similar method and it was pretty neat. I recommend to only use it in RPGs or puzzle games though
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Flickerless 4 Level GrayScale
« Reply #10 on: January 30, 2008, 07:27:00 pm »
that could be a concept of a Nemesiat style game



The problem is the bad looking HUD but it's because the original had ASCII sprites so map was 60px wide instead of 80, letting more space for the HUD
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline nitacku

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 300
  • Rating: +30/-1
  • ni-ta-ku ^_^
    • View Profile
Flickerless 4 Level GrayScale
« Reply #11 on: January 30, 2008, 07:59:00 pm »
Nice!
I'm glad to see that someone is using my utility :D

If you would like, I can even program a sprite editor to make the process easier.
It probably wouldn't have real-time grayscale editing, but it would feature the automatic grayscale conversion so that you can preview the sprites whenever you want.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Flickerless 4 Level GrayScale
« Reply #12 on: January 30, 2008, 09:30:00 pm »
nah dont worry it should be ok. I do all my spriting on the PC anyway ^^
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Liazon

  • Guest
Flickerless 4 Level GrayScale
« Reply #13 on: January 30, 2008, 10:28:00 pm »
o.o those are nice sprites and tiles!

Offline nitacku

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 300
  • Rating: +30/-1
  • ni-ta-ku ^_^
    • View Profile
Flickerless 4 Level GrayScale
« Reply #14 on: February 01, 2008, 11:06:00 pm »
The program has been updated.
Check the first post for download.

The new version fixes a little bug that occurred in the last 4 columns of pixels.
Also, Swap and Delete functions were added to make editing pictures easier.