aboutsummaryrefslogtreecommitdiff
path: root/fmdriver
diff options
context:
space:
mode:
Diffstat (limited to 'fmdriver')
-rw-r--r--fmdriver/fmdriver.h9
-rw-r--r--fmdriver/fmdriver_fmp.c48
-rw-r--r--fmdriver/ppz8.c1
3 files changed, 50 insertions, 8 deletions
diff --git a/fmdriver/fmdriver.h b/fmdriver/fmdriver.h
index b9946da..63d27c0 100644
--- a/fmdriver/fmdriver.h
+++ b/fmdriver/fmdriver.h
@@ -15,12 +15,19 @@ enum fmdriver_track_type {
FMDRIVER_TRACK_FM,
FMDRIVER_TRACK_SSG,
FMDRIVER_TRACK_ADPCM,
- FMDRIVER_TRACK_PPZ8
+};
+
+enum fmdriver_track_info {
+ FMDRIVER_TRACK_INFO_NORMAL,
+ FMDRIVER_TRACK_INFO_SSG_NOISE_ONLY,
+ FMDRIVER_TRACK_INFO_SSG_NOISE_MIX,
+ FMDRIVER_TRACK_INFO_PPZ8
};
struct fmdriver_track_status {
bool playing;
enum fmdriver_track_type type;
+ enum fmdriver_track_info info;
uint8_t num;
uint8_t ticks;
uint8_t ticks_left;
diff --git a/fmdriver/fmdriver_fmp.c b/fmdriver/fmdriver_fmp.c
index 9195276..43fb69d 100644
--- a/fmdriver/fmdriver_fmp.c
+++ b/fmdriver/fmdriver_fmp.c
@@ -2719,8 +2719,9 @@ static uint8_t fmp_note2key(uint8_t note) {
return key;
}
-static void fmp_work_status_update(struct fmdriver_work *work,
- struct driver_fmp *fmp) {
+static void fmp_work_status_init(struct fmdriver_work *work,
+ const struct driver_fmp *fmp) {
+
static const uint8_t fmp_track_map[FMDRIVER_TRACK_NUM] = {
FMP_PART_FM_1,
FMP_PART_FM_2,
@@ -2736,26 +2737,58 @@ static void fmp_work_status_update(struct fmdriver_work *work,
for (int t = 0; t < FMDRIVER_TRACK_NUM; t++) {
struct fmdriver_track_status *track = &work->track_status[t];
- struct fmp_part *part = &fmp->parts[fmp_track_map[t]];
+ const struct fmp_part *part = &fmp->parts[fmp_track_map[t]];
track->playing = !part->status.off;
track->num = (part->pdzf.mode ? part->pdzf.ppz8_channel : part->opna_keyon_out)+1;
+ track->info = FMDRIVER_TRACK_INFO_NORMAL;
if (part->type.adpcm) {
track->type = FMDRIVER_TRACK_ADPCM;
+ } else if (part->type.ssg) {
+ track->type = FMDRIVER_TRACK_SSG;
+ } else {
+ track->type = FMDRIVER_TRACK_FM;
+ }
+ if (part->type.fm && part->opna_keyon_out > 3) {
+ track->num--;
+ }
+ }
+}
+
+static void fmp_work_status_update(struct fmdriver_work *work,
+ const struct driver_fmp *fmp) {
+ static const uint8_t fmp_track_map[FMDRIVER_TRACK_NUM] = {
+ FMP_PART_FM_1,
+ FMP_PART_FM_2,
+ FMP_PART_FM_3,
+ FMP_PART_FM_4,
+ FMP_PART_FM_5,
+ FMP_PART_FM_6,
+ FMP_PART_SSG_1,
+ FMP_PART_SSG_2,
+ FMP_PART_SSG_3,
+ FMP_PART_ADPCM,
+ };
+
+ for (int t = 0; t < FMDRIVER_TRACK_NUM; t++) {
+ struct fmdriver_track_status *track = &work->track_status[t];
+ const struct fmp_part *part = &fmp->parts[fmp_track_map[t]];
+ track->playing = !part->status.off;
+ track->num = (part->pdzf.mode ? part->pdzf.ppz8_channel : part->opna_keyon_out)+1;
+ track->info = FMDRIVER_TRACK_INFO_NORMAL;
+ if (part->type.adpcm) {
track->actual_key = 0xff;
} else if (part->type.ssg) {
if (part->u.ssg.env_f.ppz || part->pdzf.mode) {
- track->type = FMDRIVER_TRACK_PPZ8;
+ track->info = FMDRIVER_TRACK_INFO_PPZ8;
track->actual_key = 0xff;
} else {
- track->type = FMDRIVER_TRACK_SSG;
track->actual_key = part->status.rest ? 0xff : fmp_ssg_freq2key(part->prev_freq);
}
} else {
if (part->pdzf.mode) {
- track->type = FMDRIVER_TRACK_PPZ8;
+ track->info = FMDRIVER_TRACK_INFO_PPZ8;
track->actual_key = 0xff;
} else {
- track->type = FMDRIVER_TRACK_FM;
track->actual_key = part->status.rest ? 0xff : fmp_fm_freq2key(part->prev_freq);
}
}
@@ -3407,6 +3440,7 @@ void fmp_init(struct fmdriver_work *work, struct driver_fmp *fmp) {
fmp_set_tempo(work, fmp);
work->driver = fmp;
work->driver_opna_interrupt = fmp_opna_interrupt;
+ fmp_work_status_init(work, fmp);
}
// 4235
diff --git a/fmdriver/ppz8.c b/fmdriver/ppz8.c
index 7984575..39caf0d 100644
--- a/fmdriver/ppz8.c
+++ b/fmdriver/ppz8.c
@@ -247,6 +247,7 @@ static void ppz8_channel_stop(struct ppz8 *ppz8, uint8_t ch) {
if (ch >= 8) return;
struct ppz8_channel *channel = &ppz8->channel[ch];
channel->playing = false;
+ channel->ptr = -1;
}
static void ppz8_channel_volume(struct ppz8 *ppz8, uint8_t ch, uint8_t vol) {