*PRIMARY ROUTINES

*FOR SLOT 4

*

ORG $9000

;ADDRESSES FOR FIRST 6522

ORB EQU $C400 ;PORT B

ORA EQU $C401 ;PORT A

DDRB EQU $C402 ;DATA DIRECTION REGISTER (A)

DDRA EQU $C403 ;DATA DIRECTION REGISTER (B)

;ADDRESSES FOR SECOND 6522

ORB2 EQU $C480 ;PORT B

ORA2 EQU $C481 ;PORT A

DDRB2 EQU $C482 ;DATA DIRECTION REGISTER (B)

DDRA2 EQU $C483 ;DATA DIRECTION REGISTER (A)

*

*ROUTINES FOR FIRST 6522

*

INIT LDA #$FF ;SET PORT A FOR OUTPUT

 STA DDRA 

 LDA #$07 ;SET PORT B FOR OUTPUT

 STA DDRB

 RTS ;RETURN

*

LATCH LDA #$07 ;SEND "LATCH COMMAND"

 STA ORB ;TO SOUND CHIP

 LDA #$04 ;THROUGH PORT B

 STA ORB

 RTS ;RETURN

*

WRITE LDA #$06 ;SEND "WRITECOMMAND"

 STA ORB ;TO SOUND CHIP

 LDA #$04 ;THROUGHPORT B

 STA ORB

 RTS ;RETURN

*

RESET LDA #$00 ;SEND "RESET COMMAND"

 STA ORB ;TO SOUND CHIP

 LDA #$04 ;THROUGH PORT B

 STA ORB

 RTS ;RETURN

*

*ROUTINES FOR SECOND 6522

*

INIT2 LDA #$FF ;SET PORT A FOR OUTPUT

 STA DDRA2

 LDA #$07 ;SET PORT B FOR OUTPUT

 STA DDRB2

 RTS ;RETURN

*

 

LATCH2 LDA #$07 ;SEND "LATCH COMMAND"

 STA ORB2 ;TO SOUND CHIP

 LDA #$04 ;THROUGH PORT B

 STA ORB2 

 RTS ;RETURN 

*

WRITE2 LDA #$06 ;SEND "WRITECOMMAND"

 STA ORB2 ;TO SOUND CHIP

 LDA #$04 ;THROUGHPORT B

 STA ORB2

 RTS ;RETURN

* 

 STA #$00 ;SEND "RESET COMMAND"

 STA ORB2 ;TO SOUND CHIP

 LDA #$04 ;THROUGH PORT B

 STA ORB2

 RTS ;RETURN
