yui 2015-11-23 02:14:35 +00:00
parent 94fbced9b0
commit 99e54b2199
30 changed files with 609 additions and 1029 deletions

View File

@ -5,7 +5,6 @@
#include "pccore.h"
#include "iocore.h"
IOCORE iocore;
CGROM cgrom;
CMT cmt;
@ -16,7 +15,6 @@
PCG pcg;
PPI ppi;
SIO sio;
SNDBOARD sndboard;
SUBCPU subcpu;

View File

@ -73,7 +73,6 @@ extern FDC fdc;
extern PCG pcg;
extern PPI ppi;
extern SIO sio;
extern SNDBOARD sndboard;
extern SUBCPU subcpu;

View File

@ -1,128 +1,146 @@
#include "compiler.h"
#include "joymng.h"
#include "pccore.h"
#include "iocore.h"
#include "keystat.h"
#include "sound.h"
#include "sndctrl.h"
#include "x1f.h"
/**
* @file sndboard.h
* @brief Implementation of the sound boards
*/
#include "compiler.h"
#include "joymng.h"
#include "pccore.h"
#include "iocore.h"
#include "keystat.h"
#include "sound.h"
#include "sndctrl.h"
static UINT8 s_rapids;
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
void IOOUTCALL opm_o(UINT port, REG8 dat) {
REG8 lsb;
REG8 reg;
void IOOUTCALL opm_o(UINT port, REG8 dat)
{
REG8 lsb;
lsb = (UINT8)port;
if (lsb == 0x00) { /* 0700 */
sndboard.opmreg = (UINT8)dat;
if (lsb == 0x00) /* 0700 */
{
g_opm.s.addr = (UINT8)dat;
}
else if (lsb == 0x01) { /* 0701 */
reg = sndboard.opmreg;
sndboard.opmdat[reg] = dat;
x1f_opm(reg, dat);
#if !defined(DISABLE_SOUND)
opmgen_setreg(&g_opmgen, reg, dat);
#endif
else if (lsb == 0x01) /* 0701 */
{
opm_writeRegister(&g_opm, g_opm.s.addr, dat);
}
else if ((lsb & (~3)) == 0x04) { /* 0704-0707 */
else if ((lsb & (~3)) == 0x04) /* 0704-0707 */
{
ctc_o(port, dat);
}
}
REG8 IOINPCALL opm_i(UINT port) {
REG8 lsb;
REG8 IOINPCALL opm_i(UINT port)
{
REG8 lsb;
lsb = (UINT8)port;
if ((lsb & (~1)) == 0x00) { /* 0700/0701 */
return(0x00); /* ƒ[ƒŠƒA<C692>[ƒh */
if ((lsb & (~1)) == 0x00) /* 0700/0701 */
{
return 0x00; /* ƒ[ƒŠƒA<C692>[ƒh */
}
else if ((lsb & (~3)) == 0x04) { /* 0704-0707 */
return(ctc_i(port));
else if ((lsb & (~3)) == 0x04) /* 0704-0707 */
{
return ctc_i(port);
}
else {
return(0xff);
else
{
return 0xff;
}
}
#endif
void IOOUTCALL sndboard_psgreg(UINT port, REG8 dat) {
sndboard.psgreg = dat;
void IOOUTCALL sndboard_psgreg(UINT port, REG8 dat)
{
g_psg.s.addr = dat;
(void)port;
}
void IOOUTCALL sndboard_psgdat(UINT port, REG8 dat) {
REG8 reg;
reg = sndboard.psgreg;
if (reg < 0x0e) {
sndboard.psgdat[reg] = dat;
x1f_psg(reg, dat);
#if !defined(DISABLE_SOUND)
psggen_setreg(&psggen, reg, dat);
#endif
}
void IOOUTCALL sndboard_psgdat(UINT port, REG8 dat)
{
psg_writeRegister(&g_psg, g_psg.s.addr, dat);
(void)port;
}
REG8 IOINPCALL sndboard_psgsta(UINT port) {
REG8 IOINPCALL sndboard_psgsta(UINT port)
{
REG8 nAddress;
REG8 ret;
REG8 ret;
if (sndboard.psgreg < 0x0e) {
return(sndboard.psgdat[sndboard.psgreg]);
nAddress = g_psg.s.addr;
if (nAddress < 0x0e)
{
return psg_readRegister(&g_psg, nAddress);
}
else if (sndboard.psgreg < 0x10) {
else if (nAddress < 0x10)
{
ret = 0xff;
if (sndboard.psgreg == (xmilcfg.KEY_MODE + 0x0d)) {
if (nAddress == (xmilcfg.KEY_MODE + 0x0d))
{
ret &= keystat_getjoy();
}
if (sndboard.psgreg == 0x0e) {
if (nAddress == 0x0e)
{
ret &= joymng_getstat();
}
if (xmilcfg.BTN_RAPID) {
sndboard.rapids ^= 0x60;
ret |= sndboard.rapids;
if (xmilcfg.BTN_RAPID)
{
s_rapids ^= 0x60;
ret |= s_rapids;
}
if (xmilcfg.BTN_MODE) {
if (xmilcfg.BTN_MODE)
{
ret = (ret & (~0x60)) | ((ret & 0x40) >> 1) | ((ret & 0x20) << 1);
}
return(ret);
return ret;
}
else {
else
{
(void)port;
return(0xff);
return 0xff;
}
}
/* reset */
#if !defined(DISABLE_SOUND)
void sndboard_update(void) {
UINT i;
for (i=0; i<14; i++) {
psggen_setreg(&psggen, (REG8)i, sndboard.psgdat[i]);
}
void sndboard_initialize(void)
{
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
for (i=0x20; i<0x100; i++) {
opmgen_setreg(&g_opmgen, (REG8)i, sndboard.opmdat[i]);
}
opm_construct(&g_opm);
#endif
}
#endif
void sndboard_reset(void) {
ZeroMemory(&sndboard, sizeof(sndboard));
sndboard.psgdat[0x07] = 0x3f;
sndctrl_reset();
psg_construct(&g_psg);
}
void sndboard_deinitialize(void)
{
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
opm_destruct(&g_opm);
#endif
psg_destruct(&g_psg);
}
/**
* reset
*/
void sndboard_reset(void)
{
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
UINT8 cCaps;
cCaps = (pccore.SOUND_SW) ? (OPM_HAS_OPM | OPM_X1F) : 0;
opm_reset(&g_opm, cCaps);
opm_bind(&g_opm);
#endif
psg_reset(&g_psg, PSG_HAS_PSG | PSG_X1F);
psg_bind(&g_psg);
}
void sndboard_update(void)
{
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
opm_restore(&g_opm);
#endif
psg_restore(&g_psg);
}

View File

@ -1,28 +1,13 @@
/**
* @file sndboard.h
* @brief Interface of the sound boards
*/
typedef struct {
UINT8 psgreg;
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
UINT8 opmreg;
#else
UINT8 _protected_opmreg;
#endif
UINT8 rapids;
UINT8 padding;
UINT8 psgdat[0x10];
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
UINT8 opmdat[0x100];
#endif
} SNDBOARD;
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(DISABLE_SOUND)
void sndboard_update(void);
#else
#define sndboard_update()
extern "C"
{
#endif
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
@ -34,7 +19,10 @@ void IOOUTCALL sndboard_psgreg(UINT port, REG8 dat);
void IOOUTCALL sndboard_psgdat(UINT port, REG8 dat);
REG8 IOINPCALL sndboard_psgsta(UINT port);
void sndboard_initialize(void);
void sndboard_deinitialize(void);
void sndboard_reset(void);
void sndboard_update(void);
#ifdef __cplusplus
}

View File

@ -69,10 +69,13 @@ void pccore_initialize(void) {
crtc_initialize();
pcg_initialize();
ppi_initialize();
sndboard_initialize();
}
void pccore_deinitialize(void) {
sndboard_deinitialize();
sndctrl_deinitialize();
fddfile_eject(0);

View File

@ -127,6 +127,8 @@
BAABD7341BC3BA5E00522E67 /* z80dmap.c in Sources */ = {isa = PBXBuildFile; fileRef = BAABD69D1BC3BA5D00522E67 /* z80dmap.c */; };
BAABD7351BC3BA5E00522E67 /* z80mem.c in Sources */ = {isa = PBXBuildFile; fileRef = BAABD69F1BC3BA5D00522E67 /* z80mem.c */; };
BAABD73B1BC3BBE200522E67 /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BAABD73A1BC3BBE200522E67 /* SDL2.framework */; };
BAD1A2CD1BE7569C00B23E7C /* opm.c in Sources */ = {isa = PBXBuildFile; fileRef = BAD1A2CB1BE7569C00B23E7C /* opm.c */; };
BAD1A2D01BE756A400B23E7C /* psg.c in Sources */ = {isa = PBXBuildFile; fileRef = BAD1A2CE1BE756A400B23E7C /* psg.c */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -354,6 +356,10 @@
BAABD6A01BC3BA5D00522E67 /* z80mem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = z80mem.h; sourceTree = "<group>"; };
BAABD7391BC3BB2400522E67 /* compiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = compiler.h; sourceTree = "<group>"; };
BAABD73A1BC3BBE200522E67 /* SDL2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = SDL2.framework; sourceTree = "<group>"; };
BAD1A2CB1BE7569C00B23E7C /* opm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = opm.c; sourceTree = "<group>"; };
BAD1A2CC1BE7569C00B23E7C /* opm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = opm.h; sourceTree = "<group>"; };
BAD1A2CE1BE756A400B23E7C /* psg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = psg.c; sourceTree = "<group>"; };
BAD1A2CF1BE756A400B23E7C /* psg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = psg.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -694,9 +700,13 @@
BAABD6641BC3BA5D00522E67 /* sound */ = {
isa = PBXGroup;
children = (
BAD1A2CB1BE7569C00B23E7C /* opm.c */,
BAD1A2CC1BE7569C00B23E7C /* opm.h */,
BAABD6651BC3BA5D00522E67 /* opmgen.h */,
BAABD6661BC3BA5D00522E67 /* opmgenc.c */,
BAABD6671BC3BA5D00522E67 /* opmgeng.c */,
BAD1A2CE1BE756A400B23E7C /* psg.c */,
BAD1A2CF1BE756A400B23E7C /* psg.h */,
BAABD6681BC3BA5D00522E67 /* psggen.h */,
BAABD6691BC3BA5D00522E67 /* psggenc.c */,
BAABD66A1BC3BA5D00522E67 /* psggeng.c */,
@ -924,9 +934,11 @@
BAABD7201BC3BA5D00522E67 /* makescrn.c in Sources */,
BAABD7221BC3BA5E00522E67 /* maketxth.c in Sources */,
BAABD6E51BC3BA5D00522E67 /* vramio.c in Sources */,
BAD1A2D01BE756A400B23E7C /* psg.c in Sources */,
BAABD6D81BC3BA5D00522E67 /* crtc.c in Sources */,
BAABD6DE1BC3BA5D00522E67 /* iocore.c in Sources */,
BAABD7011BC3BA5D00522E67 /* scrnmng.c in Sources */,
BAD1A2CD1BE7569C00B23E7C /* opm.c in Sources */,
BAABD6E81BC3BA5D00522E67 /* nevent.c in Sources */,
BAABD6C61BC3BA5D00522E67 /* vramhdl.c in Sources */,
BAABD6E21BC3BA5D00522E67 /* sio.c in Sources */,

View File

@ -121,6 +121,8 @@
BA6D169E193D5CC1006EC729 /* z80c_sb.c in Sources */ = {isa = PBXBuildFile; fileRef = BA6D160C193D5CC1006EC729 /* z80c_sb.c */; };
BA6D169F193D5CC1006EC729 /* z80dmap.c in Sources */ = {isa = PBXBuildFile; fileRef = BA6D160E193D5CC1006EC729 /* z80dmap.c */; };
BA6D16A0193D5CC1006EC729 /* z80mem.c in Sources */ = {isa = PBXBuildFile; fileRef = BA6D1610193D5CC1006EC729 /* z80mem.c */; };
BAD1A2C71BE7565800B23E7C /* opm.c in Sources */ = {isa = PBXBuildFile; fileRef = BAD1A2C51BE7565800B23E7C /* opm.c */; };
BAD1A2CA1BE7566400B23E7C /* psg.c in Sources */ = {isa = PBXBuildFile; fileRef = BAD1A2C81BE7566400B23E7C /* psg.c */; };
BAD9FBD9193F194700B3C0D5 /* Default-Landscape.png in Resources */ = {isa = PBXBuildFile; fileRef = BAD9FBD7193F194700B3C0D5 /* Default-Landscape.png */; };
BAD9FBDA193F194700B3C0D5 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = BAD9FBD8193F194700B3C0D5 /* Icon-72.png */; };
FD779EDE0E26BA1200F39101 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD779EDD0E26BA1200F39101 /* CoreAudio.framework */; };
@ -400,6 +402,10 @@
BA6D160F193D5CC1006EC729 /* z80dmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = z80dmap.h; sourceTree = "<group>"; };
BA6D1610193D5CC1006EC729 /* z80mem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = z80mem.c; sourceTree = "<group>"; };
BA6D1611193D5CC1006EC729 /* z80mem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = z80mem.h; sourceTree = "<group>"; };
BAD1A2C51BE7565800B23E7C /* opm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = opm.c; sourceTree = "<group>"; };
BAD1A2C61BE7565800B23E7C /* opm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = opm.h; sourceTree = "<group>"; };
BAD1A2C81BE7566400B23E7C /* psg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = psg.c; sourceTree = "<group>"; };
BAD1A2C91BE7566400B23E7C /* psg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = psg.h; sourceTree = "<group>"; };
BAD9FBD7193F194700B3C0D5 /* Default-Landscape.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Landscape.png"; sourceTree = "<group>"; };
BAD9FBD8193F194700B3C0D5 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = "<group>"; };
FD779EDD0E26BA1200F39101 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };
@ -806,9 +812,13 @@
BA6D15D6193D5CC1006EC729 /* sound */ = {
isa = PBXGroup;
children = (
BAD1A2C51BE7565800B23E7C /* opm.c */,
BAD1A2C61BE7565800B23E7C /* opm.h */,
BA6D15D7193D5CC1006EC729 /* opmgen.h */,
BA6D15D8193D5CC1006EC729 /* opmgenc.c */,
BA6D15D9193D5CC1006EC729 /* opmgeng.c */,
BAD1A2C81BE7566400B23E7C /* psg.c */,
BAD1A2C91BE7566400B23E7C /* psg.h */,
BA6D15DA193D5CC1006EC729 /* psggen.h */,
BA6D15DB193D5CC1006EC729 /* psggenc.c */,
BA6D15DC193D5CC1006EC729 /* psggeng.c */,
@ -939,6 +949,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BAD1A2CA1BE7566400B23E7C /* psg.c in Sources */,
BA6D1649193D5CC1006EC729 /* crtc.c in Sources */,
BA6D1687193D5CC1006EC729 /* make24.c in Sources */,
BA6D1685193D5CC1006EC729 /* timing.c in Sources */,
@ -972,6 +983,7 @@
BA6D1651193D5CC1006EC729 /* pcg.c in Sources */,
BA6D161D193D5CC1006EC729 /* _memory.c in Sources */,
BA6D1640193D5CC1006EC729 /* font.c in Sources */,
BAD1A2C71BE7565800B23E7C /* opm.c in Sources */,
BA6D1656193D5CC1006EC729 /* vramio.c in Sources */,
BA6D163A193D5CC1006EC729 /* fdd_2d.c in Sources */,
BA6D163F193D5CC1006EC729 /* newdisk.c in Sources */,

View File

@ -441,6 +441,10 @@
<Filter
Name="sound"
>
<File
RelativePath="..\..\sound\opm.c"
>
</File>
<File
RelativePath="..\..\sound\opmgenc.c"
>
@ -449,6 +453,10 @@
RelativePath="..\..\sound\opmgeng.c"
>
</File>
<File
RelativePath="..\..\sound\psg.c"
>
</File>
<File
RelativePath="..\..\sound\psggenc.c"
>
@ -911,10 +919,18 @@
<Filter
Name="sound"
>
<File
RelativePath="..\..\sound\opm.h"
>
</File>
<File
RelativePath="..\..\sound\opmgen.h"
>
</File>
<File
RelativePath="..\..\sound\psg.h"
>
</File>
<File
RelativePath="..\..\sound\psggen.h"
>

115
sound/opm.c Normal file
View File

@ -0,0 +1,115 @@
/**
* @file opm.c
* @brief Implementation of OPM
*/
#include "compiler.h"
#include "opm.h"
#include "sound.h"
#include "x1f.h"
static void writeRegister(POPM opm, REG8 nAddress, REG8 cData);
/**
* Initialize instance
* @param[in] opm The instance
*/
void opm_construct(POPM opm)
{
memset(opm, 0, sizeof(*opm));
}
/**
* Deinitialize instance
* @param[in] opm The instance
*/
void opm_destruct(POPM opm)
{
}
/**
* Reset
* @param[in] opm The instance
* @param[in] cCaps
*/
void opm_reset(POPM opm, REG8 cCaps)
{
memset(&opm->s, 0, sizeof(opm->s));
opm->s.cCaps = cCaps;
memset(&opm->s.reg[0x20], 0xff, 0xe0);
opmgen_reset(&opm->opmgen);
}
/**
* Restore
* @param[in] opm The instance
*/
void opm_restore(POPM opm)
{
UINT i;
// FM
for (i = 0; i < 0x100; i++)
{
if (i == 8)
{
continue;
}
writeRegister(opm, (REG8)i, opm->s.reg[i]);
}
}
/**
* Bind
* @param[in] opm The instance
*/
void opm_bind(POPM opm)
{
const UINT8 cCaps = opm->s.cCaps;
opm_restore(opm);
if (cCaps & OPM_HAS_OPM)
{
sound_streamregist(&opm->opmgen, (SOUNDCB)opmgen_getpcm);
}
}
/**
* Writes register
* @param[in] opm The instance
* @param[in] nAddress The address
* @param[in] cData The data
*/
void opm_writeRegister(POPM opm, REG8 nAddress, REG8 cData)
{
opm->s.reg[nAddress] = cData;
if (opm->s.cCaps & OPM_X1F)
{
x1f_opm(nAddress, cData);
}
writeRegister(opm, nAddress, cData);
}
/**
* Writes register (Inner)
* @param[in] opm The instance
* @param[in] nAddress The address
* @param[in] cData The data
*/
static void writeRegister(POPM opm, REG8 nAddress, REG8 cData)
{
const UINT8 cCaps = opm->s.cCaps;
if (cCaps & OPM_HAS_OPM)
{
if ((nAddress < 0x20) && ((0x0b178102 & ((1 << nAddress))) == 0))
{
return;
}
opmgen_setreg(&opm->opmgen, nAddress, cData);
}
}

57
sound/opm.h Normal file
View File

@ -0,0 +1,57 @@
/**
* @file opm.h
* @brief Interface of OPM
*/
#pragma once
#include "opmgen.h"
/**
* Chips flags
*/
enum
{
OPM_HAS_OPM = 0x01, /*!< Has OPM */
OPM_X1F = 0x02, /*!< Supports S98 */
};
/**
* @brief opm
*/
struct tagOpmState
{
UINT8 addr;
UINT8 cCaps;
UINT8 reg[0x100];
};
/**
* @brief opm
*/
struct tagOpm
{
struct tagOpmState s;
INTPTR userdata;
_OPMGEN opmgen;
};
typedef struct tagOpm OPM;
typedef struct tagOpm* POPM;
#ifdef __cplusplus
extern "C"
{
#endif
void opm_construct(POPM opm);
void opm_destruct(POPM opm);
void opm_reset(POPM opm, REG8 cCaps);
void opm_bind(POPM opm);
void opm_restore(POPM opm);
void opm_writeRegister(POPM opm, REG8 nAddress, REG8 cData);
#ifdef __cplusplus
}
#endif

View File

@ -1,3 +1,11 @@
/**
* @file omngen.h
* @brief Interface of the OPM generator
*/
#pragma once
#include "sound.h"
#define OPM_CLOCK 4000000L /* X1 & X68000 OPM 4MHz */
#define OPMCH_MAX 8

View File

@ -8,7 +8,6 @@
#ifndef PALMOS
#include <math.h>
#endif
#include "sound.h"
#include "opmgen.h"

View File

@ -4,7 +4,6 @@
*/
#include "compiler.h"
#include "sound.h"
#include "opmgen.h"
extern OPMCFG opmcfg;

147
sound/psg.c Normal file
View File

@ -0,0 +1,147 @@
/**
* @file psg.c
* @brief Implementation of PSG
*/
#include "compiler.h"
#include "psg.h"
#include "sound.h"
#include "x1f.h"
static void writeRegister(PPSG psg, REG8 nAddress, REG8 cData);
/**
* Initialize instance
* @param[in] psg The instance
*/
void psg_construct(PPSG psg)
{
memset(psg, 0, sizeof(*psg));
}
/**
* Deinitialize instance
* @param[in] psg The instance
*/
void psg_destruct(PPSG psg)
{
}
/**
* Reset
* @param[in] psg The instance
* @param[in] cCaps
*/
void psg_reset(PPSG psg, REG8 cCaps)
{
memset(&psg->s, 0, sizeof(psg->s));
psg->s.cCaps = cCaps;
psg->s.reg[0x07] = 0xbf;
psg->s.reg[0x0e] = 0xff;
psg->s.reg[0x0f] = 0xff;
psggen_reset(&psg->psg);
}
/**
* Restore
* @param[in] psg The instance
*/
void psg_restore(PPSG psg)
{
REG8 i;
// PSG
for (i = 0; i < 14; i++)
{
writeRegister(psg, i, psg->s.reg[i]);
}
}
/**
* Bind
* @param[in] psg The instance
*/
void psg_bind(PPSG psg)
{
const UINT8 cCaps = psg->s.cCaps;
psg_restore(psg);
if (cCaps & PSG_HAS_PSG)
{
sound_streamregist(&psg->psg, (SOUNDCB)psggen_getpcm);
}
}
/**
* Status
* @param[in] psg The instance
* @return Status
*/
REG8 psg_readStatus(PPSG psg)
{
if (psg->s.cCaps & PSG_HAS_PSG)
{
return 0;
}
return 0xff;
}
/**
* Writes register
* @param[in] psg The instance
* @param[in] nAddress The address
* @param[in] cData The data
*/
void psg_writeRegister(PPSG psg, REG8 nAddress, REG8 cData)
{
if (nAddress >= 0x10)
{
return;
}
psg->s.reg[nAddress] = cData;
if (psg->s.cCaps & PSG_X1F)
{
x1f_psg(nAddress, cData);
}
writeRegister(psg, nAddress, cData);
}
/**
* Writes register (Inner)
* @param[in] psg The instance
* @param[in] nAddress The address
* @param[in] cData The data
*/
static void writeRegister(PPSG psg, REG8 nAddress, REG8 cData)
{
const UINT8 cCaps = psg->s.cCaps;
if (nAddress < 0x10)
{
if (cCaps & PSG_HAS_PSG)
{
psggen_setreg(&psg->psg, nAddress, cData);
}
}
}
/**
* Reads register
* @param[in] psg The instance
* @param[in] nAddress The address
* @return data
*/
REG8 psg_readRegister(PPSG psg, REG8 nAddress)
{
if (nAddress < 0x10)
{
if (psg->s.cCaps & PSG_HAS_PSG)
{
return psg->s.reg[nAddress];
}
}
return 0xff;
}

59
sound/psg.h Normal file
View File

@ -0,0 +1,59 @@
/**
* @file psg.h
* @brief Interface of PSG
*/
#pragma once
#include "psggen.h"
/**
* Chips flags
*/
enum
{
PSG_HAS_PSG = 0x01, /*!< Has PSG */
PSG_X1F = 0x02, /*!< Supports S98 */
};
/**
* @brief psg
*/
struct tagPsgState
{
UINT8 addr;
UINT8 cCaps;
UINT8 reg[16];
};
/**
* @brief psg
*/
struct tagPsg
{
struct tagPsgState s;
INTPTR userdata;
_PSGGEN psg;
};
typedef struct tagPsg PSG;
typedef struct tagPsg* PPSG;
#ifdef __cplusplus
extern "C"
{
#endif
void psg_construct(PPSG psg);
void psg_destruct(PPSG psg);
void psg_reset(PPSG psg, REG8 cCaps);
void psg_restore(PPSG psg);
void psg_bind(PPSG psg);
REG8 psg_readStatus(PPSG psg);
REG8 psg_readRegister(PPSG psg, REG8 nAddress);
void psg_writeRegister(PPSG psg, REG8 nAddress, REG8 cData);
#ifdef __cplusplus
}
#endif

View File

@ -1,3 +1,11 @@
/**
* @file psggen.h
* @brief Interface of the PSG generator
*/
#pragma once
#include "sound.h"
enum {
PSGFREQPADBIT = 12,
@ -78,4 +86,3 @@ void SOUNDCALL psggen_getpcm(PSGGEN psg, SINT32 *pcm, UINT count);
#ifdef __cplusplus
}
#endif

View File

@ -5,7 +5,6 @@
#include "compiler.h"
#include <math.h>
#include "sound.h"
#include "psggen.h"
PSGGENCFG psggencfg;

View File

@ -4,7 +4,6 @@
*/
#include "compiler.h"
#include "sound.h"
#include "psggen.h"
#include "parts.h"

View File

@ -1,19 +1,22 @@
#include "compiler.h"
#if !defined(DISABLE_SOUND)
#include "soundmng.h"
#include "pccore.h"
#include "sound.h"
#include "sndctrl.h"
/**
* @file sndctrl.c
* @brief Implementation of the sound
*/
#include "compiler.h"
#include "sndctrl.h"
#if !defined(DISABLE_SOUND)
#include "soundmng.h"
#include "pccore.h"
#include "sound.h"
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
_OPMGEN g_opmgen;
OPM g_opm;
#endif
_PSGGEN psggen;
void sndctrl_initialize(void) {
PSG g_psg;
void sndctrl_initialize(void)
{
UINT rate;
rate = xmilcfg.samplingrate;
@ -26,21 +29,13 @@ void sndctrl_initialize(void) {
psggen_setvol(xmilcfg.vol_ssg);
}
void sndctrl_deinitialize(void) {
void sndctrl_deinitialize(void)
{
soundmng_stop();
sound_destroy();
}
void sndctrl_reset(void) {
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
opmgen_reset(&g_opmgen);
sound_streamregist(&g_opmgen, (SOUNDCB)opmgen_getpcm);
#endif
psggen_reset(&psggen);
sound_streamregist(&psggen, (SOUNDCB)psggen_getpcm);
void sndctrl_reset(void)
{
}
#endif

View File

@ -1,17 +1,24 @@
/**
* @file sndctrl.h
* @brief Interface of the sound
*/
#include "opmgen.h"
#include "psggen.h"
#pragma once
#include "opm.h"
#include "psg.h"
#if !defined(DISABLE_SOUND)
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
extern _OPMGEN g_opmgen;
extern OPM g_opm;
#endif
extern _PSGGEN psggen;
extern PSG g_psg;
void sndctrl_initialize(void);
void sndctrl_deinitialize(void);

View File

@ -1,3 +1,9 @@
/**
* @file sound.h
* @brief Interface of the sound
*/
#pragma once
#ifndef SOUNDCALL
#define SOUNDCALL

View File

@ -61,9 +61,9 @@ BRESULT x1f_open(const OEMCHAR *filename) {
return(FAILURE);
}
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
CopyMemory(buf, sndboard.opmdat, 256);
memcpy(buf, g_opm.s.reg, 256);
#else
ZeroMemory(buf, 256);
memset(buf, 0, 256);
#endif
CopyMemory(buf, "X1F", 4);
file_write(fh, buf, 256);
@ -73,7 +73,7 @@ BRESULT x1f_open(const OEMCHAR *filename) {
x1f.counter = 0;
x1f.pos = 0;
for (i=0; i<14; i++) {
x1f_psg((REG8)i, ((UINT8 *)&psggen.reg)[i]);
x1f_psg((REG8)i, g_psg.s.reg[i]);
}
return(SUCCESS);
}

View File

@ -15,6 +15,7 @@
#include "palettes.h"
#include "makescrn.h"
#include "sound.h"
#include "sndctrl.h"
#include "fddfile.h"
#if defined(MACOS)

View File

@ -56,10 +56,13 @@ static const SFENTRY xmiltbl[] = {
{"PCG", 0, STATFLAG_BIN, &pcg, sizeof(pcg)},
{"PPI", 0, STATFLAG_BIN, &ppi, sizeof(ppi)},
{"SIO", 0, STATFLAG_BIN, &sio, sizeof(sio)},
{"SNDBOARD", 0, STATFLAG_BIN, &sndboard, sizeof(sndboard)},
{"SUBCPU", 0, STATFLAG_BIN, &subcpu.s, sizeof(subcpu.s)},
{"CALENDAR", 0, STATFLAG_BIN, &cal, sizeof(cal)},
{"NEVENT", 0, STATFLAG_EVT, &nevent, sizeof(nevent)},
{"DISK", 0, STATFLAG_DISK, NULL, 0},
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
{"OPM", 0, STATFLAG_BIN, &g_opm.s, sizeof(g_opm.s)},
#endif
{"PSG", 0, STATFLAG_BIN, &g_psg.s, sizeof(g_psg.s)},
{"TERMINATE", 0, STATFLAG_TERM, NULL, 0}};

View File

@ -1,604 +0,0 @@
#include "compiler.h"
#include "romeo.h"
#include "juliet.h"
enum {
ROMEO_AVAIL = 0x01,
ROMEO_YMF288 = 0x02,
ROMEO_YM2151 = 0x04
};
typedef struct {
UINT8 op[8];
UINT8 ttl[8*4];
} YM2151FLAG;
typedef struct {
UINT8 algo[8];
UINT8 ttl[8*4];
UINT8 psgmix;
} YMF288FLAG;
typedef struct {
HMODULE mod;
PCIFINDDEV finddev;
PCICFGREAD32 read32;
PCIMEMWR8 out8;
PCIMEMWR16 out16;
PCIMEMWR32 out32;
PCIMEMRD8 in8;
PCIMEMRD16 in16;
PCIMEMRD32 in32;
ULONG addr;
ULONG irq;
ULONG avail;
ULONG snoopcount;
YM2151FLAG ym2151;
YMF288FLAG ymf288;
} _ROMEO;
static const UINT8 opmask[] = {0x08,0x08,0x08,0x08,0x0c,0x0e,0x0e,0x0f};
typedef struct {
const char *symbol;
UINT addr;
} DLLPROCESS;
static const char fnstr_finddev[] = FN_PCIFINDDEV;
static const char fnstr_read32[] = FN_PCICFGREAD32;
static const char fnstr_out8[] = FN_PCIMEMWR8;
static const char fnstr_out16[] = FN_PCIMEMWR16;
static const char fnstr_out32[] = FN_PCIMEMWR32;
static const char fnstr_inp8[] = FN_PCIMEMRD8;
static const char fnstr_inp16[] = FN_PCIMEMRD16;
static const char fnstr_inp32[] = FN_PCIMEMRD32;
static const DLLPROCESS dllproc[] = {
{fnstr_finddev, offsetof(_ROMEO, finddev)},
{fnstr_read32, offsetof(_ROMEO, read32)},
{fnstr_out8, offsetof(_ROMEO, out8)},
{fnstr_out16, offsetof(_ROMEO, out16)},
{fnstr_out32, offsetof(_ROMEO, out32)},
{fnstr_inp8, offsetof(_ROMEO, in8)},
{fnstr_inp16, offsetof(_ROMEO, in16)},
{fnstr_inp32, offsetof(_ROMEO, in32)}};
static _ROMEO romeo;
static SINT8 YM2151vol = -12;
BOOL juliet_load(void) {
int i;
const DLLPROCESS *dp;
BOOL r = SUCCESS;
juliet_unload();
romeo.mod = LoadLibrary(OEMTEXT(PCIDEBUG_DLL));
if (romeo.mod == NULL) {
return(FAILURE);
}
for (i=0, dp=dllproc; i<sizeof(dllproc)/sizeof(DLLPROCESS); i++, dp++) {
FARPROC proc;
proc = GetProcAddress(romeo.mod, dp->symbol);
if (proc == NULL) {
r = FAILURE;
break;
}
*(DWORD *)(((UINT8 *)&romeo) + dp->addr) = (DWORD)proc;
}
if (r) {
juliet_unload();
}
return(r);
}
void juliet_unload(void) {
if (romeo.mod) {
FreeLibrary(romeo.mod);
}
ZeroMemory(&romeo, sizeof(romeo));
FillMemory(romeo.ym2151.ttl, 8*4, 0x7f);
FillMemory(romeo.ymf288.ttl, 8*4, 0x7f);
romeo.ymf288.psgmix = 0x3f;
}
// ----
// pciFindPciDevice使うと、OS起動後一発目に見つけられないことが多いので
// 自前で検索する(矢野さん方式)
#define PCIBUSDEVFUNC(b, d, f) (((b) << 8) | ((d) << 3) | (f))
#define DEVVEND(v, d) ((ULONG)((v) | ((d) << 16)))
static ULONG searchRomeo(void) {
UINT bus;
UINT dev;
UINT func;
ULONG addr;
ULONG dev_vend;
for (bus=0; bus<0x100; bus++) {
for (dev=0; dev<0x20; dev++) {
for (func=0; func<0x08; func++) {
addr = PCIBUSDEVFUNC(bus, dev, func);
dev_vend = romeo.read32(addr, 0x0000);
if ((dev_vend == DEVVEND(ROMEO_VENDORID, ROMEO_DEVICEID)) ||
(dev_vend == DEVVEND(ROMEO_VENDORID, ROMEO_DEVICEID2))) {
return(addr);
}
}
}
}
return((ULONG)-1);
}
BRESULT juliet_prepare(void) {
ULONG pciaddr;
if (romeo.mod == NULL) {
return(FAILURE);
}
pciaddr = searchRomeo();
if (pciaddr != (ULONG)-1) {
romeo.addr = romeo.read32(pciaddr, ROMEO_BASEADDRESS1);
romeo.irq = romeo.read32(pciaddr, ROMEO_PCIINTERRUPT) & 0xff;
if (romeo.addr) {
romeo.avail = ROMEO_AVAIL | ROMEO_YMF288;
juliet_YM2151Reset();
juliet_YMF288Reset();
}
return(SUCCESS);
}
return(FAILURE);
}
// ---- YM2151部
static void YM2151W(UINT8 addr, UINT8 data) {
// 書き込み直後だと、ROMEOチップでの遅延のため、まだ書き込みが起こっていないBusyが
// 立っていない可能性がある。ので、Snoopカウンタで書き込み発生を見張る
while ( romeo.snoopcount==romeo.in32(romeo.addr + ROMEO_SNOOPCTRL) ) Sleep(0);
romeo.snoopcount = romeo.in32(romeo.addr + ROMEO_SNOOPCTRL);
// カウンタ増えた時点ではまだBusyの可能性があるので、OPMのBusyも見張る
while ( romeo.in8(romeo.addr + ROMEO_YM2151DATA)&0x80 ) Sleep(0);
romeo.out8(romeo.addr + ROMEO_YM2151ADDR, addr);
romeo.in8(romeo.addr + ROMEO_YM2151DATA);
romeo.out8(romeo.addr + ROMEO_YM2151DATA, data);
}
static void YM2151setvolume(UINT8 ch, int vol) {
UINT8 mask;
int ttl;
ch &= 7;
mask = romeo.ym2151.op[ch];
do {
if (mask & 1) {
ttl = romeo.ym2151.ttl[ch] & 0x7f;
ttl -= vol;
if (ttl < 0) {
ttl = 0;
}
else if (ttl > 0x7f) {
ttl = 0x7f;
}
YM2151W(ch + 0x60, (UINT8)ttl);
}
ch += 0x08;
mask >>= 1;
} while(mask);
}
// リセットと同時に、OPMチップの有無も確認
void juliet_YM2151Reset(void) {
BYTE flag;
if (romeo.avail & ROMEO_AVAIL) {
juliet_YM2151Enable(FALSE);
romeo.out32(romeo.addr + ROMEO_YM2151CTRL, 0x00);
Sleep(10); // 44.1kHz x 192 clk = 4.35ms 以上ないと、DACのリセットかからない
flag = romeo.in8(romeo.addr + ROMEO_YM2151DATA) + 1;
romeo.out32(romeo.addr + ROMEO_YM2151CTRL, 0x80);
Sleep(10); // リセット解除後、一応安定するまでちょっと待つ
flag |= romeo.in8(romeo.addr + ROMEO_YM2151DATA);
if ( !flag ) { // flag!=0 だと OPM チップがない
romeo.avail |= ROMEO_YM2151;
// Busy検出用にSnoopカウンタを使う
romeo.out32(romeo.addr + ROMEO_SNOOPCTRL, (unsigned int)0x80000000);
romeo.snoopcount = 0xffffffff;
}
}
}
BOOL juliet_YM2151IsEnable(void) {
return((romeo.avail & ROMEO_YM2151) != 0);
}
BOOL juliet_YM2151IsBusy(void) {
BOOL ret;
ret = FALSE;
if (romeo.avail & ROMEO_YM2151) {
if ((romeo.snoopcount == romeo.in32(romeo.addr + ROMEO_SNOOPCTRL)) ||
(romeo.in8(romeo.addr + ROMEO_YM2151DATA) & 0x80)) {
ret = TRUE;
}
}
return(ret);
}
void juliet_YM2151W(UINT8 addr, UINT8 data) {
UINT ch;
int ttl;
UINT8 mask;
if (romeo.avail & ROMEO_YM2151) {
if ((addr & 0xe0) == 0x60) { // ttl
romeo.ym2151.ttl[addr & 0x1f] = data;
if (romeo.ym2151.op[addr & 7] & (1 << ((addr >> 3) & 3))) {
ttl = (data & 0x7f) - YM2151vol;
if (ttl < 0) {
ttl = 0;
}
else if (ttl > 0x7f) {
ttl = 0x7f;
}
data = (UINT8)ttl;
}
}
else if ((addr & 0xf8) == 0x20) { // algorithm
ch = addr & 7;
mask = opmask[data & 7];
if (romeo.ym2151.op[ch] != mask) {
romeo.ym2151.op[ch] = mask;
YM2151setvolume((UINT8)ch, YM2151vol);
}
}
YM2151W(addr, data);
}
}
void juliet_YM2151Enable(BOOL enable) {
UINT8 ch;
int vol;
if (romeo.avail & ROMEO_YM2151) {
vol = (enable)?YM2151vol:-127;
for (ch=0; ch<8; ch++) {
YM2151setvolume(ch, vol);
}
}
}
// ---- YMF288部
static void YMF288W(UINT8 a1, UINT8 addr, UINT8 data) {
while(romeo.in8(romeo.addr + ROMEO_YMF288ADDR1) & 0x80) {
Sleep(0);
}
romeo.out8(romeo.addr + (a1?ROMEO_YMF288ADDR2:ROMEO_YMF288ADDR1), addr);
while(romeo.in8(romeo.addr + ROMEO_YMF288ADDR1) & 0x80) {
Sleep(0);
}
romeo.out8(romeo.addr + (a1?ROMEO_YMF288DATA2:ROMEO_YMF288DATA1), data);
}
static void YMF288setvolume(UINT ch, int vol) {
UINT8 a1;
UINT8 mask;
const UINT8 *pttl;
int ttl;
a1 = ch & 4;
mask = opmask[romeo.ymf288.algo[ch & 7] & 7];
pttl = romeo.ymf288.ttl + ((ch & 4) << 2);
ch = 0x40 + (ch & 3);
do {
if (mask & 1) {
ttl = pttl[ch & 0x0f] & 0x7f;
ttl -= vol;
if (ttl < 0) {
ttl = 0;
}
else if (ttl > 0x7f) {
ttl = 0x7f;
}
YMF288W(a1, ch, (UINT8)ttl);
}
ch += 0x04;
mask >>= 1;
} while(mask);
}
void juliet_YMF288Reset(void) {
if (romeo.avail & ROMEO_YMF288) {
juliet_YMF288Enable(FALSE);
romeo.out32(romeo.addr + ROMEO_YMF288CTRL, 0x00);
Sleep(150);
romeo.out32(romeo.addr + ROMEO_YMF288CTRL, 0x80);
Sleep(150);
}
}
BOOL juliet_YMF288IsEnable(void) {
return((romeo.avail & ROMEO_YMF288) != 0);
}
BOOL juliet_YMF288IsBusy(void) {
return((!(romeo.avail & ROMEO_YMF288)) ||
((romeo.in8(romeo.addr + ROMEO_YMF288ADDR1) & 0x80) != 0));
}
void juliet_YMF288A(UINT8 addr, UINT8 data) {
if (romeo.avail & ROMEO_YMF288) {
if (addr == 0x07) { // psg mix
romeo.ymf288.psgmix = data;
}
else if ((addr & 0xf0) == 0x40) { // ttl
romeo.ymf288.ttl[addr & 0x0f] = data;
}
else if ((addr & 0xfc) == 0xb0) { // algorithm
romeo.ymf288.algo[addr & 3] = data;
}
YMF288W(0, addr, data);
}
}
void juliet_YMF288B(UINT8 addr, UINT8 data) {
if (romeo.avail & ROMEO_YMF288) {
if ((addr & 0xf0) == 0x40) { // ttl
romeo.ymf288.ttl[0x10 + (addr & 0x0f)] = data;
}
else if ((addr & 0xfc) == 0xb0) { // algorithm
romeo.ymf288.algo[4 + (addr & 3)] = data;
}
YMF288W(1, addr, data);
}
}
void juliet_YMF288Enable(BOOL enable) {
UINT8 ch;
int vol;
if (romeo.avail & ROMEO_YMF288) {
YMF288W(0, 0x07, (enable)?romeo.ymf288.psgmix:0x3f);
vol = (enable)?0:-127;
for (ch=0; ch<3; ch++) {
YMF288setvolume(ch + 0, vol);
YMF288setvolume(ch + 4, vol);
}
}
}
#if 0
// ---- delay...
#define FM_BUFBIT 10
#define FM_BUFFERS (1 << FM_BUFBIT)
typedef struct {
DWORD clock;
DWORD data;
} FMRINGDATA;
typedef struct {
DWORD base;
DWORD pos;
DWORD avail;
DWORD maxclock;
FMRINGDATA datas[FM_BUFFERS];
} FMRING;
static FMRING fmr;
#ifdef __cplusplus
extern "C" {
#endif
DWORD basedclk = 0;
#ifdef __cplusplus
}
#endif
static void (*sendfmfn[3])(BYTE addr, BYTE data) =
{juliet_YM2151W, juliet_YMF288A, juliet_YMF288B};
LABEL static void fmr_release(void) {
__asm {
dec fmr.avail
mov edx, fmr.pos
mov eax, fmr.datas.data[edx * 8]
inc edx
and edx, (FM_BUFFERS - 1);
mov fmr.pos, edx
push eax
shr eax, 8
push eax
shr eax, 8
call sendfmfn[eax*4]
add esp, 8
ret
}
}
LABEL static void fmr_send(DWORD clock, DWORD data) {
__asm {
mov ecx, fmr.avail
cmp ecx, FM_BUFFERS
jne short fmdatasend
call fmr_release
dec ecx
fmdatasend: add ecx, fmr.pos
and ecx, (FM_BUFFERS - 1);
mov eax, fmr.base
add eax, [esp + 4]
mov fmr.datas.clock[ecx * 8], eax
mov eax, [esp + 8]
mov fmr.datas.data[ecx * 8], eax
inc fmr.avail
ret
}
}
#define _CPUID __asm _emit 00fh __asm _emit 0a2h
#define _RDTSC __asm _emit 00fh __asm _emit 031h
#define RDTSC_SFT 6
LABEL void juliet2_reset(void) {
__asm {
push ebx
push esi
push edi
mov ecx, (type fmr) / 4
xor eax, eax
mov edi, offset fmr
rep stosd
pushfd
pop edx
mov edi, edx
xor edx, 00200000h
push edx
popfd
pushfd
pop edx
cmp edi, edx
je short jul2reset_exit
inc eax
_CPUID
xor eax, eax
test edx, 10h
je short jul2reset_exit
push 100
mov edi, dword ptr Sleep
_CPUID
_RDTSC
mov esi, edx
xchg edi, eax
call eax
_CPUID
_RDTSC
sub eax, edi
sbb edx, esi
shrd eax, edx, RDTSC_SFT
mov fmr.maxclock, eax
jul2reset_exit: xor eax, eax
mov basedclk, eax
pop edi
pop esi
pop ebx
ret
}
}
LABEL void juliet2_sync(DWORD delaytick) {
__asm {
_RDTSC
shrd eax, edx, RDTSC_SFT
mov fmr.base, eax
mov eax, [esp+4]
mul basedclk
mov ecx, 100
div ecx
add fmr.base, eax
ret
}
}
LABEL void juliet2_exec(void) {
__asm {
cmp fmr.avail, 0
je jul2exe_exit
jul2exe: _RDTSC
shrd eax, edx, RDTSC_SFT
neg eax
mov edx, fmr.pos
add eax, fmr.datas[edx * 8].clock
cmp eax, fmr.maxclock
jb jul2exe_exit
call fmr_release
cmp fmr.avail, 0
jne short jul2exe
jul2exe_exit: ret
}
}
void juliet2_YM2151W(BYTE addr, BYTE data, DWORD clock) {
if (romeo.avail & ROMEO_YM2151) {
if (basedclk) {
fmr_send(clock, (addr << 8) | data);
}
else {
juliet_YM2151W(addr, data);
}
}
}
void juliet2_YMF288A(BYTE addr, BYTE data, DWORD clock) {
if (romeo.avail & ROMEO_YMF288) {
if (basedclk) {
fmr_send(clock, 0x10000 | (addr << 8) | data);
}
else {
juliet_YMF288A(addr, data);
}
}
}
void juliet2_YMF288B(BYTE addr, BYTE data, DWORD clock) {
if (romeo.avail & ROMEO_YMF288) {
if (basedclk) {
fmr_send(clock, 0x20000 | (addr << 8) | data);
}
else {
juliet_YMF288B(addr, data);
}
}
}
#endif

View File

@ -1,34 +0,0 @@
#ifdef __cplusplus
extern "C" {
#endif
BOOL juliet_load(void);
void juliet_unload(void);
BRESULT juliet_prepare(void);
void juliet_YM2151Reset(void);
BOOL juliet_YM2151IsEnable(void);
BOOL juliet_YM2151IsBusy(void);
void juliet_YM2151W(UINT8 addr, UINT8 data);
void juliet_YM2151Enable(BOOL enable);
void juliet_YMF288Reset(void);
BOOL juliet_YMF288IsEnable(void);
BOOL juliet_YMF288IsBusy(void);
void juliet_YMF288A(UINT8 addr, UINT8 data);
void juliet_YMF288B(UINT8 addr, UINT8 data);
void juliet_YMF288Enable(BOOL enable);
void juliet2_reset(void);
void juliet2_sync(DWORD delayclock);
void juliet2_exec(void);
void juliet2_YM2151W(BYTE addr, BYTE data, DWORD clock);
void juliet2_YMF288A(BYTE addr, BYTE data, DWORD clock);
void juliet2_YMF288B(BYTE addr, BYTE data, DWORD clock);
#ifdef __cplusplus
}
#endif

View File

@ -1,59 +0,0 @@
#ifndef _ROMEO_ROMEO_H
#define _ROMEO_ROMEO_H
#define ROMEO_VENDORID 0x6809
#define ROMEO_DEVICEID 0x2151
#define ROMEO_DEVICEID2 0x8121 /* for Developer version */
enum {
PCIERR_SUCCESS = 0x00,
PCIERR_INVALIDCLASS = 0x83,
PCIERR_DEVNOTFOUND = 0x86
};
enum {
ROMEO_DEVICE_VENDOR = 0x00,
ROMEO_STATUS_COMMAND = 0x04,
ROMEO_CLASS_REVISON = 0x08,
ROMEO_HEADTYPE = 0x0c,
ROMEO_BASEADDRESS0 = 0x10,
ROMEO_BASEADDRESS1 = 0x14,
ROMEO_SUB_DEVICE_VENDOR = 0x2c,
ROMEO_PCIINTERRUPT = 0x3c
};
enum {
ROMEO_YM2151ADDR = 0x0000,
ROMEO_YM2151DATA = 0x0004,
ROMEO_SNOOPCTRL = 0x0010,
ROMEO_CMDQUEUE = 0x0018,
ROMEO_YM2151CTRL = 0x001c,
ROMEO_YMF288ADDR1 = 0x0100,
ROMEO_YMF288DATA1 = 0x0104,
ROMEO_YMF288ADDR2 = 0x0108,
ROMEO_YMF288DATA2 = 0x010c,
ROMEO_YMF288CTRL = 0x011c
};
#define PCIDEBUG_DLL "pcidebug.dll"
typedef ULONG (WINAPI *PCIFINDDEV)(ULONG ven, ULONG dev, ULONG index);
typedef ULONG (WINAPI *PCICFGREAD32)(ULONG pciaddr, ULONG regaddr);
typedef void (WINAPI *PCIMEMWR8)(ULONG addr, UCHAR param);
typedef void (WINAPI *PCIMEMWR16)(ULONG addr, USHORT param);
typedef void (WINAPI *PCIMEMWR32)(ULONG addr, ULONG param);
typedef UCHAR (WINAPI *PCIMEMRD8)(ULONG addr);
typedef USHORT (WINAPI *PCIMEMRD16)(ULONG addr);
typedef ULONG (WINAPI *PCIMEMRD32)(ULONG addr);
#define FN_PCIFINDDEV "_pciFindPciDevice"
#define FN_PCICFGREAD32 "_pciConfigReadLong"
#define FN_PCIMEMWR8 "_MemWriteChar"
#define FN_PCIMEMWR16 "_MemWriteShort"
#define FN_PCIMEMWR32 "_MemWriteLong"
#define FN_PCIMEMRD8 "_MemReadChar"
#define FN_PCIMEMRD16 "_MemReadShort"
#define FN_PCIMEMRD32 "_MemReadLong"
#endif /* _ROMEO_ROMEO_H */

View File

@ -1,162 +0,0 @@
#include "compiler.h"
#include "joymng.h"
#include "pccore.h"
#include "iocore.h"
#include "keystat.h"
#include "sound.h"
#include "sndctrl.h"
#include "x1f.h"
#include "romeo\juliet.h"
static BOOL romeo_exist;
static const UINT8 psggen_deftbl[0x10] =
{0, 0, 0, 0, 0, 0, 0, 0xbf, 0, 0, 0, 0, 0, 0, 0xff, 0xff};
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
void IOOUTCALL opm_o(UINT port, REG8 dat) {
REG8 lsb;
REG8 reg;
lsb = (UINT8)port;
if (lsb == 0x00) { /* 0700 */
sndboard.opmreg = (UINT8)dat;
}
else if (lsb == 0x01) { /* 0701 */
reg = sndboard.opmreg;
sndboard.opmdat[reg] = dat;
x1f_opm(reg, dat);
#if !defined(DISABLE_SOUND)
if (romeo_exist) {
juliet_YM2151W(reg, dat);
}
else {
opmgen_setreg(&g_opmgen, reg, dat);
}
#endif
}
else if ((lsb & (~3)) == 0x04) { /* 0704-0707 */
ctc_o(port, dat);
}
}
REG8 IOINPCALL opm_i(UINT port) {
REG8 lsb;
lsb = (UINT8)port;
if ((lsb & (~1)) == 0x00) { /* 0700/0701 */
return(0x00); /* ƒ[ƒŠƒA<C692>[ƒh */
}
else if ((lsb & (~3)) == 0x04) { /* 0704-0707 */
return(ctc_i(port));
}
else {
return(0xff);
}
}
#endif
void IOOUTCALL sndboard_psgreg(UINT port, REG8 dat) {
sndboard.psgreg = dat;
(void)port;
}
void IOOUTCALL sndboard_psgdat(UINT port, REG8 dat) {
REG8 reg;
reg = sndboard.psgreg;
if (reg < 0x0e) {
sndboard.psgdat[reg] = dat;
x1f_psg(reg, dat);
#if !defined(DISABLE_SOUND)
if (romeo_exist) {
juliet_YMF288A(reg, dat);
}
else {
psggen_setreg(&psggen, reg, dat);
}
#endif
}
(void)port;
}
REG8 IOINPCALL sndboard_psgsta(UINT port) {
REG8 ret;
if (sndboard.psgreg < 0x0e) {
return(sndboard.psgdat[sndboard.psgreg]);
}
else if (sndboard.psgreg < 0x10) {
ret = 0xff;
if (sndboard.psgreg == (xmilcfg.KEY_MODE + 0x0d)) {
ret &= keystat_getjoy();
}
if (sndboard.psgreg == 0x0e) {
ret &= joymng_getstat();
}
if (xmilcfg.BTN_RAPID) {
sndboard.rapids ^= 0x60;
ret |= sndboard.rapids;
}
if (xmilcfg.BTN_MODE) {
ret = (ret & (~0x60)) | ((ret & 0x40) >> 1) | ((ret & 0x20) << 1);
}
return(ret);
}
else {
(void)port;
return(0xff);
}
}
/* reset */
#if !defined(DISABLE_SOUND)
void sndboard_update(void) {
UINT i;
if (romeo_exist) {
for (i=0; i<14; i++) {
juliet_YMF288A((REG8)i, sndboard.psgdat[i]);
}
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
for (i=0x20; i<0x100; i++) {
juliet_YM2151W((REG8)i, sndboard.opmdat[i]);
}
#endif
}
else {
for (i=0; i<14; i++) {
psggen_setreg(&psggen, (REG8)i, sndboard.psgdat[i]);
}
#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM)
for (i=0x20; i<0x100; i++) {
opmgen_setreg(&g_opmgen, (REG8)i, sndboard.opmdat[i]);
}
#endif
}
}
#endif
void sndboard_reset(void) {
ZeroMemory(&sndboard, sizeof(sndboard));
CopyMemory(sndboard.psgdat, psggen_deftbl, sizeof(psggen_deftbl));
romeo_exist = juliet_YM2151IsEnable();
if (romeo_exist) {
juliet_YM2151Reset();
juliet_YMF288Reset();
}
else {
sndctrl_reset();
}
}

View File

@ -13,7 +13,6 @@
#include "winkbd.h"
#include "menu.h"
#include "ini.h"
#include "ext\romeo\juliet.h"
#include "dialog.h"
#include "extclass.h"
#include "misc\wndloc.h"
@ -898,9 +897,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,
}
}
juliet_load();
juliet_prepare();
// juliet2_reset();
if (soundmng_initialize() == SUCCESS) {
#if !defined(DISABLE_SOUND)
soundmng_pcmload(SOUND_PCMSEEK, OEMTEXT("fddseek.wav"), 0);
@ -1014,10 +1010,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,
soundmng_deinitialize();
juliet_YM2151Reset();
juliet_YMF288Reset();
juliet_unload();
scrnmng_destroy();
if (sys_updates & (SYS_UPDATECFG | SYS_UPDATEOSCFG)) {

View File

@ -636,7 +636,7 @@ SOURCE=..\IO\SIO.C
# End Source File
# Begin Source File
SOURCE=.\ext\sndboard.cpp
SOURCE=..\IO\SNDBOARD.C
# End Source File
# Begin Source File
@ -712,6 +712,14 @@ SOURCE=..\VRAM\VRAM.C
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\sound\opm.c
# End Source File
# Begin Source File
SOURCE=..\sound\opm.h
# End Source File
# Begin Source File
SOURCE=..\sound\opmgen.h
# End Source File
# Begin Source File
@ -775,6 +783,14 @@ InputName=opmgeng
# End Source File
# Begin Source File
SOURCE=..\sound\psg.c
# End Source File
# Begin Source File
SOURCE=..\sound\psg.h
# End Source File
# Begin Source File
SOURCE=..\sound\psggen.h
# End Source File
# Begin Source File
@ -888,22 +904,6 @@ SOURCE=.\DIALOG\EXTCLASS.CPP
# Begin Group "ext"
# PROP Default_Filter ""
# Begin Group "romeo"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\ext\romeo\juliet.cpp
# End Source File
# Begin Source File
SOURCE=.\ext\romeo\juliet.h
# End Source File
# Begin Source File
SOURCE=.\ext\romeo\romeo.h
# End Source File
# End Group
# End Group
# Begin Group "misc"