home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Set of Apple II Hard Drive Images
/
eric.hdv
/
OBJSRC
/
DRUMMACH.SRC.txt
< prev
next >
Wrap
Text File
|
2020-08-13
|
6KB
|
278 lines
; ********************************************
; * DRUMMACH.SRC - DRUM MACHINE OBJECT
; * (C) 1993, ERIC RANGELL
; ********************************************
;
;------------GLOBAL EQUATES
RECEIVER EQU $FA
MSG EQU $FB
MYOBJ EQU $FD
MYADRS EQU $FE ;WILL POINT TO 'BASE' WHEN OBJECT INVOKED
;
USRVECT EQU $0A ;APPLESOFT USR VECTOR - USED TO CALL OBJECTS
;
;------------OBJECTS REFERENCED
DRUMMACH EQU 11
MOCKBRD EQU 10 ;<=== MOCKINGBOARD INTERFACE
;
;------------OBJECT HEADER
ORG $6000
;
LDA #$00 ;CALL OBJECT SETUP ROUTINE
STA $FA
JSR $000A
DFB DRUMMACH ;OBJECT NUMBER
DFB 0,0,0,0,0,0,0 ;SAVE AREA
BASE CLV
BVC CODE
RETCODE DFB $00 ;RETURN CODE
;
;==========================================
; INTERNAL DATA MAINTAINED BY OBJECT:
;
DRUM DFB $01 ; DRUM NUMBER
;
; INSTRUMENT DATA: NOISE PERIOD, COARSE TONE PERIOD
; 0=CYMBAL, 1=HIHAT, 2=SNARE, 3=TOMTOM, 4=BASSDRUM
;
NOISE DFB $01,$01,$04,$10,$1F
COARSE DFB $10,$02,$04,$02,$04
;
DRUMMAP DFB $FF,60,52,44,36
;
INITFLAG DFB 2 ;>0=INITIALIZE MKBD, WILL COUNT DOWN TO ZERO
;
INITMSG ASC 'I'
POKEMSG ASC 'P'
REGISTER DFB $00
DATA DFB $00
SPKRMSG DFB 'S'
SPEAKER DFB $00 ; 0=LEFT 1=RIGHT
;==========================================
; METHODS:
;
; D <DRUM #> = BANG DRUM (0-4)
; N <MIDI NOTE#> = BANG DRUM CORRESPONDING TO MIDI NOTE #
;
;==========================================
CODE LDY #0
LDA (MSG),Y
CMP #'N'
BNE CODED
;
INY
LDA (MSG),Y
AND #$7F
TAX
LDA #4
CLC
ADC #DRUMMAP-BASE
TAY
TXA
LOOP CMP (MYADRS),Y
BCC GOTIT
DEY
BNE LOOP
GOTIT TYA
SEC
SBC #DRUMMAP-BASE
LDY #DRUM-BASE
STA (MYADRS),Y
CLV
BVC DRUMNOW
;
CODEEX LDY #RETCODE-BASE
LDA #12
STA (MYADRS),Y
SEC
RTS
;
;--------
CODED CMP #'D'
BNE CODEEX
LDY #1
LDA (MSG),Y
CMP #5
BCC STORIT
LDA #4
STORIT LDY #DRUM-BASE
STA (MYADRS),Y
;
DRUMNOW LDY #INITFLAG-BASE
LDA (MYADRS),Y
BEQ DONTINIT
SEC
SBC #1
STA (MYADRS),Y
BEQ PHASE2
;
LDA #MOCKBRD ;INIT MOCK
STA RECEIVER
LDA #INITMSG-BASE
CLC
ADC MYADRS
STA MSG
LDA #00
ADC MYADRS+1
STA MSG+1
JSR USRVECT
;
PHASE2 LDA #16
LDY #DATA-BASE
STA (MYADRS),Y
LDA #8
LDY #REGISTER-BASE
STA (MYADRS),Y
;
LDA #MOCKBRD
STA RECEIVER
LDA #POKEMSG-BASE
CLC
ADC MYADRS
STA MSG
LDA #00
ADC MYADRS+1
STA MSG+1
JSR USRVECT
;
LDA #16
LDY #DATA-BASE
STA (MYADRS),Y
LDA #9
LDY #REGISTER-BASE
STA (MYADRS),Y
;
LDA #MOCKBRD
STA RECEIVER
LDA #POKEMSG-BASE
CLC
ADC MYADRS
STA MSG
LDA #00
ADC MYADRS+1
STA MSG+1
JSR USRVECT
;
CLV
BVC AROUND
DONTINIT CLV
BVC DONTINI2
;
AROUND LDA #16
LDY #DATA-BASE
STA (MYADRS),Y
LDA #10
LDY #REGISTER-BASE
STA (MYADRS),Y
;
LDA #MOCKBRD
STA RECEIVER
LDA #POKEMSG-BASE
CLC
ADC MYADRS
STA MSG
LDA #00
ADC MYADRS+1
STA MSG+1
JSR USRVECT
;
LDA #$07 ;ENABLE=7 (ALL NOISE)
LDY #REGISTER-BASE
STA (MYADRS),Y
LDY #DATA-BASE
STA (MYADRS),Y
LDA #MOCKBRD
STA RECEIVER
LDA #POKEMSG-BASE
CLC
ADC MYADRS
STA MSG
LDA #00
ADC MYADRS+1
STA MSG+1
JSR USRVECT
;
DONTINI2 LDY #DRUM-BASE
LDA (MYADRS),Y
CLC
ADC #NOISE-BASE
TAY
LDA (MYADRS),Y
LDY #DATA-BASE
STA (MYADRS),Y
LDA #6 ;NOISE PERIOD
LDY #REGISTER-BASE
STA (MYADRS),Y
;
LDA #MOCKBRD
STA RECEIVER
LDA #POKEMSG-BASE
CLC
ADC MYADRS
STA MSG
LDA #00
ADC MYADRS+1
STA MSG+1
JSR USRVECT
;
LDY #DRUM-BASE
LDA (MYADRS),Y
CLC
ADC #COARSE-BASE
TAY
LDA (MYADRS),Y
LDY #DATA-BASE
STA (MYADRS),Y
LDA #12 ;COARSE PERIOD
LDY #REGISTER-BASE
STA (MYADRS),Y
;
LDA #MOCKBRD
STA RECEIVER
LDA #POKEMSG-BASE
CLC
ADC MYADRS
STA MSG
LDA #00
ADC MYADRS+1
STA MSG+1
JSR USRVECT
;
LDA #9
LDY #DATA-BASE
STA (MYADRS),Y
LDA #13 ;ENV SHAPE
LDY #REGISTER-BASE
STA (MYADRS),Y
;
LDA #MOCKBRD
STA RECEIVER
LDA #POKEMSG-BASE
CLC
ADC MYADRS
STA MSG
LDA #00
ADC MYADRS+1
STA MSG+1
JSR USRVECT
;
; TOGGLE SPEAKER
;
LDY #SPEAKER-BASE
LDA (MYADRS),Y
EOR #1
STA (MYADRS),Y
;
LDA #MOCKBRD ;SET SPEAKER
STA RECEIVER
LDA #SPKRMSG-BASE
CLC
ADC MYADRS
STA MSG
LDA #00
ADC MYADRS+1
STA MSG+1
JSR USRVECT
;
RTS