Merge branch 'master' of https://github.com/tildearrow/furnace into es5506_alt

This commit is contained in:
cam900 2022-10-26 12:28:24 +09:00
commit 13b2a72a01
27 changed files with 551 additions and 63 deletions

View File

@ -515,6 +515,7 @@ src/engine/platform/zxbeeper.cpp
src/engine/platform/bubsyswsg.cpp
src/engine/platform/n163.cpp
src/engine/platform/pet.cpp
src/engine/platform/pong.cpp
src/engine/platform/vic20.cpp
src/engine/platform/vrc6.cpp
src/engine/platform/es5506.cpp

View File

@ -65,6 +65,7 @@
#include "imgui.h"
#include "imgui_impl_sdl.h"
#include <stdio.h>
#include <cmath>
// SDL
@ -288,6 +289,7 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
if (!platform_io.Monitors.empty() && platform_io.Monitors[0].DpiScale > 1.0f)
{
// The Framebuffer is scaled by an integer ceiling of the actual ratio, so 2.0 not 1.685 on Mac!
//printf("multiply by %f\n",platform_io.Monitors[0].DpiScale);
mouse_pos.x *= std::ceil(platform_io.Monitors[0].DpiScale);
mouse_pos.y *= std::ceil(platform_io.Monitors[0].DpiScale);
}
@ -690,10 +692,11 @@ void ImGui_ImplSDL2_NewFrame()
// On Apple and Wayland, The window size is reported in Low DPI, even when running in high DPI mode
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
if (!platform_io.Monitors.empty() /*&& platform_io.Monitors[0].DpiScale > 1.0f*/ && display_h != h)
if (!platform_io.Monitors.empty() /*&& platform_io.Monitors[0].DpiScale > 1.0f*/ && display_h != h && w != 0)
{
io.DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
io.DisplaySize = ImVec2((float)display_w, (float)display_h);
//printf("write %d/%d to DpiScale\n",display_w,w);
platform_io.Monitors[0].DpiScale=(float)display_w/(float)w;
}

View File

@ -19,7 +19,65 @@ also known as Famicom. it is a five-channel sound generator: first two channels
- `x` is the time.
- `y` is the shift.
- set to 0 to disable it.
- `15xx`: set envelope mode.
- `0`: envelope + length counter (volume represents envelope duration).
- `1`: length counter (volume represents output volume).
- `2`: looping envelope (volume represents envelope duration).
- `3`: constant volume (default; volume represents output volume).
- pulse and noise channels only.
- you may need to apply a phase reset (using the macro) to make the envelope effective.
- `16xx`: set length counter.
- see table below for possible values.
- this will trigger phase reset.
- `17xx`: set frame counter mode.
- `0`: 4-step.
- NTSC: 120Hz sweeps and lengths; 240Hz envelope.
- PAL: 100Hz sweeps and lengths; 200Hz envelope.
- Dendy: 118.9Hz sweeps and lengths; 237.8Hz envelope.
- `1`: 5-step.
- NTSC: 96Hz sweeps and lengths; 192Hz envelope.
- PAL: 80Hz sweeps and lengths; 160Hz envelope.
- Dendy: 95.1Hz sweeps and lengths; 190.2Hz envelope.
- `18xx`: set PCM channel mode.
- `00`: PCM (software).
- `01`: DPCM (hardware).
- when in DPCM mode, samples will sound muffled (due to its nature), availables pitches are limited and loop point is ignored.
# length counter table
val | raw | NTSC | PAL | Dendy | NTSC 5-step | PAL 5-step | Dendy 5-step
----|-----|-------|-------|-------|-------------|------------|--------------
00 | 10 | 83ms | 100ms | 84ms | 104ms | 125ms | 105ms
01 | 254 | 2.1s | 2.5s | 2.1s | 2.6s | 3.2s | 2.7s
02 | 20 | 166ms | 200ms | 168ms | 208ms | 250ms | 210ms
03 | 2 | 17ms | 20ms | 17ms | 21ms | 25ms | 21ms
04 | 40 | 333ms | 400ms | 336ms | 417ms | 500ms | 421ms
05 | 4 | 33ms | 40ms | 34ms | 42ms | 50ms | 42ms
06 | 80 | 667ms | 800ms | 673ms | 833ms | 1.0s | 841ms
07 | 6 | 50ms | 60ms | 50ms | 63ms | 75ms | 63ms
08 | 160 | 1.3s | 1.6s | 1.3s | 1.7s | 2.0s | 1.7s
09 | 8 | 67ms | 80ms | 67ms | 83ms | 100ms | 84ms
0A | 60 | 500ms | 600ms | 505ms | 625ms | 750ms | 631ms
0B | 10 | 83ms | 100ms | 84ms | 104ms | 125ms | 105ms
0C | 14 | 117ms | 140ms | 118ms | 146ms | 175ms | 147ms
0D | 12 | 100ms | 120ms | 101ms | 125ms | 150ms | 126ms
0E | 26 | 217ms | 260ms | 219ms | 271ms | 325ms | 273ms
0F | 14 | 117ms | 140ms | 118ms | 145ms | 175ms | 147ms
10 | 12 | 100ms | 120ms | 101ms | 125ms | 150ms | 126ms
11 | 16 | 133ms | 160ms | 135ms | 167ms | 200ms | 168ms
12 | 24 | 200ms | 240ms | 202ms | 250ms | 300ms | 252ms
13 | 18 | 150ms | 180ms | 151ms | 188ms | 225ms | 189ms
14 | 48 | 400ms | 480ms | 404ms | 500ms | 600ms | 505ms
15 | 20 | 167ms | 200ms | 168ms | 208ms | 250ms | 210ms
16 | 96 | 800ms | 960ms | 807ms | 1.0s | 1.2s | 1.0s
17 | 22 | 183ms | 220ms | 185ms | 229ms | 275ms | 231ms
18 | 192 | 1.6s | 1.9s | 1.6s | 2.0s | 2.4s | 2.0s
19 | 24 | 200ms | 240ms | 202ms | 250ms | 300ms | 252ms
1A | 72 | 600ms | 720ms | 606ms | 750ms | 900ms | 757ms
1B | 26 | 217ms | 260ms | 219ms | 271ms | 325ms | 273ms
1C | 16 | 133ms | 160ms | 135ms | 167ms | 200ms | 168ms
1D | 28 | 233ms | 280ms | 235ms | 292ms | 350ms | 294ms
1E | 32 | 267ms | 320ms | 269ms | 333ms | 400ms | 336ms
1F | 30 | 250ms | 300ms | 252ms | 313ms | 375ms | 315ms
reference: [NESdev](https://www.nesdev.org/wiki/APU_Length_Counter)

View File

@ -265,6 +265,7 @@ size | description
| - 0xc5: YM2610B CSM - 20 channels
| - 0xde: YM2610B extended - 19 channels
| - 0xe0: QSound - 19 channels
| - 0xfc: Pong - 1 channel
| - 0xfd: Dummy System - 8 channels
| - 0xfe: reserved for development
| - 0xff: reserved for development

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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) {

View File

@ -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),

View File

@ -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;

View File

@ -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();

View File

@ -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;

View 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() {
}

View 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

View File

@ -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 {

View File

@ -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;

View File

@ -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;
}

View File

@ -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
};

View File

@ -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).",

View File

