Implement readline and readword for VIC-20

This commit is contained in:
Karol Stasiak 2020-09-30 01:37:00 +02:00
parent 24c0e8a8ee
commit a00e10382d
13 changed files with 67 additions and 9 deletions

View File

@ -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.

View File

@ -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)

View File

@ -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).

21
docs/stdlib/vic20.md Normal file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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]

View File

@ -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]

30
include/vic20_basic.mfk Normal file
View File

@ -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!

View File

@ -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