mirror of
https://github.com/irmen/prog8.git
synced 2025-02-16 22:30:46 +00:00
Feature/read cursor position (#111)
* feat: add ability to read cursor position on CBM machines * feat: implement plot()/column() for atari target; add get_cursor(), get_column(), row(), and get_row() * feat: implement wait_key() for Commodore targets; add get_cursor(), get_column(), row(), get_row() * feat: really implement waitkey() on CBM targets * fix: make waitkey void for compatibility with atari
This commit is contained in:
parent
70436f5dca
commit
ff324955dd
@ -24,12 +24,24 @@ sub spc() {
|
|||||||
txt.chrout(' ')
|
txt.chrout(' ')
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub column(ubyte col @A) clobbers(A, X, Y) {
|
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
|
; ---- set the cursor on the given column (starting with 0) on the current line
|
||||||
; TODO
|
pokew(COLCRS, col as uword)
|
||||||
%asm {{
|
}
|
||||||
rts
|
|
||||||
}}
|
sub get_column() -> ubyte {
|
||||||
|
return peekw(COLCRS) as ubyte
|
||||||
|
}
|
||||||
|
|
||||||
|
sub row(ubyte rownum) {
|
||||||
|
; ---- set the cursor on the given row (starting with 0) on the current line
|
||||||
|
@(ROWCRS) = rownum
|
||||||
|
}
|
||||||
|
|
||||||
|
sub get_row() -> ubyte {
|
||||||
|
return @(ROWCRS)
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub fill_screen (ubyte character @ A, ubyte color @ Y) clobbers(A) {
|
asmsub fill_screen (ubyte character @ A, ubyte color @ Y) clobbers(A) {
|
||||||
@ -372,12 +384,14 @@ sub setcc (ubyte col, ubyte row, ubyte char, ubyte charcolor) {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub plot (ubyte col @ Y, ubyte row @ A) {
|
sub plot(ubyte col, ubyte rownum) {
|
||||||
; ---- set cursor at specific position
|
column(col)
|
||||||
; TODO
|
row(rownum)
|
||||||
%asm {{
|
}
|
||||||
rts
|
|
||||||
}}
|
sub get_cursor(uword colptr, uword rowptr) {
|
||||||
|
@(colptr) = get_column()
|
||||||
|
@(rowptr) = get_row()
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub width() clobbers(X,Y) -> ubyte @A {
|
asmsub width() clobbers(X,Y) -> ubyte @A {
|
||||||
|
@ -40,6 +40,45 @@ asmsub column(ubyte col @A) clobbers(A, X, Y) {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
asmsub get_column() -> ubyte @Y {
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jmp cbm.PLOT
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub row(ubyte rownum @A) clobbers(A, X, Y) {
|
||||||
|
; ---- set the cursor on the given row (starting with 0) on the current line
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jsr cbm.PLOT
|
||||||
|
tax
|
||||||
|
clc
|
||||||
|
jmp cbm.PLOT
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub get_row() -> ubyte @X {
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jmp cbm.PLOT
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub get_cursor(uword colptr, uword rowptr) {
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jsr cbm.PLOT
|
||||||
|
tya
|
||||||
|
ldy #$00
|
||||||
|
sta (colptr),y
|
||||||
|
txa
|
||||||
|
sta (rowptr),y
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
asmsub fill_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) {
|
asmsub fill_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) {
|
||||||
; ---- fill the character screen with the given fill character and character color.
|
; ---- fill the character screen with the given fill character and character color.
|
||||||
; (assumes screen and color matrix are at their default addresses)
|
; (assumes screen and color matrix are at their default addresses)
|
||||||
@ -587,4 +626,11 @@ asmsub height() clobbers(X, Y) -> ubyte @A {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asmsub waitkey() {
|
||||||
|
%asm {{
|
||||||
|
- jsr cbm.GETIN
|
||||||
|
beq -
|
||||||
|
rts
|
||||||
|
}}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,45 @@ asmsub column(ubyte col @A) clobbers(A, X, Y) {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
asmsub get_column() -> ubyte @Y {
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jmp cbm.PLOT
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub row(ubyte rownum @A) clobbers(A, X, Y) {
|
||||||
|
; ---- set the cursor on the given row (starting with 0) on the current line
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jsr cbm.PLOT
|
||||||
|
tax
|
||||||
|
clc
|
||||||
|
jmp cbm.PLOT
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub get_row() -> ubyte @X {
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jmp cbm.PLOT
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub get_cursor(uword colptr, uword rowptr) {
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jsr cbm.PLOT
|
||||||
|
tya
|
||||||
|
ldy #$00
|
||||||
|
sta (colptr),y
|
||||||
|
txa
|
||||||
|
sta (rowptr),y
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
asmsub fill_screen (ubyte character @ A, ubyte color @ Y) clobbers(A) {
|
asmsub fill_screen (ubyte character @ A, ubyte color @ Y) clobbers(A) {
|
||||||
; ---- fill the character screen with the given fill character and character color.
|
; ---- fill the character screen with the given fill character and character color.
|
||||||
; (assumes screen and color matrix are at their default addresses)
|
; (assumes screen and color matrix are at their default addresses)
|
||||||
@ -586,4 +625,11 @@ asmsub height() clobbers(X, Y) -> ubyte @A {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asmsub waitkey() {
|
||||||
|
%asm {{
|
||||||
|
- jsr cbm.GETIN
|
||||||
|
beq -
|
||||||
|
rts
|
||||||
|
}}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,43 @@ asmsub column(ubyte col @A) clobbers(A, X, Y) {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asmsub get_column() -> ubyte @Y {
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jmp cbm.PLOT
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub row(ubyte rownum @A) clobbers(A, X, Y) {
|
||||||
|
; ---- set the cursor on the given row (starting with 0) on the current line
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jsr cbm.PLOT
|
||||||
|
tax
|
||||||
|
clc
|
||||||
|
jmp cbm.PLOT
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub get_row() -> ubyte @X {
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jmp cbm.PLOT
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub get_cursor(uword colptr, uword rowptr) {
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jsr cbm.PLOT
|
||||||
|
tya
|
||||||
|
ldy #$00
|
||||||
|
sta (colptr),y
|
||||||
|
txa
|
||||||
|
sta (rowptr),y
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
asmsub fill_screen (ubyte character @ A, ubyte color @ Y) clobbers(A, X) {
|
asmsub fill_screen (ubyte character @ A, ubyte color @ Y) clobbers(A, X) {
|
||||||
; ---- fill the character screen with the given fill character and character color.
|
; ---- fill the character screen with the given fill character and character color.
|
||||||
%asm {{
|
%asm {{
|
||||||
@ -759,4 +796,11 @@ asmsub height() clobbers(X, Y) -> ubyte @A {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asmsub waitkey() {
|
||||||
|
%asm {{
|
||||||
|
- jsr cbm.GETIN
|
||||||
|
beq -
|
||||||
|
rts
|
||||||
|
}}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,45 @@ sub spc() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
asmsub get_column() -> ubyte @Y {
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jmp cbm.PLOT
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub row(ubyte rownum @A) clobbers(A, X, Y) {
|
||||||
|
; ---- set the cursor on the given row (starting with 0) on the current line
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jsr cbm.PLOT
|
||||||
|
tax
|
||||||
|
clc
|
||||||
|
jmp cbm.PLOT
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub get_row() -> ubyte @X {
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jmp cbm.PLOT
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub get_cursor(uword colptr, uword rowptr) {
|
||||||
|
%asm {{
|
||||||
|
sec
|
||||||
|
jsr cbm.PLOT
|
||||||
|
tya
|
||||||
|
ldy #$00
|
||||||
|
sta (colptr),y
|
||||||
|
txa
|
||||||
|
sta (rowptr),y
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
asmsub fill_screen (ubyte character @ A, ubyte color @ Y) clobbers(A) {
|
asmsub fill_screen (ubyte character @ A, ubyte color @ Y) clobbers(A) {
|
||||||
; ---- fill the character screen with the given fill character. color is ignored on PET
|
; ---- fill the character screen with the given fill character. color is ignored on PET
|
||||||
%asm {{
|
%asm {{
|
||||||
@ -456,4 +495,11 @@ asmsub height() clobbers(X, Y) -> ubyte @A {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asmsub waitkey() {
|
||||||
|
%asm {{
|
||||||
|
- jsr cbm.GETIN
|
||||||
|
beq -
|
||||||
|
rts
|
||||||
|
}}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user