diff options
author | Takamichi Horikawa <takamichiho@gmail.com> | 2017-02-12 11:03:42 +0900 |
---|---|---|
committer | Takamichi Horikawa <takamichiho@gmail.com> | 2017-02-12 11:03:42 +0900 |
commit | 93dde8cf16973e07e687e7e0740cf02c38786c38 (patch) | |
tree | f303dca889d30e77578ad88f52a9cadf92f542cc /fmdriver | |
parent | b1065289a6ca6d07d13fbbad2021b3ea5186393d (diff) |
u8s16 to u8s8
Diffstat (limited to 'fmdriver')
-rw-r--r-- | fmdriver/fmdriver.h | 8 | ||||
-rw-r--r-- | fmdriver/fmdriver_common.h | 4 | ||||
-rw-r--r-- | fmdriver/fmdriver_fmp.c | 40 |
3 files changed, 41 insertions, 11 deletions
diff --git a/fmdriver/fmdriver.h b/fmdriver/fmdriver.h index 63d27c0..e858567 100644 --- a/fmdriver/fmdriver.h +++ b/fmdriver/fmdriver.h @@ -34,6 +34,11 @@ struct fmdriver_track_status { uint8_t key; // key after pitchbend, LFO, etc. applied uint8_t actual_key; + uint8_t tonenum; + uint8_t volume; + uint8_t gate; + int8_t detune; + char status[9]; }; struct fmdriver_work { @@ -56,7 +61,8 @@ struct fmdriver_work { // CP932 encoded //const char *title; char comment[3][FMDRIVER_TITLE_BUFLEN]; - // driver status + // driver status (for display) + uint8_t ssg_noise_freq; struct fmdriver_track_status track_status[FMDRIVER_TRACK_NUM]; // fm3ex part map }; diff --git a/fmdriver/fmdriver_common.h b/fmdriver/fmdriver_common.h index 23600cb..706dc95 100644 --- a/fmdriver/fmdriver_common.h +++ b/fmdriver/fmdriver_common.h @@ -5,12 +5,12 @@ static inline uint16_t read16le(const uint8_t *ptr) { return (unsigned)ptr[0] | (((unsigned)ptr[1])<<8); } -static inline int16_t u8s16(uint8_t v) { +static inline int8_t u8s8(uint8_t v) { return (v & 0x80) ? ((int16_t)v)-0x100 : v; } static inline int16_t u16s16(uint16_t v) { - return (v & 0x8000) ? ((int32_t)v)-0x10000 : v; + return (v & 0x8000u) ? ((int32_t)v)-0x10000l : v; } #if 0 diff --git a/fmdriver/fmdriver_fmp.c b/fmdriver/fmdriver_fmp.c index 33ab925..8f3c948 100644 --- a/fmdriver/fmdriver_fmp.c +++ b/fmdriver/fmdriver_fmp.c @@ -252,7 +252,7 @@ static uint16_t fmp_adpcm_freq(uint8_t note) { }
static uint8_t fmp_pdzf_vol_clamp(uint8_t v, uint8_t ev) {
- int16_t ret = v + u8s16(ev);
+ int16_t ret = v + u8s8(ev);
if (ret < 0) ret = 0;
if (ret > 0xf) ret = 0xf;
return ret;
@@ -993,10 +993,10 @@ static bool fmp_cmd75_lfo(struct fmdriver_work *work, // 22f1
fmp->timer_ch3 |= 0x40;
if (val & 0x20) {
- fmp->ch3_se_freqdiff[0] = u8s16(fmp_part_cmdload(fmp, part));
- fmp->ch3_se_freqdiff[1] = u8s16(fmp_part_cmdload(fmp, part));
- fmp->ch3_se_freqdiff[2] = u8s16(fmp_part_cmdload(fmp, part));
- fmp->ch3_se_freqdiff[3] = u8s16(fmp_part_cmdload(fmp, part));
+ fmp->ch3_se_freqdiff[0] = u8s8(fmp_part_cmdload(fmp, part));
+ fmp->ch3_se_freqdiff[1] = u8s8(fmp_part_cmdload(fmp, part));
+ fmp->ch3_se_freqdiff[2] = u8s8(fmp_part_cmdload(fmp, part));
+ fmp->ch3_se_freqdiff[3] = u8s8(fmp_part_cmdload(fmp, part));
}
} else {
// 22e9
@@ -1094,7 +1094,7 @@ static bool fmp_cmd78_lfo_r(struct fmdriver_work *work, part->pdzf.pan = upan - 5;
}
} else {
- int8_t pan = u8s16(lfo->rate);
+ int8_t pan = u8s8(lfo->rate);
if (pan < -4) pan = -4;
if (pan > 4) pan = 4;
part->pdzf.pan = pan;
@@ -1306,7 +1306,7 @@ static bool fmp_cmd7c_lfo_pan_fm(struct fmdriver_work *work, struct pdzf_rhythm *pr = &fmp->pdzf.rhythm[pdzf_i-1];
pr->voice[0] = part->u.fm.wlfo.delay;
pr->voice[1] = part->u.fm.wlfo.speed;
- int16_t panpot = u8s16(part->u.fm.wlfo.rate);
+ int16_t panpot = u8s8(part->u.fm.wlfo.rate);
if (panpot < -4) panpot = -4;
if (panpot > 4) panpot = 4;
pr->pan = panpot;
@@ -1419,7 +1419,7 @@ static bool fmp_cmd7e_loop_det(struct fmdriver_work *work, } else {
// detune relative
// DX
- int16_t det = u8s16(fmp_part_cmdload(fmp, part));
+ int16_t det = u8s8(fmp_part_cmdload(fmp, part));
part->detune += det;
}
return true;
@@ -1826,6 +1826,10 @@ static void fmp_part_init_lfo_awe(struct fmdriver_work *work, // 3073
part->u.fm.alfo.delay_cnt = part->u.fm.alfo.delay;
part->u.fm.alfo.depth_cnt = part->u.fm.alfo.depth;
+ // this line not found in fmp but should be there somewhere
+ // without this, when LFO E, delay would be random every keyon
+ part->u.fm.alfo.speed_cnt = part->u.fm.alfo.speed;
+
part->u.fm.alfo.rate = part->u.fm.alfo.rate_orig;
if (part->u.fm.hlfo_freq & 0x80) {
work->opna_writereg(work, 0x22, 0x00);
@@ -2760,6 +2764,7 @@ static void fmp_work_status_init(struct fmdriver_work *work, static void fmp_work_status_update(struct fmdriver_work *work,
const struct driver_fmp *fmp) {
+ work->ssg_noise_freq = fmp->ssg_noise_freq;
static const uint8_t fmp_track_map[FMDRIVER_TRACK_NUM] = {
FMP_PART_FM_1,
FMP_PART_FM_2,
@@ -2781,13 +2786,21 @@ static void fmp_work_status_update(struct fmdriver_work *work, track->info = FMDRIVER_TRACK_INFO_NORMAL;
if (part->type.adpcm) {
track->actual_key = 0xff;
+ track->volume = part->actual_vol;
} else if (part->type.ssg) {
if (part->u.ssg.env_f.ppz || part->pdzf.mode) {
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->volume = part->current_vol - 1;
} else {
if (part->pdzf.mode) {
track->info = FMDRIVER_TRACK_INFO_PPZ8;
@@ -2795,6 +2808,7 @@ static void fmp_work_status_update(struct fmdriver_work *work, } else {
track->actual_key = part->status.rest ? 0xff : fmp_fm_freq2key(part->prev_freq);
}
+ track->volume = 0x7f - part->actual_vol;
}
if (part->type.fm && part->opna_keyon_out > 3) {
track->num--;
@@ -2802,6 +2816,16 @@ static void fmp_work_status_update(struct fmdriver_work *work, track->ticks = part->status.off ? 0 : part->tonelen-1;
track->ticks_left = part->tonelen_cnt;
track->key = part->status.rest ? 0xff : fmp_note2key(part->prev_note);
+ track->tonenum = part->tone;
+ track->detune = part->detune - ((part->detune & 0x8000) ? 0x10000 : 0);
+ track->status[0] = part->lfo_f.p ? 'P' : '-';
+ track->status[1] = part->lfo_f.q ? 'Q' : '-';
+ track->status[2] = part->lfo_f.r ? 'R' : '-';
+ track->status[3] = part->lfo_f.a ? 'A' : '-';
+ track->status[4] = '-';
+ track->status[5] = part->lfo_f.e ? 'e' : '-';
+ track->status[6] = (part->type.fm && part->u.fm.hlfo_apms) ? 'H' : '-';
+ track->status[7] = part->status.pitchbend ? 'P' : '-';
}
}
|