SAMPLE ASSEMBLY LISTINGS

The first routine loads samples from the A-to-D converter and outputs them to the D-to-A converter. This rout~ne simulates the freerun option used in the ADA software. The second routine ~s a simPIe play the sample program. Enjoy.

1 ORG $1000 ;CODE STARTS AT $1000
2 STRTADD DFB $36 ;START ADDR OF SOUND
3 LENGTH DFB 96 ;LENGTH OF SOUND
4 PITCH DFB 4 ;SOUND PITCH(OFFSET FOR PITCHBL)
5 SMPLDEL DFB 10 ;DELAY BETWEEN SAMPLES
6 BDSLOT DFB $30 ;SLOT BUFFER (SLOT# 3)
7 LEVEL DFB 2Z ;OUTPUT VOLUME
8 PBUF DFB 0 ;BUFFER FOR PITCHBL ADDRESSING
9 ADDCALC EQU $FA ;ADDRESS CALC STORAGE
10 INDIRLO EQU $FB ;INDIRECT ADD POINTER
11 BLOCKS EQU $FD ;# OF PAGES OF DATA TO PLAY
12 READADC EQU $CO81 ;BASE I/O ADDR ADC
13 BUSY EQU $C083 ;SASE I/O ADDR ADC BUSY LINE
14 OUTLEV EQU $C085 ;BASE I/O ADDR OUTPUT LEVEL
15 WRDAC EQU $C086 ;BASE I/O ADDR OUTPUT DATA
16 KEYBD EQU $C000 ;APPLE II KEYBRD LOCATION

17 *******************************
18;
19; THIS SUB-ROUTINE PLAYS SOUND FROM ADC TO DAC
20;
21 FREERUN LDX BDSLOT ;GET BOARD SLOT
22 LDA LEVEL ;GET OUTPUT VOLUME
23 STA OUTLEY,X ;SET VOLUME DAC
24 FRERUN1 LDA READADC,X ;READ ADC CONVERTER
25 STA WRDAC,X ;PLAY IT
26 LDA KEYBD
27 BMI DONE ;BRANCH IS KEYPRESSED
28 LDX SMPLDEL ;DELAY BETWEEN SAMPLES
29 FREDEL DEX
30 BNE FREDEL ;LOOP TILL DELAY DONE
31 LDX BDSLOT ;SET X TO BD SLOT
32 FRELOOP LDA SUSY,X ;IS ADC READY FOR SAMPLE
33 BPL FRELOOP ;BRANCH IF NOT READY
34 BMI FRERUN1 ;IT'S READY
35 DONE RTS
36 ************************************
37;
38;THIS SUB-ROUTINE PLAYS SOUND DATA FROM MEMORY
39;
40 INTPLAY LDX BDSLOT ;GET BD SLOT
41 LDA LEVEL ;GET OUTPUT VOLUME
42 STA OUTLEV,X ; SET DAC VOLUME
43 LDA LENGTH ;GET SAMPLE LENGTH
44 STA BLOCKS ;SAVE LENGTH
45 LDA PITCH ;GET PITCH NOTE
46 ASL A ;MULT BY TWO FOR PITCHBL ADDR
47 STA PBUF ;SAVE FOR ROUTINE BELOW
48 LDA #300 ;CLEAR ACCUMULATOR
49 STA ADDCALC ;INIT FINE ADDRESSING CALC BUFFER
50 STA INDIRLO ;INIT INDIRECT POINTER
51 LDA STRTADD ;GET PTR TO BEGINNING OF SOUND
5Z STA INDIRLO+1 ; SAVE INDIR PTR ~ HIGH BYTE )
53 LDY #$00 ;INIT Y FOR INDEXING
54 PLAY LDX PBUF ;GET PITCH NOTE
55 LDA PITCHTBL+1,X ;GET FINE TUNE CONSTANT
56 CLC ;CLEAR CARRY FOR ADDITION
57 ADC ADDCALC ;ADD TO OLD PARTIAL PTR VALUE
58 STA ADDCALC ;SAVE IT
59 LDA PITCHBL,X ;GET COARSE TUNE CONSTANT
60 ADC INDIRLO ;ADD TO OLD MID PTR VALUE
61 STA INDIRLO ;SAVE IT AWAY
62 BCS NEXTPAGE ;BRANCH IF DONE WITH PAGE
63 LDA (INDIRLO),Y ;GET SOUND DATA
64 LDX BDSLOT ;SET X TO BD SLOT
65 STA WRDAC,X ;PLAY SOUND
66 LDA KEYBD ;QUIT IF KEYPRESSED
67 BMI PDONE ;BRANCH IF YES
68 JMP PLAY ;NO,PLAY MORE
69 NEXTPAGE INC INDIRLO+1 ;POINT TO NEXT PAGE
70 DEC BLOCKS ;ARE WE DONE?
71 BNE PLAY ;BRANCH IF NOT DONE
72 PDONE RTS ;BACK TO CALLING ROUTINE OR BASIC

73 PITCHTBL DFB 0,128 ;LOWER NOTES FIRST
74 DFB 0,136
75 DFB 0,144 ;1ST VALUE IS COARSE TUNE,2ND=FINE
76 DFB 0,152
77 DFB 0,161
78 DFB 0,171 ;HIGHER NOTE
79 ;ETC
END