I am working on some code for a VIC-20 project that starts up as a cartridge in BLK-5.
Simple code has been working fine as expected, but as things become more complex with more zero page and stack usage, I am getting unexpected results, AKA crashes.
I think the reason is my lack of understanding of what happens when the VIC powers on, and what still might be happening even when I take full control.
Here is what I understand from what I have read so far...
VIC boots, then looks for the A0CBM sequence at location 40964 and if found, starts code at the reset vector address found at location 40960.
This seems to work fine, and I have been using this bit of code...
Code: Select all
; START ADDRESS = 40969 @ 40960 TO 40961
.ORG 40960
.BYTE 9,160
; RESET ADDRESS = 40969 @ 40962 TO 40963
.ORG 40962
.BYTE 9,160
; BOOT CODE = A0CBM @ 40964 TO 40968
.ORG 40964
.BYTE 65,48,195,194,205
; PROGRAM START @ 40969 TO 49151
.ORG 40969
At one point, VIC actually came back to the console and reported "Illegal Quantity Error".
How the heck is that even possible? Basic can't possibly be running if I am in charge.
In further experimentation, I tried this after a few routines... "JMP 64802", expecting to see the VIC reset into basic.
Sometimes this worked, and sometimes it failed. Seems to have to do with what I do with zero page.
Obviously I am wrong in my understanding that nothing at all is running on the 6502 if I am am booting and taking total control.
Seems some Kernal fragment must be competing with my use of zero page. is it on some kind of timer interrupt?
Another thing that seems to happen is that if I leave my expanded SRAM as RAM (not ROM), the VIC trashes it on startup, even though my code does take control. Seems the Kernal gets in there first and does a bunch of writes and reads to see what kind of expansion memory is connected. This isn't going to work all the well considering I am stuffing said SRAM with code that needs to run!
I have about 50 VIC-20 manuals downloaded, and most are either great books on coding basic or assembly, but none get too far into what really happens under the hood.
Can someone point me to a really in depth write-up on what the VIC does on power up, and when may still be happening even if basic is not started?
I can code 6502 assembly like a second language, but there seems to be some other forces acting against me here!
Thanks,
Brad