Author Topic: [semi-tuto] "beautiful" grayscale without interrupts  (Read 2934 times)

0 Members and 1 Guest are viewing this topic.

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
[semi-tuto] "beautiful" grayscale without interrupts
« on: March 22, 2013, 10:07:36 am »
Hayleia recently posted this: http://ourl.ca/17145

It got me thinking: how do I make a "more precise" method for greyscale and I came up with a semi-solution (no interrupts necessary!)



This is a calibration screen. At the end it prints the number to put in A, which is a semi-timer variable.

When I say semi, that means that the ability to do this has completely to do with the time the program takes to run (A is about 12 on my calc, but about 150 or 75 is needed for wabbit in my case.)

This works with 3 and 4 level grayscale, as shown with my screenie.

Without further ado: my code!

Code: [Select]
.AA

12->A
0->C
0->B

[FFFFFFFFFFFFFFFF]->Pic1

ClrDraw(rr)
For(X,0,11)
For(Y,0,7)
Pt-On(X*8,Y*8,Pic1)(r)
End
End

Repeat (getKey(54))
If (getKey)
Pause 250
End
getKey(4)-getKey(1)->B
A+B->A
If (A=0)
255->A
End
If (A=256)
1->A
End
C++
If (C->A)
DispGraph(r)
0->C
End
End
DispGraphClrDraw(rr)
ClrHome
Output(0,0,A>Dec)
Repeat (getKey(15))
End

The "sweet spot" A depends on the calculator and how quickly the program loops in its normal state, as well as how often you need to refresh the screen.

Possible use: pic viewers

Maybe possible use: non-action games (like chess)

Not possible use: action games

I hope this is helpful!
I am Bach.

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: [semi-tuto] "beautiful" grayscale without interrupts
« Reply #1 on: March 22, 2013, 02:00:38 pm »
recently
I don't think october is recent. :P
Also to make the screen gray you should use ClrDraw:Fill(L3,768,255) which is much faster since you don't do any calculation. ;) And it's much easier to read.
This could work for RPGs too but it will force you to have slow scrolling since you're using the same loop for both. Even if this method is nice in some cases (like a pic viewer or a chess game as you pointed out) since it's a bit easier to set up, interrupts are the way to go when possible since it can actually make stuff more optimized sometimes.
« Last Edit: March 22, 2013, 02:09:53 pm by Streetwalker »

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: [semi-tuto] "beautiful" grayscale without interrupts
« Reply #2 on: March 22, 2013, 03:07:11 pm »
This method does not always hold true because the loop time is almost never constant for games. If you wanted to use this method for picture drawing, sure, but it's not going to work with something more processor-heavy.
In-progress: Graviter (...)

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Re: [semi-tuto] "beautiful" grayscale without interrupts
« Reply #3 on: March 22, 2013, 03:19:24 pm »
This method does not always hold true because the loop time is almost never constant for games. If you wanted to use this method for picture drawing, sure, but it's not going to work with something more processor-heavy.
Which is why I said pic drawing or turn-based games only... I think I have an idea with the interrupts version though...
I am Bach.

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: [semi-tuto] "beautiful" grayscale without interrupts
« Reply #4 on: March 22, 2013, 03:46:45 pm »
Even in turn based games, AI would break it all, leaving you with a gray blank for a little while.