possibly fix VGM, ZSM and SAP-R export

issue #2408
This commit is contained in:
tildearrow 2025-03-11 11:23:25 -05:00
parent 6ae3f33513
commit 79e71c3d02
3 changed files with 3 additions and 19 deletions

View file

@ -27,9 +27,6 @@
#include <array>
#include <vector>
constexpr int MASTER_CLOCK_PREC=(sizeof(void*)==8)?8:0;
constexpr int MASTER_CLOCK_MASK=(sizeof(void*)==8)?0xff:0;
static String ticksToTime(double rate, int ticks) {
double timing = ticks / rate;
@ -112,7 +109,6 @@ void DivExportSAPR::run() {
// Prepare to write song data.
e->playSub(false);
bool done=false;
int fracWait=0; // accumulates fractional ticks
e->disCont[POKEY].dispatch->toggleRegisterDump(true);
std::array<uint8_t, 9> currRegs;
@ -136,10 +132,7 @@ void DivExportSAPR::run() {
// write wait
tickCount++;
int totalWait=e->cycles>>MASTER_CLOCK_PREC;
fracWait+=e->cycles&MASTER_CLOCK_MASK;
totalWait+=fracWait>>MASTER_CLOCK_PREC;
fracWait&=MASTER_CLOCK_MASK;
int totalWait=e->cycles;
if (totalWait>0 && !done) {
while (totalWait) {
regs.push_back(currRegs);

View file

@ -518,9 +518,6 @@ void DivZSM::flushTicks() {
/// ZSM export
constexpr int MASTER_CLOCK_PREC=(sizeof(void*)==8)?8:0;
constexpr int MASTER_CLOCK_MASK=(sizeof(void*)==8)?0xff:0;
void DivExportZSM::run() {
// settings
unsigned int zsmrate=conf.getInt("zsmrate",60);
@ -598,7 +595,6 @@ void DivExportZSM::run() {
bool done=false;
bool loopNow=false;
int loopPos=-1;
int fracWait=0; // accumulates fractional ticks
if (VERA>=0) e->disCont[VERA].dispatch->toggleRegisterDump(true);
if (YM>=0) {
e->disCont[YM].dispatch->toggleRegisterDump(true);
@ -687,10 +683,7 @@ void DivExportZSM::run() {
}
// write wait
int totalWait=e->cycles>>MASTER_CLOCK_PREC;
fracWait+=e->cycles&MASTER_CLOCK_MASK;
totalWait+=fracWait>>MASTER_CLOCK_PREC;
fracWait&=MASTER_CLOCK_MASK;
int totalWait=e->cycles;
if (totalWait>0 && !done) {
zsm.tick(totalWait);
//tickCount+=totalWait;

View file

@ -22,8 +22,6 @@
#include "../utfutils.h"
#include "song.h"
constexpr int MASTER_CLOCK_PREC=(sizeof(void*)==8)?8:0;
// this function is so long
// may as well make it something else
void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write, int streamOff, double* loopTimer, double* loopFreq, int* loopSample, bool* sampleDir, bool isSecond, int* pendingFreq, int* playingSample, int* setPos, unsigned int* sampleOff8, unsigned int* sampleLen8, size_t bankOffset, bool directStream, bool* sampleStoppable) {
@ -2741,7 +2739,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
};
// calculate number of samples in this tick
int totalWait=cycles>>MASTER_CLOCK_PREC;
int totalWait=cycles;
// get register dumps and put them into delayed writes
int writeNum=0;