Mercurial > hg > Members > kono > nitros9-code
changeset 1338:b3caa1b456ed
Additional comments and some changes by the Rodney man!
author | boisy |
---|---|
date | Sat, 13 Sep 2003 16:10:19 +0000 |
parents | c061b3b3c10d |
children | bd102e2f30a4 |
files | level2/modules/keydrv_cc3.asm |
diffstat | 1 files changed, 100 insertions(+), 85 deletions(-) [+] |
line wrap: on
line diff
--- a/level2/modules/keydrv_cc3.asm Wed Sep 10 02:31:51 2003 +0000 +++ b/level2/modules/keydrv_cc3.asm Sat Sep 13 16:10:19 2003 +0000 @@ -16,7 +16,7 @@ ifp1 use defsfile - endc + ENDC tylg set Systm+Objct atrv set ReEnt+rev @@ -43,11 +43,10 @@ * Read - read keys if pressed ReadKys ldu <D.CCMem Get CC3IO global memory into U ldx #PIA0Base base address of PIA #0 - clrb - comb - stb $02,x clear all strobe lines - ldb ,x read PIA #0 - comb bit values 0=off 1=on + ldb #$FF + stb $02,x clear all row strobes + ldb ,x read Joystick buttons + comb invert bits so 1=pressed andb #%00001111 keep only buttons bne L0059 branch if button pushed; error routine clr $02,x enable all strobe lines @@ -65,8 +64,12 @@ ldb <G.CapLok,u CapsLock/SysRq key down flag bne L0056 clr <G.KTblLC,u Key table entry# last checked (1-3) - coma - comb + IFNE H6309 + comd + ELSE + coma + comb + ENDC sta <G.LKeyCd,u last keyboard code sta <G.2Key1,u 2nd key table storage; $FF=none std <G.2Key2,u format (Row/Column) @@ -75,37 +78,37 @@ L005B rts L005C ldx #PIA0Base base value of PIA #0 - ifne H6309 + IFNE H6309 clrd - else + ELSE clra clrb - endc + ENDC std <G.ShftDn shift/CTRL flag; 0=NO $FF=YES std <G.KeyFlg PIA bits/ALT flag * %00000111-Column # (Output, 0-7) * %00111000-Row # (Input, 0-6) - ifne H6309 - comd - else + IFNE H6309 + comd set D to $FFFF + ELSE coma comb set primary key table - endc + ENDC std <G.Key1 key 1&2 flags $FF=none - sta <G.Key3 key 3 ² + sta <G.Key3 key 3 " deca ie. lda #%11111110 sta $02,x strobe one column -L006E lda ,x read PIA #0 - coma +L006E lda ,x read PIA #0 row states + coma invert bits so 1=key pressed anda #$7F keep only keys, bit 0=off 1=on - beq L0082 + beq L0082 no keys pressed, try next column ldb #$FF preset counter to -1 L0077 incb lsra bit test regA bcc L007E no key so branch lbsr L010E convert column/row to matrix value and store it L007E cmpb #$06 max counter - bcs L0077 loop if more bits to test + blo L0077 loop if more bits to test L0082 inc <G.KeyFlg counter; used here for column orcc #Carry bit marker; disable strobe rol $02,x shift to next column @@ -116,7 +119,7 @@ bne L0095 inc <G.KySame same key flag ?counter? L0095 sta <G.LKeyCd setup for last key pressed - beq L00B5 + beq L00B5 if @ key, use lookup table suba #$1A the key value (matrix) of Z bhi L00B5 not a letter so go adda #$1A restore regA @@ -130,45 +133,47 @@ bne L00E0 not shifted so go adda #$20 convert to ASCII lower case bra L00E0 -* key is not a letter; this routine is not based on some underlining principle of -* the keyboard hardware. It is also a function of the decode table at $1DC,pcr. -L00B5 ldb #$03 - mul regB = (key#-26) times 3 +* not a letter key, use the special keycode lookup table at L01DC. +* Entry: regA = table index (matrix scancode-26) +L00B5 ldb #$03 three entries per key (normal,shift,ctrl) + mul convert index to table offset lda <G.ShftDn shift key flag beq L00BF not shifted so go - incb + incb adjust offset for SHIFTed entry bra L00C5 L00BF lda <G.CntlDn CTRL flag - beq L00C5 + beq L00C5 adjust offset for CONTROL entry addb #$02 L00C5 ldx <G.CurDev point X to device's static memory lda <$22,x key sense flag beq L00D0 not set so go cmpb #$11 spacebar ble L00F3 must be an arrow so go -L00D0 cmpb #$4C SHIFTed ALT key +L00D0 cmpb #$4B ALT key? (was cmpb #$4C) blt L00D8 not ALT, CTRL, F1, F2, or SHIFT so go inc <G.AltDwn flag special keys (ALT,CTRL) - subb #$06 + subb #$06 and adjust offset to skip them L00D8 leax >L01DC,pcr decode table lda b,x - bmi L00F6 if regA = $81 - $84 + bmi L00F6 if regA = $81 - $84, special key * several entries to this routine from any key press; regA is already ASCII L00E0 ldb <G.AltDwn was ALT flagged? beq L00F0 no so go cmpa #$3F ? bls L00EE # or code cmpa #$5B [ - bcc L00EE capital letter so go + bhs L00EE capital letter so go ora #$20 convert to lower case L00EE ora #$80 set for ALT characters L00F0 andcc #^Negative not negative rts L00F3 orcc #Negative set negative L00F5 rts +* Flag that a special key was hit L00F6 inc <G.CapLok caps lock/SysRq inc <G.Clear one shot caps lock/SysRq bra L00F0 +* Calculate arrow keys for key sense byte L00FC pshs b,a convert column into power of 2 clrb orcc #Carry @@ -176,10 +181,11 @@ L0102 rolb deca bne L0102 - bra L0108 WHY IS THIS HERE?? +* bra L0108 WHY IS THIS HERE?? L0108 orb <G.KySns previous value of column stb <G.KySns puls pc,b,a +* Check special keys (Shift, Cntrl, Alt) L010E pshs b,a cmpb #$03 is it row 3? bne L011C @@ -226,7 +232,7 @@ L0160 stb $02,x ldb #$03 puls pc,a -* simlutaneous key test +* simultaneous key test L0166 pshs y,x,b ldb <G.KTblLC key table entry # beq L019D @@ -260,7 +266,7 @@ bpl L01B5 deca bne L01A2 - ldb <G.KTblLc key table entry (can test for 3 simul keys) + ldb <G.KTblLC key table entry (can test for 3 simul keys) beq L01C0 decb leax <$2A,u 2nd key table @@ -273,61 +279,63 @@ L01BE puls pc,y,x,b L01C0 orcc #Negative flag negative puls pc,y,x,b -L01C4 leax <$2A,u - bsr L01CF +* Sort 3 byte packet @ G.2Key1 according to sign of each byte +* so that positive #'s are at beginning & negative #'s at end +L01C4 leax <$2A,u 2nd key table + bsr L01CF sort bytes 1 & 2 leax $01,x - bsr L01CF - leax -$01,x -L01CF lda ,x - bpl L01DB - ldb $01,x - bmi L01DB - sta $01,x - stb ,x + bsr L01CF sort bytes 2 & 3 + leax -$01,x sort 1 & 2 again (fall thru for third pass) +L01CF ldb ,x get current byte + bpl L01DB positive - no swap + lda $01,x get next byte + bmi L01DB negative - no swap + std ,x swap the bytes L01DB rts -* These seem to be special key combination values; 3 per key in ASCII -*L01DC fcb @,shift@,nul -* fcb up,shifted,CTRL -* fcb down, shifted, CTRLed -* fcb left, shifted, CTRLed -* fcb right, shifted, CTRLed -* fcb spacebar, spacebar, spacebar -* fcb ~0,~0,$81 signal shiftlock change -* fcb ~1,~!,~| -* fcb ~2,~”,null -* fcb ~3,~#,~~ -* fcb ~4,~$,null -* fcb ~5,~%,null -* fcb ~6,~&,null -* fcb ~7,~~,~^ -* fcb ~8,~(,~[ -* fcb ~9,~),~] -* fcb ~:,~*,null -* fcb ~;,~+,DEL -* fcb ~,,~<,~{ -* fcb ~-,~=,~_ -* fcb ~.,~>,~} -* fcb ~/,~?,~\ -* fcb ENTER,ENTER,ENTER -* I think these are for ALT -* fcb $82,$83,$84 -* fcb ENQ,BREAK,ESC -* the next I think are for the F1 and F2 keys -* fcb ~1,~3,~5 -* fcb ~2,~4,~6 -L01DC fdb $4060,$000c,$1c13,$0a1a,$1208,$1810,$0919,$1120 - fdb $2020,$3030,$8131,$217c,$3222,$0033,$237e,$3424 - fdb $0035,$2500,$3626,$0037,$275e,$3828,$5b39,$295d - fdb $3a2a,$003b,$2b7f,$2c3c,$7b2d,$3d5f,$2e3e,$7d2f - fdb $3f5c,$0d0d,$0d82,$8384,$0503,$1b31,$3335,$3234 - fcb $36 + +* Special Key Codes Table : 3 entries per key - Normal, Shift, Control +* They are in COCO keyboard scan matrix order; the alphabetic and meta +* control keys are handled elsewhere. See INSIDE OS9 LEVEL II p.4-1-7 +L01DC fcb $40,$60,$00 '@,'`,null + fcb $0c,$1c,$13 UP ARROW: FF, FS,DC3 + fcb $0a,$1a,$12 DOWN ARROW: LF,SUB,DC2 + fcb $08,$18,$10 LEFT ARROW: BS,CAN,DLE + fcb $09,$19,$11 RIGHT ARROW: HT, EM,DC1 + fcb $20,$20,$20 SPACEBAR + fcb $30,$30,$81 '0,'0,$81 (caps lock toggle) + fcb $31,$21,$7c '1,'!,'| + fcb $32,$22,$00 '2,'",null + fcb $33,$23,$7e '3,'#,'~ + fcb $34,$24,$1d '4,'$,GS (was null) + fcb $35,$25,$1e '5,'%,RS (was null) + fcb $36,$26,$1f '6,'&,US (was null) + fcb $37,$27,$5e '7,'','^ + fcb $38,$28,$5b '8,'(,'[ + fcb $39,$29,$5d '9,'),'] + fcb $3a,$2a,$00 ':,'*,null + fcb $3b,$2b,$7f ';,'+,DEL + fcb $2c,$3c,$7b ',,'<,'{ + fcb $2d,$3d,$5f '-,'=,'_ + fcb $2e,$3e,$7d '.,'>,'} + fcb $2f,$3f,$5c '/,'?,'\ + fcb $0d,$0d,$0d ENTER key + fcb $82,$83,$84 CLEAR key (NextWin, PrevWin, KbdMouse toggle) + fcb $05,$03,$1b BREAK key (ENQ,ETX,ESC) + fcb $31,$33,$35 F1 key (converts to $B1,$B3,$B5) + fcb $32,$34,$36 F2 key (converts to $B2,$B4,$B6) + +*L01DC fdb $4060,$000c,$1c13,$0a1a,$1208,$1810,$0919,$1120 +* fdb $2020,$3030,$8131,$217c,$3222,$0033,$237e,$3424 +* fdb $0035,$2500,$3626,$0037,$275e,$3828,$5b39,$295d +* fdb $3a2a,$003b,$2b7f,$2c3c,$7b2d,$3d5f,$2e3e,$7d2f +* fdb $3f5c,$0d0d,$0d82,$8384,$0503,$1b31,$3335,$3234 +* fcb $36 * Init and Term do nothing for this CoCo keyboard subroutine module Init Term clrb rts - * This entry point tests for the F1/F2 function keys on a CoCo 3 * keyboard. * Exit: A = Function keys pressed (Bit 0 = F1, Bit 2 = F2) @@ -336,19 +344,26 @@ clra clear A ldb #%11011111 strobe column #6 of PIA #0 stb $02,x + IFNE H6309 + tim #%01000000,0,x F1 down? + ELSE ldb ,x read PIA #0 bitb #%01000000 test for F1 function key + ENDC bne CheckF2 branch if set (key not down) inca flag F1 as down CheckF2 ldb #%10111111 strobe column #7 PIA #0 stb $02,x + IFNE H6309 + tim #%01000000,0,x F2 down? + ELSE ldb ,x read PIA #0 bitb #%01000000 test for F2 function key + ENDC bne L024C ora #$04 flag F2 as down L024C rts - emod -eom equ * - end - + emod +eom equ * + end