DeskTop: tighten up clock code, remove extra space

This commit is contained in:
Joshua Bell 2019-03-26 18:49:22 -07:00
parent 546c264d5e
commit 2f2c4ba26b
2 changed files with 24 additions and 38 deletions

View File

@ -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)

View File

@ -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 "