unlock the power of DECIMAL HZ!
This commit is contained in:
parent
02760ddcbc
commit
02e9edbad9
7 changed files with 41 additions and 31 deletions
|
|
@ -1095,18 +1095,18 @@ unsigned char DivEngine::getSpeed2() {
|
|||
return speed2;
|
||||
}
|
||||
|
||||
int DivEngine::getHz() {
|
||||
float DivEngine::getHz() {
|
||||
if (song.customTempo) {
|
||||
return song.hz;
|
||||
} else if (song.pal) {
|
||||
return 60;
|
||||
return 60.0;
|
||||
} else {
|
||||
return 50;
|
||||
return 50.0;
|
||||
}
|
||||
return 60;
|
||||
return 60.0;
|
||||
}
|
||||
|
||||
int DivEngine::getCurHz() {
|
||||
float DivEngine::getCurHz() {
|
||||
return divider;
|
||||
}
|
||||
|
||||
|
|
@ -2216,11 +2216,12 @@ void DivEngine::setSysFlags(int system, unsigned int flags, bool restart) {
|
|||
isBusy.unlock();
|
||||
}
|
||||
|
||||
void DivEngine::setSongRate(int hz, bool pal) {
|
||||
void DivEngine::setSongRate(float hz, bool pal) {
|
||||
isBusy.lock();
|
||||
song.pal=!pal;
|
||||
song.hz=hz;
|
||||
song.customTempo=(song.hz!=50 && song.hz!=60);
|
||||
// what?
|
||||
song.customTempo=true;
|
||||
divider=60;
|
||||
if (song.customTempo) {
|
||||
divider=song.hz;
|
||||
|
|
|
|||
|
|
@ -182,8 +182,11 @@ class DivEngine {
|
|||
bool halted;
|
||||
bool forceMono;
|
||||
bool cmdStreamEnabled;
|
||||
int ticks, curRow, curOrder, remainingLoops, nextSpeed, divider;
|
||||
int cycles, clockDrift, stepPlay;
|
||||
int ticks, curRow, curOrder, remainingLoops, nextSpeed;
|
||||
double divider;
|
||||
int cycles;
|
||||
double clockDrift;
|
||||
int stepPlay;
|
||||
int changeOrd, changePos, totalSeconds, totalTicks, totalTicksR, totalCmds, lastCmds, cmdsPerSecond, globalPitch;
|
||||
unsigned char extValue;
|
||||
unsigned char speed1, speed2;
|
||||
|
|
@ -431,10 +434,10 @@ class DivEngine {
|
|||
unsigned char getSpeed2();
|
||||
|
||||
// get Hz
|
||||
int getHz();
|
||||
float getHz();
|
||||
|
||||
// get current Hz
|
||||
int getCurHz();
|
||||
float getCurHz();
|
||||
|
||||
// get time
|
||||
int getTotalTicks(); // 1/1000000th of a second
|
||||
|
|
@ -526,7 +529,7 @@ class DivEngine {
|
|||
void setSysFlags(int system, unsigned int flags, bool restart);
|
||||
|
||||
// set Hz
|
||||
void setSongRate(int hz, bool pal);
|
||||
void setSongRate(float hz, bool pal);
|
||||
|
||||
// set remaining loops. -1 means loop forever.
|
||||
void setLoops(int loops);
|
||||
|
|
|
|||
|
|
@ -841,7 +841,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
ds.arpLen=reader.readC();
|
||||
ds.hz=reader.readF();
|
||||
ds.pal=(ds.hz>=53);
|
||||
if (ds.hz!=50 && ds.hz!=60) ds.customTempo=true;
|
||||
ds.customTempo=true;
|
||||
|
||||
ds.patLen=reader.readS();
|
||||
ds.ordersLen=reader.readS();
|
||||
|
|
@ -2064,7 +2064,7 @@ SafeWriter* DivEngine::saveDMF(unsigned char version) {
|
|||
w->writeC(song.customTempo);
|
||||
char customHz[4];
|
||||
memset(customHz,0,4);
|
||||
snprintf(customHz,4,"%d",song.hz);
|
||||
snprintf(customHz,4,"%d",(int)song.hz);
|
||||
w->write(customHz,3);
|
||||
w->writeI(song.patLen);
|
||||
w->writeC(song.ordersLen);
|
||||
|
|
|
|||
|
|
@ -946,7 +946,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
|||
globalPitch+=(signed char)(effectVal-0x80);
|
||||
break;
|
||||
case 0xf0: // set Hz by tempo
|
||||
divider=(effectVal*2+2)/5;
|
||||
divider=(double)effectVal*2.0/5.0;
|
||||
if (divider<10) divider=10;
|
||||
cycles=((int)(got.rate)<<MASTER_CLOCK_PREC)/divider;
|
||||
clockDrift=0;
|
||||
|
|
@ -1166,7 +1166,7 @@ bool DivEngine::nextTick(bool noAccum) {
|
|||
if (divider<10) divider=10;
|
||||
|
||||
cycles=((int)(got.rate)<<MASTER_CLOCK_PREC)/divider;
|
||||
clockDrift+=((int)(got.rate)<<MASTER_CLOCK_PREC)%divider;
|
||||
clockDrift+=fmod((double)((int)(got.rate)<<MASTER_CLOCK_PREC),(double)divider);
|
||||
if (clockDrift>=divider) {
|
||||
clockDrift-=divider;
|
||||
cycles++;
|
||||
|
|
|
|||
|
|
@ -271,8 +271,8 @@ struct DivSong {
|
|||
unsigned char timeBase, speed1, speed2, arpLen;
|
||||
bool pal;
|
||||
bool customTempo;
|
||||
// TODO: change Hz to float?
|
||||
int hz, patLen, ordersLen, insLen, waveLen, sampleLen;
|
||||
float hz;
|
||||
int patLen, ordersLen, insLen, waveLen, sampleLen;
|
||||
float masterVol;
|
||||
float tuning;
|
||||
|
||||
|
|
@ -345,7 +345,7 @@ struct DivSong {
|
|||
arpLen(1),
|
||||
pal(true),
|
||||
customTempo(false),
|
||||
hz(60),
|
||||
hz(60.0),
|
||||
patLen(64),
|
||||
ordersLen(1),
|
||||
insLen(0),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue