Re: [cc65] C64, Interrupt and in need of an example

From: MagerValp <MagerValp1cling.gu.se>
Date: 2008-03-03 09:14:32
>>>>> "MS" == Markus Stehr <bastetfurry@ircnet.de> writes:

MS> Could someone please provide me with an usable example for an
MS> interrupt for the C64? I have been reading the manual and asked
MS> Google for 2 hours now and i am as clueless as i was 2 hours ago.

In (almost) pure C:


#include <c64.h>
#include <peekpoke.h>


void music_init(void) {
}


void music_play(void) {
}


void my_irq(void) {
  ++VIC.bgcolor0;
  music_play();
  --VIC.bgcolor0;

  /* ack raster IRQ */
  VIC.irr = 1;
  __asm__(" jmp $ea31");
}


void __fastcall__ irq_setup(void (*irqh)(void)) {
  /* disable IRQ sources, SEI not needed */
  CIA1.icr = 0x7f;
  VIC.imr = 0;

  /* irq on line 100 */
  VIC.rasterline = 100;
  VIC.ctrl1 = 0x1b;

  /* set kernal IRQ vector */
  POKEW(0x0314, (int)irqh);

  /* enable raster IRQs */
  VIC.imr = 1;
}


void main(void) {
  music_init();

  irq_setup(&my_irq);

  while (PEEK(0xc6) == 0) {
    ;
  }
}

-- 
    ___          .     .  .         .       . +  .         .      o   
  _|___|_   +   .  +     .     +         .  Per Olofsson, arkadspelare
    o-o    .      .     .   o         +          MagerValp@cling.gu.se
     -       +            +    .     http://www.cling.gu.se/~cl3polof/
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Mar 3 09:14:52 2008

This archive was generated by hypermail 2.1.8 : 2008-03-03 09:14:55 CET