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 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 {

View File

@ -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
@ -395,6 +390,12 @@ sub get_cursor(uword colptr, uword rowptr) {
@(rowptr) = get_row()
}
asmsub waitkey() -> ubyte @A {
%asm {{
jmp atari.waitkey
}}
}
asmsub width() clobbers(X,Y) -> ubyte @A {
; -- returns the text screen width (number of columns)
; TODO

View File

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

View File

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

View File

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

View File

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

View File

@ -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 ....
...

View File

@ -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()
}
}