From c45866cfe4f923bcdaaa9d3a61b74becaaf8e275 Mon Sep 17 00:00:00 2001 From: cam900 Date: Tue, 2 Apr 2019 14:05:03 +0900 Subject: [PATCH] Implement Namcot 163 expansion sound volume difference related to iNES format devices/bus/nes/namcot.cpp : Add note --- hash/nes.xml | 20 ++++++++++++++++ src/devices/bus/nes/namcot.cpp | 18 ++++++++++++++ src/devices/bus/nes/nes_ines.hxx | 10 ++++++++ src/devices/bus/nes/nes_pcb.hxx | 41 ++++++++++++++++++++++++++++++++ src/devices/bus/nes/nes_slot.h | 2 ++ 5 files changed, 91 insertions(+) diff --git a/hash/nes.xml b/hash/nes.xml index 5f88616ad53..3761edabca2 100644 --- a/hash/nes.xml +++ b/hash/nes.xml @@ -3478,6 +3478,7 @@ + @@ -8648,6 +8649,7 @@ + @@ -9820,6 +9822,7 @@ + @@ -10913,6 +10916,7 @@ + @@ -12110,6 +12114,7 @@ + @@ -12771,6 +12776,7 @@ + @@ -17113,6 +17119,7 @@ + @@ -19108,6 +19115,7 @@ + @@ -19260,6 +19268,7 @@ + @@ -19941,6 +19950,7 @@ + @@ -23019,6 +23029,7 @@ + @@ -23733,6 +23744,7 @@ + @@ -24618,6 +24630,7 @@ + @@ -25867,6 +25880,7 @@ + @@ -25889,6 +25903,7 @@ + @@ -31223,6 +31238,7 @@ + @@ -32110,6 +32126,7 @@ + @@ -32136,6 +32153,7 @@ + @@ -35237,6 +35255,7 @@ + @@ -42824,6 +42843,7 @@ + diff --git a/src/devices/bus/nes/namcot.cpp b/src/devices/bus/nes/namcot.cpp index 256e5d65f3b..445f630e3f7 100644 --- a/src/devices/bus/nes/namcot.cpp +++ b/src/devices/bus/nes/namcot.cpp @@ -209,6 +209,24 @@ void nes_namcot163_device::device_start() m_mapper_sram_size = 0x2000; m_mapper_sram = m_n163_ram; + + // TODO : Measure actual volume + if (m_n163_vol == 2) // Submapper 2 - No expansion sound + { + m_namco163snd->set_output_gain(ALL_OUTPUTS, 0.0); + } + else if (m_n163_vol == 3) // Submapper 3 - N163 expansion sound: 11.0-13.0 dB louder than NES APU + { + m_namco163snd->set_output_gain(ALL_OUTPUTS, 1.125); + } + else if (m_n163_vol == 4) // Submapper 4 - N163 expansion sound: 16.0-17.0 dB louder than NES APU + { + m_namco163snd->set_output_gain(ALL_OUTPUTS, 1.17); + } + else if (m_n163_vol == 5) // Submapper 5 - N163 expansion sound: 18.0-19.5 dB louder than NES APU + { + m_namco163snd->set_output_gain(ALL_OUTPUTS, 1.19); + } } void nes_namcot163_device::pcb_reset() diff --git a/src/devices/bus/nes/nes_ines.hxx b/src/devices/bus/nes/nes_ines.hxx index e5a2a80d3e4..6887256fc59 100644 --- a/src/devices/bus/nes/nes_ines.hxx +++ b/src/devices/bus/nes/nes_ines.hxx @@ -428,6 +428,16 @@ void nes_cart_slot_device::call_load_ines() bus_conflict = true; else if (mapper == 7 && submapper == 2) bus_conflict = true; + // 019: Namcot N163 + else if (mapper == 19) + { + int vol = submapper & 0x07; + if (vol >= 0 && vol <= 5) + { + pcb_id = NAMCOT_163; + m_cart->set_n163_vol(vol); + } + } // 021, 023, 025: VRC4 / VRC2 else if (mapper == 21 || mapper == 23 || mapper == 25) { diff --git a/src/devices/bus/nes/nes_pcb.hxx b/src/devices/bus/nes/nes_pcb.hxx index 610c85bcb88..e26bd71dfd2 100644 --- a/src/devices/bus/nes/nes_pcb.hxx +++ b/src/devices/bus/nes/nes_pcb.hxx @@ -435,6 +435,41 @@ static int nes_cart_get_line( const char *feature ) return nes_line->line; } +struct n163_vol_lines +{ + const char *tag; + int line; +}; + +static const struct n163_vol_lines n163_vol_table[] = +{ + { "SUBMAPPER 0", 0 }, + { "SUBMAPPER 1", 1 }, + { "SUBMAPPER 2", 2 }, + { "SUBMAPPER 3", 3 }, + { "SUBMAPPER 4", 4 }, + { "SUBMAPPER 5", 5 }, + { nullptr } +}; + +static int n163_get_submapper_num( const char *feature ) +{ + const struct n163_vol_lines *n163_line = &n163_vol_table[0]; + + if (feature == nullptr) + return 128; + + while (n163_line->tag) + { + if (strcmp(n163_line->tag, feature) == 0) + break; + + n163_line++; + } + + return n163_line->line; +} + void nes_cart_slot_device::call_load_pcb() { uint32_t vram_size = 0, prgram_size = 0, battery_size = 0, mapper_sram_size = 0; @@ -551,6 +586,12 @@ void nes_cart_slot_device::call_load_pcb() mapper_sram_size = m_cart->get_mapper_sram_size(); } + if (m_pcb_id == NAMCOT_163) + { + if (get_feature("n163-vol")) + m_cart->set_n163_vol(n163_get_submapper_num(get_feature("n163-vol"))); + } + // pirate variants of boards with bus conflict are often not suffering from it // and actually games glitch if bus conflict is emulated... diff --git a/src/devices/bus/nes/nes_slot.h b/src/devices/bus/nes/nes_slot.h index 952ffd74b1f..f26c526b360 100644 --- a/src/devices/bus/nes/nes_slot.h +++ b/src/devices/bus/nes/nes_slot.h @@ -200,6 +200,7 @@ public: void set_ce(int mask, int state) { m_ce_mask = mask; m_ce_state = state; } void set_vrc_lines(int PRG_A, int PRG_B, int CHR) { m_vrc_ls_prg_a = PRG_A; m_vrc_ls_prg_b = PRG_B; m_vrc_ls_chr = CHR; } + void set_n163_vol(int vol) { m_n163_vol = vol; } void set_x1_005_alt(bool val) { m_x1_005_alt_mirroring = val; } void set_bus_conflict(bool val) { m_bus_conflict = val; } uint8_t get_open_bus() { return m_open_bus; } @@ -267,6 +268,7 @@ protected: int m_vrc_ls_prg_a; int m_vrc_ls_prg_b; int m_vrc_ls_chr; + int m_n163_vol; int m_mirroring; bool m_pcb_ctrl_mirror, m_four_screen_vram, m_has_trainer;