A83: Interrupt Help.


[Prev][Next][Index][Thread]

A83: Interrupt Help.




What am I doing wrong?  The calculator (well, the emulator...) does a lot
of funky-assed shit, but not what I want it to do =Þ...

Could someone help?  Thanks.

James.

---------------------------------------------
.NOLIST
#define equ .equ
#define EQU .equ
#define end .end
#include "ti83asm.inc"
#include "tokens.inc"
.LIST

.org 9327h

     im 1                     ; make sure it isn't running in im 2

     ld hl,trig		      ; Display "ZTrigMode!"
     call _puts
     call _newline
     ld hl,Dekker             ; display "By Dekker"
     call _puts               ;
     call _newline            ;

     ld a,(state)             ; check if it is running
     or a                     ;
     jr nz,disable_interrupt  ;

enable_interrupt:		; Enable the interrupts.

     ld hl,On                 ; dipslay "On."
     call _puts               ;
     call _newline            ;

     ld a,1                   ; set state to enabled
     call store_state         ;

     ld hl,$8300              ; set up interrupt vector
     ld de,$8301              ;
     ld (hl),$84              ;
     ld bc,$0100              ;
     ldir                     ;

     ld hl,interrupt_start    ; copy interrupt
     ld de,$8484              ;
     ld bc,interrupt_end-interrupt_start+1  ;
     ldir                     ;

     ld a,$83                 ; point i to interrupt vector
     ld i,a                   ;
     im 2                     ;
     ret                      ;


disable_interrupt:		; Disable them.

     ld hl,Off                ; display "Off."
     call _puts               ;
     call _newline            ;

     xor a                    ; set state to disabled
     ld (state),a             ;

store_state:

     push af                  ; write back state
     call _zerooop1           ;
     ld de,op1                ;
     ld hl,prog               ;
     ld bc,7                  ;
     ldir                     ;
     call _chkfindsym         ;
     inc de                   ;
     inc de                   ;
     ld hl,state-$9327        ;
     add hl,de                ;
     pop af                   ;
     ld (hl),a                ;
     ret                      ;

interrupt_start:

     di
     ex af,af'
     exx

     ld a,($800A)             ; turn off calc if apd
     cp $11                   ;
     jr c,interrupt_off       ;

     ld      hl,0050h
     ld      (pencol),hl
     bit     trigdeg,(iy+trigflags)
     jr      z,radians
     ld      hl,degreestext
     call    _vputs
     jr      exit_interrupt

radians:
     ld	     hl,radianstext
     call    _vputs

exit_interrupt:

     exx                      ;
     ex af,af'                ;
     jp $0038                 ; normal interrupt handler

interrupt_off:

     ld a,$74                 ; reset apd counter
     ld ($800A),a             ;

     ld a,$08                 ; turn off lcd
     out (3),a                ;
     ld a,$01                 ; mask on key interrupts
     out (3),a                ;
     pop hl                   ; return to when the int occured
     exx                      ;
     ex af,af'                ;
     ei                       ; enable interrupts
     halt                     ; wait for an interrupt
     jp $0038                 ;

interrupt_end:

trig:		.db "ZTrigMode!",0
Dekker:		.db "by Dekker.",0
On:		.db "Status: On.",0
Off:		.db "Status: Off.",0
degreestext:	.db "Degrees",0
radianstext:	.db "Radians",0
prog:           .db 05h,"ZTRIG",0         ; program name for write back
state:          .db $00                  ; interrupt state

.end
END
------------------------