Skip to content

Commit

Permalink
snes, fix clicks in yuuyuuhakusho intro
Browse files Browse the repository at this point in the history
  • Loading branch information
dinkc64 committed Nov 19, 2024
1 parent 7ef5c83 commit 51783fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/burn/drv/snes/d_snes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29479,7 +29479,7 @@ struct BurnDriver BurnDrvsnes_Yuuyuuhakusho = {
BDF_GAME_WORKING, 2, HARDWARE_SNES, GBF_VSFIGHT, 0,
SNESGetZipName, snes_YuuyuuhakushoRomInfo, snes_YuuyuuhakushoRomName, NULL, NULL, NULL, NULL, SNESInputInfo, SNESDIPInfo,
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x8000,
512, 480, 4, 3
512, 448, 4, 3
};

// Yuu Yuu Hakusho Final - Makai Saikyou Retsuden
Expand Down
10 changes: 7 additions & 3 deletions src/burn/drv/snes/dsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ void dsp_reset(Dsp* dsp) {
memset(dsp->firBufferR, 0, sizeof(dsp->firBufferR));
memset(dsp->sampleBuffer, 0, sizeof(dsp->sampleBuffer));
dsp->sampleOffset = 0;
dsp->sampleCount = 0;
dsp->lastFrameBoundary = 0;
}

Expand Down Expand Up @@ -186,6 +187,7 @@ void dsp_handleState(Dsp* dsp, StateHandler* sh) {
}
sh_handleByteArray(sh, dsp->ram, 0x80);
// sh_handleByteArray(sh, (UINT8*)&dsp->sampleBuffer[0], 0x800*2*2);
// sh_handleInts(sh, dsp->sampleCount, NULL);
}

void dsp_cycle(Dsp* dsp) {
Expand All @@ -207,8 +209,9 @@ void dsp_cycle(Dsp* dsp) {
}
if (bBurnRunAheadFrame == 0) {
// put final sample in the samplebuffer
dsp->sampleBuffer[(dsp->sampleOffset & 0x7ff) * 2] = dsp->sampleOutL;
dsp->sampleBuffer[(dsp->sampleOffset & 0x7ff) * 2 + 0] = dsp->sampleOutL;
dsp->sampleBuffer[(dsp->sampleOffset++ & 0x7ff) * 2 + 1] = dsp->sampleOutR;
dsp->sampleCount++;
}
}
static int clamp16(int val) {
Expand Down Expand Up @@ -590,11 +593,12 @@ void dsp_write(Dsp* dsp, uint8_t adr, uint8_t val) {

void dsp_getSamples(Dsp* dsp, int16_t* sampleData, int samplesPerFrame) {
// resample from 534 / 641 samples per frame to wanted value
float wantedSamples = (dsp->apu->snes->palTiming ? 641.0 : 534.0);
float wantedSamples = dsp->sampleCount; // (dsp->apu->snes->palTiming ? 641.0 : 534.0);
dsp->sampleCount = 0;
double adder = wantedSamples / samplesPerFrame;
double location = dsp->lastFrameBoundary - wantedSamples;
for(int i = 0; i < samplesPerFrame; i++) {
sampleData[i * 2] = dsp->sampleBuffer[(((int) location) & 0x7ff) * 2];
sampleData[i * 2 + 0] = dsp->sampleBuffer[(((int) location) & 0x7ff) * 2 + 0];
sampleData[i * 2 + 1] = dsp->sampleBuffer[(((int) location) & 0x7ff) * 2 + 1];
location += adder;
}
Expand Down
1 change: 1 addition & 0 deletions src/burn/drv/snes/dsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ struct Dsp {
// sample ring buffer (2048 samples, *2 for stereo)
int16_t sampleBuffer[0x800 * 2];
uint16_t sampleOffset; // current offset in samplebuffer
uint32_t sampleCount; // samples generated since last render
uint16_t lastFrameBoundary;
};

Expand Down

0 comments on commit 51783fe

Please sign in to comment.