mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
txt.waitkey() now returns the key that was pressed
This commit is contained in:
parent
f21adaa3ef
commit
8e2c304b3c
@ -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 {
|
||||||
|
@ -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
|
||||||
@ -386,13 +381,19 @@ sub setcc (ubyte col, ubyte row, ubyte char, ubyte charcolor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub plot(ubyte col, ubyte rownum) {
|
sub plot(ubyte col, ubyte rownum) {
|
||||||
column(col)
|
column(col)
|
||||||
row(rownum)
|
row(rownum)
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_cursor(uword colptr, uword rowptr) {
|
sub get_cursor(uword colptr, uword rowptr) {
|
||||||
@(colptr) = get_column()
|
@(colptr) = get_column()
|
||||||
@(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 {
|
||||||
|
@ -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 -
|
||||||
|
@ -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 -
|
||||||
|
@ -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 -
|
||||||
|
@ -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 -
|
||||||
|
@ -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 ....
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user