PoP 1 Sprites Conversion Tool

Discussions about all other tools (CusPop, SAV/HOF editors) and hex editing.

Moderator: English Moderator Team

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

PoP 1 Sprites Conversion Tool

Post by lvcabral » August 5th, 2016, 5:59 am

In my quest to convert the PoP Mods to be used by my Roku port, I decided to create a tool to help me on this endeavor.

The result is the PoP Sprites Converter popsc

You can find the source code at: https://github.com/lvcabral/PoPSpritesConverter
And the released binary at: https://github.com/lvcabral/PoPSpritesC ... /v1.0.0.77

It requires a complete set of exported image and palette files using David's PR 1.3.1 pre-release 2.

Usage:

Code: Select all

popsc <PR resources path> <sprites output path> [-pwm=<palace marks mode>]

Optional parameter:
0 : Change palace wall marks palette to the 15th color of wall.pal (default)
1 : Keep palace wall marks pallete from the bmp files
2 : Special palace wall marks configuration for SNES Mods
Features:
  • It exports both the individual frames as transparent png files, and packaged sprite sheets with its correspondent json maps.
  • It generates the sprites of the guards in all 7 different colors and the shadow using the XOR effect
  • The tiles are generated assembled as individual sprites.
I decided to release the code so anyone that create mods could convert their mods to be used in the upcoming v0.12 of my Roku remake.

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

Re: PoP 1 Sprites Conversion Tool

Post by Norbert » August 5th, 2016, 10:42 am

I didn't actually test the program (yet), but I did try to get it to compile/link/run under Linux.
It works.
I had to rename the "packing" directory to "Packing" (with a capital p).
After that I could create the executable with: xbuild PoPSpritesConverter.csproj
It gave a warning, but I could ignore that warning: "Scenes.cs(42,48): warning CS0168: The variable `sheetPath' is declared but never used"
After that I could run the program with: mono popsc.exe

User avatar
oitofelix
Wise Scribe
Wise Scribe
Posts: 202
Joined: February 17th, 2016, 1:59 pm
Contact:

Re: PoP 1 Sprites Conversion Tool

Post by oitofelix » August 5th, 2016, 2:26 pm

Congratulations on this new tool, lvcabral! :)

Code: Select all

 88888  FFFFF Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF]
 8   8  F     http://oitofelix.freeshell.org/mininim/
 88888  FFFF  mailto:oitofelix@gnu.org
 8   8  F     irc://chat.freenode.org/oitofelix
 88888  F     Please, support my work: http://oitofelix.freeshell.org/funding.html

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

Re: PoP 1 Sprites Conversion Tool

Post by lvcabral » August 5th, 2016, 5:40 pm

Norbert wrote:I didn't actually test the program (yet), but I did try to get it to compile/link/run under Linux.
It works.
I had to rename the "packing" directory to "Packing" (with a capital p).
After that I could create the executable with: xbuild PoPSpritesConverter.csproj
It gave a warning, but I could ignore that warning: "Scenes.cs(42,48): warning CS0168: The variable `sheetPath' is declared but never used"
After that I could run the program with: mono popsc.exe
I will.fix those Norbert, thanks for the test on Linux.

I will also attach to the release a zip with sample input files to make test it easier.

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

Re: PoP 1 Sprites Conversion Tool

Post by lvcabral » August 5th, 2016, 5:40 pm

oitofelix wrote:Congratulations on this new tool, lvcabral! :)
Obrigado oitofelix!

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

Re: PoP 1 Sprites Conversion Tool

Post by lvcabral » August 10th, 2016, 5:59 pm

I submitted to github a fix for the tile build method to an issue I discovered while converting Norbert's "Prince of Wateria" mod.

BTW nice trick using a wall tile as a background decoration.

I also created a set of batch files to use wget, apoplexy, pr and my tool to download and convert mod levels and sprites into a folder ready to be used by Roku remake. I will release it together with a simple UI as a "Total Pack" for my version of the game.

