Switched the OPL and NukedOPL code to VARCem's reworked (and cleaner) versions.
This commit is contained in:
@@ -1,31 +1,61 @@
|
||||
/* Copyright holders: Sarah Walker
|
||||
see COPYING for more details
|
||||
*/
|
||||
typedef struct opl_t
|
||||
{
|
||||
int pos, chip_nr[2];
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Definitions for the OPL interface.
|
||||
*
|
||||
* Version: @(#)snd_opl.h 1.0.3 2020/07/15
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* TheCollector1995, <mariogplayer@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2017-2020 Fred N. van Kempen.
|
||||
* Copyright 2016-2019 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*/
|
||||
#ifndef SOUND_OPL_H
|
||||
# define SOUND_OPL_H
|
||||
|
||||
int32_t buffer[SOUNDBUFLEN * 2],
|
||||
buffer2[SOUNDBUFLEN * 2];
|
||||
|
||||
pc_timer_t timers[2][2];
|
||||
typedef void (*tmrfunc)(void *priv, int timer, uint64_t period);
|
||||
|
||||
/* Define an OPLx chip. */
|
||||
typedef struct {
|
||||
#ifdef SOUND_OPL_NUKED_H
|
||||
nuked_t *opl;
|
||||
#else
|
||||
void *opl;
|
||||
#endif
|
||||
int8_t is_opl3;
|
||||
|
||||
uint16_t port;
|
||||
uint8_t status;
|
||||
uint8_t status_mask;
|
||||
uint8_t timer_ctrl;
|
||||
uint16_t timer[2];
|
||||
|
||||
pc_timer_t timers[2];
|
||||
|
||||
int pos;
|
||||
int32_t buffer[SOUNDBUFLEN * 2];
|
||||
} opl_t;
|
||||
|
||||
|
||||
extern uint8_t opl2_read(uint16_t a, void *priv);
|
||||
extern void opl2_write(uint16_t a, uint8_t v, void *priv);
|
||||
extern uint8_t opl2_l_read(uint16_t a, void *priv);
|
||||
extern void opl2_l_write(uint16_t a, uint8_t v, void *priv);
|
||||
extern uint8_t opl2_r_read(uint16_t a, void *priv);
|
||||
extern void opl2_r_write(uint16_t a, uint8_t v, void *priv);
|
||||
extern uint8_t opl3_read(uint16_t a, void *priv);
|
||||
extern void opl3_write(uint16_t a, uint8_t v, void *priv);
|
||||
extern uint8_t opl2_read(uint16_t port, void *);
|
||||
extern void opl2_write(uint16_t port, uint8_t val, void *);
|
||||
extern void opl2_init(opl_t *);
|
||||
extern void opl2_update(opl_t *);
|
||||
|
||||
extern void opl2_poll(opl_t *opl, int16_t *bufl, int16_t *bufr);
|
||||
extern void opl3_poll(opl_t *opl, int16_t *bufl, int16_t *bufr);
|
||||
extern uint8_t opl3_read(uint16_t port, void *);
|
||||
extern void opl3_write(uint16_t port, uint8_t val, void *);
|
||||
extern void opl3_init(opl_t *);
|
||||
extern void opl3_update(opl_t *);
|
||||
|
||||
extern void opl2_init(opl_t *opl);
|
||||
extern void opl3_init(opl_t *opl);
|
||||
|
||||
extern void opl2_update2(opl_t *opl);
|
||||
extern void opl3_update2(opl_t *opl);
|
||||
#endif /*SOUND_OPL_H*/
|
||||
|
@@ -1,17 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker, SA1988
|
||||
see COPYING for more details
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void opl_init(void (*timer_callback)(void *param, int timer, uint64_t period), void *timer_param, int nr, int is_opl3);
|
||||
void opl_write(int nr, uint16_t addr, uint8_t val);
|
||||
uint8_t opl_read(int nr, uint16_t addr);
|
||||
void opl_timer_over(int nr, int timer);
|
||||
void opl2_update(int nr, int32_t *buffer, int samples);
|
||||
void opl3_update(int nr, int32_t *buffer, int samples);
|
||||
|
||||
extern int opl_type;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
35
src/include/86box/snd_opl_nuked.h
Normal file
35
src/include/86box/snd_opl_nuked.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Definitions for the NukedOPL3 driver.
|
||||
*
|
||||
* Version: @(#)snd_opl_nuked.h 1.0.5 2020/07/16
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2017-2020 Fred N. van Kempen.
|
||||
* Copyright 2016-2019 Miran Grca.
|
||||
*/
|
||||
#ifndef SOUND_OPL_NUKED_H
|
||||
# define SOUND_OPL_NUKED_H
|
||||
|
||||
|
||||
extern void * nuked_init(uint32_t sample_rate);
|
||||
extern void nuked_close(void *);
|
||||
|
||||
extern uint16_t nuked_write_addr(void *, uint16_t port, uint8_t val);
|
||||
extern void nuked_write_reg(void *, uint16_t reg, uint8_t v);
|
||||
extern void nuked_write_reg_buffered(void *, uint16_t reg, uint8_t v);
|
||||
|
||||
extern void nuked_generate(void *, int32_t *buf);
|
||||
extern void nuked_generate_resampled(void *, int32_t *buf);
|
||||
extern void nuked_generate_stream(void *, int32_t *sndptr, uint32_t num);
|
||||
|
||||
|
||||
#endif /*SOUND_OPL_NUKED_H*/
|
@@ -113,7 +113,7 @@ typedef struct sb_ct1745_mixer_t
|
||||
typedef struct sb_t
|
||||
{
|
||||
uint8_t opl_enabled;
|
||||
opl_t opl;
|
||||
opl_t opl, opl2;
|
||||
sb_dsp_t dsp;
|
||||
union {
|
||||
sb_ct1335_mixer_t mixer_sb2;
|
||||
|
@@ -1,151 +0,0 @@
|
||||
//
|
||||
// Copyright (C) 2013-2018 Alexey Khokholov (Nuke.YKT)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// Nuked OPL3 emulator.
|
||||
// Thanks:
|
||||
// MAME Development Team(Jarek Burczynski, Tatsuyuki Satoh):
|
||||
// Feedback and Rhythm part calculation information.
|
||||
// forums.submarine.org.uk(carbon14, opl3):
|
||||
// Tremolo and phase generator calculation information.
|
||||
// OPLx decapsulated(Matthew Gambrell, Olli Niemitalo):
|
||||
// OPL2 ROMs.
|
||||
// siliconpr0n.org(John McMaster, digshadow):
|
||||
// YMF262 and VRC VII decaps and die shots.
|
||||
//
|
||||
// version: 1.8
|
||||
//
|
||||
|
||||
#ifndef NUKEDOPL_H
|
||||
#define NUKEDOPL_H
|
||||
#define OPL_WRITEBUF_SIZE 1024
|
||||
#define OPL_WRITEBUF_DELAY 1
|
||||
|
||||
//#include "dosbox.h"
|
||||
#include <stdint.h>
|
||||
typedef signed int Bits;
|
||||
typedef unsigned int Bitu;
|
||||
typedef int8_t Bit8s;
|
||||
typedef uint8_t Bit8u;
|
||||
typedef int16_t Bit16s;
|
||||
typedef uint16_t Bit16u;
|
||||
typedef int32_t Bit32s;
|
||||
typedef uint32_t Bit32u;
|
||||
typedef int64_t Bit64s;
|
||||
typedef uint64_t Bit64u;
|
||||
|
||||
struct opl3_slot;
|
||||
struct opl3_channel;
|
||||
struct opl3_writebuf;
|
||||
struct opl3_chip;
|
||||
|
||||
struct opl3_slot {
|
||||
struct opl3_channel *channel;
|
||||
struct opl3_chip *chip;
|
||||
Bit16s out;
|
||||
Bit16s fbmod;
|
||||
Bit16s *mod;
|
||||
Bit16s prout;
|
||||
Bit16s eg_rout;
|
||||
Bit16s eg_out;
|
||||
Bit8u eg_inc;
|
||||
Bit8u eg_gen;
|
||||
Bit8u eg_rate;
|
||||
Bit8u eg_ksl;
|
||||
Bit8u *trem;
|
||||
Bit8u reg_vib;
|
||||
Bit8u reg_type;
|
||||
Bit8u reg_ksr;
|
||||
Bit8u reg_mult;
|
||||
Bit8u reg_ksl;
|
||||
Bit8u reg_tl;
|
||||
Bit8u reg_ar;
|
||||
Bit8u reg_dr;
|
||||
Bit8u reg_sl;
|
||||
Bit8u reg_rr;
|
||||
Bit8u reg_wf;
|
||||
Bit8u key;
|
||||
Bit32u pg_reset;
|
||||
Bit32u pg_phase;
|
||||
Bit16u pg_phase_out;
|
||||
Bit8u slot_num;
|
||||
};
|
||||
|
||||
struct opl3_channel {
|
||||
struct opl3_slot *slots[2];
|
||||
struct opl3_channel *pair;
|
||||
struct opl3_chip *chip;
|
||||
Bit16s *out[4];
|
||||
Bit8u chtype;
|
||||
Bit16u f_num;
|
||||
Bit8u block;
|
||||
Bit8u fb;
|
||||
Bit8u con;
|
||||
Bit8u alg;
|
||||
Bit8u ksv;
|
||||
Bit16u cha, chb;
|
||||
Bit8u ch_num;
|
||||
};
|
||||
|
||||
struct opl3_writebuf {
|
||||
Bit64u time;
|
||||
Bit16u reg;
|
||||
Bit8u data;
|
||||
};
|
||||
|
||||
struct opl3_chip {
|
||||
struct opl3_channel channel[18];
|
||||
struct opl3_slot slot[36];
|
||||
Bit16u timer;
|
||||
Bit64u eg_timer;
|
||||
Bit8u eg_timerrem;
|
||||
Bit8u eg_state;
|
||||
Bit8u eg_add;
|
||||
Bit8u newm;
|
||||
Bit8u nts;
|
||||
Bit8u rhy;
|
||||
Bit8u vibpos;
|
||||
Bit8u vibshift;
|
||||
Bit8u tremolo;
|
||||
Bit8u tremolopos;
|
||||
Bit8u tremoloshift;
|
||||
Bit32u noise;
|
||||
Bit16s zeromod;
|
||||
Bit32s mixbuff[2];
|
||||
Bit8u rm_hh_bit2;
|
||||
Bit8u rm_hh_bit3;
|
||||
Bit8u rm_hh_bit7;
|
||||
Bit8u rm_hh_bit8;
|
||||
Bit8u rm_tc_bit3;
|
||||
Bit8u rm_tc_bit5;
|
||||
//OPL3L
|
||||
Bit32s rateratio;
|
||||
Bit32s samplecnt;
|
||||
Bit32s oldsamples[2];
|
||||
Bit32s samples[2];
|
||||
|
||||
Bit64u writebuf_samplecnt;
|
||||
Bit32u writebuf_cur;
|
||||
Bit32u writebuf_last;
|
||||
Bit64u writebuf_lasttime;
|
||||
struct opl3_writebuf writebuf[OPL_WRITEBUF_SIZE];
|
||||
};
|
||||
|
||||
void OPL3_Generate(struct opl3_chip *chip, Bit32s *buf);
|
||||
void OPL3_GenerateResampled(struct opl3_chip *chip, Bit32s *buf);
|
||||
void OPL3_Reset(struct opl3_chip *chip, Bit32u samplerate);
|
||||
Bit32u OPL3_WriteAddr(struct opl3_chip *chip, Bit32u port, Bit8u val);
|
||||
void OPL3_WriteReg(struct opl3_chip *chip, Bit16u reg, Bit8u v);
|
||||
void OPL3_WriteRegBuffered(struct opl3_chip *chip, Bit16u reg, Bit8u v);
|
||||
void OPL3_GenerateStream(struct opl3_chip *chip, Bit32s *sndptr, Bit32u numsamples);
|
||||
#endif
|
1374
src/sound/nukedopl.c
1374
src/sound/nukedopl.c
File diff suppressed because it is too large
Load Diff
@@ -47,7 +47,7 @@ static void adlib_get_buffer(int32_t *buffer, int len, void *p)
|
||||
adlib_t *adlib = (adlib_t *)p;
|
||||
int c;
|
||||
|
||||
opl2_update2(&adlib->opl);
|
||||
opl2_update(&adlib->opl);
|
||||
|
||||
for (c = 0; c < len * 2; c++)
|
||||
buffer[c] += (int32_t)adlib->opl.buffer[c];
|
||||
|
@@ -646,7 +646,7 @@ static void adgold_get_buffer(int32_t *buffer, int len, void *p)
|
||||
|
||||
int c;
|
||||
|
||||
opl3_update2(&adgold->opl);
|
||||
opl3_update(&adgold->opl);
|
||||
adgold_update(adgold);
|
||||
|
||||
for (c = 0; c < len * 2; c += 2)
|
||||
|
@@ -1,222 +1,284 @@
|
||||
/* Copyright holders: Sarah Walker, SA1988
|
||||
see COPYING for more details
|
||||
*/
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Interface to the actual OPL emulator.
|
||||
*
|
||||
* TODO: Finish re-working this into a device_t, which requires a
|
||||
* poll-like function for "update" so the sound card can call
|
||||
* that and get a buffer-full of sample data.
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* TheCollector1995, <mariogplayer@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2017-2020 Fred N. van Kempen.
|
||||
* Copyright 2016-2019 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#define dbglog sound_card_log
|
||||
#include <86box/86box.h>
|
||||
#include <86box/timer.h>
|
||||
#include "cpu.h"
|
||||
#include <86box/io.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/sound.h>
|
||||
#include <86box/snd_opl.h>
|
||||
#include <86box/snd_opl_backend.h>
|
||||
#include <86box/snd_opl_nuked.h>
|
||||
|
||||
|
||||
/*Interfaces between 86Box and the actual OPL emulator*/
|
||||
enum {
|
||||
STATUS_TIMER_1 = 0x40,
|
||||
STATUS_TIMER_2 = 0x20,
|
||||
STATUS_TIMER_ALL = 0x80
|
||||
};
|
||||
|
||||
enum {
|
||||
CTRL_IRQ_RESET = 0x80,
|
||||
CTRL_TIMER1_MASK = 0x40,
|
||||
CTRL_TIMER2_MASK = 0x20,
|
||||
CTRL_TIMER2_CTRL = 0x02,
|
||||
CTRL_TIMER1_CTRL = 0x01
|
||||
};
|
||||
|
||||
|
||||
uint8_t
|
||||
opl2_read(uint16_t a, void *priv)
|
||||
static void
|
||||
status_update(opl_t *dev)
|
||||
{
|
||||
opl_t *opl = (opl_t *)priv;
|
||||
|
||||
sub_cycles((int) (isa_timing * 8));
|
||||
opl2_update2(opl);
|
||||
|
||||
return opl_read(0, a);
|
||||
if (dev->status & (STATUS_TIMER_1 | STATUS_TIMER_2) & dev->status_mask)
|
||||
dev->status |= STATUS_TIMER_ALL;
|
||||
else
|
||||
dev->status &= ~STATUS_TIMER_ALL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
opl2_write(uint16_t a, uint8_t v, void *priv)
|
||||
static void
|
||||
timer_set(opl_t *dev, int timer, uint64_t period)
|
||||
{
|
||||
opl_t *opl = (opl_t *)priv;
|
||||
|
||||
opl2_update2(opl);
|
||||
opl_write(0, a, v);
|
||||
opl_write(1, a, v);
|
||||
timer_on_auto(&dev->timers[timer], ((double) period) * 20.0);
|
||||
}
|
||||
|
||||
|
||||
uint8_t
|
||||
opl2_l_read(uint16_t a, void *priv)
|
||||
static void
|
||||
timer_over(opl_t *dev, int tmr)
|
||||
{
|
||||
opl_t *opl = (opl_t *)priv;
|
||||
if (tmr) {
|
||||
dev->status |= STATUS_TIMER_2;
|
||||
timer_set(dev, 1, dev->timer[1] * 16);
|
||||
} else {
|
||||
dev->status |= STATUS_TIMER_1;
|
||||
timer_set(dev, 0, dev->timer[0] * 4);
|
||||
}
|
||||
|
||||
sub_cycles((int)(isa_timing * 8));
|
||||
opl2_update2(opl);
|
||||
|
||||
return opl_read(0, a);
|
||||
status_update(dev);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
opl2_l_write(uint16_t a, uint8_t v, void *priv)
|
||||
static void
|
||||
timer_1(void *priv)
|
||||
{
|
||||
opl_t *opl = (opl_t *)priv;
|
||||
opl_t *dev = (opl_t *)priv;
|
||||
|
||||
opl2_update2(opl);
|
||||
opl_write(0, a, v);
|
||||
timer_over(dev, 0);
|
||||
}
|
||||
|
||||
|
||||
uint8_t
|
||||
opl2_r_read(uint16_t a, void *priv)
|
||||
static void
|
||||
timer_2(void *priv)
|
||||
{
|
||||
opl_t *opl = (opl_t *)priv;
|
||||
opl_t *dev = (opl_t *)priv;
|
||||
|
||||
sub_cycles((int)(isa_timing * 8));
|
||||
opl2_update2(opl);
|
||||
|
||||
return opl_read(1, a);
|
||||
timer_over(dev, 1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
opl2_r_write(uint16_t a, uint8_t v, void *priv)
|
||||
static uint8_t
|
||||
opl_read(opl_t *dev, uint16_t port)
|
||||
{
|
||||
opl_t *opl = (opl_t *)priv;
|
||||
if (! (port & 1))
|
||||
return((dev->status & dev->status_mask) | (dev->is_opl3 ? 0x00 : 0x06));
|
||||
|
||||
opl2_update2(opl);
|
||||
opl_write(1, a, v);
|
||||
if (dev->is_opl3 && ((port & 0x03) == 0x03))
|
||||
return(0x00);
|
||||
|
||||
return(dev->is_opl3 ? 0x00 : 0xff);
|
||||
}
|
||||
|
||||
|
||||
uint8_t
|
||||
opl3_read(uint16_t a, void *priv)
|
||||
static void
|
||||
opl_write(opl_t *dev, uint16_t port, uint8_t val)
|
||||
{
|
||||
opl_t *opl = (opl_t *)priv;
|
||||
if (! (port & 1)) {
|
||||
dev->port = nuked_write_addr(dev->opl, port, val) & 0x01ff;
|
||||
|
||||
sub_cycles((int)(isa_timing * 8));
|
||||
opl3_update2(opl);
|
||||
if (! dev->is_opl3)
|
||||
dev->port &= 0x00ff;
|
||||
|
||||
return opl_read(0, a);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
nuked_write_reg_buffered(dev->opl, dev->port, val);
|
||||
|
||||
void
|
||||
opl3_write(uint16_t a, uint8_t v, void *priv)
|
||||
{
|
||||
opl_t *opl = (opl_t *)priv;
|
||||
|
||||
opl3_update2(opl);
|
||||
opl_write(0, a, v);
|
||||
}
|
||||
switch (dev->port) {
|
||||
case 0x02: // timer 1
|
||||
dev->timer[0] = 256 - val;
|
||||
break;
|
||||
|
||||
case 0x03: // timer 2
|
||||
dev->timer[1] = 256 - val;
|
||||
break;
|
||||
|
||||
void
|
||||
opl2_update2(opl_t *opl)
|
||||
{
|
||||
if (opl->pos < sound_pos_global) {
|
||||
opl2_update(0, &opl->buffer[opl->pos << 1], sound_pos_global - opl->pos);
|
||||
opl2_update(1, &opl->buffer2[opl->pos << 1], sound_pos_global - opl->pos);
|
||||
for (; opl->pos < sound_pos_global; opl->pos++) {
|
||||
opl->buffer[(opl->pos << 1) + 1] = opl->buffer2[(opl->pos << 1) + 1];
|
||||
opl->buffer[opl->pos << 1] = (opl->buffer[opl->pos << 1] / 2);
|
||||
opl->buffer[(opl->pos << 1) + 1] = (opl->buffer[(opl->pos << 1) + 1] / 2);
|
||||
}
|
||||
case 0x04: // timer control
|
||||
if (val & CTRL_IRQ_RESET) {
|
||||
dev->status &= ~(STATUS_TIMER_1 | STATUS_TIMER_2);
|
||||
status_update(dev);
|
||||
return;
|
||||
}
|
||||
if ((val ^ dev->timer_ctrl) & CTRL_TIMER1_CTRL) {
|
||||
if (val & CTRL_TIMER1_CTRL)
|
||||
timer_set(dev, 0, dev->timer[0] * 4);
|
||||
else
|
||||
timer_set(dev, 0, 0);
|
||||
}
|
||||
if ((val ^ dev->timer_ctrl) & CTRL_TIMER2_CTRL) {
|
||||
if (val & CTRL_TIMER2_CTRL)
|
||||
timer_set(dev, 1, dev->timer[1] * 16);
|
||||
else
|
||||
timer_set(dev, 1, 0);
|
||||
}
|
||||
dev->status_mask = (~val & (CTRL_TIMER1_MASK | CTRL_TIMER2_MASK)) | 0x80;
|
||||
dev->timer_ctrl = val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
opl3_update2(opl_t *opl)
|
||||
static void
|
||||
opl_init(opl_t *dev, int is_opl3)
|
||||
{
|
||||
if (opl->pos < sound_pos_global) {
|
||||
opl3_update(0, &opl->buffer[(opl->pos << 1)], sound_pos_global - opl->pos);
|
||||
for (; opl->pos < sound_pos_global; opl->pos++) {
|
||||
opl->buffer[opl->pos << 1] = (opl->buffer[opl->pos << 1] / 2);
|
||||
opl->buffer[(opl->pos << 1) + 1] = (opl->buffer[(opl->pos << 1) + 1] / 2);
|
||||
}
|
||||
memset(dev, 0x00, sizeof(opl_t));
|
||||
dev->is_opl3 = is_opl3;
|
||||
|
||||
/* Create a NukedOPL object. */
|
||||
dev->opl = nuked_init(48000);
|
||||
|
||||
timer_add(&dev->timers[0], timer_1, dev, 0);
|
||||
timer_add(&dev->timers[1], timer_2, dev, 0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
opl_close(opl_t *dev)
|
||||
{
|
||||
/* Release the NukedOPL object. */
|
||||
if (dev->opl) {
|
||||
nuked_close(dev->opl);
|
||||
dev->opl = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ym3812_timer_set_0(void *param, int timer, uint64_t period)
|
||||
uint8_t
|
||||
opl2_read(uint16_t port, void *priv)
|
||||
{
|
||||
opl_t *opl = (opl_t *)param;
|
||||
opl_t *dev = (opl_t *)priv;
|
||||
|
||||
if (period)
|
||||
timer_set_delay_u64(&opl->timers[0][timer], period * TIMER_USEC * 20);
|
||||
else
|
||||
timer_disable(&opl->timers[0][timer]);
|
||||
cycles -= ISA_CYCLES(8);
|
||||
|
||||
opl2_update(dev);
|
||||
|
||||
return(opl_read(dev, port));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ym3812_timer_set_1(void *param, int timer, uint64_t period)
|
||||
opl2_write(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
opl_t *opl = (opl_t *)param;
|
||||
opl_t *dev = (opl_t *)priv;
|
||||
|
||||
if (period)
|
||||
timer_set_delay_u64(&opl->timers[1][timer], period * TIMER_USEC * 20);
|
||||
else
|
||||
timer_disable(&opl->timers[1][timer]);
|
||||
}
|
||||
opl2_update(dev);
|
||||
|
||||
|
||||
void
|
||||
ymf262_timer_set(void *param, int timer, uint64_t period)
|
||||
{
|
||||
opl_t *opl = (opl_t *)param;
|
||||
|
||||
if (period)
|
||||
timer_set_delay_u64(&opl->timers[0][timer], period * TIMER_USEC * 20);
|
||||
else
|
||||
timer_disable(&opl->timers[0][timer]);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
opl_timer_callback00(void *p)
|
||||
{
|
||||
opl_timer_over(0, 0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
opl_timer_callback01(void *p)
|
||||
{
|
||||
opl_timer_over(0, 1);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
opl_timer_callback10(void *p)
|
||||
{
|
||||
opl_timer_over(1, 0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
opl_timer_callback11(void *p)
|
||||
{
|
||||
opl_timer_over(1, 1);
|
||||
opl_write(dev, port, val);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
opl2_init(opl_t *opl)
|
||||
opl2_init(opl_t *dev)
|
||||
{
|
||||
opl_init(ym3812_timer_set_0, opl, 0, 0);
|
||||
opl_init(ym3812_timer_set_1, opl, 1, 0);
|
||||
|
||||
timer_add(&opl->timers[0][0], opl_timer_callback00, (void *)opl, 0);
|
||||
timer_add(&opl->timers[0][1], opl_timer_callback01, (void *)opl, 0);
|
||||
timer_add(&opl->timers[1][0], opl_timer_callback10, (void *)opl, 0);
|
||||
timer_add(&opl->timers[1][1], opl_timer_callback11, (void *)opl, 0);
|
||||
opl_init(dev, 0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
opl3_init(opl_t *opl)
|
||||
opl2_update(opl_t *dev)
|
||||
{
|
||||
opl_init(ymf262_timer_set, opl, 0, 1);
|
||||
if (dev->pos >= sound_pos_global)
|
||||
return;
|
||||
|
||||
timer_add(&opl->timers[0][0], opl_timer_callback00, (void *)opl, 0);
|
||||
timer_add(&opl->timers[0][1], opl_timer_callback01, (void *)opl, 0);
|
||||
nuked_generate_stream(dev->opl,
|
||||
&dev->buffer[dev->pos * 2],
|
||||
sound_pos_global - dev->pos);
|
||||
|
||||
for (; dev->pos < sound_pos_global; dev->pos++) {
|
||||
dev->buffer[dev->pos * 2] /= 2;
|
||||
dev->buffer[(dev->pos * 2) + 1] = dev->buffer[dev->pos * 2];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint8_t
|
||||
opl3_read(uint16_t port, void *priv)
|
||||
{
|
||||
opl_t *dev = (opl_t *)priv;
|
||||
|
||||
cycles -= ISA_CYCLES(8);
|
||||
|
||||
opl3_update(dev);
|
||||
|
||||
return(opl_read(dev, port));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
opl3_write(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
opl_t *dev = (opl_t *)priv;
|
||||
|
||||
opl3_update(dev);
|
||||
|
||||
opl_write(dev, port, val);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
opl3_init(opl_t *dev)
|
||||
{
|
||||
opl_init(dev, 1);
|
||||
}
|
||||
|
||||
|
||||
/* API to sound interface. */
|
||||
void
|
||||
opl3_update(opl_t *dev)
|
||||
{
|
||||
if (dev->pos >= sound_pos_global)
|
||||
return;
|
||||
|
||||
nuked_generate_stream(dev->opl,
|
||||
&dev->buffer[dev->pos * 2],
|
||||
sound_pos_global - dev->pos);
|
||||
|
||||
for (; dev->pos < sound_pos_global; dev->pos++) {
|
||||
dev->buffer[dev->pos * 2] /= 2;
|
||||
dev->buffer[(dev->pos * 2) + 1] /= 2;
|
||||
}
|
||||
}
|
||||
|
@@ -1,158 +0,0 @@
|
||||
/* Copyright holders: Sarah Walker, SA1988
|
||||
see COPYING for more details
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <86box/86box.h>
|
||||
#include <nukedopl.h>
|
||||
#include <86box/sound.h>
|
||||
#include <86box/snd_opl_backend.h>
|
||||
#include "cpu.h"
|
||||
#include <86box/mem.h>
|
||||
|
||||
|
||||
int opl_type = 0;
|
||||
|
||||
|
||||
static struct
|
||||
{
|
||||
struct opl3_chip opl3chip;
|
||||
int addr;
|
||||
int timer[2];
|
||||
uint8_t timer_ctrl;
|
||||
uint8_t status_mask;
|
||||
uint8_t status;
|
||||
int is_opl3;
|
||||
|
||||
void (*timer_callback)(void *param, int timer, uint64_t period);
|
||||
void *timer_param;
|
||||
} opl[2];
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
STATUS_TIMER_1 = 0x40,
|
||||
STATUS_TIMER_2 = 0x20,
|
||||
STATUS_TIMER_ALL = 0x80
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CTRL_IRQ_RESET = 0x80,
|
||||
CTRL_TIMER1_MASK = 0x40,
|
||||
CTRL_TIMER2_MASK = 0x20,
|
||||
CTRL_TIMER2_CTRL = 0x02,
|
||||
CTRL_TIMER1_CTRL = 0x01
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
opl_init(void (*timer_callback)(void *param, int timer, uint64_t period), void *timer_param, int nr, int is_opl3)
|
||||
{
|
||||
opl[nr].timer_callback = timer_callback;
|
||||
opl[nr].timer_param = timer_param;
|
||||
opl[nr].is_opl3 = is_opl3;
|
||||
|
||||
opl[nr].opl3chip.newm = 0;
|
||||
OPL3_Reset(&opl[nr].opl3chip, 48000);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
opl_status_update(int nr)
|
||||
{
|
||||
if (opl[nr].status & (STATUS_TIMER_1 | STATUS_TIMER_2) & opl[nr].status_mask)
|
||||
opl[nr].status |= STATUS_TIMER_ALL;
|
||||
else
|
||||
opl[nr].status &= ~STATUS_TIMER_ALL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
opl_timer_over(int nr, int timer)
|
||||
{
|
||||
if (!timer) {
|
||||
opl[nr].status |= STATUS_TIMER_1;
|
||||
opl[nr].timer_callback(opl[nr].timer_param, 0, opl[nr].timer[0] * 4);
|
||||
} else {
|
||||
opl[nr].status |= STATUS_TIMER_2;
|
||||
opl[nr].timer_callback(opl[nr].timer_param, 1, opl[nr].timer[1] * 16);
|
||||
}
|
||||
|
||||
opl_status_update(nr);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
opl_write(int nr, uint16_t addr, uint8_t val)
|
||||
{
|
||||
if (!(addr & 1)) {
|
||||
opl[nr].addr = (int)OPL3_WriteAddr(&opl[nr].opl3chip, addr, val) & 0x1ff;
|
||||
if (!opl[nr].is_opl3)
|
||||
opl[nr].addr &= 0xff;
|
||||
} else {
|
||||
OPL3_WriteRegBuffered(&opl[nr].opl3chip, (uint16_t) opl[nr].addr, val);
|
||||
if (opl[nr].addr == 0x105)
|
||||
opl[nr].opl3chip.newm = opl[nr].addr & 0x01;
|
||||
|
||||
switch (opl[nr].addr) {
|
||||
case 0x02: /*Timer 1*/
|
||||
opl[nr].timer[0] = 256 - val;
|
||||
break;
|
||||
case 0x03: /*Timer 2*/
|
||||
opl[nr].timer[1] = 256 - val;
|
||||
break;
|
||||
case 0x04: /*Timer control*/
|
||||
if (val & CTRL_IRQ_RESET) { /*IRQ reset*/
|
||||
opl[nr].status &= ~(STATUS_TIMER_1 | STATUS_TIMER_2);
|
||||
opl_status_update(nr);
|
||||
return;
|
||||
}
|
||||
if ((val ^ opl[nr].timer_ctrl) & CTRL_TIMER1_CTRL) {
|
||||
if (val & CTRL_TIMER1_CTRL)
|
||||
opl[nr].timer_callback(opl[nr].timer_param, 0, opl[nr].timer[0] * 4);
|
||||
else
|
||||
opl[nr].timer_callback(opl[nr].timer_param, 0, 0);
|
||||
}
|
||||
if ((val ^ opl[nr].timer_ctrl) & CTRL_TIMER2_CTRL) {
|
||||
if (val & CTRL_TIMER2_CTRL)
|
||||
opl[nr].timer_callback(opl[nr].timer_param, 1, opl[nr].timer[1] * 16);
|
||||
else
|
||||
opl[nr].timer_callback(opl[nr].timer_param, 1, 0);
|
||||
}
|
||||
opl[nr].status_mask = (~val & (CTRL_TIMER1_MASK | CTRL_TIMER2_MASK)) | 0x80;
|
||||
opl[nr].timer_ctrl = val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint8_t
|
||||
opl_read(int nr, uint16_t addr)
|
||||
{
|
||||
if (!(addr & 1))
|
||||
return (opl[nr].status & opl[nr].status_mask) | (opl[nr].is_opl3 ? 0 : 0x06);
|
||||
|
||||
if (opl[nr].is_opl3 && ((addr & 3) == 3))
|
||||
return 0x00;
|
||||
|
||||
return opl[nr].is_opl3 ? 0 : 0xff;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
opl2_update(int nr, int32_t *buffer, int samples)
|
||||
{
|
||||
OPL3_GenerateStream(&opl[nr].opl3chip, buffer, samples);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
opl3_update(int nr, int32_t *buffer, int samples)
|
||||
{
|
||||
OPL3_GenerateStream(&opl[nr].opl3chip, buffer, samples);
|
||||
}
|
1404
src/sound/snd_opl_nuked.c
Normal file
1404
src/sound/snd_opl_nuked.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -715,7 +715,7 @@ void pas16_get_buffer(int32_t *buffer, int len, void *p)
|
||||
pas16_t *pas16 = (pas16_t *)p;
|
||||
int c;
|
||||
|
||||
opl3_update2(&pas16->opl);
|
||||
opl3_update(&pas16->opl);
|
||||
sb_dsp_update(&pas16->dsp);
|
||||
pas16_update(pas16);
|
||||
for (c = 0; c < len * 2; c++)
|
||||
|
@@ -98,13 +98,16 @@ static void sb_get_buffer_sb2(int32_t *buffer, int len, void *p)
|
||||
int c;
|
||||
|
||||
if (sb->opl_enabled)
|
||||
opl2_update2(&sb->opl);
|
||||
opl2_update(&sb->opl);
|
||||
|
||||
sb_dsp_update(&sb->dsp);
|
||||
|
||||
for (c = 0; c < len * 2; c += 2)
|
||||
{
|
||||
int32_t out = 0;
|
||||
if (sb->opl_enabled)
|
||||
out = ((sb->opl.buffer[c] * (sb->opl_emu ? 47000 : 51000)) >> 16);
|
||||
|
||||
//TODO: Recording: Mic and line In with AGC
|
||||
out += (int32_t)(((sb_iir(0, (float)sb->dsp.buffer[c]) / 1.3) * 65536) / 3) >> 16;
|
||||
|
||||
@@ -113,7 +116,10 @@ static void sb_get_buffer_sb2(int32_t *buffer, int len, void *p)
|
||||
}
|
||||
|
||||
sb->pos = 0;
|
||||
sb->opl.pos = 0;
|
||||
|
||||
if (sb->opl_enabled)
|
||||
sb->opl.pos = 0;
|
||||
|
||||
sb->dsp.pos = 0;
|
||||
}
|
||||
|
||||
@@ -125,14 +131,17 @@ static void sb_get_buffer_sb2_mixer(int32_t *buffer, int len, void *p)
|
||||
int c;
|
||||
|
||||
if (sb->opl_enabled)
|
||||
opl2_update2(&sb->opl);
|
||||
opl2_update(&sb->opl);
|
||||
|
||||
sb_dsp_update(&sb->dsp);
|
||||
|
||||
for (c = 0; c < len * 2; c += 2)
|
||||
{
|
||||
int32_t out = 0;
|
||||
|
||||
if (sb->opl_enabled)
|
||||
out = ((((sb->opl.buffer[c] * mixer->fm) >> 16) * (sb->opl_emu ? 47000 : 51000)) >> 15);
|
||||
|
||||
/* TODO: Recording : I assume it has direct mic and line in like sb2 */
|
||||
/* It is unclear from the docs if it has a filter, but it probably does */
|
||||
out += (int32_t)(((sb_iir(0, (float)sb->dsp.buffer[c]) / 1.3) * mixer->voice) / 3) >> 15;
|
||||
@@ -144,7 +153,10 @@ static void sb_get_buffer_sb2_mixer(int32_t *buffer, int len, void *p)
|
||||
}
|
||||
|
||||
sb->pos = 0;
|
||||
sb->opl.pos = 0;
|
||||
|
||||
if (sb->opl_enabled)
|
||||
sb->opl.pos = 0;
|
||||
|
||||
sb->dsp.pos = 0;
|
||||
}
|
||||
|
||||
@@ -156,22 +168,34 @@ void sb_get_buffer_sbpro(int32_t *buffer, int len, void *p)
|
||||
int c;
|
||||
|
||||
if (sb->opl_enabled) {
|
||||
if (sb->dsp.sb_type == SBPRO)
|
||||
opl2_update2(&sb->opl);
|
||||
else
|
||||
opl3_update2(&sb->opl);
|
||||
if (sb->dsp.sb_type == SBPRO) {
|
||||
opl2_update(&sb->opl);
|
||||
opl2_update(&sb->opl2);
|
||||
} else
|
||||
opl3_update(&sb->opl);
|
||||
}
|
||||
|
||||
sb_dsp_update(&sb->dsp);
|
||||
|
||||
for (c = 0; c < len * 2; c += 2)
|
||||
{
|
||||
int32_t out_l = 0, out_r = 0;
|
||||
|
||||
if (sb->opl_enabled) {
|
||||
out_l = ((((sb->opl.buffer[c] * mixer->fm_l) >> 16) * (sb->opl_emu ? 47000 : 51000)) >> 15);
|
||||
out_r = ((((sb->opl.buffer[c + 1] * mixer->fm_r) >> 16) * (sb->opl_emu ? 47000 : 51000)) >> 15);
|
||||
if (sb->dsp.sb_type == SBPRO) {
|
||||
/*
|
||||
* Two chips for LEFT and RIGHT channels.
|
||||
* Each chip stores data into the LEFT channel
|
||||
* only (no sample alternating.)
|
||||
*/
|
||||
out_l = ((((sb->opl.buffer[c] * mixer->fm_l) >> 16) * (sb->opl_emu ? 47000 : 51000)) >> 15);
|
||||
out_r = ((((sb->opl2.buffer[c] * mixer->fm_r) >> 16) * (sb->opl_emu ? 47000 : 51000)) >> 15);
|
||||
} else {
|
||||
out_l = ((((sb->opl.buffer[c] * mixer->fm_l) >> 16) * (sb->opl_emu ? 47000 : 51000)) >> 15);
|
||||
out_r = ((((sb->opl.buffer[c + 1] * mixer->fm_r) >> 16) * (sb->opl_emu ? 47000 : 51000)) >> 15);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*TODO: Implement the stereo switch on the mixer instead of on the dsp? */
|
||||
if (mixer->output_filter)
|
||||
{
|
||||
@@ -193,7 +217,13 @@ void sb_get_buffer_sbpro(int32_t *buffer, int len, void *p)
|
||||
}
|
||||
|
||||
sb->pos = 0;
|
||||
sb->opl.pos = 0;
|
||||
|
||||
if (sb->opl_enabled) {
|
||||
sb->opl.pos = 0;
|
||||
if (sb->dsp.sb_type != SBPRO)
|
||||
sb->opl2.pos = 0;
|
||||
}
|
||||
|
||||
sb->dsp.pos = 0;
|
||||
}
|
||||
|
||||
@@ -201,13 +231,14 @@ static void sb_get_buffer_sb16(int32_t *buffer, int len, void *p)
|
||||
{
|
||||
sb_t *sb = (sb_t *)p;
|
||||
sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
|
||||
|
||||
int c;
|
||||
int dsp_rec_pos = sb->dsp.record_pos_write;
|
||||
int c;
|
||||
|
||||
if (sb->opl_enabled)
|
||||
opl3_update2(&sb->opl);
|
||||
opl3_update(&sb->opl);
|
||||
|
||||
sb_dsp_update(&sb->dsp);
|
||||
const int dsp_rec_pos = sb->dsp.record_pos_write;
|
||||
|
||||
for (c = 0; c < len * 2; c += 2)
|
||||
{
|
||||
int32_t out_l = 0, out_r = 0, in_l, in_r;
|
||||
@@ -266,7 +297,10 @@ static void sb_get_buffer_sb16(int32_t *buffer, int len, void *p)
|
||||
sb->dsp.record_pos_write&=0xFFFF;
|
||||
|
||||
sb->pos = 0;
|
||||
sb->opl.pos = 0;
|
||||
|
||||
if (sb->opl_enabled)
|
||||
sb->opl.pos = 0;
|
||||
|
||||
sb->dsp.pos = 0;
|
||||
}
|
||||
#ifdef SB_DSP_RECORD_DEBUG
|
||||
@@ -278,14 +312,16 @@ static void sb_get_buffer_emu8k(int32_t *buffer, int len, void *p)
|
||||
{
|
||||
sb_t *sb = (sb_t *)p;
|
||||
sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
|
||||
|
||||
int c;
|
||||
int c;
|
||||
int dsp_rec_pos = sb->dsp.record_pos_write;
|
||||
|
||||
if (sb->opl_enabled)
|
||||
opl3_update2(&sb->opl);
|
||||
opl3_update(&sb->opl);
|
||||
|
||||
emu8k_update(&sb->emu8k);
|
||||
|
||||
sb_dsp_update(&sb->dsp);
|
||||
const int dsp_rec_pos = sb->dsp.record_pos_write;
|
||||
|
||||
for (c = 0; c < len * 2; c += 2)
|
||||
{
|
||||
int32_t out_l = 0, out_r = 0, in_l, in_r;
|
||||
@@ -374,9 +410,14 @@ static void sb_get_buffer_emu8k(int32_t *buffer, int len, void *p)
|
||||
|
||||
sb->dsp.record_pos_write+=((len * sb->dsp.sb_freq) / 48000)*2;
|
||||
sb->dsp.record_pos_write&=0xFFFF;
|
||||
|
||||
sb->pos = 0;
|
||||
sb->opl.pos = 0;
|
||||
|
||||
if (sb->opl_enabled)
|
||||
sb->opl.pos = 0;
|
||||
|
||||
sb->dsp.pos = 0;
|
||||
|
||||
sb->emu8k.pos = 0;
|
||||
}
|
||||
|
||||
@@ -1140,6 +1181,35 @@ void *sb_2_init(const device_t *info)
|
||||
return sb;
|
||||
}
|
||||
|
||||
|
||||
static uint8_t
|
||||
sb_pro_v1_opl_read(uint16_t port, void *priv)
|
||||
{
|
||||
sb_t *sb = (sb_t *)priv;
|
||||
|
||||
(void)opl2_read(port, &sb->opl2); // read, but ignore
|
||||
return(opl2_read(port, &sb->opl));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
sb_pro_v1_opl_write(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
sb_t *sb = (sb_t *)priv;
|
||||
|
||||
opl2_write(port, val, &sb->opl);
|
||||
opl2_write(port, val, &sb->opl2);
|
||||
}
|
||||
|
||||
|
||||
/*sbpro port mappings. 220h or 240h.
|
||||
2x0 to 2x1 -> FM chip, Left (9*2 voices)
|
||||
2x1 to 2x3 -> FM chip, Right (9*2 voices)
|
||||
2x4 to 2x5 -> Mixer interface
|
||||
2x6, 2xA, 2xC, 2xE -> DSP chip
|
||||
2x8, 2x9, 388 and 389 FM chip (9 voices)
|
||||
2x0+10 to 2x0+13 CDROM interface.
|
||||
*/
|
||||
void *sb_pro_v1_init(const device_t *info)
|
||||
{
|
||||
/*sbpro port mappings. 220h or 240h.
|
||||
@@ -1153,8 +1223,10 @@ void *sb_pro_v1_init(const device_t *info)
|
||||
memset(sb, 0, sizeof(sb_t));
|
||||
|
||||
sb->opl_enabled = device_get_config_int("opl");
|
||||
if (sb->opl_enabled)
|
||||
if (sb->opl_enabled) {
|
||||
opl2_init(&sb->opl);
|
||||
opl2_init(&sb->opl2);
|
||||
}
|
||||
sb_dsp_init(&sb->dsp, SBPRO, SB_SUBTYPE_DEFAULT, sb);
|
||||
sb_dsp_setaddr(&sb->dsp, addr);
|
||||
sb_dsp_setirq(&sb->dsp, device_get_config_int("irq"));
|
||||
@@ -1162,10 +1234,14 @@ void *sb_pro_v1_init(const device_t *info)
|
||||
sb_ct1345_mixer_reset(sb);
|
||||
/* DSP I/O handler is activated in sb_dsp_setaddr */
|
||||
if (sb->opl_enabled) {
|
||||
io_sethandler(addr+0, 0x0002, opl2_l_read, NULL, NULL, opl2_l_write, NULL, NULL, &sb->opl);
|
||||
io_sethandler(addr+2, 0x0002, opl2_r_read, NULL, NULL, opl2_r_write, NULL, NULL, &sb->opl);
|
||||
io_sethandler(addr+8, 0x0002, opl2_read, NULL, NULL, opl2_write, NULL, NULL, &sb->opl);
|
||||
io_sethandler(0x0388, 0x0002, opl2_read, NULL, NULL, opl2_write, NULL, NULL, &sb->opl);
|
||||
io_sethandler(addr + 0, 2,
|
||||
opl2_read,NULL,NULL, opl2_write,NULL,NULL, &sb->opl);
|
||||
io_sethandler(addr + 2, 2,
|
||||
opl2_read,NULL,NULL, opl2_write,NULL,NULL, &sb->opl2);
|
||||
io_sethandler(addr + 8, 2,
|
||||
sb_pro_v1_opl_read,NULL,NULL, sb_pro_v1_opl_write,NULL,NULL, sb);
|
||||
io_sethandler(0x0388, 2,
|
||||
sb_pro_v1_opl_read,NULL,NULL, sb_pro_v1_opl_write,NULL,NULL, sb);
|
||||
}
|
||||
io_sethandler(addr+4, 0x0002, sb_ct1345_mixer_read, NULL, NULL, sb_ct1345_mixer_write, NULL, NULL, sb);
|
||||
sound_add_handler(sb_get_buffer_sbpro, sb);
|
||||
|
@@ -81,7 +81,7 @@ static void wss_get_buffer(int32_t *buffer, int len, void *p)
|
||||
wss_t *wss = (wss_t *)p;
|
||||
int c;
|
||||
|
||||
opl3_update2(&wss->opl);
|
||||
opl3_update(&wss->opl);
|
||||
ad1848_update(&wss->ad1848);
|
||||
for (c = 0; c < len * 2; c++) {
|
||||
buffer[c] += wss->opl.buffer[c];
|
||||
|
@@ -702,8 +702,7 @@ PRINTOBJ := png.o prt_cpmap.o \
|
||||
|
||||
SNDOBJ := sound.o \
|
||||
openal.o \
|
||||
snd_opl.o snd_opl_backend.o \
|
||||
nukedopl.o \
|
||||
snd_opl.o snd_opl_nuked.o \
|
||||
snd_resid.o \
|
||||
convolve.o convolve-sse.o envelope.o extfilt.o \
|
||||
filter.o pot.o sid.o voice.o wave6581__ST.o \
|
||||
|
Reference in New Issue
Block a user