2020-08-27 16:10:22 +00:00
|
|
|
; Prog8 definitions for the Text I/O and Screen routines for the CommanderX16
|
2023-11-06 22:18:24 +00:00
|
|
|
; All routines work with Screencode character encoding, except `print`, `chrout` and `input_chars`,
|
|
|
|
; these work with PETSCII encoding instead.
|
2020-08-25 23:56:26 +00:00
|
|
|
|
2020-09-20 21:49:36 +00:00
|
|
|
%import syslib
|
2020-08-26 18:52:38 +00:00
|
|
|
%import conv
|
2020-08-25 23:56:26 +00:00
|
|
|
|
|
|
|
|
2020-08-27 16:10:22 +00:00
|
|
|
txt {
|
2020-08-25 23:56:26 +00:00
|
|
|
|
2023-12-26 22:37:59 +00:00
|
|
|
%option no_symbol_prefixing, ignore_unused
|
2023-06-29 22:29:50 +00:00
|
|
|
|
2020-09-19 22:17:33 +00:00
|
|
|
const ubyte DEFAULT_WIDTH = 80
|
|
|
|
const ubyte DEFAULT_HEIGHT = 60
|
|
|
|
|
2022-03-31 21:47:11 +00:00
|
|
|
const ubyte VERA_TEXTMATRIX_BANK = 1
|
|
|
|
const uword VERA_TEXTMATRIX_ADDR = $b000
|
|
|
|
|
2020-09-19 22:17:33 +00:00
|
|
|
|
2021-01-08 15:20:56 +00:00
|
|
|
sub clear_screen() {
|
2020-12-14 13:28:53 +00:00
|
|
|
txt.chrout(147)
|
2020-08-30 17:31:20 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 21:51:09 +00:00
|
|
|
sub home() {
|
|
|
|
txt.chrout(19)
|
|
|
|
}
|
|
|
|
|
2021-01-08 15:20:56 +00:00
|
|
|
sub nl() {
|
|
|
|
txt.chrout('\n')
|
|
|
|
}
|
|
|
|
|
2021-01-14 21:51:09 +00:00
|
|
|
sub spc() {
|
|
|
|
txt.chrout(' ')
|
2021-01-08 15:20:56 +00:00
|
|
|
}
|
|
|
|
|
2021-02-10 21:47:49 +00:00
|
|
|
asmsub column(ubyte col @A) clobbers(A, X, Y) {
|
|
|
|
; ---- set the cursor on the given column (starting with 0) on the current line
|
|
|
|
%asm {{
|
|
|
|
sec
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.PLOT
|
2021-02-10 21:47:49 +00:00
|
|
|
tay
|
|
|
|
clc
|
2023-04-28 21:13:03 +00:00
|
|
|
jmp cbm.PLOT
|
2021-02-10 21:47:49 +00:00
|
|
|
}}
|
|
|
|
}
|
2021-01-14 21:51:09 +00:00
|
|
|
|
2023-11-07 21:19:16 +00:00
|
|
|
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
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2023-08-28 15:35:53 +00:00
|
|
|
asmsub fill_screen (ubyte character @ A, ubyte color @ Y) clobbers(A, X) {
|
2020-08-31 16:23:52 +00:00
|
|
|
; ---- fill the character screen with the given fill character and character color.
|
2020-08-25 23:56:26 +00:00
|
|
|
%asm {{
|
2022-03-31 21:47:11 +00:00
|
|
|
sty _ly+1
|
2020-09-21 17:23:21 +00:00
|
|
|
pha
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.SCREEN ; get dimensions in X/Y
|
2020-08-31 16:23:52 +00:00
|
|
|
txa
|
2020-09-21 17:23:21 +00:00
|
|
|
lsr a
|
|
|
|
lsr a
|
|
|
|
sta _lx+1
|
|
|
|
lda #%00010000
|
2022-03-31 21:47:11 +00:00
|
|
|
jsr set_vera_textmatrix_addresses
|
2020-09-21 17:23:21 +00:00
|
|
|
pla
|
|
|
|
_lx ldx #0 ; modified
|
|
|
|
phy
|
|
|
|
_ly ldy #1 ; modified
|
|
|
|
- sta cx16.VERA_DATA0
|
|
|
|
sty cx16.VERA_DATA0
|
2020-08-31 16:23:52 +00:00
|
|
|
sta cx16.VERA_DATA0
|
2020-09-21 17:23:21 +00:00
|
|
|
sty cx16.VERA_DATA0
|
2020-08-31 16:23:52 +00:00
|
|
|
sta cx16.VERA_DATA0
|
2020-09-21 17:23:21 +00:00
|
|
|
sty cx16.VERA_DATA0
|
|
|
|
sta cx16.VERA_DATA0
|
|
|
|
sty cx16.VERA_DATA0
|
2020-08-31 16:23:52 +00:00
|
|
|
dex
|
|
|
|
bne -
|
2020-09-21 17:23:21 +00:00
|
|
|
ply
|
2020-08-31 16:23:52 +00:00
|
|
|
dey
|
2020-09-21 17:23:21 +00:00
|
|
|
beq +
|
|
|
|
stz cx16.VERA_ADDR_L
|
|
|
|
inc cx16.VERA_ADDR_M ; next line
|
|
|
|
bra _lx
|
2023-07-15 13:18:26 +00:00
|
|
|
+ rts
|
2022-03-31 21:47:11 +00:00
|
|
|
|
|
|
|
set_vera_textmatrix_addresses:
|
|
|
|
stz cx16.VERA_CTRL
|
|
|
|
ora #VERA_TEXTMATRIX_BANK
|
|
|
|
sta cx16.VERA_ADDR_H
|
|
|
|
stz cx16.VERA_ADDR_L ; start at (0,0)
|
|
|
|
lda #>VERA_TEXTMATRIX_ADDR
|
|
|
|
sta cx16.VERA_ADDR_M
|
|
|
|
rts
|
|
|
|
|
2020-09-21 17:23:21 +00:00
|
|
|
}}
|
2020-08-25 23:56:26 +00:00
|
|
|
}
|
|
|
|
|
2023-08-28 15:35:53 +00:00
|
|
|
asmsub clear_screenchars (ubyte character @ A) clobbers(X, Y) {
|
2020-09-04 22:17:58 +00:00
|
|
|
; ---- clear the character screen with the given fill character (leaves colors)
|
|
|
|
; (assumes screen matrix is at the default address)
|
|
|
|
%asm {{
|
|
|
|
pha
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.SCREEN ; get dimensions in X/Y
|
2020-09-21 16:42:28 +00:00
|
|
|
txa
|
2020-09-21 17:23:21 +00:00
|
|
|
lsr a
|
|
|
|
lsr a
|
|
|
|
sta _lx+1
|
|
|
|
lda #%00100000
|
2022-03-31 21:47:11 +00:00
|
|
|
jsr fill_screen.set_vera_textmatrix_addresses
|
2020-09-21 16:42:28 +00:00
|
|
|
pla
|
2020-09-21 17:23:21 +00:00
|
|
|
_lx ldx #0 ; modified
|
|
|
|
- sta cx16.VERA_DATA0
|
|
|
|
sta cx16.VERA_DATA0
|
|
|
|
sta cx16.VERA_DATA0
|
2020-09-21 16:42:28 +00:00
|
|
|
sta cx16.VERA_DATA0
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
dey
|
2020-09-21 17:23:21 +00:00
|
|
|
beq +
|
|
|
|
stz cx16.VERA_ADDR_L
|
|
|
|
inc cx16.VERA_ADDR_M ; next line
|
|
|
|
bra _lx
|
2023-07-15 13:18:26 +00:00
|
|
|
+ rts
|
2020-09-21 16:42:28 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub clear_screencolors (ubyte color @ A) clobbers(X, Y) {
|
2020-09-21 16:42:28 +00:00
|
|
|
; ---- clear the character screen colors with the given color (leaves characters).
|
|
|
|
; (assumes color matrix is at the default address)
|
|
|
|
%asm {{
|
2020-09-21 17:23:21 +00:00
|
|
|
sta _la+1
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.SCREEN ; get dimensions in X/Y
|
2020-09-04 22:17:58 +00:00
|
|
|
txa
|
2020-09-21 17:23:21 +00:00
|
|
|
lsr a
|
|
|
|
lsr a
|
|
|
|
sta _lx+1
|
2020-09-21 21:04:01 +00:00
|
|
|
stz cx16.VERA_CTRL
|
2020-09-21 17:23:21 +00:00
|
|
|
lda #%00100000
|
2022-03-31 21:47:11 +00:00
|
|
|
jsr fill_screen.set_vera_textmatrix_addresses
|
|
|
|
inc cx16.VERA_ADDR_L ; start at (1,0) - the color attribute byte
|
2020-09-21 17:23:21 +00:00
|
|
|
_lx ldx #0 ; modified
|
|
|
|
_la lda #0 ; modified
|
|
|
|
- sta cx16.VERA_DATA0
|
|
|
|
sta cx16.VERA_DATA0
|
|
|
|
sta cx16.VERA_DATA0
|
2020-09-04 22:17:58 +00:00
|
|
|
sta cx16.VERA_DATA0
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
dey
|
2020-09-21 17:23:21 +00:00
|
|
|
beq +
|
|
|
|
lda #1
|
|
|
|
sta cx16.VERA_ADDR_L
|
|
|
|
inc cx16.VERA_ADDR_M ; next line
|
|
|
|
bra _lx
|
2023-07-15 13:18:26 +00:00
|
|
|
+ rts
|
2020-09-04 22:17:58 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2020-09-21 16:42:28 +00:00
|
|
|
|
2020-08-29 22:15:18 +00:00
|
|
|
ubyte[16] color_to_charcode = [$90,$05,$1c,$9f,$9c,$1e,$1f,$9e,$81,$95,$96,$97,$98,$99,$9a,$9b]
|
|
|
|
|
|
|
|
sub color (ubyte txtcol) {
|
2020-10-17 14:00:49 +00:00
|
|
|
txtcol &= 15
|
2023-04-28 21:13:03 +00:00
|
|
|
cbm.CHROUT(color_to_charcode[txtcol])
|
2020-08-29 22:15:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub color2 (ubyte txtcol, ubyte bgcol) {
|
2020-10-17 14:00:49 +00:00
|
|
|
txtcol &= 15
|
|
|
|
bgcol &= 15
|
2023-04-28 21:13:03 +00:00
|
|
|
cbm.CHROUT(color_to_charcode[bgcol])
|
|
|
|
cbm.CHROUT(1) ; switch fg and bg colors
|
|
|
|
cbm.CHROUT(color_to_charcode[txtcol])
|
2020-08-29 22:15:18 +00:00
|
|
|
}
|
|
|
|
|
2020-09-19 20:37:24 +00:00
|
|
|
sub lowercase() {
|
2023-04-28 21:13:03 +00:00
|
|
|
cbm.CHROUT($0e)
|
2022-01-19 00:08:24 +00:00
|
|
|
; this is not 100% compatible: cx16.screen_set_charset(3, 0) ; lowercase petscii charset
|
2020-09-19 20:37:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub uppercase() {
|
2023-04-28 21:13:03 +00:00
|
|
|
cbm.CHROUT($8e)
|
2022-01-19 00:08:24 +00:00
|
|
|
; this is not 100% compatible: cx16.screen_set_charset(2, 0) ; uppercase petscii charset
|
2020-09-19 20:37:24 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 20:35:29 +00:00
|
|
|
sub iso() {
|
2023-04-28 21:13:03 +00:00
|
|
|
cbm.CHROUT($0f)
|
2022-01-19 00:08:24 +00:00
|
|
|
; This doesn't enable it completely: cx16.screen_set_charset(1, 0) ; iso charset
|
|
|
|
}
|
|
|
|
|
|
|
|
sub iso_off() {
|
|
|
|
; -- you have to call this first when switching back from iso charset to regular charset.
|
2023-04-28 21:13:03 +00:00
|
|
|
cbm.CHROUT($8f)
|
2022-01-18 20:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub scroll_left() clobbers(A, X, Y) {
|
2022-04-04 19:11:09 +00:00
|
|
|
; ---- scroll the whole screen 1 character to the left
|
2020-09-21 19:39:36 +00:00
|
|
|
; contents of the rightmost column are unchanged, you should clear/refill this yourself
|
2020-09-21 20:35:07 +00:00
|
|
|
%asm {{
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.SCREEN
|
2020-09-21 21:04:01 +00:00
|
|
|
dex
|
2020-09-21 21:39:25 +00:00
|
|
|
stx _lx+1
|
2020-09-21 21:04:01 +00:00
|
|
|
dey
|
|
|
|
sty P8ZP_SCRATCH_B1 ; number of rows to scroll
|
|
|
|
|
2020-09-21 21:39:25 +00:00
|
|
|
_nextline
|
|
|
|
stz cx16.VERA_CTRL ; data port 0: source column
|
2022-03-31 21:47:11 +00:00
|
|
|
lda #%00010000 | VERA_TEXTMATRIX_BANK ; auto increment 1
|
2020-09-21 21:39:25 +00:00
|
|
|
sta cx16.VERA_ADDR_H
|
|
|
|
lda #2
|
|
|
|
sta cx16.VERA_ADDR_L ; begin in column 1
|
2022-03-31 21:47:11 +00:00
|
|
|
lda P8ZP_SCRATCH_B1
|
|
|
|
clc
|
|
|
|
adc #>VERA_TEXTMATRIX_ADDR
|
|
|
|
tay
|
2020-09-21 21:39:25 +00:00
|
|
|
sty cx16.VERA_ADDR_M
|
|
|
|
lda #1
|
|
|
|
sta cx16.VERA_CTRL ; data port 1: destination column
|
2022-03-31 21:47:11 +00:00
|
|
|
lda #%00010000 | VERA_TEXTMATRIX_BANK ; auto increment 1
|
2020-09-21 21:39:25 +00:00
|
|
|
sta cx16.VERA_ADDR_H
|
2020-09-21 21:04:01 +00:00
|
|
|
stz cx16.VERA_ADDR_L
|
|
|
|
sty cx16.VERA_ADDR_M
|
2020-09-21 20:35:07 +00:00
|
|
|
|
2020-09-21 21:39:25 +00:00
|
|
|
_lx ldx #0 ; modified
|
|
|
|
- lda cx16.VERA_DATA0
|
|
|
|
sta cx16.VERA_DATA1 ; copy char
|
|
|
|
lda cx16.VERA_DATA0
|
|
|
|
sta cx16.VERA_DATA1 ; copy color
|
2020-09-21 21:04:01 +00:00
|
|
|
dex
|
2020-09-21 21:39:25 +00:00
|
|
|
bne -
|
2020-09-21 21:04:01 +00:00
|
|
|
dec P8ZP_SCRATCH_B1
|
2020-09-21 21:39:25 +00:00
|
|
|
bpl _nextline
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta cx16.VERA_CTRL
|
2020-09-21 20:35:07 +00:00
|
|
|
rts
|
|
|
|
}}
|
2020-09-21 19:39:36 +00:00
|
|
|
}
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub scroll_right() clobbers(A,X,Y) {
|
2022-04-04 19:11:09 +00:00
|
|
|
; ---- scroll the whole screen 1 character to the right
|
2020-09-21 19:39:36 +00:00
|
|
|
; contents of the leftmost column are unchanged, you should clear/refill this yourself
|
2020-09-21 22:00:22 +00:00
|
|
|
%asm {{
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.SCREEN
|
2020-09-21 22:00:22 +00:00
|
|
|
dex
|
|
|
|
stx _lx+1
|
|
|
|
txa
|
|
|
|
asl a
|
|
|
|
dea
|
|
|
|
sta _rcol+1
|
|
|
|
ina
|
|
|
|
ina
|
|
|
|
sta _rcol2+1
|
|
|
|
dey
|
|
|
|
sty P8ZP_SCRATCH_B1 ; number of rows to scroll
|
|
|
|
|
|
|
|
_nextline
|
|
|
|
stz cx16.VERA_CTRL ; data port 0: source column
|
2022-03-31 21:47:11 +00:00
|
|
|
lda #%00011000 | VERA_TEXTMATRIX_BANK ; auto decrement 1
|
2020-09-21 22:00:22 +00:00
|
|
|
sta cx16.VERA_ADDR_H
|
2022-03-31 21:47:11 +00:00
|
|
|
_rcol lda #79*2-1 ; modified
|
2020-09-21 22:00:22 +00:00
|
|
|
sta cx16.VERA_ADDR_L ; begin in rightmost column minus one
|
2022-03-31 21:47:11 +00:00
|
|
|
lda P8ZP_SCRATCH_B1
|
|
|
|
clc
|
|
|
|
adc #>VERA_TEXTMATRIX_ADDR
|
|
|
|
tay
|
2020-09-21 22:00:22 +00:00
|
|
|
sty cx16.VERA_ADDR_M
|
|
|
|
lda #1
|
|
|
|
sta cx16.VERA_CTRL ; data port 1: destination column
|
2022-03-31 21:47:11 +00:00
|
|
|
lda #%00011000 | VERA_TEXTMATRIX_BANK ; auto decrement 1
|
2020-09-21 22:00:22 +00:00
|
|
|
sta cx16.VERA_ADDR_H
|
2022-03-31 21:47:11 +00:00
|
|
|
_rcol2 lda #79*2+1 ; modified
|
2020-09-21 22:00:22 +00:00
|
|
|
sta cx16.VERA_ADDR_L
|
|
|
|
sty cx16.VERA_ADDR_M
|
|
|
|
|
|
|
|
_lx ldx #0 ; modified
|
|
|
|
- lda cx16.VERA_DATA0
|
|
|
|
sta cx16.VERA_DATA1 ; copy char
|
|
|
|
lda cx16.VERA_DATA0
|
|
|
|
sta cx16.VERA_DATA1 ; copy color
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
dec P8ZP_SCRATCH_B1
|
|
|
|
bpl _nextline
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta cx16.VERA_CTRL
|
|
|
|
rts
|
|
|
|
}}
|
2020-09-21 19:39:36 +00:00
|
|
|
}
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub scroll_up() clobbers(A, X, Y) {
|
2022-04-04 19:11:09 +00:00
|
|
|
; ---- scroll the whole screen 1 character up
|
2020-09-21 19:39:36 +00:00
|
|
|
; contents of the bottom row are unchanged, you should refill/clear this yourself
|
|
|
|
%asm {{
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.SCREEN
|
2020-09-21 22:18:00 +00:00
|
|
|
stx _nextline+1
|
2020-09-21 19:39:36 +00:00
|
|
|
dey
|
2020-09-21 22:18:00 +00:00
|
|
|
sty P8ZP_SCRATCH_B1
|
|
|
|
stz cx16.VERA_CTRL ; data port 0 is source
|
2022-03-31 21:47:11 +00:00
|
|
|
lda #1 | (>VERA_TEXTMATRIX_ADDR)
|
2020-09-21 22:18:00 +00:00
|
|
|
sta cx16.VERA_ADDR_M ; start at second line
|
|
|
|
stz cx16.VERA_ADDR_L
|
2022-03-31 21:47:11 +00:00
|
|
|
lda #%00010000 | VERA_TEXTMATRIX_BANK
|
2020-09-21 19:39:36 +00:00
|
|
|
sta cx16.VERA_ADDR_H ; enable auto increment by 1, bank 0.
|
2020-09-21 20:06:48 +00:00
|
|
|
|
2020-09-21 22:18:00 +00:00
|
|
|
lda #1
|
|
|
|
sta cx16.VERA_CTRL ; data port 1 is destination
|
2022-03-31 21:47:11 +00:00
|
|
|
lda #>VERA_TEXTMATRIX_ADDR
|
|
|
|
sta cx16.VERA_ADDR_M ; start at top line
|
2020-09-21 19:39:36 +00:00
|
|
|
stz cx16.VERA_ADDR_L
|
2022-03-31 21:47:11 +00:00
|
|
|
lda #%00010000 | VERA_TEXTMATRIX_BANK
|
2020-09-21 22:18:00 +00:00
|
|
|
sta cx16.VERA_ADDR_H ; enable auto increment by 1, bank 0.
|
|
|
|
|
|
|
|
_nextline
|
|
|
|
ldx #80 ; modified
|
2020-09-21 19:39:36 +00:00
|
|
|
- lda cx16.VERA_DATA0
|
2020-09-21 22:18:00 +00:00
|
|
|
sta cx16.VERA_DATA1 ; copy char
|
2020-09-21 19:39:36 +00:00
|
|
|
lda cx16.VERA_DATA0
|
2020-09-21 22:18:00 +00:00
|
|
|
sta cx16.VERA_DATA1 ; copy color
|
2020-09-21 19:39:36 +00:00
|
|
|
dex
|
2020-09-21 22:18:00 +00:00
|
|
|
bne -
|
|
|
|
dec P8ZP_SCRATCH_B1
|
|
|
|
beq +
|
|
|
|
stz cx16.VERA_CTRL ; data port 0
|
2020-09-21 20:06:48 +00:00
|
|
|
stz cx16.VERA_ADDR_L
|
2020-09-21 22:18:00 +00:00
|
|
|
inc cx16.VERA_ADDR_M
|
|
|
|
lda #1
|
|
|
|
sta cx16.VERA_CTRL ; data port 1
|
|
|
|
stz cx16.VERA_ADDR_L
|
|
|
|
inc cx16.VERA_ADDR_M
|
|
|
|
bra _nextline
|
2020-09-21 19:39:36 +00:00
|
|
|
|
2020-09-21 22:18:00 +00:00
|
|
|
+ lda #0
|
|
|
|
sta cx16.VERA_CTRL
|
|
|
|
rts
|
2020-09-21 19:39:36 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub scroll_down() clobbers(A, X, Y) {
|
2022-04-04 19:11:09 +00:00
|
|
|
; ---- scroll the whole screen 1 character down
|
2020-09-21 19:39:36 +00:00
|
|
|
; contents of the top row are unchanged, you should refill/clear this yourself
|
2020-09-21 20:06:48 +00:00
|
|
|
%asm {{
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.SCREEN
|
2020-09-21 22:18:00 +00:00
|
|
|
stx _nextline+1
|
2020-09-21 20:06:48 +00:00
|
|
|
dey
|
2020-09-21 22:18:00 +00:00
|
|
|
sty P8ZP_SCRATCH_B1
|
|
|
|
stz cx16.VERA_CTRL ; data port 0 is source
|
|
|
|
dey
|
2022-03-31 21:47:11 +00:00
|
|
|
tya
|
|
|
|
clc
|
|
|
|
adc #>VERA_TEXTMATRIX_ADDR
|
|
|
|
sta cx16.VERA_ADDR_M ; start at line before bottom line
|
2020-09-21 22:18:00 +00:00
|
|
|
stz cx16.VERA_ADDR_L
|
2022-03-31 21:47:11 +00:00
|
|
|
lda #%00010000 | VERA_TEXTMATRIX_BANK
|
2020-09-21 20:06:48 +00:00
|
|
|
sta cx16.VERA_ADDR_H ; enable auto increment by 1, bank 0.
|
|
|
|
|
2020-09-21 22:18:00 +00:00
|
|
|
lda #1
|
|
|
|
sta cx16.VERA_CTRL ; data port 1 is destination
|
|
|
|
iny
|
2022-03-31 21:47:11 +00:00
|
|
|
tya
|
|
|
|
clc
|
|
|
|
adc #>VERA_TEXTMATRIX_ADDR
|
|
|
|
sta cx16.VERA_ADDR_M ; start at bottom line
|
2020-09-21 22:18:00 +00:00
|
|
|
stz cx16.VERA_ADDR_L
|
2022-03-31 21:47:11 +00:00
|
|
|
lda #%00010000 | VERA_TEXTMATRIX_BANK
|
2020-09-21 22:18:00 +00:00
|
|
|
sta cx16.VERA_ADDR_H ; enable auto increment by 1, bank 0.
|
|
|
|
|
|
|
|
_nextline
|
|
|
|
ldx #80 ; modified
|
|
|
|
- lda cx16.VERA_DATA0
|
|
|
|
sta cx16.VERA_DATA1 ; copy char
|
|
|
|
lda cx16.VERA_DATA0
|
|
|
|
sta cx16.VERA_DATA1 ; copy color
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
dec P8ZP_SCRATCH_B1
|
|
|
|
beq +
|
|
|
|
stz cx16.VERA_CTRL ; data port 0
|
|
|
|
stz cx16.VERA_ADDR_L
|
2020-09-21 20:06:48 +00:00
|
|
|
dec cx16.VERA_ADDR_M
|
2020-09-21 22:18:00 +00:00
|
|
|
lda #1
|
|
|
|
sta cx16.VERA_CTRL ; data port 1
|
|
|
|
stz cx16.VERA_ADDR_L
|
2020-09-21 20:06:48 +00:00
|
|
|
dec cx16.VERA_ADDR_M
|
2020-09-21 22:18:00 +00:00
|
|
|
bra _nextline
|
|
|
|
|
|
|
|
+ lda #0
|
|
|
|
sta cx16.VERA_CTRL
|
2020-09-21 20:06:48 +00:00
|
|
|
rts
|
|
|
|
}}
|
2020-09-21 19:39:36 +00:00
|
|
|
}
|
2020-09-19 21:00:47 +00:00
|
|
|
|
2023-11-06 22:18:24 +00:00
|
|
|
romsub $FFD2 = chrout(ubyte character @ A) ; for consistency. You can also use cbm.CHROUT directly ofcourse. Note: takes a PETSCII encoded character.
|
2020-09-19 20:10:33 +00:00
|
|
|
|
2020-08-25 23:56:26 +00:00
|
|
|
asmsub print (str text @ AY) clobbers(A,Y) {
|
2023-11-06 22:18:24 +00:00
|
|
|
; ---- print null terminated string, in PETSCII encoding, from A/Y
|
2020-08-25 23:56:26 +00:00
|
|
|
; note: the compiler contains an optimization that will replace
|
|
|
|
; a call to this subroutine with a string argument of just one char,
|
2023-04-28 21:13:03 +00:00
|
|
|
; by just one call to cbm.CHROUT of that single char.
|
2020-08-25 23:56:26 +00:00
|
|
|
%asm {{
|
|
|
|
sta P8ZP_SCRATCH_B1
|
|
|
|
sty P8ZP_SCRATCH_REG
|
|
|
|
ldy #0
|
|
|
|
- lda (P8ZP_SCRATCH_B1),y
|
|
|
|
beq +
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
iny
|
|
|
|
bne -
|
|
|
|
+ rts
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub print_ub0 (ubyte value @ A) clobbers(A,X,Y) {
|
2020-08-25 23:56:26 +00:00
|
|
|
; ---- print the ubyte in A in decimal form, with left padding 0s (3 positions total)
|
|
|
|
%asm {{
|
2020-08-26 18:52:38 +00:00
|
|
|
jsr conv.ubyte2decimal
|
2020-08-25 23:56:26 +00:00
|
|
|
pha
|
|
|
|
tya
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
pla
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
txa
|
2023-07-15 13:18:26 +00:00
|
|
|
jmp cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub print_ub (ubyte value @ A) clobbers(A,X,Y) {
|
2020-08-25 23:56:26 +00:00
|
|
|
; ---- print the ubyte in A in decimal form, without left padding 0s
|
|
|
|
%asm {{
|
2020-08-26 18:52:38 +00:00
|
|
|
jsr conv.ubyte2decimal
|
2020-08-25 23:56:26 +00:00
|
|
|
_print_byte_digits
|
|
|
|
pha
|
|
|
|
cpy #'0'
|
|
|
|
beq +
|
|
|
|
tya
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
pla
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.CHROUT
|
2021-02-28 15:15:49 +00:00
|
|
|
bra _ones
|
2020-08-25 23:56:26 +00:00
|
|
|
+ pla
|
|
|
|
cmp #'0'
|
|
|
|
beq _ones
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
_ones txa
|
2023-07-15 13:18:26 +00:00
|
|
|
jmp cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub print_b (byte value @ A) clobbers(A,X,Y) {
|
2020-08-25 23:56:26 +00:00
|
|
|
; ---- print the byte in A in decimal form, without left padding 0s
|
|
|
|
%asm {{
|
|
|
|
pha
|
|
|
|
cmp #0
|
|
|
|
bpl +
|
|
|
|
lda #'-'
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
+ pla
|
2020-08-26 18:52:38 +00:00
|
|
|
jsr conv.byte2decimal
|
2021-02-28 15:15:49 +00:00
|
|
|
bra print_ub._print_byte_digits
|
2020-08-25 23:56:26 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub print_ubhex (ubyte value @ A, bool prefix @ Pc) clobbers(A,X,Y) {
|
2020-08-25 23:56:26 +00:00
|
|
|
; ---- print the ubyte in A in hex form (if Carry is set, a radix prefix '$' is printed as well)
|
|
|
|
%asm {{
|
|
|
|
bcc +
|
|
|
|
pha
|
|
|
|
lda #'$'
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
pla
|
2020-08-26 18:52:38 +00:00
|
|
|
+ jsr conv.ubyte2hex
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
tya
|
2023-07-15 13:18:26 +00:00
|
|
|
jmp cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub print_ubbin (ubyte value @ A, bool prefix @ Pc) clobbers(A,X,Y) {
|
2020-08-25 23:56:26 +00:00
|
|
|
; ---- print the ubyte in A in binary form (if Carry is set, a radix prefix '%' is printed as well)
|
|
|
|
%asm {{
|
|
|
|
sta P8ZP_SCRATCH_B1
|
|
|
|
bcc +
|
|
|
|
lda #'%'
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
+ ldy #8
|
|
|
|
- lda #'0'
|
|
|
|
asl P8ZP_SCRATCH_B1
|
|
|
|
bcc +
|
|
|
|
lda #'1'
|
2023-04-28 21:13:03 +00:00
|
|
|
+ jsr cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
dey
|
|
|
|
bne -
|
|
|
|
rts
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub print_uwbin (uword value @ AY, bool prefix @ Pc) clobbers(A,X,Y) {
|
2020-08-25 23:56:26 +00:00
|
|
|
; ---- print the uword in A/Y in binary form (if Carry is set, a radix prefix '%' is printed as well)
|
|
|
|
%asm {{
|
|
|
|
pha
|
|
|
|
tya
|
|
|
|
jsr print_ubbin
|
|
|
|
pla
|
|
|
|
clc
|
2021-02-28 15:15:49 +00:00
|
|
|
bra print_ubbin
|
2020-08-25 23:56:26 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub print_uwhex (uword value @ AY, bool prefix @ Pc) clobbers(A,X,Y) {
|
2020-08-25 23:56:26 +00:00
|
|
|
; ---- print the uword in A/Y in hexadecimal form (4 digits)
|
|
|
|
; (if Carry is set, a radix prefix '$' is printed as well)
|
|
|
|
%asm {{
|
|
|
|
pha
|
|
|
|
tya
|
|
|
|
jsr print_ubhex
|
|
|
|
pla
|
|
|
|
clc
|
2021-02-28 15:15:49 +00:00
|
|
|
bra print_ubhex
|
2020-08-25 23:56:26 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub print_uw0 (uword value @ AY) clobbers(A,X,Y) {
|
2020-08-25 23:56:26 +00:00
|
|
|
; ---- print the uword in A/Y in decimal form, with left padding 0s (5 positions total)
|
|
|
|
%asm {{
|
2020-08-26 18:52:38 +00:00
|
|
|
jsr conv.uword2decimal
|
2020-08-25 23:56:26 +00:00
|
|
|
ldy #0
|
2020-08-26 18:52:38 +00:00
|
|
|
- lda conv.uword2decimal.decTenThousands,y
|
2020-08-25 23:56:26 +00:00
|
|
|
beq +
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
iny
|
|
|
|
bne -
|
2023-07-15 13:18:26 +00:00
|
|
|
+ rts
|
2020-08-25 23:56:26 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub print_uw (uword value @ AY) clobbers(A,X,Y) {
|
2020-08-25 23:56:26 +00:00
|
|
|
; ---- print the uword in A/Y in decimal form, without left padding 0s
|
|
|
|
%asm {{
|
2020-08-26 18:52:38 +00:00
|
|
|
jsr conv.uword2decimal
|
2020-08-25 23:56:26 +00:00
|
|
|
ldy #0
|
2020-08-26 18:52:38 +00:00
|
|
|
- lda conv.uword2decimal.decTenThousands,y
|
2020-08-25 23:56:26 +00:00
|
|
|
beq _allzero
|
|
|
|
cmp #'0'
|
|
|
|
bne _gotdigit
|
|
|
|
iny
|
|
|
|
bne -
|
|
|
|
|
|
|
|
_gotdigit
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
iny
|
2020-08-26 18:52:38 +00:00
|
|
|
lda conv.uword2decimal.decTenThousands,y
|
2020-08-25 23:56:26 +00:00
|
|
|
bne _gotdigit
|
|
|
|
rts
|
|
|
|
_allzero
|
|
|
|
lda #'0'
|
2023-04-28 21:13:03 +00:00
|
|
|
jmp cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub print_w (word value @ AY) clobbers(A,X,Y) {
|
2020-08-25 23:56:26 +00:00
|
|
|
; ---- print the (signed) word in A/Y in decimal form, without left padding 0's
|
|
|
|
%asm {{
|
|
|
|
cpy #0
|
|
|
|
bpl +
|
|
|
|
pha
|
|
|
|
lda #'-'
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.CHROUT
|
2020-08-25 23:56:26 +00:00
|
|
|
tya
|
|
|
|
eor #255
|
|
|
|
tay
|
|
|
|
pla
|
|
|
|
eor #255
|
2021-11-28 23:07:15 +00:00
|
|
|
ina
|
|
|
|
bne +
|
2020-08-25 23:56:26 +00:00
|
|
|
iny
|
2021-02-28 15:15:49 +00:00
|
|
|
+ bra print_uw
|
2020-08-25 23:56:26 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2020-09-19 20:10:33 +00:00
|
|
|
asmsub input_chars (uword buffer @ AY) clobbers(A) -> ubyte @ Y {
|
2023-11-06 22:18:24 +00:00
|
|
|
; ---- Input a string (max. 80 chars) from the keyboard, in PETSCII encoding.
|
|
|
|
; Returns length in Y. (string is terminated with a 0 byte as well)
|
2020-09-19 20:10:33 +00:00
|
|
|
; It assumes the keyboard is selected as I/O channel!
|
|
|
|
|
|
|
|
%asm {{
|
|
|
|
sta P8ZP_SCRATCH_W1
|
|
|
|
sty P8ZP_SCRATCH_W1+1
|
|
|
|
ldy #0 ; char counter = 0
|
2023-04-28 21:13:03 +00:00
|
|
|
- jsr cbm.CHRIN
|
2020-09-19 20:10:33 +00:00
|
|
|
cmp #$0d ; return (ascii 13) pressed?
|
|
|
|
beq + ; yes, end.
|
|
|
|
sta (P8ZP_SCRATCH_W1),y ; else store char in buffer
|
|
|
|
iny
|
|
|
|
bne -
|
|
|
|
+ lda #0
|
|
|
|
sta (P8ZP_SCRATCH_W1),y ; finish string with 0 byte
|
|
|
|
rts
|
|
|
|
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2020-09-19 21:00:47 +00:00
|
|
|
asmsub setchr (ubyte col @X, ubyte row @Y, ubyte character @A) clobbers(A) {
|
|
|
|
; ---- sets the character in the screen matrix at the given position
|
|
|
|
%asm {{
|
2021-02-10 21:47:49 +00:00
|
|
|
pha
|
2022-03-31 21:47:11 +00:00
|
|
|
stz cx16.VERA_CTRL
|
|
|
|
lda #VERA_TEXTMATRIX_BANK
|
|
|
|
sta cx16.VERA_ADDR_H
|
2021-02-10 21:47:49 +00:00
|
|
|
txa
|
|
|
|
asl a
|
|
|
|
sta cx16.VERA_ADDR_L
|
2022-03-31 21:47:11 +00:00
|
|
|
tya
|
2022-04-04 19:11:09 +00:00
|
|
|
; clc
|
2022-03-31 21:47:11 +00:00
|
|
|
adc #>VERA_TEXTMATRIX_ADDR
|
|
|
|
sta cx16.VERA_ADDR_M
|
2021-02-10 21:47:49 +00:00
|
|
|
pla
|
|
|
|
sta cx16.VERA_DATA0
|
|
|
|
rts
|
2020-09-19 21:00:47 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
|
|
|
asmsub getchr (ubyte col @A, ubyte row @Y) -> ubyte @ A {
|
|
|
|
; ---- get the character in the screen matrix at the given location
|
|
|
|
%asm {{
|
2021-02-10 21:47:49 +00:00
|
|
|
asl a
|
2022-03-31 21:47:11 +00:00
|
|
|
pha
|
2021-02-10 21:47:49 +00:00
|
|
|
stz cx16.VERA_CTRL
|
2022-03-31 21:47:11 +00:00
|
|
|
lda #VERA_TEXTMATRIX_BANK
|
|
|
|
sta cx16.VERA_ADDR_H
|
|
|
|
pla
|
2021-02-10 21:47:49 +00:00
|
|
|
sta cx16.VERA_ADDR_L
|
2022-03-31 21:47:11 +00:00
|
|
|
tya
|
2022-04-04 19:11:09 +00:00
|
|
|
; clc
|
2022-03-31 21:47:11 +00:00
|
|
|
adc #>VERA_TEXTMATRIX_ADDR
|
|
|
|
sta cx16.VERA_ADDR_M
|
2021-02-10 21:47:49 +00:00
|
|
|
lda cx16.VERA_DATA0
|
|
|
|
rts
|
2020-09-19 21:00:47 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
|
|
|
asmsub setclr (ubyte col @X, ubyte row @Y, ubyte color @A) clobbers(A) {
|
|
|
|
; ---- set the color in A on the screen matrix at the given position
|
2021-02-15 16:47:48 +00:00
|
|
|
; note: on the CommanderX16 this allows you to set both Fg and Bg colors;
|
|
|
|
; use the high nybble in A to set the Bg color!
|
2020-09-19 21:00:47 +00:00
|
|
|
%asm {{
|
2021-02-10 21:47:49 +00:00
|
|
|
pha
|
2022-03-31 21:47:11 +00:00
|
|
|
stz cx16.VERA_CTRL
|
|
|
|
lda #VERA_TEXTMATRIX_BANK
|
|
|
|
sta cx16.VERA_ADDR_H
|
2021-02-10 21:47:49 +00:00
|
|
|
txa
|
|
|
|
asl a
|
|
|
|
ina
|
|
|
|
sta cx16.VERA_ADDR_L
|
2022-03-31 21:47:11 +00:00
|
|
|
tya
|
2022-04-04 19:11:09 +00:00
|
|
|
; clc
|
2022-03-31 21:47:11 +00:00
|
|
|
adc #>VERA_TEXTMATRIX_ADDR
|
|
|
|
sta cx16.VERA_ADDR_M
|
2021-02-10 21:47:49 +00:00
|
|
|
pla
|
|
|
|
sta cx16.VERA_DATA0
|
|
|
|
rts
|
2020-09-19 21:00:47 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
|
|
|
asmsub getclr (ubyte col @A, ubyte row @Y) -> ubyte @ A {
|
|
|
|
; ---- get the color in the screen color matrix at the given location
|
|
|
|
%asm {{
|
2021-02-10 21:47:49 +00:00
|
|
|
asl a
|
|
|
|
ina
|
2022-03-31 21:47:11 +00:00
|
|
|
pha
|
2021-02-10 21:47:49 +00:00
|
|
|
stz cx16.VERA_CTRL
|
2022-03-31 21:47:11 +00:00
|
|
|
lda #VERA_TEXTMATRIX_BANK
|
|
|
|
sta cx16.VERA_ADDR_H
|
|
|
|
pla
|
2021-02-10 21:47:49 +00:00
|
|
|
sta cx16.VERA_ADDR_L
|
2022-03-31 21:47:11 +00:00
|
|
|
tya
|
2022-04-04 19:11:09 +00:00
|
|
|
; clc
|
2022-03-31 21:47:11 +00:00
|
|
|
adc #>VERA_TEXTMATRIX_ADDR
|
|
|
|
sta cx16.VERA_ADDR_M
|
2021-02-10 21:47:49 +00:00
|
|
|
lda cx16.VERA_DATA0
|
|
|
|
rts
|
2020-09-19 21:00:47 +00:00
|
|
|
}}
|
|
|
|
}
|
2020-08-31 19:01:18 +00:00
|
|
|
|
2023-08-28 15:35:53 +00:00
|
|
|
sub setcc (ubyte col, ubyte row, ubyte character, ubyte charcolor) {
|
2022-04-04 19:11:09 +00:00
|
|
|
; ---- set char+color at the given position on the screen
|
|
|
|
; note: color handling is the same as on the C64: it only sets the foreground color and leaves the background color as is.
|
|
|
|
; Use setcc2 if you want Cx-16 specific feature of setting both Bg+Fg colors (is faster as well).
|
2020-08-31 19:01:18 +00:00
|
|
|
%asm {{
|
2023-08-28 15:35:53 +00:00
|
|
|
lda col
|
2021-02-10 21:47:49 +00:00
|
|
|
asl a
|
|
|
|
tax
|
|
|
|
ldy row
|
|
|
|
stz cx16.VERA_CTRL
|
2022-03-31 21:47:11 +00:00
|
|
|
lda #VERA_TEXTMATRIX_BANK
|
|
|
|
sta cx16.VERA_ADDR_H
|
2021-02-10 21:47:49 +00:00
|
|
|
stx cx16.VERA_ADDR_L
|
2022-03-31 21:47:11 +00:00
|
|
|
tya
|
2022-04-04 19:11:09 +00:00
|
|
|
;clc
|
2022-03-31 21:47:11 +00:00
|
|
|
adc #>VERA_TEXTMATRIX_ADDR
|
|
|
|
sta cx16.VERA_ADDR_M
|
2023-08-28 15:35:53 +00:00
|
|
|
lda character
|
2021-02-10 21:47:49 +00:00
|
|
|
sta cx16.VERA_DATA0
|
2022-04-04 19:11:09 +00:00
|
|
|
inc cx16.VERA_ADDR_L
|
|
|
|
lda charcolor
|
|
|
|
and #$0f
|
|
|
|
sta P8ZP_SCRATCH_B1
|
2021-02-10 21:47:49 +00:00
|
|
|
lda cx16.VERA_DATA0
|
|
|
|
and #$f0
|
|
|
|
ora P8ZP_SCRATCH_B1
|
|
|
|
sta cx16.VERA_DATA0
|
|
|
|
rts
|
2020-08-31 19:01:18 +00:00
|
|
|
}}
|
2020-08-29 21:55:26 +00:00
|
|
|
}
|
|
|
|
|
2023-08-28 15:35:53 +00:00
|
|
|
sub setcc2 (ubyte col, ubyte row, ubyte character, ubyte colors) {
|
2022-04-04 19:11:09 +00:00
|
|
|
; ---- set char+color at the given position on the screen
|
2021-02-15 16:47:48 +00:00
|
|
|
; note: on the CommanderX16 this allows you to set both Fg and Bg colors;
|
2022-04-04 19:11:09 +00:00
|
|
|
; use the high nybble in A to set the Bg color! Is a bit faster than setcc() too.
|
2021-02-15 16:47:48 +00:00
|
|
|
%asm {{
|
2023-08-28 15:35:53 +00:00
|
|
|
lda col
|
2021-02-15 16:47:48 +00:00
|
|
|
asl a
|
|
|
|
tax
|
|
|
|
ldy row
|
|
|
|
stz cx16.VERA_CTRL
|
2022-03-31 21:47:11 +00:00
|
|
|
lda #VERA_TEXTMATRIX_BANK
|
|
|
|
sta cx16.VERA_ADDR_H
|
2021-02-15 16:47:48 +00:00
|
|
|
stx cx16.VERA_ADDR_L
|
2022-03-31 21:47:11 +00:00
|
|
|
tya
|
2022-04-04 19:11:09 +00:00
|
|
|
; clc
|
2022-03-31 21:47:11 +00:00
|
|
|
adc #>VERA_TEXTMATRIX_ADDR
|
|
|
|
sta cx16.VERA_ADDR_M
|
2023-08-28 15:35:53 +00:00
|
|
|
lda character
|
2021-02-15 16:47:48 +00:00
|
|
|
sta cx16.VERA_DATA0
|
2022-04-04 19:11:09 +00:00
|
|
|
inc cx16.VERA_ADDR_L
|
2021-02-15 16:47:48 +00:00
|
|
|
lda colors
|
|
|
|
sta cx16.VERA_DATA0
|
|
|
|
rts
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2023-07-15 13:18:26 +00:00
|
|
|
asmsub plot (ubyte col @ Y, ubyte row @ X) {
|
2020-08-25 23:56:26 +00:00
|
|
|
%asm {{
|
|
|
|
clc
|
2023-07-15 13:18:26 +00:00
|
|
|
jmp cbm.PLOT
|
2020-08-25 23:56:26 +00:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2020-09-19 21:23:32 +00:00
|
|
|
asmsub width() clobbers(X,Y) -> ubyte @A {
|
|
|
|
; -- returns the text screen width (number of columns)
|
|
|
|
%asm {{
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.SCREEN
|
2020-09-19 21:23:32 +00:00
|
|
|
txa
|
|
|
|
rts
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
|
|
|
asmsub height() clobbers(X, Y) -> ubyte @A {
|
|
|
|
; -- returns the text screen height (number of rows)
|
|
|
|
%asm {{
|
2023-04-28 21:13:03 +00:00
|
|
|
jsr cbm.SCREEN
|
2020-09-19 21:23:32 +00:00
|
|
|
tya
|
|
|
|
rts
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
2023-11-17 19:30:50 +00:00
|
|
|
asmsub waitkey() -> ubyte @A {
|
2023-11-07 21:19:16 +00:00
|
|
|
%asm {{
|
|
|
|
- jsr cbm.GETIN
|
|
|
|
beq -
|
|
|
|
rts
|
|
|
|
}}
|
|
|
|
}
|
2020-08-27 16:10:22 +00:00
|
|
|
}
|