@ -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++) {

View File

@ -379,6 +379,14 @@ void FurnaceGUI::drawDebug() {
}
ImGui::TreePop();
}
if (ImGui::TreeNode("Window Debug")) {
ImGui::Text("Screen: %dx%d+%d+%d",scrW,scrH,scrX,scrY);
ImGui::Text("Screen (Conf): %dx%d+%d+%d",scrConfW,scrConfH,scrConfX,scrConfY);
ImGui::Text("Canvas: %dx%d",canvasW,canvasH);
ImGui::Text("Maximized: %d",scrMax);
ImGui::Text("System Managed Scale: %d",sysManagedScale);
ImGui::TreePop();
}
if (ImGui::TreeNode("Playground")) {
if (pgSys<0 || pgSys>=e->song.systemLen) pgSys=0;
if (ImGui::BeginCombo("Chip",fmt::sprintf("%d. %s",pgSys+1,e->getSystemName(e->song.system[pgSys])).c_str())) {

View File

@ -1340,7 +1340,7 @@ void FurnaceGUI::doAction(int what) {
wave->max=255;
wave->len=end-start;
for (unsigned int i=start; i<end; i++) {
wave->data[i-start]=(sample->data8[i]&0xff)^0x80;
wave->data[i-start]=(((unsigned short)sample->data16[i]&0xff00)>>8)^0x80;
}
nextWindow=GUI_WINDOW_WAVE_EDIT;
MARK_MODIFIED;

View File

@ -3003,6 +3003,7 @@ bool FurnaceGUI::loop() {
scrH=ev.window.data2;
portrait=(scrW<scrH);
logV("portrait: %d (%dx%d)",portrait,scrW,scrH);
logD("window resized to %dx%d",scrW,scrH);
updateWindow=true;
break;
case SDL_WINDOWEVENT_MOVED:
@ -3020,6 +3021,15 @@ bool FurnaceGUI::loop() {
break;
}
break;
case SDL_DISPLAYEVENT: {
switch (ev.display.event) {
case SDL_DISPLAYEVENT_ORIENTATION:
logD("display oriented to %d",ev.display.data1);
updateWindow=true;
break;
}
break;
}
case SDL_KEYDOWN:
if (!ImGui::GetIO().WantCaptureKeyboard) {
keyDown(ev);
@ -3074,15 +3084,21 @@ bool FurnaceGUI::loop() {
// update config x/y/w/h values based on scrMax state
if (updateWindow) {
logV("updateWindow is true");
if (!scrMax) {
scrConfX=scrX;
scrConfY=scrY;
scrConfW=scrW;
scrConfH=scrH;
}
// update canvas size as well
SDL_GetRendererOutputSize(sdlRend,&canvasW,&canvasH);
}
// update canvas size as well
if (SDL_GetRendererOutputSize(sdlRend,&canvasW,&canvasH)!=0) {
logW("loop: error while getting output size! %s",SDL_GetError());
} else {
//logV("updateWindow: canvas size %dx%d",canvasW,canvasH);
// and therefore window size
SDL_GetWindowSize(sdlWin,&scrW,&scrH);
}
wantCaptureKeyboard=ImGui::GetIO().WantTextInput;

View File

@ -961,6 +961,7 @@ const int availableSystems[]={
DIV_SYSTEM_SNES,
DIV_SYSTEM_MSM5232,
DIV_SYSTEM_PCM_DAC,
DIV_SYSTEM_PONG,
0 // don't remove this last one!
};

View File

@ -1104,42 +1104,6 @@ void FurnaceGUI::initSystemPresets() {
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"ZX Spectrum (128K) with TurboSound FM + SAA", {
DIV_SYSTEM_AY8910, 64, 0, 1,
DIV_SYSTEM_OPN, 64, 0, 1,
DIV_SYSTEM_OPN, 64, 0, 1,
DIV_SYSTEM_SAA1099, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"ZX Spectrum (128K) with TurboSound FM + SAA (extended channel 3 on first OPN)", {
DIV_SYSTEM_AY8910, 64, 0, 1,
DIV_SYSTEM_OPN_EXT, 64, 0, 1,
DIV_SYSTEM_OPN, 64, 0, 1,
DIV_SYSTEM_SAA1099, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"ZX Spectrum (128K) with TurboSound FM + SAA (extended channel 3 on second OPN)", {
DIV_SYSTEM_AY8910, 64, 0, 1,
DIV_SYSTEM_OPN, 64, 0, 1,
DIV_SYSTEM_OPN_EXT, 64, 0, 1,
DIV_SYSTEM_SAA1099, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"ZX Spectrum (128K) with TurboSound FM + SAA (extended channel 3 on both OPNs)", {
DIV_SYSTEM_AY8910, 64, 0, 1,
DIV_SYSTEM_OPN_EXT, 64, 0, 1,
DIV_SYSTEM_OPN_EXT, 64, 0, 1,
DIV_SYSTEM_SAA1099, 64, 0, 0,
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"ZX Spectrum (128K) with TurboSound", {
DIV_SYSTEM_AY8910, 64, 0, 1,

View File

@ -18,6 +18,7 @@
*/
#include "gui.h"
#include <imgui.h>
void FurnaceGUI::drawRegView() {
if (nextWindow==GUI_WINDOW_REGISTER_VIEW) {
@ -38,6 +39,8 @@ void FurnaceGUI::drawRegView() {
} else {
ImGui::PushFont(patFont);
if (ImGui::BeginTable("Memory",17)) {
ImGui::TableSetupColumn("addr",ImGuiTableColumnFlags_WidthFixed);
ImGui::TableNextRow();
ImGui::TableNextColumn();
for (int i=0; i<16; i++) {

View File

@ -1442,6 +1442,7 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo
case DIV_SYSTEM_YMU759:
case DIV_SYSTEM_PET:
case DIV_SYSTEM_T6W28:
case DIV_SYSTEM_VBOY:
ImGui::Text("nothing to configure");
break;
default: {