diff --git a/CMakeLists.txt b/CMakeLists.txt index 09ea5422..d0fe0ed1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,8 @@ IF( NOT NO_SDL ) ENDIF( NOT NO_SDL ) IF( WITH_LIRC ) SET( WITHLIRC 1 ) +ELSE( WITH_LIRC ) + SET( WITHLIRC 0 ) ENDIF( WITH_LIRC ) # Check that the dependencies are met to build the GTK frontend @@ -105,8 +107,8 @@ IF ( WIN32 ) ELSE ( WIN32 ) SET( CMAKE_ASM_FLAGS "-Isrc/hq/asm/ -O1 -DELF -w-orphan-labels") ENDIF ( WIN32 ) -SET( CMAKE_C_FLAGS "-O3 -Wall") -SET( CMAKE_CXX_FLAGS "-O3 -Wall") +SET( CMAKE_C_FLAGS "-O3 -mtune=native -Wall") +SET( CMAKE_CXX_FLAGS "-O3 -mtune=native -Wall") # Source files definition SET(SRC_MAIN @@ -222,14 +224,18 @@ ELSE(CMAKE_ASM_COMPILER_LOADED AND USE_ASM_SCALERS) SET(SRC_HQ ${SRC_HQ_C}) ENDIF(CMAKE_ASM_COMPILER_LOADED AND USE_ASM_SCALERS) -include_directories( +INCLUDE_DIRECTORIES( ${ZLIB_INCLUDE_DIR} - ${GTKMM_INCLUDE_DIRS} - ${GLADEMM_INCLUDE_DIRS} ${SDL_INCLUDE_DIRS} - ${GTKGLMM_INCLUDE_DIRS} ) +IF( CAN_BUILD_GVBAM ) + INCLUDE_DIRECTORIES( + ${GTKMM_INCLUDE_DIRS} + ${GLADEMM_INCLUDE_DIRS} + ) +ENDIF( CAN_BUILD_GVBAM ) + ADD_LIBRARY ( vbamcore ${PROJECT_SRCS} @@ -253,15 +259,19 @@ IF( CAN_BUILD_VBAM ) SET( WIN32_LIBRARIES wsock32 ) ENDIF( WIN32 ) + IF( WITH_LIRC ) + SET( LIRC_CLIENT_LIBRARY lirc_client ) + ENDIF( WITH_LIRC ) + TARGET_LINK_LIBRARIES ( vbam vbamcore - lirc_client ${SDL_LIBRARY} ${ZLIB_LIBRARY} ${PNG_LIBRARY} ${OPENGL_LIBRARY} ${WIN32_LIBRARIES} + ${LIRC_CLIENT_LIBRARY} ) INSTALL(PROGRAMS vbam DESTINATION bin) diff --git a/src/agb/GBA.cpp b/src/agb/GBA.cpp index 0fbb9a0b..a299eeec 100644 --- a/src/agb/GBA.cpp +++ b/src/agb/GBA.cpp @@ -1288,6 +1288,14 @@ void CPUCleanUp() emulating = 0; } +/* allocation of memory segments + display where they are (for ptrace PEEK/POKE) */ +void * pom_calloc(int elem, int kolik, const char * const co) +{ + void * poi = calloc(elem, kolik); + fprintf(stderr,"%s allocated at 0x%08x - 0x%08x\n", co, (int)poi, (int)poi + kolik - 1); + return poi; +} + int CPULoadRom(const char *szFile) { romSize = 0x2000000; @@ -1297,13 +1305,13 @@ int CPULoadRom(const char *szFile) systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; - rom = (u8 *)malloc(0x2000000); + rom = (u8 *)pom_calloc(1, romSize, "ROM"); if(rom == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "ROM"); return 0; } - workRAM = (u8 *)calloc(1, 0x40000); + workRAM = (u8 *)pom_calloc(1, 0x40000, "RAM"); if(workRAM == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "WRAM"); @@ -1353,49 +1361,49 @@ int CPULoadRom(const char *szFile) temp++; } - bios = (u8 *)calloc(1,0x4000); + bios = (u8 *)pom_calloc(1, 0x4000, "BIOS"); if(bios == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "BIOS"); CPUCleanUp(); return 0; } - internalRAM = (u8 *)calloc(1,0x8000); + internalRAM = (u8 *)pom_calloc(1, 0x8000, "internal RAM"); if(internalRAM == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "IRAM"); CPUCleanUp(); return 0; } - paletteRAM = (u8 *)calloc(1,0x400); + paletteRAM = (u8 *)pom_calloc(1, 0x400, "palette RAM"); if(paletteRAM == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "PRAM"); CPUCleanUp(); return 0; } - vram = (u8 *)calloc(1, 0x20000); + vram = (u8 *)pom_calloc(1, 0x20000, "vRAM"); if(vram == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "VRAM"); CPUCleanUp(); return 0; } - oam = (u8 *)calloc(1, 0x400); + oam = (u8 *)pom_calloc(1, 0x400, "oam"); if(oam == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "OAM"); CPUCleanUp(); return 0; } - pix = (u8 *)calloc(1, 4 * 241 * 162); + pix = (u8 *)pom_calloc(1, 4 * 241 * 162, "PIX"); if(pix == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "PIX"); CPUCleanUp(); return 0; } - ioMem = (u8 *)calloc(1, 0x400); + ioMem = (u8 *)pom_calloc(1, 0x400, "IO"); if(ioMem == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "IO"); diff --git a/src/sdl/SDL.cpp b/src/sdl/SDL.cpp index d53537ad..e29f50be 100644 --- a/src/sdl/SDL.cpp +++ b/src/sdl/SDL.cpp @@ -45,6 +45,7 @@ #include "../Util.h" #include "../dmg/gb.h" #include "../dmg/gbGlobals.h" +#include "../dmg/gbCheats.h" #include "../Cheats.h" #include "debugger.h" @@ -68,7 +69,7 @@ # include #endif // ! __GNUC__ -#ifdef WITH_LIRC +#if WITH_LIRC #include #include #endif @@ -362,7 +363,7 @@ struct option sdlOptions[] = { { NULL, no_argument, NULL, 0 } }; -#ifdef WITH_LIRC +#if WITH_LIRC //LIRC code bool LIRCEnabled = false; int LIRCfd = 0; @@ -419,7 +420,7 @@ u32 sdlFromHex(char *s) return value; } -#ifdef WITH_LIRC +#if WITH_LIRC void lircCheckInput(void) { if(LIRCEnabled) { @@ -2469,7 +2470,7 @@ int main(int argc, char **argv) systemMessage(0, "Failed to init joystick support: %s", SDL_GetError()); } -#ifdef WITH_LIRC +#if WITH_LIRC StartLirc(); #endif sdlCheckKeys(); @@ -2552,6 +2553,9 @@ int main(int argc, char **argv) } else if (l == 13 && p[8] == ' ') { fprintf(stderr,"Adding CBA cheat code %s\n", p); cheatsAddCBACode(p, p); + } else if (l == 8) { + fprintf(stderr,"Adding GB(GS) cheat code %s\n", p); + gbAddGsCheat(p, p); } else { fprintf(stderr,"Unknown format for cheat code %s\n", p); } @@ -2575,7 +2579,7 @@ int main(int argc, char **argv) SDL_Delay(500); } sdlPollEvents(); - #ifdef WITH_LIRC + #if WITH_LIRC lircCheckInput(); #endif if(mouseCounter) { @@ -2605,7 +2609,7 @@ int main(int argc, char **argv) filterPix = NULL; } -#ifdef WITH_LIRC +#if WITH_LIRC StopLirc(); #endif