From 689363d0834c1cc3a04a19999a3ca2485a3a0f30 Mon Sep 17 00:00:00 2001 From: Brooke Date: Sun, 22 Jun 2025 20:00:35 -0700 Subject: [PATCH 1/3] WIP code for elapsed time not finished, doesn't work right --- mandel.s | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/mandel.s b/mandel.s index 3419466..dc7e323 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: @@ -1953,6 +1969,55 @@ 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 -> temp + jsr FPI + lda FR0 + sta temp + lda FR0 + 1 + sta temp + 1 + + .macro countdown divisor, string + .scope + ; count the hours + ldx #0 + countdown_loop: + lda temp + 1 + cmp #.hibyte(divisor) + bmi countdown_done + lda temp + cmp #.lobyte(divisor) + bmi countdown_done + sec + lda temp + sbc #.lobyte(divisor) + sta temp + lda temp + 1 + sbc #.hibyte(divisor) + sta temp + 1 + inx + jmp countdown_loop + countdown_done: + stx FR0 + ldx #0 + stx FR0 + 1 + jsr IFP + jsr FASC + jsr draw_string + draw_string_const string + .endscope + .endmacro + + draw_string_const str_space + countdown 3600, str_h + countdown 60, str_m + countdown 1, str_s + skipped: ; sx += fill_level[fill_masks] + 1 From f7082ab371b0454c32ed2b120cdac5f28e02a587 Mon Sep 17 00:00:00 2001 From: Brooke Date: Sun, 22 Jun 2025 22:21:26 -0700 Subject: [PATCH 2/3] wip subtraction method, still not working --- mandel.s | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/mandel.s b/mandel.s index dc7e323..73a8ebb 100644 --- a/mandel.s +++ b/mandel.s @@ -221,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) @@ -1982,7 +1986,11 @@ update_status: lda FR0 + 1 sta temp + 1 - .macro countdown divisor, string + ;jsr IFP + ;jsr FASC + ;jsr draw_string + + .macro countdown divisor, digits .scope ; count the hours ldx #0 @@ -2003,20 +2011,27 @@ update_status: inx jmp countdown_loop countdown_done: - stx FR0 - ldx #0 - stx FR0 + 1 - jsr IFP - jsr FASC + lda digits,x + eor #$80 + sta temp2 + lda #.lobyte(temp2) + sta INBUFF + lda #.hibyte(temp2) + sta INBUFF + 1 jsr draw_string - draw_string_const string .endscope .endmacro draw_string_const str_space - countdown 3600, str_h - countdown 60, str_m - countdown 1, str_s + 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: From 5cf64970c8a9ca8efe7821a9f425cb9282c92e29 Mon Sep 17 00:00:00 2001 From: Brooke Vibber Date: Sun, 22 Jun 2025 23:10:43 -0700 Subject: [PATCH 3/3] Ah that's better used the appropriate instruction for comparison --- mandel.s | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/mandel.s b/mandel.s index 73a8ebb..6837e00 100644 --- a/mandel.s +++ b/mandel.s @@ -398,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 @@ -1979,12 +1984,12 @@ update_status: ldx #.lobyte(total_sec) ldy #.hibyte(total_sec) jsr FLD0R - ; FR0 -> integer -> temp + ; FR0 -> integer -> elapsed_work jsr FPI lda FR0 - sta temp + sta elapsed_work lda FR0 + 1 - sta temp + 1 + sta elapsed_work + 1 ;jsr IFP ;jsr FASC @@ -1995,28 +2000,28 @@ update_status: ; count the hours ldx #0 countdown_loop: - lda temp + 1 + lda elapsed_work + 1 cmp #.hibyte(divisor) - bmi countdown_done - lda temp + bcc countdown_done + lda elapsed_work cmp #.lobyte(divisor) - bmi countdown_done + bcc countdown_done sec - lda temp + lda elapsed_work sbc #.lobyte(divisor) - sta temp - lda temp + 1 + sta elapsed_work + lda elapsed_work + 1 sbc #.hibyte(divisor) - sta temp + 1 + sta elapsed_work + 1 inx jmp countdown_loop countdown_done: lda digits,x eor #$80 - sta temp2 - lda #.lobyte(temp2) + sta elapsed_digit + lda #.lobyte(elapsed_digit) sta INBUFF - lda #.hibyte(temp2) + lda #.hibyte(elapsed_digit) sta INBUFF + 1 jsr draw_string .endscope