CusPop TODO list

Discussions about all other tools (CusPop, SAV/HOF editors) and hex editing.
Falcury
Calif
Calif
Posts: 565
Joined: June 25th, 2009, 10:01 pm

Re: CusPop TODO list

Post by Falcury »

In princehack.xml, it looks like the guard types hack only has offsets available for the unpacked executables:

Code: Select all

<hack name="guard types" help="Note that this only affects the resource file that is loaded and therefore the bitmaps that are displayed. For example, if you set up level 3 to use the Jaffar sprite, it will remain unkillable. Killing guards using the skeleton or shadow sprite or meeting a guard when no resource is loaded causes the game to crash, since it would need to load a nonexistent resource.">
	<offset file="u0" value="0x1c964"/>
	<offset file="u3" value="0x1c702"/>
	<offset file="u4" value="0x1905e"/>
	<read type="signed short int" name="guard resources demo level" minval="-1" maxval="4">
	...
I stumbled upon this, because I'm trying to read offsets from modded EXE files, and I noticed that this particular option was not working.
I see that in CusPop, the option is disabled if I select one of the packed executable types.
I guess I can safely assume that if some hack is unavailable for a particular executable type, then it should always be unmodified from the original.
So probably this is not a big deal.

Some other instances where offsets are not available for all executable types:
flipdown hack (only 1.0 unpacked and packed)
quitting when time expires (only 1.0 unpacked) - is there any mod that uses this?
allowed resources per level (only unpacked versions)
cutscenes (only 1.0 unpacked)
loose tiles in level 12 (only 1.0 and 1.4)
changing additional hit-points of guards with different skills (only unpacked versions)

Edit: something else, about the level 3 checkpoint:

Code: Select all

<read default="4" name="location of the tile to clear" type="char" minval="0" maxval="29" help="The room tiles are from 0 to 29 in the same way as the location. Remember that you can erase potions, you can also set it to an empty tile to do nothing."/>
It looks like this should be the column of the tile to clear, instead of the tile position ranged 0 to 29.
The relevant part of the disassembly is this:

Code: Select all

seg003:01C7 B8 07 00                             mov     ax, 7
seg003:01CA 50                                   push    ax              ; room
seg003:01CB B8 04 00                             mov     ax, 4 ; <-- 4 is the modified byte
seg003:01CE 50                                   push    ax              ; col
seg003:01CF 2B C0                                sub     ax, ax
seg003:01D1 50                                   push    ax              ; row
seg003:01D2 9A 06 00 CB 06                       call    get_tile
David
The Prince of Persia
The Prince of Persia
Posts: 2848
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: CusPop TODO list

Post by David »

Falcury wrote: March 14th, 2018, 8:44 pm In princehack.xml, it looks like the guard types hack only has offsets available for the unpacked executables:
Yes. That's because in the packed version, the zeroes of levels from 7 to 11 are packed, and thus they can't be edited without unpacking the exe.

This is what the guard types table (array) looks like in 1.0 unpacked:

Code: Select all

0001C964: 00 00 00 00 00 00 02 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 04 00 03 00 FF FF FF FF
And in 1.0 packed:

Code: Select all

0001AE0C: 00 00 00 00 00 00 02 00 00 00 00 00 01 [79 01 B2 00 0B 00 B0] 04 00 03 00 FF FF FF FF
As you can see, the packing replaces the 11 zero bytes with something shorter.
Thus you cannot edit that part without unpacking the exe first.

The compression used by EXEPACK is quite simple, it packs only consecutive runs of identical bytes.
Therefore, problems like this are usually limited to those tables that contain mostly zeroes.

In case you're interested, this is what the bracketed part means:

Code: Select all

