Page 3 of 3

Re: DEV-SNIP #1 - Input

Posted: Tue Nov 14, 2017 9:59 pm
by sirmorris
Even getting the joystick value IN() isn't the end of it - most of the problem using joysticks from BASIC is the lack of bitwise logic :(

Re: DEV-SNIP #1 - Input

Posted: Tue Nov 14, 2017 10:13 pm
by BarryN
Some quotes and information from the ZXpand+ manual:

One way to read the joystick data from BASIC is by using the following code:
LET J = USR(8190)
Each bit in the variable J, as used in the example above, represents a direction or button.
Bit Meaning
7 up/forward
6 down/back
5 left
4 right
3 fire
Unfortunately ZX81 BASIC lacks bitwise operators, so decoding this value may be tedious.
Another way to get joystick input in BASIC is to use the INKEY$ integration which is setup using the CONFIG "J=udlrf" command where the lower case letters udlrf should be substituted with the keys you want for up, down, left, right, and fire, respectively. Unfortunately this ONLY works with INKEY$ and ONLY when the ZXpand rom is active.

So I guess what is needed is to disassemble the routine in the ZXpand rom at 8190 and see what it is doing if we want to be able to properly support it from machine code without having the program crash on machines without a ZXpand?

Re: DEV-SNIP #1 - Input

Posted: Tue Nov 14, 2017 10:15 pm
by 1024MAK
sirmorris wrote: Tue Nov 14, 2017 9:59 pm Even getting the joystick value IN() isn't the end of it - most of the problem using joysticks from BASIC is the lack of bitwise logic :(
Aye, but that problem has always been a limitation of both ZX81 and ZX Spectrum BASIC. It also makes reading the keyboard directly a pain.

Mark

Re: DEV-SNIP #1 - Input

Posted: Tue Nov 14, 2017 10:44 pm
by sirmorris
I know a fair bit about the ZXpand ROM - I'm happy to tell y'all :lol:

I alluded to the answer to this in my reply to Martin, we'd just use the low-level command protocol to request a joystick read then INput the data. On a machine without ZXpand you'd effectively end up reading the value $ff, the equivalent of no input detected.

Re: DEV-SNIP #1 - Input

Posted: Wed Nov 15, 2017 6:19 am
by mrtinb
A Pragmatic solution would be:

INPUT “USE JOYSTICK? [K]EMPSTON [Z]XPAND [N]ONE”;N$

(And please DON’T make 10 different .P files depending on hardware combinations. Just ask the user on the screen instead of complex hardware detection routines that might crash on other hardware anyway.)

Re: DEV-SNIP #1 - Input

Posted: Wed Nov 15, 2017 9:13 am
by sirmorris
mrtinb wrote: Wed Nov 15, 2017 6:19 amplease DON’T make 10 different .P files depending on hardware combinations
I completely agree with this. One P to rule them all :D

Re: DEV-SNIP #1 - Input

Posted: Wed Nov 15, 2017 9:45 am
by Andy Rea
Well for zxpand joystick input, near the start of my program i tested to see if zxpand is present, the code for this will not crash a not zxpand machine, and then set a flag accordingly. Later on during user input routine the flag is tested and joystick input skipped if zxpand not present.

Regards Andy