From 893a411ff3eb6ffdeba62acae34ac5511466599f Mon Sep 17 00:00:00 2001 From: Takamichi Horikawa Date: Fri, 17 Mar 2017 22:32:52 +0900 Subject: libopna: ssg tone period access function --- libopna/opnassg.c | 6 ++++-- libopna/opnassg.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'libopna') diff --git a/libopna/opnassg.c b/libopna/opnassg.c index 3c5b108..223758c 100644 --- a/libopna/opnassg.c +++ b/libopna/opnassg.c @@ -108,8 +108,10 @@ unsigned opna_ssg_readreg(const struct opna_ssg *ssg, unsigned reg) { return ssg->regs[reg]; } -static int opna_ssg_tone_period(const struct opna_ssg *ssg, int chan) { - return ssg->regs[0+chan*2] | ((ssg->regs[1+chan*2] & 0xf) << 8); +unsigned opna_ssg_tone_period(const struct opna_ssg *ssg, int ch) { + if (ch < 0) return 0; + if (ch >= 3) return 0; + return ssg->regs[0+ch*2] | ((ssg->regs[1+ch*2] & 0xf) << 8); } static bool opna_ssg_chan_env(const struct opna_ssg *ssg, int chan) { diff --git a/libopna/opnassg.h b/libopna/opnassg.h index 1bd607a..8a59d91 100644 --- a/libopna/opnassg.h +++ b/libopna/opnassg.h @@ -53,6 +53,7 @@ void opna_ssg_writereg(struct opna_ssg *ssg, unsigned reg, unsigned val); unsigned opna_ssg_readreg(const struct opna_ssg *ssg, unsigned reg); // channel level (0 - 31) int opna_ssg_channel_level(const struct opna_ssg *ssg, int ch); +unsigned opna_ssg_tone_period(const struct opna_ssg *ssg, int ch); #ifdef __cplusplus } -- cgit v1.2.3