From 353923d3bc6da98447cdde44029fdc8c3d950f34 Mon Sep 17 00:00:00 2001 From: Karol Stasiak Date: Tue, 31 Mar 2020 18:58:19 +0200 Subject: [PATCH] Add readkeytest example --- examples/README.md | 4 +++- examples/crossplatform/readkeytest.mfk | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 examples/crossplatform/readkeytest.mfk diff --git a/examples/README.md b/examples/README.md index a96d5d9e..31bc64cf 100644 --- a/examples/README.md +++ b/examples/README.md @@ -11,7 +11,7 @@ If you are using a release version of the compiler, consider browsing the older ## Cross-platform examples -* [Hello world](crossplatform/hello_world.mfk) (C64/C16/PET/VIC-20/PET/Atari/Apple II/BBC Micro/ZX Spectrum/PC-88/Armstrad CPC/MSX) – simple text output +* [Hello world](crossplatform/hello_world.mfk) (C64/C16/PET/VIC-20/Atari/Apple II/BBC Micro/ZX Spectrum/PC-88/Armstrad CPC/MSX) – simple text output * [Fizzbuzz](crossplatform/fizzbuzz.mfk) (C64/C16/PET/VIC-20/PET/Atari/Apple II/BBC Micro/ZX Spectrum/PC-88/Armstrad CPC/MSX/X16) – everyone's favourite programming task @@ -29,6 +29,8 @@ If you are using a release version of the compiler, consider browsing the older * [Fire effect](crossplatform/fire.mfk) (C64/C16/ZX Spectrum) – a simple fire effect +* [`readkey` test](crossplatform/readkeytest.mfk) (C64/C16/PET/VIC-20/Atari/Armstrad CPC/ZX Spectrum/PC-88) – keyboard reading test + * [Screen encoding test](crossplatform/screnctest.mfk) (C64/C16) – default-to-screen encoding conversion test * [Bell](crossplatform/bell.mfk) (Apple II/ZX Spectrum) – a program that goes \*ding!\* diff --git a/examples/crossplatform/readkeytest.mfk b/examples/crossplatform/readkeytest.mfk new file mode 100644 index 00000000..f4cb00a7 --- /dev/null +++ b/examples/crossplatform/readkeytest.mfk @@ -0,0 +1,13 @@ +import stdio +import keyboard +void main() { + byte c + ensure_mixedcase() + while true { + c = readkey() + putchar(c) + putchar(hi_nibble_to_hex(c)) + putchar(lo_nibble_to_hex(c)) + putchar(' ') + } +}