mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-08 06:44:12 +08:00
Merge branch 'dev_cheat' of https://gitee.com/anod/open_agb_firm into dev_cheat
This commit is contained in:
commit
8b63147903
@ -12,6 +12,7 @@ typedef const char* atp_text_t;
|
||||
typedef uint8_t atp_boolean_t;
|
||||
typedef uint8_t atp_pageopt_t;
|
||||
typedef uint8_t atp_color_t;
|
||||
typedef uint8_t atp_placement_t;
|
||||
typedef uint8_t atp_error_t;
|
||||
typedef void * atp_callerdata_t;
|
||||
|
||||
@ -30,6 +31,11 @@ typedef void * atp_callerdata_t;
|
||||
#define ATP_COLOR_CYAN 6
|
||||
#define ATP_COLOR_WHITE 7
|
||||
|
||||
// text align
|
||||
#define ATP_PLACEMENT_LEFT 0
|
||||
#define ATP_PLACEMENT_RIGHT 1
|
||||
#define ATP_PLACEMENT_CENTER 2
|
||||
|
||||
// page option
|
||||
#define ATP_PAGE_NOOPTION 0
|
||||
#define ATP_PAGE_UPDATE 1 // UPDATE THE CURSOR ROW
|
||||
@ -40,7 +46,8 @@ typedef atp_error_t (*atp_lineinfo_t)(
|
||||
INPUT(atp_counter_t) line_index_of_this_page,
|
||||
OUTPUT(atp_text_t) line_text_of_this_line,
|
||||
OUTPUT(atp_itemval_t) option_value_of_this_item,
|
||||
OUTPUT(atp_color_t) value_of_atp_color
|
||||
OUTPUT(atp_color_t) value_of_atp_color,
|
||||
OUTPUT(atp_placement_t) value_of_atp_placement
|
||||
);
|
||||
|
||||
typedef atp_pageopt_t (*atp_keyhandler_t)(
|
||||
@ -65,6 +72,11 @@ extern atp_itemval_t atp_select(
|
||||
INPUT(atp_callerdata_t) some_data_from_caller
|
||||
);
|
||||
|
||||
extern atp_error_t atp_tips(
|
||||
INPUT(atp_text_t) text_at_left_bottom,
|
||||
INPUT(atp_text_t) text_at_right_bottom
|
||||
);
|
||||
|
||||
#undef INPUT
|
||||
#undef OUTPUT
|
||||
|
||||
|
@ -4,9 +4,13 @@
|
||||
#include "arm11/drivers/hid.h"
|
||||
#include "drivers/gfx.h"
|
||||
|
||||
#define TIPS_MAX 64
|
||||
static char ta[TIPS_MAX] = {'\0'};
|
||||
static char tb[TIPS_MAX] = {'\0'};
|
||||
|
||||
//---------------------------------------------------
|
||||
// basic print helper
|
||||
/*
|
||||
|
||||
static void set_screen_color( acf_callerdata_t data, acf_position_t tx, acf_position_t ty, acf_color_t b )
|
||||
{
|
||||
if( b == 0 ) return;
|
||||
@ -21,7 +25,7 @@ static void set_screen_color( acf_callerdata_t data, acf_position_t tx, acf_posi
|
||||
}
|
||||
}
|
||||
|
||||
static const char *acf_draw(int x, int y, int width, int height, int maxwidth, u16 color, const char* text)
|
||||
const char *acf_put_text(int x, int y, int width, int height, int maxwidth, u8 color, u8 placement, const char* text)
|
||||
{
|
||||
uint8_t draw_data[sizeof(int)*5];
|
||||
|
||||
@ -30,16 +34,18 @@ static const char *acf_draw(int x, int y, int width, int height, int maxwidth, u
|
||||
draw_data_int[1] = y;
|
||||
draw_data_int[2] = width;
|
||||
draw_data_int[3] = height;
|
||||
draw_data_int[4] = color;
|
||||
draw_data_int[4] = (int)consoleGetRGB565Color(color);
|
||||
|
||||
const char *retval = text;
|
||||
acf_canvas_t canvas = acf_get_canvas(maxwidth, text, NULL, NULL, &retval);
|
||||
acf_rectedge_t realwid;
|
||||
acf_canvas_t canvas = acf_get_canvas(maxwidth, text, &realwid, NULL, &retval);
|
||||
if( !canvas ) return retval;
|
||||
if( placement == ATP_PLACEMENT_RIGHT ) draw_data_int[0] += maxwidth - realwid;
|
||||
else if( placement == ATP_PLACEMENT_CENTER ) draw_data_int[0] += (maxwidth-realwid) >> 1;
|
||||
acf_recycle( acf_use_canvas(canvas, set_screen_color, draw_data) );
|
||||
return retval;
|
||||
}
|
||||
*/
|
||||
extern const char *acf_draw(int x, int y, int width, int height, int maxwidth, u16 color, const char* text);
|
||||
|
||||
//---------------------------------------------------
|
||||
|
||||
#define CONTAINER_LEFTTOP_X 20u
|
||||
@ -51,7 +57,12 @@ extern const char *acf_draw(int x, int y, int width, int height, int maxwidth, u
|
||||
|
||||
#define FONT_HEIGHT 15u
|
||||
|
||||
#define screen_clean() memset(consoleGet()->frameBuffer, 0, WINDOW_WIDTH*WINDOW_HEIGHT*sizeof(uint16_t))
|
||||
static void screen_clean()
|
||||
{
|
||||
memset(consoleGet()->frameBuffer, 0, WINDOW_WIDTH*WINDOW_HEIGHT*sizeof(uint16_t));
|
||||
acf_put_text( 5, 215, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH-10, ATP_COLOR_BLUE, ATP_PLACEMENT_LEFT, ta );
|
||||
acf_put_text( 5, 215, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH-10, ATP_COLOR_BLUE, ATP_PLACEMENT_RIGHT, tb );
|
||||
}
|
||||
|
||||
// wait key pressed, if power key is pressed, return 0
|
||||
static uint32_t waitKey()
|
||||
@ -74,15 +85,17 @@ static void paint_one_line( atp_lineinfo_t provider, acf_callerdata_t data, int
|
||||
{
|
||||
atp_text_t text;
|
||||
atp_color_t color = ATP_COLOR_WHITE;
|
||||
atp_error_t err = provider( data, idx, &text, NULL, &color );
|
||||
atp_placement_t align = ATP_PLACEMENT_LEFT;
|
||||
atp_error_t err = provider( data, idx, &text, NULL, &color, &align );
|
||||
if( !err ){
|
||||
acf_draw(
|
||||
acf_put_text(
|
||||
CONTAINER_LEFTTOP_X,
|
||||
CONTAINER_LEFTTOP_Y + row*FONT_HEIGHT,
|
||||
WINDOW_WIDTH,
|
||||
WINDOW_HEIGHT,
|
||||
CONTAINER_RECT_WIDTH,
|
||||
consoleGetRGB565Color(color > ATP_COLOR_WHITE ? ATP_COLOR_WHITE : color),
|
||||
color > ATP_COLOR_WHITE ? ATP_COLOR_WHITE : color,
|
||||
align,
|
||||
text
|
||||
);
|
||||
}
|
||||
@ -129,3 +142,15 @@ atp_error_t atp_show( atp_counter_t cnt, atp_lineinfo_t provider, atp_callerdata
|
||||
}
|
||||
}
|
||||
|
||||
atp_error_t atp_tips( atp_text_t tipsA, atp_text_t tipsB )
|
||||
{
|
||||
if( tipsA != NULL ){
|
||||
strncpy( ta, tipsA, TIPS_MAX-1 );
|
||||
ta[TIPS_MAX-1] = 0;
|
||||
}
|
||||
if( tipsB != NULL ){
|
||||
strncpy( tb, tipsB, TIPS_MAX-1 );
|
||||
tb[TIPS_MAX-1] = 0;
|
||||
}
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
@ -59,36 +59,9 @@ typedef struct
|
||||
char *ptrs[MAX_DIR_ENTRIES]; // For fast sorting.
|
||||
} DirList;
|
||||
|
||||
void set_screen_color( acf_callerdata_t data, acf_position_t tx, acf_position_t ty, acf_color_t b )
|
||||
{
|
||||
if( b == 0 ) return;
|
||||
|
||||
int *draw_data = data;
|
||||
u16 *frame = consoleGet()->frameBuffer;
|
||||
|
||||
int x = tx + draw_data[0];
|
||||
int y = ty + draw_data[1];
|
||||
if( 0 <= x && x < draw_data[2] && 0 <= y && y < draw_data[3] ){
|
||||
frame[ x*draw_data[3] + (draw_data[3]-1-y) ] = (u16)draw_data[4];
|
||||
}
|
||||
}
|
||||
|
||||
const char *acf_draw(int x, int y, int width, int height, int maxwidth, u16 color, const char* text)
|
||||
{
|
||||
uint8_t draw_data[sizeof(int)*5];
|
||||
|
||||
int *draw_data_int = (int*)&draw_data;
|
||||
draw_data_int[0] = x;
|
||||
draw_data_int[1] = y;
|
||||
draw_data_int[2] = width;
|
||||
draw_data_int[3] = height;
|
||||
draw_data_int[4] = color;
|
||||
|
||||
const char *retval = text;
|
||||
acf_canvas_t canvas = acf_get_canvas(maxwidth, text, NULL, NULL, &retval);
|
||||
if( !canvas ) return retval;
|
||||
acf_recycle( acf_use_canvas(canvas, set_screen_color, draw_data) );
|
||||
return retval;
|
||||
return atf_put_text(x, y, width, height, maxwidth, color, ATP_PLACEMENT_LEFT, text);
|
||||
}
|
||||
|
||||
static const char *page[] = {
|
||||
@ -116,7 +89,7 @@ static const char *page[] = {
|
||||
"女儿情长埋葬"
|
||||
};
|
||||
|
||||
static atp_error_t test_show( atp_callerdata_t data, atp_counter_t idx, atp_text_t *ptext, atp_itemval_t *pval, atp_color_t *c )
|
||||
static atp_error_t test_show( atp_callerdata_t data, atp_counter_t idx, atp_text_t *ptext, atp_itemval_t *pval, atp_color_t *c, atp_placement_t *p )
|
||||
{
|
||||
if( idx < sizeof(page) ){
|
||||
*ptext = page[idx];
|
||||
|
Loading…
x
Reference in New Issue
Block a user