No room bad hold

Discuss PoP1 for DOS here.
Post Reply
User avatar
Emiliano
Wizard Scribe
Wizard Scribe
Posts: 718
Joined: July 31st, 2019, 8:53 pm
Location: Mexico
Contact:

No room bad hold

Post by Emiliano »

Hi again, I don't know if you have seen this before, for this you need to have a wall if there's no room at the left and put it in a corner, I can't hold using that wall and the four-tile jump failed with this
Look:
65536
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1785
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: No room bad hold

Post by atrueprincefanfrom18 »

Emiliano Fierro wrote: September 3rd, 2020, 1:20 am [...] I can't hold using that wall [...]
Even I had that experience. It's great if it's fixed.
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
David
The Prince of Persia
The Prince of Persia
Posts: 2850
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: No room bad hold

Post by David »

Emiliano Fierro wrote: September 3rd, 2020, 1:20 am Hi again, I don't know if you have seen this before, for this you need to have a wall if there's no room at the left and put it in a corner, I can't hold using that wall and the four-tile jump failed with this
I've seen this before in the SNES-PC-set mod: viewtopic.php?p=29854#p29854


This bug occurs both in DOS PoP and SDLPoP.

A similar thing happens if you try to climb down from such a ledge without releasing it: The prince will release the ledge even if you hold down Shift.
I figured out what happens in this case.

The prince releases the ledge here:
https://github.com/NagyD/SDLPoP/blob/v1 ... 005.c#L710

Code: Select all

				if (! tile_is_floor(get_tile_above_char())) {
					hang_fall();
				}
Here the game checks if the prince is still hanging onto a floor, in case it was a loose floor which fell since he grabbed it.
If the tile is not a floor then the prince will fall.

In the first case shown in your video, get_tile_above_char() will call get_tile() with room = (room where the prince is), col = -1, row = -1.
get_tile() in turn calls find_room_of_tile(): https://github.com/NagyD/SDLPoP/blob/v1 ... g006.c#L46
The purpose of find_room_of_tile() is to normalize the room,column,row coordinates, so that the latter two are inside bounds (0 ≤ row ≤ 2 and 0 ≤ col ≤ 9).
There the game first checks if the current tile position is outside the current room leftwards, and since it is, the code "goes" to the room on the left side, which is room 0.

Code: Select all

	if (tile_col < 0) {
		tile_col += 10;
		if (curr_room) {
			curr_room = level.roomlinks[curr_room - 1].left;
		}
Next the code checks if the current tile position is outside the current room upwards:

Code: Select all

	if (tile_row < 0) {
		tile_row += 3;
		if (curr_room) {
			curr_room = level.roomlinks[curr_room - 1].up;
		}
curr_room is 0, so the condition of the inner if is false, therefore curr_room remains 0.
curr_room = 0 means get_tile() will return a tile from room 0, which is treated as being filled with walls.

Code: Select all

	if (curr_room > 0) {
		[...]
	} else {
		// wall in room 0
		curr_tile2 = custom->level_edge_hit_tile; // tiles_20_wall
	}
So get_tile() and then get_tile_above_char() returns wall (20), which is not a floor, and thus the prince falls.

The solution is to change find_room_of_tile() so that the if with condition (tile_row < 0) appears first.
That way find_room_of_tile() will first go up (room = room above, col = 2, row = -1) then left (room = room above-left, col = 2, row = 9), and it will return the actual tile which the prince is grabbing.

I fixed this now in SDLPoP: https://github.com/NagyD/SDLPoP/commit/ ... d69a994f8b
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1785
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: No room bad hold

Post by atrueprincefanfrom18 »

Is it difficult to fix for DOS PoP? You haven't posted any hex codes for Emiliano.
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
David
The Prince of Persia
The Prince of Persia
Posts: 2850
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: No room bad hold

Post by David »

atrueprincefanfrom18 wrote: September 5th, 2020, 6:01 pm Is it difficult to fix for DOS PoP? You haven't posted any hex codes for Emiliano.
Here are the codes for DOS PoP.
(Time taken: about 10 minutes.)

I've put the codes into a code block so the bytes after Search and Change line up with each other.

Code: Select all

"--" means you don't need to change that byte.

Search: 83 3E 32 43 00 7D 1A 83 06 32 43 0A 83 3E 2A 43 00 74 74 8B 1E 2A 43 D1 E3 D1 E3 8A 87 20 57 EB 61
Change: -- -- 36 -- -- -- -- -- -- 36 -- 03 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 22 -- -- --
(This part starts at 0x85BD in unpacked v1.0)

Search: 83 3E 36 43 00 7D 1A 83 06 36 43 03 83 3E 2A 43 00 74 32 8B 1E 2A 43 D1 E3 D1 E3 8A 87 22 57 EB 1F
Change: -- -- 32 -- -- -- -- -- -- 32 -- 0A -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20 -- -- --
(This part starts at 0x85FF in unpacked v1.0)
Details:

Code: Select all

We swap these two parts of the code:

seg006:005D 83 3E 32 43 00                       cmp     tile_col, 0
seg006:0062 7D 1A                                jge     loc_6D2E
seg006:0064 83 06 32 43 0A                       add     tile_col, 10
seg006:0069 83 3E 2A 43 00                       cmp     curr_room, 0
seg006:006E 74 74                                jz      loc_6D94
seg006:0070 8B 1E 2A 43                          mov     bx, curr_room
seg006:0074 D1 E3                                shl     bx, 1
seg006:0076 D1 E3                                shl     bx, 1
seg006:0078 8A 87 20 57                          mov     al, link_left_1[bx]
seg006:007C EB 61                                jmp     short loc_6D8F

seg006:009F 83 3E 36 43 00                       cmp     tile_row, 0
seg006:00A4 7D 1A                                jge     loc_6D70
seg006:00A6 83 06 36 43 03                       add     tile_row, 3
seg006:00AB 83 3E 2A 43 00                       cmp     curr_room, 0
seg006:00B0 74 32                                jz      loc_6D94
seg006:00B2 8B 1E 2A 43                          mov     bx, curr_room
seg006:00B6 D1 E3                                shl     bx, 1
seg006:00B8 D1 E3                                shl     bx, 1
seg006:00BA 8A 87 22 57                          mov     al, link_up_1[bx]
seg006:00BE EB 1F                                jmp     short loc_6D8F
User avatar
Emiliano
Wizard Scribe
Wizard Scribe
Posts: 718
Joined: July 31st, 2019, 8:53 pm
Location: Mexico
Contact:

Re: No room bad hold

Post by Emiliano »

David wrote: September 5th, 2020, 6:37 pm (Time taken: about 10 minutes.)
Thanks a lot for your effort and knowledge, this will help me
By the way I need your help making SDLPoP version of my mod
65536
Post Reply