CLRCHN

From C64-Wiki
Jump to navigationJump to search

The CLRCHN kernal routine is located at $FFCC (65484).

This routine does an indirect jump to vector $0322/$0323 (802/803), which by default points to $F333 (62259). It restores the screen as current output device and the keyboard as current input device.

FFCC   6C 22 03   JMP ($0322)   ; (F333) restore I/O devices to default
↓
F333   A2 03      LDX #$03      ; device 3 is the screen
F335   E4 9A      CPX $9A       ; check if current output device is the screen
F337   B0 03      BCS $F33C     ; if equal or a lower device is current, skip next subroutine
F339   20 FE ED   JSR $EDFE     ; send unlisten on serial bus
F33C   E4 99      CPX $99       ; check if current input device is the screen
F33E   B0 03      BCS $F343     ; if equal or a lower device is current, skip next subroutine
F340   20 EF ED   JSR $EDEF     ; send talk on serial bus
F343   86 9A      STX $9A       ; set screen as current output device
F345   A9 00      LDA #$00      ; device 0 is the keyboard
F347   85 99      STA $99       ; set keyboard as current input device
F349   60         RTS           ; return