aboutsummaryrefslogtreecommitdiff
path: root/src/keyclick.s
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-03-01 02:00:23 -0500
committerB. Watson <urchlay@slackware.uk>2026-03-01 02:00:23 -0500
commit6521e971cdb772c53256d84a54c8d7b2d1ffa632 (patch)
tree28af564e7a12dd629d791e815834b3782177ec0c /src/keyclick.s
parentd3a19b319e8ecdf111de44ffa9847474301edcbb (diff)
downloadfujinet-chat-6521e971cdb772c53256d84a54c8d7b2d1ffa632.tar.gz
Scrollback!
Diffstat (limited to 'src/keyclick.s')
-rw-r--r--src/keyclick.s53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/keyclick.s b/src/keyclick.s
new file mode 100644
index 0000000..bbe613c
--- /dev/null
+++ b/src/keyclick.s
@@ -0,0 +1,53 @@
+ .include "atari.inc"
+ .export _keyclick
+
+; keyclick.s - just what you think it is.
+
+; How do you make it possible to disable the keyclick on the 400/800?
+; Don't use the OS K: handler.
+
+ ;.ifdef REAL_KEYCLICK
+ .if 1
+
+; Copied from OS ROM source, 12 bytes of code. Because of the repeated
+; stx WSYNC, you don't want to use this if you're using DLIs.
+; Preserves A and Y, returns with X=$ff, N set, Z clear.
+_keyclick:
+ ldx #$7f
+@rc1:
+ stx CONSOL
+ stx WSYNC
+ dex
+ bpl @rc1
+ rts
+
+ .else
+
+; Fake keyclick. 25 bytes of code. Sounds just like the real one, but
+; it won't mess up your DLIs because it's interruptible (though DLIs
+; might mess it up). Loop timing assumes a GR.0 type display list
+; with playfield DMA enabled and P/M DMA disabled.
+; Preserves A, returns with X=$ff, Y=0, N set, Z clear.
+_keyclick:
+@wcount:
+ ldx VCOUNT ; To make the timing consistent, wait until we're sure
+ cpx #$10 ; that ANTIC is doing DMA.
+ bne @wcount
+
+ ldx #$7f
+@click: ; I tuned this by ear, then cycle-counted afterward.
+ stx CONSOL ; 4
+ ldy #$07 ; 2
+ ;lda #0 ; 2
+ nop
+@c1:
+ dey ; inner: 2
+ nop ; 2
+ bne @c1 ; 3
+ ; 7 cycles/loop, *7 = 49, -1 for failed BNE
+ ; 48
+ dex ; 2
+ bpl @click ; 3 = 61
+ rts
+
+ .endif