DOS Shadow Sprites

About PR usage and development, and about the POP format.
Post Reply
lvcabral
Vizier
Vizier
Posts: 115
Joined: March 11th, 2016, 10:34 pm

DOS Shadow Sprites

Post by lvcabral »

I understand that in DOS port the Shadow is done programmatically but anyone ever captured the images to have the sprites already changed ?
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: DOS Shadow Sprites

Post by Norbert »

Some possible paths to obtain what you want:
- Use the images of the prince, and make them partially transparent, as MININIM does.
- Use the images of the prince, and process them with custom code taken partially from SDLPoP.
- Use a terminal/shell (command-line) and run a program to process the images of the prince, for example with G'MIC or ImageMagick.

Note that - readers, correct me if I'm wrong - the bitwise xor operation is performed with two images (layers). As you can see in the attached image, the location of the shadow impacts the look of his face (and body) because of the position of the background's shadow. When using G'MIC or ImageMagick, the second layer could just be fully black. But this is why making screenshots of the game itself, for instance frame by frame to get the images, isn't ideal.

I've had no success with this, but ImageMagick's convert might be usable like this:
convert in1.png in2.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" out.png
(I found that on StackOverflow.)

And G'MIC like this, although I wouldn't know what value "200" should be changed into:
gmic in.png -xor 200 -o out.png

Also, GIMP has a gimp-gmic plug-in.
You'd need two layers, and then go to: Filters -> G'MIC...
- On the left, for "Input layers..." pick "All".
- Layers -> Blend [standard] -> Mode: Xor
- Apply.

Actually, I don't understand why the shadow has a white outline.
Maybe there's more going on than just a bitwise xor?
Attachments
bitwise xor
bitwise xor
bitwise_xor.png (7.01 KiB) Viewed 3598 times
lvcabral
Vizier
Vizier
Posts: 115
Joined: March 11th, 2016, 10:34 pm

Re: DOS Shadow Sprites

Post by lvcabral »

Thanks Norbert, great explanation.

I already did something similar to MININIM but I would prefer to have it look closer to the original.
lvcabral
Vizier
Vizier
Posts: 115
Joined: March 11th, 2016, 10:34 pm

Re: DOS Shadow Sprites

Post by lvcabral »

I did a quick test using Paint.Net and it seems I got good results!
Attachments
ShadowTest.PNG
lvcabral
Vizier
Vizier
Posts: 115
Joined: March 11th, 2016, 10:34 pm

Re: DOS Shadow Sprites

Post by lvcabral »

I managed to make the sprites look like the original, I think this is good enough :)

Thanks again Norbert for the tips.
screenshot-43-20160604.jpg
lvcabral
Vizier
Vizier
Posts: 115
Joined: March 11th, 2016, 10:34 pm

Re: DOS Shadow Sprites

Post by lvcabral »

Just to share If someone needs these sprites I'm attaching a zip with all the frames I needed to the shadow.
Attachments
shadow-dos.zip
(86.1 KiB) Downloaded 121 times
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: DOS Shadow Sprites

Post by David »

Norbert wrote:Actually, I don't understand why the shadow has a white outline.
Maybe there's more going on than just a bitwise xor?
Well, that's exactly what happens if you xor the white clothes with the black background.

As a side note, the original DOS game xors the color indices instead of the RGB values.
And, the "base" image is drawn with the or blitter there, which I replaced in SDLPoP with a simple transparent blitter.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: DOS Shadow Sprites

Post by Norbert »

David wrote:
Norbert wrote:Actually, I don't understand why the shadow has a white outline.
Well, that's exactly what happens if you xor the white clothes with the black background.
That doesn't make any sense to me, but I trust your word for it.
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: DOS Shadow Sprites

Post by David »

(Continuing the outline thing.)
Basically, if you have a row of white pixels, with black at each end, then this will happen if you xor the image with its copy shifted one pixel: (see attachment)
Black = 0, so White xor White = Black and White xor Black = White.
Attachments
bitwise_xor_explain_2.png
bitwise_xor_explain_2.png (3 KiB) Viewed 3561 times
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: DOS Shadow Sprites

Post by Norbert »

Thanks for explaining it.
With "its copy shifted one pixel" it all makes sense.
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: DOS Shadow Sprites

Post by David »

Wait, did you think the two copies are positioned exactly on top of each other?

By the way, here is how the shadow is drawn in SDLPoP: https://github.com/NagyD/SDLPoP/blob/ma ... 08.c#L1528
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: DOS Shadow Sprites

Post by Norbert »

David wrote:Wait, did you think the two copies are positioned exactly on top of each other?
I initially did, yes.
Post Reply