From 86aa5d980080176ec93bc52a9dd38fedcf37ab9b Mon Sep 17 00:00:00 2001 From: yabause Date: Fri, 9 Jan 2009 00:02:57 +0000 Subject: [PATCH] Fixed compilation on linux --- desmume/src/Makefile.am | 4 +- desmume/src/addons.h | 65 +++++++------- desmume/src/addons/compactFlash.cpp | 4 +- desmume/src/addons/gbagame.cpp | 129 ++++++++++++++-------------- desmume/src/addons/none.cpp | 1 + desmume/src/addons/rumblepak.cpp | 1 + 6 files changed, 107 insertions(+), 97 deletions(-) diff --git a/desmume/src/Makefile.am b/desmume/src/Makefile.am index ad0240847..739d97c02 100644 --- a/desmume/src/Makefile.am +++ b/desmume/src/Makefile.am @@ -43,7 +43,9 @@ libdesmume_a_SOURCES = \ utils/ConvertUTF.c utils/ConvertUTF.h utils/guid.cpp utils/guid.h \ utils/md5.cpp utils/md5.h utils/valuearray.h utils/xstring.cpp utils/xstring.h \ utils/decrypt/crc.cpp utils/decrypt/crc.h utils/decrypt/decrypt.cpp \ - utils/decrypt/decrypt.h utils/decrypt/header.cpp utils/decrypt/header.h + utils/decrypt/decrypt.h utils/decrypt/header.cpp utils/decrypt/header.h \ + addons.c addons.h \ + addons/compactFlash.cpp addons/gbagame.cpp addons/none.cpp addons/rumblepak.cpp if HAVE_GDB_STUB libdesmume_a_SOURCES += gdbstub.h endif diff --git a/desmume/src/addons.h b/desmume/src/addons.h index a5018bb56..852d98dfc 100644 --- a/desmume/src/addons.h +++ b/desmume/src/addons.h @@ -1,32 +1,37 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef __ADDONS_H__ -#define __ADDONS_H__ - -#include "common.h" -#include "types.h" -#include "debug.h" +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef __ADDONS_H__ +#define __ADDONS_H__ + +#include "common.h" +#include "types.h" +#include "debug.h" + +#ifdef __GNUC__ +#include +#define MAX_PATH PATH_MAX +#endif typedef struct { @@ -83,4 +88,4 @@ extern void addonsClose(); // Shutdown addons extern void addonsReset(); // Reset addon extern BOOL addonsChangePak(u8 type); // change current adddon -#endif \ No newline at end of file +#endif diff --git a/desmume/src/addons/compactFlash.cpp b/desmume/src/addons/compactFlash.cpp index 79c503964..27ba0bdbd 100644 --- a/desmume/src/addons/compactFlash.cpp +++ b/desmume/src/addons/compactFlash.cpp @@ -22,6 +22,7 @@ */ #include "../addons.h" +#include #ifdef EXPERIMENTAL_GBASLOT #define DEBUG @@ -31,7 +32,6 @@ #include #include #include -#include #include #include @@ -1031,4 +1031,4 @@ ADDONINTERFACE addonCFlash = { CFlash_info}; #undef DEBUG -#undef CFLASHDEBUG \ No newline at end of file +#undef CFLASHDEBUG diff --git a/desmume/src/addons/gbagame.cpp b/desmume/src/addons/gbagame.cpp index f90890d42..909644002 100644 --- a/desmume/src/addons/gbagame.cpp +++ b/desmume/src/addons/gbagame.cpp @@ -23,82 +23,83 @@ #include "../addons.h" #include "../mem.h" +#include #include "../MMU.h" u8 *GBArom = NULL; -BOOL GBAgame_init(void) -{ - GBArom = new u8 [32 * 1024 * 1024]; - return (TRUE); -}; -void GBAgame_reset(void) -{ - memset(GBArom, 0, 32 * 1024 * 1024); - - if (!strlen(GBAgameName)) return; - FILE *fgame = 0; - - fgame = fopen(GBAgameName,"rb"); - if (!fgame) return; - INFO("Loaded \"%s\" in GBA slot\n", GBAgameName); +BOOL GBAgame_init(void) +{ + GBArom = new u8 [32 * 1024 * 1024]; + return (TRUE); +}; +void GBAgame_reset(void) +{ + memset(GBArom, 0, 32 * 1024 * 1024); + + if (!strlen(GBAgameName)) return; + FILE *fgame = 0; + + fgame = fopen(GBAgameName,"rb"); + if (!fgame) return; + INFO("Loaded \"%s\" in GBA slot\n", GBAgameName); fseek(fgame, 0, SEEK_END); u32 size = ftell(fgame); - rewind(fgame); - + rewind(fgame); + if (!fread(GBArom, 1, size, fgame)) { fclose(fgame); return; } - - fclose(fgame); -}; -void GBAgame_close(void) -{ - if (GBArom) - { - delete [] GBArom; - GBArom = NULL; - } -}; -void GBAgame_config(void) {} -void GBAgame_write08(u32 adr, u8 val){} -void GBAgame_write16(u32 adr, u16 val) {} -void GBAgame_write32(u32 adr, u32 val) {} -u8 GBAgame_read08(u32 adr) -{ - //INFO("Read08 at 0x%08X value 0x%02X\n", adr, (u8)T1ReadByte(GBArom, (adr - 0x08000000))); - if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) - return MMU.MMU_MEM[0][0xFF][(adr +0x1C) & MMU.MMU_MASK[0][0xFF]]; - return (u8)T1ReadByte(GBArom, (adr - 0x08000000)); -} -u16 GBAgame_read16(u32 adr) -{ - //INFO("Read16 at 0x%08X value 0x%04X\n", adr, (u16)T1ReadWord(GBArom, (adr - 0x08000000))); - if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) - return T1ReadWord(MMU.MMU_MEM[0][0xFF], (adr +0x1C) & MMU.MMU_MASK[0][0xFF]); - return (u16)T1ReadWord(GBArom, (adr - 0x08000000)); -} -u32 GBAgame_read32(u32 adr) -{ - //INFO("Read32 at 0x%08X value 0x%08X\n", adr, (u32)T1ReadLong(GBArom, (adr - 0x08000000))); - if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) - return T1ReadLong(MMU.MMU_MEM[0][0xFF], (adr +0x1C) & MMU.MMU_MASK[0][0xFF]); - return (u32)T1ReadLong(GBArom, (adr - 0x08000000)); -} + + fclose(fgame); +}; +void GBAgame_close(void) +{ + if (GBArom) + { + delete [] GBArom; + GBArom = NULL; + } +}; +void GBAgame_config(void) {} +void GBAgame_write08(u32 adr, u8 val){} +void GBAgame_write16(u32 adr, u16 val) {} +void GBAgame_write32(u32 adr, u32 val) {} +u8 GBAgame_read08(u32 adr) +{ + //INFO("Read08 at 0x%08X value 0x%02X\n", adr, (u8)T1ReadByte(GBArom, (adr - 0x08000000))); + if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) + return MMU.MMU_MEM[0][0xFF][(adr +0x1C) & MMU.MMU_MASK[0][0xFF]]; + return (u8)T1ReadByte(GBArom, (adr - 0x08000000)); +} +u16 GBAgame_read16(u32 adr) +{ + //INFO("Read16 at 0x%08X value 0x%04X\n", adr, (u16)T1ReadWord(GBArom, (adr - 0x08000000))); + if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) + return T1ReadWord(MMU.MMU_MEM[0][0xFF], (adr +0x1C) & MMU.MMU_MASK[0][0xFF]); + return (u16)T1ReadWord(GBArom, (adr - 0x08000000)); +} +u32 GBAgame_read32(u32 adr) +{ + //INFO("Read32 at 0x%08X value 0x%08X\n", adr, (u32)T1ReadLong(GBArom, (adr - 0x08000000))); + if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) + return T1ReadLong(MMU.MMU_MEM[0][0xFF], (adr +0x1C) & MMU.MMU_MASK[0][0xFF]); + return (u32)T1ReadLong(GBArom, (adr - 0x08000000)); +} void GBAgame_info(char *info) { strcpy(info, "GBA game in slot"); }; ADDONINTERFACE addonGBAgame = { "GBA game", - GBAgame_init, - GBAgame_reset, - GBAgame_close, - GBAgame_config, - GBAgame_write08, - GBAgame_write16, - GBAgame_write32, - GBAgame_read08, - GBAgame_read16, - GBAgame_read32, - GBAgame_info}; \ No newline at end of file + GBAgame_init, + GBAgame_reset, + GBAgame_close, + GBAgame_config, + GBAgame_write08, + GBAgame_write16, + GBAgame_write32, + GBAgame_read08, + GBAgame_read16, + GBAgame_read32, + GBAgame_info}; diff --git a/desmume/src/addons/none.cpp b/desmume/src/addons/none.cpp index f6f32456b..423a2eb1e 100644 --- a/desmume/src/addons/none.cpp +++ b/desmume/src/addons/none.cpp @@ -22,6 +22,7 @@ */ #include "../addons.h" +#include BOOL None_init(void) { return (TRUE); }; void None_reset(void) {}; diff --git a/desmume/src/addons/rumblepak.cpp b/desmume/src/addons/rumblepak.cpp index e00141687..91f53f474 100644 --- a/desmume/src/addons/rumblepak.cpp +++ b/desmume/src/addons/rumblepak.cpp @@ -24,6 +24,7 @@ #include "../addons.h" #include "../mem.h" #include "../MMU.h" +#include u8 rumble_hdr[0xC0];