; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
;     http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; > $.Hdr.KeyWS

; ***********************************
; ***    C h a n g e   L i s t    ***
; ***********************************

; Date       Name  Description
; ----       ----  -----------
; 06-Feb-91  TMD   Added LastLED
; 09-Mar-92  TMD   Added JustGotKbID
; 24-Feb-93  SMC   Reorganised for new keyboard/mouse interfaces
; 19-Jul-93  JSR   Changed conditional from A1Keyboard to Keyboard_Type = "A1A500"

; Keyboard variables

          GBLS  keyprefix
keyprefix SETS  "Key$"

        ^       0, R11

CurrKey         #       4               ; current key in two key rollover
OldKey          #       4               ; old key in two key rollover
KbId            #       1
LastKbId        #       1
AutoRepeatCount #       1
Debouncing      #       1               ; NZ => do delay next, Z => do repeat
MouseButtons    #       1               ; bit0=R, bit1=C, bit2=L
PendingAltType  #       1               ; 1 => A, 2 => SA, 3 => CA, 4 => CSA
LastLED         #       1               ; last request for LED change, so we don't send repeated ones
MouseType       #       1               ; current pointer device type
MouseReporting  #       1               ; mouse is sending reports itself
NoDebounce      #       1               ; NZ => no kernel key debounce
                                        ; set if R2="NoKd" on KeyV 0 entry

                # 3 :AND: (- :INDEX: @)

InkeyCounter    #       4
MouseX          #       4
MouseY          #       4
SoftKeyPtr      #       4
MouseXMult      #       4
MouseYMult      #       4
KeyVec          #       4
MouseAltX       #       4
MouseAltY       #       4


MouseBounds     #       16
MouseBoundLCol  *       MouseBounds+0
MouseBoundBRow  *       MouseBounds+4
MouseBoundRCol  *       MouseBounds+8
MouseBoundTRow  *       MouseBounds+12

KeysDown        #       &300/8          ; bitmap of all down keys

SoftKeyName     #       3 + :LEN:(keyprefix)    ; up to 2 digits + terminator

SoftKeyExpand   #       255             ; current key expansion

        ASSERT  (:INDEX: @) < KeyWorkSpaceSize
UserKeyWorkSpaceSize *  KeyWorkSpaceSize-(:INDEX: @)
UserKeyWorkSpace #      UserKeyWorkSpaceSize

 [ :DEF: ShowWS
      ! 0, "UserKeyWorkSpaceSize  is ":CC::STR:(UserKeyWorkSpaceSize)
 ]
        ASSERT  UserKeyWorkSpaceSize >= 64 ; "About 170 bytes" according to IntKey.Doc.HandlerAPI, but we've been smaller than that for a long time

; PMF -> VDU communication stuff put in here because both VDU and PMF
; 'GET' this file

;        GBLA    ExtEntries
;ExtEntries SETA 0
;
;        MACRO
;        AddExtEntry $EntryName
;Index_$EntryName * ExtEntries
;Value_$ExtEntries * $EntryName
;ExtEntries SETA ExtEntries +1
;        MEND
;
;        MACRO
;$Table  OutputExternals
;$Table
;        LCLA    count
;count   SETA    0
;        WHILE   count < ExtEntries
;        &       Value_$count - $Table -4
;count   SETA    count + 1
;        WEND
;        MEND

        MACRO
        ByteToNosbod $EntryName
        VDWS    WsPtr
        BL      $EntryName
        MEND

;        AddExtEntry     DoReadPOSVPOSI
;        AddExtEntry     DoReadPOSVPOSO
;        AddExtEntry     DoOSBYTE87
;        AddExtEntry     DoResetFont
;        AddExtEntry     DoReadFont
;        AddExtEntry     DoReadVDUStatus
;        AddExtEntry     DoReadVDUVariable
;        AddExtEntry     DoReadPalette
;        AddExtEntry     DoSetPalette
;        AddExtEntry     DoPointerStuff
;        AddExtEntry     DoSetScreenStart
;        AddExtEntry     DoSetDriverBank
;        AddExtEntry     DoSetDisplayBank
;        AddExtEntry     DoOsbyte163_242
;        AddExtEntry     DoOsWord13

        END