1

The description of the opcode FX0A is:

Wait for a keypress and store the result in register VX

My question is if a key is already pressed while the opcode is called, is it considered a keypress? Or will it not be considered a keypress until the key is released and then pressed again?

In other words, do I need to wait until a value of a key is pressed, or until a value is set from not_pressed to pressed?

Peter G
  • 2,773
  • 3
  • 25
  • 35
Tom
  • 129
  • 2
  • 8
  • In my opinion this makes very little functional difference. Maybe try implementing it both ways and test which one feels right when playing games. I'd say you should wait for depressing and pressing again but that's my feeling when looking at some older console games. – zubergu Dec 20 '16 at 13:30
  • I've asked a [similar question in Retrocomputing.SE](http://retrocomputing.stackexchange.com/q/358/115), and got a very nicely detailed answer based on the original CHIP-8 interpreter. "So, according to this, if the `Fx0A` instruction is executed while a key has been already pressed, the instruction will wait until the key is released and then it will return the key code in register `Vx`." – Cactus Feb 15 '17 at 12:19

1 Answers1

1

Fx0A - LD Vx, K Wait for a key press, store the value of the key in Vx. All execution stops until a key is pressed, then the value of that key is stored in Vx.

(Source)

If we take this literally, "wait for a key press" would imply no previous input, but to simply wait right here and now for a key.

Though perhaps you should just make it configurable in your application.

Emily
  • 1,030
  • 1
  • 12
  • 20