| Line 25... |
Line 25... |
| 25 |
#include "libboot.h"
|
25 |
#include "libboot.h"
|
| 26 |
#include "libpng.h"
|
26 |
#include "libpng.h"
|
| 27 |
#include "libui.h"
|
27 |
#include "libui.h"
|
| 28 |
#include "libmkfat32.h"
|
28 |
#include "libmkfat32.h"
|
| 29 |
|
29 |
|
| - |
|
30 |
extern char background_png[];
|
| - |
|
31 |
extern uint32_t background_png_size;
|
| - |
|
32 |
extern char icons_png[];
|
| - |
|
33 |
extern uint32_t icons_png_size;
|
| - |
|
34 |
extern char rockbox_png[];
|
| - |
|
35 |
extern uint32_t rockbox_png_size;
|
| - |
|
36 |
|
| 30 |
struct libpng_api* png;
|
37 |
struct libpng_api* png;
|
| 31 |
struct libboot_api* boot;
|
38 |
struct libboot_api* boot;
|
| 32 |
struct libui_api* ui;
|
39 |
struct libui_api* ui;
|
| 33 |
void* framebuf;
|
40 |
void* framebuf;
|
| 34 |
void* bg;
|
41 |
void* bg;
|
| Line 40... |
Line 47... |
| 40 |
struct emcorelib_header* lib = get_library(identifier, version, LIBSOURCE_BOOTFLASH, filename);
|
47 |
struct emcorelib_header* lib = get_library(identifier, version, LIBSOURCE_BOOTFLASH, filename);
|
| 41 |
if (!lib) panicf(PANIC_KILLTHREAD, "Could not load %s", filename);
|
48 |
if (!lib) panicf(PANIC_KILLTHREAD, "Could not load %s", filename);
|
| 42 |
return lib;
|
49 |
return lib;
|
| 43 |
}
|
50 |
}
|
| 44 |
|
51 |
|
| 45 |
static void* loadpng(const char* filename, void* (*decoder)(struct png_info* handle))
|
52 |
static void* loadpng(const char* buf, const uint32_t size, void* (*decoder)(struct png_info* handle))
|
| 46 |
{
|
53 |
{
|
| 47 |
int size = bootflash_filesize(filename);
|
- |
|
| 48 |
if (size == -1) panicf(PANIC_KILLTHREAD, "Could not load %s", filename);
|
54 |
if (size == 0) panicf(PANIC_KILLTHREAD, "Could not load PNG at 0x%08X", buf);
|
| 49 |
void* buf = memalign(0x10, size);
|
- |
|
| 50 |
if (!buf) panicf(PANIC_KILLTHREAD, "Could not allocate buffer for %s", filename);
|
- |
|
| 51 |
bootflash_read(filename, buf, 0, size);
|
- |
|
| 52 |
struct png_info* handle = png->png_open(buf, size);
|
55 |
struct png_info* handle = png->png_open(buf, size);
|
| 53 |
if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse %s", filename);
|
56 |
if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse PNG at 0x%08X", buf);
|
| 54 |
void* out = decoder(handle);
|
57 |
void* out = decoder(handle);
|
| 55 |
if (!out) panicf(PANIC_KILLTHREAD, "Could not decode %s", filename);
|
58 |
if (!out) panicf(PANIC_KILLTHREAD, "Could not decode PNG at 0x%08X", buf);
|
| 56 |
png->png_destroy(handle);
|
59 |
png->png_destroy(handle);
|
| 57 |
free(buf);
|
- |
|
| 58 |
return out;
|
60 |
return out;
|
| 59 |
}
|
61 |
}
|
| 60 |
|
62 |
|
| 61 |
static void message(int x, const char* line1, const char* line2)
|
63 |
static void message(int x, const char* line1, const char* line2)
|
| 62 |
{
|
64 |
{
|
| Line 548... |
Line 550... |
| 548 |
|
550 |
|
| 549 |
static void main()
|
551 |
static void main()
|
| 550 |
{
|
552 |
{
|
| 551 |
struct emcorelib_header* libpng = loadlib(LIBPNG_IDENTIFIER, LIBPNG_API_VERSION, "libpng ");
|
553 |
struct emcorelib_header* libpng = loadlib(LIBPNG_IDENTIFIER, LIBPNG_API_VERSION, "libpng ");
|
| 552 |
png = (struct libpng_api*)libpng->api;
|
554 |
png = (struct libpng_api*)libpng->api;
|
| 553 |
bg = loadpng("backgrnd", (void* (*)(struct png_info*))(png->png_decode_rgb));
|
555 |
bg = loadpng(background_png, background_png_size, (void* (*)(struct png_info*))(png->png_decode_rgb));
|
| 554 |
icons = loadpng("iconset ", (void* (*)(struct png_info*))(png->png_decode_rgba));
|
556 |
icons = loadpng(icons_png, icons_png_size, (void* (*)(struct png_info*))(png->png_decode_rgba));
|
| 555 |
rbxlogo = loadpng("rbxlogo ", (void* (*)(struct png_info*))(png->png_decode_rgb));
|
557 |
rbxlogo = loadpng(rockbox_png, rockbox_png_size, (void* (*)(struct png_info*))(png->png_decode_rgb));
|
| 556 |
release_library(libpng);
|
558 |
release_library(libpng);
|
| 557 |
library_unload(libpng);
|
559 |
library_unload(libpng);
|
| 558 |
struct emcorelib_header* libboot = loadlib(LIBBOOT_IDENTIFIER,
|
560 |
struct emcorelib_header* libboot = loadlib(LIBBOOT_IDENTIFIER,
|
| 559 |
LIBBOOT_API_VERSION, "libboot ");
|
561 |
LIBBOOT_API_VERSION, "libboot ");
|
| 560 |
boot = (struct libboot_api*)libboot->api;
|
562 |
boot = (struct libboot_api*)libboot->api;
|