#include "../libpicofe/posix.h"\r
#include "../libpicofe/input.h"\r
#include "../libpicofe/fonts.h"\r
+#include "../libpicofe/sndout.h"\r
#include "../libpicofe/lprintf.h"\r
#include "../libpicofe/plat.h"\r
#include "emu.h"\r
#include "input_pico.h"\r
#include "menu_pico.h"\r
-#include "config.h"\r
+#include "config_file.h"\r
\r
#include <pico/pico_int.h>\r
#include <pico/patch.h>\r
int pico_inp_mode = 0;\r
int engineState = PGS_Menu;\r
\r
+static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
+\r
/* tmp buff to reduce stack usage for plats with small stack */\r
static char static_buff[512];\r
const char *rom_fname_reload;\r
PicoMessage = plat_status_msg_busy_next;\r
PicoMCDopenTray = emu_tray_open;\r
PicoMCDcloseTray = emu_tray_close;\r
+\r
+ sndout_init();\r
}\r
\r
void emu_finish(void)\r
pprof_finish();\r
\r
PicoExit();\r
+ sndout_exit();\r
+}\r
+\r
+static void snd_write_nonblocking(int len)\r
+{\r
+ sndout_write_nb(PsndOut, len);\r
+}\r
+\r
+void emu_sound_start(void)\r
+{\r
+ PsndOut = NULL;\r
+\r
+ if (currentConfig.EmuOpt & EOPT_EN_SOUND)\r
+ {\r
+ int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0;\r
+\r
+ PsndRerate(Pico.m.frame_count ? 1 : 0);\r
+\r
+ printf("starting audio: %i len: %i stereo: %i, pal: %i\n",\r
+ PsndRate, PsndLen, is_stereo, Pico.m.pal);\r
+ sndout_start(PsndRate, is_stereo);\r
+ PicoWriteSound = snd_write_nonblocking;\r
+ plat_update_volume(0, 0);\r
+ memset(sndBuffer, 0, sizeof(sndBuffer));\r
+ PsndOut = sndBuffer;\r
+ }\r
+}\r
+\r
+void emu_sound_stop(void)\r
+{\r
+ sndout_stop();\r
+}\r
+\r
+void emu_sound_wait(void)\r
+{\r
+ sndout_wait();\r
+}\r
+\r
+static void emu_loop_prep(void)\r
+{\r
+ static int pal_old = -1;\r
+ static int filter_old = -1;\r
+\r
+ if (currentConfig.CPUclock != plat_target_cpu_clock_get())\r
+ plat_target_cpu_clock_set(currentConfig.CPUclock);\r
+\r
+ if (Pico.m.pal != pal_old) {\r
+ plat_target_lcdrate_set(Pico.m.pal);\r
+ pal_old = Pico.m.pal;\r
+ }\r
+\r
+ if (currentConfig.filter != filter_old) {\r
+ plat_target_hwfilter_set(currentConfig.filter);\r
+ filter_old = currentConfig.filter;\r
+ }\r
+\r
+ plat_target_gamma_set(currentConfig.gamma, 0);\r
+\r
+ pemu_loop_prep();\r
}\r
\r
static void skip_frame(int do_audio)\r
PicoCDBufferInit();\r
\r
plat_video_loop_prepare();\r
- pemu_loop_prep();\r
+ emu_loop_prep();\r
+ pemu_sound_start();\r
\r
/* number of ticks per frame */\r
if (Pico.m.pal) {\r
}\r
\r
pemu_loop_end();\r
+ emu_sound_stop();\r
\r
// pemu_loop_end() might want to do 1 frame for bg image,\r
// so free CD buffer here\r