mirror of
https://github.com/joncampbell123/dosbox-x.git
synced 2025-05-08 19:32:39 +08:00
psggen re-port
This commit is contained in:
parent
2149d4cb86
commit
8c691c9d07
@ -62,8 +62,11 @@ typedef void* NEVENTITEM;
|
||||
#define OEMTEXT(x) (x)
|
||||
#define SOUNDCALL
|
||||
|
||||
#define LOADINTELWORD(x) host_readw((HostPt)(x))
|
||||
#define STOREINTELWORD(x,y) host_writew((HostPt)(x),(y))
|
||||
//#define LOADINTELWORD(x) host_readw((HostPt)(x))
|
||||
//#define STOREINTELWORD(x,y) host_writew((HostPt)(x),(y))
|
||||
|
||||
#define LOADINTELWORD(x) ( *((uint16_t*)(&(x))) )
|
||||
#define STOREINTELWORD(x,y) *((uint16_t*)(&(x))) = (y)
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
@ -212,3 +215,11 @@ extern NP2CFG pccore;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef reg
|
||||
#undef reg
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src/aviwriter -I$(top_srcdir)/src/hardware/snd_pc98/sound
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src/aviwriter -I$(top_srcdir)/src/hardware/snd_pc98/sound -I$(top_srcdir)/src/hardware/snd_pc98/common -I$(top_srcdir)/src/hardware/snd_pc98/generic
|
||||
|
||||
SUBDIRS = serialport parport reSID
|
||||
|
||||
@ -14,5 +14,6 @@ libhardware_a_SOURCES = adlib.cpp dma.cpp gameblaster.cpp hardware.cpp iohandler
|
||||
cmos.cpp disney.cpp gus.cpp mpu401.cpp ipx.cpp ipxserver.cpp ne2000.cpp hardopl.cpp dbopl.cpp innova.cpp dongle.cpp \
|
||||
voodoo.cpp voodoo_interface.cpp voodoo_emu.cpp ps1_sound.cpp sn76496.h ide.cpp floppy.cpp voodoo_vogl.cpp voodoo_opengl.cpp nukedopl.cpp pc98.cpp vga_pc98_gdc.cpp vga_pc98_dac.cpp vga_pc98_crtc.cpp vga_pc98_cg.cpp vga_pc98_egc.cpp pc98_fm.cpp \
|
||||
snd_pc98/sound/opngenc.c snd_pc98/sound/opngeng.c snd_pc98/sound/pcm86c.c snd_pc98/sound/pcm86g.c \
|
||||
snd_pc98/sound/tms3631c.c snd_pc98/sound/tms3631g.c
|
||||
snd_pc98/sound/tms3631c.c snd_pc98/sound/tms3631g.c snd_pc98/sound/psggenc.c snd_pc98/sound/psggeng.c \
|
||||
snd_pc98/common/parts.c
|
||||
|
||||
|
@ -124,7 +124,10 @@ am_libhardware_a_OBJECTS = adlib.$(OBJEXT) dma.$(OBJEXT) \
|
||||
snd_pc98/sound/pcm86c.$(OBJEXT) \
|
||||
snd_pc98/sound/pcm86g.$(OBJEXT) \
|
||||
snd_pc98/sound/tms3631c.$(OBJEXT) \
|
||||
snd_pc98/sound/tms3631g.$(OBJEXT)
|
||||
snd_pc98/sound/tms3631g.$(OBJEXT) \
|
||||
snd_pc98/sound/psggenc.$(OBJEXT) \
|
||||
snd_pc98/sound/psggeng.$(OBJEXT) \
|
||||
snd_pc98/common/parts.$(OBJEXT)
|
||||
libhardware_a_OBJECTS = $(am_libhardware_a_OBJECTS)
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||
@ -345,7 +348,7 @@ target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src/aviwriter -I$(top_srcdir)/src/hardware/snd_pc98/sound
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src/aviwriter -I$(top_srcdir)/src/hardware/snd_pc98/sound -I$(top_srcdir)/src/hardware/snd_pc98/common -I$(top_srcdir)/src/hardware/snd_pc98/generic
|
||||
SUBDIRS = serialport parport reSID
|
||||
EXTRA_DIST = opl.cpp opl.h adlib.h dbopl.h pci_devices.h voodoo_types.h voodoo_def.h voodoo_data.h \
|
||||
voodoo_interface.h voodoo_emu.h voodoo_vogl.h voodoo_opengl.h
|
||||
@ -358,7 +361,8 @@ libhardware_a_SOURCES = adlib.cpp dma.cpp gameblaster.cpp hardware.cpp iohandler
|
||||
cmos.cpp disney.cpp gus.cpp mpu401.cpp ipx.cpp ipxserver.cpp ne2000.cpp hardopl.cpp dbopl.cpp innova.cpp dongle.cpp \
|
||||
voodoo.cpp voodoo_interface.cpp voodoo_emu.cpp ps1_sound.cpp sn76496.h ide.cpp floppy.cpp voodoo_vogl.cpp voodoo_opengl.cpp nukedopl.cpp pc98.cpp vga_pc98_gdc.cpp vga_pc98_dac.cpp vga_pc98_crtc.cpp vga_pc98_cg.cpp vga_pc98_egc.cpp pc98_fm.cpp \
|
||||
snd_pc98/sound/opngenc.c snd_pc98/sound/opngeng.c snd_pc98/sound/pcm86c.c snd_pc98/sound/pcm86g.c \
|
||||
snd_pc98/sound/tms3631c.c snd_pc98/sound/tms3631g.c
|
||||
snd_pc98/sound/tms3631c.c snd_pc98/sound/tms3631g.c snd_pc98/sound/psggenc.c snd_pc98/sound/psggeng.c \
|
||||
snd_pc98/common/parts.c
|
||||
|
||||
all: all-recursive
|
||||
|
||||
@ -415,6 +419,18 @@ snd_pc98/sound/tms3631c.$(OBJEXT): snd_pc98/sound/$(am__dirstamp) \
|
||||
snd_pc98/sound/$(DEPDIR)/$(am__dirstamp)
|
||||
snd_pc98/sound/tms3631g.$(OBJEXT): snd_pc98/sound/$(am__dirstamp) \
|
||||
snd_pc98/sound/$(DEPDIR)/$(am__dirstamp)
|
||||
snd_pc98/sound/psggenc.$(OBJEXT): snd_pc98/sound/$(am__dirstamp) \
|
||||
snd_pc98/sound/$(DEPDIR)/$(am__dirstamp)
|
||||
snd_pc98/sound/psggeng.$(OBJEXT): snd_pc98/sound/$(am__dirstamp) \
|
||||
snd_pc98/sound/$(DEPDIR)/$(am__dirstamp)
|
||||
snd_pc98/common/$(am__dirstamp):
|
||||
@$(MKDIR_P) snd_pc98/common
|
||||
@: > snd_pc98/common/$(am__dirstamp)
|
||||
snd_pc98/common/$(DEPDIR)/$(am__dirstamp):
|
||||
@$(MKDIR_P) snd_pc98/common/$(DEPDIR)
|
||||
@: > snd_pc98/common/$(DEPDIR)/$(am__dirstamp)
|
||||
snd_pc98/common/parts.$(OBJEXT): snd_pc98/common/$(am__dirstamp) \
|
||||
snd_pc98/common/$(DEPDIR)/$(am__dirstamp)
|
||||
|
||||
libhardware.a: $(libhardware_a_OBJECTS) $(libhardware_a_DEPENDENCIES) $(EXTRA_libhardware_a_DEPENDENCIES)
|
||||
$(AM_V_at)-rm -f libhardware.a
|
||||
@ -423,6 +439,7 @@ libhardware.a: $(libhardware_a_OBJECTS) $(libhardware_a_DEPENDENCIES) $(EXTRA_li
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
-rm -f snd_pc98/common/*.$(OBJEXT)
|
||||
-rm -f snd_pc98/sound/*.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
@ -484,10 +501,13 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/voodoo_interface.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/voodoo_opengl.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/voodoo_vogl.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@snd_pc98/common/$(DEPDIR)/parts.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@snd_pc98/sound/$(DEPDIR)/opngenc.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@snd_pc98/sound/$(DEPDIR)/opngeng.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@snd_pc98/sound/$(DEPDIR)/pcm86c.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@snd_pc98/sound/$(DEPDIR)/pcm86g.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@snd_pc98/sound/$(DEPDIR)/psggenc.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@snd_pc98/sound/$(DEPDIR)/psggeng.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@snd_pc98/sound/$(DEPDIR)/tms3631c.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@snd_pc98/sound/$(DEPDIR)/tms3631g.Po@am__quote@
|
||||
|
||||
@ -708,6 +728,8 @@ clean-generic:
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
-rm -f snd_pc98/common/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f snd_pc98/common/$(am__dirstamp)
|
||||
-rm -f snd_pc98/sound/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f snd_pc98/sound/$(am__dirstamp)
|
||||
|
||||
@ -719,7 +741,7 @@ clean: clean-recursive
|
||||
clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
|
||||
|
||||
distclean: distclean-recursive
|
||||
-rm -rf ./$(DEPDIR) snd_pc98/sound/$(DEPDIR)
|
||||
-rm -rf ./$(DEPDIR) snd_pc98/common/$(DEPDIR) snd_pc98/sound/$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
@ -765,7 +787,7 @@ install-ps-am:
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-recursive
|
||||
-rm -rf ./$(DEPDIR) snd_pc98/sound/$(DEPDIR)
|
||||
-rm -rf ./$(DEPDIR) snd_pc98/common/$(DEPDIR) snd_pc98/sound/$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
|
@ -176,17 +176,6 @@ void rhythm_setreg(RHYTHM rhy, UINT reg, REG8 val);
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void psggen_initialize(UINT rate);
|
||||
void psggen_setvol(UINT vol);
|
||||
|
||||
void psggen_reset(PSGGEN psg);
|
||||
void psggen_restore(PSGGEN psg);
|
||||
void psggen_setreg(PSGGEN psg, UINT reg, REG8 val);
|
||||
REG8 psggen_getreg(PSGGEN psg, UINT reg);
|
||||
void psggen_setpan(PSGGEN psg, UINT ch, REG8 pan);
|
||||
|
||||
void SOUNDCALL psggen_getpcm(PSGGEN psg, SINT32 *pcm, UINT count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@ -430,8 +419,6 @@ extern OPNCFG opncfg;
|
||||
|
||||
static KEYDISP keydisp;
|
||||
|
||||
PSGGENCFG psggencfg;
|
||||
|
||||
static const void *psgtbl[3] = {&psg1, &psg2, &psg3};
|
||||
|
||||
static void delaysetevent(UINT8 ch, UINT8 key);
|
||||
@ -507,26 +494,6 @@ void keydisp_psgmix(void *psg) {
|
||||
}
|
||||
|
||||
|
||||
static const UINT8 psggen_deftbl[0x10] =
|
||||
{0, 0, 0, 0, 0, 0, 0, 0xbf, 0, 0, 0, 0, 0, 0, 0xff, 0xff};
|
||||
|
||||
static const UINT8 psgenv_pat[16] = {
|
||||
PSGENV_ONESHOT,
|
||||
PSGENV_ONESHOT,
|
||||
PSGENV_ONESHOT,
|
||||
PSGENV_ONESHOT,
|
||||
PSGENV_ONESHOT | PSGENV_INC,
|
||||
PSGENV_ONESHOT | PSGENV_INC,
|
||||
PSGENV_ONESHOT | PSGENV_INC,
|
||||
PSGENV_ONESHOT | PSGENV_INC,
|
||||
PSGENV_ONECYCLE,
|
||||
PSGENV_ONESHOT,
|
||||
0,
|
||||
PSGENV_ONESHOT | PSGENV_LASTON,
|
||||
PSGENV_ONECYCLE | PSGENV_INC,
|
||||
PSGENV_ONESHOT | PSGENV_INC | PSGENV_LASTON,
|
||||
PSGENV_INC,
|
||||
PSGENV_ONESHOT | PSGENV_INC};
|
||||
|
||||
static void psgvol(UINT8 ch, PSGGEN psg, UINT8 i) {
|
||||
|
||||
@ -559,61 +526,6 @@ static void psgkeyreset(void) {
|
||||
ZeroMemory(keydisp.psgctl, sizeof(keydisp.psgctl));
|
||||
}
|
||||
|
||||
|
||||
void psggen_initialize(UINT rate) {
|
||||
|
||||
double pom;
|
||||
UINT i;
|
||||
|
||||
ZeroMemory(&psggencfg, sizeof(psggencfg));
|
||||
psggencfg.rate = rate;
|
||||
pom = (double)0x0c00;
|
||||
for (i=15; i; i--) {
|
||||
psggencfg.voltbl[i] = (SINT32)pom;
|
||||
pom /= 1.41492;
|
||||
}
|
||||
psggencfg.puchidec = (UINT16)(rate / 11025) * 2;
|
||||
if (psggencfg.puchidec == 0) {
|
||||
psggencfg.puchidec = 1;
|
||||
}
|
||||
if (rate) {
|
||||
psggencfg.base = (5000 * (1 << (32 - PSGFREQPADBIT - PSGADDEDBIT)))
|
||||
/ (rate / 25);
|
||||
}
|
||||
}
|
||||
|
||||
void psggen_setvol(UINT vol) {
|
||||
|
||||
UINT i;
|
||||
|
||||
for (i=1; i<16; i++) {
|
||||
psggencfg.volume[i] = (psggencfg.voltbl[i] * vol) >>
|
||||
(6 + PSGADDEDBIT);
|
||||
}
|
||||
}
|
||||
|
||||
void psggen_reset(PSGGEN psg) {
|
||||
|
||||
UINT i;
|
||||
|
||||
ZeroMemory(psg, sizeof(_PSGGEN));
|
||||
for (i=0; i<3; i++) {
|
||||
psg->tone[i].pvol = psggencfg.volume + 0;
|
||||
}
|
||||
for (i=0; i<sizeof(psggen_deftbl); i++) {
|
||||
psggen_setreg(psg, i, psggen_deftbl[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void psggen_restore(PSGGEN psg) {
|
||||
|
||||
UINT i;
|
||||
|
||||
for (i=0; i<0x0e; i++) {
|
||||
psggen_setreg(psg, i, ((UINT8 *)&psg->reg)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void keydisp_psgvol(void *psg, UINT8 ch) {
|
||||
|
||||
UINT8 c;
|
||||
@ -629,95 +541,6 @@ void keydisp_psgvol(void *psg, UINT8 ch) {
|
||||
}
|
||||
}
|
||||
|
||||
void psggen_setreg(PSGGEN psg, UINT reg, REG8 value) {
|
||||
|
||||
UINT ch;
|
||||
UINT freq;
|
||||
|
||||
reg = reg & 15;
|
||||
if (reg < 14) {
|
||||
sound_sync();
|
||||
}
|
||||
((UINT8 *)&psg->reg)[reg] = value;
|
||||
switch(reg) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
ch = reg >> 1;
|
||||
freq = LOADINTELWORD(psg->reg.tune[ch]) & 0xfff;
|
||||
if (freq > 9) {
|
||||
psg->tone[ch].freq = (psggencfg.base / freq) << PSGFREQPADBIT;
|
||||
}
|
||||
else {
|
||||
psg->tone[ch].freq = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 6:
|
||||
freq = value & 0x1f;
|
||||
if (freq == 0) {
|
||||
freq = 1;
|
||||
}
|
||||
psg->noise.freq = psggencfg.base / freq;
|
||||
psg->noise.freq <<= PSGFREQPADBIT;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
keydisp_psgmix(psg);
|
||||
psg->mixer = ~value;
|
||||
psg->puchicount = psggencfg.puchidec;
|
||||
// TRACEOUT(("psg %x 7 %d", (long)psg, value));
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
ch = reg - 8;
|
||||
keydisp_psgvol(psg, (UINT8)ch);
|
||||
if (value & 0x10) {
|
||||
psg->tone[ch].pvol = &psg->evol;
|
||||
}
|
||||
else {
|
||||
psg->tone[ch].pvol = psggencfg.volume + (value & 15);
|
||||
}
|
||||
psg->tone[ch].puchi = psggencfg.puchidec;
|
||||
psg->puchicount = psggencfg.puchidec;
|
||||
// TRACEOUT(("psg %x %x %d", (long)psg, reg, value));
|
||||
break;
|
||||
|
||||
case 11:
|
||||
case 12:
|
||||
freq = LOADINTELWORD(psg->reg.envtime);
|
||||
freq = psggencfg.rate * freq / 125000;
|
||||
if (freq == 0) {
|
||||
freq = 1;
|
||||
}
|
||||
psg->envmax = freq;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
psg->envmode = psgenv_pat[value & 0x0f];
|
||||
psg->envvolcnt = 16;
|
||||
psg->envcnt = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
REG8 psggen_getreg(PSGGEN psg, UINT reg) {
|
||||
|
||||
return(((UINT8 *)&psg->reg)[reg & 15]);
|
||||
}
|
||||
|
||||
void psggen_setpan(PSGGEN psg, UINT ch, REG8 pan) {
|
||||
|
||||
if ((psg) && (ch < 3)) {
|
||||
psg->tone[ch].pan = pan;
|
||||
}
|
||||
}
|
||||
|
||||
static void chkeyoff(UINT ch) {
|
||||
|
||||
UINT i;
|
||||
@ -2296,135 +2119,6 @@ adpcmstop:
|
||||
ad->remain = 0;
|
||||
}
|
||||
|
||||
static SINT32 randseed = 1;
|
||||
|
||||
void rand_setseed(SINT32 seed) {
|
||||
|
||||
randseed = seed;
|
||||
}
|
||||
|
||||
SINT32 rand_get(void) {
|
||||
|
||||
randseed = (randseed * 0x343fd) + 0x269ec3;
|
||||
return(randseed >> 16);
|
||||
}
|
||||
|
||||
void SOUNDCALL psggen_getpcm(PSGGEN psg, SINT32 *pcm, UINT count) {
|
||||
|
||||
SINT32 noisevol;
|
||||
UINT8 mixer;
|
||||
UINT noisetbl = 0;
|
||||
PSGTONE *tone;
|
||||
PSGTONE *toneterm;
|
||||
SINT32 samp;
|
||||
// UINT psgvol;
|
||||
SINT32 vol;
|
||||
UINT i;
|
||||
UINT noise;
|
||||
|
||||
if ((psg->mixer & 0x3f) == 0) {
|
||||
count = min(count, psg->puchicount);
|
||||
psg->puchicount -= count;
|
||||
}
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
do {
|
||||
noisevol = 0;
|
||||
if (psg->envcnt) {
|
||||
psg->envcnt--;
|
||||
if (psg->envcnt == 0) {
|
||||
psg->envvolcnt--;
|
||||
if (psg->envvolcnt < 0) {
|
||||
if (psg->envmode & PSGENV_ONESHOT) {
|
||||
psg->envvol = (psg->envmode & PSGENV_LASTON)?15:0;
|
||||
}
|
||||
else {
|
||||
psg->envvolcnt = 15;
|
||||
if (!(psg->envmode & PSGENV_ONECYCLE)) {
|
||||
psg->envmode ^= PSGENV_INC;
|
||||
}
|
||||
psg->envcnt = psg->envmax;
|
||||
psg->envvol = (psg->envvolcnt ^ psg->envmode) & 0x0f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
psg->envcnt = psg->envmax;
|
||||
psg->envvol = (psg->envvolcnt ^ psg->envmode) & 0x0f;
|
||||
}
|
||||
psg->evol = psggencfg.volume[psg->envvol];
|
||||
}
|
||||
}
|
||||
mixer = psg->mixer;
|
||||
if (mixer & 0x38) {
|
||||
for (i=0; i<(1 << PSGADDEDBIT); i++) {
|
||||
SINT32 countbak;
|
||||
countbak = psg->noise.count;
|
||||
psg->noise.count -= psg->noise.freq;
|
||||
if (psg->noise.count > countbak) {
|
||||
// psg->noise.base = GETRAND() & (1 << (1 << PSGADDEDBIT));
|
||||
psg->noise.base = rand_get() & (1 << (1 << PSGADDEDBIT));
|
||||
}
|
||||
noisetbl += psg->noise.base;
|
||||
noisetbl >>= 1;
|
||||
}
|
||||
}
|
||||
tone = psg->tone;
|
||||
toneterm = tone + 3;
|
||||
do {
|
||||
vol = *(tone->pvol);
|
||||
if (vol) {
|
||||
samp = 0;
|
||||
switch(mixer & 9) {
|
||||
case 0: // no mix
|
||||
if (tone->puchi) {
|
||||
tone->puchi--;
|
||||
samp += vol << PSGADDEDBIT;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: // tone only
|
||||
for (i=0; i<(1 << PSGADDEDBIT); i++) {
|
||||
tone->count += tone->freq;
|
||||
samp += vol * ((tone->count>=0)?1:-1);
|
||||
}
|
||||
break;
|
||||
|
||||
case 8: // noise only
|
||||
noise = noisetbl;
|
||||
for (i=0; i<(1 << PSGADDEDBIT); i++) {
|
||||
samp += vol * ((noise & 1)?1:-1);
|
||||
noise >>= 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 9:
|
||||
noise = noisetbl;
|
||||
for (i=0; i<(1 << PSGADDEDBIT); i++) {
|
||||
tone->count += tone->freq;
|
||||
if ((tone->count >= 0) || (noise & 1)) {
|
||||
samp += vol;
|
||||
}
|
||||
else {
|
||||
samp -= vol;
|
||||
}
|
||||
noise >>= 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!(tone->pan & 1)) {
|
||||
pcm[0] += samp;
|
||||
}
|
||||
if (!(tone->pan & 2)) {
|
||||
pcm[1] += samp;
|
||||
}
|
||||
}
|
||||
mixer >>= 1;
|
||||
} while(++tone < toneterm);
|
||||
pcm += 2;
|
||||
} while(--count);
|
||||
}
|
||||
|
||||
static void pc98_mix_CallBack(Bitu len) {
|
||||
unsigned int s = len;
|
||||
|
||||
|
107
src/hardware/snd_pc98/common/parts.c
Normal file
107
src/hardware/snd_pc98/common/parts.c
Normal file
@ -0,0 +1,107 @@
|
||||
#include "np2glue.h"
|
||||
|
||||
//#include "compiler.h"
|
||||
#include "parts.h"
|
||||
|
||||
|
||||
static SINT32 randseed = 1;
|
||||
|
||||
|
||||
void PARTSCALL rand_setseed(SINT32 seed) {
|
||||
|
||||
randseed = seed;
|
||||
}
|
||||
|
||||
SINT32 PARTSCALL rand_get(void) {
|
||||
|
||||
randseed = (randseed * 0x343fd) + 0x269ec3;
|
||||
return(randseed >> 16);
|
||||
}
|
||||
|
||||
UINT8 PARTSCALL AdjustAfterMultiply(UINT8 value) {
|
||||
|
||||
return((UINT8)(((value / 10) << 4) + (value % 10)));
|
||||
}
|
||||
|
||||
UINT8 PARTSCALL AdjustBeforeDivision(UINT8 value) {
|
||||
|
||||
return((UINT8)(((value >> 4) * 10) + (value & 0xf)));
|
||||
}
|
||||
|
||||
UINT PARTSCALL sjis2jis(UINT sjis) {
|
||||
|
||||
UINT ret;
|
||||
|
||||
ret = sjis & 0xff;
|
||||
ret -= (ret >> 7);
|
||||
ret += 0x62;
|
||||
if (ret < 256) {
|
||||
ret = (ret - 0xa2) & 0x1ff;
|
||||
}
|
||||
ret += 0x1f21;
|
||||
ret += (sjis & 0x3f00) << 1;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
UINT PARTSCALL jis2sjis(UINT jis) {
|
||||
|
||||
UINT high;
|
||||
UINT low;
|
||||
|
||||
low = jis & 0x7f;
|
||||
high = (jis >> 8) & 0x7f;
|
||||
low += ((high & 1) - 1) & 0x5e;
|
||||
if (low >= 0x60) {
|
||||
low++;
|
||||
}
|
||||
high += 0x121;
|
||||
low += 0x1f;
|
||||
high >>= 1;
|
||||
high ^= 0x20;
|
||||
return((high << 8) | low);
|
||||
}
|
||||
|
||||
void PARTSCALL satuation_s16(SINT16 *dst, const SINT32 *src, UINT size) {
|
||||
|
||||
SINT32 data;
|
||||
|
||||
size >>= 1;
|
||||
while(size--) {
|
||||
data = *src++;
|
||||
if (data > 32767) {
|
||||
data = 32767;
|
||||
}
|
||||
else if (data < -32768) {
|
||||
data = -32768;
|
||||
}
|
||||
*dst++ = (SINT16)data;
|
||||
}
|
||||
}
|
||||
|
||||
void PARTSCALL satuation_s16x(SINT16 *dst, const SINT32 *src, UINT size) {
|
||||
|
||||
SINT32 data;
|
||||
|
||||
size >>= 2;
|
||||
while(size--) {
|
||||
data = src[0];
|
||||
if (data > 32767) {
|
||||
data = 32767;
|
||||
}
|
||||
else if (data < -32768) {
|
||||
data = -32768;
|
||||
}
|
||||
dst[1] = (SINT16)data;
|
||||
data = src[1];
|
||||
if (data > 32767) {
|
||||
data = 32767;
|
||||
}
|
||||
else if (data < -32768) {
|
||||
data = -32768;
|
||||
}
|
||||
dst[0] = (SINT16)data;
|
||||
src += 2;
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
|
22
src/hardware/snd_pc98/common/parts.h
Normal file
22
src/hardware/snd_pc98/common/parts.h
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
#ifndef PARTSCALL
|
||||
#define PARTSCALL
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void PARTSCALL rand_setseed(SINT32 seed);
|
||||
SINT32 PARTSCALL rand_get(void);
|
||||
UINT8 PARTSCALL AdjustAfterMultiply(UINT8 value);
|
||||
UINT8 PARTSCALL AdjustBeforeDivision(UINT8 value);
|
||||
UINT PARTSCALL sjis2jis(UINT sjis);
|
||||
UINT PARTSCALL jis2sjis(UINT jis);
|
||||
void PARTSCALL satuation_s16(SINT16 *dst, const SINT32 *src, UINT size);
|
||||
void PARTSCALL satuation_s16x(SINT16 *dst, const SINT32 *src, UINT size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
90
src/hardware/snd_pc98/common/profile.h
Normal file
90
src/hardware/snd_pc98/common/profile.h
Normal file
@ -0,0 +1,90 @@
|
||||
|
||||
#if !defined(NP2_PROFILE_H__)
|
||||
#define NP2_PROFILE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
BOOL profile_enum(const OEMCHAR *filename, void *arg,
|
||||
BOOL (*proc)(void *arg, const OEMCHAR *para,
|
||||
const OEMCHAR *key, const OEMCHAR *data));
|
||||
const OEMCHAR *profile_getarg(const OEMCHAR *str, OEMCHAR *buf, UINT leng);
|
||||
|
||||
|
||||
|
||||
|
||||
// ---- ‚Ü‚¾ƒeƒXƒg
|
||||
|
||||
enum {
|
||||
PFILEH_READONLY = 0x0001,
|
||||
PFILEH_MODIFY = 0x0002
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
OEMCHAR *buffer;
|
||||
UINT buffers;
|
||||
UINT size;
|
||||
UINT8 hdr[4];
|
||||
UINT hdrsize;
|
||||
UINT flag;
|
||||
OEMCHAR path[MAX_PATH];
|
||||
} _PFILEH, *PFILEH;
|
||||
|
||||
PFILEH profile_open(const OEMCHAR *filename, UINT flag);
|
||||
void profile_close(PFILEH hdl);
|
||||
BRESULT profile_read(const OEMCHAR *app, const OEMCHAR *key,
|
||||
const OEMCHAR *def, OEMCHAR *ret, UINT size, PFILEH hdl);
|
||||
BRESULT profile_write(const OEMCHAR *app, const OEMCHAR *key,
|
||||
const OEMCHAR *data, PFILEH hdl);
|
||||
|
||||
|
||||
enum {
|
||||
PFTYPE_STR = 0,
|
||||
PFTYPE_BOOL,
|
||||
PFTYPE_BITMAP,
|
||||
PFTYPE_BIN,
|
||||
PFTYPE_SINT8,
|
||||
PFTYPE_SINT16,
|
||||
PFTYPE_SINT32,
|
||||
PFTYPE_UINT8,
|
||||
PFTYPE_UINT16,
|
||||
PFTYPE_UINT32,
|
||||
PFTYPE_HEX8,
|
||||
PFTYPE_HEX16,
|
||||
PFTYPE_HEX32,
|
||||
PFTYPE_USER,
|
||||
PFTYPE_MASK = 0xff,
|
||||
|
||||
PFFLAG_RO = 0x0100,
|
||||
PFFLAG_MAX = 0x0200,
|
||||
PFFLAG_AND = 0x0400
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
OEMCHAR item[12];
|
||||
UINT itemtype;
|
||||
void *value;
|
||||
UINT32 arg;
|
||||
} PFTBL;
|
||||
|
||||
#define PFSTR(k, f, a) {OEMTEXT(k), f, a, NELEMENTS(a)}
|
||||
#define PFVAL(k, f, a) {OEMTEXT(k), f, a, 0}
|
||||
#define PFMAX(k, f, a, v) {OEMTEXT(k), f | PFFLAG_MAX, a, v}
|
||||
#define PFAND(k, f, a, v) {OEMTEXT(k), f | PFFLAG_AND, a, v}
|
||||
#define PFEXT(k, f, a, v) {OEMTEXT(k), f, a, v}
|
||||
|
||||
typedef void (*PFREAD)(const PFTBL *item, const OEMCHAR *string);
|
||||
typedef OEMCHAR *(*PFWRITE)(const PFTBL *item, OEMCHAR *string, UINT size);
|
||||
|
||||
void profile_iniread(const OEMCHAR *path, const OEMCHAR *app,
|
||||
const PFTBL *tbl, UINT count, PFREAD cb);
|
||||
void profile_iniwrite(const OEMCHAR *path, const OEMCHAR *app,
|
||||
const PFTBL *tbl, UINT count, PFWRITE cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // defined(NP2_PROFILE_H__)
|
||||
|
59
src/hardware/snd_pc98/common/wavefile.h
Normal file
59
src/hardware/snd_pc98/common/wavefile.h
Normal file
@ -0,0 +1,59 @@
|
||||
|
||||
// あとで GETSNDに乗り換えるかも…
|
||||
|
||||
#if defined(BYTESEX_BIG)
|
||||
#define WAVE_SIG(a, b, c, d) \
|
||||
(UINT32)((d) + ((c) << 8) + ((b) << 16) + ((a) << 24))
|
||||
#else
|
||||
#define WAVE_SIG(a, b, c, d) \
|
||||
(UINT32)((a) + ((b) << 8) + ((c) << 16) + ((d) << 24))
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
UINT32 sig;
|
||||
UINT8 size[4];
|
||||
UINT32 fmt;
|
||||
} RIFF_HEADER;
|
||||
|
||||
typedef struct {
|
||||
UINT sig;
|
||||
UINT8 size[4];
|
||||
} WAVE_HEADER;
|
||||
|
||||
typedef struct {
|
||||
UINT8 format[2];
|
||||
UINT8 channel[2];
|
||||
UINT8 rate[4];
|
||||
UINT8 rps[4];
|
||||
UINT8 block[2];
|
||||
UINT8 bit[2];
|
||||
} WAVE_INFOS;
|
||||
|
||||
|
||||
// ---- write
|
||||
|
||||
typedef struct {
|
||||
long fh;
|
||||
UINT rate;
|
||||
UINT bits;
|
||||
UINT ch;
|
||||
UINT size;
|
||||
|
||||
UINT8 *ptr;
|
||||
UINT remain;
|
||||
UINT8 buf[4096];
|
||||
} _WAVEWR, *WAVEWR;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
WAVEWR wavewr_open(const OEMCHAR *filename, UINT rate, UINT bits, UINT ch);
|
||||
UINT wavewr_write(WAVEWR hdl, const void *buf, UINT size);
|
||||
void wavewr_close(WAVEWR hdl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
1003
src/hardware/snd_pc98/generic/keydisp.c
Normal file
1003
src/hardware/snd_pc98/generic/keydisp.c
Normal file
File diff suppressed because it is too large
Load Diff
103
src/hardware/snd_pc98/generic/keydisp.h
Normal file
103
src/hardware/snd_pc98/generic/keydisp.h
Normal file
@ -0,0 +1,103 @@
|
||||
|
||||
#if defined(SUPPORT_KEYDISP)
|
||||
|
||||
#include "cmndraw.h"
|
||||
|
||||
struct _cmnpalfn {
|
||||
UINT8 (*get8)(struct _cmnpalfn *fn, UINT num);
|
||||
UINT32 (*get32)(struct _cmnpalfn *fn, UINT num);
|
||||
UINT16 (*cnv16)(struct _cmnpalfn *fn, RGB32 pal32);
|
||||
long userdata;
|
||||
};
|
||||
typedef struct _cmnpalfn CMNPALFN;
|
||||
|
||||
typedef struct {
|
||||
UINT8 pal8;
|
||||
UINT8 padding;
|
||||
UINT16 pal16;
|
||||
RGB32 pal32;
|
||||
} CMNPALS;
|
||||
|
||||
|
||||
enum {
|
||||
KEYDISP_MODENONE = 0,
|
||||
KEYDISP_MODEFM,
|
||||
KEYDISP_MODEMIDI
|
||||
};
|
||||
|
||||
#if defined(SUPPORT_PX)
|
||||
enum {
|
||||
KEYDISP_CHMAX = 39,
|
||||
KEYDISP_FMCHMAX = 30,
|
||||
KEYDISP_PSGMAX = 3
|
||||
};
|
||||
#else // defined(SUPPORT_PX)
|
||||
enum {
|
||||
KEYDISP_CHMAX = 16,
|
||||
KEYDISP_FMCHMAX = 12,
|
||||
KEYDISP_PSGMAX = 3
|
||||
};
|
||||
#endif // defined(SUPPORT_PX)
|
||||
|
||||
enum {
|
||||
KEYDISP_NOTEMAX = 16,
|
||||
|
||||
KEYDISP_KEYCX = 28,
|
||||
KEYDISP_KEYCY = 14,
|
||||
|
||||
KEYDISP_LEVEL = (1 << 4),
|
||||
|
||||
KEYDISP_WIDTH = 301,
|
||||
KEYDISP_HEIGHT = (KEYDISP_KEYCY * KEYDISP_CHMAX) + 1,
|
||||
|
||||
KEYDISP_DELAYEVENTS = 2048,
|
||||
};
|
||||
|
||||
enum {
|
||||
KEYDISP_PALBG = 0,
|
||||
KEYDISP_PALFG,
|
||||
KEYDISP_PALHIT,
|
||||
|
||||
KEYDISP_PALS
|
||||
};
|
||||
|
||||
enum {
|
||||
KEYDISP_FLAGDRAW = 0x01,
|
||||
KEYDISP_FLAGREDRAW = 0x02,
|
||||
KEYDISP_FLAGSIZING = 0x04
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void keydisp_initialize(void);
|
||||
void keydisp_setmode(UINT8 mode);
|
||||
void keydisp_setpal(CMNPALFN *palfn);
|
||||
void keydisp_setdelay(UINT8 frames);
|
||||
UINT8 keydisp_process(UINT8 framepast);
|
||||
void keydisp_getsize(int *width, int *height);
|
||||
BOOL keydisp_paint(CMNVRAM *vram, BOOL redraw);
|
||||
|
||||
void keydisp_setfmboard(UINT board);
|
||||
void keydisp_fmkeyon(UINT8 ch, UINT8 value);
|
||||
void keydisp_psgmix(void *psg);
|
||||
void keydisp_psgvol(void *psg, UINT8 ch);
|
||||
void keydisp_midi(const UINT8 *msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define keydisp_draw(a)
|
||||
#define keydisp_setfmboard(a)
|
||||
#define keydisp_fmkeyon(a, b)
|
||||
#define keydisp_psgmix(a)
|
||||
#define keydisp_psgvol(a, b)
|
||||
#define keydisp_midi(a)
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "compiler.h"
|
||||
#include "np2glue.h"
|
||||
//#include "compiler.h"
|
||||
#include <math.h>
|
||||
#include "sound.h"
|
||||
#include "psggen.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "compiler.h"
|
||||
#include "np2glue.h"
|
||||
//#include "compiler.h"
|
||||
#include "parts.h"
|
||||
#include "sound.h"
|
||||
#include "psggen.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user