Decompilation/commenting of C1/7615 - C1/7641 Related to CC [1e 0c XX YY]: Increase character XX's speed by YY Copied out of ebasm.txt. Commented by AnyoneEB. Last Updated: 2004-07-13 20:12 See also: http://pkhack.fobby.net/misc/txt/C08FF7.txt See also: Note that this code is not separated from the code around it in any way except that it logically works as a single line of C code and a complete use of JSR $C08FF7. C1/7615: AD BA 97 LDA $97BA ;load A from $97BA (addressing?) \ C1/7618: 29 FF 00 AND #$00FF ;leave only lowest order byte of A / load one byte from $97BA into A C1/761B: AA TAX ;put that byte into X (CC arg XX?) C1/761C: 3A DEC ;decrement A //A = (byte) *($97BA) - 1 C1/761D: A0 5F 00 LDY #$005F ;Y = 0x5f \ C1/7620: 22 F7 8F C0 JSR $C08FF7 ;MUL A, Y / MUL A, 0x5F //A = ((byte) *($97BA) - 1) * 0x5F C1/7624: 18 CLC ;clear carry C1/7625: 69 25 9A ADC #$9A25 ;add 0x9A25 to A (what's there?) //A = (((byte) *($97BA) - 1) * 0x5F) + 0x9A25 C1/7628: A8 TAY ;put A into Y //Y = (((byte) *($97BA) - 1) * 0x5F) + 0x9A25 C1/7629: A5 0E LDA $0E ;read in YY arg \ A = *($0E) C1/762B: E2 20 SEP #$20 ;put A into 8-bit mode / A = (byte) *($0E) C1/762D: 85 00 STA $00 ;store A in $00 \ C1/762F: B9 00 00 LDA $0000,Y ;load A from $0000 + Y (remember that Y = old A value) \ Using $00 as temp storage C1/7632: 18 CLC ;clear carry > *($0000 + Y) += A C1/7633: 65 00 ADC $00 ;add $00 to A (remember we just put it there before loading / OR C1/7635: 99 00 00 STA $0000,Y ;write into $0000 + Y (where we just read from) / *($0000 + (((byte) *($97BA) - 1) * 0x5F) + 0x9A25) += (byte) *(0x0E) C1/7638: C2 20 REP #$20 ;take A out of 8-bit mode C1/763A: 8A TXA ;put CC arg XX into A //A = XX for [1E 0C 01 01] *($0000 + (((byte) *($97BA) - 1) * 0x5F) + 0x9A25) += (byte) *(0x0E) *($0000 + (( byte(D501) - 1) * 0x5F) + 0x9A25) += (byte) *(0x0E) *($0000 + (( 01 - 1) * 0x5F) + 0x9A25) += (byte) *(0x0E) *($0000 + ( 00 * 0x5F) + 0x9A25) += (byte) *(0x0E) *($0000 + ( 00 ) + 0x9A25) += (byte) *(0x0E) *($7E:9A25) += (byte) *($00:1EA5) *($7E:9A25) += 0x01 *($7E:9A25) = 0x01 + 0x00 *($7E:9A25) = 0x01 Generally: *($0000 + (( (CC arg XX) - 1 ) * 0x5F) + 0x9A25) += (byte) (CC arg YY) 0x 5F = entry length of character info in wram 0x9A25 = unknown byte near end of table of character info in wram Adding... WHY? Value is 0 in all tests so far... maybe it's affected by something set to 00. Not testing that now. $C2/1AEB C2 31 REP #$31 ;reset bits for no appearent reason $C2/1AED 0B PHD ;push D $C2/1AEE 48 PHA ;push A \ $C2/1AEF 7B TDC ;move D to A \ $C2/1AF0 69 EB FF ADC #$FFEB ;subtract 0x15 from A > D -= 0x15 //IMPORTANT: STA $XX is based on D $C2/1AF3 5B TCD ;move A to D / $C2/1AF4 68 PLA ;pop A / $C2/1AF5 AA TAX ;move A to X (huh? wasn't it loaded from X a little while back?) $C2/1AF6 3A DEC A ;decrement A (sounds familar...) //entry number $C2/1AF7 85 02 STA $02 [$00:1E84] ;write A to $02 (remember -0x15) $C2/1AF9 85 13 STA $13 [$00:1E95] ;write A to $13 (remember -0x15) $C2/1AFB A5 02 LDA $02 [$00:1E84] ;WTF, read A back from $02 ?! Why?! in case of EM interference?! $C2/1AFD A0 5F 00 LDY #$005F ;Y = 0x5F \\same as above entry size of something $C2/1B00 22 F7 8F C0 JSL $C08FF7[$C0:8FF7] ;MUL A, Y //MUL A, 0x5f Database register pushed and moved down 0x15. All temporary memory used for the rest of this CC is in that 0x15 byte area. XX - 1 is written to $02 and $13. A = (XX - 1) * 0x5F; $C2/1B04 AA TAX ;move A into X //offset of entry $C2/1B05 BD EC 99 LDA $99EC,x[$7E:99EC] ;A = *($99EC + X) //load speed stat of selected char (Ness' in this case) $C2/1B08 29 FF 00 AND #$00FF ;A = (byte) *($99EC + X) $C2/1B0B A8 TAY ;Y = A = (byte) *($99EC + X) $C2/1B0C 84 11 STY $11 [$00:1E93] ;*($11) = Y = A = (byte) *($99EC + X) $C2/1B0E BD 00 9A LDA $9A00,x[$7E:9A00] ;A = *($9A00 + X) //load ? equipment of selected char $C2/1B11 29 FF 00 AND #$00FF ;A = (byte) *($9A00 + X) $C2/1B14 F0 3B BEQ $3B [$1B51] ;if zero, jump ahead by $3B... what is this skipping and why? $C2/1B51 A5 13 LDA $13 [$00:1E95] ;load A back from $13 (offset) $C2/1B53 85 02 STA $02 [$00:1E84] ;rewrite A into $02, maybe that BEQ affects it? $C2/1B55 A0 5F 00 LDY #$005F ;Y = 0x5F \\ $C2/1B58 22 F7 8F C0 JSL $C08FF7[$C0:8FF7] ;MUL A, Y // MUL A, 0x5f //why doesn't it save this value or something? X = (XX - 1) * 0x5F; $11 = speed byte of the stats before item effects of the specified character A = the weapon of the char indicated by the XX and YY args TODO: BEQ unknown A = (XX - 1) * 0x5F; $C2/1B5C AA TAX ;move A into X //offset of entry $C2/1B5D BD 25 9A LDA $9A25,x[$7E:9A25] ;load place YY arg was added to into A //remember it was always 0 in testing $C2/1B60 29 FF 00 AND #$00FF ;A --> byte $C2/1B63 85 04 STA $04 [$00:1E86] ;store A into $04 $C2/1B65 A4 11 LDY $11 [$00:1E93] ;reload Y from $11 ( (byte) *($99EC + X) ) //Y = selected stat of selected char $C2/1B67 98 TYA ;set A to Y, see above line $C2/1B68 18 CLC ;clear carry $C2/1B69 65 04 ADC $04 [$00:1E86] ;A += *($04) //Add current value of stat with possibly non-zero value plus YY arg? $C2/1B6B 85 0F STA $0F [$00:1E91] ;store A into $0F $C2/1B6D 85 04 STA $04 [$00:1E86] ;store A into $04 $C2/1B6F A9 00 00 LDA #$0000 ;set A to 0x0000 $C2/1B72 18 CLC ;clear carry $C2/1B73 E5 04 SBC $04 [$00:1E86] ;subtract *($04) from A; A = -(*($04)) $C2/1B75 50 04 BVC $04 [$1B7B] ;TODO Branch on overflow (result non-negitive) $C2/1B7B 30 05 BMI $05 [$1B82] ;TODO Branch on negitive $C2/1B82 A5 0F LDA $0F [$00:1E91] ;load A from $0F, see above (stat value + YY)? $C2/1B84 C2 20 REP #$20 ;puts A into 16-bit mode, which is already is in (maybe the branch could change that?) $C2/1B86 29 FF 00 AND #$00FF ;A --> byte //didn't we do this before saving it? $C2/1B89 AA TAX ;X = A $C2/1B8A 8A TXA ;A = X (why?!) $C2/1B8B E2 20 SEP #$20 ;Put A into 8-bit mode $C2/1B8D 85 0E STA $0E [$00:1E90] ;Store A at $0E //making sure $0F isn't modifed $C2/1B8F C2 20 REP #$20 ;restore A to 16-bit mode $C2/1B91 A5 02 LDA $02 [$00:1E84] ;load A from $02 $C2/1AFD A0 5F 00 LDY #$005F ;Y = 0x5F \\same as above entry size of something $C2/1B00 22 F7 8F C0 JSL $C08FF7[$C0:8FF7] ;MUL A, Y //MUL A, 0x5f X = (XX - 1) * 0x5F; $0F = $04 = YY + speed A = -$04 TODO: _TWO_ unknown branches $0E = $0F A = (XX - 1) * 0x5F; $C2/1B9A AA TAX ;move A into X //offset of entry $C2/1B9B E2 20 SEP #$20 ;Put A into 8-bit mode $C2/1B9D A5 0E LDA $0E [$00:1E90] ;Read only one byte from $0E $C2/1B9F 9D E5 99 STA $99E5,x[$7E:99E5] ;Write to stats after item effects $C2/1BA2 2B PLD ;Pop D (remember we subtracted 0x15 before) $C2/1BA3 6B RTL ;Return X = (XX - 1) * 0x5F; Set stats after item effects to YY + speed Pop database register $C1/763F C2 20 REP #$20 ;put A back into 16-bit mode $C1/7641 A9 00 00 LDA #$0000 ;set A to zero Reset A *** NMI *** NMI *** NMI *** NMI End of block.