Page 1 of 1

Joystick and Joystick Interface Testing

Posted: Sat Jun 09, 2018 4:06 pm
by 1024MAK
The simplest Kempston joystick interface test program is:-

Code: Select all

10 PRINT AT 0,0;IN 31,
20 GO TO 10
A more sophisticated program is this one:-

Code: Select all

 1 REM A 1024MAK program
 5 PRINT "Kempston Joystick Testing"
10 LET J=IN 31
20 IF J>31 THEN LET J=J-32: GO TO 20
30 PRINT AT 2,0;J,
40 IF J=1 THEN PRINT "Right",
50 IF J=2 THEN PRINT "Left",
60 IF J=4 THEN PRINT "Down",
70 IF J=8 THEN PRINT "Up",
80 IF J=16 THEN PRINT "Fire",
90 PRINT ,
100 GO TO 10
900 SAVE "Kempston"
To test a joystick interface that uses the Sinclair standard, use:

Code: Select all

 1 REM A 1024MAK program
 5 PRINT "Sinclair Joystick Testing"
10 LET J$=INKEY$
20 IF J$<"0" OR J$>"9" THEN PRINT AT 2,0,,: GO TO 10
30 PRINT AT 2,0;J$,
40 IF J$="1" OR J$="6" THEN PRINT "Left"
50 IF J$="2" OR J$="7" THEN PRINT "Right"
60 IF J$="3" OR J$="8" THEN PRINT "Down"
70 IF J$="4" OR J$="9" THEN PRINT "Up"
80 IF J$="5" OR J$="0" THEN PRINT "Fire"
100 GO TO 10
900 SAVE "Sinclair"
This will also test Cursor joystick interfaces, but the directions/fire button details will be wrong.

Some years ago I also wrote this test program:-

This is useful for testing interfaces that conform to the Sinclair Interface 2 standard:

Code: Select all

   1 REM A 1024MAK program
   5 PRINT AT 3,0;"76543210            76543210"
  10 LET a=IN 61438
  11 LET b=IN 63486
  12 LET k$=INKEY$
  13 IF k$="Q" OR k$="q" THEN GO TO 9999
  14 LET num=a
  15 GO SUB 1000
  16 LET c$=b$
  22 LET num=b
  24 GO SUB 1000
  50 PRINT AT 4,0 ;c$;" ";a;"  ";
  55 PRINT AT 4,20 ;b$;" ";b;"  ";
  70 GO TO 10
1000 REM convert to bin
1010 REM takes number in num and returns bin number in b$
1020 LET b$="00000000"
1030 IF num<1 OR num >255 THEN RETURN 
1040 IF num>=128 THEN LET num=INT (num-128) : LET b$(1)="1"
1050 IF num>=64 THEN LET num=INT (num-64) : LET b$(2)="1"
1060 IF num>=32 THEN LET num=INT (num-32) : LET b$(3)="1"
1070 IF num>=16 THEN LET num=INT (num-16) : LET b$(4)="1"
1080 IF num>=8 THEN LET num=INT (num-8) : LET b$(5)="1"
1090 IF num>=4 THEN LET num=INT (num-4) : LET b$(6)="1"
1100 IF num>=2 THEN LET num=INT (num-2) : LET b$(7)="1"
1110 IF num=1 THEN LET b$(8)="1"
1170 RETURN 
Mark

Re: Joystick and Joystick Interface Testing

Posted: Sat Jun 09, 2018 5:53 pm
by 1024MAK
All but the simple Kempston test program in the above post are included in the attached file (Joystick and Interface Testing.tap.zip) plus two bonus programs :D

Mark

Re: Joystick and Joystick Interface Testing

Posted: Sat Jun 09, 2018 10:15 pm
by McKlaud
Hi Mark :)

Small but useful items, thanks.

Re: Joystick and Joystick Interface Testing

Posted: Sun Jul 07, 2019 2:59 pm
by albertusj
How would one alter the KEMPSTON test program for 4K BASIC on the ZX80?

Re: Joystick and Joystick Interface Testing

Posted: Mon Jul 08, 2019 1:20 am
by 1024MAK
albertusj wrote: Sun Jul 07, 2019 2:59 pm How would one alter the KEMPSTON test program for 4K BASIC on the ZX80?
You need some machine code, because neither ZX80 or ZX81 BASIC has the IN function.
By some, I think it is just two or three lines of machine code. I have done it for the ZX81 in the past, back when I confirmed that a Kempston joystick interface would work with a ZX81.

I’ll get back to you on this, but it will not be until Tuesday or Wednesday.

Mark

Re: Joystick and Joystick Interface Testing

Posted: Mon Jul 08, 2019 10:33 am
by albertusj
That's fine. Thank you.

Re: Joystick and Joystick Interface Testing

Posted: Mon Jul 08, 2019 3:18 pm
by albertusj
I think I found what I need to use:
http://www.myprius.co.za/projects.zip
Easy Add-on Projects for Spectrum, ZX81 and Ace
pages 27, 174

Re: Joystick and Joystick Interface Testing

Posted: Mon Jul 08, 2019 7:57 pm
by albertusj
I tried the program on page 175, but only get 16514 printed on the screen. I had to add brackets to the USR command, so perhaps there are other ZX80 4K BASIC specific things I'm missing. The address for the joystick is 1F=31.

Maybe I should just test it on my ZX81 or Spectrum.... ;)

Re: Joystick and Joystick Interface Testing

Posted: Tue Jul 09, 2019 12:42 pm
by albertusj
Tested and it works beautifully on my Spectrum. I'd still like to test it on my ZX80. Obviously, the hardware works but I'd still like to see how one would do it on a ZX80 with 4K BASIC.