[Atsoft-commit] CVS: dcgen/ym2612 fm.c,1.2,1.3 fm.h,1.1.1.1,1.2
Brought to you by:
atani
|
From: Mike D. <at...@us...> - 2002-04-10 04:53:13
|
Update of /cvsroot/atsoft/dcgen/ym2612
In directory usw-pr-cvs1:/tmp/cvs-serv25081/ym2612
Modified Files:
fm.c fm.h
Log Message:
Various speed hacks, fixes to the options screen and auto-frameskip code.
new feature: auto-frameskip.
Index: fm.c
===================================================================
RCS file: /cvsroot/atsoft/dcgen/ym2612/fm.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** fm.c 8 Apr 2002 01:15:33 -0000 1.2
--- fm.c 10 Apr 2002 04:53:08 -0000 1.3
***************
*** 1,16 ****
#include <kos.h>
- /*
- double pow(double x, double y) {
- double res = y;
- int pow_counter;
- for(pow_counter = 0;pow_counter<x;pow_counter++) res *= y;
- return res;
- }
-
- double log(double base)
- {
- return base;
- }
- */
#define YM2610B_WARNING
--- 1,3 ----
***************
*** 341,348 ****
int clock; /* master clock (Hz) */
int rate; /* sampling rate (Hz) */
! double freqbase; /* frequency base */
! double TimerBase; /* Timer base time */
#if FM_BUSY_FLAG_SUPPORT
! double BusyExpire; /* ExpireTime of Busy clear */
#endif
UINT8 address; /* address register */
--- 328,335 ----
int clock; /* master clock (Hz) */
int rate; /* sampling rate (Hz) */
! float freqbase; /* frequency base */
! float TimerBase; /* Timer base time */
#if FM_BUSY_FLAG_SUPPORT
! float BusyExpire; /* ExpireTime of Busy clear */
#endif
UINT8 address; /* address register */
***************
*** 954,958 ****
{
int i,d;
! double rate;
#if 0
--- 941,945 ----
{
int i,d;
! float rate;
#if 0
***************
*** 964,968 ****
for (d = 0;d <= 3;d++){
for (i = 0;i <= 31;i++){
! rate = ((double)DTTABLE[d*32 + i]) * SIN_LEN * ST->freqbase * (1<<FREQ_SH) / ((double)(1<<20));
ST->DT_TABLE[d][i] = (INT32) rate;
ST->DT_TABLE[d+4][i] = (INT32)-rate;
--- 951,955 ----
for (d = 0;d <= 3;d++){
for (i = 0;i <= 31;i++){
! rate = ((float)DTTABLE[d*32 + i]) * SIN_LEN * ST->freqbase * (1<<FREQ_SH) / ((float)(1<<20));
ST->DT_TABLE[d][i] = (INT32) rate;
ST->DT_TABLE[d+4][i] = (INT32)-rate;
***************
*** 983,992 ****
rate *= 1<< (i>>2); /* b2-5 : shift bit */
rate /= 12.0 * 1024.0;
! rate *= (double)(1<<ENV_SH);
ST->eg_tab[32+i] = rate;
#if 0
logerror("FM.C: Rate %2i %1i Decay [real %11.4f ms][emul %11.4f ms][d=%08x]\n",i>>2, i&3,
! ( ((double)(ENV_LEN<<ENV_SH)) / rate ) * (1000.0 / (double)ST->rate),
! ( ((double)(ENV_LEN<<ENV_SH)) / (double)ST->eg_tab[32+i] ) * (1000.0 / (double)ST->rate), ST->eg_tab[32+i] );
#endif
}
--- 970,979 ----
rate *= 1<< (i>>2); /* b2-5 : shift bit */
rate /= 12.0 * 1024.0;
! rate *= (float)(1<<ENV_SH);
ST->eg_tab[32+i] = rate;
#if 0
logerror("FM.C: Rate %2i %1i Decay [real %11.4f ms][emul %11.4f ms][d=%08x]\n",i>>2, i&3,
! ( ((float)(ENV_LEN<<ENV_SH)) / rate ) * (1000.0 / (float)ST->rate),
! ( ((float)(ENV_LEN<<ENV_SH)) / (float)ST->eg_tab[32+i] ) * (1000.0 / (float)ST->rate), ST->eg_tab[32+i] );
#endif
}
***************
*** 1028,1032 ****
signed int i,x;
signed int n;
! double o,m;
for (x=0; x<TL_RES_LEN; x++)
--- 1015,1019 ----
signed int i,x;
signed int n;
! float o,m;
for (x=0; x<TL_RES_LEN; x++)
***************
*** 1281,1292 ****
/* frequency base */
#if 1
! OPN->ST.freqbase = (OPN->ST.rate) ? ((double)OPN->ST.clock / OPN->ST.rate) / pres : 0;
#else
! OPN->ST.rate = (double)OPN->ST.clock / pres;
OPN->ST.freqbase = 1.0;
#endif
/* Timer base time */
! OPN->ST.TimerBase = 1.0/((double)OPN->ST.clock / (double)TimerPres);
/* SSG part prescaler set */
if( SSGpres ) SSGClk( OPN->ST.index, OPN->ST.clock * 2 / SSGpres );
--- 1268,1279 ----
/* frequency base */
#if 1
! OPN->ST.freqbase = (OPN->ST.rate) ? ((float)OPN->ST.clock / OPN->ST.rate) / pres : 0;
#else
! OPN->ST.rate = (float)OPN->ST.clock / pres;
OPN->ST.freqbase = 1.0;
#endif
/* Timer base time */
! OPN->ST.TimerBase = 1.0/((float)OPN->ST.clock / (float)TimerPres);
/* SSG part prescaler set */
if( SSGpres ) SSGClk( OPN->ST.index, OPN->ST.clock * 2 / SSGpres );
***************
*** 1298,1302 ****
/* freq table for octave 7 */
/* opn phase increment counter = 20bit */
! OPN->FN_TABLE[i] = (UINT32)( (double)i * 64 * OPN->ST.freqbase * (1<<(FREQ_SH-10)) ); /* -10 because chip works with 10.10 fixed point, while we use 16.16 */
#if 0
logerror("FM.C: FN_TABLE[%4i] = %08x (dec=%8i)\n",
--- 1285,1289 ----
/* freq table for octave 7 */
/* opn phase increment counter = 20bit */
! OPN->FN_TABLE[i] = (UINT32)( (float)i * 64 * OPN->ST.freqbase * (1<<(FREQ_SH-10)) ); /* -10 because chip works with 10.10 fixed point, while we use 16.16 */
#if 0
logerror("FM.C: FN_TABLE[%4i] = %08x (dec=%8i)\n",
***************
*** 1308,1313 ****
{
/* 3.98Hz,5.56Hz,6.02Hz,6.37Hz,6.88Hz,9.63Hz,48.1Hz,72.2Hz @ 8MHz */
! #define FM_LF(Hz) ((double)LFO_ENT*(1<<LFO_SH)*(Hz)/(8000000.0/144))
! static const double freq_table[8] = { FM_LF(3.98),FM_LF(5.56),FM_LF(6.02),FM_LF(6.37),FM_LF(6.88),FM_LF(9.63),FM_LF(48.1),FM_LF(72.2) };
#undef FM_LF
for(i=0;i<8;i++)
--- 1295,1300 ----
{
/* 3.98Hz,5.56Hz,6.02Hz,6.37Hz,6.88Hz,9.63Hz,48.1Hz,72.2Hz @ 8MHz */
! #define FM_LF(Hz) ((float)LFO_ENT*(1<<LFO_SH)*(Hz)/(8000000.0/144))
! static const float freq_table[8] = { FM_LF(3.98),FM_LF(5.56),FM_LF(6.02),FM_LF(6.37),FM_LF(6.88),FM_LF(9.63),FM_LF(48.1),FM_LF(72.2) };
#undef FM_LF
for(i=0;i<8;i++)
***************
*** 1457,1461 ****
/* b0-2 PMS */
/* 0,3.4,6.7,10,14,20,40,80(cent) */
! static const double pmd_table[8]={0,3.4,6.7,10,14,20,40,80};
/* b4-5 AMS */
--- 1444,1448 ----
/* b0-2 PMS */
/* 0,3.4,6.7,10,14,20,40,80(cent) */
! static const float pmd_table[8]={0,3.4,6.7,10,14,20,40,80};
/* b4-5 AMS */
***************
*** 3626,3634 ****
YM2151 *OPM = &(FMOPM[num]);
int i;
! double pom;
! double rate;
if (FMOPM[num].ST.rate)
! rate = (double)(1<<FREQ_BITS) / (3579545.0 / FMOPM[num].ST.clock * FMOPM[num].ST.rate);
else rate = 1;
--- 3613,3621 ----
YM2151 *OPM = &(FMOPM[num]);
int i;
! float pom;
! float rate;
if (FMOPM[num].ST.rate)
! rate = (float)(1<<FREQ_BITS) / (3579545.0 / FMOPM[num].ST.clock * FMOPM[num].ST.rate);
else rate = 1;
***************
*** 3710,3720 ****
/* f = fm * 2^(LFRQ/16) / (4295*10^6) */
{
! static double drate[16]={
1.0 ,1.044273782,1.090507733,1.138788635, /*0-3*/
1.189207115,1.241857812,1.296839555,1.354255547, /*4-7*/
1.414213562,1.476826146,1.542210825,1.610490332, /*8-11*/
1.681792831,1.75625216 ,1.834008086,1.915206561};
! double rate = pow(2.0,v/16)*drate[v&0x0f] / 4295000000.0;
! OPM->LFOIncr = (UINT32)((double)LFO_ENT*(1<<LFO_SH) * (OPM->ST.freqbase*64) * rate);
cur_chip = NULL;
}
--- 3697,3707 ----
/* f = fm * 2^(LFRQ/16) / (4295*10^6) */
{
! static float drate[16]={
1.0 ,1.044273782,1.090507733,1.138788635, /*0-3*/
1.189207115,1.241857812,1.296839555,1.354255547, /*4-7*/
1.414213562,1.476826146,1.542210825,1.610490332, /*8-11*/
1.681792831,1.75625216 ,1.834008086,1.915206561};
! float rate = pow(2.0,v/16)*drate[v&0x0f] / 4295000000.0;
! OPM->LFOIncr = (UINT32)((float)LFO_ENT*(1<<LFO_SH) * (OPM->ST.freqbase*64) * rate);
cur_chip = NULL;
}
***************
*** 3888,3893 ****
/* FMOPM[i].ST.status = 0; */
FMOPM[i].ST.timermodel = FM_TIMER_INTERVAL;
! FMOPM[i].ST.freqbase = rate ? ((double)clock / rate) / 64 : 0;
! FMOPM[i].ST.TimerBase = 1.0/((double)clock / 64.0);
/* Extend handler */
FMOPM[i].ST.Timer_Handler = TimerHandler;
--- 3875,3880 ----
/* FMOPM[i].ST.status = 0; */
FMOPM[i].ST.timermodel = FM_TIMER_INTERVAL;
! FMOPM[i].ST.freqbase = rate ? ((float)clock / rate) / 64 : 0;
! FMOPM[i].ST.TimerBase = 1.0/((float)clock / 64.0);
/* Extend handler */
FMOPM[i].ST.Timer_Handler = TimerHandler;
Index: fm.h
===================================================================
RCS file: /cvsroot/atsoft/dcgen/ym2612/fm.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** fm.h 18 Jan 2002 02:42:54 -0000 1.1.1.1
--- fm.h 10 Apr 2002 04:53:08 -0000 1.2
***************
*** 131,135 ****
#endif
! typedef void (*FM_TIMERHANDLER)(int n,int c,int cnt,double stepTime);
typedef void (*FM_IRQHANDLER)(int n,int irq);
/* FM_TIMERHANDLER : Stop or Start timer */
--- 131,135 ----
#endif
! typedef void (*FM_TIMERHANDLER)(int n,int c,int cnt,float stepTime);
typedef void (*FM_IRQHANDLER)(int n,int irq);
/* FM_TIMERHANDLER : Stop or Start timer */
|