home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Magazine 5
/
Mega_Magazine_05_19xx___nl_Side_B.atr
/
sampling.lzh
/
CDPLAY.SRC
next >
Wrap
Text File
|
1988-09-01
|
2KB
|
166 lines
*************************************
* *
* - SAMPLE PLAYER - *
* *
* COMPACT DISK SPEED (44.1 KHZ) *
* DELAY TIME: 40 CLOCK CYCLES *
* *
* 4-BITS SAMPLES (2 SAMPLES/BYTE) *
* *
* (C)1992 FRANKENSTEIN *
* *
*************************************
SPBEG EQU $0000
SPEND EQU $FFFF
SPL EQU $F2 (AND $F3)
DUMZP EQU $F4
TAB0123 EQU $BA00
TAB4567 EQU $BB00
ORG $B800
LDA #SPBEG:L
STA SPL
LDA #SPBEG:H
STA SPL+1
LDA #SPEND:L
STA JERKL+1
LDA #SPEND:H
STA JERKH+1
*------------------------------------
* MAIN LOOP
*------------------------------------
JSR MAKTAB
JSR INTOFF
LDA #0
STA $D400
JSR PLAY
JSR INTON
RTS
*------------------------------------
* CREATE LOOKUP TABLES:
**
* TAB0123: ----xxxx
* TAB4567: xxxx----
*
*------------------------------------
* 4-BITS/SAMPLE
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
* AT COMPACT DISK SPEED (44.1 KHZ)
*------------------------------------
* 15 + 11 + 14 = 40 CYCLES DELAY
* 1.78979 / 40 = 44.1 KHZ
PLAY LDY #0
* 15 CLOCK CYCLES IN:
RUN LDA (SPL),Y ; 5
TAX ; 2
LDA TAB4567,X ; 4
STA $D201 ; 4
* 14 EXTRA CYCLES
NOP ; 2
NOP ; 2
NOP ; 2
NOP ; 2
NOP ; 2
NOP ; 2
NOP ; 2
* 11 CLOCK CYCLES IN:
LDA SPL+1 ; 3
JERKH CMP #$FF ; 2
BNE NO ; 2
JERKL CPY #$FF ; 2
BNE EXIT ; 2
RTS
NO NOP ; 2
NOP ; 2
* 15 CLOCK CYCLES IN:
EXIT LDA (SPL),Y ; 5
TAX ; 2
LDA TAB0123,X ; 4
STA $D201 ; 4
* 14 EXTRA CYCLES
NOP ; 2
NOP ; 2
NOP ; 2
NOP ; 2
NOP ; 2
NOP ; 2
NOP ; 2
* 11 CLOCK CYCLES IN:
INY ; 2
BNE HOLD ; 2
INC SPL+1 ; 5
BNE RUN ; 2
HOLD STA DUMZP ; 3
LDA #0 ; 2
BEQ RUN ; 2¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