Atari joystick without ZXpand+

Discussions about Sinclair ZX80 and ZX81 Hardware
User avatar
msknight
Posts: 386
Joined: Fri Dec 15, 2023 8:26 pm
Location: Sussex, UK

Re: Atari joystick without ZXpand+

Post by msknight »

Ah. That makes sense. So the ZXpand+ is its own API and isn't using INKEY$.
User avatar
msknight
Posts: 386
Joined: Fri Dec 15, 2023 8:26 pm
Location: Sussex, UK

Re: Atari joystick without ZXpand+

Post by msknight »

The manual stated something which made me assume that it was... so I obviously misunderstood it.
INKEY$ can be used to detect the 4 ordinal directions of an attached joystick. No diagonals are usable at this time. The default joystick codes are 6, 7, 5, 8 and 0 which map to the cursor directions.
User avatar
Paul
Posts: 1517
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: Atari joystick without ZXpand+

Post by Paul »

Inkey can only use single keys.
But the ROM reads the keyboard by eight IN commands. Each can have five keys detected which makes the 40 keys.
Games can do the same.
But even with inkey you can use more directions.
If the game takes T for up and V for down, F for left and G for right then R might be up&left, C down&left, B down&right and Y up&right.
Joy81 supports this
In theory, there is no difference between theory and practice. But, in practice, there is.
User avatar
msknight
Posts: 386
Joined: Fri Dec 15, 2023 8:26 pm
Location: Sussex, UK

Re: Atari joystick without ZXpand+

Post by msknight »

That's all good information. Many thanks.

I'm still left with the question of why I told the ZXPand+ to use the keys for Mazogs, but yet still had to download a version altered for joystick so it would work with the spand... if the spand is using inkey.

...or was Mazogs not using inkey and calling the ROM instead?
User avatar
Paul
Posts: 1517
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: Atari joystick without ZXpand+

Post by Paul »

Of that I'm not Shure.
But if mazogs didn't work without altering then it doesn't look into the systemvariable LASTK (which inkey does) but either uses the ROM call or own routines.
In theory, there is no difference between theory and practice. But, in practice, there is.
User avatar
msknight
Posts: 386
Joined: Fri Dec 15, 2023 8:26 pm
Location: Sussex, UK

Re: Atari joystick without ZXpand+

Post by msknight »

Just to let you know... Kelly has responded to me, so things will move forward :-)
User avatar
1024MAK
Posts: 5118
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Atari joystick without ZXpand+

Post by 1024MAK »

BASIC always uses its own ROM routines to read the keyboard.

At the lowest level, this is the Z80 processor using the Z80 machine code IN instruction. Each keyboard half row has its own I/O address. The data returned is one byte, but only five bits are keyboard data. Hence it takes eight IN instructions to read the whole 40 key keyboard. This is what is meant as a keyboard scan.

The ROM decodes the "raw" data to work out which key(s) has been pressed, taking into amount if the SHIFT key was pressed. This data is then put in the system variable (buffer).

Then another part of BASIC reads this value. This is what INKEY$ reads. This is effectively a higher layer.

Because ZXspand uses its own ROM, it can intervene to add joystick support.

Machine code games can either use BASIC to scan the keyboard, taking the result and using it. Or the software author may choose to use their own low level keyboard scan code. If the latter, the ZXpand+ can't intervene, at it does not have the hardware to do this.

Further, because machine code games may only need to detect a limited number of keys, for speed reasons, they will not scan all of the keyboard. This also makes the code short and simple.

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
msknight
Posts: 386
Joined: Fri Dec 15, 2023 8:26 pm
Location: Sussex, UK

Re: Atari joystick without ZXpand+

Post by msknight »

Makes sense... so they can either read inkey$ or go direct to the keyboard themselves... in the latter case, that'll mean code will have to be changed to work.

Thanks for all the detail. I think I've got it straight in my head now.
Spinnetti
Posts: 255
Joined: Sat Sep 12, 2020 11:29 pm

Re: Atari joystick without ZXpand+

Post by Spinnetti »

back in 82, I simply cut a hole in the case, put in a joystick port, and hardwired it to the arrow keys... pretty simple....
Zeddy: ZX80, ZX81/ZXpand, TS1000/ZXpand, TS1500/Zxpand+,Printer
Speccy: 48k, +, +2, +3, TS2068, "Bare Metal" Pi, Next KS2, IF1/Microdrives/Vdrive/Light Gun/VGA-Joy
QL: Minerva/QL-VGA/Custom PSU
C5: 24v, LiFE battery, Disc brakes
User avatar
msknight
Posts: 386
Joined: Fri Dec 15, 2023 8:26 pm
Location: Sussex, UK

Re: Atari joystick without ZXpand+

Post by msknight »

Spinnetti wrote: Sat Mar 16, 2024 3:10 am back in 82, I simply cut a hole in the case, put in a joystick port, and hardwired it to the arrow keys... pretty simple....
You know some people in here are currently chewing on their knuckles and screaming at that revelation... right? ;-) :-D
Post Reply