还差一个问题没解决,但是acf已经解决好了,先存档

This commit is contained in:
root 2022-08-10 11:28:09 +08:00
parent 3008b789c4
commit c7de48e5a0
5 changed files with 21 additions and 17 deletions

View File

@ -15,15 +15,15 @@
extern int acf_set_font(const char *); extern int acf_set_font(const char *);
extern const char *acf_draw(int, int, unsigned, unsigned, unsigned, 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 (0 <= (x) && (x) < (w) && 0 <= (y) && (y) < (h)) \
{ \ { \
if ((islit)) \ if ((islit)) \
{ \ { \
frame[ (h)*(x) + (h-1-y) ] = fg; \ frame[ (h)*(x) + (h-1-y) ] = fg; \
} \ } \
} \ } \
} }
#endif //_ANOD_COMPILED_FONT_H_ #endif //_ANOD_COMPILED_FONT_H_

View File

@ -333,7 +333,7 @@ const char *acf_draw(int x, int y, unsigned width, unsigned height, unsigned max
if( maxwidth == 0 ) maxwidth = width; if( maxwidth == 0 ) maxwidth = width;
unsigned *option = width == 0 ? NULL : &maxwidth; 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 ); uint8_t *localram = malloc( ramsize );
memset( localram, 0, 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 ) for( int j=0; j < (int)maxwidth; ++j )
{ {
if( BIT_AT_POS(localram, PIX_IN_LINE(j, i, maxwidth)) ) 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); ACF_LIT_POINT(x+j, y-(gblfont.height-1-i), (int)width, (int)height, 1);
} }
} }

View File

@ -27,7 +27,7 @@
#include "drivers/gfx.h" #include "drivers/gfx.h"
#include "arm11/acf.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: // Notes on these settings:
// MAX_ENT_BUF_SIZE should be big enough to hold the average file/dir name length * MAX_DIR_ENTRIES. // 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_COLS 19
#define SCREEN_ROWS 14u #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_FILE (0)
#define ENT_TYPE_DIR (1) #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(printStr, i - start, &dList->ptrs[i][1]); // TODO: use acf to display
ee_printf("\x1b[%dm", *dList -> ptrs[i] == ENT_TYPE_FILE ? 37 : 36); 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 ) 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( 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 { else {
//ee_printf("\x1b[%lu;H\x1b[0m>%.51s", cursorPos - windowPos, "<no gba rom>"); //ee_printf("\x1b[%lu;H\x1b[0m>%.51s", cursorPos - windowPos, "<no gba rom>");
ee_printf("\x1b[0m"); ee_printf("\x1b[0m");
acf_draw( 0, LINENO_TO_Y(cursorPos-windowPos), 320, 240, 292, "<NO GBA ROM>" ); acf_draw( 20, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, 292, "<NO GBA ROM>" );
} }
u32 kDown; u32 kDown;

View File

@ -55,7 +55,6 @@ int main(void)
setBacklight(); setBacklight();
consoleInit(SCREEN_BOT, NULL); consoleInit(SCREEN_BOT, NULL);
//CODEC_init(); //CODEC_init();
res = acf_set_font("wqy11.acf");
if(res == RES_OK && (res = oafInitAndRun()) == RES_OK) if(res == RES_OK && (res = oafInitAndRun()) == RES_OK)
{ {

View File

@ -684,6 +684,8 @@ Result oafParseConfigEarly(void)
// Create the saves folder. // Create the saves folder.
if((res = fMkdir(OAF_SAVE_DIR)) != RES_OK && res != RES_FR_EXIST) break; 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. // Parse the config.
res = parseOafConfig("config.ini", true); res = parseOafConfig("config.ini", true);
} while(0); } while(0);