I chose to do these two together, because both hacks need to pay attention to the prince leaving rooms.
First part: Watch for the prince exiting rooms.
WRONG: At 0x8139 write: 20 60 FA
WRONG: At 0xFA60 write: 8D 8B 05 A2 0F BD 90 FA CD 79 05 D0 1F BD A0 FA CD 62 04 D0 17 BD B0 FA CD 8B 05 D0 0F BD C0 FA F0 08 C9 FF D0 03 4C FA 9E 4C BF 83 CA 10 D8 60
FIX: At 0x82CF write: 20 60 FA
FIX: At 0xFA60 write: 8D 8B 05 A2 0F BD A0 FA CD 79 05 D0 21 BD B0 FA CD 62 04 D0 19 BD C0 FA CD 8B 05 D0 11 BD D0 FA F0 0C C9 FF D0 03 4C FA 9E 20 BF 83 80 03 CA 10 D4 AD 8B 05 4C 72 84
Second part: Handle checkpoints when restarting the level.
At 0xDF18 write: 4C 10 FB
At 0xFB10 write: AD 27 06 D0 03 4C 1B E0 A2 0F BD A0 FA CD 79 05 D0 20 BD D0 FA CD 27 06 D0 18 BD E0 FA 8F 10 F1 7F BD F0 FA 8F 11 F1 7F BD 00 FB 8F 12 F1 7F 4C 1B E0 CA 10 D5 4C 1B E0
Third part: Configuring the special exits and checkpoints.
16 events are supported by default, so the index X can go from 0x0 to 0xF.
At 0xFAA0 + X write the level number. 00=level 1, 01=level 2, etc. as usual.
At 0xFAB0 + X write the room which the prince needs to leave to trigger the event.
At 0xFAC0 + X write the direction in which the prince needs to leave the room. 00=left, 01=right, 02=up, 03=down.
At 0xFAD0 + X write what should happen: 00=nothing, FF=level complete, 01,02,03,etc.=set checkpoint. (Different checkpoints on the same level must have different numbers.)
For checkpoints only:
At 0xFAE0 + X write the room where the prince should restart.
At 0xFAF0 + X write the tile position where the prince should restart.
At 0xFB00 + X write the direction to turn: 00=right, FF=left.
If you need more than 16 events (in the whole game) then change the following:
* The bytes after A2 bytes (LDX #$..) to the number of events minus 1.
* The 2-byte offsets after BD bytes (LDA $....,X), to the new location of each table.
Details:
Code: Select all
First part:
At 0x82CF write:
20 60 FA JSR $FA60
At 0xFA60 write:
8D 8B 05 STA $058B ; ]cutdir
A2 0F LDX #$0F ; number of room events-1
:loop
BD A0 FA LDA $FAA0,X ; level[X]
CD 79 05 CMP $0579 ; current level
D0 21 BNE :no
BD B0 FA LDA $FAB0,X ; leave_room[X]
CD 62 04 CMP $0462 ; Char.room ; CharScrn
D0 19 BNE :no
BD C0 FA LDA $FAC0,X ; leave_direction[X]
CD 8B 05 CMP $058B ; ]cutdir
D0 11 BNE :no
; found a room event
BD D0 FA LDA $FAD0,X ; action[X]
F0 0C BEQ :no ; zero means no action
C9 FF CMP #$FF
D0 03 BNE :chkp ; FF means next level
4C FA 9E JMP $9EFA ; seq level ended ; GoneUpstairs
:chkp ; 01..FE means checkpoint
20 BF 83 JSR $83BF ; set checkpoint
80 03 BRA :end
:no
CA DEX
10 D4 BPL :loop
:end
AD 8B 05 LDA $058B ; ]cutdir
4C 72 84 JMP $8472 ; do warp? ; CUT
Second part:
At 0xDF18 write:
4C 10 FB JMP $FB10
At 0xFB10 write:
AD 27 06 LDA $0627 ; checkpoint on/off
D0 03 BNE :1
4C 1B E0 JMP $E01B ; default startpos
:1
A2 0F LDX #$0F ; number of room events-1
:loop
BD A0 FA LDA $FAA0,X ; level[X]
CD 79 05 CMP $0579 ; current level
D0 20 BNE :no
BD D0 FA LDA $FAD0,X ; action[X]
CD 27 06 CMP $0627 ; checkpoint on/off
D0 18 BNE :no ; zero means no action
BD E0 FA LDA $FAE0,X ; restart_room[X]
8F 10 F1 7F STA $7F:F110 ; start room
BD F0 FA LDA $FAF0,X ; restart_tile[X]
8F 11 F1 7F STA $7F:F111 ; start tile
BD 00 FB LDA $FB00,X ; restart_direction[X]
8F 12 F1 7F STA $7F:F112 ; start direction
4C 1B E0 JMP $E01B ; default startpos
:no
CA DEX
10 D5 BPL :loop
4C 1B E0 JMP $E01B ; default startpos