Below a screenshot with the early version of the UI:
Image

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

Re: PoP 1 Sprites Conversion Tool

Post by Norbert » August 10th, 2016, 6:52 pm

lvcabral wrote:BTW nice trick using a wall tile as a background decoration.
Thanks. I was trying to do something similar as KingOfPersia did (Ctrl+f for his mod) with his Repetition of Time.
lvcabral wrote:I also created a set of batch files [...]
Just a heads up, if you use mods.xml, see also modsu.xml. The latter is a lot smaller (>300kB versus <300b) and usable to check when the former was last updated. The latter is used by starwindz's Total Pack to notify the user of available updates.

By the way, maybe it's not my place to bring this up, but I was thinking that maybe starwindz, who has released several Total Packs (PoP1, PoP2, C64), prefers "Total Pack" to be used for just his software. I personally do associate it with him.

Somewhat related, I noticed that your program's icon is the same as what I picked for apoplexy. It's the prince's head, which was not a very original pick on my part, but your icon does exactly match my icon: the same selection of pixels of the head facing left. Obviously I don't have a monopoly here, but I was just thinking from your perspective that you could have stronger, more unique branding. To prevent misunderstanding, feel free to keep it as is though, I don't mind it; just noticed the similarity.

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

Re: PoP 1 Sprites Conversion Tool

Post by lvcabral » August 10th, 2016, 7:01 pm

Norbert wrote:Just a heads up, if you use mods.xml, see also modsu.xml. The latter is a lot smaller (>300kB versus <300b) and usable to check when the former was last updated. The latter is used by starwindz's Total Pack to notify the user of available updates.
I will use that, thanks.

Norbert wrote:By the way, maybe it's not my place to bring this up, but I was thinking that maybe starwindz, who has released several Total Packs (PoP1, PoP2, C64), prefers "Total Pack" to be used for just his software. I personally do associate it with him.

Somewhat related, I noticed that your program's icon is the same as what I picked for apoplexy. It's the prince's head, which was not a very original pick on my part, but your icon does exactly match my icon: the same selection of pixels of the head facing left. Obviously I don't have a monopoly here, but I was just thinking from your perspective that you could have stronger, more unique branding. To prevent misunderstanding, feel free to keep it as is though, I don't mind it; just noticed the similarity.
I will change both, it was just lack of creativity :) I did not want to think about new names and icons at this early stage.

An issue I have now is know how to to handle some mods that the author renamed the DAT files, I assume they hack the PRINCE.EXE to have the different name. I could use PR to extract all (regardless of the name) but there are other mods that keep the original dat files in the ZIP file, that would be a problem using PR for all DAT files in this case.

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

Re: PoP 1 Sprites Conversion Tool

Post by Norbert » August 10th, 2016, 7:40 pm

lvcabral wrote:author renamed the DAT files, I assume they hack the PRINCE.EXE
I don't know exactly what you want to do, but I'll give an example of how to figure out the name of the file with levels (default: LEVELS.DAT).

The file princehack.xml (latest version) used by CusPop contains this section:

Code: Select all

<read name="Levels" readoperation="tolower;" default="levels.dat" writeoperation="toupper;" type="string" size="10"/>
<offset file="p0" value="0x1ae28"/>
<offset file="p3" value="0x1bb26"/>
<offset file="p4" value="0x17eaa"/>
<offset file="u0" value="0x1c984"/>
<offset file="u3" value="0x1c742"/>
<offset file="u4" value="0x1909e"/>
It gives you offsets to where the string of 10 characters is inside the executable that give you the name of the file with levels.

It lists 6 offsets: packed and unpacked variants of PoP1 executables for versions 1.0, 1.3 and 1.4. (2 x 3 = 6)

The file apoplexy.c contains this code:

