wip us/iter counter
seems wrong, gives 32 all the time and that seems too small
This commit is contained in:
parent
eaa00a055a
commit
918d15e813
1 changed files with 68 additions and 35 deletions
103
mandel.s
103
mandel.s
|
@ -31,9 +31,10 @@ chroma_offset = $bb ; u8
|
||||||
palette_ticks = $bc ; u8
|
palette_ticks = $bc ; u8
|
||||||
chroma_ticks = $bd ; u8
|
chroma_ticks = $bd ; u8
|
||||||
count_frames = $be ; u8
|
count_frames = $be ; u8
|
||||||
count_pixels = $bf ; u8
|
; free space $bf
|
||||||
|
|
||||||
; free space c0-cb
|
count_iters = $c0 ; u16
|
||||||
|
; free space c2-cb
|
||||||
temp = $cc ; u16
|
temp = $cc ; u16
|
||||||
temp2 = $ce ; u16
|
temp2 = $ce ; u16
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ LBUFF = $0580 ; result buffer for FASC routine
|
||||||
; FP ROM routine vectors
|
; FP ROM routine vectors
|
||||||
FASC = $D8E6 ; FLOATING POINT TO ASCII (output in INBUFF, last char has high bit set)
|
FASC = $D8E6 ; FLOATING POINT TO ASCII (output in INBUFF, last char has high bit set)
|
||||||
IFP = $D9AA ; INTEGER TO FLOATING POINT CONVERSION (FR0:u16 -> FR0:float48)
|
IFP = $D9AA ; INTEGER TO FLOATING POINT CONVERSION (FR0:u16 -> FR0:float48)
|
||||||
|
FPI = $D9D2 ; floating point to integer
|
||||||
FADD = $DA66 ; ADDITION (FR0 += FR1)
|
FADD = $DA66 ; ADDITION (FR0 += FR1)
|
||||||
FSUB = $DA60 ; SUBTRACTION (FR0 -= FR1)
|
FSUB = $DA60 ; SUBTRACTION (FR0 -= FR1)
|
||||||
FMUL = $DADB ; MULTIPLICATION (FR0 *= FR1)
|
FMUL = $DADB ; MULTIPLICATION (FR0 *= FR1)
|
||||||
|
@ -141,7 +143,7 @@ str_self:
|
||||||
.byte "MANDEL-6502"
|
.byte "MANDEL-6502"
|
||||||
str_self_end:
|
str_self_end:
|
||||||
str_speed:
|
str_speed:
|
||||||
.byte " sec/px"
|
.byte "us/iter: "
|
||||||
str_speed_end:
|
str_speed_end:
|
||||||
str_run:
|
str_run:
|
||||||
.byte " RUN"
|
.byte " RUN"
|
||||||
|
@ -154,7 +156,7 @@ str_self_len = str_self_end - str_self
|
||||||
str_speed_len = str_speed_end - str_speed
|
str_speed_len = str_speed_end - str_speed
|
||||||
str_run_len = str_run_end - str_run
|
str_run_len = str_run_end - str_run
|
||||||
str_done_len = str_done_end - str_done
|
str_done_len = str_done_end - str_done
|
||||||
speed_precision = 6
|
speed_precision = 5
|
||||||
|
|
||||||
speed_start = 40 - str_done_len - str_speed_len - speed_precision - 1
|
speed_start = 40 - str_done_len - str_speed_len - speed_precision - 1
|
||||||
speed_len = 14 + str_speed_len
|
speed_len = 14 + str_speed_len
|
||||||
|
@ -196,14 +198,22 @@ aspect_y: ; fixed3.13 3/4
|
||||||
.word 3 << (13 - 2)
|
.word 3 << (13 - 2)
|
||||||
|
|
||||||
sec_per_frame: ; float48 0.016666667
|
sec_per_frame: ; float48 0.016666667
|
||||||
.byte 63 ; exponent/sign
|
.byte 63 ; exponent/sign - -2
|
||||||
.byte $01 ; BCD digits
|
.byte $01 ; BCD digits
|
||||||
.byte $66
|
.byte $66
|
||||||
.byte $66
|
.byte $66
|
||||||
.byte $66
|
.byte $66
|
||||||
.byte $67
|
.byte $67
|
||||||
|
|
||||||
total_pixels: ; float48
|
us_per_sec: ; float48 1e9
|
||||||
|
.byte 68 ; exponent/sign +8
|
||||||
|
.byte $10 ; BCD digits
|
||||||
|
.byte $00
|
||||||
|
.byte $00
|
||||||
|
.byte $00
|
||||||
|
.byte $00
|
||||||
|
|
||||||
|
total_iters: ; float48
|
||||||
.repeat 6
|
.repeat 6
|
||||||
.byte 0
|
.byte 0
|
||||||
.endrepeat
|
.endrepeat
|
||||||
|
@ -927,6 +937,11 @@ next:
|
||||||
sta z_buffer_end
|
sta z_buffer_end
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
|
inc count_iters
|
||||||
|
bne low_iters
|
||||||
|
inc count_iters + 1
|
||||||
|
low_iters:
|
||||||
|
|
||||||
; iter++ & max-iters break
|
; iter++ & max-iters break
|
||||||
inc iter
|
inc iter
|
||||||
bne keep_going
|
bne keep_going
|
||||||
|
@ -1230,6 +1245,7 @@ done:
|
||||||
; clobbers A, X
|
; clobbers A, X
|
||||||
.local loop
|
.local loop
|
||||||
.local done
|
.local done
|
||||||
|
.local padding
|
||||||
ldx #0
|
ldx #0
|
||||||
loop:
|
loop:
|
||||||
cpx #len
|
cpx #len
|
||||||
|
@ -1237,11 +1253,23 @@ loop:
|
||||||
txa
|
txa
|
||||||
tay
|
tay
|
||||||
lda (strptr),y
|
lda (strptr),y
|
||||||
|
bmi padding
|
||||||
tay
|
tay
|
||||||
lda char_map,y
|
lda char_map,y
|
||||||
sta textbuffer + col,x
|
sta textbuffer + col,x
|
||||||
inx
|
inx
|
||||||
jmp loop
|
jmp loop
|
||||||
|
|
||||||
|
padding:
|
||||||
|
ldy #32 ; space
|
||||||
|
lda char_map,y
|
||||||
|
|
||||||
|
cpx #len
|
||||||
|
beq done
|
||||||
|
sta textbuffer + col,x
|
||||||
|
inx
|
||||||
|
jmp padding
|
||||||
|
|
||||||
done:
|
done:
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
@ -1569,18 +1597,19 @@ copy_byte_loop:
|
||||||
jsr SETVBV
|
jsr SETVBV
|
||||||
|
|
||||||
main_loop:
|
main_loop:
|
||||||
; count_frames = 0; count_pixels = 0
|
; count_frames = 0; count_iters = 0
|
||||||
lda #0
|
lda #0
|
||||||
sta count_frames
|
sta count_frames
|
||||||
sta count_pixels
|
sta count_iters
|
||||||
|
sta count_iters + 1
|
||||||
|
|
||||||
; total_sec = 0.0; total_pixels = 0.0
|
; total_sec = 0.0; total_iters = 0.0
|
||||||
jsr ZFR0
|
jsr ZFR0
|
||||||
ldx #.lobyte(total_sec)
|
ldx #.lobyte(total_sec)
|
||||||
ldy #.hibyte(total_sec)
|
ldy #.hibyte(total_sec)
|
||||||
jsr FST0R
|
jsr FST0R
|
||||||
ldx #.lobyte(total_pixels)
|
ldx #.lobyte(total_iters)
|
||||||
ldy #.hibyte(total_pixels)
|
ldy #.hibyte(total_iters)
|
||||||
jsr FST0R
|
jsr FST0R
|
||||||
|
|
||||||
jsr clear_screen
|
jsr clear_screen
|
||||||
|
@ -1653,38 +1682,32 @@ not_skipped_mask:
|
||||||
|
|
||||||
no_key:
|
no_key:
|
||||||
; check if we should update the counters
|
; check if we should update the counters
|
||||||
;
|
|
||||||
; count_pixels >= width? update!
|
|
||||||
inc count_pixels
|
|
||||||
lda count_pixels
|
|
||||||
cmp #width
|
|
||||||
bmi update_status
|
|
||||||
|
|
||||||
; count_frames >= 120? update!
|
; count_frames >= 120? update!
|
||||||
lda count_frames
|
lda count_frames
|
||||||
cmp #120 ; >= 2 seconds
|
cmp #120 ; >= 2 seconds
|
||||||
bmi skipped
|
bpl update_status
|
||||||
|
jmp skipped
|
||||||
|
|
||||||
update_status:
|
update_status:
|
||||||
; FR0 = (float)count_pixels & clear count_pixels
|
; FR0 = (float)count_iters & clear count_iters
|
||||||
lda count_pixels
|
copy16 FR0, count_iters
|
||||||
sta FR0
|
|
||||||
lda #0
|
|
||||||
sta FR0 + 1
|
|
||||||
sta count_pixels
|
|
||||||
jsr IFP
|
jsr IFP
|
||||||
|
lda #0
|
||||||
|
sta count_iters
|
||||||
|
sta count_iters + 1
|
||||||
|
|
||||||
; FR1 = total_pixels
|
; FR1 = total_iters
|
||||||
ldx #.lobyte(total_pixels)
|
ldx #.lobyte(total_iters)
|
||||||
ldy #.hibyte(total_pixels)
|
ldy #.hibyte(total_iters)
|
||||||
jsr FLD1R
|
jsr FLD1R
|
||||||
|
|
||||||
; FR0 += FR1
|
; FR0 += FR1
|
||||||
jsr FADD
|
jsr FADD
|
||||||
|
|
||||||
; total_pixels = FR0
|
; total_iters = FR0
|
||||||
ldx #.lobyte(total_pixels)
|
ldx #.lobyte(total_iters)
|
||||||
ldy #.hibyte(total_pixels)
|
ldy #.hibyte(total_iters)
|
||||||
jsr FST0R
|
jsr FST0R
|
||||||
|
|
||||||
|
|
||||||
|
@ -1714,18 +1737,28 @@ update_status:
|
||||||
ldy #.hibyte(total_sec)
|
ldy #.hibyte(total_sec)
|
||||||
jsr FST0R
|
jsr FST0R
|
||||||
|
|
||||||
; FR0 /= total_pixels
|
; FR0 /= total_iters
|
||||||
ldx #.lobyte(total_pixels)
|
ldx #.lobyte(total_iters)
|
||||||
ldy #.hibyte(total_pixels)
|
ldy #.hibyte(total_iters)
|
||||||
jsr FLD1R
|
jsr FLD1R
|
||||||
jsr FDIV
|
jsr FDIV
|
||||||
|
|
||||||
|
; FR0 *= us_per_sec
|
||||||
|
ldx #.lobyte(us_per_sec)
|
||||||
|
ldy #.hibyte(us_per_sec)
|
||||||
|
jsr FLD1R
|
||||||
|
jsr FMUL
|
||||||
|
|
||||||
|
; round to integer
|
||||||
|
jsr FPI
|
||||||
|
jsr IFP
|
||||||
|
|
||||||
; convert to ASCII in INBUFF
|
; convert to ASCII in INBUFF
|
||||||
jsr FASC
|
jsr FASC
|
||||||
|
|
||||||
; print the first 6 digits
|
; print the first 6 digits
|
||||||
draw_text_indirect speed_start, speed_precision, INBUFF
|
draw_text speed_start, str_speed_len, str_speed
|
||||||
draw_text speed_start + speed_precision, str_speed_len, str_speed
|
draw_text_indirect speed_start + str_speed_len, speed_precision, INBUFF
|
||||||
|
|
||||||
skipped:
|
skipped:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue