Merge branch 'master' of https://github.com/tildearrow/furnace into es5506_alt
This commit is contained in:
commit
13b2a72a01
27 changed files with 551 additions and 63 deletions
|
|
@ -130,7 +130,7 @@ long brrEncode(short* buf, unsigned char* out, long len, long loopStart) {
|
|||
}
|
||||
|
||||
// encode with filter
|
||||
if (i && i!=loopStart) {
|
||||
if (i /*&& i!=loopStart*/) {
|
||||
// 1: x = o0 - o1 * 15/16
|
||||
// 2: x = o0 + o2 * 15/16 - o1 * 61/32
|
||||
// 3: x = o0 + o2 * 13/16 - o1 * 115/64
|
||||
|
|
|
|||
|
|
@ -217,6 +217,10 @@ enum DivDispatchCmds {
|
|||
DIV_CMD_SNES_ECHO_FEEDBACK,
|
||||
DIV_CMD_SNES_ECHO_FIR,
|
||||
|
||||
DIV_CMD_NES_ENV_MODE,
|
||||
DIV_CMD_NES_LENGTH,
|
||||
DIV_CMD_NES_COUNT_MODE,
|
||||
|
||||
DIV_ALWAYS_SET_VOLUME, // () -> alwaysSetVol
|
||||
|
||||
DIV_CMD_MAX
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@
|
|||
#include "platform/bubsyswsg.h"
|
||||
#include "platform/n163.h"
|
||||
#include "platform/pet.h"
|
||||
#include "platform/pong.h"
|
||||
#include "platform/vic20.h"
|
||||
#include "platform/vrc6.h"
|
||||
#include "platform/fds.h"
|
||||
|
|
@ -366,6 +367,9 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
|
|||
case DIV_SYSTEM_VIC20:
|
||||
dispatch=new DivPlatformVIC20;
|
||||
break;
|
||||
case DIV_SYSTEM_PONG:
|
||||
dispatch=new DivPlatformPong;
|
||||
break;
|
||||
case DIV_SYSTEM_VRC6:
|
||||
dispatch=new DivPlatformVRC6;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1042,6 +1042,8 @@ void DivEngine::runExportThread() {
|
|||
curOrder=0;
|
||||
prevOrder=0;
|
||||
curFadeOutSample=0;
|
||||
lastLoopPos=-1;
|
||||
totalLoops=0;
|
||||
isFadingOut=false;
|
||||
if (exportFadeOut<=0.01) {
|
||||
remainingLoops=loopCount;
|
||||
|
|
@ -1984,10 +1986,14 @@ void DivEngine::getCommandStream(std::vector<DivCommand>& where) {
|
|||
}
|
||||
|
||||
void DivEngine::playSub(bool preserveDrift, int goalRow) {
|
||||
logV("playSub() called");
|
||||
std::chrono::high_resolution_clock::time_point timeStart=std::chrono::high_resolution_clock::now();
|
||||
for (int i=0; i<song.systemLen; i++) disCont[i].dispatch->setSkipRegisterWrites(false);
|
||||
reset();
|
||||
if (preserveDrift && curOrder==0) return;
|
||||
if (preserveDrift && curOrder==0) {
|
||||
logV("preserveDrift && curOrder is true");
|
||||
return;
|
||||
}
|
||||
bool oldRepeatPattern=repeatPattern;
|
||||
repeatPattern=false;
|
||||
int goal=curOrder;
|
||||
|
|
@ -2000,9 +2006,7 @@ void DivEngine::playSub(bool preserveDrift, int goalRow) {
|
|||
prevDrift=clockDrift;
|
||||
clockDrift=0;
|
||||
cycles=0;
|
||||
if (preserveDrift) {
|
||||
endOfSong=false;
|
||||
} else {
|
||||
if (!preserveDrift) {
|
||||
ticks=1;
|
||||
tempoAccum=0;
|
||||
totalTicks=0;
|
||||
|
|
@ -2011,6 +2015,7 @@ void DivEngine::playSub(bool preserveDrift, int goalRow) {
|
|||
totalLoops=0;
|
||||
lastLoopPos=-1;
|
||||
}
|
||||
endOfSong=false;
|
||||
speedAB=false;
|
||||
playing=true;
|
||||
skipping=true;
|
||||
|
|
@ -2352,6 +2357,7 @@ void DivEngine::reset() {
|
|||
speed2=curSubSong->speed2;
|
||||
firstTick=false;
|
||||
shallStop=false;
|
||||
shallStopSched=false;
|
||||
nextSpeed=speed1;
|
||||
divider=60;
|
||||
if (curSubSong->customTempo) {
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ class DivEngine {
|
|||
bool lowQuality;
|
||||
bool playing;
|
||||
bool freelance;
|
||||
bool shallStop;
|
||||
bool shallStop, shallStopSched;
|
||||
bool speedAB;
|
||||
bool endOfSong;
|
||||
bool consoleMode;
|
||||
|
|
@ -1017,6 +1017,7 @@ class DivEngine {
|
|||
playing(false),
|
||||
freelance(false),
|
||||
shallStop(false),
|
||||
shallStopSched(false),
|
||||
speedAB(false),
|
||||
endOfSong(false),
|
||||
consoleMode(false),
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ int DivPlatformMMC5::dispatch(DivCommand c) {
|
|||
}
|
||||
case DIV_CMD_STD_NOISE_MODE:
|
||||
chan[c.chan].duty=c.value;
|
||||
rWrite(0x5000+c.chan*4,0x30|chan[c.chan].outVol|((chan[c.chan].duty&3)<<6));
|
||||
rWrite(0x5000+c.chan*4,0x30|(chan[c.chan].active?chan[c.chan].outVol:0)|((chan[c.chan].duty&3)<<6));
|
||||
break;
|
||||
case DIV_CMD_SAMPLE_BANK:
|
||||
sampleBank=c.value;
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ void DivPlatformNES::tick(bool sysTick) {
|
|||
rWrite(0x4000+i*4,(chan[i].outVol==0)?0:255);
|
||||
chan[i].freqChanged=true;
|
||||
} else {
|
||||
rWrite(0x4000+i*4,0x30|chan[i].outVol|((chan[i].duty&3)<<6));
|
||||
rWrite(0x4000+i*4,(chan[i].envMode<<4)|chan[i].outVol|((chan[i].duty&3)<<6));
|
||||
}
|
||||
}
|
||||
if (chan[i].std.arp.had) {
|
||||
|
|
@ -239,7 +239,7 @@ void DivPlatformNES::tick(bool sysTick) {
|
|||
}
|
||||
}
|
||||
if (i!=2) {
|
||||
rWrite(0x4000+i*4,0x30|chan[i].outVol|((chan[i].duty&3)<<6));
|
||||
rWrite(0x4000+i*4,(chan[i].envMode<<4)|chan[i].outVol|((chan[i].duty&3)<<6));
|
||||
}
|
||||
if (i==3) { // noise
|
||||
chan[i].freqChanged=true;
|
||||
|
|
@ -289,11 +289,11 @@ void DivPlatformNES::tick(bool sysTick) {
|
|||
}
|
||||
if (i==3) { // noise
|
||||
rWrite(0x4002+i*4,(chan[i].duty<<7)|chan[i].freq);
|
||||
rWrite(0x4003+i*4,0xf0);
|
||||
rWrite(0x4003+i*4,(chan[i].len<<3));
|
||||
} else {
|
||||
rWrite(0x4002+i*4,chan[i].freq&0xff);
|
||||
if ((chan[i].prevFreq>>8)!=(chan[i].freq>>8) || i==2) {
|
||||
rWrite(0x4003+i*4,0xf8|(chan[i].freq>>8));
|
||||
rWrite(0x4003+i*4,(chan[i].len<<3)|(chan[i].freq>>8));
|
||||
}
|
||||
if (chan[i].freq!=65535 && chan[i].freq!=0) {
|
||||
chan[i].prevFreq=chan[i].freq;
|
||||
|
|
@ -419,7 +419,7 @@ int DivPlatformNES::dispatch(DivCommand c) {
|
|||
if (c.chan==2) {
|
||||
rWrite(0x4000+c.chan*4,0xff);
|
||||
} else if (!parent->song.brokenOutVol2) {
|
||||
rWrite(0x4000+c.chan*4,0x30|chan[c.chan].vol|((chan[c.chan].duty&3)<<6));
|
||||
rWrite(0x4000+c.chan*4,(chan[c.chan].envMode<<4)|chan[c.chan].vol|((chan[c.chan].duty&3)<<6));
|
||||
}
|
||||
break;
|
||||
case DIV_CMD_NOTE_OFF:
|
||||
|
|
@ -451,7 +451,7 @@ int DivPlatformNES::dispatch(DivCommand c) {
|
|||
if (c.chan==2) {
|
||||
rWrite(0x4000+c.chan*4,0xff);
|
||||
} else {
|
||||
rWrite(0x4000+c.chan*4,0x30|chan[c.chan].vol|((chan[c.chan].duty&3)<<6));
|
||||
rWrite(0x4000+c.chan*4,(chan[c.chan].envMode<<4)|chan[c.chan].vol|((chan[c.chan].duty&3)<<6));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -491,7 +491,7 @@ int DivPlatformNES::dispatch(DivCommand c) {
|
|||
if (c.chan==3) { // noise
|
||||
chan[c.chan].freqChanged=true;
|
||||
} else if (c.chan<2) {
|
||||
rWrite(0x4000+c.chan*4,0x30|chan[c.chan].outVol|((chan[c.chan].duty&3)<<6));
|
||||
rWrite(0x4000+c.chan*4,(chan[c.chan].active?((chan[c.chan].envMode<<4)|chan[c.chan].outVol):0x30)|((chan[c.chan].duty&3)<<6));
|
||||
}
|
||||
break;
|
||||
case DIV_CMD_NES_SWEEP:
|
||||
|
|
@ -507,6 +507,24 @@ int DivPlatformNES::dispatch(DivCommand c) {
|
|||
}
|
||||
rWrite(0x4001+(c.chan*4),chan[c.chan].sweep);
|
||||
break;
|
||||
case DIV_CMD_NES_ENV_MODE:
|
||||
chan[c.chan].envMode=c.value&3;
|
||||
if (c.chan==3) { // noise
|
||||
chan[c.chan].freqChanged=true;
|
||||
} else if (c.chan<2) {
|
||||
rWrite(0x4000+c.chan*4,(chan[c.chan].active?((chan[c.chan].envMode<<4)|chan[c.chan].outVol):0x30)|((chan[c.chan].duty&3)<<6));
|
||||
}
|
||||
break;
|
||||
case DIV_CMD_NES_LENGTH:
|
||||
if (c.chan>=4) break;
|
||||
chan[c.chan].len=c.value&0x1f;
|
||||
chan[c.chan].freqChanged=true;
|
||||
chan[c.chan].prevFreq=-1;
|
||||
break;
|
||||
case DIV_CMD_NES_COUNT_MODE:
|
||||
countMode=c.value;
|
||||
rWrite(0x4017,countMode?0x80:0);
|
||||
break;
|
||||
case DIV_CMD_NES_DMC:
|
||||
rWrite(0x4011,c.value&0x7f);
|
||||
break;
|
||||
|
|
@ -572,6 +590,7 @@ void DivPlatformNES::forceIns() {
|
|||
}
|
||||
rWrite(0x4001,chan[0].sweep);
|
||||
rWrite(0x4005,chan[1].sweep);
|
||||
rWrite(0x4017,countMode?0x80:0);
|
||||
}
|
||||
|
||||
void* DivPlatformNES::getChanState(int ch) {
|
||||
|
|
@ -615,6 +634,7 @@ void DivPlatformNES::reset() {
|
|||
dpcmBank=0;
|
||||
dpcmMode=false;
|
||||
goingToLoop=false;
|
||||
countMode=false;
|
||||
|
||||
if (useNP) {
|
||||
nes1_NP->Reset();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
class DivPlatformNES: public DivDispatch {
|
||||
struct Channel {
|
||||
int freq, baseFreq, pitch, pitch2, prevFreq, note, ins;
|
||||
unsigned char duty, sweep;
|
||||
unsigned char duty, sweep, envMode, len;
|
||||
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, furnaceDac;
|
||||
signed char vol, outVol, wave;
|
||||
DivMacroInt std;
|
||||
|
|
@ -46,6 +46,8 @@ class DivPlatformNES: public DivDispatch {
|
|||
ins(-1),
|
||||
duty(0),
|
||||
sweep(8),
|
||||
envMode(3),
|
||||
len(0x1f),
|
||||
active(false),
|
||||
insChanged(true),
|
||||
freqChanged(false),
|
||||
|
|
@ -74,6 +76,7 @@ class DivPlatformNES: public DivDispatch {
|
|||
bool dacAntiClickOn;
|
||||
bool useNP;
|
||||
bool goingToLoop;
|
||||
bool countMode;
|
||||
struct NESAPU* nes;
|
||||
xgm::NES_APU* nes1_NP;
|
||||
xgm::NES_DMC* nes2_NP;
|
||||
|
|
|
|||
267
src/engine/platform/pong.cpp
Normal file
267
src/engine/platform/pong.cpp
Normal file
|
|
@ -0,0 +1,267 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2022 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "pong.h"
|
||||
#include "../engine.h"
|
||||
#include "../../ta-log.h"
|
||||
|
||||
#define CHIP_DIVIDER 16
|
||||
|
||||
void DivPlatformPong::acquire(short* bufL, short* bufR, size_t start, size_t len) {
|
||||
int out=0;
|
||||
for (size_t i=start; i<start+len; i++) {
|
||||
if (on) {
|
||||
if (--pos<=0) {
|
||||
pos=(freq?2:1)<<4;
|
||||
flip=!flip;
|
||||
}
|
||||
out=(flip && !isMuted[0])?32767:0;
|
||||
bufL[i]=out;
|
||||
oscBuf->data[oscBuf->needle++]=out;
|
||||
} else {
|
||||
bufL[i]=0;
|
||||
oscBuf->data[oscBuf->needle++]=0;
|
||||
flip=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DivPlatformPong::tick(bool sysTick) {
|
||||
for (int i=0; i<1; i++) {
|
||||
chan[i].std.next();
|
||||
if (chan[i].std.vol.had) {
|
||||
chan[i].outVol=(chan[i].vol && chan[i].std.vol.val);
|
||||
on=chan[i].outVol;
|
||||
}
|
||||
if (chan[i].std.arp.had) {
|
||||
if (!chan[i].inPorta) {
|
||||
chan[i].baseFreq=NOTE_PERIODIC(parent->calcArp(chan[i].note,chan[i].std.arp.val));
|
||||
}
|
||||
chan[i].freqChanged=true;
|
||||
}
|
||||
if (sysTick) {
|
||||
flip=false;
|
||||
pos=0;
|
||||
}
|
||||
if (chan[i].std.pitch.had) {
|
||||
if (chan[i].std.pitch.mode) {
|
||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||
} else {
|
||||
chan[i].pitch2=chan[i].std.pitch.val;
|
||||
}
|
||||
chan[i].freqChanged=true;
|
||||
}
|
||||
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
|
||||
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true,0,chan[i].pitch2,chipClock,CHIP_DIVIDER)-1;
|
||||
if (chan[i].freq<0) chan[i].freq=0;
|
||||
if (chan[i].freq>1) chan[i].freq=1;
|
||||
if (chan[i].keyOn) {
|
||||
on=true;
|
||||
}
|
||||
if (chan[i].keyOff) {
|
||||
on=false;
|
||||
}
|
||||
freq=chan[i].freq;
|
||||
if (chan[i].keyOn) chan[i].keyOn=false;
|
||||
if (chan[i].keyOff) chan[i].keyOff=false;
|
||||
chan[i].freqChanged=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int DivPlatformPong::dispatch(DivCommand c) {
|
||||
switch (c.cmd) {
|
||||
case DIV_CMD_NOTE_ON:
|
||||
if (c.value!=DIV_NOTE_NULL) {
|
||||
chan[c.chan].baseFreq=NOTE_PERIODIC(c.value);
|
||||
chan[c.chan].freqChanged=true;
|
||||
chan[c.chan].note=c.value;
|
||||
}
|
||||
chan[c.chan].active=true;
|
||||
chan[c.chan].keyOn=true;
|
||||
chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_BEEPER));
|
||||
if (!parent->song.brokenOutVol && !chan[c.chan].std.vol.will) {
|
||||
chan[c.chan].outVol=chan[c.chan].vol;
|
||||
}
|
||||
break;
|
||||
case DIV_CMD_NOTE_OFF:
|
||||
chan[c.chan].active=false;
|
||||
chan[c.chan].keyOff=true;
|
||||
chan[c.chan].macroInit(NULL);
|
||||
break;
|
||||
case DIV_CMD_NOTE_OFF_ENV:
|
||||
case DIV_CMD_ENV_RELEASE:
|
||||
chan[c.chan].std.release();
|
||||
break;
|
||||
case DIV_CMD_INSTRUMENT:
|
||||
if (chan[c.chan].ins!=c.value || c.value2==1) {
|
||||
chan[c.chan].ins=c.value;
|
||||
}
|
||||
break;
|
||||
case DIV_CMD_VOLUME:
|
||||
if (chan[c.chan].vol!=c.value) {
|
||||
chan[c.chan].vol=c.value;
|
||||
if (!chan[c.chan].std.vol.has) {
|
||||
chan[c.chan].outVol=c.value;
|
||||
}
|
||||
if (chan[c.chan].active) {
|
||||
on=chan[c.chan].vol;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DIV_CMD_GET_VOLUME:
|
||||
return chan[c.chan].vol;
|
||||
break;
|
||||
case DIV_CMD_PITCH:
|
||||
chan[c.chan].pitch=c.value;
|
||||
chan[c.chan].freqChanged=true;
|
||||
break;
|
||||
case DIV_CMD_NOTE_PORTA: {
|
||||
int destFreq=NOTE_PERIODIC(c.value2);
|
||||
bool return2=false;
|
||||
if (destFreq>chan[c.chan].baseFreq) {
|
||||
chan[c.chan].baseFreq+=c.value;
|
||||
if (chan[c.chan].baseFreq>=destFreq) {
|
||||
chan[c.chan].baseFreq=destFreq;
|
||||
return2=true;
|
||||
}
|
||||
} else {
|
||||
chan[c.chan].baseFreq-=c.value;
|
||||
if (chan[c.chan].baseFreq<=destFreq) {
|
||||
chan[c.chan].baseFreq=destFreq;
|
||||
return2=true;
|
||||
}
|
||||
}
|
||||
chan[c.chan].freqChanged=true;
|
||||
if (return2) {
|
||||
chan[c.chan].inPorta=false;
|
||||
return 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DIV_CMD_LEGATO:
|
||||
if (c.chan==3) break;
|
||||
chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0)));
|
||||
chan[c.chan].freqChanged=true;
|
||||
chan[c.chan].note=c.value;
|
||||
break;
|
||||
case DIV_CMD_PRE_PORTA:
|
||||
if (chan[c.chan].active && c.value2) {
|
||||
if (parent->song.resetMacroOnPorta) chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_BEEPER));
|
||||
}
|
||||
if (!chan[c.chan].inPorta && c.value && !parent->song.brokenPortaArp && chan[c.chan].std.arp.will) chan[c.chan].baseFreq=NOTE_PERIODIC(chan[c.chan].note);
|
||||
chan[c.chan].inPorta=c.value;
|
||||
break;
|
||||
case DIV_CMD_GET_VOLMAX:
|
||||
return 1;
|
||||
break;
|
||||
case DIV_ALWAYS_SET_VOLUME:
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void DivPlatformPong::muteChannel(int ch, bool mute) {
|
||||
isMuted[ch]=mute;
|
||||
}
|
||||
|
||||
void DivPlatformPong::forceIns() {
|
||||
for (int i=0; i<1; i++) {
|
||||
chan[i].insChanged=true;
|
||||
}
|
||||
}
|
||||
|
||||
void* DivPlatformPong::getChanState(int ch) {
|
||||
return &chan[ch];
|
||||
}
|
||||
|
||||
DivMacroInt* DivPlatformPong::getChanMacroInt(int ch) {
|
||||
return &chan[ch].std;
|
||||
}
|
||||
|
||||
DivDispatchOscBuffer* DivPlatformPong::getOscBuffer(int ch) {
|
||||
return oscBuf;
|
||||
}
|
||||
|
||||
void DivPlatformPong::reset() {
|
||||
for (int i=0; i<1; i++) {
|
||||
chan[i]=DivPlatformPong::Channel();
|
||||
chan[i].std.setEngine(parent);
|
||||
}
|
||||
if (dumpWrites) {
|
||||
addWrite(0xffffffff,0);
|
||||
}
|
||||
|
||||
on=false;
|
||||
lastOn=false;
|
||||
freq=0;
|
||||
pos=0;
|
||||
flip=false;
|
||||
|
||||
memset(regPool,0,2);
|
||||
}
|
||||
|
||||
bool DivPlatformPong::keyOffAffectsArp(int ch) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void DivPlatformPong::setFlags(const DivConfig& flags) {
|
||||
chipClock=15625;
|
||||
rate=chipClock;
|
||||
oscBuf->rate=rate;
|
||||
}
|
||||
|
||||
void DivPlatformPong::notifyInsDeletion(void* ins) {
|
||||
for (int i=0; i<1; i++) {
|
||||
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
|
||||
}
|
||||
}
|
||||
|
||||
void DivPlatformPong::poke(unsigned int addr, unsigned short val) {
|
||||
// ???
|
||||
}
|
||||
|
||||
void DivPlatformPong::poke(std::vector<DivRegWrite>& wlist) {
|
||||
// ???
|
||||
}
|
||||
|
||||
int DivPlatformPong::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {
|
||||
parent=p;
|
||||
dumpWrites=false;
|
||||
skipRegisterWrites=false;
|
||||
for (int i=0; i<1; i++) {
|
||||
isMuted[i]=false;
|
||||
}
|
||||
oscBuf=new DivDispatchOscBuffer;
|
||||
setFlags(flags);
|
||||
|
||||
reset();
|
||||
return 5;
|
||||
}
|
||||
|
||||
void DivPlatformPong::quit() {
|
||||
delete oscBuf;
|
||||
}
|
||||
|
||||
DivPlatformPong::~DivPlatformPong() {
|
||||
}
|
||||
89
src/engine/platform/pong.h
Normal file
89
src/engine/platform/pong.h
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2022 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef _PONG_H
|
||||
#define _PONG_H
|
||||
|
||||
#include "../dispatch.h"
|
||||
#include "../macroInt.h"
|
||||
|
||||
class DivPlatformPong: public DivDispatch {
|
||||
struct Channel {
|
||||
int freq, baseFreq, pitch, pitch2, note, ins;
|
||||
unsigned char duty, sweep;
|
||||
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, furnaceDac;
|
||||
signed char vol, outVol, wave;
|
||||
DivMacroInt std;
|
||||
void macroInit(DivInstrument* which) {
|
||||
std.init(which);
|
||||
pitch2=0;
|
||||
}
|
||||
Channel():
|
||||
freq(0),
|
||||
baseFreq(0),
|
||||
pitch(0),
|
||||
pitch2(0),
|
||||
note(0),
|
||||
ins(-1),
|
||||
duty(0),
|
||||
sweep(8),
|
||||
active(false),
|
||||
insChanged(true),
|
||||
freqChanged(false),
|
||||
sweepChanged(false),
|
||||
keyOn(false),
|
||||
keyOff(false),
|
||||
inPorta(false),
|
||||
furnaceDac(false),
|
||||
vol(1),
|
||||
outVol(1),
|
||||
wave(-1) {}
|
||||
};
|
||||
Channel chan[1];
|
||||
DivDispatchOscBuffer* oscBuf;
|
||||
bool isMuted[1];
|
||||
bool on, flip, lastOn;
|
||||
int pos;
|
||||
bool freq;
|
||||
unsigned char regPool[2];
|
||||
|
||||
friend void putDispatchChip(void*,int);
|
||||
friend void putDispatchChan(void*,int,int);
|
||||
|
||||
public:
|
||||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivMacroInt* getChanMacroInt(int ch);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
void reset();
|
||||
void forceIns();
|
||||
void tick(bool sysTick=true);
|
||||
void muteChannel(int ch, bool mute);
|
||||
bool keyOffAffectsArp(int ch);
|
||||
void setFlags(const DivConfig& flags);
|
||||
void notifyInsDeletion(void* ins);
|
||||
void poke(unsigned int addr, unsigned short val);
|
||||
void poke(std::vector<DivRegWrite>& wlist);
|
||||
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
|
||||
void quit();
|
||||
~DivPlatformPong();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -596,10 +596,16 @@ void DivPlatformSNES::writeOutVol(int ch) {
|
|||
|
||||
void DivPlatformSNES::writeEnv(int ch) {
|
||||
if (chan[ch].state.useEnv) {
|
||||
chWrite(ch,5,chan[ch].state.a|(chan[ch].state.d<<4)|0x80);
|
||||
if (chan[ch].state.sus && chan[ch].active) {
|
||||
chWrite(ch,6,chan[ch].state.s<<5);
|
||||
if (chan[ch].state.sus) {
|
||||
if (chan[ch].active) {
|
||||
chWrite(ch,5,chan[ch].state.a|(chan[ch].state.d<<4)|0x80);
|
||||
chWrite(ch,6,chan[ch].state.s<<5);
|
||||
} else { // dec linear
|
||||
chWrite(ch,7,0x80|chan[ch].state.r);
|
||||
chWrite(ch,5,0);
|
||||
}
|
||||
} else {
|
||||
chWrite(ch,5,chan[ch].state.a|(chan[ch].state.d<<4)|0x80);
|
||||
chWrite(ch,6,chan[ch].state.r|(chan[ch].state.s<<5));
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -627,7 +627,7 @@ void DivPlatformYM2608::tick(bool sysTick) {
|
|||
immWrite(0x109,chan[15].freq&0xff);
|
||||
immWrite(0x10a,(chan[15].freq>>8)&0xff);
|
||||
if (chan[15].keyOn || chan[15].keyOff) {
|
||||
immWrite(0x100,0x01); // reset
|
||||
if (chan[15].keyOff) immWrite(0x100,0x01); // reset
|
||||
if (chan[15].active && chan[15].keyOn && !chan[15].keyOff) {
|
||||
if (chan[15].sample>=0 && chan[15].sample<parent->song.sampleLen) {
|
||||
DivSample* s=parent->getSample(chan[15].sample);
|
||||
|
|
@ -685,6 +685,7 @@ int DivPlatformYM2608::dispatch(DivCommand c) {
|
|||
chan[c.chan].sample=ins->amiga.getSample(c.value);
|
||||
if (chan[c.chan].sample>=0 && chan[c.chan].sample<parent->song.sampleLen) {
|
||||
DivSample* s=parent->getSample(chan[c.chan].sample);
|
||||
immWrite(0x100,0x01); // reset
|
||||
immWrite(0x102,(sampleOffB[chan[c.chan].sample]>>5)&0xff);
|
||||
immWrite(0x103,(sampleOffB[chan[c.chan].sample]>>13)&0xff);
|
||||
int end=sampleOffB[chan[c.chan].sample]+s->lengthB-1;
|
||||
|
|
@ -716,6 +717,7 @@ int DivPlatformYM2608::dispatch(DivCommand c) {
|
|||
chan[c.chan].sample=12*sampleBank+c.value%12;
|
||||
if (chan[c.chan].sample>=0 && chan[c.chan].sample<parent->song.sampleLen) {
|
||||
DivSample* s=parent->getSample(chan[c.chan].sample);
|
||||
immWrite(0x100,0x01); // reset
|
||||
immWrite(0x102,(sampleOffB[chan[c.chan].sample]>>5)&0xff);
|
||||
immWrite(0x103,(sampleOffB[chan[c.chan].sample]>>13)&0xff);
|
||||
int end=sampleOffB[chan[c.chan].sample]+s->lengthB-1;
|
||||
|
|
|
|||
|
|
@ -218,6 +218,10 @@ const char* cmdName[]={
|
|||
"SNES_ECHO_FEEDBACK",
|
||||
"SNES_ECHO_FIR",
|
||||
|
||||
"DIV_CMD_NES_ENV_MODE",
|
||||
"DIV_CMD_NES_LENGTH",
|
||||
"DIV_CMD_NES_COUNT_MODE",
|
||||
|
||||
"ALWAYS_SET_VOLUME"
|
||||
};
|
||||
|
||||
|
|
@ -856,7 +860,8 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
|||
break;
|
||||
|
||||
case 0xff: // stop song
|
||||
shallStop=true;
|
||||
shallStopSched=true;
|
||||
logV("scheduling stop");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1144,7 +1149,11 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
|
|||
tempoAccum-=curSubSong->virtualTempoD;
|
||||
if (--ticks<=0) {
|
||||
ret=endOfSong;
|
||||
if (endOfSong) {
|
||||
if (shallStopSched) {
|
||||
logV("acknowledging scheduled stop");
|
||||
shallStop=true;
|
||||
break;
|
||||
} else if (endOfSong) {
|
||||
if (song.loopModality!=2) {
|
||||
playSub(true);
|
||||
}
|
||||
|
|
@ -1159,7 +1168,7 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
|
|||
if (tempoAccum>1023) tempoAccum=1023;
|
||||
}
|
||||
// process stuff
|
||||
for (int i=0; i<chans; i++) {
|
||||
if (!shallStop) for (int i=0; i<chans; i++) {
|
||||
if (chan[i].rowDelay>0) {
|
||||
if (--chan[i].rowDelay==0) {
|
||||
processRow(i,true);
|
||||
|
|
@ -1287,6 +1296,11 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// still tick the subtick counter
|
||||
if (--subticks<=0) {
|
||||
subticks=tickMult;
|
||||
}
|
||||
}
|
||||
|
||||
firstTick=false;
|
||||
|
|
@ -1303,6 +1317,7 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
|
|||
sPreview.dir=false;
|
||||
ret=true;
|
||||
shallStop=false;
|
||||
shallStopSched=false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ enum DivSystem {
|
|||
DIV_SYSTEM_MSM5232,
|
||||
DIV_SYSTEM_T6W28,
|
||||
DIV_SYSTEM_PCM_DAC,
|
||||
DIV_SYSTEM_PONG,
|
||||
DIV_SYSTEM_DUMMY,
|
||||
DIV_SYSTEM_MAX // boundary for max system number
|
||||
};
|
||||
|
|
|
|||
|
|
@ -701,6 +701,9 @@ void DivEngine::registerSystems() {
|
|||
{0x12, {DIV_CMD_STD_NOISE_MODE, "12xx: Set duty cycle/noise mode (pulse: 0 to 3; noise: 0 or 1)"}},
|
||||
{0x13, {DIV_CMD_NES_SWEEP, "13xy: Sweep up (x: time; y: shift)",constVal<0>,effectVal}},
|
||||
{0x14, {DIV_CMD_NES_SWEEP, "14xy: Sweep down (x: time; y: shift)",constVal<1>,effectVal}},
|
||||
{0x15, {DIV_CMD_NES_ENV_MODE, "15xx: Set envelope mode (0: envelope, 1: length, 2: looping, 3: constant)"}},
|
||||
{0x16, {DIV_CMD_NES_LENGTH, "16xx: Set length counter (refer to manual for a list of values)"}},
|
||||
{0x17, {DIV_CMD_NES_COUNT_MODE, "17xx: Set frame counter mode (0: 4-step, 1: 5-step)"}},
|
||||
{0x18, {DIV_CMD_SAMPLE_MODE, "18xx: Select PCM/DPCM mode (0: PCM; 1: DPCM)"}}
|
||||
}
|
||||
);
|
||||
|
|
@ -1110,6 +1113,15 @@ void DivEngine::registerSystems() {
|
|||
{DIV_INS_BEEPER}
|
||||
);
|
||||
|
||||
sysDefs[DIV_SYSTEM_PONG]=new DivSysDef(
|
||||
"Pong", NULL, 0xfc, 0, 1, false, true, 0, false, 0,
|
||||
"LOL",
|
||||
{"Square"},
|
||||
{"SQ"},
|
||||
{DIV_CH_PULSE},
|
||||
{DIV_INS_BEEPER}
|
||||
);
|
||||
|
||||
sysDefs[DIV_SYSTEM_POKEY]=new DivSysDef(
|
||||
"POKEY", NULL, 0x94, 0, 4, false, true, 0, false, 0,
|
||||
"TIA, but better and more flexible.\nused in the Atari 8-bit family of computers (400/800/XL/XE).",
|
||||
|
|
|
|||
|
|
@ -2053,9 +2053,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
|||
}
|
||||
// write write
|
||||
performVGMWrite(w,song.system[i.first],i.second.write,streamIDs[i.first],loopTimer,loopFreq,loopSample,sampleDir,isSecond[i.first],directStream);
|
||||
writeCount++;
|
||||
}
|
||||
sortedWrites.clear();
|
||||
totalWait-=lastOne;
|
||||
tickCount+=lastOne;
|
||||
}
|
||||
} else {
|
||||
for (int i=0; i<streamID; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue