Sunday, January 6, 2013

Preliminary algorithm discovered for LDP-1450 text

I've discovered a preliminary algorithm for rendering LDP-1450 overlay text which will probably undergo a lot of tweaking as I study the different modes that the text can be rendered in.

But if the text is rendered in the mode that Dragon's Lair 2 uses, here is a pretty close approximation (pretty close meaning it is within 1 pixel of being perfectly aligned with the original capture).

Here is the original capture I just made:

First of all, I should mention that I am quite sure that each character is stored internally (in the LDP-1450) as a 16x16 bitmap.  When it is rendered in the above mode from the capture, it is stretched vertically by a factor of 2 (so every character is 32 lines tall).  Attempting to render a character in a multiple other than 16 would require complex graphics hardware which is probably beyond the technology available when this player was made (or at least it would've been very expensive) so it is safe to assume all rendered characters must be either 16, 32, or 48/64 lines tall (so far I have only encountered 16 and 32 lines tall).  If I am wrong about this, I will be very surprised (but I will still find it very interesting).

The horizontal stretching is another matter.  In the case of this capture, each character is about 25 or 26 pixels wide, so it scales about 1.625x or 1.5625x.  I decided to measure a whole row of characters to try to get a more accurate scaling factor and found that an entire row of 10 characters is about 261 pixels (internally this would be 160 pixels), so each character is about 26.1 pixels wide.  This means that the actual scaling factor is about 1.63125 ;  so we take the total width (720) and divide by this number and end up with 441.379 pixels as a "native" resolution in which we can write characters that are 16 pixels wide and then let the hardware handle scaling for us.  Unfortunately, 441.379 is not an available resolution so we are forced to choose either 441 or 442; I decided to go for 441.

So how to test to see how close to the original I can come if I use a resolution of 441x240 ?

First, I re-create the 10x3 grid of characters which is 160x48 pixels.  NOTE that since I created this by hand, I only added the grey borders around some of the edge characters.  This is not some flaw in my logic :)

Then I place it in a 441x240 black rectangle, using GIMP to figure out which X and Y pixels to paste it at.

Then I scale this up to 720x480 and compare it to the original to see how close I got.

By zooming in on GIMP, I verified that I am only off at most by 1 pixel (the right-most edge extends 1 pixel beyond the original capture).  This is _probably_ as good as I am going to be able to get.  The human eye will (of course) not be able to tell any difference.

Conclusion: render 16x16 letters to a 441x240 surface and let the OpenGL hardware scale it up to 640x480 or 720x480 or whatever!

No comments:

Post a Comment