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

  1. #include "asm86.h"
  2. #include "ti86asm.inc"
  3. #include "ti86user.inc"            ;My new include file to make mods easier!
  4. #include "ram86.inc"            ;For cursor update addresses.
  5.  
  6. .org _asm_exec_ram                ;This part is in the regular assembly area
  7.  res userInt,(iy+userflags)        ;Disable old user interrupt, if it exists
  8.  ld hl,CodeStart                ;Point hl at the new interrupt code
  9.  ld de,_user_int_ram            ;Point de to where it goes
  10.  ld bc,IntEnd-IntStart            ;Calculate how long the code is
  11.  ldir                        ;Move bc bytes from hl to de
  12.  ld a,(_user_int_ram)            ;These codes just calculate
  13.  ld hl,_user_int_ram+$27            ; the checksum of the user
  14.  add a,(hl)                    ; interrupt.  The calc checks
  15.  ld hl,_user_int_ram+$4F            ; this so it can avoid damaged
  16.  add a,(hl)                    ; interrupt code.  There's
  17.  ld hl,_user_int_ram+$77            ; probably an easier way to
  18.  add a,(hl)                    ; calculate it, but it's late
  19.  ld hl,_user_int_ram+$9F            ; at night and I'm too tired
  20.  add a,(hl)                    ; to think about it.  Besides,
  21.  ld hl,_user_int_ram+$C7            ; you should only need to run
  22.  add a,(hl)                    ; this once!
  23.  ld (_user_int_chk),a            ;Put the checksum where the calc will find it
  24.  set userInt,(iy+userflags)        ;Activates the new interrupt code!
  25.  ret                            ;Return to TI-OS
  26.  
  27. CodeStart:                    ;_asm_exec_ram pointer to interrupt
  28. .org _user_int_ram                ;I don't use it here, but this lets you use JPs
  29.                             ; and CALLs in the interrupt
  30. IntStart:                        ;Makes the math easier
  31.  push af                        ;_Must_ do!
  32.  push bc                        ;Shouldn't need these, but the
  33.  push hl                        ; checksum fails w/o them
  34.  bit shiftAlpha,(iy+shiftflags)    ;Is the calc in Alpha mode?
  35.  jr z,SkipIt                    ;If not, skip all this crap!
  36.  ld a,$5F                        ;Mask out all but [ALPHA]'s row
  37.  out (1),a                    ;Send to keyboard
  38.  nop                            ;Wait for the keyboard port
  39.  nop                            ; to finish reading keypress
  40.  in a,(1)                        ;Read keypress
  41.  cp $80                        ;Was the key in [ALPHA]'s column?
  42.  jr nz,NoFix                    ;If not, just skip the the regular code.
  43.  res shiftAlpha,(iy+shiftflags)    ;Just turn off Alpha, don't bother w/ case
  44. NoFix:
  45.  set shiftALock,(iy+shiftflags)    ;Forces calc to go directly to A-lock
  46.  bit shift2nd,(iy+shiftflags)        ;Has 2nd been pressed?
  47.  jr z,SkipIt                    ;If not, don't bother
  48.  ld a,$28                        ;Set bits 3 (turn off 2nd) and 5 (flip Alpha case).
  49.  xor (iy+shiftflags)            ;Modify flags into a...
  50.  ld (iy+shiftflags),a            ;...and put them back where they go
  51. SkipIt:
  52.  pop hl                        ;And this cleans up our stack
  53.  pop bc                        ;Ditto...
  54.  pop af                        ;Restore the calc's registers
  55.  ret                            ;Head back to the main interrupt
  56. IntEnd:                        ;See comment for IntStart ;)
  57. .end
  58.