OpenCores
URL https://opencores.org/ocsvn/rf6809/rf6809/trunk

Subversion Repositories rf6809

[/] [rf6809/] [trunk/] [software/] [boot/] [keyboard.asm] - Diff between revs 4 and 14

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 4 Rev 14
Line 60... Line 60...
krb3:
krb3:
        bsr             KeybdGetStatus  ; wait for response from keyboard
        bsr             KeybdGetStatus  ; wait for response from keyboard
        tstb
        tstb
        bmi             krb4                                            ; is input buffer full ? yes, branch
        bmi             krb4                                            ; is input buffer full ? yes, branch
        bsr             Wait10ms                                ; wait a bit
        bsr             Wait10ms                                ; wait a bit
        leax    -1,x
        dex
        bne             krb3                                            ; go back and try again
        bne             krb3                                            ; go back and try again
        ldd             #-1                                                     ; return -1
        ldd             #-1                                                     ; return -1
        puls    x,pc
        puls    x,pc
krb4:
krb4:
        bsr             KeybdGetScancode
        bsr             KeybdGetScancode
Line 98... Line 98...
kwt1:
kwt1:
        bsr             KeybdGetStatus
        bsr             KeybdGetStatus
        andb    #$40                            ; check for transmit complete bit; branch if bit set
        andb    #$40                            ; check for transmit complete bit; branch if bit set
        bne             kwt2
        bne             kwt2
        bsr             Wait10ms                ; delay a little bit
        bsr             Wait10ms                ; delay a little bit
        leax    -1,x
        dex
        bne             kwt1                            ; go back and try again
        bne             kwt1                            ; go back and try again
        ldd             #-1                                     ; timed out, return -1
        ldd             #-1                                     ; timed out, return -1
        puls    x,pc
        puls    x,pc
kwt2:
kwt2:
        clra                                                    ; wait complete, return 0
        clra                                                    ; wait complete, return 0
Line 182... Line 182...
 
 
KeybdGetScancode:
KeybdGetScancode:
        clra
        clra
        ldb             KEYBD                           ; get the scan code
        ldb             KEYBD                           ; get the scan code
        clr             KEYBD+1                 ; clear receive register (write $00 to status reg)
        clr             KEYBD+1                 ; clear receive register (write $00 to status reg)
        ; The following useful during debug.
 
;       lbsr    DispByteAsHex
 
;       pshs    b
 
;       ldb             #' '
 
;       lbsr    OUTCH
 
;       puls    b
 
        rts
        rts
 
 
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Set the LEDs on the keyboard.
; Set the LEDs on the keyboard.
;
;
Line 257... Line 251...
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
 
KeybdInit:
KeybdInit:
        pshs    d,y
        pshs    d,y
        ldy             #5
        ldy             #5
 
        clr             KeyState1               ; records key up/down state
 
        clr             KeyState2               ; records shift,ctrl,alt state
kbdi0002:
kbdi0002:
        bsr             Wait10ms
        bsr             Wait10ms
        clr             KEYBD+1                 ; clear receive register (write $00 to status reg)
        clr             KEYBD+1                 ; clear receive register (write $00 to status reg)
        ldb             #-1                                     ; send reset code to keyboard
        ldb             #-1                                     ; send reset code to keyboard
        stb             KEYBD+1                 ; write $FF to status reg to clear TX state
        stb             KEYBD+1                 ; write $FF to status reg to clear TX state
Line 316... Line 312...
        puls    d,y,pc
        puls    d,y,pc
 
 
msgBadKeybd:
msgBadKeybd:
        fcb             "Keyboard error",0
        fcb             "Keyboard error",0
 
 
 
;------------------------------------------------------------------------------
 
; Calculate number of character in input buffer
 
;
 
; Parameters:
 
;               y = $Cn00000 where n is core id
 
; Returns:
 
;               d = number of bytes in buffer.
 
;------------------------------------------------------------------------------
 
 
 
kbdRcvCount:
 
        clra
 
        ldb             kbdTailRcv,y
 
        subb    kbdHeadRcv,y
 
        bge             krcXit
 
        ldb             #$40
 
        subb    kbdHeadRcv,y
 
        addb    kbdTailRcv,y
 