Code: Select all

      stat (POP1_EXECUTABLE, &stStatus);
      switch ((int)stStatus.st_size)
      {
        case 123335:
          snprintf (sEXEType, MAX_EXETYPE, "%s", "p0");
          iEXEType = 0; iEXEPacked = 1; break;
        case 129504:
          snprintf (sEXEType, MAX_EXETYPE, "%s", "u0");
          iEXEType = 1; iEXEPacked = 0; break;
        case 125115:
          snprintf (sEXEType, MAX_EXETYPE, "%s", "p3");
          iEXEType = 2; iEXEPacked = 1; break;
        case 129472:
          snprintf (sEXEType, MAX_EXETYPE, "%s", "u3");
          iEXEType = 3; iEXEPacked = 0; break;
        case 110855:
          snprintf (sEXEType, MAX_EXETYPE, "%s", "p4");
          iEXEType = 4; iEXEPacked = 1; break;
        case 115008:
          snprintf (sEXEType, MAX_EXETYPE, "%s", "u4");
          iEXEType = 5; iEXEPacked = 0; break;
        default:
          snprintf (sEXEType, MAX_EXETYPE, "%s", "unknown"); break;
      }
It checks the number of bytes of the executable, to determine the variant.
(Careful with the different order here, e.g. p0 p3 etc. for XML, and p0 u0 etc. for C.)

This should be enough to determine the name of the file with levels.
Of course, something similar could be done with other file names.
The program diffpop does something similar.

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

Re: PoP 1 Sprites Conversion Tool

Post by lvcabral » August 11th, 2016, 5:39 pm

Thanks for the detailed information Norbert!

I noticed that the xml has some information about the mods, like the executable name and minutes to finish the game, but other information like number of initial and maximum health points are not there. Would maybe interesting to have a tool to extract this info from the executable and generate the xml entries.

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

Re: PoP 1 Sprites Conversion Tool

Post by lvcabral » August 14th, 2016, 5:46 am

Just released a new version of the PoP 1 Sprites Conversion tool:
https://github.com/lvcabral/PoPSpritesC ... v1.1.0.130

It now correctly supports mods with wda (wall-drawing algorithm) on palace tiles and support multicolor palettes on potion bubbles.

The GUI tool I mentioned in a previous post is not open to everyone yet, I need to work on the UI a little bit and see if I can add more features before open the source. I renamed it to "PoP 1 Mod Converter" and it uses wget, 7zip, apopplexy, pr and PopSpritesConverter to download, extract, convert graphics and generate a mod package for Roku. I'm so happy I managed to create this, now I convert any mod in seconds :)

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

Re: PoP 1 Sprites Conversion Tool

Post by Norbert » August 14th, 2016, 10:15 am

lvcabral wrote:I'm so happy I managed to create this, now I convert any mod in seconds :)
Nice. :)

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

Re: PoP 1 Sprites Conversion Tool

Post by lvcabral » August 15th, 2016, 5:45 am

New release to address two small fixes related to palace tiles (mirror, balcony):
https://github.com/lvcabral/PoPSpritesC ... v1.1.1.133

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

Re: PoP 1 Sprites Conversion Tool

Post by lvcabral » August 24th, 2016, 6:41 am

Release v1.1.2 is available at:

https://github.com/lvcabral/PoPSpritesC ... v1.1.2.147

Changelog:
  • Add: Support for different palettes on tiles (DOS 1.3 & 1.4)
  • Fix: Door frames painting is wrong
  • Fix: Stars frames to scenes are not included on sprite map
  • Fix: Title messages should not be transparent (except game-name)
  • Fix: Slicer painting is wrong
  • Fix: Palace potions are getting dungeon graphics
  • Fix: Dungeon should only have two potion foreground tiles

salvadorc17
Calif
Calif
Posts: 523
Joined: August 27th, 2011, 2:04 am

Re: PoP 1 Sprites Conversion Tool

Post by salvadorc17 » August 29th, 2016, 10:39 pm

Good work with this, now the question will be if you want to expand engine with snes features...

Post Reply