From 1decdb74c622f2c00e9b37bf4165f2a6e5bcdec3 Mon Sep 17 00:00:00 2001 From: Apaczer <94932128+Apaczer@users.noreply.github.com> Date: Sun, 24 Mar 2024 15:12:08 +0100 Subject: [PATCH 3/7] add MIYOO changes make CC=${CROSS_COMPILE}gcc CFLAGS="-DMIYOO -Ofast" --- inputmap.h | 38 ++++++++++++++++++++++++++++++++++++++ sdlbook.c | 34 ++++++++++++++++++++++------------ 2 files changed, 60 insertions(+), 12 deletions(-) diff --git a/inputmap.h b/inputmap.h index 0210a24..a34978f 100644 --- a/inputmap.h +++ b/inputmap.h @@ -1,6 +1,43 @@ #ifndef INPUTMAP_H #define INPUTMAP_H +#ifdef MIYOO +#define INPUT_UP SDLK_UP +#define INPUT_DOWN SDLK_DOWN +#define INPUT_LEFT SDLK_LEFT +#define INPUT_RIGHT SDLK_RIGHT +#define INPUT_LMOD SDLK_PAGEUP +#define INPUT_RMOD SDLK_PAGEDOWN +#define INPUT_PGDOWN SDLK_BACKSPACE +#define INPUT_PGUP SDLK_TAB +#define INPUT_ZOOMIN SDLK_LSHIFT +#define INPUT_ZOOMOUT SDLK_SPACE +#define INPUT_PAGEN SDLK_ESCAPE +#define INPUT_CLEAR SDLK_LCTRL +#define INPUT_CANCEL SDLK_LCTRL +#define INPUT_CONFIRM SDLK_LALT +#define INPUT_EXIT SDLK_RCTRL +#define INPUT_QUIT SDLK_q +#define INPUT_HELP SDLK_RETURN + +#define STR_UP "UP" +#define STR_DOWN "DOWN" +#define STR_LEFT "LEFT" +#define STR_RIGHT "RIGHT" +#define STR_LMOD "L2" +#define STR_RMOD "R2" +#define STR_PGDOWN "R1" +#define STR_PGUP "L1" +#define STR_ZOOMIN "X" +#define STR_ZOOMOUT "Y" +#define STR_PAGEN "SELECT" +#define STR_CLEAR "?" +#define STR_CANCEL "B" +#define STR_CONFIRM "A" +#define STR_EXIT "RESET" +#define STR_QUIT "" +#define STR_HELP "START" +#else #define INPUT_UP SDLK_UP #define INPUT_DOWN SDLK_DOWN #define INPUT_LEFT SDLK_LEFT @@ -36,5 +73,6 @@ #define STR_EXIT "ESC" #define STR_QUIT "Q" #define STR_HELP "F1" +#endif #endif diff --git a/sdlbook.c b/sdlbook.c index 79b77f3..584f02d 100644 --- a/sdlbook.c +++ b/sdlbook.c @@ -117,9 +117,15 @@ static void read_write_config(int doread) { cfg_close(config); } if(doread) { +#ifdef MIYOO + if(!config_data.w) config_data.w = 320; + if(!config_data.h) config_data.h = 240; + if(!config_data.scale) config_data.scale = 80; +#else if(!config_data.w) config_data.w = 640; if(!config_data.h) config_data.h = 480; if(!config_data.scale) config_data.scale = 100; +#endif } } @@ -550,14 +556,14 @@ static int change_scroll_h(int incr) { } #define HELP_TEXT \ - "HELP SCREEN - HIT ANY KEY TO EXIT\n" \ - STR_UP ", " STR_DOWN " - SCROLL 32 PIX\n" \ - STR_LMOD "/" STR_RMOD " + " STR_UP "/" STR_DOWN " - SCROLL 96 PIX\n" \ - STR_PGUP "/" STR_PGDOWN " - SCROLL ONE PAGE\n" \ - STR_ZOOMIN "/" STR_ZOOMOUT " OR " STR_LMOD "/" STR_RMOD " + WHEEL - ZOOM\n" \ - STR_PAGEN " - ENTER PAGE NUMBER\n" \ - STR_QUIT "/" STR_EXIT " - QUIT\n" \ - STR_HELP " - SHOW HELP SCREEN\n" + " HELP SCREEN\n (press any key to exit)\n" \ + STR_UP ", " STR_DOWN " - scroll 32px\n" \ + STR_LMOD "/" STR_RMOD " + " STR_UP "/" STR_DOWN " - scroll 96px\n" \ + STR_PGUP "/" STR_PGDOWN " - scroll one page -/+\n" \ + STR_ZOOMIN "/" STR_ZOOMOUT " - zoom in/out\n" \ + STR_PAGEN " - jump to page number\n" \ + STR_QUIT "/" STR_EXIT " - quit\n" \ + STR_HELP " - show this message\n" static int get_return_count(const char* text) { int count = 0; @@ -584,9 +590,9 @@ static void input_loop(const char* title, char *result, enum input_flags flags) { int ret_count = get_return_count(title); if(!ret_count) ret_count = 1; - int desired_height = (ret_count+2) * 10 * 2; + int desired_height = (ret_count) * 10 * 2 + 10; ezsdl_fill_rect(0,0, ezsdl_get_width(), MIN(desired_height, ezsdl_get_height()), RGB(0xff,0x00,0x00), 1); - draw_font_lines(title, &ss_font, 8, 8, 2); + draw_font_lines(title, &ss_font, 8, 8, 1); ezsdl_update_region(0, 0, ezsdl_get_width(), MIN(desired_height, ezsdl_get_height())); char* p = result; *p = 0; @@ -657,8 +663,8 @@ static void input_loop(const char* title, char *result, enum input_flags flags) *p = 0; } drawit: - ezsdl_fill_rect(8, desired_height - 10*2, ezsdl_get_width() -8, MIN(desired_height, ezsdl_get_height()), RGB(0xff,0x00,0x00), 1); - draw_font(result, &ss_font, 8, desired_height - 10*2, 2); + ezsdl_fill_rect(8, desired_height - 11*2, ezsdl_get_width() -8, MIN(desired_height, ezsdl_get_height()), RGB(0xff,0x00,0x00), 1); + draw_font(result, &ss_font, 8, desired_height - 11*2, 2); ezsdl_update_region(0, 0, ezsdl_get_width(), MIN(desired_height, ezsdl_get_height())); break; } @@ -770,7 +776,11 @@ int main(int argc, char **argv) { init_gfx(); +#ifdef MIYOO + SDL_ShowCursor(0); +#else SDL_ShowCursor(1); +#endif #ifndef USE_SDL2 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); #endif -- 2.34.1