Difference between revisions of "OSBYTE &7A"
m (1 revision) |
(Added sample code.) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
[[Category:OSBYTE]] | [[Category:OSBYTE]] | ||
− | OSBYTE &7A (122) | + | {{PageTitle|OSBYTE &7A (122) Keyboard Scan from &10}} |
+ | Simply performs [[OSBYTE &79]] with X=16 to scan the main keyboard | ||
+ | skipping the modifier keys and DIP links. | ||
+ | On entry: | ||
+ | no parameters | ||
+ | On exit: | ||
+ | X=&FF : for no key pressed | ||
+ | X<&80 : internal keynumber of key pressed | ||
− | + | ==Usage== | |
+ | OSBYTE &7A is used by ROMs on startup to test for a keypress to select | ||
+ | themselves, usually on [[Service calls|service call]] &03, in the | ||
+ | following manner: | ||
+ | LDA #&7A:JSR OSBYTE :\ Check for keys pressed | ||
+ | TXA:BMI Select :\ No key pressed, select | ||
+ | CMP #mykeynum:BNE Exit :\ My selection key not pressed, exit | ||
+ | LDA #&78:JSR OSBYTE :\ Write the key back to cancel it | ||
+ | .Select | ||
+ | \ Select myself | ||
+ | .Exit | ||
− | ==See | + | The ''mykeynum'' is the internal keycode for the keypress, which is the |
+ | negative INKEY number EOR'd with &FF. For example, &32 for 'D', &55 for 'N'. | ||
+ | |||
+ | [[OSBYTE &78]] to cancel the keypress can write any value with bit 7 set to 0. | ||
+ | The keypress value tested from OSBYTE &7A will always be less than &80, | ||
+ | so it is fine to use it as the entry value to OSBYTE &78. | ||
+ | |||
+ | On exit from OSBYTE &7A, Y is undefined, and typically contains &EE pointing | ||
+ | to the third keyboard workspace location, and an invalid | ||
+ | keynumber.<ref name="seddon-osbyte7a">Stardot forum [https://stardot.org.uk/forums/viewtopic.php?p=441827#p441827 post by Tom Seddon], 11th December 2024.</ref> | ||
+ | |||
+ | Paged ROMs that use the above code incorrectly pass Y unchanged to OSBYTE &78 | ||
+ | where it sets an undefined keynumber as the second active rollover key. | ||
+ | This does not cause a spurious keypress in practice as the value passed | ||
+ | is not a valid keypress (it is the 'Kanji' key on a Japanese keyboard), | ||
+ | so on the BBC it is treated as 'no keypress'. | ||
+ | |||
+ | If you want your code to rigourously adhere to the API, you would use the following: | ||
+ | LDA #&7A:JSR OSBYTE :\ Check for keys pressed | ||
+ | TXA:BMI Select :\ No key pressed, select | ||
+ | EOR #mykeynum:BNE Exit :\ My selection key not pressed, exit | ||
+ | TAY:LDA #&78:JSR OSBYTE :\ Write the key back to cancel it | ||
+ | .Select | ||
+ | \ Select myself | ||
+ | .Exit | ||
+ | |||
+ | ==See also== | ||
* http://mdfs.net/Docs/Comp/BBC/Osbyte00 | * http://mdfs.net/Docs/Comp/BBC/Osbyte00 | ||
+ | |||
+ | == References == | ||
+ | <references/> | ||
[[User:Jgharston|Jgharston]] 21:17, 26 May 2009 (UTC) | [[User:Jgharston|Jgharston]] 21:17, 26 May 2009 (UTC) |
Latest revision as of 11:14, 18 December 2024
Simply performs OSBYTE &79 with X=16 to scan the main keyboard skipping the modifier keys and DIP links.
On entry: no parameters On exit: X=&FF : for no key pressed X<&80 : internal keynumber of key pressed
Usage
OSBYTE &7A is used by ROMs on startup to test for a keypress to select themselves, usually on service call &03, in the following manner:
LDA #&7A:JSR OSBYTE :\ Check for keys pressed TXA:BMI Select :\ No key pressed, select CMP #mykeynum:BNE Exit :\ My selection key not pressed, exit LDA #&78:JSR OSBYTE :\ Write the key back to cancel it .Select \ Select myself .Exit
The mykeynum is the internal keycode for the keypress, which is the negative INKEY number EOR'd with &FF. For example, &32 for 'D', &55 for 'N'.
OSBYTE &78 to cancel the keypress can write any value with bit 7 set to 0. The keypress value tested from OSBYTE &7A will always be less than &80, so it is fine to use it as the entry value to OSBYTE &78.
On exit from OSBYTE &7A, Y is undefined, and typically contains &EE pointing to the third keyboard workspace location, and an invalid keynumber.[1]
Paged ROMs that use the above code incorrectly pass Y unchanged to OSBYTE &78 where it sets an undefined keynumber as the second active rollover key. This does not cause a spurious keypress in practice as the value passed is not a valid keypress (it is the 'Kanji' key on a Japanese keyboard), so on the BBC it is treated as 'no keypress'.
If you want your code to rigourously adhere to the API, you would use the following:
LDA #&7A:JSR OSBYTE :\ Check for keys pressed TXA:BMI Select :\ No key pressed, select EOR #mykeynum:BNE Exit :\ My selection key not pressed, exit TAY:LDA #&78:JSR OSBYTE :\ Write the key back to cancel it .Select \ Select myself .Exit
See also
References
- ↑ Stardot forum post by Tom Seddon, 11th December 2024.
Jgharston 21:17, 26 May 2009 (UTC)