Hacking the SNES ROM

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

Re: Hacking the SNES ROM

Post by David »

Shauing wrote: July 15th, 2020, 6:09 pm All right, I'll check this out to see if I understood how it works. And yes, see if it can be extended to possibly 240-300 minutes.
At 0xE961 write the number of minutes.
It's one byte so it can't be more than 255.

At 0xE941 write the time given in ticks (2 bytes), i.e. the number of minutes multiplied by the ticks in a minute.

Convert minutes to 3-digit BCD instead of 2-digit semi-BCD.
At 0xE962 write: 20 30 FF
At 0xFF30 write: DA C3 01 90 02 A3 01 49 FF 38 63 01 A2 00 38 E9 64 90 03 E8 80 F8 18 69 64 8E 2A 05 A2 00 38 E9 0A 90 03 E8 80 F8 18 69 0A 48 8A 0A 0A 0A 0A 18 63 01 FA FA 60

Display 3-digit minutes correctly in the pause menu.
At 0x16335 write: 4C 50 FF
At 0x17F50 write: AC 2A 05 C9 A0 90 03 88 A9 99 48 98 F0 05 18 69 30 95 00 68 4C 42 E3
Decrease minutes by one correctly when minutes = 100, 200.
At 0x16313 write: 20 40 FF
At 0x17F40 write: AD 27 05 0D 2A 05 60

Display 3-digit minutes correctly in pop-up messages.
At 0xC9BF write: AE 2A 05 48 8A 18 69 30 8D 56 08 68 EA EA EA EA
Trim leading zeroes (instead of spaces).
At 0xC9FD write 30.

Show seconds only if 1 minute is left (not 101, 201).
At 0xC9A6, 0xC9DE, 0xE319 write: 20 20 FF EA EA
At 0xFF20 write: AD 2A 05 D0 06 AD 27 05 C9 02 60 AD 27 05 38 60

Don't think it's "TIME UP" if only the last 2 digits of the minutes are zero.
At 0x8442, 0x8686, 0xC98E, 0xEF80, 0xF00F, 0xF3D6, 0xF7CC write: 20 10 FF
At 0xFF10 write: AD 27 05 0D 2A 05 60

Details:

Code: Select all

You might have noticed that most assembly listings here look rather different than the older ones.
That's because I made those hacks using an assembler instead of hand-assembling, and the listing output of the assembler looks like this.

Convert minutes to 3-digit BCD instead of 2-digit semi-BCD.
start address $01FF30
     1 01FF30                              .ORG   $01FF30
     2 01FF30
     3 01FF30                                                      ; convert minutes to 3-digit BCD instead of 2-digit semi-BCD
     4 01FF30
memory 8-bit
     5 01FF30                              .MEM   8
index 8-bit
     6 01FF30                              .INDEX 8
     7 01FF30
     8 01FF30 DA                           PHX
     9 01FF31 C3 01                        CMP    $01,S
    10 01FF33 90 02                        BCC    Z
    11 01FF35 A3 01                        LDA    $01,S
    12 01FF37             Z
    13 01FF37 49 FF                        EOR    #$FF
    14 01FF39 38                           SEC
    15 01FF3A 63 01                        ADC    $01,S
    16 01FF3C
    17 01FF3C A2 00                        LDX    #$00
    18 01FF3E             LOOP_HUNDREDS
    19 01FF3E 38                           SEC
    20 01FF3F E9 64                        SBC    #100
    21 01FF41 90 03                        BCC    END_HUNDREDS
    22 01FF43 E8                           INX
    23 01FF44 80 F8                        BRA    LOOP_HUNDREDS
    24 01FF46
    25 01FF46             END_HUNDREDS
    26 01FF46 18                           CLC
    27 01FF47 69 64                        ADC    #100
    28 01FF49
    29 01FF49 8E 2A 05                     STX    $052A            ; remaining min hundreds
    30 01FF4C
    31 01FF4C A2 00                        LDX    #$00
    32 01FF4E             LOOP_TENS
    33 01FF4E 38                           SEC
    34 01FF4F E9 0A                        SBC    #10
    35 01FF51 90 03                        BCC    END_TENS
    36 01FF53 E8                           INX
    37 01FF54 80 F8                        BRA    LOOP_TENS
    38 01FF56
    39 01FF56             END_TENS
    40 01FF56 18                           CLC
    41 01FF57 69 0A                        ADC    #10
    42 01FF59
    43 01FF59 48                           PHA
    44 01FF5A 8A                           TXA
    45 01FF5B 0A                           ASL
    46 01FF5C 0A                           ASL
    47 01FF5D 0A                           ASL
    48 01FF5E 0A                           ASL
    49 01FF5F 18                           CLC
    50 01FF60 63 01                        ADC    $01,S
    51 01FF62 FA                           PLX
    52 01FF63 FA                           PLX
    53 01FF64
    54 01FF64 60                           RTS


