diff --git a/arm7/source/main.c b/arm7/source/main.c index 946718e..3716380 100644 --- a/arm7/source/main.c +++ b/arm7/source/main.c @@ -98,23 +98,6 @@ void fifoCheckHandler() { prepairReset(); } } - - - /*u32 fifo; - if(!(REG_IPC_FIFO_CR & IPC_FIFO_RECV_EMPTY)) { - fifo = REG_IPC_FIFO_RX; - - if(fifo == IPC_CMD_GBAMODE)gbaMode(); - if(fifo == IPC_CMD_SLOT2)prepairReset(); - if(fifo == IPC_CMD_TURNOFF) { - PM_SetControl(1<<6); - while(1); - } - if(fifo == IPC_CMD_SR_R4TF)ret_menu7_R4(); - if(fifo == IPC_CMD_SR_DLMS)LinkReset_ARM7(); - if(fifo == IPC_CMD_SR_GEN)ret_menu7_Gen(); - if(fifo == IPC_CMD_SR_MSE)ret_menu7_mse(); - }*/ } void VblankHandler(void) { diff --git a/arm9/Makefile b/arm9/Makefile index e945f2c..b047ba2 100644 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -25,7 +25,7 @@ STATICLIBS := #--------------------------------------------------------------------------------- # $(ARCH) $(INCLUDE) -DARM9 -D_LegacyCardLib ARCH := -mthumb -mthumb-interwork -march=armv5te -mtune=arm946e-s -CFLAGS := -g -Wall -O2 \ +CFLAGS := -g -Wall -Wno-format-overflow -O2 \ $(ARCH) $(INCLUDE) -DARM9 CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions ASFLAGS := -g $(ARCH) @@ -34,9 +34,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- -# LIBS := -lfat -ldswifi9 -lnds9 -# disable Wifi lib. It's not being used in this build -LIBS := -lfat -lnds329 +LIBS := -lfat -lnds9 #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing diff --git a/arm9/include/dsCard.h b/arm9/include/dsCard.h deleted file mode 100644 index b5246db..0000000 --- a/arm9/include/dsCard.h +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************************************************************** - * ´ËÎļþΪ dsCard.h ÎļþµÄµÚ¶þ°æ - * ÈÕÆÚ£º2006Äê11ÔÂ27ÈÕ11µã33·Ö µÚÒ»°æ version 1.0 - * ×÷Õߣºaladdin - * CopyRight : EZFlash Group - * - **************************************************************************************************************/ - -#ifndef NDS_DSCARD_V2_INCLUDE -#define NDS_DSCARD_V2_INCLUDE - -#include "nds.h" - - #ifdef __cplusplus - extern "C" { - #endif - -#ifndef BYTE -typedef unsigned char BYTE; -#endif - -#ifndef WORD -typedef unsigned short WORD; -#endif - -#ifndef DWORD -typedef unsigned long DWORD; -#endif - -#ifndef BOOL -typedef bool BOOL ; -#endif -// export interface - - - - -//--------------------------------------------------- -//DS ¿¨ »ù±¾²Ù×÷ - //Arm9 ·½Ãæ»ù±¾²Ù×÷ÈÝÐíARM7·ÃÎÊslot1 - void Enable_Arm7DS(void); - - //Arm9 ·½Ãæ»ù±¾²Ù×÷ÈÝÐíARM9·ÃÎÊslot1 - void Enable_Arm9DS(void); - - - //ÏÂÃæÊÇ·ÃÎÊÕ𶯿¨µÄº¯Êý -#define FlashBase 0x08000000 -#define _Ez5PsRAM 0x08000000 - void OpenNorWrite(); - void CloseNorWrite(); - void SetRompage(u16 page); - void SetRampage(u16 page); - void OpenRamWrite(); - void CloseRamWrite(); - void SetSerialMode(); - uint32 ReadNorFlashID(); - void chip_reset(); - void Block_Erase(u32 blockAdd); - void ReadNorFlash(u8* pBuf,u32 address,u16 len); - void WriteNorFlash(u32 address,u8 *buffer,u32 size); - void WriteSram(uint32 address, u8* data , uint32 size ); - void ReadSram(uint32 address, u8* data , uint32 size ); - void SetShake(u16 data); - #ifdef __cplusplus - } - #endif -#endif diff --git a/arm9/source/cache.h b/arm9/source/cache.h deleted file mode 100644 index 3871d2c..0000000 --- a/arm9/source/cache.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - cache.h - The cache is not visible to the user. It should be flushed - when any file is closed or changes are made to the filesystem. - - This cache implements a least-used-page replacement policy. This will - distribute sectors evenly over the pages, so if less than the maximum - pages are used at once, they should all eventually remain in the cache. - This also has the benefit of throwing out old sectors, so as not to keep - too many stale pages around. - - Copyright (c) 2006 Michael "Chishm" Chisholm - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - 3. The name of the author may not be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - 2006-07-11 - Chishm - * Original release -*/ - -#ifndef _CACHE_H -#define _CACHE_H - -#include "common.h" -#include "disc_io/disc_io.h" - -#define CACHE_PAGE_SIZE BYTES_PER_READ - -typedef struct { - u32 sector; - u32 count; - bool dirty; -} CACHE_ENTRY; - -typedef struct { - const IO_INTERFACE* disc; - u32 numberOfPages; - CACHE_ENTRY* cacheEntries; - u8* pages; -} CACHE; - - -/* -Read data from a sector in the cache -If the sector is not in the cache, it will be swapped in -offset is the position to start reading from -size is the amount of data to read -Precondition: offset + size <= BYTES_PER_READ -*/ -bool _FAT_cache_readPartialSector (CACHE* cache, void* buffer, u32 sector, u32 offset, u32 size); - -/* -Write data to a sector in the cache -If the sector is not in the cache, it will be swapped in. -When the sector is swapped out, the data will be written to the disc -offset is the position to start reading from -size is the amount of data to read -Precondition: offset + size <= BYTES_PER_READ -*/ -bool _FAT_cache_writePartialSector (CACHE* cache, const void* buffer, u32 sector, u32 offset, u32 size); - -/* -Write data to a sector in the cache, zeroing the sector first -If the sector is not in the cache, it will be swapped in. -When the sector is swapped out, the data will be written to the disc -offset is the position to start reading from -size is the amount of data to read -Precondition: offset + size <= BYTES_PER_READ -*/ -bool _FAT_cache_eraseWritePartialSector (CACHE* cache, const void* buffer, u32 sector, u32 offset, u32 size); - -/* -Read a full sector from the cache -*/ -static inline bool _FAT_cache_readSector (CACHE* cache, void* buffer, u32 sector) { - return _FAT_cache_readPartialSector (cache, buffer, sector, 0, BYTES_PER_READ); -} - -/* -Write a full sector to the cache -*/ -static inline bool _FAT_cache_writeSector (CACHE* cache, const void* buffer, u32 sector) { - return _FAT_cache_writePartialSector (cache, buffer, sector, 0, BYTES_PER_READ); -} - -/* -Write any dirty sectors back to disc and clear out the contents of the cache -*/ -bool _FAT_cache_flush (CACHE* cache); - -/* -Clear out the contents of the cache without writing any dirty sectors first -*/ -void _FAT_cache_invalidate (CACHE* cache); - -CACHE* _FAT_cache_constructor (u32 numberOfPages, const IO_INTERFACE* discInterface); - -void _FAT_cache_destructor (CACHE* cache); - -#endif // _CACHE_H diff --git a/arm9/source/dsCard.cpp b/arm9/source/dsCard.cpp index 9559523..c6cbe79 100644 --- a/arm9/source/dsCard.cpp +++ b/arm9/source/dsCard.cpp @@ -5,8 +5,11 @@ * CopyRight : EZFlash Group * **************************************************************************************************************/ +#include + #include "dscard.h" #include "string.h" +#include "io_sc_common.h" #ifdef __cplusplus extern "C" { @@ -28,8 +31,7 @@ void Enable_Arm7DS() WAIT_CR |= 0x0800; } *************/ -void OpenNorWrite() -{ +void OpenNorWrite() { *(vuint16 *)0x9fe0000 = 0xd200; *(vuint16 *)0x8000000 = 0x1500; *(vuint16 *)0x8020000 = 0xd200; @@ -39,8 +41,7 @@ void OpenNorWrite() } -void CloseNorWrite() -{ +void CloseNorWrite() { *(vuint16 *)0x9fe0000 = 0xd200; *(vuint16 *)0x8000000 = 0x1500; *(vuint16 *)0x8020000 = 0xd200; @@ -49,8 +50,7 @@ void CloseNorWrite() *(vuint16 *)0x9fc0000 = 0x1500; } -void SetRompage(u16 page) -{ +void SetRompage(u16 page) { *(vuint16 *)0x9fe0000 = 0xd200; *(vuint16 *)0x8000000 = 0x1500; *(vuint16 *)0x8020000 = 0xd200; @@ -58,8 +58,8 @@ void SetRompage(u16 page) *(vuint16 *)0x9880000 = page; *(vuint16 *)0x9fc0000 = 0x1500; } -void SetRampage(u16 page) -{ + +void SetRampage(u16 page) { *(vu16 *)0x9fe0000 = 0xd200; *(vu16 *)0x8000000 = 0x1500; *(vu16 *)0x8020000 = 0xd200; @@ -67,8 +67,8 @@ void SetRampage(u16 page) *(vu16 *)0x9c00000 = page; *(vu16 *)0x9fc0000 = 0x1500; } -void SetSerialMode() -{ + +void SetSerialMode() { *(vu16 *)0x9fe0000 = 0xd200; *(vu16 *)0x8000000 = 0x1500; @@ -78,235 +78,245 @@ void SetSerialMode() *(vu16 *)0x9fc0000 = 0x1500; } -uint32 ReadNorFlashID() -{ - vuint16 id1,id2; //,id3,id4; - ID=0; - *((vuint16 *)(FlashBase+0x555*2)) = 0xAA ; - *((vuint16 *)(FlashBase+0x2AA*2)) = 0x55 ; - *((vuint16 *)(FlashBase+0x555*2)) = 0x90 ; - *((vuint16 *)(FlashBase+0x1555*2)) = 0xAA ; - *((vuint16 *)(FlashBase+0x12AA*2)) = 0x55 ; - *((vuint16 *)(FlashBase+0x1555*2)) = 0x90 ; - id1 = *((vuint16 *)(FlashBase+0x2)) ; - id2 = *((vuint16 *)(FlashBase+0x2002)) ; - if( (id1!=0x227E)|| (id2!=0x227E)) - return 0; - - id1 = *((vuint16 *)(FlashBase+0xE*2)) ; - id2 = *((vuint16 *)(FlashBase+0x100e*2)) ; - if(id1==0x2218 && id2==0x2218) //H6H6 - { - ID = 0x227E2218; - return 0x227E2218; - } - - if(id1==0x2202 && id2==0x2202) //VZ064 - { - ID = 0x227E2202; - return 0x227E2202; - } - if(id1==0x2202 && id2==0x2220) //VZ064 - { - ID = 0x227E2202; - return 0x227E2202; - } - if(id1==0x2202 && id2==0x2215) //VZ064 - { - ID = 0x227E2202; - return 0x227E2202; - } - return 0x227E2220; +static bool checkForSuperCard() { + _SC_changeMode(SC_MODE_RAM); // Try again with SuperCard + // _SC_changeMode16(0x1510); + *(vu16*)(0x08000000) = 0x4D54; + if (*(vu16*)(0x08000000) == 0x4D54)return true; + return false; } -void chip_reset() -{ + +static bool checkFor3in1Plus() { + SetRompage(381); // Try again with EZ Flash + OpenNorWrite(); + *(vu16*)(0x08060000) = 0x4D54; + if (*(vu16*)(0x08060000) == 0x4D54)return true; + return false; +} + +uint32 ReadNorFlashID() { + vuint16 id1,id2; //,id3,id4; + ID = 0; + *((vuint16 *)(FlashBase+0x555*2)) = 0xAA; + *((vuint16 *)(FlashBase+0x2AA*2)) = 0x55; + *((vuint16 *)(FlashBase+0x555*2)) = 0x90; + + *((vuint16 *)(FlashBase+0x1555*2)) = 0xAA; + *((vuint16 *)(FlashBase+0x12AA*2)) = 0x55; + *((vuint16 *)(FlashBase+0x1555*2)) = 0x90; + + id1 = *((vuint16 *)(FlashBase+0x2)); + id2 = *((vuint16 *)(FlashBase+0x2002)); + + if ((id1!=0x227E) || (id2!=0x227E)) { + if (checkFor3in1Plus()) { + ID = 0x227E2202; + return 0x227E2222; + } + if (checkForSuperCard()) { + ID = 0x227E2202; + return 0x227E0000; + } + return 0; + } + + id1 = *((vuint16 *)(FlashBase+0xE*2)); + id2 = *((vuint16 *)(FlashBase+0x100e*2)); + + /*FILE *testFile = fopen("/gbacardID.bin", "wb"); + if (testFile) { + fwrite((void*)FlashBase+0xE*2, 2, 1, testFile); + fwrite((void*)FlashBase+0x100e*2, 2, 1, testFile); + fclose(testFile); + }*/ + + // H6H6 + if(id1==0x2218 && id2==0x2218) { + ID = 0x227E2218; + return 0x227E2218; + } + + // VZ064 + if(id1==0x2202 && id2==0x2202) { + ID = 0x227E2202; + return 0x227E2202; + } + // VZ064 + if(id1==0x2202 && id2==0x2220) { + ID = 0x227E2202; + return 0x227E2202; + } + // VZ064 + if(id1==0x2202 && id2==0x2215) { + ID = 0x227E2202; + return 0x227E2202; + } + // 3in1 Plus + /*if(id1==0x8916 && id2==0x8916) { + ID = 0x227E2202; + return 0x227E2222; + }*/ + return 0x227E2220; +} + +void chip_reset() { *((vu16 *)(FlashBase)) = 0xF0 ; *((vu16 *)(FlashBase+0x1000*2)) = 0xF0 ; - if(ID==0x227E2202) - { + if(ID==0x227E2202) { *((vu16 *)(FlashBase+0x1000000)) = 0xF0 ; *((vu16 *)(FlashBase+0x1000000+0x1000*2)) = 0xF0 ; } } -void Block_Erase(u32 blockAdd) -{ - vu16 page,v1,v2; - u32 Address; - u32 loop; - u32 off=0; - if( (blockAdd>=0x1000000) && (ID==0x227E2202)) - { - off=0x1000000; - *((vu16 *)(FlashBase+off+0x555*2)) = 0xF0 ; - *((vu16 *)(FlashBase+off+0x1555*2)) = 0xF0 ; - } - else - off=0; - Address=blockAdd; - *((vu16 *)(FlashBase+0x555*2)) = 0xF0 ; - *((vu16 *)(FlashBase+0x1555*2)) = 0xF0 ; - - - if( (blockAdd==0) || (blockAdd==0x1FC0000) || (blockAdd==0xFC0000) || (blockAdd==0x1000000)) - { - for(loop=0;loop<0x40000;loop+=0x8000) - { - *((vu16 *)(FlashBase+off+0x555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x2AA*2)) = 0x55 ; - *((vu16 *)(FlashBase+off+0x555*2)) = 0x80 ; - *((vu16 *)(FlashBase+off+0x555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x2AA*2)) = 0x55 ; - *((vu16 *)(FlashBase+Address+loop)) = 0x30 ; - - *((vu16 *)(FlashBase+off+0x1555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x12AA*2)) = 0x55 ; - *((vu16 *)(FlashBase+off+0x1555*2)) = 0x80 ; - *((vu16 *)(FlashBase+off+0x1555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x12AA*2)) = 0x55 ; - *((vu16 *)(FlashBase+Address+loop+0x2000)) = 0x30 ; - - *((vu16 *)(FlashBase+off+0x2555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x22AA*2)) = 0x55 ; - *((vu16 *)(FlashBase+off+0x2555*2)) = 0x80 ; - *((vu16 *)(FlashBase+off+0x2555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x22AA*2)) = 0x55 ; - *((vu16 *)(FlashBase+Address+loop+0x4000)) = 0x30 ; - - *((vu16 *)(FlashBase+off+0x3555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x32AA*2)) = 0x55 ; - *((vu16 *)(FlashBase+off+0x3555*2)) = 0x80 ; - *((vu16 *)(FlashBase+off+0x3555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x32AA*2)) = 0x55 ; - *((vu16 *)(FlashBase+Address+loop+0x6000)) = 0x30 ; - do - { - - v1 = *((vu16 *)(FlashBase+Address+loop)) ; - v2 = *((vu16 *)(FlashBase+Address+loop)) ; - }while(v1!=v2); - do - { - - v1 = *((vu16 *)(FlashBase+Address+loop+0x2000)) ; - v2 = *((vu16 *)(FlashBase+Address+loop+0x2000)) ; - }while(v1!=v2); - do - { - - v1 = *((vu16 *)(FlashBase+Address+loop+0x4000)) ; - v2 = *((vu16 *)(FlashBase+Address+loop+0x4000)) ; - }while(v1!=v2); - do - { - - v1 = *((vu16 *)(FlashBase+Address+loop+0x6000)) ; - v2 = *((vu16 *)(FlashBase+Address+loop+0x6000)) ; - }while(v1!=v2); - } - } - else - { - *((vu16 *)(FlashBase+off+0x555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x2AA*2)) = 0x55 ; - *((vu16 *)(FlashBase+off+0x555*2)) = 0x80 ; - *((vu16 *)(FlashBase+off+0x555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x2AA*2)) = 0x55; - *((vu16 *)(FlashBase+Address)) = 0x30 ; - - *((vu16 *)(FlashBase+off+0x1555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x12AA*2)) = 0x55 ; - *((vu16 *)(FlashBase+off+0x1555*2)) = 0x80 ; - *((vu16 *)(FlashBase+off+0x1555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x12AA*2)) = 0x55 ; - *((vu16 *)(FlashBase+Address+0x2000)) = 0x30 ; - - do - { - v1 = *((vu16 *)(FlashBase+Address)) ; - v2 = *((vu16 *)(FlashBase+Address)) ; - }while(v1!=v2); - do - { - v1 = *((vu16 *)(FlashBase+Address+0x2000)) ; - v2 = *((vu16 *)(FlashBase+Address+0x2000)) ; - }while(v1!=v2); - - *((vu16 *)(FlashBase+off+0x555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x2AA*2)) = 0x55 ; - *((vu16 *)(FlashBase+off+0x555*2)) = 0x80 ; - *((vu16 *)(FlashBase+off+0x555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x2AA*2)) = 0x55; - *((vu16 *)(FlashBase+Address+0x20000)) = 0x30 ; - - *((vu16 *)(FlashBase+off+0x1555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x12AA*2)) = 0x55 ; - *((vu16 *)(FlashBase+off+0x1555*2)) = 0x80 ; - *((vu16 *)(FlashBase+off+0x1555*2)) = 0xAA ; - *((vu16 *)(FlashBase+off+0x12AA*2)) = 0x55 ; - *((vu16 *)(FlashBase+Address+0x2000+0x20000)) = 0x30 ; - - do - { - v1 = *((vu16 *)(FlashBase+Address+0x20000)) ; - v2 = *((vu16 *)(FlashBase+Address+0x20000)) ; - }while(v1!=v2); - do - { - v1 = *((vu16 *)(FlashBase+Address+0x2000+0x20000)) ; - v2 = *((vu16 *)(FlashBase+Address+0x2000+0x20000)) ; - }while(v1!=v2); - } -} -void ReadNorFlash(u8* pBuf,u32 address,u16 len) -{ - vu16 *p = (vu16 *)pBuf; +void Block_Erase(u32 blockAdd) { + vu16 v1,v2; + u32 Address; u32 loop; - for(loop=0;loop=0x1000000) && (ID==0x227E2202)) { + off=0x1000000; + *((vu16 *)(FlashBase+off+0x555*2)) = 0xF0 ; + *((vu16 *)(FlashBase+off+0x1555*2)) = 0xF0 ; + } else { + off=0; + } + Address=blockAdd; + *((vu16 *)(FlashBase+0x555*2)) = 0xF0 ; + *((vu16 *)(FlashBase+0x1555*2)) = 0xF0 ; + + + if( (blockAdd==0) || (blockAdd==0x1FC0000) || (blockAdd==0xFC0000) || (blockAdd==0x1000000)) { + for(loop=0;loop<0x40000;loop+=0x8000) { + *((vu16 *)(FlashBase+off+0x555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x2AA*2)) = 0x55 ; + *((vu16 *)(FlashBase+off+0x555*2)) = 0x80 ; + *((vu16 *)(FlashBase+off+0x555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x2AA*2)) = 0x55 ; + *((vu16 *)(FlashBase+Address+loop)) = 0x30 ; + + *((vu16 *)(FlashBase+off+0x1555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x12AA*2)) = 0x55 ; + *((vu16 *)(FlashBase+off+0x1555*2)) = 0x80 ; + *((vu16 *)(FlashBase+off+0x1555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x12AA*2)) = 0x55 ; + *((vu16 *)(FlashBase+Address+loop+0x2000)) = 0x30 ; + + *((vu16 *)(FlashBase+off+0x2555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x22AA*2)) = 0x55 ; + *((vu16 *)(FlashBase+off+0x2555*2)) = 0x80 ; + *((vu16 *)(FlashBase+off+0x2555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x22AA*2)) = 0x55 ; + *((vu16 *)(FlashBase+Address+loop+0x4000)) = 0x30 ; + + *((vu16 *)(FlashBase+off+0x3555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x32AA*2)) = 0x55 ; + *((vu16 *)(FlashBase+off+0x3555*2)) = 0x80 ; + *((vu16 *)(FlashBase+off+0x3555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x32AA*2)) = 0x55 ; + *((vu16 *)(FlashBase+Address+loop+0x6000)) = 0x30 ; + do { + v1 = *((vu16 *)(FlashBase+Address+loop)) ; + v2 = *((vu16 *)(FlashBase+Address+loop)) ; + } while(v1!=v2); + do { + v1 = *((vu16 *)(FlashBase+Address+loop+0x2000)) ; + v2 = *((vu16 *)(FlashBase+Address+loop+0x2000)) ; + } while(v1!=v2); + do { + v1 = *((vu16 *)(FlashBase+Address+loop+0x4000)) ; + v2 = *((vu16 *)(FlashBase+Address+loop+0x4000)) ; + } while(v1!=v2); + do { + v1 = *((vu16 *)(FlashBase+Address+loop+0x6000)) ; + v2 = *((vu16 *)(FlashBase+Address+loop+0x6000)) ; + } while(v1!=v2); + } + } else { + *((vu16 *)(FlashBase+off+0x555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x2AA*2)) = 0x55 ; + *((vu16 *)(FlashBase+off+0x555*2)) = 0x80 ; + *((vu16 *)(FlashBase+off+0x555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x2AA*2)) = 0x55; + *((vu16 *)(FlashBase+Address)) = 0x30 ; + + *((vu16 *)(FlashBase+off+0x1555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x12AA*2)) = 0x55 ; + *((vu16 *)(FlashBase+off+0x1555*2)) = 0x80 ; + *((vu16 *)(FlashBase+off+0x1555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x12AA*2)) = 0x55 ; + *((vu16 *)(FlashBase+Address+0x2000)) = 0x30 ; + + do { + v1 = *((vu16 *)(FlashBase+Address)) ; + v2 = *((vu16 *)(FlashBase+Address)) ; + } while(v1!=v2); + do { + v1 = *((vu16 *)(FlashBase+Address+0x2000)) ; + v2 = *((vu16 *)(FlashBase+Address+0x2000)) ; + } while(v1!=v2); + + *((vu16 *)(FlashBase+off+0x555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x2AA*2)) = 0x55 ; + *((vu16 *)(FlashBase+off+0x555*2)) = 0x80 ; + *((vu16 *)(FlashBase+off+0x555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x2AA*2)) = 0x55; + *((vu16 *)(FlashBase+Address+0x20000)) = 0x30 ; + + *((vu16 *)(FlashBase+off+0x1555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x12AA*2)) = 0x55 ; + *((vu16 *)(FlashBase+off+0x1555*2)) = 0x80 ; + *((vu16 *)(FlashBase+off+0x1555*2)) = 0xAA ; + *((vu16 *)(FlashBase+off+0x12AA*2)) = 0x55 ; + *((vu16 *)(FlashBase+Address+0x2000+0x20000)) = 0x30 ; + + do { + v1 = *((vu16 *)(FlashBase+Address+0x20000)) ; + v2 = *((vu16 *)(FlashBase+Address+0x20000)) ; + } while(v1!=v2); + do { + v1 = *((vu16 *)(FlashBase+Address+0x2000+0x20000)) ; + v2 = *((vu16 *)(FlashBase+Address+0x2000+0x20000)) ; + } while(v1!=v2); + } } -void WriteNorFlash(u32 address,u8 *buffer,u32 size) -{ +void ReadNorFlash(u8* pBuf,u32 address,u16 len) { + vu16 *p = (vu16 *)pBuf; + u32 loop; + for(loop=0;loop=0x1000000) && (ID==0x227E2202)) - { + if( (address>=0x1000000) && (ID==0x227E2202)) { off=0x1000000; - } - else + } else{ off=0; - if(size>0x4000) - { + } + if(size>0x4000) { size2 = size >>1 ; lop = 2; - } - else - { + } else { size2 = size ; lop = 1; } mapaddress = address; - for(j=0;j>2);loopwrite++) - { + for(loopwrite=0;loopwrite<(size2>>2);loopwrite++) { *((vu16 *)(FlashBase+off+0x555*2)) = 0xAA ; *((vu16 *)(FlashBase+off+0x2AA*2)) = 0x55 ; *((vu16 *)(FlashBase+off+0x555*2)) = 0xA0 ; @@ -316,31 +326,27 @@ void WriteNorFlash(u32 address,u8 *buffer,u32 size) *((vu16 *)(FlashBase+off+0x12AA*2)) = 0x55 ; *((vu16 *)(FlashBase+off+0x1555*2)) = 0xA0 ; *((vu16 *)(FlashBase+mapaddress+0x2000+loopwrite*2)) = buf[0x1000+loopwrite]; - do - { + do { v1 = *((vu16 *)(FlashBase+mapaddress+loopwrite*2)) ; v2 = *((vu16 *)(FlashBase+mapaddress+loopwrite*2)) ; - }while(v1!=v2); - do - { + } while(v1!=v2); + do { v1 = *((vu16 *)(FlashBase+mapaddress+0x2000+loopwrite*2)) ; v2 = *((vu16 *)(FlashBase+mapaddress+0x2000+loopwrite*2)) ; - }while(v1!=v2); + } while(v1!=v2); } } } -void WriteSram(uint32 address, u8* data , uint32 size ) -{ + +void WriteSram(uint32 address, u8* data , uint32 size ) { uint32 i ; - for(i=0;i 1) + if(PatchCnt > 1) { oldtype = PatchType[PatchCnt-1]/0x10; - else oldtype = 0; + } else { + oldtype = 0; + } i = ofs; for(ii = 0; ii < bufsize / 4; ii++) { ii = _type_chk(pbuf, ii, i); - if(SaveType == 8) break; + if(SaveType == 8)break; if(oldtype == 0 || oldtype == 2) { ii = _eeprom_chk(pbuf, ii, i, size); @@ -844,21 +836,18 @@ u32 gba_check_Ram1(u8 *buf, u32 bufsize, u32 size, u32 ofs) } -static void _ReadPSram(uint32 address, u8* data , uint32 size ) -{ +static void _ReadPSram(uint32 address, u8* data , uint32 size ) { u32 i; u16* pData = (u16*)data; u16* sData = (u16*)address; - for(i = 0; i < size / 2; i++) - pData[i] = sData[i]; + for(i = 0; i < size / 2; i++)pData[i] = sData[i]; } -void gba_check_Ram2(u32 exp, u8 *buf, u32 bufsize, u32 size) -{ +void gba_check_Ram2(u32 exp, u8 *buf, u32 bufsize, u32 size) { u32 i, ii; u32 *pbuf; - int cnt; + // int cnt; if(SaveType == 0) { // UNKNOWN Famicom Mini @@ -875,8 +864,7 @@ void gba_check_Ram2(u32 exp, u8 *buf, u32 bufsize, u32 size) PatchCnt++; } - if(SaveType < 2 || PatchCnt <= 1 || SaveType == PatchType[1]/0x10) - return; + if(SaveType < 2 || PatchCnt <= 1 || SaveType == PatchType[1]/0x10)return; pbuf = (u32*)buf; PatchCnt = 1; @@ -884,7 +872,7 @@ void gba_check_Ram2(u32 exp, u8 *buf, u32 bufsize, u32 size) _ReadPSram(exp, buf, bufsize+0x400); // dmaCopy((void *)exp, buf, bufsize); // dmaCopyWords(3, buf, (void *)exp, 0x100000); - cnt = PatchCnt; + // cnt = PatchCnt; for(ii = 0; ii < bufsize / 4; ii++) { if(SaveType == 2) { ii = _eeprom_chk(pbuf, ii, i, size); @@ -908,12 +896,11 @@ void gba_check_Ram2(u32 exp, u8 *buf, u32 bufsize, u32 size) } -u32 gba_check(FILE *gbaFile, u32 size, u8 *buf, u32 bufsize) -{ +u32 gba_check(FILE *gbaFile, u32 size, u8 *buf, u32 bufsize) { u32 i, ii; u32 *pbuf; u32 oldtype; - int cnt; + // int cnt; // if(SaveType != 0) @@ -1006,7 +993,7 @@ u32 gba_check(FILE *gbaFile, u32 size, u8 *buf, u32 bufsize) dsp_bar(3, i * 100 / size); - cnt = PatchCnt; + // cnt = PatchCnt; for(ii = 0; ii < bufsize / 4; ii++) { if(SaveType == 2) { ii = _eeprom_chk(pbuf, ii, i, size); @@ -1374,9 +1361,7 @@ static const u8 patch_flash1M_6E2[] = { }; static u8 patch_flash1M_6M[] = { - 0x00, 0xB5, 0x00, 0x20, 0x02, 0xBC, 0x08, 0x47, 0x04, 0x30, 0x08, 0x22, 0x12, 0x06, 0x13, 0x88, 0x8E, 0x21, 0x09, 0x05, 0x4B, 0x88, 0xD3, 0x89, 0x12, 0x49, 0x8B, 0x8B, 0x12, 0x49, 0x4B, 0x89, 0x12, 0x49, 0x4B, 0x8A, 0x13, 0x88, 0x12, 0x49, 0xCB, 0x88, 0x41, 0x01, 0x89, 0x18, 0x0B, 0x88, 0x10, 0x49, 0xCB, 0x89, 0x13, 0x88, 0x09, 0x22, 0x12, 0x06, 0x13, 0x88, 0x0E, 0x49, 0x0B, 0x88, 0x8B, 0x89, 0x8B, 0x89, 0x8B, 0x89, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x0A, 0x1C, 0x96, 0x3A, 0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 0x98, 0x22, 0x12, 0x05, 0x40, 0x04, 0x80, 0x18, 0x03, 0x88, 0x0B, 0x89, 0x70, 0x47, 0xE0, 0x1F, 0x80, 0x08, 0x40, 0x10, 0x00, 0x08, 0x00, 0x06, 0x80, 0x08, 0x60, 0x1B, 0x80, 0x08, 0x00, 0x08, 0x00, 0x08, 0xE0, 0xFF, 0xFF, 0x09 - }; static const u8 patch_flash1M_7[] = { @@ -1459,9 +1444,7 @@ static const u8 patch_flash1M_8E[] = { }; static u8 patch_flash1M_8M[] = { - 0x38, 0xB5, 0x04, 0x06, 0x20, 0x0F, 0x24, 0x01, 0x24, 0x0C, 0x64, 0x18, 0x15, 0x1C, 0x04, 0x30, 0x08, 0x22, 0x12, 0x06, 0x13, 0x88, 0x8E, 0x21, 0x09, 0x05, 0x4B, 0x88, 0xD3, 0x89, 0x16, 0x49, 0x8B, 0x8B, 0x16, 0x49, 0x4B, 0x89, 0x16, 0x49, 0x4B, 0x8A, 0x13, 0x88, 0x15, 0x49, 0xCB, 0x88, 0x41, 0x01, 0x89, 0x18, 0x0B, 0x88, 0x14, 0x49, 0xCB, 0x89, 0x13, 0x88, 0x09, 0x22, 0x12, 0x06, 0x13, 0x88, 0x12, 0x49, 0x0B, 0x88, 0x8B, 0x89, 0x8B, 0x89, 0x8B, 0x89, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x0A, 0x1C, 0x96, 0x3A, 0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 0x98, 0x22, 0x12, 0x05, 0x40, 0x04, 0x80, 0x18, 0x03, 0x88, 0x0B, 0x89, 0x0E, 0x21, 0x09, 0x06, 0x09, 0x19, 0x0D, 0x70, 0x00, 0x20, 0x38, 0xBC, 0x02, 0xBC, 0x08, 0x47, 0xE0, 0x1F, 0x80, 0x08, 0x40, 0x10, 0x00, 0x08, 0x00, 0x06, 0x80, 0x08, 0x60, 0x1B, 0x80, 0x08, 0x00, 0x08, 0x00, 0x08, 0xE0, 0xFF, 0xFF, 0x09 - }; static u8 patch_flash1M_9[] = { @@ -1548,9 +1531,7 @@ static const u8 patch_flash1M_9E[] = { }; static u8 patch_flash1M_9M[] = { - 0x3C, 0xB5, 0x04, 0x06, 0x20, 0x0F, 0x24, 0x01, 0x24, 0x0C, 0x0D, 0x1C, 0x04, 0x30, 0x08, 0x22, 0x12, 0x06, 0x13, 0x88, 0x8E, 0x21, 0x09, 0x05, 0x4B, 0x88, 0xD3, 0x89, 0x1A, 0x49, 0x8B, 0x8B, 0x1A, 0x49, 0x4B, 0x89, 0x1A, 0x49, 0x4B, 0x8A, 0x13, 0x88, 0x1A, 0x49, 0xCB, 0x88, 0x41, 0x01, 0x89, 0x18, 0x0B, 0x88, 0x18, 0x49, 0xCB, 0x89, 0x13, 0x88, 0x09, 0x22, 0x12, 0x06, 0x13, 0x88, 0x16, 0x49, 0x0B, 0x88, 0x8B, 0x89, 0x8B, 0x89, 0x8B, 0x89, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x0A, 0x1C, 0x96, 0x3A, 0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 0x98, 0x22, 0x12, 0x05, 0x40, 0x04, 0x80, 0x18, 0x03, 0x88, 0x0B, 0x89, 0x0E, 0x21, 0x09, 0x06, 0x09, 0x19, 0x01, 0x23, 0x1B, 0x03, 0x28, 0x78, 0x08, 0x70, 0x01, 0x3B, 0x01, 0x35, 0x01, 0x31, 0x00, 0x2B, 0xF8, 0xD1, 0x00, 0x20, 0x3C, 0xBC, 0x02, 0xBC, 0x08, 0x47, 0x00, 0x00, 0xE0, 0x1F, 0x80, 0x08, 0x40, 0x10, 0x00, 0x08, 0x00, 0x06, 0x80, 0x08, 0x60, 0x1B, 0x80, 0x08, 0x00, 0x08, 0x00, 0x08, 0xE0, 0xFF, 0xFF, 0x09 - }; @@ -1691,8 +1672,7 @@ static const u8 patch_flash_6[] = { }; -static void _patch_ram(u8 *buf, u32 ofs, const u8 *data, u32 size) -{ +static void _patch_ram(u8 *buf, u32 ofs, const u8 *data, u32 size) { u16 *pbuf; u16 *pdata; u32 i; @@ -1700,18 +1680,13 @@ static void _patch_ram(u8 *buf, u32 ofs, const u8 *data, u32 size) pbuf = (u16*)buf; pdata = (u16*)data; - for(i = 0; i < size/2; i++, ofs++) { - pbuf[ofs] = pdata[i]; - } + for(i = 0; i < size/2; i++, ofs++)pbuf[ofs] = pdata[i]; } -static void _patch(u8 *buf, u32 ofs, const u8 *data, u32 size, u32 bend) -{ +static void _patch(u8 *buf, u32 ofs, const u8 *data, u32 size, u32 bend) { u32 i; - for(i = 0; i < size && ofs < bend; i++, ofs++) { - buf[ofs] = data[i]; - } + for(i = 0; i < size && ofs < bend; i++, ofs++)buf[ofs] = data[i]; if(i < size) { RemainPtr = (u8*)data + i; @@ -1720,12 +1695,10 @@ static void _patch(u8 *buf, u32 ofs, const u8 *data, u32 size, u32 bend) RemainPtr = 0; RemainByte = 0; } - } -static void _patch_write(char *name) -{ +static void _patch_write(char *name) { FILE *sign; u8 buf[512]; int i; @@ -1739,8 +1712,7 @@ static void _patch_write(char *name) return; } - if(PatchVer == PATCH_VER) - return; + if(PatchVer == PATCH_VER)return; PatchVer = PATCH_VER; if(SaveType == 0) { @@ -1750,15 +1722,14 @@ static void _patch_write(char *name) } sign = fopen((char *)buf, "wb"); - if(sign == NULL) return; + if(sign == NULL)return; memset(buf, 0x00, 256); *((u32*)(buf + 0)) = PatchVer; *((u32*)(buf + 4)) = PatchCnt; *((u32*)(buf + 8)) = SaveType; *((u32*)(buf + 12)) = SaveSize; - for(i = 0; i < 16; i++) - buf[i + 16] = SaveVer[i]; + for(i = 0; i < 16; i++)buf[i + 16] = SaveVer[i]; for(i = 0; i < PatchCnt; i++) { *((u32*)(buf + 32 + i * 8)) = PatchType[i]; *((u32*)(buf + 36 + i * 8)) = PatchAddr[i]; @@ -1769,8 +1740,7 @@ static void _patch_write(char *name) } -void gba_patch_Ram(u32 exp, char *name, int cart) -{ +void gba_patch_Ram(u32 exp, char *name, int cart) { u8 *buf; int i, j; u32 ofs = 0; @@ -1780,11 +1750,10 @@ void gba_patch_Ram(u32 exp, char *name, int cart) _patch_write(name); - if(SaveType < 2) return; + if(SaveType < 2)return; - if(SaveType == 5 && cart == 6) - return; + if(SaveType == 5 && cart == 6)return; // buf = (u8*)exp; @@ -1794,14 +1763,10 @@ void gba_patch_Ram(u32 exp, char *name, int cart) buf = (u8*)(exp + PatchAddr[i]); switch(SaveType) { case 2: // EEPROM - if(PatchType[i] == 0x21) - _patch_ram(buf, ofs, patch_eeprom_1, sizeof(patch_eeprom_1)); - if(PatchType[i] == 0x22) - _patch_ram(buf, ofs, patch_eeprom_2, sizeof(patch_eeprom_2)); - if(PatchType[i] == 0x23) - _patch_ram(buf, ofs, patch_eeprom_2, sizeof(patch_eeprom_2)); - if(PatchType[i] == 0x24) - _patch_ram(buf, ofs, patch_eeprom_2, sizeof(patch_eeprom_2)); + if(PatchType[i] == 0x21)_patch_ram(buf, ofs, patch_eeprom_1, sizeof(patch_eeprom_1)); + if(PatchType[i] == 0x22)_patch_ram(buf, ofs, patch_eeprom_2, sizeof(patch_eeprom_2)); + if(PatchType[i] == 0x23)_patch_ram(buf, ofs, patch_eeprom_2, sizeof(patch_eeprom_2)); + if(PatchType[i] == 0x24)_patch_ram(buf, ofs, patch_eeprom_2, sizeof(patch_eeprom_2)); if(PatchType[i] == 0x25) { paddr = 0x08000001 + PatchAddr[i+2]; patch_eeprom111_1[4] = (u8)(paddr & 0xFF); @@ -1811,86 +1776,74 @@ void gba_patch_Ram(u32 exp, char *name, int cart) // *((u32*)(patch_eeprom111_1 + 4)) = 0x08000001 + PatchAddr[i+2]; _patch_ram(buf, ofs, patch_eeprom111_1, sizeof(patch_eeprom111_1)); } - if(PatchType[i] == 0x26) - _patch_ram(buf, ofs, patch_eeprom111_2, sizeof(patch_eeprom111_2)); - if(PatchType[i] == 0x27) - _patch_ram(buf, ofs, patch_eeprom111_3, sizeof(patch_eeprom111_3)); + if(PatchType[i] == 0x26)_patch_ram(buf, ofs, patch_eeprom111_2, sizeof(patch_eeprom111_2)); + if(PatchType[i] == 0x27)_patch_ram(buf, ofs, patch_eeprom111_3, sizeof(patch_eeprom111_3)); break; case 3: // FLASH512_V - if(PatchType[i] == 0x31) - _patch_ram(buf, ofs, patch_flash_5, sizeof(patch_flash_5)); - if(PatchType[i] == 0x32) - _patch_ram(buf, ofs, patch_flash_3, sizeof(patch_flash_3)); - if(PatchType[i] == 0x33) - _patch_ram(buf, ofs, patch_flash_2, sizeof(patch_flash_2)); - if(PatchType[i] == 0x34) - _patch_ram(buf, ofs, patch_flash_2, sizeof(patch_flash_2)); - if(PatchType[i] == 0x35) - _patch_ram(buf, ofs, patch_flash_6, sizeof(patch_flash_6)); + if(PatchType[i] == 0x31)_patch_ram(buf, ofs, patch_flash_5, sizeof(patch_flash_5)); + if(PatchType[i] == 0x32)_patch_ram(buf, ofs, patch_flash_3, sizeof(patch_flash_3)); + if(PatchType[i] == 0x33)_patch_ram(buf, ofs, patch_flash_2, sizeof(patch_flash_2)); + if(PatchType[i] == 0x34)_patch_ram(buf, ofs, patch_flash_2, sizeof(patch_flash_2)); + if(PatchType[i] == 0x35)_patch_ram(buf, ofs, patch_flash_6, sizeof(patch_flash_6)); break; case 4: // FLASH_V - if(PatchType[i] == 0x41) - _patch_ram(buf, ofs, patch_flash120_1, sizeof(patch_flash120_1)); - if(PatchType[i] == 0x42) - _patch_ram(buf, ofs, patch_flash_1, sizeof(patch_flash_1)); - if(PatchType[i] == 0x43) - _patch_ram(buf, ofs, patch_flash_2, sizeof(patch_flash_2)); + if(PatchType[i] == 0x41)_patch_ram(buf, ofs, patch_flash120_1, sizeof(patch_flash120_1)); + if(PatchType[i] == 0x42)_patch_ram(buf, ofs, patch_flash_1, sizeof(patch_flash_1)); + if(PatchType[i] == 0x43)_patch_ram(buf, ofs, patch_flash_2, sizeof(patch_flash_2)); if(PatchType[i] == 0x44) { - if(PatchType[1] == 0x41) + if(PatchType[1] == 0x41) { _patch_ram(buf, ofs, patch_flash120_2, sizeof(patch_flash120_2)); - else _patch_ram(buf, ofs, patch_flash_2, sizeof(patch_flash_2)); + } else { + _patch_ram(buf, ofs, patch_flash_2, sizeof(patch_flash_2)); + } } if(PatchType[i] == 0x45) { - if(PatchType[1] == 0x41) + if(PatchType[1] == 0x41) { _patch_ram(buf, ofs, patch_flash120_3, sizeof(patch_flash120_3)); - else _patch_ram(buf, ofs, patch_flash_4, sizeof(patch_flash_4)); + } else { + _patch_ram(buf, ofs, patch_flash_4, sizeof(patch_flash_4)); + } } - if(PatchType[i] == 0x46) - _patch_ram(buf, ofs, patch_flash_3, sizeof(patch_flash_3)); - if(PatchType[i] == 0x47) - _patch_ram(buf, ofs, patch_flash_5, sizeof(patch_flash_5)); - if(PatchType[i] == 0x48) - _patch_ram(buf, ofs, patch_flash_2, sizeof(patch_flash_2)); - if(PatchType[i] == 0x49) - _patch_ram(buf, ofs, patch_flash_2, sizeof(patch_flash_2)); - if(PatchType[i] == 0x4A) - _patch_ram(buf, ofs, patch_flash_6, sizeof(patch_flash_6)); + if(PatchType[i] == 0x46)_patch_ram(buf, ofs, patch_flash_3, sizeof(patch_flash_3)); + if(PatchType[i] == 0x47)_patch_ram(buf, ofs, patch_flash_5, sizeof(patch_flash_5)); + if(PatchType[i] == 0x48)_patch_ram(buf, ofs, patch_flash_2, sizeof(patch_flash_2)); + if(PatchType[i] == 0x49)_patch_ram(buf, ofs, patch_flash_2, sizeof(patch_flash_2)); + if(PatchType[i] == 0x4A)_patch_ram(buf, ofs, patch_flash_6, sizeof(patch_flash_6)); break; case 5: // FLASH1M_V if(PatchType[i] == 0x51) { for(j = i + 1; j < PatchCnt; j++) { // if(PatchType[j] == 0x56) // savel = PatchAddr[j]; - if(PatchType[j] == 0x58) - break; + if(PatchType[j] == 0x58)break; } - if(j < PatchCnt) V102 = false; - if((cart == 4 || cart == 5) && V102) { // EWIN V102 + if (j < PatchCnt)V102 = false; + if ((cart == 4 || cart == 5) && V102) { // EWIN V102 _patch_ram(buf, ofs, patch_flash1M_1E, sizeof(patch_flash1M_1E)); break; } // *((u16*)(patch_flash1M_1 + 4)) = (u16)(0xF800 + ((savel + 2 - PatchAddr[i]) / 2)); - if(V102) + if(V102) { patch_flash1M_1[4] = 0x55; // V102 - else patch_flash1M_1[4] = 0x5B; // V103 + } else { + patch_flash1M_1[4] = 0x5B; // V103 + } _patch_ram(buf, ofs, patch_flash1M_1, sizeof(patch_flash1M_1)); } - if(PatchType[i] == 0x52) // V103 - _patch_ram(buf, ofs, patch_flash1M_2, sizeof(patch_flash1M_2)); - if(PatchType[i] == 0x53) // V103 - _patch_ram(buf, ofs, patch_flash1M_3, sizeof(patch_flash1M_3)); - if(PatchType[i] == 0x5A) // V102 - _patch_ram(buf, ofs, patch_flash1M_3E, sizeof(patch_flash1M_3E)); + if(PatchType[i] == 0x52)_patch_ram(buf, ofs, patch_flash1M_2, sizeof(patch_flash1M_2)); // V103 + if(PatchType[i] == 0x53)_patch_ram(buf, ofs, patch_flash1M_3, sizeof(patch_flash1M_3)); // V103 + if(PatchType[i] == 0x5A)_patch_ram(buf, ofs, patch_flash1M_3E, sizeof(patch_flash1M_3E)); // V102 if(PatchType[i] == 0x54) { - if((cart == 4 || cart == 5) && V102) - break; + if((cart == 4 || cart == 5) && V102)break; _patch_ram(buf, ofs, patch_flash1M_4, sizeof(patch_flash1M_4)); } if(PatchType[i] == 0x55) { - if((cart == 4 || cart == 5) && V102) + if((cart == 4 || cart == 5) && V102) { _patch_ram(buf, ofs, patch_flash1M_5E, sizeof(patch_flash1M_5E)); - else _patch_ram(buf, ofs, patch_flash1M_5, sizeof(patch_flash1M_5)); + } else { + _patch_ram(buf, ofs, patch_flash1M_5, sizeof(patch_flash1M_5)); + } } if(PatchType[i] == 0x56) { if(cart == 6) { @@ -1898,19 +1851,23 @@ void gba_patch_Ram(u32 exp, char *name, int cart) break; } if(cart == 4 || cart == 5) { - if(V102) + if(V102) { _patch_ram(buf, ofs, patch_flash1M_6E2, sizeof(patch_flash1M_6E2)); - else _patch_ram(buf, ofs, patch_flash1M_6E, sizeof(patch_flash1M_6E)); + } else { + _patch_ram(buf, ofs, patch_flash1M_6E, sizeof(patch_flash1M_6E)); + } } else { - if(cart != 3) + if(cart != 3) { patch_flash1M_6[38] = 0x32; - else patch_flash1M_6[38] = 0x10; + } else { + patch_flash1M_6[38] = 0x10; + } _patch_ram(buf, ofs, patch_flash1M_6, sizeof(patch_flash1M_6)); } } if(PatchType[i] == 0x57) { // V102 // if(V102) - _patch_ram(buf, ofs, patch_flash1M_7, sizeof(patch_flash1M_7)); + _patch_ram(buf, ofs, patch_flash1M_7, sizeof(patch_flash1M_7)); } if(PatchType[i] == 0x58) { if(cart == 6) { @@ -1921,9 +1878,11 @@ void gba_patch_Ram(u32 exp, char *name, int cart) if(V102) break; _patch_ram(buf, ofs, patch_flash1M_8E, sizeof(patch_flash1M_8E)); } else { - if(cart != 3) + if(cart != 3) { patch_flash1M_8[46] = 0x32; - else patch_flash1M_8[46] = 0x10; + } else { + patch_flash1M_8[46] = 0x10; + } _patch_ram(buf, ofs, patch_flash1M_8, sizeof(patch_flash1M_8)); } } @@ -1936,9 +1895,11 @@ void gba_patch_Ram(u32 exp, char *name, int cart) if(V102) break; _patch_ram(buf, ofs, patch_flash1M_9E, sizeof(patch_flash1M_9E)); } else { - if(cart != 3) + if(cart != 3) { patch_flash1M_9[50] = 0x32; - else patch_flash1M_9[50] = 0x10; + } else { + patch_flash1M_9[50] = 0x10; + } _patch_ram(buf, ofs, patch_flash1M_9, sizeof(patch_flash1M_9)); } } @@ -2001,32 +1962,29 @@ void gba_patch_Ram(u32 exp, char *name, int cart) } *************/ if(PatchType[i] == 0x86) { - if(fmini == 124) + if(fmini == 124) { _patch_ram(buf, ofs, patch_fmini_5, sizeof(patch_fmini_5)); - else _patch_ram(buf, ofs, patch_fmini_6, sizeof(patch_fmini_6)); + } else { + _patch_ram(buf, ofs, patch_fmini_6, sizeof(patch_fmini_6)); + } } break; } } - } - -void gba_patch(u8 *buf, u32 add, u32 bufsize, int GBAmode, char *name) -{ +void gba_patch(u8 *buf, u32 add, u32 bufsize, int GBAmode, char *name) { int i, j; u32 ofs; u32 paddr; int fmini; - if(add == 0) - _patch_write(name); + if(add == 0)_patch_write(name); - if(SaveType < 2) return; + if(SaveType < 2)return; - if(RemainByte != 0) - _patch(buf, 0, RemainPtr, RemainByte, bufsize); + if(RemainByte != 0)_patch(buf, 0, RemainPtr, RemainByte, bufsize); fmini = 124; @@ -2037,14 +1995,10 @@ void gba_patch(u8 *buf, u32 add, u32 bufsize, int GBAmode, char *name) ofs = PatchAddr[i] - add; switch(SaveType) { case 2: // EEPROM - if(PatchType[i] == 0x21) - _patch(buf, ofs, patch_eeprom_1, sizeof(patch_eeprom_1), bufsize); - if(PatchType[i] == 0x22) - _patch(buf, ofs, patch_eeprom_2, sizeof(patch_eeprom_2), bufsize); - if(PatchType[i] == 0x23) - _patch(buf, ofs, patch_eeprom_2, sizeof(patch_eeprom_2), bufsize); - if(PatchType[i] == 0x24) - _patch(buf, ofs, patch_eeprom_2, sizeof(patch_eeprom_2), bufsize); + if(PatchType[i] == 0x21)_patch(buf, ofs, patch_eeprom_1, sizeof(patch_eeprom_1), bufsize); + if(PatchType[i] == 0x22)_patch(buf, ofs, patch_eeprom_2, sizeof(patch_eeprom_2), bufsize); + if(PatchType[i] == 0x23)_patch(buf, ofs, patch_eeprom_2, sizeof(patch_eeprom_2), bufsize); + if(PatchType[i] == 0x24)_patch(buf, ofs, patch_eeprom_2, sizeof(patch_eeprom_2), bufsize); if(PatchType[i] == 0x25) { paddr = 0x08000001 + PatchAddr[i+2]; patch_eeprom111_1[4] = (u8)(paddr & 0xFF); @@ -2053,89 +2007,79 @@ void gba_patch(u8 *buf, u32 add, u32 bufsize, int GBAmode, char *name) patch_eeprom111_1[7] = (u8)((paddr >> 24) & 0xFF); _patch(buf, ofs, patch_eeprom111_1, sizeof(patch_eeprom111_1), bufsize); } - if(PatchType[i] == 0x26) - _patch(buf, ofs, patch_eeprom111_2, sizeof(patch_eeprom111_2), bufsize); - if(PatchType[i] == 0x27) - _patch(buf, ofs, patch_eeprom111_3, sizeof(patch_eeprom111_3), bufsize); + if(PatchType[i] == 0x26)_patch(buf, ofs, patch_eeprom111_2, sizeof(patch_eeprom111_2), bufsize); + if(PatchType[i] == 0x27)_patch(buf, ofs, patch_eeprom111_3, sizeof(patch_eeprom111_3), bufsize); break; case 3: // FLASH512_V - if(PatchType[i] == 0x31) - _patch(buf, ofs, patch_flash_5, sizeof(patch_flash_5), bufsize); - if(PatchType[i] == 0x32) - _patch(buf, ofs, patch_flash_3, sizeof(patch_flash_3), bufsize); - if(PatchType[i] == 0x33) - _patch(buf, ofs, patch_flash_2, sizeof(patch_flash_2), bufsize); - if(PatchType[i] == 0x34) - _patch(buf, ofs, patch_flash_2, sizeof(patch_flash_2), bufsize); - if(PatchType[i] == 0x35) - _patch(buf, ofs, patch_flash_6, sizeof(patch_flash_6), bufsize); + if(PatchType[i] == 0x31)_patch(buf, ofs, patch_flash_5, sizeof(patch_flash_5), bufsize); + if(PatchType[i] == 0x32)_patch(buf, ofs, patch_flash_3, sizeof(patch_flash_3), bufsize); + if(PatchType[i] == 0x33)_patch(buf, ofs, patch_flash_2, sizeof(patch_flash_2), bufsize); + if(PatchType[i] == 0x34)_patch(buf, ofs, patch_flash_2, sizeof(patch_flash_2), bufsize); + if(PatchType[i] == 0x35)_patch(buf, ofs, patch_flash_6, sizeof(patch_flash_6), bufsize); break; case 4: // FLASH_V - if(PatchType[i] == 0x41) - _patch(buf, ofs, patch_flash120_1, sizeof(patch_flash120_1), bufsize); - if(PatchType[i] == 0x42) - _patch(buf, ofs, patch_flash_1, sizeof(patch_flash_1), bufsize); - if(PatchType[i] == 0x43) - _patch(buf, ofs, patch_flash_2, sizeof(patch_flash_2), bufsize); + if(PatchType[i] == 0x41)_patch(buf, ofs, patch_flash120_1, sizeof(patch_flash120_1), bufsize); + if(PatchType[i] == 0x42)_patch(buf, ofs, patch_flash_1, sizeof(patch_flash_1), bufsize); + if(PatchType[i] == 0x43)_patch(buf, ofs, patch_flash_2, sizeof(patch_flash_2), bufsize); if(PatchType[i] == 0x44) { - if(PatchType[1] == 0x41) + if(PatchType[1] == 0x41) { _patch(buf, ofs, patch_flash120_2, sizeof(patch_flash120_2), bufsize); - else _patch(buf, ofs, patch_flash_2, sizeof(patch_flash_2), bufsize); + } else { + _patch(buf, ofs, patch_flash_2, sizeof(patch_flash_2), bufsize); + } } if(PatchType[i] == 0x45) { - if(PatchType[1] == 0x41) + if(PatchType[1] == 0x41) { _patch(buf, ofs, patch_flash120_3, sizeof(patch_flash120_3), bufsize); - else _patch(buf, ofs, patch_flash_4, sizeof(patch_flash_4), bufsize); + } else { + _patch(buf, ofs, patch_flash_4, sizeof(patch_flash_4), bufsize); + } } - if(PatchType[i] == 0x46) - _patch(buf, ofs, patch_flash_3, sizeof(patch_flash_3), bufsize); - if(PatchType[i] == 0x47) - _patch(buf, ofs, patch_flash_5, sizeof(patch_flash_5), bufsize); - if(PatchType[i] == 0x48) - _patch(buf, ofs, patch_flash_2, sizeof(patch_flash_2), bufsize); - if(PatchType[i] == 0x49) - _patch(buf, ofs, patch_flash_2, sizeof(patch_flash_2), bufsize); - if(PatchType[i] == 0x4A) - _patch(buf, ofs, patch_flash_6, sizeof(patch_flash_6), bufsize); + if(PatchType[i] == 0x46)_patch(buf, ofs, patch_flash_3, sizeof(patch_flash_3), bufsize); + if(PatchType[i] == 0x47)_patch(buf, ofs, patch_flash_5, sizeof(patch_flash_5), bufsize); + if(PatchType[i] == 0x48)_patch(buf, ofs, patch_flash_2, sizeof(patch_flash_2), bufsize); + if(PatchType[i] == 0x49)_patch(buf, ofs, patch_flash_2, sizeof(patch_flash_2), bufsize); + if(PatchType[i] == 0x4A)_patch(buf, ofs, patch_flash_6, sizeof(patch_flash_6), bufsize); break; case 5: // FLASH1M_V if(PatchType[i] == 0x51) { for(j = i + 1; j < PatchCnt; j++) { - if(PatchType[j] == 0x58) - break; + if(PatchType[j] == 0x58)break; } - if(j < PatchCnt) + if(j < PatchCnt) { patch_flash1M_1[4] = 0x5B; // V103 - else patch_flash1M_1[4] = 0x55; // V102 - + } else { + patch_flash1M_1[4] = 0x55; // V102 + } _patch(buf, ofs, patch_flash1M_1, sizeof(patch_flash1M_1), bufsize); } - if(PatchType[i] == 0x52) - _patch(buf, ofs, patch_flash1M_2, sizeof(patch_flash1M_2), bufsize); - if(PatchType[i] == 0x53) - _patch(buf, ofs, patch_flash1M_3, sizeof(patch_flash1M_3), bufsize); - if(PatchType[i] == 0x54) - _patch(buf, ofs, patch_flash1M_4, sizeof(patch_flash1M_4), bufsize); - if(PatchType[i] == 0x55) - _patch(buf, ofs, patch_flash1M_5, sizeof(patch_flash1M_5), bufsize); + if(PatchType[i] == 0x52)_patch(buf, ofs, patch_flash1M_2, sizeof(patch_flash1M_2), bufsize); + if(PatchType[i] == 0x53)_patch(buf, ofs, patch_flash1M_3, sizeof(patch_flash1M_3), bufsize); + if(PatchType[i] == 0x54)_patch(buf, ofs, patch_flash1M_4, sizeof(patch_flash1M_4), bufsize); + if(PatchType[i] == 0x55)_patch(buf, ofs, patch_flash1M_5, sizeof(patch_flash1M_5), bufsize); if(PatchType[i] == 0x56) { - if(GBAmode == 0) + if(GBAmode == 0) { patch_flash1M_6[38] = 0x32; - else patch_flash1M_6[38] = 0x10; + } else { + patch_flash1M_6[38] = 0x10; + } _patch(buf, ofs, patch_flash1M_6, sizeof(patch_flash1M_6), bufsize); } - if(PatchType[i] == 0x57) - _patch(buf, ofs, patch_flash1M_7, sizeof(patch_flash1M_7), bufsize); + if(PatchType[i] == 0x57)_patch(buf, ofs, patch_flash1M_7, sizeof(patch_flash1M_7), bufsize); if(PatchType[i] == 0x58) { - if(GBAmode == 0) + if(GBAmode == 0) { patch_flash1M_8[46] = 0x32; - else patch_flash1M_8[46] = 0x10; + } else { + patch_flash1M_8[46] = 0x10; + } _patch(buf, ofs, patch_flash1M_8, sizeof(patch_flash1M_8), bufsize); } if(PatchType[i] == 0x59) { - if(GBAmode == 0) + if(GBAmode == 0) { patch_flash1M_9[50] = 0x32; - else patch_flash1M_9[50] = 0x10; + } else { + patch_flash1M_9[50] = 0x10; + } _patch(buf, ofs, patch_flash1M_9, sizeof(patch_flash1M_9), bufsize); } break; @@ -2181,14 +2125,15 @@ void gba_patch(u8 *buf, u32 add, u32 bufsize, int GBAmode, char *name) patch_fmini_6[0x43] = (u8)((paddr >> 24) & 0xFF); } if(PatchType[i] == 0x86) { - if(fmini == 124) + if(fmini == 124) { _patch(buf, ofs, patch_fmini_5, sizeof(patch_fmini_5), bufsize); - else _patch(buf, ofs, patch_fmini_6, sizeof(patch_fmini_6), bufsize); + } else { + _patch(buf, ofs, patch_fmini_6, sizeof(patch_fmini_6), bufsize); + } } break; } } - PatchCntS = i; - } + diff --git a/arm9/source/gbaldr.cpp b/arm9/source/gbaldr.cpp index f3425f8..e421f03 100644 --- a/arm9/source/gbaldr.cpp +++ b/arm9/source/gbaldr.cpp @@ -29,6 +29,7 @@ //#include //basic print funcionality #define MAX_NOR 0x2000000 // 32MByte +#define MAX_NORPLUS 0x4000000 // 64MByte (3 in 1 Plus) #define MAX_PSRAM 0x1000000 // 16MByte #define SRAM_PAGE_SIZE 0x1000 // SRAM Page Size #define MAX_SRAM 0x80000 // 4MBit/512KByte total SRAM @@ -51,6 +52,8 @@ #define PSRAM_BUF 0x8000 // 32KB +#define poke(addr) do{(void)*(vu8*)addr;} while(0) +#define poke16(addr) do{(void)*(vu16*)addr;} while(0) #ifdef __cplusplus extern "C" { @@ -72,27 +75,29 @@ extern int GBAmode; static u32 savesize; int carttype = 0; +bool isSuperCard = false; +bool is3in1Plus = false; extern int save_sel(int mod, char *name); using namespace std; void SetEWINRam(u8 page) { - vu32 wait; - vu8 a; + vu32 wait; + // vu8 a; - a = *(vu8*)0x0A005555; - a = *(vu8*)0x0A002AAA; - a = *(vu8*)0x0A00B055; + poke(0x0A005555); + poke(0x0A002AAA); + poke(0x0A00B055); *(vu8*)0x0A000000 = page; for(wait = 0; wait < 15000; wait++); // 1ms - a = *(vu8*)0x0A000000; - a = *(vu8*)0x0A000000; - a = *(vu8*)0x0A000000; + poke(0x0A000000); + poke(0x0A000000); + poke(0x0A000000); } @@ -186,179 +191,170 @@ bool Close_EWIN() { } - - void SetM3Ram(u8 page) { u32 mode; - vu16 tmp; + // vu16 tmp; mode = (u32)page << 5; // M3 - tmp = *(vu16*)0x08000000; - tmp = *(vu16*)0x08E00002; - tmp = *(vu16*)0x0800000E; - tmp = *(vu16*)0x08801FFC; - tmp = *(vu16*)0x0800104A; - tmp = *(vu16*)0x08800612; - tmp = *(vu16*)0x08000000; - tmp = *(vu16*)0x08801B66; - tmp = *(vu16*)(0x08000000 + mode); - tmp = *(vu16*)0x0800080E; - tmp = *(vu16*)0x08000000; + poke16(0x08000000); + poke16(0x08E00002); + poke16(0x0800000E); + poke16(0x08801FFC); + poke16(0x0800104A); + poke16(0x08800612); + poke16(0x08000000); + poke16(0x08801B66); + poke16((0x08000000 + mode)); + poke16(0x0800080E); + poke16(0x08000000); // G6 - tmp = *(vu16*)0x09000000; - tmp = *(vu16*)0x09FFFFE0; - tmp = *(vu16*)0x09FFFFEC; - tmp = *(vu16*)0x09FFFFEC; - tmp = *(vu16*)0x09FFFFEC; - tmp = *(vu16*)0x09FFFFFC; - tmp = *(vu16*)0x09FFFFFC; - tmp = *(vu16*)0x09FFFFFC; - tmp = *(vu16*)0x09FFFF4A; - tmp = *(vu16*)0x09FFFF4A; - tmp = *(vu16*)0x09FFFF4A; - - tmp = *(vu16*)(0x09800000 + (mode << 12)); -// tmp = *(vu16*)0x09FFFFF0; - tmp = *(vu16*)0x09FFFFE8; + poke16(0x09000000); + poke16(0x09FFFFE0); + poke16(0x09FFFFEC); + poke16(0x09FFFFEC); + poke16(0x09FFFFEC); + poke16(0x09FFFFFC); + poke16(0x09FFFFFC); + poke16(0x09FFFFFC); + poke16(0x09FFFF4A); + poke16(0x09FFFF4A); + poke16(0x09FFFF4A); + poke16((0x09800000 + (mode << 12))); +// poke16(0x09FFFFF0); + poke16(0x09FFFFE8); } -bool _set_M3(int sw) { +bool _set_M3(int sw) { vu32 wait; - vu16 tmp; - vu8 a; + // vu16 tmp; + // vu8 a; // M3 - tmp = *(vu16*)0x08000000; - tmp = *(vu16*)0x08E00002; - tmp = *(vu16*)0x0800000E; - tmp = *(vu16*)0x08801FFC; - tmp = *(vu16*)0x0800104A; - tmp = *(vu16*)0x08800612; - tmp = *(vu16*)0x08000000; - tmp = *(vu16*)0x08801B66; - if(sw == 0) - tmp = *(vu16*)0x08800004; - if(sw == 1) - tmp = *(vu16*)0x0880000C; - if(sw == 2) - tmp = *(vu16*)0x08800008; - tmp = *(vu16*)0x0800080E; - tmp = *(vu16*)0x08000000; + poke16(0x08000000); + poke16(0x08E00002); + poke16(0x0800000E); + poke16(0x08801FFC); + poke16(0x0800104A); + poke16(0x08800612); + poke16(0x08000000); + poke16(0x08801B66); + if(sw == 0)poke16(0x08800004); + if(sw == 1)poke16(0x0880000C); + if(sw == 2)poke16(0x08800008); + poke16(0x0800080E); + poke16(0x08000000); if(sw == 2) { - tmp = *(vu16*)0x080001E4; - tmp = *(vu16*)0x080001E4; - tmp = *(vu16*)0x08000188; - tmp = *(vu16*)0x08000188; + poke16(0x080001E4); + poke16(0x080001E4); + poke16(0x08000188); + poke16(0x08000188); } // G6 - tmp = *(vu16*)0x09000000; - tmp = *(vu16*)0x09FFFFE0; - tmp = *(vu16*)0x09FFFFEC; - tmp = *(vu16*)0x09FFFFEC; - tmp = *(vu16*)0x09FFFFEC; - tmp = *(vu16*)0x09FFFFFC; - tmp = *(vu16*)0x09FFFFFC; - tmp = *(vu16*)0x09FFFFFC; - tmp = *(vu16*)0x09FFFF4A; - tmp = *(vu16*)0x09FFFF4A; - tmp = *(vu16*)0x09FFFF4A; + poke16(0x09000000); + poke16(0x09FFFFE0); + poke16(0x09FFFFEC); + poke16(0x09FFFFEC); + poke16(0x09FFFFEC); + poke16(0x09FFFFFC); + poke16(0x09FFFFFC); + poke16(0x09FFFFFC); + poke16(0x09FFFF4A); + poke16(0x09FFFF4A); + poke16(0x09FFFF4A); - if(sw == 0) - tmp = *(vu16*)0x09200004; - if(sw == 1) - tmp = *(vu16*)0x0920000C; - if(sw == 2) - tmp = *(vu16*)0x09200008; - tmp = *(vu16*)0x09FFFFF0; - tmp = *(vu16*)0x09FFFFE8; + if(sw == 0)poke16(0x09200004); + if(sw == 1)poke16(0x0920000C); + if(sw == 2)poke16(0x09200008); + poke16(0x09FFFFF0); + poke16(0x09FFFFE8); // GBA Pack - a = *(vu8*)0x0A000000; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A000001; - tmp = *(vu16*)0x08000000; + poke(0x0A000000); + poke(0x0A009999); + poke(0x0A009999); + poke(0x0A006666); + poke(0x0A006666); + poke(0x0A000001); + poke16(0x08000000); // tmp - a = *(vu8*)0x0A000000; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A000006; - tmp = *(vu16*)0x08000800; + poke(0x0A000000); + poke(0x0A009999); + poke(0x0A009999); + poke(0x0A006666); + poke(0x0A006666); + poke(0x0A000006); + poke16(0x08000800); // tmp - a = *(vu8*)0x0A000000; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A000008; - tmp = *(vu16*)0x09000040; + poke(0x0A000000); + poke(0x0A009999); + poke(0x0A009999); + poke(0x0A006666); + poke(0x0A006666); + poke(0x0A000008); + poke16(0x09000040); // tmp - a = *(vu8*)0x0A000000; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A000008; - tmp = *(vu16*)0x09000060; + poke(0x0A000000); + poke(0x0A009999); + poke(0x0A009999); + poke(0x0A006666); + poke(0x0A006666); + poke(0x0A000008); + poke16(0x09000060); // tmp - a = *(vu8*)0x0A000000; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A000006; - tmp = *(vu16*)0x08000800; + poke(0x0A000000); + poke(0x0A009999); + poke(0x0A009999); + poke(0x0A006666); + poke(0x0A006666); + poke(0x0A000006); + poke16(0x08000800); // tmp - a = *(vu8*)0x0A000000; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A000007; - tmp = *(vu16*)0x08000000; + poke(0x0A000000); + poke(0x0A009999); + poke(0x0A009999); + poke(0x0A006666); + poke(0x0A006666); + poke(0x0A000007); + poke16(0x08000000); // tmp - a = *(vu8*)0x0A000000; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A000003; + poke(0x0A000000); + poke(0x0A009999); + poke(0x0A009999); + poke(0x0A006666); + poke(0x0A006666); + poke(0x0A000003); - a = *(vu8*)0x0A000000; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A000005; - tmp = *(vu16*)0x08000000; + poke(0x0A000000); + poke(0x0A009999); + poke(0x0A009999); + poke(0x0A006666); + poke(0x0A006666); + poke(0x0A000005); + poke16(0x08000000); // tmp for(wait = 0; wait < 15000; wait++); // 1ms - a = *(vu8*)0x0A000000; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A00000A; - tmp = *(vu16*)0x08000000; + poke(0x0A000000); + poke(0x0A009999); + poke(0x0A009999); + poke(0x0A006666); + poke(0x0A006666); + poke(0x0A00000A); + poke16(0x08000000); // tmp - a = *(vu8*)0x0A000000; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A009999; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A006666; - a = *(vu8*)0x0A000003; + poke(0x0A000000); + poke(0x0A009999); + poke(0x0A009999); + poke(0x0A006666); + poke(0x0A006666); + poke(0x0A000003); return true; } @@ -390,49 +386,41 @@ int cehck_M3() { } - -void _RamPG() { - if(carttype == 3) { - SetRampage(USE_SRAM_PG_EZ4); - return; +void _RamPG() { + switch (carttype) { + case 3: + SetRampage(USE_SRAM_PG_EZ4); + return; + case 4: + SetEWINRam(USE_SRAM_PG_EWN); + return; + case 5: + SetEWINRam(USE_SRAM_PG_EWN128); + return; + case 6: + SetM3Ram(USE_SRAM_PG_M3); + return; } - if(carttype == 4) { - SetEWINRam(USE_SRAM_PG_EWN); - return; - } - if(carttype == 5) { - SetEWINRam(USE_SRAM_PG_EWN128); - return; - } - if(carttype == 6) { - SetM3Ram(USE_SRAM_PG_M3); - return; - } - SetRampage(USE_SRAM_PG); return; - } void _RamSave(int bnk) { - if(carttype == 3) { - SetRampage(USE_SRAM_PSR_EZ4 + bnk * 16); - return; - } - if(carttype == 6) { - SetM3Ram(USE_SRAM_PSR_M3 + bnk); - return; + switch (carttype) { + case 3: + SetRampage(USE_SRAM_PSR_EZ4 + bnk * 16); + return; + case 6: + SetM3Ram(USE_SRAM_PSR_M3 + bnk); + return; } + if(carttype >= 4) { SetEWINRam(USE_SRAM_PSR_EWN + bnk); return; } - if(GBAmode == 0) { - SetRampage(USE_SRAM_PSR + bnk * 16); - } else { - SetRampage(USE_SRAM_NOR + bnk * 16); - } + if(GBAmode == 0) { SetRampage(USE_SRAM_PSR + bnk * 16); } else { SetRampage(USE_SRAM_NOR + bnk * 16); } return; } @@ -452,29 +440,29 @@ int checkFlashID() { carttype = id; switch (id) { - case 0x227E2218: carttype = 1; - case 0x227E2202: carttype = 2; - case 0x227E2220: carttype = 3; // EZ4 - } - - if(carttype == 0 && cehck_M3())carttype = 6; - - if(carttype == 0) { - ewin = cehck_EWIN(); - if(ewin > 0) { - carttype = 3 + ewin; - } else { - #ifdef _DEBUG - FILE *testFile = fopen("/gbacardID.bin", "wb"); - if (testFile) { - fwrite((void*)id, 4, 1, testFile); - fclose(testFile); + case 0: + if (cehck_M3()) { + carttype = 6; // M3/G6 + return carttype; } - #endif - } + ewin = cehck_EWIN(); + if(ewin > 0)carttype = 3 + ewin; // EWIN + return carttype; + case 0x227E2218: carttype = 1; return carttype; // 3in1 + case 0x227E2202: carttype = 2; return carttype; // New3in1 + case 0x227E2222: + is3in1Plus = true; + isSuperCard = false; + carttype = 2; // 3in1 Plus + return carttype; + case 0x227E2220: carttype = 3; return carttype; // EZ4 + case 0x227E0000: // SuperCard + carttype = 6; + is3in1Plus = false; + isSuperCard = true; + return carttype; // SuperCard + default: return 0; // Unsupported/Unimplemented Cart ID } - - return(carttype); } @@ -508,8 +496,7 @@ int checkSRAM(char *name) { break; } - if(carttype < 4) - OpenNorWrite(); + if(carttype < 4)OpenNorWrite(); if(Rudolph[i] != 0) { strcpy((char *)ctrl.sign, Rudolph); @@ -534,13 +521,11 @@ int checkSRAM(char *name) { savesize = 0x10000; ctrl.save_siz[GBAmode] = savesize; ctrl_set(); - if(carttype < 4) - CloseNorWrite(); + if(carttype < 4)CloseNorWrite(); return false; } - if(carttype < 4) - CloseNorWrite(); + if(carttype < 4)CloseNorWrite(); return true; } @@ -840,12 +825,11 @@ int writeFileToNor(int sel) { int cmd; bool gba; - fsz = MAX_NOR; + if (is3in1Plus) { fsz = MAX_NORPLUS; } else { fsz = MAX_NOR; } + exp = 0x00000000; - if(fs[sel].filesize > fsz) { - return(1); - } + if(fs[sel].filesize > fsz)return 1; if(checkSRAM(savName) == false) { err_cnf(4, 5); @@ -876,13 +860,13 @@ int writeFileToNor(int sel) { for(siz = 0; siz < fs[sel].filesize; siz += 0x40000) { dsp_bar(0, siz * 100 / fs[sel].filesize); - Block_Erase(siz); + Block_Erase(siz); } dsp_bar(0, 100); chip_reset(); CloseNorWrite(); - + SetRampage(USE_SRAM_NOR); OpenNorWrite(); SetSerialMode(); @@ -891,15 +875,14 @@ int writeFileToNor(int sel) { dsp_bar(-1, 100); savesize = gba_check(gbaFile, fs[sel].filesize, rwbuf, PSRAM_BUF*32); - dsp_bar(1, -1); + for(siz = 0; siz < fs[sel].filesize; siz += PSRAM_BUF*32) { fread(rwbuf, 1, PSRAM_BUF*32, gbaFile); // dsp_bar(1, siz * 100 / fs[sel].filesize); - if(siz == 0 && gba) - header_rep(rwbuf); + if(siz == 0 && gba)header_rep(rwbuf); wsz = fs[sel].filesize - siz; if(wsz > PSRAM_BUF*32) wsz = PSRAM_BUF*32; @@ -912,14 +895,17 @@ int writeFileToNor(int sel) { exp += PSRAM_BUF; } } + dsp_bar(1, 100); fclose(gbaFile); CloseNorWrite(); // getSaveFilename(sel, savName); - if(cmd >= 0) + if(cmd >= 0) { writeSramFromFile(savName); - else blankSRAM(savName); + } else { + blankSRAM(savName); + } dsp_bar(-1, 100); // SetRampage(USE_SRAM_NOR); @@ -936,16 +922,12 @@ int writeFileToRam(int sel) { int cmd; bool gba; - if(carttype >= 3) - fsz = MAX_NOR; - else fsz = MAX_PSRAM; + if(carttype >= 3) { fsz = MAX_NOR; } else { fsz = MAX_PSRAM; } - if(carttype >= 4) - exp = 0x08000000; - else exp = 0x08060000; + if(carttype >= 4) { exp = 0x08000000; } else { exp = 0x08060000; } exps = exp; - if(fs[sel].filesize > fsz)return(1); + if(fs[sel].filesize > fsz)return 1; // if(checkSRAM(savName) == false) { @@ -1009,7 +991,7 @@ int writeFileToRam(int sel) { if(carttype < 4)CloseNorWrite(); _RamSave(0); - if(carttype >= 4) { + if(carttype >= 4 && !isSuperCard) { if(carttype == 6) { Close_M3(); } else { Close_EWIN(); } } if(carttype == 3)SetRompage(0x300); diff --git a/arm9/source/header_rep.cpp b/arm9/source/header_rep.cpp index f2d2881..e742e4b 100644 --- a/arm9/source/header_rep.cpp +++ b/arm9/source/header_rep.cpp @@ -8,41 +8,33 @@ #include "GBA_ini.h" #include "header_rep.h" -u8 _comple(u8 *buf, u32 st, u32 en) -{ +u8 _comple(u8 *buf, u32 st, u32 en){ u8 crc; u32 i; - crc = 0; - for(i = st; i <= en; i++) - crc -= buf[i]; - - crc = (crc - 0x19) & 0xff; + for(i = st; i <= en; i++)crc -= buf[i]; + crc = (crc - 0x19) & 0xff; return(crc); } -void header_rep(u8 *rwbuf) -{ - char buf[256]; - FILE *hed; +void header_rep(u8 *rwbuf) { + char buf[256]; + FILE *hed; int i; rwbuf[0xBD] = _comple(rwbuf, 0xA0, 0xBC); // rwbuf[0xBE] = _comple(rwbuf, 0x04, 0x9F); - if(_comple(rwbuf, 0x04, 0x9F) == 0xCC) - return; + if(_comple(rwbuf, 0x04, 0x9F) == 0xCC)return; sprintf(buf, "%s/header.dat", ini.sign_dir); hed = fopen(buf, "rb"); - if(hed == NULL) return; + if(hed == NULL)return; fread(buf, 1, 256, hed); - if(_comple((u8*)buf, 0x04, 0x9F) != 0xCC) - return; + if(_comple((u8*)buf, 0x04, 0x9F) != 0xCC)return; - for(i = 0x04; i < 0xA0; i++) - rwbuf[i] = buf[i]; + for(i = 0x04; i < 0xA0; i++)rwbuf[i] = buf[i]; fclose(hed); } diff --git a/arm9/source/io_sc_common.c b/arm9/source/io_sc_common.c new file mode 100644 index 0000000..b453d4f --- /dev/null +++ b/arm9/source/io_sc_common.c @@ -0,0 +1,54 @@ +/* + io_m3_common.h + + Routines common to all version of the Super Card + + Copyright (c) 2006 Michael "Chishm" Chisholm + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + 3. The name of the author may not be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "io_sc_common.h" + +/*----------------------------------------------------------------- +_SC_changeMode (was SC_Unlock) +Added by MightyMax +Modified by Chishm +Modified again by loopy +1=ram(readonly), 5=ram, 3=SD interface? +-----------------------------------------------------------------*/ +void _SC_changeMode(u8 mode) { + vu16 *unlockAddress = (vu16*)0x09FFFFFE; + *unlockAddress = 0xA55A; + *unlockAddress = 0xA55A; + *unlockAddress = mode; + *unlockAddress = mode; +} + +void _SC_changeMode16(u16 mode) { + vu16 *unlockAddress = (vu16*)0x09FFFFFE; + *unlockAddress = 0xA55A; + *unlockAddress = 0xA55A; + *unlockAddress = mode; + *unlockAddress = mode; +} + diff --git a/arm9/source/io_sc_common.h b/arm9/source/io_sc_common.h new file mode 100644 index 0000000..534e979 --- /dev/null +++ b/arm9/source/io_sc_common.h @@ -0,0 +1,57 @@ +/* + io_sc_common.h + + Routines common to all version of the Super Card + + Copyright (c) 2006 Michael "Chishm" Chisholm + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + 3. The name of the author may not be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 2006-07-11 - Chishm + * Original release +*/ + +#ifndef IO_SC_COMMON_H +#define IO_SC_COMMON_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// Values for changing mode +#define SC_MODE_RAM 0x5 +#define SC_MODE_MEDIA 0x3 +#define SC_MODE_RAM_RO 0x1 + +#define SC_MODE_ROM_PROG 0x1510 + +extern void _SC_changeMode(u8 mode); +extern void _SC_changeMode16(u16 mode); + +#ifdef __cplusplus +} +#endif + +#endif // IO_SC_COMMON_H + diff --git a/arm9/source/main.c b/arm9/source/main.c index e76a3a3..84612a0 100644 --- a/arm9/source/main.c +++ b/arm9/source/main.c @@ -27,9 +27,7 @@ #include #include -// #include #include - #include #include #include @@ -53,7 +51,7 @@ extern uint16* SubScreen; #define BG_256_COLOR (BIT(7)) -#define VERSTRING "v0.58" +#define VERSTRING "v0.59" int numFiles = 0; int numGames = 0; @@ -74,13 +72,9 @@ u8 *rwbuf; #define IPC_CMD_SR_DLMS 12 #define IPC_CMD_SR_GEN 13 -extern int carttype; - - -// void Vblank() { } -// void FIFOInit() { REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; } -// void FIFOSend(u32 val) { REG_IPC_FIFO_TX = val; } - +extern int carttype; +extern bool isSuperCard; +extern bool is3in1Plus; u32 inp_key() { @@ -107,6 +101,10 @@ extern bool ret_menu_chk(void); extern bool ret_menu9_Gen(void); extern void ret_menu9_GENs(void); + +extern void setGBAmode(void); +extern void getGBAmode(void); + void turn_off(int cmd) { if(cmd == 0) { // “dŒ¹’f // FIFOSend(IPC_CMD_TURNOFF); @@ -200,7 +198,7 @@ static void resetToSlot2() { ITCM_CODE void gbaMode() { if(strncmp(GBA_HEADER.gamecode, "PASS", 4) == 0) { - resetARM9Memory(); + // resetARM9Memory(); resetToSlot2(); } @@ -208,13 +206,11 @@ ITCM_CODE void gbaMode() { videoSetModeSub(0); vramSetPrimaryBanks(VRAM_A_MAIN_BG, VRAM_B_MAIN_BG, VRAM_C_MAIN_BG, VRAM_D_MAIN_BG); -// vramSetMainBanks(VRAM_A_MAIN_BG, VRAM_B_MAIN_BG, VRAM_C_ARM7, VRAM_D_ARM7); if(PersonalData->gbaScreen) { lcdMainOnBottom(); } else { lcdMainOnTop(); } gba_frame(); - // FIFOSend(IPC_CMD_GBAMODE); sysSetBusOwners(ARM7_OWNS_CARD, ARM7_OWNS_ROM); fifoSendValue32(FIFO_USER_01, 1); REG_IME = 0; @@ -231,8 +227,7 @@ void err_cnf(int n1, int n2) { int gsiz; len = strlen(errmsg[n1]); - if(len < strlen(errmsg[n2])) - len = strlen(errmsg[n2]); + if(len < strlen(errmsg[n2]))len = strlen(errmsg[n2]); if(len < 10) len = 10; x1 = (256 - len * 6) / 2 - 4; @@ -281,8 +276,7 @@ int cnf_inp(int n1, int n2) { u32 ky; len = strlen(cnfmsg[n1]); - if(len < strlen(cnfmsg[n2])) - len = strlen(cnfmsg[n2]); + if(len < strlen(cnfmsg[n2]))len = strlen(cnfmsg[n2]); if(len < 20) len = 20; x1 = (256 - len * 6) / 2 - 4; @@ -346,8 +340,7 @@ void dsp_bar(int mod, int per) { DrawBox(MainScreen, x1+1, y1+1, x2-1, y2-1, RGB15(0,0,31), 1); DrawBox(MainScreen, x1+2, y1+2, x2-2, y2-2, RGB15(31,31,0), 0); - if(per != -2) - DrawBox(MainScreen, x1 + 28, y1 + 20, x1 + 129, y1 + 40, RGB15(31,31,31), 0); + if(per != -2)DrawBox(MainScreen, x1 + 28, y1 + 20, x1 + 129, y1 + 40, RGB15(31,31,31), 0); ShinoPrint(MainScreen, x1 + 26, y1 + 6, (u8 *)barmsg[mod], RGB15(31,31,31), RGB15(31,31,31), 0); oldper = -1; return; @@ -397,9 +390,6 @@ void RamClear() { } -extern void setGBAmode(void); -extern void getGBAmode(void); - int GBAmode; int r4tf; @@ -519,7 +509,7 @@ int rumble_cmd() { void _gba_dsp(int no, int mod, int x, int y) { - char dsp[40]; + char dsp[40]; int sn; sn = sortfile[no]; @@ -599,9 +589,11 @@ void _gba_sel_dsp(int no, int yc, int mod) { // DrawBox_SUB(SubScreen, 76, 116, 180, 135, 5, 1); // DrawBox_SUB(SubScreen, 77, 117, 179, 134, 0, 0); - if(carttype < 4) + if(carttype < 4) { ShinoPrint_SUB( SubScreen, 15*6, 10*12, (u8 *)t_msg[1], 0, 5, 1); - else ShinoPrint_SUB( SubScreen, 15*6, 10*12, (u8 *)t_msg[21], 0, 5, 1); + } else { + ShinoPrint_SUB( SubScreen, 15*6, 10*12, (u8 *)t_msg[21], 0, 5, 1); + } ShinoPrint_SUB( SubScreen, 2*6, 11*12+6, (u8 *)t_msg[2], 1, 0, 1); ShinoPrint_SUB( SubScreen, 2*6, 12*12+6, (u8 *)t_msg[3], 1, 0, 1); @@ -915,8 +907,7 @@ int gba_sel() { SetRampage(16); gbaMode(); } else { - if(cnf_inp(7, 8) & KEY_A) - SRAMdump(0); + if(cnf_inp(7, 8) & KEY_A)SRAMdump(0); } } @@ -991,10 +982,10 @@ extern void setLang(void); void mainloop(void) { // vu16 reg; - FILE *r4dt; - __handle *handle; - // FILE_STRUCT *file; - FILE *file; + // FILE *r4dt; + // __handle *handle; + // _FILE_STRUCT *file; + // FILE *file; // PARTITION *part; int cmd; @@ -1025,12 +1016,16 @@ REG_EXMEMCNT = (reg & 0xFFE0) | (1 << 4) | (1 << 2) | 1; **********/ // OpenNorWrite(); // chip_reset(); + + setLangMsg(); + + if(isDSiMode()) { err_cnf(14, 15); turn_off(0); } + CloseNorWrite(); SetRompage(0); SetRampage(16); SetShake(0x08); - setLangMsg(); /******** ram_init(DETECT_RAM); @@ -1039,7 +1034,7 @@ REG_EXMEMCNT = (reg & 0xFFE0) | (1 << 4) | (1 << 2) | 1; inp_key(); ********/ if(!fatInitDefault()) { err_cnf(0, 1); turn_off(0); } - + checkFlashID(); switch (carttype) { @@ -1051,17 +1046,29 @@ REG_EXMEMCNT = (reg & 0xFFE0) | (1 << 4) | (1 << 2) | 1; err_cnf(2, 3); turn_off(r4tf); break; - case 1: ShinoPrint_SUB( SubScreen, 23*6, 1*12-2, (u8*)" [ 3in1 ]", 0, 0, 0 ); break; // SetRampage(16); // SetShake(0x08); - case 2: ShinoPrint_SUB( SubScreen, 23*6, 1*12-2, (u8*)"[New3in1]", 0, 0, 0 ); break; + case 1: + ShinoPrint_SUB( SubScreen, 23*6, 1*12-2, (u8*)" [ 3in1 ]", 0, 0, 0 ); break; // SetRampage(16); // SetShake(0x08); + case 2: + if (is3in1Plus) { + ShinoPrint_SUB( SubScreen, 23*6, 1*12-2, (u8*)"[3in1Plus]", 0, 0, 0 ); + } else { + ShinoPrint_SUB( SubScreen, 23*6, 1*12-2, (u8*)"[New3in1]", 0, 0, 0 ); + } + break; case 3: SetRompage(0x300); ShinoPrint_SUB( SubScreen, 23*6, 1*12-2, (u8*)" [ EZ4 ]", 0, 0, 0 ); break; case 4: ShinoPrint_SUB( SubScreen, 23*6, 1*12-2, (u8*)"[EXP256K]", 0, 0, 0 ); break; case 5: ShinoPrint_SUB( SubScreen, 23*6, 1*12-2, (u8*)"[EXP128K]", 0, 0, 0 ); break; - case 6: ShinoPrint_SUB( SubScreen, 23*6, 1*12-2, (u8*)"[ M3/G6 ]", 0, 0, 0 ); break; + case 6: + if (isSuperCard) { + ShinoPrint_SUB( SubScreen, 23*6, 1*12-2, (u8*)"[ SC ]", 0, 0, 0 ); + } else { + ShinoPrint_SUB( SubScreen, 23*6, 1*12-2, (u8*)"[ M3/G6 ]", 0, 0, 0 ); + } + break; } - ShinoPrint_SUB( SubScreen, 9*6, 5*12, (u8 *)t_msg[16], 1, 0, 0 ); // if(!fatInitDefault()) { err_cnf(0, 1); turn_off(0); } @@ -1078,16 +1085,17 @@ REG_EXMEMCNT = (reg & 0xFFE0) | (1 << 4) | (1 << 2) | 1; r4tf = 0; if(io_dldi_data->ioInterface.ioType == 0x46543452) { // R4TF if((*(vu32*)0x027FFE18) == 0x00000000) { - r4dt = fopen("/_DS_MENU.DAT", "rb"); + /*r4dt = fopen("/_DS_MENU.DAT", "rb"); if(r4dt != NULL) { handle = (__handle *)r4dt->_file; - // file = (FILE_STRUCT *)handle->fileStruct; + // handle = (_handle*)r4dt->_file; + // file = (_FILE_STRUCT*)handle->fileStruct; file = (FILE*)handle->fileStruct; // part = file->partition; // (*(vu32*)0x027FFE18) = (part->rootDirStart + file->dirEntryStart.sector) * 512 + file->dirEntryStart.offset * 32; fclose(r4dt); r4tf = 1; - } + }*/ } else { r4tf = 1; } @@ -1213,7 +1221,7 @@ int main(void) { ClearBG_SUB( SubScreen, 0 ); //ƒoƒbƒN‚ð”’‚É swiWaitForVBlank(); - swiWaitForVBlank(); + sysSetBusOwners(BUS_OWNER_ARM9,BUS_OWNER_ARM9); mainloop(); diff --git a/arm9/source/memcleaner.cpp b/arm9/source/memcleaner.cpp index 1ffd191..36cf5d6 100644 --- a/arm9/source/memcleaner.cpp +++ b/arm9/source/memcleaner.cpp @@ -25,21 +25,10 @@ THE SOFTWARE. ---------------------------------------------------------------------------------*/ #include -#include #include "memcleaner.h" -/* -static inline void dmaFillWords(const void* src, void* dest, uint32 size) { - DMA_SRC(3) = (uint32)src; - DMA_DEST(3) = (uint32)dest; - DMA_CR(3) = DMA_COPY_WORDS | DMA_SRC_FIX | (size>>2); - while(DMA_CR(3) & DMA_BUSY); -} -*/ - -void resetARM9Memory() -{ +void resetARM9Memory() { // DMA for (u8 i=0; i<4; i++) { DMA_CR(i) = 0; @@ -75,7 +64,7 @@ void resetARM9Memory() VRAM_H_CR = 0; VRAM_I_CR = 0; VRAM_CR = 0x00000000; - POWER_CR = 0x820F; // turn on all engines + REG_POWERCNT = 0x820F; // turn on all engines // Interrupt REG_IME = 0; diff --git a/arm9/source/message.cpp b/arm9/source/message.cpp index c008e5c..7705341 100644 --- a/arm9/source/message.cpp +++ b/arm9/source/message.cpp @@ -1,178 +1,180 @@ - #include - #include #include "message.h" -char *errmsg[14]; -char *cnfmsg[11]; -char *barmsg[4]; -char *cmd_m[4]; -char *t_msg[22]; -char *savmsg[6]; +char *errmsg[16]; +char *cnfmsg[11]; +char *barmsg[4]; +char *cmd_m[4]; +char *t_msg[22]; +char *savmsg[6]; -static const char *errmsg_j[14] = { - "FAT‚̉Šú‰»‚ÉŽ¸”s‚µ‚Ü‚µ‚½", // 0 - "“KØ‚ÈDLDIƒpƒbƒ`‚ðs‚Á‚Ä‚­‚¾‚³‚¢", // 1 - "Slot2Šg’£ƒpƒbƒN‚ªƒZƒbƒg‚³‚ê‚Ä‚¢‚Ü‚¹‚ñ", // 2 - "ʼn‚©‚ç‚â‚è’¼‚µ‚Ä‚­‚¾‚³‚¢", // 3 - "SRAM‚ÌSAVEÃÞ°À‚ªAÁޏ‚µ‚Ä‚¢‚Ü‚µ‚½", // 4 - "SAV̧²Ù‚̈—‚Ís‚¦‚Ü‚¹‚ñ", // 5 - "32MBˆÈã‚̃tƒ@ƒCƒ‹‚͈µ‚¦‚Ü‚¹‚ñ", // 6 - "Žw’肵‚½ƒtƒ@ƒCƒ‹‚͑傫‚·‚¬‚Ü‚·", // 7 - "16MBˆÈã‚̃tƒ@ƒCƒ‹‚͈µ‚¦‚Ü‚¹‚ñ", // 8 - "Flash 1Mb‚ÌSAVEƒ^ƒCƒv‚ÍA", // 9 - "[EXP128K]‚ÅŽæ‚舵‚¤Ž–‚ª‚Å‚«‚Ü‚¹‚ñ", // 10 - "SAV̧²Ù‚ª‚ ‚è‚Ü‚¹‚ñI", // 11 - "SAV̧²Ù‚ð휂µ‚Ä‚¢‚Ü‚¹‚©H", // 12 - "(A):Šm”F" // 13 +static const char *errmsg_j[16] = { + "FAT‚̉Šú‰»‚ÉŽ¸”s‚µ‚Ü‚µ‚½", // 0 + "“KØ‚ÈDLDIƒpƒbƒ`‚ðs‚Á‚Ä‚­‚¾‚³‚¢", // 1 + "Slot2Šg’£ƒpƒbƒN‚ªƒZƒbƒg‚³‚ê‚Ä‚¢‚Ü‚¹‚ñ", // 2 + "ʼn‚©‚ç‚â‚è’¼‚µ‚Ä‚­‚¾‚³‚¢", // 3 + "SRAM‚ÌSAVEÃÞ°À‚ªAÁޏ‚µ‚Ä‚¢‚Ü‚µ‚½", // 4 + "SAV̧²Ù‚̈—‚Ís‚¦‚Ü‚¹‚ñ", // 5 + "32MBˆÈã‚̃tƒ@ƒCƒ‹‚͈µ‚¦‚Ü‚¹‚ñ", // 6 + "Žw’肵‚½ƒtƒ@ƒCƒ‹‚͑傫‚·‚¬‚Ü‚·", // 7 + "16MBˆÈã‚̃tƒ@ƒCƒ‹‚͈µ‚¦‚Ü‚¹‚ñ", // 8 + "Flash 1Mb‚ÌSAVEƒ^ƒCƒv‚ÍA", // 9 + "[EXP128K]‚ÅŽæ‚舵‚¤Ž–‚ª‚Å‚«‚Ü‚¹‚ñ", // 10 + "SAV̧²Ù‚ª‚ ‚è‚Ü‚¹‚ñI", // 11 + "SAV̧²Ù‚ð휂µ‚Ä‚¢‚Ü‚¹‚©H", // 12 + "(A):Šm”F", // 13 + "DSi/3DS‚ɂ͑Ήž‚µ‚Ä‚¨‚è‚Ü‚¹‚ñI", // 14 + "DS/DS Lite‚݂̂ɑΉž‚µ‚Ä‚¢‚Ü‚·B" // 15 }; -static const char *errmsg_e[14] = { - "FAT initialization failed ", // 0 - "Please apply the appropriate DLDI Patch.", // 1 - "Slot2 expansion pack not found ", // 2 - "Please redo from start.", // 3 - "SRAM save data not found ", // 4 - "Can't process to SAV file.", // 5 - "Can't load a file above 32MB", // 6 - "Selected file too big.", // 7 - "Can't load a file above 16MB", // 8 - "The SAVE type of Flash 1Mb", // 9 - "Can't be treated with [EXP128K].", // 10 - "SAV file not found!", // 11 - " delete the SAV file?", // 12 - "(A):Confirm" // 13 +static const char *errmsg_e[16] = { + "FAT initialization failed ", // 0 + "Please apply the appropriate DLDI Patch.", // 1 + "Slot2 expansion pack not found ", // 2 + "Please redo from start.", // 3 + "SRAM save data not found ", // 4 + "Can't process to SAV file.", // 5 + "Can't load a file above 32MB", // 6 + "Selected file too big.", // 7 + "Can't load a file above 16MB", // 8 + "The SAVE type of Flash 1Mb", // 9 + "Can't be treated with [EXP128K].", // 10 + "SAV file not found!", // 11 + " delete the SAV file?", // 12 + "(A):Confirm", // 13 + "DSi/3DS Consoles not supported!", // 14 + "Only compatible with DS/DS Lite." // 15 }; static const char *cnfmsg_j[11] = { - "(A):ŽÀs, (B):ŽæÁ", // 0 - "Œ»Ý‚ÌSRAM‚É‚ ‚éSAVEƒf[ƒ^‚ð", // 1 - "SAVƒtƒ@ƒCƒ‹‚ɕۑ¶‚µ‚Ü‚·", // 2 - "SAVƒtƒ@ƒCƒ‹‚̃f[ƒ^‚ð", // 3 - "SRAM‚ÌSAVE‚Ƀ[ƒh‚µ‚Ü‚·", // 4 - "‘SSRAM—̈æ‚ðƒoƒbƒNƒAƒbƒvƒtƒ@ƒCƒ‹", // 5 - "(SRAM.BIN)‚©‚畜‹Œ‚µ‚Ü‚·", // 6 - "‘SSRAM—̈æ‚ðƒoƒbƒNƒAƒbƒv‚Æ‚µ‚Ä", // 7 - "SRAM.BIN‚É‘Þ”ð‚µ‚Ü‚·", // 8 - "‚±‚ÌSlot2Šg’£ƒpƒbƒN‚ð GBA ExpLoader—p‚É", // 9 - "Ý’è(SRAM‚ÍŽ¸‚í‚ê‚Ü‚·)‚µ‚Ä‚¢‚¢‚Å‚·‚©H" // 10 + "(A):ŽÀs, (B):ŽæÁ", // 0 + "Œ»Ý‚ÌSRAM‚É‚ ‚éSAVEƒf[ƒ^‚ð", // 1 + "SAVƒtƒ@ƒCƒ‹‚ɕۑ¶‚µ‚Ü‚·", // 2 + "SAVƒtƒ@ƒCƒ‹‚̃f[ƒ^‚ð", // 3 + "SRAM‚ÌSAVE‚Ƀ[ƒh‚µ‚Ü‚·", // 4 + "‘SSRAM—̈æ‚ðƒoƒbƒNƒAƒbƒvƒtƒ@ƒCƒ‹", // 5 + "(SRAM.BIN)‚©‚畜‹Œ‚µ‚Ü‚·", // 6 + "‘SSRAM—̈æ‚ðƒoƒbƒNƒAƒbƒv‚Æ‚µ‚Ä", // 7 + "SRAM.BIN‚É‘Þ”ð‚µ‚Ü‚·", // 8 + "‚±‚ÌSlot2Šg’£ƒpƒbƒN‚ð GBA ExpLoader—p‚É", // 9 + "Ý’è(SRAM‚ÍŽ¸‚í‚ê‚Ü‚·)‚µ‚Ä‚¢‚¢‚Å‚·‚©H" // 10 }; static const char *cnfmsg_e[11] = { - "(A):Run, (B):Cancel", // 0 - "Write save data in SRAM", // 1 - " to SAV file", // 2 - "Load save data in SRAM", // 3 - " from SAV file", // 4 - "Restore all data in SRAM", // 5 - " from file SRAM.BIN", // 6 - "Backup all data in SRAM", // 7 - " to file SRAM.BIN", // 8 - "May I set this Slot2 expansion pack", // 9 - "for GBA ExpLoader?" // 10 + "(A):Run, (B):Cancel", // 0 + "Write save data in SRAM", // 1 + " to SAV file", // 2 + "Load save data in SRAM", // 3 + " from SAV file", // 4 + "Restore all data in SRAM", // 5 + " from file SRAM.BIN", // 6 + "Backup all data in SRAM", // 7 + " to file SRAM.BIN", // 8 + "May I set this Slot2 expansion pack", // 9 + "for GBA ExpLoader?" // 10 }; static const char *barmsg_j[4] = { - " NOR‚ðÁ‹Ž’†... ", // 0 - " NOR‚ɃRƒs[’†... ", // 1 - " RAM‚Ƀ[ƒh’†... ", // 2 - " ROM‚ð‰ðÍ’†... " // 3 + " NOR‚ðÁ‹Ž’†... ", // 0 + " NOR‚ɃRƒs[’†... ", // 1 + " RAM‚Ƀ[ƒh’†... ", // 2 + " ROM‚ð‰ðÍ’†... " // 3 }; static const char *barmsg_e[4] = { - " Erasing NOR... ", // 0 - " Copying to NOR... ", // 1 - " Loading to RAM... ", // 2 - " Analyzing ROM... " // 3 + " Erasing NOR... ", // 0 + " Copying to NOR... ", // 1 + " Loading to RAM... ", // 2 + " Analyzing ROM... " // 3 }; static const char *cmd_m_j[4] = { - " U“®ƒŒƒxƒ‹ F (¬) ", - " U“®ƒŒƒxƒ‹ F (’†) ", - " U“®ƒŒƒxƒ‹ F (‘å) ", - " ƒuƒ‰ƒEƒU—pŠg’£ƒƒ‚ƒŠ " + " U“®ƒŒƒxƒ‹ F (¬) ", + " U“®ƒŒƒxƒ‹ F (’†) ", + " U“®ƒŒƒxƒ‹ F (‘å) ", + " ƒuƒ‰ƒEƒU—pŠg’£ƒƒ‚ƒŠ " }; static const char *cmd_m_e[4] = { - " Rumble level: Weak ", - " Rumble level: Medium ", - " Rumble level: Strong ", - " Expansion RAM " + " Rumble level: Weak ", + " Rumble level: Medium ", + " Rumble level: Strong ", + " Expansion RAM " }; static const char *t_msg_j[22] = { - "‘I‘𒆂̃Q[ƒ€", - " PSRAMƒ‚[ƒh", - "(A):RAM‚ɃQ[ƒ€‚ðƒ[ƒh‚µ‚ÄŽÀs ", - "(B):SRAM‚ÌSAVEÃÞ°À‚ð SAV̧²Ù‚ɕۑ¶ ", - " ‘SSRAMÃÞ°À—̈æ (X):‘Þ”ð, (Y):•œ‹Œ", - "(R):ƒ‚[ƒh•ÏX ", - "(L)/(R):ƒ‚[ƒh•ÏX ", - "(L):ƒ‚[ƒh•ÏX ", - " NORƒ‚[ƒh ", - "(A):ƒQ[ƒ€‚̃Rƒs[ (X):NOR‚ðŽÀs ", - "(B):SRAM‚ÌSAVEÃÞ°À‚ð SAV̧²Ù‚ɕۑ¶ ", // 10 - "(Y):SAV̧²Ù‚ð SRAM‚ÌSAVE‚Ƀ[ƒh ", - "[%s] %d ƒQ[ƒ€", - "Áޏ‚à‚µ‚­‚ÍV‹Kó‘Ô", - "Œ»Ý‚ÌSRAM‚ÌSAVE", - " == GBAƒtƒ@ƒCƒ‹‚ª‚ ‚è‚Ü‚¹‚ñ == ", - "‰Šú‰»’†....", - " Šg’£ƒ‚[ƒh", - "(A):3in1‚ðݒ肵‚ÄƒŠƒZƒbƒg", - "(L):ƒ‚[ƒh•ÏX ", - "(R):ƒuƒ‰ƒEƒU—pŠg’£ƒƒ‚ƒŠ ", - " SDRAMƒ‚[ƒh", + "‘I‘𒆂̃Q[ƒ€", + " PSRAMƒ‚[ƒh", + "(A):RAM‚ɃQ[ƒ€‚ðƒ[ƒh‚µ‚ÄŽÀs ", + "(B):SRAM‚ÌSAVEÃÞ°À‚ð SAV̧²Ù‚ɕۑ¶ ", + " ‘SSRAMÃÞ°À—̈æ (X):‘Þ”ð, (Y):•œ‹Œ", + "(R):ƒ‚[ƒh•ÏX ", + "(L)/(R):ƒ‚[ƒh•ÏX ", + "(L):ƒ‚[ƒh•ÏX ", + " NORƒ‚[ƒh ", + "(A):ƒQ[ƒ€‚̃Rƒs[ (X):NOR‚ðŽÀs ", + "(B):SRAM‚ÌSAVEÃÞ°À‚ð SAV̧²Ù‚ɕۑ¶ ", // 10 + "(Y):SAV̧²Ù‚ð SRAM‚ÌSAVE‚Ƀ[ƒh ", + "[%s] %d ƒQ[ƒ€", + "Áޏ‚à‚µ‚­‚ÍV‹Kó‘Ô", + "Œ»Ý‚ÌSRAM‚ÌSAVE", + " == GBAƒtƒ@ƒCƒ‹‚ª‚ ‚è‚Ü‚¹‚ñ == ", + "‰Šú‰»’†....", + " Šg’£ƒ‚[ƒh", + "(A):3in1‚ðݒ肵‚ÄƒŠƒZƒbƒg", + "(L):ƒ‚[ƒh•ÏX ", + "(R):ƒuƒ‰ƒEƒU—pŠg’£ƒƒ‚ƒŠ ", + " SDRAMƒ‚[ƒh", }; static const char *t_msg_e[22] = { - "Selected game", - " PSRAM Mode ", - "(A):Run (B):Write SRAM to SAV file", - "(X):Backup whole SRAM to SRAM.BIN ", - "(Y):Restore SRAM.BIN to SRAM ", - "(R):Change mode ", - "(L)/(R):Change mode ", - "(L):Change mode ", - " NOR mode ", - "(A):Copy game (X):Run game in NOR ", - "(B):Write SRAM to SAV file ", // 10 - "(Y):Load SAV file to SRAM ", - "[%s] %d game", - "Empty or new state", - "Current SRAM Save", - " == GBA file not found == ", - "Initialize....", - "Expansion mode", - "(A):Set mode and soft reset", - "(L):Change mode ", - "(R):Expansion RAM ", - " SDRAM Mode ", + "Selected game", + " PSRAM Mode ", + "(A):Run (B):Write SRAM to SAV file", + "(X):Backup whole SRAM to SRAM.BIN ", + "(Y):Restore SRAM.BIN to SRAM ", + "(R):Change mode ", + "(L)/(R):Change mode ", + "(L):Change mode ", + " NOR mode ", + "(A):Copy game (X):Run game in NOR ", + "(B):Write SRAM to SAV file ", // 10 + "(Y):Load SAV file to SRAM ", + "[%s] %d game", + "Empty or new state", + "Current SRAM Save", + " == GBA file not found == ", + "Initialize....", + "Expansion mode", + "(A):Set mode and soft reset", + "(L):Change mode ", + "(R):Expansion RAM ", + " SDRAM Mode ", }; static const char *savmsg_j[6] = { - " SRAM‚ÉSAVEƒf[ƒ^‚ðƒ[ƒh", // 0 - "(A):‘I‘ð‚µ‚½ƒtƒ@ƒCƒ‹‚ðƒ[ƒh", // 1 - "(B):ƒ[ƒh‚µ‚È‚¢(V‹KƒQ[ƒ€)", // 2 - " SRAM‚ÌSAVEƒf[ƒ^‚ð•Û‘¶ ", // 3 - "(A):‘I‘ð‚µ‚½ƒtƒ@ƒCƒ‹‚ɕۑ¶", // 4 - "(B):•Û‘¶‚µ‚È‚¢(ŽæÁ)", // 5 + " SRAM‚ÉSAVEƒf[ƒ^‚ðƒ[ƒh", // 0 + "(A):‘I‘ð‚µ‚½ƒtƒ@ƒCƒ‹‚ðƒ[ƒh", // 1 + "(B):ƒ[ƒh‚µ‚È‚¢(V‹KƒQ[ƒ€)", // 2 + " SRAM‚ÌSAVEƒf[ƒ^‚ð•Û‘¶ ", // 3 + "(A):‘I‘ð‚µ‚½ƒtƒ@ƒCƒ‹‚ɕۑ¶", // 4 + "(B):•Û‘¶‚µ‚È‚¢(ŽæÁ)", // 5 }; static const char *savmsg_e[6] = { - " Load SRAM from SAV file ", // 0 - "(A):Load from selected file", // 1 - "(B):No load(New Game)", // 2 - " Write SRAM to SAV file ", // 3 - "(A):write to selected file", // 4 - "(B):No write(Cancel)", // 5 + " Load SRAM from SAV file ", // 0 + "(A):Load from selected file", // 1 + "(B):No load(New Game)", // 2 + " Write SRAM to SAV file ", // 3 + "(A):write to selected file", // 4 + "(B):No write(Cancel)", // 5 }; @@ -183,7 +185,7 @@ void setLangMsg() { UserLang = PersonalData->language; if(UserLang != 0) { - for(i = 0; i < 14; i++)errmsg[i] = (char*)errmsg_e[i]; + for(i = 0; i < 16; i++)errmsg[i] = (char*)errmsg_e[i]; for(i = 0; i < 11; i++)cnfmsg[i] = (char*)cnfmsg_e[i]; for(i = 0; i < 4; i++)barmsg[i] = (char*)barmsg_e[i]; for(i = 0; i < 4; i++)cmd_m[i] = (char*)cmd_m_e[i]; @@ -192,7 +194,7 @@ void setLangMsg() { return; } - for(i = 0; i < 14; i++)errmsg[i] = (char*)errmsg_j[i]; + for(i = 0; i < 16; i++)errmsg[i] = (char*)errmsg_j[i]; for(i = 0; i < 11; i++)cnfmsg[i] = (char*)cnfmsg_j[i]; for(i = 0; i < 4; i++)barmsg[i] = (char*)barmsg_j[i]; for(i = 0; i < 4; i++)cmd_m[i] = (char*)cmd_m_j[i]; @@ -200,33 +202,27 @@ void setLangMsg() { for(i = 0; i < 6; i++)savmsg[i] = (char*)savmsg_j[i]; } -static bool _isKanji1(u8 ch) { - if((ch >= 0x81) && (ch <= 0x9F)) - return true; - if((ch >= 0xE0) && (ch <= 0xEF)) - return true; - if((ch >= 0xFA) && (ch <= 0xFB)) // JIS X 0218‘¼ IBMŠg’£•¶Žš (0xFA40-0xFC4B) - return true; +static bool _isKanji1(u8 ch) { + if((ch >= 0x81) && (ch <= 0x9F))return true; + if((ch >= 0xE0) && (ch <= 0xEF))return true; + if((ch >= 0xFA) && (ch <= 0xFB))return true; // JIS X 0218‘¼ IBMŠg’£•¶Žš (0xFA40-0xFC4B) return false; } char *jstrncpy(char *s1, char *s2, size_t n) { - bool kan; + bool kan = false; - char *p = s1; + char *p = s1; while(n) { n--; kan = _isKanji1((u8)*s2); - if(!(*s1++ = *s2++)) - break; + if(!(*s1++ = *s2++))break; } - if(kan) - *(s1 - 1) = '\0'; + if(kan)*(s1 - 1) = '\0'; - while(n--) - *s1++ = '\0'; + while(n--)*s1++ = '\0'; *s1 = '\0'; diff --git a/arm9/source/save_sel.c b/arm9/source/save_sel.c index 2731dbc..a07338e 100644 --- a/arm9/source/save_sel.c +++ b/arm9/source/save_sel.c @@ -178,7 +178,3 @@ int save_sel(int mod, char *name) { return(cmd); } - - - - diff --git a/arm9/source/unicode.c b/arm9/source/unicode.c index cc83174..a5e2ca8 100644 --- a/arm9/source/unicode.c +++ b/arm9/source/unicode.c @@ -167,16 +167,14 @@ u32 _unistrnlen( const u16 * unistr, u32 maxlen ) return len; } -int _unistrncmp( const u16 * src, const u16 * dest, u32 maxlen ) -{ - if( NULL == src || NULL == dest ) - { - if( src == dest ) return NULL; +int _unistrncmp( const u16 * src, const u16 * dest, u32 maxlen ) { + if( NULL == src || NULL == dest ) { + // if( src == dest ) return NULL; + if( src == dest ) return -1; return (NULL == src ) ? -1 : 1; } - while( *src == *dest && maxlen && *src != 0x0000 && *dest != 0x0000 ) - { + while( *src == *dest && maxlen && *src != 0x0000 && *dest != 0x0000 ) { ++src; ++dest; --maxlen;