Revert "add undo to instrument editor (check for diffs on the current DivInstrument in insEdit, record them in a stack)"

This reverts commit 5c9fd69ac1.
This commit is contained in:
tildearrow 2024-08-19 02:49:14 -05:00
parent f1de0bf2b7
commit d3af810462
8 changed files with 55 additions and 307 deletions

View file

@ -23,10 +23,8 @@
#include "dataErrors.h"
#include "../ta-utils.h"
#include "../pch.h"
#include "../fixedQueue.h"
struct DivSong;
struct DivInstrument;
// NOTICE!
// before adding new instrument types to this struct, please ask me first.
@ -862,7 +860,8 @@ struct DivInstrumentSID2 {
noiseMode(0) {}
};
struct DivInstrumentPOD {
struct DivInstrument {
String name;
DivInstrumentType type;
DivInstrumentFM fm;
DivInstrumentSTD std;
@ -881,63 +880,6 @@ struct DivInstrumentPOD {
DivInstrumentPowerNoise powernoise;
DivInstrumentSID2 sid2;
DivInstrumentPOD() :
type(DIV_INS_FM) {
}
};
struct MemPatch {
MemPatch() :
data(nullptr)
, offset(0)
, size(0) {
}
~MemPatch() {
if (data) {
free(data);
}
}
void clear();
bool calcDiff(const void* pre, const void* post, size_t size);
void applyAndReverse(void* target, size_t inputSize);
bool isValid() const { return size > 0; }
uint8_t* data;
size_t offset;
size_t size;
};
struct DivInstrumentUndoStep {
DivInstrumentUndoStep() :
name(""),
nameValid(false),
processTime(0) {
}
MemPatch podPatch;
String name;
bool nameValid;
size_t processTime;
void clear();
void applyAndReverse(DivInstrument* target);
bool makeUndoPatch(size_t processTime_, const DivInstrument* pre, const DivInstrument* post);
};
struct DivInstrument : DivInstrumentPOD {
String name;
/**
* undo stuff
*/
FixedQueue<DivInstrumentUndoStep*, 128> undoHist;
FixedQueue<DivInstrumentUndoStep*, 128> redoHist;
void recordUndoStepIfChanged(size_t processTime, const DivInstrument* old);
int undo();
int redo();
/**
* these are internal functions.
*/
@ -1022,11 +964,9 @@ struct DivInstrument : DivInstrumentPOD {
* @return whether it was successful.
*/
bool saveDMP(const char* path);
DivInstrument() :
name("") {
// clear and construct DivInstrumentPOD so it doesn't have any garbage in the padding
memset((DivInstrumentPOD*)this, 0, sizeof(DivInstrumentPOD));
new ((DivInstrumentPOD*)this) DivInstrumentPOD;
DivInstrument():
name(""),
type(DIV_INS_FM) {
}
};
#endif