mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-14 22:31:57 +00:00
040cb17370
# 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
91 lines
2.3 KiB
C++
91 lines
2.3 KiB
C++
// Nintendo Game Boy CPU emulator
|
|
// Treats every instruction as taking 4 cycles
|
|
|
|
// Game_Music_Emu https://bitbucket.org/mpyne/game-music-emu/
|
|
#ifndef GB_CPU_H
|
|
#define GB_CPU_H
|
|
|
|
#include "blargg_common.h"
|
|
#include "blargg_endian.h"
|
|
|
|
typedef unsigned gb_addr_t; // 16-bit CPU address
|
|
|
|
class Gb_Cpu {
|
|
enum { clocks_per_instr = 4 };
|
|
public:
|
|
// Clear registers and map all pages to unmapped
|
|
void reset( void* unmapped = 0 );
|
|
|
|
// Map code memory (memory accessed via the program counter). Start and size
|
|
// must be multiple of page_size.
|
|
enum { page_size = 0x2000 };
|
|
void map_code( gb_addr_t start, unsigned size, void* code );
|
|
|
|
uint8_t* get_code( gb_addr_t );
|
|
|
|
// Push a byte on the stack
|
|
void push_byte( int );
|
|
|
|
// Game Boy Z80 registers. *Not* kept updated during a call to run().
|
|
struct core_regs_t {
|
|
#if BLARGG_BIG_ENDIAN
|
|
uint8_t b, c, d, e, h, l, flags, a;
|
|
#else
|
|
uint8_t c, b, e, d, l, h, a, flags;
|
|
#endif
|
|
};
|
|
|
|
struct registers_t : core_regs_t {
|
|
long pc; // more than 16 bits to allow overflow detection
|
|
uint16_t sp;
|
|
};
|
|
registers_t r;
|
|
|
|
// Interrupt enable flag set by EI and cleared by DI
|
|
//bool interrupts_enabled; // unused
|
|
|
|
// Base address for RST vectors (normally 0)
|
|
gb_addr_t rst_base;
|
|
|
|
// If CPU executes opcode 0xFF at this address, it treats as illegal instruction
|
|
enum { idle_addr = 0xF00D };
|
|
|
|
// Run CPU for at least 'count' cycles and return false, or return true if
|
|
// illegal instruction is encountered.
|
|
bool run( blargg_long count );
|
|
|
|
// Number of clock cycles remaining for most recent run() call
|
|
blargg_long remain() const { return state->remain * clocks_per_instr; }
|
|
|
|
// Can read this many bytes past end of a page
|
|
enum { cpu_padding = 8 };
|
|
|
|
public:
|
|
Gb_Cpu() : rst_base( 0 ) { state = &state_; }
|
|
enum { page_shift = 13 };
|
|
enum { page_count = 0x10000 >> page_shift };
|
|
private:
|
|
// noncopyable
|
|
Gb_Cpu( const Gb_Cpu& );
|
|
Gb_Cpu& operator = ( const Gb_Cpu& );
|
|
|
|
struct state_t {
|
|
uint8_t* code_map [page_count + 1];
|
|
blargg_long remain;
|
|
};
|
|
state_t* state; // points to state_ or a local copy within run()
|
|
state_t state_;
|
|
|
|
void set_code_page( int, uint8_t* );
|
|
};
|
|
|
|
inline uint8_t* Gb_Cpu::get_code( gb_addr_t addr )
|
|
{
|
|
return state->code_map [addr >> page_shift] + addr
|
|
#if !BLARGG_NONPORTABLE
|
|
% (unsigned) page_size
|
|
#endif
|
|
;
|
|
}
|
|
|
|
#endif
|