diff --git a/include/arm11/acf.h b/include/arm11/acf.h index 77331b0..91e8ea1 100644 --- a/include/arm11/acf.h +++ b/include/arm11/acf.h @@ -12,8 +12,8 @@ extern int acf_set_font(const char *); extern const char *acf_draw(int, int, unsigned, unsigned, unsigned, const char *); -#include "acf_dev.h" -#include "acf_cfg.h" +#include "arm11/acf_dev.h" +#include "arm11/acf_cfg.h" #if ACF_CANVAS == ACFDEV_U8GBITMAP @@ -55,7 +55,7 @@ extern uint8_t *acfCanvas; #include #include #include -#include +#include "arm11/console.h" #include "fs.h" @@ -71,4 +71,4 @@ extern uint8_t *acfCanvas; #else #endif -#endif //_ANOD_COMPILED_FONT_H_ \ No newline at end of file +#endif //_ANOD_COMPILED_FONT_H_ diff --git a/source/arm11/acf.c b/source/arm11/acf.c index a1a710d..4b4246f 100644 --- a/source/arm11/acf.c +++ b/source/arm11/acf.c @@ -5,7 +5,7 @@ * 3数据,每个数据是前4个字节的bbx,第5个字节的前7位是DWIDTH的x分量,后1位0表示位图每次读取1字节,为1表示每次读取2字节。第6个字节及以后是BITMAP的数据,总长度是bbx[1]的长度。 */ -#include "acf.h" +#include "arm11/acf.h" // 画点函数 #ifndef ACF_LIT_POINT @@ -53,7 +53,7 @@ int acf_set_font(const char *acfile) // open the font file FHandle font; u32 readed; - if( (RES_OK = fOpen(&font, acfile, FA_READ)) != RES_OK ) + if( RES_OK != fOpen(&font, acfile, FA_READ) ) return ACFONT_NOT_FOUND; // 读取数据 @@ -159,7 +159,7 @@ int acf_set_font(const char *acfile) #define ISSET_H(c) TEST_H(c) == BYTE_H #define EXBYTE 0x3fu #define EXDATA(c) ((c)&EXBYTE) -inline const char *next_unicode(const char *utf8, uint32_t *code) +static inline const char *next_unicode(const char *utf8, uint32_t *code) { if (utf8 == NULL || *utf8 == '\0') return NULL; @@ -239,7 +239,7 @@ static int bsearch_font(FHandle fd, uint32_t unicode) uint8_t *cache = (uint8_t *)malloc(size); if( RES_OK != fRead(fd, cache, size, &readed) || - readed != size ) + readed != (u32)size ) { free(cache); return ACFONT_READ_EOF; @@ -269,7 +269,7 @@ static int bsearch_font(FHandle fd, uint32_t unicode) #define BIT_AT_POS(mem, idx) ((mem)[(idx) / 8] & (1 << ((idx) % 8))) #define SIZEOF_S6 6 -inline int readS6(uint8_t *p, int index) +static inline int readS6(uint8_t *p, int index) { int ret = 0; int symbol = BIT_AT_POS(p, index); @@ -293,7 +293,7 @@ static int render_unicode(FHandle fd, int *x, int *y, unsigned width, unsigned h int font_pos = bsearch_font(fd, code); if (font_pos < 0) return 0; - if (font_pos > gblfont.filesize) + if ((uint32_t)font_pos > gblfont.filesize) return 0; font_pos += ACFONT_HEAD_SIZE + gblfont.amount * ACFONT_SIZEOF_INDEX; @@ -302,7 +302,7 @@ static int render_unicode(FHandle fd, int *x, int *y, unsigned width, unsigned h return 1; if( RES_OK != fRead(fd, font, ACFONT_SIZEOF_GLYPH, &readed) || - (readed != ACFONT_SIZEOF_GLYPH && font_pos + ACFONT_SIZEOF_GLYPH < gblfont.filesize) ) + (readed != ACFONT_SIZEOF_GLYPH && (uint32_t)font_pos + ACFONT_SIZEOF_GLYPH < gblfont.filesize) ) return 1; int8_t bbx[4]; @@ -318,7 +318,7 @@ static int render_unicode(FHandle fd, int *x, int *y, unsigned width, unsigned h int cx = px + bbx[2], cy = py + bbx[1] + bbx[3]; // cx/cy计算位置进行绘制 // 先检查宽度 - if ((width_max != NULL) && (cx + bbx[0] >= *width_max)) + if ((width_max != NULL) && (cx + bbx[0] >= (int)(*width_max))) return 1; // 绘制 @@ -326,7 +326,7 @@ static int render_unicode(FHandle fd, int *x, int *y, unsigned width, unsigned h { for (int j = 0; j < bbx[0]; ++j) { - ACF_LIT_POINT(cx + j, cy - i, width, height, BIT_AT_POS(font + 4, bbx[0] * i + j)); + ACF_LIT_POINT(cx + j, cy - i, (int)width, (int)height, BIT_AT_POS(font + 4, bbx[0] * i + j)); } } @@ -344,7 +344,7 @@ static int render_unicode(FHandle fd, int *x, int *y, unsigned width, unsigned h const char *acf_draw(int x, int y, unsigned width, unsigned height, unsigned maxwidth, const char *utf8_line) { u32 font; - if( RES_OK != fOpen(&font, gblfont.filename, FA_READ) ) + if( gblfont.filename == NULL || RES_OK != fOpen(&font, gblfont.filename, FA_READ) ) { // log return utf8_line; @@ -367,4 +367,4 @@ const char *acf_draw(int x, int y, unsigned width, unsigned height, unsigned max } fClose(font); return NULL; -} \ No newline at end of file +} diff --git a/source/arm11/filebrowser.c b/source/arm11/filebrowser.c index af1aa92..af85659 100644 --- a/source/arm11/filebrowser.c +++ b/source/arm11/filebrowser.c @@ -25,7 +25,7 @@ #include "arm11/drivers/hid.h" #include "arm11/fmt.h" #include "drivers/gfx.h" -#include "acf.h" +#include "arm11/acf.h" #define screenClean() ee_printf("\x1b[2J\x1b[0m") @@ -85,7 +85,6 @@ static Result scanDir(const char *const path, DirList *const dList, const char * u32 read; // Number of entries read by fReadDir(). u32 numEntries = 0; // Total number of processed entries. u32 entBufPos = 0; // Entry buffer position/number of bytes used. - acf_set_font("wqy11.acf"); const u32 filterLen = strlen(filter); do { @@ -170,7 +169,7 @@ Result browseFiles(const char *const basePath, char selected[512]) //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; + ee_printf("\x1b[%dm", *dList -> ptrs[oldCursorPos] == ENT_TYPE_FILE ? 37:36); acf_draw( 20, LINENO_TO_Y(oldCursorPos-windowPos), 320, 240, 292, &dList->ptrs[oldCursorPos][1] ); } acf_draw( 20, LINENO_TO_Y(cursorPos-windowPos), 320, 240, 292, &dList->ptrs[cursorPos][1] ); diff --git a/source/arm11/open_agb_firm.c b/source/arm11/open_agb_firm.c index b0f547f..8c4cbaf 100644 --- a/source/arm11/open_agb_firm.c +++ b/source/arm11/open_agb_firm.c @@ -36,6 +36,7 @@ #include "arm11/drivers/lcd.h" #include "arm11/gpu_cmd_lists.h" #include "arm11/drivers/mcu.h" +#include "arm11/acf.h" #include "kernel.h" #include "kevent.h" @@ -685,6 +686,9 @@ Result oafParseConfigEarly(void) // Parse the config. res = parseOafConfig("config.ini", true); + + // load font + acf_set_font("wqy11.acf"); } while(0); return res;