Subversion Repositories freemyipod

Rev

Rev 838 | Rev 848 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 838 Rev 843
Line 45... Line 45...
45
    .size = 0,
45
    .size = 0,
46
    .app = NULL,
46
    .app = NULL,
47
    .argc = 0,
47
    .argc = 0,
48
    .argv = NULL
48
    .argv = NULL
49
};
49
};
-
 
50
static const char* theme_arg = "--run-as-theme";
50
 
51
 
51
 
52
 
52
static void main(int argc, const char** argv)
53
static void main(int argc, const char** argv)
53
{
54
{
54
    settings_init();
55
    int buttons = clickwheel_get_state() & 0x1f;
55
    
56
    
56
    struct emcorelib_header* libboot = loadlib(LIBBOOT_IDENTIFIER,
57
    if (buttons != 6)
-
 
58
    {
57
                                               LIBBOOT_API_VERSION, "libboot ");
59
        bool success = false;
58
    boot = (struct libboot_api*)libboot->api;
60
        void* buffer = NULL;
59
 
-
 
60
    if (!(clickwheel_get_state() & 0x1f))
61
        int fd = file_open("/.apps/bootmenu/theme.emcoreapp", O_RDONLY);
61
        switch (settings.fastboot_item)
62
        if (fd > 0)
62
        {
63
        {
63
            case 1:
-
 
64
                fastboot_rockbox();
64
            int size = filesize(fd);
65
                break;
65
            if (size > 0)
66
            
66
            {
67
            case 2:
67
                buffer = memalign(0x10, size);
68
                fastboot_umsboot();
68
                if (buffer)
69
                break;
69
                {
-
 
70
                    if (read(fd, buffer, size) == size) success = true;
70
            
71
                    else free(buffer);
71
            case 3:
72
                }
72
                bootinfo.valid = true;
73
            }
73
                break;
74
            close(fd);
74
        }
75
        }
-
 
76
        if (success && execimage(buffer, false, 1, &theme_arg) != NULL)
-
 
77
            bootinfo.valid = true;
-
 
78
    }
75
 
79
 
76
    if (!bootinfo.valid)
80
    if (!bootinfo.valid)
77
    {
81
    {
78
        struct emcorelib_header* libpng = loadlib(LIBPNG_IDENTIFIER, LIBPNG_API_VERSION, "libpng  ");
-
 
79
        struct libpng_api* png = (struct libpng_api*)libpng->api;
-
 
80
        bg = loadpng(png, background_png, background_png_size, (void* (*)(struct png_info*))(png->png_decode_rgb));
-
 
81
        icons = loadpng(png, icons_png, icons_png_size, (void* (*)(struct png_info*))(png->png_decode_rgba));
-
 
82
        rbxlogo = loadpng(png, rockbox_png, rockbox_png_size, (void* (*)(struct png_info*))(png->png_decode_rgb));
-
 
83
        release_library(libpng);
82
        settings_init();
84
        library_unload(libpng);
-
 
85
        
-
 
86
        struct emcorelib_header* libui = loadlib(LIBUI_IDENTIFIER, LIBUI_API_VERSION, "libui   ");
-
 
87
        ui = (struct libui_api*)libui->api;
-
 
88
        
83
        
89
        framebuf = malloc(320 * 240 * 3);
-
 
90
        if (!framebuf) panicf(PANIC_KILLTHREAD, "Could not allocate framebuffer!");
84
        struct emcorelib_header* libboot = loadlib(LIBBOOT_IDENTIFIER,
91
        framebuf2 = malloc(320 * 240 * 3);
-
 
92
        if (!framebuf2) panicf(PANIC_KILLTHREAD, "Could not allocate framebuffer 2!");
85
                                                   LIBBOOT_API_VERSION, "libboot ");
93
 
-
 
94
        mainchooser_init();
-
 
95
        toolchooser_init();
-
 
96
        settingchooser_init();
-
 
97
        confirmchooser_init();
86
        boot = (struct libboot_api*)libboot->api;
98
        snow_init();
-
 
99
        
87
        
100
        run_mainchooser();
88
        if (!buttons)
-
 
89
            switch (settings.fastboot_item)
101
        
90
            {
102
        free(framebuf2);
91
                case 1:
-
 
92
                    fastboot_rockbox();
103
        free(framebuf);
93
                    break;
104
        free(rbxlogo);
94
                
105
        free(icons);
95
                case 2:
-
 
96
                    fastboot_umsboot();
-
 
97
                    break;
106
        free(bg);
98
                
107
        release_library(libui);
99
                case 3:
-
 
100
                    bootinfo.valid = true;
108
        library_unload(libui);
101
                    break;
109
    }
102
            }
110
 
103
 
-
 
104
        if (!bootinfo.valid)
-
 
105
        {
-
 
106
            struct emcorelib_header* libpng = loadlib(LIBPNG_IDENTIFIER,
-
 
107
                                                      LIBPNG_API_VERSION, "libpng  ");
-
 
108
            struct libpng_api* png = (struct libpng_api*)libpng->api;
-
 
109
            bg = loadpng(png, background_png, background_png_size,
-
 
110
                         (void* (*)(struct png_info*))(png->png_decode_rgb));
-
 
111
            icons = loadpng(png, icons_png, icons_png_size,
-
 
112
                            (void* (*)(struct png_info*))(png->png_decode_rgba));
-
 
113
            rbxlogo = loadpng(png, rockbox_png, rockbox_png_size,
-
 
114
                              (void* (*)(struct png_info*))(png->png_decode_rgb));
111
    release_library(libboot);
115
            release_library(libpng);
112
    library_unload(libboot);
116
            library_unload(libpng);
-
 
117
            
-
 
118
            struct emcorelib_header* libui = loadlib(LIBUI_IDENTIFIER,
-
 
119
                                                     LIBUI_API_VERSION, "libui   ");
-
 
120
            ui = (struct libui_api*)libui->api;
-
 
121
            
-
 
122
            framebuf = malloc(320 * 240 * 3);
-
 
123
            if (!framebuf) panicf(PANIC_KILLTHREAD, "Could not allocate framebuffer!");
-
 
124
            framebuf2 = malloc(320 * 240 * 3);
-
 
125
            if (!framebuf2) panicf(PANIC_KILLTHREAD, "Could not allocate framebuffer 2!");
-
 
126
 
-
 
127
            mainchooser_init();
-
 
128
            toolchooser_init();
-
 
129
            settingchooser_init();
-
 
130
            confirmchooser_init();
-
 
131
            
-
 
132
            run_mainchooser();
-
 
133
            
-
 
134
            free(framebuf2);
-
 
135
            free(framebuf);
-
 
136
            free(rbxlogo);
-
 
137
            free(icons);
-
 
138
            free(bg);
-
 
139
            release_library(libui);
-
 
140
            library_unload(libui);
-
 
141
        }
113
 
142
 
-
 
143
        release_library(libboot);
-
 
144
        library_unload(libboot);
-
 
145
    }
-
 
146
    
114
    if (bootinfo.firmware)
147
    if (bootinfo.firmware)
115
    {
148
    {
116
        shutdown(false);
149
        shutdown(false);
117
        execfirmware((void*)0x08000000, bootinfo.firmware, bootinfo.size);
150
        execfirmware((void*)0x08000000, bootinfo.firmware, bootinfo.size);
118
    }
151
    }