Subversion Repositories Spectranet

[/] [branches/] [gnubinutils/] [rom/] [ui_keyscan.asm] - Diff between revs 383 and 384

Show entire file | Details | Blame | View Log

Rev 383 Rev 384
Line 39... Line 39...
key_table_sym_letters:
key_table_sym_letters:
                        db 0xe2, '*', '?', 0xcd, 0xc8, 0xcc, 0xcb, '^'
                        db 0xe2, '*', '?', 0xcd, 0xc8, 0xcc, 0xcb, '^'
                        db 0xac, '-', '+', '=', '.', ',', ';', '"'
                        db 0xac, '-', '+', '=', '.', ',', ';', '"'
                        db 0xc7, '<', 0xc3, '>', 0xc5, '/', 0xc9, 0x60, 0xc6, ':'
                        db 0xc7, '<', 0xc3, '>', 0xc5, '/', 0xc9, 0x60, 0xc6, ':'
.text
.text
key_scan:
.globl F_key_scan
 
F_key_scan:
                        ; scan keyboard, returning key code(s) in DE.
                        ; scan keyboard, returning key code(s) in DE.
                        ; Numbering rows B-Sp=0, H-En=1, Y-P=2, 6-0=3, 1-5=4, Q-T=5, A-G=6, Cs-V=7,
                        ; Numbering rows B-Sp=0, H-En=1, Y-P=2, 6-0=3, 1-5=4, Q-T=5, A-G=6, Cs-V=7,
                        ; key code is rownum + ((5 - bit number) << 3).
                        ; key code is rownum + ((5 - bit number) << 3).
                        ; The first key encountered, ordering by descending row and ascending bit
                        ; The first key encountered, ordering by descending row and ascending bit
                        ; within row, is put in E. The second key is put in D.
                        ; within row, is put in E. The second key is put in D.
Line 106... Line 107...
key_scan_no_ss:
key_scan_no_ss:
                        ld a,d                                                  ; only remaining valid condition is if D is
                        ld a,d                                                  ; only remaining valid condition is if D is
                        cp 0x18                                                 ; symbol shift; check for this condition and
                        cp 0x18                                                 ; symbol shift; check for this condition and
                        ret                                                             ; return with Z flag indicating the result
                        ret                                                             ; return with Z flag indicating the result
 
 
key_test:
.globl F_key_test
 
F_key_test:
                        ; Test that a successful (zero flag set) response from key_scan is indeed
                        ; Test that a successful (zero flag set) response from key_scan is indeed
                        ; a real key (i.e0. not just a shift key on its own). As described by Toni Baker
                        ; a real key (i.e0. not just a shift key on its own). As described by Toni Baker
                        ; (Mastering Machine Code on your ZX Spectrum, ch11):
                        ; (Mastering Machine Code on your ZX Spectrum, ch11):
                        ;   i) B will be made to contain the value formerly held by D
                        ;   i) B will be made to contain the value formerly held by D
                        ;  ii) D will be made to contain zero
                        ;  ii) D will be made to contain zero
Line 132... Line 134...
                        add hl,de
                        add hl,de
                        ld a,(hl)
                        ld a,(hl)
                        scf
                        scf
                        ret
                        ret
; 0x0333
; 0x0333
key_code:
.globl F_key_code
 
F_key_code:
                        ; Convert base character to ASCII code, respecting shifts and current key mode.
                        ; Convert base character to ASCII code, respecting shifts and current key mode.
                        ; entry: E = base character
                        ; entry: E = base character
                        ; B = shift code (FF, 27 or 18)
                        ; B = shift code (FF, 27 or 18)
                        ; C = editor mode (0 = K/L/C, 1 = E, 2 = G)
                        ; C = editor mode (0 = K/L/C, 1 = E, 2 = G)
                        ; bit 3 of D = 0 for K mode, 1 for L/C mode
                        ; bit 3 of D = 0 for K mode, 1 for L/C mode