Page 1 of 1

Question: hex edit to make chomper -1hp instead of kill?

Posted: September 25th, 2015, 5:08 pm
by Norbert
Can an easy hex edit of PRINCE.EXE be made to make the chomper remove 1 hit point instead of killing the prince?

Re: Question: hex edit to make chomper -1hp instead of kill?

Posted: September 26th, 2015, 5:06 pm
by David
Norbert wrote: Can an easy hex edit of PRINCE.EXE be made to make the chomper remove 1 hit point instead of killing the prince?
The relevant part of the disassembly:

Code: Select all

seg004:0811 B8 64 00                             mov     ax, 100
seg004:0814 50                                   push    ax              ; count
seg004:0815 9A BD 06 CB 06                       call    take_hp
seg004:081A B8 2E 00                             mov     ax, sound_46_something_chopped
seg004:081D 50                                   push    ax              ; sound_id
seg004:081E 9A C5 12 00 00                       call    play_sound
seg004:0823 B8 36 00                             mov     ax, 54          ; chomped
seg004:0826 50                                   push    ax              ; seq_index
seg004:0827 9A 0A 00 DE 05                       call    seqtbl_offset_char
Search: B8 64 00 50 9A BD 06 CB 06 B8 2E 00 50 9A C5 12 00 00 B8 36 00 50
Change:
* 0x64 -> 0x01 (how many HP to take)
* 0x36 -> what do you want instead of being chomped:
0x11 = seq_17_soft_land
0x1A = seq_26_crouch_while_running
0x32 = seq_50_crouch
0x4F = seq_79_crouch_hop
See types.h of SDLPoP for other numbers.

Now, if the prince had only 1 HP then there might be a problem...

You might also want to remove blood:

Code: Select all

seg004:07C0 8A 1E ED 42                          mov     bl, curr_tile_pos
seg004:07C4 2A FF                                sub     bh, bh
seg004:07C6 8B 36 88 5F                          mov     si, curr_room_modif
seg004:07CA 80 08 80                             or      byte ptr [bx+si], 80h ; put blood
seg004:07CD 80 3E 22 3D B2                       cmp     char_frame, 178 ; chopped
Search: 80 08 80 80, change to 80 08 00 80


What is your goal, by the way?
Maybe you are making some new mod where the chomper (graphics) is replaced with something different?

Re: Question: hex edit to make chomper -1hp instead of kill?

Posted: October 16th, 2015, 8:07 am
by Norbert
Neat. :)
David wrote:What is your goal, by the way?
To be honest I was merely curious to see the modified chomper in action. I just have and it's quite fun to see the chomper just take one hitpoint. I hope it didn't take too much effort on your part to find the hex modifications necessary for it. I tried to make sure you wouldn't put in a lot of effort finding them - if that would've been necessary - by including "an easy hex edit" in my question, but now that I'm thinking about it, that phrase is multi-interpretable. It could also refer to how easy the edit(s) is (are) to apply after being found.
David wrote:Now, if the prince had only 1 HP then there might be a problem...
Yes, it causes a problem, because the game basically hangs. If there was a way to fix this, maybe the modifications could be used for the easiest setting of King of Persia. But it's probably better if you focus your energy on other things. ;)

Re: Question: hex edit to make chomper -1hp instead of kill?

Posted: January 31st, 2021, 6:06 pm
by Norbert
Norbert wrote: October 16th, 2015, 8:07 am
David wrote:Now, if the prince had only 1 HP then there might be a problem...
[...] If there was a way to fix this, [...]
Is there?
I think once fixed this is an interesting modification, because it changes the impact of chomper usage in levels.