NES:codestyle

This commit is contained in:
tildearrow 2024-08-24 16:43:15 -05:00
parent efb89f7f94
commit c06759b235
3 changed files with 27 additions and 29 deletions

View file

@ -109,8 +109,7 @@ void DivPlatformNES::acquire_puNES(short** buf, size_t len) {
for (size_t i=0; i<len; i++) { for (size_t i=0; i<len; i++) {
doPCM; doPCM;
if (!writes.empty()) if (!writes.empty()) {
{
QueuedWrite w=writes.front(); QueuedWrite w=writes.front();
doWrite(w.addr,w.val); doWrite(w.addr,w.val);
regPool[w.addr&0x1f]=w.val; regPool[w.addr&0x1f]=w.val;
@ -143,8 +142,7 @@ void DivPlatformNES::acquire_NSFPlay(short** buf, size_t len) {
for (size_t i=0; i<len; i++) { for (size_t i=0; i<len; i++) {
doPCM; doPCM;
if (!writes.empty()) if (!writes.empty()) {
{
QueuedWrite w=writes.front(); QueuedWrite w=writes.front();
doWrite(w.addr,w.val); doWrite(w.addr,w.val);
regPool[w.addr&0x1f]=w.val; regPool[w.addr&0x1f]=w.val;
@ -416,8 +414,8 @@ void DivPlatformNES::tick(bool sysTick) {
logV("switching bank to %d",dpcmBank); logV("switching bank to %d",dpcmBank);
if (dumpWrites) addWrite(0xffff0004,dpcmBank); if (dumpWrites) addWrite(0xffff0004,dpcmBank);
} }
//sample custom loop point...
// sample custom loop point...
DivSample* lsamp=parent->getSample(dacSample); DivSample* lsamp=parent->getSample(dacSample);
// how it works: // how it works:
@ -437,13 +435,12 @@ void DivPlatformNES::tick(bool sysTick) {
// https://www.nesdev.org/wiki/APU_DMC // https://www.nesdev.org/wiki/APU_DMC
// https://www.youtube.com/watch?v=vB4P8x2Am6Y // https://www.youtube.com/watch?v=vB4P8x2Am6Y
if(lsamp->loopEnd > lsamp->loopStart && goingToLoop) if (lsamp->loopEnd>lsamp->loopStart && goingToLoop) {
{ int loopStartAddr=(sampleOffDPCM[dacSample]+lsamp->loopStart)>>3;
int loop_start_addr = (sampleOffDPCM[dacSample] + lsamp->loopStart) / 8; int loopLen=(lsamp->loopEnd-lsamp->loopStart)>>3;
int loop_len = (lsamp->loopEnd - lsamp->loopStart) / 8;
rWrite(0x4012,(loop_start_addr >> 6)&0xff); rWrite(0x4012,(loopStartAddr>>6)&0xff);
rWrite(0x4013,(loop_len >> 4)&0xff); rWrite(0x4013,(loopLen>>4)&0xff);
} }
} }
} else { } else {

View file

@ -302,6 +302,7 @@ const char* aboutLine[]={
_N("NDS sound emulator by cam900"), _N("NDS sound emulator by cam900"),
"", "",
_N("greetings to:"), _N("greetings to:"),
"floxy!",
"NEOART Costa Rica", "NEOART Costa Rica",
"Xenium Demoparty", "Xenium Demoparty",
"@party", "@party",

View file

@ -253,8 +253,7 @@ void FurnaceGUI::drawSampleEdit() {
SAMPLE_WARN(warnLength,"QSound: maximum sample length is 65535"); SAMPLE_WARN(warnLength,"QSound: maximum sample length is 65535");
} }
break; break;
case DIV_SYSTEM_NES: case DIV_SYSTEM_NES: {
{
if (sample->loop) { if (sample->loop) {
if (sample->loopStart&511) { if (sample->loopStart&511) {
int tryWith=(sample->loopStart)&(~511); int tryWith=(sample->loopStart)&(~511);
@ -263,7 +262,8 @@ void FurnaceGUI::drawSampleEdit() {
SAMPLE_WARN(warnLoopStart,alignHint); SAMPLE_WARN(warnLoopStart,alignHint);
} }
if ((sample->loopEnd)&127) { 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; if (tryWith>(int)sample->samples) tryWith-=128;
String alignHint=fmt::sprintf(_("NES: loop end must be a multiple of 128 (try with %d)"),tryWith); String alignHint=fmt::sprintf(_("NES: loop end must be a multiple of 128 (try with %d)"),tryWith);
SAMPLE_WARN(warnLoopEnd,alignHint); SAMPLE_WARN(warnLoopEnd,alignHint);