segas16b: Added analog filters. [Couriersud]

Analog filters added to systems with YM2151 and UPD7759.
Reviewers can use USE_NL define to produce unfiltered sound.
This commit is contained in:
couriersud 2020-01-25 15:35:28 +01:00
parent 42d351a4eb
commit ea1897f605
8 changed files with 417 additions and 7 deletions

View File

@ -3461,6 +3461,8 @@ files {
MAME_DIR .. "src/mame/drivers/segas16b.cpp",
MAME_DIR .. "src/mame/includes/segas16b.h",
MAME_DIR .. "src/mame/video/segas16b.cpp",
MAME_DIR .. "src/mame/audio/nl_segas16b.cpp",
MAME_DIR .. "src/mame/audio/nl_segas16b.h",
MAME_DIR .. "src/mame/drivers/segas18.cpp",
MAME_DIR .. "src/mame/includes/segas18.h",
MAME_DIR .. "src/mame/video/segas18.cpp",

View File

@ -23,10 +23,11 @@ CPUS["M6803"] = true
CPUS["M6809"] = true
CPUS["MCS48"] = true
CPUS["I8085"] = true
--CPUS["MCS51"] = true
CPUS["MCS51"] = true
--CPUS["M6800"] = true
--CPUS["M6809"] = true
--CPUS["M680X0"] = true
CPUS["M680X0"] = true
--CPUS["TMS9900"] = true
--CPUS["COP400"] = true
CPUS["F8"] = true
@ -43,11 +44,14 @@ SOUNDS["AY8910"] = true
SOUNDS["MSM5205"] = true
--SOUNDS["ASTROCADE"] = true
SOUNDS["TMS5220"] = true
--SOUNDS["OKIM6295"] = true
SOUNDS["OKIM6295"] = true
SOUNDS["UPD7759"] = true
--SOUNDS["HC55516"] = true
--SOUNDS["YM3812"] = true
--SOUNDS["CEM3394"] = true
--SOUNDS["VOTRAX"] = true
SOUNDS["YM2151"] = true
SOUNDS["YM2413"] = true
SOUNDS["BEEP"] = true
SOUNDS["VOLT_REG"] = true
SOUNDS["SPEAKER"] = true
@ -81,6 +85,8 @@ MACHINES["6821PIA"] = true
MACHINES["I8255"] = true
MACHINES["WATCHDOG"] = true
MACHINES["EEPROMDEV"] = true
MACHINES["UPD4701"] = true
MACHINES["CXD1095"] = true
--MACHINES["TTL74148"] = true
--MACHINES["TTL74153"] = true
--MACHINES["TTL7474"] = true
@ -212,6 +218,28 @@ files{
MAME_DIR .. "src/mame/machine/nl_palestra.cpp",
MAME_DIR .. "src/mame/machine/nl_palestra.h",
MAME_DIR .. "src/mame/drivers/segas16b.cpp",
MAME_DIR .. "src/mame/includes/segas16b.h",
MAME_DIR .. "src/mame/video/segas16b.cpp",
MAME_DIR .. "src/mame/audio/nl_segas16b.cpp",
MAME_DIR .. "src/mame/audio/nl_segas16b.h",
MAME_DIR .. "src/mame/machine/315_5195.cpp",
MAME_DIR .. "src/mame/machine/315_5195.h",
MAME_DIR .. "src/mame/machine/fd1089.cpp",
MAME_DIR .. "src/mame/machine/fd1089.h",
MAME_DIR .. "src/mame/machine/fd1094.cpp",
MAME_DIR .. "src/mame/machine/fd1094.h",
MAME_DIR .. "src/mame/machine/segaic16.cpp",
MAME_DIR .. "src/mame/machine/segaic16.h",
MAME_DIR .. "src/mame/video/sega16sp.cpp",
MAME_DIR .. "src/mame/video/sega16sp.h",
MAME_DIR .. "src/mame/machine/mc8123.cpp",
MAME_DIR .. "src/mame/machine/mc8123.h",
MAME_DIR .. "src/mame/video/segaic16.cpp",
MAME_DIR .. "src/mame/video/segaic16.h",
MAME_DIR .. "src/mame/video/segaic16_road.cpp",
MAME_DIR .. "src/mame/video/segaic16_road.h",
MAME_DIR .. "src/mame/drivers/testpat.cpp",
MAME_DIR .. "src/mame/machine/nl_tp1983.cpp",
MAME_DIR .. "src/mame/machine/nl_tp1983.h",

View File

@ -185,6 +185,7 @@ static inline int orientation_add(int orientation1, int orientation2)
static inline float apply_brightness_contrast_gamma_fp(float srcval, float brightness, float contrast, float gamma)
{
#if 0
/* first apply gamma */
srcval = pow(srcval, 1.0f / gamma);
@ -197,6 +198,21 @@ static inline float apply_brightness_contrast_gamma_fp(float srcval, float brigh
if (srcval > 1.0f)
srcval = 1.0f;
return srcval;
#else
/* contrast/brightness */
srcval = (srcval * contrast) + brightness - 1.0f;
/* clamp and return */
if (srcval < 0.0f)
srcval = 0.0f;
if (srcval > 1.0f)
srcval = 1.0f;
/* apply gamma */
srcval = std::pow(srcval, gamma);
return srcval;
#endif
}

View File

@ -0,0 +1,172 @@
// license:CC0
// copyright-holders:Couriersud
#include "netlist/devices/net_lib.h"
#ifdef NLBASE_H_
#error Somehow nl_base.h made it into the include chain.
#endif
NETLIST_START(segas16b_audio)
SOLVER(Solver, 48000)
//PARAM(Solver.DYNAMIC_TS, 1)
ANALOG_INPUT(VP5, 5)
ANALOG_INPUT(VP12, 12)
/* UPD7759 has resistor of 47K on reference pin
* ==> IREF ~30 uA
* According to datasheet maximum current sink
* is 34 * IREF.
*
* MAME must provide range of 0 to 1020 uA to the current sink.
*
*/
#if 0
CLOCK(T0, 10)
NET_C(GND, T0.GND)
NET_C(VP5, T0.VCC)
RES(T0R, RES_M(10000000))
NET_C(T0, T0R.1)
CS(T1, 0.0)
//PARAM(T1.FUNC, "0.001020 * (0.5 + 0.5 * sin(6280 * T))")
RES(T2, 1000)
NET_C(GND, T2.2, T1.2)
NET_C(T1.1, T2.1, T0R.2)
#endif
CS(SPEECH, 0)
//PARAM(SPEECH.FUNC, "0.001020 * (0.5 + 0.5 * sin(6280 * T))")
NET_C(SPEECH.2, GND)
ANALOG_INPUT(CH1, 0)
ANALOG_INPUT(CH2, 0)
#if 0
VS(CH1VS, 0)
PARAM(CH1VS.FUNC, "2.5 + 1.25 * sin(6280 * T)")
NET_C(CH1VS.2, GND)
ALIAS(CH2, CH1VS.1)
#endif
/* The YM3012 uses only one dac for the two channels.
* Sample-and-hold is used to two toggle between the two channels.
* This is not emulated here since the YM2151 signals are provided
* externally.
*
* Therefore two RCOM resistors are used for now directly connected
* to the channels.
*
* The YM3012 datasheet gives a formula for digital to VOUT:
* VOUT = 0.5 VDD + 0.25 * VDD *(-1 + D9 + d8/2 .. + d0/512 + 1/1024)/pow(2,N)
* N= S2Q*4+S1Q*2+S0Q
* 3 bits ignored (I0,I1,I2)
* Serial data stream: I0,I1,I2,D0,..., D9,S0,S1,S2
*
* Basically output is between 0.25 * VDD and 0.75 * VDD.
* This needs to be done in MAME interface
*/
TL084_DIP(D20)
LM324_DIP(XC20)
RES(RCOM1, 390)
RES(RCOM2, 390)
CAP(C21, CAP_U(2.2))
CAP(C22, CAP_U(2.2)) // Needs verification
CAP(C27, CAP_P(1500))
CAP(C28, CAP_P(1500))
// ------------------------------------
// YM2151/YM3012 inputs
// ------------------------------------
NET_C(CH1, RCOM1.1)
NET_C(RCOM1.2, C27.1, D20.5)
NET_C(D20.7, D20.6, C22.1)
NET_C(CH2, RCOM2.1)
NET_C(RCOM2.2, C28.1, D20.10)
NET_C(D20.8, D20.9, C21.1)
NET_C(GND, C27.2, C28.2)
// OPAMPS, no information on schematics, assume 12V since
// TL084 with 5V would be outside specifications
// No negative voltages found on schematics
NET_C(VP12, XC20.4, D20.4)
NET_C(GND, XC20.11, D20.11)
// ------------------------------------
// Speech inputs
// ------------------------------------
RES(R11, RES_K(1))
RES(R14, RES_K(5.6))
RES(R16, RES_K(6.8))
RES(R15, RES_K(12))
RES(R12, RES_K(1.3))
RES(R13, RES_K(6.2))
CAP(C25, CAP_U(0.0022))
CAP(C26, CAP_U(0.022))
CAP(C23, CAP_U(0.022))
CAP(C29, CAP_U(0.01))
CAP(C62, CAP_U(2.2))
NET_C(VP5, R11.1)
NET_C(SPEECH.1, R11.2, R14.1)
NET_C(R14.2, R16.1, C26.1, R15.1)
NET_C(R15.2, C25.1, XC20.5)
NET_C(XC20.7, XC20.6, C26.2, R12.1)
NET_C(R12.2, C23.1, R13.1)
NET_C(R13.2, C29.1, XC20.3)
NET_C(XC20.1, XC20.2, C23.2, C62.1)
NET_C(GND, R16.2, C25.2, C29.2)
// ------------------------------------
// Mixing and pre amplifier
// ------------------------------------
RES(R6, RES_K(10))
RES(R9, RES_K(47))
RES(R10, RES_K(47))
RES(R4, RES_K(10))
RES(R7, RES_K(47))
RES(R3, RES_K(10))
RES(R5, RES_K(10))
RES(VR1, RES_K(2)) // FIXME: Actually a potentiometer
CAP(C12, CAP_U(10))
CAP(C63, CAP_U(2.2))
CAP(C20, CAP_P(1000))
CAP(C19, CAP_U(47)) // FIXME: Needs verification
RES(AMP_IN, RES_K(100))
NET_C(C62.2, R6.1)
NET_C(C22.2, R9.1)
NET_C(C21.2, R10.1)
NET_C(R6.2, R9.2, R10.2, XC20.9, C20.1, R7.1) // FIXME: Schematics read "9" (XC20.9) - other AMP?
NET_C(R7.2, C20.2, C63.1, XC20.8) // FIXME: Schematics read "7" (XC20.7) - other AMP?
NET_C(VP5, R4.1)
NET_C(R4.2, C19.1, R5.1, XC20.10) // FIXME: Schematics read "8" (XC20.8) - other AMP?
NET_C(C63.2, R3.1)
NET_C(R3.2, VR1.1, C12.1)
NET_C(C12.2, AMP_IN.1)
NET_C(GND, VR1.2, C19.2, R5.2, AMP_IN.2)
// OUTPUT
ALIAS(OUT, AMP_IN.1)
// Not connected
NET_C(GND, XC20.13, XC20.12, D20.13, D20.12, D20.2, D20.3)
NET_C(GND, XC20.14, D20.14, D20.1)
NETLIST_END()

View File

@ -0,0 +1,4 @@
// license:CC0
// copyright-holders:Couriersud
NETLIST_EXTERNAL(segas16b_audio)

View File

@ -876,6 +876,13 @@ S11 S13 S15 S17 |EPR12194 - - - EPR12195 - -
#include "sound/okim6295.h"
#include "speaker.h"
#define USE_NL (1)
#if USE_NL
#include "machine/netlist.h"
#include "netlist/nl_setup.h"
#include "audio/nl_segas16b.h"
#endif
//**************************************************************************
// CONSTANTS
@ -3933,12 +3940,37 @@ void segas16b_state::system16b(machine_config &config)
// sound hardware
SPEAKER(config, "mono").front_center();
#if USE_NL
YM2151(config, m_ym2151, MASTER_CLOCK_8MHz/2)
.add_route(0, "netlist", 1.0, 0)
.add_route(1, "netlist", 1.0, 1);
UPD7759(config, m_upd7759);
m_upd7759->md_w(0);
m_upd7759->drq().set(FUNC(segas16b_state::upd7759_generate_nmi));
m_upd7759->add_route(0, "netlist", 1.0, 2);
NETLIST_SOUND(config, "netlist", 48000)
.set_source(netlist_segas16b_audio)
.add_route(ALL_OUTPUTS, "mono", 1.0);
// please refer to the netlist code for details about
// the multipliers and offsets.
NETLIST_STREAM_INPUT(config, "netlist:cin0", 0, "CH1.IN")
.set_mult_offset(0.5/32768.0, 2.5);
NETLIST_STREAM_INPUT(config, "netlist:cin1", 1, "CH2.IN")
.set_mult_offset(0.5/32768.0, 2.5);
NETLIST_STREAM_INPUT(config, "netlist:cin2", 2, "SPEECH.I")
.set_mult_offset(0.001020/32768.0/2.0, 0.001020/2.0);
NETLIST_STREAM_OUTPUT(config, "netlist:cout0", 0, "OUT").set_mult_offset(30000.0 / 0.2, 0.0);
#else
YM2151(config, m_ym2151, MASTER_CLOCK_8MHz/2).add_route(ALL_OUTPUTS, "mono", 0.43);
UPD7759(config, m_upd7759);
m_upd7759->md_w(0);
m_upd7759->drq().set(FUNC(segas16b_state::upd7759_generate_nmi));
m_upd7759->add_route(ALL_OUTPUTS, "mono", 0.48);
#endif
}
void segas16b_state::system16b_mc8123(machine_config &config)

View File

@ -290,6 +290,150 @@ popeyej
popeyejo
popeyehs
@source:segas16b.cpp
aceattac // (c) 1988 (FD1094)
//afightere
//afighterf
//afighterg
//afighterh
aliensyn // (c) 1987 (Unprotected)
aliensyn3 // (c) 1987 (FD1089A)
aliensyn7 // (c) 1987 (MC-8123B)
aliensynj // (c) 1987 (FD1089A)
altbeast // (c) 1988 (8751)
altbeast2 // (c) 1988 (MC-8123B)
altbeast4 // (c) 1988 (MC-8123B)
altbeast5 // (c) 1988 (FD1094)
altbeast5d //
altbeast6 // (c) 1988 (8751)
altbeastj // (c) 1988 (8751)
altbeastj1 // (c) 1988 (protected)
altbeastj3 // (c) 1988 (FD1094)
altbeastj3d //
atomicp // (c) 1990 Philko - korean clone board
aurail // (c) 1990 Sega / Westone
aurail1 // (c) 1990 Sega / Westone (FD1089B)
aurail1d //
aurailj // (C) 1990 Sega / Westone (FD1089A)
aurailjd //
bayroute // (c) 1989 Sunsoft / Sega (FD1094)
bayroute1 // (c) 1989 Sunsoft / Sega (Unprotected)
bayrouted //
bayroutej // (c) 1989 Sunsoft / Sega (FD1094)
bayroutejd //
bullet // (c) 1987 (FD1094)
bulletd //
cencourt // (c) 1988 (MC-8123B)
cotton // (c) 1990 (FD1094)
cottond //
cottonj // (c) 1990 (FD1094)
cottonja // (c) 1990 (FD1094)
cottonjad //
cottonjd //
cottonu // (c) 1990 (FD1094)
cottonud //
ddux // (c) 1989 (FD1094)
ddux1 // (c) 1989 (8751)
dduxd //
dduxj // (c) 1989 (FD1094)
dduxjd //
//defense // (c) 1987 (FD1094)
dfjail //
dunkshot // (c) 1986 (FD1089A)
dunkshota // (c) 1986 (FD1089A)
dunkshoto // (c) 1986 (FD1089A)
eswat // (c) 1989 (FD1094)
eswatd //
eswatj // (c) 1989 (FD1094)
eswatj1 // (c) 1989 (FD1094)
eswatj1d //
eswatjd //
eswatu // (c) 1989 (FD1094)
eswatud //
exctleag // (c) 1988 (FD1094)
exctleagd //
fantzn2x // (c) 2008 Sega / M2
fantzn2xp // (c) 2008 Sega / M2
//fantzoneta // (c) 2008 Sega / M2 (bootleg conversion)
fpoint // (c) 1989 (Japan, FD1094)
fpoint1 // (c) 1989 (Japan, FD1094)
fpoint1d //
fpointbj // (c) 1989 (Datsu bootleg, Japan)
fpointbl // (c) 1989 (Datsu bootleg)
fpointbla //
fpointd //
goldnaxe // (c) 1989 (8751)
goldnaxe1 // (c) 1989 (FD1094)
goldnaxe1d //
goldnaxe2 // (c) 1989 (8751)
goldnaxe3 // (c) 1989 (FD1094)
goldnaxe3d //
goldnaxej // (c) 1989 (FD1094)
goldnaxejd //
goldnaxeu // (c) 1989 (FD1094)
goldnaxeud //
hwchamp // (c) 1987 (Unprotected)
hwchampj // (c) 1987 (FD1094)
hwchampjd //
isgsm //
lockonph //
mvp // (c) 1989 (FD1094)
mvpd //
mvpj // (c) 1989 (FD1094)
mvpjd //
passsht // (c) 1988 (FD1094)
passshta // (c) 1988 (FD1094)
passshtad //
passshtd //
passshtj // (c) 1988 (FD1094)
passshtjd //
riotcity // (c) 1991 Sega / Westone (Unprotected)
ryukyu // (c) 1990 (FD1094)
ryukyua // (c) 1990 (FD1094)
ryukyud //
//sdib // (c) 1987 (FD1089A)
//sdibl // (c) 1987 bootleg
//sdibl2 // bootleg
//sdibl3 // bootleg
//sdibl4 // bootleg
//sdibl5 // bootleg
//sdibl6 // bootleg
shinfz //
//shinobi2 // (c) 1987 (FD1094)
//shinobi2d //
//shinobi3 // (c) 1987 (MC-8123B)
//shinobi4 // (c) 1987 (MC-8123B)
//shinobi5 // (c) 1987 (Unprotected)
//shinobi6 // (c) 1987 (Unprotected)
sjryuko // (c) 1988 White Board (FD1094)
snapper // (c) 1990 Philko - korean clone board
sonicbom // (c) 1987 (FD1094)
sonicbomd //
suprleag // (c) 1987 (FD1094)
tetrbx //
//tetris1 // (c) 1988 (FD1094) S16B
//tetris1d //
//tetris2 // (c) 1988 (FD1094) S16B
//tetris2d //
timescan // (c) 1987 (Unprotected)
toryumon // (c) 1995 (Unprotected)
tturf // (c) 1989 Sega / Sunsoft (8751)
tturfu // (c) 1989 Sega / Sunsoft (8751)
ultracin // (c) 1996 Sega (Unprotected)
wb3 // (c) 1988 Sega / Westone (8751)
wb32 // (c) 1988 Sega / Westone (FD1094)
wb32d //
wb33 // (c) 1988 Sega / Westone (FD1094)
wb33d //
wb34 // (c) 1988 Sega / Westone (FD1094)
wb34d //
wrestwar // (c) 1989 (8751)
wrestwar1 // (c) 1989 (FD1094)
wrestwar1d //
wrestwar2 // (c) 1989 (FD1094)
wrestwar2d //
@source:testpat.cpp
tp1983
tp1985

View File

@ -20,6 +20,7 @@
#include "osdcomm.h"
#include "emu.h"
#include "emuopts.h"
#include "rendutil.h"
#ifdef OSD_MAC
#define GL_SILENCE_DEPRECATION (1)
@ -135,7 +136,7 @@ typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuin
//============================================================
#define DEBUG_MODE_SCORES 0
#define USE_WIN32_STYLE_LINES 0 // use the same method baseline does - yields somewhat nicer vectors but a little buggy
#define USE_WIN32_STYLE_LINES 1 // use the same method baseline does - yields somewhat nicer vectors but a little buggy
//============================================================
// CONSTANTS
@ -150,7 +151,8 @@ enum
TEXTURE_TYPE_SURFACE
};
//#undef GL_TEXTURE_2D
//#define GL_TEXTURE_2D GL_TEXTURE_2D_MULTISAMPLE
//============================================================
// MACROS
//============================================================
@ -185,7 +187,7 @@ struct line_aa_step
float weight; // weight contribution
};
#if 0
#if 1
static const line_aa_step line_aa_1step[] =
{
{ 0.00f, 0.00f, 1.00f },
@ -1123,11 +1125,21 @@ int renderer_ogl::draw(const int update)
GLsizei iScale = 1;
#if 1
//glEnable(GL_FRAMEBUFFER_SRGB);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glEnable(GL_LINE_SMOOTH);
//glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
//glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_MULTISAMPLE_ARB);
glEnable(GL_MULTISAMPLE);
#endif
/*
Mac hack: macOS version 10.15 and later flipped from assuming you don't support Retina to
assuming you do support Retina. SDL 2.0.11 is scheduled to fix this, but it's not out yet.
So we double-scale everything if you're on 10.15 or later and SDL is not at least version 2.0.11.
*/
#if defined(SDLMAME_MACOSX) || defined(OSD_MAC)
SDL_version sdlVers;
SDL_GetVersion(&sdlVers);
@ -1263,10 +1275,10 @@ int renderer_ogl::draw(const int update)
pendingPrimitive=GL_NO_PRIMITIVE;
}
set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim.flags));
//set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim.flags));
// compute the effective width based on the direction of the line
effwidth = prim.width();
effwidth = prim.width;
if (effwidth < 0.5f)
effwidth = 0.5f;