Merge branch 'tildearrow:master' into master

This commit is contained in:
DevEd 2023-10-02 01:07:35 -04:00 committed by GitHub
commit ac85732ef2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
83 changed files with 602 additions and 211 deletions

View file

@ -21,8 +21,6 @@
#define _DIVCONFIG_H
#include "../ta-utils.h"
#include <map>
#include <vector>
#include <initializer_list>
class DivConfig {

View file

@ -22,7 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <vector>
#include "../pch.h"
#include "config.h"
#include "chipUtils.h"

View file

@ -30,13 +30,9 @@
#include "cmdStream.h"
#include "../audio/taAudio.h"
#include "blip_buf.h"
#include <atomic>
#include <functional>
#include <initializer_list>
#include <thread>
#include <mutex>
#include <map>
#include <unordered_map>
#include "../fixedQueue.h"
class DivWorkPool;
@ -56,10 +52,10 @@ class DivWorkPool;
#define EXTERN_BUSY_BEGIN_SOFT e->softLocked=true; e->isBusy.lock();
#define EXTERN_BUSY_END e->isBusy.unlock(); e->softLocked=false;
#define DIV_UNSTABLE
//#define DIV_UNSTABLE
#define DIV_VERSION "0.6pre16"
#define DIV_ENGINE_VERSION 178
#define DIV_VERSION "0.6"
#define DIV_ENGINE_VERSION 181
// for imports
#define DIV_VERSION_MOD 0xff01
#define DIV_VERSION_FC 0xff02

View file

@ -22,7 +22,7 @@
#include "song.h"
#include <initializer_list>
#include <vector>
#include "../pch.h"
class DivEngine;

View file

@ -464,6 +464,13 @@ DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth,
accum/=channels;
sample->data8[i]=accum;
}
if (bigEndian) {
for (unsigned int i=0; (i+1)<samples; i+=2) {
sample->data8[i]^=sample->data8[i^1];
sample->data8[i^1]^=sample->data8[i];
sample->data8[i]^=sample->data8[i^1];
}
}
} else {
memcpy(sample->getCurBuf(),buf,len);
}

View file

@ -22,7 +22,7 @@
#include "safeWriter.h"
#include "dataErrors.h"
#include "../ta-utils.h"
#include <vector>
#include "../pch.h"
struct DivSong;

View file

