This might be the correct solution, but still I don't know where to find the value in the code. I'll wait for more detailed answer.atrueprincefanfrom18 wrote: βFebruary 25th, 2021, 6:31 pm Edit the hex where it says to activate the checkpoint when you move to left, instead activate it when you move to the right.
I need help with custom hacks
-
- Sheikh
- Posts: 25
- Joined: February 22nd, 2021, 8:48 pm
- Location: Czech Republic
Re: I need help with custom hacks
I have never thought about taking a look into the SDLPoP's "src" folder (or basically anywhere else than SDLPoP.ini). The files inside the folder seem to be pretty useful for PoP modding. I was considering to use this program in my levelset, but back then it appeared to me that there's too few functions. Thank you for this advice, I'll try to go through the files and reconsider using the program β together with the DOS one; I want it to be playable on PoP1 Total Pack and poplaun, so I'll include both programs.
- atrueprincefanfrom18
- Site Shah
- Posts: 1786
- Joined: January 21st, 2020, 2:53 pm
- Contact:
Re: I need help with custom hacks
Yes! Editing SDLPoP source code is real fun. Before I tried to give you the answer, I tried it myself and it's real fun, you can do anything. I'm serious. Literally. Anything!
It's so cool we don't need to know the assembly π, otherwise doing some different things would be completely impossible without it if SDLPoP didn't exist. So have fun with it!
It's so cool we don't need to know the assembly π, otherwise doing some different things would be completely impossible without it if SDLPoP didn't exist. So have fun with it!
Re: I need help with custom hacks
β’ In CusPop you can edit where to restart after the checkpoint was activated, and which tile to clear.T0mmiTheGreat wrote: βFebruary 22nd, 2021, 11:09 pm Greetings, I have a (hopefully) simple question:
Is it possible to set a checkpoint to be triggered by leaving room 7 to the right?
Apparently, the checkpoint in Level 3 is triggered by moving from room 7 to room 2 to the left.
[...]
My goal is to set the checkpoint in Level 7, triggered by moving from room 7 to 2 to the right, the Prince should respawn in room 2, at location 20, facing right, and the tile to clear can be in room 22, location 0.
β’ To edit which room activates the checkpoint, see this: viewtopic.php?p=20783#p20783
β’ Now, changing the direction is the tricky part.
The following parts of the code deal with special events triggered by exiting a room to the left or to the right:
Code: Select all
In leave_room():
seg002:0544 loc_3BC4:
seg002:0544
seg002:0544 8B 46 F8 mov ax, [bp+leave_dir]
seg002:0547 0B C0 or ax, ax
seg002:0549 75 03 jnz loc_3BCE
seg002:054B E9 BE 00 jmp leave_left
seg002:054E ; βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
seg002:054E
seg002:054E loc_3BCE:
seg002:054E 3D 01 00 cmp ax, 1
seg002:0551 75 03 jnz loc_3BD6
seg002:0553 E9 CE 00 jmp leave_right
seg002:0556 ; βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
seg002:060C leave_left:
seg002:060C 0E push cs
seg002:060D E8 C3 00 call near ptr play_mirr_mus ; 0x0610 + 0x00C3 = 0x06D3
seg002:0610 0E push cs
seg002:0611 E8 51 00 call near ptr level3_set_chkp ; 0x0614 + 0x0051 = 0x0665
seg002:0614 0E push cs
seg002:0615 E8 2B 00 call near ptr Jaffar_exit ; 0x0618 + 0x002B = 0x0643
seg002:0618
seg002:0618 loc_3C98:
seg002:0618
seg002:0618 FF 76 F8 push [bp+leave_dir] ; direction
seg002:061B 0E push cs
seg002:061C E8 67 FE call near ptr goto_other_room
seg002:061F 8B 46 F8 mov ax, [bp+leave_dir]
seg002:0622 EB 1B jmp short return
seg002:0624 ; βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
seg002:0624
seg002:0624 leave_right:
seg002:0624 0E push cs
seg002:0625 E8 58 00 call near ptr sword_disappears ; 0x0628 + 0x0058 = 0x0680
seg002:0628 0E push cs
seg002:0629 E8 82 00 call near ptr meet_Jaffar ; 0x062C + 0x0082 = 0x06AE
seg002:062C EB EA jmp short loc_3C98
seg002:062E ; βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
You could swap the call to level3_set_chkp with one of the calls under leave_right.
This means that one of the events under leave_right must be either changed to be triggered by exiting a room to the left, or not used at all.
However, all call near addresses (after the E8 bytes) are *relative*, which means you cannot simply copy the bytes of the calls from one place to another.
Instead you need to calculate the difference between the address of the routine to call and the address of the byte following the call instruction.
For example, if you want to call level3_set_chkp instead of sword_disappears at seg002:0625, then:
The address of the routine to call, level3_set_chkp, is 0x0665.
From this, subtract the address of the byte after the call at seg002:0625, which is 0x0628.
The result is 0x003D, so write E8 3D 00 (in place of E8 58 00).
But here is a better solution:
Move the block starting at seg002:0618 back by 4 bytes, and move the call level3_set_chkp after it.
Search: 0E E8 C3 00 0E E8 51 00 0E E8 2B 00 FF 76 F8 0E E8 67 FE 8B 46 F8 EB 1B 0E E8 58 00 0E E8 82 00 EB EA
Change: 0E E8 C3 00 0E E8 2F 00 FF 76 F8 0E E8 6B FE 8B 46 F8 EB 1F 0E E8 41 00 0E E8 58 00 0E E8 82 00 EB E6
Then change all references to loc_3C98 accordingly:
Code: Select all
seg002:055E loc_3BDE:
seg002:055E E9 B7 00 jmp loc_3C98
Change: E9 B3 00
Code: Select all
seg002:062E 83 3E 9E 0F 06 cmp current_level, 6 ; Special event: falling exit
seg002:0633 75 E3 jnz loc_3C98
seg002:0635 80 3E 2B 3D 01 cmp char.room, 1
seg002:063A 75 DC jnz loc_3C98
Change: 83 3E 9E 0F 06 75 DF 80 3E 2B 3D 01 75 D8
And change the reference to leave_right:
Code: Select all
seg002:054E loc_3BCE:
seg002:054E 3D 01 00 cmp ax, 1
seg002:0551 75 03 jnz loc_3BD6
seg002:0553 E9 CE 00 jmp leave_right
Change: 3D 01 00 75 03 E9 CA 00
What other tools do you mean?T0mmiTheGreat wrote: βFebruary 22nd, 2021, 11:09 pm CusPop doesn't allow modifying this, and other tools are way too complicated for me.
Re: I need help with custom hacks
In case T0mmi means hex editing...David wrote: βFebruary 28th, 2021, 10:41 amWhat other tools do you mean?T0mmiTheGreat wrote: βFebruary 22nd, 2021, 11:09 pm CusPop doesn't allow modifying this, and other tools are way too complicated for me.
T0mmi, take a look at this thread.
You'll need to use a hex editor to implement what's suggested by David.
Re: I need help with custom hacks
The last sentence of this post suggests that T0mmi is okay with hex editing.Norbert wrote: βFebruary 28th, 2021, 1:27 pmIn case T0mmi means hex editing...David wrote: βFebruary 28th, 2021, 10:41 amWhat other tools do you mean?T0mmiTheGreat wrote: βFebruary 22nd, 2021, 11:09 pm CusPop doesn't allow modifying this, and other tools are way too complicated for me.
T0mmi, take a look at this thread.
You'll need to use a hex editor to implement what's suggested by David.
-
- Sheikh
- Posts: 25
- Joined: February 22nd, 2021, 8:48 pm
- Location: Czech Republic
Re: I need help with custom hacks
So, I tried to edit the .exe file by the David's answer, and⦠it didn't work.
Besides that, I found another problem. In the respawn room there's also the exit door, therefore it can't be entered after the prince respawns at the checkpoint. I can fix it simply by moving the door to the next room, and it won't have any impact on the gameplay. Just in case, someone has free time and likes to code, it would look a little better in my level
And to your questions:
And finally, thank you both for your replies
+ If you'd like to view the .exe file, here it is:
One problem may be here β the first line of this code is apart from the other 3 lines in my file. I think it's because I moved the falling exit to level 8. Anyways, I found those 3 lines and changed them, it does nothing.David wrote: βFebruary 28th, 2021, 10:41 amCode: Select all
seg002:062E 83 3E 9E 0F 06 cmp current_level, 6 ; Special event: falling exit seg002:0633 75 E3 jnz loc_3C98 seg002:0635 80 3E 2B 3D 01 cmp char.room, 1 seg002:063A 75 DC jnz loc_3C98
I also tried to move the level3_set_chkp from leave_left to leave_right (moved "0E E8 51 00" right before "0E E8 58 00"). The result was that the screen didn't move when I left a room to the right.David wrote: βFebruary 28th, 2021, 10:41 amCode: Select all
In leave_room(): seg002:0544 loc_3BC4: seg002:0544 seg002:0544 8B 46 F8 mov ax, [bp+leave_dir] seg002:0547 0B C0 or ax, ax seg002:0549 75 03 jnz loc_3BCE seg002:054B E9 BE 00 jmp leave_left seg002:054E ; βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ seg002:054E seg002:054E loc_3BCE: seg002:054E 3D 01 00 cmp ax, 1 seg002:0551 75 03 jnz loc_3BD6 seg002:0553 E9 CE 00 jmp leave_right seg002:0556 ; βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ seg002:060C leave_left: seg002:060C 0E push cs seg002:060D E8 C3 00 call near ptr play_mirr_mus ; 0x0610 + 0x00C3 = 0x06D3 seg002:0610 0E push cs seg002:0611 E8 51 00 call near ptr level3_set_chkp ; 0x0614 + 0x0051 = 0x0665 seg002:0614 0E push cs seg002:0615 E8 2B 00 call near ptr Jaffar_exit ; 0x0618 + 0x002B = 0x0643 seg002:0618 seg002:0618 loc_3C98: seg002:0618 seg002:0618 FF 76 F8 push [bp+leave_dir] ; direction seg002:061B 0E push cs seg002:061C E8 67 FE call near ptr goto_other_room seg002:061F 8B 46 F8 mov ax, [bp+leave_dir] seg002:0622 EB 1B jmp short return seg002:0624 ; βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ seg002:0624 seg002:0624 leave_right: seg002:0624 0E push cs seg002:0625 E8 58 00 call near ptr sword_disappears ; 0x0628 + 0x0058 = 0x0680 seg002:0628 0E push cs seg002:0629 E8 82 00 call near ptr meet_Jaffar ; 0x062C + 0x0082 = 0x06AE seg002:062C EB EA jmp short loc_3C98 seg002:062E ; βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Besides that, I found another problem. In the respawn room there's also the exit door, therefore it can't be entered after the prince respawns at the checkpoint. I can fix it simply by moving the door to the next room, and it won't have any impact on the gameplay. Just in case, someone has free time and likes to code, it would look a little better in my level
And to your questions:
I tried to take a look at the CusAsm, but didn't manage to make it work. I think I got the wrong TASM release. Or maybe just misunderstood the instructions in the PDF tutorial. And I also tried PrinHackEd, it doesn't allow changing what I need.
I have already read the post and got the program. After a long time I've got a PoP-related program that I managed to run
And finally, thank you both for your replies
+ If you'd like to view the .exe file, here it is:
- Attachments
-
- PRINCE.zip
- (70.58 KiB) Downloaded 148 times
Re: I need help with custom hacks
Ah, sorry, I didn't know that you already edited your prince.exe.T0mmiTheGreat wrote: βFebruary 28th, 2021, 9:45 pm One problem may be here β the first line of this code is apart from the other 3 lines in my file. I think it's because I moved the falling exit to level 8. Anyways, I found those 3 lines and changed them, it does nothing.
Here is what to change using offsets instead of what to search.
(For unpacked v1.0)
At 0x5484 write: CA
At 0x548F write: B3
At 0x5542 write: 2F
At 0x5544 write: FF 76 F8 0E E8 6B FE 8B 46 F8 EB 1F 0E E8 41 00
At 0x555D write: E6
At 0x5564 write: DF
At 0x556B write: D8
There is a hack for that here: viewtopic.php?p=16135#p16135T0mmiTheGreat wrote: βFebruary 28th, 2021, 9:45 pm Besides that, I found another problem. In the respawn room there's also the exit door, therefore it can't be entered after the prince respawns at the checkpoint.
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
To be honest I have never used CusAsm, and I didn't even remember there is a tutorial, even though I downloaded it in 2016.T0mmiTheGreat wrote: βFebruary 28th, 2021, 9:45 pm I tried to take a look at the CusAsm, but didn't manage to make it work. I think I got the wrong TASM release. Or maybe just misunderstood the instructions in the PDF tutorial.
(Links to anyone interested: viewtopic.php?p=18010#p18010 )
I have read the tutorial now, and as I see it, this tutorial is not useful if you want to change anything other than the level or room of a special event.
To find hacks, I usually use my disassemblies.
You can find them here: viewtopic.php?p=17830#p17830
-
- Sheikh
- Posts: 25
- Joined: February 22nd, 2021, 8:48 pm
- Location: Czech Republic
Re: I need help with custom hacks
As I said:
Besides that, I tested the "door in respawn room" problem in another level in the starting room, and it works. Thank you . I also suggested it to be included in CusPoP, I find this to be a good feature for it.
That means I've already tried this solution:T0mmiTheGreat wrote: βFebruary 28th, 2021, 9:45 pm I found those 3 lines (that were apart from the first one in the code) and changed them
and it didn't work. Nevermind, thanks, at least I verified it. Maybe the first solution that you wanted to show me in this post would work fine�
Besides that, I tested the "door in respawn room" problem in another level in the starting room, and it works. Thank you . I also suggested it to be included in CusPoP, I find this to be a good feature for it.
-
- Sheikh
- Posts: 25
- Joined: February 22nd, 2021, 8:48 pm
- Location: Czech Republic
Re: I need help with custom hacks
Just found out, the hack with the door will work⦠but not exactly how I need it.
Technically, the respawn room becomes starting room when the checkpoint is triggered. The game makes one of the door in starting room appear open, then shut immediately when the level starts. And as the door in respawn room is the exit in my level, I need to prevent this somehow.
I've got an idea on how to achieve it:
When there are multiple doors in the starting room, the animation only applies to one of them. It might be possible to make the game think there is other door somewhere in the respawn room. Maybe⦠it's just my idea.
If there's no way to achieve this, I'll just simply move the door or checkpoint to another room; right here I'm not limited by space.
Technically, the respawn room becomes starting room when the checkpoint is triggered. The game makes one of the door in starting room appear open, then shut immediately when the level starts. And as the door in respawn room is the exit in my level, I need to prevent this somehow.
I've got an idea on how to achieve it:
When there are multiple doors in the starting room, the animation only applies to one of them. It might be possible to make the game think there is other door somewhere in the respawn room. Maybe⦠it's just my idea.
If there's no way to achieve this, I'll just simply move the door or checkpoint to another room; right here I'm not limited by space.
Re: I need help with custom hacks
I've attached a PRINCE.EXE I made by applying my hack to the PRINCE.EXE you posted here.T0mmiTheGreat wrote: βMarch 7th, 2021, 5:10 pm and it didn't work. Nevermind, thanks, at least I verified it.
I also included a LEVELS.DAT with a changed starting position on level 3.
Start on level 3 and leave the new starting room to the right.
Then press Ctrl+A. Now the prince should restart at the checkpoint.
- Attachments
-
- level 3 checkpoint left-to-right.zip
- (78.67 KiB) Downloaded 123 times
-
- Sheikh
- Posts: 25
- Joined: February 22nd, 2021, 8:48 pm
- Location: Czech Republic
Re: I need help with custom hacks
Yup, this works. It seems that the problem is changing the respawn level. I tried changing it using CusPoP and also using this solution:
neither worked. Changing the room is okay, but levels are acting up. And not only in my levelset, the error happens in the original game too. Both by keeping the leaving direction to the left, and then changing it to right.
Re: I need help with custom hacks
In CusPoP you can change the level where the prince can restart at a checkpoint.T0mmiTheGreat wrote: βMarch 13th, 2021, 8:46 pm Yup, this works. It seems that the problem is changing the respawn level. I tried changing it using CusPoP and also using this solution:neither worked. Changing the room is okay, but levels are acting up. And not only in my levelset, the error happens in the original game too. Both by keeping the leaving direction to the left, and then changing it to right.
(offset: 0x624E in unpacked v1.0)
With the hack you quoted, you can change the level where the prince can activate the checkpoint.
(offset: 0x5599 in unpacked v1.0)
You need to change both to the same level.
-
- Sheikh
- Posts: 25
- Joined: February 22nd, 2021, 8:48 pm
- Location: Czech Republic
Re: I need help with custom hacks
Oh, I kind of misunderstood that post. Now the checkpoint is working all right. Thank you again for your help.
- atrueprincefanfrom18
- Site Shah
- Posts: 1786
- Joined: January 21st, 2020, 2:53 pm
- Contact:
Re: I need help with custom hacks
By the way, are you creating a mod?T0mmiTheGreat wrote: βMarch 14th, 2021, 10:15 am Oh, I kind of misunderstood that post. Now the checkpoint is working all right. Thank you again for your help.
-
- Sheikh
- Posts: 25
- Joined: February 22nd, 2021, 8:48 pm
- Location: Czech Republic
Re: I need help with custom hacks
Yes, I am. Something for beginners who have completed the original game, a little more difficult than the original Prince of Persia. I'm trying to make it fun and not frustrating (see above, this is how hard I'm trying ), but nothing too revolutionary; I'm rather a newbie to PoP modding (again, see above).atrueprincefanfrom18 wrote: βMarch 14th, 2021, 11:24 amBy the way, are you creating a mod?T0mmiTheGreat wrote: βMarch 14th, 2021, 10:15 am Oh, I kind of misunderstood that post. Now the checkpoint is working all right. Thank you again for your help.