Thanks for getting it to build, lazycow. My cat also likes this demo, haha.
I did notice another thing in lnAddSpr that could be optimized, maybe a little controversial though. The INX INX INX INX sequence could be replaced with TXA / AXS #$FC unofficial opcode (it trashes A, but the loop trashes it already). That will be 4 cycles faster per iteration. I never paid much attention to the unofficial NMOS 6502 ops, but AXS immediate ($CB) seems to be one of the most useful ones. It's sure to break something somewhere though (the Project Nested emulator comes to mind, dunno what else).
I was doing a funny experiment with vbcc last night, and ran into a bug or something I don't understand. I'm compiling a 6502 emulator (fake6502). It's set up so every emulated memory read simply returns $EA to make it NOP forever.
It barely fits into memory, rodata overflows unless I combine -size with -O2 (or higher). (see edit below) It compiles, but doesn't assemble because some labels are missing.
vc +nrom256v -c99 -+ -O3 -size cpu.c fake6502.c -o cpu.nes
Code: Select all
\Users\membl\AppData\Local\Temp\vbcc068c.o: In "_callexternal":
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0xf): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x13): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x2f): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x33): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x4f): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x53): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x6f): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x73): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x8f): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x93): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0xaf): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0xb3): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0xcf): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0xd3): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0xef): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0xf3): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x10f): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x113): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x12f): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x133): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x139): Reference to undefined symbol l38.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x13b): Reference to undefined symbol l38.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x14f): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x153): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x16f): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x173): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x179): Reference to undefined symbol l38.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x17b): Reference to undefined symbol l38.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x18f): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x193): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x1af): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x1b3): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x1cf): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x1d3): Reference to undefined symbol l62.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x1ef): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x1f3): Reference to undefined symbol l65.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x35d): Reference to undefined symbol l459.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x38d): Reference to undefined symbol l230.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x395): Reference to undefined symbol l230.
Error 21: \Users\membl\AppData\Local\Temp\vbcc068c.o (data+0x3a5): Reference to undefined symbol l230.
vlink -b rawbin1 -Cvbcc -T%VBCC%/targets/6502-nes/nrom256v.cmd -L%VBCC%/targets/6502-nes/lib %VBCC%/targets/6502-nes/lib/startup.o "C:\Users\membl\AppData\Local\Temp\vbcc068c.o" -o cpu.nes -lvc failed
If I build with -O2, there is a longer list of undefined symbols. -O3 and -O4 appears to be the same.
If I build with -S and look at the source, I can indeed see the references to the labels that look like this, but no label anywhere (in this copy/paste l230 is missing, surrounded by references to labels that do exist).
Code: Select all
word l230
word l206
word l350
word l507
word l230
word l206
word l242
word l507
word l296
word l206
word l251
word l350
word l230
edit:
I was mistaken, the version I posted does compile if I exclude the -size option. The above error only happens with -size. The resulting program crashes (invalid op in Mesen) when run though. Removed calls to reset6502() step6502(), and it's still a black screen (but no invalid op, at least). Removing fake6502.c from the build lets it work again (as in, the blue blackground is there and printf works).