Subversion Repositories freemyipod

Rev

Rev 535 | Rev 551 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
528 theseven 1
#include "emcoreapp.h"
2
#include "libboot.h"
3
#include "libpng.h"
4
#include "libui.h"
5
 
6
 
7
void* framebuf;
8
 
9
 
10
bool mychooser_preblit(struct chooser_data* data)
11
{
12
    char buf[4];
13
    struct chooser_action_handler_wheel_data* adata;
14
    adata = (struct chooser_action_handler_wheel_data*)(data->actionhandlerdata);
15
    snprintf(buf, sizeof(buf), "%3d", adata->timeout_remaining / 1000000);
545 theseven 16
    rendertext(framebuf, 158, 124, 176, 0xffffcccc, 0, buf);
528 theseven 17
    return false;
18
}
19
 
20
 
21
struct chooser_renderer_iconflow_itemdata mychooser_rparams_0 =
22
{
545 theseven 23
    .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 31)),
24
                          LIBUI_POINT(44, 40)),
25
    .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 31)),
26
                                   LIBUI_POINT(44, 40)),
528 theseven 27
    .text = "Power off",
28
    .text_color = 0xffffcccc,
29
};
30
 
31
struct chooser_renderer_iconflow_itemdata mychooser_rparams_1 =
32
{
545 theseven 33
    .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 177)),
34
                          LIBUI_POINT(44, 43)),
35
    .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 177)),
36
                                   LIBUI_POINT(44, 43)),
37
    .text = "Original firmware",
528 theseven 38
    .text_color = 0xffffcccc,
39
};
40
 
41
struct chooser_renderer_iconflow_itemdata mychooser_rparams_2 =
42
{
545 theseven 43
    .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 0)),
44
                          LIBUI_POINT(44, 14)),
45
    .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 0)),
46
                                   LIBUI_POINT(44, 14)),
47
    .text = "Rockbox",
528 theseven 48
    .text_color = 0xffffcccc,
49
};
50
 
51
struct chooser_renderer_iconflow_itemdata mychooser_rparams_3 =
52
{
545 theseven 53
    .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 14)),
54
                          LIBUI_POINT(44, 17)),
55
    .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 14)),
56
                                   LIBUI_POINT(44, 17)),
57
    .text = "emCORE console",
58
    .text_color = 0xffffcccc,
59
};
60
 
61
struct chooser_renderer_iconflow_itemdata mychooser_rparams_4 =
62
{
63
    .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 71)),
64
                          LIBUI_POINT(44, 31)),
65
    .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 71)),
66
                                   LIBUI_POINT(44, 31)),
528 theseven 67
    .text = "UMSboot",
68
    .text_color = 0xffffcccc,
69
};
70
 
545 theseven 71
struct chooser_renderer_iconflow_itemdata mychooser_rparams_5 =
72
{
73
    .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 133)),
74
                          LIBUI_POINT(44, 44)),
75
    .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 133)),
76
                                   LIBUI_POINT(44, 44)),
77
    .text = "Diagnostics mode",
78
    .text_color = 0xffffcccc,
79
};
80
 
81
struct chooser_renderer_iconflow_itemdata mychooser_rparams_6 =
82
{
83
    .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 102)),
84
                          LIBUI_POINT(44, 31)),
85
    .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 102)),
86
                                   LIBUI_POINT(44, 31)),
87
    .text = "Disk mode",
88
    .text_color = 0xffffcccc,
89
};
90
 
528 theseven 91
struct chooser_renderer_iconflow_params mychooser_rparams =
92
{
93
    .version = CHOOSER_RENDERER_LIST_PARAMS_VERSION,
545 theseven 94
    .copy_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 0)),
95
    .copy_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 0)),
96
                              LIBUI_POINT(176, 132)),
528 theseven 97
    .bg_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
98
    .bg_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
99
                            LIBUI_POINT(0, 0)),
