diff --git a/include/arm11/acf.h b/include/arm11/acf.h index f698a5c..2d3c18f 100644 --- a/include/arm11/acf.h +++ b/include/arm11/acf.h @@ -15,15 +15,15 @@ extern int acf_set_font(const char *); extern const char *acf_draw(int, int, unsigned, unsigned, unsigned, const char *); -#define ACF_LIT_POINT(x, y, w, h, islit) \ - { \ +#define ACF_LIT_POINT(x, y, w, h, islit) \ + { \ if (0 <= (x) && (x) < (w) && 0 <= (y) && (y) < (h)) \ - { \ - if ((islit)) \ - { \ - frame[ (h)*(x) + (h-1-y) ] = fg; \ - } \ - } \ + { \ + if ((islit)) \ + { \ + frame[ (h)*(x) + (h-1-y) ] = fg; \ + } \ + } \ } #endif //_ANOD_COMPILED_FONT_H_ diff --git a/source/arm11/acf.c b/source/arm11/acf.c index 068a199..fcf3009 100644 --- a/source/arm11/acf.c +++ b/source/arm11/acf.c @@ -333,7 +333,7 @@ const char *acf_draw(int x, int y, unsigned width, unsigned height, unsigned max if( maxwidth == 0 ) maxwidth = width; unsigned *option = width == 0 ? NULL : &maxwidth; - const int ramsize = gblfont.height * maxwidth / BIT_PER_BYTE; + const int ramsize = gblfont.height * maxwidth + BIT_PER_BYTE - 1 / BIT_PER_BYTE; uint8_t *localram = malloc( ramsize ); memset( localram, 0, ramsize ); @@ -360,7 +360,7 @@ const char *acf_draw(int x, int y, unsigned width, unsigned height, unsigned max for( int j=0; j < (int)maxwidth; ++j ) { if( BIT_AT_POS(localram, PIX_IN_LINE(j, i, maxwidth)) ) - { + { ACF_LIT_POINT(x+j, y-(gblfont.height-1-i), (int)width, (int)height, 1); } } diff --git a/source/arm11/filebrowser.c b/source/arm11/filebrowser.c index becab8a..47d2c78 100644 --- a/source/arm11/filebrowser.c +++ b/source/arm11/filebrowser.c @@ -27,7 +27,7 @@ #include "drivers/gfx.h" #include "arm11/acf.h" -#define screenClean() //ee_printf("\x1b[2J\x1b[0m") +#define screenClean() ee_printf("\x1b[2J\x1b[0m") // Notes on these settings: // MAX_ENT_BUF_SIZE should be big enough to hold the average file/dir name length * MAX_DIR_ENTRIES. @@ -40,7 +40,9 @@ #define SCREEN_COLS 19 #define SCREEN_ROWS 14u -#define LINENO_TO_Y(y) ((y)+1)*15 +#define LINENO_TO_Y(y) 4+(y)*15 +#define CWIDTH 320u +#define CHEIGHT 240u #define ENT_TYPE_FILE (0) #define ENT_TYPE_DIR (1) @@ -138,7 +140,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(0, LINENO_TO_Y(i-start), 320, 240, 292, &dList->ptrs[i][1] ); + acf_draw(20, LINENO_TO_Y(i-start), CWIDTH, CHEIGHT, 292, &dList->ptrs[i][1] ); } } @@ -170,14 +172,15 @@ Result browseFiles(const char *const basePath, char selected[512]) if( oldCursorPos != cursorPos ) { ee_printf("\x1b[%dm", *dList -> ptrs[oldCursorPos] == ENT_TYPE_FILE ? 37:36); - acf_draw( 0, LINENO_TO_Y(oldCursorPos-windowPos), 320, 240, 292, &dList->ptrs[oldCursorPos][1] ); + acf_draw( 20, LINENO_TO_Y(oldCursorPos-windowPos), CWIDTH, CHEIGHT, 292, &dList->ptrs[oldCursorPos][1] ); } - acf_draw( 0, LINENO_TO_Y(cursorPos-windowPos), 320, 240, 292, &dList->ptrs[cursorPos][1] ); + ee_printf("\x1b[33m"); + acf_draw( 20, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, 292, &dList->ptrs[cursorPos][1] ); } else { //ee_printf("\x1b[%lu;H\x1b[0m>%.51s", cursorPos - windowPos, ""); ee_printf("\x1b[0m"); - acf_draw( 0, LINENO_TO_Y(cursorPos-windowPos), 320, 240, 292, "" ); + acf_draw( 20, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, 292, "" ); } u32 kDown; diff --git a/source/arm11/main.c b/source/arm11/main.c index 5e8aed8..70a4fe7 100644 --- a/source/arm11/main.c +++ b/source/arm11/main.c @@ -55,7 +55,6 @@ int main(void) setBacklight(); consoleInit(SCREEN_BOT, NULL); //CODEC_init(); - res = acf_set_font("wqy11.acf"); if(res == RES_OK && (res = oafInitAndRun()) == RES_OK) { diff --git a/source/arm11/open_agb_firm.c b/source/arm11/open_agb_firm.c index 39b554f..b9794bb 100644 --- a/source/arm11/open_agb_firm.c +++ b/source/arm11/open_agb_firm.c @@ -684,6 +684,8 @@ 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; + // Parse the config. res = parseOafConfig("config.ini", true); } while(0);