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
25 ; Enable interrupts, as old ProDOS versions (i.e. 1.1.1)
26 ; jump to SYS and BIN programs with interrupts disabled.
30 ; Print error message and exit
38 errmsg: .ifdef __APPLE2ENH__
39 .byte $8D, 't'|$80, 'p'|$80, 'u'|$80, 'r'|$80, 'r'|$80
40 .byte 'e'|$80, 't'|$80, 'n'|$80, 'i'|$80, ' '|$80, 'c'|$80
41 .byte 'o'|$80, 'l'|$80, 'l'|$80, 'a'|$80, ' '|$80, 'o'|$80
42 .byte 't'|$80, ' '|$80, 'd'|$80, 'e'|$80, 'l'|$80, 'i'|$80
43 .byte 'a'|$80, 'F'|$80, $8D
45 .byte $8D, 'T'|$80, 'P'|$80, 'U'|$80, 'R'|$80, 'R'|$80
46 .byte 'E'|$80, 'T'|$80, 'N'|$80, 'I'|$80, ' '|$80, 'C'|$80
47 .byte 'O'|$80, 'L'|$80, 'L'|$80, 'A'|$80, ' '|$80, 'O'|$80
48 .byte 'T'|$80, ' '|$80, 'D'|$80, 'E'|$80, 'L'|$80, 'I'|$80
49 .byte 'A'|$80, 'F'|$80, $8D
57 ; Check for valid interrupt vector table entry number which
58 ; IS necessary as this gets called even if initirq failed.
62 ; Deallocate interrupt vector table entry
63 dec i_param ; Adjust parameter count
64 jsr $BF00 ; MLI call entry point
65 .byte $41 ; Dealloc interrupt
72 ; ProDOS TechRefMan, chapter 6.2:
73 ; "Each installed routine must begin with a CLD instruction."
76 ; Call interruptors and check for success
80 ; ProDOS TechRefMan, chapter 6.2:
81 ; "When the routine that can process the interrupt is called, it
82 ; should ... return (via an RTS) with the carry flag clear."
86 ; ProDOS TechRefMan, chapter 6.2:
87 ; "When a routine that cannot process the interrupt is called,
88 ; it should return (via an RTS) with the cary flag set ..."
94 ; MLI parameter list for (de)alloc interrupt
95 i_param:.byte $02 ; param_count
96 int_num:.byte $00 ; int_num
97 .addr intptr ; int_code