krcXit:
 
        rts
 
 
 
 
 
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
 
 
KeybdIRQ:
 
        lda             KEYBD+1                                         ; check status
 
        bita    #$80                                                    ; was key pressed?
 
        beq             notKbdIRQ                                       ; if not, exit
 
        ldb             KEYBD                                                   ; get the scan code
 
        clr             KEYBD+1                                         ; clear receive register (write $00 to status reg)
 
        pshs    b                                                                       ; save it off
 
        lda             IOFocusID                                       ; compute core memory address $Cn0000
 
        clrb
 
        asla
 
        asla
 
        asla
 
        asla
 
        ora             #$C00                                                   ; address $Cn0000
 
        tfr             d,y                                                             ; y =
 
        bsr             kbdRcvCount                             ; get count of scan codes in buffer
 
        cmpb    #64                                                             ; check if buffer full?
 
        bhs             kbdBufFull                              ; if buffer full, ignore new keystroke
 
        tfr             y,x                                                             ; compute fifo address
 
        ldb             kbdTailRcv,y                    ; b = buffer index
 
        puls    a                                                                       ; get back scancode
 
        leax    kbdFifo,x                                       ; x = base address for fifo
 
        sta             b,x                                                             ; store in buffer
 
        incb                                                                            ; increment buffer index
 
        andb    #$3f                                                    ; wrap around at 64 chars
 
        stb             kbdTailRcv,y                    ; update it
 
        lda             #28                                                             ; Keyboard is IRQ #28
 
        sta             IrqSource                                       ; stuff a byte indicating the IRQ source for PEEK()
 
notKbdIRQ:
 
        rts
 
kbdBufFull:
 
        leas    1,s                                                             ; get rid of saved scancode
 
        rts
 
 
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
 
DBGCheckForKey:
DBGCheckForKey:
        bra             KeybdGetStatus
        bra             KeybdGetStatus
Line 339... Line 393...
; |         =    "
; |         =    "
; |         =    "
; |         =    "
; +-------- = extended
; +-------- = extended
 
 
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Debug versison of keyboard get routine.
; Keyboard get routine.
 
;
 
; The routine may get characters directly from the scancode input or less
 
; directly from the scancode buffer, if things are interrupt driven.
;
;
; Parameters:
; Parameters:
;               b:      0 = non blocking, otherwise blocking
;               b:  bit 11 = blocking status 1=blocking, 0=non blocking
 
;               b:      bit 1  = scancode source 1=scancode buffer, 0=direct
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
 
DBGGetKey:
GetKey:
        pshs    x
        pshs    x,y
 
        stb             KeybdBlock                              ; save off blocking status
dbgk2:
dbgk2:
 
        ldb             KeybdBlock
        pshs    b
        pshs    b
 
        bitb    #1                                                              ; what is the scancode source
 
        beq             dbgk20                                          ; branch if direct read
 
        lda             COREID                                          ; compute core memory address
 
        clrb
 
        asla
 
        asla
 
        asla
 
        asla
 
        ora             #$C00
 
        tfr             d,y                                                             ; y = $Cn0000
 
        bsr             kbdRcvCount
 
        tstb                                                                            ; anything in buffer?
 
        puls    b
 
        bne             dbgk1                                                   ; branch if something in buffer
 
        tstb
 
        bmi             dbgk2                                                   ; if no key and blocking - loop
 
dbgk20:
 
        ldy             #0
        bsr             KeybdGetStatus
        bsr             KeybdGetStatus
        andb    #$80                                                    ; is key available?
        andb    #$80                                                    ; is key available?
        puls    b
        puls    b
        bne             dbgk1                                                   ; branch if key
        bne             dbgk1                                                   ; branch if key
        tstb                                                                            ; block?
        tstb                                                                            ; block?
        bne             dbgk2                                                   ; If no key and blocking - loop
        bmi             dbgk2                                                   ; If no key and blocking - loop
        ldd             #-1                                                             ; return -1 if no block and no key
        ldd             #-1                                                             ; return -1 if no block and no key
        puls    x,pc
        puls    x,pc
dbgk1:
dbgk1:
        bsr             KeybdGetScancode
        cmpy    #0
 
        bne             dbgk22
 
        bsr             KeybdGetScancode        ; get scancode directly
 
        bra             dbgk23
 
