From 3bd9f6ff1aa5eec78a762c24c95cdddbefc5d70a Mon Sep 17 00:00:00 2001 From: dinkc64 Date: Fri, 16 Aug 2024 20:55:49 -0400 Subject: [PATCH] nes_apu, dmc mode for arcade --- src/burn/snd/nes_apu.cpp | 8 ++++++++ src/burn/snd/nes_apu.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/burn/snd/nes_apu.cpp b/src/burn/snd/nes_apu.cpp index 7962058112..5fe0ef8c80 100644 --- a/src/burn/snd/nes_apu.cpp +++ b/src/burn/snd/nes_apu.cpp @@ -105,11 +105,17 @@ struct nesapu_info static nesapu_info nesapu_chips[CHIP_NUM]; static INT32 cycles_per_frame; +static UINT32 arcade_mode = 0; // not cycle accurate dpcm/dmc (needed for arcade) #if 0 INT32 nes_scanline(); #endif +void nesapuSetArcade(INT32 mode) +{ + arcade_mode = mode; +} + static UINT32 nes_nesapu_sync(INT32 samples_rate) { return (samples_rate * M6502TotalCycles()) / cycles_per_frame; /* ntsc: (341*262 / 3) + 0.5 pal: (341*312 / 3.2) + 0.5*/ @@ -848,6 +854,8 @@ static void apu_update(struct nesapu_info *info) INT32 dmc = dmc_buffer[dmcoffs]; INT32 ext = nes_ext_buffer[dmcoffs]; + if (arcade_mode) dmc = apu_dpcm(info, &info->APU.dpcm); + INT32 out = (INT32)(((float)info->tnd_table[3*triangle + 2*noise + dmc] + info->square_table[square1 + square2] + info->square_table[square3 + square4]) * 0x3fff); diff --git a/src/burn/snd/nes_apu.h b/src/burn/snd/nes_apu.h index 9413cfb731..9bbadd8894 100644 --- a/src/burn/snd/nes_apu.h +++ b/src/burn/snd/nes_apu.h @@ -5,6 +5,7 @@ extern INT32 nesapu_mixermode; void nesapuInitPal(INT32 chip, INT32 clock, INT32 bAdd); // pal nes void nesapuInit(INT32 chip, INT32 clock, INT32 bAdd); // ntsc nes void nesapuInit(INT32 chip, INT32 clock, INT32 is_pal, UINT32 (*pSyncCallback)(INT32 samples_per_frame), INT32 nAdd); +void nesapuSetArcade(INT32 mode); void nesapuUpdate(INT32 chip, INT16 *buffer, INT32 samples); void nesapuSetRoute(INT32 chip, INT32 nIndex, double nVolume, INT32 nRouteDir); void nesapuSetDMCBitDirection(INT32 reversed);