Hacking the SNES ROM

Discuss PoP1 for SNES here.
User avatar
Shauing
Calif
Calif
Posts: 435
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

David wrote: August 11th, 2018, 1:27 pm The original code around x8C06 removes the shadow if he has left the mirror room.
Unfortunately it also removes the shadow if he appeared for one of the other events.
This also means that if I just disable his disappearing (as my hack does), then he won't disappear even if he should.
I'm wondering if there is a way to detect that the current shadow came from a mirror.
Ohh, darn. It seems that I will have to remove the mirror jump/shadow appears sequence, so to not sacrifice the mirror puzzles and the other shadow sequences. Or, move it to a previous level, though at this point where I am in the mod, I can only think in one place where it could occur.

EDIT: Had to move it to a previous level, but also remove the mirror puzzles as the shadow kept appearing in any mirror the prince jumped.
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
David
The Prince of Persia
The Prince of Persia
Posts: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

Shauing wrote: August 11th, 2018, 6:42 pm EDIT: Had to move it to a previous level, but also remove the mirror puzzles as the shadow kept appearing in any mirror the prince jumped.
So, you want to be able to jump through any mirror, but the shadow should appear only from one certain mirror?
User avatar
Shauing
Calif
Calif
Posts: 435
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

David wrote: August 12th, 2018, 5:38 pm
So, you want to be able to jump through any mirror, but the shadow should appear only from one certain mirror?
Yes, that's what I want.


Another thing I wanted to know if it is possible; can checkpoints be activated by exiting a room up or down? The "hacks..." window only has left or right depending of the level in the original game.
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
David
The Prince of Persia
The Prince of Persia
Posts: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

Shauing wrote: August 12th, 2018, 5:54 pm
David wrote: August 12th, 2018, 5:38 pm
So, you want to be able to jump through any mirror, but the shadow should appear only from one certain mirror?
Yes, that's what I want.
At xD14D write: 4C D0 FE.
At xFED0 write: AD 21 05 C9 FF D0 14 AD 79 05 C9 LL D0 0A AD 62 04 C9 RR D0 03 20 54 D1 20 80 D1 9C 21 05 60.
Where LL is the level number minus 1, RR is the room number where you want to allow the shadow. (both in hexadecimal)

I think you can also re-enable the disappearing of the shadow if he's offscreen, since, as you wrote, the mirrors are on a different level than the other shadow-related events.
At x8C06 write: F0 03 4C D5 92.
User avatar
Shauing
Calif
Calif
Posts: 435
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

David wrote: August 18th, 2018, 4:16 pm
At xD14D write: 4C D0 FE.
At xFED0 write: AD 21 05 C9 FF D0 14 AD 79 05 C9 LL D0 0A AD 62 04 C9 RR D0 03 20 54 D1 20 80 D1 9C 21 05 60.
Where LL is the level number minus 1, RR is the room number where you want to allow the shadow. (both in hexadecimal)
It works. I was going to say that the 1 HP damage didn't work, but I initially wrote the second part on another place by mistake.
David wrote: August 18th, 2018, 4:16 pm I think you can also re-enable the disappearing of the shadow if he's offscreen, since, as you wrote, the mirrors are on a different level than the other shadow-related events.
At x8C06 write: F0 03 4C D5 92.
Actually, the mirror puzzles are on the same level as the other shadow events. The shadow appearing through jumping on a specific mirror is what I moved to another level in order to avoid the bug/glitch.

By the way, is it possible to change the trigger for the mirror to appear? Instead of a door end trigger, could it be a specific normal door trigger? The level where the mirror appearing/jump occurs has a special exit.
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
David
The Prince of Persia
The Prince of Persia
Posts: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

Shauing wrote: August 12th, 2018, 5:54 pm Another thing I wanted to know if it is possible; can checkpoints be activated by exiting a room up or down? The "hacks..." window only has left or right depending of the level in the original game.
Here is how to activate a checkpoint by exiting a room down:
At x82AF write: 20 B0 FE.
At xFEB0 write: AD 79 05 C9 LL D0 0A A9 RR CD 62 04 D0 03 20 BD 83 20 49 83.
Where LL is the level number minus 1, RR is the room number.

You also need to set where to restart the level after the checkpoint is activated.
You can do that in the hacks window.
Shauing wrote: August 18th, 2018, 9:16 pm By the way, is it possible to change the trigger for the mirror to appear? Instead of a door end trigger, could it be a specific normal door trigger? The level where the mirror appearing/jump occurs has a special exit.
You could trigger an exit door in an unused room together with the gate, but I guess the sound would give it away...
I'll look into this.
User avatar
Shauing
Calif
Calif
Posts: 435
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

