From: Oliver Schmidt Date: Fri, 17 Aug 2018 22:13:38 +0000 (+0200) Subject: Fixed 12 AM/PM handling. X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cb7ec508f650e79e1d2527bd3b5fdb86e390f9ed;p=cc65 Fixed 12 AM/PM handling. Midnight is 12 AM and noon is 12 PM (see https://en.wikipedia.org/wiki/12-hour_clock). Therefore we need to subtract 12 hours in exactly those two hours. --- diff --git a/libsrc/c128/gettime.s b/libsrc/c128/gettime.s index b59789117..81f49c640 100644 --- a/libsrc/c128/gettime.s +++ b/libsrc/c128/gettime.s @@ -24,13 +24,18 @@ jsr pushax lda CIA1_TODHR - bpl AM - and #%01111111 sed + tax ; Save PM flag + and #%01111111 + cmp #$12 ; 12 AM/PM + bcc @L1 + sbc #$12 +@L1: inx ; Get PM flag + bpl @L2 clc adc #$12 - cld -AM: jsr BCD2dec +@L2: cld + jsr BCD2dec sta TM + tm::tm_hour lda CIA1_TODMIN jsr BCD2dec diff --git a/libsrc/c64/gettime.s b/libsrc/c64/gettime.s index 61c5115ae..8973e0e33 100644 --- a/libsrc/c64/gettime.s +++ b/libsrc/c64/gettime.s @@ -24,13 +24,18 @@ jsr pushax lda CIA1_TODHR - bpl AM - and #%01111111 sed + tax ; Save PM flag + and #%01111111 + cmp #$12 ; 12 AM/PM + bcc @L1 + sbc #$12 +@L1: inx ; Get PM flag + bpl @L2 clc adc #$12 - cld -AM: jsr BCD2dec +@L2: cld + jsr BCD2dec sta TM + tm::tm_hour lda CIA1_TODMIN jsr BCD2dec diff --git a/libsrc/cbm510/gettime.s b/libsrc/cbm510/gettime.s index 3ad162e3b..b89b9b16b 100644 --- a/libsrc/cbm510/gettime.s +++ b/libsrc/cbm510/gettime.s @@ -26,13 +26,18 @@ ldy #CIA::TODHR lda (cia2),y - bpl AM - and #%01111111 sed + tax ; Save PM flag + and #%01111111 + cmp #$12 ; 12 AM/PM + bcc @L1 + sbc #$12 +@L1: inx ; Get PM flag + bpl @L2 clc adc #$12 - cld -AM: jsr BCD2dec +@L2: cld + jsr BCD2dec sta TM + tm::tm_hour ldy #CIA::TODMIN lda (cia2),y diff --git a/libsrc/cbm610/gettime.s b/libsrc/cbm610/gettime.s index 30226213d..cfd2a9fe9 100644 --- a/libsrc/cbm610/gettime.s +++ b/libsrc/cbm610/gettime.s @@ -26,13 +26,18 @@ ldy #CIA::TODHR lda (cia),y - bpl AM - and #%01111111 sed + tax ; Save PM flag + and #%01111111 + cmp #$12 ; 12 AM/PM + bcc @L1 + sbc #$12 +@L1: inx ; Get PM flag + bpl @L2 clc adc #$12 - cld -AM: jsr BCD2dec +@L2: cld + jsr BCD2dec sta TM + tm::tm_hour ldy #CIA::TODMIN lda (cia),y