X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2Fsound%2Fym2612.c;h=f626260133862921f74c92e164e3a1b2a613d2f4;hb=b5e5172d049a83251874fb33e65a53c9654dc0bc;hp=75d5ad325522db3377a7f269a1d107b8733e34f5;hpb=85f8e92973ca60968cfb844d2119b669ce610c2d;p=picodrive.git diff --git a/Pico/sound/ym2612.c b/Pico/sound/ym2612.c index 75d5ad3..f626260 100644 --- a/Pico/sound/ym2612.c +++ b/Pico/sound/ym2612.c @@ -112,7 +112,6 @@ #include #include "ym2612.h" -#include "mix.h" #ifndef EXTERNAL_YM2612 #include @@ -125,6 +124,8 @@ extern YM2612 *ym2612_940; #endif +void memset32(int *dest, int c, int count); + #ifndef __GNUC__ #pragma warning (disable:4100) // unreferenced formal parameter @@ -1636,8 +1637,7 @@ void YM2612Init_(int clock, int rate) ym2612_dacen = &ym2612.dacen; ym2612_dacout = &ym2612.dacout; - /* clear everything but the regs */ - memset(ym2612.CH, 0, sizeof(ym2612)-sizeof(ym2612.REGS)-4); + memset(&ym2612, 0, sizeof(ym2612)); init_tables(); ym2612.OPN.ST.clock = clock; @@ -1653,8 +1653,11 @@ void YM2612ResetChip_(void) { int i; + memset(ym2612.REGS, 0, sizeof(ym2612.REGS)); + OPNSetPres( 6*24 ); set_timers( 0x30 ); /* mode 0 , timer reset */ + ym2612.REGS[0x27] = 0x30; ym2612.OPN.eg_timer = 0; ym2612.OPN.eg_cnt = 0; @@ -1665,6 +1668,8 @@ void YM2612ResetChip_(void) { OPNWriteReg(i ,0xc0); OPNWriteReg(i|0x100,0xc0); + ym2612.REGS[i ] = 0xc0; + ym2612.REGS[i|0x100] = 0xc0; } for(i = 0xb2 ; i >= 0x30 ; i-- ) { @@ -1674,6 +1679,7 @@ void YM2612ResetChip_(void) for(i = 0x26 ; i >= 0x20 ; i-- ) OPNWriteReg(i,0); /* DAC mode clear */ ym2612.dacen = 0; + ym2612.addr_A1 = 0; } @@ -1701,7 +1707,9 @@ int YM2612Write_(unsigned int a, unsigned int v) } addr = ym2612.OPN.ST.address; +#ifndef EXTERNAL_YM2612 ym2612.REGS[addr] = v; +#endif switch( addr & 0xf0 ) { @@ -1799,7 +1807,9 @@ int YM2612Write_(unsigned int a, unsigned int v) } addr = ym2612.OPN.ST.address | 0x100; +#ifndef EXTERNAL_YM2612 ym2612.REGS[addr] = v; +#endif ret = OPNWriteReg(addr, v); break; @@ -1847,7 +1857,7 @@ int YM2612PicoTick_(int n) void YM2612PicoStateLoad_(void) { #ifndef EXTERNAL_YM2612 - int i, old_A1 = ym2612.addr_A1; + int i, real_A1 = ym2612.addr_A1; reset_channels( &ym2612.CH[0], 6 ); @@ -1856,19 +1866,23 @@ void YM2612PicoStateLoad_(void) YM2612Write_(0, i); YM2612Write_(1, ym2612.REGS[i]); } + for(i = 0; i < 0x100; i++) { YM2612Write_(2, i); YM2612Write_(3, ym2612.REGS[i|0x100]); } - ym2612.addr_A1 = old_A1; + ym2612.addr_A1 = real_A1; #else reset_channels( &ym2612.CH[0], 6 ); #endif } +#ifndef EXTERNAL_YM2612 void *YM2612GetRegs(void) { return ym2612.REGS; } +#endif +