DEV-SNIP #1 - Input

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: DEV-SNIP #1 - Input

Post 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 :(
User avatar
BarryN
Posts: 151
Joined: Thu Nov 09, 2017 11:34 pm

Re: DEV-SNIP #1 - Input

Post 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?
User avatar
1024MAK
Posts: 5087
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: DEV-SNIP #1 - Input

Post 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
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.
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: DEV-SNIP #1 - Input

Post 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.
User avatar
mrtinb
Posts: 1905
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: DEV-SNIP #1 - Input

Post 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.)
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: DEV-SNIP #1 - Input

Post 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
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: DEV-SNIP #1 - Input

Post 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
what's that Smell.... smells like fresh flux and solder fumes...
Post Reply