Hacking the SNES ROM

Discuss PoP1 for SNES here.
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

Shauing wrote: May 16th, 2020, 4:53 pm 4. Can the Best Time menu look like this? :
Make the second column start from level 7:
At 0x15647 write: 06
At 0x1564C write: 06
At 0x15655 write: 06

Push the times one row down:
At 0x1564F write: 03

Put the total time into the slot for level 14:
At 0x15849 write: 0D
(This intentionally overwrites part of an earlier hack.)

Make the frame one row shorter:
At 0x1560F write: 0D
Remove the last row so it doesn't overwrite the bottom border:
At 0x157CE write: 00

Move the frame one row down (so it matches your mock-up exactly):
At 0x1560D write: 08

(Of course, you need to edit the texts in the 0x1570B..0x157CD area to match the new layout.)
User avatar
Shauing
Calif
Calif
Posts: 431
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

David wrote: May 23rd, 2020, 7:31 pm
Spoiler: show
Shauing wrote: May 16th, 2020, 4:53 pm 1. Be able to skip the Konami and/or Title Screen by pressing any button like in the Japanese version and on DOS, instead of being forced to wait until after the title screen appears.
At 0x1807D write: A9 00

Details:
The byte at RAM offset $0456 determines whether interruption is enabled.
If it's #$FF then the player can't interrupt the current scene, if it's #$00 then thay can interrupt it.

The hack changes the code where it's initially disabled:

Code: Select all

clear screen for intro:
03:8075: 22 0b b6 00 JSR $00:b60b ; screen off (RTL)
03:8079: 22 2d a9 00 JSR $00:a92d ; clear joypad data
03:807D: a9 ff       LDA #$ff
03:807F: 8d 56 04    STA $0456 ; disable interruption
03:8082: 60          RTS

Nice; is this code even in the Japanese ROM? Or was added to the US/Europe only.
David wrote: May 23rd, 2020, 8:00 pm
Spoiler: show
Shauing wrote: May 16th, 2020, 4:53 pm 2. Shadow's hitbox palette should be the same as Prince but not in design, as the Prince has the triangle pointing to the right, and all of the enemies triangle point to the left.
This hack will use the Prince's HP flipped for the shadow, because I found this easier than fiddling with the palette.

At 0x5141 write: 20 30 FF
At 0x7F30 write: A9 FD 3E E2 20 48 AD 84 04 C9 02 68 C2 20 B0 03 A9 FC 7E 60

Details:

Code: Select all

We overwrite this code:
00:D141: A9 FD 3E    LDA #$3EFD ; opponent's HP

With the following:

At 0x5141 write:
20 30 FF  JSR $FF30

At 0x7F30 write:
A9 FD 3E  LDA #$3EFD ; opponent's HP
E2 20     SEP #$20 ; 8-bit acc
48        PHA
AD 84 04  LDA $0484 ; Shad.chtype ; ShadID
C9 02     CMP #$02 ; check if chtype<2 (kid=0, shadow=1)
68        PLA
C2 20     REP #$20 ; 16-bit acc
B0 03     BCS :1 ; skip if not <2
A9 FC 7E  LDA #$7EFC ; Prince's HP flipped
          :1
60        RTS

I moved this one to 7F00 because of three-color palette hack I did, which I also moved at 7F20.
David wrote: May 23rd, 2020, 8:47 pm
Spoiler: show
Shauing wrote: May 16th, 2020, 4:53 pm 3. The float potion lacks a green screen flash like on DOS; without it, visually there's no indication for the potion.
At 0xD06A write: 20 A0 FD
At 0xFDA0 write: 8D 40 05 A9 6F 8D C4 04 A9 05 8D C3 04 60

Details:

Code: Select all

At 0xD06A write:
20 A0 FD  JSR $FDA0

At 0xFDA0 write:
8D 40 05  STA $0540 ; slow fall blue
A9 6F     LDA #$4F ; color: green
8D C4 04  STA $04c4 ; flash color
A9 05     LDA #$05
8D C3 04  STA $04c3 ; flash count
60        RTS

Cool. The code you wrote still had the yellow color, but the details you provided have the correct value for the green potion.
David wrote: May 23rd, 2020, 9:17 pm
Spoiler: show
Shauing wrote: May 16th, 2020, 4:53 pm Hmm ok, but the ''60 minutes left'' text prompt is back. This cannot be hidden?
At 0xF00C write: 20 90 FD
At 0xFD90 write: AD 79 05 C9 13 B0 03 20 0C E3 60

Code: Select all

At 0xF00C write:
20 90 FD  JSR $FD90

At 0xFD90 write:
AD 79 05  LDA $0579 ; current level
C9 13     CMP #$13
B0 03     BCS :1
20 0C E3  JSR $E30C ; showtime
          :1
60        RTS

