;; #LAYOUT# STD * #TAKE ;; #LAYOUT# * * #IGNORE ; ; CIA1's TOD from the Arnitech controller's real time (mc64 only, arnitech's ADR 0023) ; ; The controller lays its time out as the TOD reads it, so the copy goes hours first, which stops ; the TOD, and tenths last, which starts it. The CIA flips the PM bit when an hour of 12 is ; written (VICE does so too), so an hour of 12 has bit 7 flipped first. ; !ifdef CONFIG_ARNITECH_CONTROLLER { ; ; ARNI_SETTOD, $FF09: see ff00.arnitech_jumptable.s ; arnitech_set_tod: lda CIA1_CRA ora #$80 ; TOD on 50 Hz, the mc64's mains sta CIA1_CRA ; FALLTHROUGH ; ; The copy alone, for IOINIT, which has set CRA already. ; Out: carry clear if set, carry set if no controller answers. A and X are not kept, Y is. ; arnitech_tod_from_clock: jsr arnitech_check_signature bcs @2 lda ARNITECH_CLOCK_LATCH ; copies the clock into $DE91-$DE9E ldx ARNITECH_CLOCK_HRS txa and #$7F cmp #$12 bne @1 txa eor #$80 ; the CIA flips it back tax @1: stx CIA1_TODHRS ; stops the TOD lda ARNITECH_CLOCK_MIN sta CIA1_TODMIN lda ARNITECH_CLOCK_SEC sta CIA1_TODSEC lda ARNITECH_CLOCK_TEN sta CIA1_TODTEN ; starts it clc @2: rts }