Subversion Repositories freemyipod

Rev

Rev 552 | Rev 671 | 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
{
651 theseven 189
    struct emcorelib_header* libboot = get_library(LIBBOOT_IDENTIFIER, LIBBOOT_API_VERSION, LIBSOURCE_BOOTFLASH, "libboot ");
528 theseven 190
    if (!libboot) panicf(PANIC_KILLTHREAD, "Could not load booting library!");
191
    struct libboot_api* boot = (struct libboot_api*)libboot->api;
651 theseven 192
    struct emcorelib_header* libpng = get_library(LIBPNG_IDENTIFIER, LIBPNG_API_VERSION, LIBSOURCE_BOOTFLASH, "libpng  ");
528 theseven 193
    if (!libpng) panicf(PANIC_KILLTHREAD, "Could not load PNG decoder library!");
194
    struct libpng_api* png = (struct libpng_api*)libpng->api;
651 theseven 195
    struct emcorelib_header* libui = get_library(LIBUI_IDENTIFIER, LIBUI_API_VERSION, LIBSOURCE_BOOTFLASH, "libui   ");
528 theseven 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;
551 theseven 266
    backlight_set_brightness(177);
528 theseven 267
    void* firmware = NULL;
268
    while (!firmware)
269
    {
270
        const struct chooser_item* result = ui->chooser_run(&mychooser);
271
        switch ((int)(result->user))
272
        {
273
        case 0:
274
            shutdown(true);
275
            power_off();
276
            break;
277
        case 1:
278
        {
279
            int i;
545 theseven 280
            for (i = 23; i <= 115; i += 23)
528 theseven 281
            {
545 theseven 282
                if (i < 115)
283
                    ui->blend(176, 132, 50, framebuf, 0, 0, 176,
284
                              framebuf, 0, 0, 176, bg, 0, 0, 176);
285
                else memcpy(framebuf, bg, 176 * 132 * 3);
286
                memcpy(framebuf2, framebuf, 176 * 132 * 3);
287
                ui->blenda(111, i, 255, framebuf2, 32, 0, 176,
288
                           framebuf2, 32, 0, 176, crapple, 0, 115 - i, 111);
289
                displaylcd(0, 0, 176, 132, framebuf2, 0, 0, 176);
528 theseven 290
            }
545 theseven 291
            int fd = file_open("/.boot/appleos.bin", O_RDONLY);
292
            if (fd > 0)
293
            {
294
                size = filesize(fd);
295
                if (size > 0)
296
                {
297
                    void* buf = memalign(0x10, size);
298
                    if (buf)
299
                    {
300
                        if (read(fd, buf, size) == size) firmware = buf;
301
                        else free(buf);
302
                    }
303
                }
304
                close(fd);
305
            }
306
            if (!firmware)
307
            {
308
                rendertext(framebuf2, 7, 73, 176, 0xff3333ff, 0xa0000000, "Loading appleos.bin failed!");
309
                rendertext(framebuf2, 7, 81, 176, 0xff3333ff, 0xa0000000, "  Returning to main menu.  ");
310
                displaylcd(0, 0, 176, 132, framebuf2, 0, 0, 176);
311
                sleep(5000000);
312
            }
313
            break;
314
        }
315
        case 2:
316
        {
317
            int i;
318
            for (i = 2; i <= 52; i += 10)
319
            {
320
                if (i < 52)
321
                    ui->blend(176, 132, 50, framebuf, 0, 0, 176,
322
                              framebuf, 0, 0, 176, bg, 0, 0, 176);
323
                else memcpy(framebuf, bg, 176 * 132 * 3);
324
                ui->blit(154, MIN(47, i), 3, framebuf, 11, MAX(0, i - 47), 176,
325
                         rbxlogo, 0, MAX(0, 47 - i), 154);
326
                displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
327
            }
528 theseven 328
            int fd = file_open("/.rockbox/rockbox.ipod", O_RDONLY);
329
            if (fd > 0)
330
            {
331
                size = filesize(fd);
332
                if (size > 0)
333
                {
334
                    void* buf = memalign(0x10, size);
335
                    if (buf)
336
                    {
337
                        if (read(fd, buf, size) == size)
338
                            if (!boot->verify_rockbox_checksum(buf, size))
339
                                firmware = buf;
340
                        if (!firmware) free(buf);
341
                    }
342
                }
343
                close(fd);
344
            }
345
            if (!firmware)
346
            {
545 theseven 347
                rendertext(framebuf, 4, 73, 176, 0xff3333ff, 0xa0000000, "Loading rockbox.ipod failed!");
348
                rendertext(framebuf, 4, 81, 176, 0xff3333ff, 0xa0000000, "  Trying fallback image...  ");
349
                displaylcd(0, 0, 176, 132, framebuf, 0, 0, 132);
528 theseven 350
                sleep(5000000);
351
                size = bootflash_filesize("rockbox ");
352
                if (size > 0)
353
                {
354
                    void* buf = memalign(0x10, size);
355
                    if (buf)
356
                    {
357
                        bootflash_read("rockbox ", buf, 0, size);
358
                        if (bootflash_attributes("rockbox ") & 0x800)
359
                        {
360
                            void* buf2 = malloc(0x100000);
361
                            if (buf2)
362
                            {
363
                                if (!ucl_decompress(buf, size, buf2, (uint32_t*)&size))
364
                                {
365
                                    free(buf);
366
                                    buf = realloc(buf2, size);
367
                                    if (!buf) buf = buf2;
368
                                    if (!boot->verify_rockbox_checksum(buf, size))
369
                                        firmware = buf;
370
                                    else free(buf);
371
                                }
372
                                else
373
                                {
374
                                    free(buf2);
375
                                    free(buf);
376
                                }
377
                            }
378
                            else free(buf);
379
                        }
380
                        else
381
                        {
382
                            if (!boot->verify_rockbox_checksum(buf, size)) firmware = buf;
383
                            else free(buf);
384
                        }
385
                    }
386
                }
387
            }
388
            if (!firmware)
389
            {
545 theseven 390
                memcpy(framebuf, bg, 176 * 132 * 3);
391
                rendertext(framebuf, 19, 73, 176, 0xff3333ff, 0xa0000000, "Loading Rockbox failed!");
392
                rendertext(framebuf, 19, 81, 176, 0xff3333ff, 0xa0000000, "Returning to main menu.");
393
                displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
528 theseven 394
                sleep(5000000);
395
            }
396
            break;
397
        }
545 theseven 398
        case 3:
528 theseven 399
            goto leave;
545 theseven 400
        case 4:
528 theseven 401
            size = bootflash_filesize("umsboot ");
402
            if (size > 0)
403
            {
404
                void* buf = memalign(0x10, size);
405
                if (buf)
406
                {
407
                    bootflash_read("umsboot ", buf, 0, size);
408
                    if (bootflash_attributes("umsboot ") & 0x800)
409
                    {
410
                        void* buf2 = malloc(0x10000);
411
                        if (buf2)
412
                        {
413
                            if (!ucl_decompress(buf, size, buf2, (uint32_t*)&size))
414
                            {
415
                                free(buf);
416
                                buf = realloc(buf2, size);
417
                                if (!buf) buf = buf2;
418
                                firmware = buf;
419
                            }
420
                            else
421
                            {
422
                                free(buf2);
423
                                free(buf);
424
                            }
425
                        }
426
                        else free(buf);
427
                    }
428
                    else firmware = buf;
429
                }
430
            }
431
            if (!firmware)
432
            {
545 theseven 433
                memcpy(framebuf, bg, 176 * 132 * 3);
434
                rendertext(framebuf, 19, 73, 176, 0xff3333ff, 0xa0000000, "Loading UMSboot failed!");
435
                rendertext(framebuf, 19, 81, 176, 0xff3333ff, 0xa0000000, "Returning to main menu.");
436
                displaylcd(0, 0, 176, 132, framebuf, 0, 0, 132);
528 theseven 437
                sleep(5000000);
438
            }
439
            break;
545 theseven 440
        case 5:
441
            size = bootflash_filesize("diagmode");
442
            if (size > 0)
443
            {
444
                void* buf = memalign(0x10, size);
445
                if (buf)
446
                {
447
                    bootflash_read("diagmode", buf, 0, size);
448
                    if (bootflash_attributes("diagmode") & 0x800)
449
                    {
552 theseven 450
                        void* buf2 = malloc(0x80000);
545 theseven 451
                        if (buf2)
452
                        {
453
                            if (!ucl_decompress(buf, size, buf2, (uint32_t*)&size))
454
                            {
455
                                free(buf);
456
                                buf = realloc(buf2, size);
457
                                if (!buf) buf = buf2;
458
                                firmware = buf;
459
                            }
460
                            else
461
                            {
462
                                free(buf2);
463
                                free(buf);
464
                            }
465
                        }
466
                        else free(buf);
467
                    }
468
                    else firmware = buf;
469
                }
470
            }
471
            if (!firmware)
472
            {
473
                memcpy(framebuf, bg, 176 * 132 * 3);
474
                rendertext(framebuf, 13, 73, 176, 0xff3333ff, 0xa0000000, "Loading diag mode failed!");
475
                rendertext(framebuf, 13, 81, 176, 0xff3333ff, 0xa0000000, " Returning to main menu. ");
476
                displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
477
                sleep(5000000);
478
            }
479
            break;
480
        case 6:
481
            size = bootflash_filesize("diskmode");
482
            if (size > 0)
483
            {
484
                void* buf = memalign(0x10, size);
485
                if (buf)
486
                {
487
                    bootflash_read("diskmode", buf, 0, size);
488
                    if (bootflash_attributes("diskmode") & 0x800)
489
                    {
552 theseven 490
                        void* buf2 = malloc(0x80000);
545 theseven 491
                        if (buf2)
492
                        {
493
                            if (!ucl_decompress(buf, size, buf2, (uint32_t*)&size))
494
                            {
495
                                free(buf);
496
                                buf = realloc(buf2, size);
497
                                if (!buf) buf = buf2;
498
                                firmware = buf;
499
                            }
500
                            else
501
                            {
502
                                free(buf2);
503
                                free(buf);
504
                            }
505
                        }
506
                        else free(buf);
507
                    }
508
                    else firmware = buf;
509
                }
510
            }
511
            if (!firmware)
512
            {
513
                memcpy(framebuf, bg, 176 * 132 * 3);
514
                rendertext(framebuf, 13, 73, 176, 0xff3333ff, 0xa0000000, "Loading disk mode failed!");
515
                rendertext(framebuf, 13, 81, 176, 0xff3333ff, 0xa0000000, " Returning to main menu. ");
516
                displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
517
                sleep(5000000);
518
            }
519
            break;
528 theseven 520
        }
521
    }
522
leave:
545 theseven 523
    free(framebuf2);
528 theseven 524
    free(framebuf);
545 theseven 525
    free(crapple);
528 theseven 526
    free(rbxlogo);
527
    free(icons);
528
    free(bg);
529
    release_library(libui);
545 theseven 530
    release_library(libpng);
531
    release_library(libboot);
528 theseven 532
    library_unload(libui);
533
    library_unload(libpng);
534
    library_unload(libboot);
535
    if (firmware)
536
    {
537
        shutdown(false);
538
        execfirmware((void*)0x08000000, firmware, size);
539
    }
540
    else cputs(3, "Dropped into emCORE console.\n");
541
}
542
 
543
 
544
EMCORE_APP_HEADER("Boot menu", main, 127)