poplaun 0.1

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

Moderator: English Moderator Team

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

poplaun 0.1

Post by Norbert » February 26th, 2017, 2:25 am

A tool to download and launch Prince of Persia mods by parsing popot.org XML files.

GNU/Linux download: poplaun-0.1.tar.gz
Windows download: poplaun-0.1-win32.zip

There is no Windows version (yet).
I'd be grateful if someone with the required skills would create a Windows port. Please read:
Spoiler: show
The source code is one file.
It includes checks if WIN32/WIN64 is defined, and should have all the Windows specific code.
However, I coded these portions 'blind', not being able to verify them.
The code complies with the c99 standard.

It relies on three cross-platform libraries: GTK+ 3.18+ (3.18.9 to be exact), libzip and libxml2.

The Windows specific code expects ZSNES\ and DOSBox\ directories to be available.
Those directories can be found in the latest apoplexy package for Windows.

The docs/README.txt file of apoplexy ends with some information on how to compile using Dev-C++.
This is not fully usable, but it does have instructions that show how to set things like C compiler options, and how to work with MinGW(64).

The program itself loads a window icon.
If, for some reason, none shows up, you could use from the package:
poplaun-0.1/png/poplaun_icon.ico

Please verify you can launch a:
- PoP1 for DOS mod,
- PoP2 for DOS mod,
- PoP1 for SNES mod,
- SDLPoP mod (Secrets of the Citadel).
Also, all but the SNES mods should be able to launch directly in level, let's say, 3.

If you look into this, please write down what exactly you did to pull it off.
I've been unable to create a Windows port, and you could semi-teach me how to fish.
Thanks a lot in advance.
Image
Last edited by David on March 11th, 2017, 9:55 am, edited 1 time in total.
Reason: Added link for Windows version

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

Re: poplaun 0.1

Post by David » February 26th, 2017, 1:51 pm

Norbert wrote: I'd be grateful if someone with the required skills would create a Windows port.

If you look into this, please write down what exactly you did to pull it off.
I've been unable to create a Windows port, and you could semi-teach me how to fish.
This is what I found so far:
Here is how I could compile poplaun for Windows:

The required libraries

libzip:
https://apps.fedoraproject.org/packages ... zip/builds (choose the newest)
libzip: https://kojipkgs.fedoraproject.org//pac ... noarch.rpm

