diff --git a/CHANGELOG.md b/CHANGELOG.md index d4c17282..7867a43f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,8 @@ * Added detection for various PET variants and implemented `readkey` for PET. + * Implemented `readkey` and `readline` for Apple II. + * Changed the default load address for BBC Micro. * Multiple fixes to the `string`, `scrstring` and `encconv` modules. diff --git a/docs/stdlib/frequent.md b/docs/stdlib/frequent.md index 05fe55b3..fe650633 100644 --- a/docs/stdlib/frequent.md +++ b/docs/stdlib/frequent.md @@ -48,6 +48,7 @@ Available for: ZX Spectrum, NEC PC-88, MSX, +Apple II, Commodore 64 with `c64_basic` module (requires KERNAL and BASIC), Commodore 16 or Plus/4 with `c264_basic` module (requires KERNAL and BASIC). @@ -59,6 +60,7 @@ Available for: ZX Spectrum, NEC PC-88, MSX, +Apple II, 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/examples/README.md b/examples/README.md index 911e5d22..1563fe53 100644 --- a/examples/README.md +++ b/examples/README.md @@ -21,15 +21,15 @@ 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/ZX Spectrum/PC-88/MSX)– simple text input and output +* [Echo](crossplatform/echo.mfk) (C64/C16/Apple II/ZX Spectrum/PC-88/MSX)– simple text input and output -* [Calculator](crossplatform/calculator.mfk) (C64/C16/ZX Spectrum/PC-88/MSX) – simple numeric input and output +* [Calculator](crossplatform/calculator.mfk) (C64/C16/Apple II/ZX Spectrum/PC-88/MSX) – simple numeric input and output -* [Guessing game](crossplatform/guess.mfk) (C64/C16/ZX Spectrum/PC-88/MSX) – a guess-a-number game +* [Guessing game](crossplatform/guess.mfk) (C64/C16/Apple II/ZX Spectrum/PC-88/MSX) – a guess-a-number game * [Fire effect](crossplatform/fire.mfk) (C64/C16/ZX Spectrum) – a simple fire effect -* [`readkey` test](crossplatform/readkeytest.mfk) (C64/C16/PET/VIC-20/Atari/Armstrad CPC/ZX Spectrum/PC-88) – keyboard reading test +* [`readkey` test](crossplatform/readkeytest.mfk) (C64/C16/PET/VIC-20/Atari/Apple II/Armstrad CPC/ZX Spectrum/PC-88) – keyboard reading test * [Screen encoding test](crossplatform/screnctest.mfk) (C64/C16) – default-to-screen encoding conversion test @@ -37,7 +37,7 @@ If you are using a release version of the compiler, consider browsing the older * [Life](crossplatform/life.mfk) (C64/C16/Atari/ZX Spectrum) – Conway's game of life -* [Test suite](tests) (C64/C16/Atari/Armstrad CPC/ZX Spectrum/PC-88) – the semi-official test-suite for Millfork +* [Test suite](tests) (C64/C16/Atari/Apple II/BBC Micro/Armstrad CPC/ZX Spectrum/PC-88) – the semi-official test-suite for Millfork ## Commodore 64 examples diff --git a/examples/crossplatform/echo.mfk b/examples/crossplatform/echo.mfk index caba1b01..6983b546 100644 --- a/examples/crossplatform/echo.mfk +++ b/examples/crossplatform/echo.mfk @@ -15,8 +15,9 @@ void main() { pointer line while true { line = readline() - // empty line is read as a single space + // empty line is read as a single space on C64 if line[0] == 32 && line[1] == 0 { return } + if line[0] == 0 { return } putstrz(line) new_line() } diff --git a/examples/crossplatform/guess.mfk b/examples/crossplatform/guess.mfk index 89b90e8d..c375a4ec 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 +#define READKEY = CBM_64 | CBM_264 | ZX_SPECTRUM | NEC_PC_88 | APPLE_2 #if READKEY import keyboard diff --git a/examples/tests/README.md b/examples/tests/README.md index ecdb6dc3..27838929 100644 --- a/examples/tests/README.md +++ b/examples/tests/README.md @@ -28,6 +28,8 @@ note that support for these targets may end when the suite grows beyond their me * BBC Micro, loadable programs (`bbcmicro`) +* Apple II, loadable programs (`apple2`) + Compiling with the `-D PRINT_SUCCESSES` will cause the suite to print all tests, including successful ones. Otherwise, only failed tests will be printed. diff --git a/examples/tests/framework.mfk b/examples/tests/framework.mfk index 5bd82f64..efad296d 100644 --- a/examples/tests/framework.mfk +++ b/examples/tests/framework.mfk @@ -4,7 +4,7 @@ pointer current_suite_name byte current_test_number word failure_count = 0 -#if ZX_SPECTRUM || CBM || NEC_PC88 || ATARI_8 || AMSTRAD_CPC +#if ZX_SPECTRUM || CBM || NEC_PC88 || ATARI_8 || AMSTRAD_CPC || APPLE_2 import keyboard alias wait_after_failure = readkey diff --git a/include/apple2.ini b/include/apple2.ini index 89d5b089..9d840546 100644 --- a/include/apple2.ini +++ b/include/apple2.ini @@ -1,7 +1,7 @@ [compilation] arch=strict encoding=apple2 -modules=apple2_kernel,default_panic,stdlib +modules=apple2_kernel,default_panic,stdlib,default_readword lenient_encoding=true diff --git a/include/apple2_kernel.mfk b/include/apple2_kernel.mfk index 9b699c93..a875f140 100644 --- a/include/apple2_kernel.mfk +++ b/include/apple2_kernel.mfk @@ -10,3 +10,16 @@ asm void bell() @$FBE4 extern asm void putchar(byte register(a) char) @$FDED extern asm void new_line() @$FC62 extern +asm pointer readline() { + jsr $FD6A + ldx #$ff + __readline_loop: + inx + lda $200,x + cmp #$8d + bne __readline_loop + lda #0 + sta $200,x + ldx #2 + rts +} diff --git a/include/keyboard.mfk b/include/keyboard.mfk index 06e0ebbe..5329407a 100644 --- a/include/keyboard.mfk +++ b/include/keyboard.mfk @@ -112,6 +112,12 @@ noinline asm byte readkey() { #endif +#if APPLE_2 +asm byte readkey() @$FD0C extern +#define OK = 1 +#endif + + #if NEC_PC_88 asm byte readkey() @$3583 extern #define OK = 1