Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rhargreaves committed Nov 15, 2018
1 parent 9b02c10 commit 895aa76
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ static const char HEADER[] = "Sega Mega Drive MIDI Interface";
static void vsync(void);
static void printHeader(void);
static void printLoad(void);
static u16 loadPercent(void);
static void printLastError(void);
static void printErrorText(const char* text);

Expand All @@ -38,13 +39,17 @@ static void printHeader(void)
VDP_drawText(BUILD, (MAX_X - sizeof(BUILD)) / 2, 3);
}

static void printLoad(void)
static u16 loadPercent(void)
{
static char loadText[20];
u16 idle = comm_idleCount();
u16 busy = comm_busyCount();
u16 percent = (busy * 100) / (idle + busy);
sprintf(loadText, "Load %i%s ", percent, "%");
return (busy * 100) / (idle + busy);
}

static void printLoad(void)
{
static char loadText[16];
sprintf(loadText, "Load %i%s ", loadPercent(), "%");
comm_resetCounts();
VDP_setTextPalette(PAL0);
VDP_drawText(loadText, 1, 7);
Expand Down

0 comments on commit 895aa76

Please sign in to comment.