prepare to allow disable opt passes
This commit is contained in:
parent
e9911ab0aa
commit
27cde60f0b
|
|
@ -103,6 +103,14 @@ class DivCSPlayer {
|
||||||
stream(buf,len) {}
|
stream(buf,len) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DivCSProgress {
|
||||||
|
int stage, count, total;
|
||||||
|
DivCSProgress():
|
||||||
|
stage(0),
|
||||||
|
count(0),
|
||||||
|
total(0) {}
|
||||||
|
};
|
||||||
|
|
||||||
// command stream utilities
|
// command stream utilities
|
||||||
namespace DivCS {
|
namespace DivCS {
|
||||||
int getCmdLength(unsigned char ext);
|
int getCmdLength(unsigned char ext);
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,6 @@
|
||||||
#include "../ta-log.h"
|
#include "../ta-log.h"
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
//#define DISABLE_BLOCK_SEARCH
|
|
||||||
|
|
||||||
int DivCS::getCmdLength(unsigned char ext) {
|
int DivCS::getCmdLength(unsigned char ext) {
|
||||||
switch (ext) {
|
switch (ext) {
|
||||||
case DIV_CMD_SAMPLE_MODE:
|
case DIV_CMD_SAMPLE_MODE:
|
||||||
|
|
@ -673,7 +671,7 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
||||||
for (size_t groupSize=stream->size()>>1; groupSize>=8; groupSize--) {
|
for (size_t groupSize=stream->size()>>1; groupSize>=8; groupSize--) {
|
||||||
//for (size_t groupSize=7; groupSize<=stream->size()>>1; groupSize++) {
|
//for (size_t groupSize=7; groupSize<=stream->size()>>1; groupSize++) {
|
||||||
bool foundSomething=false;
|
bool foundSomething=false;
|
||||||
//logD("...try size %d",groupSize);
|
logV("...try size %d",groupSize);
|
||||||
for (size_t searchPos=0; (searchPos+groupSize)<stream->size();) {
|
for (size_t searchPos=0; (searchPos+groupSize)<stream->size();) {
|
||||||
const unsigned char* group=&buf[searchPos];
|
const unsigned char* group=&buf[searchPos];
|
||||||
size_t groupLen=0;
|
size_t groupLen=0;
|
||||||
|
|
@ -792,7 +790,7 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
SafeWriter* DivEngine::saveCommand() {
|
SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, unsigned int disablePasses) {
|
||||||
stop();
|
stop();
|
||||||
repeatPattern=false;
|
repeatPattern=false;
|
||||||
shallStop=false;
|
shallStop=false;
|
||||||
|
|
@ -932,6 +930,7 @@ SafeWriter* DivEngine::saveCommand() {
|
||||||
BUSY_END;
|
BUSY_END;
|
||||||
|
|
||||||
// PASS 1: optimize command calls
|
// PASS 1: optimize command calls
|
||||||
|
if (!(disablePasses&1)) {
|
||||||
// calculate command usage
|
// calculate command usage
|
||||||
int sortCand=-1;
|
int sortCand=-1;
|
||||||
int sortPos=0;
|
int sortPos=0;
|
||||||
|
|
@ -954,7 +953,7 @@ SafeWriter* DivEngine::saveCommand() {
|
||||||
sortPos++;
|
sortPos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set speed dial commands (TODO)
|
// set speed dial commands
|
||||||
for (int h=0; h<chans; h++) {
|
for (int h=0; h<chans; h++) {
|
||||||
unsigned char* buf=chanStream[h]->getFinalBuf();
|
unsigned char* buf=chanStream[h]->getFinalBuf();
|
||||||
for (size_t i=0; i<chanStream[h]->size();) {
|
for (size_t i=0; i<chanStream[h]->size();) {
|
||||||
|
|
@ -981,8 +980,10 @@ SafeWriter* DivEngine::saveCommand() {
|
||||||
i+=insLen;
|
i+=insLen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// PASS 2: condense delays
|
// PASS 2: condense delays
|
||||||
|
if (!(disablePasses&2)) {
|
||||||
// calculate delay usage
|
// calculate delay usage
|
||||||
for (int h=0; h<chans; h++) {
|
for (int h=0; h<chans; h++) {
|
||||||
unsigned char* buf=chanStream[h]->getFinalBuf();
|
unsigned char* buf=chanStream[h]->getFinalBuf();
|
||||||
|
|
@ -1006,8 +1007,8 @@ SafeWriter* DivEngine::saveCommand() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// preset delays
|
// preset delays
|
||||||
sortCand=-1;
|
int sortCand=-1;
|
||||||
sortPos=0;
|
int sortPos=0;
|
||||||
while (sortPos<16) {
|
while (sortPos<16) {
|
||||||
sortCand=-1;
|
sortCand=-1;
|
||||||
for (int i=0; i<256; i++) {
|
for (int i=0; i<256; i++) {
|
||||||
|
|
@ -1083,6 +1084,7 @@ SafeWriter* DivEngine::saveCommand() {
|
||||||
i+=insLen;
|
i+=insLen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// PASS 3: remove nop's
|
// PASS 3: remove nop's
|
||||||
// this includes modifying call addresses to compensate
|
// this includes modifying call addresses to compensate
|
||||||
|
|
@ -1090,8 +1092,8 @@ SafeWriter* DivEngine::saveCommand() {
|
||||||
chanStream[h]=stripNops(chanStream[h],sortedCmd);
|
chanStream[h]=stripNops(chanStream[h],sortedCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_BLOCK_SEARCH
|
|
||||||
// PASS 4: find sub-blocks and isolate them
|
// PASS 4: find sub-blocks and isolate them
|
||||||
|
if (!(disablePasses&4)) {
|
||||||
for (int h=0; h<chans; h++) {
|
for (int h=0; h<chans; h++) {
|
||||||
std::vector<SafeWriter*> subBlocks;
|
std::vector<SafeWriter*> subBlocks;
|
||||||
size_t beforeSize=chanStream[h]->size();
|
size_t beforeSize=chanStream[h]->size();
|
||||||
|
|
@ -1184,7 +1186,7 @@ SafeWriter* DivEngine::saveCommand() {
|
||||||
size_t afterSize=chanStream[h]->size();
|
size_t afterSize=chanStream[h]->size();
|
||||||
logI("(before: %d - after: %d)",(int)beforeSize,(int)afterSize);
|
logI("(before: %d - after: %d)",(int)beforeSize,(int)afterSize);
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
// PASS 5: remove nop's (again)
|
// PASS 5: remove nop's (again)
|
||||||
for (int h=0; h<chans; h++) {
|
for (int h=0; h<chans; h++) {
|
||||||
|
|
|
||||||
|
|
@ -730,7 +730,7 @@ class DivEngine {
|
||||||
// dump to TIunA.
|
// dump to TIunA.
|
||||||
SafeWriter* saveTiuna(const bool* sysToExport, const char* baseLabel, int firstBankSize, int otherBankSize);
|
SafeWriter* saveTiuna(const bool* sysToExport, const char* baseLabel, int firstBankSize, int otherBankSize);
|
||||||
// dump command stream.
|
// dump command stream.
|
||||||
SafeWriter* saveCommand();
|
SafeWriter* saveCommand(DivCSProgress* progress=NULL, unsigned int disablePasses=0);
|
||||||
// export to text
|
// export to text
|
||||||
SafeWriter* saveText(bool separatePatterns=true);
|
SafeWriter* saveText(bool separatePatterns=true);
|
||||||
// export to an audio file
|
// export to an audio file
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue