#include "src/lib/16_snd.h"
-void opl2out(word data, word reg)
+void opl2out(word reg, word data)
{\r
__asm
{\r
mov ax,reg\r
- mov dx,word ptr [OPLPORT]\r
+ mov dx,word ptr [ADLIB_FM_ADDRESS]\r
or ah,ah\r
jz @@1\r
add dx,2\r
}
}\r
\r
-void opl3out(word data, word reg)
+void opl3out(word reg, word data)
{\r
__asm
{\r
mov ax,reg\r
- mov dx,word ptr [OPLPORT]\r
+ mov dx,word ptr [ADLIB_FM_ADDRESS]\r
or ah,ah\r
jz @@1\r
add dx,2\r
__asm
{\r
mov ax,data\r
- mov dx,word ptr [OPLPORT]\r
+ mov dx,word ptr [ADLIB_FM_ADDRESS]\r
add dx,2\r
out dx,al\r
mov cx,6\r
@@2: in al,dx\r
loop @@2
}\r
-}
\ No newline at end of file
+}
+
+/* Function: FMResest *******************************************************\r
+*\r
+* Description: quick and dirty sound card reset (zeros all\r
+* registers).\r
+*\r
+*/\r
+void FMReset(void/*int percusiveMode*/)
+{\r
+ int i;\r
+\r
+ /* zero all registers */\r
+ for(i = MIN_REGISTER; i < MAX_REGISTER+1; i++) opl2out(i, 0);\r
+\r
+ /* allow FM chips to control the waveform of each operator */\r
+ opl2out(0x01, 0x20);\r
+\r
+ /* set rhythm enabled (6 melodic voices, 5 percussive) */\r
+ opl2out(0xBD, 0x20);\r
+\r
+ //FMSetPercusiveMode(percusiveMode);\r
+} /* End of FMReset */
#include "src/lib/16_head.h"
-#define OPLPORT 388
+#define MIN_REGISTER 0x01\r
+#define MAX_REGISTER 0xF5\r
+#define ADLIB_FM_ADDRESS 0x388 /* adlib address/status register */\r
+#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_*/