additional vpoke operations to do or,and,xor in one go without the need for a separate vpeek

This commit is contained in:
Irmen de Jong 2020-12-23 01:02:43 +01:00
parent d65cfbf093
commit 583af3bd4f
2 changed files with 58 additions and 40 deletions

View File

@ -296,6 +296,63 @@ sub vpoke(ubyte bank, uword address, ubyte value) {
}}
}
sub vpoke_or(ubyte bank, uword address, ubyte value) {
; -- or a single byte to the value already in the VERA's video memory at that location
; note: inefficient when writing multiple sequential bytes!
%asm {{
stz cx16.VERA_CTRL
lda bank
and #1
sta cx16.VERA_ADDR_H
lda address
sta cx16.VERA_ADDR_L
lda address+1
sta cx16.VERA_ADDR_M
lda value
ora cx16.VERA_DATA0
sta cx16.VERA_DATA0
rts
}}
}
sub vpoke_and(ubyte bank, uword address, ubyte value) {
; -- and a single byte to the value already in the VERA's video memory at that location
; note: inefficient when writing multiple sequential bytes!
%asm {{
stz cx16.VERA_CTRL
lda bank
and #1
sta cx16.VERA_ADDR_H
lda address
sta cx16.VERA_ADDR_L
lda address+1
sta cx16.VERA_ADDR_M
lda value
and cx16.VERA_DATA0
sta cx16.VERA_DATA0
rts
}}
}
sub vpoke_xor(ubyte bank, uword address, ubyte value) {
; -- xor a single byte to the value already in the VERA's video memory at that location
; note: inefficient when writing multiple sequential bytes!
%asm {{
stz cx16.VERA_CTRL
lda bank
and #1
sta cx16.VERA_ADDR_H
lda address
sta cx16.VERA_ADDR_L
lda address+1
sta cx16.VERA_ADDR_M
lda value
eor cx16.VERA_DATA0
sta cx16.VERA_DATA0
rts
}}
}
sub FB_set_pixels_from_buf(uword buffer, uword count) {
%asm {{
; -- This is replacement code for the normal FB_set_pixels subroutine in ROM

View File

@ -15,40 +15,6 @@ main {
sub start () {
txt.print("hello\n")
uword xx
xx = 777
%asm {{
lda xx
ldy xx+1
jsr math.mul_word_20
sta xx
sty xx+1
}}
txt.print_uw(xx)
txt.chrout('\n')
xx = 777
%asm {{
lda xx
ldy xx+1
jsr math.mul_word_40
sta xx
sty xx+1
}}
txt.print_uw(xx)
txt.chrout('\n')
xx = 777
%asm {{
lda xx
ldy xx+1
jsr math.mul_word_80
sta xx
sty xx+1
}}
txt.print_uw(xx)
txt.chrout('\n')
return
gfx2.set_mode(128)
gfx2.clear_screen()
@ -167,7 +133,6 @@ gfx2 {
when active_mode {
0 -> {
; TODO problem when y>=204 and x=..something... then the address gets > 64K; so we really need 24 bit address calculations...
addr = y
addr_mul_24_320()
addr_add_word_24(x)
@ -175,11 +140,7 @@ gfx2 {
}
128 -> {
ubyte[8] bits = [128, 64, 32, 16, 8, 4, 2, 1]
addr = 0
addr += y*(640/8)
addr += x/8
ubyte pix = cx16.vpeek(0, addr) | bits[lsb(x)&7]
cx16.vpoke(0, addr, pix)
cx16.vpoke_or(0, y*(640/8) + x/8, bits[lsb(x)&7])
}
}