home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Magazine 5
/
Mega_Magazine_05_19xx___nl_Side_B.atr
/
sampling.lzh
/
PLAY4VOL.SRC
< prev
next >
Wrap
Text File
|
1988-09-01
|
3KB
|
203 lines
*************************************
* *
* - SAMPLE PLAYER - *
* *
* WITH VOLUME CONTROL *
* DONE BY FRANKENSTEIN 18/10/92 *
* *
*************************************
SPBEG EQU $0700
SPEND EQU $B400
ZP EQU $F0 (AND $F1)
END EQU $F2 (AND $F3)
VOLUME EQU $F4
COUNT EQU $F5
TAB0123 EQU $BA00
TAB4567 EQU $BB00
ORG $B400
*------------------------------------
* MAIN LOOP
*------------------------------------
LDA #%00010000
STA VOLUME
JSR MAKTAB
JSR INTOFF
LOOP LDA #SPBEG:L
STA ZP
LDA #SPBEG:H
STA ZP+1
LDA #SPEND:L
STA END
LDA #SPEND:H
STA END+1
LDA #0
STA COUNT
STA $D400
JSR PLAY
JMP LOOP
JSR INTON
RTS
*------------------------------------
* CREATE LOOKUP TABLES:
*
* FOR 4-BIT SAMPLES:
*
* TAB0123: ----xxxx
* TAB4567: xxxx----
*
* x : BITS USED TO LOOKUP
* - : DOESN'T MATTER BITS
*
* SETS VOLUME ONLY BIT IN TABLES TOO!
*------------------------------------
* 4-BIT TABLES (8/4=2)
MAKTAB LDX #0
N0123 TXA
AND #%00001111
ORA #%00010000
STA TAB0123,X
INX
BNE N0123
N4567 TXA
AND #%11110000
LSR
LSR
LSR
LSR
ORA #%00010000
STA TAB4567,X
INX
BNE N4567
RTS
*------------------------------------
* INTERRUPTS OFF
*------------------------------------
INTOFF LDA #0
STA $D20E
STA $D40E
RTS
*------------------------------------
* INTERRUPTS ON
*------------------------------------
INTON LDA 16
STA $D20E
LDA #$C0
STA $D40E
RTS
*------------------------------------
* THIS ROUTINE PLAYS 4-BIT SAMPLES
* SELECT/OPTION FOR VOLUME CONTROL
*------------------------------------
PLAY LDY #0
* PLAY: xxxx0000
NOHO LDA (ZP),Y
TAX
LDA TAB4567,X
LDX VOLUME
STA $D40A
STA $D201
STA $D203
STX $D205
STX $D207
*------------------------------------
* VOLUME CONTROL BY SELECT/OPTION
*------------------------------------
INC COUNT ; DELAY
BEQ YOVOL
LDA #8
STA $D01F
BNE EXITVC
YOVOL LDX VOLUME
LDA $D01F
EOR #%00000111
BEQ EXITVC
CMP #%00000100 ; OPTION
BNE OPTNO
* OPTION = VOLUME UP
CPX #%00011111 ; MAX.VOL?
BEQ EXITVC
INX
BNE STORE
* SELECT = VOLUME DOWN
OPTNO CMP #%00000010 ; SELECT
BNE EXITVC
CPX #%00010000 ; MIN.VOL?
BEQ EXITVC
DEX
STORE STX VOLUME
TXA
ASL
STA $D01A
* PLAY: 0000xxxx
EXITVC LDA (ZP),Y
TAX
LDA TAB0123,X
LDX VOLUME
STA $D40A
STA $D201
STA $D203
STX $D205
STX $D207
*------------------------------------
* GET NEXT BYTE FROM DATA
*------------------------------------
NEXBT INC ZP
BNE NOWAY
INC ZP+1
NOWAY LDA ZP+1
CMP END+1
BNE NOHO
LDA ZP
CMP END
BNE NOHO
RTS
* VARS
LEN DFB 0,0¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