PlanetJanus Posted May 31, 2019 Share Posted May 31, 2019 I was playing with the code in examples/controller. (Thanks @NanoChess)I created a single controller output...mostly. The Number Pad is to the Right of the controller output.The ROM is Below. Here is the code. BORDER BORDER_BLACK CLSloop: WAIT IF cont1.up THEN PRINT AT SCREENPOS(4, 1),"U" ELSE PRINT AT SCREENPOS(4, 1),"0" IF cont1.left THEN PRINT AT SCREENPOS(3, 2),"L" ELSE PRINT AT SCREENPOS(3, 2),"0" IF cont1.right THEN PRINT AT SCREENPOS(5, 2),"R" ELSE PRINT AT SCREENPOS(5, 2),"0" IF cont1.down THEN PRINT AT SCREENPOS(4, 3),"D" ELSE PRINT AT SCREENPOS(4, 3),"0" IF cont1.b0 THEN PRINT AT SCREENPOS(3, 5),"x" ELSE PRINT AT SCREENPOS(3, 5),"0" IF cont1.b1 THEN PRINT AT SCREENPOS(4, 5),"y" ELSE PRINT AT SCREENPOS(4, 5),"0" IF cont1.b2 THEN PRINT AT SCREENPOS(5, 5),"z" ELSE PRINT AT SCREENPOS(5, 5),"0" ' KEYPAD IF NUMLOCK = 1 THEN PRINT AT SCREENPOS (11, 1), "1" ELSE PRINT AT SCREENPOS (11, 1),"X" IF NUMLOCK = 2 THEN PRINT AT SCREENPOS (13, 1), "2" ELSE PRINT AT SCREENPOS (13, 1),"X" IF NUMLOCK = 3 THEN PRINT AT SCREENPOS (15, 1), "3" ELSE PRINT AT SCREENPOS (15, 1),"X" IF NUMLOCK = 4 THEN PRINT AT SCREENPOS (11, 3), "4" ELSE PRINT AT SCREENPOS (11, 3),"X" IF NUMLOCK = 5 THEN PRINT AT SCREENPOS (13, 3), "5" ELSE PRINT AT SCREENPOS (13, 3),"X" IF NUMLOCK = 6 THEN PRINT AT SCREENPOS (15, 3), "6" ELSE PRINT AT SCREENPOS (15, 3),"X" IF NUMLOCK = 7 THEN PRINT AT SCREENPOS (11, 5), "7" ELSE PRINT AT SCREENPOS (11, 5),"X" IF NUMLOCK = 8 THEN PRINT AT SCREENPOS (13, 5), "8" ELSE PRINT AT SCREENPOS (13, 5),"X" IF NUMLOCK = 9 THEN PRINT AT SCREENPOS (15, 5), "9" ELSE PRINT AT SCREENPOS (15, 5),"X" IF NUMLOCK = 88 THEN PRINT AT SCREENPOS (11, 7), "A" ELSE PRINT AT SCREENPOS (11, 7),"X" 'zero key IF NUMLOCK = 0 THEN PRINT AT SCREENPOS (13, 7), "0" ELSE PRINT AT SCREENPOS (13, 7),"X" 'period/delete key IF NUMLOCK = 100 THEN PRINT AT SCREENPOS (15, 7), "E" ELSE PRINT AT SCREENPOS (15, 7),"X" 'enterkey a=cont1 PRINT AT 183 b=a/16 GOSUB hex b=a GOSUB hex a=cont1.key PRINT AT 141,"key " b=a/16 GOSUB hex b=a: NUMLOCK = B 'PRINT AT SCREENPOS (13, 9), B GOSUB hex GOTO LOOPhex: PROCEDURE b = b and 15 b = b + "0" if b > "9" then b=b+7 PRINT b*8+7 RETURN END InfiniteLoop: GOTO InfiniteLoop_____________________________________________________________________________________________________________________________I don't understand what the HEX subroutine is for? Converting the numberpad into hexidecimal perhaps? Why is this important enough to be exemplified?The ZERO and ENTER key of the KEYPAD do not work and just have dummy numbers in place. The output of the key for ZERO is 88 and listed as button A. The output for ENTER is 28 and listed as button B. i was unable to find a numerical output that works.Button C or the output C is constantly running, so is that "C" a "C button" or indicative of "Clear" meaning no input from keyboard? Quote Link to comment Share on other sites More sharing options...
carlsson Posted June 1, 2019 Share Posted June 1, 2019 The hex routine is to print a decimal number 0-255 as a hexadecimal number 00-FF. The input value might consist of two groups of 4 bits each, which makes hexadecimal easier to read for those who understand it, than a decimal number. Binary would be most obvious but takes far more space on the screen. 1 Quote Link to comment Share on other sites More sharing options...
PlanetJanus Posted June 3, 2019 Author Share Posted June 3, 2019 Thanks Carlson,I was thinking about hexidecimal and the letter C.many programs to check to see no input is incoming from the controller put in the line:IF cont1.key <> 12 then [...] "C" is 12 in hexidecimal, so the key pad is always emitting a value of 12 in hexidecimal when nothing is being pressed. 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.