LASooner Posted October 2, 2017 Share Posted October 2, 2017 (edited) Is there a way to detect a Joystick button press using CALL KEY 0? I'm using the whole keyboard for other aspects of the game, and there seems to be a noticeable performance drop when I use two CALL KEY commands just to detect JOY 1's button being pressed. Edited October 2, 2017 by LASooner Quote Link to comment Share on other sites More sharing options...
RXB Posted October 2, 2017 Share Posted October 2, 2017 RXB has a command CALL IO that scans the keyboard CRU bits and can detect on a REAL TI99/4A up to 4 keys pressed at same time and report different values for each of two variables. You get two values and by interpreting each value you get to see all the keys being pressed. CALL KEY in RXB is much more advanced than Basic or XB: CALL ONKEY in RXB that has an IF X THEN ON GOTO line-number,line-number,line-number.............so on Now this RXB demo only really works on a REAL TI99/4A as Emulator do not duplicate the CRU on keyboards accurately. Also this RXB Demo only detects keys FCTN, CTRL, SHIFT, ENTER and Space Bar though it could have been set up to detect more keys I simplified it. 100 DISPLAY AT(1,1)ERASE ALL:"THIS PROGRAM CHECKS FOR UNUSUAL KEYS BEING PRESSED, EVEN IF MORE THEN FOUR KEYS ARE BEING PRESSED AT ONCE" 110 CALL IO(2,16,3,A,B) :: IF A=18 AND B=255 THEN 110 ELSE CALL HPUT(24,3,RPT$(" ",30),24,24,STR$(A)&" "&STR$(B)) 120 IF A=146 THEN CALL HPUT(24,3,"FUNCTION KEY")ELSE IF B=191 THEN CALL HPUT(24,3,"CONTROL KEY")ELSE IF B=223 THEN CALL HPUT(24,3,"SHIFT KEY") 130 IF B=251 THEN CALL HPUT(24,3,"ENTER KEY")ELSE IF B=253 THEN CALL HPUT(24,3,"SPACE BAR")ELSE IF B=254 THEN CALL HPUT(24,3,"PLUS/EQUAL KEY") 140 GOTO 110 1 Quote Link to comment Share on other sites More sharing options...
Tursi Posted October 2, 2017 Share Posted October 2, 2017 Is there a way to detect a Joystick button press using CALL KEY 0? I'm using the whole keyboard for other aspects of the game, and there seems to be a noticeable performance drop when I use two CALL KEY commands just to detect JOY 1's button being pressed. Without the direct access available in RXB, no. Modes 3,4, and 5 scan the main keyboard but omit the joystick port (and 0 defaults to 5). Only modes 1 and 2 scan the joystick port (as well as half the keyboard). Now this RXB demo only really works on a REAL TI99/4A as Emulator do not duplicate the CRU on keyboards accurately. That has more to do with how PC keyboards work than emulators. 2 Quote Link to comment Share on other sites More sharing options...
+mizapf Posted October 2, 2017 Share Posted October 2, 2017 (edited) Now this RXB demo only really works on a REAL TI99/4A as Emulator do not duplicate the CRU on keyboards accurately. Well, it does work on MAME in the sense that multiple keys can be detected (until, as Tursi implied, the keyboard rollover (https://en.wikipedia.org/wiki/Rollover_(key) ) is exceeded). When I press Ctrl + Enter + Plus, I get a 186 from CALL IO in B (binary 10111010, i.e. three 0 indicating three pressed keys). However, I am a bit puzzled about the IO output. I suppose it reads up to 16 bits into the two variables, starting with the LSB of the second variable. But why does FCTN change variable A? The FCTN line is CRU bit 7, so it should affect the 5th bit from the right, hence in B. BTW, here is RXB 2015 as an RPK. rxb_2015.rpk Edited October 2, 2017 by mizapf 1 Quote Link to comment Share on other sites More sharing options...
RXB Posted October 3, 2017 Share Posted October 3, 2017 That has more to do with how PC keyboards work than emulators. Sorry I stand corrected, my mistake. Quote Link to comment Share on other sites More sharing options...
RXB Posted October 3, 2017 Share Posted October 3, 2017 Well, it does work on MAME in the sense that multiple keys can be detected (until, as Tursi implied, the keyboard rollover (https://en.wikipedia.org/wiki/Rollover_(key) ) is exceeded). When I press Ctrl + Enter + Plus, I get a 186 from CALL IO in B (binary 10111010, i.e. three 0 indicating three pressed keys). However, I am a bit puzzled about the IO output. I suppose it reads up to 16 bits into the two variables, starting with the LSB of the second variable. But why does FCTN change variable A? The FCTN line is CRU bit 7, so it should affect the 5th bit from the right, hence in B. BTW, here is RXB 2015 as an RPK. Part of the issue I assume is two variables are 16 bits and CRU is only 12 bits, I do not right justify the bits so unfilled bits may be in the wrong locations in RXB CALL IO Quote Link to comment Share on other sites More sharing options...
+mizapf Posted October 3, 2017 Share Posted October 3, 2017 Still, what I don't understand is why in RXB in MAME the FCTN key appears somewhere else. For that reason, your program from above does not detect FCTN, and the polling loop is exited every time (because A != 18). The following assembly language program delivers the reaction at the proper place. * * TOOL FOR READING THE 9901 LINES * MICHAEL ZAPF * DEF RUN REF VMBW,VWTR TEXT TEXT 'READING THE 9901 LINES' RUN CLR R0 BL @SETADR LI R2,960 LI R1,>2000 CLEAR MOVB R1,@>8C00 DEC R2 JNE CLEAR LI R0,>01F0 BLWP @VWTR LI R0,>07B1 BLWP @VWTR LI R0,>0078 LI R1,TEXT LI R2,22 BLWP @VMBW LI R4,>0020 LI R12,>0024 CLR R5 LDCR R5,3 CLR R12 START LI R0,>01E0 BL @SETADR BACK STCR R1,0 LI R2,16 LOOP1 SRL R1,1 JOC ITS1 LI R3,>3000 JMP PRDIG ITS1 LI R3,>3100 PRDIG MOVB R3,@>8C00 DEC R2 JNE LOOP1 XOR R4,R12 JEQ START LIMI 2 LIMI 0 JMP BACK SETADR ORI R0,>4000 SWPB R0 MOVB R0,@>8C02 SWPB R0 MOVB R0,@>8C02 RT END RUN 1 Quote Link to comment Share on other sites More sharing options...
RXB Posted October 3, 2017 Share Posted October 3, 2017 (edited) Still, what I don't understand is why in RXB in MAME the FCTN key appears somewhere else. For that reason, your program from above does not detect FCTN, and the polling loop is exited every time (because A != 18). The following assembly language program delivers the reaction at the proper place. * * TOOL FOR READING THE 9901 LINES * MICHAEL ZAPF * DEF RUN REF VMBW,VWTR TEXT TEXT 'READING THE 9901 LINES' RUN CLR R0 BL @SETADR LI R2,960 LI R1,>2000 CLEAR MOVB R1,@>8C00 DEC R2 JNE CLEAR LI R0,>01F0 BLWP @VWTR LI R0,>07B1 BLWP @VWTR LI R0,>0078 LI R1,TEXT LI R2,22 BLWP @VMBW LI R4,>0020 LI R12,>0024 CLR R5 LDCR R5,3 CLR R12 START LI R0,>01E0 BL @SETADR BACK STCR R1,0 LI R2,16 LOOP1 SRL R1,1 JOC ITS1 LI R3,>3000 JMP PRDIG ITS1 LI R3,>3100 PRDIG MOVB R3,@>8C00 DEC R2 JNE LOOP1 XOR R4,R12 JEQ START LIMI 2 LIMI 0 JMP BACK SETADR ORI R0,>4000 SWPB R0 MOVB R0,@>8C02 SWPB R0 MOVB R0,@>8C02 RT END RUN On real iron the CALL IO works fine and even detects both CTRL, FCTN and SHIFT keys on different CRU addresses. After all you can pick which key line per CRU to scan. My original CRU KEY SCAN using CALL IO in RXB 2001 I demoed at the Chicago Faire could detect which FCTN/SHIFT/CTRL key you pressed left or right side of SPACE BAR. Of course this DEMO was huge as it had to do more then 5 different CRU scans and a ton of IF A=value THEN show key. Do you think the CALL IO values are wrong? Edited October 3, 2017 by RXB Quote Link to comment Share on other sites More sharing options...
+mizapf Posted October 3, 2017 Share Posted October 3, 2017 I'm not sure what's wrong. In fact, if I do a CALL IO(2,16,3,A,B) in RXB 2015 (on MAME), I get A=86 and B=255 when no key is pressed, and this differs from 18 and 255 as you seem to expect in your program. 18 = (00010010) 86 = (01010110) I have two extra ones, and I'd like to find out where they come from. FCTN is A=146 in your program, and here I get A=214. 146 = (10010010) 214 = (11010110) The same here: My result differs by the byte 0x44 = (01000100) Can you say what CRU bits correspond to these ones? Quote Link to comment Share on other sites More sharing options...
RXB Posted October 4, 2017 Share Posted October 4, 2017 I'm not sure what's wrong. In fact, if I do a CALL IO(2,16,3,A,B) in RXB 2015 (on MAME), I get A=86 and B=255 when no key is pressed, and this differs from 18 and 255 as you seem to expect in your program. 18 = (00010010) 86 = (01010110) I have two extra ones, and I'd like to find out where they come from. FCTN is A=146 in your program, and here I get A=214. 146 = (10010010) 214 = (11010110) The same here: My result differs by the byte 0x44 = (01000100) Can you say what CRU bits correspond to these ones? Yea in Classic99 using CALL IO(2,16,3,A,B) I get A=95 and B=255 from just edit mode or program mode? When I wrote the programs to check keys I just did a test program of 100 CALL IO(2,16,3,A,B) 110 PRINT A,B 120 CALL KEY("",0,K,S) 130 GOTO 100 What is get is most keys are A=95 and B=255 FCTN 3 - A=223 B=255 FCTN 5 - A=223 B=255 FCTN 6 - A=223 B=255 ` - A=223 B=255 ~ - A=223 B=255 - - A=92 B=254 _ - A=223 B-251 = - A=95 B=254 + - A=95 B=222 DEL - A=223 B=255 TAB - A=223 B=247 [ - A=223 B=191 { - A=223 B=223 ] - A=223 B=255 } - A=223 B=255 \ - A=223 B=255 | - A=223 B=255 ; - A=223 B=255 " - A=223 B=255 ENTER- A=95 B=251 SPACE- A=95 B=253 ARROWS all A=223 B=255 I never considered the values they are supposed to show, guess I should look into why these are returned? Quote Link to comment Share on other sites More sharing options...
+mizapf Posted October 10, 2017 Share Posted October 10, 2017 Could you show me the source code of the IO subprogram? Quote Link to comment Share on other sites More sharing options...
RXB Posted October 10, 2017 Share Posted October 10, 2017 Could you show me the source code of the IO subprogram? RXB GPL Source: ************************** RXBIO CALL SPNUM1 * IO IOAGN CALL GETNUM * TYPE 0-6 CHE >07,@FAC1 BS ERRBV ST @FAC1,@VARY CALL SUBLP3 * ADDRESS/ CASE @VARY * BITS/BYTES BR SOG BR SOV BR CRUI BR CRUO BR CSW BR CSR BR CSV SOG I/O 0,@FAC BR IODONE SOV I/O 1,@FAC BR IODONE CRUI CALL CRUSET I/O 2,@VAR4 XML PGMCHR CALL SNDER CALL CLRFAC ST @VAR0,@FAC1 CALL CIFSND * VARIABLE1 CHE >09,@VARY BS CRUI16 BR IODONE CRUI16 XML PGMCHR CALL SNDER CALL CLRFAC ST @VAR1,@FAC1 CALL CIFSND * VARIABLE2 BR IODONE CRUO CALL CRUSET CALL SUBLP3 * VARIABLE1 DCHE >0100,@FAC BS ERRBV CHE >09,@VARY BS CRUO16 ST @FAC1,@VAR0 BR CRUO8 CRUO16 DST @FAC,@VAR0 CALL SUBLP3 * VARIABLE2 DCHE >0100,@FAC BS ERRBV ST @FAC1,@VAR1 CRUO8 I/O 3,@VAR4 BR IODONE CSW CALL CSLOAD I/O 4,@VAR4 BR IODONE CSR CALL CSLOAD I/O 5,@VAR4 BR IODONE CSV CALL CSLOAD I/O 6,@VAR4 IODONE CEQ >B3,@CHAT BS IOAGN BR LNKRTN CRUTMP DST @FAC,@VAR4 DCLR @VAR5 DCLR @VAR0 RTN CRUSET CZ @FAC1 BS ERRBV CHE >11,@FAC BS ERRBV ST @FAC1,@VARY CALL SUBLP3 * CRU-ADDRESS CALL CRUTMP ST @VARY,@VAR5 RTN CSLOAD CALL CRUTMP CALL SUBLP3 * ADDRESS DST @FAC,@VAR5 RTN ******************************* ****************************** * SPNUM1 ROUTINE * ****************************** SPNUM1 CEQ LPARZ,@CHAT Should be "(" BR ERRSYN RTN ****************************** ************************************************************ STRFCH XML PGMCHR XML PARSE BYTE RPARZ RTN STRGET CALL STRFCH CEQ >65,@FAC2 BR ERRSNM * STRING NUM MISMATCH RTN NUMFCH CALL STRFCH CEQ >65,@FAC2 BS ERRSNM * STRING NUM MISMATCH RTN CFIFCH XML CFI CEQ >03,@FAC+10 BS ERRBV * NUMERIC OVERFLOW RTN GETNUM CALL SUBLP3 CEQ >B3,@CHAT BR ERRSYN RTN ROWCOL CALL GETNUM DCGT 24,@FAC BS ERRBV DDEC @FAC ST @XPT,@MNUM ST @FAC1,@YPT CALL GETNUM DCGT 32,@FAC BS ERRBV DDEC @FAC ST @FAC1,@XPT RTN NGOOD XML PGMCHR NGOOD1 CHE >80,@CHAT BS ERRSYN * ? CALL SNDER CEQ >65,@FAC2 BR ERRSNM * STRING NUMBER MISMATCH DST >001C,@FAC DST @SREF,@FAC4 DST @BYTES,@FAC6 BR SNDASS SNDER XML SYM XML SMB XML VPUSH RTN CIFSND XML CIF SNDASS XML ASSGNV RTN GETLP ST @CB,@VAR0 ST @CB,@VAR1 SUB OFFSET,@VAR1 ST @VAR1,V@0(@STRPTR) DINC @STRPTR RTN PUTLP ST V@0(@FAC4),@VAR0 ADD OFFSET,@VAR0 DINC @FAC4 RTN HFMT FMT DATA >E000 FEND RTN VFMT FMT DATA >E000 BYTE >9E FEND RTN SUBLP3 CALL NUMFCH CALL CFIFCH RTN CLRFAC CLR @FAC MOVE 7,@FAC,@FAC1 RTN *********************************************************** Quote Link to comment Share on other sites More sharing options...
+mizapf Posted October 11, 2017 Share Posted October 11, 2017 Here is an updated version of my 9901 query tool. You can see the effects of different key presses. (Note that in MAME, this will only work with the "emulated keyboard", not with the "natural keyboard", which is a known limitation of the natural keyboard.) I can't make sense of the IO subprogram output, but I cannot tell where the problem is. The FCTN key should be found at CRU bit 7 in mode 0 (8th digit from the left in the upper (long) row). Try to transfer the attached source code to your real computer. Accordingly, this line should be queried with a CALL IO(2,1,7,A), but this does not work. On the other hand, a CALL IO(2,1,8,A) correctly detects the Shift key. I checked your IO source code, but I could not find any (obvious) error. Unfortunately, it is virtually impossible to debug GPL with MAME (because it cannot know that there is a virtual machine inside the TI). * * TOOL FOR READING THE 9901 LINES * MICHAEL ZAPF * DEF RUN TEXT TEXT 'READING THE 9901 LINES' LABEL TEXT 'MODE=' RUN CLR R0 BL @SETADR LI R2,960 LI R1,>2000 CLEAR MOVB R1,@>8C00 DEC R2 JNE CLEAR LI R0,>01F0 BL @SETREG LI R0,>07B1 BL @SETREG LI R0,>0078 LI R1,TEXT LI R2,22 BL @SETADR TL0 MOVB *R1+,@>8C00 DEC R2 JNE TL0 LI R0,>0168 LI R1,LABEL LI R2,5 BL @SETADR TL1 MOVB *R1+,@>8C00 DEC R2 JNE TL1 LI R3,>3000 LI R4,>016D TL2 MOV R4,R0 BL @SETADR MOVB R3,@>8C00 AI R4,40 AI R3,>0100 CI R3,>3800 JNE TL2 CLR R4 LOOP1 LI R12,>0024 LDCR R4,3 MOV R4,R4 JNE KEYB LI R0,>0170 FIRST LINE BL @SETADR BL @SHOWCR DATA >0000,16 BL @SHOWCR DATA >0020,16 LI R5,>0173 JMP LOOP2 KEYB BL @SHOWCR DATA >0006,8 LOOP2 AI R5,40 MOV R5,R0 BL @SETADR AI R4,>0100 ANDI R4,>0700 LIMI 2 LIMI 0 JMP LOOP1 * * SHOWCR: SHOW CRU BITS ACCORDING TO DATA * H30 BYTE >30 H31 BYTE >31 SHOWCR MOV *R11+,R12 MOV *R11+,R1 MOV R11,R10 STCR R2,0 CI R1,8 JHE SHOWLP SRL R2,8 SHOWLP SRL R2,1 JNC ITS0 MOVB @H31,@>8C00 JMP ITS1 ITS0 MOVB @H30,@>8C00 ITS1 DEC R1 JNE SHOWLP MOV R10,R11 RT SETADR ORI R0,>4000 JMP S1 SETREG ORI R0,>8000 S1 SWPB R0 MOVB R0,@>8C02 SWPB R0 MOVB R0,@>8C02 RT END RUN 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.