home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug041.arc / MWBKEY.MAC < prev    next >
Text File  |  1979-12-31  |  2KB  |  65 lines

  1. ; Program associated with LANGUAGE TRANSLATORS, INTERPRETERS, MICROWORLD BASIC,
  2. ;   SWAPPING OF CONTROL-A AND CONTROL-S document.
  3. ; G. Irlam - 26 January 1986
  4. ; A macro-80 program.
  5.  
  6.  
  7.         .Z80
  8.  
  9.  
  10. keypt   EQU     000C2h
  11.  
  12.  
  13. ctrlS   EQU      19d
  14. ctrlA   EQU       1d
  15.  
  16.  
  17.         CSEG
  18.  
  19. init:   PUSH    HL              ; why not
  20.         LD      HL, (keypt)
  21.         LD      (trueat), HL    ; save old address
  22.         LD      HL, fake
  23.         LD      (keypt), HL     ; store fake address
  24.         POP     HL
  25.         RET
  26.  
  27. deinit: PUSH    HL
  28.         LD      HL, (trueat)
  29.         LD      (keypt), HL     ; restore real address
  30.         POP     HL
  31.         RET
  32.  
  33. fake:   PUSH    HL              ; store HL - can usse HL without fear
  34.         LD      HL, cont
  35.         PUSH    HL              ; return from following call will be at cont
  36.         LD      HL, (trueat)
  37.         JP      (HL)
  38. cont:   JP      NZ, nokey       ; no key was pressed
  39.         CP      ctrlS
  40.         JP      NZ, notctS
  41.         LD      A, ctrlA        ; convert ^S to ^A
  42.         JP      retkey
  43. notctS: CP      ctrlA
  44.         JP      NZ, retkey
  45.         LD      A, ctrlS        ; convert ^A to ^S
  46. retkey: LD      L, A            ; save key - can't push as flags also pushed,
  47.         LD      A, 0d           ;   but they have to be altered below
  48.         CP      0d              ; set Z flag as a key was pressed
  49.         LD      A, L            ; restore key
  50.         JP      return
  51. nokey:  LD      L, A            ; save "no key"
  52.         LD      A, 0d
  53.         CP      1d              ; reset Z flag
  54.         LD      A, L            ; restore "no key"
  55. return: POP     HL
  56.         RET
  57.  
  58.  
  59.         DSEG
  60.  
  61. trueat: DW
  62.  
  63.  
  64.         END
  65.