Merge branch 'master' into fixedblock2

This commit is contained in:
tildearrow 2025-01-27 16:33:45 -05:00
commit 24cffc562a
18 changed files with 81 additions and 46 deletions

View file

@ -200,13 +200,16 @@ bool DivCSPlayer::tick() {
case DIV_CMD_HINT_PITCH:
arg0=(signed char)stream.readC();
break;
case DIV_CMD_PANNING:
case DIV_CMD_HINT_VIBRATO:
case DIV_CMD_HINT_ARPEGGIO:
case DIV_CMD_HINT_PORTA:
arg0=(signed char)stream.readC();
arg1=(unsigned char)stream.readC();
break;
case DIV_CMD_PANNING:
arg0=(unsigned char)stream.readC();
arg1=(unsigned char)stream.readC();
break;
case DIV_CMD_PRE_PORTA:
arg0=(unsigned char)stream.readC();
arg1=(arg0&0x40)?1:0;

View file

@ -67,9 +67,9 @@ enum DivDispatchCmds {
DIV_CMD_HINT_ARPEGGIO, // (note1, note2)
DIV_CMD_HINT_VOLUME, // (vol)
DIV_CMD_HINT_VOL_SLIDE, // (amount, oneTick)
DIV_CMD_HINT_VOL_SLIDE_TARGET, // (amount, target)
DIV_CMD_HINT_PORTA, // (target, speed)
DIV_CMD_HINT_LEGATO, // (note)
DIV_CMD_HINT_VOL_SLIDE_TARGET, // (amount, target)
DIV_CMD_SAMPLE_MODE, // (enabled)
DIV_CMD_SAMPLE_FREQ, // (frequency)

View file

@ -910,7 +910,8 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
int vol=50;
short* data;
unsigned char* adpcmData;
if (length<0) {
// I don't think a sample can be that big
if (length<0 || length>(1<<29L)) {
logE("invalid sample length %d. are we doing something wrong?",length);
lastError="file is corrupt or unreadable at samples";
delete[] file;
@ -928,6 +929,11 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
sample->centerRate=sample->rate;
pitch=reader.readC();
vol=reader.readC();
if (pitch<0 || pitch>10) {
logW("%d: sample pitch is wrong! (%d)",i,pitch);
pitch=5;
}
}
if (ds.version<=0x08) {
sample->rate=ymuSampleRate*400;

View file

@ -198,7 +198,7 @@ bool DivEngine::loadMod(unsigned char* file, size_t len) {
int period=data[1]+((data[0]&0x0f)<<8);
if (period>0 && period<0x0fff) {
short note=(short)round(log2(3424.0/period)*12);
dstrow[0]=((note-1)%12)+1;
dstrow[0]=((note+11)%12)+1;
dstrow[1]=(note-1)/12+1;
if (period<114) {
bypassLimits=true;

View file

@ -67,9 +67,9 @@ const char* cmdName[]={
"HINT_ARPEGGIO",
"HINT_VOLUME",
"HINT_VOL_SLIDE",
"HINT_VOL_SLIDE_TARGET",
"HINT_PORTA",
"HINT_LEGATO",
"HINT_VOL_SLIDE_TARGET",
"SAMPLE_MODE",
"SAMPLE_FREQ",

View file

@ -61,6 +61,7 @@ int SafeReader::read(void* where, size_t count) {
#endif
if (count==0) return 0;
if (curSeek+count>len) throw EndOfFileException(this,len);
if (curSeek+count<curSeek) throw EndOfFileException(this,len);
memcpy(where,&buf[curSeek],count);
curSeek+=count;
return count;
@ -71,6 +72,7 @@ signed char SafeReader::readC() {
logD("SR: reading char %x:",curSeek);
#endif
if (curSeek+1>len) throw EndOfFileException(this,len);
if (curSeek+1<curSeek) throw EndOfFileException(this,len);
#ifdef READ_DEBUG
logD("SR: %.2x",buf[curSeek]);
#endif
@ -83,6 +85,7 @@ short SafeReader::readS_BE() {
logD("SR: reading short %x:",curSeek);
#endif
if (curSeek+2>len) throw EndOfFileException(this,len);
if (curSeek+2<curSeek) throw EndOfFileException(this,len);
short ret;
memcpy(&ret,&buf[curSeek],2);
#ifdef READ_DEBUG
@ -94,6 +97,7 @@ short SafeReader::readS_BE() {
short SafeReader::readS() {
if (curSeek+2>len) throw EndOfFileException(this,len);
if (curSeek+2<curSeek) throw EndOfFileException(this,len);
short ret;
memcpy(&ret,&buf[curSeek],2);
curSeek+=2;
@ -105,6 +109,7 @@ int SafeReader::readI_BE() {
logD("SR: reading int %x:",curSeek);
#endif
if (curSeek+4>len) throw EndOfFileException(this,len);
if (curSeek+4<curSeek) throw EndOfFileException(this,len);
int ret;
memcpy(&ret,&buf[curSeek],4);
curSeek+=4;
@ -116,6 +121,7 @@ int SafeReader::readI_BE() {
int SafeReader::readI() {
if (curSeek+4>len) throw EndOfFileException(this,len);
if (curSeek+4<curSeek) throw EndOfFileException(this,len);
unsigned int ret;
memcpy(&ret,&buf[curSeek],4);
curSeek+=4;
@ -124,6 +130,7 @@ int SafeReader::readI() {
int64_t SafeReader::readL() {
if (curSeek+8>len) throw EndOfFileException(this,len);
if (curSeek+8<curSeek) throw EndOfFileException(this,len);
unsigned char ret[8];
memcpy(ret,&buf[curSeek],8);
curSeek+=8;
@ -132,6 +139,7 @@ int64_t SafeReader::readL() {
float SafeReader::readF() {
if (curSeek+4>len) throw EndOfFileException(this,len);
if (curSeek+4<curSeek) throw EndOfFileException(this,len);
unsigned int ret;
memcpy(&ret,&buf[curSeek],4);
curSeek+=4;
@ -143,6 +151,7 @@ float SafeReader::readF() {
double SafeReader::readD() {
if (curSeek+8>len) throw EndOfFileException(this,len);
if (curSeek+8<curSeek) throw EndOfFileException(this,len);
unsigned char ret[8];
unsigned char retB[8];
memcpy(ret,&buf[curSeek],8);
@ -165,6 +174,7 @@ short SafeReader::readS() {
logD("SR: reading short %x:",curSeek);
#endif
if (curSeek+2>len) throw EndOfFileException(this,len);
if (curSeek+2<curSeek) throw EndOfFileException(this,len);
short ret;
memcpy(&ret,&buf[curSeek],2);
#ifdef READ_DEBUG
@ -176,6 +186,7 @@ short SafeReader::readS() {
short SafeReader::readS_BE() {
if (curSeek+2>len) throw EndOfFileException(this,len);
if (curSeek+2<curSeek) throw EndOfFileException(this,len);
short ret;
memcpy(&ret,&buf[curSeek],2);
curSeek+=2;
@ -187,6 +198,7 @@ int SafeReader::readI() {
logD("SR: reading int %x:",curSeek);
#endif
if (curSeek+4>len) throw EndOfFileException(this,len);
if (curSeek+4<curSeek) throw EndOfFileException(this,len);
int ret;
memcpy(&ret,&buf[curSeek],4);
curSeek+=4;
@ -198,6 +210,7 @@ int SafeReader::readI() {
int SafeReader::readI_BE() {
if (curSeek+4>len) throw EndOfFileException(this,len);
if (curSeek+4<curSeek) throw EndOfFileException(this,len);
unsigned int ret;
memcpy(&ret,&buf[curSeek],4);
curSeek+=4;
@ -206,6 +219,7 @@ int SafeReader::readI_BE() {
int64_t SafeReader::readL() {
if (curSeek+8>len) throw EndOfFileException(this,len);
if (curSeek+8<curSeek) throw EndOfFileException(this,len);
int64_t ret;
memcpy(&ret,&buf[curSeek],8);
curSeek+=8;
@ -214,6 +228,7 @@ int64_t SafeReader::readL() {
float SafeReader::readF() {
if (curSeek+4>len) throw EndOfFileException(this,len);
if (curSeek+4<curSeek) throw EndOfFileException(this,len);
float ret;
memcpy(&ret,&buf[curSeek],4);
curSeek+=4;
@ -222,6 +237,7 @@ float SafeReader::readF() {
double SafeReader::readD() {
if (curSeek+8>len) throw EndOfFileException(this,len);
if (curSeek+8<curSeek) throw EndOfFileException(this,len);
double ret;
memcpy(&ret,&buf[curSeek],8);
curSeek+=8;