libxml2:
According to the dependency graph (https://www.zlatkovic.com/libxml.en.html), I need these:
libxml2: ftp://ftp.zlatkovic.com/libxml/64bit/li ... n32-x86.7z
iconv: ftp://ftp.zlatkovic.com/libxml/64bit/ic ... n32-x86.7z
zlib: ftp://ftp.zlatkovic.com/libxml/64bit/zl ... n32-x86.7z

GTK+:

https://www.gtk.org/download/windows.php
The current GTK+ stack uses APIs that are available only on Windows Vista or later.
If you require builds for unsupported versions of Windows, you should do a custom build of an older version of GLib and GTK+.
This is going to be a long day...
At least they could have told me which "older version" should I try.

Anyway, (the source of) the version you mentioned is here: http://ftp.gnome.org/pub/gnome/sources/ ... 8.9.tar.xz
UPDATE:
And the binary is here: http://dl.fedoraproject.org/pub/fedora/ ... noarch.rpm
Found by this search: https://pkgs.org/download/mingw32-gtk3
(It's somewhat odd that mingw packages are on Fedora's site...)

Unfortunately, that binary relies on a system file that is not in Windows XP. (dwmapi.dll)
So I used this version of GTK+ instead: http://dl.fedoraproject.org/pub/epel/7/ ... noarch.rpm

And of course there are the dependencies: (From Fedora 23 to match GTK+.)
* glib2: http://dl.fedoraproject.org/pub/fedora/ ... noarch.rpm
* pango: http://dl.fedoraproject.org/pub/fedora/ ... noarch.rpm
* cairo: http://dl.fedoraproject.org/pub/fedora/ ... noarch.rpm
* gdk-pixbuf: http://dl.fedoraproject.org/pub/fedora/ ... noarch.rpm
* atk: http://dl.fedoraproject.org/pub/fedora/ ... noarch.rpm
And the dependencies that are not required for compiling, only for running: (DLLs)
* libffi: http://dl.fedoraproject.org/pub/fedora/ ... noarch.rpm
* libpng: http://dl.fedoraproject.org/pub/fedora/ ... noarch.rpm
And even more required DLLs that I copied from GIMP's folder...
* libfontconfig-1.dll
* libgcc_s_dw2-1.dll
* libgcc_s_sjlj-1.dll
* libintl-8.dll
* libpixman-1-0.dll

Installing the *.rpm packages:
* Open it with 7-zip.
* Go down in the nested archives and folders until you find the mingw folder.
* Extract that mingw folder somewhere. You should "overwrite" the mingw folder from the previous version. (But there will be no real overwrites, since all of them contain different files.)

Installing the *.7z packages
* Extract them into the aforementioned mingw folder.

Making a Dev-C++ project

Changes needed in the poplaun.c:
* You need to change \ to \\ in the path strings.
* In ShellExecute(), for some reason, an additional "..\" is required.
Either that, or remove the trailing slash from sDir.
* If the name of the SNES ROM file contains spaces (example: Prince Of Persia Evolution.snes) then it must be quoted in sPar.
Otherwise ZSNES will start without loading the ROM.
* The name of GetMenu() clashes with a function in windows.h. It has to be renamed.
I used this trick:

Code: Select all

#if defined WIN32 || _WIN32 || WIN64 || _WIN64
#include <windows.h>
#define GetMenu POPLAUN_GetMenu // windows.h also has a GetMenu().
#endif
Project options -> Directories -> Library
* Add the ...\mingw\lib folder. (That is within the aforementioned mingw folder.)

Project options -> Directories -> Include
* Add the ...\mingw\include folder, and all of its immediate subfolders.
* Alternately, you could move the contents of the subfolders (usually a single folder) out of them.

Project options -> Parameters -> Linker -> add these:

Code: Select all

-l"gdk_pixbuf-2.0.dll"
-l"gio-2.0.dll"
-l"glib-2.0.dll"
-l"gobject-2.0.dll"
-l"gtk-3.dll"
-l"xml2.dll"
-l"zip.dll"
Needed DLLs: (copy them to the folder of poplaun.exe)

Code: Select all

libatk-1.0-0.dll
libcairo-2.dll
libcairo-gobject-2.dll
libffi-6.dll
libfontconfig-1.dll
libfreetype-6.dll
libgcc_s_dw2-1.dll
libgcc_s_sjlj-1.dll
libgdk-3-0.dll
libgdk_pixbuf-2.0-0.dll
libgio-2.0-0.dll
libglib-2.0-0.dll
libgmodule-2.0-0.dll
libgobject-2.0-0.dll
libgtk-3-0.dll
libiconv-2.dll
libintl-8.dll
libpango-1.0-0.dll
libpangocairo-1.0-0.dll
libpangowin32-1.0-0.dll
libpixman-1-0.dll
libpng16-16.dll
libxml2-2.dll
libzip-4.dll
zlib1.dll
Remaining problems
* Hyperlinks don't work.

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

Re: poplaun 0.1

Post by Norbert » February 26th, 2017, 3:13 pm

Awesome David. :D
I'll create the Windows port, based on your explanation, next week.

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

Re: poplaun 0.1

Post by salvadorc17 » February 27th, 2017, 10:33 pm

What do you think about android port for this tool, or other systems?

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

Re: poplaun 0.1

Post by Norbert » February 28th, 2017, 12:05 am

salvadorc17 wrote:What do you think about android port for this tool, or other systems?
Android and iOS will not be possible.
I will create a Windows port this week.
OS X is possible in theory, but I won't look into that.

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

Re: poplaun 0.1

Post by Norbert » March 1st, 2017, 8:53 am

Windows download: poplaun-0.1-win32.zip

If a moderator can also add the above line to the first post of this thread, thanks.

The package includes a docs/compile_win32.txt file that credits David for helping out.

David, you can do a diff to see what ShellExecute() solution I've eventually settled with.

Note that popot.org is currently down constantly.
If popot.org is down the program doesn't work properly, it may hang or whatever.

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

Re: poplaun 0.1

Post by Norbert » March 1st, 2017, 11:15 am

On Linux, when I test the Windows application (with an emulator), it only works the first time I run it.
If I use the application again, it crashes.
Does this also happen on Windows?

Falcury
Wise Scribe
Wise Scribe
Posts: 315
Joined: June 25th, 2009, 10:01 pm

Re: poplaun 0.1

Post by Falcury » March 1st, 2017, 7:12 pm

Nice job! I tested it in VirtualBox under Debian, works fantastic.
Maybe you could add in the documentation that DOSBox and zsnes are not included, and should be installed/downloaded separately for playing the DOS and SNES mods?

Just downloaded the Windows version.

I am getting many warnings like this in the console:

Code: Select all

(poplaun.exe:5352): Gtk-WARNING **: Could not find the icon 'pan-down-symbolic-l
tr'. The 'hicolor' theme
was not found either, perhaps you need to install it.
You can get a copy from:
        http://icon-theme.freedesktop.org/releases

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OB
JECT (object)' failed

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OB
JECT (object)' failed

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OB
JECT (object)' failed

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OB
JECT (object)' failed

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OB
JECT (object)' failed

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OB
JECT (object)' failed

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OB
JECT (object)' failed

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OB
JECT (object)' failed

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): Gtk-WARNING **: Error loading theme icon 'image-missing' for
 stock: Icon 'image-missing' not present in theme Adwaita

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJE
CT (object)' failed

