From c5e0516ec1ea11cf03cb7b5b0adb192d4d1591ca Mon Sep 17 00:00:00 2001 From: root <182859762@qq.com> Date: Wed, 10 Aug 2022 13:26:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=95=BF=E5=BA=A6=E8=B6=85?= =?UTF-8?q?=E5=87=BA=E9=99=90=E5=AE=9A=E9=95=BF=E5=BA=A6=E4=B8=8D=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E7=9A=84=E9=97=AE=E9=A2=98=20=E6=8A=8Afilebrowser.c?= =?UTF-8?q?=E7=9A=84=E5=AD=97=E9=9D=A2=E5=B8=B8=E9=87=8F=E5=8F=98=E6=88=90?= =?UTF-8?q?=E5=AE=8F=E5=B8=B8=E9=87=8F=20=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E5=AD=97=E4=BD=93=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/arm11/acf.c | 5 ++++- source/arm11/filebrowser.c | 13 +++++++------ source/arm11/open_agb_firm.c | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/source/arm11/acf.c b/source/arm11/acf.c index fcf3009..6cc1b14 100644 --- a/source/arm11/acf.c +++ b/source/arm11/acf.c @@ -342,7 +342,10 @@ const char *acf_draw(int x, int y, unsigned width, unsigned height, unsigned max next = next_unicode(utf8_line, &unicode)) { int error = render_unicode(font, &linex, maxwidth, height, unicode, option, localram); - if (error) + if (error > 0 ) break; + else if(error < 0 ) error = render_unicode(font, &linex, maxwidth, height, '?', option, localram); + + if( error ) { free( localram ); fClose(font); diff --git a/source/arm11/filebrowser.c b/source/arm11/filebrowser.c index 47d2c78..a068bbe 100644 --- a/source/arm11/filebrowser.c +++ b/source/arm11/filebrowser.c @@ -40,9 +40,11 @@ #define SCREEN_COLS 19 #define SCREEN_ROWS 14u -#define LINENO_TO_Y(y) 4+(y)*15 +#define LINENO_TO_Y(y) 15+(y)*15 #define CWIDTH 320u #define CHEIGHT 240u +#define CLEFTMARGIN 20u +#define CLINELIMIT 282u #define ENT_TYPE_FILE (0) #define ENT_TYPE_DIR (1) @@ -140,7 +142,7 @@ static void showDirList(const DirList *const dList, u32 start) //ee_printf(printStr, i - start, &dList->ptrs[i][1]); // TODO: use acf to display ee_printf("\x1b[%dm", *dList -> ptrs[i] == ENT_TYPE_FILE ? 37 : 36); - acf_draw(20, LINENO_TO_Y(i-start), CWIDTH, CHEIGHT, 292, &dList->ptrs[i][1] ); + acf_draw(CLEFTMARGIN, LINENO_TO_Y(i-start), CWIDTH, CHEIGHT, CLINELIMIT, &dList->ptrs[i][1] ); } } @@ -165,22 +167,21 @@ Result browseFiles(const char *const basePath, char selected[512]) s32 oldCursorPos = 0; while(1) { - // TODO: use acf to display if( dList->num > 0 ){ //ee_printf(*dList->ptrs[oldCursorPos] == ENT_TYPE_FILE ? "\x1b[%lu;H\x1b[37m %.51s" : "\x1b[%lu;H\x1b[36m %.51s", oldCursorPos - windowPos, &dList->ptrs[oldCursorPos][1]); // Clear old cursor. //ee_printf("\x1b[%lu;H\x1b[33m>%.51s", cursorPos - windowPos, &dList->ptrs[cursorPos][1]); // Draw cursor. if( oldCursorPos != cursorPos ) { ee_printf("\x1b[%dm", *dList -> ptrs[oldCursorPos] == ENT_TYPE_FILE ? 37:36); - acf_draw( 20, LINENO_TO_Y(oldCursorPos-windowPos), CWIDTH, CHEIGHT, 292, &dList->ptrs[oldCursorPos][1] ); + acf_draw( CLEFTMARGIN, LINENO_TO_Y(oldCursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, &dList->ptrs[oldCursorPos][1] ); } ee_printf("\x1b[33m"); - acf_draw( 20, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, 292, &dList->ptrs[cursorPos][1] ); + acf_draw( CLEFTMARGIN, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, &dList->ptrs[cursorPos][1] ); } else { //ee_printf("\x1b[%lu;H\x1b[0m>%.51s", cursorPos - windowPos, ""); ee_printf("\x1b[0m"); - acf_draw( 20, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, 292, "" ); + acf_draw( CLEFTMARGIN, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, "" ); } u32 kDown; diff --git a/source/arm11/open_agb_firm.c b/source/arm11/open_agb_firm.c index b9794bb..26b9462 100644 --- a/source/arm11/open_agb_firm.c +++ b/source/arm11/open_agb_firm.c @@ -684,7 +684,7 @@ Result oafParseConfigEarly(void) // Create the saves folder. if((res = fMkdir(OAF_SAVE_DIR)) != RES_OK && res != RES_FR_EXIST) break; - if((res = acf_set_font("wqy11.acf")) != RES_OK ) break; + if((res = acf_set_font("wqy11.fnt")) != RES_OK ) break; // Parse the config. res = parseOafConfig("config.ini", true);