Nice. I still wonder if two demos could play by making it choose between two sequences.
David wrote: May 23rd, 2020, 9:37 pm
Spoiler: show
Shauing wrote: May 16th, 2020, 4:53 pm Also, the maximum time value for the duration of the effect (FF) is still a bit short than what the music lasts (potion effect lasts 17 seconds, music lasts around 19).
My solution is to decrement the slow fall counter only in every other frame.
This makes the length of the slow fall the double of what's specified in the Hacks window.

At 0xF8AF write: 4C 70 FD
At 0xFD70 write: AD 01 05 1A 29 01 8D 01 05 D0 06 AD 00 05 4C B2 F8 AD 00 05 F0 F8 4C BA F8

Code: Select all

At 0xF8AF write:
4C 70 FD  JMP $FD70

At 0xFD70 write:
AD 01 05  LDA $0501 ; I've repurposed this unused byte to toggle between 00 and 01 in each frame.
1A        INC
29 01     AND #$01
8D 01 05  STA $0501 ; as above
D0 06     BNE :1
AD 00 05  LDA $0500 ; slow fall remaining time
          :2
4C B2 F8  JMP $F8B2 ; continue with decrement
          :1
AD 00 05  LDA $0500 ; slow fall remaining time
F0 F8     BEQ :2 ; if slow fall is not active, jump to the BEQ at F8B2 which will skip everything related to slow fall
4C BA F8  JMP $F8BA ; skip decrement

Nice. I didn't know there was an option on the hacks window (even though I have checked countless times the many options available there); I did it via hex-editing first.
David wrote: May 23rd, 2020, 10:18 pm
Spoiler: show
Shauing wrote: May 16th, 2020, 4:53 pm 4. Can the Best Time menu look like this? :
Make the second column start from level 7:
At 0x15647 write: 06
At 0x1564C write: 06
At 0x15655 write: 06

Push the times one row down:
At 0x1564F write: 03

Put the total time into the slot for level 14:
At 0x15849 write: 0D
(This intentionally overwrites part of an earlier hack.)

Make the frame one row shorter:
At 0x1560F write: 0D
Remove the last row so it doesn't overwrite the bottom border:
At 0x157CE write: 00

Move the frame one row down (so it matches your mock-up exactly):
At 0x1560D write: 08

(Of course, you need to edit the texts in the 0x1570B..0x157CD area to match the new layout.)

Niiice.

Well, except for seeing if a two demo autoplays is possible, this is pretty much it. Cannot thank you enough.
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: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

Shauing wrote: May 23rd, 2020, 10:30 pm Nice. I still wonder if two demos could play by making it choose between two sequences.
Demo moves are stored in the 0xE49B..0xE75A range.
For the following hack, the first sequence should start at 0xE49B, and the second at some later address.
The demoplay will use the two sequences alternatingly.

At 0x1806D write: 20 E0 FF
At 0x1FFE0 write: 8D 79 05 AD 04 05 1A 29 01 8D 04 05 F0 05 A9 xx 8D 77 0A 60
Where xx is the offset of the second sequence, minus 0xE49B.
Hopefully the first sequence is not longer than 0xFF bytes and xx fits into a single byte.

Details:

Code: Select all

At 0x1806D write:
20 E0 FF  JSR $FFE0

At 0x1FFE0 write:
8D 79 05  STA $0579 ; current level
AD 04 05  LDA $0504
1A        INC
29 01     AND #$01 ; 0 or 1
8D 04 05  STA $0504
F0 05     BEQ :1
A9 xx     LDA #$xx ; offset
8D 77 0A  STA $0A77 ; demo autoplay position
          :1
60        RTS
Note: The DOS version works differently.
There, in the swordfight on the demo level, the prince is controlled by the same logic which is used for the guards.
Since that's randomized, the result of the swordfight will also be random.
User avatar
Shauing
Calif
Calif
Posts: 431
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

David wrote: May 24th, 2020, 4:27 pm
Spoiler: show
Shauing wrote: May 23rd, 2020, 10:30 pm Nice. I still wonder if two demos could play by making it choose between two sequences.
Demo moves are stored in the 0xE49B..0xE75A range.
For the following hack, the first sequence should start at 0xE49B, and the second at some later address.
The demoplay will use the two sequences alternatingly.

At 0x1806D write: 20 E0 FF
At 0x1FFE0 write: 8D 79 05 AD 04 05 1A 29 01 8D 04 05 F0 05 A9 xx 8D 77 0A 60
Where xx is the offset of the second sequence, minus 0xE49B.
Hopefully the first sequence is not longer than 0xFF bytes and xx fits into a single byte.

Details:

Code: Select all

At 0x1806D write:
20 E0 FF  JSR $FFE0

