0100 ;MUSICIAN›0110 ;BY MIKE EGGERS AND MATT LOVELESS›0120 ;(c) 1987, ANTIC PUBLISHING›0130 .TITLE "MUSICIAN -- Music Player"›0140 ;›0150 AUDC1 = $D201 ;Control reg for›0160 ; sounds›0170 AUDF1 = $D200 ;Tone frequency›0180 ; reg.›0190 CLOCK = $14 ;Last byte of›0200 ; real-time clock›0210 TEMPO = $D6 ;Tempo index›0220 ; number*4›0230 OCTAVE = $D7 ;Octave of note›0240 ; (3-6).›0250 DURATN = $D8 ;Tone duration 0211 ; index.›0260 ; index›0270 POS = $D9 ;Current pos.›0280 ; in string.›0290 ADDR = $DA ;Location of›0300 ; string.›0310 TONES = $DC ;Addr of string›0320 ; w/note info.›0330 TIME = $DE ;Addr of string with duration info›0340 ; ; w/duration inf›0350 ;›0360 *= $0600›0370 ;›0380 TOP›0390 LDA #0 ;Set default›0400 STA TEMPO ; tempo,›0410 STA DURATN ; duration,›0420 STA POS ; position›0430 LDA #2 ; & octave.›0440 STA OCTAVE›0450 PLA ;Ignore argument›0460 ; count.›0470 PLA ;get addr›0480 ; of string.›0490 STA ADDR+1›0500 PLA ›0510 STA ADDR›0520 PLA ;Get addr of›0530 ; tone variable.›0540 STA TONES+1›0550 PLA ›0560 STA TONES›0570 PLA ;Get addr of›0580 ; time variable.›0590 STA TIME+1›0600 PLA ›0610 STA TIME›0620 PLA ;Ignore hi-byte›0630 ; of volume.›0640 PLA ;Get low-byte›0650 ; of volume,›0660 ORA #$A0 ;OR w/distortion›0670 ; value,›0680 STA AUDC1 ; init sound.›0690 INC1›0700 LDY POS ;Find index into›0710 ; string.›0720 INC POS ;Move right›0730 LDA (ADDR),Y ;Get current›0740 ; character.›0750 TAX ; Save it.›0760 INY ; Increase again›0770 LDA (ADDR),Y ;Get operand›0780 ; (if any)›0790 TAY ;Save it.›0800 SEC ;Make operand›0810 ; into an index›0820 SBC #$31 ; by subtracting›0830 ; a "1".›0840 CPX #$54 ;Is it a tempo›0850 ; command?›0860 BNE TSTDUR ;No. Try again.›0870 ;›0880 ASL A ;Multiply by 4›0890 ; for an index›0900 ASL A ; into table.›0910 STA TEMPO ;Done.›0920 ;›0930 TSTDUR›0940 CPX #$4C ;A duration cmd?›0950 BNE TSTOCT ;No. Try again.›0960 ;›0970 STA DURATN ;Save new›0980 ; dur. index.›0990 TSTOCT›1000 CPX #$4F ;Is it an "O"›1010 ; (An Octave?)›1020 BNE TSTPER ;No. Try again.›1030 ;›1040 SEC ;subtract two to›1050 SBC #$02 ; find total of›1060 ; "3"›1070 STA OCTAVE ; and save it.›1080 TSTPER›1090 CPX #$2E ;Is it a period?›1100 BNE TSTCOM ;No.›1110 ;›1120 RTS ›1130 ;›1140 TSTCOM›1150 CPX #$2C ;Is it a delay?›1160 BNE TSTSEM ;No.›1170 ;›1180 LDA TEMPO ;1st duration›1190 ; for this tempo›1200 CLC ; and branch.›1210 BCC DELAY2 ;UNCONDITIONAL!›1220 ;›1230 TSTSEM›1240 CPX #$3B ;Is it a " ; "?›1250 BNE TSTNOTE ;No. Try again.›1260 ;›1270 LDA #5 ;Delay for 1/12›1280 ; of a second.›1290 BNE DELAY3 ;UNCONDITIONAL!›1300 ;›1310 TSTNOTE›1320 CPX #$41 ;Less than "A" ?›1330 BMI INC1 ;Yes...›1340 ;›1350 CPX #$48 ;Gr. than "G" ?›1360 BCS INC1 ;Yes, so note›1370 ; is illegal.›1380 ;›1390 TXA ;Convert note to›1400 ; an index›1410 SEC ; by subtracting›1420 ; an "A"›1430 SBC #$41›1440 ASL A ;Multiply by two›1450 CPY #$23 ;Is next char.›1460 ; a "#" ?›1470 BNE FLAT ;No. Try again.›1480 ;›1490 CLC ;get flat of nxt›1500 ; higher note.›1510 ADC #3›1520 FLAT›1530 CPY #$2D ;Is next char a›1540 ; "-" ?›1550 BNE TIMES4 ;No. Try again.›1560 ;›1570 CLC ;Point to Flat›1580 ; value.›1590 ADC #1›1600 TIMES4›1610 CMP #$0F ;Is Note greater›1620 ; than G# ?›1630 BCC TIMES5 ;No. Try again.›1640 ;›1650 LDA #1 ;Yes. Go back to›1660 ; A-flat.›1670 TIMES5›1680 ASL A ;Multiply note›1690 ; by 4 to get a›1700 ASL A ; table index.›1710 CLC ;Add octave for›1720 ADC OCTAVE ; position of›1730 ; sound vlue›1740 TAY ;Prepare to LOAD›1750 LDA (TONES),Y ;get actual›1760 ; sound value›1770 STA AUDF1 ; & start note.›1780 DELAY›1790 LDA TEMPO ;Figure tone›1800 ; duration by›1810 CLC ; by adding›1820 ; duration to›1830 ; TEMPO*4›1840 ADC DURATN ; to get index.›1850 DELAY2›1860 TAY ;Prepare to LOAD›1870 LDA (TIME),Y ;Get actual›1880 ; tone duration.›1890 DELAY3›1900 LDY #0 ;Reset clock›1910 STY CLOCK›1920 WAIT›1930 CMP CLOCK ;Time up?›1940 BCS WAIT ;No. Continue.›1950 ;›1960 STY AUDF1 ;Turn off sound.›1970 CLC ›1980 BCC INC1 ;UNCONDITIONAL!›1990 ;›2000 .END ›