From 04b8c0296c31cf9265b52f68a96f344de506150a Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Fri, 13 Oct 2017 00:23:59 +0100 Subject: [PATCH] split out memorypak and about screen to seperate modules --- inc/debug.h | 21 ++------------------ inc/main.h | 2 -- inc/menu.h | 15 ++++++++++++++ src/debug.c | 21 ++++++++++++++++++++ src/main.c | 51 +++--------------------------------------------- src/memorypak.c | 2 +- src/menu.c | 30 ++++++++++++++++++++++++++++ src/menu_about.c | 32 ++++++++++++++++++++++++++++++ 8 files changed, 104 insertions(+), 70 deletions(-) create mode 100644 inc/menu.h create mode 100644 src/debug.c create mode 100644 src/menu.c create mode 100644 src/menu_about.c diff --git a/inc/debug.h b/inc/debug.h index 97ba183..0e788f6 100644 --- a/inc/debug.h +++ b/inc/debug.h @@ -12,25 +12,8 @@ #else #define TRACEF(disp, text, ...) do { if (0) dbg_printf(disp, text, __VA_ARGS__); } while (0) #define TRACE(disp, text) do { if (0) printText(text, 3, -1, disp); } while (0) -#endif /* DEBUG */ - -#include -#include - -void dbg_printf(display_context_t disp, const char *fmt, ...) -{ - char buf[32]; - setbuf(stderr, buf); - - va_list args; - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - - u8 tmp[32]; - sprintf(tmp, "%s", buf); - printText(tmp, 3, -1, disp); -} +#endif +void dbg_printf(display_context_t disp, const char *fmt, ...); #endif diff --git a/inc/main.h b/inc/main.h index 4ed601a..02072d2 100644 --- a/inc/main.h +++ b/inc/main.h @@ -16,8 +16,6 @@ int saveTypeToSd(display_context_t disp, char* save_filename ,int type); void drawShortInfoBox(display_context_t disp, char* text, u8 mode); void drawTextInput(display_context_t disp,char *msg); -void printText(char *msg, int x, int y, display_context_t dcon); - //#define ishexchar(c) (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'F')) || ((c >= 'a') && (c <= 'f'))) /** diff --git a/inc/menu.h b/inc/menu.h new file mode 100644 index 0000000..729e1ae --- /dev/null +++ b/inc/menu.h @@ -0,0 +1,15 @@ +// +// Copyright (c) 2017 The Altra64 project contributors +// See LICENSE file in the project root for full license information. +// + +#ifndef _MENU_H_ +#define _MENU_H_ + +extern int text_offset; + +void printText(char *msg, int x, int y, display_context_t dcon); + +void menu_about(display_context_t disp); + +#endif \ No newline at end of file diff --git a/src/debug.c b/src/debug.c new file mode 100644 index 0000000..9a4c421 --- /dev/null +++ b/src/debug.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include "types.h" +#include "debug.h" +#include "menu.h" + +void dbg_printf(display_context_t disp, const char *fmt, ...) +{ + char buf[32]; + setbuf(stderr, buf); + + va_list args; + va_start(args, fmt); + vfprintf(stderr, fmt, args); + va_end(args); + + u8 tmp[32]; + sprintf(tmp, "%s", buf); + printText(tmp, 3, -1, disp); +} \ No newline at end of file diff --git a/src/main.c b/src/main.c index ff3a15c..a38cbdb 100644 --- a/src/main.c +++ b/src/main.c @@ -37,18 +37,16 @@ #include "sound.h" #include "mp3.h" -//debug -#include "debug.h" - // YAML parser #include +#include "debug.h" #include "mem.h" #include "chksum64.h" -#include "version.h" #include "image.h" #include "rom.h" #include "memorypak.h" +#include "menu.h" #ifdef USE_TRUETYPE #define STB_TRUETYPE_IMPLEMENTATION @@ -223,7 +221,6 @@ char *save_path; u8 sound_on = 0; u8 page_display = 0; -int text_offset = 0; u8 tv_mode = 0; // 1=ntsc 2=pal 3=mpal 0=default automatic u8 quick_boot = 0; u8 enable_colored_list = 0; @@ -244,9 +241,6 @@ char list_pwd_backup[256]; char dirz[512] = "rom://"; -short int gCursorX; -short int gCursorY; - int count = 0; int page = 0; int cursor = 0; @@ -633,26 +627,6 @@ void display_dir(direntry_t *list, int cursor, int page, int max, int count, dis graphics_set_color(forecolor_menu, backcolor); } -void printText(char *msg, int x, int y, display_context_t dcon) -{ - x = x + text_offset; - - if (x != -1) - gCursorX = x; - if (y != -1) - gCursorY = y; - - if (dcon) - graphics_draw_text(dcon, gCursorX * 8, gCursorY * 8, msg); - - gCursorY++; - if (gCursorY > 29) - { - gCursorY = 0; - gCursorX++; - } -} - //background sprite void drawBg(display_context_t disp) { @@ -2867,32 +2841,13 @@ void drawSet4(display_context_t disp) void showAboutScreen(display_context_t disp) { - char version_str[32]; - char firmware_str[32]; - drawBoxNumber(disp, 2); display_show(disp); if (sound_on) playSound(2); - - sprintf(version_str, "Altra64: v%s", Altra64_GetVersionString()); - printText(version_str, 9, 8, disp); - sprintf(firmware_str, "ED64 firmware: v%03x", evd_getFirmVersion()); - printText(firmware_str, 9, -1, disp); - printText("by JonesAlmighty", 9, -1, disp); - printText(" ", 9, -1, disp); - printText("Based on ALT64", 9, -1, disp); - printText("By Saturnu", 9, -1, disp); - printText(" ", 9, -1, disp); - printText("credits to:", 9, -1, disp); - printText("Jay Oster", 9, -1, disp); - printText("Krikzz", 9, -1, disp); - printText("Richard Weick", 9, -1, disp); - printText("ChillyWilly", 9, -1, disp); - printText("ShaunTaylor", 9, -1, disp); - printText("Conle", 9, -1, disp); + menu_about(disp); } void loadFile(display_context_t disp) diff --git a/src/memorypak.c b/src/memorypak.c index 8558e04..386351c 100644 --- a/src/memorypak.c +++ b/src/memorypak.c @@ -10,7 +10,7 @@ #include "types.h" #include "memorypak.h" #include "fat.h" -#include "main.h" +#include "menu.h" #include "mem.h" #include "strlib.h" #include "sys.h" diff --git a/src/menu.c b/src/menu.c new file mode 100644 index 0000000..ea1537b --- /dev/null +++ b/src/menu.c @@ -0,0 +1,30 @@ + +#include +#include "types.h" +#include "debug.h" + + +short int gCursorX; +short int gCursorY; + +int text_offset = 0; + +void printText(char *msg, int x, int y, display_context_t dcon) +{ + x = x + text_offset; + + if (x != -1) + gCursorX = x; + if (y != -1) + gCursorY = y; + + if (dcon) + graphics_draw_text(dcon, gCursorX * 8, gCursorY * 8, msg); + + gCursorY++; + if (gCursorY > 29) + { + gCursorY = 0; + gCursorX++; + } +} diff --git a/src/menu_about.c b/src/menu_about.c new file mode 100644 index 0000000..99177fd --- /dev/null +++ b/src/menu_about.c @@ -0,0 +1,32 @@ + +#include +#include +#include "types.h" +#include "menu.h" +#include "version.h" +#include "main.h" +#include "everdrive.h" + + +void menu_about(display_context_t disp) +{ + char version_str[32]; + char firmware_str[32]; + + sprintf(version_str, "Altra64: v%s", Altra64_GetVersionString()); + printText(version_str, 9, 8, disp); + sprintf(firmware_str, "ED64 firmware: v%03x", evd_getFirmVersion()); + printText(firmware_str, 9, -1, disp); + printText("by JonesAlmighty", 9, -1, disp); + printText(" ", 9, -1, disp); + printText("Based on ALT64", 9, -1, disp); + printText("By Saturnu", 9, -1, disp); + printText(" ", 9, -1, disp); + printText("credits to:", 9, -1, disp); + printText("Jay Oster", 9, -1, disp); + printText("Krikzz", 9, -1, disp); + printText("Richard Weick", 9, -1, disp); + printText("ChillyWilly", 9, -1, disp); + printText("ShaunTaylor", 9, -1, disp); + printText("Conle", 9, -1, disp); +}