// master int buffer to mix to\r
static int PsndBuffer[2*(44100+100)/50];\r
\r
-// dac\r
+// dac, psg\r
static unsigned short dac_info[312+4]; // pos in sample buffer\r
\r
// cdda output buffer\r
int PsndLen=0; // number of mono samples, multiply by 2 for stereo\r
int PsndLen_exc_add=0; // this is for non-integer sample counts per line, eg. 22050/60\r
int PsndLen_exc_cnt=0;\r
-int PsndDacLine=0;\r
+int PsndDacLine, PsndPsgLine;\r
short *PsndOut=NULL; // PCM data buffer\r
static int PsndLen_use;\r
\r
PsndLen_use++;\r
}\r
\r
- PsndDacLine = 0;\r
+ PsndDacLine = PsndPsgLine = 0;\r
emustatus &= ~1;\r
dac_info[224] = PsndLen_use;\r
}\r
\r
if (PicoOpt & POPT_EN_STEREO) {\r
short *d = PsndOut + pos*2;\r
- for (; len > 0; len--, d+=2) *d = dout;\r
+ for (; len > 0; len--, d+=2) *d += dout;\r
} else {\r
short *d = PsndOut + pos;\r
- for (; len > 0; len--, d++) *d = dout;\r
+ for (; len > 0; len--, d++) *d += dout;\r
}\r
}\r
\r
+PICO_INTERNAL void PsndDoPSG(int line_to)\r
+{\r
+ int line_from = PsndPsgLine;\r
+ int pos, pos1, len;\r
+ int stereo = 0;\r
+\r
+ if (line_to >= 312)\r
+ line_to = 311;\r
+\r
+ pos = dac_info[line_from];\r
+ pos1 = dac_info[line_to + 1];\r
+ len = pos1 - pos;\r
+ //elprintf(EL_STATUS, "%3d %3d %3d %3d %3d",\r
+ // pos, pos1, len, line_from, line_to);\r
+ if (len <= 0)\r
+ return;\r
+\r
+ PsndPsgLine = line_to + 1;\r
+\r
+ if (!PsndOut || !(PicoOpt & POPT_EN_PSG))\r
+ return;\r
+\r
+ if (PicoOpt & POPT_EN_STEREO) {\r
+ stereo = 1;\r
+ pos <<= 1;\r
+ }\r
+ SN76496Update(PsndOut + pos, len, stereo);\r
+}\r
+\r
// cdda\r
static void cdda_raw_update(int *buffer, int length)\r
{\r
\r
pprof_start(sound);\r
\r
- // PSG\r
- if (PicoOpt & POPT_EN_PSG)\r
- SN76496Update(PsndOut+offset, length, stereo);\r
-\r
if (PicoAHW & PAHW_PICO) {\r
PicoPicoPCMUpdate(PsndOut+offset, length, stereo);\r
return length;\r
\r
if (ym2612.dacen && PsndDacLine < y)\r
PsndDoDAC(y - 1);\r
+ PsndDoPSG(y - 1);\r
\r
if (y == 224)\r
{\r