From cad6f27185bd44f3deae4b8ec44a3a6027953d6d Mon Sep 17 00:00:00 2001 From: Karol Stasiak Date: Fri, 31 Jul 2020 01:58:40 +0200 Subject: [PATCH] Preliminary CoCo support --- CHANGELOG.md | 3 +++ docs/api/coco-programming-guide.md | 15 +++++++++++++++ docs/api/target-platforms.md | 3 +++ docs/lang/text.md | 7 +++++++ docs/stdlib/keyboard.md | 3 ++- include/coco/kernal.mfk | 7 +++++++ include/coco/keyboard.mfk | 7 +++++++ include/encoding/coco.tbl | 12 ++++++++++++ include/encoding/cocoscr.tbl | 11 +++++++++++ include/keyboard.mfk | 4 ++++ include/platform/coco_rsdos.ini | 30 ++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 12 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 docs/api/coco-programming-guide.md create mode 100644 include/coco/kernal.mfk create mode 100644 include/coco/keyboard.mfk create mode 100644 include/encoding/coco.tbl create mode 100644 include/encoding/cocoscr.tbl create mode 100644 include/platform/coco_rsdos.ini diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f404d50..96800db0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * Support for Motorola 6809 (complete, but still experimental). +* Preliminary support for Tandy Color Computer running RS-DOS. + * Added support for modifying large variables via pointers. * Added the ability to declare structure alignment. @@ -22,6 +24,7 @@ There are no built-in encodings now, the include path needs to contain the neces * Added encodings: `apple2c`, `apple2e`, `apple2gs`, +`coco`, `cocoscr`, `cpc_da`, `cpc_en`, `cpc_es`, `cpc_fr`, `cp437`, `cp850`, `cp851`, `cp852`, `cp855`, `cp858`, `cp866`, `cp1250`, `cp1251`, `cp1252`, diff --git a/docs/api/coco-programming-guide.md b/docs/api/coco-programming-guide.md new file mode 100644 index 00000000..ffe3710b --- /dev/null +++ b/docs/api/coco-programming-guide.md @@ -0,0 +1,15 @@ +[< back to index](../doc_index.md) + +### A note about Color Computer + +The `coco_rsdos` target creates binary files that can run on Tandy Color Computer running RS-DOS. + +The compiler output is a raw machine code file with the `.bin` extension, which then has to be put on a disk. +You can do it using `imgtool` from the [MAME project](https://www.mamedev.org/): + + imgtool create coco_jvc_rsdos disk_image.dsk + imgtool put coco_jvc_rsdos disk_image.dsk compiler_output.bin CO.BIN + +The resulting file can then be loaded and ran using the following commands: + + LOADM"CO":EXEC diff --git a/docs/api/target-platforms.md b/docs/api/target-platforms.md index 615aff5d..4212fa0b 100644 --- a/docs/api/target-platforms.md +++ b/docs/api/target-platforms.md @@ -99,6 +99,9 @@ The compiler emits COM files. * `cpm_z80` – CP/M on Z80 +* `coco_rsdos` – Tandy Color Computer running RS-DOS. (very experimental) +Read [the Color Computer programming guide](./coco-programming-guide.md) for more info. + * `dos_com` – a COM file for DOS on IBM PC. (very experimental) * `x16_experimental` – Commander X16; very experimental, diff --git a/docs/lang/text.md b/docs/lang/text.md index b0104246..b5c69af7 100644 --- a/docs/lang/text.md +++ b/docs/lang/text.md @@ -108,6 +108,10 @@ English, Japanese, Spanish/Italian and French/German respectively * `galaksija` – text encoding used on Galaksija computers +* `coco` – text encoding used on Tandy Color Computer + +* `cocoscr` – Tandy Color Computer screencodes + * `ebcdic` – EBCDIC codepage 037 (partial coverage) * `utf8` – UTF-8 @@ -208,6 +212,7 @@ Encoding | lowercase letters | backslash | currencies | intl | card suits `cpc_fr` | yes | no | £ | French⁷ | yes `cpc_da` | yes | no | £ | Nor/Dan. | yes `vectrex` | no | yes | | none | no +`coco`,`cocoscr` | no | yes | | none | no `pokemon1jp` | no | no | | both kana | no `pokemon1en` | yes | no | | none | no `pokemon1fr` | yes | no | | Ger/Fre. | no @@ -264,5 +269,7 @@ Encoding | new line | braces | backspace | cursor movement | text colour | rever `koi7n2` | yes | no | yes | no | no | no | no `koi8*` | yes | yes | yes | no | no | no | no `vectrex` | no | no | no | no | no | no | no +`coco` | yes | no | yes | no | no | no | no +`cocoscr` | no | no | no | no | no | no | no `utf*` | yes | yes | yes | no | no | no | no all the rest | yes | yes | no | no | no | no | no diff --git a/docs/stdlib/keyboard.md b/docs/stdlib/keyboard.md index 20ecf181..5a2eb91a 100644 --- a/docs/stdlib/keyboard.md +++ b/docs/stdlib/keyboard.md @@ -27,7 +27,8 @@ VIC 20 (requires KERNAL), Atari, Amstrad CPC, ZX Spectrum, -NEC PC-88. +NEC PC-88, +Tandy Color Computer. #### `const byte KEY_ENTER` diff --git a/include/coco/kernal.mfk b/include/coco/kernal.mfk new file mode 100644 index 00000000..ae76344d --- /dev/null +++ b/include/coco/kernal.mfk @@ -0,0 +1,7 @@ + +noinline asm void putchar(byte register(a) character) { + clr <$6f + jsr [$a002] + rts +} + diff --git a/include/coco/keyboard.mfk b/include/coco/keyboard.mfk new file mode 100644 index 00000000..7270a369 --- /dev/null +++ b/include/coco/keyboard.mfk @@ -0,0 +1,7 @@ + +noinline asm byte readkey() { + clr <$6f + jsr [$A000] + tfr b,a + rts +} diff --git a/include/encoding/coco.tbl b/include/encoding/coco.tbl new file mode 100644 index 00000000..b736f2f6 --- /dev/null +++ b/include/encoding/coco.tbl @@ -0,0 +1,12 @@ +NAME=Color-Computer +EOT=00 + +20=U+0020 +21-3f=!"#$%&'()*+,-./0123456789:;<=>? +40-5f=@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]↑← + +{b}=08 +{n}=0d +{q}=22 +{apos}=27 +^=5E diff --git a/include/encoding/cocoscr.tbl b/include/encoding/cocoscr.tbl new file mode 100644 index 00000000..0af67021 --- /dev/null +++ b/include/encoding/cocoscr.tbl @@ -0,0 +1,11 @@ +NAME=Color-Computer-Screen +EOT=D0 + +60=U+0020 +61-7f=!"#$%&'()*+,-./0123456789:;<=>? +40-5f=@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]↑← + +{b}=08 +{q}=62 +{apos}=67 +^=5E diff --git a/include/keyboard.mfk b/include/keyboard.mfk index 5329407a..ae3d87c4 100644 --- a/include/keyboard.mfk +++ b/include/keyboard.mfk @@ -144,6 +144,10 @@ __readkey__start: #define OK = 1 #endif +#if COCO +import coco/keyboard +#define OK = 1 +#endif #if not(OK) #if KEYBOARD diff --git a/include/platform/coco_rsdos.ini b/include/platform/coco_rsdos.ini new file mode 100644 index 00000000..40ae103a --- /dev/null +++ b/include/platform/coco_rsdos.ini @@ -0,0 +1,30 @@ +; a single-load program for Tandy Color Computer running RSDOS +; VERY EXPERIMENTAL +[compilation] +arch=6809 +; todo: is it ascii? +encoding=coco +screen_encoding=cocoscr +modules=default_panic,stdlib,coco/kernal +u_stack=true + +[allocation] +segments=default +segment_default_start=$3f00 +segment_default_datastart=after_code +segment_default_end=$7fff + +[define] +COCO=1 +WIDESCREEN=0 +KEYBOARD=1 +; TODO: ? +JOYSTICKS=1 +HAS_BITMAP_MODE=1 + +[output] +style=single +format=0,length_be,startaddr_be,allocated,$ff,0,0,startaddr_be +extension=.bin + + diff --git a/mkdocs.yml b/mkdocs.yml index 0a959255..20cf4d2c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -18,6 +18,7 @@ nav: - BBC Micro: api/bbcmicro-programming-guide.md - Game Boy: api/gb-programming-guide.md - NES/Famicom: api/famicom-programming-guide.md + - Color Computer: api/coco-programming-guide.md - Language reference: - Preprocessor: lang/preprocessor.md - Modules: lang/modules.md