Users browsing this thread: 1 Guest(s)
Displaying item received, spell learned or amount of gold received in a dialog box
To answer my own question and for everyone else who would like to know, I did a little research...
Here's the treasure chest decoding function:
This function check if the treasure chest contain GP, an item or a monster and will call the appropriate event (respectively CA/0010, CA/0008, CA/0040 or even CA/0014, the event for an empty chest).
Those event will then display the dialog box with the item or the amount of GP as a parameter if it's the case.
If we take the example of subroutine CA/0008, the only place I found in the entire game that it is called is in the portion of code I posted and therefore is only used for treasure chests. There is no example in the event dump where CA/0008 is called. I beleive there is no way to give the item name as a parameter in events.
Every item given through events will need a custom dialog box, where you write "Receive 'item name'!" and you need to manually add the item to the inventory using command 80.
The situation is probably the same for the amount of GP to display and for the dialog box that display "Learned []!", where is a spell, it may be only used at the end of a battle, not through events.
Here's the treasure chest decoding function:
Code:
Treasure chest decoding function
C0/4C06: C220 REP #$20 (16 bit accum./memory)
C0/4C08: BF3886ED LDA $ED8638,X
C0/4C0C: 851A STA $1A (now the contents of the chest)
C0/4C0E: BF3686ED LDA $ED8636,X
C0/4C12: 851E STA $1E (the bit of this chest)
C0/4C14: 290700 AND #$0007
C0/4C17: AA TAX
C0/4C18: A51E LDA $1E
C0/4C1A: 29FF01 AND #$01FF
C0/4C1D: 4A LSR A
C0/4C1E: 4A LSR A
C0/4C1F: 4A LSR A
C0/4C20: A8 TAY
C0/4C21: 7B TDC
C0/4C22: E220 SEP #$20 (8 bit accum./memory)
C0/4C24: B9401E LDA $1E40,Y (treasure chest bits)
C0/4C27: 3FFCBAC0 AND $C0BAFC,X (is it this bit?)
C0/4C2B: D0A6 BNE $4BD3 (branch and exit if not. interesting fail-safe)
C0/4C2D: B9401E LDA $1E40,Y (treasure chest bits)
C0/4C30: 1FFCBAC0 ORA $C0BAFC,X
C0/4C34: 99401E STA $1E40,Y (set this chest as now open)
C0/4C37: A51F LDA $1F
C0/4C39: 1045 BPL $4C80 (if high bit = 0 then it's not a GP chest)
C0/4C3B: A51A LDA $1A
C0/4C3D: 8D0242 STA $4202
C0/4C40: A964 LDA #$64 (GP amount * 100)
C0/4C42: 8D0342 STA $4203
C0/4C45: EA NOP
C0/4C46: EA NOP
C0/4C47: EA NOP
C0/4C48: AC1642 LDY $4216
C0/4C4B: 8422 STY $22
C0/4C4D: 6424 STZ $24 (shame all 24-bits aren't used here)
C0/4C4F: C221 REP #$21
C0/4C51: 98 TYA
C0/4C52: 6D6018 ADC $1860 (add to current GP, low two bytes)
C0/4C55: 8D6018 STA $1860 (and save)
C0/4C58: 7B TDC
C0/4C59: E220 SEP #$20 (8 bit accum./memory)
C0/4C5B: 6D6218 ADC $1862 (wrap high byte if needed)
C0/4C5E: 8D6218 STA $1862 (and save)
C0/4C61: C998 CMP #$98 (is high byte greater than 152? this check is not perfect... LDX $1861 CPX #$9896 may give more precision)
C0/4C63: 9013 BCC $4C78 (branch if not, GP not maxed out)
C0/4C65: AE6018 LDX $1860
C0/4C68: E07F96 CPX #$967F
C0/4C6B: 900B BCC $4C78
C0/4C6D: A27F96 LDX #$967F
C0/4C70: 8E6018 STX $1860
C0/4C73: A998 LDA #$98
C0/4C75: 8D6218 STA $1862 (set max GP as 9999999)
C0/4C78: 20E502 JSR $02E5 (get number grabbed ready for display purposes)
C0/4C7B: A21000 LDX #$0010 (set CA/0010, event for "Found x GP!")
C0/4C7E: 802C BRA $4CAC
C0/4C80: A51F LDA $1F (would've been better to BIT all of these checks, so A would be intact throughout)
C0/4C82: 2940 AND #$40 (is it a item-containing chest?)
C0/4C84: F00D BEQ $4C93 (branch if not)
C0/4C86: A51A LDA $1A
C0/4C88: 8D8305 STA $0583 (item index)
C0/4C8B: 20FCAC JSR $ACFC
C0/4C8E: A20800 LDX #$0008 (set CA/0008, event for "Received x!")
C0/4C91: 8019 BRA $4CAC
C0/4C93: A51F LDA $1F
C0/4C95: 2920 AND #$20 (is it a monster-in-a-box?)
C0/4C97: F00A BEQ $4CA3 (branch if not)
C0/4C99: A51A LDA $1A (load the "contents" byte)
C0/4C9B: 8D8907 STA $0789 (store that to $0789; now this is the stored monster set to use with gen. act. 0x8E)
C0/4C9E: A24000 LDX #$0040 (set CA/0040, event for "Monster-in-a-box!")
C0/4CA1: 8009 BRA $4CAC
C0/4CA3: A51F LDA $1F
C0/4CA5: 2910 AND #$10 (is it something else???)
C0/4CA7: F000 BEQ $4CA9 (why check... this is a totally pointless line probably inserted in case they wanted to branch elsewhere to code for some other type of chest)
C0/4CA9: A21400 LDX #$0014 (set CA/0014, event for "Empty!")
C0/4CAC: 86E5 STX $E5 (many things branch here, so this actually sets a few events)
C0/4CAE: 8EF405 STX $05F4
C0/4CB1: A9CA LDA #$CA
C0/4CB3: 85E7 STA $E7
C0/4CB5: 8DF605 STA $05F6
C0/4CB8: A20000 LDX #$0000 (LDX $00...)
C0/4CBB: 8E9405 STX $0594
C0/4CBE: A9CA LDA #$CA
C0/4CC0: 8D9605 STA $0596
C0/4CC3: A901 LDA #$01
C0/4CC5: 8DC705 STA $05C7
C0/4CC8: A20300 LDX #$0003
C0/4CCB: 86E8 STX $E8
C0/4CCD: AC0308 LDY $0803
C0/4CD0: B97C08 LDA $087C,Y
C0/4CD3: 997D08 STA $087D,Y
C0/4CD6: A904 LDA #$04
C0/4CD8: 997C08 STA $087C,Y
C0/4CDB: 20ED2F JSR $2FED
C0/4CDE: A62A LDX $2A
C0/4CE0: BF00007F LDA $7F0000,X
C0/4CE4: C913 CMP #$13
C0/4CE6: D01E BNE $4D06
C0/4CE8: 868F STX $8F
C0/4CEA: A20C4D LDX #$4D0C
C0/4CED: 868C STX $8C
C0/4CEF: A9C0 LDA #$C0
C0/4CF1: 858E STA $8E (C0/4D0C?)
C0/4CF3: A20000 LDX #$0000 (LDX $00...)
C0/4CF6: 862A STX $2A
C0/4CF8: A904 LDA #$04
C0/4CFA: 8D5A05 STA $055A
C0/4CFD: 20C41E JSR $1EC4
C0/4D00: A9A6 LDA #$A6
C0/4D02: 20D302 JSR $02D3 (JMP fool!)
C0/4D05: 60 RTS
This function check if the treasure chest contain GP, an item or a monster and will call the appropriate event (respectively CA/0010, CA/0008, CA/0040 or even CA/0014, the event for an empty chest).
Those event will then display the dialog box with the item or the amount of GP as a parameter if it's the case.
If we take the example of subroutine CA/0008, the only place I found in the entire game that it is called is in the portion of code I posted and therefore is only used for treasure chests. There is no example in the event dump where CA/0008 is called. I beleive there is no way to give the item name as a parameter in events.
Every item given through events will need a custom dialog box, where you write "Receive 'item name'!" and you need to manually add the item to the inventory using command 80.
The situation is probably the same for the amount of GP to display and for the dialog box that display "Learned []!", where is a spell, it may be only used at the end of a battle, not through events.
« Next Oldest | Next Newest »
Users browsing this thread: 1 Guest(s)