diff --git a/mandel.s b/mandel.s index be1f59e..6880e8b 100644 --- a/mandel.s +++ b/mandel.s @@ -16,13 +16,6 @@ dist = $9c ; fixed6.26: z_x^2 + z_y^2 iter = $a0 ; u8: iteration count zoom = $a1 ; u8: zoom shift level temp = $a2 ; u16 -temp2 = $a4 ; u16 - -pixel_ptr = $b0 ; u16 -pixel_color = $b2 ; u8 -pixel_mask = $b3 ; u8 -pixel_shift = $b4 ; u8 -pixel_offset = $b5 ; u8 ; FP registers in zero page FR0 = $d4 @@ -40,8 +33,7 @@ framebuffer_end = $a000 height = 184 half_height = height >> 1 width = 160 -half_width = width >> 1 -stride = width >> 2 +half_width = 160 >> 1 width_ratio_3_13 = (5 << 11) ; 5/4 height_ratio_3_13 = (3 << 11) ; 5/4 @@ -114,8 +106,8 @@ bit_masks: .byte 3 << 6 display_list_start: - ; 24 lines overscan - .repeat 3 + ; 48 lines overscan + .repeat 5 .byte $70 ; 8 blank lines .endrep @@ -141,14 +133,6 @@ display_list_start: display_list_end: display_list_len = display_list_end - display_list_start -color_map: - .byte 0 - .repeat 85 - .byte 1 - .byte 2 - .byte 3 - .endrepeat - .code .export start @@ -191,8 +175,8 @@ color_map: .macro shl bytes, arg asl arg - .repeat bytes-1, i - rol arg + 1 + i + .repeat bytes-1 + rol arg .endrepeat .endmacro @@ -244,21 +228,6 @@ color_map: neg 4, arg .endmacro -.macro extend_8_16 dest, src - ; clobbers A, X - ; 13-15 cycles - .local positive - .local negative - ldx #0 ; 2 cyc - lda src ; 3 cyc - sta dest ; 3 cyc - bpl positive ; 2 cyc -negative: - dex ; 2 cyc -positive: - stx dest + 1 ; 3 cyc -.endmacro - ; inner loop for imul16 ; bitnum < 8: 25 or 41 cycles ; bitnum >= 8: 30 or 46 cycles @@ -530,86 +499,6 @@ enough: ; screen coords in signed sx,sy ; iter holds the target to use ; @todo implement - - ; iter -> color - ldx iter - lda color_map,x - sta pixel_color - lda #(255 - 3) - sta pixel_mask - - ; sy -> line base address in temp - lda sy - bpl positive - -negative: - ; temp1 = top half - lda #.lobyte(framebuffer_top + stride * half_height) - sta pixel_ptr - lda #.hibyte(framebuffer_top + stride * half_height) - sta pixel_ptr + 1 - jmp point - -positive: - - lda #.lobyte(framebuffer_bottom) - sta pixel_ptr - lda #.hibyte(framebuffer_bottom) - sta pixel_ptr + 1 - -point: - - ; pixel_ptr += sy * stride - ; temp * 40 - ; = temp * 32 + temp * 8 - ; = (temp << 5) + (temp << 3) - copy16 temp, sy - shl16 temp - shl16 temp - shl16 temp - add16 pixel_ptr, pixel_ptr, temp - shl16 temp - shl16 temp - add16 pixel_ptr, pixel_ptr, temp - - ; Ok so temp1 points to the start of the line, which is 40 bytes. - ; Get the byte and bit offsets - lda sx - clc - adc #half_width - sta temp - - ; pixel_shift = temp & 3 - ; pixel_color <<= pixel_shift (shifting in zeros) - ; pixel_mask <<= pixel_shift (shifting in ones) - and #3 - sta pixel_shift - tax -shift_loop: - beq shift_done - asl pixel_color - asl pixel_color - sec - rol pixel_mask - sec - rol pixel_mask - dex - jmp shift_loop -shift_done: - - ; pixel_offset = temp >> 2 - lda temp - lsr a - lsr a - sta pixel_offset - tay - - ; read, mask, or, write - lda (pixel_ptr),y - and pixel_mask - ora pixel_color - sta (pixel_ptr),y - rts .endproc @@ -707,32 +596,33 @@ loop_sx: jsr mandelbrot jsr pset - clc + lda sx + clc adc #1 sta sx + + cmp #half_width + beq loop_sx_done + lda sx + 1 adc #0 sta sx + 1 - - lda sx - cmp #half_width - beq loop_sx_done jmp loop_sx loop_sx_done: - clc lda sy + clc adc #1 sta sy + + cmp #half_height + beq loop_sy_done + lda sy + 1 adc #0 sta sy + 1 - - lda sy - cmp #half_height - beq loop_sy_done jmp loop_sy loop_sy_done: