gzdoom-gles/libraries/game-music-emu/gme/Nes_Oscs.h
Christoph Oelckers 040cb17370 - moved third party library projects to a subfolder to reduce size of the root.
# Conflicts:
#	CMakeLists.txt
#	libraries/glslang/OGLCompilersDLL/CMakeLists.txt
#	libraries/glslang/OGLCompilersDLL/InitializeDll.cpp
#	libraries/glslang/OGLCompilersDLL/InitializeDll.h
#	libraries/glslang/glslang/CMakeLists.txt
#	libraries/glslang/glslang/GenericCodeGen/CodeGen.cpp
#	libraries/glslang/glslang/GenericCodeGen/Link.cpp
#	libraries/glslang/glslang/Include/BaseTypes.h
#	libraries/glslang/glslang/Include/Common.h
#	libraries/glslang/glslang/Include/ConstantUnion.h
#	libraries/glslang/glslang/Include/InfoSink.h
#	libraries/glslang/glslang/Include/InitializeGlobals.h
#	libraries/glslang/glslang/Include/PoolAlloc.h
#	libraries/glslang/glslang/Include/ResourceLimits.h
#	libraries/glslang/glslang/Include/ShHandle.h
#	libraries/glslang/glslang/Include/Types.h
#	libraries/glslang/glslang/Include/arrays.h
#	libraries/glslang/glslang/Include/intermediate.h
#	libraries/glslang/glslang/Include/revision.h
#	libraries/glslang/glslang/Include/revision.template
#	libraries/glslang/glslang/MachineIndependent/Constant.cpp
#	libraries/glslang/glslang/MachineIndependent/InfoSink.cpp
#	libraries/glslang/glslang/MachineIndependent/Initialize.cpp
#	libraries/glslang/glslang/MachineIndependent/Initialize.h
#	libraries/glslang/glslang/MachineIndependent/IntermTraverse.cpp
#	libraries/glslang/glslang/MachineIndependent/Intermediate.cpp
#	libraries/glslang/glslang/MachineIndependent/LiveTraverser.h
#	libraries/glslang/glslang/MachineIndependent/ParseContextBase.cpp
#	libraries/glslang/glslang/MachineIndependent/ParseHelper.cpp
#	libraries/glslang/glslang/MachineIndependent/ParseHelper.h
#	libraries/glslang/glslang/MachineIndependent/PoolAlloc.cpp
#	libraries/glslang/glslang/MachineIndependent/RemoveTree.cpp
#	libraries/glslang/glslang/MachineIndependent/RemoveTree.h
#	libraries/glslang/glslang/MachineIndependent/Scan.cpp
#	libraries/glslang/glslang/MachineIndependent/Scan.h
#	libraries/glslang/glslang/MachineIndependent/ScanContext.h
#	libraries/glslang/glslang/MachineIndependent/ShaderLang.cpp
#	libraries/glslang/glslang/MachineIndependent/SymbolTable.cpp
#	libraries/glslang/glslang/MachineIndependent/SymbolTable.h
#	libraries/glslang/glslang/MachineIndependent/Versions.cpp
#	libraries/glslang/glslang/MachineIndependent/Versions.h
#	libraries/glslang/glslang/MachineIndependent/attribute.cpp
#	libraries/glslang/glslang/MachineIndependent/attribute.h
#	libraries/glslang/glslang/MachineIndependent/gl_types.h
#	libraries/glslang/glslang/MachineIndependent/glslang.y
#	libraries/glslang/glslang/MachineIndependent/glslang_tab.cpp
#	libraries/glslang/glslang/MachineIndependent/glslang_tab.cpp.h
#	libraries/glslang/glslang/MachineIndependent/intermOut.cpp
#	libraries/glslang/glslang/MachineIndependent/iomapper.cpp
#	libraries/glslang/glslang/MachineIndependent/iomapper.h
#	libraries/glslang/glslang/MachineIndependent/limits.cpp
#	libraries/glslang/glslang/MachineIndependent/linkValidate.cpp
#	libraries/glslang/glslang/MachineIndependent/localintermediate.h
#	libraries/glslang/glslang/MachineIndependent/parseConst.cpp
#	libraries/glslang/glslang/MachineIndependent/parseVersions.h
#	libraries/glslang/glslang/MachineIndependent/pch.cpp
#	libraries/glslang/glslang/MachineIndependent/pch.h
#	libraries/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp
#	libraries/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp
#	libraries/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp
#	libraries/glslang/glslang/MachineIndependent/preprocessor/PpContext.h
#	libraries/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp
#	libraries/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp
#	libraries/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h
#	libraries/glslang/glslang/MachineIndependent/propagateNoContraction.cpp
#	libraries/glslang/glslang/MachineIndependent/propagateNoContraction.h
#	libraries/glslang/glslang/MachineIndependent/reflection.cpp
#	libraries/glslang/glslang/MachineIndependent/reflection.h
#	libraries/glslang/glslang/OSDependent/Unix/CMakeLists.txt
#	libraries/glslang/glslang/OSDependent/Unix/ossource.cpp
#	libraries/glslang/glslang/OSDependent/Windows/CMakeLists.txt
#	libraries/glslang/glslang/OSDependent/Windows/main.cpp
#	libraries/glslang/glslang/OSDependent/Windows/ossource.cpp
#	libraries/glslang/glslang/OSDependent/osinclude.h
#	libraries/glslang/glslang/Public/ShaderLang.h
#	libraries/glslang/glslang/updateGrammar
#	libraries/glslang/spirv/CMakeLists.txt
#	libraries/glslang/spirv/GLSL.ext.AMD.h
#	libraries/glslang/spirv/GLSL.ext.EXT.h
#	libraries/glslang/spirv/GLSL.ext.KHR.h
#	libraries/glslang/spirv/GLSL.ext.NV.h
#	libraries/glslang/spirv/GLSL.std.450.h
#	libraries/glslang/spirv/GlslangToSpv.cpp
#	libraries/glslang/spirv/GlslangToSpv.h
#	libraries/glslang/spirv/InReadableOrder.cpp
#	libraries/glslang/spirv/Logger.cpp
#	libraries/glslang/spirv/Logger.h
#	libraries/glslang/spirv/SPVRemapper.cpp
#	libraries/glslang/spirv/SPVRemapper.h
#	libraries/glslang/spirv/SpvBuilder.cpp
#	libraries/glslang/spirv/SpvBuilder.h
#	libraries/glslang/spirv/SpvPostProcess.cpp
#	libraries/glslang/spirv/SpvTools.cpp
#	libraries/glslang/spirv/SpvTools.h
#	libraries/glslang/spirv/bitutils.h
#	libraries/glslang/spirv/disassemble.cpp
#	libraries/glslang/spirv/disassemble.h
#	libraries/glslang/spirv/doc.cpp
#	libraries/glslang/spirv/doc.h
#	libraries/glslang/spirv/hex_float.h
#	libraries/glslang/spirv/spirv.hpp
#	libraries/glslang/spirv/spvIR.h
#	src/CMakeLists.txt
2020-01-04 21:30:08 +01:00

147 lines
2.8 KiB
C++

// Private oscillators used by Nes_Apu
// Nes_Snd_Emu 0.1.8
#ifndef NES_OSCS_H
#define NES_OSCS_H
#include "blargg_common.h"
#include "Blip_Buffer.h"
class Nes_Apu;
struct Nes_Osc
{
unsigned char regs [4];
bool reg_written [4];
Blip_Buffer* output;
int length_counter;// length counter (0 if unused by oscillator)
int delay; // delay until next (potential) transition
int last_amp; // last amplitude oscillator was outputting
void clock_length( int halt_mask );
int period() const {
return (regs [3] & 7) * 0x100 + (regs [2] & 0xFF);
}
void reset() {
delay = 0;
last_amp = 0;
}
int update_amp( int amp ) {
int delta = amp - last_amp;
last_amp = amp;
return delta;
}
};
struct Nes_Envelope : Nes_Osc
{
int envelope;
int env_delay;
void clock_envelope();
int volume() const;
void reset() {
envelope = 0;
env_delay = 0;
Nes_Osc::reset();
}
};
// Nes_Square
struct Nes_Square : Nes_Envelope
{
enum { negate_flag = 0x08 };
enum { shift_mask = 0x07 };
enum { phase_range = 8 };
int phase;
int sweep_delay;
typedef Blip_Synth<blip_good_quality,1> Synth;
Synth const& synth; // shared between squares
Nes_Square( Synth const* s ) : synth( *s ) { }
void clock_sweep( int adjust );
void run( nes_time_t, nes_time_t );
void reset() {
sweep_delay = 0;
Nes_Envelope::reset();
}
nes_time_t maintain_phase( nes_time_t time, nes_time_t end_time,
nes_time_t timer_period );
};
// Nes_Triangle
struct Nes_Triangle : Nes_Osc
{
enum { phase_range = 16 };
int phase;
int linear_counter;
Blip_Synth<blip_med_quality,1> synth;
int calc_amp() const;
void run( nes_time_t, nes_time_t );
void clock_linear_counter();
void reset() {
linear_counter = 0;
phase = 1;
Nes_Osc::reset();
}
nes_time_t maintain_phase( nes_time_t time, nes_time_t end_time,
nes_time_t timer_period );
};
// Nes_Noise
struct Nes_Noise : Nes_Envelope
{
int noise;
Blip_Synth<blip_med_quality,1> synth;
void run( nes_time_t, nes_time_t );
void reset() {
noise = 1 << 14;
Nes_Envelope::reset();
}
};
// Nes_Dmc
struct Nes_Dmc : Nes_Osc
{
int address; // address of next byte to read
int period;
//int length_counter; // bytes remaining to play (already defined in Nes_Osc)
int buf;
int bits_remain;
int bits;
bool buf_full;
bool silence;
enum { loop_flag = 0x40 };
int dac;
nes_time_t next_irq;
bool irq_enabled;
bool irq_flag;
bool pal_mode;
bool nonlinear;
int (*prg_reader)( void*, nes_addr_t ); // needs to be initialized to prg read function
void* prg_reader_data;
Nes_Apu* apu;
Blip_Synth<blip_med_quality,1> synth;
void start();
void write_register( int, int );
void run( nes_time_t, nes_time_t );
void recalc_irq();
void fill_buffer();
void reload_sample();
void reset();
int count_reads( nes_time_t, nes_time_t* ) const;
nes_time_t next_read_time() const;
};
#endif