]> git.proxmox.com Git - mirror_qemu.git/blobdiff - hw/audio/fmopl.c
i386: Add x-force-features option for testing
[mirror_qemu.git] / hw / audio / fmopl.c
index 48db828a490289df4a1d8f8d412d381cb89dc234..9f50a89b4a888962092e2f4daf8754eeff08e6a8 100644 (file)
 #include <math.h>
 //#include "driver.h"          /* use M.A.M.E. */
 #include "fmopl.h"
-
 #ifndef PI
 #define PI 3.14159265358979323846
 #endif
 
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-#endif
-
 /* -------------------- for debug --------------------- */
 /* #define OPL_OUTPUT_LOG */
 #ifdef OPL_OUTPUT_LOG
@@ -260,8 +255,6 @@ static inline void OPL_STATUS_SET(FM_OPL *OPL,int flag)
                if(OPL->status & OPL->statusmask)
                {       /* IRQ on */
                        OPL->status |= 0x80;
-                       /* callback user interrupt handler (IRQ is OFF to ON) */
-                       if(OPL->IRQHandler) (OPL->IRQHandler)(OPL->IRQParam,1);
                }
        }
 }
@@ -276,8 +269,6 @@ static inline void OPL_STATUS_RESET(FM_OPL *OPL,int flag)
                if (!(OPL->status & OPL->statusmask) )
                {
                        OPL->status &= 0x7f;
-                       /* callback user interrupt handler (IRQ is ON to OFF) */
-                       if(OPL->IRQHandler) (OPL->IRQHandler)(OPL->IRQParam,0);
                }
        }
 }
@@ -796,14 +787,18 @@ static void OPLWriteReg(FM_OPL *OPL, int r, int v)
                                {
                                        double interval = st2 ? (double)OPL->T[1]*OPL->TimerBase : 0.0;
                                        OPL->st[1] = st2;
-                                       if (OPL->TimerHandler) (OPL->TimerHandler)(OPL->TimerParam+1,interval);
+                    if (OPL->TimerHandler) {
+                        (OPL->TimerHandler)(OPL->TimerParam, 1, interval);
+                    }
                                }
                                /* timer 1 */
                                if(OPL->st[0] != st1)
                                {
                                        double interval = st1 ? (double)OPL->T[0]*OPL->TimerBase : 0.0;
                                        OPL->st[0] = st1;
-                                       if (OPL->TimerHandler) (OPL->TimerHandler)(OPL->TimerParam+0,interval);
+                    if (OPL->TimerHandler) {
+                        (OPL->TimerHandler)(OPL->TimerParam, 0, interval);
+                    }
                                }
                        }
                        return;
@@ -1040,7 +1035,7 @@ void YM3812UpdateOne(FM_OPL *OPL, int16_t *buffer, int length)
 }
 
 /* ---------- reset one of chip ---------- */
-void OPLResetChip(FM_OPL *OPL)
+static void OPLResetChip(FM_OPL *OPL)
 {
        int c,s;
        int i;
@@ -1136,21 +1131,13 @@ void OPLDestroy(FM_OPL *OPL)
 
 /* ----------  Option handlers ----------       */
 
-void OPLSetTimerHandler(FM_OPL *OPL,OPL_TIMERHANDLER TimerHandler,int channelOffset)
+void OPLSetTimerHandler(FM_OPL *OPL, OPL_TIMERHANDLER TimerHandler,
+                        void *param)
 {
        OPL->TimerHandler   = TimerHandler;
-       OPL->TimerParam = channelOffset;
-}
-void OPLSetIRQHandler(FM_OPL *OPL,OPL_IRQHANDLER IRQHandler,int param)
-{
-       OPL->IRQHandler     = IRQHandler;
-       OPL->IRQParam = param;
-}
-void OPLSetUpdateHandler(FM_OPL *OPL,OPL_UPDATEHANDLER UpdateHandler,int param)
-{
-       OPL->UpdateHandler = UpdateHandler;
-       OPL->UpdateParam = param;
+    OPL->TimerParam = param;
 }
+
 /* ---------- YM3812 I/O interface ---------- */
 int OPLWrite(FM_OPL *OPL,int a,int v)
 {
@@ -1160,7 +1147,6 @@ int OPLWrite(FM_OPL *OPL,int a,int v)
        }
        else
        {       /* data port */
-               if(OPL->UpdateHandler) OPL->UpdateHandler(OPL->UpdateParam,0);
 #ifdef OPL_OUTPUT_LOG
        if(opl_dbg_fp)
        {
@@ -1210,12 +1196,14 @@ int OPLTimerOver(FM_OPL *OPL,int c)
                if( OPL->mode & 0x80 )
                {       /* CSM mode total level latch and auto key on */
                        int ch;
-                       if(OPL->UpdateHandler) OPL->UpdateHandler(OPL->UpdateParam,0);
                        for(ch=0;ch<9;ch++)
                                CSMKeyControll( &OPL->P_CH[ch] );
                }
        }
        /* reload timer */
-       if (OPL->TimerHandler) (OPL->TimerHandler)(OPL->TimerParam+c,(double)OPL->T[c]*OPL->TimerBase);
+    if (OPL->TimerHandler) {
+        (OPL->TimerHandler)(OPL->TimerParam, c,
+                            (double)OPL->T[c] * OPL->TimerBase);
+    }
        return OPL->status>>7;
 }