Display 3-digit minutes correctly in the pause menu.
start address $02FF50
     1 02FF50                              .ORG   $02FF50
optimize addresses enabled
     2 02FF50                              .OPTIMIZE ON
     3 02FF50
     4 02FF50                                                      ; display 3-digit minutes correctly in pause menu
     5 02FF50
memory 8-bit
     6 02FF50                              .MEM   8
index 8-bit
     7 02FF50                              .INDEX 8
     8 02FF50
     9 02FF50                                                      ; Remaining min was just decreased.
    10 02FF50                                                      ; Decrease hundreds if there was borrow.
    11 02FF50
    12 02FF50 AC 2A 05                     LDY    $052A            ; remaining min hundreds
    13 02FF53 C9 A0                        CMP    #$A0
    14 02FF55 90 03                        BLT    @1
    15 02FF57 88                           DEY
    16 02FF58 A9 99                        LDA    #$99
    17 02FF5A             @1
    18 02FF5A
    19 02FF5A 48                           PHA
    20 02FF5B 98                           TYA                     ; remaining min hundreds
    21 02FF5C F0 05                        BEQ    SKIP
    22 02FF5E 18                           CLC
    23 02FF5F 69 30                        ADC    #'0'
    24 02FF61 95 00                        STA    $00,X
    25 02FF63             SKIP
    26 02FF63 68                           PLA
    27 02FF64 4C 42 E3                     JMP    $02E342

Decrease minutes by one correctly when minutes = 100, 200.

Original code at 02:E313 = 0x16313:
02:E313: ad 27 05    LDA $0527 ; remaining min ; <-- overwrite with JSR $FF40
02:E316: f0 0e       BEQ $e326

At 02:FF40 = 0x17F40 write:
AD 27 05  LDA $0527 ; remaining min
0D 2A 05  ORA $052A ; remaining min hundreds
60        RTS


Display 3-digit minutes correctly in pop-up messages.
start address $01C9BF
     1 01C9BF                              .ORG   $01C9BF
     2 01C9BF
     3 01C9BF                                                      ; display 3-digit minutes correctly in pop-up messages
     4 01C9BF
memory 8-bit
     5 01C9BF                              .MEM   8
index 8-bit
     6 01C9BF                              .INDEX 8
     7 01C9BF
     8 01C9BF AE 2A 05                     LDX    $052A            ; remaining min hundreds
     9 01C9C2 48                           PHA
    10 01C9C3 8A                           TXA
    11 01C9C4 18                           CLC
    12 01C9C5 69 30                        ADC    #'0'
    13 01C9C7 8D 56 08                     STA    $0856            ; buffer for strings
    14 01C9CA 68                           PLA
    15 01C9CB EA                           NOP
    16 01C9CC EA                           NOP
    17 01C9CD EA                           NOP
    18 01C9CE EA                           NOP
    19 01C9CF                                                      ; 01:C9CF


Show seconds only if 1 minute is left (not 101, 201).
start address $01FF20
     1 01FF20                              .ORG   $01FF20
     2 01FF20
     3 01FF20                                                      ; Show seconds only if 1 minute is left (not 101, 201).
     4 01FF20
