>From Kim Holviala kim at holviala.com Wed Feb 23 2011 Yup, got my side project, the Atari/Commodore joystick interface for M100 working reliably.
This is a simple passive interface only requiring two connectors, some cable and five diodes. Total cost is under $10 including a case for the Sub-D9 connector. Schematic: LPT port D9 male 3 PD0 ------|<------- 1 UP 5 PD1 ------|<------- 2 DOWN 7 PD2 ------|<------- 3 LEFT 9 PD3 ------|<------- 4 RIGHT 11 PD4 ------|<------- 6 BUTTON 21 BUSY -------------- 8 GROUND Parts: 1 2x13 pin female flat cable connector (0.1" spacing) 1 D9 male connector (solder type) 1 D9 connector case 6" 26-pin flat cable (or at least 4 inches) 5 1N4148 (or similar) I used 1N4007 for the diodes, but using something physically smaller like 1N4148 is easier if you want to fit everything into the D9 case. Theory of operation: We're doing it all backwards. Instead of feeding ground through joystick port pin 8 and reading the directions from pins 1-4 and 6, we're feeding signals through 1-4 and 6 and reading the result from pin 8 (which is connected to BUSY in LPT port). Using with 100% Basic: This works (even though it shouldn't) but isn't very reliable. We're fighting with the keyboard interrupt, and quite often it hits between our OUT and IN messing up the readings. OUT 185,254:U=INP(187) AND 4 OUT 185,253:D=INP(187) AND 4 OUT 185,251:L=INP(187) AND 4 OUT 185,247:R=INP(187) AND 4 OUT 185,239:B=INP(187) AND 4 Variables U/D/L/R and B now contain 0 if that particular direction is selected and 4 if the direction is not selected. Mostly Basic, but some assembly required: This version seems to be 100% reliable even though it doesn't disable interrupts between the assembler out and in. 10 CLS 20 A$=CHR$(211)+CHR$(185)+CHR$(219)+CHR$(187)+CHR$(119)+CHR$(201) 30 AS=PEEK(VARPTR(A$)+1)+(256*PEEK(VARPTR(A$)+2)) 40 U%=0:D%=0:L%=0:R%=0:B%=0 50 CALL AS,254,VARPTR(U%):U%=U% AND 4 60 CALL AS,253,VARPTR(D%):D%=D% AND 4 70 CALL AS,251,VARPTR(L%):L%=L% AND 4 80 CALL AS,247,VARPTR(R%):R%=R% AND 4 90 CALL AS,239,VARPTR(B%):B%=B% AND 4 100 IF U%=0 THEN PRINT " U" ELSE PRINT " *" 110 IF L%=0 THEN PRINT "L "; ELSE PRINT "* "; 120 IF R%=0 THEN PRINT "R" ELSE PRINT "*" 130 IF D%=0 THEN PRINT " D" ELSE PRINT " *" 140 IF B%=0 THEN PRINT "BTN" ELSE PRINT " * " 150 PRINT CHR$(11); 160 GOTO 50 The assembler code on line 20 is as follows (needs a bitmask in A, outputs joystick info to [HL]): out 185 in 187 mov m,a ret That's about it. Now back to the WiFi adapter... - Kim ----- Original Message ----- From: Brian White To: [email protected] Sent: Tuesday, January 05, 2021 7:16 AM Subject: Re: [M100] Joystick for the M100 On Mon, Jan 4, 2021, 2:55 PM Jim Anderson <[email protected]> wrote: > -----Original Message----- > For input, there are only 2 signals, BUSY and BUSY_N. Each of these can > be read independenty. As I recall, the way it worked was that the five switches (directional switches and fire) were wired to the first five output bits, and the common return from all five switches was wired to BUSY. To poll the joystick you'd cycle through outputting ASCII 1, 2, 4, 8, and 16, and read BUSY each time. Whichever bits resulted in assertion of BUSY meant that switch was currently closed. Nice. -- bkw
