leepivonka wrote:
Are you sure about your disassembler? $40 is RTI, a 1 byte opcode valid on all 6502 versions.
Ugh, damned dyslexia.
I'm not sure which exact line I pulled that from, but looking over my source code listing again it's virtually certain I transposed a nibble in my post. I believe the correct op code and operand are
nop $00 ($04 $00).
That said, no, I'm not 100% sure of my disassembler. I'm using
radare2 for my project. I was doing this all by hand one byte at a time, but after 1000 bytes I got sick of doing this by hand and switched to
radare2 like so:
Code:
rasm2 -a 6502 -D -B -o 0x8000 -f no_header_game.img > game.asm
Then I used a bunch of
vim macros to juggle text columns around and ensure things are formatted the way
64tass expects. I'm doing a manual pass right now to ensure everything lines up nicely and (hopefully!) assembles as expected when I'm done cleaning it up.
leepivonka wrote:
Are you trying to disassemble data? The game cartridge ROM can contain other data interleaved with 6502 opcode sequences.
That was a problem at first, even when I was doing this 100% by hand. Eventually, everything was just such nonsense that I knew I had screwed up somewhere along the line. After more than a few frustrated curses, I figured out that the first 89 bytes were the cartridge header and accompanying "chip packets." So, I used
dd to strip off the cartridge header roughly as follows:
Code:
dd if=game.cart of=no_header_game.img bs=1 skip=89
When I do that, the first byte corresponds to the
sei instruction as I expect.
Yes, stock C64's have NMOS 6502's. Those outfit with older CPU accelerators may have a CMOS variant. These days, accelerators like the Turbo Chameleon are fancy FPGA's that implement the "undocumented" op codes of the original NMOS variant.
It's my expectation that, now that I'm passed the header, I'm not going to run into any more data bytes that could be mistaken for code. Is that likely, or am I mistaken?
Assuming I'm wrong or to help me when I "graduate" to a disk-based game, what are some efficient ways to tell that I've hit data instead of instructions? Obviously, instructions that make zero sense is one way. But, I'm sure there are others.