Enterprise Forever

:UK => Programming => Topic started by: Sdw on 2016.September.08. 23:07:59

Title: How to read joystick?
Post by: Sdw 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! :)
Title: Re: How to read joystick?
Post by: gflorez on 2016.September.08. 23:25:30
Read this document:

Converting Spectrum programs to run on the Enterprise (http://enterprise.iko.hu/technical/Converting_Spectrum_programs.pdf)

It will give you useful tips, not only related to converting Spectrum programs.
Title: Re: How to read joystick?
Post by: Zozosoft 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.
Title: Re: How to read joystick?
Post by: Sdw 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! :)