@ -18,7 +18,7 @@
*/
#include "safeReader.h"
#include <vector>
#include "../pch.h"
struct DivPattern {
String name;

View file

@ -21,7 +21,6 @@
#include "../engine.h"
#include "../../ta-log.h"
#include <math.h>
#include <map>
#define CHIP_FREQBASE (is219?74448896:12582912)
@ -246,10 +245,10 @@ void DivPlatformC140::tick(bool sysTick) {
if (chan[i].sample>=0 && chan[i].sample<parent->song.sampleLen && s->isLoopable()) {
if (is219) {
loop=MIN(start+(s->loopStart>>1),65535);
end=MIN(start+(s->loopEnd>>1)-1,65535);
end=MIN(start+(s->loopEnd>>1),65535);
} else {
loop=MIN(start+s->loopStart,65535);
end=MIN(start+s->loopEnd-1,65535);
loop=MIN(start+s->loopStart+1,65535);
end=MIN(start+s->loopEnd+1,65535);
}
} else if (chan[i].noise && is219) {
loop=0;
@ -576,7 +575,7 @@ void DivPlatformC140::renderSamples(int sysID) {
}
if (is219) { // C219 (8-bit)
unsigned int length=s->length8;
unsigned int length=s->length8+4;
// fit sample size to single bank size
if (length>131072) {
length=131072;
@ -595,27 +594,39 @@ void DivPlatformC140::renderSamples(int sysID) {
logW("out of C219 memory for sample %d!",i);
}
if (s->depth==DIV_SAMPLE_DEPTH_C219) {
unsigned char next=0;
unsigned int sPos=0;
for (unsigned int i=0; i<length; i++) {
if (i>=s->lengthC219) {
sampleMem[(memPos+i)^1]=0;
} else {
sampleMem[(memPos+i)^1]=s->dataC219[i];
if (sPos<s->lengthC219) {
next=s->dataC219[sPos++];
if (s->isLoopable()) {
if ((int)sPos>=s->loopEnd) {
sPos=s->loopStart;
}
}
}
sampleMem[(memPos+i)^1]=next;
}
} else {
signed char next=0;
unsigned int sPos=0;
for (unsigned int i=0; i<length; i++) {
if (i>=s->length8) {
sampleMem[(memPos+i)^1]=0;
} else {
sampleMem[(memPos+i)^1]=s->data8[i];
if (sPos<s->length8) {
next=s->data8[sPos++];
if (s->isLoopable()) {
if ((int)sPos>=s->loopEnd) {
sPos=s->loopStart;
}
}
}
sampleMem[(memPos+i)^1]=next;
}
}
sampleOff[i]=memPos>>1;
sampleLoaded[i]=true;
memPos+=length;
} else { // C140 (16-bit)
unsigned int length=s->length16;
unsigned int length=s->length16+4;
// fit sample size to single bank size
if (length>(131072)) {
length=131072;
@ -642,7 +653,20 @@ void DivPlatformC140::renderSamples(int sysID) {
sampleMem[1+i+memPos]=c140Mu;
}
} else {
memcpy(sampleMem+memPos,s->data16,length);
short next=0;
unsigned int sPos=0;
for (unsigned int i=0; i<length; i+=2) {
if (sPos<s->samples) {
next=s->data16[sPos++];
if (s->isLoopable()) {
if ((int)sPos>=s->loopEnd) {
sPos=s->loopStart;
}
}
}
sampleMem[memPos+i]=((unsigned short)next);
sampleMem[memPos+i+1]=((unsigned short)next)>>8;
}
}
sampleOff[i]=memPos>>1;
sampleLoaded[i]=true;

View file

@ -21,7 +21,6 @@
#include "../engine.h"
#include "../../ta-log.h"
#include <math.h>
#include <map>
#define PITCH_OFFSET ((double)(16*2048*(chanMax+1)))
#define NOTE_ES5506(c,note) (parent->calcBaseFreq(chipClock,chan[c].pcm.freqOffs,note,false))

View file

@ -431,7 +431,7 @@ DivMacroInt* DivPlatformK007232::getChanMacroInt(int ch) {
}
unsigned short DivPlatformK007232::getPan(int ch) {
return ((chan[ch].panning&15)<<8)|((chan[ch].panning&0xf0)>>4);
return stereo?(((chan[ch].panning&15)<<8)|((chan[ch].panning&0xf0)>>4)):0;
}
DivDispatchOscBuffer* DivPlatformK007232::getOscBuffer(int ch) {

View file

@ -185,7 +185,7 @@ int DivPlatformMSM6295::dispatch(DivCommand c) {
chan[c.chan].std.release();
break;
case DIV_CMD_VOLUME: {
chan[c.chan].vol=c.value;
chan[c.chan].vol=MIN(8,c.value);
if (!chan[c.chan].std.vol.has) {
chan[c.chan].outVol=c.value;
}

View file

@ -201,7 +201,7 @@ void DivPlatformNamcoWSG::tick(bool sysTick) {
if (chan[i].std.vol.had) {
chan[i].outVol=((chan[i].vol&15)*MIN(15,chan[i].std.vol.val))>>4;
}
if (chan[i].std.duty.had && i>=4) {
if (chan[i].std.duty.had) {
chan[i].noise=chan[i].std.duty.val;
chan[i].freqChanged=true;
}
@ -418,6 +418,7 @@ int DivPlatformNamcoWSG::dispatch(DivCommand c) {
}
case DIV_CMD_STD_NOISE_MODE:
chan[c.chan].noise=c.value;
chan[c.chan].freqChanged=true;
break;
case DIV_CMD_PANNING: {
chan[c.chan].pan=(c.value&0xf0)|(c.value2>>4);

View file

@ -23,7 +23,6 @@
#include "../dispatch.h"
#include "../../fixedQueue.h"
#include <thread>
#include <mutex>
#include <condition_variable>
class DivPlatformPCSpeaker: public DivDispatch {

View file

@ -21,7 +21,6 @@
#include "../engine.h"
#include "../../ta-log.h"
#include <math.h>
#include <map>
#define CHIP_DIVIDER (1248*2)
#define QS_NOTE_FREQUENCY(x) parent->calcBaseFreq(440,4096,(x)-3,false)

View file

@ -104,7 +104,7 @@ void c140_voice_tick(struct c140_t *c140, const unsigned char v, const int cycle
if (!voice->muted)
{
// fetch 12 bit sample
signed short s1 = c140->sample_mem[((unsigned int)(voice->bank) << 16) | voice->addr] & ~0xf;
signed short s1 = c140->sample_mem[((unsigned int)(voice->bank) << 16) | (voice->addr & 0xffff)] & ~0xf;
signed short s2 = c140->sample_mem[((unsigned int)(voice->bank) << 16) | ((voice->addr + 1) & 0xffff)] & ~0xf;
if (voice->compressed)
{
@ -171,7 +171,7 @@ void c219_voice_tick(struct c219_t *c219, const unsigned char v, const int cycle
else
{
// fetch 8 bit sample
signed short s1 = c219->sample_mem[((unsigned int)(c219->bank[(v >> 2) & 3]) << 17) | (voice->addr^1)];
signed short s1 = c219->sample_mem[((unsigned int)(c219->bank[(v >> 2) & 3]) << 17) | ((voice->addr^1) & 0x1ffff)];
signed short s2 = c219->sample_mem[((unsigned int)(c219->bank[(v >> 2) & 3]) << 17) | (((voice->addr + 1) & 0x1ffff)^1)];
if (voice->compressed)
{

View file

@ -231,7 +231,7 @@ void DivPlatformYM2203::acquire_combo(short** buf, size_t len) {
buf[0][h]=os;
for (int i=0; i<3; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=fm_nuked.ch_out[i]<<1;
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(fm_nuked.ch_out[i]<<1,-32768,32767);
}
for (int i=3; i<6; i++) {
@ -282,7 +282,8 @@ void DivPlatformYM2203::acquire_ymfm(short** buf, size_t len) {
for (int i=0; i<3; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(fmChan[i]->debug_output(0)+fmChan[i]->debug_output(1))<<1;
int out=(fmChan[i]->debug_output(0)+fmChan[i]->debug_output(1))<<1;
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(out,-32768,32767);
}
for (int i=3; i<6; i++) {

View file

@ -402,7 +402,7 @@ void DivPlatformYM2608::acquire_combo(short** buf, size_t len) {
for (int i=0; i<psgChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=fm_nuked.ch_out[i]<<1;
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(fm_nuked.ch_out[i]<<1,-32768,32767);
}
ssge->get_last_out(ssgOut);
@ -471,7 +471,8 @@ void DivPlatformYM2608::acquire_ymfm(short** buf, size_t len) {
buf[1][h]=os[1];
for (int i=0; i<6; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(fmChan[i]->debug_output(0)+fmChan[i]->debug_output(1))<<1;
int out=(fmChan[i]->debug_output(0)+fmChan[i]->debug_output(1))<<1;
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(out,-32768,32767);
}
ssge->get_last_out(ssgOut);

View file

@ -333,7 +333,7 @@ void DivPlatformYM2610::acquire_combo(short** buf, size_t len) {
for (int i=0; i<psgChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=fm_nuked.ch_out[bchOffs[i]]<<1;
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(fm_nuked.ch_out[bchOffs[i]]<<1,-32768,32767);
}
ssge->get_last_out(ssgOut);
@ -404,7 +404,8 @@ void DivPlatformYM2610::acquire_ymfm(short** buf, size_t len) {
buf[1][h]=os[1];
for (int i=0; i<psgChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(fmChan[i]->debug_output(0)+fmChan[i]->debug_output(1))<<1;
int out=(fmChan[i]->debug_output(0)+fmChan[i]->debug_output(1))<<1;
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(out,-32768,32767);
}
ssge->get_last_out(ssgOut);

View file

@ -401,7 +401,7 @@ void DivPlatformYM2610B::acquire_combo(short** buf, size_t len) {
for (int i=0; i<psgChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=fm_nuked.ch_out[i]<<1;
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(fm_nuked.ch_out[i]<<1,-32768,32767);
}
ssge->get_last_out(ssgOut);
@ -471,7 +471,8 @@ void DivPlatformYM2610B::acquire_ymfm(short** buf, size_t len) {
for (int i=0; i<psgChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(fmChan[i]->debug_output(0)+fmChan[i]->debug_output(1))<<1;
int out=(fmChan[i]->debug_output(0)+fmChan[i]->debug_output(1))<<1;
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(out,-32768,32767);
}
ssge->get_last_out(ssgOut);

View file

@ -21,7 +21,6 @@
#include "../engine.h"
#include "../../ta-log.h"
#include <math.h>
#include <map>
#define CHIP_FREQBASE 25165824

View file

@ -20,7 +20,7 @@
#ifndef _SONG_H
#define _SONG_H
#include <stdio.h>
#include <vector>
#include "../pch.h"
#include "defines.h"
#include "../ta-utils.h"

View file

@ -1181,7 +1181,7 @@ void DivEngine::registerSystems() {
sysDefs[DIV_SYSTEM_SWAN]=new DivSysDef(
"WonderSwan", NULL, 0x96, 0, 4, false, true, 0x171, false, 1U<<DIV_SAMPLE_DEPTH_8BIT,
"developed by the makers of the Game Boy and the Virtual Boy...",
{"Wave", "Wave/PCM", "Wave", "Wave/Noise"},
{"Wave", "Wave/PCM", "Wave/Sweep", "Wave/Noise"},
{"CH1", "CH2", "CH3", "CH4"},
{DIV_CH_WAVE, DIV_CH_PCM, DIV_CH_WAVE, DIV_CH_NOISE},
{DIV_INS_SWAN, DIV_INS_SWAN, DIV_INS_SWAN, DIV_INS_SWAN},
@ -1649,7 +1649,7 @@ void DivEngine::registerSystems() {
{0x1e, {DIV_CMD_SU_SYNC_PERIOD_LOW, "1Exx: Set phase reset period low byte"}},
{0x1f, {DIV_CMD_SU_SYNC_PERIOD_HIGH, "1Fxx: Set phase reset period high byte"}},
{0x20, {DIV_CMD_SU_SWEEP_ENABLE, "20xx: Toggle frequency sweep (bit 0-6: speed; bit 7: direction is up)", constVal<0>, effectVal}},
{0x21, {DIV_CMD_SU_SWEEP_ENABLE, "21xx: Toggle volume sweep (bit 0-4: speed; bit 5: direciton is up; bit 6: loop; bit 7: alternate)", constVal<1>, effectVal}},
{0x21, {DIV_CMD_SU_SWEEP_ENABLE, "21xx: Toggle volume sweep (bit 0-4: speed; bit 5: direction is up; bit 6: loop; bit 7: alternate)", constVal<1>, effectVal}},
{0x22, {DIV_CMD_SU_SWEEP_ENABLE, "22xx: Toggle cutoff sweep (bit 0-6: speed; bit 7: direction is up)", constVal<2>, effectVal}},
};
const EffectHandler suCutoffHandler(DIV_CMD_C64_FINE_CUTOFF, "4xxx: Set cutoff (0 to FFF)", effectValLong<12>);
@ -1708,6 +1708,10 @@ void DivEngine::registerSystems() {
EffectHandlerMap namcoEffectHandlerMap={
{0x10, {DIV_CMD_WAVE, "10xx: Set waveform"}},
};
EffectHandlerMap namcoC30EffectHandlerMap={
{0x10, {DIV_CMD_WAVE, "10xx: Set waveform"}},
{0x11, {DIV_CMD_STD_NOISE_MODE, "11xx: Toggle noise mode"}},
};
@ -1741,7 +1745,7 @@ void DivEngine::registerSystems() {
{DIV_CH_WAVE, DIV_CH_WAVE, DIV_CH_WAVE, DIV_CH_WAVE, DIV_CH_WAVE, DIV_CH_WAVE, DIV_CH_WAVE, DIV_CH_WAVE},
{DIV_INS_NAMCO, DIV_INS_NAMCO, DIV_INS_NAMCO, DIV_INS_NAMCO, DIV_INS_NAMCO, DIV_INS_NAMCO, DIV_INS_NAMCO, DIV_INS_NAMCO},
{},
namcoEffectHandlerMap
namcoC30EffectHandlerMap
);
sysDefs[DIV_SYSTEM_MSM5232]=new DivSysDef(

View file

@ -1747,13 +1747,13 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
if (!hasRFC1) {
hasRFC1=disCont[i].dispatch->chipClock;
isSecond[i]=true;
CHIP_VOL(16,1.6);
CHIP_VOL(16,0.8);
willExport[i]=true;
writeRF5C68[1]=disCont[i].dispatch;
}
} else if (!hasRFC) {
hasRFC=disCont[i].dispatch->chipClock;
CHIP_VOL(5,1.6);
CHIP_VOL(5,1.1);
willExport[i]=true;
writeRF5C68[0]=disCont[i].dispatch;
}
@ -2418,8 +2418,10 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
}
while (!done) {
if (loopPos==-1) {
if (loopOrder==curOrder && loopRow==curRow && ticks==1) {
writeLoop=true;
if (loopOrder==curOrder && loopRow==curRow) {
if ((ticks-((tempoAccum+curSubSong->virtualTempoN)/curSubSong->virtualTempoD))<=0) {
writeLoop=true;
}
}
}
songTick++;

View file

@ -106,7 +106,6 @@ void DivEngine::runExportThread() {
if (sfWrap.doClose()!=0) {
logE("could not close audio file!");
}
exporting=false;
if (initAudioBackend()) {
for (int i=0; i<song.systemLen; i++) {
@ -118,6 +117,7 @@ void DivEngine::runExportThread() {
}
}
logI("done!");
exporting=false;
break;
}
case DIV_EXPORT_MODE_MANY_SYS: {
@ -217,7 +217,6 @@ void DivEngine::runExportThread() {
logE("could not close audio file!");
}
}
exporting=false;
if (initAudioBackend()) {
for (int i=0; i<song.systemLen; i++) {
@ -229,6 +228,7 @@ void DivEngine::runExportThread() {
}
}
logI("done!");
exporting=false;
break;
}
case DIV_EXPORT_MODE_MANY_CHAN: {
@ -336,7 +336,6 @@ void DivEngine::runExportThread() {
if (stopExport) break;
}
exporting=false;
delete[] outBuf[0];
delete[] outBuf[1];
@ -359,6 +358,7 @@ void DivEngine::runExportThread() {
}
}
logI("done!");
exporting=false;
break;
}
}

View file

@ -21,7 +21,6 @@
#define _WORKPOOL_H
#include <thread>
#include <mutex>
#include <atomic>
#include <functional>
#include <future>