home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Magazine 5
/
Mega_Magazine_05_19xx___nl_Side_B.atr
/
sampling.lzh
/
PLAYBOTH.SRC
< prev
next >
Wrap
Text File
|
1988-09-01
|
3KB
|
259 lines
*************************************
* *
* - SAMPLE PLAYER - *
* *
* TO COMPARE THE DIFFERENCE BETWEEN *
* PLAYING THE R.DAVID 2-BIT SAMPLES * *
* *
* THE WRONG WAY: PLAYED AS IF THEY *
* WERE 4-BIT SAMPLES (BIG DEMO) *
* *
* THE RIGHT WAY: PLAYED AS 2-BIT *
* POINTER SAMPLES (OFFICIAL WAY) *
* *
*************************************
SPBEG EQU $1000
SPEND EQU $B400
ZP EQU $F0 (AND $F1)
END EQU $F2 (AND $F3)
SPLBYTE EQU $F4
TAB01 EQU $B600
TAB23 EQU $B700
TAB45 EQU $B800
TAB67 EQU $B900
TAB0123 EQU $BA00
TAB4567 EQU $BB00
ORG $B400
LDA #SPBEG:L
STA ZP
LDA #SPBEG:H
STA ZP+1
LDA #SPEND:L
STA END
LDA #SPEND:H
STA END+1
*------------------------------------
* MAIN LOOP
*------------------------------------
JSR MAKTAB
JSR INTOFF
JSR PLAY
JSR INTON
RTS
*------------------------------------
* CREATE A LOOKUP TABLES:
*
* FOR 2-BIT SAMPLES:
*
* TAB01 : ------xx
* TAB23 : ----xx--
* TAB45 : --xx----
* TAB67 : xx------
*
* FOR 4-BIT SAMPLES:
*
* TAB0123: ----xxxx
* TAB4567: xxxx----
*
* x : BITS USED TO LOOKUP
* - : DOESN'T MATTER BITS
*
* SETS VOLUME ONLY BIT IN TABLES TOO!
*------------------------------------
* 2-BIT TABLES (8/2=4)
MAKTAB LDX #0
N01 TXA
AND #%00000011
TAY
LDA RALF,Y
STA TAB01,X
INX
BNE N01
N23 TXA
AND #%00001100
LSR
LSR
TAY
LDA RALF,Y
STA TAB23,X
INX
BNE N23
N45 TXA
AND #%00110000
LSR
LSR
LSR
LSR
TAY
LDA RALF,Y
STA TAB45,X
INX
BNE N45
N67 TXA
AND #%11000000
LSR
LSR
LSR
LSR
LSR
LSR
TAY
LDA RALF,Y
STA TAB67,X
INX
BNE N67
* 4-BIT TABLES (8/4=2)
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
* VALUES FOR POKEY
RALF DFB $10,$13,$16,$19
*------------------------------------
* 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 2-BIT SAMPLES
* HOLD OPTION FOR 4-BIT PLAYING
*------------------------------------
PLAY LDY #0
NOHO LDA (ZP),Y
STA SPLBYTE
LDA $D01F
CMP #3 ;OPTION?
BNE TWOBIT
* PLAY: xxxx0000
LDA SPLBYTE
TAX
LDA TAB4567,X
STA $D40A
STA $D40A
STA $D201
* PLAY: 0000xxxx
LDA SPLBYTE
TAX
LDA TAB0123,X
STA $D40A
STA $D40A
STA $D201
BNE NEXBT ;ALWAYS!
*------------------------------------
* 2-BIT PLAY ROUTINE
*------------------------------------
* PLAY: xx------
TWOBIT LDA SPLBYTE
TAX
LDA TAB67,X
STA $D40A
STA $D201
* PLAY: --xx----
LDA SPLBYTE
TAX
LDA TAB45,X
STA $D40A
STA $D201
* PLAY: ----xx--
LDA SPLBYTE
TAX
LDA TAB23,X
STA $D40A
STA $D201
* PLAY: ------xx
LDA SPLBYTE
TAX
LDA TAB01,X
STA $D40A
STA $D201
*------------------------------------
* 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¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