sms: do psg like md does
authornotaz <notasas@gmail.com>
Sat, 21 Oct 2017 21:39:43 +0000 (00:39 +0300)
committernotaz <notasas@gmail.com>
Sat, 21 Oct 2017 23:13:36 +0000 (02:13 +0300)
pico/sms.c
pico/sound/sound.c

index 748c326..6955a7d 100644 (file)
@@ -8,10 +8,8 @@
 /*
  * TODO:
  * - start in a state as if BIOS ran
- * - remaining status flags (OVR/COL)
  * - RAM support in mapper
  * - region support
- * - SN76496 DAC-like usage
  * - H counter
  */
 #include "pico_int.h"
@@ -133,8 +131,9 @@ static void z80_sms_out(unsigned short a, unsigned char d)
 
     case 0x40:
     case 0x41:
-      if (PicoIn.opt & POPT_EN_PSG)
-        SN76496Write(d);
+      if ((d & 0x90) == 0x90 && PsndPsgLine < Pico.m.scanline)
+        PsndDoPSG(Pico.m.scanline);
+      SN76496Write(d);
       break;
 
     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_done += z80_run((cycles_aim - cycles_done) >> 8) << 8;
   }
 
-  if (PsndOut)
-    PsndGetSamplesMS();
+  if (PsndOut && PsndPsgLine < lines)
+    PsndDoPSG(lines - 1);
 }
 
 void PicoFrameDrawOnlyMS(void)
@@ -319,3 +322,4 @@ void PicoFrameDrawOnlyMS(void)
     PicoLineMode4(y);
 }
 
+// vim:ts=2:sw=2:expandtab
index 56ffe3f..e799e93 100644 (file)
@@ -370,15 +370,12 @@ PICO_INTERNAL void PsndGetSamples(int y)
 \r
 PICO_INTERNAL void PsndGetSamplesMS(void)\r
 {\r
-  int stereo = (PicoIn.opt & 8) >> 3;\r
   int length = PsndLen_use;\r
 \r
-  // PSG\r
-  if (PicoIn.opt & POPT_EN_PSG)\r
-    SN76496Update(PsndOut, length, stereo);\r
+  PsndDoPSG(223);\r
 \r
   // upmix to "stereo" if needed\r
-  if (stereo) {\r
+  if (PicoIn.opt & POPT_EN_STEREO) {\r
     int i, *p;\r
     for (i = length, p = (void *)PsndOut; i > 0; i--, p++)\r
       *p |= *p << 16;\r
@@ -387,6 +384,8 @@ PICO_INTERNAL void PsndGetSamplesMS(void)
   if (PicoWriteSound != NULL)\r
     PicoWriteSound(length * ((PicoIn.opt & POPT_EN_STEREO) ? 4 : 2));\r
   PsndClear();\r
+\r
+  dac_info[224] = 0;\r
 }\r
 \r
 // vim:shiftwidth=2:ts=2:expandtab\r