Fix regression from merging ptr and pixel_ptr

the XE fast-path assumed low byte of ptr never changes
to save a couple cycles
This commit is contained in:
Brooke Vibber 2026-08-22 15:35:03 -07:00
commit e284587edc

View file

@ -18,6 +18,7 @@ z_buffer_start: .res 1 ; u8: index into z_buffer
z_buffer_end: .res 1 ; u8: index into z_buffer z_buffer_end: .res 1 ; u8: index into z_buffer
iter: .res 1 ; u8: iteration count iter: .res 1 ; u8: iteration count
ptr: .res 2 ; u16 ptr: .res 2 ; u16
pixel_ptr: .res 2 ; u16
temp: .res 2 ; u16 temp: .res 2 ; u16
temp2: .res 2 ; u16 temp2: .res 2 ; u16
@ -1254,21 +1255,21 @@ enough:
negative: negative:
; temp1 = top half ; temp1 = top half
lda #.lobyte(framebuffer_top + stride * half_height) lda #.lobyte(framebuffer_top + stride * half_height)
sta ptr sta pixel_ptr
lda #.hibyte(framebuffer_top + stride * half_height) lda #.hibyte(framebuffer_top + stride * half_height)
sta ptr + 1 sta pixel_ptr + 1
jmp point jmp point
positive: positive:
lda #.lobyte(framebuffer_bottom) lda #.lobyte(framebuffer_bottom)
sta ptr sta pixel_ptr
lda #.hibyte(framebuffer_bottom) lda #.hibyte(framebuffer_bottom)
sta ptr + 1 sta pixel_ptr + 1
point: point:
; ptr += sy * stride ; pixel_ptr += sy * stride
; temp * 40 ; temp * 40
; = temp * 32 + temp * 8 ; = temp * 32 + temp * 8
; = (temp << 5) + (temp << 3) ; = (temp << 5) + (temp << 3)
@ -1276,10 +1277,10 @@ point:
shl16 temp shl16 temp
shl16 temp shl16 temp
shl16 temp shl16 temp
add16 ptr, ptr, temp add16 pixel_ptr, pixel_ptr, temp
shl16 temp shl16 temp
shl16 temp shl16 temp
add16 ptr, ptr, temp add16 pixel_ptr, pixel_ptr, temp
; Ok so temp1 points to the start of the line, which is 40 bytes. ; Ok so temp1 points to the start of the line, which is 40 bytes.
; Get the byte and bit offsets ; Get the byte and bit offsets
@ -1319,20 +1320,20 @@ shift_done:
draw_pixel: draw_pixel:
; read, mask, or, write ; read, mask, or, write
lda (ptr),y lda (pixel_ptr),y
and pixel_mask and pixel_mask
ora pixel_color ora pixel_color
sta (ptr),y sta (pixel_ptr),y
dex dex
beq done beq done
clc clc
lda #40 lda #40
adc ptr adc pixel_ptr
sta ptr sta pixel_ptr
lda #0 lda #0
adc ptr + 1 adc pixel_ptr + 1
sta ptr + 1 sta pixel_ptr + 1
jmp draw_pixel jmp draw_pixel
done: done: