Author Topic: Seeing Through Sprites  (Read 8000 times)

0 Members and 1 Guest are viewing this topic.

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: Seeing Through Sprites
« Reply #15 on: October 20, 2010, 02:11:30 pm »
Er what do you mean? I just went by your previous post, where you posted this:
Code: [Select]
           Second buffer
            1       0    
First   1   Black   Gray
Buffer  0   White   Transparent
I did not imply anything different. All I said was that you simply just had to not bother using any gray in there. In other words, what I meant was
Code: [Select]
           Second buffer
            1       0    
First   1   Black  
Buffer  0   White   Transparent
« Last Edit: October 20, 2010, 02:12:16 pm by DJ Omnimaga »

ASHBAD_ALVIN

  • Guest
Re: Seeing Through Sprites
« Reply #16 on: October 20, 2010, 02:18:46 pm »
Yes, you can use the Pt-Mask() routine for masking monochrome sprites, but you didn't quite define the logic of how things are drawn correctly. You got how to draw white and transparent pixels correctly, but black pixels need to have their corresponding bit be on in both buffers, not just the front buffer. Having the bit on in just the front buffer was designed for gray, which turns the pixel on in the back buffer (not used in black and white displaying) but turns the pixel off in the front buffer.

Not true, runer.  If you use Dispgraph with no r at the end it does it with only black on the first buffer...

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Seeing Through Sprites
« Reply #17 on: October 20, 2010, 02:35:56 pm »
Sorry for the confusion, my last post was directed towards ASBAD_ALVIN, not you DJ.

Yes, you can use the Pt-Mask() routine for masking monochrome sprites, but you didn't quite define the logic of how things are drawn correctly. You got how to draw white and transparent pixels correctly, but black pixels need to have their corresponding bit be on in both buffers, not just the front buffer. Having the bit on in just the front buffer was designed for gray, which turns the pixel on in the back buffer (not used in black and white displaying) but turns the pixel off in the front buffer.

Not true, runer.  If you use Dispgraph with no r at the end it does it with only black on the first buffer...


Take the following program for example:
Code: [Select]
.TEST
[FFFFFFFF00000000]→Pic1
[FFFF0000FFFF0000]
ClrDraw
DrawInv
Pt-Mask(0,0,Pic1)
DispGraph
Repeat getKey
End

That sprite has both bits set for the first two lines of data, only the first buffer bits set for the third and fourth lines, only the second buffer bits set for the fifth and sixth lines, and all of the bits unset for the seventh and eighth lines. You get the result displayed in the attached picture. The first two lines are black, because both bits are set in the sprite data, but when only the first buffer bit is set in the sprite (lines three and four), the result is white. This is because the Pt-Mask() command is doing what would be gray, which means the back buffer pixels are on but the front buffer pixels are off.

EDIT by DJ: post was messed up due to additional code tag at beginning. Fixed :P

EDIT by me: I think I might have fixed it first, in which case you would have been edit ninja'd :P
« Last Edit: October 24, 2010, 03:04:18 am by Runer112 »

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: Seeing Through Sprites
« Reply #18 on: October 20, 2010, 02:39:47 pm »
Ah ok I see x.x

Basically, Pt-mask() does the masking work for you, but the downside is that you cannot have 4 level grayscale masked sprites (although in many cases it doesn't matter much plus it saves space)

EDIT: Btw your post was messed up but before I clicked edit I went to check it and it still showed the original post so I clicked edit anyway. We must have clicked at the same time :P
« Last Edit: October 20, 2010, 02:40:39 pm by DJ Omnimaga »

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: Seeing Through Sprites
« Reply #19 on: October 20, 2010, 04:49:43 pm »
You can still have 4 level grayscale by using 4 level backgrounds and 3 level foreground sprites.  I think this is what the original game boy used for the same reason.  But be aware that when you use the Pt-Mask routine for monochrome, data will still be written to the back-buffer even when you're not displaying it.  So you can't use L3 to store additional variables and data structures since they can easily get corrupted.
« Last Edit: October 20, 2010, 04:50:17 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Seeing Through Sprites
« Reply #20 on: October 20, 2010, 04:58:11 pm »
Ah, okay.  Now that I see what you're asking, either use this:
http://ourl.ca/5980
I believe Builderboy explains it pretty well. :)
or Pt-Mask().  Whichever you want to use will work. ;D  Good luck. :)

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: Seeing Through Sprites
« Reply #21 on: October 21, 2010, 04:28:58 am »
You can still have 4 level grayscale by using 4 level backgrounds and 3 level foreground sprites.  I think this is what the original game boy used for the same reason.  But be aware that when you use the Pt-Mask routine for monochrome, data will still be written to the back-buffer even when you're not displaying it.  So you can't use L3 to store additional variables and data structures since they can easily get corrupted.
yeah that's what I meant. To get 4 level grayscale masked sprites and backgrounds, you need to use about 3 or 4 sprite for each 4 level masked sprites I think. That might be slow with many at once and a tilemapper...
« Last Edit: October 21, 2010, 04:29:29 am by DJ Omnimaga »

ASHBAD_ALVIN

  • Guest
Re: Seeing Through Sprites
« Reply #22 on: October 21, 2010, 05:43:46 am »
Sorry for the confusion, my last post was directed towards ASBAD_ALVIN, not you DJ.

Yes, you can use the Pt-Mask() routine for masking monochrome sprites, but you didn't quite define the logic of how things are drawn correctly. You got how to draw white and transparent pixels correctly, but black pixels need to have their corresponding bit be on in both buffers, not just the front buffer. Having the bit on in just the front buffer was designed for gray, which turns the pixel on in the back buffer (not used in black and white displaying) but turns the pixel off in the front buffer.

Not true, runer.  If you use Dispgraph with no r at the end it does it with only black on the first buffer...


Take the following program for example:
Code: [Select]
.TEST
[FFFFFFFF00000000]→Pic1
[FFFF0000FFFF0000]
ClrDraw
DrawInv
Pt-Mask(0,0,Pic1)
DispGraph
Repeat getKey
End

That sprite has both bits set for the first two lines of data, only the first buffer bits set for the third and fourth lines, only the second buffer bits set for the fifth and sixth lines, and all of the bits unset for the seventh and eighth lines. You get the result displayed in the attached picture. The first two lines are black, because both bits are set in the sprite data, but when only the first buffer bit is set in the sprite (lines three and four), the result is white. This is because the Pt-Mask() command is doing what would be gray, which means the back buffer pixels are on but the front buffer pixels are off.

EDIT by DJ: post was messed up due to additional code tag at beginning. Fixed :P

EDIT by me: I think I might have fixed it first, in which case you would have been edit ninja'd :P

kk