Note: The decompression is done from the end of the file towards the beginning. Don't ask me why.
B0 = repeat
0B 00 = 0x000B=11 times
00 <-- this byte is repeated
B2 = raw copy
79 01 = 0x0179=377 bytes
Falcury wrote: March 14th, 2018, 8:44 pm Some other instances where offsets are not available for all executable types:
Most of these should be hackable in all versions, we were just "lazy" and didn't yet find the offsets in all versions.
The exceptions are those that work only in unpacked versions, these have same problem as the guard types explained above.
Falcury wrote: March 14th, 2018, 8:44 pm Edit: something else, about the level 3 checkpoint:
It looks like this should be the column of the tile to clear, instead of the tile position ranged 0 to 29.
I guess you're right. This field is the column, and the next field, "Floor of the tile to clear:", is the row.
4DPlayer

Re: CusPop TODO list

Post by 4DPlayer »

Why when I generate the prince of Persia game from princed.org/cuspop, I only get the exe instead of the whole zip?
David
The Prince of Persia
The Prince of Persia
Posts: 2848
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: CusPop TODO list

Post by David »

4DPlayer wrote: May 26th, 2019, 3:24 am Why when I generate the prince of Persia game from princed.org/cuspop, I only get the exe instead of the whole zip?
Because CusPop changes only the EXE.
4DPlayer

Re: CusPop TODO list

Post by 4DPlayer »

David wrote: May 26th, 2019, 12:46 pm
4DPlayer wrote: May 26th, 2019, 3:24 am Why when I generate the prince of Persia game from princed.org/cuspop, I only get the exe instead of the whole zip?
Because CusPop changes only the EXE.
So if I combine the exe with the other PoP DAT files, I will get the exe changes?
David
The Prince of Persia
The Prince of Persia
Posts: 2848
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: CusPop TODO list

Post by David »

4DPlayer wrote: May 26th, 2019, 2:48 pm So if I combine the exe with the other PoP DAT files, I will get the exe changes?
Yes.
4DPlayer

Re: CusPop TODO list

Post by 4DPlayer »

David wrote: June 1st, 2019, 6:24 pm
4DPlayer wrote: May 26th, 2019, 2:48 pm So if I combine the exe with the other PoP DAT files, I will get the exe changes?
Yes.
Did so. Thanks for the tip
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5745
Joined: April 9th, 2009, 10:58 pm

Re: CusPop TODO list

Post by Norbert »

David has posted a fix for the demo level playable hack.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5745
Joined: April 9th, 2009, 10:58 pm

Re: CusPop TODO list

Post by Norbert »

David wrote: April 12th, 2015, 11:20 am80 3E D8 28 00 : numpad 5 (down)
80 3E DC 28 00 : numpad 2 / down
Only if this is easy enough for you David, is there a way to disallow down (as above) except for sheathing the sword?
David
The Prince of Persia
The Prince of Persia
Posts: 2848
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: CusPop TODO list

Post by David »

Norbert wrote: February 3rd, 2021, 4:00 pm Only if this is easy enough for you David, is there a way to disallow down (as above) except for sheathing the sword?
This hack will overwrite the check for the numpad 5 (center) key.

Code: Select all

seg000:151C 80 3E D8 28 00                  cmp  key_states_4C_center, 0 ; <-- change to: cmp holding_sword, 0
seg000:1521 75 07                           jnz  loc_152A ; <-- change to: jz loc_152F
seg000:1523 80 3E DC 28 00                  cmp  key_states_50_down, 0
seg000:1528 74 05                           jz   loc_152F
seg000:152A
seg000:152A                      loc_152A:
seg000:152A C6 06 1C 46 01                  mov  control_y, 1
seg000:152F                      loc_152F:
search: 80 3E D8 28 00 75 07
change: 83 3E 4E 59 00 74 0C


Fun fact: I originally wrote 74 0E, which, by complete accident, makes the prince run left!
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5745
Joined: April 9th, 2009, 10:58 pm

Re: CusPop TODO list

Post by Norbert »

David wrote: February 6th, 2021, 8:12 pm
Norbert wrote: February 3rd, 2021, 4:00 pm Only if this is easy enough for you David, is there a way to disallow down (as above) except for sheathing the sword?
[...] search: [...] change: [...]
Thanks.
David
The Prince of Persia
The Prince of Persia
Posts: 2848
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: CusPop TODO list

