From 01175cf5739985cd3832f08a1202e09bbbd450b5 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Sun, 22 Oct 2023 17:08:34 -0400 Subject: [PATCH] Prevent hang probing for The Cricket! in MAME on IIc/IIc+ In MAME, for the SSC in Slot 2, the STATUS flag never comes back with ready-to-send, so the probe would hang. Introduce a timer, same as on the receiving side, and timeout instead of hanging. Similar to https://github.com/a2stuff/a2d/commit/14e72b7384cdbedd3ac5ac6eb287927e8952d7c7 --- clocks/cricket/cricket.system.s | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/clocks/cricket/cricket.system.s b/clocks/cricket/cricket.system.s index 40f7423..efc4b80 100644 --- a/clocks/cricket/cricket.system.s +++ b/clocks/cricket/cricket.system.s @@ -89,6 +89,7 @@ init_ssc: ;; Read Cricket ID code: 00 ($00) lda #0 jsr sendbyte + bcs cricket_not_found ; timeout ;; "The Cricket will return a "C" (195, $C3) followed by a ;; version number (in ASCII) and a carriage return (141, $8D)." @@ -168,12 +169,33 @@ saved_control: .byte 0 ;; Write byte in A .proc sendbyte + tries := $100 * read_delay_hi + counter := $A5 + pha -: lda STATUS + + lda #tries + sta counter+1 + +check: lda STATUS and #(1 << 4) ; transmit register empty? (bit 4) - beq :- ; nope, keep waiting + bne ready ; yes, ready to write + + dec counter + bne check + dec counter+1 + bne check + + pla + sec ; failed + rts + +ready: pla sta TDREG + clc rts .endproc