ramidavis Posted October 17, 2017 Share Posted October 17, 2017 (edited) ... Edited January 2, 2018 by ramidavis Quote Link to comment Share on other sites More sharing options...
+jedimatt42 Posted October 18, 2017 Share Posted October 18, 2017 http://www.unige.ch/medecine/nouspikel/ti99/keyboard.htm Electrically, both shift keys are the same. The link above covers everything you never wanted to know. TI's BASICS don't support testing for the modifiers alone. But in any other language that gives you access to setting and testing CRU bits you can. -M@ Quote Link to comment Share on other sites More sharing options...
RXB Posted October 18, 2017 Share Posted October 18, 2017 (edited) RXB on REAL TI99/4A can detect up to 4 keys being pressed if you scan some rows using RXB command CALL IO for CRU reading of each Keyboard line. Of course the Alpha Lock key will kill off the Joystick UP line if depressed as it cuts off the reading of this line from seeing the UP line on Joysticks. Here is a map and using CRU address lines (divided by 2) in RXB allows you to read each line of keys being scaned: ============================================================================================ = . Column 0 1 2 3 4 5 6 7 A-lock = = R12 address Pin # 12 13 14 15 9 8 J7 J2 6 = = >0006 5/J4 = . , M N / Fire Fire = = >0008 4/J5 Space L K J H ; Left Left = = >000A 1/J9 Enter O I U Y P Right Right = = >000C 2/J8 = = 9 8 7 6 0 Down Down = = >000E 7/J3 Fctn 2 3 4 5 1 Up Up A-lock = = >0010 3 Shift S D F G A = = = = >0012 10 Ctrl W E R T Q = = = = >0014 11 = = X C V B Z = ============================================================================================ Example: CALL IO(2,16,3,A,B) Would put the key scan line pin values of = . , M N / Fire1 Fire2 The values of 12 13 14 15 9 8 J7 J8 RXB can do things no other XB can possible do. To read more then one keyboard line at a time just add more variables EXAMPLE: CALL IO(2,16,3,A,B,2,16,4,C,D) this would read CRU line 6 and CRU line 8 of the keyboard (CRU value 6 and 8 divided by 2) into variables A & B and C & D Edited October 18, 2017 by RXB Quote Link to comment Share on other sites More sharing options...
+mizapf Posted October 18, 2017 Share Posted October 18, 2017 If you decided to use assembly language after all, http://atariage.com/forums/topic/270570-detecting-joystick-button-press-with-call-key0ab/?p=3865591shows you a simple tool to query those keys. Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted October 19, 2017 Share Posted October 19, 2017 You can do the same as Assembly Language with fbForth CRU words. ...lee Quote Link to comment Share on other sites More sharing options...
+TheBF Posted October 21, 2017 Share Posted October 21, 2017 I too wanted a faster way to catch a keystroke. Mine was to break out of loops without slowing the loop down too much. This is little routine will only detect a control C key press. But it could be configured to different keys. It is 4 times faster than using KSCAN. (approx. 250ms vs over 1mS) Here is the matrix I used to understand how to do it. \ R1 TB 0 TB 1 TB 2 TB 3 TB 4 TB 5 TB 6 TB 7 \ --------------------------------------------------------------------- \ 0000 = space enter fctn shift ctrl \ 0100 . L O 9 2 S W X \ 0200 , K I 8 3 D E C \ 0300 M J U 7 4 F R V \ 0400 N H Y 6 5 G T B \ 0500 / ; P 0 1 A Q Z \ 0600 Fire1 Left1 Right1 Down1 Up1 \ 0700 Fire2 Left2 Right2 Down2 Up2 \ --------------------------------------------------------------------- Written in reverse assembler. (put the instruction on the other side for conventional assembler) Weirdness: TOS is just a renamed R4. PUSH is a macro that moves the stack pointer. (SP DECT) and moves a register ( MOV R4,*SP) The method is I collect bits in R4, while looping through the keyboard rows (Register 1) When R4 = C000 I have a ctrl C pressed. So by changing that value you could detect any key. I took this code from a more general routine and I am sure it can be improved. As I look at It, I see it does not need to look at row 0100 at all for a control C. Duh! So I can speed it up more in the future. CODE: ^C? ( -- ?) \ fast check if ctrl C key pressed TOS PUSH, \ make room in TOS register TOS CLR, \ TOS will accumulate keyboard bits R1 CLR, \ R1 is column to read. starts at 0 @@1: R12 0024 LI, \ set CRU address for column select chip R1 3 LDCR, \ Set 3 bits of column R2 SETO, \ R2 gets the bits. set all bits to 1 R12 0006 LI, \ R12-address to read rows R2 8 STCR, \ store 8 column values (bits)->R2 R2 INV, \ outputs are low active so flip bits R2 TOS ADD, \ collect all the bits in TOS (R4) R1 0100 ADDI, \ advance to next row R1 0300 CMPI, \ are we at row 3? @@1 JNE, \ if not jump back SCRTO @@ CLR, \ Reset TI system screen timeout counter TOS C000 CMPI, \ look for ctrl 'C'. (2 bits set) @@2 JEQ, \ ^C was pressed TOS CLR, \ no ^C, clear TOS, return to forth NEXT, @@2: TOS SETO, \ set TOS to -1 (Forth true flag) NEXT, \ return to Forth END-CODE 1 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted October 22, 2017 Share Posted October 22, 2017 I don't mean to get in the way here, but I am used to seeing this in columns and rows opposite to your presentation as follows: \ +-----+-----------------------------------------------------------------+------------+ \ | |<------------------------- COLUMN ------------------------------>| | \ +-----+-------+-------+-------+-------+-------+-------+--------+--------+------------+ \ | ROW | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | alpha-lock | \ +-----+-------+-------+-------+-------+-------+-------+--------+--------+------------+ \ | 0 | = | . | , | M | N | / | fire1 | fire2 | | \ +-----+-------+-------+-------+-------+-------+-------+--------+--------+------------+ \ | 1 | space | L | K | J | H | ; | left1 | left2 | | \ +-----+-------+-------+-------+-------+-------+-------+--------+--------+------------+ \ | 2 | enter | O | I | U | Y | P | right1 | right2 | | \ +-----+-------+-------+-------+-------+-------+-------+--------+--------+------------+ \ | 3 | | 9 | 8 | 7 | 6 | 0 | down1 | down2 | | \ +-----+-------+-------+-------+-------+-------+-------+--------+--------+------------+ \ | 4 | fctn | 2 | 3 | 4 | 5 | 1 | up1 | up2 | alpha-lock | \ +-----+-------+-------+-------+-------+-------+-------+--------+--------+------------+ \ | 5 | shift | S | D | F | G | A | | | | \ +-----+-------+-------+-------+-------+-------+-------+--------+--------+------------+ \ | 6 | ctrl | W | E | R | T | Q | | | | \ +-----+-------+-------+-------+-------+-------+-------+--------+--------+------------+ \ | 7 | | X | C | V | B | Z | | | | \ +-----+-------+-------+-------+-------+-------+-------+--------+--------+------------+ Then it is a little less confusing (to me, at least) to change a few of your comments (not your code!) to CODE: ^C? ( -- ?) \ fast check if ctrl C key pressed TOS PUSH, \ make room in TOS register TOS CLR, \ TOS will accumulate keyboard bits R1 CLR, \ R1 is column to read. starts at 0 @@1: R12 0024 LI, \ set CRU address for column select chip R1 3 LDCR, \ Set 3 bits of column R2 SETO, \ R2 gets the bits. set all bits to 1 R12 0006 LI, \ R12-address to read rows R2 8 STCR, \ store 8 row values of current column (bits)->R2 *** R2 INV, \ outputs are low active so flip bits R2 TOS ADD, \ collect all the bits in TOS (R4) R1 0100 ADDI, \ advance to next column *** R1 0300 CMPI, \ are we at column 3? *** @@1 JNE, \ if not jump back SCRTO @@ CLR, \ Reset TI system screen timeout counter TOS C000 CMPI, \ look for ctrl 'C'. (2 bits set) @@2 JEQ, \ ^C was pressed TOS CLR, \ no ^C, clear TOS, return to forth NEXT, @@2: TOS SETO, \ set TOS to -1 (Forth true flag) NEXT, \ return to Forth END-CODE ...lee 1 Quote Link to comment Share on other sites More sharing options...
+TheBF Posted October 23, 2017 Share Posted October 23, 2017 Thanks for the corrections Lee, I will update my source code file. I don't remember where I found the table. But I know I didn't derive it all by myself. Yours appears to align with the Thierry Nouspikel Web site. So I will avail myself of yours in my source as well with credit to you as it makes more sense. Quote Link to comment Share on other sites More sharing options...
+TheBF Posted October 23, 2017 Share Posted October 23, 2017 Since I was looking at the code I re-wrote it so it does not look at column 1 by factoring the hardware reading code as a sub-routine. This further improved the speed from 336uS in the old verison to 273uS but cost 4 bytes of space. The screen capture shows the test results using the 9901 timer word 'TMR@" versus calling KSCAN (ASM word KEY? in Forth) This ctrl C reader is over 4X faster than calling KSCAN Here is the new version in case anybody finds it useful. To use this concept in TI ASM just remember that TOS is just a re-name for R4. \ sub routine to read key matrix. Set R1 to the column to read L: _RKEYS R12 0024 LI, \ set CRU address for column select chip R1 3 LDCR, \ Set 3 bits of column R2 SETO, \ R2 gets the bits. set all bits to 1 R12 0006 LI, \ R12-address to read rows R2 8 STCR, \ store 8 row values of current column (bits)->R2 *** R2 INV, \ outputs are low active so flip bits R2 TOS ADD, \ collect all the bits in TOS (R4) RT, CODE: ^C? ( -- ?) \ fast check if ctrl C key pressed TOS PUSH, \ make room in TOS register TOS CLR, \ TOS will accumulate keyboard bits R1 CLR, \ R1 is column to read. starts at 0 _RKEYS @@ BL, \ read keys in column 0 R1 0200 LI, \ set column to 2 _RKEYS @@ BL, \ read keys in column 0 SCRTO @@ CLR, \ Reset TI system screen timeout counter TOS C000 CMPI, \ look for ctrl 'C'. (2 bits set) @@2 JEQ, \ ^C was pressed TOS CLR, \ no ^C, clear TOS, return to forth NEXT, @@2: TOS SETO, \ set TOS to -1 (Forth true flag) NEXT, \ return to Forth END-CODE Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.