aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakamichi Horikawa <takamichiho@gmail.com>2017-03-17 22:32:52 +0900
committerTakamichi Horikawa <takamichiho@gmail.com>2017-03-17 22:32:52 +0900
commit893a411ff3eb6ffdeba62acae34ac5511466599f (patch)
treeeebdfae8771fbf3c8b27eb279137c3b6579d8e04
parent41ebb5a449feea3ead78398a3e225c10fd3fc303 (diff)
libopna: ssg tone period access function
-rw-r--r--libopna/opnassg.c6
-rw-r--r--libopna/opnassg.h1
2 files changed, 5 insertions, 2 deletions
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
}