2 ; Oliver Schmidt, 2012-11-17
4 ; IRQ handling (Apple2 version)
7 .export initirq, doneirq
8 .import callirq, __dos_type, _exit
19 ; Allocate interrupt vector table entry
20 jsr $BF00 ; MLI call entry point
21 .byte $40 ; Alloc interrupt
26 ; Print error message and exit
34 errmsg: .ifdef __APPLE2ENH__
35 .byte $8D, 't'|$80, 'p'|$80, 'u'|$80, 'r'|$80, 'r'|$80
36 .byte 'e'|$80, 't'|$80, 'n'|$80, 'i'|$80, ' '|$80, 'c'|$80
37 .byte 'o'|$80, 'l'|$80, 'l'|$80, 'a'|$80, ' '|$80, 'o'|$80
38 .byte 't'|$80, ' '|$80, 'd'|$80, 'e'|$80, 'l'|$80, 'i'|$80
39 .byte 'a'|$80, 'F'|$80, $8D
41 .byte $8D, 'T'|$80, 'P'|$80, 'U'|$80, 'R'|$80, 'R'|$80
42 .byte 'E'|$80, 'T'|$80, 'N'|$80, 'I'|$80, ' '|$80, 'C'|$80
43 .byte 'O'|$80, 'L'|$80, 'L'|$80, 'A'|$80, ' '|$80, 'O'|$80
44 .byte 'T'|$80, ' '|$80, 'D'|$80, 'E'|$80, 'L'|$80, 'I'|$80
45 .byte 'A'|$80, 'F'|$80, $8D
53 ; Check for valid interrupt vector table entry number which
54 ; IS necessary as this gets called even if initirq failed.
58 ; Deallocate interrupt vector table entry
59 dec i_param ; Adjust parameter count
60 jsr $BF00 ; MLI call entry point
61 .byte $41 ; Dealloc interrupt
68 ; ProDOS TechRefMan, chapter 6.2:
69 ; "Each installed routine must begin with a CLD instruction."
72 ; Call interruptors and check for success
76 ; ProDOS TechRefMan, chapter 6.2:
77 ; "When the routine that can process the interrupt is called, it
78 ; should ... return (via an RTS) with the carry flag clear."
82 ; ProDOS TechRefMan, chapter 6.2:
83 ; "When a routine that cannot process the interrupt is called,
84 ; it should return (via an RTS) with the cary flag set ..."
90 ; MLI parameter list for (de)alloc interrupt
91 i_param:.byte $02 ; param_count
92 int_num:.byte $00 ; int_num
93 .addr intptr ; int_code