At 0x1FFE0 write:
8D 79 05  STA $0579 ; current level
AD 04 05  LDA $0504
1A        INC
29 01     AND #$01 ; 0 or 1
8D 04 05  STA $0504
F0 05     BEQ :1
A9 xx     LDA #$xx ; offset
8D 77 0A  STA $0A77 ; demo autoplay position
          :1
60        RTS

I imagine the offset value is the number of bytes after E49B. It is not the case here but, what if it was longer than FF?
David wrote: May 24th, 2020, 4:27 pm
Spoiler: show
Note: The DOS version works differently.
There, in the swordfight on the demo level, the prince is controlled by the same logic which is used for the guards.
Since that's randomized, the result of the swordfight will also be random.

Ah, that explains why there's different results after the Prince goes pass the door that leads to the room with the guard. I tried to recreate one of the many where the Prince wins (it is slightly different because the guard wouldn't do certain moves). I will do the same for the one where the Prince loses.
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: 431
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

Norbert brought to me a couple of minor things that weren't attempted to adapt from DOS and I'm curious if they could be added.
1. Shadow (1b down) floor bridge on Level 12 after merging to look like normal floor tile and remain always visible after passing by the first time. Only the first half I managed to do by changing the four sprite pointers of the shadow floor animation to the level floor sprite, but I can't figure out how to make it permanently visible once the Prince steps on them.
2. Mouse returns from where it came after opening gate on Level 8 (from the right) instead of doing somersault jump and leaving to the left.
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: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

Shauing wrote: May 30th, 2020, 12:22 am 1. Shadow (1b down) floor bridge on Level 12 after merging to look like normal floor tile and remain always visible after passing by the first time. Only the first half I managed to do by changing the four sprite pointers of the shadow floor animation to the level floor sprite, but I can't figure out how to make it permanently visible once the Prince steps on them.
Part 1: remain always visible.

Make the animation stop at frame 3:
At 0xDA7E write: C9 03
At 0xDA82 write: A9 03

Stop the floors from disappearing when you leave the room:
At 0xDA89 write: A9 03

Part 1 can be used without Part 2.
That way the loose floor will freeze at the frame which is the closest to a whole (outlined) floor.


Part 2: look like normal floor tile.
I know you already solved this, but I was curious how to do this without changing the sprite pointers.
And I also found some neat floor animations which might interest someone.

Make the shadow floor look like a regular floor:
At 0x670B write: 00 (or 01 for a different effect)

With the above hack, the floor "pops out" (or "pops down") when it appears, because the animation now plays the frames of the floor buttons.

If you don't want that, do this:
At 0x65C9 write: A9 01 EA EA
(Use A9 00 EA EA if you used 01 in the previous write.)


Details:

Code: Select all

Part 1 changes this part:

animate:
01:DA78: ad 8c 05    LDA $058c ; current modifier (anim) ; state
01:DA7B: 30 07       BMI $da84
01:DA7D: 1a          INC
01:DA7E: c9 07       CMP #$07 ; <-- this
01:DA80: 90 02       BCC $da84
01:DA82: a9 07       LDA #$07 ; <-- this
01:DA84: 8d 8c 05    STA $058c ; current modifier (anim) ; state
01:DA87: 80 08       BRA $da91

stop:
01:DA89: a9 00       LDA #$00 ; <-- this
01:DA8B: 8d 8c 05    STA $058c ; current modifier (anim) ; state


Part 2 changes this part:

00:E5C5: e0 1b       CPX #$1b
00:E5C7: d0 06       BNE $e5cf
is shadow floor:
00:E5C9: b9 80 e0    LDA $e080,Y ; current room modifiers (w=16,h=5)
00:E5CC: 3a          DEC
00:E5CD: 80 3e       BRA $e60d ; end of object

At 0x65C9 (00:E5C9) write:
A9 01  LDA #$01 ; or #$00
EA     NOP
EA     NOP
This forces the game to show the same image regardless of the current modifier (current animation frame).

end of object:
00:E60D: 18          CLC
00:E60E: 7f f0 e6 00 ADC $00:e6f0,X ; object bg sprites

X = 0x1B (code of shadow floor), so the ADC reads from 0xE6F0 + 0x1B = 0xE70B, hence we need to change 0x670B to change what the loose floor looks like.

David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

Shauing wrote: May 30th, 2020, 12:22 am 2. Mouse returns from where it came after opening gate on Level 8 (from the right) instead of doing somersault jump and leaving to the left.
The game already contains the original moves of the mouse from the DOS (Apple II) version in the sequence table, so we just need to use them:
At 0x8BDA write: A9 6B

