Welcome, Guest. Please login or register.


Author Topic: How to read joystick? (Read 573 times)

Offline Sdw

  • User
  • *
  • Posts: 50
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 48.0 Firefox 48.0
    • View Profile
How to read joystick?
« on: 2016.September.08. 23:07:59 »
Anyone have code snippets on how to read the joystick?
Also, generally, what is used as the "fire" button normally? Space bar? Shift? Whatever it is, some code to read that as well would be appreciated! :)

Online gflorez

  • EP addict
  • *
  • Posts: 2587
  • Country: es
  • OS:
  • Windows NT 10.0 Windows NT 10.0
  • Browser:
  • Firefox 48.0 Firefox 48.0
    • View Profile
Re: How to read joystick?
« Reply #1 on: 2016.September.08. 23:25:30 »
Read this document:

Converting Spectrum programs to run on the Enterprise

It will give you useful tips, not only related to converting Spectrum programs.
« Last Edit: 2016.September.09. 07:31:26 by Zozosoft, Reason: Link fixed »

Online Zozosoft

  • EP addict
  • *
  • Posts: 13377
  • Country: hu
  • OS:
  • Windows NT 10.0 Windows NT 10.0
  • Browser:
  • Firefox 48.0 Firefox 48.0
    • View Profile
    • http://enterprise.iko.hu/
Re: How to read joystick?
« Reply #2 on: 2016.September.09. 07:36:46 »
Are you think about the Internal or External joystick?
Internal:
Code: ZiLOG Z80 Assembler
  1. LD A,7
  2. OUT (0B5H),A
  3. IN A,(0B5H)
Bit5: Left, b3: Up, b2: Right, b1: Down
Code: ZiLOG Z80 Assembler
  1. LD A,8
  2. OUT (0B5H),A
  3. IN A,(0B5H)
Bit6: Space (Fire)

External: see one possible solution in the linke PDF at Page 3.

Offline Sdw

  • User
  • *
  • Posts: 50
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 48.0 Firefox 48.0
    • View Profile
Re: How to read joystick?
« Reply #3 on: 2016.September.09. 10:30:26 »
Thank you, yes, I was primarily thinking about the internal joystick.
But looking at the document, it would be quite easy to add external joystick support as well, so I guess I might as well read those values as well, and then the user can grab whatever he feels like to control! :)