home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 86 / asm / source / apdint.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  2.8 KB  |  92 lines

  1. #include "asm86.h"
  2. #include "ram86.inc"
  3. #include "ti86asm.inc"
  4.  
  5. _user_int_ram EQU $d2fd                      ;Area where interrupt handler goes
  6.  
  7. .org _asm_exec_ram                                               ;Instruction Counter starts at $D748
  8.         
  9.   bit 2,(iy+$23)
  10.   jp z,Install
  11.   res 2,(iy+$23)
  12.   ld hl,$0000
  13.   ld (_curRow),hl
  14.   ld hl,UnInstMsg
  15.   jp DoneMain
  16.                                              
  17. Install:   
  18.         ld hl,int_copy                       ;copy prog to user int buffer
  19.         ld de,_user_int_ram+1                            ;1 byte ahead of checksum
  20.         ld bc,int_end-int_start              ;length of interrupt handler
  21.         ldir                                 ;hl is the source, de is the destination,
  22.                                              ;and bc is the length
  23.    
  24.         ld a,(_user_int_ram+1)               ;set up checksum byte
  25.         ld hl,_user_int_ram+($28*1)          ;load byte
  26.         add a,(hl)                           ;add to total
  27.         ld hl,_user_int_ram+($28*2)          ;load byte
  28.         add a,(hl)                           ;add to total
  29.         ld hl,_user_int_ram+($28*3)          ;load byte
  30.         add a,(hl)                           ;add to total
  31.         ld hl,_user_int_ram+($28*4)          ;load byte
  32.         add a,(hl)                           ;add to total
  33.         ld hl,_user_int_ram+($28*5)          ;load byte
  34.         add a,(hl)                           ;add to total
  35.         ld (_user_int_ram),a                 ;load checksum in its location
  36.  
  37.         set 2,(iy+$23)                       ;turn it on
  38.   ld hl,$0000
  39.   ld (_curRow),hl
  40.   ld hl,InstMsg
  41. DoneMain:  
  42.   call _puts
  43.   call _getkey                             
  44.         ret
  45.  
  46. InstMsg:
  47.   .db "Installed",0
  48. UnInstMsg:
  49.   .db "Uninstalled",0
  50.  
  51. int_copy:
  52.         
  53.         .org $D2FE                      ; Intruction Counter starts at $D2FE
  54. int_start:
  55.   jr RealStart
  56.   .db $00           ;Have we set bit 3 at $C3ED?
  57. RealStart:
  58.   push af            ;Save regs for rest of interrupt
  59.   push bc
  60.   push hl
  61.   xor a             ;Check if we set bit 3 of $C3ED
  62.   ld hl,(int_start+2)
  63.   cp (hl)
  64.   jr z,Cont
  65.   res 3,(iy+$08)    ;If so, reset it...
  66.   ld (hl),a         ;...and the marker.
  67. Cont:
  68.   ld a,%01101111    ;Check row 4
  69.   out (1),a      
  70.   nop
  71.   nop
  72.   in a,(1)
  73.   cp $FF            ;Exit if no key pressed
  74.   jr z,Done
  75.   bit 4,a           ;Check if EE pressed
  76.   jr nz,Done
  77.   bit 3,a           ;Check if 7 pressed
  78.   jr nz,Done
  79.   ld a,1            ;Set APD timer 
  80.   ld ($C00A),a
  81.   ld (int_start+2),a  ;Mark that we set 3, iy+$08
  82.   set 2,(iy+$08)    ;Should be already set, but it doesn't hurt to make sure
  83.   set 3,(iy+$08)    ;Must be set to trigger APD
  84. Done: 
  85.   pop hl            ;Restore regs
  86.   pop bc
  87.   pop af
  88.   ret               
  89. int_end:
  90.  
  91. .end
  92.