100
    .bg_opacity = 0,
101
    .fill_dest = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
102
                               LIBUI_POINT(0, 0)),
103
    .fill_color = 0,
545 theseven 104
    .viewport = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 16)),
105
                              LIBUI_POINT(176, 72)),
106
    .text_pos = LIBUI_POINT(88, 118),
528 theseven 107
    .blit_dest = LIBUI_POINT(0, 0),
545 theseven 108
    .blit_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 0)),
109
                              LIBUI_POINT(176, 132)),
528 theseven 110
    .smoothness = 500000,
111
    .startposition = -3,
112
    .iconsinview = 4,
113
    .preblit = mychooser_preblit,
114
    .postblit = NULL
115
};
116
 
117
struct chooser_action_handler_wheel_params mychooser_aparams =
118
{
119
    .version = CHOOSER_ACTION_HANDLER_WHEEL_PARAMS_VERSION,
120
    .stepsperitem = 512,
121
    .eventfilter = NULL,
122
    .timeout_initial = 30500000,
123
    .timeout_idle = 300500000,
124
    .timeout_item = 0,
125
    .tick_force_redraw = true,
126
    .buttoncount = 3,
127
    .buttonmap =
128
    {
129
        CHOOSER_ACTION_HANDLER_WHEEL_ACTION_SELECT,
130
        CHOOSER_ACTION_HANDLER_WHEEL_ACTION_NEXT,
131
        CHOOSER_ACTION_HANDLER_WHEEL_ACTION_PREV
132
    }
133
};
134
 
135
struct chooser_info mychooser =
136
{
137
    .version = CHOOSER_INFO_VERSION,
138
    .actionhandler = NULL,
139
    .actionhandlerparams = &mychooser_aparams,
140
    .renderer = NULL,
141
    .rendererparams = &mychooser_rparams,
142
    .userparams = NULL,
143
    .tickinterval = 990000,
545 theseven 144
    .itemcount = 7,
145
    .defaultitem = 2,
528 theseven 146
    .items =
147
    {
148
        {
149
            .user = (void*)0,
150
            .actionparams = NULL,
151
            .renderparams = &mychooser_rparams_0
152
        },
153
        {
154
            .user = (void*)1,
155
            .actionparams = NULL,
156
            .renderparams = &mychooser_rparams_1
157
        },
158
        {
159
            .user = (void*)2,
160
            .actionparams = NULL,
161
            .renderparams = &mychooser_rparams_2
162
        },
163
        {
164
            .user = (void*)3,
165
            .actionparams = NULL,
166
            .renderparams = &mychooser_rparams_3
545 theseven 167
        },
168
        {
169
            .user = (void*)4,
170
            .actionparams = NULL,
171
            .renderparams = &mychooser_rparams_4
172
        },
173
        {
174
            .user = (void*)5,
175
            .actionparams = NULL,
176
            .renderparams = &mychooser_rparams_5
177
        },
178
        {
179
            .user = (void*)6,
180
            .actionparams = NULL,
181
            .renderparams = &mychooser_rparams_6
528 theseven 182
        }
183
    }
184
};
185
 
186
 
187
static void main()
188
{
189
    struct emcorelib_header* libboot = get_library(0x4c424365, LIBBOOT_API_VERSION, LIBSOURCE_BOOTFLASH, "libboot ");
190
    if (!libboot) panicf(PANIC_KILLTHREAD, "Could not load booting library!");
191
    struct libboot_api* boot = (struct libboot_api*)libboot->api;
192
    struct emcorelib_header* libpng = get_library(0x64474e50, LIBPNG_API_VERSION, LIBSOURCE_BOOTFLASH, "libpng  ");
193
    if (!libpng) panicf(PANIC_KILLTHREAD, "Could not load PNG decoder library!");
194
    struct libpng_api* png = (struct libpng_api*)libpng->api;
195
    struct emcorelib_header* libui = get_library(0x49554365, LIBUI_API_VERSION, LIBSOURCE_BOOTFLASH, "libui   ");
196
    if (!libui) panicf(PANIC_KILLTHREAD, "Could not load user interface library!");
197
    struct libui_api* ui = (struct libui_api*)libui->api;
198
    int size = bootflash_filesize("backgrnd");
199
    if (size == -1) panicf(PANIC_KILLTHREAD, "Could not find background image!");
200
    void* buf = memalign(0x10, size);
201
    if (!buf) panicf(PANIC_KILLTHREAD, "Could not allocate buffer for background image!");
202
    bootflash_read("backgrnd", buf, 0, size);
203
    struct png_info* handle = png->png_open(buf, size);
204
    if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse background image!");
205
    struct png_rgb* bg = png->png_decode_rgb(handle);
206
    if (!bg) panicf(PANIC_KILLTHREAD, "Could not decode background image!");
207
    png->png_destroy(handle);
208
    free(buf);
209
    size = bootflash_filesize("iconset ");
210
    if (size == -1) panicf(PANIC_KILLTHREAD, "Could not find icon set!");
211
    buf = memalign(0x10, size);
212
    if (!buf) panicf(PANIC_KILLTHREAD, "Could not allocate buffer for icon set!");
213
    bootflash_read("iconset ", buf, 0, size);
214
    handle = png->png_open(buf, size);
215
    if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse icon set!");
216
    struct png_rgba* icons = png->png_decode_rgba(handle);
217
    if (!icons) panicf(PANIC_KILLTHREAD, "Could not decode icon set!");
218
    png->png_destroy(handle);
219
    free(buf);
220
    size = bootflash_filesize("rbxlogo ");
221
    if (size == -1) panicf(PANIC_KILLTHREAD, "Could not find Rockbox logo!");
222
    buf = memalign(0x10, size);
223
    if (!buf) panicf(PANIC_KILLTHREAD, "Could not allocate buffer for Rockbox logo!");
224
    bootflash_read("rbxlogo ", buf, 0, size);
225
    handle = png->png_open(buf, size);
226
    if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse Rockbox logo!");
227
    struct png_rgb* rbxlogo = png->png_decode_rgb(handle);
228
    if (!rbxlogo) panicf(PANIC_KILLTHREAD, "Could not decode Rockbox logo!");
229
    png->png_destroy(handle);
230
    free(buf);
545 theseven 231
    size = bootflash_filesize("crapple ");
232
    if (size == -1) panicf(PANIC_KILLTHREAD, "Could not find OF logo!");
233
    buf = memalign(0x10, size);
234
    if (!buf) panicf(PANIC_KILLTHREAD, "Could not allocate buffer for OF logo!");
235
    bootflash_read("crapple ", buf, 0, size);
236
    handle = png->png_open(buf, size);
237
    if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse OF logo!");
238
    struct png_rgba* crapple = png->png_decode_rgba(handle);
239
    if (!rbxlogo) panicf(PANIC_KILLTHREAD, "Could not decode OF logo!");
240
    png->png_destroy(handle);
241
    free(buf);
242
    framebuf = malloc(176 * 132 * 3);
528 theseven 243
    if (!framebuf) panicf(PANIC_KILLTHREAD, "Could not allocate framebuffer!");
545 theseven 244
    void* framebuf2 = malloc(176 * 132 * 3);
245
    if (!framebuf2) panicf(PANIC_KILLTHREAD, "Could not allocate framebuffer 2!");
528 theseven 246
    mychooser.actionhandler = ui->chooser_action_handler_wheel;
247
    mychooser.renderer = ui->chooser_renderer_iconflow;
248
    mychooser_rparams.copy_dest.buf.addr = framebuf;
249
    mychooser_rparams.copy_src.loc.buf.addr = bg;
250
    mychooser_rparams.viewport.loc.buf.addr = framebuf;
251
    mychooser_rparams.blit_src.loc.buf.addr = framebuf;
252
    mychooser_rparams_0.icon.loc.buf.addr = icons;
253
    mychooser_rparams_0.icon_selected.loc.buf.addr = icons;
254
    mychooser_rparams_1.icon.loc.buf.addr = icons;
255
    mychooser_rparams_1.icon_selected.loc.buf.addr = icons;
256
    mychooser_rparams_2.icon.loc.buf.addr = icons;
257
    mychooser_rparams_2.icon_selected.loc.buf.addr = icons;
258
    mychooser_rparams_3.icon.loc.buf.addr = icons;
259
    mychooser_rparams_3.icon_selected.loc.buf.addr = icons;
545 theseven 260
    mychooser_rparams_4.icon.loc.buf.addr = icons;
261
    mychooser_rparams_4.icon_selected.loc.buf.addr = icons;
262
    mychooser_rparams_5.icon.loc.buf.addr = icons;
263
    mychooser_rparams_5.icon_selected.loc.buf.addr = icons;
264
    mychooser_rparams_6.icon.loc.buf.addr = icons;
265
    mychooser_rparams_6.icon_selected.loc.buf.addr = icons;
528 theseven 266
    void* firmware = NULL;
267
    while (!firmware)
268
    {
269
        const struct chooser_item* result = ui->chooser_run(&mychooser);
270
        switch ((int)(result->user))
271
        {
272
        case 0:
273
            shutdown(true);
274
            power_off();
275
            break;
276
        case 1:
277
        {
278
            int i;
545 theseven 279
            for (i = 23; i <= 115; i += 23)
528 theseven 280
            {
545 theseven 281
                if (i < 115)
282
                    ui->blend(176, 132, 50, framebuf, 0, 0, 176,
283
                              framebuf, 0, 0, 176, bg, 0, 0, 176);
284
                else memcpy(framebuf, bg, 176 * 132 * 3);
285
                memcpy(framebuf2, framebuf, 176 * 132 * 3);
286
                ui->blenda(111, i, 255, framebuf2, 32, 0, 176,
287
                           framebuf2, 32, 0, 176, crapple, 0, 115 - i, 111);
288
                displaylcd(0, 0, 176, 132, framebuf2, 0, 0, 176);
528 theseven 289
            }
545 theseven 290
            int fd = file_open("/.boot/appleos.bin", O_RDONLY);
291
            if (fd > 0)
292
            {
293
                size = filesize(fd);
294
                if (size > 0)
295
                {
296
                    void* buf = memalign(0x10, size);
297
                    if (buf)
298
                    {
299
                        if (read(fd, buf, size) == size) firmware = buf;
300
                        else free(buf);
301
                    }
302
                }
303
                close(fd);
304
            }
305
            if (!firmware)
306
            {
307
                rendertext(framebuf2, 7, 73, 176, 0xff3333ff, 0xa0000000, "Loading appleos.bin failed!");
308
                rendertext(framebuf2, 7, 81, 176, 0xff3333ff, 0xa0000000, "  Returning to main menu.  ");
309
                displaylcd(0, 0, 176, 132, framebuf2, 0, 0, 176);
310
                sleep(5000000);
311
            }
312
            break;
313
        }
314
        case 2:
315
        {
316
            int i;
317
            for (i = 2; i <= 52; i += 10)
318
            {
319
                if (i < 52)
320
                    ui->blend(176, 132, 50, framebuf, 0, 0, 176,
321
                              framebuf, 0, 0, 176, bg, 0, 0, 176);
322
                else memcpy(framebuf, bg, 176 * 132 * 3);
323
                ui->blit(154, MIN(47, i), 3, framebuf, 11, MAX(0, i - 47), 176,
324
                         rbxlogo, 0, MAX(0, 47 - i), 154);
325
                displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
326
            }
528 theseven 327
            int fd = file_open("/.rockbox/rockbox.ipod", O_RDONLY);
328
            if (fd > 0)
329
            {
330
                size = filesize(fd);
331
                if (size > 0)
332
                {
333
                    void* buf = memalign(0x10, size);
334
                    if (buf)
335
                    {
336
                        if (read(fd, buf, size) == size)
337
                            if (!boot->verify_rockbox_checksum(buf, size))
338
                                firmware = buf;
339
                        if (!firmware) free(buf);
340
                    }
341
                }
342
                close(fd);
343
            }
344
            if (!firmware)
345
            {
545 theseven 346
                rendertext(framebuf, 4, 73, 176, 0xff3333ff, 0xa0000000, "Loading rockbox.ipod failed!");
347
                rendertext(framebuf, 4, 81, 176, 0xff3333ff, 0xa0000000, "  Trying fallback image...  ");
348
                displaylcd(0, 0, 176, 132, framebuf, 0, 0, 132);
528 theseven 349
                sleep(5000000);
350
                size = bootflash_filesize("rockbox ");
351
                if (size > 0)
352
                {
353
                    void* buf = memalign(0x10, size);
354
                    if (buf)
355
                    {
356
                        bootflash_read("rockbox ", buf, 0, size);
357
                        if (bootflash_attributes("rockbox ") & 0x800)
358
                        {
359
                            void* buf2 = malloc(0x100000);
360
                            if (buf2)
361
                            {
362
                                if (!ucl_decompress(buf, size, buf2, (uint32_t*)&size))
363
                                {
364
                                    free(buf);
365
                                    buf = realloc(buf2, size);
366
                                    if (!buf) buf = buf2;
367
                                    if (!boot->verify_rockbox_checksum(buf, size))
368
                                        firmware = buf;
369
                                    else free(buf);
370
                                }
371
                                else
372
                                {
373
                                    free(buf2);
374
                                    free(buf);
375
                                }
376
                            }
377
                            else free(buf);
378
                        }
379
                        else
380
                        {
381
                            if (!boot->verify_rockbox_checksum(buf, size)) firmware = buf;
382
                            else free(buf);
383
                        }
384
                    }
385
                }
386
            }
387
            if (!firmware)
388
            {
545 theseven 389
                memcpy(framebuf, bg, 176 * 132 * 3);
390
                rendertext(framebuf, 19, 73, 176, 0xff3333ff, 0xa0000000, "Loading Rockbox failed!");
391
                rendertext(framebuf, 19, 81, 176, 0xff3333ff, 0xa0000000, "Returning to main menu.");
392
                displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
528 theseven 393
                sleep(5000000);
394
            }
395
            break;
396
        }
545 theseven 397
        case 3:
528 theseven 398
            goto leave;
545 theseven 399
        case 4:
528 theseven 400
            size = bootflash_filesize("umsboot ");
401
            if (size > 0)
402
            {
403
                void* buf = memalign(0x10, size);
404
                if (buf)
405
                {
406
                    bootflash_read("umsboot ", buf, 0, size);
407
                    if (bootflash_attributes("umsboot ") & 0x800)
408
                    {
409
                        void* buf2 = malloc(0x10000);
410
                        if (buf2)
411
                        {
412
                            if (!ucl_decompress(buf, size, buf2, (uint32_t*)&size))
413
                            {
414
                                free(buf);
415
                                buf = realloc(buf2, size);
416
                                if (!buf) buf = buf2;
417
                                firmware = buf;
418
                            }
419
                            else
420
                            {
421
                                free(buf2);
422
                                free(buf);
423
                            }
424
                        }
425
                        else free(buf);
426
                    }
427
                    else firmware = buf;
428
                }
429
            }
430
            if (!firmware)
431
            {
545 theseven 432
                memcpy(framebuf, bg, 176 * 132 * 3);
433
                rendertext(framebuf, 19, 73, 176, 0xff3333ff, 0xa0000000, "Loading UMSboot failed!");
434
                rendertext(framebuf, 19, 81, 176, 0xff3333ff, 0xa0000000, "Returning to main menu.");
435
                displaylcd(0, 0, 176, 132, framebuf, 0, 0, 132);
528 theseven 436
                sleep(5000000);
437
            }
438
            break;
545 theseven 439
        case 5:
440
            size = bootflash_filesize("diagmode");
441
            if (size > 0)
442
            {
443
                void* buf = memalign(0x10, size);
444
                if (buf)
445
                {
446
                    bootflash_read("diagmode", buf, 0, size);
447
                    if (bootflash_attributes("diagmode") & 0x800)
448
                    {
449
                        void* buf2 = malloc(0x10000);
450
                        if (buf2)
451
                        {
452
                            if (!ucl_decompress(buf, size, buf2, (uint32_t*)&size))
453
                            {
454
                                free(buf);
455
                                buf = realloc(buf2, size);
456
                                if (!buf) buf = buf2;
457
                                firmware = buf;
458
                            }
459
                            else
460
                            {
461
                                free(buf2);
462
                                free(buf);
463
                            }
464
                        }
465
                        else free(buf);
466
                    }
467
                    else firmware = buf;
468
                }
469
            }
470
            if (!firmware)
471
            {
472
                memcpy(framebuf, bg, 176 * 132 * 3);
473
                rendertext(framebuf, 13, 73, 176, 0xff3333ff, 0xa0000000, "Loading diag mode failed!");
474
                rendertext(framebuf, 13, 81, 176, 0xff3333ff, 0xa0000000, " Returning to main menu. ");
475
                displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
476
                sleep(5000000);
477
            }
478
            break;
479
        case 6:
480
            size = bootflash_filesize("diskmode");
481
            if (size > 0)
482
            {
483
                void* buf = memalign(0x10, size);
484
                if (buf)
485
                {
486
                    bootflash_read("diskmode", buf, 0, size);
487
                    if (bootflash_attributes("diskmode") & 0x800)
488
                    {
489
                        void* buf2 = malloc(0x10000);
490
                        if (buf2)
491
                        {
492
                            if (!ucl_decompress(buf, size, buf2, (uint32_t*)&size))
493
                            {
494
                                free(buf);
495
                                buf = realloc(buf2, size);
496
                                if (!buf) buf = buf2;
497
                                firmware = buf;
498
                            }
499
                            else
500
                            {
501
                                free(buf2);
502
                                free(buf);
503
                            }
504
                        }
505
                        else free(buf);
506
                    }
507
                    else firmware = buf;
508
                }
509
            }
510
            if (!firmware)
511
            {
512
                memcpy(framebuf, bg, 176 * 132 * 3);
513
                rendertext(framebuf, 13, 73, 176, 0xff3333ff, 0xa0000000, "Loading disk mode failed!");
514
                rendertext(framebuf, 13, 81, 176, 0xff3333ff, 0xa0000000, " Returning to main menu. ");
515
                displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
516
                sleep(5000000);
517
            }
518
            break;
528 theseven 519
        }
520
    }
521
leave:
545 theseven 522
    free(framebuf2);
528 theseven 523
    free(framebuf);
545 theseven 524
    free(crapple);
528 theseven 525
    free(rbxlogo);
526
    free(icons);
527
    free(bg);
528
    release_library(libui);
545 theseven 529
    release_library(libpng);
530
    release_library(libboot);
528 theseven 531
    library_unload(libui);
532
    library_unload(libpng);
533
    library_unload(libboot);
534
    if (firmware)
535
    {
536
        shutdown(false);
537
        execfirmware((void*)0x08000000, firmware, size);
538
    }
539
    else cputs(3, "Dropped into emCORE console.\n");
540
}
541
 
542
 
543
EMCORE_APP_HEADER("Boot menu", main, 127)