offset = pos;\r
}\r
\r
- if (PicoMessage != NULL && offset > 4 * 1024 * 1024)\r
- PicoMessage("Decompressing data...");\r
+ if (PicoIn.osdMessage != NULL && offset > 4 * 1024 * 1024)\r
+ PicoIn.osdMessage("Decompressing data...");\r
\r
while (offset > 0) {\r
char buf[16 * 1024];\r
set_reg16(0x3e, 0x0000);
set_reg16(0x40, 0x000f);
- if (PicoMCDcloseTray)
- PicoMCDcloseTray();
+ if (PicoIn.mcdTrayClose)
+ PicoIn.mcdTrayClose();
return;
}
set_reg16(0x3e, 0x0000);
set_reg16(0x40, ~CD_OPEN & 0x0f);
- if (PicoMCDopenTray)
- PicoMCDopenTray();
+ if (PicoIn.mcdTrayOpen)
+ PicoIn.mcdTrayOpen();
return;
}
static unsigned int mcd_m68k_cycle_base;
static unsigned int mcd_s68k_cycle_base;
-void (*PicoMCDopenTray)(void) = NULL;
-void (*PicoMCDcloseTray)(void) = NULL;
-
PICO_INTERNAL void PicoInitMCD(void)
{
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80))
PicoSyncZ80(Pico.t.m68c_cnt + line_sample * 488);
- if (PsndOut)
+ if (PicoIn.sndOut)
PsndGetSamples(line_sample);
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80)) {
PicoSyncZ80(Pico.t.m68c_cnt + 224 * 488);
z80_int();
}
- if (PsndOut)
+ if (PicoIn.sndOut)
PsndGetSamples(224);
// sync z80
Pico.t.m68c_cnt += Pico.m.pal ? 151809 : 127671; // cycles adjusted for converter
PicoSyncZ80(Pico.t.m68c_cnt);
}
- if (PsndOut && ym2612.dacen && PsndDacLine < lines)
+ if (PicoIn.sndOut && ym2612.dacen && Pico.snd.dac_line < lines)
PsndDoDAC(lines - 1);
PsndDoPSG(lines - 1);
static void psg_write_68k(u32 d)\r
{\r
// look for volume write and update if needed\r
- if ((d & 0x90) == 0x90 && PsndPsgLine < Pico.m.scanline)\r
+ if ((d & 0x90) == 0x90 && Pico.snd.psg_line < Pico.m.scanline)\r
PsndDoPSG(Pico.m.scanline);\r
\r
SN76496Write(d);\r
{\r
if ((d & 0x90) == 0x90) {\r
int scanline = get_scanline(1);\r
- if (PsndPsgLine < scanline)\r
+ if (Pico.snd.psg_line < scanline)\r
PsndDoPSG(scanline);\r
}\r
\r
int xcycles = z80_cycles << 8;\r
\r
/* check for overflows */\r
- if ((mode_old & 4) && xcycles > timer_a_next_oflow)\r
+ if ((mode_old & 4) && xcycles > Pico.t.timer_a_next_oflow)\r
ym2612.OPN.ST.status |= 1;\r
\r
- if ((mode_old & 8) && xcycles > timer_b_next_oflow)\r
+ if ((mode_old & 8) && xcycles > Pico.t.timer_b_next_oflow)\r
ym2612.OPN.ST.status |= 2;\r
\r
/* update timer a */\r
if (mode_old & 1)\r
- while (xcycles > timer_a_next_oflow)\r
- timer_a_next_oflow += timer_a_step;\r
+ while (xcycles > Pico.t.timer_a_next_oflow)\r
+ Pico.t.timer_a_next_oflow += Pico.t.timer_a_step;\r
\r
if ((mode_old ^ mode_new) & 1) // turning on/off\r
{\r
if (mode_old & 1)\r
- timer_a_next_oflow = TIMER_NO_OFLOW;\r
+ Pico.t.timer_a_next_oflow = TIMER_NO_OFLOW;\r
else\r
- timer_a_next_oflow = xcycles + timer_a_step;\r
+ Pico.t.timer_a_next_oflow = xcycles + Pico.t.timer_a_step;\r
}\r
if (mode_new & 1)\r
- elprintf(EL_YMTIMER, "timer a upd to %i @ %i", timer_a_next_oflow>>8, z80_cycles);\r
+ elprintf(EL_YMTIMER, "timer a upd to %i @ %i", Pico.t.timer_a_next_oflow>>8, z80_cycles);\r
\r
/* update timer b */\r
if (mode_old & 2)\r
- while (xcycles > timer_b_next_oflow)\r
- timer_b_next_oflow += timer_b_step;\r
+ while (xcycles > Pico.t.timer_b_next_oflow)\r
+ Pico.t.timer_b_next_oflow += Pico.t.timer_b_step;\r
\r
if ((mode_old ^ mode_new) & 2)\r
{\r
if (mode_old & 2)\r
- timer_b_next_oflow = TIMER_NO_OFLOW;\r
+ Pico.t.timer_b_next_oflow = TIMER_NO_OFLOW;\r
else\r
- timer_b_next_oflow = xcycles + timer_b_step;\r
+ Pico.t.timer_b_next_oflow = xcycles + Pico.t.timer_b_step;\r
}\r
if (mode_new & 2)\r
- elprintf(EL_YMTIMER, "timer b upd to %i @ %i", timer_b_next_oflow>>8, z80_cycles);\r
+ elprintf(EL_YMTIMER, "timer b upd to %i @ %i", Pico.t.timer_b_next_oflow>>8, z80_cycles);\r
}\r
\r
// ym2612 DAC and timer I/O handlers for z80\r
if (a == 1 && ym2612.OPN.ST.address == 0x2a) /* DAC data */\r
{\r
int scanline = get_scanline(is_from_z80);\r
- //elprintf(EL_STATUS, "%03i -> %03i dac w %08x z80 %i", PsndDacLine, scanline, d, is_from_z80);\r
+ //elprintf(EL_STATUS, "%03i -> %03i dac w %08x z80 %i", Pico.snd.dac_line, scanline, d, is_from_z80);\r
ym2612.dacout = ((int)d - 0x80) << 6;\r
if (ym2612.dacen)\r
PsndDoDAC(scanline);\r
ym2612.OPN.ST.TA = TAnew;\r
//ym2612.OPN.ST.TAC = (1024-TAnew)*18;\r
//ym2612.OPN.ST.TAT = 0;\r
- timer_a_step = TIMER_A_TICK_ZCYCLES * (1024 - TAnew);\r
+ Pico.t.timer_a_step = TIMER_A_TICK_ZCYCLES * (1024 - TAnew);\r
if (ym2612.OPN.ST.mode & 1) {\r
// this is not right, should really be done on overflow only\r
int cycles = is_from_z80 ? z80_cyclesDone() : z80_cycles_from_68k();\r
- timer_a_next_oflow = (cycles << 8) + timer_a_step;\r
+ Pico.t.timer_a_next_oflow = (cycles << 8) + Pico.t.timer_a_step;\r
}\r
- elprintf(EL_YMTIMER, "timer a set to %i, %i", 1024 - TAnew, timer_a_next_oflow>>8);\r
+ elprintf(EL_YMTIMER, "timer a set to %i, %i", 1024 - TAnew, Pico.t.timer_a_next_oflow>>8);\r
}\r
return 0;\r
}\r
ym2612.OPN.ST.TB = d;\r
//ym2612.OPN.ST.TBC = (256-d) * 288;\r
//ym2612.OPN.ST.TBT = 0;\r
- timer_b_step = TIMER_B_TICK_ZCYCLES * (256 - d); // 262800\r
+ Pico.t.timer_b_step = TIMER_B_TICK_ZCYCLES * (256 - d); // 262800\r
if (ym2612.OPN.ST.mode & 2) {\r
int cycles = is_from_z80 ? z80_cyclesDone() : z80_cycles_from_68k();\r
- timer_b_next_oflow = (cycles << 8) + timer_b_step;\r
+ Pico.t.timer_b_next_oflow = (cycles << 8) + Pico.t.timer_b_step;\r
}\r
- elprintf(EL_YMTIMER, "timer b set to %i, %i", 256 - d, timer_b_next_oflow>>8);\r
+ elprintf(EL_YMTIMER, "timer b set to %i, %i", 256 - d, Pico.t.timer_b_next_oflow>>8);\r
}\r
return 0;\r
case 0x27: { /* mode, timer control */\r
int scanline = get_scanline(is_from_z80);\r
if (ym2612.dacen != (d & 0x80)) {\r
ym2612.dacen = d & 0x80;\r
- PsndDacLine = scanline;\r
+ Pico.snd.dac_line = scanline;\r
}\r
#ifdef __GP2X__\r
if (PicoIn.opt & POPT_EXT_FM) YM2612Write_940(a, d, scanline);\r
\r
\r
#define ym2612_read_local() \\r
- if (xcycles >= timer_a_next_oflow) \\r
+ if (xcycles >= Pico.t.timer_a_next_oflow) \\r
ym2612.OPN.ST.status |= (ym2612.OPN.ST.mode >> 2) & 1; \\r
- if (xcycles >= timer_b_next_oflow) \\r
+ if (xcycles >= Pico.t.timer_b_next_oflow) \\r
ym2612.OPN.ST.status |= (ym2612.OPN.ST.mode >> 2) & 2\r
\r
static u32 ym2612_read_local_z80(void)\r
\r
ym2612_read_local();\r
\r
- elprintf(EL_YMTIMER, "timer z80 read %i, sched %i, %i @ %i|%i", ym2612.OPN.ST.status,\r
- timer_a_next_oflow>>8, timer_b_next_oflow>>8, xcycles >> 8, (xcycles >> 8) / 228);\r
+ elprintf(EL_YMTIMER, "timer z80 read %i, sched %i, %i @ %i|%i",\r
+ ym2612.OPN.ST.status, Pico.t.timer_a_next_oflow >> 8,\r
+ Pico.t.timer_b_next_oflow >> 8, xcycles >> 8, (xcycles >> 8) / 228);\r
return ym2612.OPN.ST.status;\r
}\r
\r
\r
ym2612_read_local();\r
\r
- elprintf(EL_YMTIMER, "timer 68k read %i, sched %i, %i @ %i|%i", ym2612.OPN.ST.status,\r
- timer_a_next_oflow>>8, timer_b_next_oflow>>8, xcycles >> 8, (xcycles >> 8) / 228);\r
+ elprintf(EL_YMTIMER, "timer 68k read %i, sched %i, %i @ %i|%i",\r
+ ym2612.OPN.ST.status, Pico.t.timer_a_next_oflow >> 8,\r
+ Pico.t.timer_b_next_oflow >> 8, xcycles >> 8, (xcycles >> 8) / 228);\r
return ym2612.OPN.ST.status;\r
}\r
\r
int tac, tat = 0, tbc, tbt = 0;\r
tac = 1024 - ym2612.OPN.ST.TA;\r
tbc = 256 - ym2612.OPN.ST.TB;\r
- if (timer_a_next_oflow != TIMER_NO_OFLOW)\r
- tat = (int)((double)(timer_a_step - timer_a_next_oflow) / (double)timer_a_step * tac * 65536);\r
- if (timer_b_next_oflow != TIMER_NO_OFLOW)\r
- tbt = (int)((double)(timer_b_step - timer_b_next_oflow) / (double)timer_b_step * tbc * 65536);\r
+ if (Pico.t.timer_a_next_oflow != TIMER_NO_OFLOW)\r
+ tat = (int)((double)(Pico.t.timer_a_step - Pico.t.timer_a_next_oflow)\r
+ / (double)Pico.t.timer_a_step * tac * 65536);\r
+ if (Pico.t.timer_b_next_oflow != TIMER_NO_OFLOW)\r
+ tbt = (int)((double)(Pico.t.timer_b_step - Pico.t.timer_b_next_oflow)\r
+ / (double)Pico.t.timer_b_step * tbc * 65536);\r
elprintf(EL_YMTIMER, "save: timer a %i/%i", tat >> 16, tac);\r
elprintf(EL_YMTIMER, "save: timer b %i/%i", tbt >> 16, tbc);\r
\r
tac = (1024 - ym2612.OPN.ST.TA) << 16;\r
tbc = (256 - ym2612.OPN.ST.TB) << 16;\r
if (ym2612.OPN.ST.mode & 1)\r
- timer_a_next_oflow = (int)((double)(tac - tat) / (double)tac * timer_a_step);\r
+ Pico.t.timer_a_next_oflow = (int)((double)(tac - tat) / (double)tac * Pico.t.timer_a_step);\r
else\r
- timer_a_next_oflow = TIMER_NO_OFLOW;\r
+ Pico.t.timer_a_next_oflow = TIMER_NO_OFLOW;\r
if (ym2612.OPN.ST.mode & 2)\r
- timer_b_next_oflow = (int)((double)(tbc - tbt) / (double)tbc * timer_b_step);\r
+ Pico.t.timer_b_next_oflow = (int)((double)(tbc - tbt) / (double)tbc * Pico.t.timer_b_step);\r
else\r
- timer_b_next_oflow = TIMER_NO_OFLOW;\r
- elprintf(EL_YMTIMER, "load: %i/%i, timer_a_next_oflow %i", tat>>16, tac>>16, timer_a_next_oflow >> 8);\r
- elprintf(EL_YMTIMER, "load: %i/%i, timer_b_next_oflow %i", tbt>>16, tbc>>16, timer_b_next_oflow >> 8);\r
+ Pico.t.timer_b_next_oflow = TIMER_NO_OFLOW;\r
+ elprintf(EL_YMTIMER, "load: %i/%i, timer_a_next_oflow %i", tat>>16, tac>>16, Pico.t.timer_a_next_oflow >> 8);\r
+ elprintf(EL_YMTIMER, "load: %i/%i, timer_b_next_oflow %i", tbt>>16, tbc>>16, Pico.t.timer_b_next_oflow >> 8);\r
}\r
\r
#if defined(NO_32X) && defined(_ASM_MEMORY_C)\r
struct PicoMem PicoMem;\r
PicoInterface PicoIn;\r
\r
-void (*PicoWriteSound)(int len) = NULL; // called at the best time to send sound buffer (PsndOut) to hardware\r
void (*PicoResetHook)(void) = NULL;\r
void (*PicoLineHook)(void) = NULL;\r
\r
}\r
}\r
\r
-// callback to output message from emu\r
-void (*PicoMessage)(const char *msg)=NULL;\r
-\r
+// vim:ts=2:sw=2:expandtab\r
\r
unsigned short quirks; // game-specific quirks: PQUIRK_*\r
unsigned short overclockM68k; // overclock the emulated 68k, in %\r
+\r
+ int sndRate; // rate in Hz\r
+ short *sndOut; // PCM output buffer\r
+ void (*writeSound)(int len); // write .sndOut callback, called once per frame\r
+\r
+ void (*osdMessage)(const char *msg); // output OSD message from emu, optional\r
+\r
+ void (*mcdTrayOpen)(void);\r
+ void (*mcdTrayClose)(void);\r
} PicoInterface;\r
\r
extern PicoInterface PicoIn;\r
void PicoLoopPrepare(void);\r
void PicoFrame(void);\r
void PicoFrameDrawOnly(void);\r
-extern void (*PicoWriteSound)(int bytes); // called once per frame at the best time to send sound buffer (PsndOut) to hardware\r
-extern void (*PicoMessage)(const char *msg); // callback to output text message from emu\r
typedef enum { PI_ROM, PI_ISPAL, PI_IS40_CELL, PI_IS240_LINES } pint_t;\r
typedef union { int vint; void *vptr; } pint_ret_t;\r
void PicoGetInternal(pint_t which, pint_ret_t *ret);\r
\r
struct PicoEState;\r
\r
-// cd/mcd.c\r
-extern void (*PicoMCDopenTray)(void);\r
-extern void (*PicoMCDcloseTray)(void);\r
-\r
// pico.c\r
#define XPCM_BUFFER_SIZE (320+160)\r
typedef struct\r
#define PICO_SSH2_HZ ((int)(7670442.0 * 2.4))\r
\r
// sound.c\r
-extern int PsndRate,PsndLen;\r
-extern short *PsndOut;\r
extern void (*PsndMix_32_to_16l)(short *dest, int *src, int count);\r
void PsndRerate(int preserve_state);\r
\r
PICO_INTERNAL void PicoPicoPCMRerate(int xpcm_rate)
{
- stepsamples = (PsndRate<<10)/xpcm_rate;
+ stepsamples = (PicoIn.sndRate<<10)/xpcm_rate;
}
#define XSHIFT 6
}
// get samples from sound chips
- if ((y == 224 || y == line_sample) && PsndOut)
+ if ((y == 224 || y == line_sample) && PicoIn.sndOut)
{
cycles = SekCyclesDone();
#endif
// get samples from sound chips
- if (y == 224 && PsndOut)
+ if (y == 224 && PicoIn.sndOut)
PsndGetSamples(y);
// Run scanline:
cycles = SekCyclesDone();
if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80))
PicoSyncZ80(cycles);
- if (PsndOut && ym2612.dacen && PsndDacLine < lines)
+ if (PicoIn.sndOut && ym2612.dacen && Pico.snd.dac_line < lines)
PsndDoDAC(lines - 1);
- if (PsndOut && PsndPsgLine < lines)
+ if (PicoIn.sndOut && Pico.snd.psg_line < lines)
PsndDoPSG(lines - 1);
#ifdef PICO_CD
unsigned int z80c_cnt; // z80 cycles done (this frame)\r
unsigned int z80c_aim;\r
int z80_scanline;\r
+\r
+ int timer_a_next_oflow, timer_a_step; // in z80 cycles\r
+ int timer_b_next_oflow, timer_b_step;\r
+};\r
+\r
+struct PicoSound\r
+{\r
+ short len; // number of mono samples\r
+ short len_use; // adjusted\r
+ int len_e_add; // for non-int samples/frame\r
+ int len_e_cnt;\r
+ short dac_line;\r
+ short psg_line;\r
};\r
\r
// run tools/mkoffsets pico/pico_int_o32.h if you change these\r
struct PicoMisc m;\r
struct PicoTiming t;\r
struct PicoCartSave sv;\r
+ struct PicoSound snd;\r
struct PicoEState est;\r
struct PicoMS ms;\r
\r
\r
// sound/sound.c\r
extern short cdda_out_buffer[2*1152];\r
-extern int PsndLen_exc_cnt;\r
-extern int PsndLen_exc_add;\r
-extern int timer_a_next_oflow, timer_a_step; // in z80 cycles\r
-extern int timer_b_next_oflow, timer_b_step;\r
\r
void cdda_start_play(int lba_base, int lba_offset, int lb_len);\r
\r
#define TIMER_B_TICK_ZCYCLES 262800 // 275251 broken, see Dai Makaimura\r
\r
#define timers_cycle() \\r
- if (timer_a_next_oflow > 0 && timer_a_next_oflow < TIMER_NO_OFLOW) \\r
- timer_a_next_oflow -= Pico.m.pal ? 70938*256 : 59659*256; \\r
- if (timer_b_next_oflow > 0 && timer_b_next_oflow < TIMER_NO_OFLOW) \\r
- timer_b_next_oflow -= Pico.m.pal ? 70938*256 : 59659*256; \\r
+ if (Pico.t.timer_a_next_oflow > 0 && Pico.t.timer_a_next_oflow < TIMER_NO_OFLOW) \\r
+ Pico.t.timer_a_next_oflow -= Pico.m.pal ? 70938*256 : 59659*256; \\r
+ if (Pico.t.timer_b_next_oflow > 0 && Pico.t.timer_b_next_oflow < TIMER_NO_OFLOW) \\r
+ Pico.t.timer_b_next_oflow -= Pico.m.pal ? 70938*256 : 59659*256; \\r
ym2612_sync_timers(0, ym2612.OPN.ST.mode, ym2612.OPN.ST.mode);\r
\r
#define timers_reset() \\r
- timer_a_next_oflow = timer_b_next_oflow = TIMER_NO_OFLOW; \\r
- timer_a_step = TIMER_A_TICK_ZCYCLES * 1024; \\r
- timer_b_step = TIMER_B_TICK_ZCYCLES * 256;\r
+ Pico.t.timer_a_next_oflow = Pico.t.timer_b_next_oflow = TIMER_NO_OFLOW; \\r
+ Pico.t.timer_a_step = TIMER_A_TICK_ZCYCLES * 1024; \\r
+ Pico.t.timer_b_step = TIMER_B_TICK_ZCYCLES * 256;\r
\r
\r
// videoport.c\r
PICO_INTERNAL void PsndClear(void);\r
PICO_INTERNAL void PsndGetSamples(int y);\r
PICO_INTERNAL void PsndGetSamplesMS(void);\r
-extern int PsndDacLine, PsndPsgLine;\r
\r
// sms.c\r
#ifndef NO_SMS\r
#define OFS_Pico_m_hardware 0x0047
#define OFS_Pico_m_z80_reset 0x004f
#define OFS_Pico_m_sram_reg 0x0049
-#define OFS_Pico_sv 0x007c
-#define OFS_Pico_sv_data 0x007c
-#define OFS_Pico_sv_start 0x0080
-#define OFS_Pico_sv_end 0x0084
-#define OFS_Pico_sv_flags 0x0088
-#define OFS_Pico_rom 0x031c
-#define OFS_Pico_romsize 0x0320
+#define OFS_Pico_sv 0x008c
+#define OFS_Pico_sv_data 0x008c
+#define OFS_Pico_sv_start 0x0090
+#define OFS_Pico_sv_end 0x0094
+#define OFS_Pico_sv_flags 0x0098
+#define OFS_Pico_rom 0x033c
+#define OFS_Pico_romsize 0x0340
#define OFS_EST_DrawScanline 0x00
#define OFS_EST_rendstatus 0x04
#define OFS_EST_DrawLineDest 0x08
case 0x40:
case 0x41:
- if ((d & 0x90) == 0x90 && PsndPsgLine < Pico.m.scanline)
+ if ((d & 0x90) == 0x90 && Pico.snd.psg_line < Pico.m.scanline)
PsndDoPSG(Pico.m.scanline);
SN76496Write(d);
break;
}
// 224 because of how it's done for MD...
- if (y == 224 && PsndOut)
+ if (y == 224 && PicoIn.sndOut)
PsndGetSamplesMS();
cycles_aim += cycles_line;
cycles_done += z80_run((cycles_aim - cycles_done) >> 8) << 8;
}
- if (PsndOut && PsndPsgLine < lines)
+ if (PicoIn.sndOut && Pico.snd.psg_line < lines)
PsndDoPSG(lines - 1);
}
// cdda output buffer\r
short cdda_out_buffer[2*1152];\r
\r
-// for Pico\r
-int PsndRate=0;\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, PsndPsgLine;\r
-short *PsndOut=NULL; // PCM data buffer\r
-static int PsndLen_use;\r
-\r
-// timers\r
-int timer_a_next_oflow, timer_a_step; // in z80 cycles\r
-int timer_b_next_oflow, timer_b_step;\r
-\r
// sn76496\r
extern int *sn76496_regs;\r
\r
\r
static void dac_recalculate(void)\r
{\r
- int i, dac_cnt, pos, len, lines = Pico.m.pal ? 313 : 262, mid = Pico.m.pal ? 68 : 93;\r
+ int lines = Pico.m.pal ? 313 : 262;\r
+ int mid = Pico.m.pal ? 68 : 93;\r
+ int i, dac_cnt, pos, len;\r
\r
- if (PsndLen <= lines)\r
+ if (Pico.snd.len <= lines)\r
{\r
// shrinking algo\r
- dac_cnt = -PsndLen;\r
+ dac_cnt = -Pico.snd.len;\r
len=1; pos=0;\r
dac_info[225] = 1;\r
\r
pos++;\r
dac_cnt += lines;\r
}\r
- dac_cnt -= PsndLen;\r
+ dac_cnt -= Pico.snd.len;\r
dac_info[i] = pos;\r
}\r
}\r
else\r
{\r
// stretching\r
- dac_cnt = PsndLen;\r
+ dac_cnt = Pico.snd.len;\r
pos=0;\r
for(i = 225; i != 224; i++)\r
{\r
len++;\r
}\r
if (i == mid) // midpoint\r
- while(pos+len < PsndLen/2) {\r
+ while(pos+len < Pico.snd.len/2) {\r
dac_cnt -= lines;\r
len++;\r
}\r
- dac_cnt += PsndLen;\r
+ dac_cnt += Pico.snd.len;\r
pos += len;\r
dac_info[i] = pos;\r
}\r
ym2612_pack_state();\r
memcpy(state, YM2612GetRegs(), 0x204);\r
}\r
- YM2612Init(Pico.m.pal ? OSC_PAL/7 : OSC_NTSC/7, PsndRate);\r
+ YM2612Init(Pico.m.pal ? OSC_PAL/7 : OSC_NTSC/7, PicoIn.sndRate);\r
if (preserve_state) {\r
// feed it back it's own registers, just like after loading state\r
memcpy(YM2612GetRegs(), state, 0x204);\r
}\r
\r
if (preserve_state) memcpy(state, sn76496_regs, 28*4); // remember old state\r
- SN76496_init(Pico.m.pal ? OSC_PAL/15 : OSC_NTSC/15, PsndRate);\r
+ SN76496_init(Pico.m.pal ? OSC_PAL/15 : OSC_NTSC/15, PicoIn.sndRate);\r
if (preserve_state) memcpy(sn76496_regs, state, 28*4); // restore old state\r
\r
if (state)\r
free(state);\r
\r
- // calculate PsndLen\r
- PsndLen=PsndRate / target_fps;\r
- PsndLen_exc_add=((PsndRate - PsndLen*target_fps)<<16) / target_fps;\r
- PsndLen_exc_cnt=0;\r
+ // calculate Pico.snd.len\r
+ Pico.snd.len = PicoIn.sndRate / target_fps;\r
+ Pico.snd.len_e_add = ((PicoIn.sndRate - Pico.snd.len * target_fps) << 16) / target_fps;\r
+ Pico.snd.len_e_cnt = 0;\r
\r
// recalculate dac info\r
dac_recalculate();\r
// clear all buffers\r
memset32(PsndBuffer, 0, sizeof(PsndBuffer)/4);\r
memset(cdda_out_buffer, 0, sizeof(cdda_out_buffer));\r
- if (PsndOut)\r
+ if (PicoIn.sndOut)\r
PsndClear();\r
\r
// set mixer\r
\r
PICO_INTERNAL void PsndStartFrame(void)\r
{\r
- // compensate for float part of PsndLen\r
- PsndLen_use = PsndLen;\r
- PsndLen_exc_cnt += PsndLen_exc_add;\r
- if (PsndLen_exc_cnt >= 0x10000) {\r
- PsndLen_exc_cnt -= 0x10000;\r
- PsndLen_use++;\r
+ // compensate for float part of Pico.snd.len\r
+ Pico.snd.len_use = Pico.snd.len;\r
+ Pico.snd.len_e_cnt += Pico.snd.len_e_add;\r
+ if (Pico.snd.len_e_cnt >= 0x10000) {\r
+ Pico.snd.len_e_cnt -= 0x10000;\r
+ Pico.snd.len_use++;\r
}\r
\r
- PsndDacLine = PsndPsgLine = 0;\r
+ Pico.snd.dac_line = Pico.snd.psg_line = 0;\r
Pico.m.status &= ~1;\r
- dac_info[224] = PsndLen_use;\r
+ dac_info[224] = Pico.snd.len_use;\r
}\r
\r
PICO_INTERNAL void PsndDoDAC(int line_to)\r
{\r
int pos, pos1, len;\r
int dout = ym2612.dacout;\r
- int line_from = PsndDacLine;\r
+ int line_from = Pico.snd.dac_line;\r
\r
if (line_to >= 313)\r
line_to = 312;\r
if (len <= 0)\r
return;\r
\r
- PsndDacLine = line_to + 1;\r
+ Pico.snd.dac_line = line_to + 1;\r
\r
- if (!PsndOut)\r
+ if (!PicoIn.sndOut)\r
return;\r
\r
if (PicoIn.opt & POPT_EN_STEREO) {\r
- short *d = PsndOut + pos*2;\r
+ short *d = PicoIn.sndOut + pos*2;\r
for (; len > 0; len--, d+=2) *d += dout;\r
} else {\r
- short *d = PsndOut + pos;\r
+ short *d = PicoIn.sndOut + pos;\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 line_from = Pico.snd.psg_line;\r
int pos, pos1, len;\r
int stereo = 0;\r
\r
if (len <= 0)\r
return;\r
\r
- PsndPsgLine = line_to + 1;\r
+ Pico.snd.psg_line = line_to + 1;\r
\r
- if (!PsndOut || !(PicoIn.opt & POPT_EN_PSG))\r
+ if (!PicoIn.sndOut || !(PicoIn.opt & POPT_EN_PSG))\r
return;\r
\r
if (PicoIn.opt & POPT_EN_STEREO) {\r
stereo = 1;\r
pos <<= 1;\r
}\r
- SN76496Update(PsndOut + pos, len, stereo);\r
+ SN76496Update(PicoIn.sndOut + pos, len, stereo);\r
}\r
\r
// cdda\r
int ret, cdda_bytes, mult = 1;\r
\r
cdda_bytes = length*4;\r
- if (PsndRate <= 22050 + 100) mult = 2;\r
- if (PsndRate < 22050 - 100) mult = 4;\r
+ if (PicoIn.sndRate <= 22050 + 100) mult = 2;\r
+ if (PicoIn.sndRate < 22050 - 100) mult = 4;\r
cdda_bytes *= mult;\r
\r
ret = pm_read(cdda_out_buffer, cdda_bytes, Pico_mcd->cdda_stream);\r
\r
PICO_INTERNAL void PsndClear(void)\r
{\r
- int len = PsndLen;\r
- if (PsndLen_exc_add) len++;\r
+ int len = Pico.snd.len;\r
+ if (Pico.snd.len_e_add) len++;\r
if (PicoIn.opt & POPT_EN_STEREO)\r
- memset32((int *) PsndOut, 0, len); // assume PsndOut to be aligned\r
+ memset32((int *) PicoIn.sndOut, 0, len); // assume PicoIn.sndOut to be aligned\r
else {\r
- short *out = PsndOut;\r
+ short *out = PicoIn.sndOut;\r
if ((long)out & 2) { *out++ = 0; len--; }\r
memset32((int *) out, 0, len/2);\r
if (len & 1) out[len-1] = 0;\r
pprof_start(sound);\r
\r
if (PicoIn.AHW & PAHW_PICO) {\r
- PicoPicoPCMUpdate(PsndOut+offset, length, stereo);\r
+ PicoPicoPCMUpdate(PicoIn.sndOut+offset, length, stereo);\r
return length;\r
}\r
\r
p32x_pwm_update(buf32, length, stereo);\r
\r
// convert + limit to normal 16bit output\r
- PsndMix_32_to_16l(PsndOut+offset, buf32, length);\r
+ PsndMix_32_to_16l(PicoIn.sndOut+offset, buf32, length);\r
\r
pprof_end(sound);\r
\r
{\r
static int curr_pos = 0;\r
\r
- if (ym2612.dacen && PsndDacLine < y)\r
+ if (ym2612.dacen && Pico.snd.dac_line < y)\r
PsndDoDAC(y - 1);\r
PsndDoPSG(y - 1);\r
\r
if (y == 224)\r
{\r
if (Pico.m.status & 2)\r
- curr_pos += PsndRender(curr_pos, PsndLen-PsndLen/2);\r
- else curr_pos = PsndRender(0, PsndLen_use);\r
+ curr_pos += PsndRender(curr_pos, Pico.snd.len-Pico.snd.len/2);\r
+ else curr_pos = PsndRender(0, Pico.snd.len_use);\r
if (Pico.m.status & 1)\r
Pico.m.status |= 2;\r
else Pico.m.status &= ~2;\r
- if (PicoWriteSound)\r
- PicoWriteSound(curr_pos * ((PicoIn.opt & POPT_EN_STEREO) ? 4 : 2));\r
+ if (PicoIn.writeSound)\r
+ PicoIn.writeSound(curr_pos * ((PicoIn.opt & POPT_EN_STEREO) ? 4 : 2));\r
// clear sound buffer\r
PsndClear();\r
- PsndDacLine = 224;\r
+ Pico.snd.dac_line = 224;\r
dac_info[224] = 0;\r
}\r
else if (Pico.m.status & 3) {\r
Pico.m.status |= 2;\r
Pico.m.status &= ~1;\r
- curr_pos = PsndRender(0, PsndLen/2);\r
+ curr_pos = PsndRender(0, Pico.snd.len/2);\r
}\r
}\r
\r
PICO_INTERNAL void PsndGetSamplesMS(void)\r
{\r
- int length = PsndLen_use;\r
+ int length = Pico.snd.len_use;\r
\r
PsndDoPSG(223);\r
\r
// upmix to "stereo" if needed\r
if (PicoIn.opt & POPT_EN_STEREO) {\r
int i, *p;\r
- for (i = length, p = (void *)PsndOut; i > 0; i--, p++)\r
+ for (i = length, p = (void *)PicoIn.sndOut; i > 0; i--, p++)\r
*p |= *p << 16;\r
}\r
\r
- if (PicoWriteSound != NULL)\r
- PicoWriteSound(length * ((PicoIn.opt & POPT_EN_STEREO) ? 4 : 2));\r
+ if (PicoIn.writeSound != NULL)\r
+ PicoIn.writeSound(length * ((PicoIn.opt & POPT_EN_STEREO) ? 4 : 2));\r
PsndClear();\r
\r
dac_info[224] = 0;\r
case MA_OPT_SOUND_QUALITY:
if (strcasecmp(var, "Sound Quality") != 0) return 0;
- PsndRate = strtoul(val, &tmp, 10);
- if (PsndRate < 8000 || PsndRate > 44100)
- PsndRate = 22050;
+ PicoIn.sndRate = strtoul(val, &tmp, 10);
+ if (PicoIn.sndRate < 8000 || PicoIn.sndRate > 44100)
+ PicoIn.sndRate = 22050;
if (*tmp == 'H' || *tmp == 'h') tmp++;
if (*tmp == 'Z' || *tmp == 'z') tmp++;
while (*tmp == ' ') tmp++;
{\r
memcpy(¤tConfig, &defaultConfig, sizeof(currentConfig));\r
PicoIn.opt = currentConfig.s_PicoOpt;\r
- PsndRate = currentConfig.s_PsndRate;\r
+ PicoIn.sndRate = currentConfig.s_PsndRate;\r
PicoIn.regionOverride = currentConfig.s_PicoRegion;\r
PicoIn.autoRgnOrder = currentConfig.s_PicoAutoRgnOrder;\r
}\r
static int set_Frameskip, set_EmuOpt, is_on = 0;\r
\r
if (set_on && !is_on) {\r
- set_PsndOut = PsndOut;\r
+ set_PsndOut = PicoIn.sndOut;\r
set_Frameskip = currentConfig.Frameskip;\r
set_EmuOpt = currentConfig.EmuOpt;\r
- PsndOut = NULL;\r
+ PicoIn.sndOut = NULL;\r
currentConfig.Frameskip = 8;\r
currentConfig.EmuOpt &= ~4;\r
currentConfig.EmuOpt |= 0x40000;\r
emu_status_msg("FAST FORWARD");\r
}\r
else if (!set_on && is_on) {\r
- PsndOut = set_PsndOut;\r
+ PicoIn.sndOut = set_PsndOut;\r
currentConfig.Frameskip = set_Frameskip;\r
currentConfig.EmuOpt = set_EmuOpt;\r
PsndRerate(1);\r
config_readlrom(path);\r
\r
PicoInit();\r
- PicoMessage = plat_status_msg_busy_next;\r
- PicoMCDopenTray = emu_tray_open;\r
- PicoMCDcloseTray = emu_tray_close;\r
+ PicoIn.osdMessage = plat_status_msg_busy_next;\r
+ PicoIn.mcdTrayOpen = emu_tray_open;\r
+ PicoIn.mcdTrayClose = emu_tray_close;\r
\r
sndout_init();\r
}\r
\r
static void snd_write_nonblocking(int len)\r
{\r
- sndout_write_nb(PsndOut, len);\r
+ sndout_write_nb(PicoIn.sndOut, len);\r
}\r
\r
void emu_sound_start(void)\r
{\r
- PsndOut = NULL;\r
+ PicoIn.sndOut = NULL;\r
\r
if (currentConfig.EmuOpt & EOPT_EN_SOUND)\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
+ PicoIn.sndRate, Pico.snd.len, is_stereo, Pico.m.pal);\r
+ sndout_start(PicoIn.sndRate, is_stereo);\r
+ PicoIn.writeSound = snd_write_nonblocking;\r
plat_update_volume(0, 0);\r
memset(sndBuffer, 0, sizeof(sndBuffer));\r
- PsndOut = sndBuffer;\r
+ PicoIn.sndOut = sndBuffer;\r
}\r
}\r
\r
{
switch (id) {
case MA_OPT_SOUND_QUALITY:
- PsndRate = sndrate_prevnext(PsndRate, keys & PBTN_RIGHT);
+ PicoIn.sndRate = sndrate_prevnext(PicoIn.sndRate, keys & PBTN_RIGHT);
break;
case MA_OPT_REGION:
region_prevnext(keys & PBTN_RIGHT);
const char *str2;
*offs = -8;
str2 = (PicoIn.opt & POPT_EN_STEREO) ? "stereo" : "mono";
- sprintf(static_buff, "%5iHz %s", PsndRate, str2);
+ sprintf(static_buff, "%5iHz %s", PicoIn.sndRate, str2);
return static_buff;
}
if (inp & PBTN_UP) pv->debug_p ^= PVD_KILL_S_HI;
if (inp & PBTN_MA2) pv->debug_p ^= PVD_KILL_32X;
if (inp & PBTN_MOK) {
- PsndOut = NULL; // just in case
+ PicoIn.sndOut = NULL; // just in case
PicoIn.skipFrame = 1;
PicoFrame();
PicoIn.skipFrame = 0;
return;
length_mp3 = length;
- if (PsndRate <= 11025 + 100) {
+ if (PicoIn.sndRate <= 11025 + 100) {
mix_samples = mix_16h_to_32_s2;
length_mp3 <<= 2; shr = 2;
}
- else if (PsndRate <= 22050 + 100) {
+ else if (PicoIn.sndRate <= 22050 + 100) {
mix_samples = mix_16h_to_32_s1;
length_mp3 <<= 1; shr = 1;
}
static void updateSound(int len)
{
snd_all_samples += len / 2;
- PsndOut += len / 2;
- if (PsndOut - snd_cbuff >= snd_cbuf_samples)
+ PicoIn.sndOut += len / 2;
+ if (PicoIn.sndOut - snd_cbuff >= snd_cbuf_samples)
{
- //if (PsndOut - snd_cbuff != snd_cbuf_samples)
- // stdbg("snd diff is %i, not %i", PsndOut - snd_cbuff, snd_cbuf_samples);
- PsndOut = snd_cbuff;
+ //if (PicoIn.sndOut - snd_cbuff != snd_cbuf_samples)
+ // stdbg("snd diff is %i, not %i", PicoIn.sndOut - snd_cbuff, snd_cbuf_samples);
+ PicoIn.sndOut = snd_cbuff;
}
}
{
int do_it = 1;
- if (PsndOut != NULL)
+ if (PicoIn.sndOut != NULL)
FrameworkAudio_SetPause(1);
if (giz_screen == NULL)
giz_screen = fb_lock(1);
Sleep(0);
}
- if (PsndOut != NULL)
+ if (PicoIn.sndOut != NULL)
FrameworkAudio_SetPause(0);
reset_timing = 1;
}
events = (allActions[0] | allActions[1]) >> 16;
// volume is treated in special way and triggered every frame
- if ((events & 0x6000) && PsndOut != NULL)
+ if ((events & 0x6000) && PicoIn.sndOut != NULL)
{
int vol = currentConfig.volume;
if (events & 0x2000) {
if (PicoIn.AHW & PAHW_MCD) PicoCDBufferInit();
// prepare sound stuff
- PsndOut = NULL;
+ PicoIn.sndOut = NULL;
if (currentConfig.EmuOpt & 4)
{
int ret, snd_excess_add, stereo;
- if (PsndRate != PsndRate_old || (PicoIn.opt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) {
+ if (PicoIn.sndRate != PsndRate_old || (PicoIn.opt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) {
PsndRerate(Pico.m.frame_count ? 1 : 0);
}
stereo=(PicoIn.opt&8)>>3;
- snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;
- snd_cbuf_samples = (PsndRate<<stereo) * 16 / target_fps;
+ snd_excess_add = ((PicoIn.sndRate - Pico.snd.len*target_fps)<<16) / target_fps;
+ snd_cbuf_samples = (PicoIn.sndRate<<stereo) * 16 / target_fps;
lprintf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",
- PsndRate, PsndLen, snd_excess_add, stereo, Pico.m.pal);
- ret = FrameworkAudio_Init(PsndRate, snd_cbuf_samples, stereo);
+ PicoIn.sndRate, Pico.snd.len, snd_excess_add, stereo, Pico.m.pal);
+ ret = FrameworkAudio_Init(PicoIn.sndRate, snd_cbuf_samples, stereo);
if (ret != 0) {
lprintf("FrameworkAudio_Init() failed: %i\n", ret);
sprintf(noticeMsg, "sound init failed (%i), snd disabled", ret);
currentConfig.EmuOpt &= ~4;
} else {
FrameworkAudio_SetVolume(currentConfig.volume, currentConfig.volume);
- PicoWriteSound = updateSound;
+ PicoIn.writeSound = updateSound;
snd_cbuff = FrameworkAudio_56448Buffer();
- PsndOut = snd_cbuff + snd_cbuf_samples / 2; // start writing at the middle
+ PicoIn.sndOut = snd_cbuff + snd_cbuf_samples / 2; // start writing at the middle
snd_all_samples = 0;
- PsndRate_old = PsndRate;
+ PsndRate_old = PicoIn.sndRate;
PicoOpt_old = PicoIn.opt;
pal_old = Pico.m.pal;
}
//tval_thissec += 1000;
tval_thissec += sec_ms;
- if (PsndOut != NULL)
+ if (PicoIn.sndOut != NULL)
{
/* some code which tries to sync things to audio clock, the dirty way */
static int audio_skew_prev = 0;
int audio_skew, adj, co = 9, shift = 7;
audio_skew = snd_all_samples*2 - FrameworkAudio_BufferPos();
- if (PsndRate == 22050) co = 10;
- if (PsndRate > 22050) co = 11;
+ if (PicoIn.sndRate == 22050) co = 10;
+ if (PicoIn.sndRate > 22050) co = 11;
if (PicoIn.opt&8) shift++;
if (audio_skew < 0) {
adj = -((-audio_skew) >> shift);
for (i = 0; i < currentConfig.Frameskip; i++) {
updateKeys();
SkipFrame(); frames_done++;
- if (PsndOut) { // do framelimitting if sound is enabled
+ if (PicoIn.sndOut) { // do framelimitting if sound is enabled
int tval_diff;
tval = GetTickCount();
tval_diff = (int)(tval - tval_thissec) << 8;
if (currentConfig.Frameskip < 0 && tval_diff - lim_time >= (300<<8)) // slowdown detection
reset_timing = 1;
- else if (PsndOut != NULL || currentConfig.Frameskip < 0)
+ else if (PicoIn.sndOut != NULL || currentConfig.Frameskip < 0)
{
// sleep if we are still too fast
if (tval_diff < lim_time)
if (PicoIn.AHW & PAHW_MCD) PicoCDBufferFree();
- if (PsndOut != NULL) {
- PsndOut = snd_cbuff = NULL;
+ if (PicoIn.sndOut != NULL) {
+ PicoIn.sndOut = snd_cbuff = NULL;
FrameworkAudio_Close();
}
break;\r
case MA_OPT_SOUND_QUALITY:\r
str = (PicoIn.opt&0x08)?"stereo":"mono";\r
- text_out16(x, y, "Sound Quality: %5iHz %s", PsndRate, str);\r
+ text_out16(x, y, "Sound Quality: %5iHz %s", PicoIn.sndRate, str);\r
break;\r
case MA_OPT_REGION:\r
text_out16(x, y, "Region: %s", me_region_name(PicoIn.regionOverride, PicoIn.autoRgnOrder));\r
}\r
break;\r
case MA_OPT_SOUND_QUALITY:\r
- if ((inp & PBTN_RIGHT) && PsndRate == 44100 &&\r
+ if ((inp & PBTN_RIGHT) && PicoIn.sndRate == 44100 &&\r
!(PicoIn.opt&0x08))\r
{\r
- PsndRate = 11025;\r
+ PicoIn.sndRate = 11025;\r
PicoIn.opt |= 8;\r
- } else if ((inp & PBTN_LEFT) && PsndRate == 11025 &&\r
+ } else if ((inp & PBTN_LEFT) && PicoIn.sndRate == 11025 &&\r
(PicoIn.opt&0x08) && !(PicoIn.AHW&1))\r
{\r
- PsndRate = 44100;\r
+ PicoIn.sndRate = 44100;\r
PicoIn.opt &= ~8;\r
} else\r
- PsndRate = sndrate_prevnext(PsndRate, inp & PBTN_RIGHT);\r
+ PicoIn.sndRate = sndrate_prevnext(PicoIn.sndRate, inp & PBTN_RIGHT);\r
break;\r
case MA_OPT_REGION:\r
region_prevnext(inp & PBTN_RIGHT);\r
writebuff_ptr = 0;\r
\r
/* predict sample counter for next frame */\r
- if (PsndLen_exc_add) {\r
- length = PsndLen;\r
- if (PsndLen_exc_cnt + PsndLen_exc_add >= 0x10000) length++;\r
+ if (Pico.snd.len_e_add) {\r
+ length = Pico.snd.len;\r
+ if (Pico.snd.len_e_cnt + Pico.snd.len_e_add >= 0x10000) length++;\r
}\r
\r
/* give 940 ym job */\r
\r
if (loaded_mp3 != f)\r
{\r
- if (PicoMessage != NULL)\r
+ if (PicoIn.osdMessage != NULL)\r
{\r
fseek(f, 0, SEEK_END);\r
if (ftell(f) > 2*1024*1024)\r
- PicoMessage("Loading MP3...");\r
+ PicoIn.osdMessage("Loading MP3...");\r
}\r
fseek(f, 0, SEEK_SET);\r
fread(mp3_mem, 1, MP3_SIZE_MAX, f);\r
{\r
soc = soc_detect();\r
if (soc == SOCID_POLLUX) {\r
- PsndRate = pollux_get_real_snd_rate(PsndRate);\r
+ PicoIn.sndRate = pollux_get_real_snd_rate(PicoIn.sndRate);\r
PsndRerate(Pico.m.frame_count ? 1 : 0);\r
}\r
\r
int i;\r
\r
/* get back from Pollux pain */\r
- PsndRate += 1000;\r
+ PicoIn.sndRate += 1000;\r
for (i = 0; i < ARRAY_SIZE(sound_rates); i++) {\r
- if (PsndRate >= sound_rates[i]) {\r
- PsndRate = sound_rates[i];\r
+ if (PicoIn.sndRate >= sound_rates[i]) {\r
+ PicoIn.sndRate = sound_rates[i];\r
break;\r
}\r
}\r
PicoLoopPrepare();
- PicoWriteSound = snd_write;
+ PicoIn.writeSound = snd_write;
memset(sndBuffer, 0, sizeof(sndBuffer));
- PsndOut = sndBuffer;
+ PicoIn.sndOut = sndBuffer;
PsndRerate(0);
return true;
static void snd_write(int len)
{
- audio_batch_cb(PsndOut, len / 4);
+ audio_batch_cb(PicoIn.sndOut, len / 4);
}
static enum input_device input_name_to_val(const char *name)
#endif
PicoIn.opt |= POPT_EN_DRC;
#endif
- PsndRate = 44100;
+ PicoIn.sndRate = 44100;
PicoIn.autoRgnOrder = 0x184; // US, EU, JP
vout_width = 320;
PicoDrawSetOutFormat(PDF_RGB555, 0);
PicoDrawSetOutBuf(vout_buf, vout_width * 2);
- //PicoMessage = plat_status_msg_busy_next;
- PicoMCDopenTray = disk_tray_open;
- PicoMCDcloseTray = disk_tray_close;
+ //PicoIn.osdMessage = plat_status_msg_busy_next;
+ PicoIn.mcdTrayOpen = disk_tray_open;
+ PicoIn.mcdTrayClose = disk_tray_close;
update_variables();
}
samples_made = samples_done = 0;
- if (PsndRate != PsndRate_old || (PicoIn.opt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) {
+ if (PicoIn.sndRate != PsndRate_old || (PicoIn.opt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) {
PsndRerate(Pico.m.frame_count ? 1 : 0);
}
stereo=(PicoIn.opt&8)>>3;
samples_block = Pico.m.pal ? SOUND_BLOCK_SIZE_PAL : SOUND_BLOCK_SIZE_NTSC;
- if (PsndRate <= 22050) samples_block /= 2;
+ if (PicoIn.sndRate <= 22050) samples_block /= 2;
sndBuffer_endptr = &sndBuffer[samples_block*SOUND_BLOCK_COUNT];
lprintf("starting audio: %i, len: %i, stereo: %i, pal: %i, block samples: %i\n",
- PsndRate, PsndLen, stereo, Pico.m.pal, samples_block);
+ PicoIn.sndRate, Pico.snd.len, stereo, Pico.m.pal, samples_block);
// while (sceAudioOutput2GetRestSample() > 0) psp_msleep(100);
// sceAudio_5C37C0AE();
- ret = sceAudio_38553111(samples_block/2, PsndRate, 2); // seems to not need that stupid 64byte alignment
+ ret = sceAudio_38553111(samples_block/2, PicoIn.sndRate, 2); // seems to not need that stupid 64byte alignment
if (ret < 0) {
lprintf("sceAudio_38553111() failed: %i\n", ret);
emu_status_msg("sound init failed (%i), snd disabled", ret);
currentConfig.EmuOpt &= ~EOPT_EN_SOUND;
} else {
- PicoWriteSound = writeSound;
+ PicoIn.writeSound = writeSound;
memset32((int *)(void *)sndBuffer, 0, sizeof(sndBuffer)/4);
snd_playptr = sndBuffer_endptr - samples_block;
samples_made = samples_block; // send 1 empty block first..
- PsndOut = sndBuffer;
- PsndRate_old = PsndRate;
+ PicoIn.sndOut = sndBuffer;
+ PsndRate_old = PicoIn.sndRate;
PicoOpt_old = PicoIn.opt;
pal_old = Pico.m.pal;
}
{
int ret;
- PsndOut += len / 2;
- /*if (PsndOut > sndBuffer_endptr) {
- memcpy32((int *)(void *)sndBuffer, (int *)endptr, (PsndOut - endptr + 1) / 2);
- PsndOut = &sndBuffer[PsndOut - endptr];
+ PicoIn.sndOut += len / 2;
+ /*if (PicoIn.sndOut > sndBuffer_endptr) {
+ memcpy32((int *)(void *)sndBuffer, (int *)endptr, (PicoIn.sndOut - endptr + 1) / 2);
+ PicoIn.sndOut = &sndBuffer[PicoIn.sndOut - endptr];
lprintf("mov\n");
}
else*/
- if (PsndOut > sndBuffer_endptr) lprintf("snd oflow %i!\n", PsndOut - sndBuffer_endptr);
- if (PsndOut >= sndBuffer_endptr)
- PsndOut = sndBuffer;
+ if (PicoIn.sndOut > sndBuffer_endptr) lprintf("snd oflow %i!\n", PicoIn.sndOut - sndBuffer_endptr);
+ if (PicoIn.sndOut >= sndBuffer_endptr)
+ PicoIn.sndOut = sndBuffer;
// signal the snd thread
samples_made += len / 2;
}
// prepare sound stuff
- PsndOut = NULL;
+ PicoIn.sndOut = NULL;
if (currentConfig.EmuOpt & EOPT_EN_SOUND)
{
pemu_sound_start();
if (PicoIn.AHW & PAHW_MCD) PicoCDBufferFree();
- if (PsndOut != NULL) {
+ if (PicoIn.sndOut != NULL) {
pemu_sound_stop();
- PsndOut = NULL;
+ PicoIn.sndOut = NULL;
}
// save SRAM
break;
case MA_OPT_SOUND_QUALITY:
str = (PicoIn.opt&0x08)?"stereo":"mono";
- text_out16(x, y, "Sound Quality: %5iHz %s", PsndRate, str);
+ text_out16(x, y, "Sound Quality: %5iHz %s", PicoIn.sndRate, str);
break;
case MA_OPT_REGION:
text_out16(x, y, "Region: %s", me_region_name(PicoIn.regionOverride, PicoIn.autoRgnOrder));
}
break;
case MA_OPT_SOUND_QUALITY:
- PsndRate = sndrate_prevnext(PsndRate, inp & PBTN_RIGHT);
+ PicoIn.sndRate = sndrate_prevnext(PicoIn.sndRate, inp & PBTN_RIGHT);
break;
case MA_OPT_REGION:
region_prevnext(inp & PBTN_RIGHT);
if (mp3_handle < 0 || mp3_src_pos >= mp3_src_size) return;
length_mp3 = length;
- if (PsndRate == 22050) length_mp3 <<= 1; // mp3s are locked to 44100Hz stereo
- else if (PsndRate == 11025) length_mp3 <<= 2; // so make length 44100ish
+ if (PicoIn.sndRate == 22050) length_mp3 <<= 1; // mp3s are locked to 44100Hz stereo
+ else if (PicoIn.sndRate == 11025) length_mp3 <<= 2; // so make length 44100ish
/* do we have to wait? */
if (mp3_job_started && mp3_samples_ready < length_mp3)
{
int shr = 0;
void (*mix_samples)(int *dest_buf, short *mp3_buf, int count) = mix_16h_to_32;
- if (PsndRate == 22050) { mix_samples = mix_16h_to_32_s1; shr = 1; }
- else if (PsndRate == 11025) { mix_samples = mix_16h_to_32_s2; shr = 2; }
+ if (PicoIn.sndRate == 22050) { mix_samples = mix_16h_to_32_s1; shr = 1; }
+ else if (PicoIn.sndRate == 11025) { mix_samples = mix_16h_to_32_s2; shr = 2; }
if (1152 - mp3_buffer_offs >= length_mp3) {
mix_samples(buffer, mp3_mix_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, length<<1);
{
int ret;
- PsndOut = NULL;
+ PicoIn.sndOut = NULL;
currentConfig.EmuOpt &= ~EOPT_EXT_FRMLIMIT;
// prepare sound stuff
{
PsndRerate(0);
- ret = DSoundInit(FrameWnd, PsndRate, (PicoIn.opt & POPT_EN_STEREO) ? 1 : 0, PsndLen);
+ ret = DSoundInit(FrameWnd, PicoIn.sndRate, (PicoIn.opt & POPT_EN_STEREO) ? 1 : 0, Pico.snd.len);
if (ret != 0) {
lprintf("dsound init failed\n");
return;
}
- PsndOut = (void *)sndbuff;
- PicoWriteSound = update_sound;
+ PicoIn.sndOut = (void *)sndbuff;
+ PicoIn.writeSound = update_sound;
currentConfig.EmuOpt |= EOPT_EXT_FRMLIMIT;
}
}
DUMP_EST(f, Pico);
DUMP_EST(f, PicoMem_vram);
DUMP_EST(f, PicoMem_cram);
- DUMP_EST(f, PicoIn.opt);
+ DUMP_EST(f, PicoOpt);
DUMP_EST(f, Draw2FB);
DUMP_EST(f, HighPal);
DUMP_PMEM(f, vram);