Skip to content

Commit

Permalink
The Cricket!: fix hang on Total Replay (#19)
Browse files Browse the repository at this point in the history
* The Cricket!: fix hang on Total Replay

The Cricket reset command sends Total Replay into an endless loop when launched, presumably because of an interrupt situation (TR just does RTI on an interrupt). Toggling the COMMAND and CONTROL settings seems to allow TR to function properly, while also allowing the Cricket initialization code to silence any playing notes.

* The Cricket!: Reset Cricket before probing

Finds the Cricket every single time this way. Occasionally the driver would miss finding it due to it being in a wait state. Sending a reset first fixes that.

* The Cricket!: make sure registers are toggled for TR
  • Loading branch information
frankmilliron authored Jul 17, 2023
1 parent 9401723 commit b182a53
Showing 1 changed file with 38 additions and 16 deletions.
54 changes: 38 additions & 16 deletions clocks/cricket/cricket.system.s
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,24 @@ ssc_not_found:
init_ssc:
php
sei

;; Reset SSC
sta KBDSTRB ; Port 2 DSR line connected to KBDSTRB
lda #0
sta COMMAND ; hardware reset all Port 2 ACIA registers
sta CONTROL
sta STATUS
lda COMMAND ; save status of SSC registers
sta saved_command
lda CONTROL
sta saved_control

;; Reset the Cricket (stops any playing notes & ensures Cricket is listening)
jsr restore_cmd_ctl ; have to change registers for this to work
jsr reset_cricket
jsr restore_cmd_ctl
jsr reset_cricket ; does it twice in original Cricket driver
jsr restore_cmd_ctl

;; Configure SSC
lda #%00001011 ; no parity/echo/interrupts, RTS low, DTR low
sta COMMAND
lda #%10011110 ; 9600 baud, 8 data bits, 2 stop bits
sta CONTROL

;; Reset Cricket
jsr readbyte ; done on original disk
lda #HI(ASCII_CR) ; two carriage returns
jsr sendbyte
lda #HI(ASCII_CR)
jsr sendbyte
lda #HI('!') ; Reset Cricket (everything but time/date)
jsr sendbyte

;; Read Cricket ID code: 00 ($00)
lda #0
jsr sendbyte
Expand All @@ -126,10 +121,12 @@ digit: cmp #HI('0') ; < '0' ?
bcc :-

cricket_found:
jsr restore_cmd_ctl
plp
jmp install_driver

cricket_not_found:
jsr restore_cmd_ctl
plp
;; fall through...

Expand All @@ -145,6 +142,31 @@ not_found:

sec ; failure
rts

reset_cricket:
lda #%00001011 ; no parity/echo/interrupts, RTS low, DTR low
sta COMMAND
lda #%10011110 ; 9600 baud, 8 data bits, 2 stop bits
sta CONTROL

jsr readbyte ; done on original disk
lda #HI(ASCII_CR) ; two carriage returns
jsr sendbyte
lda #HI(ASCII_CR)
jsr sendbyte
lda #HI('!') ; Reset Cricket (everything but time/date)
jsr sendbyte
rts

restore_cmd_ctl:
lda saved_control
sta CONTROL
lda saved_command
sta COMMAND
rts

saved_command: .byte 0
saved_control: .byte 0
.endproc

;; Write byte in A
Expand Down

0 comments on commit b182a53

Please sign in to comment.