Post by David »

Change which room activates the checkpoint: viewtopic.php?p=20783#p20783
T0mmiTheGreat
Sheikh
Sheikh
Posts: 25
Joined: February 22nd, 2021, 8:48 pm
Location: Czech Republic

Re: CusPop TODO list

Post by T0mmiTheGreat »

Allow using a door in the starting room as the exit door.
David posted this great solution:
David wrote: March 7th, 2021, 10:23 am There is a hack for that here: viewtopic.php?p=16135#p16135

Here is what to change using offsets instead of what to search.
(For unpacked v1.0)
At 0x7B32 write: 8B 36 88 5F 8A 00 3C 2A 7C 09 90 90 90
At 0xA44E write: C6
At 0xA450 write: 9C 40 01 90 90 80
At 0xA457 write: 28 43 2B 72 3A 90 90 90 90 90 90 90
At 0xD247 write: 90 90
At 0xD24B write: 9C 40
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5745
Joined: April 9th, 2009, 10:58 pm

Re: CusPop TODO list

Post by Norbert »

Norbert wrote: February 7th, 2021, 12:31 am
David wrote: February 6th, 2021, 8:12 pm
Norbert wrote: February 3rd, 2021, 4:00 pm Only if this is easy enough for you David, is there a way to disallow down (as above) except for sheathing the sword?
[...] search: [...] change: [...]
Thanks.
I found a small snag, that happens rarely but is particularly noticeable in room 5 of level 10.

It can be replicated as follows:
- Disable Shift and arrow down, while still allowing sheathing. The easiest way to do this is via F4 with the new apoplexy 3.14. See the attached image.
- Face a guard (any guard, anywhere), the prince will draw his sword.
- Put away the sword.
- Face away from the guard, i.e. turn around.
- Face the guard again, which will make the prince (re)draw his sword.
- Now the sword can no longer be sheathed.

Another, even more minor, snag is that arrow down (for hopping, etc) will be possible after a painful fall that occurred from a fighting stance position.
So, face a guard, then move back into a two-floor deep chasm.
Attachments
disable.png
disable.png (1.33 KiB) Viewed 6552 times
David
The Prince of Persia
The Prince of Persia
Posts: 2848
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: CusPop TODO list

Post by David »

Norbert wrote: March 21st, 2021, 2:16 pm I found a small snag, that happens rarely but is particularly noticeable in room 5 of level 10.

It can be replicated as follows:
- Disable Shift and arrow down, while still allowing sheathing. The easiest way to do this is via F4 with the new apoplexy 3.14. See the attached image.
- Face a guard (any guard, anywhere), the prince will draw his sword.
- Put away the sword.
- Face away from the guard, i.e. turn around.
- Face the guard again, which will make the prince (re)draw his sword.
- Now the sword can no longer be sheathed.
Yes, sorry, it turned out that I picked the wrong variable for determining whether the prince is holding the sword.
I used holding_sword (data:59DE), but it is not set to 1 (true) if the prince draws his sword together with turning around.
See back_pressed().
Therefore my hack thinks that the prince is not holding the sword and does not allow using the down arrow.
The correct variable is Kid.sword (data:4364).

The correct hack is:
search: 80 3E D8 28 00 75 07
change: 80 3E 64 43 00 74 0C
Norbert wrote: March 21st, 2021, 2:16 pm Another, even more minor, snag is that arrow down (for hopping, etc) will be possible after a painful fall that occurred from a fighting stance position.
So, face a guard, then move back into a two-floor deep chasm.
The fall doesn't even have to be painful and two-floor deep. A single-row fall has the same effect.

The culprit is the holding_sword variable again.
It is not set to 0 (false) when the prince starts falling from fighting stance; but Kid.sword is.
The fix which I wrote above fixes this as well.
Post Reply