Example #1
0
        public static int YM2203Init(int num, int clock, int rate, FM_TIMERHANDLER TimerHandler, FM_IRQHANDLER IRQHandler)
        {
            if (FM2203 != null) return (-1);	/* duplicate init. */
            cur_chip = null;	/* hiro-shi!! */

            YM2203NumChips = num;

            FM2203 = new YM2203[YM2203NumChips];

            for (int i = 0; i < YM2203NumChips; i++) FM2203[i] = new YM2203();

            /* allocate total level table (128kb space) */
            if (FMInitTable() == 0)
            {
                FM2203 = null;
                return (-1);
            }

            for (int i = 0; i < YM2203NumChips; i++)
            {
                FM2203[i].OPN.ST.index = (byte)i;
                FM2203[i].OPN.type = TYPE_YM2203;
                FM2203[i].OPN.P_CH = FM2203[i].CH;
                FM2203[i].OPN.ST.clock = clock;
                FM2203[i].OPN.ST.rate = rate;
                /* FM2203[i].OPN.ST.irq = 0; */
                /* FM2203[i].OPN.ST.satus = 0; */
                FM2203[i].OPN.ST.timermodel = FM_TIMER_INTERVAL;
                /* Extend handler */
                FM2203[i].OPN.ST.Timer_Handler = TimerHandler;
                FM2203[i].OPN.ST.IRQ_Handler = IRQHandler;
                YM2203ResetChip(i);
            }
            return (0);
        }
Example #2
0
        public static int OPMInit(int num, int clock, int rate,FM_TIMERHANDLER TimerHandler, FM_IRQHANDLER IRQHandler)
        {
            if (FMOPM!=null) return (-1);	/* duplicate init. */
            cur_chip = null;	/* hiro-shi!! */

            YM2151NumChips = num;

            /* allocate ym2151 state space */
            FMOPM = new YM2151[YM2151NumChips];

            for (int i = 0; i < YM2151NumChips; i++)
                FMOPM[i] = new YM2151();

            /* allocate total lebel table (128kb space) */
            if (FMInitTable()==0)
            {
                FMOPM = null;
                return (-1);
            }
            for (int i = 0; i < YM2151NumChips; i++)
            {
                FMOPM[i].ST.index = (byte)i;
                FMOPM[i].ST.clock = clock;
                FMOPM[i].ST.rate = rate;
                /* FMOPM[i].ST.irq  = 0; */
                /* FMOPM[i].ST.status = 0; */
                FMOPM[i].ST.timermodel = FM_TIMER_INTERVAL;
                FMOPM[i].ST.freqbase = rate !=0? ((double)clock / rate) / 64 : 0;
                FMOPM[i].ST.TimerBase = 1.0 / ((double)clock / 64.0);
                /* Extend handler */
                FMOPM[i].ST.Timer_Handler = TimerHandler;
                FMOPM[i].ST.IRQ_Handler = IRQHandler;
                /* Reset callback handler of CT0/1 */
                FMOPM[i].PortWrite = null;
                OPMResetChip(i);
            }
            return (0);
        }