From 551cb8e8660fc2edca7480c8adb8e26efb46c3e6 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sat, 13 Dec 2008 02:47:07 +0000 Subject: [PATCH] clean up header file, for fewer dependencies and hopefully slightly faster builds. also fix a couple of const arrays which were being defined in a .h file --- src/boards/mapinc.h | 2 -- src/debug.cpp | 23 +++++++++++++++++ src/debug.h | 21 +-------------- src/drivers/win/main.cpp | 5 +++- src/drivers/win/replay.cpp | 1 + src/fceu.cpp | 5 +++- src/mappers/mapinc.h | 1 - src/state.h | 2 -- src/types.h | 8 ------ src/utils/endian.h | 2 +- src/x6502.cpp | 52 +++++++++++++++++++++++++++++++++++++ src/x6502.h | 53 +++----------------------------------- 12 files changed, 89 insertions(+), 86 deletions(-) diff --git a/src/boards/mapinc.h b/src/boards/mapinc.h index 36cb06cf..0de564ac 100644 --- a/src/boards/mapinc.h +++ b/src/boards/mapinc.h @@ -1,5 +1,3 @@ -#include -#include #include "../types.h" #include "../utils/memory.h" #include "../x6502.h" diff --git a/src/debug.cpp b/src/debug.cpp index 6128a2f1..b79b7557 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -609,3 +609,26 @@ void DebugCycle() { //if(logging || (hMemView && (EditingMode == 2))) LogInstruction(); FCEUD_TraceInstruction(); } + + +//opbrktype is used to grab the breakpoint type that each instruction will cause. +//WP_X is not used because ALL opcodes will have the execute bit set. +const uint8 opbrktype[256] = { + /*0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F*/ +/*0x00*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, 0, WP_R, WP_R|WP_W, 0, +/*0x10*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, +/*0x20*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, +/*0x30*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, +/*0x40*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, 0, WP_R, WP_R|WP_W, 0, +/*0x50*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, +/*0x60*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, +/*0x70*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, +/*0x80*/ 0, WP_W, 0, 0, WP_W, WP_W, WP_W, 0, 0, 0, 0, 0, WP_W, WP_W, WP_W, 0, +/*0x90*/ 0, WP_W, 0, 0, WP_W, WP_W, WP_W, 0, 0, WP_W, 0, 0, 0, WP_W, 0, 0, +/*0xA0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R, 0, +/*0xB0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R, 0, 0, WP_R, 0, 0, WP_R, WP_R, WP_R, 0, +/*0xC0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, +/*0xD0*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, +/*0xE0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, +/*0xF0*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0 +}; \ No newline at end of file diff --git a/src/debug.h b/src/debug.h index 95cb4586..85d893d5 100644 --- a/src/debug.h +++ b/src/debug.h @@ -17,26 +17,7 @@ #define BT_S 0x40 //break type, sprite mem //opbrktype is used to grab the breakpoint type that each instruction will cause. -//WP_X is not used because ALL opcodes will have the execute bit set. -static const uint8 opbrktype[256] = { - /*0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F*/ -/*0x00*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x10*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x20*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, -/*0x30*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x40*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x50*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x60*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, -/*0x70*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0x80*/ 0, WP_W, 0, 0, WP_W, WP_W, WP_W, 0, 0, 0, 0, 0, WP_W, WP_W, WP_W, 0, -/*0x90*/ 0, WP_W, 0, 0, WP_W, WP_W, WP_W, 0, 0, WP_W, 0, 0, 0, WP_W, 0, 0, -/*0xA0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R, 0, -/*0xB0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R, 0, 0, WP_R, 0, 0, WP_R, WP_R, WP_R, 0, -/*0xC0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, -/*0xD0*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, -/*0xE0*/ 0, WP_R, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, 0, 0, 0, 0, WP_R, WP_R, WP_R|WP_W, 0, -/*0xF0*/ 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0, 0, WP_R, 0, 0, 0, WP_R, WP_R|WP_W, 0 -}; +extern const uint8 opbrktype[256]; typedef struct { uint16 address; diff --git a/src/drivers/win/main.cpp b/src/drivers/win/main.cpp index dfb23468..acb603b2 100644 --- a/src/drivers/win/main.cpp +++ b/src/drivers/win/main.cpp @@ -28,6 +28,7 @@ #undef LPCWAVEFORMATEX #include "dsound.h" #include "dinput.h" +#include #include #include // For directories configuration dialog. #undef uint8 @@ -544,9 +545,11 @@ void initDirectories() strcpy(directory_names[NUMBER_OF_DIRECTORIES - 1], BaseDirectory.c_str()); } } - +#include "x6502.h" int main(int argc,char *argv[]) { + printf("%08x",opsize); + char *t; initArchiveSystem(); diff --git a/src/drivers/win/replay.cpp b/src/drivers/win/replay.cpp index cf398691..946d7b82 100644 --- a/src/drivers/win/replay.cpp +++ b/src/drivers/win/replay.cpp @@ -1,3 +1,4 @@ +#include #include "replay.h" #include "common.h" #include "main.h" diff --git a/src/fceu.cpp b/src/fceu.cpp index 5cf83cb7..4242acfa 100644 --- a/src/fceu.cpp +++ b/src/fceu.cpp @@ -70,11 +70,14 @@ bool justLagged = false; bool frameAdvanceLagSkip = false; //If this is true, frame advance will skip over lag frame (i.e. it will emulate 2 frames instead of 1) bool movieSubtitles = true; //Toggle for displaying movie subtitles +#include "x6502.h" FCEUGI::FCEUGI() : filename(0) , archiveFilename(0) -{} +{ + printf("%08x",opsize); +} FCEUGI::~FCEUGI() { diff --git a/src/mappers/mapinc.h b/src/mappers/mapinc.h index 5f2b37f7..b14e2c22 100644 --- a/src/mappers/mapinc.h +++ b/src/mappers/mapinc.h @@ -1,4 +1,3 @@ -#include #include "../types.h" #include "../x6502.h" #include "../fceu.h" diff --git a/src/state.h b/src/state.h index 1fad0bf9..c7d640b2 100644 --- a/src/state.h +++ b/src/state.h @@ -18,8 +18,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - enum ENUM_SSLOADPARAMS { SSLOADPARAM_NOBACKUP, diff --git a/src/types.h b/src/types.h index 76b4cf75..8eccf574 100644 --- a/src/types.h +++ b/src/types.h @@ -22,9 +22,6 @@ #ifndef __FCEU_TYPES #define __FCEU_TYPES -#include -#include - #define FCEU_NAME "FCEUX" #define FCEU_VERSION_STRING "2.0.4-interim" #define FCEU_VERSION_NUMERIC 20004 @@ -44,11 +41,6 @@ typedef unsigned int uint32; typedef signed char int8; typedef signed short int16; typedef signed int int32; -#include -#include -#include -#include -#include #define dup _dup #define stat _stat #define fstat _fstat diff --git a/src/utils/endian.h b/src/utils/endian.h index 74537281..d6e12335 100644 --- a/src/utils/endian.h +++ b/src/utils/endian.h @@ -1,7 +1,7 @@ #ifndef __FCEU_ENDIAN #define __FCEU_ENDIAN -//#include +#include #include diff --git a/src/x6502.cpp b/src/x6502.cpp index dbae6495..202703cb 100644 --- a/src/x6502.cpp +++ b/src/x6502.cpp @@ -523,3 +523,55 @@ void FCEUI_GetIVectors(uint16 *reset, uint16 *irq, uint16 *nmi) *irq|=RdMem(0xFFFF)<<8; fceuindbg=0; } + +//the opsize table is used to quickly grab the instruction sizes (in bytes) +const uint8 opsize[256] = { +/*0x00*/ 1,2,0,0,0,2,2,0,1,2,1,0,0,3,3,0, +/*0x10*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0, +/*0x20*/ 3,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0, +/*0x30*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0, +/*0x40*/ 1,2,0,0,0,2,2,0,1,2,1,0,3,3,3,0, +/*0x50*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0, +/*0x60*/ 1,2,0,0,0,2,2,0,1,2,1,0,3,3,3,0, +/*0x70*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0, +/*0x80*/ 0,2,0,0,2,2,2,0,1,0,1,0,3,3,3,0, +/*0x90*/ 2,2,0,0,2,2,2,0,1,3,1,0,0,3,0,0, +/*0xA0*/ 2,2,2,0,2,2,2,0,1,2,1,0,3,3,3,0, +/*0xB0*/ 2,2,0,0,2,2,2,0,1,3,1,0,3,3,3,0, +/*0xC0*/ 2,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0, +/*0xD0*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0, +/*0xE0*/ 2,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0, +/*0xF0*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0 +}; + + +//the optype table is a quick way to grab the addressing mode for any 6502 opcode +// +// 0 = Implied\Accumulator\Immediate\Branch\NULL +// 1 = (Indirect,X) +// 2 = Zero Page +// 3 = Absolute +// 4 = (Indirect),Y +// 5 = Zero Page,X +// 6 = Absolute,Y +// 7 = Absolute,X +// 8 = Zero Page,Y +// +const uint8 optype[256] = { +/*0x00*/ 0,1,0,0,0,2,2,0,0,0,0,0,0,3,3,0, +/*0x10*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0, +/*0x20*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0, +/*0x30*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0, +/*0x40*/ 0,1,0,0,0,2,2,0,0,0,0,0,0,3,3,0, +/*0x50*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0, +/*0x60*/ 0,1,0,0,0,2,2,0,0,0,0,0,3,3,3,0, +/*0x70*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0, +/*0x80*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0, +/*0x90*/ 0,4,0,0,5,5,8,0,0,6,0,0,0,7,0,0, +/*0xA0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0, +/*0xB0*/ 0,4,0,0,5,5,8,0,0,6,0,0,7,7,6,0, +/*0xC0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0, +/*0xD0*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0, +/*0xE0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0, +/*0xF0*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0 +}; \ No newline at end of file diff --git a/src/x6502.h b/src/x6502.h index acbebf56..5c1e71a6 100644 --- a/src/x6502.h +++ b/src/x6502.h @@ -26,57 +26,10 @@ extern X6502 X; //the opsize table is used to quickly grab the instruction sizes (in bytes) -static const uint8 opsize[256] = { -/*0x00*/ 1,2,0,0,0,2,2,0,1,2,1,0,0,3,3,0, -/*0x10*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0, -/*0x20*/ 3,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0, -/*0x30*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0, -/*0x40*/ 1,2,0,0,0,2,2,0,1,2,1,0,3,3,3,0, -/*0x50*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0, -/*0x60*/ 1,2,0,0,0,2,2,0,1,2,1,0,3,3,3,0, -/*0x70*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0, -/*0x80*/ 0,2,0,0,2,2,2,0,1,0,1,0,3,3,3,0, -/*0x90*/ 2,2,0,0,2,2,2,0,1,3,1,0,0,3,0,0, -/*0xA0*/ 2,2,2,0,2,2,2,0,1,2,1,0,3,3,3,0, -/*0xB0*/ 2,2,0,0,2,2,2,0,1,3,1,0,3,3,3,0, -/*0xC0*/ 2,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0, -/*0xD0*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0, -/*0xE0*/ 2,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0, -/*0xF0*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0 -}; +extern const uint8 opsize[256]; - -/* -the optype table is a quick way to grab the addressing mode for any 6502 opcode - - 0 = Implied\Accumulator\Immediate\Branch\NULL - 1 = (Indirect,X) - 2 = Zero Page - 3 = Absolute - 4 = (Indirect),Y - 5 = Zero Page,X - 6 = Absolute,Y - 7 = Absolute,X - 8 = Zero Page,Y -*/ -static const uint8 optype[256] = { -/*0x00*/ 0,1,0,0,0,2,2,0,0,0,0,0,0,3,3,0, -/*0x10*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0, -/*0x20*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0, -/*0x30*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0, -/*0x40*/ 0,1,0,0,0,2,2,0,0,0,0,0,0,3,3,0, -/*0x50*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0, -/*0x60*/ 0,1,0,0,0,2,2,0,0,0,0,0,3,3,3,0, -/*0x70*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0, -/*0x80*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0, -/*0x90*/ 0,4,0,0,5,5,8,0,0,6,0,0,0,7,0,0, -/*0xA0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0, -/*0xB0*/ 0,4,0,0,5,5,8,0,0,6,0,0,7,7,6,0, -/*0xC0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0, -/*0xD0*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0, -/*0xE0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0, -/*0xF0*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0 -}; +//the optype table is a quick way to grab the addressing mode for any 6502 opcode +extern const uint8 optype[256]; //----------- //mbg 6/30/06 - some of this was removed to mimic XD