tabs to spaces

This commit is contained in:
tildearrow 2022-02-22 22:13:17 -05:00
parent 4122238a4a
commit a5561f1899
8 changed files with 322 additions and 321 deletions

View file

@ -225,7 +225,7 @@ class DivDispatch {
/** /**
* get the bit depth of the register pool of this dispatch. * get the bit depth of the register pool of this dispatch.
* If the result is 16, it should be casted to unsigned short * If the result is 16, it should be casted to unsigned short.
* @return the depth. Default value is 8 * @return the depth. Default value is 8
*/ */
virtual int getRegisterPoolDepth(); virtual int getRegisterPoolDepth();

View file

@ -437,11 +437,11 @@ void DivEngine::notifyWaveChange(int wave) {
// ADPCM code attribution: https://wiki.neogeodev.org/index.php?title=ADPCM_codecs // ADPCM code attribution: https://wiki.neogeodev.org/index.php?title=ADPCM_codecs
static short adSteps[49]={ static short adSteps[49]={
16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37,
41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97,
107, 118, 130, 143, 157, 173, 190, 209, 230, 253, 107, 118, 130, 143, 157, 173, 190, 209, 230, 253,
279, 307, 337, 371, 408, 449, 494, 544, 598, 658, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658,
724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552
}; };
static int adStepSeek[16]={ static int adStepSeek[16]={
@ -606,9 +606,10 @@ void DivEngine::renderSamples() {
memPos=0; memPos=0;
for (int i=0; i<song.sampleLen; i++) { for (int i=0; i<song.sampleLen; i++) {
DivSample* s=song.sample[i]; DivSample* s=song.sample[i];
int length = s->rendLength; int length = s->rendLength;
if(length > 65536-16) if (length > 65536-16) {
length = 65536-16; length = 65536-16;
}
if ((memPos&0xff0000)!=((memPos+length)&0xff0000)) { if ((memPos&0xff0000)!=((memPos+length)&0xff0000)) {
memPos=(memPos+0xffff)&0xff0000; memPos=(memPos+0xffff)&0xff0000;
} }
@ -617,16 +618,14 @@ void DivEngine::renderSamples() {
break; break;
} }
if (memPos+length>=16777216) { if (memPos+length>=16777216) {
for(unsigned int i=0; i<16777216-(memPos+length); i++) for (unsigned int i=0; i<16777216-(memPos+length); i++) {
{ qsoundMem[(memPos + i) ^ 0x8000] = s->rendData[i] >> ((s->depth == 16) ? 8 : 0);
qsoundMem[(memPos + i) ^ 0x8000] = s->rendData[i] >> ((s->depth == 16) ? 8 : 0); }
}
logW("out of QSound PCM memory for sample %d!\n",i); logW("out of QSound PCM memory for sample %d!\n",i);
} else { } else {
for(int i=0; i<length; i++) for (int i=0; i<length; i++) {
{ qsoundMem[(memPos + i) ^ 0x8000] = s->rendData[i] >> ((s->depth == 16) ? 8 : 0);
qsoundMem[(memPos + i) ^ 0x8000] = s->rendData[i] >> ((s->depth == 16) ? 8 : 0); }
}
} }
s->rendOffQsound=memPos ^ 0x8000; s->rendOffQsound=memPos ^ 0x8000;
memPos+=length+16; memPos+=length+16;

View file

@ -684,7 +684,7 @@ class DivEngine {
adpcmMemLen(0), adpcmMemLen(0),
adpcmBMem(NULL), adpcmBMem(NULL),
adpcmBMemLen(0), adpcmBMemLen(0),
qsoundMem(NULL), qsoundMem(NULL),
qsoundMemLen(0) {} qsoundMemLen(0) {}
}; };
#endif #endif

View file

@ -30,219 +30,219 @@
#define immWrite(a,v) {qsound_write_data(&chip,a,v); if(dumpWrites) addWrite(a,v);} #define immWrite(a,v) {qsound_write_data(&chip,a,v); if(dumpWrites) addWrite(a,v);}
const char* regCheatSheetQSound[]={ const char* regCheatSheetQSound[]={
"Ch15_Bank", "00", "Ch15_Bank", "00",
"Ch00_Start", "01", "Ch00_Start", "01",
"Ch00_Freq", "02", "Ch00_Freq", "02",
"Ch00_Phase", "03", "Ch00_Phase", "03",
"Ch00_Loop", "04", "Ch00_Loop", "04",
"Ch00_End", "05", "Ch00_End", "05",
"Ch00_Volume", "06", "Ch00_Volume", "06",
"Ch00_Bank", "08", "Ch00_Bank", "08",
"Ch01_Start", "09", "Ch01_Start", "09",
"Ch01_Freq", "0A", "Ch01_Freq", "0A",
"Ch01_Phase", "0B", "Ch01_Phase", "0B",
"Ch01_Loop", "0C", "Ch01_Loop", "0C",
"Ch01_End", "0D", "Ch01_End", "0D",
"Ch01_Volume", "0E", "Ch01_Volume", "0E",
"Ch01_Bank", "10", "Ch01_Bank", "10",
"Ch02_Start", "11", "Ch02_Start", "11",
"Ch02_Freq", "12", "Ch02_Freq", "12",
"Ch02_Phase", "13", "Ch02_Phase", "13",
"Ch02_Loop", "14", "Ch02_Loop", "14",
"Ch02_End", "15", "Ch02_End", "15",
"Ch02_Volume", "16", "Ch02_Volume", "16",
"Ch02_Bank", "18", "Ch02_Bank", "18",
"Ch03_Start", "19", "Ch03_Start", "19",
"Ch03_Freq", "1A", "Ch03_Freq", "1A",
"Ch03_Phase", "1B", "Ch03_Phase", "1B",
"Ch03_Loop", "1C", "Ch03_Loop", "1C",
"Ch03_End", "1D", "Ch03_End", "1D",
"Ch03_Volume", "1E", "Ch03_Volume", "1E",
"Ch03_Bank", "20", "Ch03_Bank", "20",
"Ch04_Start", "21", "Ch04_Start", "21",
"Ch04_Freq", "22", "Ch04_Freq", "22",
"Ch04_Phase", "23", "Ch04_Phase", "23",
"Ch04_Loop", "24", "Ch04_Loop", "24",
"Ch04_End", "25", "Ch04_End", "25",
"Ch04_Volume", "26", "Ch04_Volume", "26",
"Ch04_Bank", "28", "Ch04_Bank", "28",
"Ch05_Start", "29", "Ch05_Start", "29",
"Ch05_Freq", "2A", "Ch05_Freq", "2A",
"Ch05_Phase", "2B", "Ch05_Phase", "2B",
"Ch05_Loop", "2C", "Ch05_Loop", "2C",
"Ch05_End", "2D", "Ch05_End", "2D",
"Ch05_Volume", "2E", "Ch05_Volume", "2E",
"Ch05_Bank", "30", "Ch05_Bank", "30",
"Ch06_Start", "31", "Ch06_Start", "31",
"Ch06_Freq", "32", "Ch06_Freq", "32",
"Ch06_Phase", "33", "Ch06_Phase", "33",
"Ch06_Loop", "34", "Ch06_Loop", "34",
"Ch06_End", "35", "Ch06_End", "35",
"Ch06_Volume", "36", "Ch06_Volume", "36",
"Ch06_Bank", "38", "Ch06_Bank", "38",
"Ch07_Start", "39", "Ch07_Start", "39",
"Ch07_Freq", "3A", "Ch07_Freq", "3A",
"Ch07_Phase", "3B", "Ch07_Phase", "3B",
"Ch07_Loop", "3C", "Ch07_Loop", "3C",
"Ch07_End", "3D", "Ch07_End", "3D",
"Ch07_Volume", "3E", "Ch07_Volume", "3E",
"Ch07_Bank", "40", "Ch07_Bank", "40",
"Ch08_Start", "41", "Ch08_Start", "41",
"Ch08_Freq", "42", "Ch08_Freq", "42",
"Ch08_Phase", "43", "Ch08_Phase", "43",
"Ch08_Loop", "44", "Ch08_Loop", "44",
"Ch08_End", "45", "Ch08_End", "45",
"Ch08_Volume", "46", "Ch08_Volume", "46",
"Ch08_Bank", "48", "Ch08_Bank", "48",
"Ch09_Start", "49", "Ch09_Start", "49",
"Ch09_Freq", "4A", "Ch09_Freq", "4A",
"Ch09_Phase", "4B", "Ch09_Phase", "4B",
"Ch09_Loop", "4C", "Ch09_Loop", "4C",
"Ch09_End", "4D", "Ch09_End", "4D",
"Ch09_Volume", "4E", "Ch09_Volume", "4E",
"Ch09_Bank", "50", "Ch09_Bank", "50",
"Ch10_Start", "51", "Ch10_Start", "51",
"Ch10_Freq", "52", "Ch10_Freq", "52",
"Ch10_Phase", "53", "Ch10_Phase", "53",
"Ch10_Loop", "54", "Ch10_Loop", "54",
"Ch10_End", "55", "Ch10_End", "55",
"Ch10_Volume", "56", "Ch10_Volume", "56",
"Ch10_Bank", "58", "Ch10_Bank", "58",
"Ch11_Start", "59", "Ch11_Start", "59",
"Ch11_Freq", "5A", "Ch11_Freq", "5A",
"Ch11_Phase", "5B", "Ch11_Phase", "5B",
"Ch11_Loop", "5C", "Ch11_Loop", "5C",
"Ch11_End", "5D", "Ch11_End", "5D",
"Ch11_Volume", "5E", "Ch11_Volume", "5E",
"Ch11_Bank", "60", "Ch11_Bank", "60",
"Ch12_Start", "61", "Ch12_Start", "61",
"Ch12_Freq", "62", "Ch12_Freq", "62",
"Ch12_Phase", "63", "Ch12_Phase", "63",
"Ch12_Loop", "64", "Ch12_Loop", "64",
"Ch12_End", "65", "Ch12_End", "65",
"Ch12_Volume", "66", "Ch12_Volume", "66",
"Ch12_Bank", "68", "Ch12_Bank", "68",
"Ch13_Start", "69", "Ch13_Start", "69",
"Ch13_Freq", "6A", "Ch13_Freq", "6A",
"Ch13_Phase", "6B", "Ch13_Phase", "6B",
"Ch13_Loop", "6C", "Ch13_Loop", "6C",
"Ch13_End", "6D", "Ch13_End", "6D",
"Ch13_Volume", "6E", "Ch13_Volume", "6E",
"Ch13_Bank", "70", "Ch13_Bank", "70",
"Ch14_Start", "71", "Ch14_Start", "71",
"Ch14_Freq", "72", "Ch14_Freq", "72",
"Ch14_Phase", "73", "Ch14_Phase", "73",
"Ch14_Loop", "74", "Ch14_Loop", "74",
"Ch14_End", "75", "Ch14_End", "75",
"Ch14_Volume", "76", "Ch14_Volume", "76",
"Ch14_Bank", "78", "Ch14_Bank", "78",
"Ch15_Start", "79", "Ch15_Start", "79",
"Ch15_Freq", "7A", "Ch15_Freq", "7A",
"Ch15_Phase", "7B", "Ch15_Phase", "7B",
"Ch15_Loop", "7C", "Ch15_Loop", "7C",
"Ch15_End", "7D", "Ch15_End", "7D",
"Ch15_Volume", "7E", "Ch15_Volume", "7E",
"Ch00_Panning", "80", "Ch00_Panning", "80",
"Ch01_Panning", "81", "Ch01_Panning", "81",
"Ch02_Panning", "82", "Ch02_Panning", "82",
"Ch03_Panning", "83", "Ch03_Panning", "83",
"Ch04_Panning", "84", "Ch04_Panning", "84",
"Ch05_Panning", "85", "Ch05_Panning", "85",
"Ch06_Panning", "86", "Ch06_Panning", "86",
"Ch07_Panning", "87", "Ch07_Panning", "87",
"Ch08_Panning", "88", "Ch08_Panning", "88",
"Ch09_Panning", "89", "Ch09_Panning", "89",
"Ch10_Panning", "8A", "Ch10_Panning", "8A",
"Ch11_Panning", "8B", "Ch11_Panning", "8B",
"Ch12_Panning", "8C", "Ch12_Panning", "8C",
"Ch13_Panning", "8D", "Ch13_Panning", "8D",
"Ch14_Panning", "8E", "Ch14_Panning", "8E",
"Ch15_Panning", "8F", "Ch15_Panning", "8F",
"Adpcm0_Panning","90", "Adpcm0_Panning","90",
"Adpcm1_Panning","91", "Adpcm1_Panning","91",
"Adpcm2_Panning","92", "Adpcm2_Panning","92",
"Echo_Feedback","93", "Echo_Feedback","93",
"Ch00_Echo", "BA", "Ch00_Echo", "BA",
"Ch01_Echo", "BB", "Ch01_Echo", "BB",
"Ch02_Echo", "BC", "Ch02_Echo", "BC",
"Ch03_Echo", "BD", "Ch03_Echo", "BD",
"Ch04_Echo", "BE", "Ch04_Echo", "BE",
"Ch05_Echo", "BF", "Ch05_Echo", "BF",
"Ch06_Echo", "C0", "Ch06_Echo", "C0",
"Ch07_Echo", "C1", "Ch07_Echo", "C1",
"Ch08_Echo", "C2", "Ch08_Echo", "C2",
"Ch09_Echo", "C3", "Ch09_Echo", "C3",
"Ch10_Echo", "C4", "Ch10_Echo", "C4",
"Ch11_Echo", "C5", "Ch11_Echo", "C5",
"Ch12_Echo", "C6", "Ch12_Echo", "C6",
"Ch13_Echo", "C7", "Ch13_Echo", "C7",
"Ch14_Echo", "C8", "Ch14_Echo", "C8",
"Ch15_Echo", "C9", "Ch15_Echo", "C9",
"Adpcm0_Start", "CA", "Adpcm0_Start", "CA",
"Adpcm0_End", "CB", "Adpcm0_End", "CB",
"Adpcm0_Bank", "CC", "Adpcm0_Bank", "CC",
"Adpcm0_Volume","CD", "Adpcm0_Volume","CD",
"Adpcm1_Start", "CE", "Adpcm1_Start", "CE",
"Adpcm1_End", "CF", "Adpcm1_End", "CF",
"Adpcm1_Bank", "D0", "Adpcm1_Bank", "D0",
"Adpcm1_Volume","D1", "Adpcm1_Volume","D1",
"Adpcm2_Start", "D2", "Adpcm2_Start", "D2",
"Adpcm2_End", "D3", "Adpcm2_End", "D3",
"Adpcm2_Bank", "D4", "Adpcm2_Bank", "D4",
"Adpcm2_Volume","D5", "Adpcm2_Volume","D5",
"Adpcm0_KeyOn", "D6", "Adpcm0_KeyOn", "D6",
"Adpcm1_KeyOn", "D7", "Adpcm1_KeyOn", "D7",
"Adpcm2_KeyOn", "D8", "Adpcm2_KeyOn", "D8",
"Echo_Delay", "D9", "Echo_Delay", "D9",
"L_Wet_Filter", "DA", "L_Wet_Filter", "DA",
"L_Dry_Filter", "DB", "L_Dry_Filter", "DB",
"R_Wet_Filter", "DC", "R_Wet_Filter", "DC",
"R_Dry_Filter", "DD", "R_Dry_Filter", "DD",
"L_Wet_Delay", "DE", "L_Wet_Delay", "DE",
"L_Dry_Delay", "DF", "L_Dry_Delay", "DF",
"R_Wet_Delay", "E0", "R_Wet_Delay", "E0",
"R_Dry_Delay", "E1", "R_Dry_Delay", "E1",
"Delay_Flag", "E2", "Delay_Flag", "E2",
"Mode_Select", "E3", //valid: 0000,0288,0039,061A,004F "Mode_Select", "E3", //valid: 0000,0288,0039,061A,004F
"L_Wet_Volume", "E4", "L_Wet_Volume", "E4",
"L_Dry_Volume", "E5", "L_Dry_Volume", "E5",
"R_Wet_Volume", "E6", "R_Wet_Volume", "E6",
"R_Dry_Volume", "E7", "R_Dry_Volume", "E7",
NULL NULL
}; };
enum q1_register_name { enum q1_register_name {
Q1V_BANK = 0, Q1V_BANK = 0,
Q1V_START = 1, Q1V_START = 1,
Q1V_FREQ = 2, Q1V_FREQ = 2,
Q1V_PHASE = 3, Q1V_PHASE = 3,
Q1V_LOOP = 4, Q1V_LOOP = 4,
Q1V_END = 5, Q1V_END = 5,
Q1V_VOL = 6, Q1V_VOL = 6,
Q1V_REG_COUNT = 7, Q1V_REG_COUNT = 7,
Q1_PAN = 0x80, Q1_PAN = 0x80,
Q1_ECHO = 0xba, Q1_ECHO = 0xba,
Q1A_PAN = 0x90, Q1A_PAN = 0x90,
Q1A_START = 0xca, Q1A_START = 0xca,
Q1A_END = 0xcb, Q1A_END = 0xcb,
Q1A_BANK = 0xcc, Q1A_BANK = 0xcc,
Q1A_VOL = 0xcd, Q1A_VOL = 0xcd,
Q1A_KEYON = 0xd6, Q1A_KEYON = 0xd6,
Q1_ECHO_FEEDBACK = 0x93, Q1_ECHO_FEEDBACK = 0x93,
Q1_ECHO_LENGTH = 0xd9, Q1_ECHO_LENGTH = 0xd9,
}; };
const unsigned char q1_reg_map[Q1V_REG_COUNT][16] = { const unsigned char q1_reg_map[Q1V_REG_COUNT][16] = {
{0x78,0x00,0x08,0x10,0x18,0x20,0x28,0x30,0x38,0x40,0x48,0x50,0x58,0x60,0x68,0x70}, {0x78,0x00,0x08,0x10,0x18,0x20,0x28,0x30,0x38,0x40,0x48,0x50,0x58,0x60,0x68,0x70},
{0x01,0x09,0x11,0x19,0x21,0x29,0x31,0x39,0x41,0x49,0x51,0x59,0x61,0x69,0x71,0x79}, {0x01,0x09,0x11,0x19,0x21,0x29,0x31,0x39,0x41,0x49,0x51,0x59,0x61,0x69,0x71,0x79},
{0x02,0x0a,0x12,0x1a,0x22,0x2a,0x32,0x3a,0x42,0x4a,0x52,0x5a,0x62,0x6a,0x72,0x7a}, {0x02,0x0a,0x12,0x1a,0x22,0x2a,0x32,0x3a,0x42,0x4a,0x52,0x5a,0x62,0x6a,0x72,0x7a},
{0x03,0x0b,0x13,0x1b,0x23,0x2b,0x33,0x3b,0x43,0x4b,0x53,0x5b,0x63,0x6b,0x73,0x7b}, {0x03,0x0b,0x13,0x1b,0x23,0x2b,0x33,0x3b,0x43,0x4b,0x53,0x5b,0x63,0x6b,0x73,0x7b},
{0x04,0x0c,0x14,0x1c,0x24,0x2c,0x34,0x3c,0x44,0x4c,0x54,0x5c,0x64,0x6c,0x74,0x7c}, {0x04,0x0c,0x14,0x1c,0x24,0x2c,0x34,0x3c,0x44,0x4c,0x54,0x5c,0x64,0x6c,0x74,0x7c},
{0x05,0x0d,0x15,0x1d,0x25,0x2d,0x35,0x3d,0x45,0x4d,0x55,0x5d,0x65,0x6d,0x75,0x7d}, {0x05,0x0d,0x15,0x1d,0x25,0x2d,0x35,0x3d,0x45,0x4d,0x55,0x5d,0x65,0x6d,0x75,0x7d},
{0x06,0x0e,0x16,0x1e,0x26,0x2e,0x36,0x3e,0x46,0x4e,0x56,0x5e,0x66,0x6e,0x76,0x7e}, {0x06,0x0e,0x16,0x1e,0x26,0x2e,0x36,0x3e,0x46,0x4e,0x56,0x5e,0x66,0x6e,0x76,0x7e},
}; };
const char** DivPlatformQSound::getRegisterSheet() { const char** DivPlatformQSound::getRegisterSheet() {
@ -258,8 +258,9 @@ const char* DivPlatformQSound::getEffectName(unsigned char effect) {
return "11xx: Set channel echo level (00 to FF)"; return "11xx: Set channel echo level (00 to FF)";
break; break;
default: default:
if((effect & 0xf0) == 0x30) if ((effect & 0xf0) == 0x30) {
return "3xxx: Set echo delay buffer length (000 to AA5)"; return "3xxx: Set echo delay buffer length (000 to AA5)";
}
} }
return NULL; return NULL;
} }
@ -267,7 +268,7 @@ void DivPlatformQSound::acquire(short* bufL, short* bufR, size_t start, size_t l
chip.rom_data = parent->qsoundMem; chip.rom_data = parent->qsoundMem;
chip.rom_mask = 0xffffff; chip.rom_mask = 0xffffff;
for (size_t h=start; h<start+len; h++) { for (size_t h=start; h<start+len; h++) {
qsound_update(&chip); qsound_update(&chip);
bufL[h]=chip.out[0]; bufL[h]=chip.out[0];
bufR[h]=chip.out[1]; bufR[h]=chip.out[1];
} }
@ -277,18 +278,17 @@ void DivPlatformQSound::tick() {
for (int i=0; i<16; i++) { for (int i=0; i<16; i++) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.hadVol) { if (chan[i].std.hadVol) {
chan[i].outVol=((chan[i].vol%256)*MIN(255,chan[i].std.vol << 2))>>8; chan[i].outVol=((chan[i].vol&0xff)*MIN(255,chan[i].std.vol<<2))>>8;
// Check if enabled and write volume // Check if enabled and write volume
if(chan[i].active) if (chan[i].active) {
{ rWrite(q1_reg_map[Q1V_VOL][i], chan[i].outVol << 5);
rWrite(q1_reg_map[Q1V_VOL][i], chan[i].outVol << 5); //logW("ch %d vol=%04x (hadVol)!\n",i,chan[i].outVol << 5);
//logW("ch %d vol=%04x (hadVol)!\n",i,chan[i].outVol << 5); }
}
} }
uint16_t qsound_bank = 0; uint16_t qsound_bank = 0;
uint16_t qsound_addr = 0; uint16_t qsound_addr = 0;
uint16_t qsound_loop = 0; uint16_t qsound_loop = 0;
uint16_t qsound_end = 0; uint16_t qsound_end = 0;
double off=1.0; double off=1.0;
if (chan[i].sample>=0 && chan[i].sample<parent->song.sampleLen) { if (chan[i].sample>=0 && chan[i].sample<parent->song.sampleLen) {
DivSample* s=parent->song.sample[chan[i].sample]; DivSample* s=parent->song.sample[chan[i].sample];
@ -297,22 +297,20 @@ void DivPlatformQSound::tick() {
} else { } else {
off=(double)s->centerRate/24038.0/16.0; off=(double)s->centerRate/24038.0/16.0;
} }
qsound_bank = 0x8000 | (s->rendOffQsound >> 16); qsound_bank = 0x8000 | (s->rendOffQsound >> 16);
qsound_addr = s->rendOffQsound & 0xffff; qsound_addr = s->rendOffQsound & 0xffff;
int length = s->length; int length = s->length;
if(length > 65536 - 16) if (length > 65536 - 16) {
length = 65536 - 16; length = 65536 - 16;
if(s->loopStart == -1 || s->loopStart >= length) }
{ if (s->loopStart == -1 || s->loopStart >= length) {
qsound_end = s->rendOffQsound + length + 15; qsound_end = s->rendOffQsound + length + 15;
qsound_loop = 15; qsound_loop = 15;
} } else {
else qsound_end = s->rendOffQsound + length;
{ qsound_loop = length - s->loopStart;
qsound_end = s->rendOffQsound + length; }
qsound_loop = length - s->loopStart;
}
} }
if (chan[i].std.hadArp) { if (chan[i].std.hadArp) {
if (!chan[i].inPorta) { if (!chan[i].inPorta) {
@ -333,29 +331,27 @@ void DivPlatformQSound::tick() {
//DivInstrument* ins=parent->getIns(chan[i].ins); //DivInstrument* ins=parent->getIns(chan[i].ins);
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false); chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false);
if (chan[i].freq>0xffff) chan[i].freq=0xffff; if (chan[i].freq>0xffff) chan[i].freq=0xffff;
//if (chan[i].note>0x5d) chan[i].freq=0x01; //????
if (chan[i].keyOn) { if (chan[i].keyOn) {
rWrite(q1_reg_map[Q1V_BANK][i], qsound_bank); rWrite(q1_reg_map[Q1V_BANK][i], qsound_bank);
rWrite(q1_reg_map[Q1V_END][i], qsound_end); rWrite(q1_reg_map[Q1V_END][i], qsound_end);
rWrite(q1_reg_map[Q1V_LOOP][i], qsound_loop); rWrite(q1_reg_map[Q1V_LOOP][i], qsound_loop);
rWrite(q1_reg_map[Q1V_START][i], qsound_addr); rWrite(q1_reg_map[Q1V_START][i], qsound_addr);
rWrite(q1_reg_map[Q1V_PHASE][i], 0x8000); rWrite(q1_reg_map[Q1V_PHASE][i], 0x8000);
//logW("ch %d bank=%04x, addr=%04x, end=%04x, loop=%04x!\n",i,qsound_bank,qsound_addr,qsound_end,qsound_loop); //logW("ch %d bank=%04x, addr=%04x, end=%04x, loop=%04x!\n",i,qsound_bank,qsound_addr,qsound_end,qsound_loop);
// Write sample address. Enable volume // Write sample address. Enable volume
if (!chan[i].std.hadVol) { if (!chan[i].std.hadVol) {
rWrite(q1_reg_map[Q1V_VOL][i], chan[i].vol << 5); rWrite(q1_reg_map[Q1V_VOL][i], chan[i].vol << 5);
//logW("ch %d vol=%04x (!hadVol)!\n",i,chan[i].vol << 5); //logW("ch %d vol=%04x (!hadVol)!\n",i,chan[i].vol << 5);
} }
} }
if (chan[i].keyOff) { if (chan[i].keyOff) {
rWrite(q1_reg_map[Q1V_VOL][i], 0); // Disable volume
rWrite(q1_reg_map[Q1V_FREQ][i], 0); rWrite(q1_reg_map[Q1V_VOL][i], 0);
// Disable volume rWrite(q1_reg_map[Q1V_FREQ][i], 0);
} else if (chan[i].active) {
//logW("ch %d frequency set to %04x, off=%f, note=%d, %04x!\n",i,chan[i].freq,off,chan[i].note,QS_NOTE_FREQUENCY(chan[i].note));
rWrite(q1_reg_map[Q1V_FREQ][i], chan[i].freq);
} }
else if (chan[i].active) {
//logW("ch %d frequency set to %04x, off=%f, note=%d, %04x!\n",i,chan[i].freq,off,chan[i].note,QS_NOTE_FREQUENCY(chan[i].note));
rWrite(q1_reg_map[Q1V_FREQ][i], chan[i].freq);
}
if (chan[i].keyOn) chan[i].keyOn=false; if (chan[i].keyOn) chan[i].keyOn=false;
if (chan[i].keyOff) chan[i].keyOff=false; if (chan[i].keyOff) chan[i].keyOff=false;
chan[i].freqChanged=false; chan[i].freqChanged=false;
@ -411,13 +407,12 @@ int DivPlatformQSound::dispatch(DivCommand c) {
if (chan[c.chan].vol!=c.value) { if (chan[c.chan].vol!=c.value) {
chan[c.chan].vol=c.value; chan[c.chan].vol=c.value;
if (!chan[c.chan].std.hasVol) { if (!chan[c.chan].std.hasVol) {
// Check if enabled and write volume // Check if enabled and write volume
chan[c.chan].outVol=c.value; chan[c.chan].outVol=c.value;
if(chan[c.chan].active && c.chan < 16) if (chan[c.chan].active && c.chan < 16) {
{ rWrite(q1_reg_map[Q1V_VOL][c.chan], chan[c.chan].outVol << 5);
rWrite(q1_reg_map[Q1V_VOL][c.chan], chan[c.chan].outVol << 5); //logW("ch %d vol=%04x (cmd vol)!\n",c.chan,chan[c.chan].outVol << 5);
//logW("ch %d vol=%04x (cmd vol)!\n",c.chan,chan[c.chan].outVol << 5); }
}
} }
} }
break; break;
@ -428,16 +423,16 @@ int DivPlatformQSound::dispatch(DivCommand c) {
return chan[c.chan].outVol; return chan[c.chan].outVol;
break; break;
case DIV_CMD_PANNING: case DIV_CMD_PANNING:
immWrite(Q1_PAN+c.chan, c.value + 0x110); immWrite(Q1_PAN+c.chan, c.value + 0x110);
break; break;
case DIV_CMD_QSOUND_ECHO_LEVEL: case DIV_CMD_QSOUND_ECHO_LEVEL:
immWrite(Q1_ECHO+c.chan, c.value << 7); immWrite(Q1_ECHO+c.chan, c.value << 7);
break; break;
case DIV_CMD_QSOUND_ECHO_FEEDBACK: case DIV_CMD_QSOUND_ECHO_FEEDBACK:
immWrite(Q1_ECHO_FEEDBACK, c.value << 6); immWrite(Q1_ECHO_FEEDBACK, c.value << 6);
break; break;
case DIV_CMD_QSOUND_ECHO_DELAY: case DIV_CMD_QSOUND_ECHO_DELAY:
immWrite(Q1_ECHO_LENGTH, (c.value > 2725 ? 0xfff : 0xfff - (2725 - c.value))); immWrite(Q1_ECHO_LENGTH, (c.value > 2725 ? 0xfff : 0xfff - (2725 - c.value)));
break; break;
case DIV_CMD_PITCH: case DIV_CMD_PITCH:
chan[c.chan].pitch=c.value; chan[c.chan].pitch=c.value;
@ -509,10 +504,11 @@ int DivPlatformQSound::dispatch(DivCommand c) {
} }
void DivPlatformQSound::muteChannel(int ch, bool mute) { void DivPlatformQSound::muteChannel(int ch, bool mute) {
if(mute) if (mute) {
chip.mute_mask |= (1 << ch); chip.mute_mask|=(1<<ch);
else } else {
chip.mute_mask &= ~(1 << ch); chip.mute_mask&=~(1<<ch);
}
} }
void DivPlatformQSound::forceIns() { void DivPlatformQSound::forceIns() {
@ -532,8 +528,9 @@ void DivPlatformQSound::reset() {
chan[i]=DivPlatformQSound::Channel(); chan[i]=DivPlatformQSound::Channel();
} }
qsound_reset(&chip); qsound_reset(&chip);
while(!chip.ready_flag) while(!chip.ready_flag) {
qsound_update(&chip); qsound_update(&chip);
}
immWrite(Q1_ECHO_LENGTH, 0xfff - (2725 - echoDelay)); immWrite(Q1_ECHO_LENGTH, 0xfff - (2725 - echoDelay));
immWrite(Q1_ECHO_FEEDBACK, echoFeedback << 6); immWrite(Q1_ECHO_FEEDBACK, echoFeedback << 6);
@ -557,6 +554,7 @@ void DivPlatformQSound::notifyInsChange(int ins) {
void DivPlatformQSound::notifyWaveChange(int wave) { void DivPlatformQSound::notifyWaveChange(int wave) {
// TODO when wavetables are added // TODO when wavetables are added
// TODO they probably won't be added unless the samples reside in RAM
} }
void DivPlatformQSound::notifyInsDeletion(void* ins) { void DivPlatformQSound::notifyInsDeletion(void* ins) {
@ -569,10 +567,12 @@ void DivPlatformQSound::setFlags(unsigned int flags) {
echoDelay = 2725 - (flags & 0xfff); echoDelay = 2725 - (flags & 0xfff);
echoFeedback = (flags >> 12) & 255; echoFeedback = (flags >> 12) & 255;
if(echoDelay < 0) if(echoDelay < 0) {
echoDelay = 0; echoDelay = 0;
if(echoDelay > 2725) }
echoDelay = 2725; if(echoDelay > 2725) {
echoDelay = 2725;
}
//rate=chipClock/CHIP_DIVIDER; //rate=chipClock/CHIP_DIVIDER;
} }
@ -586,21 +586,21 @@ void DivPlatformQSound::poke(std::vector<DivRegWrite>& wlist) {
} }
unsigned char* DivPlatformQSound::getRegisterPool() { unsigned char* DivPlatformQSound::getRegisterPool() {
unsigned short* regPoolPtr = regPool; unsigned short* regPoolPtr = regPool;
for(int i=0; i<256; i++) for(int i=0; i<256; i++)
{ {
uint16_t data = qsound_read_data(&chip, i); uint16_t data = qsound_read_data(&chip, i);
*regPoolPtr++ = data; *regPoolPtr++ = data;
} }
return (unsigned char*)regPool; return (unsigned char*)regPool;
} }
int DivPlatformQSound::getRegisterPoolSize() { int DivPlatformQSound::getRegisterPoolSize() {
return 256; return 256;
} }
int DivPlatformQSound::getRegisterPoolDepth() { int DivPlatformQSound::getRegisterPoolDepth() {
return 16; return 16;
} }
int DivPlatformQSound::init(DivEngine* p, int channels, int sugRate, unsigned int flags) { int DivPlatformQSound::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
@ -608,9 +608,9 @@ int DivPlatformQSound::init(DivEngine* p, int channels, int sugRate, unsigned in
dumpWrites=false; dumpWrites=false;
skipRegisterWrites=false; skipRegisterWrites=false;
// for (int i=0; i<16; i++) { //for (int i=0; i<16; i++) {
// isMuted[i]=false; // isMuted[i]=false;
// } //}
setFlags(flags); setFlags(flags);
chipClock=60000000; chipClock=60000000;

View file

@ -33,7 +33,7 @@ class DivPlatformQSound: public DivDispatch {
int sample, wave; int sample, wave;
unsigned char ins; unsigned char ins;
int note; int note;
int panning; int panning;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave; bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave;
int vol, outVol; int vol, outVol;
DivMacroInt std; DivMacroInt std;
@ -46,7 +46,7 @@ class DivPlatformQSound: public DivDispatch {
sample(-1), sample(-1),
ins(-1), ins(-1),
note(0), note(0),
panning(0x10), panning(0x10),
active(false), active(false),
insChanged(true), insChanged(true),
freqChanged(false), freqChanged(false),

View file

@ -241,10 +241,10 @@ bool DivEngine::perSystemEffect(int ch, unsigned char effect, unsigned char effe
dispatchCmd(DivCommand(DIV_CMD_QSOUND_ECHO_LEVEL,ch,effectVal)); dispatchCmd(DivCommand(DIV_CMD_QSOUND_ECHO_LEVEL,ch,effectVal));
break; break;
default: default:
if ((effect & 0xf0)==0x30) { if ((effect&0xf0)==0x30) {
dispatchCmd(DivCommand(DIV_CMD_QSOUND_ECHO_DELAY,ch,((effect & 0x0f) << 8) | effectVal)); dispatchCmd(DivCommand(DIV_CMD_QSOUND_ECHO_DELAY,ch,((effect & 0x0f) << 8) | effectVal));
} else { } else {
return false; return false;
} }
break; break;
} }

View file

@ -975,10 +975,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop) {
} }
if (writeQSound && qsoundMemLen>0) { if (writeQSound && qsoundMemLen>0) {
// always write a whole bank // always write a whole bank
unsigned int blockSize=(qsoundMemLen + 0xffff) & ~0xffff; unsigned int blockSize=(qsoundMemLen+0xffff)&(~0xffff);
if(blockSize > 0x1000000) if (blockSize > 0x1000000) {
blockSize = 0x1000000; blockSize = 0x1000000;
}
w->writeC(0x67); w->writeC(0x67);
w->writeC(0x66); w->writeC(0x66);
w->writeC(0x8F); w->writeC(0x8F);

View file

@ -2098,9 +2098,9 @@ void FurnaceGUI::drawRegView() {
for (int i=0; i<e->song.systemLen; i++) { for (int i=0; i<e->song.systemLen; i++) {
ImGui::Text("%d. %s",i+1,getSystemName(e->song.system[i])); ImGui::Text("%d. %s",i+1,getSystemName(e->song.system[i]));
int size=0; int size=0;
int depth=8; int depth=8;
unsigned char* regPool=e->getRegisterPool(i,size,depth); unsigned char* regPool=e->getRegisterPool(i,size,depth);
unsigned short* regPoolW=(unsigned short*) regPool; unsigned short* regPoolW=(unsigned short*)regPool;
if (regPool==NULL) { if (regPool==NULL) {
ImGui::Text("- no register pool available"); ImGui::Text("- no register pool available");
} else { } else {
@ -2119,12 +2119,13 @@ void FurnaceGUI::drawRegView() {
for (int j=0; j<16; j++) { for (int j=0; j<16; j++) {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
if (i*16+j>=size) continue; if (i*16+j>=size) continue;
if(depth == 8) if (depth == 8) {
ImGui::Text("%.2x",regPool[i*16+j]); ImGui::Text("%.2x",regPool[i*16+j]);
else if(depth == 16) } else if (depth == 16) {
ImGui::Text("%.4x",regPoolW[i*16+j]); ImGui::Text("%.4x",regPoolW[i*16+j]);
else } else {
ImGui::Text("??"); ImGui::Text("??");
}
} }
} }
ImGui::EndTable(); ImGui::EndTable();