presentations icon indicating copy to clipboard operation
presentations copied to clipboard

irq functions

Open frocentus opened this issue 5 years ago • 0 comments

Hi Jason,

thanks for this awesome presentation :)

I was wondering, if it is possible to write interrupt-functions in c++. The C64 has some Interrupts, the normal at Adress 0x314 and 0x315 which locates the address of the interrupt routine.

Is it possible to write an function in c++ and to write the 16bit address of this function into the interrupt-vector?

I failed miserably by trying to create a struct :) with a correct function:

struct Interrupts {
  static constexpr uint16_t INTERRUPT = 0x0314;
  volatile void setirq(uint16_t *irq_function) {
    *reinterpret_cast<uint16_t*>(INTERRUPT) = *irq_function;
  }
};

void raster_irq() {
    VIC_II vic;
    vic.border() = 4;
}

int main() {

  Interrupts irqs;
  uint16_t *raster_irq_function = (uint16_t*) &raster_irq;

  irqs.setirq(raster_irq_function);
}

would be nice if there is a soultion or you can give me a hint in the right direction!

frocentus avatar Sep 16 '19 20:09 frocentus