prepare for multiple chip support

This commit is contained in:
tildearrow 2022-01-08 01:57:37 -05:00
parent 6aab9f01cf
commit 121a9b2cb8
9 changed files with 35 additions and 29 deletions

View file

@ -141,6 +141,10 @@ int DivEngine::getChannelCount(DivSystem sys) {
return 0;
}
int DivEngine::getTotalChannelCount() {
return chans;
}
const char* DivEngine::getSystemName(DivSystem sys) {
switch (sys) {
case DIV_SYSTEM_NULL:
@ -1579,7 +1583,7 @@ void DivEngine::stop() {
}
void DivEngine::reset() {
for (int i=0; i<17; i++) {
for (int i=0; i<DIV_MAX_CHANS; i++) {
chan[i]=DivChannelState();
chan[i].volMax=(dispatch->dispatch(DivCommand(DIV_CMD_GET_VOLMAX,i))<<8)|0xff;
chan[i].volume=chan[i].volMax;
@ -2132,7 +2136,7 @@ void DivEngine::quitDispatch() {
totalCmds=0;
lastCmds=0;
cmdsPerSecond=0;
for (int i=0; i<17; i++) {
for (int i=0; i<DIV_MAX_CHANS; i++) {
isMuted[i]=0;
}
isBusy.unlock();
@ -2281,7 +2285,7 @@ bool DivEngine::init(String outName) {
vibTable[i]=127*sin(((double)i/64.0)*(2*M_PI));
}
for (int i=0; i<17; i++) {
for (int i=0; i<DIV_MAX_CHANS; i++) {
isMuted[i]=0;
}

View file

@ -12,7 +12,6 @@
// TODO;
// - prepare for multi-chip support
// - implement the .fur format
// - increase all 17 fields to 128 or more
#define DIV_VERSION "0.2.2"
#define DIV_ENGINE_VERSION 14
@ -112,11 +111,11 @@ class DivEngine {
unsigned char extValue;
unsigned char speed1, speed2;
DivStatusView view;
DivChannelState chan[17];
DivChannelState chan[DIV_MAX_CHANS];
DivAudioEngines audioEngine;
std::map<String,String> conf;
std::queue<DivNoteEvent> pendingNotes;
bool isMuted[17];
bool isMuted[DIV_MAX_CHANS];
std::mutex isBusy;
String configPath;
String configFile;
@ -211,7 +210,7 @@ class DivEngine {
// get sys channel count
int getChannelCount(DivSystem sys);
// TODO: get channel count
// get channel count
int getTotalChannelCount();
// get channel type

View file

@ -1,7 +1,7 @@
struct DivOrders {
unsigned char ord[32][128];
unsigned char ord[DIV_MAX_CHANS][128];
DivOrders() {
memset(ord,0,32*128);
memset(ord,0,DIV_MAX_CHANS*128);
}
};

View file

@ -76,7 +76,7 @@ void DivPlatformDummy::reset() {
int DivPlatformDummy::init(DivEngine* p, int channels, int sugRate, bool pal) {
parent=p;
skipRegisterWrites=false;
for (int i=0; i<17; i++) {
for (int i=0; i<DIV_MAX_CHANS; i++) {
isMuted[i]=false;
}
rate=65536;

View file

@ -12,8 +12,8 @@ class DivPlatformDummy: public DivDispatch {
signed char amp;
Channel(): freq(0), baseFreq(0), pitch(0), pos(0), active(false), freqChanged(false), vol(0), amp(64) {}
};
Channel chan[17];
bool isMuted[17];
Channel chan[128];
bool isMuted[128];
unsigned char chans;
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);

View file

@ -16,7 +16,7 @@ void DivSong::unload() {
}
sample.clear();
for (int i=0; i<17; i++) {
for (int i=0; i<DIV_MAX_CHANS; i++) {
pat[i].wipePatterns();
}
}

View file

@ -1,5 +1,8 @@
#include <stdio.h>
#include <vector>
#define DIV_MAX_CHANS 128
#include "../ta-utils.h"
#include "orders.h"
#include "instrument.h"
@ -94,7 +97,7 @@ struct DivSong {
DivOrders orders;
std::vector<DivInstrument*> ins;
DivChannelData pat[17];
DivChannelData pat[DIV_MAX_CHANS];
std::vector<DivWavetable*> wave;
std::vector<DivSample*> sample;