Compare commits
No commits in common. "d36667938d8a3b11ac9c1cb7ecaf80125a1c19ba" and "335c4d2c9682ae9a4fbc25951c273ab1703d074a" have entirely different histories.
d36667938d
...
335c4d2c96
1 changed files with 16 additions and 126 deletions
142
mandel.s
142
mandel.s
|
@ -16,13 +16,6 @@ dist = $9c ; fixed6.26: z_x^2 + z_y^2
|
||||||
iter = $a0 ; u8: iteration count
|
iter = $a0 ; u8: iteration count
|
||||||
zoom = $a1 ; u8: zoom shift level
|
zoom = $a1 ; u8: zoom shift level
|
||||||
temp = $a2 ; u16
|
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
|
; FP registers in zero page
|
||||||
FR0 = $d4
|
FR0 = $d4
|
||||||
|
@ -40,8 +33,7 @@ framebuffer_end = $a000
|
||||||
height = 184
|
height = 184
|
||||||
half_height = height >> 1
|
half_height = height >> 1
|
||||||
width = 160
|
width = 160
|
||||||
half_width = width >> 1
|
half_width = 160 >> 1
|
||||||
stride = width >> 2
|
|
||||||
width_ratio_3_13 = (5 << 11) ; 5/4
|
width_ratio_3_13 = (5 << 11) ; 5/4
|
||||||
height_ratio_3_13 = (3 << 11) ; 5/4
|
height_ratio_3_13 = (3 << 11) ; 5/4
|
||||||
|
|
||||||
|
@ -114,8 +106,8 @@ bit_masks:
|
||||||
.byte 3 << 6
|
.byte 3 << 6
|
||||||
|
|
||||||
display_list_start:
|
display_list_start:
|
||||||
; 24 lines overscan
|
; 48 lines overscan
|
||||||
.repeat 3
|
.repeat 5
|
||||||
.byte $70 ; 8 blank lines
|
.byte $70 ; 8 blank lines
|
||||||
.endrep
|
.endrep
|
||||||
|
|
||||||
|
@ -141,14 +133,6 @@ display_list_start:
|
||||||
display_list_end:
|
display_list_end:
|
||||||
display_list_len = display_list_end - display_list_start
|
display_list_len = display_list_end - display_list_start
|
||||||
|
|
||||||
color_map:
|
|
||||||
.byte 0
|
|
||||||
.repeat 85
|
|
||||||
.byte 1
|
|
||||||
.byte 2
|
|
||||||
.byte 3
|
|
||||||
.endrepeat
|
|
||||||
|
|
||||||
.code
|
.code
|
||||||
|
|
||||||
.export start
|
.export start
|
||||||
|
@ -191,8 +175,8 @@ color_map:
|
||||||
|
|
||||||
.macro shl bytes, arg
|
.macro shl bytes, arg
|
||||||
asl arg
|
asl arg
|
||||||
.repeat bytes-1, i
|
.repeat bytes-1
|
||||||
rol arg + 1 + i
|
rol arg
|
||||||
.endrepeat
|
.endrepeat
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
@ -244,21 +228,6 @@ color_map:
|
||||||
neg 4, arg
|
neg 4, arg
|
||||||
.endmacro
|
.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
|
; inner loop for imul16
|
||||||
; bitnum < 8: 25 or 41 cycles
|
; bitnum < 8: 25 or 41 cycles
|
||||||
; bitnum >= 8: 30 or 46 cycles
|
; bitnum >= 8: 30 or 46 cycles
|
||||||
|
@ -530,86 +499,6 @@ enough:
|
||||||
; screen coords in signed sx,sy
|
; screen coords in signed sx,sy
|
||||||
; iter holds the target to use
|
; iter holds the target to use
|
||||||
; @todo implement
|
; @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
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
@ -707,32 +596,33 @@ loop_sx:
|
||||||
jsr mandelbrot
|
jsr mandelbrot
|
||||||
jsr pset
|
jsr pset
|
||||||
|
|
||||||
clc
|
|
||||||
lda sx
|
lda sx
|
||||||
|
clc
|
||||||
adc #1
|
adc #1
|
||||||
sta sx
|
sta sx
|
||||||
|
|
||||||
|
cmp #half_width
|
||||||
|
beq loop_sx_done
|
||||||
|
|
||||||
lda sx + 1
|
lda sx + 1
|
||||||
adc #0
|
adc #0
|
||||||
sta sx + 1
|
sta sx + 1
|
||||||
|
|
||||||
lda sx
|
|
||||||
cmp #half_width
|
|
||||||
beq loop_sx_done
|
|
||||||
jmp loop_sx
|
jmp loop_sx
|
||||||
|
|
||||||
loop_sx_done:
|
loop_sx_done:
|
||||||
|
|
||||||
clc
|
|
||||||
lda sy
|
lda sy
|
||||||
|
clc
|
||||||
adc #1
|
adc #1
|
||||||
sta sy
|
sta sy
|
||||||
|
|
||||||
|
cmp #half_height
|
||||||
|
beq loop_sy_done
|
||||||
|
|
||||||
lda sy + 1
|
lda sy + 1
|
||||||
adc #0
|
adc #0
|
||||||
sta sy + 1
|
sta sy + 1
|
||||||
|
|
||||||
lda sy
|
|
||||||
cmp #half_height
|
|
||||||
beq loop_sy_done
|
|
||||||
jmp loop_sy
|
jmp loop_sy
|
||||||
|
|
||||||
loop_sy_done:
|
loop_sy_done:
|
||||||
|
|
Loading…
Reference in a new issue