Page 3 of 4

Re: Atari joystick without ZXpand+

Posted: Fri Mar 15, 2024 8:27 am
by msknight
Ah. That makes sense. So the ZXpand+ is its own API and isn't using INKEY$.

Re: Atari joystick without ZXpand+

Posted: Fri Mar 15, 2024 8:30 am
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.

Re: Atari joystick without ZXpand+

Posted: Fri Mar 15, 2024 9:11 am
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

Re: Atari joystick without ZXpand+

Posted: Fri Mar 15, 2024 10:00 am
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?

Re: Atari joystick without ZXpand+

Posted: Fri Mar 15, 2024 10:12 am
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.

Re: Atari joystick without ZXpand+

Posted: Fri Mar 15, 2024 10:16 am
by msknight
Just to let you know... Kelly has responded to me, so things will move forward :-)

Re: Atari joystick without ZXpand+

Posted: Fri Mar 15, 2024 1:37 pm
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

Re: Atari joystick without ZXpand+

Posted: Fri Mar 15, 2024 2:21 pm
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.

Re: Atari joystick without ZXpand+

Posted: Sat Mar 16, 2024 3:10 am
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....

Re: Atari joystick without ZXpand+

Posted: Sat Mar 16, 2024 8:58 am
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