YM2612 - prescaler/table init problem!
Posted: Tue Jun 21, 2011 1:16 am
hey all! i'm mocking up a ym2612 core using javascript (YES, javascript). i'm basically converting the genplus-gx ym2612 core from apr 30, but i'm stuck at a bit of implementation.
i'm trying to init the ym2612 w/a clock of 7670448 and a rate of 1.0 (i want the core to run at 1x speed, so i assume this would do it). having basically copied eke's work piece by piece, my YM2612Init sets OPN.ST.clock to the clock above and OPN.ST.rate to the rate above, then calls OPNSetPres(144) (6 fm channels * 24 fm clocks; i'll abstract these to variables later); BUT the problem i'm having lies in OPNSetPres, and at the same time init_timetables.
so OPNSetPres calculates freqbase as the following:
...which, given the above values (7670448, 1.0, 144) would result in 53267 (as i would normally expect). but THEN the original code had the following line:
the rest of OPNSetPres makes liberal use of freqbase for calculations, then passes it to init_timetables, which uses freqbase to generate the detune & fnum tables. then init_timetables uses freqbase in every single one of its calculations, also making liberal use of the FREQ_SH constant.
BUT WHAT IS freqbase SUPPOSED TO BE???
is it a ratio (which would validate the hi-quality toggle's usage) or is it supposed to be the absolute frequency (which would validate the 53267)? or maybe i passed the wrong value as rate? if i leave freqbase as 53267, things run entirely too slow and the timetables have insanely large values (and so do the EG timer, timer_add, and timer_overflow) as a result of the *freqbase*(1<<(FREQ_SH-10)) portion of calculation, but if i normalize it to a ratio of 53267 (making it 1.0), i'm not positive the timetables are generated correctly, but things run at an acceptable speed and generate no output.
i must be misunderstanding the table generation portion of the code or something; please help!
i'm trying to init the ym2612 w/a clock of 7670448 and a rate of 1.0 (i want the core to run at 1x speed, so i assume this would do it). having basically copied eke's work piece by piece, my YM2612Init sets OPN.ST.clock to the clock above and OPN.ST.rate to the rate above, then calls OPNSetPres(144) (6 fm channels * 24 fm clocks; i'll abstract these to variables later); BUT the problem i'm having lies in OPNSetPres, and at the same time init_timetables.
so OPNSetPres calculates freqbase as the following:
Code: Select all
double freqbase = ym2612.OPN.ST.clock/ym2612.OPN.ST.rate/pres;
Code: Select all
if (config.hq_fm) freqbase = 1.0;
BUT WHAT IS freqbase SUPPOSED TO BE???
is it a ratio (which would validate the hi-quality toggle's usage) or is it supposed to be the absolute frequency (which would validate the 53267)? or maybe i passed the wrong value as rate? if i leave freqbase as 53267, things run entirely too slow and the timetables have insanely large values (and so do the EG timer, timer_add, and timer_overflow) as a result of the *freqbase*(1<<(FREQ_SH-10)) portion of calculation, but if i normalize it to a ratio of 53267 (making it 1.0), i'm not positive the timetables are generated correctly, but things run at an acceptable speed and generate no output.
i must be misunderstanding the table generation portion of the code or something; please help!