From d06758019c0b9214df1ce42080bbeb89ec57daf7 Mon Sep 17 00:00:00 2001 From: root <182859762@qq.com> Date: Fri, 5 Aug 2022 18:44:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=A4=B1=E8=B4=A5=E4=BA=86?= =?UTF-8?q?=EF=BC=8C=E4=B8=8B=E5=9B=9E=E6=9D=A5=E7=9C=8B=E7=9C=8B=E6=80=8E?= =?UTF-8?q?=E4=B9=88=E5=9B=9E=E4=BA=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/arm11/acf.h | 8 ++++---- source/arm11/acf.c | 26 +++++++++++++------------- source/arm11/filebrowser.c | 7 ++++--- 3 files changed, 21 insertions(+), 20 deletions(-) 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 c9ac93b..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 @@ -21,7 +21,7 @@ typedef struct uint16_t amount; char *filename; uint16_t *chapter; - uint32 filesize; + uint32_t filesize; } ACFont; static ACFont gblfont = { @@ -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,14 +344,14 @@ 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; } uint32_t unicode; - unsigned *option = width == 0 ? NULL : &width; + unsigned *option = width == 0 ? NULL : &maxwidth; for (const char *next = next_unicode(utf8_line, &unicode); next != NULL; next = next_unicode(utf8_line, &unicode)) @@ -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 d931280..7107338 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") @@ -84,7 +84,8 @@ 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. + u32 entBufPos = 0; // Entry buffer position/number of bytes used + acf_set_font("wqy11.acf"); const u32 filterLen = strlen(filter); do { @@ -169,7 +170,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] );