In late 1983, I began learning 6502 assembly-language by hand-assembling 6502 code on an Apple II computer at school. I had also been toying with a Commodore 64.
I had been reading some C64 articles that pertained to inserting interrupt-driven machine-code routines by modifying the vector stored in $0314 / $0315.
My first interrupt-driven C64 code simply incremented the border color with each invocation of the timer interrupt. Although I had originally written the code using Jim Butterfield’s SuperMon 64, I recently rewrote the same code using a label-based assembler:
; Interrupt-driver border changer for the C64 ; ; License: MIT / X11 ; Copyright (c) 2013 by James K. Lawless ; email@example.com ; http://lawlessguy.com ; ; Permission is hereby granted, free of charge, to any person ; obtaining a copy of this software and associated documentation ; files (the "Software"), to deal in the Software without ; restriction, including without limitation the rights to use, ; copy, modify, merge, publish, distribute, sublicense, and/or sell ; copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following ; conditions: ; ; The above copyright notice and this permission notice shall be ; included in all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES ; OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR ; OTHER DEALINGS IN THE SOFTWARE. ; ; To use in C64 BASIC: ; sys 49152 * = $c000 sei lda $0314 sta jumper+1 lda $0315 sta jumper+2 lda #<iroutine sta $0314 lda #>iroutine sta $0315 cli rts iroutine = * inc $d020 lda $d020 and #$0f sta $d020 ; the target address will be dynamically modified by the ; init portion of this code jumper = * jmp $0000 end
You can download the source and .P00 file here:
When I had run the original program, the timing seemed to work nicely with NTSC video. I recall the colors changing in a manner that left scrolling colored stripes in the border where each stripe was about the size of a C64 character in height.
I no longer have a stock C64, so I had tried to tune VICE into generating the same effect, to no avail. Here’s what the code looked like in VICE with my settings: