;TABLE ACCESS ROUTINE

;FOR SLOT 4

*

ORG $8000

;ADDRESSES FOR FIRST 6522

PTR EQU $08 ;DATA POINTER

ORA EQU $C401 ;PORT A

LATCH EQU $900B ;LATCH SUB-ROUTINE

 

WRITE EQU $9016 ;WRITE SUB-ROUTINE

RESET EQU $9021 ;RESET SUB-ROUTINE

;ADDRESSES FOR SECOND 6522

PRT2 EQU $0A ;DATA POINTER

ORA2 EQU $C481 ;PORT A

LATCH2 EQU $9037 ;LATCH SUB-ROUTINE

WRITE2 EQU $9042 ;RESET SUB-ROUTINE

RESET2 EQU $904D ;RESET SUB-ROUTINE

* 

*ROUTINES FOR FIRST 6255

*

 

START JSR RESET ;RESET SOUND CHIP

 LDY #$00 ;USED TO IDENTIFY REGISTER

LOOP STY ORA ;# OF SOUND CHIP

 JSR LATCH

 LDA (PTR),Y ;GET DATA FROM TABLE

 STA ORA

 JSR WRITE ;STORE IN REGISTER

 CPY #$0F ;END OF DATA?

 BEQ DONE ;YES, EXIT

 INY

 JMP LOOP ;NO, GET NEXT SET

DONE RTS ;RETURN

* 

*ROUTINES FOR SECOND 6522 

* 

START2 JSR RESET2 ;SAME INSTRUCTIONS AS 

 LDY #$00 ;ABOVE

LOOP2 STY ORA2

 JSR LATCH2

 LDA (PTR2),Y

 STA ORA2

 JSR WRITE2

 CPY #$0F

 BEQ DONE2

 INY

 JMP LOOP2

DONE2 RTS