SDLPoP; David's open-source port of PoP

Open-source port of PoP that runs natively on Windows, Linux, etc.
David
The Prince of Persia
The Prince of Persia
Posts: 2803
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: SDLPoP; David's open-source port of PoP

Post by David »

(I wanted to post this a week ago, but the forum kept timing out then...)
Norbert wrote: November 26th, 2022, 12:13 pm As an example, the documentation says, "T: Toggle display of timer".
To me, "T" is a capital t, which makes me do Shift+t, which increases hit points.
[Edit: Maybe it is just me and my programmer mind. That nobody else is confused by the documentation.]
Dunno, GIMP for example shows letter keys with capital letters, whether they need Shift or not...
GIMP en.png
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5685
Joined: April 9th, 2009, 10:58 pm

Re: SDLPoP; David's open-source port of PoP

Post by Norbert »

David wrote: January 8th, 2023, 4:25 pmDunno, GIMP for example shows letter keys with capital letters, whether they need Shift or not...
Yeah, it's fine as is, I just need to get used to it.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5685
Joined: April 9th, 2009, 10:58 pm

Re: SDLPoP; David's open-source port of PoP

Post by Norbert »

Can anyone tell me how the program knows that PRINCE/ has a collection of res151-173.png images that are part of a certain chtab that goes from 0-22 (and not e.g. 23)?
Time and time again, I try to modify SDLPoP to create custom stuff, but I simply cannot grasp how everything works. It's too complex for me. Every time I see a function, e.g. load_sprites_from_file(), it uses another function, e.g. load_from_opendats_alloc(), that uses another function, e.g. load_from_opendats_metadata(), and then I just lose track of things, and feel sad about how powerless I am when it comes to tweaking things.
Sometimes I then try to work around everything, by using my own image loading function and then drawing stuff to the screen, but the game loop is so intricate and tight that there's no way I can just dump something in there and have it show up in-game.
Damn. :(
David
The Prince of Persia
The Prince of Persia
Posts: 2803
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: SDLPoP; David's open-source port of PoP

Post by David »

Norbert wrote: January 8th, 2023, 10:18 pm Can anyone tell me how the program knows that PRINCE/ has a collection of res151-173.png images that are part of a certain chtab that goes from 0-22 (and not e.g. 23)?
The number of images is in the first byte of the palette, res150.pal in your example.
0x17 = 23 means that image IDs go from 150+1 = 151 to 150+23 = 173.

This code tells which set is loaded into which chtab:
(seg000.c)

Code: Select all

	dathandle = open_dat("PRINCE.DAT", 'G');
[...]
	// PRINCE.DAT: sword
	chtab_addrs[id_chtab_0_sword] = load_sprites_from_file(700, 1<<2, 1);
	// PRINCE.DAT: flame, sword on floor, potion
	chtab_addrs[id_chtab_1_flameswordpotion] = load_sprites_from_file(150, 1<<3, 1);
The original PoP has this weird system for loading resources, where the function which loads a resource doesn't have a DAT file name parameter, it just scans through whatever DAT files are open at the moment.

This code loads the palette, which also contains the number of images:
(seg009.c)

Code: Select all

	dat_shpl_type* shpl = (dat_shpl_type*) load_from_opendats_alloc(resource, "pal", NULL, NULL);
[...]
	int n_images = shpl->n_images;
[...]
	for (int i = 1; i <= n_images; i++) {
		SDL_Surface* image = load_image(resource + i, pal_ptr);
[...]
		chtab->images[i-1] = image;
	}
And here is the top-level structure of *.pal files:
(types.h)

Code: Select all

typedef struct dat_shpl_type {
	byte n_images;
	dat_pal_type palette;
} dat_shpl_type;
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5685
Joined: April 9th, 2009, 10:58 pm

Re: SDLPoP; David's open-source port of PoP

Post by Norbert »

David wrote: January 14th, 2023, 1:13 pmThe number of images is in the first byte of the palette, [...] [...]
All right, I'll get cracking again soon then.
Let's see what I can make.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5685
Joined: April 9th, 2009, 10:58 pm

Re: SDLPoP; David's open-source port of PoP

Post by Norbert »

Norbert wrote: January 14th, 2023, 5:35 pm
David wrote: January 14th, 2023, 1:13 pmThe number of images is in the first byte of the palette, [...] [...]
All right, I'll get cracking again soon then.
Let's see what I can make.
My plan was to add collectable rotating coins, using floors with modifier 0x04, for a coins-mod. I tried that for 1 day (14th), then gave up and converted the plan into this basic tile idea instead. Next, I created Puny Prince from scratch, and included the previously planned coins-mod in it as "Coins of Persia".
Post Reply