David wrote: August 19th, 2018, 6:08 pm
Here is how to activate a checkpoint by exiting a room down:
At x82AF write: 20 B0 FE.
At xFEB0 write: AD 79 05 C9 LL D0 0A A9 RR CD 62 04 D0 03 20 BD 83 20 49 83.
Where LL is the level number minus 1, RR is the room number.

You also need to set where to restart the level after the checkpoint is activated.
You can do that in the hacks window.
Is it possible as well by exiting a room up?
David wrote: August 19th, 2018, 6:08 pm You could trigger an exit door in an unused room together with the gate, but I guess the sound would give it away...
I'll look into this.
Yeah, that could be confusing as well.
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
David
The Prince of Persia
The Prince of Persia
Posts: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

Shauing wrote: August 18th, 2018, 9:16 pm By the way, is it possible to change the trigger for the mirror to appear? Instead of a door end trigger, could it be a specific normal door trigger? The level where the mirror appearing/jump occurs has a special exit.
At xD2D4 write: 20 90 FE.
At xFE90 write: AD 79 05 C9 LL D0 0F AD C1 04 D0 0A AE 8F 05 E0 XX D0 03 20 F6 E0 AE 8F 05 60.
Where LL is the level number minus 1, XX is the number of the door event that should trigger the mirror.
(Both are in hex, but the event number is already displayed in hex by Pr1SnesLevEd, so you don't need to convert that.)
Don't forget to set "mirror appear level" in the Hacks window as well.
David
The Prince of Persia
The Prince of Persia
Posts: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

First, a correction:
David wrote: August 19th, 2018, 6:08 pm At x82AF write: 20 B0 FE.
At xFEB0 write: AD 79 05 C9 LL D0 0A A9 RR CD 62 04 D0 03 20 BD 83 20 49 83.
The second part is wrong.
The correct code is:
At xFEB0 write: AD 79 05 C9 LL D0 0A A9 RR CD 62 04 D0 03 4C BD 83 4C 49 83
(I.e. change both 20 bytes to 4C.)
Shauing wrote: August 19th, 2018, 6:39 pm Is it possible as well by exiting a room up?
At x81DE write: 4C 70 FE.
At xFE70 write: AD 79 05 C9 LL D0 0A A9 RR CD 62 04 D0 03 20 BD 83 4C A5 82.
Where LL is the level number minus 1, RR is the room number.
User avatar
Shauing
Calif
Calif
Posts: 435
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

Could it be possible to modify the Prince actions (and of guards/bosses too if posible) during the demo and recap sequences?

Practically in every recap, the prince gets killed by guards or other hazards and in the demo (that I have modified) he does some actions that are unnecessary.
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
User avatar
Shauing
Calif
Calif
Posts: 435
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

David wrote: August 19th, 2018, 8:14 pm First, a correction:
David wrote: August 19th, 2018, 6:08 pm At x82AF write: 20 B0 FE.
At xFEB0 write: AD 79 05 C9 LL D0 0A A9 RR CD 62 04 D0 03 20 BD 83 20 49 83.
The second part is wrong.
The correct code is:
At xFEB0 write: AD 79 05 C9 LL D0 0A A9 RR CD 62 04 D0 03 4C BD 83 4C 49 83
(I.e. change both 20 bytes to 4C.)
It works, though there is a bug; when the Prince falls down on the room that activates the checkpoint, he will keep falling by reappearing up in the same room, fall into the actual room below and die. Only by climbing down, hang to a tile while falling, or falling along with a loose tile, the bug doesn't happen.
Shauing wrote: August 19th, 2018, 6:39 pm Is it possible as well by exiting a room up?
David wrote: August 19th, 2018, 6:08 pm At x81DE write: 4C 70 FE.
At xFE70 write: AD 79 05 C9 LL D0 0A A9 RR CD 62 04 D0 03 20 BD 83 4C A5 82.
Where LL is the level number minus 1, RR is the room number.
It works. It didn't at first, but that was because on the hacks window, I had to change the number on the activate room (exit left) tab to 31. Though the Prince enters by running even when I deactivated it on the hacks window.
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
David
The Prince of Persia
The Prince of Persia
Posts: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

Shauing wrote: August 25th, 2018, 10:22 am Could it be possible to modify the Prince actions (and of guards/bosses too if posible) during the demo and recap sequences?

Practically in every recap, the prince gets killed by guards or other hazards and in the demo (that I have modified) he does some actions that are unnecessary.
The Prince's actions are stored here:

Code: Select all

demo keys:
01:E49B: WORD $0300,$1202,$0300,$0520,$0122,$0620,$0300,$000a,$0900,$0820,$0628,$0408,$0a00,$1102,$0e00,$0a02,$0200,$0520,$0122,$0120,$0700,$000a,[CLIPPED]
demo 1 keys:
01:E75B: WORD $1201,$1700,$0120,$0800,$ffff
demo 3 keys:
01:E765: WORD $0801,$1600,$0208,$0120,$0200,$ffff
demo 5 keys:
01:E771: WORD $0e00,$0c02,$0a00,$0920,$0000,$0201,$0800,$0a01,$1002,$000a,$002a,$010a,$0700,$ffff
demo 6 keys:
01:E78D: WORD $2d00,$ffff
demo 9 keys:
01:E791: WORD $0602,$1000,$0002,$0400,$0008,$0120,$0000,$0108,$0120,$0100,$0008,$0028,$0220,$0000,$0008,$0028,$0120,$0100,$0008,$0220,$ffff
demo 11 keys:
01:E7BB: WORD $0701,$0500,$0320,$0221,$1120,$0321,$1a20,$0221,$0020,$0c00,$ffff
demo 13 keys:
01:E7D1: WORD $1902,$1400,$0108,$0320,$0400,$0102,$0000,$0108,$0028,$0220,$0300,$0008,$0102,$0208,$0028,$ffff
demo 15 keys:
01:E7F1: WORD $0701,$1300,$0108,$0320,$0500,$0101,$0000,$0008,$0028,$0220,$0800,$0104,$1a00,$0701,$0400,$ffff
demo 18 keys:
01:E811: WORD $0901,$1000,$0008,$0120,$0100,$0008,$0220,$0000,$0008,$0220,$0000,$0008,$0220,$ffff
demo 20 keys:
01:E82D: WORD $4000,$ffff
The format of these tables are as following:
In each 2-byte item, the lower (first) byte stores the keys pressed, and the upper (second) byte stores the number of frames (minus 1) for which these keys are pressed.
(Remember, two-byte numbers are stored with swapped bytes, so $0300 is stored as 00 03, etc.)

The following keys are possible:
$00 = none
$01 = right
$02 = left
$04 = down
$08 = up
$20 = A ("shift")
$FF = end
You can combine multiple pressed keys by adding different numbers together. (It's actually a bitwise OR.)
For example shift+left/right for a safe step, or up+left/right for a jump.

As an example, here is the beginning of the demo level key sequence at xE49B:
00 03 = For 3+1 frames, press no keys.
02 12 = For $12+1=18+1 frames, hold left ($02). (run left)
00 03 = For 3+1 frames, press no keys again.
20 05 = For 5+1 frames, hold A ($20).
22 01 = For 1+1 frame, press left, while still holding A ($22 = $20 + $02). (step left)
20 06 = For 6+1 frames, hold A ($20).
00 03 = For 3+1 frames, press no keys.
0A 00 = For 0+1 frames, press up and left ($0A = $08 + $02). (standing jump left)
And so on.


There is this table for locating the key sequences for the recaps:

Code: Select all

end demo keys address:
01:E473: WORD $e75b,$e49b,$e765,$e49b,$e771,$e78d,$e49b,$e49b,$e791,$e49b,$e7bb,$e49b,$e7d1,$e49b,$e7f1,$e49b,$e49b,$e811,$e49b,$e82d
The table contains data for every level from 1 to 20, even for those levels that don't appear in the recap.
It seems that unused entries point to the key sequence of the demo level.


The following data are used for initializing the recap sequences:

Code: Select all

end demo direction:
01:E0FF: BYTE $ff,$00,$ff,$00,$00,$ff,$00,$00,$00,$00,$ff,$00,$00,$00,$ff,$00,$00,$ff,$00,$00
end demo room:
01:E113: BYTE $14,$00,$0d,$00,$0f,$15,$00,$00,$10,$00,$16,$00,$12,$00,$11,$00,$00,$0b,$00,$04
end demo tile:
01:E127: BYTE $0a,$00,$00,$00,$09,$15,$00,$00,$13,$00,$16,$00,$09,$00,$0a,$00,$00,$14,$00,$11
end demo HP:
01:E13B: BYTE $03,$00,$04,$00,$05,$05,$00,$00,$06,$00,$07,$00,$08,$00,$09,$00,$00,$0a,$00,$0f

end demo kid sequence:
01:E157: BYTE $02,$02,$54,$02,$54,$54,$02,$02,$54,$02,$54,$02,$54,$02,$02,$02,$54,$54,$02,$01
These tables tell where does the prince start on each level in the recaps.
Again, the tables contain data for every level from 1 to 20, even for those levels that don't appear in the recap.

Recaps are activated by the code at x1AF64..x1AFDB.
For each recap there is data in this format:

Code: Select all

03:AF64: a9 01       LDA #$01
03:AF66: 20 0d b0    JSR $b00d ; load level A-1 for memory scenes
03:AF69: a2 80       LDX #$80
03:AF6B: a0 a0       LDY #$a0
03:AF6D: 20 27 b0    JSR $b027 ; frame circle
That is: A9 LL 20 0D B0 A2 XX A0 YY 20 SS SS
Where:
LL is the level number.
At the end of the recap, a shape will appear.
XX and YY are the X and Y coordinates (in pixels) of the center of the shape (after it stops moving).
The origin of the coordinate system is in the top left corner. X increases rightwards, Y increases downwards.
SS SS determines which shape will appear.
The following shapes exist:
$b027 = circle
$b0a2 = square
$b166 = diamond
$b23f = hexagon
$b24d = hexagon (without fade out) -- This is used for the last recap, because it has its own, slower fade out.


If anything is unclear, just ask.
David
The Prince of Persia
The Prince of Persia
Posts: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

Shauing wrote: August 26th, 2018, 2:24 am It works, though there is a bug; when the Prince falls down on the room that activates the checkpoint, he will keep falling by reappearing up in the same room, fall into the actual room below and die. Only by climbing down, hang to a tile while falling, or falling along with a loose tile, the bug doesn't happen.
I have seen such a bug as well, but I thought I have fixed that.
I guess I haven't tried every way of falling down.

I think I found how to fix this:
At x82AF write back the original bytes: 20 49 83.
At x81E5 write: 4C B0 FE.
At xFEB0 write: AD 79 05 C9 LL D0 0A A9 RR CD 62 04 D0 03 20 BD 83 4C AF 82.
Again, LL = level - 1, RR = room.
Shauing wrote: August 26th, 2018, 2:24 am It works. It didn't at first, but that was because on the hacks window, I had to change the number on the activate room (exit left) tab to 31.
Though the Prince enters by running even when I deactivated it on the hacks window.
You need to make sure that *none* of the "running entry" dropdowns (there are 4 of them) contain that level where you don't want a running entry.
User avatar
Shauing
Calif
Calif
Posts: 435
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

David wrote: August 26th, 2018, 9:32 am
Shauing wrote: August 26th, 2018, 2:24 am It works, though there is a bug; when the Prince falls down on the room that activates the checkpoint, he will keep falling by reappearing up in the same room, fall into the actual room below and die. Only by climbing down, hang to a tile while falling, or falling along with a loose tile, the bug doesn't happen.
I have seen such a bug as well, but I thought I have fixed that.
I guess I haven't tried every way of falling down.

I think I found how to fix this:
At x82AF write back the original bytes: 20 49 83.
At x81E5 write: 4C B0 FE.
At xFEB0 write: AD 79 05 C9 LL D0 0A A9 RR CD 62 04 D0 03 20 BD 83 4C AF 82.
Again, LL = level - 1, RR = room.
That fixed it, thanks. I tried to fall in every way I could think in order to make sure the bug wasn't there anymore.
David wrote: August 26th, 2018, 9:32 am
Shauing wrote: August 26th, 2018, 2:24 am It works. It didn't at first, but that was because on the hacks window, I had to change the number on the activate room (exit left) tab to 31.
Though the Prince enters by running even when I deactivated it on the hacks window.
You need to make sure that *none* of the "running entry" dropdowns (there are 4 of them) contain that level where you don't want a running entry.
None of the other ''running entry'' dropdowns on the checkpoints tab matched the level where I didn't want it to, but I had activated a ''running entry'' when starting the level (i took that from Level 17 of the original game); I deactivated and that fixed the issue. A minor sacrifice, though.
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
User avatar
Shauing
Calif
Calif
Posts: 435
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

David wrote: August 19th, 2018, 8:14 pm
Shauing wrote: August 19th, 2018, 6:39 pm Is it possible as well by exiting a room up?
At x81DE write: 4C 70 FE.
At xFE70 write: AD 79 05 C9 LL D0 0A A9 RR CD 62 04 D0 03 20 BD 83 4C A5 82.
Where LL is the level number minus 1, RR is the room number.
I think I will either need two more of exiting a room up, or one more each for exiting a room up or down.

I think this won't be possible but, can a checkpoint be triggered by exiting/entering a room via a teleporter?
NEW UPDATE! Prince Of Persia: 30th Anniversary Port v1.1.5. Download it today!: viewtopic.php?p=29053#p29053
NEW UPDATE! Prince Of Persia: The Queen Of Light v2.6. Download it today! viewtopic.php?p=33174#p33174
Post Reply