07-01-2018, 11:20 PM
(This post was last modified: 07-01-2018, 11:52 PM by NPCnextdoor.)
Found it! Thanks Madsiur!
And yes, I already made a script to randomize the treasure chests. It will only be a matter of fooling around with the function to write information back to the ROM.
Code:
Checking chest coordinates and event bit
15F1 20 13 D6 -- JSR $D613 Preparing the division
15F4 BF 34 86 ED LDA $ED8634,X Load (X, Y) coordinates of chest into A
15F8 85 2A -- -- STA $2A Store X coordinate in $2A, Y coordinate into $2B
15FA DA -- -- -- PHX Push X to stack
15FB EA EA EA -- NOP x 3 Being haunted by the ghosts of your past for 6 cycles.
15FE 20 1D D6 -- JSR $D61D
1601 4C 11 16 -- JMP $1611
1604 FF FF FF FF
1608 FF FF FF FF
160C FF FF FF FF
1610 FF -- -- --
Opening a treasure chest
C0/4C06 C2 20 -- -- REP #$20
C0/4C08 20 13 D6 -- JSR $D613
C0/4C0B BF 38 86 ED LDA $ED8638,X
C0/4C0F 85 1A -- -- STA $1A
C0/4C11 BF 36 86 ED LDA $ED8636,X
C0/4C15 85 1E -- -- STA $1E
C0/4C17 20 1D D6 -- JSR $D61D
C0/4C1A 4C 21 4C -- JMP $4C21
C0/4C1D FF FF FF FF
Division & Retrieving event byte/bit
C0/D613 8E 04 42 -- STX $4204 Store X as dividend
C0/D616 A9 00 05 -- LDA #$0500
C0/D619 8D 06 42 -- STA $4206 Store 0x05 as divisor
C0/D61C 60 -- -- -- RTS
C0/D61D AD 16 42 -- LDA $4216 Load quotient into A
C0/D620 29 07 00 -- AND #$0007 A = A AND 0x07, keeping encoding bit
C0/D623 AA -- -- -- TAX Transfer A to X
C0/D624 AD 16 42 -- LDA $4216 Reload quotient into A
C0/D627 4A -- -- -- LSR A
C0/D628 4A -- -- -- LSR A
C0/D629 4A -- -- -- LSR A Shift 3 bits to the right, keeping encoding byte
C0/D62A A8 -- -- -- TAY Transfer A to Y
C0/D62B 60 -- -- -- RTS
And yes, I already made a script to randomize the treasure chests. It will only be a matter of fooling around with the function to write information back to the ROM.