Nope, I haven't given up on my game; I have been busy working on other programs and playing games, though. Took a look into the boss AI in CV1, which seems much simpler than that in CV3, although I haven't mapped out the RAM, so it's a bit more tedious for me to read. (Yes, I'm sad to say that I can look through code in CV3 and often just mentally replace RAM addresses with variable names; it's kinda like reading Japanese.)
Anyway, I tried to get a better understanding of how the division operations used by Konami worked in 6502 ASM. The bat boss uses it, so I've been able to break it down, I think.
07:CA4B:A9 00 LDA #$00
07:CA4D:A2 11 LDX #$11
07:CA4F:18 CLC
07:CA50:26 02 ROL $0002 = #$00
07:CA52:26 01 ROL $0001 = #$00
07:CA54:26 00 ROL $0000 = #$57
07:CA56:CA DEX
07:CA57:F0 09 BEQ $CA62
07:CA59:2A ROL
07:CA5A:C5 03 CMP $0003 = #$5A
07:CA5C:90 F2 BCC $CA50
07:CA5E:E5 03 SBC $0003 = #$5A
07:CA60:B0 EE BCS $CA50
07:CA62:60 RTS
Above is the division code used in CV1 for the bat boss. This is one method used for division.
Register X is the max number of bits to consider. In this case, address $0000 is the numerator and $0003 is the denominator. Address $0001 is the integral dividend, while $0002 is the fraction (in this example, $57/$5A yields a decimal, which if you multiply by $FF will result in a value of $F7 for address $0002 once the script has run its course).
No comments:
Post a Comment