diff --git a/NINTV-DS.nds b/NINTV-DS.nds index f25c0aa..998c8bc 100644 Binary files a/NINTV-DS.nds and b/NINTV-DS.nds differ diff --git a/arm9/Makefile b/arm9/Makefile index a760fee..e4baa4a 100644 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -26,7 +26,7 @@ GRAPHICS := gfx #ARCH := -mthumb -mthumb-interwork ARCH := -CFLAGS := -Ofast -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math $(ARCH) -falign-functions=16 -frename-registers +CFLAGS := -Ofast -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math $(ARCH) -falign-functions=4 -frename-registers CFLAGS += $(INCLUDE) -DARM9 CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -Wno-conversion-null diff --git a/arm9/source/debugger.cpp b/arm9/source/debugger.cpp index f3f3314..a5c431b 100644 --- a/arm9/source/debugger.cpp +++ b/arm9/source/debugger.cpp @@ -32,7 +32,7 @@ #include "AudioMixer.h" #include "printf.h" -INT32 debug[8] __attribute__((section(".dtcm"))) = {0}; +INT32 debug[DEBUG_SIZE] __attribute__((section(".dtcm"))) = {0}; int getMemUsed(void) // returns the amount of used memory in bytes { diff --git a/arm9/source/debugger.h b/arm9/source/debugger.h index f472324..3b2a95a 100644 --- a/arm9/source/debugger.h +++ b/arm9/source/debugger.h @@ -32,6 +32,7 @@ extern AY38900 *debug_stic; extern AY38914 *debug_psg; extern AY38914 *debug_psg2; +#define DEBUG_SIZE 8 extern INT32 debug[]; extern void show_debug_overlay(void); diff --git a/arm9/source/emucore/SP0256.cpp b/arm9/source/emucore/SP0256.cpp index 55726b3..2d662ab 100644 --- a/arm9/source/emucore/SP0256.cpp +++ b/arm9/source/emucore/SP0256.cpp @@ -27,7 +27,7 @@ INT32 bitsLeft __attribute__((section(".dtcm"))); INT32 currentBits __attribute__((section(".dtcm"))); UINT16 pc __attribute__((section(".dtcm"))); UINT16 stack __attribute__((section(".dtcm"))); -INT32 mode __attribute__((section(".dtcm"))); +UINT8 mode __attribute__((section(".dtcm"))); INT32 repeatPrefix __attribute__((section(".dtcm"))); UINT16 fifoBytes[64] __attribute__((section(".dtcm"))); @@ -166,8 +166,7 @@ ITCM_CODE INT32 SP0256::tick(INT32 minimum) if (periodCounter == 0) { periodCounter = 64; repeat--; - for (UINT8 j = 0; j < 6; j++) - y[j][0] = y[j][1] = 0; + memset(y, 0x00, sizeof(y)); } else periodCounter--; @@ -183,9 +182,7 @@ ITCM_CODE INT32 SP0256::tick(INT32 minimum) periodCounter = period; repeat--; sample = ((amplitude & 0x1F) << ((amplitude & 0xE0) >> 5)); - for (INT32 j = 0; j < 6; j++) - y[j][0] = y[j][1] = 0; - + memset(y, 0x00, sizeof(y)); } else periodCounter--; @@ -213,7 +210,7 @@ ITCM_CODE INT32 SP0256::tick(INT32 minimum) return totalTicks; } -INT8 SP0256::readDelta(INT32 numBits) { +ITCM_CODE INT8 SP0256::readDelta(INT32 numBits) { INT32 value = readBits(numBits); if ((value & (1 << (numBits - 1))) != 0) value |= -1 << numBits; @@ -270,7 +267,6 @@ ITCM_CODE INT32 SP0256::readBits(INT32 numBits) bitsLeft += 10; pc++; } - } INT32 output = currentBits & bitMasks[numBits-1]; @@ -800,7 +796,7 @@ void SP0256::PAUSE(INT32 immed4) { periodInterpolation = 0; } -void SP0256::decode() { +ITCM_CODE void SP0256::decode() { INT32 immed4 = readBits(4); INT32 nextInstruction = readBitsReverse(4); switch (nextInstruction) { diff --git a/arm9/source/emucore/SP0256.h b/arm9/source/emucore/SP0256.h index dabb184..1896c93 100644 --- a/arm9/source/emucore/SP0256.h +++ b/arm9/source/emucore/SP0256.h @@ -67,7 +67,7 @@ extern INT32 currentBits; //registers extern UINT16 pc; extern UINT16 stack; -extern INT32 mode; +extern UINT8 mode; extern INT32 repeatPrefix; extern INT32 command; diff --git a/arm9/source/loadgame.cpp b/arm9/source/loadgame.cpp index a8663c3..fe34262 100644 --- a/arm9/source/loadgame.cpp +++ b/arm9/source/loadgame.cpp @@ -61,7 +61,8 @@ BOOL LoadCart(const CHAR* filename) bIsFatalError = false; bGameLoaded = FALSE; - memset(debug, 0x00, 8 * (sizeof(UINT32))); + // Clear out the debug array with every new game loaded + memset(debug, 0x00, DEBUG_SIZE * (sizeof(UINT32))); // Load up the configuration based on the CRC32 of the game. Do this early since we need some of those properties to load the RIP FindAndLoadConfig(CRC32::getCrc(filename)); @@ -84,6 +85,11 @@ BOOL LoadCart(const CHAR* filename) const CHAR* extStart = filename + strlen(filename) - 4; + // ------------------------------------------------------------------------------------------------------------------------- + // A .bin is always assumed to be a flat binary file (and may or may not have a .cfg file to go with it). + // A .rom is always assumed to be a file with extra meta-data that lets us know where to load it in memory. + // A .int file can switch-hit and might be a .bin or a .rom -- we look for the signature 0xA8 byte to see if it's a .rom + // ------------------------------------------------------------------------------------------------------------------------- UINT8 bIsROM = ((strcmpi(extStart, ".rom") == 0) ? true:false); if (strcmpi(extStart, ".int") == 0) { @@ -93,7 +99,7 @@ BOOL LoadCart(const CHAR* filename) if (file == NULL) { FatalError("BIN FILE DOES NOT EXIST"); - return NULL; + return FALSE; } if (fgetc(file) == 0xA8) bIsROM = true; fclose(file); @@ -101,7 +107,7 @@ BOOL LoadCart(const CHAR* filename) if (bIsROM) { - //load the binary file as a Rip + //load the .rom file as a Rip with meta-data parsed currentRip = Rip::LoadRom(filename); if (currentRip == NULL) {