OSDN Git Service

[VM][General][WIP] Start to merge upstream 2018-10-14.Open branch upstream_20181014 .
[csp-qt/common_source_project-fm7.git] / source / src / vm / familybasic / apu.h
index 6b7fd94..8404dfa 100644 (file)
@@ -21,113 +21,113 @@ namespace FAMILYBASIC {
 #define APUQUEUE_SIZE  4096
 #define APUQUEUE_MASK  (APUQUEUE_SIZE - 1)
 
+// rectangle
+typedef struct {
+       uint8_t regs[4];
+       bool enabled;
+       int32_t phaseacc;
+       int32_t freq;
+       int32_t output_vol;
+       bool fixed_envelope;
+       bool holdnote;
+       uint8_t volume;
+       int32_t sweep_phase;
+       int32_t sweep_delay;
+       bool sweep_on;
+       uint8_t sweep_shifts;
+       uint8_t sweep_length;
+       bool sweep_inc;
+       int32_t freq_limit;
+       bool sweep_complement;
+       int32_t env_phase;
+       int32_t env_delay;
+       uint8_t env_vol;
+       int vbl_length;
+       uint8_t adder;
+       int duty_flip;
+       bool enabled_cur;
+       bool holdnote_cur;
+       int vbl_length_cur;
+} rectangle_t;
+
+// triangle
+typedef struct {
+       uint8_t regs[3];
+       bool enabled;
+       int32_t freq;
+       int32_t phaseacc;
+       int32_t output_vol;
+       uint8_t adder;
+       bool holdnote;
+       bool counter_started;
+       int write_latency;
+       int vbl_length;
+       int linear_length;
+       bool enabled_cur;
+       bool holdnote_cur;
+       bool counter_started_cur;
+       int vbl_length_cur;
+} triangle_t;
+
+// noise
+typedef struct {
+       uint8_t regs[3];
+       bool enabled;
+       int32_t freq;
+       int32_t phaseacc;
+       int32_t output_vol;
+       int32_t env_phase;
+       int32_t env_delay;
+       uint8_t env_vol;
+       bool fixed_envelope;
+       bool holdnote;
+       uint8_t volume;
+       int vbl_length;
+       uint8_t xor_tap;
+       bool enabled_cur;
+       bool holdnote_cur;
+       int vbl_length_cur;
+       
+       int shift_reg;
+       int noise_bit;
+} noise_t;
+
+// dmc
+typedef struct {
+       uint8_t regs[4];
+       bool enabled;
+       int32_t freq;
+       int32_t phaseacc;
+       int32_t output_vol;
+       uint32_t address;
+       uint32_t cached_addr;
+       int dma_length;
+       int cached_dmalength;
+       uint8_t cur_byte;
+       bool looping;
+       bool irq_gen;
+       bool irq_occurred;
+       int32_t freq_cur;
+       int32_t phaseacc_cur;
+       int dma_length_cur;
+       int cached_dmalength_cur;
+       bool enabled_cur;
+       bool looping_cur;
+       bool irq_gen_cur;
+       bool irq_occurred_cur;
+} dmc_t;
+
+// queue
+typedef struct {
+       uint32_t timestamp, addr;
+       uint32_t data;
+} queue_t;
+
 class APU : public DEVICE
 {
 private:
        DEVICE *d_cpu, *d_mem;
        
-       // rectangle
-       typedef struct {
-               uint8_t regs[4];
-               bool enabled;
-               int32_t phaseacc;
-               int32_t freq;
-               int32_t output_vol;
-               bool fixed_envelope;
-               bool holdnote;
-               uint8_t volume;
-               int32_t sweep_phase;
-               int32_t sweep_delay;
-               bool sweep_on;
-               uint8_t sweep_shifts;
-               uint8_t sweep_length;
-               bool sweep_inc;
-               int32_t freq_limit;
-               bool sweep_complement;
-               int32_t env_phase;
-               int32_t env_delay;
-               uint8_t env_vol;
-               int vbl_length;
-               uint8_t adder;
-               int duty_flip;
-               bool enabled_cur;
-               bool holdnote_cur;
-               int vbl_length_cur;
-       } rectangle_t;
-       
-       // triangle
-       typedef struct {
-               uint8_t regs[3];
-               bool enabled;
-               int32_t freq;
-               int32_t phaseacc;
-               int32_t output_vol;
-               uint8_t adder;
-               bool holdnote;
-               bool counter_started;
-               int write_latency;
-               int vbl_length;
-               int linear_length;
-               bool enabled_cur;
-               bool holdnote_cur;
-               bool counter_started_cur;
-               int vbl_length_cur;
-       } triangle_t;
-       
-       // noise
-       typedef struct {
-               uint8_t regs[3];
-               bool enabled;
-               int32_t freq;
-               int32_t phaseacc;
-               int32_t output_vol;
-               int32_t env_phase;
-               int32_t env_delay;
-               uint8_t env_vol;
-               bool fixed_envelope;
-               bool holdnote;
-               uint8_t volume;
-               int vbl_length;
-               uint8_t xor_tap;
-               bool enabled_cur;
-               bool holdnote_cur;
-               int vbl_length_cur;
-               
-               int shift_reg;
-               int noise_bit;
-       } noise_t;
-       
-       // dmc
-       typedef struct {
-               uint8_t regs[4];
-               bool enabled;
-               int32_t freq;
-               int32_t phaseacc;
-               int32_t output_vol;
-               uint32_t address;
-               uint32_t cached_addr;
-               int dma_length;
-               int cached_dmalength;
-               uint8_t cur_byte;
-               bool looping;
-               bool irq_gen;
-               bool irq_occurred;
-               int32_t freq_cur;
-               int32_t phaseacc_cur;
-               int dma_length_cur;
-               int cached_dmalength_cur;
-               bool enabled_cur;
-               bool looping_cur;
-               bool irq_gen_cur;
-               bool irq_occurred_cur;
-       } dmc_t;
-       
-       // queue
-       typedef struct {
-               uint32_t timestamp, addr;
-               uint32_t data;
-       } queue_t;
-       
        rectangle_t rectangle[2];
        triangle_t triangle;
        noise_t noise;