Quote from: Zack on 17 Jul 2024, 01:26 PMNote: It's important to call vcsJmp3() a few times throughout the screen because the 6507 can only address 4KB of contiguous ROM space and allowing PC to go past $1fff would transfer control to TIA read registers, eventually crashing the 6507.
Took me a while to understand this, but to clarify for other readers - the kernel is pumping bytes onto the bus which are instructions executed by the 6507 -- various register updates (PF0/GRP0) etc. The kernel does this for 192 scanlines - and the 6507 happily executes these instructions. However, the 6507 program counter is "free running" - it thinks it is retrieving all of these instructions from memory linearly. So it's doing 192 scanlines of code execution without any looping or branching. Let's say (just roughly) 50 bytes per scanline. So with just 4K of address space we would run out of runway within about 80 scanlines at the very best. Depends on where the PC is when we start. It seems to me that setting PC to $1000 at the start of a kernel, then every (say) 32 lines we do a vcsJmp3() to reset it... would be safe enough.
However, the kernel could keep a track of implicit PC address and only do the vcsJmp3() write when it becomes necessary/urgent. If I'm understanding all of this correctly, the current centered kernel uses 36 bytes without the pC rest. If the PC was set to $1000 just before the scanline loop, then that would suggest 113 scanlines would be possible before we're in trouble. That would require just one vcsJmp3() halfway down the screen.