Example code by Fabrice Broche:
_Synchro .( STA $04 STX $03 LDA #$80 STA $00 LDA #$BB STA $01 LDY #$00 CLC L1 LDA $04 STA ($00),Y LDX $03 loop1 DEX BNE loop1 TYA ADC #$28 TAY BCC L1 LDA #$00 ADC $01 STA $01 CMP #$C0 BCC L1 RTS .)
_DoSync .( SEI L6 LSR $02DF LDA #$40 L2 BIT $030D BEQ L2 LDA #$11 LDX #$01 JSR _Synchro LDA #$12 LDX #$12 JSR _Synchro BRK BRK LDA $02DF CMP #$D3 BNE L3 INC $0306 BNE L3 INC $0307 L3 CMP #$C6 BNE L4 LDX $0306 BNE L5 DEC $0307 L5 DEC $0306 L4 CMP #$D1 BNE L6 CLI RTS .)