diff --git a/compiler/res/prog8lib/atari/syslib.p8 b/compiler/res/prog8lib/atari/syslib.p8 index ead2eb7ce..4b16df4bd 100644 --- a/compiler/res/prog8lib/atari/syslib.p8 +++ b/compiler/res/prog8lib/atari/syslib.p8 @@ -8,6 +8,13 @@ atari { &uword RESET_VEC = $FFFC ; 6502 reset vector, determined by the kernal if banked in &uword IRQ_VEC = $FFFE ; 6502 interrupt vector, determined by the kernal if banked in + &uword COLCRS = 85 + &ubyte ROWCRS = 84 + + romsub $F24A = getchar() -> ubyte @A + romsub $F2B0 = outchar(ubyte character @ A) + romsub $F2FD = waitkey() -> ubyte @A + } sys { diff --git a/compiler/res/prog8lib/atari/textio.p8 b/compiler/res/prog8lib/atari/textio.p8 index 393c585fe..6641a7c49 100644 --- a/compiler/res/prog8lib/atari/textio.p8 +++ b/compiler/res/prog8lib/atari/textio.p8 @@ -25,24 +25,22 @@ sub spc() { txt.chrout(' ') } -const uword COLCRS = 85 -const uword ROWCRS = 84 sub column(ubyte col) { ; ---- set the cursor on the given column (starting with 0) on the current line - pokew(COLCRS, col as uword) + atari.COLCRS = col } sub get_column() -> ubyte { - return peekw(COLCRS) as ubyte + return atari.COLCRS as ubyte } sub row(ubyte rownum) { ; ---- set the cursor on the given row (starting with 0) on the current line - @(ROWCRS) = rownum + atari.ROWCRS = rownum } sub get_row() -> ubyte { - return @(ROWCRS) + return atari.ROWCRS } asmsub fill_screen (ubyte character @ A, ubyte color @ Y) clobbers(A) { @@ -127,9 +125,6 @@ asmsub scroll_down (bool alsocolors @ Pc) clobbers(A) { } -romsub $F2B0 = outchar(ubyte character @ A) -romsub $F2Fd = waitkey() - asmsub chrout(ubyte character @ A) { %asm {{ sta _tmp_outchar+1 @@ -139,7 +134,7 @@ asmsub chrout(ubyte character @ A) { pha _tmp_outchar lda #0 - jsr outchar + jsr atari.outchar pla tay pla @@ -386,13 +381,19 @@ sub setcc (ubyte col, ubyte row, ubyte char, ubyte charcolor) { } sub plot(ubyte col, ubyte rownum) { - column(col) - row(rownum) + column(col) + row(rownum) } sub get_cursor(uword colptr, uword rowptr) { - @(colptr) = get_column() - @(rowptr) = get_row() + @(colptr) = get_column() + @(rowptr) = get_row() +} + +asmsub waitkey() -> ubyte @A { + %asm {{ + jmp atari.waitkey + }} } asmsub width() clobbers(X,Y) -> ubyte @A { diff --git a/compiler/res/prog8lib/c128/textio.p8 b/compiler/res/prog8lib/c128/textio.p8 index c0d5473f3..9eee73ca5 100644 --- a/compiler/res/prog8lib/c128/textio.p8 +++ b/compiler/res/prog8lib/c128/textio.p8 @@ -626,7 +626,7 @@ asmsub height() clobbers(X, Y) -> ubyte @A { }} } -asmsub waitkey() { +asmsub waitkey() -> ubyte @A { %asm {{ - jsr cbm.GETIN beq - diff --git a/compiler/res/prog8lib/c64/textio.p8 b/compiler/res/prog8lib/c64/textio.p8 index 8bdf8bded..0a9146da8 100644 --- a/compiler/res/prog8lib/c64/textio.p8 +++ b/compiler/res/prog8lib/c64/textio.p8 @@ -625,7 +625,7 @@ asmsub height() clobbers(X, Y) -> ubyte @A { }} } -asmsub waitkey() { +asmsub waitkey() -> ubyte @A { %asm {{ - jsr cbm.GETIN beq - diff --git a/compiler/res/prog8lib/cx16/textio.p8 b/compiler/res/prog8lib/cx16/textio.p8 index bb7747cbb..ee0213cc4 100644 --- a/compiler/res/prog8lib/cx16/textio.p8 +++ b/compiler/res/prog8lib/cx16/textio.p8 @@ -796,7 +796,7 @@ asmsub height() clobbers(X, Y) -> ubyte @A { }} } -asmsub waitkey() { +asmsub waitkey() -> ubyte @A { %asm {{ - jsr cbm.GETIN beq - diff --git a/compiler/res/prog8lib/pet32/textio.p8 b/compiler/res/prog8lib/pet32/textio.p8 index fd4fe9ad2..c64cef41e 100644 --- a/compiler/res/prog8lib/pet32/textio.p8 +++ b/compiler/res/prog8lib/pet32/textio.p8 @@ -495,7 +495,7 @@ asmsub height() clobbers(X, Y) -> ubyte @A { }} } -asmsub waitkey() { +asmsub waitkey() -> ubyte @A { %asm {{ - jsr cbm.GETIN beq - diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 1c6d8eeae..32b2a45d7 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,8 +2,6 @@ TODO ==== -- txt.waitkey() should return the pressed key? Also on atari. - - [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 .... ... diff --git a/examples/atari/hello.p8 b/examples/atari/hello.p8 index 7bf351f33..e3a35f2ad 100644 --- a/examples/atari/hello.p8 +++ b/examples/atari/hello.p8 @@ -1,6 +1,5 @@ %import textio %zeropage basicsafe -%address $2000 ; hello world test for Atari 8-bit @@ -8,6 +7,6 @@ main { sub start() { txt.print("Hello, World!") txt.nl() - txt.waitkey() + void txt.waitkey() } }