From bc8ac1f6965922518a72aad91f8879171fd0ffab Mon Sep 17 00:00:00 2001 From: Karol Stasiak Date: Wed, 5 Jun 2019 13:31:43 +0200 Subject: [PATCH] Preliminary MSX support --- .gitignore | 1 + CHANGELOG.md | 2 ++ README.md | 4 +++- docs/api/command-line.md | 1 + docs/api/target-platforms.md | 4 +++- docs/lang/preprocessor.md | 2 ++ docs/stdlib/frequent.md | 2 ++ examples/README.md | 8 ++++---- include/msx.mfk | 22 ++++++++++++++++++++++ include/msx_crt.ini | 32 ++++++++++++++++++++++++++++++++ include/msx_crt.mfk | 5 +++++ 11 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 include/msx.mfk create mode 100644 include/msx_crt.ini create mode 100644 include/msx_crt.mfk diff --git a/.gitignore b/.gitignore index 5f059d8c..74d49b8f 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,7 @@ examples/lunix/ *.d88 *.com *.gb +*.rom HELLO HELLOCPC diff --git a/CHANGELOG.md b/CHANGELOG.md index f50df5ef..ae268d4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * Preliminary experimental Game Boy support. +* Preliminary MSX support. + * Super experimental and very incomplete Intel 8086 support via 8080-to-8086 translation. * Support for Intel 8085. diff --git a/README.md b/README.md index 57fc9a89..45765034 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ For binary releases, see: https://github.com/KarolS/millfork/releases * Amstrad CPC + * MSX + * CP/M * Atari 2600 (experimental) @@ -70,7 +72,7 @@ Therefore, no attribution is needed if you are developing and distributing Millf * more 6502 targets: Oric computers, PC-Engine/Turbografx-16, Atari Lynx -* more Z80 targets: MSX, TI-83, Sega Master System +* more Z80 targets: TI-83, Sega Master System * better support for 65816, Intel 8080, Sharp LR35902 and eZ80 diff --git a/docs/api/command-line.md b/docs/api/command-line.md index c26b2c42..a2d76ccd 100644 --- a/docs/api/command-line.md +++ b/docs/api/command-line.md @@ -22,6 +22,7 @@ Extension will be added automatically, no extension for BBC micro program file, `.inf` for BBC Micro metadata, `.d88` for PC-88 disk images, +`.rom` for MSX cartridge images, `.tap` for ZX-Spectrum tape images. * `-s` – Generate also the assembly output. It is not compatible with any assembler, but it serves purely informational purpose. The file has the same nam as the output file and the extension is `.asm`. diff --git a/docs/api/target-platforms.md b/docs/api/target-platforms.md index 06f52f77..5e425d82 100644 --- a/docs/api/target-platforms.md +++ b/docs/api/target-platforms.md @@ -4,7 +4,7 @@ Currently, Millfork supports creating disk- or tape-based programs for Commodore, Apple, BBC and Atari 8-bit computers, NEC PC-88, ZX Spectrum 48k, Amstrad CPC, CP/M, -and cartridge-based programs for Commodore 64, VIC-20, Famicom/NES and Atari 2600, +and cartridge-based programs for Commodore 64, VIC-20, MSX, Famicom/NES and Atari 2600, but it may be expanded to support other 6502-based and Z80-based platforms in the future. To add a custom platform yourself, see [the custom platform adding guide](./custom-platform.md). @@ -78,6 +78,8 @@ The compiler emits tape images. * `zxspectrum_8080` – Sinclair ZX Spectrum 48k, using only Intel 8080 instructions +* `msx_crt` – MSX 16kB cartridge, using only 16kB RAM + * `gb_small` – a tiny 32K Game Boy program. (experimental) The compiler emits GB files. Read [the Game Boy programming guide](./gb-programming-guide.md) for more info. diff --git a/docs/lang/preprocessor.md b/docs/lang/preprocessor.md index 7ff97808..1ef5db65 100644 --- a/docs/lang/preprocessor.md +++ b/docs/lang/preprocessor.md @@ -90,6 +90,8 @@ The following features are defined based on the chosen CPU and compilation optio * `IBM_PC` – 1 if the target is IBM PC, 0 otherwise +* `MSX` – 1 if the target is MSX, 0 otherwise + * `NTSC` – 1 if the target is NTSC, 0 otherwise * `PAL` – 1 if the target is PAL, 0 otherwise diff --git a/docs/stdlib/frequent.md b/docs/stdlib/frequent.md index 31954a01..e649dbe1 100644 --- a/docs/stdlib/frequent.md +++ b/docs/stdlib/frequent.md @@ -24,6 +24,7 @@ The string is valid only until next read from the console. Available for: ZX Spectrum, NEC PC-88, +MSX, Commodore 64 with `c64_basic` module, Commodore 16 or Plus/4 with `c264_basic` module. @@ -34,6 +35,7 @@ Reads a 16-bit unsigned integer from the console. Available for: ZX Spectrum, NEC PC-88, +MSX, Commodore 64 with `c64_basic` module, Commodore 16 or Plus/4 with `c264_basic` module. diff --git a/examples/README.md b/examples/README.md index c37f10ec..508d1fa5 100644 --- a/examples/README.md +++ b/examples/README.md @@ -2,15 +2,15 @@ ## 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) – simple text output +* [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 * [Text encodings](crossplatform/text_encodings.mfk) (C64/ZX Spectrum) – examples of text encoding features -* [Echo](crossplatform/echo.mfk) (C64/C16/ZX Spectrum/PC-88)– simple text input and output +* [Echo](crossplatform/echo.mfk) (C64/C16/ZX Spectrum/PC-88/MSX)– simple text input and output -* [Calculator](crossplatform/calculator.mfk) (C64/C16/ZX Spectrum/PC-88) – simple numeric input and output +* [Calculator](crossplatform/calculator.mfk) (C64/C16/ZX Spectrum/PC-88/MSX) – simple numeric input and output -* [Guessing game](crossplatform/guess.mfk) (C64/C16/ZX Spectrum/PC-88) – a guess-a-number game +* [Guessing game](crossplatform/guess.mfk) (C64/C16/ZX Spectrum/PC-88/MSX) – a guess-a-number game * [Fire effect](crossplatform/fire.mfk) (C64/C16/ZX Spectrum) – a simple fire effect diff --git a/include/msx.mfk b/include/msx.mfk new file mode 100644 index 00000000..d86c5f87 --- /dev/null +++ b/include/msx.mfk @@ -0,0 +1,22 @@ + +#if not(MSX) +#warn msx module should be only used on MSX-compatible targets +#endif + +#pragma zilog_syntax + +asm void putchar(byte a) @$00a2 extern + +inline void new_line() { + putchar(13) + putchar(10) +} + +const pointer readline_out = $F55E + +asm pointer readline() { + ? ld hl, $F55D + call $00b1 + ? ld hl, $F55E + ? ret +} diff --git a/include/msx_crt.ini b/include/msx_crt.ini new file mode 100644 index 00000000..1cb785c0 --- /dev/null +++ b/include/msx_crt.ini @@ -0,0 +1,32 @@ +; MSX1 16kB RAM +; 16K cartridge + +[compilation] +arch=z80 +encoding=ascii +screen_encoding=ascii +modules=stdlib,msx1,default_panic,msx1_crt,default_readword + + +[allocation] +segments=default +default_code_segment=default +segment_default_start=$4000 +segment_default_codeend=$8fff +segment_default_datastart=$8000 +segment_default_end=$bfff + +[define] +MSX=1 +WIDESCREEN=1 +KEYBOARD=1 +; TODO: ? +JOYSTICKS=2 +HAS_BITMAP_MODE=1 + +[output] +style=single +format=$4000:$7fff +extension=rom + + diff --git a/include/msx_crt.mfk b/include/msx_crt.mfk new file mode 100644 index 00000000..89d72c5d --- /dev/null +++ b/include/msx_crt.mfk @@ -0,0 +1,5 @@ +array __header[16] @$4000 = [ + "AB" ascii, + @word [main.addr, 0, 0, 0], + 0,0, 0,0, 0,0 +]