Author Topic: How does 4-level greyscale work in Axe?  (Read 26787 times)

0 Members and 1 Guest are viewing this topic.

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: How does 4-level greyscale work in Axe?
« Reply #15 on: June 05, 2010, 09:32:48 pm »
So, It's caused by the screen updating too fast? Wow. I'd assume that, if that's true, the time for the pause probably decreases. Is that right?

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: How does 4-level greyscale work in Axe?
« Reply #16 on: June 06, 2010, 07:34:39 pm »
4-level grayscale? I still don't even get 3-level. ;D

I've tried something like this:
ClrDraw
ClrDrawr
DrawInvr
Repeat getKey
DispGraphr
End


It doesn't really produce a gray. The screen just seems to be clear. Is this also because it's updating too fast?

Also, should I use Repeat getKey or Repeat getKey(0) in this situation? Does it matter?

Sorry for taking advantage of your thread, willrandship.
« Last Edit: June 06, 2010, 08:05:19 pm by Deep Thought »




Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: How does 4-level greyscale work in Axe?
« Reply #17 on: June 06, 2010, 08:01:02 pm »
did you get that to compile? i think you meant clrdraw and clrdraw^r, not clrhome. also, it does work, but since the whole screen is being drawn gray, you perceive it as if the contrast had been changed darker. try this:
Code: [Select]
.GRAY
ClrHome
ClrDraw
ClrDraw^R             //clear buffers
[FFFFFFFFFFFFFFFF->Pic1      //16 F's. a black square. which we will make.. gray (:
0->X->Y                            // coordinates
Repeat getKey(15)
Pt-Change(X,Y,Pic1           // draw the black square
Pt-Change(X+8,Y,Pic1)^r    // draw a black square on the back buffer 8 pixels to the right
DispGraph^r                     // draw buffer (with black square) and draw the square on the back buffer with a checkerboard pattern
Pt-Change(X,Y,Pic1           // to create grayscale
Pt-Change(X+8,Y,Pic1)^r
X+getKey(3)-getKey(2)->X
Y+getKey(1)-getKey(4)->Y        // Movement code
End
it just makes a rectangle, one half of it is black and the other half gray so you can see the difference. and, you can move it.


Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: How does 4-level greyscale work in Axe?
« Reply #18 on: June 06, 2010, 08:16:11 pm »
did you get that to compile? i think you meant clrdraw and clrdraw^r, not clrhome.

Whoops, typo.

And that program is a perfect example for me. Thanks.

Except for one thing: I still can't understand why the second set of Pt-Change(s is needed. I tried it without them, and it didn't work, but I can't figure out how.




Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: How does 4-level greyscale work in Axe?
« Reply #19 on: June 06, 2010, 08:43:09 pm »
basically the second set of pt-change( 's turn off the sprites so there's no left over residue from movement. i'll try to show you visually.. pardon me if this fails spectacularly. i'm just going to do this in black/white so i can use paint to show you.
1 is a black pixel. 0 is a white pixel. pretend the screen is a grid 3x3 pixels
010
111
010
for example, this would be a cross.
pretend your sprite is:
11
11
or a black rectangle. now, let's jump to the code.
after the first two pt-change('s, your little black rectangle is on the buffer. then it's displayed:
110
110
000
now look what happens without the next two pt-change's. the movement code comes. let's say the user moved the black rectangle one to the right.
101
101
000
what just happened? think about it.
what should've happen was this:
011
011
000
however, since the buffer already has this painted onto it:
110
110
000
and it's inverting the pixels at the new position:
1|10|
1|10|
000
you get...
101
101
000
with the two pt-change's after the dispgraph, it prevents this from happening since the buffer doesn't have any sprite residue left over. hopefully this made sense. and sorry for the long post i tried to be as thorough as possible

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: How does 4-level greyscale work in Axe?
« Reply #20 on: June 06, 2010, 08:44:34 pm »
Well I think it is actually erasing the path that would be left behind (or turning those pixels off so it can be done again). I don't know though. I haven't tested that yet.

Edit: Ninja'd :P

But I think it is kind of like in TI-BASIC when you are doing a basic sprite moving routine on the homescreen and you move the character over and you have a left over character in the path. So you use the "_" (space) token to erase that. Hope that makes sense.
« Last Edit: June 06, 2010, 08:47:28 pm by meishe91 »
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: How does 4-level greyscale work in Axe?
« Reply #21 on: June 06, 2010, 08:51:46 pm »
Oh, I see. Thanks!




Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: How does 4-level greyscale work in Axe?
« Reply #22 on: June 06, 2010, 08:55:03 pm »
yeah it's kind of hard to understand. i don't even want to start to understand what would happen without the pt-change's in my grayscale example. it works, that's all i need to know lol. it's one of those situations where a computer does exactly what you tell it to do, and the only way to understand it would be to go step by step through as if you were a computer  :P


Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: How does 4-level greyscale work in Axe?
« Reply #23 on: June 06, 2010, 08:56:10 pm »
@nemo
Was my explanation correct?
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: How does 4-level greyscale work in Axe?
« Reply #24 on: June 06, 2010, 09:02:13 pm »
yes, it is. except unlike using the space character in basic, which updates the screen automatically, in axe you have to manually turn off the sprite on the buffer after displaying the buffer... if that makes sense. but yes, you're correct.


Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: How does 4-level greyscale work in Axe?
« Reply #25 on: June 06, 2010, 09:11:32 pm »
Ok, ya. Couldn't you technically use a blank ([0000000000000000]) sprite to erase it on the buffer? Or not while doing grayscale?
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: How does 4-level greyscale work in Axe?
« Reply #26 on: June 06, 2010, 09:27:21 pm »
yes, but a sprite is 8x8, right? so if you use a blank 8x8 sprite it'll also erase anything close to the sprite on the buffer. pt-change ONLY changes the black pixels of the sprite to white, which makes it perfect to use. also, if you wanted to, you could use pt-off, which would do the same thing. pt-off clears the 8x8 area.


Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: How does 4-level greyscale work in Axe?
« Reply #27 on: June 06, 2010, 09:29:10 pm »
yes, but a sprite is 8x8, right? so if you use a blank 8x8 sprite it'll also erase anything close to the sprite on the buffer. pt-change ONLY changes the black pixels of the sprite to white, which makes it perfect to use. also, if you wanted to, you could use pt-off, which would do the same thing. pt-off clears the 8x8 area.
Actually, pt-off is Replace logic, where the 8x8 sprite replaces whatever is under it.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: How does 4-level greyscale work in Axe?
« Reply #28 on: June 06, 2010, 09:54:08 pm »
Oh, so you're talking about like when you would have a map underneath the sprite?
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: How does 4-level greyscale work in Axe?
« Reply #29 on: June 06, 2010, 10:05:17 pm »
Drawing Sprite A...
Over WhiteOver BlackOver Sprite B
Pt-OnABlackA OR B
Pt-ChangeAA InvertA XOR B
Pt-OffAAA

Also, xoring twice is the same as removing since (A xor B) xor B = A
« Last Edit: June 06, 2010, 10:06:40 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!