DEV-SNIP #1 - Input

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
User avatar
sirmorris
Posts: 2667
Joined: Thu May 08, 2008 4:45 pm
Location: oxon, uk

Re: DEV-SNIP #1 - Input

Post by sirmorris » Tue Nov 14, 2017 8: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 :(
--=== ZXpand+ ... A more moderner all-in-one upgrade solution for ZX81 ===--
* SD/MMC storage * 32K Hires-capable RAM * AY sound chip * Joystick port * Serial *
* BASIC enhancements - plug & play * Reset button * Auto-boot facility *

User avatar
BarryN
Posts: 13
Joined: Thu Nov 09, 2017 10:34 pm

Re: DEV-SNIP #1 - Input

Post by BarryN » Tue Nov 14, 2017 9:13 pm

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: 1771
Joined: Mon Sep 26, 2011 9:56 am
Location: Looking forward to summer in Somerset, UK...

Re: DEV-SNIP #1 - Input

Post by 1024MAK » Tue Nov 14, 2017 9:15 pm

sirmorris wrote:
Tue Nov 14, 2017 8: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

User avatar
sirmorris
Posts: 2667
Joined: Thu May 08, 2008 4:45 pm
Location: oxon, uk

Re: DEV-SNIP #1 - Input

Post by sirmorris » Tue Nov 14, 2017 9:44 pm

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.
--=== ZXpand+ ... A more moderner all-in-one upgrade solution for ZX81 ===--
* SD/MMC storage * 32K Hires-capable RAM * AY sound chip * Joystick port * Serial *
* BASIC enhancements - plug & play * Reset button * Auto-boot facility *

User avatar
mrtinb
Posts: 508
Joined: Fri Nov 06, 2015 4:44 pm
Location: Denmark
Contact:

Re: DEV-SNIP #1 - Input

Post by mrtinb » Wed Nov 15, 2017 5:19 am

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
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube

User avatar
sirmorris
Posts: 2667
Joined: Thu May 08, 2008 4:45 pm
Location: oxon, uk

Re: DEV-SNIP #1 - Input

Post by sirmorris » Wed Nov 15, 2017 8:13 am

mrtinb wrote:
Wed Nov 15, 2017 5:19 am
please DON’T make 10 different .P files depending on hardware combinations
I completely agree with this. One P to rule them all :D
--=== ZXpand+ ... A more moderner all-in-one upgrade solution for ZX81 ===--
* SD/MMC storage * 32K Hires-capable RAM * AY sound chip * Joystick port * Serial *
* BASIC enhancements - plug & play * Reset button * Auto-boot facility *

User avatar
Andy Rea
Posts: 1267
Joined: Fri May 09, 2008 1:48 pm
Location: notts UK

Re: DEV-SNIP #1 - Input

Post by Andy Rea » Wed Nov 15, 2017 8:45 am

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
6 x ZX81, 1 x TS1500 , 1 x +3e, 1 x timex 2040 printer, 1 x timex 2020 cassette deck, siclair printer and some spectrum

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest