diff --git a/mandel.s b/mandel.s index 3419466..6837e00 100644 --- a/mandel.s +++ b/mandel.s @@ -162,12 +162,28 @@ str_padding: str_padding_end: .byte 0 +str_space: + .byte " " + .byte 0 + +str_h: + .byte "h" + .byte 0 +str_m: + .byte "m" + .byte 0 +str_s: + .byte "s" + .byte 0 + str_speed_len = str_speed_end - str_speed str_run_len = str_run_end - str_run str_done_len = str_done_end - str_done str_padding_len = str_padding_end - str_padding -speed_start = 40 - str_done_len - str_speed_len - str_padding_len - 1 +; "3h59m59s" +str_elapsed_spacer = 8 +speed_start = 40 - str_done_len - str_speed_len - str_padding_len - str_elapsed_spacer - 1 col_x = 1 str_x: @@ -205,8 +221,12 @@ char_map: .endrepeat hex_chars: +digits_zero: .byte "0123456789abcdef" +digits_space: + .byte " 123456789abcdef" + aspect: ; aspect ratio! ; pixels at 320w are 5:6 (narrow) @@ -378,6 +398,11 @@ viewport_oy: .dword ($fffe0000 & $3fffffff) << 2 .dword $ff000000 +elapsed_work: + .dword 0 +elapsed_digit: + .byte 0 + ; 2 + 9 * byte cycles .macro add bytes, dest, arg1, arg2 clc ; 2 cyc @@ -1953,6 +1978,66 @@ update_status: ; convert to ASCII in INBUFF and print jsr FASC jsr draw_string + + ; elapsed time + ; FR0 = total_sec + ldx #.lobyte(total_sec) + ldy #.hibyte(total_sec) + jsr FLD0R + ; FR0 -> integer -> elapsed_work + jsr FPI + lda FR0 + sta elapsed_work + lda FR0 + 1 + sta elapsed_work + 1 + + ;jsr IFP + ;jsr FASC + ;jsr draw_string + + .macro countdown divisor, digits + .scope + ; count the hours + ldx #0 + countdown_loop: + lda elapsed_work + 1 + cmp #.hibyte(divisor) + bcc countdown_done + lda elapsed_work + cmp #.lobyte(divisor) + bcc countdown_done + sec + lda elapsed_work + sbc #.lobyte(divisor) + sta elapsed_work + lda elapsed_work + 1 + sbc #.hibyte(divisor) + sta elapsed_work + 1 + inx + jmp countdown_loop + countdown_done: + lda digits,x + eor #$80 + sta elapsed_digit + lda #.lobyte(elapsed_digit) + sta INBUFF + lda #.hibyte(elapsed_digit) + sta INBUFF + 1 + jsr draw_string + .endscope + .endmacro + + draw_string_const str_space + countdown 36000, digits_space + countdown 3600, digits_zero + draw_string_const str_h + countdown 600, digits_zero + countdown 60, digits_zero + draw_string_const str_m + countdown 10, digits_zero + countdown 1, digits_zero + draw_string_const str_s + skipped: ; sx += fill_level[fill_masks] + 1