home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Aktief 1995 #3
/
CDA3.iso
/
sound
/
tnypl211.zip
/
MODPLAY.ASM
< prev
next >
Wrap
Assembly Source File
|
1994-06-21
|
63KB
|
2,097 lines
;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
; Tiny MOD Player for Watcom C/C++32 and DOS/4GW
; Version 2.11a June 5th, 1994
;
; Copyright 1993,94 Carlos Hasan
;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
ideal
p386
model flat,c
smart
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
; EQUATES AND PUBLICS
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
MAXVOICES = 8 ; number of voices
DMABUFLEN = 1024 ; DMA buffer length (multiple of 64)
VOLBUFLEN = 66*256 ; volume table length
MIXBUFLEN = 2*DMABUFLEN+2048 ; mixing/boosting buffer length
TIMERRATE = 17000 ; timer interrupt rate in ticks
global MODPlayModule:proc
global MODStopModule:proc
global MODPlaySample:proc
global MODStopSample:proc
global MODSetPeriod:proc
global MODSetVolume:proc
global MODSetMusicVolume:proc
global MODSetSampleVolume:proc
global MODDetectCard:proc
global MODPoll:proc
global MODVoiceTable:dword
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
; STRUCTURES
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
struc module ; module structure
numtracks dw ? ; number of tracks
orderlen dw ? ; order length
orders db 128 dup (?) ; order list
patterns dd 128 dup (?) ; pattern addresses
sampptr dd 32 dup (?) ; sample start addresses
sampend dd 32 dup (?) ; sample end addresses
samploop dd 32 dup (?) ; sample loop point addresses
sampvolume db 32 dup (?) ; sample default volumes
ends module
struc sample ; sample structure
period dw ? ; default period
volume dw ? ; default volume
datalen dd ? ; sample data length
dataptr dd ? ; sample data address
ends sample
struc track ; track structure
note dw ? ; note index
period dw ? ; period value
inst db ? ; instrument
volume db ? ; volume
effect dw ? ; effect
destperiod dw ? ; toneporta wanted period
tonespeed db ? ; toneporta speed
vibparm db ? ; vibrato depth/rate
vibpos db ? ; vibrato wave position
tremparm db ? ; tremolo depth/rate
trempos db ? ; tremolo wave position
db ? ; alignment
arptable dw 3 dup (?) ; arpeggio periods
ends track
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
; DATA
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
;░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒
; Module Player data
;░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒
udataseg
moduleptr dd ? ; current module address
pattptr dd ? ; current playing pattern address
orderpos db ? ; order position
orderlen db ? ; order length
pattrow db ? ; pattern row
tempo db ? ; tempo
tempocount db ? ; tempo counter
bpm db ? ; beats per minute
musicvolume db ? ; music channels volume
samplevolume db ? ; sample channels volume
numtracks dw ? ; number of tracks
tracks track MAXVOICES dup (?)
pitchtable dd 3425 dup (?) ; period to pitch table
; Amiga period table
dataseg
periodtable dw 0
dw 3424,3232,3048,2880,2712,2560,2416,2280,2152,2032,1920,1812
dw 1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,906
dw 856,808,762,720,678,640,604,570,538,508,480,453
dw 428,404,381,360,339,320,302,285,269,254,240,226
dw 214,202,190,180,170,160,151,143,135,127,120,113
dw 107,101,95,90,85,80,75,71,67,63,60,56
dw 53,50,47,45,42,40,37,35,33,31,30,28
; Sinus wave table
sintable db 0,25,50,74,98,120,142,162,180,197,212,225
db 236,244,250,254,255,254,250,244,236,225
db 212,197,180,162,142,120,98,74,50,25
;░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒
; Sound Blaster driver data
;░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒
udataseg
; Voices programmable parameters
label MODVoiceTable dword
voicepos dd MAXVOICES dup (?)
voiceend dd MAXVOICES dup (?)
voiceloop dd MAXVOICES dup (?)
voicefrac dd MAXVOICES dup (?)
voicepitch dd MAXVOICES dup (?)
voicevolume dd MAXVOICES dup (?)
; Internal driver data
dataseg
mixbuffer dd ? ; mixing buffer address
boosttable dd ? ; boosting table address
voltable dd ? ; volume table address
numvoices dw ? ; number of active voices
mixfreq dw ? ; playback frequency
ioaddr dw ? ; card I/O port address
irqnum db ? ; card IRQ level
drqnum db ? ; card DMA channel
timerproc dd ? ; timer callback address
timeracc dd ? ; timer callback accumulator
timerspeed dd ? ; timer callback speed
datasel dw ? ; flat model data selector
bufsel dw ? ; DOS memory block selector
bufptr dd ? ; DMA buffer address
bufoff dd ? ; double buffer offset
oldirqoff dd ? ; old IRQ vector address
oldirqsel dw ?
oldtimeroff dd ? ; old timer IRQ0 vector address
oldtimersel dw ?
oldtimeracc dw ? ; old timer accumulator
manualmode db ? ; timer/manual polling mode
playing db 0 ; playing/stopped status
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
; CODE
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
codeseg
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
; Copyright Strings
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
db 'Tiny MOD Player V2.11 Copyright 1993,94 Carlos Hasan',0
db 'Compiled on: ',??date,' ',??time,0
;░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒
; Module Player stuff
;░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
; MODPlayModule - start playing a music module
; In:
; Song = module address
; Chans = number of channels
; Rate = playback rate
; Port = port address
; irq = irq number
; dma = dma channel
; mode = polling mode
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
proc MODPlayModule Song:dword,Chans:dword,Rate:dword,Port:dword,IRQ:dword,DRQ:dword,Mode:dword
pushad
; setup th