summary refs log tree commit diff stats
path: root/test
Commit message (Expand)AuthorAgeFilesLines
* keyparser: added copying info to testcasehut2010-03-091-0/+15
* keyparser: lots of stuffhut2010-03-091-5/+9
* keyparser: fixeshut2010-03-091-1/+1
* keyparser: renamed KeyMap.add to KeyMap.maphut2010-03-091-45/+45
* keyparser: swapped argument order in KeyMap.add()hut2010-03-091-21/+21
* keyparser: allow passive actions (for hints, show bookmarks)hut2010-03-091-0/+30
* integrating keyparser...hut2010-03-091-0/+12
* deleted old testcasehut2010-03-091-100/+0
* keyparser: moved classes from test/ to ranger/hut2010-03-091-415/+17
* keyparser: implemented aliaseshut2010-03-091-11/+87
* keyparser: minor updateshut2010-03-091-2/+8
* keyparse: implemented Tree.mergehut2010-03-091-31/+92
* keyparser: Remove the restriction that a root can't be a leafhut2010-03-091-1/+0
* keyparser: updated test_tree_deep_copyhut2010-03-091-5/+4
* keyparser: added test case for tree emrgehut2010-03-091-0/+36
* keyparser: added tree.copy() for deep copieshut2010-03-091-0/+25
* keyparser: minor changeshut2010-03-091-3/+5
* keyparser: turned KeyMap into a treehut2010-03-091-76/+59
* keyparser: added seperate Tree classhut2010-03-091-0/+53
* keyparser: proper parsing of <xyz> in keybindingshut2010-03-091-51/+118
* keyparser: added test for directions as functions, cleanupshut2010-03-091-27/+66
* keyparser: cleanupshut2010-03-091-7/+4
* keyparser: some additionshut2010-03-091-16/+60
* keyparser: allow arbitrary number/order of directionshut2010-03-091-34/+66
* keyparser: reworkedhut2010-03-091-51/+61
* keyparser: "." matches any characterhut2010-03-091-23/+71
* keyparser: some improvements<
# check keyboard for a key
# return 0 on no keypress or unrecognized key
#
# We need to do this in machine code because Mu doesn't have global variables
# yet (for the keyboard buffer).

== code

# Most keys correspond to their ASCII/Unicode values.
# TODO: Support for international keyboards and multi-byte Unicode.
#
# However there are some exceptions that have no assigned place in Unicode
# (and with good reason):
#   0x80 = left arrow ←
#   0x81 = down arrow ↓
#   0x82 = up arrow ↑
#   0x83 = right arrow →
# These code points are not used by Unicode and their semantics are agreed to
# be context-sensitive: https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C1_controls.
# Mu cannibalizes them in yet another non-standard way.
read-key:  # kbd: (addr keyboard) -> result/eax: byte
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # . save registers
    51/push-ecx
    # result = 0
    b8/copy-to-eax 0/imm32
    # ecx = keyboard
    8b/-> *(ebp+8) 1/r32/ecx
    81 7/subop/compare %ecx 0/imm32
    {
      75/jump-if-!= break/disp8
      # var buffer-byte-addr/ecx: (addr byte)
      8b/-> *Keyboard-buffer:read 1/r32/CL
      81 0/subop/add %ecx Keyboard-buffer:data/imm32
      # var next-key/eax: byte = *buffer-byte-addr
      8a/byte-> *ecx 0/r32/AL
      # if (next-key != 0) lock and remove from keyboard buffer
      81 7/subop/compare %eax 0/imm32
      {
        74/jump-if-= break/disp8
        fa/disable-interrupts
        c6 0/subop/copy-byte *ecx 0/imm8
        ff 0/subop/increment *Keyboard-buffer:read
        81 4/subop/and *Keyboard-buffer:read 0x0f/imm32
        fb/enable-interrupts
      }
      # return
      eb $read-key:end/disp8
    }
    # TODO: fake keyboard
$read-key:end:
    # . restore registers
    59/pop-to-ecx
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return
d993873febe7b9c'>added documentation, clean up
hut2009-12-312-7/+7
* removed test/stuff directoryhut2009-12-306-236/+0
* fixed a few things~hut2009-12-301-11/+0