Expansion of Treasure Chest subroutine
#3
Found it! Thanks Madsiur!

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.
Reply


Messages In This Thread
RE: Expansion of Treasure Chest subroutine - by NPCnextdoor - 07-01-2018, 11:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Zone Doctor and FF6LE Expansion madsiur 66 70,616 07-24-2025, 12:39 PM
Last Post: madsiur
  Monster Expansion madsiur 31 43,092 02-23-2023, 02:38 PM
Last Post: madsiur
  Command Change Relic Table Expansion Celestial84 2 2,677 12-04-2021, 07:01 AM
Last Post: Celestial84
  SRAM Expansion madsiur 5 6,566 12-19-2016, 09:17 AM
Last Post: seibaby
  FF6 Expansion Editor (FF6ExpED) madsiur 25 29,640 05-12-2016, 01:57 PM
Last Post: Imzogelmo
  Treasure Chest Offset Fenrir 1 2,752 03-14-2013, 05:41 PM
Last Post: m06
  Custom Treasure Chest madsiur 8 8,754 05-03-2012, 12:02 PM
Last Post: SSJ Rick

Forum Jump:


Users browsing this thread: 1 Guest(s)