workaround for FB_set_pixels bug

This commit is contained in:
Irmen de Jong 2020-12-10 21:44:04 +01:00
parent 4094f89d4a
commit 0d735c2ccc
2 changed files with 37 additions and 14 deletions

View File

@ -277,6 +277,40 @@ romsub $fecc = monitor() clobbers(A,X,Y)
}}
}
sub FB_set_pixels_from_buf(uword buffer, uword count) {
%asm {{
; -- This is replacement code for the normal FB_set_pixels subroutine in ROM
; However that routine contains a bug in the current v38 ROM that makes it crash when count > 255.
; So the code below replaces that. Once the ROM is patched this routine is no longer necessary.
; See https://github.com/commanderx16/x16-rom/issues/179
phx
lda buffer
ldy buffer+1
sta P8ZP_SCRATCH_W1
sty P8ZP_SCRATCH_W1+1
jsr _pixels
plx
rts
_pixels lda count+1
beq +
ldx #0
- jsr _loop
inc P8ZP_SCRATCH_W1+1
dec count+1
bne -
+ ldx count
_loop ldy #0
- lda (P8ZP_SCRATCH_W1),y
sta cx16.VERA_DATA0
iny
dex
bne -
rts
}}
}
; ---- system stuff -----

View File

@ -184,20 +184,9 @@ main {
cx16.r1 = y
cx16.FB_cursor_position()
; FB_set_pixels crashes with a size > 255 hence the loop for strips of 128
; TODO remove this workaround once the bug is fixed, see https://github.com/commanderx16/x16-rom/issues/179
cx16.r1 = 128
ubyte rest = lsb(width) & 127
repeat width >> 7 {
cx16.r0 = bitmapptr
cx16.FB_set_pixels()
bitmapptr += 128
}
if rest {
cx16.r0 = bitmapptr
cx16.FB_set_pixels()
bitmapptr += rest
}
; FB_set_pixels in rom v38 crashes with a size > 255 so we use our own replacement for now
cx16.FB_set_pixels_from_buf(bitmapptr, width)
bitmapptr += width
}
}