X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2Fsound%2Fym2612.c;h=754f496995a737dc71b5c97930adc053e490dbd6;hb=55ca4154a2e8aa3687c4f73f2c4c4d5fcdc5a836;hp=60d6c818c44396565d4fd2c9f43a29f195b2a2e1;hpb=4f265db77684ec33f9533e7c76734498df03bba4;p=picodrive.git diff --git a/Pico/sound/ym2612.c b/Pico/sound/ym2612.c index 60d6c81..754f496 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 @@ -841,7 +842,7 @@ typedef struct UINT32 eg_timer; UINT32 eg_timer_add; UINT32 pack; // 4c: stereo, lastchan, disabled, lfo_enabled | pan_r, pan_l, ams[2] | AMmasks[4] | FB[4] | lfo_ampm[16] - UINT32 algo; /* 50 */ + UINT32 algo; /* 50: algo[3], was_update */ INT32 op1_out; } chan_rend_context; @@ -1077,6 +1078,7 @@ static void chan_render_loop(chan_rend_context *ct, int *buffer, int length) } else { buffer[scounter] += smp; } + ct->algo = 8; // algo is only used in asm, here only bit3 is used } /* update phase counters AFTER output calculations */ @@ -1091,7 +1093,7 @@ void chan_render_loop(chan_rend_context *ct, int *buffer, unsigned short length) #endif -static void chan_render(int *buffer, int length, FM_CH *CH, UINT32 flags) // flags: stereo, lastchan, disabled, ?, pan_r, pan_l +static int chan_render(int *buffer, int length, FM_CH *CH, UINT32 flags) // flags: stereo, lastchan, disabled, ?, pan_r, pan_l { chan_rend_context ct; @@ -1193,6 +1195,8 @@ static void chan_render(int *buffer, int length, FM_CH *CH, UINT32 flags) // fla CH->SLOT[SLOT3].phase = ct.phase3; CH->SLOT[SLOT4].phase = ct.phase4; CH->mem_value = ct.mem; + + return (ct.algo & 8) >> 3; // had output } /* update phase increment and envelope generator */ @@ -1587,6 +1591,7 @@ INT32 *ym2612_dacout; int YM2612UpdateOne_(int *buffer, int length, int stereo, int is_buf_empty) { int pan; + int active_chs = 0; // if !is_buf_empty, it means it has valid samples to mix with, else it may contain trash if (is_buf_empty) memset32(buffer, 0, length<>2)); - chan_render(buffer, length, &ym2612.CH[4], stereo|((pan&0x300)>>4)); - chan_render(buffer, length, &ym2612.CH[5], stereo|((pan&0xc00)>>6)|(ym2612.dacen<<2)|2); - - return 1; // buffer updated + // flags: stereo, lastchan, disabled, ?, pan_r, pan_l + active_chs |= chan_render(buffer, length, &ym2612.CH[0], stereo|((pan&0x003)<<4)) << 0; + active_chs |= chan_render(buffer, length, &ym2612.CH[1], stereo|((pan&0x00c)<<2)) << 1; + active_chs |= chan_render(buffer, length, &ym2612.CH[2], stereo|((pan&0x030) )) << 2; + active_chs |= chan_render(buffer, length, &ym2612.CH[3], stereo|((pan&0x0c0)>>2)) << 3; + active_chs |= chan_render(buffer, length, &ym2612.CH[4], stereo|((pan&0x300)>>4)) << 4; + active_chs |= chan_render(buffer, length, &ym2612.CH[5], stereo|((pan&0xc00)>>6)|(ym2612.dacen<<2)|2) << 5; + + return active_chs; // 1 if buffer updated } @@ -1696,7 +1702,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 ) { @@ -1794,7 +1802,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; @@ -1863,7 +1873,10 @@ void YM2612PicoStateLoad_(void) } +#ifndef EXTERNAL_YM2612 void *YM2612GetRegs(void) { return ym2612.REGS; } +#endif +