Except sequence #$6B has the two frames of the mouse swapped, when compared to the DOS version.
(The two frames are frame 4 when the mouse is standing up, and frame 1 when it's on all fours.)

So fix it:
At 0x176CC write: 01 01 01 04 04 04 04 04 04 04 04
(That is, change the 01 bytes to 04 and the 04 bytes to 01.)


Details:

The first hack changes this part:

Code: Select all

01:8BDA: a9 83       LDA #$83
01:8BDC: 20 42 ae    JSR $ae42 ; char sequence ; jumpseq
01:8BDF: 4c 8a 95    JMP $958a ; play char sequence ; animchar
The second hack changes part of the sequence table.
I posted the "disassembly" of the sequence table here: viewtopic.php?p=17498#p17498
User avatar
Shauing
Calif
Calif
Posts: 431
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

David wrote: May 30th, 2020, 6:01 pm
Spoiler: show
Shauing wrote: May 30th, 2020, 12:22 am 1. Shadow (1b down) floor bridge on Level 12 after merging to look like normal floor tile and remain always visible after passing by the first time. Only the first half I managed to do by changing the four sprite pointers of the shadow floor animation to the level floor sprite, but I can't figure out how to make it permanently visible once the Prince steps on them.
Part 1: remain always visible.

Make the animation stop at frame 3:
At 0xDA7E write: C9 03
At 0xDA82 write: A9 03

Stop the floors from disappearing when you leave the room:
At 0xDA89 write: A9 03

Part 1 can be used without Part 2.
That way the loose floor will freeze at the frame which is the closest to a whole (outlined) floor.


Part 2: look like normal floor tile.
I know you already solved this, but I was curious how to do this without changing the sprite pointers.
And I also found some neat floor animations which might interest someone.

Make the shadow floor look like a regular floor:
At 0x670B write: 00 (or 01 for a different effect)

With the above hack, the floor "pops out" (or "pops down") when it appears, because the animation now plays the frames of the floor buttons.

If you don't want that, do this:
At 0x65C9 write: A9 01 EA EA
(Use A9 00 EA EA if you used 01 in the previous write.)


Details:

Code: Select all

Part 1 changes this part:

animate:
01:DA78: ad 8c 05    LDA $058c ; current modifier (anim) ; state
01:DA7B: 30 07       BMI $da84
01:DA7D: 1a          INC
01:DA7E: c9 07       CMP #$07 ; <-- this
01:DA80: 90 02       BCC $da84
01:DA82: a9 07       LDA #$07 ; <-- this
01:DA84: 8d 8c 05    STA $058c ; current modifier (anim) ; state
01:DA87: 80 08       BRA $da91

stop:
01:DA89: a9 00       LDA #$00 ; <-- this
01:DA8B: 8d 8c 05    STA $058c ; current modifier (anim) ; state


Part 2 changes this part:

00:E5C5: e0 1b       CPX #$1b
00:E5C7: d0 06       BNE $e5cf
is shadow floor:
00:E5C9: b9 80 e0    LDA $e080,Y ; current room modifiers (w=16,h=5)
00:E5CC: 3a          DEC
00:E5CD: 80 3e       BRA $e60d ; end of object

At 0x65C9 (00:E5C9) write:
A9 01  LDA #$01 ; or #$00
EA     NOP
EA     NOP
This forces the game to show the same image regardless of the current modifier (current animation frame).

end of object:
00:E60D: 18          CLC
00:E60E: 7f f0 e6 00 ADC $00:e6f0,X ; object bg sprites

X = 0x1B (code of shadow floor), so the ADC reads from 0xE6F0 + 0x1B = 0xE70B, hence we need to change 0x670B to change what the loose floor looks like.

Nice, nice.
It's a cool effect, but for this mod I'll skip the animated open/close tile floor.
David wrote: May 30th, 2020, 6:42 pm
Spoiler: show
Shauing wrote: May 30th, 2020, 12:22 am 2. Mouse returns from where it came after opening gate on Level 8 (from the right) instead of doing somersault jump and leaving to the left.
The game already contains the original moves of the mouse from the DOS (Apple II) version in the sequence table, so we just need to use them:
At 0x8BDA write: A9 6B

Except sequence #$6B has the two frames of the mouse swapped, when compared to the DOS version.
(The two frames are frame 4 when the mouse is standing up, and frame 1 when it's on all fours.)

So fix it:
At 0x176CC write: 01 01 01 04 04 04 04 04 04 04 04
(That is, change the 01 bytes to 04 and the 04 bytes to 01.)


Details:

The first hack changes this part:

Code: Select all

01:8BDA: a9 83       LDA #$83
01:8BDC: 20 42 ae    JSR $ae42 ; char sequence ; jumpseq
01:8BDF: 4c 8a 95    JMP $958a ; play char sequence ; animchar
The second hack changes part of the sequence table.
I posted the "disassembly" of the sequence table here: viewtopic.php?p=17498#p17498

Cool, though it breaks its sequence on the cutscene of Level 8. Normally, it stands, then changes to all four looking left, then goes off-screen to the right. This change makes it change to all four looking to the left for one frame then stand up, and then goes off-screen to the right. Perhaps adding a new sequence a little bit below where there are zeros?
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: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

Shauing wrote: May 30th, 2020, 7:26 pm Cool, though it breaks its sequence on the cutscene of Level 8.
Oops, I didn't think of that!
I'll see what I can do.

Shauing wrote: May 24th, 2020, 8:47 pm I imagine the offset value is the number of bytes after E49B. It is not the case here but, what if it was longer than FF?
Then I would replace this part:

Code: Select all

F0 05     BEQ :1
A9 xx     LDA #$xx ; offset
8D 77 0A  STA $0A77 ; demo autoplay position
          :1
with this:

Code: Select all

F0 0A     BEQ :1
A9 xx     LDA #$xx ; offset low byte
8D 77 0A  STA $0A77 ; demo autoplay position low byte
A9 yy     LDA #$yy ; offset high byte
8D 78 0A  STA $0A78 ; demo autoplay position high byte
          :1
Where the offset is $yyxx.

Shauing wrote: May 30th, 2020, 12:22 am Norbert brought to me a couple of minor things that weren't attempted to adapt from DOS and I'm curious if they could be added.
I've found some more:

* When the prince or the guard dies on the demo level, the DOS version doesn't play music.
In the mod it's played; and, if the prince died, the music is even interrupted.

* In the DOS version, guards with skill 0 (on level 1) come towards the prince even if I keep attacking.
The SNES version has the same (see here), but you probably used a different skill number for the level 1 guards?

* The mirror music is played even if I enter the mirror room in the middle row. It should be played only if the prince is in the top row.

* On the SNES, the prince steps onto closer buttons, but steps up to opener buttons. In the DOS version it's the other way around.
Mentioned here: viewtopic.php?p=6312#p6312
While it makes sense that the prince can only avoid what he can see, the DOS behaviour is more useful, for example on level 7.
User avatar
Shauing
Calif
Calif
Posts: 431
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

David wrote: May 30th, 2020, 7:42 pm
Shauing wrote: May 30th, 2020, 12:22 am Norbert brought to me a couple of minor things that weren't attempted to adapt from DOS and I'm curious if they could be added.
I've found some more:

* When the prince or the guard dies on the demo level, the DOS version doesn't play music.
In the mod it's played; and, if the prince died, the music is even interrupted.
Yeah, I noticed that when I did the second demo autoplay. Can it be fixed?
David wrote: May 30th, 2020, 7:42 pm * In the DOS version, guards with skill 0 (on level 1) come towards the prince even if I keep attacking.
The SNES version has the same (see here), but you probably used a different skill number for the level 1 guards?
I think I used a green guard skill, but I did wrote every skill that was used on DOS based on the list that was posted somewhere here on the forum.
David wrote: May 30th, 2020, 7:42 pm * The mirror music is played even if I enter the mirror room in the middle row. It should be played only if the prince is in the top row.

* On the SNES, the prince steps onto closer buttons, but steps up to opener buttons. In the DOS version it's the other way around.
Mentioned here: viewtopic.php?p=6312#p6312
While it makes sense that the prince can only avoid what he can see, the DOS behaviour is more useful, for example on level 7.
Interesting. Can both be fixed?

NIMT-T brought a few more things that could be changed:
1. When the Prince dies, you have to wait for the music to end to restart the level, but on DOS you can interrupt this. Though I find this a bit disrespectful to the music, you still lose time.
2. When the guard or Prince gets hit, the small orange-yellow pointy star-ish shape also reflects their HP palette.
3. On Level 5, it seems that the Shadow should not display his HP.
4. On Level 12, if the Prince takes damage, Shadow also takes damage. You can get killed pretty in 4 hits even if you have a full 9 HP bar.
5. When the Prince jumps up to check which floors are loose floors, on DOS it also shakes the ones that are after walls and holes.
6. The sound of the skull pressing on a switch to make fall the loose tiles on Level 13. Perhaps a hack for making the loose tiles fall without needing a skull and a switch?
7. The level end door on Level 13 opens when the Prince goes back to the room where it is located after killing Jaffar, and it does not open when Jaffar is killed.
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: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

Shauing wrote: May 30th, 2020, 7:26 pm Cool, though it breaks its sequence on the cutscene of Level 8. Normally, it stands, then changes to all four looking left, then goes off-screen to the right. This change makes it change to all four looking to the left for one frame then stand up, and then goes off-screen to the right. Perhaps adding a new sequence a little bit below where there are zeros?
First undo the changes in my previous post, or start from a ROM which doesn't have them.

This new hack will keep using sequence #$83, but changes it to match the DOS animation.

At 0x176F2 write: F9 00 F2 08 01 01 01 04 04 04 04 04 04 04 04 FE FB 08 FF B2 F6
(That is, copy 0x176C8..0x176DC here, but with 01 and 04 swapped.)
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

Shauing wrote: May 30th, 2020, 8:41 pm 4. On Level 12, if the Prince takes damage, Shadow also takes damage. You can get killed pretty in 4 hits even if you have a full 9 HP bar.
At 0xF879 write: 80 05

It changes this part:

Code: Select all

01:F86C: AD 94 04    LDA $0494 ; OpID ; Opp.chtype
01:F86F: 0D 64 04    ORA $0464 ; Char.chtype ; CharID
01:F872: C9 01       CMP #$01 ; shadow
01:F874: D0 12       BNE $F888
01:F876: AD 09 05    LDA $0509 ; kid delta HP ; ChgKidStr
01:F879: 10 05       BPL $F880 ; <-- we change this to BRA $F880
01:F87B: 8D 0C 05    STA $050C ; guard delta HP ; ChgOppStr
01:F87E: 80 08       BRA $F888

01:F880: AD 0C 05    LDA $050C ; guard delta HP ; ChgOppStr
01:F883: 10 03       BPL $F888
01:F885: 8D 09 05    STA $0509 ; kid delta HP ; ChgKidStr
01:F888: AD 08 05    LDA $0508 ; kid current HP ; KidStrength
Shauing wrote: May 30th, 2020, 8:41 pm 5. When the Prince jumps up to check which floors are loose floors, on DOS it also shakes the ones that are after walls and holes.
At 0xDB59 write: D0 03
At 0xDB87 write: D0 03

It changes this part:

Code: Select all

01:DB57: C9 02       CMP #$02 ; loose floor
01:DB59: D0 0A       BNE $DB65 ; <-- we change this to BNE $DB5E: don't exit the loop
01:DB5B: 20 98 DB    JSR $DB98 ; shake one loose floor
01:DB5E: A3 02       LDA $02,S

01:DB85: C9 02       CMP #$02 ; loose floor
01:DB87: D0 0A       BNE $DB93 ; <-- we change this to BNE $DB8C: as above
01:DB89: 20 98 DB    JSR $DB98 ; shake one loose floor
01:DB8C: A3 02       LDA $02,S
David wrote: May 30th, 2020, 7:42 pm * On the SNES, the prince steps onto closer buttons, but steps up to opener buttons. In the DOS version it's the other way around.
At 0x9BEB write: C9 05

It changes this part:

Code: Select all

01:9BE7: C9 02       CMP #$02 ; loose floor
01:9BE9: F0 22       BEQ $9C0D ; :toEOB
01:9BEB: C9 04       CMP #$04 ; open button ; <-- we change this to CMP #$05 (closer button)
01:9BED: F0 15       BEQ $9C04 ; :toEOB1
01:9BEF: C9 0A       CMP #$0A ; sword
01:9BF1: F0 11       BEQ $9C04 ; :toEOB1
01:9BF3: 20 91 97    JSR $9791 ; is potion? ; cmp #flask
01:9BF6: F0 0C       BEQ $9C04 ; :toEOB1
David wrote: May 30th, 2020, 7:42 pm * The mirror music is played even if I enter the mirror room in the middle row. It should be played only if the prince is in the top row.
At 0x828B write: 20 60 FD
At 0xFD60 write: AC 6C 04 D0 03 20 52 84 60

Code: Select all

We alter this part:
01:828B: 20 52 84    JSR $8452 ; level 5 room 19 (exit left) (mirror music+stun)

At 0x828B write:
20 60 FD  JSR $FD60

At 0xFD60 write:
AC 6C 04  LDA $046C ; Kid.row
D0 03     BNE :1
20 52 84  JSR $8452 ; level 5 room 19 (exit left) (mirror music+stun)
          :1
60        RTS
User avatar
Shauing
Calif
Calif
Posts: 431
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

Spoiler: show
David wrote: May 31st, 2020, 4:40 pm
Spoiler: show
Shauing wrote: May 30th, 2020, 8:41 pm 4. On Level 12, if the Prince takes damage, Shadow also takes damage. You can get killed pretty in 4 hits even if you have a full 9 HP bar.
At 0xF879 write: 80 05

It changes this part:

Code: Select all

01:F86C: AD 94 04    LDA $0494 ; OpID ; Opp.chtype
01:F86F: 0D 64 04    ORA $0464 ; Char.chtype ; CharID
01:F872: C9 01       CMP #$01 ; shadow
01:F874: D0 12       BNE $F888
01:F876: AD 09 05    LDA $0509 ; kid delta HP ; ChgKidStr
01:F879: 10 05       BPL $F880 ; <-- we change this to BRA $F880
01:F87B: 8D 0C 05    STA $050C ; guard delta HP ; ChgOppStr
01:F87E: 80 08       BRA $F888

01:F880: AD 0C 05    LDA $050C ; guard delta HP ; ChgOppStr
01:F883: 10 03       BPL $F888
01:F885: 8D 09 05    STA $0509 ; kid delta HP ; ChgKidStr
01:F888: AD 08 05    LDA $0508 ; kid current HP ; KidStrength
Spoiler: show
Shauing wrote: May 30th, 2020, 8:41 pm 5. When the Prince jumps up to check which floors are loose floors, on DOS it also shakes the ones that are after walls and holes.
At 0xDB59 write: D0 03
At 0xDB87 write: D0 03

It changes this part:

Code: Select all

01:DB57: C9 02       CMP #$02 ; loose floor
01:DB59: D0 0A       BNE $DB65 ; <-- we change this to BNE $DB5E: don't exit the loop
01:DB5B: 20 98 DB    JSR $DB98 ; shake one loose floor
01:DB5E: A3 02       LDA $02,S

01:DB85: C9 02       CMP #$02 ; loose floor
01:DB87: D0 0A       BNE $DB93 ; <-- we change this to BNE $DB8C: as above
01:DB89: 20 98 DB    JSR $DB98 ; shake one loose floor
01:DB8C: A3 02       LDA $02,S
Spoiler: show
David wrote: May 30th, 2020, 7:42 pm * On the SNES, the prince steps onto closer buttons, but steps up to opener buttons. In the DOS version it's the other way around.
At 0x9BEB write: C9 05

It changes this part:

Code: Select all

01:9BE7: C9 02       CMP #$02 ; loose floor
01:9BE9: F0 22       BEQ $9C0D ; :toEOB
01:9BEB: C9 04       CMP #$04 ; open button ; <-- we change this to CMP #$05 (closer button)
01:9BED: F0 15       BEQ $9C04 ; :toEOB1
01:9BEF: C9 0A       CMP #$0A ; sword
01:9BF1: F0 11       BEQ $9C04 ; :toEOB1
01:9BF3: 20 91 97    JSR $9791 ; is potion? ; cmp #flask
01:9BF6: F0 0C       BEQ $9C04 ; :toEOB1
Spoiler: show
David wrote: May 30th, 2020, 7:42 pm * The mirror music is played even if I enter the mirror room in the middle row. It should be played only if the prince is in the top row.
At 0x828B write: 20 60 FD
At 0xFD60 write: AC 6C 04 D0 03 20 52 84 60

Code: Select all

We alter this part:
01:828B: 20 52 84    JSR $8452 ; level 5 room 19 (exit left) (mirror music+stun)

At 0x828B write:
20 60 FD  JSR $FD60

At 0xFD60 write:
AC 6C 04  LDA $046C ; Kid.row
D0 03     BNE :1
20 52 84  JSR $8452 ; level 5 room 19 (exit left) (mirror music+stun)
          :1
60        RTS
Nice. Thank you. I find weird though that on the last one, the mirror appears and no music is played when you're in the middle row; this also happens on DOS.

Just to write down here what is left to do:
1. When the Prince dies, you have to wait for the music to end to restart the level, but on DOS you can restart the level immediately. Though I find this a bit disrespectful to the music, you still lose time while waiting for the music to end.
2. When the guard or Prince gets hit, the small orange-yellow pointy star-ish hit shape that appears also reflects their HP palette.
3. On Level 5, it seems that the Shadow should not display his HP.
4. You can hear the sound of the skull pressing a switch to make fall the loose tiles on Level 13. Perhaps a hack for making the loose tiles fall without needing a skull and a switch?
5. On DOS, the level end door of Level 13 opens when the Prince goes back to the room where said door is located after killing Jaffar; it does not open when Jaffar is killed.
6. When the Prince or the guard dies on the demo level, the DOS version doesn't play music.
In the mod it's played; and, if the prince died, the music is even interrupted.
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: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

Shauing wrote: June 3rd, 2020, 5:25 am 3. On Level 5, it seems that the Shadow should not display his HP.
In the DOS version the Shadow shows HP only on level 12.

Here is how to do that on the SNES:
At 0x5125 write: 4C E0 FE
At 0x7EE0 write: C9 01 00 D0 0E AD 79 05 29 FF 00 C9 0B 00 F0 03 4C 2A D1 4C 2F D1

Details:

Code: Select all

At 0x5125 write:
4C E0 FE  JMP $FEE0

At 0x7EE0 write:
C9 01 00  CMP #$0001 ; shadow
D0 0E     BNE :1
AD 79 05  LDA $0579 ; current level
29 FF 00  AND #$00FF
C9 0B 00  CMP #$000B ; level 12
F0 03     BEQ :1
4C 2A D1  JMP $D12A ; don't draw HP
          :1
4C 2F D1  JMP $D12F ; draw HP

While testing the hack above, I noticed a problem: On level 6, the shadow won't step onto the closer button when you jump over to his side.
That's caused by one of my previous hacks, which makes the prince step up to closer buttons, instead of stepping onto them.
But it also causes the shadow to do the same.

Here is my fix:
At 0x9BEB write: 4C 40 FD EA
At 0xFD40 write: C9 05 D0 0D AD 64 04 C9 01 F0 03 4C 04 9C 4C FE 9B 4C EF 9B

This will make the shadow step onto the closer button, while the prince will still step up to them.

Details:

Code: Select all

At 0x9BEB write:
4C 40 FD  JMP $FD40
EA        NOP

At 0xFD40 write:
C9 05     CMP #$05 ; closer button
D0 0D     BNE :1
AD 64 04  LDA $0464 ; Char.chtype
C9 01     CMP #$01 ; shadow
F0 03     BEQ :2
4C 04 9C  JMP $9C04 ; step up to edge
          :2
4C FE 9B  JMP $9BFE ; full step
          :1
4C EF 9B  JMP $9BEF ; continue checking for other tile types
Note: In the DOS version, the shadow on level 6 is placed right next to the left edge of the button. That's why he can step onto the button.
The DOS version places the shadow using a special event, so it can set the place of the shadow pixel-perfectly.
In the SNES version, the shadow on level 6 is just a regular guard in the room, which does not allow such precision.
I wonder if this is part of the reason why they decided to make the prince step onto closer buttons in the SNES version.
User avatar
Shauing
Calif
Calif
Posts: 431
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

Spoiler: show
David wrote: June 7th, 2020, 4:30 pm In the DOS version the Shadow shows HP only on level 12.

Here is how to do that on the SNES:
At 0x5125 write: 4C E0 FE
At 0x7EE0 write: C9 01 00 D0 0E AD 79 05 29 FF 00 C9 0B 00 F0 03 4C 2A D1 4C 2F D1

Details:

Code: Select all

At 0x5125 write:
4C E0 FE  JMP $FEE0

At 0x7EE0 write:
C9 01 00  CMP #$0001 ; shadow
D0 0E     BNE :1
AD 79 05  LDA $0579 ; current level
29 FF 00  AND #$00FF
C9 0B 00  CMP #$000B ; level 12
F0 03     BEQ :1
4C 2A D1  JMP $D12A ; don't draw HP
          :1
4C 2F D1  JMP $D12F ; draw HP

While testing the hack above, I noticed a problem: On level 6, the shadow won't step onto the closer button when you jump over to his side.
That's caused by one of my previous hacks, which makes the prince step up to closer buttons, instead of stepping onto them.
But it also causes the shadow to do the same.

Here is my fix:
At 0x9BEB write: 4C 40 FD EA
At 0xFD40 write: C9 05 D0 0D AD 64 04 C9 01 F0 03 4C 04 9C 4C FE 9B 4C EF 9B

This will make the shadow step onto the closer button, while the prince will still step up to them.

Details:

Code: Select all

At 0x9BEB write:
4C 40 FD  JMP $FD40
EA        NOP

At 0xFD40 write:
C9 05     CMP #$05 ; closer button
D0 0D     BNE :1
AD 64 04  LDA $0464 ; Char.chtype
C9 01     CMP #$01 ; shadow
F0 03     BEQ :2
4C 04 9C  JMP $9C04 ; step up to edge
          :2
4C FE 9B  JMP $9BFE ; full step
          :1
4C EF 9B  JMP $9BEF ; continue checking for other tile types
Note: In the DOS version, the shadow on level 6 is placed right next to the left edge of the button. That's why he can step onto the button.
The DOS version places the shadow using a special event, so it can set the place of the shadow pixel-perfectly.
In the SNES version, the shadow on level 6 is just a regular guard in the room, which does not allow such precision.
I wonder if this is part of the reason why they decided to make the prince step onto closer buttons in the SNES version.
Nice, and interesting; it makes me wonder also why the Shadow is a regular guard for that specific event in the SNES version?

Now to just to see for the rest of the 30th port hacks pending and adding one for The Queen Of Light. How can I make passwords invalid if time is above 90 minutes? I think the hack you gave me for the 30th port invalidates passwords when time is above 60 minutes.

And adding the main ones for the third mod far in the distance in importance order:
- Multiple special exits per level in all four directions.
- Multiple checkpoint and restart points per level. (Maybe passwords can use the unused checkpoint feature that would restore you at the checkpoint, or the code isn't complete?)
- Change ''Level xx'' to a level name like I did on the ''Training Levels'' for The Queen Of Light but for all 27 levels (this includes Jaffar, Demo and Training Levels) (I tried to do this myself, but the hack is slightly longer so it would lead to crashes or softlocks at the menu if quitting the game before the level prompt disappears and only works for Levels 1-20).
- Remove the Level number on the pause menu.
- Best time menu should only display the total final time.
- A hack for at least one type/skill guard not displaying HP.
* I was also touting with modifying very subtly the run/jump/climb physics but probably this is too complex.
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