From 10492bc534856b75cc0e7d3677d6d6fc89253326 Mon Sep 17 00:00:00 2001 From: Karol Stasiak Date: Wed, 19 Dec 2018 22:32:55 +0100 Subject: [PATCH] Updated examples --- docs/stdlib/frequent.md | 10 +++++++-- examples/README.md | 22 +++++++++---------- examples/{apple2 => crossplatform}/bell.mfk | 0 .../{c64 => crossplatform}/calculator.mfk | 11 +++++++++- examples/{c64 => crossplatform}/echo.mfk | 13 ++++++++++- .../{c64 => crossplatform}/text_encodings.mfk | 0 6 files changed, 41 insertions(+), 15 deletions(-) rename examples/{apple2 => crossplatform}/bell.mfk (100%) rename examples/{c64 => crossplatform}/calculator.mfk (76%) rename examples/{c64 => crossplatform}/echo.mfk (59%) rename examples/{c64 => crossplatform}/text_encodings.mfk (100%) diff --git a/docs/stdlib/frequent.md b/docs/stdlib/frequent.md index 79c3a4e8..e027306f 100644 --- a/docs/stdlib/frequent.md +++ b/docs/stdlib/frequent.md @@ -21,13 +21,19 @@ Available for: all computer targets. Reads a line from the console and returns a pointer to a null-terminated string. The string is valid only until next read from the console. -Available for: Commodore 64 with `c64_basic` module. +Available for: +ZX Spectrum, +Commodore 64 with `c64_basic` module, +Commodore 16 or Plus/4 with `c264_basic`. #### `word readword()` Reads a 16-bit unsigned integer from the console. -Available for: Commodore 64 with `c64_basic` module. +Available for: +ZX Spectrum, +Commodore 64 with `c64_basic` module, +Commodore 16 or Plus/4 with `c264_basic`. #### `void bell()` diff --git a/examples/README.md b/examples/README.md index 4ce50be9..24c83ed3 100644 --- a/examples/README.md +++ b/examples/README.md @@ -2,22 +2,18 @@ ## Cross-platform examples -* [Hello world](hello_world/hello_world.mfk) (C64/C16/PET/VIC-20/Atari/Apple II/BBC Micro/PC-88/Armstrad CPC) – 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) – simple text output -* [Text encodings](c64/text_encodings.mfk) (C64/ZX Spectrum) – examples of text encoding features +* [Text encodings](crossplatform/text_encodings.mfk) (C64/ZX Spectrum) – examples of text encoding features -* [Bell](apple2/bell.mfk) (Apple II/ZX Spectrum) – a program that goes \*ding!\* +* [Echo](crossplatform/echo.mfk) (C64/C16/ZX Spectrum)– simple text input and output + +* [Calculator](crossplatform/calculator.mfk) (C64/C16/ZX Spectrum) – simple numeric input and output + +* [Bell](crossplatform/bell.mfk) (Apple II/ZX Spectrum) – a program that goes \*ding!\* ## Commodore 64 examples -### Console I/O examples - -* [Echo](c64/echo.mfk) – simple text input and output - -* [Calculator](c64/calculator.mfk) – simple numeric input and output - -* [Panic](c64/panic_test.mfk) – how panic works on C64, showing the address of where it happened - ### Graphical examples * [Rasterbar](c64/rasterbar.mfk) – simple rasterbar effect @@ -26,6 +22,10 @@ * [Galencia starfield](c64/galencia.mfk) – a port of the starfield effect from the game *Galencia* +### Other examples + +* [Panic](c64/panic_test.mfk) – how panic works on C64, showing the address of where it happened + ## Famicom/NES examples * [NES 101 tutorial example](nes/nestest.mfk) – a port of the tutorial example from the NES 101 tutorial by Michael Martin diff --git a/examples/apple2/bell.mfk b/examples/crossplatform/bell.mfk similarity index 100% rename from examples/apple2/bell.mfk rename to examples/crossplatform/bell.mfk diff --git a/examples/c64/calculator.mfk b/examples/crossplatform/calculator.mfk similarity index 76% rename from examples/c64/calculator.mfk rename to examples/crossplatform/calculator.mfk index a8878cef..f8512fc4 100644 --- a/examples/c64/calculator.mfk +++ b/examples/crossplatform/calculator.mfk @@ -1,5 +1,14 @@ import stdio -import c64_basic + +#if CBM_64 + import c64_basic +#elseif CBM_264 + import c264_basic +#elseif ZX_SPECTRUM + // no imports needed +#else + #error Unsupported platform +#endif void main() { word a diff --git a/examples/c64/echo.mfk b/examples/crossplatform/echo.mfk similarity index 59% rename from examples/c64/echo.mfk rename to examples/crossplatform/echo.mfk index f6fa9bee..a57184bb 100644 --- a/examples/c64/echo.mfk +++ b/examples/crossplatform/echo.mfk @@ -1,5 +1,16 @@ -import c64_basic + +#if CBM_64 + import c64_basic +#elseif CBM_264 + import c264_basic +#elseif ZX_SPECTRUM + // no imports needed +#else + #error Unsupported platform +#endif + import stdio + void main() { while true { readline() diff --git a/examples/c64/text_encodings.mfk b/examples/crossplatform/text_encodings.mfk similarity index 100% rename from examples/c64/text_encodings.mfk rename to examples/crossplatform/text_encodings.mfk