From 62575263c242b96c2edbea1d136861178dce628e Mon Sep 17 00:00:00 2001 From: Karol Stasiak Date: Thu, 20 Dec 2018 00:47:42 +0100 Subject: [PATCH] NEC PC-88: `readline` --- docs/stdlib/frequent.md | 6 ++++-- examples/README.md | 2 +- examples/crossplatform/calculator.mfk | 2 +- include/pc88.ini | 2 +- include/pc88.mfk | 8 ++++++++ include/stdio.mfk | 7 +++++++ 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/docs/stdlib/frequent.md b/docs/stdlib/frequent.md index e027306f..96719582 100644 --- a/docs/stdlib/frequent.md +++ b/docs/stdlib/frequent.md @@ -23,8 +23,9 @@ The string is valid only until next read from the console. Available for: ZX Spectrum, +NEC PC-88, Commodore 64 with `c64_basic` module, -Commodore 16 or Plus/4 with `c264_basic`. +Commodore 16 or Plus/4 with `c264_basic` module. #### `word readword()` @@ -32,8 +33,9 @@ Reads a 16-bit unsigned integer from the console. Available for: ZX Spectrum, +NEC PC-88, Commodore 64 with `c64_basic` module, -Commodore 16 or Plus/4 with `c264_basic`. +Commodore 16 or Plus/4 with `c264_basic` module. #### `void bell()` diff --git a/examples/README.md b/examples/README.md index 24c83ed3..e30dfc27 100644 --- a/examples/README.md +++ b/examples/README.md @@ -8,7 +8,7 @@ * [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 +* [Calculator](crossplatform/calculator.mfk) (C64/C16/ZX Spectrum/PC-88) – simple numeric input and output * [Bell](crossplatform/bell.mfk) (Apple II/ZX Spectrum) – a program that goes \*ding!\* diff --git a/examples/crossplatform/calculator.mfk b/examples/crossplatform/calculator.mfk index f8512fc4..3cca6cac 100644 --- a/examples/crossplatform/calculator.mfk +++ b/examples/crossplatform/calculator.mfk @@ -4,7 +4,7 @@ import stdio import c64_basic #elseif CBM_264 import c264_basic -#elseif ZX_SPECTRUM +#elseif ZX_SPECTRUM || NEC_PC_88 // no imports needed #else #error Unsupported platform diff --git a/include/pc88.ini b/include/pc88.ini index 3dc71942..cd0bf885 100644 --- a/include/pc88.ini +++ b/include/pc88.ini @@ -3,7 +3,7 @@ [compilation] arch=z80 encoding=jisx -modules=default_panic,stdlib,pc88 +modules=default_panic,stdlib,pc88,default_readword [allocation] ; TODO: find a more optimal start address diff --git a/include/pc88.mfk b/include/pc88.mfk index ac33dbb1..3970b7bd 100644 --- a/include/pc88.mfk +++ b/include/pc88.mfk @@ -1,3 +1,4 @@ +#pragma zilog_syntax #if not(NEC_PC_88) #warn pc88 module should be only used on PC-88 targets @@ -9,3 +10,10 @@ inline void new_line() { putchar(13) putchar(10) } + +asm pointer readline() { + call $5f92 + // TODO: if carry set, then STOP was pressed; should we care? + ? inc hl + ? ret +} diff --git a/include/stdio.mfk b/include/stdio.mfk index ff5d084b..362d3a29 100644 --- a/include/stdio.mfk +++ b/include/stdio.mfk @@ -16,6 +16,13 @@ void putstr(pointer str, byte len) { index += 1 } } +#endif + +#if NEC_PC_88 +asm void putstrz(pointer hl) @$5550 extern +#endif + +#if not(ZX_SPECTRUM) && not(NEC_PC_88) void putstrz(pointer str) { byte index index = 0