// This code is meant to keep the C64 running while the program it is part of banks // out the BASIC or Kernal ROM to have RAM available. If an IRQ or NMI occurs during // that time and a ROM routine is called that isn't there, the C64 will crash. // This code replaces the IRQ and NMI handling code to bank the BASIC and Kernal ROMs // back in, call the original handling routines, and then restore the situation as it // was when the interrupt happened. #include "memmap.h" __asm DoneTrampoline { stx $01 // The ROM code at jmp ($fffa) has saved our X value // so we can restore it to $01. Our banks our back to whatever it was pla // now we pull X and A and restore them tax pla rti // RTI can now pull the original status byte and return address and // return to the original code. } __asm IRQTrampoline { pha txa pha lda #>DoneTrampoline pha lda #DoneTrampoline // $01fa save the high byte of DoneTrampoline() pha lda #