For the likes of events such as BKZXes and DoZs, reusage of this code is pretty much grounds for disqualification, but it might be worthwhile as a reference at the very least during such events.
KEY_CODE/PRESSED MAP
KEY_PRESSED
KEY_PRESSED is like the KEY counter introduced much earlier in MZX's history but at the time it had far more functionality than KEY did, as well as auto-repeat. The auto-repeat makes it incredibly useful for cleanly receiving typed input, however, only one key can be detected at a time with KEY_PRESSED, so it may not be particularly useful for actual gameplay. The auto-repeat runs close to MZX speed 4, even in faster MZX speeds.
You should use KEY_PRESSED when writing joypad mapping utilities (or write something that maps KEY_CODE to KEY_PRESSED... ugh).
- 32-127 KEY_PRESSED shift translation strings: If shift is not pressed, you index $kpNormal by KEY_PRESSED. If it is, you index $kpShift by KEY_PRESSED.
set "$kpNormal+32" to " !\"#$%&&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ " set "$kpShift+32" to " xxxxxx\"xx*+<_>?)!@#$%^&&*(x:x+xxxxxxxxxxxxxxxxxxxxxxxxxxxxx{|}xx~ABCDEFGHIJKLMNOPQRSTUVWXYZxxxxx"
- Key names for KEY_PRESSED (spoilered because it's big).
Spoiler
KEY_CODE / KEY#
KEY_CODE uses a different system than KEY_PRESSED does, so it needs different mapping strings. It has auto-repeat and like KEY_PRESSED, cannot be checked for multiple values -- however, the KEY# counters, where # is a KEY_CODE value, can. The KEY# counters lack auto-repeat which can make precision input more difficult for the player in some game engines. Detection of keypresses may also be missed by the KEY# counters if a key is pressed and released between frames at slower MZX speeds.
- Reassignable KEY# wrappers: the idea here is that you set up some counters and strings ahead of time and then use special counters later that take auto-repeat into account, or to see if the key was -just- pressed. These also abstract the actual KEY# counter reads, so you can easily reassign keys at any time.
Spoiler
This post has been edited by Lachesis: 29 January 2019 - 01:46 AM
Reason for edit: Added missing F12 entry.

Help





