FAQ  •  Register  •  Login

Cooming 2013: "Yumiko in the haunted Mansion"

Moderator: nitrofurano

<<

LCD

Posts: 596

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Thu Jan 03, 2013 12:50 am

Re: Cooming 2013: "Yumiko in the haunted Mansion"

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. ;)

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!
<<

britlion

Posts: 766

Joined: Mon Apr 27, 2009 7:26 pm

Location: Slough, Berkshire, UK

Post Thu Jan 03, 2013 4:38 am

Re: Cooming 2013: "Yumiko in the haunted Mansion"

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.
<<

LCD

Posts: 596

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Thu Jan 03, 2013 8:56 am

Re: Cooming 2013: "Yumiko in the haunted Mansion"

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!
<<

britlion

Posts: 766

Joined: Mon Apr 27, 2009 7:26 pm

Location: Slough, Berkshire, UK

Post Thu Jan 03, 2013 12:53 pm

Re: Cooming 2013: "Yumiko in the haunted Mansion"

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? :)
<<

LCD

Posts: 596

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Thu Jan 03, 2013 8:53 pm

Re: Cooming 2013: "Yumiko in the haunted Mansion"

britlion wrote:
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? :)

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 :).
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

britlion

Posts: 766

Joined: Mon Apr 27, 2009 7:26 pm

Location: Slough, Berkshire, UK

Post Thu Jan 03, 2013 9:12 pm

Re: Cooming 2013: "Yumiko in the haunted Mansion"

Clever! I like that.
Previous

Return to Gallery

Who is online

Users browsing this forum: No registered users and 2 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO