Subversion Repositories freemyipod

Rev

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

Rev Author Line No. Line
660 theseven 1
//
2
//
3
//    Copyright 2011 TheSeven
4
//
5
//
6
//    This file is part of emCORE.
7
//
8
//    emCORE is free software: you can redistribute it and/or
9
//    modify it under the terms of the GNU General Public License as
10
//    published by the Free Software Foundation, either version 2 of the
11
//    License, or (at your option) any later version.
12
//
13
//    emCORE is distributed in the hope that it will be useful,
14
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
//    See the GNU General Public License for more details.
17
//
18
//    You should have received a copy of the GNU General Public License along
19
//    with emCORE.  If not, see <http://www.gnu.org/licenses/>.
20
//
21
//
22
 
23
 
528 theseven 24
#include "emcoreapp.h"
808 theseven 25
#include "resources.h"
26
#include "main.h"
27
#include "boot.h"
28
#include "settings.h"
29
#include "mainchooser.h"
30
#include "settingchooser.h"
31
#include "util.h"
528 theseven 32
 
768 user890104 33
 
660 theseven 34
struct libboot_api* boot;
35
struct libui_api* ui;
36
void* framebuf;
830 theseven 37
void* framebuf2;
660 theseven 38
void* bg;
39
void* icons;
40
void* rbxlogo;
528 theseven 41
 
660 theseven 42
 
808 theseven 43
static void main()
660 theseven 44
{
808 theseven 45
    settings_init();
46
 
47
    struct emcorelib_header* libboot = loadlib(LIBBOOT_IDENTIFIER,
48
                                               LIBBOOT_API_VERSION, "libboot ");
49
    boot = (struct libboot_api*)libboot->api;
660 theseven 50
 
808 theseven 51
    bool terminate = false;
52
    void* firmware = NULL;
53
    void* app = NULL;
54
    int size;
660 theseven 55
 
808 theseven 56
    if (!(clickwheel_get_state() & 0x1f))
57
        switch (settings.fastboot_item)
660 theseven 58
        {
808 theseven 59
            case 1:
60
                fastboot_rockbox(&firmware, &app, &size);
61
                break;
62
 
63
            case 2:
64
                fastboot_umsboot(&firmware, &app, &size);
65
                break;
66
 
67
            case 3:
68
                terminate = true;
69
                break;
660 theseven 70
        }
71
 
808 theseven 72
    if (!firmware && !app && !terminate)
660 theseven 73
    {
808 theseven 74
        struct emcorelib_header* libpng = loadlib(LIBPNG_IDENTIFIER, LIBPNG_API_VERSION, "libpng  ");
75
        struct libpng_api* png = (struct libpng_api*)libpng->api;
76
        bg = loadpng(png, background_png, background_png_size, (void* (*)(struct png_info*))(png->png_decode_rgb));
77
        icons = loadpng(png, icons_png, icons_png_size, (void* (*)(struct png_info*))(png->png_decode_rgba));
78
        rbxlogo = loadpng(png, rockbox_png, rockbox_png_size, (void* (*)(struct png_info*))(png->png_decode_rgb));
79
        release_library(libpng);
80
        library_unload(libpng);
81
 
82
        struct emcorelib_header* libui = loadlib(LIBUI_IDENTIFIER, LIBUI_API_VERSION, "libui   ");
83
        ui = (struct libui_api*)libui->api;
84
 
85
        framebuf = malloc(320 * 240 * 3);
86
        if (!framebuf) panicf(PANIC_KILLTHREAD, "Could not allocate framebuffer!");
830 theseven 87
        framebuf2 = malloc(320 * 240 * 3);
88
        if (!framebuf2) panicf(PANIC_KILLTHREAD, "Could not allocate framebuffer 2!");
660 theseven 89
 
808 theseven 90
        mainchooser_init();
91
        toolchooser_init();
92
        settingchooser_init();
830 theseven 93
        confirmchooser_init();
808 theseven 94
 
95
        run_mainchooser(&firmware, &app, &size);
823 theseven 96
 
830 theseven 97
        free(framebuf2);
808 theseven 98
        free(framebuf);
99
        free(rbxlogo);
100
        free(icons);
101
        free(bg);
102
        release_library(libui);
103
        library_unload(libui);
528 theseven 104
    }
105
 
551 theseven 106
    release_library(libboot);
528 theseven 107
    library_unload(libboot);
660 theseven 108
 
528 theseven 109
    if (firmware)
110
    {
111
        shutdown(false);
112
        execfirmware((void*)0x08000000, firmware, size);
113
    }
660 theseven 114
    else if (app) execimage(app, false);
528 theseven 115
    else cputs(3, "Dropped into emCORE console.\n");
116
}
117
 
118
EMCORE_APP_HEADER("Boot menu", main, 127)