| 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 |
extern char crapple_png[];
|
| - |
|
37 |
extern uint32_t crapple_png_size;
|
| - |
|
38 |
|
| 30 |
struct libpng_api* png;
|
39 |
struct libpng_api* png;
|
| 31 |
struct libboot_api* boot;
|
40 |
struct libboot_api* boot;
|
| 32 |
struct libui_api* ui;
|
41 |
struct libui_api* ui;
|
| 33 |
void* framebuf;
|
42 |
void* framebuf;
|
| 34 |
void* framebuf2;
|
43 |
void* framebuf2;
|
| Line 42... |
Line 51... |
| 42 |
struct emcorelib_header* lib = get_library(identifier, version, LIBSOURCE_BOOTFLASH, filename);
|
51 |
struct emcorelib_header* lib = get_library(identifier, version, LIBSOURCE_BOOTFLASH, filename);
|
| 43 |
if (!lib) panicf(PANIC_KILLTHREAD, "Could not load %s", filename);
|
52 |
if (!lib) panicf(PANIC_KILLTHREAD, "Could not load %s", filename);
|
| 44 |
return lib;
|
53 |
return lib;
|
| 45 |
}
|
54 |
}
|
| 46 |
|
55 |
|
| 47 |
static void* loadpng(const char* filename, void* (*decoder)(struct png_info* handle))
|
56 |
static void* loadpng(const char* buf, const uint32_t size, void* (*decoder)(struct png_info* handle))
|
| 48 |
{
|
57 |
{
|
| 49 |
int size = bootflash_filesize(filename);
|
- |
|
| 50 |
if (size == -1) panicf(PANIC_KILLTHREAD, "Could not load %s", filename);
|
58 |
if (size == 0) panicf(PANIC_KILLTHREAD, "Could not load PNG at 0x%08X", buf);
|
| 51 |
void* buf = memalign(0x10, size);
|
- |
|
| 52 |
if (!buf) panicf(PANIC_KILLTHREAD, "Could not allocate buffer for %s", filename);
|
- |
|
| 53 |
bootflash_read(filename, buf, 0, size);
|
- |
|
| 54 |
struct png_info* handle = png->png_open(buf, size);
|
59 |
struct png_info* handle = png->png_open(buf, size);
|
| 55 |
if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse %s", filename);
|
60 |
if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse PNG at 0x%08X", buf);
|
| 56 |
void* out = decoder(handle);
|
61 |
void* out = decoder(handle);
|
| 57 |
if (!out) panicf(PANIC_KILLTHREAD, "Could not decode %s", filename);
|
62 |
if (!out) panicf(PANIC_KILLTHREAD, "Could not decode PNG at 0x%08X", buf);
|
| 58 |
png->png_destroy(handle);
|
63 |
png->png_destroy(handle);
|
| 59 |
free(buf);
|
- |
|
| 60 |
return out;
|
64 |
return out;
|
| 61 |
}
|
65 |
}
|
| 62 |
|
66 |
|
| 63 |
static void message(int x, const char* line1, const char* line2)
|
67 |
static void message(int x, const char* line1, const char* line2)
|
| 64 |
{
|
68 |
{
|
| Line 677... |
Line 681... |
| 677 |
|
681 |
|
| 678 |
static void main()
|
682 |
static void main()
|
| 679 |
{
|
683 |
{
|
| 680 |
struct emcorelib_header* libpng = loadlib(LIBPNG_IDENTIFIER, LIBPNG_API_VERSION, "libpng ");
|
684 |
struct emcorelib_header* libpng = loadlib(LIBPNG_IDENTIFIER, LIBPNG_API_VERSION, "libpng ");
|
| 681 |
png = (struct libpng_api*)libpng->api;
|
685 |
png = (struct libpng_api*)libpng->api;
|
| 682 |
bg = loadpng("backgrnd", (void* (*)(struct png_info*))(png->png_decode_rgb));
|
686 |
bg = loadpng(background_png, background_png_size, (void* (*)(struct png_info*))(png->png_decode_rgb));
|
| 683 |
icons = loadpng("iconset ", (void* (*)(struct png_info*))(png->png_decode_rgba));
|
687 |
icons = loadpng(icons_png, icons_png_size, (void* (*)(struct png_info*))(png->png_decode_rgba));
|
| 684 |
rbxlogo = loadpng("rbxlogo ", (void* (*)(struct png_info*))(png->png_decode_rgb));
|
688 |
rbxlogo = loadpng(rockbox_png, rockbox_png_size, (void* (*)(struct png_info*))(png->png_decode_rgb));
|
| 685 |
crapple = loadpng("crapple ", (void* (*)(struct png_info*))(png->png_decode_rgba));
|
689 |
crapple = loadpng(crapple_png, crapple_png_size, (void* (*)(struct png_info*))(png->png_decode_rgba));
|
| 686 |
release_library(libpng);
|
690 |
release_library(libpng);
|
| 687 |
library_unload(libpng);
|
691 |
library_unload(libpng);
|
| 688 |
struct emcorelib_header* libboot = loadlib(LIBBOOT_IDENTIFIER,
|
692 |
struct emcorelib_header* libboot = loadlib(LIBBOOT_IDENTIFIER,
|
| 689 |
LIBBOOT_API_VERSION, "libboot ");
|
693 |
LIBBOOT_API_VERSION, "libboot ");
|
| 690 |
boot = (struct libboot_api*)libboot->api;
|
694 |
boot = (struct libboot_api*)libboot->api;
|