ZXpand joystick routines

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

ZXpand joystick routines

Post by sirmorris »

I finally got around to wiring up a joystick adapter. To read it you should do the following:

Code: Select all

   ld a,$a0
   ld bc,$e007
   out (c),a
   nop
   nop
   in a,(c)
A 0 bit means direction pressed.

Code: Select all

BIT - DIRECTION
  7 - Up    
  6 - Down
  5 - Left
  4 - Right
  3 - Fire
I'm considering patching INKEY$ too.

The final firmware will have a ROM call;

Code: Select all

   LET X = USR(8190)
Now then, modern game authors - anyone fancy adding ZXpander J/S support to their games?? 8-)
Prime
Posts: 134
Joined: Thu Mar 24, 2011 3:02 am

Re: ZXpand joystick routines

Post by Prime »

Excellent so they are active low with pullups :) :)

Can I make a sugestion if you are going to have many rom calls (sorry you already know or are indeed doing this :)) but use a scheme where the location called will remain the same across firmware upgrades so something like a jump table

org some_fixed_location
JSRead JP Real_jsread
routine1 JP real_routine1
routine2 JP real_routine2

That way if the real_ addresses move, if people are using the official jump table address then they won't have hastles with later software versions.

The other way of course is a single dispatcher routine with a function code in one of the registers similar to OSBYTE/OSWORD on the Beeb, or INT calls on the PC

Cheers.

Phill.
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: ZXpand joystick routines

Post by sirmorris »

That's how I'll be doing it.

Code: Select all

    .org 8190
    jr realReadJS
Getting a value quickly into a register isn't that easy on the '81. There could be a poke but that's a bit scuzzy so a dispatcher won't happen on my watch.

At the moment I'm having issues with NMOS vc CMOS EPROMS. NMOS fail, CMOS seem to work. Any wisdom gratefully received.

C
Prime
Posts: 134
Joined: Thu Mar 24, 2011 3:02 am

Re: ZXpand joystick routines

Post by Prime »

sirmorris wrote:That's how I'll be doing it.

Code: Select all

    .org 8190
    jr realReadJS
Getting a value quickly into a register isn't that easy on the '81. There could be a poke but that's a bit scuzzy so a dispatcher won't happen on my watch.
Excellent.
Dunno Z80 that well, having dabbled a little, some 25+ years ago (when the ZX81 was my only computer!), but doesn't it have a load register imediate ?
At the moment I'm having issues with NMOS vc CMOS EPROMS. NMOS fail, CMOS seem to work. Any wisdom gratefully received.
Speed issue perhaps ? seems like the ULA /Z80 could possibly be accessing the ROM at 6.5MHz so it may be that your EPROMS are not fast enough....
CMOS are also generally less power hungry than NMOS, well if the NMOS/CMOS versions of the 6809 are to be believed, as the CMOS version stays much cooler, same too for the 6502/65c02.

Cheers.

Phill.
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: ZXpand joystick routines

Post by sirmorris »

The issue with passing parameters is the interface to BASIC. It's not as ASM friendly as our Acornic cousins ;)

I've had a thought how I can add some semblance of programmability to the joystick - at least for BASIC use with INKEY$. Games that use INKEY$ don't expect/can't handle multiple direction presses. I could use the CONFIG command to set up U,D,L,R & Fire values for the INKEY$ patch.

CONFIG"J=76580" or "J=AZNME"

I'll work on some alternate code for difficult keys like return - inverse R perhaps?
Prime
Posts: 134
Joined: Thu Mar 24, 2011 3:02 am

Re: ZXpand joystick routines

Post by Prime »

sirmorris wrote:The issue with passing parameters is the interface to BASIC. It's not as ASM friendly as our Acornic cousins ;)
Ah I see now, and of course unlike the Spectrum there are no in and out functions built into basic so you can't even read the port directly.
I've had a thought how I can add some semblance of programmability to the joystick - at least for BASIC use with INKEY$. Games that use INKEY$ don't expect/can't handle multiple direction presses. I could use the CONFIG command to set up U,D,L,R & Fire values for the INKEY$ patch.

CONFIG"J=76580" or "J=AZNME"

I'll work on some alternate code for difficult keys like return - inverse R perhaps?
CONFIG"J=1234"+CHR$(whatever return is on the 81)

Cheers.

Phill.
User avatar
bobs
Posts: 325
Joined: Thu Aug 27, 2009 10:49 pm
Location: UK
Contact:

Re: ZXpand joystick routines

Post by bobs »

Personally the Z80 method is all I'd need, so I'm happy, and would gladly add it to any future games I write.

Does that mean that we should shortly be able to buy a ZXpand interface with a joystick port included?
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: ZXpand joystick routines

Post by sirmorris »

There are solder pads all present and correct for those who like to DIY. I have knocked up a daughter card which sits between the uC and the board. I've broken the signals out to some 2x5 pin header and attached a serial port connector from the junk box - you know, the sort which you used to have on older non-atx machines. If the demand is there I'll consider making these.

I've made good progress with the INKEY$ patch, and I'll post about this later when I have a new EPROM burned.

C
User avatar
Paul
Posts: 1511
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: ZXpand joystick routines

Post by Paul »

sirmorris wrote: I've made good progress with the INKEY$ patch, and I'll post about this later when I have a new EPROM burned.

C
Do you return different keys for combined (like when E,S,D,X,SPACE would be for up,left,right,down,fire then W,R,Y,C could be the diagonal ones) directions? Do you see a possibility to configure the needed keys?

CU
Paul
In theory, there is no difference between theory and practice. But, in practice, there is.
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: ZXpand joystick routines

Post by sirmorris »

I thought about doing diagonals but games that use inkey$ will not respond to them. For new games it's recommended to use the ROM call and get all the bit states simultaneously. up-right and fire? No problem :)

The inkey$ solution really is for very basic hacks.

C
Post Reply