1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6 DSFORTH_OLD_IM2_ORG = 0
10 IF (high($) < 0x80) || (high($) >= 0xc0)
12 $WARNING "im2 interrupt handler must start in [#8000..#BFFF], but it is at #%04X; relocated", $
13 DSFORTH_OLD_IM2_ORG = $
16 $ERROR "im2 interrupt handler must start in [#8000..#BFFF], but it is at #%04X", $
21 IntrHandlerAddress equ #FFF5
22 IF USE_P3DOS || USE_SAFE_IM2_STACK
25 intr_restore_sp defb 1
29 ;; switch to temporary stack here
30 IF USE_P3DOS || USE_SAFE_IM2_STACK
35 ; do not switch stack if it is already somewhere in TSTACK
36 ld a,(intr_saved_sp+1)
37 ld (intr_restore_sp),a
43 ld (intr_restore_sp),a
49 ; save current LAST_K and clear it
53 ld (intr_saved_lastk),a
59 intr_mc_routine_addr equ $-2
69 ; check if a key was pressed
73 ; if a key was pressed, store it into `f_waskeypress` too
78 ld a,(intr_saved_lastk)
100 IF USE_P3DOS || USE_SAFE_IM2_STACK
103 ld a,(intr_restore_sp)
105 jr nz,.safeim2_skip_sp_restore
106 ; save current SP now, because we'll need it later
107 ld (intr_saved_sp),sp
108 .safeim2_skip_sp_restore:
111 ld sp,(intr_saved_sp)
121 IF (high(IntrHandlerEnd-1) >= 0xc0
122 $ERROR "im2 interrupt handler must end in #8000..#BFFF], but it is at #%04X", IntrHandlerEnd-1
125 IF DSFORTH_OLD_IM2_ORG > 0
126 org DSFORTH_OLD_IM2_ORG