dbgk22:
 
        ; Retrieve value from scancode buffer
 
        tfr             y,x
 
        leax    kbdFifo,x                                       ; x = fifo address
 
        ldb             kbdHeadRcv,y                    ; b = buffer index
 
        lda             b,x                                                             ; get the scancode
 
        incb                                                                            ; increment fifo index
 
        andb    #$3f                                                    ; and wrap around
 
        stb             kbdHeadRcv,y                    ; save it back
 
        tfr             a,b                                                             ; the scancode is needed in accb
 
dbgk23:
;       lbsr    DispByteAsHex
;       lbsr    DispByteAsHex
        ; Make sure there is a small delay between scancode reads
        ; Make sure there is a small delay between scancode reads
        ldx             #20
        ldx             #20
dbgk3:
dbgk3:
        dex
        dex
        bne             dbgk3
        bne             dbgk3
        ; switch on scan code
        ; switch on scan code
        cmpb    #SC_KEYUP
        cmpb    #SC_KEYUP
        bne             dbgk4
        bne             dbgk4
        clr             KeyState1                                       ; make KeyState1 = -1
        stb             KeyState1                                       ; make KeyState1 <> 0
        neg             KeyState1
 
        bra             dbgk2                                                   ; loop back
        bra             dbgk2                                                   ; loop back
dbgk4:
dbgk4:
        cmpb    #SC_EXTEND
        cmpb    #SC_EXTEND
        bne             dbgk5
        bne             dbgk5
        lda             KeyState2
        lda             KeyState2
Line 382... Line 473...
        bra             dbgk2
        bra             dbgk2
dbgk5:
dbgk5:
        cmpb    #SC_CTRL
        cmpb    #SC_CTRL
        bne             dbgkNotCtrl
        bne             dbgkNotCtrl
        tst             KeyState1
        tst             KeyState1
        bmi             dbgk7
        bne             dbgk7
        lda             KeyState2
        lda             KeyState2
        ora             #4
        ora             #4
        sta             KeyState2
        sta             KeyState2
        bra             dbgk8
        bra             dbgk8
dbgk7:
dbgk7:
Line 398... Line 489...
        bra             dbgk2
        bra             dbgk2
dbgkNotCtrl:
dbgkNotCtrl:
        cmpb    #SC_RSHIFT
        cmpb    #SC_RSHIFT
        bne             dbgkNotRshift
        bne             dbgkNotRshift
        tst             KeyState1
        tst             KeyState1
        bmi             dbgk9
        bne             dbgk9
        lda             KeyState2
        lda             KeyState2
        ora             #1
        ora             #1
        sta             KeyState2
        sta             KeyState2
        bra             dbgk10
        bra             dbgk10
dbgk9:
dbgk9:
Line 453... Line 544...
        bra             dbgk2
        bra             dbgk2
dbgkNotScrolllock:
dbgkNotScrolllock:
        cmpb    #SC_ALT
        cmpb    #SC_ALT
        bne             dbgkNotAlt
        bne             dbgkNotAlt
        tst             KeyState1
        tst             KeyState1
        bmi             dbgk11
        bne             dbgk11
        lda             KeyState2
        lda             KeyState2
        ora             #2
        ora             #2
        sta             KeyState2
        sta             KeyState2
        bra             dbgk12
        bra             dbgk12
dbgk11:
dbgk11:
Line 477... Line 568...
        anda    #6
        anda    #6
        cmpa    #6
        cmpa    #6
        bne             dbgk14
        bne             dbgk14
        cmpb    #SC_DEL
        cmpb    #SC_DEL
        bne             dbgk14
        bne             dbgk14
        jmp             [$FFFFFE]               ; jump to reset vector
        jmp             [$FFFFFC]               ; jump to NMI vector
dbgk14:
dbgk14:
        tst             KeyState2               ; extended code?
        tst             KeyState2               ; extended code?
        bpl             dbgk15
        bpl             dbgk15
        lda             KeyState2
        lda             KeyState2
        anda    #$7FF
        anda    #$7FF
Line 500... Line 591...
        ldx             #shiftedScanCodes
        ldx             #shiftedScanCodes
        bra             dbgk18
        bra             dbgk18
dbgk17:
dbgk17:
        ldx             #unshiftedScanCodes
        ldx             #unshiftedScanCodes
dbgk18:
dbgk18:
        abx
        ldb             b,x                                     ; load accb with ascii from table
        ldb             ,x
 
        clra
        clra
        puls    x,pc                            ; and return
        puls    x,y,pc                  ; and return
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.