From d41a42dca40023ec60eae049b8ea672b82847451 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Mon, 26 Jun 2023 01:48:45 +0000 Subject: [PATCH] scsp: improve fm register definition --- scsp.h | 28 +++++++++++++++------------- sh2.h | 2 ++ type.h | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/scsp.h b/scsp.h index 50d9a25..9f7f182 100644 --- a/scsp.h +++ b/scsp.h @@ -38,8 +38,13 @@ typedef struct scsp_slot { }; reg32 EG; }; - reg16 VOLUME; // Sound volume - reg16 FM; // FM modulation control + union { + struct { + reg16 FMU; // Sound volume + reg16 FML; // FM modulation control + }; + reg32 FM; + }; reg16 PITCH; // FM pitch control reg16 LFO; // LFO (low-freqency oscillator) union { // slot mixer @@ -234,18 +239,20 @@ enum eg_bits { #define EG__RR(n) ((n & 0x1f) << 0 ) // Release rate }; -enum volume_bits { - VOLUME__STWINH = (1 << 9), // (SI) Stack write inhibit (FM-related register) - VOLUME__SDIR = (1 << 8), // (SD) Sound direct -#define FM__TL(n) ((n) << 0) // Total level -}; - enum fm_bits { + FM__STWINH = (1 << (9 + 16)), // (SI) Stack write inhibit (FM-related register) + FM__SDIR = (1 << (8 + 16)), // (SD) Sound direct +#define FM__TL(n) ((n) << (0 + 16)) // Total level (FM) FM__MDL = ( 0b0000 << 12), // Modulation level FM__MDXSL = (0b000000 << 6 ), // Select modulation input X FM__MDYSL = (0b000000 << 0 ), // Select modulation input Y }; +//enum pitch_bits { +#define PITCH__OCT(n) (((n) & 0xf) << 11) +#define PITCH__FNS(n) (((n) & 0x3ff) << 0 ) +//}; + enum lfo_bits { LFO__LFORE = ( 1 << 15), // (RE) LFO reset LFO__LFOF = (0b00000 << 10), // LFO frequency @@ -264,11 +271,6 @@ enum mixer_bits { MIXER__EFPAN = (0b00000 << 0 ), }; -//enum pitch_bits { -#define PITCH__OCT(n) (((n) & 0xf) << 11) -#define PITCH__FNS(n) (((n) & 0x3ff) << 0 ) -//}; - enum scsp_bits { MIXER__MEM4MB = (1 << 9), MIXER__DAC18B = (1 << 8), diff --git a/sh2.h b/sh2.h index 4560ff8..2c9cb15 100644 --- a/sh2.h +++ b/sh2.h @@ -2,6 +2,8 @@ #include "type.h" +#include + typedef struct sh2_reg { reg8 SMR; // 0x000 reg8 BRR; // 0x001 diff --git a/type.h b/type.h index d2e83a6..629de0f 100644 --- a/type.h +++ b/type.h @@ -2,8 +2,8 @@ #ifndef __cplusplus #define static_assert _Static_assert -#endif #define offsetof __builtin_offsetof +#endif typedef volatile uint8_t reg8; typedef volatile uint16_t reg16;