txt.waitkey() now returns the key that was pressed

This commit is contained in:
Irmen de Jong 2023-11-17 20:30:50 +01:00
parent f21adaa3ef
commit 8e2c304b3c
8 changed files with 27 additions and 22 deletions

View File

@ -8,6 +8,13 @@ atari {
&uword RESET_VEC = $FFFC ; 6502 reset vector, determined by the kernal if banked in &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 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 { sys {

View File

@ -25,24 +25,22 @@ sub spc() {
txt.chrout(' ') txt.chrout(' ')
} }
const uword COLCRS = 85
const uword ROWCRS = 84
sub column(ubyte col) { sub column(ubyte col) {
; ---- set the cursor on the given column (starting with 0) on the current line ; ---- 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 { sub get_column() -> ubyte {
return peekw(COLCRS) as ubyte return atari.COLCRS as ubyte
} }
sub row(ubyte rownum) { sub row(ubyte rownum) {
; ---- set the cursor on the given row (starting with 0) on the current line ; ---- set the cursor on the given row (starting with 0) on the current line
@(ROWCRS) = rownum atari.ROWCRS = rownum
} }
sub get_row() -> ubyte { sub get_row() -> ubyte {
return @(ROWCRS) return atari.ROWCRS
} }
asmsub fill_screen (ubyte character @ A, ubyte color @ Y) clobbers(A) { 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) { asmsub chrout(ubyte character @ A) {
%asm {{ %asm {{
sta _tmp_outchar+1 sta _tmp_outchar+1
@ -139,7 +134,7 @@ asmsub chrout(ubyte character @ A) {
pha pha
_tmp_outchar _tmp_outchar
lda #0 lda #0
jsr outchar jsr atari.outchar
pla pla
tay tay
pla pla
@ -395,6 +390,12 @@ sub get_cursor(uword colptr, uword rowptr) {
@(rowptr) = get_row() @(rowptr) = get_row()
} }
asmsub waitkey() -> ubyte @A {
%asm {{
jmp atari.waitkey
}}
}
asmsub width() clobbers(X,Y) -> ubyte @A { asmsub width() clobbers(X,Y) -> ubyte @A {
; -- returns the text screen width (number of columns) ; -- returns the text screen width (number of columns)
; TODO ; TODO

View File

@ -626,7 +626,7 @@ asmsub height() clobbers(X, Y) -> ubyte @A {
}} }}
} }
asmsub waitkey() { asmsub waitkey() -> ubyte @A {
%asm {{ %asm {{
- jsr cbm.GETIN - jsr cbm.GETIN
beq - beq -

View File

@ -625,7 +625,7 @@ asmsub height() clobbers(X, Y) -> ubyte @A {
}} }}
} }
asmsub waitkey() { asmsub waitkey() -> ubyte @A {
%asm {{ %asm {{
- jsr cbm.GETIN - jsr cbm.GETIN
beq - beq -

View File

@ -796,7 +796,7 @@ asmsub height() clobbers(X, Y) -> ubyte @A {
}} }}
} }
asmsub waitkey() { asmsub waitkey() -> ubyte @A {
%asm {{ %asm {{
- jsr cbm.GETIN - jsr cbm.GETIN
beq - beq -

View File

@ -495,7 +495,7 @@ asmsub height() clobbers(X, Y) -> ubyte @A {
}} }}
} }
asmsub waitkey() { asmsub waitkey() -> ubyte @A {
%asm {{ %asm {{
- jsr cbm.GETIN - jsr cbm.GETIN
beq - beq -

View File

@ -2,8 +2,6 @@
TODO 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 .... - [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 ....
... ...

View File

@ -1,6 +1,5 @@
%import textio %import textio
%zeropage basicsafe %zeropage basicsafe
%address $2000
; hello world test for Atari 8-bit ; hello world test for Atari 8-bit
@ -8,6 +7,6 @@ main {
sub start() { sub start() {
txt.print("Hello, World!") txt.print("Hello, World!")
txt.nl() txt.nl()
txt.waitkey() void txt.waitkey()
} }
} }