From 2f2c4ba26bfd5db258769358f8c26c732c8ffbd6 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Tue, 26 Mar 2019 18:49:22 -0700 Subject: [PATCH] DeskTop: tighten up clock code, remove extra space --- desktop/desktop_main.s | 56 +++++++++++++++--------------------------- desktop/desktop_res.s | 6 +++-- 2 files changed, 24 insertions(+), 38 deletions(-) diff --git a/desktop/desktop_main.s b/desktop/desktop_main.s index ad74d38..bba8464 100644 --- a/desktop/desktop_main.s +++ b/desktop/desktop_main.s @@ -7023,6 +7023,8 @@ xcoord: .endproc ; draw_window_header ;;; ============================================================ +;;; Input: 16-bit unsigned number in A,X +;;; Output: length-prefixed string in str_from_int .proc int_to_string stax value @@ -9606,51 +9608,33 @@ open: MLI_RELAY_CALL OPEN, open_params ;; -------------------------------------------------- ;; Time - lda TIMEHI ; hours + lda TIMEHI ; Hours and #%00011111 - - ;; AM/PM - ldx #'A' - cmp #12 + pha ; Save hours + bne :+ ; 0 -> 12 + clc + adc #12 +: cmp #13 ; make 12-hour bcc :+ - ldx #'P' sec sbc #12 -: stx str_clock + 7 +: ldx #0 + jsr int_to_string + addr_call draw_text1, str_from_int - ;; Hours - cmp #0 ; 0 -> 12 - bne :+ - lda #12 -: ldx #' ' ; Leading space or 1? - cmp #10 - bcc :+ - ldx #'1' - sec - sbc #10 -: stx str_clock + 1 ; Tens place - ora #'0' - sta str_clock + 2 ; Ones place + addr_call draw_text1, str_colon - ;; Minutes lda TIMELO and #%00111111 - ldx #0 ; Subtract off tens (in X) -: cmp #10 - bcc :+ - inx - sec - sbc #10 - bpl :- -: ora #'0' - sta str_clock + 5 ; Ones place - txa - ora #'0' - sta str_clock + 4 ; Tens place - - addr_call draw_text1, str_clock -done: rts + ldx #0 + jsr int_to_string + addr_call draw_text1, str_from_int + pla ; Restore hours + cmp #12 + bcs :+ + addr_jump draw_text1, str_am +: addr_jump draw_text1, str_pm .endproc ;;; Day of the Week calculation (valid 1900-03-01 to 2155-12-31) diff --git a/desktop/desktop_res.s b/desktop/desktop_res.s index fd4e7ff..da8c36d 100644 --- a/desktop/desktop_res.s +++ b/desktop/desktop_res.s @@ -811,8 +811,10 @@ file_to_delete_label: pos_clock: DEFINE_POINT 475, 10 -str_clock: - PASCAL_STRING "00:00 XM " +str_colon: + PASCAL_STRING ":" +str_am: PASCAL_STRING " AM" +str_pm: PASCAL_STRING " PM" dow_strings: .byte "Sun ", "Mon ", "Tue ", "Wed ", "Thu ", "Fri ", "Sat "