From a147d8503b368981a3854225bc48d3b223000766 Mon Sep 17 00:00:00 2001 From: miya Date: Fri, 5 Dec 2008 01:50:34 +0000 Subject: [PATCH] git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@61 7061adef-622a-194b-ae81-725974e89856 --- build/tools/sctools/common/src/font.c | 11 +- build/tools/sctools/common/src/font.h | 3 +- build/tools/sctools/common/src/gfx.c | 46 ++- build/tools/sctools/common/src/gfx.h | 1 + build/tools/sctools/common/src/key.c | 32 ++ build/tools/sctools/common/src/my_fs_util.c | 301 +++++++++++++++++- build/tools/sctools/common/src/mydata.h | 2 +- build/tools/sctools/common/src/netconnect.c | 30 +- build/tools/sctools/common/src/sitedefs.c | 1 - build/tools/sctools/common/src/text.c | 3 +- build/tools/sctools/common/src/text.h | 3 +- .../sctools/copy_dst/src/hatamotolib.cpp | 2 +- .../tools/sctools/copy_dst/src/hatamotolib.h | 2 +- build/tools/sctools/copy_dst/src/main.c | 78 +++-- build/tools/sctools/copy_org/src/main.c | 21 +- 15 files changed, 461 insertions(+), 75 deletions(-) diff --git a/build/tools/sctools/common/src/font.c b/build/tools/sctools/common/src/font.c index 47e306f..a1c4af8 100644 --- a/build/tools/sctools/common/src/font.c +++ b/build/tools/sctools/common/src/font.c @@ -29,7 +29,7 @@ #include #include "font.h" -const u32 d_CharData[0xe0 * 8] = { +const u32 d_CharData[0x80 * 8] = { 0x00000000,0x00000000,0x00000000,0x00000000, //0000 0x00000000,0x00000000,0x00000000,0x00000000, 0x11111111,0x11111111,0x11111111,0x11111111, //0001 @@ -287,9 +287,7 @@ const u32 d_CharData[0xe0 * 8] = { 0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000, //007F 0x00000000,0x00000000,0x00000000,0x00000000, - - // 0x00000000,0x00000000,0x00000000,0x00000000, //0080 - // 0x00000000,0x00000000,0x00000000,0x00000000, +#if 0 /* miya */ 0x11111111,0x11111111,0x11111111,0x11111111, //0080 0x11111111,0x11111111,0x11111111,0x11111111, 0x00000000,0x00000000,0x00000000,0x00000000, //0081 @@ -484,6 +482,7 @@ const u32 d_CharData[0xe0 * 8] = { 0x00000000,0x00000000,0x00000000,0x00000000, 0x00001110,0x00001010,0x00001110,0x00000000, //00DF ゜ 0x00000000,0x00000000,0x00000000,0x00000000, +#endif }; #if 0 @@ -510,8 +509,8 @@ const u32 d_PaletteData[8 * 16] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x7c1f0000, 0x00000000, 0x00000000, 0x00000000, // purple 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x7fe00000, 0x00000000, 0x00000000, 0x00000000, // light blue - 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x7fe00000, 0x001f03e0, 0x7c0003ff, 0x7c1f0000, // light blue + 0x7fe0000f, 0x01e03c00, 0x01ff0000, 0x00ef3dff, 0x000f0000, 0x00000000, 0x00000000, 0x00000000, // dark red 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01e00000, 0x00000000, 0x00000000, 0x00000000, // dark green diff --git a/build/tools/sctools/common/src/font.h b/build/tools/sctools/common/src/font.h index 046f655..76f02d5 100644 --- a/build/tools/sctools/common/src/font.h +++ b/build/tools/sctools/common/src/font.h @@ -1,7 +1,8 @@ #ifndef _FONT_H_ #define _FONT_H_ -extern const u32 d_CharData[0xe0 * 8]; +//extern const u32 d_CharData[0xe0 * 8]; +extern const u32 d_CharData[0x80 * 8]; extern const u32 d_PaletteData[8*16]; extern const u32 d_IconCharData[0x80 * 8]; extern const u16 d_IconPaletteData[16 * 4]; diff --git a/build/tools/sctools/common/src/gfx.c b/build/tools/sctools/common/src/gfx.c index e76fd12..6049ea8 100644 --- a/build/tools/sctools/common/src/gfx.c +++ b/build/tools/sctools/common/src/gfx.c @@ -9,20 +9,6 @@ #define DPR_HEIGHT_MAX 24 #define DPR_WIDTH_MAX 32 -static u16 sDPRScrnBuffer[DPR_HEIGHT_MAX * DPR_WIDTH_MAX] ATTRIBUTE_ALIGN(32); - - - -void Gfx_Set_BG1_Color(u16 col) -{ - int i,j; - for( i = 0 ; i < DPR_HEIGHT_MAX ; i++ ) { - for( j = 0 ; j < DPR_WIDTH_MAX ; j++ ) { - sDPRScrnBuffer[i*DPR_WIDTH_MAX + j] = (u16)( ((col & 0xf) << 12) | ((u16)0x80) ); - } - } - DC_FlushRange( (void *)&(sDPRScrnBuffer),sizeof(sDPRScrnBuffer)); -} @@ -44,6 +30,32 @@ static void VBlankIntr( void ); static u32 v_blank_intr_counter = 0; static u32 g_screen[MAX_VRAM_NUM][VRAM_SIZE/sizeof(u32)] ATTRIBUTE_ALIGN(32); +static u16 g_screen_bg1[MAX_VRAM_NUM][DPR_HEIGHT_MAX * DPR_WIDTH_MAX] ATTRIBUTE_ALIGN(32); + +void Gfx_Set_BG1_line_Color(int vram_num, int num_of_line, u16 col) +{ + int i,j; + for( i = 0 ; (i < num_of_line) && (i < DPR_HEIGHT_MAX); i++ ) { + for( j = 0 ; j < DPR_WIDTH_MAX ; j++ ) { + g_screen_bg1[vram_num][i*DPR_WIDTH_MAX + j] = (u16)( ((col & 0xf) << 12) | ((u16)0x01) ); + } + } + DC_FlushRange( (void *)(g_screen_bg1[vram_num]),(sizeof(u16)*DPR_HEIGHT_MAX * DPR_WIDTH_MAX)); +} + + +void Gfx_Set_BG1_Color(u16 col) +{ + int i,j,k; + for( k = 0 ; k < NUM_OF_SCREEN ; k++ ) { + for( i = 0 ; i < DPR_HEIGHT_MAX ; i++ ) { + for( j = 0 ; j < DPR_WIDTH_MAX ; j++ ) { + g_screen_bg1[k][i*DPR_WIDTH_MAX + j] = (u16)( ((col & 0xf) << 12) | ((u16)0x01) ); + } + } + DC_FlushRange( (void *)(g_screen_bg1[k]),(sizeof(u16)*DPR_HEIGHT_MAX * DPR_WIDTH_MAX)); + } +} void Gfx_Init(void) @@ -63,7 +75,7 @@ void Gfx_Init(void) // OS_TPrintf("Init start 1\n"); for( i = 0 ; i < NUM_OF_SCREEN ; i++) { tc[i] = &(textctrl[i]); - init_text(tc[i], (u16 *)&(g_screen[i]), palette_no); + init_text(tc[i], (u16 *)&(g_screen[i]), (u16 *)&(g_screen_bg1[i]), palette_no); } Gfx_Set_BG1_Color(0); @@ -186,8 +198,8 @@ static void VBlankIntr(void) GXS_LoadBG0Scr( (void *)&(g_screen[vram_num_sub]) , 0 , VRAM_SIZE ); - GX_LoadBG1Scr(sDPRScrnBuffer, 0, sizeof(sDPRScrnBuffer)); - GXS_LoadBG1Scr(sDPRScrnBuffer, 0, sizeof(sDPRScrnBuffer)); + GX_LoadBG1Scr( &(g_screen_bg1[vram_num_main]),0,(sizeof(u16)*DPR_HEIGHT_MAX * DPR_WIDTH_MAX)); + GXS_LoadBG1Scr( &(g_screen_bg1[vram_num_sub]),0,(sizeof(u16)*DPR_HEIGHT_MAX * DPR_WIDTH_MAX)); // 仮想OAMをVRAMに反映 diff --git a/build/tools/sctools/common/src/gfx.h b/build/tools/sctools/common/src/gfx.h index 75d3a09..03e88ee 100644 --- a/build/tools/sctools/common/src/gfx.h +++ b/build/tools/sctools/common/src/gfx.h @@ -9,6 +9,7 @@ extern "C" { void Gfx_Init(void); void Gfx_Render(int main_no, int sub_no); void Gfx_Set_BG1_Color(u16 col); +void Gfx_Set_BG1_line_Color(int vram_num, int num_of_line, u16 col); #ifdef __cplusplus } diff --git a/build/tools/sctools/common/src/key.c b/build/tools/sctools/common/src/key.c index 34bb05f..c95f472 100644 --- a/build/tools/sctools/common/src/key.c +++ b/build/tools/sctools/common/src/key.c @@ -4,18 +4,49 @@ static u16 old_keydata = 0; #define REPEAT_ON 1 #define REPEAT_COUNT 20 +#define ONLY_PLUS_KEY 1 static int repeat_counter[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; +#ifdef ONLY_PLUS_KEY +static u16 plus_key[4] = { + PAD_KEY_DOWN, + PAD_KEY_UP, + PAD_KEY_LEFT, + PAD_KEY_RIGHT +}; +#endif + u16 m_get_key_trigger(void) { u16 keydata; u16 trigger; int i; +#ifndef ONLY_PLUS_KEY u16 r; +#endif keydata = (u16)PAD_Read(); trigger = (u16)(keydata & (keydata ^ old_keydata)); +#ifdef ONLY_PLUS_KEY +#if REPEAT_ON + /* r = 1; */ + /* 十字ボタンだけリピートする。 */ + for( i = 0 ; i < 4 ; i++ ) { + if( plus_key[i] & old_keydata & keydata ) { + repeat_counter[i]++; + if( repeat_counter[i] > REPEAT_COUNT ) { + trigger |= (plus_key[i]); + } + } + else { + repeat_counter[i] = 0; + } + } +#endif + + +#else #if REPEAT_ON r = 1; for( i = 0 ; i < 15 ; i++ ) { @@ -30,6 +61,7 @@ u16 m_get_key_trigger(void) } r <<= 1; } +#endif #endif old_keydata = keydata; diff --git a/build/tools/sctools/common/src/my_fs_util.c b/build/tools/sctools/common/src/my_fs_util.c index c2ec610..ab43080 100644 --- a/build/tools/sctools/common/src/my_fs_util.c +++ b/build/tools/sctools/common/src/my_fs_util.c @@ -9,9 +9,10 @@ #define ATTRIBUTE_BACK 1 -/* このフラグどこかまずい!!!*/ #define COPY_FILE_ENCRYPTION 1 +#define LIMIT_BUF 1 +#define LIMIT_BUF_ALLOC 1 static BOOL miya_debug_flag = FALSE; static int miya_debug_counter = 0; @@ -108,8 +109,6 @@ typedef struct FSPathInfo */ -static const u32 BUF_SIZE = 256; - typedef struct { FSResult result; char string[32]; @@ -282,7 +281,7 @@ s32 my_fs_crypto_write(FSFile *f, void *ptr, s32 size) return writtenSize; } - +#if 0 static BOOL LoadFile(const char* path, char **alloc_ptr, int *alloc_size, FSFile *log_fd) { FSFile f; @@ -399,40 +398,201 @@ static BOOL SaveFile(const char* path, void* pData, u32 size, FSFile *log_fd) return TRUE; } +#endif + + +#ifdef LIMIT_BUF +//#define BUF_SIZE (16*1024) +//#define BUF_SIZE (512*1024) +#define BUF_SIZE (1*1024*1024) +#ifdef LIMIT_BUF_ALLOC +static char *pBuffer = NULL; +static char *pBuffer_crypto = NULL; +#else +static char pBuffer[BUF_SIZE]; +static char pBuffer_crypto[BUF_SIZE]; +#endif /* LIMIT_BUF_ALLOC */ +#endif + BOOL CopyFile(const char *dst_path, const char *src_path, FSFile *log_fd ) { - char *alloc_ptr = NULL; + BOOL ret_flag = TRUE; + +#ifdef LIMIT_BUF + FSFile f_src; + FSFile f_dst; + u32 restSize; + u32 tempSize; + u32 fileSize; + s32 readSize = 0; + FSResult fsResult; + s32 writtenSize; + + FS_InitFile(&f_src); + + if( FALSE == FS_OpenFileEx(&f_src, src_path, FS_FILEMODE_R) ) { + miya_log_fprintf(log_fd, "%s Failed Open File\n",__FUNCTION__); + miya_log_fprintf(log_fd, " path=%s\n", src_path ); + miya_log_fprintf(log_fd, " res=%s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(src_path) )); + return FALSE; + } + + fileSize = FS_GetFileLength(&f_src); + + FS_InitFile(&f_dst); + if( FALSE == FS_OpenFileEx(&f_dst, dst_path, FS_FILEMODE_W) ) { + FSResult res = FS_GetArchiveResultCode(dst_path); + if( res == FS_RESULT_NO_ENTRY ) { + /* 本来ここで問題なし */ + } + else { + miya_log_fprintf(log_fd, "%s Failed open file %d:\n", __FUNCTION__,__LINE__); + miya_log_fprintf(log_fd, " %s\n", dst_path ); + miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word(res) ); + } + } + else { + FS_CloseFile(&f_dst); + /* backup バックアップを取っておくべき?? */ + FS_DeleteFile(dst_path); + } + + FS_CreateFile(dst_path, (FS_PERMIT_R|FS_PERMIT_W)); + if( FALSE == FS_OpenFileEx(&f_dst, dst_path, FS_FILEMODE_W) ) { + miya_log_fprintf(log_fd, "%s Failed open file %d:\n", __FUNCTION__,__LINE__); + miya_log_fprintf(log_fd, " %s\n", dst_path ); + miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word(FS_GetArchiveResultCode(dst_path)) ); + ret_flag = FALSE; + goto exit_label; + + } + else { + fsResult = FS_SetFileLength(&f_dst, 0); + if( fsResult != FS_RESULT_SUCCESS ) { + miya_log_fprintf(log_fd, "%s Error: Set file len\n", __FUNCTION__); + miya_log_fprintf(log_fd, " %s\n", dst_path ); + miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word(fsResult) ); + ret_flag = FALSE; + goto exit_label; + } + } + +#ifdef LIMIT_BUF_ALLOC + if( pBuffer == NULL ) { + pBuffer = (char*)OS_Alloc( BUF_SIZE ); + if( pBuffer == NULL ) { + miya_log_fprintf(log_fd, "%s Mem alloc error: line %d size %d\n", __FUNCTION__, __LINE__,BUF_SIZE); + ret_flag = FALSE; + goto exit_label; + } + else { + // OS_TPrintf("pBuf addr = 0x%p\n",pBuffer); + } + } + if( pBuffer_crypto == NULL ) { + pBuffer_crypto = (char*)OS_Alloc( BUF_SIZE ); + if( pBuffer_crypto == NULL ) { + miya_log_fprintf(log_fd, "%s Mem alloc error: line %d size %d\n", __FUNCTION__, __LINE__,BUF_SIZE); + ret_flag = FALSE; + goto exit_label; + } + else { + // OS_TPrintf("pBufCrypt addr = 0x%p\n",pBuffer_crypto); + } + } +#endif + + restSize = fileSize; + + while( 1 ) { + if( restSize == 0 ) { + FS_FlushFile(&f_dst); + ret_flag = TRUE; + break; + } + else if( restSize > BUF_SIZE ) { + tempSize = BUF_SIZE; + } + else { + tempSize = restSize; + } + restSize -= tempSize; + + readSize = FS_ReadFile(&f_src, pBuffer, (s32)tempSize); + if( readSize != tempSize ) { + miya_log_fprintf(log_fd, "%s Failed Read File:%s\n",__FUNCTION__ , src_path ); + miya_log_fprintf(log_fd, " request size=%d read size=%d rest size %d\n", tempSize, readSize,restSize); + ret_flag = FALSE; + break; + } + else { + /* ここからWrite */ + writtenSize = FS_WriteFile(&f_dst, pBuffer, readSize); + if( writtenSize != readSize ) { + miya_log_fprintf(log_fd, "%s Failed write file %d:\n", __FUNCTION__,__LINE__); + miya_log_fprintf(log_fd, " %s\n", dst_path ); + miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word(FS_GetArchiveResultCode(dst_path)) ); + ret_flag = FALSE; + break; + } + } + } + exit_label: + + if( FALSE == FS_CloseFile(&f_src) ) { + miya_log_fprintf(log_fd, "%s Failed Close File\n", __FUNCTION__ ); + miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(src_path))); + } + if( FALSE == FS_CloseFile(&f_dst) ) { + miya_log_fprintf(log_fd, "%s Failed Close File\n", __FUNCTION__ ); + miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(dst_path))); + } + + +#else int alloc_size = 0; + char *alloc_ptr = NULL; + if( TRUE == LoadFile(src_path, &alloc_ptr, &alloc_size, log_fd) ) { if( TRUE == SaveFile(dst_path, alloc_ptr, (u32)alloc_size, log_fd) ) { - if( alloc_ptr ) { - OS_Free(alloc_ptr); - } - return TRUE; } - if( alloc_ptr ) { - OS_Free(alloc_ptr); + else { + ret_flag = FALSE; } - return FALSE; } - return FALSE; + else { + ret_flag = FALSE; + } + if( alloc_ptr ) { + OS_Free(alloc_ptr); + } +#endif + return ret_flag; } + #ifdef COPY_FILE_ENCRYPTION + static BOOL CopyFileCrypto(const char *dst_path, const char *src_path, FSFile *log_fd ) { FSFile f_src; FSFile f_dst; +#ifdef LIMIT_BUF + u32 restSize; + u32 tempSize; +#else char* pBuffer; + char* pBuffer_crypto; +#endif u32 fileSize; s32 readSize = 0; FSResult fsResult; s32 writtenSize; CRYPTORC4FastContext context; - char* pBuffer_crypto; + BOOL ret_flag = FALSE; if( miya_debug_flag ) { @@ -454,6 +614,116 @@ static BOOL CopyFileCrypto(const char *dst_path, const char *src_path, FSFile *l fileSize = FS_GetFileLength(&f_src); + +#ifdef LIMIT_BUF + + FS_InitFile(&f_dst); + if( FALSE == FS_OpenFileEx(&f_dst, dst_path, FS_FILEMODE_W) ) { + FSResult res = FS_GetArchiveResultCode(dst_path); + if( res == FS_RESULT_NO_ENTRY ) { + /* 本来ここで問題なし */ + } + else { + miya_log_fprintf(log_fd, "%s Failed open file %d:\n", __FUNCTION__,__LINE__); + miya_log_fprintf(log_fd, " %s\n", dst_path ); + miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word(res) ); + } + } + else { + FS_CloseFile(&f_dst); + /* backup バックアップを取っておくべき?? */ + FS_DeleteFile(dst_path); + } + + FS_CreateFile(dst_path, (FS_PERMIT_R|FS_PERMIT_W)); + if( FALSE == FS_OpenFileEx(&f_dst, dst_path, FS_FILEMODE_W) ) { + miya_log_fprintf(log_fd, "%s Failed open file %d:\n", __FUNCTION__,__LINE__); + miya_log_fprintf(log_fd, " %s\n", dst_path ); + miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word(FS_GetArchiveResultCode(dst_path)) ); + ret_flag = FALSE; + goto exit_label; + + } + else { + fsResult = FS_SetFileLength(&f_dst, 0); + if( fsResult != FS_RESULT_SUCCESS ) { + miya_log_fprintf(log_fd, "%s Error: Set file len\n", __FUNCTION__); + miya_log_fprintf(log_fd, " %s\n", dst_path ); + miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word(fsResult) ); + ret_flag = FALSE; + goto exit_label; + } + } + + +#ifdef LIMIT_BUF_ALLOC + if( pBuffer == NULL ) { + pBuffer = (char*)OS_Alloc( BUF_SIZE ); + if( pBuffer == NULL ) { + miya_log_fprintf(log_fd, "%s Mem alloc error: line %d size %d\n", __FUNCTION__, __LINE__,BUF_SIZE); + ret_flag = FALSE; + goto exit_label; + } + else { + // OS_TPrintf("pBuf addr = 0x%p\n",pBuffer); + } + + } + if( pBuffer_crypto == NULL ) { + pBuffer_crypto = (char*)OS_Alloc( BUF_SIZE ); + if( pBuffer_crypto == NULL ) { + miya_log_fprintf(log_fd, "%s Mem alloc error: line %d size %d\n", __FUNCTION__, __LINE__,BUF_SIZE); + ret_flag = FALSE; + goto exit_label; + } + else { + // OS_TPrintf("pBufCrypt addr = 0x%p\n",pBuffer_crypto); + } + } +#endif + + CRYPTO_RC4FastInit(&context, my_fs_key, my_fs_GetStringLength(my_fs_key)); + + restSize = fileSize; + + while( 1 ) { + if( restSize == 0 ) { + FS_FlushFile(&f_dst); + ret_flag = TRUE; + break; + } + else if( restSize > BUF_SIZE ) { + tempSize = BUF_SIZE; + } + else { + tempSize = restSize; + } + restSize -= tempSize; + + readSize = FS_ReadFile(&f_src, pBuffer, (s32)tempSize); + if( readSize != tempSize ) { + miya_log_fprintf(log_fd, "%s Failed Read File:%s\n",__FUNCTION__ , src_path ); + miya_log_fprintf(log_fd, " request size=%d read size=%d rest size %d\n", tempSize, readSize,restSize); + ret_flag = FALSE; + break; + } + else { + /* ここからWrite */ + CRYPTO_RC4FastEncrypt(&context, pBuffer, (u32)readSize, pBuffer_crypto); + + writtenSize = FS_WriteFile(&f_dst, pBuffer_crypto, readSize); + if( writtenSize != readSize ) { + miya_log_fprintf(log_fd, "%s Failed write file %d:\n", __FUNCTION__,__LINE__); + miya_log_fprintf(log_fd, " %s\n", dst_path ); + miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word(FS_GetArchiveResultCode(dst_path)) ); + ret_flag = FALSE; + break; + } + } + } + + +#else /* LIMIT_BUF */ pBuffer = (char*)OS_Alloc( fileSize ); if( pBuffer == NULL ) { miya_log_fprintf(log_fd, "%s Mem alloc error: %d\n", __FUNCTION__, fileSize); @@ -534,7 +804,8 @@ static BOOL CopyFileCrypto(const char *dst_path, const char *src_path, FSFile *l if( pBuffer_crypto != NULL ) { OS_Free(pBuffer_crypto); } - +#endif /* LIMIT_BUF */ + exit_label: if( FALSE == FS_CloseFile(&f_src) ) { miya_log_fprintf(log_fd, "%s Failed Close File\n", __FUNCTION__ ); miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(src_path))); diff --git a/build/tools/sctools/common/src/mydata.h b/build/tools/sctools/common/src/mydata.h index ba04a6c..f0135eb 100644 --- a/build/tools/sctools/common/src/mydata.h +++ b/build/tools/sctools/common/src/mydata.h @@ -3,7 +3,7 @@ #define MY_DATA_VERSION_MAJOR 1 -#define MY_DATA_VERSION_MINOR 0 +#define MY_DATA_VERSION_MINOR 1 typedef struct { u8 version_major; diff --git a/build/tools/sctools/common/src/netconnect.c b/build/tools/sctools/common/src/netconnect.c index 74f71fd..ac97844 100644 --- a/build/tools/sctools/common/src/netconnect.c +++ b/build/tools/sctools/common/src/netconnect.c @@ -95,10 +95,24 @@ typedef struct #endif +static u32 endian_conv(u32 addr) +{ + u32 temp = 0; + temp = ( addr >> 24 ) & 0xff; + temp |= ((( addr >> 16 ) & 0xff) << 8 ); + temp |= ((( addr >> 8 ) & 0xff) << 16 ); + temp |= (( addr & 0xff) << 24 ); + return temp; +} + + + static int ncStartWiFi(void) { int result; int timeout_counter; + SOCInAddr dns1; + SOCInAddr dns2; if (previousAddr != 0) { @@ -134,9 +148,10 @@ static int ncStartWiFi(void) socl_config.host_ip.my_ip = GetIPAddr(); socl_config.host_ip.dns_ip[0] = GetDNS1(); socl_config.host_ip.dns_ip[1] = GetDNS2(); - + OS_TPrintf("DNS1 0x%08x\n",GetDNS1()); + OS_TPrintf("DNS2 0x%08x\n",GetDNS2()); - OS_TPrintf("SOCL_Startup....\n"); + OS_TPrintf("SOCL_Startup1....\n"); result = SOCL_Startup(&socl_config); } else @@ -149,7 +164,7 @@ static int ncStartWiFi(void) soc_config.mtu = 0; soc_config.rwin = 0; - OS_TPrintf("SOC_Startup....\n"); + OS_TPrintf("SOC_Startup2....\n"); result = SOC_Startup(&soc_config); } if (result < 0) @@ -184,11 +199,20 @@ static int ncStartWiFi(void) } } + // int SOC_SetResolver(const SOCInAddr* dns1, const SOCInAddr* dns2) + if( GetDNS1() || GetDNS2()) { + dns1.addr = endian_conv(GetDNS1()); + dns2.addr = endian_conv(GetDNS2()); + (void)SOC_SetResolver(&dns1, &dns2); + } + OS_TPrintf("IP addr = %3d.%3d.%3d.%3d\n", CPS_CV_IPv4(CPSMyIp)); OS_TPrintf("NetMask = %3d.%3d.%3d.%3d\n", CPS_CV_IPv4(CPSNetMask)); OS_TPrintf("GW addr = %3d.%3d.%3d.%3d\n", CPS_CV_IPv4(CPSGatewayIp)); OS_TPrintf("DNS[0] = %3d.%3d.%3d.%3d\n", CPS_CV_IPv4(CPSDnsIp[0])); OS_TPrintf("DNS[1] = %3d.%3d.%3d.%3d\n", CPS_CV_IPv4(CPSDnsIp[1])); + + return 0; } diff --git a/build/tools/sctools/common/src/sitedefs.c b/build/tools/sctools/common/src/sitedefs.c index 7b30277..7f59dc8 100644 --- a/build/tools/sctools/common/src/sitedefs.c +++ b/build/tools/sctools/common/src/sitedefs.c @@ -19,7 +19,6 @@ #include #include "sitedefs.h" - /* c:/twlsdk/include/nitro/env/env_system.h */ diff --git a/build/tools/sctools/common/src/text.c b/build/tools/sctools/common/src/text.c index 2342214..302deaf 100644 --- a/build/tools/sctools/common/src/text.c +++ b/build/tools/sctools/common/src/text.c @@ -134,9 +134,10 @@ static void init_text_buf(TEXT_BUF *tb) } -void init_text(TEXT_CTRL *tc, u16 *screen, u16 palette) +void init_text(TEXT_CTRL *tc, u16 *screen, u16 *screen_bg1, u16 palette) { tc->screen = screen; + tc->screen_bg1 = screen_bg1; tc->x_line = 0; tc->y_line = 0; tc->palette = palette; diff --git a/build/tools/sctools/common/src/text.h b/build/tools/sctools/common/src/text.h index 09b2c67..572c8cc 100644 --- a/build/tools/sctools/common/src/text.h +++ b/build/tools/sctools/common/src/text.h @@ -60,6 +60,7 @@ typedef struct { typedef struct { TEXT_BUF text_buf; u16 *screen; + u16 *screen_bg1; u16 x_line; u16 y_line; u16 palette; @@ -78,7 +79,7 @@ int init_text_buf_sys(void *heap_start, void *heap_end); void m_putchar(TEXT_CTRL *tc, int c); void m_set_palette(TEXT_CTRL *tc, u16 num); u16 m_get_palette(TEXT_CTRL *tc); -void init_text(TEXT_CTRL *tc, u16 *screen, u16 palette); +void init_text(TEXT_CTRL *tc, u16 *screen, u16 *screen_bg1, u16 palette); void m_set_display_offset_y(TEXT_CTRL *tc, int offset); int m_get_display_offset_y(TEXT_CTRL *tc); void m_set_display_offset_x(TEXT_CTRL *tc, int offset); diff --git a/build/tools/sctools/copy_dst/src/hatamotolib.cpp b/build/tools/sctools/copy_dst/src/hatamotolib.cpp index 72860e4..1bca0b9 100644 --- a/build/tools/sctools/copy_dst/src/hatamotolib.cpp +++ b/build/tools/sctools/copy_dst/src/hatamotolib.cpp @@ -633,7 +633,7 @@ static int a_to_int(char c) return -1; } -static BOOL Tid_To_GameCode(u64 tid, char *gcode) +BOOL Tid_To_GameCode(u64 tid, char *gcode) { u32 code; char *str; diff --git a/build/tools/sctools/copy_dst/src/hatamotolib.h b/build/tools/sctools/copy_dst/src/hatamotolib.h index 665935c..9b896db 100644 --- a/build/tools/sctools/copy_dst/src/hatamotolib.h +++ b/build/tools/sctools/copy_dst/src/hatamotolib.h @@ -27,7 +27,7 @@ void DeleteECDirectory(void); void SetupTitlesDataFile(const NAMTitleId* pTitleIds, u32 numTitleIds); FSFile *hatamotolib_log_start(char *log_file_name ); void hatamotolib_log_end(void); - +BOOL Tid_To_GameCode(u64 tid, char *gcode); #ifdef __cplusplus } diff --git a/build/tools/sctools/copy_dst/src/main.c b/build/tools/sctools/copy_dst/src/main.c index a5771a2..9492076 100644 --- a/build/tools/sctools/copy_dst/src/main.c +++ b/build/tools/sctools/copy_dst/src/main.c @@ -83,7 +83,8 @@ static volatile BOOL reboot_flag; static int miya_debug_level = 0; - +static OSHeapHandle hHeap; +static u32 allocator_total_size = 0; static u8 WorkForNA[NA_VERSION_DATA_WORK_SIZE]; @@ -201,71 +202,73 @@ static BOOL LoadWlanConfig(void) int i; /* ユーザーデータ書き込みモード */ if( TRUE == LoadWlanConfigFile("sdmc:/wlan_cfg.txt") ) { OS_TPrintf("SSID = %s\n", GetWlanSSID()); - mfprintf(tc[3],"SSID = %s\n", GetWlanSSID()); OS_TPrintf("MODE = "); +#if 0 + mfprintf(tc[3],"SSID = %s\n", GetWlanSSID()); mfprintf(tc[3],"MODE = "); - +#endif switch( GetWlanMode() ) { case WCM_WEPMODE_NONE: OS_TPrintf("NONE\n"); - mfprintf(tc[3],"NONE\n"); + // mfprintf(tc[3],"NONE\n"); break; case WM_WEPMODE_40BIT: - OS_TPrintf("WEP128\n"); - mfprintf(tc[3],"WEP128\n"); + OS_TPrintf("WEP40\n"); + // mfprintf(tc[3],"WEP128\n"); break; case WM_WEPMODE_104BIT: - OS_TPrintf("WEP128\n"); - mfprintf(tc[3],"WEP128\n"); + OS_TPrintf("WEP104\n"); + // mfprintf(tc[3],"WEP128\n"); break; case WM_WEPMODE_128BIT: OS_TPrintf("WEP128\n"); - mfprintf(tc[3],"WEP128\n"); + // mfprintf(tc[3],"WEP128\n"); break; case WCM_WEPMODE_WPA_TKIP: OS_TPrintf("WPA-TKIP\n"); - mfprintf(tc[3],"WPA-TKIP\n"); + // mfprintf(tc[3],"WPA-TKIP\n"); break; case WCM_WEPMODE_WPA2_TKIP: OS_TPrintf("WPA2-TKIP\n"); - mfprintf(tc[3],"WPA2-TKIP\n"); + // mfprintf(tc[3],"WPA2-TKIP\n"); break; case WCM_WEPMODE_WPA_AES: OS_TPrintf("WPA-AES\n"); - mfprintf(tc[3],"WPA-AES\n"); + // mfprintf(tc[3],"WPA-AES\n"); break; case WCM_WEPMODE_WPA2_AES : OS_TPrintf("WPA2-AES\n"); - mfprintf(tc[3],"WPA2-AES\n"); + // mfprintf(tc[3],"WPA2-AES\n"); break; defalut: OS_TPrintf("Unknow mode..\n"); - mfprintf(tc[3],"Unknow mode..\n"); + // mfprintf(tc[3],"Unknow mode..\n"); break; } if( TRUE == GetKeyModeStr() ) { OS_TPrintf("KEY STR = %s\n", GetWlanKEYSTR()); - mfprintf(tc[3],"KEY STR = %s\n", GetWlanKEYSTR()); + // mfprintf(tc[3],"KEY STR = %s\n", GetWlanKEYSTR()); } else { len = GetWlanKEYBIN(buf); if( len ) { OS_TPrintf("KEY BIN = 0x"); - mfprintf(tc[3],"KEY BIN = 0x"); + // mfprintf(tc[3],"KEY BIN = 0x"); for( i = 0 ; i < len ; i++ ) { OS_TPrintf("%02X",buf[i]); - mfprintf(tc[3],"%02X",buf[i]); + // mfprintf(tc[3],"%02X",buf[i]); } OS_TPrintf("\n"); - mfprintf(tc[3],"\n"); + // mfprintf(tc[3],"\n"); } } - mfprintf(tc[3],"\n"); + // mfprintf(tc[3],"\n"); if( TRUE == GetDhcpMODE() ) { - mfprintf(tc[3],"DHCP client\n"); + // mfprintf(tc[3],"DHCP client\n"); } +#if 0 else { u32 addr_temp; addr_temp = GetIPAddr(); @@ -289,12 +292,12 @@ static BOOL LoadWlanConfig(void) (u32)((addr_temp >> 8) & 0xff),(u32)(addr_temp & 0xff) ); } mfprintf(tc[3],"\n"); - +#endif } else { OS_TPrintf("Invalid wlan cfg file\n"); - mfprintf(tc[3],"Invalid wlan cfg file\n"); + // mfprintf(tc[3],"Invalid wlan cfg file\n"); mprintf("Invalid wlan cfg file\n"); return FALSE; } @@ -506,6 +509,7 @@ static BOOL RestoreFromSDCard7(void) BOOL ret_flag = TRUE; FSFile *log_fd; int ec_download_ret; + char game_code_buf[5]; title_id_buf_ptr = NULL; title_id_count = 0; @@ -540,8 +544,10 @@ static BOOL RestoreFromSDCard7(void) m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); for( i = 0; i < title_id_count ; i++ ) { u64 tid = *(title_id_buf_ptr + i ); - mprintf(" id %02d %08X %08X\n", i,(u32)(tid >> 32), (u32)tid); - miya_log_fprintf(log_fd," id %02d %08X %08X\n", i,(u32)(tid >> 32), (u32)tid); + (void)Tid_To_GameCode(tid, game_code_buf); + game_code_buf[4] = '\0'; + mprintf(" id %08X %08X [%s]\n", (u32)(tid >> 32), (u32)tid, game_code_buf); + miya_log_fprintf(log_fd," id %08X %08X [%s]\n", (u32)(tid >> 32), (u32)tid, game_code_buf); } } else { @@ -804,6 +810,8 @@ static void MyThreadProc(void *arg) BOOL twl_card_validation_flag; u32 command; + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + while( 1 ) { (void)OS_SendMessage(&MyMesgQueue_response, (OSMessage)0, OS_MESSAGE_NOBLOCK); (void)OS_ReceiveMessage(&MyMesgQueue_request, &message, OS_MESSAGE_BLOCK); @@ -813,10 +821,20 @@ static void MyThreadProc(void *arg) command = (u32)message; switch( command ) { case THREAD_COMMAND_FULL_FUNCTION: + if( miya_debug_level == 1 ) { + m_set_palette(tc[0], M_TEXT_COLOR_PINK ); + mprintf("Free mem size %d bytes\n", OS_GetTotalFreeSize(OS_ARENA_MAIN, hHeap)); + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + } for( function_counter = 0 ; function_counter < function_table_max ; function_counter++ ) { if( FALSE == (function_table[function_counter])() ) { flag = FALSE; } + if( miya_debug_level == 1 ) { + m_set_palette(tc[0], M_TEXT_COLOR_PINK ); + mprintf("Free mem size %d bytes\n", OS_GetTotalFreeSize(OS_ARENA_MAIN, hHeap)); + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + } } break; case THREAD_COMMAND_WIFI_FUNCTION: @@ -923,6 +941,8 @@ static void MyThreadProcNuc(void *arg) FSFile *log_fd; BOOL ret_flag; + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + while( 1 ) { (void)OS_SendMessage(&MyMesgQueue_response, (OSMessage)0, OS_MESSAGE_NOBLOCK); (void)OS_ReceiveMessage(&MyMesgQueue_request, &message, OS_MESSAGE_BLOCK); @@ -939,7 +959,6 @@ static void MyThreadProcNuc(void *arg) continue; } - mprintf("-Wireless AP conf. load "); if( TRUE == LoadWlanConfig() ) { m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */ @@ -1061,7 +1080,6 @@ static BOOL myTWLCardCallback( void ) void TwlMain(void) { void* newArenaLo; - OSHeapHandle hHeap; u16 keyData; int loop_counter = 0; int save_dir_info = 0; @@ -1121,6 +1139,9 @@ void TwlMain(void) hHeap = OS_CreateHeap(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi()); OS_SetCurrentHeap(OS_ARENA_MAIN, hHeap); + allocator_total_size = OS_GetTotalFreeSize(OS_ARENA_MAIN, hHeap); + + Gfx_Init(); RTC_Init(); @@ -1344,6 +1365,9 @@ void TwlMain(void) } loop_start: + + Gfx_Set_BG1_line_Color(1, 2, (u16)M_TEXT_COLOR_ORANGE); + while( 1 ) { Gfx_Render( vram_num_main , vram_num_sub ); OS_WaitVBlankIntr(); @@ -1568,6 +1592,8 @@ void TwlMain(void) } #endif else if ( keyData & PAD_BUTTON_SELECT ) { + miya_debug_level ^= 1; + mprintf("debug level %d\n", miya_debug_level ); } else if ( keyData & PAD_BUTTON_X ) { if( TRUE == reboot_flag ) { diff --git a/build/tools/sctools/copy_org/src/main.c b/build/tools/sctools/copy_org/src/main.c index 7b43059..a09c3ea 100644 --- a/build/tools/sctools/copy_org/src/main.c +++ b/build/tools/sctools/copy_org/src/main.c @@ -50,6 +50,8 @@ static BOOL development_console_flag = FALSE; //static int miya_debug_level = 0; +static u32 allocator_total_size = 0; +static OSHeapHandle hHeap; static void SDEvents(void *userdata, FSEvent event, void *arg) { @@ -527,6 +529,12 @@ static void MyThreadProc(void *arg) (void)CleanSDCardFiles(NULL); mprintf("done.\n"); } + else { + m_set_palette(tc[0], M_TEXT_COLOR_PINK ); + mprintf("Free mem size %d bytes\n", OS_GetTotalFreeSize(OS_ARENA_MAIN, hHeap)); + // OS_GetTotalAllocSize(OSArenaId id, OSHeapHandle heap) + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + } flag = TRUE; twl_card_validation_flag = TRUE; @@ -543,6 +551,12 @@ static void MyThreadProc(void *arg) if( FALSE == (function_table[function_counter])() ) { flag = FALSE; } + if( no_sd_clean_flag == TRUE ) { + m_set_palette(tc[0], M_TEXT_COLOR_PINK ); + mprintf("Free mem size %d bytes\n", OS_GetTotalFreeSize(OS_ARENA_MAIN, hHeap)); + // OS_GetTotalAllocSize(OSArenaId id, OSHeapHandle heap) + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + } } mprintf("\n"); if( flag == TRUE ) { @@ -605,7 +619,6 @@ static BOOL myTWLCardCallback( void ) void TwlMain(void) { void* newArenaLo; - OSHeapHandle hHeap; u16 keyData; int loop_counter = 0; int save_dir_info = 0; @@ -650,6 +663,9 @@ void TwlMain(void) hHeap = OS_CreateHeap(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi()); OS_SetCurrentHeap(OS_ARENA_MAIN, hHeap); + + allocator_total_size = OS_GetTotalFreeSize(OS_ARENA_MAIN, hHeap); + Gfx_Init(); RTC_Init(); @@ -701,6 +717,7 @@ void TwlMain(void) } + // 不要:NAM の初期化 // NAM_Init(&AllocForNAM, &FreeForNAM); @@ -849,6 +866,8 @@ void TwlMain(void) stream_play0(); /* cursor.aiff */ } + Gfx_Set_BG1_line_Color(1, 2, (u16)M_TEXT_COLOR_PURPLE); + while( 1 ) { OS_WaitVBlankIntr(); Gfx_Render( vram_num_main , vram_num_sub );