Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cooming 2013: "Yumiko in the haunted Mansion"
#31
boriel Wrote:
LCD Wrote:BTW: How to extend PutChars to add masking? I want to have some parts of the background shine through the chars by defining bitmap of a mask.
boriel Wrote:Have a look at PRINT routine. PRINT uses OVER 2 and OVER 3 for masking. Wink
PRINT masking does not allow to shine through only selected parts of the bitmap to make them appear like "sprites" with a border around them. And if I'm low on memory, I replace all prints with a routine based on PutChars because this saves around 800 bytes of memory. Maybe you noticed in source of Yumiko.
.
That's right. PRINT is a very generic routine (as BASIC requires). Usually you need OVER 2 + OVER 3 (OVER 2 + OVER 1 will also work) to do masking, but you will need to precalculate the inverted mask in advance. I haven't read your code entirely, BTW, but if you managed to get a routine that calculates some masks automatically (this is usually not possible, I guess) and invert them (e.g. at the beginning of each game level, or whatever) you will save a lot of memory. I've always wanted something like this :roll:
Sorry, I wasn't questioning your code; just suggesting you can get some ideas from the default PRINT routine (as I do from many places, the ROM included).[/quote]

Ooops, now I see what you mean. I was expecting that britlionn was answering me. Did not have noticed that it was you, boriel.
Sorry...
The problem with the Print routine is that using it may eat much memory, if used for graphics.
Print at 4,6 "ABCDEFGHIJ";at 5,6;"KLMNOPQRST" uses much more memory than
PutChars(4,6,10,2,@GfxData)
Overlaying graphics characters may even make it too slow for action games. But for simple "tricks" where speed is not important or just a single character is needed, I'm using it.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
#32
LCD Wrote:but if you managed to get a routine that calculates some masks automatically (this is usually not possible, I guess) and invert them (e.g. at the beginning of each game level, or whatever) you will save a lot of memory. I've always wanted something like this :roll:

Hmm. You know, I sort of wrote that code once or twice. Once in a routine I never got to work, trying to do automatic proportional printing for any font. And once in the random functions I put in the library...

The basic idea is to take the left hand side, and rotate until a bit drops into carry, counting how many rotates. Then you know how many pixels wide the mask is for that byte. Left hand side rotates left, right hand side rotates right - and it's reasonable to assume that you don't want to mask between the extremes of pixels, since that's sprite.

Not particularly fast, but if you're decompressing material for use, then this would work in most cases...


From the random code (imagine this is left side, and your sprite byte arrived in A):
Code:
LD C,255
    randomBinLoop:
    RLA
    JR C, randomBinLoopExit
    RR C
    JR randomBinLoop ; LOOP back UNTIL we find a bit.
    randomBinLoopExit:

Of course, this is rotating C the wrong way to be a graphics mask - I wanted to mask the active bits, not the missing ones, here.
Reply
#33
britlion Wrote:
LCD Wrote:but if you managed to get a routine that calculates some masks automatically (this is usually not possible, I guess) and invert them (e.g. at the beginning of each game level, or whatever) you will save a lot of memory. I've always wanted something like this :roll:

Hmm. You know, I sort of wrote that code once or twice. Once in a routine I never got to work, trying to do automatic proportional printing for any font. And once in the random functions I put in the library...

The basic idea is to take the left hand side, and rotate until a bit drops into carry, counting how many rotates. Then you know how many pixels wide the mask is for that byte. Left hand side rotates left, right hand side rotates right - and it's reasonable to assume that you don't want to mask between the extremes of pixels, since that's sprite.

Not particularly fast, but if you're decompressing material for use, then this would work in most cases...


From the random code (imagine this is left side, and your sprite byte arrived in A):
Code:
LD C,255
    randomBinLoop:
    RLA
    JR C, randomBinLoopExit
    RR C
    JR randomBinLoop ; LOOP back UNTIL we find a bit.
    randomBinLoopExit:

Of course, this is rotating C the wrong way to be a graphics mask - I wanted to mask the active bits, not the missing ones, here.
Not a bad idea after all. This would save a lot of memory, especialy if the graphics is compressed.
Before my father died, I already made Aplib compression for DEFB's in BorIDE, and lot more, so decompression of graphics and autogenerating mask could be great for simple sprites. Bigger and more complex sprites on the other side, won't be suitable for automasking.
Anyway, I want to add Masking ability in BorIDE's Painter later.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
#34
Quote:Not a bad idea after all. This would save a lot of memory, especialy if the graphics is compressed.

Yes - this method is pretty simple. On the plus side it doesn't mask out holes in the sprite. On the downside, if it can't be "filled" from the side, it will be imperfect.

You could do a whole fill routine, I suppose, to build a mask. Or mask all 0 bits anyway, and have the eyes see through? Smile
Reply
#35
britlion Wrote:
Quote:Not a bad idea after all. This would save a lot of memory, especialy if the graphics is compressed.

Yes - this method is pretty simple. On the plus side it doesn't mask out holes in the sprite. On the downside, if it can't be "filled" from the side, it will be imperfect.

You could do a whole fill routine, I suppose, to build a mask. Or mask all 0 bits anyway, and have the eyes see through? Smile
This depends on the Sprites itself. Small solid sprites have usualy no holes.
Rotation 1xleft and 1x right, then OR the results, and you have a nice mask too Smile.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
#36
Clever! I like that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)