From: sparky4 Date: Wed, 15 Jul 2015 18:59:09 +0000 (-0500) Subject: bakapee! X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=4920b124799b21bd91ebf26600f316cd72508821;p=16.git bakapee! modified: src/lib/16_snd.c modified: src/lib/16_snd.h --- diff --git a/src/lib/16_snd.c b/src/lib/16_snd.c index 5ade6445..828237f5 100644 --- a/src/lib/16_snd.c +++ b/src/lib/16_snd.c @@ -23,12 +23,12 @@ #include "src/lib/16_snd.h" -void opl2out(word data, word reg) +void opl2out(word reg, word data) { __asm { mov ax,reg - mov dx,word ptr [OPLPORT] + mov dx,word ptr [ADLIB_FM_ADDRESS] or ah,ah jz @@1 add dx,2 @@ -46,12 +46,12 @@ void opl2out(word data, word reg) } } -void opl3out(word data, word reg) +void opl3out(word reg, word data) { __asm { mov ax,reg - mov dx,word ptr [OPLPORT] + mov dx,word ptr [ADLIB_FM_ADDRESS] or ah,ah jz @@1 add dx,2 @@ -71,7 +71,7 @@ void opl3exp(word data) __asm { mov ax,data - mov dx,word ptr [OPLPORT] + mov dx,word ptr [ADLIB_FM_ADDRESS] add dx,2 out dx,al mov cx,6 @@ -84,4 +84,26 @@ void opl3exp(word data) @@2: in al,dx loop @@2 } -} \ No newline at end of file +} + +/* Function: FMResest ******************************************************* +* +* Description: quick and dirty sound card reset (zeros all +* registers). +* +*/ +void FMReset(void/*int percusiveMode*/) +{ + int i; + + /* zero all registers */ + for(i = MIN_REGISTER; i < MAX_REGISTER+1; i++) opl2out(i, 0); + + /* allow FM chips to control the waveform of each operator */ + opl2out(0x01, 0x20); + + /* set rhythm enabled (6 melodic voices, 5 percussive) */ + opl2out(0xBD, 0x20); + + //FMSetPercusiveMode(percusiveMode); +} /* End of FMReset */ diff --git a/src/lib/16_snd.h b/src/lib/16_snd.h index 3f752949..86c1de58 100644 --- a/src/lib/16_snd.h +++ b/src/lib/16_snd.h @@ -25,10 +25,14 @@ #include "src/lib/16_head.h" -#define OPLPORT 388 +#define MIN_REGISTER 0x01 +#define MAX_REGISTER 0xF5 +#define ADLIB_FM_ADDRESS 0x388 /* adlib address/status register */ +#define ADLIB_FM_DATA 0x389 /* adlib data register */ -void opl2out(word data, word reg); -void opl3out(word data, word reg); +void opl2out(word reg, word data); +void opl3out(word reg, word data); void opl3exp(word data); +void FMReset(void/*int percusiveMode*/); #endif /*__16_SND_H_*/