diff --git a/CHANGELOG.md b/CHANGELOG.md index 5034f417..56e042b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ * Allowed the `:` operator in const-pure functions. +* Implemented `readline` and `readword` for VIC-20. + * Fix: more instances of memset loops should be detected and optimized (#59). * Fix: things mentioned in the segment layout should not be deleted even if unused. diff --git a/docs/doc_index.md b/docs/doc_index.md index 42b40102..ca8dc2f3 100644 --- a/docs/doc_index.md +++ b/docs/doc_index.md @@ -69,6 +69,8 @@ * [Definitions available on only some platforms](stdlib/frequent.md) * [C64-only modules](stdlib/c64.md) + + * [VIC-20-only modules](stdlib/vic20.md) * [PET-only modules](stdlib/cbm_pet.md) diff --git a/docs/stdlib/frequent.md b/docs/stdlib/frequent.md index 775eba3a..caa65422 100644 --- a/docs/stdlib/frequent.md +++ b/docs/stdlib/frequent.md @@ -51,6 +51,7 @@ MSX, Apple II, Robotron Z1013 (always trims trailing spaces), TRS-80, +VIC-20 (except for `vic20_a000`), Commodore 64 with `c64_basic` module (requires KERNAL and BASIC; empty input is treated like a single space), Commodore 16 or Plus/4 with `c264_basic` module (requires KERNAL and BASIC; empty input is treated like a single space). @@ -65,6 +66,7 @@ MSX, Apple II, Robotron Z1013, TRS-80, +VIC-20 (except for `vic20_a000`), Commodore 64 with `c64_basic` module (requires KERNAL and BASIC), Commodore 16 or Plus/4 with `c264_basic` module (requires KERNAL and BASIC). diff --git a/docs/stdlib/vic20.md b/docs/stdlib/vic20.md new file mode 100644 index 00000000..2c567e05 --- /dev/null +++ b/docs/stdlib/vic20.md @@ -0,0 +1,21 @@ +[< back to index](../doc_index.md) + +# VIC-20-oriented modules + +## vic20_kernal module + +The `vic20_kernal` module is imported automatically on the VIC-20 target. +It provides access to Kernal routines. + +TODO + +## vic20_basic module + +The `vic20_basic` module provides access to Basic routines. +It is imported automatically on all PRG VIC-20 targets (`vic20`, `vic20_3k`, `vic20_8k`), but not on cartridge targets (like `vic20_a000`). + +TODO + +## vic20_hardware + +TODO diff --git a/examples/README.md b/examples/README.md index d41f2353..ce61bbc2 100644 --- a/examples/README.md +++ b/examples/README.md @@ -27,11 +27,11 @@ If you are using a release version of the compiler, consider browsing the older * [Text encodings](crossplatform/text_encodings.mfk) (C64/ZX Spectrum) – examples of text encoding features -* [Echo](crossplatform/echo.mfk) (C64/C16/Apple II/ZX Spectrum/PC-88/MSX)– simple text input and output +* [Echo](crossplatform/echo.mfk) (C64/C16/VIC-20/Apple II/ZX Spectrum/PC-88/MSX)– simple text input and output -* [Calculator](crossplatform/calculator.mfk) (C64/C16/Apple II/ZX Spectrum/PC-88/MSX/TRS-80) – simple numeric input and output +* [Calculator](crossplatform/calculator.mfk) (C64/C16/VIC-20/Apple II/ZX Spectrum/PC-88/MSX/TRS-80) – simple numeric input and output -* [Guessing game](crossplatform/guess.mfk) (C64/C16/Apple II/ZX Spectrum/PC-88/MSX/TRS-80/Z1013) – a guess-a-number game +* [Guessing game](crossplatform/guess.mfk) (C64/C16/VIC-20/Apple II/ZX Spectrum/PC-88/MSX/TRS-80/Z1013) – a guess-a-number game * [Fire effect](crossplatform/fire.mfk) (C64/C16/ZX Spectrum) – a simple fire effect diff --git a/examples/crossplatform/calculator.mfk b/examples/crossplatform/calculator.mfk index 495a6f95..58102493 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 || NEC_PC_88 || TRS80 +#elseif ZX_SPECTRUM || NEC_PC_88 || TRS80 || CBM_VIC // no imports needed #else #error Unsupported platform diff --git a/examples/crossplatform/echo.mfk b/examples/crossplatform/echo.mfk index 6983b546..725aded2 100644 --- a/examples/crossplatform/echo.mfk +++ b/examples/crossplatform/echo.mfk @@ -3,7 +3,7 @@ import c64_basic #elseif CBM_264 import c264_basic -#elseif ZX_SPECTRUM || NEC_PC_88 +#elseif CBM_VIC || ZX_SPECTRUM || NEC_PC_88 // no imports needed #else #error Unsupported platform diff --git a/examples/crossplatform/guess.mfk b/examples/crossplatform/guess.mfk index c375a4ec..6a5fdb79 100644 --- a/examples/crossplatform/guess.mfk +++ b/examples/crossplatform/guess.mfk @@ -10,7 +10,7 @@ import c64_basic import c264_basic #endif -#define READKEY = CBM_64 | CBM_264 | ZX_SPECTRUM | NEC_PC_88 | APPLE_2 +#define READKEY = CBM_64 | CBM_264 | CBM_VIC | ZX_SPECTRUM | NEC_PC_88 | APPLE_2 #if READKEY import keyboard diff --git a/include/platform/vic20.ini b/include/platform/vic20.ini index 9198fdcf..8ff998c0 100644 --- a/include/platform/vic20.ini +++ b/include/platform/vic20.ini @@ -2,7 +2,7 @@ arch=nmos encoding=petscii screen_encoding=petscr -modules=loader_1001,vic20_kernal,vic20_hardware,default_panic,stdlib +modules=loader_1001,vic20_kernal,vic20_basic,vic20_hardware,default_panic,stdlib [allocation] diff --git a/include/platform/vic20_3k.ini b/include/platform/vic20_3k.ini index 6d83cfe2..f8a550d7 100644 --- a/include/platform/vic20_3k.ini +++ b/include/platform/vic20_3k.ini @@ -2,7 +2,7 @@ arch=nmos encoding=petscii screen_encoding=petscr -modules=loader_0401,vic20_kernal,vic20_hardware,default_panic,stdlib +modules=loader_0401,vic20_kernal,vic20_basic,vic20_hardware,default_panic,stdlib [allocation] diff --git a/include/platform/vic20_8k.ini b/include/platform/vic20_8k.ini index 6fb71d38..6bbd551f 100644 --- a/include/platform/vic20_8k.ini +++ b/include/platform/vic20_8k.ini @@ -2,7 +2,7 @@ arch=nmos encoding=petscii screen_encoding=petscr -modules=loader_1201,vic20_kernal,vic20_hardware,,default_panic,stdlib +modules=loader_1201,vic20_kernal,vic20_basic,vic20_hardware,,default_panic,stdlib [allocation] diff --git a/include/vic20_basic.mfk b/include/vic20_basic.mfk new file mode 100644 index 00000000..faa69568 --- /dev/null +++ b/include/vic20_basic.mfk @@ -0,0 +1,30 @@ +// Routines from C64 BASIC ROM + +#if not(CBM_VIC) +#warn vic20_basic module should be only used on VIC-20-compatible targets +#endif + +import vic20_kernal +import err + +// print a 16-bit number on the standard output +asm void putword_basic(word register(xa) num) @$DDCD extern + +alias putword = putword_basic! + +asm void __readline_basic() @$C560 extern + +pointer readline_basic() { + __readline_basic() + return readline_out +} + +alias readline = readline_basic! + +const pointer readline_out = $200 + +inline word readword_basic() { + return strz2word(readline_basic()) +} + +alias readword = readword_basic! diff --git a/mkdocs.yml b/mkdocs.yml index 20cf4d2c..2c5345d4 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -47,6 +47,7 @@ nav: - Platform-dependent definitions: stdlib/frequent.md - cbm_file module: stdlib/cbm_file.md - C64-only modules: stdlib/c64.md + - VIC-20-only modules: stdlib/vic20.md - PET-only modules: stdlib/cbm_pet.md - NES-only modules: stdlib/nes.md - Lynx-only modules: stdlib/lynx.md