mirror of
https://github.com/irmen/prog8.git
synced 2024-07-05 22:29:04 +00:00
optimized iff planar to chunky
This commit is contained in:
parent
7d08380c7f
commit
48a4c46a6c
@ -119,14 +119,14 @@ iff_module {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uword bitplane_stride
|
ubyte bitplane_stride
|
||||||
uword interleave_stride
|
uword interleave_stride
|
||||||
uword offsetx
|
uword offsetx
|
||||||
uword offsety
|
uword offsety
|
||||||
|
|
||||||
sub start_plot() {
|
sub start_plot() {
|
||||||
bitplane_stride = width>>3
|
bitplane_stride = lsb(width>>3)
|
||||||
interleave_stride = bitplane_stride * num_planes
|
interleave_stride = (bitplane_stride as uword) * num_planes
|
||||||
offsetx = 0
|
offsetx = 0
|
||||||
offsety = 0
|
offsety = 0
|
||||||
if width < graphics.WIDTH
|
if width < graphics.WIDTH
|
||||||
@ -190,17 +190,59 @@ iff_module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub planar_to_chunky_scanline() {
|
sub planar_to_chunky_scanline() {
|
||||||
|
; ubyte[8] masks = [128,64,32,16,8,4,2,1]
|
||||||
uword x
|
uword x
|
||||||
for x in 0 to width-1 {
|
for x in 0 to width-1 {
|
||||||
ubyte bitnr = ((lsb(x) ^ 255) & 7) + 1
|
; ubyte mask = masks[lsb(x) & 7]
|
||||||
uword pixptr = x/8 + scanline_data_ptr
|
uword pixptr = x/8 + scanline_data_ptr
|
||||||
ubyte bits=0
|
ubyte bits = 0
|
||||||
repeat num_planes {
|
%asm {{
|
||||||
ubyte bb = @(pixptr) >> bitnr ; extract bit
|
bra +
|
||||||
ror(bits) ; shift it into the byte
|
_masks .byte 128, 64, 32, 16, 8, 4, 2, 1
|
||||||
pixptr += bitplane_stride
|
+ lda x
|
||||||
}
|
and #7
|
||||||
bits >>= 8-num_planes
|
tay
|
||||||
|
lda _masks,y
|
||||||
|
sta P8ZP_SCRATCH_B1 ; mask
|
||||||
|
phx
|
||||||
|
ldx num_planes
|
||||||
|
ldy #0
|
||||||
|
- lda (pixptr),y
|
||||||
|
clc
|
||||||
|
and P8ZP_SCRATCH_B1
|
||||||
|
beq +
|
||||||
|
sec
|
||||||
|
+ ror bits ; shift planar bit into chunky byte
|
||||||
|
lda pixptr
|
||||||
|
; clc
|
||||||
|
adc bitplane_stride
|
||||||
|
sta pixptr
|
||||||
|
bcc +
|
||||||
|
inc pixptr+1
|
||||||
|
+ dex
|
||||||
|
bne -
|
||||||
|
plx
|
||||||
|
lda #8
|
||||||
|
sec
|
||||||
|
sbc num_planes
|
||||||
|
beq +
|
||||||
|
tay
|
||||||
|
- lsr bits
|
||||||
|
dey
|
||||||
|
bne -
|
||||||
|
+
|
||||||
|
}}
|
||||||
|
|
||||||
|
; the assembly above is the optimized version of this:
|
||||||
|
; repeat num_planes {
|
||||||
|
; clear_carry()
|
||||||
|
; if @(pixptr) & mask
|
||||||
|
; set_carry()
|
||||||
|
; ror(bits) ; shift planar bit into chunky byte
|
||||||
|
; pixptr += bitplane_stride
|
||||||
|
; }
|
||||||
|
; bits >>= 8-num_planes
|
||||||
|
|
||||||
cx16.FB_set_pixel(bits)
|
cx16.FB_set_pixel(bits)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user