DOS Shadow Sprites

About PR usage and development, and about the POP format.

Moderator: English Moderator Team

lvcabral
Vizier
Vizier
Posts: 86
Joined: March 11th, 2016, 10:34 pm

DOS Shadow Sprites

Postby lvcabral » June 4th, 2016, 10:41 pm

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: 3020
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: DOS Shadow Sprites

Postby Norbert » June 5th, 2016, 12:16 am

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.png
bitwise xor
bitwise_xor.png (7.01 KiB) Viewed 476 times

lvcabral
Vizier
Vizier
Posts: 86
Joined: March 11th, 2016, 10:34 pm

Re: DOS Shadow Sprites

Postby lvcabral » June 5th, 2016, 2:20 am

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: 86
Joined: March 11th, 2016, 10:34 pm

Re: DOS Shadow Sprites

Postby lvcabral » June 5th, 2016, 6:45 am

I did a quick test using Paint.Net and it seems I got good results!
Attachments
ShadowTest.PNG

lvcabral
Vizier
Vizier
Posts: 86
Joined: March 11th, 2016, 10:34 pm

Re: DOS Shadow Sprites

Postby lvcabral » June 5th, 2016, 7:46 am

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: 86
Joined: March 11th, 2016, 10:34 pm

Re: DOS Shadow Sprites

Postby lvcabral » June 5th, 2016, 11:45 pm

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 14 times

David
The Prince of Persia
The Prince of Persia
Posts: 1401
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: DOS Shadow Sprites

Postby David » June 7th, 2016, 7:02 pm

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: 3020
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: DOS Shadow Sprites

Postby Norbert » June 7th, 2016, 9:58 pm

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: 1401
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: DOS Shadow Sprites

Postby David » June 11th, 2016, 12:30 pm

(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 439 times

User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 3020
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: DOS Shadow Sprites

Postby Norbert » June 11th, 2016, 2:54 pm

Thanks for explaining it.
With "its copy shifted one pixel" it all makes sense.

David
The Prince of Persia
The Prince of Persia
Posts: 1401
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: DOS Shadow Sprites

Postby David » June 16th, 2016, 4:49 pm

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: 3020
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: DOS Shadow Sprites

Postby Norbert » June 16th, 2016, 5:12 pm

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


I initially did, yes.


Return to “Princed Resources (PR)”

Who is online

Users browsing this forum: No registered users and 2 guests