(poplaun.exe:5352): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OB
JECT (object)' failed
I get a new batch of warnings when I do certain things, e.g. focus or unfocus the application window.

When I press Play for any DOS mod, nothing happens. (There also is no failure message in the console.)
Similar for SNES mods.
SDLPoP mods (Secrets of the Citadel) seem to work fine.

About using GTK on Windows: maybe it would be a good idea to write a native Win32 window layer at some point... That could drive the program size (including the dependencies) down quite a bit, because most of the DLLs (~20 MB) would no longer be needed.

(By the way, I see that libxml2-2.dll is surprisingly one of the largest DLLs in the set (4.5 MB). I would expect XML parsing to be very lightweight...)

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

Re: poplaun 0.1

Post by Norbert » March 1st, 2017, 7:29 pm

Falcury wrote:When I press Play for any DOS mod, nothing happens. (There also is no failure message in the console.) Similar for SNES mods.
That means ShellExecute() still has trouble finding the right files.
In the Wine emulator on Linux it works fine. Sigh.

[Edit:]
Falcury wrote:I am getting many warnings like this in the console: [...]
These show up because I didn't include
share/icons/Adwaita/.../actions/application-exit*
share/icons/Adwaita/.../actions/help-about*
files in the package. These are used as menu icons.

Since - apparently - I cannot properly test the functionality of ShellExecute() in Wine under Linux, I'll have to ask someone to follow the docs/compile_win32.txt guide on Windows, and then modify the (3rd parameter of) the ShellExecute() functions used for DOSBox and for ZSNES until these two applications launch in-program. This shouldn't be too much work. For DOSBox, the solution is probably "..\\..\\DOSBox\\DOSBox.exe" or "..\..\\..\\DOSBox\\DOSBox.exe" or "..\\..\\..\\DOSBox\\DOSBox.exe". Maybe remove the chdir()'s above and below the line. For ZSNES something similar.

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

Re: poplaun 0.1

Post by David » March 4th, 2017, 12:05 pm

At this part:

Code: Select all

chdir (sDir);
ShellExecute (NULL, "open", "DOSBox\\DOSBox.exe",
	sPar, sDir, SW_SHOWNORMAL);
chdir ("..\\.."); 
I had to change that into:

Code: Select all

chdir (sDir);
ShellExecute (NULL, "open", "..\\..\\DOSBox\\DOSBox.exe",
	sPar, NULL, SW_SHOWNORMAL);
chdir ("..\\..");
Similarly for the other places, i.e.:
* Change the 5th parameter from sDir to NULL. (Since you already chdir() to that folder.)
* And add "..\\..\\" in front of the 3rd parameter if it's a string literal. (ZSNES and DOSBox) (They are not in the mod's directory.)
* If the 3rd parameter is sPar then you don't need to change it. (SDLPoP and MININIM) (The batch file is in the mod's directory.)

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

Re: poplaun 0.1

Post by Norbert » March 4th, 2017, 9:05 pm

Thanks David.

I have also figured out how to stop poplaun 0.1 for Windows from crashing when I launch it a 2nd time in Wine.
In DateTimeToPosix() I had to change
sscanf (sDateTime, "%i-%i-%i %i:%i:%i", &iYear, &iMonth, &iDay, &iHour, &iMinute, &iSecond);
to
sscanf (sDateTime, "%4u-%2u-%2u %2u:%2u:%2u", &iYear, &iMonth, &iDay, &iHour, &iMinute, &iSecond);

I'll recompile and fix version 0.1 for Windows soon.

[Edit: Done. I have also updated the 0.1 for Linux to include all changes.]
Last edited by Norbert on March 4th, 2017, 10:24 pm, edited 2 times in total.

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

Re: poplaun 0.1

Post by salvadorc17 » March 4th, 2017, 9:58 pm

Also you could add prince of persia net to Pop launch, will be cool to have all versions included..

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

Re: poplaun 0.1

Post by Norbert » March 4th, 2017, 10:00 pm

Norbert wrote:Windows download: poplaun-0.1-win32.zip

If a moderator can also add the above line to the first post of this thread, thanks.
Can someone do this.

I have fixed the Windows version.
salvadorc17 wrote:Also you could add prince of persia net to Pop launch, will be cool to have all versions included..
I'll have to think about this.
The technical implications, also for popot.org.

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

Re: poplaun 0.1

Post by salvadorc17 » March 4th, 2017, 10:24 pm

Norbert wrote:
I'll have to think about this.
The technical implications, also for popot.org.
Yes, could be possible i can add support for pop dat files and other needed into it...

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

Re: poplaun 0.1

Post by Norbert » March 5th, 2017, 3:22 pm

For version 0.2 I will fix launching mods with multiple executables.
And that version will also properly deal with the new [ spoiler ] tag.

Post Reply