scsp: improve fm register definition

This commit is contained in:
Zack Buhman 2023-06-26 01:48:45 +00:00
parent 09c1fc9267
commit d41a42dca4
3 changed files with 18 additions and 14 deletions

28
scsp.h
View File

@ -38,8 +38,13 @@ typedef struct scsp_slot {
}; };
reg32 EG; reg32 EG;
}; };
reg16 VOLUME; // Sound volume union {
reg16 FM; // FM modulation control struct {
reg16 FMU; // Sound volume
reg16 FML; // FM modulation control
};
reg32 FM;
};
reg16 PITCH; // FM pitch control reg16 PITCH; // FM pitch control
reg16 LFO; // LFO (low-freqency oscillator) reg16 LFO; // LFO (low-freqency oscillator)
union { // slot mixer union { // slot mixer
@ -234,18 +239,20 @@ enum eg_bits {
#define EG__RR(n) ((n & 0x1f) << 0 ) // Release rate #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 { 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__MDL = ( 0b0000 << 12), // Modulation level
FM__MDXSL = (0b000000 << 6 ), // Select modulation input X FM__MDXSL = (0b000000 << 6 ), // Select modulation input X
FM__MDYSL = (0b000000 << 0 ), // Select modulation input Y 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 { enum lfo_bits {
LFO__LFORE = ( 1 << 15), // (RE) LFO reset LFO__LFORE = ( 1 << 15), // (RE) LFO reset
LFO__LFOF = (0b00000 << 10), // LFO frequency LFO__LFOF = (0b00000 << 10), // LFO frequency
@ -264,11 +271,6 @@ enum mixer_bits {
MIXER__EFPAN = (0b00000 << 0 ), MIXER__EFPAN = (0b00000 << 0 ),
}; };
//enum pitch_bits {
#define PITCH__OCT(n) (((n) & 0xf) << 11)
#define PITCH__FNS(n) (((n) & 0x3ff) << 0 )
//};
enum scsp_bits { enum scsp_bits {
MIXER__MEM4MB = (1 << 9), MIXER__MEM4MB = (1 << 9),
MIXER__DAC18B = (1 << 8), MIXER__DAC18B = (1 << 8),

2
sh2.h
View File

@ -2,6 +2,8 @@
#include "type.h" #include "type.h"
#include <cstddef>
typedef struct sh2_reg { typedef struct sh2_reg {
reg8 SMR; // 0x000 reg8 SMR; // 0x000
reg8 BRR; // 0x001 reg8 BRR; // 0x001

2
type.h
View File

@ -2,8 +2,8 @@
#ifndef __cplusplus #ifndef __cplusplus
#define static_assert _Static_assert #define static_assert _Static_assert
#endif
#define offsetof __builtin_offsetof #define offsetof __builtin_offsetof
#endif
typedef volatile uint8_t reg8; typedef volatile uint8_t reg8;
typedef volatile uint16_t reg16; typedef volatile uint16_t reg16;