sms: do psg like md does

This commit is contained in:
notaz 2017-10-22 00:39:43 +03:00
parent eef77d7a8b
commit 075672bf9f
2 changed files with 14 additions and 11 deletions

View file

@ -8,10 +8,8 @@
/* /*
* TODO: * TODO:
* - start in a state as if BIOS ran * - start in a state as if BIOS ran
* - remaining status flags (OVR/COL)
* - RAM support in mapper * - RAM support in mapper
* - region support * - region support
* - SN76496 DAC-like usage
* - H counter * - H counter
*/ */
#include "pico_int.h" #include "pico_int.h"
@ -133,8 +131,9 @@ static void z80_sms_out(unsigned short a, unsigned char d)
case 0x40: case 0x40:
case 0x41: case 0x41:
if (PicoIn.opt & POPT_EN_PSG) if ((d & 0x90) == 0x90 && PsndPsgLine < Pico.m.scanline)
SN76496Write(d); PsndDoPSG(Pico.m.scanline);
SN76496Write(d);
break; break;
case 0x80: case 0x80:
@ -300,12 +299,16 @@ void PicoFrameMS(void)
} }
} }
// 224 because of how it's done for MD...
if (y == 224 && PsndOut)
PsndGetSamplesMS();
cycles_aim += cycles_line; cycles_aim += cycles_line;
cycles_done += z80_run((cycles_aim - cycles_done) >> 8) << 8; cycles_done += z80_run((cycles_aim - cycles_done) >> 8) << 8;
} }
if (PsndOut) if (PsndOut && PsndPsgLine < lines)
PsndGetSamplesMS(); PsndDoPSG(lines - 1);
} }
void PicoFrameDrawOnlyMS(void) void PicoFrameDrawOnlyMS(void)
@ -319,3 +322,4 @@ void PicoFrameDrawOnlyMS(void)
PicoLineMode4(y); PicoLineMode4(y);
} }
// vim:ts=2:sw=2:expandtab

View file

@ -370,15 +370,12 @@ PICO_INTERNAL void PsndGetSamples(int y)
PICO_INTERNAL void PsndGetSamplesMS(void) PICO_INTERNAL void PsndGetSamplesMS(void)
{ {
int stereo = (PicoIn.opt & 8) >> 3;
int length = PsndLen_use; int length = PsndLen_use;
// PSG PsndDoPSG(223);
if (PicoIn.opt & POPT_EN_PSG)
SN76496Update(PsndOut, length, stereo);
// upmix to "stereo" if needed // upmix to "stereo" if needed
if (stereo) { if (PicoIn.opt & POPT_EN_STEREO) {
int i, *p; int i, *p;
for (i = length, p = (void *)PsndOut; i > 0; i--, p++) for (i = length, p = (void *)PsndOut; i > 0; i--, p++)
*p |= *p << 16; *p |= *p << 16;
@ -387,6 +384,8 @@ PICO_INTERNAL void PsndGetSamplesMS(void)
if (PicoWriteSound != NULL) if (PicoWriteSound != NULL)
PicoWriteSound(length * ((PicoIn.opt & POPT_EN_STEREO) ? 4 : 2)); PicoWriteSound(length * ((PicoIn.opt & POPT_EN_STEREO) ? 4 : 2));
PsndClear(); PsndClear();
dac_info[224] = 0;
} }
// vim:shiftwidth=2:ts=2:expandtab // vim:shiftwidth=2:ts=2:expandtab