From e7e17a311559040a8adcdbb4152e6c153004bbc6 Mon Sep 17 00:00:00 2001 From: miya Date: Mon, 20 Oct 2008 10:37:16 +0000 Subject: [PATCH] git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@15 7061adef-622a-194b-ae81-725974e89856 --- build/tools/sctools/copy_dst/Makefile | 2 +- build/tools/sctools/copy_dst/src/main.c | 337 ++++++-------------- build/tools/sctools/copy_dst/src/mfiler.c | 359 ++++++++++++++++++++++ build/tools/sctools/copy_dst/src/mfiler.h | 32 ++ build/tools/sctools/copy_org/src/main.c | 12 +- 5 files changed, 487 insertions(+), 255 deletions(-) create mode 100644 build/tools/sctools/copy_dst/src/mfiler.c create mode 100644 build/tools/sctools/copy_dst/src/mfiler.h diff --git a/build/tools/sctools/copy_dst/Makefile b/build/tools/sctools/copy_dst/Makefile index 2059f5e..fa544b6 100644 --- a/build/tools/sctools/copy_dst/Makefile +++ b/build/tools/sctools/copy_dst/Makefile @@ -22,7 +22,7 @@ TWL_ARCHGEN := LIMITED SRCDIR = ../common/src ./src -SRCS = main.c key.c font.c text.c mprintf.c logprintf.c \ +SRCS = main.c mfiler.c key.c font.c text.c mprintf.c logprintf.c \ gfx.c hwi.c mynvram.c my_fs_util.c \ kpsc.cpp ecdl.cpp hatamotolib.cpp \ sitedefs.c wcm_control.c netconnect.c mywlan.c \ diff --git a/build/tools/sctools/copy_dst/src/main.c b/build/tools/sctools/copy_dst/src/main.c index 9c441d5..09d048a 100644 --- a/build/tools/sctools/copy_dst/src/main.c +++ b/build/tools/sctools/copy_dst/src/main.c @@ -35,6 +35,7 @@ #include "nuc.h" #include "myfilename.h" +#include "mfiler.h" //================================================================================ @@ -76,7 +77,6 @@ static void MyThreadProc(void *arg); static OSMessage MyMesgBuffer[1]; static OSMessageQueue MyMesgQueue; - static void init_my_thread(void) { @@ -93,8 +93,24 @@ static void start_my_thread(void) (void)OS_SendMessage(&MyMesgQueue, (OSMessage)0, OS_MESSAGE_NOBLOCK); } +#if 0 +static BOOL RestoreFromSDCard1(void) +{ + mprintf("global info. data restore "); + if( TRUE == MydataSave( MyFile_GetGlobalInformationFileName(), (void *)&mydata, sizeof(MyData), NULL) ) { + m_set_palette(tc[0], 0x2); /* green */ + mprintf("OK.\n"); + } + else { + m_set_palette(tc[0], 0x1); /* red */ + mprintf("NG.\n"); + } + m_set_palette(tc[0], 0xF); /* white */ + return TRUE; +} +#endif -static void RestoreFromSDCard(void) +static BOOL RestoreFromSDCard(void) { /* ユーザーデータ書き込みモード */ if( TRUE == LoadWlanConfigFile("sdmc:/wlan_cfg.txt") ) { @@ -142,217 +158,19 @@ static void RestoreFromSDCard(void) OS_TPrintf("Invalid wlan cfg file\n"); } nuc_main(); + return TRUE; } -static void BackupToSDCard(void) +typedef BOOL (*function_ptr)(void); + +static function_ptr function_table[] = { - MY_DIR_ENTRY_LIST *dir_entry_list_head = NULL; - RTCDate rtc_date; - RTCTime rtc_time; - int save_dir_info = 0; - u64 *pBuffer; - int count; - int j; - u64 *ptr; + RestoreFromSDCard +}; +static int function_table_max = sizeof(function_table) / sizeof(*function_table); +static int function_counter = 0; - //miya mprintf("BACKUP to SD Card\n"); - /************************************/ - MyFile_SetPathBase("sdmc:/"); - MyFile_AddPathBase((const char *)hws_info.serialNo ); - MyFile_AddPathBase("/"); - - - /* nand:/sysディレクトリまわりの保存 */ - mprintf("Unique ID backup "); - if( TRUE == MiyaBackupHWNormalInfo( MyFile_GetUniqueIDFileName() ) ) { - m_set_palette(tc[0], 0x2); /* green */ - mprintf("OK.\n"); - } - else { - m_set_palette(tc[0], 0x1); /* red */ - mprintf("NG.\n"); - } - m_set_palette(tc[0], 0xF); /* white */ - - - /* Wifi設定の保存 */ - mprintf("WirelessLAN param. backup "); - if( TRUE == nvram_backup( MyFile_GetWifiParamFileName() ) ) { - m_set_palette(tc[0], 0x2); /* green */ - mprintf("OK.\n"); - } - else { - m_set_palette(tc[0], 0x1); /* red */ - mprintf("NG.\n"); - } - m_set_palette(tc[0], 0xF); /* white */ - - /* nand:/shared1ディレクトリまわりの保存 */ - mprintf("User setting param. backup "); - if( TRUE == MiyaBackupTWLSettings( MyFile_GetUserSettingsFileName() ) ) { - m_set_palette(tc[0], 0x2); /* green */ - mprintf("OK.\n"); - } - else { - m_set_palette(tc[0], 0x1); /* red */ - mprintf("NG.\n"); - } - m_set_palette(tc[0], 0xF); /* white */ - - - /* - nand:/shared2ディレクトリまわりの保存 - 内容はアプリケーション共有ファイル - nand:/shared2/* - */ - mprintf("App. shared files backup "); - if( 0 == copy_r( &dir_entry_list_head, MyFile_GetAppSharedSaveDirName() , "nand:/shared2" , MyFile_GetAppSharedLogFileName(),0 ) ) { - // PrintDirEntryListBackward( dir_entry_list_head, NULL ); - mydata.num_of_shared2_files = SaveDirEntryList( dir_entry_list_head, MyFile_GetAppSharedListFileName() ); - m_set_palette(tc[0], 0x2); /* green */ - mprintf("OK.\n"); - } - else { - m_set_palette(tc[0], 0x1); /* red */ - mprintf("NG.\n"); - } - m_set_palette(tc[0], 0xF); /* white */ - (void)ClearDirEntryList( &dir_entry_list_head ); - - - /* - nand2:/photoディレクトリまわりの保存 - 内容は写真長のJPEGファイル - nand2:/photo/*.* - */ - mprintf("Photo files backup "); - if( 0 == copy_r( &dir_entry_list_head, MyFile_GetPhotoSaveDirName() , "nand2:/photo" , MyFile_GetPhotoLogFileName(), 0 ) ) { - // PrintDirEntryListBackward( dir_entry_list_head, NULL ); - mydata.num_of_photo_files = SaveDirEntryList( dir_entry_list_head, MyFile_GetPhotoListFileName() ); - m_set_palette(tc[0], 0x2); /* green */ - mprintf("OK.\n"); - } - else { - m_set_palette(tc[0], 0x1); /* red */ - mprintf("NG.\n"); - } - m_set_palette(tc[0], 0xF); /* white */ - (void)ClearDirEntryList( &dir_entry_list_head ); - - - /* nand:/ticketはチケット同期?でうまいこと合わせてくれるんでバックアップ不要 */ - - /* - nand:/titleディレクトリまわりの保存 - nand:/title/*.savファイルをすべてバックアップ - */ - - mprintf("App. save data backup "); - if( 0 == find_title_save_data( &dir_entry_list_head, MyFile_GetAppDataSaveDirName(), "nand:/title", - &save_dir_info, MyFile_GetAppDataLogFileName(), 0 ) ) - { - // PrintDirEntryListBackward( dir_entry_list_head, NULL ); - mydata.num_of_app_save_data = SaveDirEntryList( dir_entry_list_head , MyFile_GetAppDataListFileName() ); - m_set_palette(tc[0], 0x2); /* green */ - mprintf("OK.\n"); - } - else { - m_set_palette(tc[0], 0x1); /* red */ - mprintf("NG.\n"); - } - m_set_palette(tc[0], 0xF); /* white */ - (void)ClearDirEntryList( &dir_entry_list_head ); - - - - /* タイトルリストの生成 */ - /* - nand:/title/00030004/ - - nand:/title/00030004/34626241/content/title.tmd - nand:/title/00030004/34626241/content/00000000.app - nand:/title/00030004/34626241/data/ - - nand:/title/00030017/484e4141 は ランチャー - nand:/title/00030015/484e4641 は shop - nand:/title/00030015/484e4241 は 本体設定 - - - No. 0 0003000f484e4c41 - No. 1 0003000f484e4841 - No. 2 0003000f484e4341 - No. 3 00030015484e4241 - No. 4 00030017484e4141 launcher - ^ - | ここの最下位ビットが1のやつがシステムアプリ - | - システムアプリはダウンロード対象外 - */ - // STD_StrCpy( path , path_base ); - // STD_StrCat( path , MY_FILE_NAME_DOWNLOAD_TITLE_ID_DATA ); - if( 0 == get_title_id( &dir_entry_list_head, "nand:/title", &save_dir_info, MyFile_GetDownloadTitleIDLogFileName(), 0 ) ) { - mprintf("get_title_id completed.\n"); - OS_TPrintf("get_title_id completed.\n"); - - GetDirEntryList( dir_entry_list_head, &pBuffer, &count); - OS_TPrintf("count = %d\n", count ); - ptr = pBuffer; - mydata.num_of_user_download_app = count; - - if( ptr != NULL && count != 0 ) { - for( j = 0 ; j < count ; j++ ) { - OS_TPrintf("No. %d ",j); - mfprintf(tc[2],"No. %d ",j); - - OS_TPrintf("%llx\n", *ptr); - mfprintf(tc[2],"%llx\n", *ptr); - ptr++; - } - OS_Free(pBuffer); - } - // (void)TitleIDSave( MyFile_GetDownloadTitleIDFileName(), u64 *pData, count, NULL); - PrintSrcDirEntryListBackward( dir_entry_list_head, NULL ); - } - (void)ClearDirEntryList( &dir_entry_list_head ); - - - - /* オリジナルのデータのバックアップ */ - if( TRUE == CheckShopRecord(NULL) ) { - mydata.shop_record_flag = TRUE; - OS_TPrintf("shop record exist - you don't have to connect the network.\n"); - mprintf("shop record exist\n"); - } - else { - mydata.shop_record_flag = FALSE; - OS_TPrintf("no shop record\n - you don't have to connect the network.\n"); - mprintf("no shop record\n"); - } - - if( RTC_RESULT_SUCCESS != RTC_GetDate( &rtc_date ) ) { - mprintf("rtc read date error.\n"); - } - if( RTC_RESULT_SUCCESS != RTC_GetTime( &rtc_time ) ) { - mprintf("rtc read time error.\n"); - } - - STD_CopyMemory( (void *)&(mydata.rtc_date), (void *)&rtc_date, sizeof(RTCDate) ); - STD_CopyMemory( (void *)&(mydata.rtc_time), (void *)&rtc_time, sizeof(RTCTime) ); - STD_CopyMemory( (void *)(mydata.movableUniqueID), (void *)hwn_info.movableUniqueID, - LCFG_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN ); - mprintf("org. data backup "); - if( TRUE == MydataSave( MyFile_GetGlobalInformationFileName(), (void *)&mydata, sizeof(MyData), NULL) ) { - m_set_palette(tc[0], 0x2); /* green */ - mprintf("OK.\n"); - } - else { - m_set_palette(tc[0], 0x1); /* red */ - mprintf("NG.\n"); - } - m_set_palette(tc[0], 0xF); /* white */ - -} static void MyThreadProc(void *arg) { @@ -360,8 +178,13 @@ static void MyThreadProc(void *arg) OSMessage message; while( 1 ) { (void)OS_ReceiveMessage(&MyMesgQueue, &message, OS_MESSAGE_BLOCK); - //RestoreFromSDCard(); - BackupToSDCard(); + for( function_counter = 0 ; function_counter < function_table_max ; function_counter++ ) { + (void)(function_table[function_counter])(); + } + if( TRUE == stream_is_play1_end() ) { + OS_TPrintf("stream play\n"); + stream_play1(); + } } } @@ -376,11 +199,10 @@ void TwlMain(void) MY_DIR_ENTRY_LIST *dir_entry_list_head = NULL; RTCDate rtc_date; RTCTime rtc_time; - // LCFGTWLHWNormalInfo hwn_info; - // LCFGTWLHWSecureInfo hws_info; int i; int n; u8 macAddress[6]; + MY_ENTRY_LIST *mfiler_list_head = NULL; OS_Init(); OS_InitThread(); @@ -485,9 +307,9 @@ void TwlMain(void) mprintf("\n"); // mprintf(" RTC Adjust data = 0x%02x\n", hwn_info.rtcAdjust ); } - mprintf("\n"); + mprintf("\n"); + - // mprintf("HW Secure Info. read "); mprintf("Serial No. read "); if( FALSE == MiyaReadHWSecureInfo( &hws_info ) ) { @@ -499,16 +321,16 @@ void TwlMain(void) m_set_palette(tc[0], 0x2); /* green */ mprintf("OK.\n"); m_set_palette(tc[0], 0xF); /* white */ - mprintf(" %s\n\n", hws_info.serialNo); + mprintf(" %s\n", hws_info.serialNo); } + mprintf("\n"); OS_GetMacAddress( macAddress ); mprintf("MAC Address 0x"); for ( i = 0 ; i < 6 ; i++ ) { mprintf("%02X", macAddress[i]); } - mprintf("\n\n"); - + mprintf("\n"); if( FALSE == SDCardValidation() ) { @@ -521,22 +343,24 @@ void TwlMain(void) sd_card_flag = TRUE; } - // miya あとで消す。 - // sd_card_flag = FALSE; - +#if 0 + mprintf("\n\n"); + mprintf( "function no.%d/%d\n", function_counter, function_table_max); + mprintf("\n\n"); +#endif + FS_RegisterEventHook("sdmc", &sSDHook, SDEvents, NULL); init_my_thread(); - if( sd_card_flag == TRUE ) { - start_my_thread(); - } + MFILER_CurrentDir_Init(); while( 1 ) { - OS_WaitVBlankIntr(); Gfx_Render( vram_num_main , vram_num_sub ); + OS_WaitVBlankIntr(); + (void)RTC_GetDate( &rtc_date ); (void)RTC_GetTime( &rtc_time ); keyData = m_get_key_trigger(); @@ -560,12 +384,28 @@ void TwlMain(void) vram_num_main = (MAX_VRAM_NUM-1); } } - - else if ( keyData & PAD_BUTTON_A ) { /* ユーザーデータ吸出しモード */ if( sd_card_flag == TRUE ) { - start_my_thread(); + if( vram_num_main != 1 ) { + } + else { + if( TRUE == MFILER_Is_Cursor_Dir( &mfiler_list_head ) ) { + MyFile_SetPathBase("sdmc:/"); + MyFile_AddPathBase((const char *)MFILER_GetCursorEntryPath( &mfiler_list_head ) ); + MyFile_AddPathBase("/"); + if(TRUE == MydataLoad( MyFile_GetGlobalInformationFileName(), &mydata, sizeof(MyData), NULL) ) { + start_my_thread(); + } + else { + mprintf("Not a backup data directory\n"); + } + } + else { + mprintf("Not a backup data directory\n"); + // mprintf("global info. read failed(Not dir.)\n"); + } + } } else { mprintf("insert SD card\n"); @@ -578,22 +418,28 @@ void TwlMain(void) else if ( keyData & PAD_BUTTON_SELECT ) { } else if ( keyData & PAD_BUTTON_X ) { - OS_TPrintf("stream on\n"); - if( TRUE == stream_is_play1_end() ) { - stream_play1(); - } } else if ( keyData & PAD_BUTTON_Y ) { } else if ( keyData & PAD_KEY_UP ) { - n = m_get_display_offset_y(tc[0]); - n++; - m_set_display_offset_y(tc[0], n); + if( vram_num_main != 1 ) { + n = m_get_display_offset_y(tc[0]); + n++; + m_set_display_offset_y(tc[0], n); + } + else { + MFILER_CursorY_Up(); + } } else if ( keyData & PAD_KEY_DOWN ) { - n = m_get_display_offset_y(tc[0]); - n--; - m_set_display_offset_y(tc[0], n); + if( vram_num_main != 1 ) { + n = m_get_display_offset_y(tc[0]); + n--; + m_set_display_offset_y(tc[0], n); + } + else { + MFILER_CursorY_Down(); + } } else if ( keyData & PAD_KEY_RIGHT ) { n = m_get_display_offset_x(tc[0]); @@ -606,18 +452,15 @@ void TwlMain(void) m_set_display_offset_x(tc[0], n); } + mfprintf(tc[1], "\f%4d/%02d/%02d %02d:%02d:%02d\n\n", + rtc_date.year + 2000, rtc_date.month , rtc_date.day, + rtc_time.hour , rtc_time.minute , rtc_time.second ); - // mfprintf(tc[1], "\f\ncounter = %d\n\n", loop_counter); - mfprintf(tc[1], "\f\n%4d/%02d/%02d %02d:%02d:%02d\n\n", - rtc_date.year + 2000, rtc_date.month , rtc_date.day, - rtc_time.hour , rtc_time.minute , rtc_time.second ); + mfprintf(tc[1], "cwd = %s\n\n", MFILER_Get_CurrentDir()); - mfprintf(tc[1], "press A -> Store to SD Card\n"); - mfprintf(tc[1], "press B -> Load to NAND Flash\n"); - mfprintf(tc[1], "\n"); - - - + MFILER_ClearDir(&mfiler_list_head); + MFILER_ReadDir(&mfiler_list_head, MFILER_Get_CurrentDir()); + MFILER_DisplayDir(tc[1], &mfiler_list_head, 0 ); loop_counter++; diff --git a/build/tools/sctools/copy_dst/src/mfiler.c b/build/tools/sctools/copy_dst/src/mfiler.c new file mode 100644 index 0000000..d845f00 --- /dev/null +++ b/build/tools/sctools/copy_dst/src/mfiler.c @@ -0,0 +1,359 @@ +#include +#include "text.h" +#include "mprintf.h" +#include "gfx.h" +#include "my_fs_util.h" +#include "mfiler.h" + +#define DISPLAY_Y_MAX 16 +static int cursor_pos_y = 0; +static int display_offset_y = 0; +static int list_count_max = 0; + + +static MY_ENTRY_LIST *current_dir_list_head = NULL; + +static BOOL mfilter_add_list( MY_ENTRY_LIST **headp, FSDirectoryEntryInfo *entry_src, const char *src_path ) +{ + MY_ENTRY_LIST *list_temp; + MY_ENTRY_LIST *list_prev_temp; + + if( *headp == NULL ) { + *headp = (MY_ENTRY_LIST *)OS_Alloc( sizeof(MY_ENTRY_LIST) ); + (*headp)->prev = NULL; + (*headp)->next = NULL; + STD_CopyMemory( (void *)&((*headp)->content), (void *)entry_src ,sizeof(FSDirectoryEntryInfo) ); + STD_StrCpy((*headp)->src_path, src_path); + } + else { + for( list_temp = *headp ; list_temp->next != NULL ; list_temp = list_temp->next ) { + ; + } + list_temp->next = (MY_ENTRY_LIST *)OS_Alloc( sizeof(MY_ENTRY_LIST) ); + list_prev_temp = list_temp; + list_temp = list_temp->next; + list_temp->prev = list_prev_temp; + list_temp->next = NULL; + STD_CopyMemory( (void *)&(list_temp->content), (void *)entry_src ,sizeof(FSDirectoryEntryInfo) ); + STD_StrCpy(list_temp->src_path, src_path); + } + return TRUE; +} + +BOOL MFILER_Is_Cursor_Dir(MY_ENTRY_LIST **headp) +{ + MY_ENTRY_LIST *list_temp; + int cursor_pos = 0; + if( headp == NULL ) { + return FALSE; + } + else { + for( list_temp = *headp ; list_temp != NULL ; list_temp = list_temp->next ) { + if( cursor_pos == cursor_pos_y ) { + if( (list_temp->content.attributes & FS_ATTRIBUTE_IS_DIRECTORY) != 0 ) { + return TRUE; + } + else { + return FALSE; + } + } + cursor_pos++; + } + } + return FALSE; +} + + +char *MFILER_GetCursorFullPath(MY_ENTRY_LIST **headp) +{ + MY_ENTRY_LIST *list_temp; + int cursor_pos = 0; + if( headp == NULL ) { + return NULL; + } + else { + for( list_temp = *headp ; list_temp != NULL ; list_temp = list_temp->next ) { + if( cursor_pos == cursor_pos_y ) { + return list_temp->src_path; + } + cursor_pos++; + } + } + return NULL; +} + +char *MFILER_GetCursorEntryPath(MY_ENTRY_LIST **headp) +{ + MY_ENTRY_LIST *list_temp; + int cursor_pos = 0; + if( headp == NULL ) { + return NULL; + } + else { + for( list_temp = *headp ; list_temp != NULL ; list_temp = list_temp->next ) { + if( cursor_pos == cursor_pos_y ) { + return list_temp->content.longname; + } + cursor_pos++; + } + } + return NULL; +} + + +void MFILER_CurrentDir_Init(void) +{ + current_dir_list_head = (MY_ENTRY_LIST *)OS_Alloc( sizeof(MY_ENTRY_LIST) ); + current_dir_list_head->prev = NULL; + current_dir_list_head->next = NULL; + // STD_CopyMemory( (void *)&((*headp)->content), (void *)entry_src ,sizeof(FSDirectoryEntryInfo) ); + STD_StrCpy(current_dir_list_head->src_path, "sdmc:"); +} + +char *MFILER_Get_CurrentDir(void) +{ + MY_ENTRY_LIST *list_temp; + list_temp = current_dir_list_head; + while( list_temp != NULL ) { + if( list_temp->next == NULL ) { + return list_temp->src_path; + } + list_temp = list_temp->next; + } + return NULL; +} + +int MFILER_ReadDir(MY_ENTRY_LIST **headp, const char *path_src) +{ + FSFile f_src; + FSDirectoryEntryInfo entry_src; + BOOL bSuccess; + char *path_src_dir = NULL; + char *path_src_full = NULL; + + int ret_value = 0; + + FS_InitFile(&f_src); + bSuccess = FS_OpenDirectory(&f_src, path_src, FS_PERMIT_R); + if(!bSuccess) { +#if 0 + mprintf("Failed Open SRC Directory\n"); + mprintf(" %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path_src) )); +#endif + ret_value = -1; + goto end_process; + } + + path_src_dir = (char *)OS_Alloc( FILE_PATH_LEN ); + if( path_src_dir == NULL ) { +#if 0 + mprintf("Error: alloc error src_dir\n"); +#endif + ret_value = -1; + goto end_process; + } + path_src_full = (char *)OS_Alloc( FILE_PATH_LEN ); + if( path_src_full == NULL ) { +#if 0 + mprintf("Error: alloc error src_full\n"); +#endif + ret_value = -1; + goto end_process; + } + STD_MemSet((void *)path_src_dir, 0, FILE_PATH_LEN); + STD_MemSet((void *)path_src_full, 0, FILE_PATH_LEN); + STD_StrCpy(path_src_dir, path_src); + STD_StrCat(path_src_dir, "/"); + + + while( FS_ReadDirectory(&f_src, &entry_src) ) { +#if 1 + if( STD_StrCmp(entry_src.longname, ".") == 0 ) { + + } + else if( STD_StrCmp(entry_src.longname, "..") == 0 ) { + } + else if( entry_src.attributes & FS_ATTRIBUTE_DOS_VOLUME ) { + } + else { + STD_StrCpy( path_src_full , path_src_dir ); + STD_StrCat( path_src_full , entry_src.longname ); + mfilter_add_list( headp, &entry_src, path_src_full ); + } +#else + STD_StrCpy( path_src_full , path_src_dir ); + STD_StrCat( path_src_full , entry_src.longname ); + mfilter_add_list( headp, &entry_src, path_src_full ); +#endif + } + + bSuccess = FS_CloseDirectory(&f_src); + if(!bSuccess) { +#if 0 + mprintf("Failed Close SRC Directory\n"); + mprintf(" %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path_src) )); +#endif + ret_value = -1; + // goto end_process; + } + + end_process: + if( path_src_dir != NULL ) { + OS_Free(path_src_dir); + } + if( path_src_full != NULL ) { + OS_Free(path_src_full); + } + + return ret_value; +} + +void MFILER_DisplayDir(TEXT_CTRL *tc, MY_ENTRY_LIST **headp, int mode ) +{ + MY_ENTRY_LIST *list_temp; + // FSPathInfo path_info; + u32 attributes; + int list_count = 0; + int backslash_count = 0; + + mfprintf(tc, "page %d entry no. %d/%d mode=%d\n\n", display_offset_y, cursor_pos_y , list_count_max , mode); + + if( cursor_pos_y > list_count_max ) { + cursor_pos_y = 0; + } + + if( headp == NULL ) { + } + else { + for( list_temp = *headp ; list_temp != NULL ; list_temp = list_temp->next ) { + if( (display_offset_y <= list_count) && (list_count < (display_offset_y + DISPLAY_Y_MAX) )) { + if( list_count == cursor_pos_y ) { + m_set_palette( tc, 2 ); + m_putchar( tc, '*'); + m_set_palette(tc, 0xF); /* white */ + } + else { + m_putchar( tc, ' '); + } + switch( mode ) { + case 0: + attributes = list_temp->content.attributes; + ( attributes & FS_ATTRIBUTE_DOS_DIRECTORY )? m_putchar( tc, 'd') : m_putchar( tc, '-'); + ( attributes & FS_ATTRIBUTE_DOS_VOLUME )? m_putchar( tc, 'v') : m_putchar( tc, '-'); + ( attributes & FS_ATTRIBUTE_DOS_SYSTEM )? m_putchar( tc, 's') : m_putchar( tc, '-'); + ( attributes & FS_ATTRIBUTE_DOS_ARCHIVE )? m_putchar( tc, 'a') : m_putchar( tc, '-'); + ( attributes & FS_ATTRIBUTE_DOS_HIDDEN )? m_putchar( tc, 'h') : m_putchar( tc, '-'); + ( attributes & FS_ATTRIBUTE_DOS_READONLY )? m_putchar( tc, 'R') : m_putchar( tc, '-'); + m_putchar( tc, ' '); + mfprintf(tc, "%s\n", list_temp->content.longname ); + + break; + case 1: + mfprintf(tc, "size %7d ", list_temp->content.filesize); + mfprintf(tc, "%s\n", list_temp->content.longname ); + break; + case 2: + mfprintf(tc, "%s\n", list_temp->src_path ); + if( list_count == cursor_pos_y ) { + text_display_newline_on( &tc[1] ); + mfprintf(&tc[1], "\f\n%s\n", list_temp->src_path); + text_display_newline_off( &tc[1] ); + } + break; + case 3: + mfprintf(tc, "%4d/%02d/%02d %02d:%02d:%02d ", list_temp->content.mtime.year, + list_temp->content.mtime.month, list_temp->content.mtime.day, + list_temp->content.mtime.hour, list_temp->content.mtime.minute, + list_temp->content.mtime.second ); + + mfprintf(tc, "%s\n", list_temp->content.longname ); + break; + case 4: + mfprintf(tc, "%4d/%02d/%02d %02d:%02d:%02d ", list_temp->content.ctime.year, + list_temp->content.ctime.month, list_temp->content.ctime.day, + list_temp->content.ctime.hour, list_temp->content.ctime.minute, + list_temp->content.ctime.second ); + + mfprintf(tc, "%s\n", list_temp->content.longname ); + break; + case 5: + mfprintf(tc, "%4d/%02d/%02d %02d:%02d:%02d ", list_temp->content.atime.year, + list_temp->content.atime.month, list_temp->content.atime.day, + list_temp->content.atime.hour, list_temp->content.atime.minute, + list_temp->content.atime.second ); + mfprintf(tc, "%s\n", list_temp->content.longname ); + break; + } + backslash_count++; + } + list_count++; + } + } + list_count_max = list_count - 1; + + while( backslash_count++ < DISPLAY_Y_MAX ) { + m_putchar( tc, '\n'); + } +} + +BOOL MFILER_ClearDir(MY_ENTRY_LIST **headp) +{ + MY_ENTRY_LIST *list_temp1 = *headp; + MY_ENTRY_LIST *list_temp2; + + *headp = NULL; + + while( list_temp1 ) { + list_temp2 = list_temp1->next; + OS_Free( list_temp1 ); + list_temp1 = list_temp2; + } + return TRUE; +} + +void MFILER_SetCursorY(int pos_y) +{ + cursor_pos_y = pos_y; +} + +int MFILER_GetCursorY(void) +{ + return cursor_pos_y; +} + + +void MFILER_CursorY_Down( void ) +{ + + cursor_pos_y++; + if( cursor_pos_y > list_count_max ) { + // cursor_pos_y = list_count_max; + cursor_pos_y = 0; + } + + if( (cursor_pos_y % DISPLAY_Y_MAX) == 0 ) { + display_offset_y += DISPLAY_Y_MAX; + if( display_offset_y > list_count_max ) { + display_offset_y = 0; + } + } + +} + +void MFILER_CursorY_Up( void ) +{ + + cursor_pos_y--; + if( cursor_pos_y < 0 ) { + // cursor_pos_y = 0; + display_offset_y = (list_count_max / DISPLAY_Y_MAX) * DISPLAY_Y_MAX ; + cursor_pos_y = list_count_max; + } + + if( (cursor_pos_y % DISPLAY_Y_MAX) == (DISPLAY_Y_MAX-1) ) { + display_offset_y -= DISPLAY_Y_MAX; + if( display_offset_y < 0 ) { + display_offset_y = (list_count_max / DISPLAY_Y_MAX) * DISPLAY_Y_MAX ; + } + } +} diff --git a/build/tools/sctools/copy_dst/src/mfiler.h b/build/tools/sctools/copy_dst/src/mfiler.h new file mode 100644 index 0000000..53e0151 --- /dev/null +++ b/build/tools/sctools/copy_dst/src/mfiler.h @@ -0,0 +1,32 @@ +#ifndef _MFILER_H_ +#define _MFILER_H_ + + +typedef struct _MY_ENTRY_LIST { + struct _MY_ENTRY_LIST *prev; + struct _MY_ENTRY_LIST *next; + FSDirectoryEntryInfo content; + char src_path[ 512 ]; +} MY_ENTRY_LIST; + + +void MFILER_CurrentDir_Init(void); +char *MFILER_Get_CurrentDir(void); +void MFILER_Change_CurrentDir(const char *path); + +int MFILER_ReadDir(MY_ENTRY_LIST **headp, const char *path_src); +void MFILER_DisplayDir(TEXT_CTRL *tc, MY_ENTRY_LIST **headp, int mode); +BOOL MFILER_ClearDir(MY_ENTRY_LIST **headp); + +void MFILER_CursorY_Down( void ); +void MFILER_CursorY_Up( void ); + +void MFILER_SetCursorY(int pos_y); +int MFILER_GetCursorY(void); + +char *MFILER_GetCursorFullPath(MY_ENTRY_LIST **headp); +char *MFILER_GetCursorEntryPath(MY_ENTRY_LIST **headp); +BOOL MFILER_Is_Cursor_Dir(MY_ENTRY_LIST **headp); +BOOL MFILER_Is_Cursor_TextFile(MY_ENTRY_LIST **headp); + +#endif /* _MFILER_H_ */ diff --git a/build/tools/sctools/copy_org/src/main.c b/build/tools/sctools/copy_org/src/main.c index bd95f66..797161e 100644 --- a/build/tools/sctools/copy_org/src/main.c +++ b/build/tools/sctools/copy_org/src/main.c @@ -373,6 +373,10 @@ static void MyThreadProc(void *arg) for( function_counter = 0 ; function_counter < function_table_max ; function_counter++ ) { (void)(function_table[function_counter])(); } + OS_TPrintf("stream on\n"); + if( TRUE == stream_is_play1_end() ) { + stream_play1(); + } } } @@ -662,10 +666,6 @@ void TwlMain(void) else if ( keyData & PAD_BUTTON_SELECT ) { } else if ( keyData & PAD_BUTTON_X ) { - OS_TPrintf("stream on\n"); - if( TRUE == stream_is_play1_end() ) { - stream_play1(); - } } else if ( keyData & PAD_BUTTON_Y ) { } @@ -696,9 +696,7 @@ void TwlMain(void) rtc_date.year + 2000, rtc_date.month , rtc_date.day, rtc_time.hour , rtc_time.minute , rtc_time.second ); - mfprintf(tc[1], "press A -> Store to SD Card\n"); - mfprintf(tc[1], "press B -> Load to NAND Flash\n"); - mfprintf(tc[1], "\n"); + mfprintf(tc[1], "function no.%d/%d\n", function_counter, function_table_max); loop_counter++;