fix shadowing warnings in asm and library code

This commit is contained in:
Irmen de Jong 2023-08-28 17:35:53 +02:00
parent bad9dd3b3b
commit 2d7ebff8e9
17 changed files with 246 additions and 246 deletions

View File

@ -32,7 +32,7 @@ asmsub column(ubyte col @A) clobbers(A, X, Y) {
}} }}
} }
asmsub fill_screen (ubyte char @ 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)
; TODO ; TODO
@ -42,7 +42,7 @@ asmsub fill_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) {
}} }}
} }
asmsub clear_screenchars (ubyte char @ A) clobbers(Y) { asmsub clear_screenchars (ubyte character @ A) clobbers(Y) {
; ---- clear the character screen with the given fill character (leaves colors) ; ---- clear the character screen with the given fill character (leaves colors)
; (assumes screen matrix is at the default address) ; (assumes screen matrix is at the default address)
; TODO ; TODO
@ -114,10 +114,10 @@ asmsub scroll_down (bool alsocolors @ Pc) clobbers(A) {
} }
romsub $F2B0 = outchar(ubyte char @ A) romsub $F2B0 = outchar(ubyte character @ A)
romsub $F2Fd = waitkey() romsub $F2Fd = waitkey()
asmsub chrout(ubyte char @ A) { asmsub chrout(ubyte character @ A) {
%asm {{ %asm {{
sta _tmp_outchar+1 sta _tmp_outchar+1
txa txa
@ -364,7 +364,7 @@ asmsub getclr (ubyte col @A, ubyte row @Y) clobbers(Y) -> ubyte @ A {
}} }}
} }
sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) { sub setcc (ubyte col, ubyte row, ubyte char, ubyte charcolor) {
; ---- set char+color at the given position on the screen ; ---- set char+color at the given position on the screen
; TODO ; TODO
%asm {{ %asm {{

View File

@ -87,7 +87,7 @@ romsub $FFC6 = CHKIN(ubyte logical @ X) clobbers(A,X) -> bool @Pc ; (via 798
romsub $FFC9 = CHKOUT(ubyte logical @ X) clobbers(A,X) ; (via 800 ($320)) define an output channel romsub $FFC9 = CHKOUT(ubyte logical @ X) clobbers(A,X) ; (via 800 ($320)) define an output channel
romsub $FFCC = CLRCHN() clobbers(A,X) ; (via 802 ($322)) restore default devices romsub $FFCC = CLRCHN() clobbers(A,X) ; (via 802 ($322)) restore default devices
romsub $FFCF = CHRIN() clobbers(X, Y) -> ubyte @ A ; (via 804 ($324)) input a character (for keyboard, read a whole line from the screen) A=byte read. romsub $FFCF = CHRIN() clobbers(X, Y) -> ubyte @ A ; (via 804 ($324)) input a character (for keyboard, read a whole line from the screen) A=byte read.
romsub $FFD2 = CHROUT(ubyte char @ A) ; (via 806 ($326)) output a character romsub $FFD2 = CHROUT(ubyte character @ A) ; (via 806 ($326)) output a character
romsub $FFD5 = LOAD(ubyte verify @ A, uword address @ XY) -> bool @Pc, ubyte @ A, uword @ XY ; (via 816 ($330)) load from device romsub $FFD5 = LOAD(ubyte verify @ A, uword address @ XY) -> bool @Pc, ubyte @ A, uword @ XY ; (via 816 ($330)) load from device
romsub $FFD8 = SAVE(ubyte zp_startaddr @ A, uword endaddr @ XY) -> bool @ Pc, ubyte @ A ; (via 818 ($332)) save to a device romsub $FFD8 = SAVE(ubyte zp_startaddr @ A, uword endaddr @ XY) -> bool @ Pc, ubyte @ A ; (via 818 ($332)) save to a device
romsub $FFDB = SETTIM(ubyte low @ A, ubyte middle @ X, ubyte high @ Y) ; set the software clock romsub $FFDB = SETTIM(ubyte low @ A, ubyte middle @ X, ubyte high @ Y) ; set the software clock

View File

@ -533,7 +533,7 @@ _mod lda $ffff ; modified
}} }}
} }
sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) { sub setcc (ubyte col, ubyte row, ubyte character, ubyte charcolor) {
; ---- set char+color at the given position on the screen ; ---- set char+color at the given position on the screen
%asm {{ %asm {{
lda row lda row
@ -545,13 +545,13 @@ sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) {
sta _colormod+2 sta _colormod+2
lda setchr._screenrows,y lda setchr._screenrows,y
clc clc
adc column adc col
sta _charmod+1 sta _charmod+1
sta _colormod+1 sta _colormod+1
bcc + bcc +
inc _charmod+2 inc _charmod+2
inc _colormod+2 inc _colormod+2
+ lda char + lda character
_charmod sta $ffff ; modified _charmod sta $ffff ; modified
lda charcolor lda charcolor
_colormod sta $ffff ; modified _colormod sta $ffff ; modified

View File

@ -127,46 +127,46 @@ graphics {
} }
} }
sub rect(uword x, ubyte y, uword width, ubyte height) { sub rect(uword xx, ubyte yy, uword width, ubyte height) {
if width==0 or height==0 if width==0 or height==0
return return
horizontal_line(x, y, width) horizontal_line(xx, yy, width)
if height==1 if height==1
return return
horizontal_line(x, y+height-1, width) horizontal_line(xx, yy+height-1, width)
vertical_line(x, y+1, height-2) vertical_line(xx, yy+1, height-2)
if width==1 if width==1
return return
vertical_line(x+width-1, y+1, height-2) vertical_line(xx+width-1, yy+1, height-2)
} }
sub fillrect(uword x, ubyte y, uword width, ubyte height) { sub fillrect(uword xx, ubyte yy, uword width, ubyte height) {
if width==0 if width==0
return return
repeat height { repeat height {
horizontal_line(x, y, width) horizontal_line(xx, yy, width)
y++ yy++
} }
} }
sub horizontal_line(uword x, ubyte y, uword length) { sub horizontal_line(uword xx, ubyte yy, uword length) {
if length<8 { if length<8 {
internal_plotx=x internal_plotx=xx
repeat lsb(length) { repeat lsb(length) {
internal_plot(y) internal_plot(yy)
internal_plotx++ internal_plotx++
} }
return return
} }
ubyte separate_pixels = lsb(x) & 7 ubyte separate_pixels = lsb(xx) & 7
uword addr = get_y_lookup(y) + (x&$fff8) uword pixaddr = get_y_lookup(yy) + (xx&$fff8)
if separate_pixels { if separate_pixels {
%asm {{ %asm {{
lda addr lda pixaddr
sta P8ZP_SCRATCH_W1 sta P8ZP_SCRATCH_W1
lda addr+1 lda pixaddr+1
sta P8ZP_SCRATCH_W1+1 sta P8ZP_SCRATCH_W1+1
ldy separate_pixels ldy separate_pixels
lda hline_filled_right,y lda hline_filled_right,y
@ -175,7 +175,7 @@ graphics {
ora (P8ZP_SCRATCH_W1),y ora (P8ZP_SCRATCH_W1),y
sta (P8ZP_SCRATCH_W1),y sta (P8ZP_SCRATCH_W1),y
}} }}
addr += 8 pixaddr += 8
length += separate_pixels length += separate_pixels
length -= 8 length -= 8
} }
@ -191,9 +191,9 @@ graphics {
ror length ror length
lsr length+1 lsr length+1
ror length ror length
lda addr lda pixaddr
sta _modified+1 sta _modified+1
lda addr+1 lda pixaddr+1
sta _modified+2 sta _modified+2
lda length lda length
ora length+1 ora length+1
@ -227,11 +227,11 @@ hline_zero2
} }
} }
sub vertical_line(uword x, ubyte y, ubyte height) { sub vertical_line(uword xx, ubyte yy, ubyte height) {
internal_plotx = x internal_plotx = xx
repeat height { repeat height {
internal_plot(y) internal_plot(yy)
y++ yy++
} }
} }
@ -300,8 +300,8 @@ hline_zero2
; here is the non-asm code for the plot routine below: ; here is the non-asm code for the plot routine below:
; sub plot_nonasm(uword px, ubyte py) { ; sub plot_nonasm(uword px, ubyte py) {
; ubyte[] ormask = [128, 64, 32, 16, 8, 4, 2, 1] ; ubyte[] ormask = [128, 64, 32, 16, 8, 4, 2, 1]
; uword addr = BITMAP_ADDRESS + 320*(py>>3) + (py & 7) + (px & %0000000111111000) ; uword pixaddr = BITMAP_ADDRESS + 320*(py>>3) + (py & 7) + (px & %0000000111111000)
; @(addr) |= ormask[lsb(px) & 7] ; @(pixaddr) |= ormask[lsb(px) & 7]
; } ; }
inline asmsub plot(uword plotx @XY, ubyte ploty @A) clobbers (A, X, Y) { inline asmsub plot(uword plotx @XY, ubyte ploty @A) clobbers (A, X, Y) {
@ -360,7 +360,7 @@ _y_lookup_hi .byte >_plot_y_values
}} }}
} }
asmsub get_y_lookup(ubyte y @Y) -> uword @AY { asmsub get_y_lookup(ubyte yy @Y) -> uword @AY {
%asm {{ %asm {{
lda internal_plot._y_lookup_lo,y lda internal_plot._y_lookup_lo,y
pha pha

View File

@ -91,7 +91,7 @@ romsub $FFC6 = CHKIN(ubyte logical @ X) clobbers(A,X) -> bool @Pc ; (via 798
romsub $FFC9 = CHKOUT(ubyte logical @ X) clobbers(A,X) ; (via 800 ($320)) define an output channel romsub $FFC9 = CHKOUT(ubyte logical @ X) clobbers(A,X) ; (via 800 ($320)) define an output channel
romsub $FFCC = CLRCHN() clobbers(A,X) ; (via 802 ($322)) restore default devices romsub $FFCC = CLRCHN() clobbers(A,X) ; (via 802 ($322)) restore default devices
romsub $FFCF = CHRIN() clobbers(X, Y) -> ubyte @ A ; (via 804 ($324)) input a character (for keyboard, read a whole line from the screen) A=byte read. romsub $FFCF = CHRIN() clobbers(X, Y) -> ubyte @ A ; (via 804 ($324)) input a character (for keyboard, read a whole line from the screen) A=byte read.
romsub $FFD2 = CHROUT(ubyte char @ A) ; (via 806 ($326)) output a character romsub $FFD2 = CHROUT(ubyte character @ A) ; (via 806 ($326)) output a character
romsub $FFD5 = LOAD(ubyte verify @ A, uword address @ XY) -> bool @Pc, ubyte @ A, uword @ XY ; (via 816 ($330)) load from device romsub $FFD5 = LOAD(ubyte verify @ A, uword address @ XY) -> bool @Pc, ubyte @ A, uword @ XY ; (via 816 ($330)) load from device
romsub $FFD8 = SAVE(ubyte zp_startaddr @ A, uword endaddr @ XY) -> bool @ Pc, ubyte @ A ; (via 818 ($332)) save to a device romsub $FFD8 = SAVE(ubyte zp_startaddr @ A, uword endaddr @ XY) -> bool @ Pc, ubyte @ A ; (via 818 ($332)) save to a device
romsub $FFDB = SETTIM(ubyte low @ A, ubyte middle @ X, ubyte high @ Y) ; set the software clock romsub $FFDB = SETTIM(ubyte low @ A, ubyte middle @ X, ubyte high @ Y) ; set the software clock

View File

@ -39,7 +39,7 @@ asmsub column(ubyte col @A) clobbers(A, X, Y) {
}} }}
} }
asmsub fill_screen (ubyte char @ 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)
@ -54,7 +54,7 @@ asmsub fill_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) {
} }
asmsub clear_screenchars (ubyte char @ A) clobbers(Y) { asmsub clear_screenchars (ubyte character @ A) clobbers(Y) {
; ---- clear the character screen with the given fill character (leaves colors) ; ---- clear the character screen with the given fill character (leaves colors)
; (assumes screen matrix is at the default address) ; (assumes screen matrix is at the default address)
%asm {{ %asm {{
@ -237,7 +237,7 @@ _scroll_screen ; scroll only the screen memory
}} }}
} }
romsub $FFD2 = chrout(ubyte char @ A) ; for consistency. You can also use cbm.CHROUT directly ofcourse. romsub $FFD2 = chrout(ubyte character @ A) ; for consistency. You can also use cbm.CHROUT directly ofcourse.
asmsub print (str text @ AY) clobbers(A,Y) { asmsub print (str text @ AY) clobbers(A,Y) {
; ---- print null terminated string from A/Y ; ---- print null terminated string from A/Y
@ -532,7 +532,7 @@ _mod lda $ffff ; modified
}} }}
} }
sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) { sub setcc (ubyte col, ubyte row, ubyte character, ubyte charcolor) {
; ---- set char+color at the given position on the screen ; ---- set char+color at the given position on the screen
%asm {{ %asm {{
lda row lda row
@ -544,13 +544,13 @@ sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) {
sta _colormod+2 sta _colormod+2
lda setchr._screenrows,y lda setchr._screenrows,y
clc clc
adc column adc col
sta _charmod+1 sta _charmod+1
sta _colormod+1 sta _colormod+1
bcc + bcc +
inc _charmod+2 inc _charmod+2
inc _colormod+2 inc _colormod+2
+ lda char + lda character
_charmod sta $ffff ; modified _charmod sta $ffff ; modified
lda charcolor lda charcolor
_colormod sta $ffff ; modified _colormod sta $ffff ; modified

View File

@ -43,12 +43,12 @@ diskio {
ubyte high = cbm.CHRIN() ubyte high = cbm.CHRIN()
txt.print_uw(mkword(high, low)) txt.print_uw(mkword(high, low))
txt.spc() txt.spc()
ubyte @zp char ubyte @zp character
repeat { repeat {
char = cbm.CHRIN() character = cbm.CHRIN()
if char==0 if character==0
break break
txt.chrout(char) txt.chrout(character)
} }
txt.nl() txt.nl()
void cbm.CHRIN() ; skip 2 bytes void cbm.CHRIN() ; skip 2 bytes
@ -209,12 +209,12 @@ io_error:
; read the filename ; read the filename
repeat { repeat {
ubyte char = cbm.CHRIN() ubyte character = cbm.CHRIN()
if char==0 if character==0
break break
if char=='\"' if character=='\"'
break break
@(nameptr) = char @(nameptr) = character
nameptr++ nameptr++
} }
@ -297,19 +297,19 @@ close_end:
list_blocks = 0 ; we reuse this variable for the total number of bytes read list_blocks = 0 ; we reuse this variable for the total number of bytes read
; commander X16 supports fast block-read via macptr() kernal call ; commander X16 supports fast block-read via macptr() kernal call
uword size uword readsize
while num_bytes { while num_bytes {
size = 255 readsize = 255
if num_bytes<size if num_bytes<readsize
size = num_bytes readsize = num_bytes
size = cx16.macptr(lsb(size), bufferpointer, false) readsize = cx16.macptr(lsb(readsize), bufferpointer, false)
if_cs if_cs
goto byte_read_loop ; macptr block read not supported, do fallback loop goto byte_read_loop ; macptr block read not supported, do fallback loop
list_blocks += size list_blocks += readsize
bufferpointer += size bufferpointer += readsize
if msb(bufferpointer) == $c0 if msb(bufferpointer) == $c0
bufferpointer = mkword($a0, lsb(bufferpointer)) ; wrap over bank boundary bufferpointer = mkword($a0, lsb(bufferpointer)) ; wrap over bank boundary
num_bytes -= size num_bytes -= readsize
if cbm.READST() & $40 { if cbm.READST() & $40 {
f_close() ; end of file, close it f_close() ; end of file, close it
break break
@ -470,25 +470,25 @@ io_error:
; saves a block of memory to disk, including the default 2 byte prg header. ; saves a block of memory to disk, including the default 2 byte prg header.
sub save(uword filenameptr, uword address, uword size) -> bool { sub save(uword filenameptr, uword startaddress, uword savesize) -> bool {
return internal_save_routine(filenameptr, address, size, false) return internal_save_routine(filenameptr, startaddress, savesize, false)
} }
; like save() but omits the 2 byte prg header. ; like save() but omits the 2 byte prg header.
sub save_raw(uword filenameptr, uword address, uword size) -> bool { sub save_raw(uword filenameptr, uword startaddress, uword savesize) -> bool {
return internal_save_routine(filenameptr, address, size, true) return internal_save_routine(filenameptr, startaddress, savesize, true)
} }
sub internal_save_routine(uword filenameptr, uword address, uword size, bool headerless) -> bool { sub internal_save_routine(uword filenameptr, uword startaddress, uword savesize, bool headerless) -> bool {
cbm.SETNAM(string.length(filenameptr), filenameptr) cbm.SETNAM(string.length(filenameptr), filenameptr)
cbm.SETLFS(1, drivenumber, 0) cbm.SETLFS(1, drivenumber, 0)
uword @shared end_address = address + size uword @shared end_address = startaddress + savesize
cx16.r0L = 0 cx16.r0L = 0
%asm {{ %asm {{
lda address lda startaddress
sta P8ZP_SCRATCH_W1 sta P8ZP_SCRATCH_W1
lda address+1 lda startaddress+1
sta P8ZP_SCRATCH_W1+1 sta P8ZP_SCRATCH_W1+1
ldx end_address ldx end_address
ldy end_address+1 ldy end_address+1
@ -532,8 +532,8 @@ io_error:
; Identical to load(), but DOES INCLUDE the first 2 bytes in the file. ; Identical to load(), but DOES INCLUDE the first 2 bytes in the file.
; No program header is assumed in the file. Everything is loaded. ; No program header is assumed in the file. Everything is loaded.
; See comments on load() for more details. ; See comments on load() for more details.
sub load_raw(uword filenameptr, uword address) -> uword { sub load_raw(uword filenameptr, uword startaddress) -> uword {
return internal_load_routine(filenameptr, address, true) return internal_load_routine(filenameptr, startaddress, true)
} }
@ -606,7 +606,7 @@ io_error:
return $2000 * (cx16.getrambank() - startbank) + endaddress - startaddress return $2000 * (cx16.getrambank() - startbank) + endaddress - startaddress
} }
asmsub vload(str name @R0, ubyte bank @A, uword address @R1) clobbers(X, Y) -> ubyte @A { asmsub vload(str name @R0, ubyte bank @A, uword startaddress @R1) clobbers(X, Y) -> ubyte @A {
; -- like the basic command VLOAD "filename",drivenumber,bank,address ; -- like the basic command VLOAD "filename",drivenumber,bank,address
; loads a file into Vera's video memory in the given bank:address, returns success in A ; loads a file into Vera's video memory in the given bank:address, returns success in A
; the file has to have the usual 2 byte header (which will be skipped) ; the file has to have the usual 2 byte header (which will be skipped)
@ -645,7 +645,7 @@ internal_vload:
}} }}
} }
asmsub vload_raw(str name @R0, ubyte bank @A, uword address @R1) clobbers(X, Y) -> ubyte @A { asmsub vload_raw(str name @R0, ubyte bank @A, uword startaddress @R1) clobbers(X, Y) -> ubyte @A {
; -- like the basic command BVLOAD "filename",drivenumber,bank,address ; -- like the basic command BVLOAD "filename",drivenumber,bank,address
; loads a file into Vera's video memory in the given bank:address, returns success in A ; loads a file into Vera's video memory in the given bank:address, returns success in A
; the file is read fully including the first two bytes. ; the file is read fully including the first two bytes.

View File

@ -133,29 +133,29 @@ gfx2 {
monochrome_dont_stipple_flag = not enable monochrome_dont_stipple_flag = not enable
} }
sub rect(uword x, uword y, uword rwidth, uword rheight, ubyte color) { sub rect(uword xx, uword yy, uword rwidth, uword rheight, ubyte color) {
if rwidth==0 or rheight==0 if rwidth==0 or rheight==0
return return
horizontal_line(x, y, rwidth, color) horizontal_line(xx, yy, rwidth, color)
if rheight==1 if rheight==1
return return
horizontal_line(x, y+rheight-1, rwidth, color) horizontal_line(xx, yy+rheight-1, rwidth, color)
vertical_line(x, y+1, rheight-2, color) vertical_line(xx, yy+1, rheight-2, color)
if rwidth==1 if rwidth==1
return return
vertical_line(x+rwidth-1, y+1, rheight-2, color) vertical_line(xx+rwidth-1, yy+1, rheight-2, color)
} }
sub fillrect(uword x, uword y, uword rwidth, uword rheight, ubyte color) { sub fillrect(uword xx, uword yy, uword rwidth, uword rheight, ubyte color) {
if rwidth==0 if rwidth==0
return return
repeat rheight { repeat rheight {
horizontal_line(x, y, rwidth, color) horizontal_line(xx, yy, rwidth, color)
y++ yy++
} }
} }
sub horizontal_line(uword x, uword y, uword length, ubyte color) { sub horizontal_line(uword xx, uword yy, uword length, ubyte color) {
ubyte[9] masked_starts = [ 0, %00000001, %00000011, %00000111, %00001111, %00011111, %00111111, %01111111, %11111111] ubyte[9] masked_starts = [ 0, %00000001, %00000011, %00000111, %00001111, %00011111, %00111111, %01111111, %11111111]
ubyte[9] masked_ends = [ 0, %10000000, %11000000, %11100000, %11110000, %11111000, %11111100, %11111110, %11111111] ubyte[9] masked_ends = [ 0, %10000000, %11000000, %11100000, %11110000, %11111000, %11111100, %11111110, %11111111]
@ -164,30 +164,30 @@ gfx2 {
when active_mode { when active_mode {
1, 5 -> { 1, 5 -> {
; monochrome modes, either resolution ; monochrome modes, either resolution
ubyte separate_pixels = (8-lsb(x)) & 7 ubyte separate_pixels = (8-lsb(xx)) & 7
if separate_pixels as uword > length if separate_pixels as uword > length
separate_pixels = lsb(length) separate_pixels = lsb(length)
if separate_pixels { if separate_pixels {
if monochrome_dont_stipple_flag { if monochrome_dont_stipple_flag {
position(x,y) position(xx,yy)
cx16.VERA_ADDR_H &= %00000111 ; vera auto-increment off cx16.VERA_ADDR_H &= %00000111 ; vera auto-increment off
if color if color
cx16.VERA_DATA0 |= masked_starts[separate_pixels] cx16.VERA_DATA0 |= masked_starts[separate_pixels]
else else
cx16.VERA_DATA0 &= ~masked_starts[separate_pixels] cx16.VERA_DATA0 &= ~masked_starts[separate_pixels]
x += separate_pixels xx += separate_pixels
} else { } else {
repeat separate_pixels { repeat separate_pixels {
plot(x, y, color) plot(xx, yy, color)
x++ xx++
} }
} }
length -= separate_pixels length -= separate_pixels
} }
if length { if length {
position(x, y) position(xx, yy)
separate_pixels = lsb(length) & 7 separate_pixels = lsb(length) & 7
x += length & $fff8 xx += length & $fff8
%asm {{ %asm {{
lsr length+1 lsr length+1
ror length ror length
@ -203,7 +203,7 @@ gfx2 {
beq _stipple beq _stipple
ldy #255 ; don't stipple ldy #255 ; don't stipple
bra _loop bra _loop
_stipple lda y _stipple lda yy
and #1 ; determine stipple pattern to use and #1 ; determine stipple pattern to use
bne + bne +
ldy #%01010101 ldy #%01010101
@ -229,8 +229,8 @@ _done
cx16.VERA_DATA0 &= ~masked_ends[separate_pixels] cx16.VERA_DATA0 &= ~masked_ends[separate_pixels]
} else { } else {
repeat separate_pixels { repeat separate_pixels {
plot(x, y, color) plot(xx, yy, color)
x++ xx++
} }
} }
} }
@ -238,7 +238,7 @@ _done
} }
4 -> { 4 -> {
; lores 256c ; lores 256c
position(x, y) position(xx, yy)
%asm {{ %asm {{
lda color lda color
ldx length+1 ldx length+1
@ -266,7 +266,7 @@ _done
colorbits[ii] = color colorbits[ii] = color
color <<= 2 color <<= 2
} }
void addr_mul_24_for_highres_4c(y, x) ; 24 bits result is in r0 and r1L (highest byte) void addr_mul_24_for_highres_4c(yy, xx) ; 24 bits result is in r0 and r1L (highest byte)
%asm {{ %asm {{
lda cx16.VERA_ADDR_H lda cx16.VERA_ADDR_H
and #%00000111 ; no auto advance and #%00000111 ; no auto advance
@ -279,7 +279,7 @@ _done
sta cx16.VERA_ADDR_L sta cx16.VERA_ADDR_L
lda cx16.r0+1 lda cx16.r0+1
sta cx16.VERA_ADDR_M sta cx16.VERA_ADDR_M
ldx x ldx xx
}} }}
repeat length { repeat length {
@ -305,15 +305,15 @@ _done
} }
} }
sub vertical_line(uword x, uword y, uword lheight, ubyte color) { sub vertical_line(uword xx, uword yy, uword lheight, ubyte color) {
when active_mode { when active_mode {
1, 5 -> { 1, 5 -> {
; monochrome, lo-res ; monochrome, lo-res
cx16.r15L = gfx2.plot.bits[x as ubyte & 7] ; bitmask cx16.r15L = gfx2.plot.maskbits[xx as ubyte & 7] ; bitmask
if color { if color {
if monochrome_dont_stipple_flag { if monochrome_dont_stipple_flag {
; draw continuous line. ; draw continuous line.
position2(x,y,true) position2(xx,yy,true)
if active_mode==1 if active_mode==1
set_both_strides(11) ; 40 increment = 1 line in 320 px monochrome set_both_strides(11) ; 40 increment = 1 line in 320 px monochrome
else else
@ -327,11 +327,11 @@ _done
} }
} else { } else {
; draw stippled line. ; draw stippled line.
if x&1 { if xx&1 {
y++ yy++
lheight-- lheight--
} }
position2(x,y,true) position2(xx,yy,true)
if active_mode==1 if active_mode==1
set_both_strides(12) ; 80 increment = 2 line in 320 px monochrome set_both_strides(12) ; 80 increment = 2 line in 320 px monochrome
else else
@ -345,7 +345,7 @@ _done
} }
} }
} else { } else {
position2(x,y,true) position2(xx,yy,true)
cx16.r15 = ~cx16.r15 ; erase pixels cx16.r15 = ~cx16.r15 ; erase pixels
if active_mode==1 if active_mode==1
set_both_strides(11) ; 40 increment = 1 line in 320 px monochrome set_both_strides(11) ; 40 increment = 1 line in 320 px monochrome
@ -363,7 +363,7 @@ _done
4 -> { 4 -> {
; lores 256c ; lores 256c
; set vera auto-increment to 320 pixel increment (=next line) ; set vera auto-increment to 320 pixel increment (=next line)
position(x,y) position(xx,yy)
cx16.VERA_ADDR_H = cx16.VERA_ADDR_H & %00000111 | (14<<4) cx16.VERA_ADDR_H = cx16.VERA_ADDR_H & %00000111 | (14<<4)
%asm {{ %asm {{
ldy lheight ldy lheight
@ -380,17 +380,17 @@ _done
; use TWO vera adress pointers simultaneously one for reading, one for writing, so auto-increment is possible ; use TWO vera adress pointers simultaneously one for reading, one for writing, so auto-increment is possible
if lheight==0 if lheight==0
return return
position2(x,y,true) position2(xx,yy,true)
set_both_strides(13) ; 160 increment = 1 line in 640 px 4c mode set_both_strides(13) ; 160 increment = 1 line in 640 px 4c mode
;; color &= 3 ;; color &= 3
;; color <<= gfx2.plot.shift4c[lsb(x) & 3] ;; color <<= gfx2.plot.shift4c[lsb(xx) & 3]
cx16.r2L = lsb(x) & 3 cx16.r2L = lsb(xx) & 3
when color & 3 { when color & 3 {
1 -> color = gfx2.plot.shiftedleft_4c_1[cx16.r2L] 1 -> color = gfx2.plot.shiftedleft_4c_1[cx16.r2L]
2 -> color = gfx2.plot.shiftedleft_4c_2[cx16.r2L] 2 -> color = gfx2.plot.shiftedleft_4c_2[cx16.r2L]
3 -> color = gfx2.plot.shiftedleft_4c_3[cx16.r2L] 3 -> color = gfx2.plot.shiftedleft_4c_3[cx16.r2L]
} }
ubyte @shared mask = gfx2.plot.mask4c[lsb(x) & 3] ubyte @shared mask = gfx2.plot.mask4c[lsb(xx) & 3]
repeat lheight { repeat lheight {
%asm {{ %asm {{
lda cx16.VERA_DATA0 lda cx16.VERA_DATA0
@ -569,8 +569,8 @@ _done
} }
} }
sub plot(uword @zp x, uword @zp y, ubyte @zp color) { sub plot(uword @zp xx, uword @zp yy, ubyte @zp color) {
ubyte[8] @shared bits = [128, 64, 32, 16, 8, 4, 2, 1] ubyte[8] @shared maskbits = [128, 64, 32, 16, 8, 4, 2, 1]
ubyte[4] @shared mask4c = [%00111111, %11001111, %11110011, %11111100] ubyte[4] @shared mask4c = [%00111111, %11001111, %11110011, %11111100]
ubyte[4] @shared shift4c = [6,4,2,0] ubyte[4] @shared shift4c = [6,4,2,0]
ubyte[4] shiftedleft_4c_1 = [1<<6, 1<<4, 1<<2, 1<<0] ubyte[4] shiftedleft_4c_1 = [1<<6, 1<<4, 1<<2, 1<<0]
@ -583,8 +583,8 @@ _done
if color { if color {
; solid color or perhaps stipple ; solid color or perhaps stipple
%asm {{ %asm {{
lda x lda xx
eor y eor yy
ora monochrome_dont_stipple_flag ora monochrome_dont_stipple_flag
and #1 and #1
}} }}
@ -605,7 +605,7 @@ _done
; TODO modes 2, 3 ; TODO modes 2, 3
4 -> { 4 -> {
; lores 256c ; lores 256c
void addr_mul_24_for_lores_256c(y, x) ; 24 bits result is in r0 and r1L (highest byte) void addr_mul_24_for_lores_256c(yy, xx) ; 24 bits result is in r0 and r1L (highest byte)
%asm {{ %asm {{
stz cx16.VERA_CTRL stz cx16.VERA_CTRL
lda cx16.r1 lda cx16.r1
@ -624,8 +624,8 @@ _done
if color { if color {
; solid color or perhaps stipple ; solid color or perhaps stipple
%asm {{ %asm {{
lda x lda xx
eor y eor yy
ora monochrome_dont_stipple_flag ora monochrome_dont_stipple_flag
and #1 and #1
}} }}
@ -645,8 +645,8 @@ _done
} }
6 -> { 6 -> {
; highres 4c ....also mostly usable for mode 2, lores 4c? ; highres 4c ....also mostly usable for mode 2, lores 4c?
void addr_mul_24_for_highres_4c(y, x) ; 24 bits result is in r0 and r1L (highest byte) void addr_mul_24_for_highres_4c(yy, xx) ; 24 bits result is in r0 and r1L (highest byte)
cx16.r2L = lsb(x) & 3 ; xbits cx16.r2L = lsb(xx) & 3 ; xbits
; color &= 3 ; color &= 3
; color <<= shift4c[cx16.r2L] ; color <<= shift4c[cx16.r2L]
when color & 3 { when color & 3 {
@ -673,65 +673,65 @@ _done
sub mode_1_prepare() { sub mode_1_prepare() {
%asm {{ %asm {{
lda x lda xx
and #7 and #7
pha ; xbits pha ; xbits
}} }}
x /= 8 xx /= 8
x += y*(320/8) xx += yy*(320/8)
%asm {{ %asm {{
stz cx16.VERA_CTRL stz cx16.VERA_CTRL
stz cx16.VERA_ADDR_H stz cx16.VERA_ADDR_H
lda x+1 lda xx+1
sta cx16.VERA_ADDR_M sta cx16.VERA_ADDR_M
lda x lda xx
sta cx16.VERA_ADDR_L sta cx16.VERA_ADDR_L
ply ; xbits ply ; xbits
lda bits,y lda maskbits,y
}} }}
} }
sub mode_5_prepare() { sub mode_5_prepare() {
%asm {{ %asm {{
lda x lda xx
and #7 and #7
pha ; xbits pha ; xbits
}} }}
x /= 8 xx /= 8
x += y*(640/8) xx += yy*(640/8)
%asm {{ %asm {{
stz cx16.VERA_CTRL stz cx16.VERA_CTRL
stz cx16.VERA_ADDR_H stz cx16.VERA_ADDR_H
lda x+1 lda xx+1
sta cx16.VERA_ADDR_M sta cx16.VERA_ADDR_M
lda x lda xx
sta cx16.VERA_ADDR_L sta cx16.VERA_ADDR_L
ply ; xbits ply ; xbits
lda bits,y lda maskbits,y
}} }}
} }
} }
sub pget(uword @zp x, uword y) -> ubyte { sub pget(uword @zp xx, uword yy) -> ubyte {
when active_mode { when active_mode {
1 -> { 1 -> {
; lores monochrome ; lores monochrome
%asm {{ %asm {{
lda x lda xx
and #7 and #7
pha ; xbits pha ; xbits
}} }}
x /= 8 xx /= 8
x += y*(320/8) xx += yy*(320/8)
%asm {{ %asm {{
stz cx16.VERA_CTRL stz cx16.VERA_CTRL
stz cx16.VERA_ADDR_H stz cx16.VERA_ADDR_H
lda x+1 lda xx+1
sta cx16.VERA_ADDR_M sta cx16.VERA_ADDR_M
lda x lda xx
sta cx16.VERA_ADDR_L sta cx16.VERA_ADDR_L
ply ; xbits ply ; xbits
lda plot.bits,y lda plot.maskbits,y
and cx16.VERA_DATA0 and cx16.VERA_DATA0
beq + beq +
lda #1 lda #1
@ -741,7 +741,7 @@ _done
; TODO modes 2, 3 ; TODO modes 2, 3
4 -> { 4 -> {
; lores 256c ; lores 256c
void addr_mul_24_for_lores_256c(y, x) ; 24 bits result is in r0 and r1L (highest byte) void addr_mul_24_for_lores_256c(yy, xx) ; 24 bits result is in r0 and r1L (highest byte)
%asm {{ %asm {{
stz cx16.VERA_CTRL stz cx16.VERA_CTRL
lda cx16.r1 lda cx16.r1
@ -756,21 +756,21 @@ _done
5 -> { 5 -> {
; hires monochrome ; hires monochrome
%asm {{ %asm {{
lda x lda xx
and #7 and #7
pha ; xbits pha ; xbits
}} }}
x /= 8 xx /= 8
x += y*(640/8) xx += yy*(640/8)
%asm {{ %asm {{
stz cx16.VERA_CTRL stz cx16.VERA_CTRL
stz cx16.VERA_ADDR_H stz cx16.VERA_ADDR_H
lda x+1 lda xx+1
sta cx16.VERA_ADDR_M sta cx16.VERA_ADDR_M
lda x lda xx
sta cx16.VERA_ADDR_L sta cx16.VERA_ADDR_L
ply ; xbits ply ; xbits
lda plot.bits,y lda plot.maskbits,y
and cx16.VERA_DATA0 and cx16.VERA_DATA0
beq + beq +
lda #1 lda #1
@ -779,7 +779,7 @@ _done
} }
6 -> { 6 -> {
; hires 4c ; hires 4c
void addr_mul_24_for_highres_4c(y, x) ; 24 bits result is in r0 and r1L (highest byte) void addr_mul_24_for_highres_4c(yy, xx) ; 24 bits result is in r0 and r1L (highest byte)
%asm {{ %asm {{
stz cx16.VERA_CTRL stz cx16.VERA_CTRL
lda cx16.r1L lda cx16.r1L
@ -791,7 +791,7 @@ _done
lda cx16.VERA_DATA0 lda cx16.VERA_DATA0
sta cx16.r0L sta cx16.r0L
}} }}
cx16.r1L = lsb(x) & 3 cx16.r1L = lsb(xx) & 3
cx16.r0L >>= gfx2.plot.shift4c[cx16.r1L] cx16.r0L >>= gfx2.plot.shift4c[cx16.r1L]
return cx16.r0L & 3 return cx16.r0L & 3
} }
@ -799,7 +799,7 @@ _done
} }
} }
sub fill(word @zp x, word @zp y, ubyte new_color) { sub fill(word @zp xx, word @zp yy, ubyte new_color) {
; Non-recursive scanline flood fill. ; Non-recursive scanline flood fill.
; based loosely on code found here https://www.codeproject.com/Articles/6017/QuickFill-An-efficient-flood-fill-algorithm ; based loosely on code found here https://www.codeproject.com/Articles/6017/QuickFill-An-efficient-flood-fill-algorithm
; with the fixes applied to the seedfill_4 routine as mentioned in the comments. ; with the fixes applied to the seedfill_4 routine as mentioned in the comments.
@ -862,85 +862,85 @@ _done
lda stack_xr_msb,y lda stack_xr_msb,y
sta x2+1 sta x2+1
lda stack_y_lsb,y lda stack_y_lsb,y
sta y sta yy
lda stack_y_msb,y lda stack_y_msb,y
sta y+1 sta yy+1
ldy cx16.r12L ldy cx16.r12L
lda stack_dy,y lda stack_dy,y
sta dy sta dy
}} }}
y+=dy yy+=dy
} }
cx16.r11L = pget(x as uword, y as uword) ; old_color cx16.r11L = pget(xx as uword, yy as uword) ; old_color
if cx16.r11L == cx16.r10L if cx16.r11L == cx16.r10L
return return
if x<0 or x > width-1 or y<0 or y > height-1 if xx<0 or xx>width-1 or yy<0 or yy>height-1
return return
push_stack(x, x, y, 1) push_stack(xx, xx, yy, 1)
push_stack(x, x, y + 1, -1) push_stack(xx, xx, yy + 1, -1)
word left = 0 word left = 0
while cx16.r12L { while cx16.r12L {
pop_stack() pop_stack()
x = x1 xx = x1
while x >= 0 and pget(x as uword, y as uword) == cx16.r11L { while xx >= 0 and pget(xx as uword, yy as uword) == cx16.r11L {
plot(x as uword, y as uword, cx16.r10L) plot(xx as uword, yy as uword, cx16.r10L)
x-- xx--
} }
if x>= x1 if xx >= x1
goto skip goto skip
left = x + 1 left = xx + 1
if left < x1 if left < x1
push_stack(left, x1 - 1, y, -dy) push_stack(left, x1 - 1, yy, -dy)
x = x1 + 1 xx = x1 + 1
do { do {
while x <= width-1 and pget(x as uword, y as uword) == cx16.r11L { while xx <= width-1 and pget(xx as uword, yy as uword) == cx16.r11L {
plot(x as uword, y as uword, cx16.r10L) plot(xx as uword, yy as uword, cx16.r10L)
x++ xx++
} }
push_stack(left, x - 1, y, dy) push_stack(left, xx - 1, yy, dy)
if x > x2 + 1 if xx > x2 + 1
push_stack(x2 + 1, x - 1, y, -dy) push_stack(x2 + 1, xx - 1, yy, -dy)
skip: skip:
x++ xx++
while x <= x2 and pget(x as uword, y as uword) != cx16.r11L while xx <= x2 and pget(xx as uword, yy as uword) != cx16.r11L
x++ xx++
left = x left = xx
} until x>x2 } until xx>x2
} }
} }
sub position(uword @zp x, uword y) { sub position(uword @zp xx, uword yy) {
when active_mode { when active_mode {
1 -> { 1 -> {
; lores monochrome ; lores monochrome
cx16.r0 = y*(320/8) + x/8 cx16.r0 = yy*(320/8) + xx/8
cx16.vaddr(0, cx16.r0, 0, 1) cx16.vaddr(0, cx16.r0, 0, 1)
} }
; TODO modes 2, 3 ; TODO modes 2, 3
4 -> { 4 -> {
; lores 256c ; lores 256c
void addr_mul_24_for_lores_256c(y, x) ; 24 bits result is in r0 and r1L (highest byte) void addr_mul_24_for_lores_256c(yy, xx) ; 24 bits result is in r0 and r1L (highest byte)
cx16.r2L = cx16.r1L cx16.r2L = cx16.r1L
cx16.vaddr(cx16.r2L, cx16.r0, 0, 1) cx16.vaddr(cx16.r2L, cx16.r0, 0, 1)
} }
5 -> { 5 -> {
; highres monochrome ; highres monochrome
cx16.r0 = y*(640/8) + x/8 cx16.r0 = yy*(640/8) + xx/8
cx16.vaddr(0, cx16.r0, 0, 1) cx16.vaddr(0, cx16.r0, 0, 1)
} }
6 -> { 6 -> {
; highres 4c ; highres 4c
void addr_mul_24_for_highres_4c(y, x) ; 24 bits result is in r0 and r1L (highest byte) void addr_mul_24_for_highres_4c(yy, xx) ; 24 bits result is in r0 and r1L (highest byte)
cx16.r2L = cx16.r1L cx16.r2L = cx16.r1L
cx16.vaddr(cx16.r2L, cx16.r0, 0, 1) cx16.vaddr(cx16.r2L, cx16.r0, 0, 1)
} }
} }
} }
sub position2(uword @zp x, uword y, bool also_port_1) { sub position2(uword @zp xx, uword yy, bool also_port_1) {
position(x, y) position(xx, yy)
if also_port_1 if also_port_1
cx16.vaddr_clone(0) cx16.vaddr_clone(0)
} }
@ -1011,7 +1011,7 @@ skip:
cx16.screen_set_charset(charset, 0) cx16.screen_set_charset(charset, 0)
} }
sub text(uword @zp x, uword y, ubyte color, uword sctextptr) { sub text(uword @zp xx, uword yy, ubyte color, uword sctextptr) {
; -- Write some text at the given pixel position. The text string must be in screencode encoding (not petscii!). ; -- Write some text at the given pixel position. The text string must be in screencode encoding (not petscii!).
; You must also have called text_charset() first to select and prepare the character set to use. ; You must also have called text_charset() first to select and prepare the character set to use.
uword chardataptr uword chardataptr
@ -1028,7 +1028,7 @@ skip:
cx16.vaddr_autoincr(charset_bank, chardataptr, 0, 1) cx16.vaddr_autoincr(charset_bank, chardataptr, 0, 1)
%asm {{ %asm {{
; pre-shift the bits ; pre-shift the bits
lda text.x lda text.xx
and #7 and #7
sta P8ZP_SCRATCH_B1 sta P8ZP_SCRATCH_B1
ldy #0 ldy #0
@ -1049,7 +1049,7 @@ skip:
bne -- bne --
}} }}
; left part of shifted char ; left part of shifted char
position2(x, y, true) position2(xx, yy, true)
set_autoincrs_mode1_or_5() set_autoincrs_mode1_or_5()
if color { if color {
%asm {{ %asm {{
@ -1074,8 +1074,8 @@ skip:
}} }}
} }
; right part of shifted char ; right part of shifted char
if lsb(x) & 7 { if lsb(xx) & 7 {
position2(x+8, y, true) position2(xx+8, yy, true)
set_autoincrs_mode1_or_5() set_autoincrs_mode1_or_5()
if color { if color {
%asm {{ %asm {{
@ -1101,7 +1101,7 @@ skip:
} }
} }
cx16.r3++ cx16.r3++
x += 8 xx += 8
} }
} }
4 -> { 4 -> {
@ -1110,8 +1110,8 @@ skip:
chardataptr = charset_addr + (@(sctextptr) as uword)*8 chardataptr = charset_addr + (@(sctextptr) as uword)*8
cx16.vaddr(charset_bank, chardataptr, 1, 1) cx16.vaddr(charset_bank, chardataptr, 1, 1)
repeat 8 { repeat 8 {
position(x,y) position(xx,yy)
y++ yy++
%asm {{ %asm {{
ldx color ldx color
lda cx16.VERA_DATA1 lda cx16.VERA_DATA1
@ -1126,8 +1126,8 @@ skip:
bne - bne -
}} }}
} }
x+=8 xx+=8
y-=8 yy-=8
sctextptr++ sctextptr++
} }
} }
@ -1138,11 +1138,11 @@ skip:
while @(sctextptr) { while @(sctextptr) {
chardataptr = charset_addr + (@(sctextptr) as uword)*8 chardataptr = charset_addr + (@(sctextptr) as uword)*8
cx16.vaddr(charset_bank, chardataptr, 1, true) ; for reading the chardata from Vera data channel 1 cx16.vaddr(charset_bank, chardataptr, 1, true) ; for reading the chardata from Vera data channel 1
position(x, y) ; only calculated once, we update vera address in the loop instead position(xx, yy) ; only calculated once, we update vera address in the loop instead
cx16.VERA_ADDR_H &= $0f ; no auto increment cx16.VERA_ADDR_H &= $0f ; no auto increment
repeat 8 { repeat 8 {
cx16.r10L = cx16.VERA_DATA1 ; get the next 8 horizontal character bits cx16.r10L = cx16.VERA_DATA1 ; get the next 8 horizontal character bits
cx16.r7 = x cx16.r7 = xx
repeat 8 { repeat 8 {
cx16.r10L <<= 1 cx16.r10L <<= 1
if_cs { if_cs {
@ -1189,7 +1189,7 @@ skip:
sta cx16.VERA_ADDR_H sta cx16.VERA_ADDR_H
}} }}
} }
x+=8 xx+=8
sctextptr++ sctextptr++
} }
} }

View File

@ -50,22 +50,22 @@ graphics {
cx16.GRAPH_draw_line(x1, y1, x2, y2) cx16.GRAPH_draw_line(x1, y1, x2, y2)
} }
sub fillrect(uword x, uword y, uword width, uword height) { sub fillrect(uword xx, uword yy, uword width, uword height) {
cx16.GRAPH_draw_rect(x, y, width, height, 0, 1) cx16.GRAPH_draw_rect(xx, yy, width, height, 0, 1)
} }
sub rect(uword x, uword y, uword width, uword height) { sub rect(uword xx, uword yy, uword width, uword height) {
cx16.GRAPH_draw_rect(x, y, width, height, 0, 0) cx16.GRAPH_draw_rect(xx, yy, width, height, 0, 0)
} }
sub horizontal_line(uword x, uword y, uword length) { sub horizontal_line(uword xx, uword yy, uword length) {
if length if length
cx16.GRAPH_draw_line(x, y, x+length-1, y) cx16.GRAPH_draw_line(xx, yy, xx+length-1, yy)
} }
sub vertical_line(uword x, uword y, uword height) { sub vertical_line(uword xx, uword yy, uword height) {
if height if height
cx16.GRAPH_draw_line(x, y, x, y+height-1) cx16.GRAPH_draw_line(xx, yy, xx, yy+height-1)
} }
sub circle(uword xcenter, ubyte ycenter, ubyte radius) { sub circle(uword xcenter, ubyte ycenter, ubyte radius) {

View File

@ -16,11 +16,11 @@ psg {
const ubyte LEFT = %01000000 const ubyte LEFT = %01000000
const ubyte RIGHT = %10000000 const ubyte RIGHT = %10000000
sub voice(ubyte voice_num, ubyte channel, ubyte volume, ubyte waveform, ubyte pulsewidth) { sub voice(ubyte voice_num, ubyte channel, ubyte vol, ubyte waveform, ubyte pulsewidth) {
; -- Enables a 'voice' on the PSG. ; -- Enables a 'voice' on the PSG.
; voice_num = 0-15, the voice number. ; voice_num = 0-15, the voice number.
; channel = either LEFT or RIGHT or (LEFT|RIGHT). Specifies the stereo channel(s) to use. ; channel = either LEFT or RIGHT or (LEFT|RIGHT). Specifies the stereo channel(s) to use.
; volume = 0-63, the starting volume for the voice ; vol = 0-63, the starting volume for the voice
; waveform = one of PULSE,SAWTOOTH,TRIANGLE,NOISE. ; waveform = one of PULSE,SAWTOOTH,TRIANGLE,NOISE.
; pulsewidth = 0-63. Specifies the pulse width for waveform=PULSE. ; pulsewidth = 0-63. Specifies the pulse width for waveform=PULSE.
envelope_states[voice_num] = 255 envelope_states[voice_num] = 255
@ -30,11 +30,11 @@ psg {
cx16.VERA_ADDR_L = lsb(cx16.r0) cx16.VERA_ADDR_L = lsb(cx16.r0)
cx16.VERA_ADDR_M = msb(cx16.r0) cx16.VERA_ADDR_M = msb(cx16.r0)
cx16.VERA_ADDR_H = 1 cx16.VERA_ADDR_H = 1
cx16.VERA_DATA0 = channel | volume cx16.VERA_DATA0 = channel | vol
cx16.VERA_ADDR_L++ cx16.VERA_ADDR_L++
cx16.VERA_DATA0 = waveform | pulsewidth cx16.VERA_DATA0 = waveform | pulsewidth
envelope_volumes[voice_num] = mkword(volume, 0) envelope_volumes[voice_num] = mkword(vol, 0)
envelope_maxvolumes[voice_num] = volume envelope_maxvolumes[voice_num] = vol
sys.irqsafe_clear_irqd() sys.irqsafe_clear_irqd()
} }

View File

@ -38,7 +38,7 @@ romsub $FFC6 = CHKIN(ubyte logical @ X) clobbers(A,X) -> bool @Pc ; (via 798
romsub $FFC9 = CHKOUT(ubyte logical @ X) clobbers(A,X) ; (via 800 ($320)) define an output channel romsub $FFC9 = CHKOUT(ubyte logical @ X) clobbers(A,X) ; (via 800 ($320)) define an output channel
romsub $FFCC = CLRCHN() clobbers(A,X) ; (via 802 ($322)) restore default devices romsub $FFCC = CLRCHN() clobbers(A,X) ; (via 802 ($322)) restore default devices
romsub $FFCF = CHRIN() clobbers(X, Y) -> ubyte @ A ; (via 804 ($324)) input a character (for keyboard, read a whole line from the screen) A=byte read. romsub $FFCF = CHRIN() clobbers(X, Y) -> ubyte @ A ; (via 804 ($324)) input a character (for keyboard, read a whole line from the screen) A=byte read.
romsub $FFD2 = CHROUT(ubyte char @ A) ; (via 806 ($326)) output a character romsub $FFD2 = CHROUT(ubyte character @ A) ; (via 806 ($326)) output a character
romsub $FFD5 = LOAD(ubyte verify @ A, uword address @ XY) -> bool @Pc, ubyte @ A, uword @ XY ; (via 816 ($330)) load from device romsub $FFD5 = LOAD(ubyte verify @ A, uword address @ XY) -> bool @Pc, ubyte @ A, uword @ XY ; (via 816 ($330)) load from device
romsub $FFD8 = SAVE(ubyte zp_startaddr @ A, uword endaddr @ XY) clobbers (X, Y) -> bool @ Pc, ubyte @ A ; (via 818 ($332)) save to a device romsub $FFD8 = SAVE(ubyte zp_startaddr @ A, uword endaddr @ XY) clobbers (X, Y) -> bool @ Pc, ubyte @ A ; (via 818 ($332)) save to a device
romsub $FFDB = SETTIM(ubyte low @ A, ubyte middle @ X, ubyte high @ Y) ; set the software clock romsub $FFDB = SETTIM(ubyte low @ A, ubyte middle @ X, ubyte high @ Y) ; set the software clock
@ -346,8 +346,8 @@ romsub $ff35 = GRAPH_draw_oval(uword x @R0, uword y @R1, uword width @R2, uword
romsub $ff38 = GRAPH_draw_image(uword x @R0, uword y @R1, uword ptr @R2, uword width @R3, uword height @R4) clobbers(A,X,Y) romsub $ff38 = GRAPH_draw_image(uword x @R0, uword y @R1, uword ptr @R2, uword width @R3, uword height @R4) clobbers(A,X,Y)
romsub $ff3b = GRAPH_set_font(uword fontptr @R0) clobbers(A,X,Y) romsub $ff3b = GRAPH_set_font(uword fontptr @R0) clobbers(A,X,Y)
romsub $ff3e = GRAPH_get_char_size(ubyte baseline @A, ubyte width @X, ubyte height_or_style @Y, bool is_control @Pc) clobbers(A,X,Y) romsub $ff3e = GRAPH_get_char_size(ubyte baseline @A, ubyte width @X, ubyte height_or_style @Y, bool is_control @Pc) clobbers(A,X,Y)
romsub $ff41 = GRAPH_put_char(uword x @R0, uword y @R1, ubyte char @A) clobbers(A,X,Y) romsub $ff41 = GRAPH_put_char(uword x @R0, uword y @R1, ubyte character @A) clobbers(A,X,Y)
romsub $ff41 = GRAPH_put_next_char(ubyte char @A) clobbers(A,X,Y) ; alias for the routine above that doesn't reset the position of the initial character romsub $ff41 = GRAPH_put_next_char(ubyte character @A) clobbers(A,X,Y) ; alias for the routine above that doesn't reset the position of the initial character
; framebuffer ; framebuffer
romsub $fef6 = FB_init() clobbers(A,X,Y) romsub $fef6 = FB_init() clobbers(A,X,Y)
@ -377,7 +377,7 @@ romsub $fee7 = memory_copy(uword source @R0, uword target @R1, uword num_bytes @
romsub $feea = memory_crc(uword address @R0, uword num_bytes @R1) clobbers(A,X,Y) -> uword @R2 romsub $feea = memory_crc(uword address @R0, uword num_bytes @R1) clobbers(A,X,Y) -> uword @R2
romsub $feed = memory_decompress(uword input @R0, uword output @R1) clobbers(A,X,Y) -> uword @R1 ; last address +1 is result in R1 romsub $feed = memory_decompress(uword input @R0, uword output @R1) clobbers(A,X,Y) -> uword @R1 ; last address +1 is result in R1
romsub $fedb = console_init(uword x @R0, uword y @R1, uword width @R2, uword height @R3) clobbers(A,X,Y) romsub $fedb = console_init(uword x @R0, uword y @R1, uword width @R2, uword height @R3) clobbers(A,X,Y)
romsub $fede = console_put_char(ubyte char @A, bool wrapping @Pc) clobbers(A,X,Y) romsub $fede = console_put_char(ubyte character @A, bool wrapping @Pc) clobbers(A,X,Y)
romsub $fee1 = console_get_char() clobbers(X,Y) -> ubyte @A romsub $fee1 = console_get_char() clobbers(X,Y) -> ubyte @A
romsub $fed8 = console_put_image(uword pointer @R0, uword width @R1, uword height @R2) clobbers(A,X,Y) romsub $fed8 = console_put_image(uword pointer @R0, uword width @R1, uword height @R2) clobbers(A,X,Y)
romsub $fed5 = console_set_paging_message(uword msgptr @R0) clobbers(A,X,Y) romsub $fed5 = console_set_paging_message(uword msgptr @R0) clobbers(A,X,Y)

View File

@ -42,7 +42,7 @@ asmsub column(ubyte col @A) clobbers(A, X, Y) {
}} }}
} }
asmsub fill_screen (ubyte char @ 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 {{
sty _ly+1 sty _ly+1
@ -88,7 +88,7 @@ set_vera_textmatrix_addresses:
}} }}
} }
asmsub clear_screenchars (ubyte char @ A) clobbers(X, Y) { asmsub clear_screenchars (ubyte character @ A) clobbers(X, Y) {
; ---- clear the character screen with the given fill character (leaves colors) ; ---- clear the character screen with the given fill character (leaves colors)
; (assumes screen matrix is at the default address) ; (assumes screen matrix is at the default address)
%asm {{ %asm {{
@ -384,7 +384,7 @@ _nextline
}} }}
} }
romsub $FFD2 = chrout(ubyte char @ A) ; for consistency. You can also use cbm.CHROUT directly ofcourse. romsub $FFD2 = chrout(ubyte character @ A) ; for consistency. You can also use cbm.CHROUT directly ofcourse.
asmsub print (str text @ AY) clobbers(A,Y) { asmsub print (str text @ AY) clobbers(A,Y) {
; ---- print null terminated string from A/Y ; ---- print null terminated string from A/Y
@ -674,12 +674,12 @@ asmsub getclr (ubyte col @A, ubyte row @Y) -> ubyte @ A {
}} }}
} }
sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) { sub setcc (ubyte col, ubyte row, ubyte character, ubyte charcolor) {
; ---- set char+color at the given position on the screen ; ---- 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. ; 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). ; Use setcc2 if you want Cx-16 specific feature of setting both Bg+Fg colors (is faster as well).
%asm {{ %asm {{
lda column lda col
asl a asl a
tax tax
ldy row ldy row
@ -691,7 +691,7 @@ sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) {
;clc ;clc
adc #>VERA_TEXTMATRIX_ADDR adc #>VERA_TEXTMATRIX_ADDR
sta cx16.VERA_ADDR_M sta cx16.VERA_ADDR_M
lda char lda character
sta cx16.VERA_DATA0 sta cx16.VERA_DATA0
inc cx16.VERA_ADDR_L inc cx16.VERA_ADDR_L
lda charcolor lda charcolor
@ -705,12 +705,12 @@ sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) {
}} }}
} }
sub setcc2 (ubyte column, ubyte row, ubyte char, ubyte colors) { sub setcc2 (ubyte col, ubyte row, ubyte character, ubyte colors) {
; ---- set char+color at the given position on the screen ; ---- set char+color at the given position on the screen
; note: on the CommanderX16 this allows you to set both Fg and Bg colors; ; 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! Is a bit faster than setcc() too. ; use the high nybble in A to set the Bg color! Is a bit faster than setcc() too.
%asm {{ %asm {{
lda column lda col
asl a asl a
tax tax
ldy row ldy row
@ -722,7 +722,7 @@ sub setcc2 (ubyte column, ubyte row, ubyte char, ubyte colors) {
; clc ; clc
adc #>VERA_TEXTMATRIX_ADDR adc #>VERA_TEXTMATRIX_ADDR
sta cx16.VERA_ADDR_M sta cx16.VERA_ADDR_M
lda char lda character
sta cx16.VERA_DATA0 sta cx16.VERA_DATA0
inc cx16.VERA_ADDR_L inc cx16.VERA_ADDR_L
lda colors lda colors

View File

@ -42,12 +42,12 @@ diskio {
ubyte high = cbm.CHRIN() ubyte high = cbm.CHRIN()
txt.print_uw(mkword(high, low)) txt.print_uw(mkword(high, low))
txt.spc() txt.spc()
ubyte @zp char ubyte @zp character
repeat { repeat {
char = cbm.CHRIN() character = cbm.CHRIN()
if char==0 if character==0
break break
txt.chrout(char) txt.chrout(character)
} }
txt.nl() txt.nl()
void cbm.CHRIN() ; skip 2 bytes void cbm.CHRIN() ; skip 2 bytes
@ -211,12 +211,12 @@ io_error:
; read the filename ; read the filename
repeat { repeat {
ubyte char = cbm.CHRIN() ubyte character = cbm.CHRIN()
if char==0 if character==0
break break
if char=='\"' if character=='\"'
break break
@(nameptr) = char @(nameptr) = character
nameptr++ nameptr++
} }
@ -444,16 +444,16 @@ io_error:
goto done goto done
} }
sub save(uword filenameptr, uword address, uword size) -> bool { sub save(uword filenameptr, uword start_address, uword savesize) -> bool {
cbm.SETNAM(string.length(filenameptr), filenameptr) cbm.SETNAM(string.length(filenameptr), filenameptr)
cbm.SETLFS(1, drivenumber, 0) cbm.SETLFS(1, drivenumber, 0)
uword @shared end_address = address + size uword @shared end_address = start_address + savesize
cx16.r0L = 0 cx16.r0L = 0
%asm {{ %asm {{
lda address lda start_address
sta P8ZP_SCRATCH_W1 sta P8ZP_SCRATCH_W1
lda address+1 lda start_address+1
sta P8ZP_SCRATCH_W1+1 sta P8ZP_SCRATCH_W1+1
lda #<P8ZP_SCRATCH_W1 lda #<P8ZP_SCRATCH_W1
ldx end_address ldx end_address
@ -504,16 +504,16 @@ io_error:
; Identical to load(), but DOES INCLUDE the first 2 bytes in the file. ; Identical to load(), but DOES INCLUDE the first 2 bytes in the file.
; No program header is assumed in the file. Everything is loaded. ; No program header is assumed in the file. Everything is loaded.
; See comments on load() for more details. ; See comments on load() for more details.
sub load_raw(uword filenameptr, uword address) -> uword { sub load_raw(uword filenameptr, uword start_address) -> uword {
; read the 2 header bytes separately to skip them ; read the 2 header bytes separately to skip them
if not f_open(filenameptr) if not f_open(filenameptr)
return 0 return 0
cx16.r1 = f_read(address, 2) cx16.r1 = f_read(start_address, 2)
f_close() f_close()
if cx16.r1!=2 if cx16.r1!=2
return 0 return 0
address += 2 start_address += 2
return load(filenameptr, address) return load(filenameptr, start_address)
} }
sub delete(uword filenameptr) { sub delete(uword filenameptr) {

View File

@ -27,7 +27,7 @@ romsub $FFC6 = CHKIN(ubyte logical @ X) clobbers(A,X) -> bool @Pc ; define an
romsub $FFC9 = CHKOUT(ubyte logical @ X) clobbers(A,X) ; define an output channel romsub $FFC9 = CHKOUT(ubyte logical @ X) clobbers(A,X) ; define an output channel
romsub $FFCC = CLRCHN() clobbers(A,X) ; restore default devices romsub $FFCC = CLRCHN() clobbers(A,X) ; restore default devices
romsub $FFCF = CHRIN() clobbers(X, Y) -> ubyte @ A ; input a character (for keyboard, read a whole line from the screen) A=byte read. romsub $FFCF = CHRIN() clobbers(X, Y) -> ubyte @ A ; input a character (for keyboard, read a whole line from the screen) A=byte read.
romsub $FFD2 = CHROUT(ubyte char @ A) ; output a character romsub $FFD2 = CHROUT(ubyte character @ A) ; output a character
romsub $FFE1 = STOP() clobbers(X) -> bool @ Pz, ubyte @ A ; check the STOP key (and some others in A) romsub $FFE1 = STOP() clobbers(X) -> bool @ Pz, ubyte @ A ; check the STOP key (and some others in A)
romsub $FFE4 = GETIN() clobbers(X,Y) -> bool @Pc, ubyte @ A ; get a character romsub $FFE4 = GETIN() clobbers(X,Y) -> bool @Pc, ubyte @ A ; get a character
romsub $FFE7 = CLALL() clobbers(A,X) ; close all files romsub $FFE7 = CLALL() clobbers(A,X) ; close all files

View File

@ -28,7 +28,7 @@ sub spc() {
} }
asmsub fill_screen (ubyte char @ 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 {{
jmp clear_screenchars jmp clear_screenchars
@ -36,7 +36,7 @@ asmsub fill_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) {
} }
asmsub clear_screenchars (ubyte char @ A) clobbers(Y) { asmsub clear_screenchars (ubyte character @ A) clobbers(Y) {
; ---- clear the character screen with the given fill character ; ---- clear the character screen with the given fill character
; (assumes screen matrix is at the default address) ; (assumes screen matrix is at the default address)
%asm {{ %asm {{
@ -139,7 +139,7 @@ asmsub scroll_down () clobbers(A,X) {
}} }}
} }
romsub $FFD2 = chrout(ubyte char @ A) ; for consistency. You can also use cbm.CHROUT directly ofcourse. romsub $FFD2 = chrout(ubyte character @ A) ; for consistency. You can also use cbm.CHROUT directly ofcourse.
asmsub print (str text @ AY) clobbers(A,Y) { asmsub print (str text @ AY) clobbers(A,Y) {
; ---- print null terminated string from A/Y ; ---- print null terminated string from A/Y
@ -396,7 +396,7 @@ sub setclr (ubyte col, ubyte row, ubyte color) {
} }
sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) { sub setcc (ubyte col, ubyte row, ubyte character, ubyte charcolor) {
; ---- set char at the given position on the screen. charcolor is ignored on PET ; ---- set char at the given position on the screen. charcolor is ignored on PET
%asm {{ %asm {{
lda row lda row
@ -406,11 +406,11 @@ sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) {
sta _charmod+2 sta _charmod+2
lda setchr._screenrows,y lda setchr._screenrows,y
clc clc
adc column adc col
sta _charmod+1 sta _charmod+1
bcc + bcc +
inc _charmod+2 inc _charmod+2
+ lda char + lda character
_charmod sta $ffff ; modified _charmod sta $ffff ; modified
rts rts
}} }}

View File

@ -225,7 +225,7 @@ _done rts
}} }}
} }
asmsub lowerchar(ubyte char @A) -> ubyte @A { asmsub lowerchar(ubyte character @A) -> ubyte @A {
%asm {{ %asm {{
and #$7f and #$7f
cmp #97 cmp #97
@ -237,7 +237,7 @@ _done rts
}} }}
} }
asmsub upperchar(ubyte char @A) -> ubyte @A { asmsub upperchar(ubyte character @A) -> ubyte @A {
%asm {{ %asm {{
cmp #65 cmp #65
bcc + bcc +
@ -280,10 +280,10 @@ _done rts
; ;
; see http://6502.org/source/strings/patmatch.htm ; see http://6502.org/source/strings/patmatch.htm
str = P8ZP_SCRATCH_W1 strptr = P8ZP_SCRATCH_W1
sta str sta strptr
sty str+1 sty strptr+1
lda cx16.r0 lda cx16.r0
sta modify_pattern1+1 sta modify_pattern1+1
sta modify_pattern2+1 sta modify_pattern2+1
@ -306,9 +306,9 @@ next lda $ffff,x ; look at next pattern character MODIFIED
iny ; no, let's look at the string iny ; no, let's look at the string
cmp #'?' ; is the pattern caracter a ques? cmp #'?' ; is the pattern caracter a ques?
bne reg ; no, it's a regular character bne reg ; no, it's a regular character
lda (str),y ; yes, so it will match anything lda (strptr),y ; yes, so it will match anything
beq fail ; except the end of string beq fail ; except the end of string
reg cmp (str),y ; are both characters the same? reg cmp (strptr),y ; are both characters the same?
bne fail ; no, so no match bne fail ; no, so no match
inx ; yes, keep checking inx ; yes, keep checking
cmp #0 ; are we at end of string? cmp #0 ; are we at end of string?
@ -330,7 +330,7 @@ stloop txa ; we first try to match with * = ""
tax tax
bcs found ; we found a match, return with c=1 bcs found ; we found a match, return with c=1
iny ; no match yet, try to grow * string iny ; no match yet, try to grow * string
lda (str),y ; are we at the end of string? lda (strptr),y ; are we at the end of string?
bne stloop ; not yet, add a character bne stloop ; not yet, add a character
fail clc ; yes, no match found, return with c=0 fail clc ; yes, no match found, return with c=0
rts rts

View File

@ -1,8 +1,8 @@
TODO TODO
==== ====
- maze example is broken on c64/c128 (not on cx16...)
- [on branch: shadowing-fixes] add shadowing warning to asm and fix shadowing errors - prefix prog8 subroutines with p8s_ instead of p8_ to not let them clash with variables in the asm?
- prefix prog8 subroutines with p8s_ instead of p8_ to not let them clash with variables in the asm
- allow 'chained' array indexing for expressions: value = ptrarray[0][0] - allow 'chained' array indexing for expressions: value = ptrarray[0][0]
- allow 'chained' array indexing for assign targets: ptrarray[0][0] = 42 this is just evaluating the lhs as a uword pointer expression - allow 'chained' array indexing for assign targets: ptrarray[0][0] = 42 this is just evaluating the lhs as a uword pointer expression