重新找了个位置试试还会不会core dump

Merge branch 'master' of https://gitee.com/anod/open_agb_firm
This commit is contained in:
anod 2022-08-05 18:55:25 +08:00
commit c4f39b7e9e
4 changed files with 21 additions and 18 deletions

View File

@ -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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <console.h>
#include "arm11/console.h"
#include "fs.h"
@ -71,4 +71,4 @@ extern uint8_t *acfCanvas;
#else
#endif
#endif //_ANOD_COMPILED_FONT_H_
#endif //_ANOD_COMPILED_FONT_H_

View File

@ -5,7 +5,7 @@
* 34bbx57DWIDTH的x分量101126BITMAP的数据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;
}
}

View File

@ -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] );

View File

@ -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;