diff options
Diffstat (limited to 'src/devices/cpu/m6502/xavix2000.cpp')
-rw-r--r-- | src/devices/cpu/m6502/xavix2000.cpp | 93 |
1 files changed, 54 insertions, 39 deletions
diff --git a/src/devices/cpu/m6502/xavix2000.cpp b/src/devices/cpu/m6502/xavix2000.cpp index 34f41a483b6..17c20b3376d 100644 --- a/src/devices/cpu/m6502/xavix2000.cpp +++ b/src/devices/cpu/m6502/xavix2000.cpp @@ -25,50 +25,65 @@ some of the documented but 'undocumented' opcodes on the 6502 to have additonal meaning for one specific function on startup - 01BC37: A0 3F ldy #$3f - 01BC39: B2 ?? - 01BC3A: 1B ?? - 9B ?? - -- outer loop - 01BC3C: 98 tya - 01BC3D: 5B (has to be 1 byte?) - -- inner loop - 01BC3E: A3 (has to be 1 byte) - 73 (could be 3 byte?) - 01BC40: 83 FB presumably fb is the address - 01BC42: A7 (presumably 1 byte) - 73 (could be 3 byte?) - 01BC44: 87 FB presumably fb is the address - 01BC46: D0 F6 bne $1bc3e - 01BC48: 88 dey - 01BC49: 10 F1 bpl $1bc3c - 01BC4B: 8D FB 00 sta $00fb - 01BC4E: A3 ?? - 01BC4F: 8D FA 00 sta $00fa - 01BC52: 07 ?? - -- - 01BC53: D0 03 bne $1bc58 - 01BC55: CE fa 00 dec $00fa - 01BC58: 80 retf + this just seems to be some very buggy checksum code where the games don't even care about the result... + (actually it looks like some games might be using it as a PRNG seed?) + + a is 80 when entering here? + + 01BC37: A0 3F ldy #$3f + 01BC39: B2 clrl // clear 32-bit 'long' register (part of it might be the accumulator?) (or clear accumulator?) + 01BC3A: 1B spa0 a // store 'accumulator' into byte 0 of PA 'address' register + 01BC3B: 9B spa2 a // store 'accumulator' into byte 2 of PA 'address' register + + -- loop point 2 + 01BC3C: 98 tya // y -> a (3f on first run of loop) + 01BC3D: 5B spa1 a // store 'accumulator' into byte 1 of PA 'address' register (803f80 on first loop? 003f00 if we clear accumulator with clrl instead) maybe should be 3f0000 ? (would make more sense for a ram test) + + -- loop point 1 + 01BC3E: A3 ldal0 a // read byte 0 of 32-bit 'long' register into accumulator + 01BC3F: 73 adcpa // adc ($Address PA), y + 01BC40: 83 stal0 a // store accumulator back in byte 0 of 32-bit 'long' register (even byte checksum?) + 01BC41: FB incpa // increase 'address' register PA + 01BC42: A7 ldal1 a // read byte 1 of 32-bit 'long' register into accumulator + 01BC43: 73 adcpa // adc ($Address PA), y + 01BC44: 87 stal1 a // store accumulator back in byte 0 of 32-bit 'long' register (odd byte checksum?) + 01BC45: FB incpa // increase 'address' register PA + 01BC46: D0 F6 bne $1bc3e // (branch based on PA increase, so PA must set flags?, probably overflows after 0xffff if upper byte is 'bank'? or at 0xff if this really is a mirror of the function below + + 01BC48: 88 dey // decrease y, which contained 3f at the start + 01BC49: 10 F1 bpl $1bc3c // branch back to loop point 2 to reload counter + + // contains the odd byte checksum once we drop out the loop + 01BC4B: 8D FB 00 sta $00fb // store it in zero page memory + 01BC4E: A3 ldal0 a // get the even byte checksum from byte 0 of 32-bit 'long' register + 01BC4F: 8D FA 00 sta $00fa // store it in zero page memory + 01BC52: 07 oral1 a // why do we want to do this? (routine below does it too) + 01BC53: D0 03 bne $1bc58 + 01BC55: CE FA 00 dec $00fa + 01BC58: 80 retf this is presumably meant to be similar to the function found in Namco Nostalgia 2 + // A is 80 on entry 09FFD8: A9 3F lda #$3f - 09FFDA: 85 01 sta $01 - 09FFDC: A0 00 ldy #$00 - 09FFDE: AD FA 00 lda $00fa - 09FFE1: 71 00 adc ($00), y - 09FFE3: 8D FA 00 sta $00fa - 09FFE6: C8 iny - 09FFE7: AD FB 00 lda $00fb - 09FFEA: 71 00 adc ($00), y - 09FFEC: 8D FB 00 sta $00fb - 09FFEF: C8 iny - 09FFF0: D0 EC bne $c - 09FFF2: C6 01 dec $01 - 09FFF4: 10 E8 bpl $9ffde - 09FFF6: 0D FA 00 ora $00fa + 09FFDA: 85 01 sta $01 // set upper bit of pointer at 0x0000 to 3f (it completely fails to initialize the ram at 00, we currently init it to ff, but should probably be 0?) + 09FFDC: A0 00 ldy #$00 // clear inner loop counter + -- loop point 1 and 2 + 09FFDE: AD FA 00 lda $00fa // read current even byte checksum value from zero page ram fa (game also completely fails to initialize this) + 09FFE1: 71 00 adc ($00), y // so 3f00 + y first outer loop, 3e00 + y second outer loop with y increasing in inner loop (add byte read to even checksum byte?) + 09FFE3: 8D FA 00 sta $00fa // store even checksum at 0xfa in zero page ram + 09FFE6: C8 iny // increase counter y + 09FFE7: AD FB 00 lda $00fb // read current odd byte checksum value from zero page ram fb (likewise never initialized!) + 09FFEA: 71 00 adc ($00), y // 3f00 + y (add byte read to odd checksum byte) + 09FFEC: 8D FB 00 sta $00fb // store odd checksum byte at 0xfb in zero page ram + 09FFEF: C8 iny // increase y + 09FFF0: D0 EC bne $9ffde // branch back if y hasn't overflowed (so work on 0x100 bytes, looping back 0x7f times) + 09FFF2: C6 01 dec $01 // decrease accumulator (started at 3f) (inner loop counter already 0 because it overflowed) + 09FFF4: 10 E8 bpl $9ffde // branch back + + // checksums are already in place after loop so no need to copy them like in above + 09FFF6: 0D FA 00 ora $00fa // same weird 'or' call -- 09FFF9: D0 03 bne $9fffe 09FFFB: CE FA 00 dec $00fa |