removed txt.VERA_TEXTMATRIX_BANK/VERA_TEXTMATRIX_ADDR it's now just txt.VERA_TEXTMATRIX (long const)

This commit is contained in:
Irmen de Jong 2024-11-15 02:05:12 +01:00
parent a874aec6a1
commit 984230e8fa
5 changed files with 39 additions and 45 deletions

View File

@ -12,9 +12,7 @@ txt {
const ubyte DEFAULT_WIDTH = 80 const ubyte DEFAULT_WIDTH = 80
const ubyte DEFAULT_HEIGHT = 60 const ubyte DEFAULT_HEIGHT = 60
const long VERA_TEXTMATRIX = $1b000
const ubyte VERA_TEXTMATRIX_BANK = 1
const uword VERA_TEXTMATRIX_ADDR = $b000
extsub $FFD2 = chrout(ubyte character @ A) ; for consistency. You can also use cbm.CHROUT directly ofcourse. Note: takes a PETSCII encoded character. extsub $FFD2 = chrout(ubyte character @ A) ; for consistency. You can also use cbm.CHROUT directly ofcourse. Note: takes a PETSCII encoded character.
@ -131,10 +129,10 @@ _ly ldy #1 ; modified
set_vera_textmatrix_addresses: set_vera_textmatrix_addresses:
stz cx16.VERA_CTRL stz cx16.VERA_CTRL
ora #VERA_TEXTMATRIX_BANK ora #VERA_TEXTMATRIX>>16
sta cx16.VERA_ADDR_H sta cx16.VERA_ADDR_H
stz cx16.VERA_ADDR_L ; start at (0,0) stz cx16.VERA_ADDR_L ; start at (0,0)
lda #>VERA_TEXTMATRIX_ADDR lda #>VERA_TEXTMATRIX
sta cx16.VERA_ADDR_M sta cx16.VERA_ADDR_M
rts rts
@ -280,18 +278,18 @@ asmsub scroll_left() clobbers(A, X, Y) {
_nextline _nextline
stz cx16.VERA_CTRL ; data port 0: source column stz cx16.VERA_CTRL ; data port 0: source column
lda #%00010000 | VERA_TEXTMATRIX_BANK ; auto increment 1 lda #%00010000 | VERA_TEXTMATRIX>>16 ; auto increment 1
sta cx16.VERA_ADDR_H sta cx16.VERA_ADDR_H
lda #2 lda #2
sta cx16.VERA_ADDR_L ; begin in column 1 sta cx16.VERA_ADDR_L ; begin in column 1
lda P8ZP_SCRATCH_B1 lda P8ZP_SCRATCH_B1
clc clc
adc #>VERA_TEXTMATRIX_ADDR adc #>VERA_TEXTMATRIX
tay tay
sty cx16.VERA_ADDR_M sty cx16.VERA_ADDR_M
lda #1 lda #1
sta cx16.VERA_CTRL ; data port 1: destination column sta cx16.VERA_CTRL ; data port 1: destination column
lda #%00010000 | VERA_TEXTMATRIX_BANK ; auto increment 1 lda #%00010000 | VERA_TEXTMATRIX>>16 ; auto increment 1
sta cx16.VERA_ADDR_H sta cx16.VERA_ADDR_H
stz cx16.VERA_ADDR_L stz cx16.VERA_ADDR_L
sty cx16.VERA_ADDR_M sty cx16.VERA_ADDR_M
@ -331,18 +329,18 @@ asmsub scroll_right() clobbers(A,X,Y) {
_nextline _nextline
stz cx16.VERA_CTRL ; data port 0: source column stz cx16.VERA_CTRL ; data port 0: source column
lda #%00011000 | VERA_TEXTMATRIX_BANK ; auto decrement 1 lda #%00011000 | VERA_TEXTMATRIX>>16 ; auto decrement 1
sta cx16.VERA_ADDR_H sta cx16.VERA_ADDR_H
_rcol lda #79*2-1 ; modified _rcol lda #79*2-1 ; modified
sta cx16.VERA_ADDR_L ; begin in rightmost column minus one sta cx16.VERA_ADDR_L ; begin in rightmost column minus one
lda P8ZP_SCRATCH_B1 lda P8ZP_SCRATCH_B1
clc clc
adc #>VERA_TEXTMATRIX_ADDR adc #>VERA_TEXTMATRIX
tay tay
sty cx16.VERA_ADDR_M sty cx16.VERA_ADDR_M
lda #1 lda #1
sta cx16.VERA_CTRL ; data port 1: destination column sta cx16.VERA_CTRL ; data port 1: destination column
lda #%00011000 | VERA_TEXTMATRIX_BANK ; auto decrement 1 lda #%00011000 | VERA_TEXTMATRIX>>16 ; auto decrement 1
sta cx16.VERA_ADDR_H sta cx16.VERA_ADDR_H
_rcol2 lda #79*2+1 ; modified _rcol2 lda #79*2+1 ; modified
sta cx16.VERA_ADDR_L sta cx16.VERA_ADDR_L
@ -373,18 +371,18 @@ asmsub scroll_up() clobbers(A, X, Y) {
dey dey
sty P8ZP_SCRATCH_B1 sty P8ZP_SCRATCH_B1
stz cx16.VERA_CTRL ; data port 0 is source stz cx16.VERA_CTRL ; data port 0 is source
lda #1 | (>VERA_TEXTMATRIX_ADDR) lda #1 | (>VERA_TEXTMATRIX)
sta cx16.VERA_ADDR_M ; start at second line sta cx16.VERA_ADDR_M ; start at second line
stz cx16.VERA_ADDR_L stz cx16.VERA_ADDR_L
lda #%00010000 | VERA_TEXTMATRIX_BANK lda #%00010000 | VERA_TEXTMATRIX>>16
sta cx16.VERA_ADDR_H ; enable auto increment by 1, bank 0. sta cx16.VERA_ADDR_H ; enable auto increment by 1, bank 0.
lda #1 lda #1
sta cx16.VERA_CTRL ; data port 1 is destination sta cx16.VERA_CTRL ; data port 1 is destination
lda #>VERA_TEXTMATRIX_ADDR lda #>VERA_TEXTMATRIX
sta cx16.VERA_ADDR_M ; start at top line sta cx16.VERA_ADDR_M ; start at top line
stz cx16.VERA_ADDR_L stz cx16.VERA_ADDR_L
lda #%00010000 | VERA_TEXTMATRIX_BANK lda #%00010000 | VERA_TEXTMATRIX>>16
sta cx16.VERA_ADDR_H ; enable auto increment by 1, bank 0. sta cx16.VERA_ADDR_H ; enable auto increment by 1, bank 0.
_nextline _nextline
@ -424,10 +422,10 @@ asmsub scroll_down() clobbers(A, X, Y) {
dey dey
tya tya
clc clc
adc #>VERA_TEXTMATRIX_ADDR adc #>VERA_TEXTMATRIX
sta cx16.VERA_ADDR_M ; start at line before bottom line sta cx16.VERA_ADDR_M ; start at line before bottom line
stz cx16.VERA_ADDR_L stz cx16.VERA_ADDR_L
lda #%00010000 | VERA_TEXTMATRIX_BANK lda #%00010000 | VERA_TEXTMATRIX>>16
sta cx16.VERA_ADDR_H ; enable auto increment by 1, bank 0. sta cx16.VERA_ADDR_H ; enable auto increment by 1, bank 0.
lda #1 lda #1
@ -435,10 +433,10 @@ asmsub scroll_down() clobbers(A, X, Y) {
iny iny
tya tya
clc clc
adc #>VERA_TEXTMATRIX_ADDR adc #>VERA_TEXTMATRIX
sta cx16.VERA_ADDR_M ; start at bottom line sta cx16.VERA_ADDR_M ; start at bottom line
stz cx16.VERA_ADDR_L stz cx16.VERA_ADDR_L
lda #%00010000 | VERA_TEXTMATRIX_BANK lda #%00010000 | VERA_TEXTMATRIX>>16
sta cx16.VERA_ADDR_H ; enable auto increment by 1, bank 0. sta cx16.VERA_ADDR_H ; enable auto increment by 1, bank 0.
_nextline _nextline
@ -471,14 +469,14 @@ asmsub setchr (ubyte col @X, ubyte row @Y, ubyte character @A) clobbers(A) {
%asm {{ %asm {{
pha pha
stz cx16.VERA_CTRL stz cx16.VERA_CTRL
lda #VERA_TEXTMATRIX_BANK lda #VERA_TEXTMATRIX>>16
sta cx16.VERA_ADDR_H sta cx16.VERA_ADDR_H
txa txa
asl a asl a
sta cx16.VERA_ADDR_L sta cx16.VERA_ADDR_L
tya tya
; clc ; clc
adc #>VERA_TEXTMATRIX_ADDR adc #>VERA_TEXTMATRIX
sta cx16.VERA_ADDR_M sta cx16.VERA_ADDR_M
pla pla
sta cx16.VERA_DATA0 sta cx16.VERA_DATA0
@ -492,13 +490,13 @@ asmsub getchr (ubyte col @A, ubyte row @Y) -> ubyte @ A {
asl a asl a
pha pha
stz cx16.VERA_CTRL stz cx16.VERA_CTRL
lda #VERA_TEXTMATRIX_BANK lda #VERA_TEXTMATRIX>>16
sta cx16.VERA_ADDR_H sta cx16.VERA_ADDR_H
pla pla
sta cx16.VERA_ADDR_L sta cx16.VERA_ADDR_L
tya tya
; clc ; clc
adc #>VERA_TEXTMATRIX_ADDR adc #>VERA_TEXTMATRIX
sta cx16.VERA_ADDR_M sta cx16.VERA_ADDR_M
lda cx16.VERA_DATA0 lda cx16.VERA_DATA0
rts rts
@ -512,7 +510,7 @@ asmsub setclr (ubyte col @X, ubyte row @Y, ubyte color @A) clobbers(A) {
%asm {{ %asm {{
pha pha
stz cx16.VERA_CTRL stz cx16.VERA_CTRL
lda #VERA_TEXTMATRIX_BANK lda #VERA_TEXTMATRIX>>16
sta cx16.VERA_ADDR_H sta cx16.VERA_ADDR_H
txa txa
asl a asl a
@ -520,7 +518,7 @@ asmsub setclr (ubyte col @X, ubyte row @Y, ubyte color @A) clobbers(A) {
sta cx16.VERA_ADDR_L sta cx16.VERA_ADDR_L
tya tya
; clc ; clc
adc #>VERA_TEXTMATRIX_ADDR adc #>VERA_TEXTMATRIX
sta cx16.VERA_ADDR_M sta cx16.VERA_ADDR_M
pla pla
sta cx16.VERA_DATA0 sta cx16.VERA_DATA0
@ -535,13 +533,13 @@ asmsub getclr (ubyte col @A, ubyte row @Y) -> ubyte @ A {
ina ina
pha pha
stz cx16.VERA_CTRL stz cx16.VERA_CTRL
lda #VERA_TEXTMATRIX_BANK lda #VERA_TEXTMATRIX>>16
sta cx16.VERA_ADDR_H sta cx16.VERA_ADDR_H
pla pla
sta cx16.VERA_ADDR_L sta cx16.VERA_ADDR_L
tya tya
; clc ; clc
adc #>VERA_TEXTMATRIX_ADDR adc #>VERA_TEXTMATRIX
sta cx16.VERA_ADDR_M sta cx16.VERA_ADDR_M
lda cx16.VERA_DATA0 lda cx16.VERA_DATA0
rts rts
@ -558,12 +556,12 @@ sub setcc (ubyte col, ubyte row, ubyte character, ubyte charcolor) {
tax tax
ldy row ldy row
stz cx16.VERA_CTRL stz cx16.VERA_CTRL
lda #VERA_TEXTMATRIX_BANK lda #VERA_TEXTMATRIX>>16
sta cx16.VERA_ADDR_H sta cx16.VERA_ADDR_H
stx cx16.VERA_ADDR_L stx cx16.VERA_ADDR_L
tya tya
;clc ;clc
adc #>VERA_TEXTMATRIX_ADDR adc #>VERA_TEXTMATRIX
sta cx16.VERA_ADDR_M sta cx16.VERA_ADDR_M
lda character lda character
sta cx16.VERA_DATA0 sta cx16.VERA_DATA0
@ -589,12 +587,12 @@ sub setcc2 (ubyte col, ubyte row, ubyte character, ubyte colors) {
tax tax
ldy row ldy row
stz cx16.VERA_CTRL stz cx16.VERA_CTRL
lda #VERA_TEXTMATRIX_BANK lda #VERA_TEXTMATRIX>>16
sta cx16.VERA_ADDR_H sta cx16.VERA_ADDR_H
stx cx16.VERA_ADDR_L stx cx16.VERA_ADDR_L
tya tya
; clc ; clc
adc #>VERA_TEXTMATRIX_ADDR adc #>VERA_TEXTMATRIX
sta cx16.VERA_ADDR_M sta cx16.VERA_ADDR_M
lda character lda character
sta cx16.VERA_DATA0 sta cx16.VERA_DATA0

View File

@ -737,7 +737,7 @@ class NumericLiteral(val type: DataType, // only numerical types allowed
throw FatalAstException("type cast of weird type $type") throw FatalAstException("type cast of weird type $type")
} }
} }
return ValueAfterCast(false, "no cast available from $type to $targettype", null) return ValueAfterCast(false, "no cast available from $type to $targettype number=$number", null)
} }
fun convertTypeKeepValue(targetDt: DataType): ValueAfterCast { fun convertTypeKeepValue(targetDt: DataType): ValueAfterCast {

View File

@ -18,7 +18,7 @@ main {
word balloon_y = 120 word balloon_y = 120
; clear the screen (including all the tiles outside of the visible area) ; clear the screen (including all the tiles outside of the visible area)
cx16.vaddr(txt.VERA_TEXTMATRIX_BANK, txt.VERA_TEXTMATRIX_ADDR, 0, 1) cx16.vaddr(txt.VERA_TEXTMATRIX>>16, txt.VERA_TEXTMATRIX & $ffff, 0, 1)
repeat 128 * txt.DEFAULT_HEIGHT { repeat 128 * txt.DEFAULT_HEIGHT {
cx16.VERA_DATA0 = sc:' ' cx16.VERA_DATA0 = sc:' '
cx16.VERA_DATA0 = $00 cx16.VERA_DATA0 = $00

View File

@ -8,9 +8,7 @@
; an example that displays and moves a single dragon (actually 2 sprites). ; an example that displays and moves a single dragon (actually 2 sprites).
main { main {
; we choose arbitrary unused vram location for sprite data: $12000 const long SPRITE_DATA = $12000
const ubyte SPRITE_DATA_BANK = 1
const uword SPRITE_DATA_ADDR = $2000
const ubyte SPRITE_PALETTE_OFFSET = 1 ; sprite palette at color index 16 const ubyte SPRITE_PALETTE_OFFSET = 1 ; sprite palette at color index 16
sub start() { sub start() {
@ -18,12 +16,12 @@ main {
txt.print("there be dragons!") txt.print("there be dragons!")
; load the sprite data and color palette directly into Vera ram ; load the sprite data and color palette directly into Vera ram
void diskio.vload_raw("dragonsprite.bin", SPRITE_DATA_BANK, SPRITE_DATA_ADDR) void diskio.vload_raw("dragonsprite.bin", SPRITE_DATA>>16, SPRITE_DATA & $ffff)
void diskio.vload_raw("dragonsprite.pal", 1, $fa00 + SPRITE_PALETTE_OFFSET*16*2) void diskio.vload_raw("dragonsprite.pal", 1, $fa00 + SPRITE_PALETTE_OFFSET*16*2)
; initialize the dragon sprites ; initialize the dragon sprites
sprites.init(1, SPRITE_DATA_BANK, SPRITE_DATA_ADDR, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16, SPRITE_PALETTE_OFFSET) sprites.init(1, SPRITE_DATA>>16, SPRITE_DATA & $ffff, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16, SPRITE_PALETTE_OFFSET)
sprites.init(2, SPRITE_DATA_BANK, SPRITE_DATA_ADDR + 64*64/2, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16,SPRITE_PALETTE_OFFSET) sprites.init(2, SPRITE_DATA>>16, (SPRITE_DATA & $ffff) + 64*64/2, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16,SPRITE_PALETTE_OFFSET)
ubyte tt = 0 ubyte tt = 0
word xpos = -64 word xpos = -64

View File

@ -8,9 +8,7 @@
; an example that displays and then moves many sprites at once. ; an example that displays and then moves many sprites at once.
main { main {
; we choose arbitrary unused vram location for sprite data: $12000 const long SPRITE_DATA = $12000
const ubyte SPRITE_DATA_BANK = 1
const uword SPRITE_DATA_ADDR = $2000
const ubyte SPRITE_PALETTE_OFFSET = 1 ; sprite palette at color index 16 const ubyte SPRITE_PALETTE_OFFSET = 1 ; sprite palette at color index 16
const ubyte NUM_DRAGONS = 25 const ubyte NUM_DRAGONS = 25
@ -22,14 +20,14 @@ main {
txt.print("there be many dragons!") txt.print("there be many dragons!")
; load the sprite data and color palette directly into Vera ram ; load the sprite data and color palette directly into Vera ram
void diskio.vload_raw("dragonsprite.bin", SPRITE_DATA_BANK, SPRITE_DATA_ADDR) void diskio.vload_raw("dragonsprite.bin", SPRITE_DATA>>16, SPRITE_DATA & $ffff)
void diskio.vload_raw("dragonsprite.pal", 1, $fa00 + SPRITE_PALETTE_OFFSET*16*2) void diskio.vload_raw("dragonsprite.pal", 1, $fa00 + SPRITE_PALETTE_OFFSET*16*2)
; initialize the dragon sprites (every dragon needs 2 sprites, top and bottom half) ; initialize the dragon sprites (every dragon needs 2 sprites, top and bottom half)
ubyte sprite_num ubyte sprite_num
for sprite_num in 0 to NUM_DRAGONS*2-2 step 2 { for sprite_num in 0 to NUM_DRAGONS*2-2 step 2 {
sprites.init(sprite_num+1, SPRITE_DATA_BANK, SPRITE_DATA_ADDR, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16, SPRITE_PALETTE_OFFSET) sprites.init(sprite_num+1, SPRITE_DATA>>16, SPRITE_DATA & $ffff, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16, SPRITE_PALETTE_OFFSET)
sprites.init(sprite_num+2, SPRITE_DATA_BANK, SPRITE_DATA_ADDR + 64*64/2, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16, SPRITE_PALETTE_OFFSET) sprites.init(sprite_num+2, SPRITE_DATA>>16, (SPRITE_DATA & $ffff) + 64*64/2, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16, SPRITE_PALETTE_OFFSET)
xpositions[sprite_num] = math.rndw() % (640-64) as word xpositions[sprite_num] = math.rndw() % (640-64) as word
xpositions[sprite_num+1] = xpositions[sprite_num] xpositions[sprite_num+1] = xpositions[sprite_num]