SDLPoP; David's open-source port of PoP
- atrueprincefanfrom18
- Site Shah
- Posts: 1785
- Joined: January 21st, 2020, 2:53 pm
- Contact:
Re: SDLPoP; David's open-source port of PoP
On Linux, SDLPoP doesn't load the files which are cAsE sEnSiTiVe. Any fix that can be done? I just noticed this when I downloaded Return To Persia because of this discussion.
SDLPoP just detects that it's Levels.dat and not LEVELS.DAT, so loads the default directory with altered graphics.
Or is PoPOT (Norbert) responsible to use UPPERCASE file names before making it available to general public?
SDLPoP just detects that it's Levels.dat and not LEVELS.DAT, so loads the default directory with altered graphics.
Or is PoPOT (Norbert) responsible to use UPPERCASE file names before making it available to general public?
Re: SDLPoP; David's open-source port of PoP
PoPOT should perhaps do that anyway, at least for LEVELS.DAT.atrueprincefanfrom18 wrote: ↑January 6th, 2021, 4:11 pmOr is PoPOT (Norbert) responsible to use UPPERCASE file names before making it available to general public?
I've already created a PHP script that, if run from inside the mod's directory ($ php fix.php), renames the file:
Code: Select all
<?php
$arResult = preg_grep ('/' . preg_quote ('LEVELS.DAT') . '$/i', glob ("./*"));
if (count ($arResult) == 1) { rename (reset ($arResult), 'LEVELS.DAT'); }
?>
- atrueprincefanfrom18
- Site Shah
- Posts: 1785
- Joined: January 21st, 2020, 2:53 pm
- Contact:
Re: SDLPoP; David's open-source port of PoP
Maybe good for all (DAT) files. Because some graphics might be altered heavily, that SDLPoP should load them instead of the default ones otherwise the game might break.
Re: SDLPoP; David's open-source port of PoP
Maybe there could be a failure path, where if the case-sensitive filename is not found, SDLPoP checks the directory listing and tries to select another file that matches case-insensitively.atrueprincefanfrom18 wrote: ↑January 6th, 2021, 4:11 pm On Linux, SDLPoP doesn't load the files which are cAsE sEnSiTiVe. Any fix that can be done?
Re: SDLPoP; David's open-source port of PoP
Perhaps it's useful (and consistent) to add a...
replays/replays.txt
...similar to...
mods/mods.txt
...that explains .p1r files can be moved into that directory?
replays/replays.txt
...similar to...
mods/mods.txt
...that explains .p1r files can be moved into that directory?
- atrueprincefanfrom18
- Site Shah
- Posts: 1785
- Joined: January 21st, 2020, 2:53 pm
- Contact:
Re: SDLPoP; David's open-source port of PoP
Was playing Repetition Of Time. And I died and revived the Kid (R). I got to this room! Funny, what exactly does SDLPoP check while drawing the room? It might be anything because it's out of range memory data?
Re: SDLPoP; David's open-source port of PoP
There are 2 arrays in the level variable called "fg" and "bg". The index of the arrays is room # (minus one) times 30 tiles for that room. The first array returns types of tiles for each tile in the 24 rooms. The second array returns an array of modifiers for the corresponding tiles. Modifiers are responsible for wall stripes, animation frames (torch, potion, gate...)
https://github.com/NagyD/SDLPoP/blob/cd ... 08.c#L1438
In your case the room # is unpredictable and can point to some random values in the array. SDLPoP will try to match those values to the enum that represents tile types. An enum means many bit combinations is going to match to one of the values.
https://github.com/NagyD/SDLPoP/blob/cd ... 08.c#L1438
In your case the room # is unpredictable and can point to some random values in the array. SDLPoP will try to match those values to the enum that represents tile types. An enum means many bit combinations is going to match to one of the values.
Re: SDLPoP; David's open-source port of PoP
You can find more of these here: viewtopic.php?f=68&t=4467atrueprincefanfrom18 wrote: ↑March 25th, 2021, 5:46 pm Was playing Repetition Of Time. And I died and revived the Kid (R). I got to this room!
These glitched rooms are usually room 128 or -128, so yes, the game is reading out of range data.atrueprincefanfrom18 wrote: ↑March 25th, 2021, 5:46 pm Funny, what exactly does SDLPoP check while drawing the room? It might be anything because it's out of range memory data?
But I admit I haven't looked into why does PoP use this room number.
- atrueprincefanfrom18
- Site Shah
- Posts: 1785
- Joined: January 21st, 2020, 2:53 pm
- Contact:
Re: SDLPoP; David's open-source port of PoP
I was just interested in modifying the SDLPoP source code, so I created these three debug cheat codes to move the Kid in the 1st, 2nd or 3rd rows of the room.
Visually, all's been good, but the Kid doesn't engage in the sword fight (I didn't test anything else like chomper or spikes). And sometimes if he bumps to the wall to the left side, he can fall down a row. Can anyone see what I'm doing wrong?
Change in seg000.c file.
Visually, all's been good, but the Kid doesn't engage in the sword fight (I didn't test anything else like chomper or spikes). And sometimes if he bumps to the wall to the left side, he can fall down a row. Can anyone see what I'm doing wrong?
Change in seg000.c file.
Code: Select all
case SDL_SCANCODE_1 | WITH_ALT:
// ALT + 1
// Move the kid to first row of same room, same column.
Char.y = 55;
break;
case SDL_SCANCODE_2 | WITH_ALT:
// ALT + 2
// Move the kid to second row of same room, same column.
Char.y = 118;
break;
case SDL_SCANCODE_3 | WITH_ALT:
// ALT + 3
// Move the kid to third row of same room, same column.
Char.y = 181;
break;
Re: SDLPoP; David's open-source port of PoP
Trying doing this
Code: Select all
// first row (0)
Char.y = y_land[1]; // row 0 + 1
Char.curr_row = 0;
// second row (1)
Char.y = y_land[2];
Char.curr_row = 1;
// third row (2)
Char.y = y_land[3];
Char.curr_row = 2;
- atrueprincefanfrom18
- Site Shah
- Posts: 1785
- Joined: January 21st, 2020, 2:53 pm
- Contact:
Re: SDLPoP; David's open-source port of PoP
Yes, that worked perfectly! Thanks. This should be added to debug cheats actually.
What does the y_land hold? If so why does it start with index 1 and not 0?
What does the y_land hold? If so why does it start with index 1 and not 0?
Re: SDLPoP; David's open-source port of PoP
The "y_land" is an array that holds the correct y-coordinate value for a row in the corresponding array index. If the preset "Char.y" value does not match the row exactly, kid/guard can start falling down or guards/trobs may not react to him.
There are more rows in a room than what you see on the screen. There is an invisible row (-1) at the top if the room that has its y-value in the array index 0. So the first visible row (0) is in the array index 1 and so on. The other 2 visible rows are 1 and 2 located in array indexes 2 and 3. There is also another invisible row (3) at index 4 below the visible room area.
The row 3 is where fallen out guards are stored and become invisible with character direction set to "dir_56_none". The top empty row in a room below can be used to make guard follow you into the room below. But for some reason that was not implemented in PoP1. If kid pushes a guard into a room below, the guard dies and disappears. And a guard will not follow you if you fell out into a room below. In my mod guards will follow you and they do not disappear. I will explain how that works horizontally (between rooms) shortly.
The x-coordinate plane is even more interesting. You can see both planes drawn by Mechner in the attachment on page 7.
There is a very similar "x_bump" array for the x coordinate. There are 10 visible columns/tiles (0-9) that 14 pixels each. But there are also 5 out-of-sight tiles (technically 4 full tiles + 2 pixels) on each side of the room. So you would have to add 5 to the "x_bump" index value place kid to the left side of a tile. But unlike the y-coordinate, the x-coordinate can be set on any part of a tile (not just at edge/center). Ex:
would put him in the middle of the second tile (#1). The " + 7" means 7 pixels to the right from the tile's left edge.
In addition to "x" and "y" properties, there are also "curr_col" and "curr_row" properties that need to be set to the actual column/row number (not the array index). Those get recalculated at specific functions during a frame execution. But since cheats can be applied at any time, it is a good idea to also set them manually.
When kid is fighting a guard or running away while going to another room, there is logic that decides where a guard should follow kid or leave (stay in the previous room).
https://github.com/NagyD/SDLPoP/blob/42 ... 002.c#L311
When a guard is following kid who got into the next and the guard is in the out-of-sight tiles, he gets erased from the previous room (https://github.com/NagyD/SDLPoP/blob/42 ... 002.c#L302). Its Char values are changed to the corresponding out-of-sight tiles on the opposite side of the next room (https://github.com/NagyD/SDLPoP/blob/42 ... 002.c#L378). That can also happen if kid pushes guard into the next room while fighting.
There are more rows in a room than what you see on the screen. There is an invisible row (-1) at the top if the room that has its y-value in the array index 0. So the first visible row (0) is in the array index 1 and so on. The other 2 visible rows are 1 and 2 located in array indexes 2 and 3. There is also another invisible row (3) at index 4 below the visible room area.
The row 3 is where fallen out guards are stored and become invisible with character direction set to "dir_56_none". The top empty row in a room below can be used to make guard follow you into the room below. But for some reason that was not implemented in PoP1. If kid pushes a guard into a room below, the guard dies and disappears. And a guard will not follow you if you fell out into a room below. In my mod guards will follow you and they do not disappear. I will explain how that works horizontally (between rooms) shortly.
The x-coordinate plane is even more interesting. You can see both planes drawn by Mechner in the attachment on page 7.
There is a very similar "x_bump" array for the x coordinate. There are 10 visible columns/tiles (0-9) that 14 pixels each. But there are also 5 out-of-sight tiles (technically 4 full tiles + 2 pixels) on each side of the room. So you would have to add 5 to the "x_bump" index value place kid to the left side of a tile. But unlike the y-coordinate, the x-coordinate can be set on any part of a tile (not just at edge/center). Ex:
Code: Select all
Kid.x = x_bump[1 + 5] + 7;
// Kid.curr_col = 1;
In addition to "x" and "y" properties, there are also "curr_col" and "curr_row" properties that need to be set to the actual column/row number (not the array index). Those get recalculated at specific functions during a frame execution. But since cheats can be applied at any time, it is a good idea to also set them manually.
When kid is fighting a guard or running away while going to another room, there is logic that decides where a guard should follow kid or leave (stay in the previous room).
https://github.com/NagyD/SDLPoP/blob/42 ... 002.c#L311
When a guard is following kid who got into the next and the guard is in the out-of-sight tiles, he gets erased from the previous room (https://github.com/NagyD/SDLPoP/blob/42 ... 002.c#L302). Its Char values are changed to the corresponding out-of-sight tiles on the opposite side of the next room (https://github.com/NagyD/SDLPoP/blob/42 ... 002.c#L378). That can also happen if kid pushes guard into the next room while fighting.
- Attachments
-
- POP1TECH.PDF
- (404.99 KiB) Downloaded 65 times
Re: SDLPoP; David's open-source port of PoP
The problem seems to be happening here on the line below. The first time kid falls out into a non-existing room, the "Char.room" value is set to 0. But I think the logic below that changes kid's coordinates can shift him to a different room. The second time the function is called the "Char.room" is now set to a weird -128/127 value is you print it as an int.
The fix seems to be to return from the function right away if "Char.room" is 0 (or > 24 just in case).
https://github.com/NagyD/SDLPoP/blob/42 ... 002.c#L380
Code: Select all
byte other_room = ((byte*)&level.roomlinks[Char.room - 1])[direction];
if (other_room == 0 || other_room > 24) {
Char.room = 0;
return 0;
}
Char.room = other_room;
Re: SDLPoP; David's open-source port of PoP
Here is my fix: https://github.com/NagyD/SDLPoP/commit/ ... 0d8c7d773f
My solution is that we should not let the prince leave room 0 once he got there.
Specifically, the game should not use any room links of room 0.
Re: SDLPoP; David's open-source port of PoP
Hey, pretty cool to see that icculus (wiki) recently contributed to SDLPoP.
[Edit:]
Hm. Perhaps the contributors list in Readme.txt should be updated, and alphabetized?
To decrease the length of my entry, you could remove the non-notable (and 'obsolete') "improved gamepad support".
[Edit:]
Hm. Perhaps the contributors list in Readme.txt should be updated, and alphabetized?
To decrease the length of my entry, you could remove the non-notable (and 'obsolete') "improved gamepad support".