memory 8-bit
     5 01FF20                              .MEM   8
index 8-bit
     6 01FF20                              .INDEX 8
     7 01FF20
     8 01FF20 AD 2A 05                     LDA    $052A            ; remaining min hundreds
     9 01FF23 D0 06                        BNE    @1
    10 01FF25 AD 27 05                     LDA    $0527            ; remaining min
    11 01FF28 C9 02                        CMP    #$02
    12 01FF2A 60                           RTS
    13 01FF2B             @1
    14 01FF2B AD 27 05                     LDA    $0527            ; remaining min
    15 01FF2E 38                           SEC
    16 01FF2F 60                           RTS


Don't think it's "TIME UP" if only the last 2 digits of the minutes are zero.

At 0x8442 etc. is this code:
01:8442: ad 27 05    LDA $0527 ; remaining min ; <-- overwrite with JSR $FF10
01:8445: 0d 29 05    ORA $0529 ; remaining sec

At 0xFF10 write:
AD 27 05  LDA $0527 ; remaining min
0D 2A 05  ORA $052A ; remaining min hundreds
60        RTS
User avatar
Shauing
Calif
Calif
Posts: 435
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

I'm wondering, now with the expanded space in a ROM. As we don't have a tool for compressing graphics for screens, if I have uncompressed tiles, how can I display them, for example, for a title screen? I also assume it has to look for a palette somewhere in the ROM?
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
Adolf
Sheikh
Sheikh
Posts: 23
Joined: October 15th, 2021, 10:54 am

Re: Hacking the SNES ROM

Post by Adolf »

Some guy released a hack

https://www.romhacking.net/hacks/6623/

"This is a project that active and optimize the game with the FastROM mode to gain some performance and reduce the slowdown"

"FastROM (3.58 MHz) allows the SNES CPU to read data and opcodes from the ROM 33.58% faster compared to SlowROM (2.68 MHz)"
User avatar
Shauing
Calif
Calif
Posts: 435
Joined: April 5th, 2018, 10:38 pm
Contact:

Re: Hacking the SNES ROM

Post by Shauing »

Hmmm, I'm more interested on how he inserted the first image of the japanese Box Art and his credit. Because that's what I would love to do, replace/add some background screens to change the story and cutscenes.
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
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5761
Joined: April 9th, 2009, 10:58 pm

Re: Hacking the SNES ROM

Post by Norbert »

Shauing wrote: March 5th, 2022, 2:19 am Hmmm, I'm more interested on how he inserted the first image of the japanese Box Art and his credit. Because that's what I would love to do, replace/add some background screens to change the story and cutscenes.
That was inserted before the actual game, so the game itself hasn't been modified.
[Edit: I guess you could ask how it was done in the comments here.]

Attaching a patched ROM, to make playtesting easier.
Attachments
PoP1_JP_FastROM.zip
(671.76 KiB) Downloaded 862 times
Adolf
Sheikh
Sheikh
Posts: 23
Joined: October 15th, 2021, 10:54 am

Re: Hacking the SNES ROM

Post by Adolf »

Through the overclocking function, you can get even better results. This hack is at the Low or Normal overclocking level (snes9x), there are fewer slowdowns, but they still exist. In the overclocking function, you can turn on the Max level and then everything will be smooth and without slowing down. But the game will be more difficult.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5761
Joined: April 9th, 2009, 10:58 pm

Re: Hacking the SNES ROM

Post by Norbert »

I just noticed that five tiles of the original game have unusual modifiers, that I do not understand the meaning of. None of the tiles contain objects, although most have an object (teleport or gate) to their left, which may (or may not) be relevant. Maybe these modifiers were mistakenly added; maybe not. They are:
- level 15, room 20, tile 18: mod 7
- level 15, room 14, tile 14: mod 3
- level 15, room 14, tile 17: mod 4
- level 17, room 2, tile 19: mod 255 (0xFF)
- level 18, room 13, tile 20: mod 255 (0xFF)
David
The Prince of Persia
The Prince of Persia
Posts: 2863
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Hacking the SNES ROM

