2017-10-16 11:55:29 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ogcsys.h>
|
|
|
|
|
|
|
|
#include "video.h"
|
|
|
|
#include "fat.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "nand.h"
|
|
|
|
#include "globals.h"
|
2023-02-19 20:47:31 +01:00
|
|
|
#include "fileops.h"
|
2017-10-16 11:55:29 +02:00
|
|
|
|
|
|
|
/* Constants */
|
|
|
|
#define CONSOLE_XCOORD 70
|
2023-02-17 00:40:02 +01:00
|
|
|
#define CONSOLE_YCOORD 114
|
2017-10-16 11:55:29 +02:00
|
|
|
#define CONSOLE_WIDTH 502
|
2023-02-07 22:44:16 +01:00
|
|
|
#define CONSOLE_HEIGHT 300
|
2017-10-16 11:55:29 +02:00
|
|
|
|
|
|
|
s32 __Gui_DrawPng(void *img, u32 x, u32 y)
|
|
|
|
{
|
|
|
|
IMGCTX ctx = NULL;
|
|
|
|
PNGUPROP imgProp;
|
2023-02-19 20:47:31 +01:00
|
|
|
char path[1024];
|
|
|
|
s32 ret = -1;
|
|
|
|
s32 i;
|
2017-10-16 11:55:29 +02:00
|
|
|
|
2023-02-19 20:47:31 +01:00
|
|
|
for (i = 0; i < FatGetDeviceCount(); i++)
|
2017-10-16 11:55:29 +02:00
|
|
|
{
|
2024-07-29 18:15:08 +02:00
|
|
|
snprintf(path, sizeof(path), "%s:%s", FatGetDevicePrefix(i), WM_BACKGROUND_PATH);
|
2023-02-19 20:47:31 +01:00
|
|
|
if (FSOPFileExists(path))
|
|
|
|
{
|
|
|
|
ctx = PNGU_SelectImageFromDevice(path);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-10-16 11:55:29 +02:00
|
|
|
}
|
2023-02-19 20:47:31 +01:00
|
|
|
|
2017-10-16 11:55:29 +02:00
|
|
|
if(!ctx)
|
|
|
|
{
|
2023-02-17 00:40:02 +01:00
|
|
|
/* Select PNG data */
|
|
|
|
ctx = PNGU_SelectImageFromBuffer(img);
|
|
|
|
if (!ctx) {
|
|
|
|
ret = -1;
|
|
|
|
goto out;
|
|
|
|
}
|
2017-10-16 11:55:29 +02:00
|
|
|
}
|
2023-02-19 20:47:31 +01:00
|
|
|
|
2017-10-16 11:55:29 +02:00
|
|
|
/* Get image properties */
|
|
|
|
ret = PNGU_GetImageProperties(ctx, &imgProp);
|
|
|
|
if (ret != PNGU_OK) {
|
|
|
|
ret = -1;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw image */
|
|
|
|
Video_DrawPng(ctx, imgProp, x, y);
|
|
|
|
|
|
|
|
/* Success */
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
out:
|
|
|
|
/* Free memory */
|
|
|
|
if (ctx)
|
|
|
|
PNGU_ReleaseImageContext(ctx);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Gui_InitConsole(void)
|
|
|
|
{
|
|
|
|
/* Initialize console */
|
|
|
|
Con_Init(CONSOLE_XCOORD, CONSOLE_YCOORD, CONSOLE_WIDTH, CONSOLE_HEIGHT);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Gui_DrawBackground(void)
|
|
|
|
{
|
|
|
|
extern char bgData[];
|
2023-02-17 00:40:02 +01:00
|
|
|
|
2017-10-16 11:55:29 +02:00
|
|
|
/* Draw background */
|
|
|
|
__Gui_DrawPng(bgData, 0, 0);
|
|
|
|
}
|