Skip to content

Commit

Permalink
Implement readkey and readline for Apple II
Browse files Browse the repository at this point in the history
  • Loading branch information
KarolS committed Apr 8, 2020
1 parent 29335d3 commit cd5e9de
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions docs/stdlib/frequent.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

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

Expand Down
10 changes: 5 additions & 5 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ 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

* [Bell](crossplatform/bell.mfk) (Apple II/ZX Spectrum) – a program that goes \*ding!\*

* [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

Expand Down
3 changes: 2 additions & 1 deletion examples/crossplatform/echo.mfk
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion examples/crossplatform/guess.mfk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions examples/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion examples/tests/framework.mfk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/apple2.ini
Original file line number Diff line number Diff line change
@@ -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


Expand Down
13 changes: 13 additions & 0 deletions include/apple2_kernel.mfk
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 6 additions & 0 deletions include/keyboard.mfk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cd5e9de

Please sign in to comment.