Post by David »

Norbert wrote: December 17th, 2022, 10:11 pm None of the tiles contain objects, although most have an object (teleport or gate) to their left, which may (or may not) be relevant.
Maybe those objects used to be where the unusual modifiers are.
Then they removed the object from the old place without removing the modifier, and added it to the tile on the left.
This is just my guess.
Norbert wrote: December 17th, 2022, 10:11 pm - level 18, room 13, tile 20: mod 255 (0xFF)
This one is in a wall.
Perhaps there used to be an open gate there, then they removed it without removing the modifier.
The gate would have led to the room on the right, which was removed as well.
(Or rather, moved elsewhere, since this level uses all 24 rooms.)
Again, this is just my guess.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5761
Joined: April 9th, 2009, 10:58 pm

Re: Hacking the SNES ROM

Post by Norbert »

David wrote: December 18th, 2022, 2:47 pmMaybe those objects used to be where the unusual modifiers are.
Then they removed the object from the old place without removing the modifier, and added it to the tile on the left.
This is just my guess.
Right. That is almost certainly it, seeing how each floor tile with an unexpected modifier has an object to its left with the same modifier value.
David wrote: December 18th, 2022, 2:47 pmThis one is in a wall.
Perhaps there used to be an open gate there, then they removed it without removing the modifier.
The gate would have led to the room on the right, which was removed as well.
(Or rather, moved elsewhere, since this level uses all 24 rooms.)
Again, this is just my guess.
Could be; modifier 0xFF is generally only used for (open) gates. It's unlikely it was a raise/drop/teleport.
Adolf
Sheikh
Sheikh
Posts: 23
Joined: October 15th, 2021, 10:54 am

Re: Hacking the SNES ROM

Post by Adolf »

This hacker released full FastROM support

Prince of Persia (U) https://www.romhacking.net/hacks/7735/

Prince of Persia (J) https://www.romhacking.net/hacks/7763/
User avatar
angel_ana
Scholar Scribe
Scholar Scribe
Posts: 4
Joined: April 26th, 2023, 8:35 pm

Re: Hacking the SNES ROM

Post by angel_ana »

Help.

I'm wanting to create a fake potion warp that when drunk it goes back to level 1.

- Potion Warp:
xXXXX = Drinking this portion will go to level 1.

Can you help me?
User avatar
spartacus735
Wise Scribe
Wise Scribe
Posts: 221
Joined: November 20th, 2011, 12:41 pm
Location: France

Re: Hacking the SNES ROM

Post by spartacus735 »

Hi everyone,

The link to download the 0.smc rom of Kashlghnoon is dead, so I reupload it for everyone.
Attachments
0.rar
The Custom Rom of Kashlghnoon
(549.81 KiB) Downloaded 124 times
>>>>>>>>>>>>>>>>>>>> http://www.youtube.com/user/spartacus735 <<<<<<<<<<<<<<<<<<<< the channel of prince of persia snes mod
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5761
Joined: April 9th, 2009, 10:58 pm

Re: Hacking the SNES ROM

Post by Norbert »

Speaking of ROM hacking, ROMhacking.net will go news-only.
Already, existing files are now read-only, and new files are no longer being accepted.
They're also copying files to the Internet Archive, in an attempt to preserve these.
User avatar
spartacus735
Wise Scribe
Wise Scribe
Posts: 221
Joined: November 20th, 2011, 12:41 pm
Location: France

Re: Hacking the SNES ROM

Post by spartacus735 »

Norbert wrote: August 3rd, 2024, 7:37 am Speaking of ROM hacking, ROMhacking.net will go news-only.
Already, existing files are now read-only, and new files are no longer being accepted.
They're also copying files to the Internet Archive, in an attempt to preserve these.
Yeah I read that yesterday, very sad news. I hope he will find a another solution. :?
>>>>>>>>>>>>>>>>>>>> http://www.youtube.com/user/spartacus735 <<<<<<<<<<<<<<<<<<<< the channel of prince of persia snes mod
Post Reply