Subversion Repositories freemyipod

Rev

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

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