diff options
author | 2022-02-20 14:22:18 -0900 | |
---|---|---|
committer | 2022-02-20 18:22:18 -0500 | |
commit | d8fd71415204a2c91bdebf199c2992a5fc6c9133 (patch) | |
tree | 591813f09346dc8d36971caf5ea72a74a37ff0a0 /src/devices/sound/nes_defs.h | |
parent | c3aecd0ea3b960f7810e907943c53e11a4921096 (diff) |
nes_apu.cpp: A few cleanups. (#9326)
- Removed old, unused, or redundant code, variables, and comments.
- Removed array used for reading back registers. APU registers cannot be read.
- Updated length counter table to match hardware counts.
- Consolidated some functions.
Diffstat (limited to 'src/devices/sound/nes_defs.h')
-rw-r--r-- | src/devices/sound/nes_defs.h | 81 |
1 files changed, 19 insertions, 62 deletions
diff --git a/src/devices/sound/nes_defs.h b/src/devices/sound/nes_defs.h index e319f93d6f0..1f4544b02c2 100644 --- a/src/devices/sound/nes_defs.h +++ b/src/devices/sound/nes_defs.h @@ -32,15 +32,6 @@ /* APU type */ struct apu_t { - /* REGULAR TYPE DEFINITIONS */ - typedef int8_t int8; - typedef int16_t int16; - typedef int32_t int32; - typedef uint8_t uint8; - typedef uint16_t uint16; - typedef uint32_t uint32; - - /* CHANNEL TYPE DEFINITIONS */ /* Square Wave */ @@ -52,16 +43,16 @@ struct apu_t elem = 0; } - uint8 regs[4]; + u8 regs[4]; int vbl_length = 0; int freq = 0; float phaseacc = 0.0; float env_phase = 0.0; float sweep_phase = 0.0; - uint8 adder = 0; - uint8 env_vol = 0; + u8 adder = 0; + u8 env_vol = 0; bool enabled = false; - uint8 output = 0; + u8 output = 0; }; /* Triangle Wave */ @@ -73,16 +64,16 @@ struct apu_t elem = 0; } - uint8 regs[4]; /* regs[1] unused */ + u8 regs[4]; /* regs[1] unused */ int linear_length = 0; bool linear_reload = false; int vbl_length = 0; int write_latency = 0; float phaseacc = 0.0; - uint8 adder = 0; + u8 adder = 0; bool counter_started = false; bool enabled = false; - uint8 output = 0; + u8 output = 0; }; /* Noise Wave */ @@ -94,14 +85,14 @@ struct apu_t elem = 0; } - uint8 regs[4]; /* regs[1] unused */ + u8 regs[4]; /* regs[1] unused */ u32 seed = 1; int vbl_length = 0; float phaseacc = 0.0; float env_phase = 0.0; - uint8 env_vol = 0; + u8 env_vol = 0; bool enabled = false; - uint8 output = 0; + u8 output = 0; }; /* DPCM Wave */ @@ -113,16 +104,16 @@ struct apu_t elem = 0; } - uint8 regs[4]; - uint32 address = 0; - uint32 length = 0; + u8 regs[4]; + u32 address = 0; + u32 length = 0; int bits_left = 0; float phaseacc = 0.0; - uint8 cur_byte = 0; + u8 cur_byte = 0; bool enabled = false; bool irq_occurred = false; - int16 vol = 0; - uint8 output = 0; + s16 vol = 0; + u8 output = 0; }; @@ -148,56 +139,22 @@ struct apu_t static constexpr unsigned SMASK = 0x15; static constexpr unsigned IRQCTRL = 0x17; - apu_t() - { - memset(regs, 0, sizeof(regs)); - } - /* Sound channels */ square_t squ[2]; triangle_t tri; noise_t noi; dpcm_t dpcm; - /* APU registers */ - unsigned char regs[0x18]; - - /* Sound pointers */ - void *buffer = nullptr; - -#ifdef USE_QUEUE - - static constexpr unsigned QUEUE_SIZE = 0x2000; - static constexpr unsigned QUEUE_MAX = QUEUE_SIZE - 1; - - struct queue_t - { - queue_t() { } - - int pos = 0; - unsigned char reg = 0, val = 0; - }; - - /* Event queue */ - queue_t queue[QUEUE_SIZE]; - int head, tail; - -#else - - int buf_pos = 0; - -#endif - int step_mode = 0; }; /* CONSTANTS */ /* vblank length table used for squares, triangle, noise */ -static const apu_t::uint8 vbl_length[32] = +static const u8 vbl_length[32] = { - 5, 127, 10, 1, 20, 2, 40, 3, 80, 4, 30, 5, 7, 6, 13, 7, - 6, 8, 12, 9, 24, 10, 48, 11, 96, 12, 36, 13, 8, 14, 16, 15 + 10, 254, 20, 2, 40, 4, 80, 6, 160, 8, 60, 10, 14, 12, 26, 14, + 12, 16, 24, 18, 48, 20, 96, 22, 192, 24, 72, 26, 16, 28, 32, 30 }; /* frequency limit of square channels */ |