?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. KEYQUEUEINCHL
  2.         INC HL
  3.         LD A,L
  4.         CP tkeyqueueend&0xff
  5.         RET NZ
  6.         LD HL,tkeyqueue
  7.         RET
  8.        
  9. tkeyqueue
  10.         DS 4*keyqueuemax
  11. tkeyqueueend
  12.  
  13.         if 1==0
  14. PEEKKEY
  15.         LD A,(keyqueueN)
  16.         OR A
  17.         ld h,a
  18.         RET Z ;a=NOKEY, h=0
  19.         LD HL,(keyqueuetail)
  20.         LD a,(HL)
  21.         INC HL
  22.         LD h,(HL)
  23.         ret
  24.         endif
  25.        
  26. GETKEY
  27. ;out: ha=key (NOKEY=none), bc=keynolang keeps de,l
  28. ;H0=1 for control codes, H0=0 for symbols
  29. ;TODO add somewhere in H bits for keyboard register
  30.         LD A,(keyqueueN)
  31.         OR A
  32.         ld h,a
  33.          ld b,a
  34.          ld c,a
  35.         RET Z ;a=NOKEY, h=0, bc=0
  36.         PUSH de
  37.         PUSH HL
  38. keyqueuetail=$+1
  39.         LD HL,tkeyqueue
  40. ;2 bytes with language
  41. ;2 bytes without language
  42.         LD e,(HL)
  43.         INC HL
  44.         LD d,(HL) ;keylang
  45.         CALL KEYQUEUEINCHL
  46.         LD c,(HL)
  47.         INC HL
  48.         LD b,(HL) ;keynolang
  49.         CALL KEYQUEUEINCHL
  50.         LD (keyqueuetail),HL
  51.         LD HL,keyqueueN
  52.         DEC (HL) ;atomic!!! (or we can miss keyqueueN increase)
  53.                  ;after reading!!! (or it might be overwritten while reading)
  54.         POP HL
  55.         ld h,d ;keylang HSB
  56.         ld a,e ;keylang LSB
  57.         pop de
  58.         RET
  59.  
  60. KEY_PUTREDRAW
  61. ;clear jeyboard queue
  62.         call GETKEY
  63.         or c
  64.         jr nz,KEY_PUTREDRAW
  65. ;store redraw key if it's absent in queue
  66.          ;;ld a,key_redraw
  67.          ;;ld (curkey),a
  68.          ;call PEEKKEY ;ld a,(curkey) ;TODO seek queue head, not tail
  69.          ;cp key_redraw
  70.          ;ret z
  71.          ld bc,key_redraw
  72.          ld (keyqueueput_codenolang),bc
  73.          ;jp KEYQUEUEPUT ;if we switched to an inactive task, nobody can read the keycode!!
  74. ;BC=code (B=1 => control key)
  75. KEYQUEUEPUT
  76. keyqueueN=$+1
  77.         LD A,0 ;decreased AFTER reading from queue
  78.         CP keyqueuemax
  79.         RET Z ;no room
  80.         INC A
  81.         LD (keyqueueN),A
  82. ;ALTGR codes: b=0, c=0..255
  83. ;letters: b=0, c>=32
  84. ;control codes: b=1, c=0..31, 0xbx, 0xcx, 0xdx, 0xfx
  85.        
  86. ;result: TODO b=1, c=0x8x, 0x9x for ALTGR codes 0..31???
  87. keyqueuehead=$+1
  88.         LD HL,tkeyqueue
  89.         LD (HL),C
  90.         INC HL
  91.         LD (HL),B ;B=0: letter, B=1: control key
  92.         CALL KEYQUEUEINCHL
  93. keyqueueput_codenolang=$+1
  94.         ld bc,0
  95.         LD (HL),C
  96.         INC HL
  97.         LD (HL),B ;B=0: symbol from ALTGR, B=1: other keys
  98.         CALL KEYQUEUEINCHL
  99.         LD (keyqueuehead),HL
  100.         RET
  101.