// to be called after changing sound rate or chips\r
void sound_rerate(int preserve_state)\r
{\r
- unsigned int state[28];\r
+ void *state = NULL;\r
int target_fps = Pico.m.pal ? 50 : 60;\r
\r
// not all rates are supported in MCD mode due to mp3 decoder limitations\r
}\r
\r
if (preserve_state) {\r
+ state = malloc(0x200);\r
+ if (state == NULL) return;\r
+ memcpy(state, YM2612GetRegs(), 0x200);\r
if ((PicoMCD & 1) && Pico_mcd->m.audio_track)\r
Pico_mcd->m.audio_offset = mp3_get_offset();\r
}\r
YM2612Init(Pico.m.pal ? OSC_PAL/7 : OSC_NTSC/7, PsndRate);\r
if (preserve_state) {\r
// feed it back it's own registers, just like after loading state\r
+ memcpy(YM2612GetRegs(), state, 0x200);\r
YM2612PicoStateLoad();\r
if ((PicoMCD & 1) && Pico_mcd->m.audio_track)\r
mp3_start_play(Pico_mcd->TOC.Tracks[Pico_mcd->m.audio_track].F, Pico_mcd->m.audio_offset);\r
SN76496_init(Pico.m.pal ? OSC_PAL/15 : OSC_NTSC/15, PsndRate);\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
ym2612_dacen = &ym2612.dacen;\r
ym2612_dacout = &ym2612.dacout;\r
\r
- /* clear everything but the regs */\r
- memset(ym2612.CH, 0, sizeof(ym2612)-sizeof(ym2612.REGS)-4);\r
+ memset(&ym2612, 0, sizeof(ym2612));\r
init_tables();\r
\r
ym2612.OPN.ST.clock = clock;\r
{\r
int i;\r
\r
+ memset(ym2612.REGS, 0, sizeof(ym2612.REGS));\r
+\r
OPNSetPres( 6*24 );\r
set_timers( 0x30 ); /* mode 0 , timer reset */\r
+ ym2612.REGS[0x27] = 0x30;\r
\r
ym2612.OPN.eg_timer = 0;\r
ym2612.OPN.eg_cnt = 0;\r
{\r
OPNWriteReg(i ,0xc0);\r
OPNWriteReg(i|0x100,0xc0);\r
+ ym2612.REGS[i ] = 0xc0;\r
+ ym2612.REGS[i|0x100] = 0xc0;\r
}\r
for(i = 0xb2 ; i >= 0x30 ; i-- )\r
{\r
for(i = 0x26 ; i >= 0x20 ; i-- ) OPNWriteReg(i,0);\r
/* DAC mode clear */\r
ym2612.dacen = 0;\r
+ ym2612.addr_A1 = 0;\r
}\r
\r
\r
void YM2612PicoStateLoad_(void)\r
{\r
#ifndef EXTERNAL_YM2612\r
- int i, old_A1 = ym2612.addr_A1;\r
+ int i, real_A1 = ym2612.addr_A1;\r
\r
reset_channels( &ym2612.CH[0], 6 );\r
\r
YM2612Write_(0, i);\r
YM2612Write_(1, ym2612.REGS[i]);\r
}\r
+\r
for(i = 0; i < 0x100; i++) {\r
YM2612Write_(2, i);\r
YM2612Write_(3, ym2612.REGS[i|0x100]);\r
}\r
\r
- ym2612.addr_A1 = old_A1;\r
+ ym2612.addr_A1 = real_A1;\r
#else\r
reset_channels( &ym2612.CH[0], 6 );\r
#endif\r
#include "../common/arm_utils.h"\r
#include "../common/menu.h"\r
#include "../../Pico/PicoInt.h"\r
+#include "../../Pico/sound/ym2612.h"\r
#include "../../Pico/sound/mix.h"\r
\r
/* we will need some gp2x internals here */\r
/* these will be managed locally on our side */\r
extern int *ym2612_dacen;\r
extern INT32 *ym2612_dacout;\r
-extern void *ym2612_regs;\r
-\r
static UINT8 *REGS = 0; /* we will also keep local copy of regs for savestates and such */\r
-static INT32 addr_A1; /* address line A1 */\r
-static int dacen;\r
+static INT32 *addr_A1; /* address line A1 */\r
+\r
+static int dacen;\r
static INT32 dacout;\r
static UINT8 ST_address; /* address register */\r
static UINT8 ST_status; /* status flag */\r
\r
switch( a ) {\r
case 0: /* address port 0 */\r
- if (!addr_A1 && ST_address == v)\r
+ if (!*addr_A1 && ST_address == v)\r
return 0; /* address already selected, don't send this command to 940 */\r
ST_address = v;\r
/* don't send DAC or timer related address changes to 940 */\r
- if (!addr_A1 && (v & 0xf0) == 0x20 &&\r
+ if (!*addr_A1 && (v & 0xf0) == 0x20 &&\r
(v == 0x24 || v == 0x25 || v == 0x26 || v == 0x2a))\r
return 0;\r
- addr_A1 = 0;\r
+ *addr_A1 = 0;\r
upd = 0;\r
break;\r
\r
case 1: /* data port 0 */\r
- if (addr_A1 != 0) {\r
+ if (*addr_A1 != 0) {\r
return 0; /* verified on real YM2608 */\r
}\r
\r
break;\r
\r
case 2: /* address port 1 */\r
- if (addr_A1 && ST_address == v)\r
+ if (*addr_A1 && ST_address == v)\r
return 0;\r
ST_address = v;\r
- addr_A1 = 1;\r
+ *addr_A1 = 1;\r
upd = 0;\r
break;\r
\r
case 3: /* data port 1 */\r
- if (addr_A1 != 1) {\r
+ if (*addr_A1 != 1) {\r
return 0; /* verified on real YM2608 */\r
}\r
\r
\r
void YM2612PicoStateLoad_940(void)\r
{\r
- int i, old_A1 = addr_A1;\r
+ int i, old_A1 = *addr_A1;\r
\r
/* make sure JOB940_PICOSTATELOAD gets done before next JOB940_YM2612UPDATEONE */\r
add_job_940(JOB940_PICOSTATELOAD);\r
YM2612Write_940(3, REGS[i|0x100]);\r
}\r
\r
- addr_A1 = old_A1;\r
+ *addr_A1 = old_A1;\r
}\r
\r
\r
ST_TAC = 0;\r
ST_TB = 0;\r
ST_TBC = 0;\r
- dacen = 0;\r
+ dacen = 0;\r
+ dacout = 0;\r
+ ST_address= 0;\r
}\r
\r
\r
memset(shared_data, 0, sizeof(*shared_data));\r
memset(shared_ctl, 0, sizeof(*shared_ctl));\r
\r
+ /* cause local ym2612 to init REGS */\r
+ YM2612Init_(baseclock, rate);\r
+\r
REGS = YM2612GetRegs();\r
+ addr_A1 = (INT32 *) (REGS + 0x200);\r
\r
ym2612_dacen = &dacen;\r
ym2612_dacout = &dacout;\r
* Fixed hang of NBA Jam (ingame saves do not work though).\r
* Adjusted timing for "accurate timing" mode and added preliminary VDP FIFO\r
emulation. Fixes Double Dragon 2, tearing in Chaos Engine and some other games.\r
+ * Fixed a few games not having sound at startup.\r
\r
1.33\r
* Updated Cyclone core to 0.0088.\r