DEV-SNIP #1 - Input
Re: DEV-SNIP #1 - Input
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
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?
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?
- 1024MAK
- Posts: 5165
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: DEV-SNIP #1 - Input
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 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 being good this year.
ZX81 Chip Pin-outs
ZX81 Video Transistor 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 being good this year.
Re: DEV-SNIP #1 - Input
I know a fair bit about the ZXpand ROM - I'm happy to tell y'all
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.
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
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.)
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
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
Regards Andy
what's that Smell.... smells like fresh flux and solder fumes...