From c06759b235f49ede75ae274356df52bab02832c8 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 24 Aug 2024 16:43:15 -0500 Subject: [PATCH] NES:codestyle --- src/engine/platform/nes.cpp | 49 +++++++++++++++++-------------------- src/gui/about.cpp | 1 + src/gui/sampleEdit.cpp | 6 ++--- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/engine/platform/nes.cpp b/src/engine/platform/nes.cpp index e48a581cc..67fdbc11e 100644 --- a/src/engine/platform/nes.cpp +++ b/src/engine/platform/nes.cpp @@ -109,8 +109,7 @@ void DivPlatformNES::acquire_puNES(short** buf, size_t len) { for (size_t i=0; igetSample(dacSample); + // sample custom loop point... + DivSample* lsamp=parent->getSample(dacSample); - //how it works: - //when the initial sample info is written (see above) and playback is launched, - //the parameters (start point in memory and length) are locked until sample end - //is reached. + // how it works: + // when the initial sample info is written (see above) and playback is launched, + // the parameters (start point in memory and length) are locked until sample end + // is reached. - //thus, if we write new data after just several APU clock cycles, it will be used only when - //sample finishes one full loop. + // thus, if we write new data after just several APU clock cycles, it will be used only when + // sample finishes one full loop. - //thus we can write sample's loop point as "start address" and sample's looped part length - //as "full sample length". + // thus we can write sample's loop point as "start address" and sample's looped part length + // as "full sample length". - //APU will play full sample once and then repeatedly cycle through the looped part. + // APU will play full sample once and then repeatedly cycle through the looped part. - //sources: - //https://www.nesdev.org/wiki/APU_DMC - //https://www.youtube.com/watch?v=vB4P8x2Am6Y + // sources: + // https://www.nesdev.org/wiki/APU_DMC + // https://www.youtube.com/watch?v=vB4P8x2Am6Y - if(lsamp->loopEnd > lsamp->loopStart && goingToLoop) - { - int loop_start_addr = (sampleOffDPCM[dacSample] + lsamp->loopStart) / 8; - int loop_len = (lsamp->loopEnd - lsamp->loopStart) / 8; + if (lsamp->loopEnd>lsamp->loopStart && goingToLoop) { + int loopStartAddr=(sampleOffDPCM[dacSample]+lsamp->loopStart)>>3; + int loopLen=(lsamp->loopEnd-lsamp->loopStart)>>3; - rWrite(0x4012,(loop_start_addr >> 6)&0xff); - rWrite(0x4013,(loop_len >> 4)&0xff); + rWrite(0x4012,(loopStartAddr>>6)&0xff); + rWrite(0x4013,(loopLen>>4)&0xff); } } } else { diff --git a/src/gui/about.cpp b/src/gui/about.cpp index efa95465b..66d229006 100644 --- a/src/gui/about.cpp +++ b/src/gui/about.cpp @@ -302,6 +302,7 @@ const char* aboutLine[]={ _N("NDS sound emulator by cam900"), "", _N("greetings to:"), + "floxy!", "NEOART Costa Rica", "Xenium Demoparty", "@party", diff --git a/src/gui/sampleEdit.cpp b/src/gui/sampleEdit.cpp index 08c0a7438..aefe38cfb 100644 --- a/src/gui/sampleEdit.cpp +++ b/src/gui/sampleEdit.cpp @@ -253,8 +253,7 @@ void FurnaceGUI::drawSampleEdit() { SAMPLE_WARN(warnLength,"QSound: maximum sample length is 65535"); } break; - case DIV_SYSTEM_NES: - { + case DIV_SYSTEM_NES: { if (sample->loop) { if (sample->loopStart&511) { int tryWith=(sample->loopStart)&(~511); @@ -263,7 +262,8 @@ void FurnaceGUI::drawSampleEdit() { SAMPLE_WARN(warnLoopStart,alignHint); } if ((sample->loopEnd)&127) { - int tryWith=(sample->loopEnd + 1)&(~127); //+1 bc of how sample length is treated: https://www.nesdev.org/wiki/APU_DMC + // +1 bc of how sample length is treated: https://www.nesdev.org/wiki/APU_DMC + int tryWith=(sample->loopEnd + 1)&(~127); if (tryWith>(int)sample->samples) tryWith-=128; String alignHint=fmt::sprintf(_("NES: loop end must be a multiple of 128 (try with %d)"),tryWith); SAMPLE_WARN(warnLoopEnd,alignHint);