Welcome, Guest. Please login or register.


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

Offline Sdw

  • User
  • *
  • Posts: 50
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! :)

Offline gflorez

  • EP addict
  • *
  • Posts: 3615
  • Country: es
    • Támogató Támogató
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 »

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14779
  • Country: hu
    • 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
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! :)