Joystick and Joystick Interface Testing

Post Reply
User avatar
1024MAK
Posts: 5103
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Joystick and Joystick Interface Testing

Post 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
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
User avatar
1024MAK
Posts: 5103
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Joystick and Joystick Interface Testing

Post 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
Attachments
Joystick and Interface Testing.tap.zip
Joystick and Interface Testing.tap
(1.3 KiB) Downloaded 503 times
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
McKlaud
Posts: 337
Joined: Tue Dec 19, 2017 10:02 pm
Location: St Albans, UK

Re: Joystick and Joystick Interface Testing

Post by McKlaud »

Hi Mark :)

Small but useful items, thanks.
Claudius
----------
albertusj
Posts: 77
Joined: Sat Aug 18, 2012 12:44 am
Location: Somerset-West, South-Africa
Contact:

Re: Joystick and Joystick Interface Testing

Post by albertusj »

How would one alter the KEMPSTON test program for 4K BASIC on the ZX80?
ZX80/ZX81/ZX Spectrum
User avatar
1024MAK
Posts: 5103
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Joystick and Joystick Interface Testing

Post 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
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
albertusj
Posts: 77
Joined: Sat Aug 18, 2012 12:44 am
Location: Somerset-West, South-Africa
Contact:

Re: Joystick and Joystick Interface Testing

Post by albertusj »

That's fine. Thank you.
ZX80/ZX81/ZX Spectrum
albertusj
Posts: 77
Joined: Sat Aug 18, 2012 12:44 am
Location: Somerset-West, South-Africa
Contact:

Re: Joystick and Joystick Interface Testing

Post 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
ZX80/ZX81/ZX Spectrum
albertusj
Posts: 77
Joined: Sat Aug 18, 2012 12:44 am
Location: Somerset-West, South-Africa
Contact:

Re: Joystick and Joystick Interface Testing

Post 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.... ;)
ZX80/ZX81/ZX Spectrum
albertusj
Posts: 77
Joined: Sat Aug 18, 2012 12:44 am
Location: Somerset-West, South-Africa
Contact:

Re: Joystick and Joystick Interface Testing

Post 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.
ZX80/ZX81/ZX Spectrum
Post Reply