mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-01 02:22:39 +00:00
NES:codestyle
This commit is contained in:
parent
efb89f7f94
commit
c06759b235
3 changed files with 27 additions and 29 deletions
|
@ -109,8 +109,7 @@ void DivPlatformNES::acquire_puNES(short** buf, size_t len) {
|
|||
for (size_t i=0; i<len; i++) {
|
||||
doPCM;
|
||||
|
||||
if (!writes.empty())
|
||||
{
|
||||
if (!writes.empty()) {
|
||||
QueuedWrite w=writes.front();
|
||||
doWrite(w.addr,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++) {
|
||||
doPCM;
|
||||
|
||||
if (!writes.empty())
|
||||
{
|
||||
if (!writes.empty()) {
|
||||
QueuedWrite w=writes.front();
|
||||
doWrite(w.addr,w.val);
|
||||
regPool[w.addr&0x1f]=w.val;
|
||||
|
@ -313,7 +311,7 @@ void DivPlatformNES::tick(bool sysTick) {
|
|||
if (chan[i].sweepChanged) {
|
||||
chan[i].sweepChanged=false;
|
||||
if (i==0) {
|
||||
//rWrite(16+i*5,chan[i].sweep);
|
||||
// rWrite(16+i*5,chan[i].sweep);
|
||||
}
|
||||
}
|
||||
if (i<3) if (chan[i].std.phaseReset.had) {
|
||||
|
@ -354,7 +352,7 @@ void DivPlatformNES::tick(bool sysTick) {
|
|||
}
|
||||
}
|
||||
if (chan[i].keyOff) {
|
||||
//rWrite(16+i*5+2,8);
|
||||
// rWrite(16+i*5+2,8);
|
||||
if (i==2) { // triangle
|
||||
rWrite(0x4000+i*4,0x00);
|
||||
} else {
|
||||
|
@ -416,34 +414,33 @@ void DivPlatformNES::tick(bool sysTick) {
|
|||
logV("switching bank to %d",dpcmBank);
|
||||
if (dumpWrites) addWrite(0xffff0004,dpcmBank);
|
||||
}
|
||||
//sample custom loop point...
|
||||
|
||||
DivSample* lsamp = parent->getSample(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 {
|
||||
|
|
|
@ -302,6 +302,7 @@ const char* aboutLine[]={
|
|||
_N("NDS sound emulator by cam900"),
|
||||
"",
|
||||
_N("greetings to:"),
|
||||
"floxy!",
|
||||
"NEOART Costa Rica",
|
||||
"Xenium Demoparty",
|
||||
"@party",
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue