From 46e2455027537dc1ef56b98b712cf92edf27dca5 Mon Sep 17 00:00:00 2001 From: Takamichi Horikawa Date: Tue, 14 Mar 2017 19:10:24 +0900 Subject: add initial PMD support --- fmdriver/fmdriver_fmp.c | 83 +++---------------------------------------------- 1 file changed, 5 insertions(+), 78 deletions(-) (limited to 'fmdriver/fmdriver_fmp.c') diff --git a/fmdriver/fmdriver_fmp.c b/fmdriver/fmdriver_fmp.c index 5643f24..90a157c 100644 --- a/fmdriver/fmdriver_fmp.c +++ b/fmdriver/fmdriver_fmp.c @@ -73,41 +73,6 @@ static uint16_t fmp_fm_freq(uint8_t note) { return freqtab[note%0xc] + ((note/0xc)<<(3+8)); } -static uint8_t fmp_fm_freq2key(uint16_t freq) { - int block = freq >> (8+3); - int f_num = freq & ((1<<(8+3))-1); - if (!f_num) return 0x00; - while (!(f_num & (1<<(8+3-1)))) { - f_num <<= 1; - block--; - } - static const uint16_t freqtab[0xc] = { - 0x042e, // < 9 (a) - 0x046e, - 0x04b1, - 0x04f9, - 0x0544, - 0x0595, - 0x05ea, - 0x0644, - 0x06a3, - 0x0708, - 0x0773, - 0x07e4, - }; - int note = 0; - for (; note < 12; note++) { - if (f_num < freqtab[note]) break; - } - note += 9; - block += (note/12); - note %= 12; - - if (block < 0) return 0x00; - if (block > 8) return 0x8b; - return (block << 4) | note; -} - static uint8_t fmp_ssg_octave(uint8_t note) { return note/0xc; } @@ -151,41 +116,6 @@ static uint16_t fmp_part_ssg_freq(struct fmp_part *part, uint8_t note) { return part->detune + freq; } -static uint8_t fmp_ssg_freq2key(uint16_t freq) { - if (!freq) return 0x00; - int octave = -5; - while (!(freq & 0x8000)) { - freq <<= 1; - octave++; - } - // 7987200.0 / (64*440*(2**((i+2+0.5)/12))/(1<<8)) - static const uint16_t freqtab[0xc] = { - 0xf57f, // > 0 (c) - 0xe7b8, - 0xdab7, - 0xce70, - 0xc2da, - 0xb7ea, - 0xad98, - 0xa3da, - 0x9aa7, - 0x91f9, - 0x89c8, - 0x820c, - }; - int note = 0; - for (; note < 12; note++) { - if (freq > freqtab[note]) break; - } - note += 11; - octave += (note/12); - note %= 12; - - if (octave < 0) return 0x00; - if (octave > 8) return 0x8b; - return (octave << 4) | note; -} - // 3172 static uint16_t fmp_adpcm_freq(uint8_t note) { static const uint16_t freqtab[4][0xc] = { @@ -2851,13 +2781,10 @@ static void fmp_work_status_update(struct fmdriver_work *work, track->info = FMDRIVER_TRACK_INFO_PPZ8; track->actual_key = 0xff; } else { - track->actual_key = part->status.rest ? 0xff : fmp_ssg_freq2key(part->prev_freq); - bool tone = !((fmp->ssg_mix >> part->opna_keyon_out) & 1); - bool noise = !((fmp->ssg_mix >> part->opna_keyon_out) & 8); - if (noise) { - if (tone) track->info = FMDRIVER_TRACK_INFO_SSG_NOISE_MIX; - else track->info = FMDRIVER_TRACK_INFO_SSG_NOISE_ONLY; - } + track->info = FMDRIVER_TRACK_INFO_SSG; + track->actual_key = part->status.rest ? 0xff : fmdriver_ssg_freq2key(part->prev_freq); + track->ssg_tone = !((fmp->ssg_mix >> part->opna_keyon_out) & 1); + track->ssg_noise = !((fmp->ssg_mix >> part->opna_keyon_out) & 8); } track->volume = part->current_vol - 1; } else { @@ -2871,7 +2798,7 @@ static void fmp_work_status_update(struct fmdriver_work *work, track->fmslotmask[s] = part->u.fm.slot_mask & (1<<(4+s)); } } - track->actual_key = part->status.rest ? 0xff : fmp_fm_freq2key(part->prev_freq); + track->actual_key = part->status.rest ? 0xff : fmdriver_fm_freq2key(part->prev_freq); } track->volume = 0x7f - part->actual_vol; } -- cgit v1.2.3