+// to be called on 224 or line_sample scanlines only\r
+PICO_INTERNAL void PsndGetSamples(int y)\r
+{\r
+#if SIMPLE_WRITE_SOUND\r
+ if (y != 224) return;\r
+ PsndRender(0, PsndLen);\r
+ if (PicoWriteSound) PicoWriteSound(PsndLen);\r
+ PsndClear();\r
+#else\r
+ static int curr_pos = 0;\r
+\r
+ if (y == 224)\r
+ {\r
+ if (emustatus & 2)\r
+ curr_pos += PsndRender(curr_pos, PsndLen-PsndLen/2);\r
+ else curr_pos = PsndRender(0, PsndLen);\r
+ if (emustatus&1) emustatus|=2; else emustatus&=~2;\r
+ if (PicoWriteSound) PicoWriteSound(curr_pos);\r
+ // clear sound buffer\r
+ PsndClear();\r
+ }\r
+ else if (emustatus & 3) {\r
+ emustatus|= 2;\r
+ emustatus&=~1;\r
+ curr_pos = PsndRender(0, PsndLen/2);\r
+ }\r
+#endif\r
+}\r
+\r