Falcury wrote:
I have a hunch what the reason might be.
It's probably because I used the linker flag /SUBSYSTEM:WINDOWS instead of /SUBSYSTEM:WINDOWS,5.01
This page has a description of the problem (if this is indeed the problem):
http://www.tripleboot.org/?p=423
Well, the subsystem version in the PE header of your EXE looks exactly like on their screenshot.
However, hex-editing your prince.exe was not enough, because it also uses VCRUNTIME140.dll and some api-ms-win-crt-*.dll files that I don't have.
Falcury wrote:
- There may be a memory leak when surfaces are created with SDL_CreateRGBSurfaceFrom(), because according to the documentation, SDL_FreeSurface() does not free the pixel data from which the surface was created.
After reading this, I thought that my original code has the same problem when loading images from DAT files.
But I use SDL_CreateRGBSurface() there:
https://github.com/NagyD/SDLPoP/blob/ma ... 009.c#L518
A thing to be careful of: you should manually free the pixel data *only* if it was allocated separately.
But sometimes you can't tell in advance whether you need to do that at a certain place.
For example, in free_chtab(), SDL_FreeSurface() might be called on images loaded from either PNGs or DATs, but the latter are *not* created using SDL_CreateRGBSurfaceFrom().
How to tell the difference?
There is a flag in each surface that tells SDL_FreeSurface() whether to free the pixel data.
https://hg.libsdl.org/SDL/file/b5cf1e85 ... ce.c#l1177
So when freeing a surface you should check that flag, and if it's set then free the pixel data manually.
Or maybe just clear the flag after creating the surface with SDL_CreateRGBSurfaceFrom().
Although I'm not sure if SDL_free() (in SDL_FreeSurface()) is compatible with regular malloc() (used in STB).
However, STB has an option to define what functions it should use for allocating and freeing memory.
Falcury wrote:
- Turning the sound off now also turns off the music, which wasn't the case with SDL_mixer.
Ctrl+S *should* turn off the music as well.
So the STB version is correct, and there is a bug in the original SDLPoP.
In the original SDLPoP, the intro music or the level 1 starting music will play even if sound is off. But the death music won't play.
And the original PoP for DOS has the opposite bug: Ctrl+S turns off only the music.
See here:
viewtopic.php?p=14208#p14208