| Index: apps/bootmenu-ipodnano2g/images/icons.psd |
| Cannot display: file marked as a binary type. |
| svn:mime-type = application/octet-stream |
| Index: apps/bootmenu-ipodnano2g/images/icons.png |
| Cannot display: file marked as a binary type. |
| svn:mime-type = application/octet-stream |
| Index: apps/bootmenu-ipodnano2g/main.c |
| — | — | @@ -1,14 +1,423 @@ |
| | 2 | +//
|
| | 3 | +//
|
| | 4 | +// Copyright 2011 TheSeven
|
| | 5 | +//
|
| | 6 | +//
|
| | 7 | +// This file is part of emCORE.
|
| | 8 | +//
|
| | 9 | +// emCORE is free software: you can redistribute it and/or
|
| | 10 | +// modify it under the terms of the GNU General Public License as
|
| | 11 | +// published by the Free Software Foundation, either version 2 of the
|
| | 12 | +// License, or (at your option) any later version.
|
| | 13 | +//
|
| | 14 | +// emCORE is distributed in the hope that it will be useful,
|
| | 15 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| | 16 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
| | 17 | +// See the GNU General Public License for more details.
|
| | 18 | +//
|
| | 19 | +// You should have received a copy of the GNU General Public License along
|
| | 20 | +// with emCORE. If not, see <http://www.gnu.org/licenses/>.
|
| | 21 | +//
|
| | 22 | +//
|
| | 23 | +
|
| | 24 | +
|
| 2 | 25 | #include "emcoreapp.h"
|
| 3 | 26 | #include "libboot.h"
|
| 4 | 27 | #include "libpng.h"
|
| 5 | 28 | #include "libui.h"
|
| | 29 | +#include "libmkfat32.h"
|
| 6 | 30 |
|
| | 31 | +struct libpng_api* png;
|
| | 32 | +struct libboot_api* boot;
|
| | 33 | +struct libui_api* ui;
|
| | 34 | +void* framebuf;
|
| | 35 | +void* framebuf2;
|
| | 36 | +void* bg;
|
| | 37 | +void* icons;
|
| | 38 | +void* rbxlogo;
|
| | 39 | +void* crapple;
|
| 7 | 40 |
|
| 8 | | -void* framebuf;
|
| 9 | | -
|
| 10 | | -
|
| 11 | | -bool mychooser_preblit(struct chooser_data* data)
|
| | 41 | +static struct emcorelib_header* loadlib(uint32_t identifier, uint32_t version, char* filename)
|
| 12 | 42 | {
|
| | 43 | + struct emcorelib_header* lib = get_library(identifier, version, LIBSOURCE_BOOTFLASH, filename);
|
| | 44 | + if (!lib) panicf(PANIC_KILLTHREAD, "Could not load %s", filename);
|
| | 45 | + return lib;
|
| | 46 | +}
|
| | 47 | +
|
| | 48 | +static void* loadpng(const char* filename, void* (*decoder)(struct png_info* handle))
|
| | 49 | +{
|
| | 50 | + int size = bootflash_filesize(filename);
|
| | 51 | + if (size == -1) panicf(PANIC_KILLTHREAD, "Could not load %s", filename);
|
| | 52 | + void* buf = memalign(0x10, size);
|
| | 53 | + if (!buf) panicf(PANIC_KILLTHREAD, "Could not allocate buffer for %s", filename);
|
| | 54 | + bootflash_read(filename, buf, 0, size);
|
| | 55 | + struct png_info* handle = png->png_open(buf, size);
|
| | 56 | + if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse %s", filename);
|
| | 57 | + void* out = decoder(handle);
|
| | 58 | + if (!out) panicf(PANIC_KILLTHREAD, "Could not decode %s", filename);
|
| | 59 | + png->png_destroy(handle);
|
| | 60 | + free(buf);
|
| | 61 | + return out;
|
| | 62 | +}
|
| | 63 | +
|
| | 64 | +static void message(int x, const char* line1, const char* line2)
|
| | 65 | +{
|
| | 66 | + rendertext(framebuf, x, 73, 176, 0xff3333ff, 0xa0000000, line1);
|
| | 67 | + rendertext(framebuf, x, 81, 176, 0xff3333ff, 0xa0000000, line2);
|
| | 68 | + displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
|
| | 69 | + sleep(5000000);
|
| | 70 | +}
|
| | 71 | +
|
| | 72 | +struct chooser_renderer_list_itemdata toolchooser_rparams_mainchooser =
|
| | 73 | +{
|
| | 74 | + .size = LIBUI_POINT(160, 10),
|
| | 75 | + .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(160, 10)),
|
| | 76 | + .fill_color = 0xa0000000,
|
| | 77 | + .fill_color_selected = 0x60ffffff,
|
| | 78 | + .icon_pos = LIBUI_POINT(0, 0),
|
| | 79 | + .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 80 | + LIBUI_POINT(0, 0)),
|
| | 81 | + .icon_opacity = 0,
|
| | 82 | + .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 83 | + LIBUI_POINT(0, 0)),
|
| | 84 | + .icon_selected_opacity = 0,
|
| | 85 | + .text = "Return to main menu",
|
| | 86 | + .text_pos = LIBUI_POINT(1, 1),
|
| | 87 | + .text_color = 0xffffffff,
|
| | 88 | + .text_color_selected = 0xff7fffff
|
| | 89 | +};
|
| | 90 | +
|
| | 91 | +struct chooser_renderer_list_itemdata toolchooser_rparams_umsboot =
|
| | 92 | +{
|
| | 93 | + .size = LIBUI_POINT(160, 10),
|
| | 94 | + .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(160, 10)),
|
| | 95 | + .fill_color = 0xa0000000,
|
| | 96 | + .fill_color_selected = 0x60ffffff,
|
| | 97 | + .icon_pos = LIBUI_POINT(0, 0),
|
| | 98 | + .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 99 | + LIBUI_POINT(0, 0)),
|
| | 100 | + .icon_opacity = 0,
|
| | 101 | + .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 102 | + LIBUI_POINT(0, 0)),
|
| | 103 | + .icon_selected_opacity = 0,
|
| | 104 | + .text = "Run UMSboot",
|
| | 105 | + .text_pos = LIBUI_POINT(1, 1),
|
| | 106 | + .text_color = 0xffffffff,
|
| | 107 | + .text_color_selected = 0xff7fffff
|
| | 108 | +};
|
| | 109 | +
|
| | 110 | +void run_umsboot(void** firmware, void** app, int* size)
|
| | 111 | +{
|
| | 112 | + boot->load_from_flash(firmware, size, false, "umsboot ", 0x10000);
|
| | 113 | + if (!*firmware)
|
| | 114 | + {
|
| | 115 | + memcpy(framebuf, bg, 176 * 132 * 3);
|
| | 116 | + message(19, "Loading UMSboot failed!", "Returning to main menu.");
|
| | 117 | + }
|
| | 118 | +}
|
| | 119 | +
|
| | 120 | +struct chooser_renderer_list_itemdata toolchooser_rparams_diagmode =
|
| | 121 | +{
|
| | 122 | + .size = LIBUI_POINT(160, 10),
|
| | 123 | + .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(160, 10)),
|
| | 124 | + .fill_color = 0xa0000000,
|
| | 125 | + .fill_color_selected = 0x60ffffff,
|
| | 126 | + .icon_pos = LIBUI_POINT(0, 0),
|
| | 127 | + .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 128 | + LIBUI_POINT(0, 0)),
|
| | 129 | + .icon_opacity = 0,
|
| | 130 | + .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 131 | + LIBUI_POINT(0, 0)),
|
| | 132 | + .icon_selected_opacity = 0,
|
| | 133 | + .text = "Run diagnostics mode",
|
| | 134 | + .text_pos = LIBUI_POINT(1, 1),
|
| | 135 | + .text_color = 0xffffffff,
|
| | 136 | + .text_color_selected = 0xff7fffff
|
| | 137 | +};
|
| | 138 | +
|
| | 139 | +void run_diagmode(void** firmware, void** app, int* size)
|
| | 140 | +{
|
| | 141 | + boot->load_from_flash(firmware, size, false, "diagmode", 0x100000);
|
| | 142 | + if (!*firmware)
|
| | 143 | + {
|
| | 144 | + memcpy(framebuf, bg, 176 * 132 * 3);
|
| | 145 | + message(16, "Loading diag mode failed!", " Returning to main menu. ");
|
| | 146 | + }
|
| | 147 | +}
|
| | 148 | +
|
| | 149 | +struct chooser_renderer_list_itemdata toolchooser_rparams_rockbox_fallback =
|
| | 150 | +{
|
| | 151 | + .size = LIBUI_POINT(160, 10),
|
| | 152 | + .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(160, 10)),
|
| | 153 | + .fill_color = 0xa0000000,
|
| | 154 | + .fill_color_selected = 0x60ffffff,
|
| | 155 | + .icon_pos = LIBUI_POINT(0, 0),
|
| | 156 | + .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 157 | + LIBUI_POINT(0, 0)),
|
| | 158 | + .icon_opacity = 0,
|
| | 159 | + .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 160 | + LIBUI_POINT(0, 0)),
|
| | 161 | + .icon_selected_opacity = 0,
|
| | 162 | + .text = "Run Rockbox fallback image",
|
| | 163 | + .text_pos = LIBUI_POINT(1, 1),
|
| | 164 | + .text_color = 0xffffffff,
|
| | 165 | + .text_color_selected = 0xff7fffff
|
| | 166 | +};
|
| | 167 | +
|
| | 168 | +void run_rockbox_fallback(void** firmware, void** app, int* size)
|
| | 169 | +{
|
| | 170 | + boot->load_from_flash(firmware, size, true, "rockbox ", 0x100000);
|
| | 171 | + if (!*firmware)
|
| | 172 | + {
|
| | 173 | + memcpy(framebuf, bg, 176 * 132 * 3);
|
| | 174 | + message(19, "Loading Rockbox failed!", "Returning to main menu.");
|
| | 175 | + }
|
| | 176 | +}
|
| | 177 | +
|
| | 178 | +struct chooser_renderer_list_itemdata toolchooser_rparams_clearcfg =
|
| | 179 | +{
|
| | 180 | + .size = LIBUI_POINT(160, 10),
|
| | 181 | + .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(160, 10)),
|
| | 182 | + .fill_color = 0xa0000000,
|
| | 183 | + .fill_color_selected = 0x60ffffff,
|
| | 184 | + .icon_pos = LIBUI_POINT(0, 0),
|
| | 185 | + .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 186 | + LIBUI_POINT(0, 0)),
|
| | 187 | + .icon_opacity = 0,
|
| | 188 | + .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 189 | + LIBUI_POINT(0, 0)),
|
| | 190 | + .icon_selected_opacity = 0,
|
| | 191 | + .text = "Clear Rockbox configuration",
|
| | 192 | + .text_pos = LIBUI_POINT(1, 1),
|
| | 193 | + .text_color = 0xffffffff,
|
| | 194 | + .text_color_selected = 0xff7fffff
|
| | 195 | +};
|
| | 196 | +
|
| | 197 | +void run_clearcfg(void** firmware, void** app, int* size)
|
| | 198 | +{
|
| | 199 | + remove("/.rockbox/config.cfg");
|
| | 200 | + memcpy(framebuf, bg, 176 * 132 * 3);
|
| | 201 | + message(25, "Rockbox configuration", " has been cleared. ");
|
| | 202 | +}
|
| | 203 | +
|
| | 204 | +struct chooser_renderer_list_itemdata toolchooser_rparams_cleardb =
|
| | 205 | +{
|
| | 206 | + .size = LIBUI_POINT(160, 10),
|
| | 207 | + .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(160, 10)),
|
| | 208 | + .fill_color = 0xa0000000,
|
| | 209 | + .fill_color_selected = 0x60ffffff,
|
| | 210 | + .icon_pos = LIBUI_POINT(0, 0),
|
| | 211 | + .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 212 | + LIBUI_POINT(0, 0)),
|
| | 213 | + .icon_opacity = 0,
|
| | 214 | + .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 215 | + LIBUI_POINT(0, 0)),
|
| | 216 | + .icon_selected_opacity = 0,
|
| | 217 | + .text = "Clear Rockbox database",
|
| | 218 | + .text_pos = LIBUI_POINT(1, 1),
|
| | 219 | + .text_color = 0xffffffff,
|
| | 220 | + .text_color_selected = 0xff7fffff
|
| | 221 | +};
|
| | 222 | +
|
| | 223 | +void run_cleardb(void** firmware, void** app, int* size)
|
| | 224 | +{
|
| | 225 | + remove("/.rockbox/database_0.tcd");
|
| | 226 | + remove("/.rockbox/database_1.tcd");
|
| | 227 | + remove("/.rockbox/database_2.tcd");
|
| | 228 | + remove("/.rockbox/database_3.tcd");
|
| | 229 | + remove("/.rockbox/database_4.tcd");
|
| | 230 | + remove("/.rockbox/database_5.tcd");
|
| | 231 | + remove("/.rockbox/database_6.tcd");
|
| | 232 | + remove("/.rockbox/database_7.tcd");
|
| | 233 | + remove("/.rockbox/database_8.tcd");
|
| | 234 | + remove("/.rockbox/database_9.tcd");
|
| | 235 | + remove("/.rockbox/database_idx.tcd");
|
| | 236 | + remove("/.rockbox/database_tmp.tcd");
|
| | 237 | + remove("/.rockbox/database_state.tcd");
|
| | 238 | + remove("/.rockbox/database_changelog.txt");
|
| | 239 | + memcpy(framebuf, bg, 176 * 132 * 3);
|
| | 240 | + message(37, "Rockbox database", "has been cleared.");
|
| | 241 | +}
|
| | 242 | +
|
| | 243 | +struct chooser_renderer_list_itemdata toolchooser_rparams_reformat =
|
| | 244 | +{
|
| | 245 | + .size = LIBUI_POINT(160, 10),
|
| | 246 | + .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(160, 10)),
|
| | 247 | + .fill_color = 0xa0000000,
|
| | 248 | + .fill_color_selected = 0x60ffffff,
|
| | 249 | + .icon_pos = LIBUI_POINT(0, 0),
|
| | 250 | + .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 251 | + LIBUI_POINT(0, 0)),
|
| | 252 | + .icon_opacity = 0,
|
| | 253 | + .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 254 | + LIBUI_POINT(0, 0)),
|
| | 255 | + .icon_selected_opacity = 0,
|
| | 256 | + .text = "Reformat data partition",
|
| | 257 | + .text_pos = LIBUI_POINT(1, 1),
|
| | 258 | + .text_color = 0xffffffff,
|
| | 259 | + .text_color_selected = 0xff7fffff
|
| | 260 | +};
|
| | 261 | +
|
| | 262 | +void fat32_progressbar_init(void* user, int max)
|
| | 263 | +{
|
| | 264 | + progressbar_init((struct progressbar_state*)user,
|
| | 265 | + 10, 165, 74, 83, 0x77ff, 0xe8, 0x125f, 0, max);
|
| | 266 | +}
|
| | 267 | +
|
| | 268 | +void fat32_progressbar_update(void* user, int current)
|
| | 269 | +{
|
| | 270 | + progressbar_setpos((struct progressbar_state*)user, current, false);
|
| | 271 | +}
|
| | 272 | +
|
| | 273 | +void run_reformat(void** firmware, void** app, int* size)
|
| | 274 | +{
|
| | 275 | + memcpy(framebuf, bg, 176 * 132 * 3);
|
| | 276 | + rendertext(framebuf, 7, 65, 176, 0xff7fffff, 0, "Reformatting data partition");
|
| | 277 | + displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
|
| | 278 | + struct emcorelib_header* libmkfat32 = loadlib(LIBMKFAT32_IDENTIFIER,
|
| | 279 | + LIBMKFAT32_API_VERSION, "libmkf32");
|
| | 280 | + struct libmkfat32_api* mf32 = (struct libmkfat32_api*)libmkfat32->api;
|
| | 281 | + struct storage_info storageinfo;
|
| | 282 | + storage_get_info(0, &storageinfo);
|
| | 283 | + struct progressbar_state progressbar;
|
| | 284 | + int rc = mf32->mkfat32(0, 0, storageinfo.num_sectors, 2048, 1, "iPod Nano2G",
|
| | 285 | + &progressbar, fat32_progressbar_init, fat32_progressbar_update);
|
| | 286 | + if (rc < 0) panicf(PANIC_KILLTHREAD, "Error formatting data partition: %08X", rc);
|
| | 287 | + release_library(libmkfat32);
|
| | 288 | + library_unload(libmkfat32);
|
| | 289 | + memcpy(framebuf, bg, 176 * 132 * 3);
|
| | 290 | + message(34, "Data partition has", "been reformatted.");
|
| | 291 | +}
|
| | 292 | +
|
| | 293 | +struct chooser_renderer_list_itemdata toolchooser_rparams_uninstaller =
|
| | 294 | +{
|
| | 295 | + .size = LIBUI_POINT(160, 10),
|
| | 296 | + .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(160, 10)),
|
| | 297 | + .fill_color = 0xa0000000,
|
| | 298 | + .fill_color_selected = 0x60ffffff,
|
| | 299 | + .icon_pos = LIBUI_POINT(0, 0),
|
| | 300 | + .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 301 | + LIBUI_POINT(0, 0)),
|
| | 302 | + .icon_opacity = 0,
|
| | 303 | + .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 304 | + LIBUI_POINT(0, 0)),
|
| | 305 | + .icon_selected_opacity = 0,
|
| | 306 | + .text = "Uninstall emCORE",
|
| | 307 | + .text_pos = LIBUI_POINT(1, 1),
|
| | 308 | + .text_color = 0xffffffff,
|
| | 309 | + .text_color_selected = 0xff7fffff
|
| | 310 | +};
|
| | 311 | +
|
| | 312 | +void run_uninstaller(void** firmware, void** app, int* size)
|
| | 313 | +{
|
| | 314 | + boot->load_from_flash(app, size, false, "uninst ", 0);
|
| | 315 | + if (!*app)
|
| | 316 | + {
|
| | 317 | + memcpy(framebuf, bg, 176 * 132 * 3);
|
| | 318 | + message(7, "Loading uninstaller failed!", " Returning to main menu. ");
|
| | 319 | + }
|
| | 320 | +}
|
| | 321 | +
|
| | 322 | +struct chooser_renderer_list_params toolchooser_rparams =
|
| | 323 | +{
|
| | 324 | + .version = CHOOSER_RENDERER_LIST_PARAMS_VERSION,
|
| | 325 | + .copy_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 0)),
|
| | 326 | + .copy_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 0)),
|
| | 327 | + LIBUI_POINT(176, 132)),
|
| | 328 | + .bg_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 329 | + .bg_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 330 | + LIBUI_POINT(0, 0)),
|
| | 331 | + .bg_opacity = 0,
|
| | 332 | + .fill_dest = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
|
| | 333 | + LIBUI_POINT(0, 0)),
|
| | 334 | + .fill_color = 0,
|
| | 335 | + .viewport = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(7, 30)),
|
| | 336 | + LIBUI_POINT(162, 80)),
|
| | 337 | + .blit_dest = LIBUI_POINT(0, 0),
|
| | 338 | + .blit_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 0)),
|
| | 339 | + LIBUI_POINT(176, 132)),
|
| | 340 | + .preblit = NULL,
|
| | 341 | + .postblit = NULL
|
| | 342 | +};
|
| | 343 | +
|
| | 344 | +struct chooser_action_handler_wheel_params toolchooser_aparams =
|
| | 345 | +{
|
| | 346 | + .version = CHOOSER_ACTION_HANDLER_WHEEL_PARAMS_VERSION,
|
| | 347 | + .stepsperitem = 128,
|
| | 348 | + .eventfilter = NULL,
|
| | 349 | + .timeout_initial = TIMEOUT_BLOCK,
|
| | 350 | + .timeout_idle = TIMEOUT_BLOCK,
|
| | 351 | + .timeout_item = 0,
|
| | 352 | + .tick_force_redraw = false,
|
| | 353 | + .buttoncount = 5,
|
| | 354 | + .buttonmap =
|
| | 355 | + {
|
| | 356 | + CHOOSER_ACTION_HANDLER_WHEEL_ACTION_SELECT,
|
| | 357 | + CHOOSER_ACTION_HANDLER_WHEEL_ACTION_NEXT,
|
| | 358 | + CHOOSER_ACTION_HANDLER_WHEEL_ACTION_PREV,
|
| | 359 | + CHOOSER_ACTION_HANDLER_WHEEL_ACTION_NEXT,
|
| | 360 | + CHOOSER_ACTION_HANDLER_WHEEL_ACTION_PREV
|
| | 361 | + }
|
| | 362 | +};
|
| | 363 | +
|
| | 364 | +struct chooser_info toolchooser =
|
| | 365 | +{
|
| | 366 | + .version = CHOOSER_INFO_VERSION,
|
| | 367 | + .actionhandler = NULL,
|
| | 368 | + .actionhandlerparams = &toolchooser_aparams,
|
| | 369 | + .renderer = NULL,
|
| | 370 | + .rendererparams = &toolchooser_rparams,
|
| | 371 | + .userparams = NULL,
|
| | 372 | + .tickinterval = 10000000,
|
| | 373 | + .itemcount = 8,
|
| | 374 | + .defaultitem = 0,
|
| | 375 | + .items =
|
| | 376 | + {
|
| | 377 | + {
|
| | 378 | + .user = NULL,
|
| | 379 | + .actionparams = NULL,
|
| | 380 | + .renderparams = &toolchooser_rparams_mainchooser
|
| | 381 | + },
|
| | 382 | + {
|
| | 383 | + .user = run_umsboot,
|
| | 384 | + .actionparams = NULL,
|
| | 385 | + .renderparams = &toolchooser_rparams_umsboot
|
| | 386 | + },
|
| | 387 | + {
|
| | 388 | + .user = run_diagmode,
|
| | 389 | + .actionparams = NULL,
|
| | 390 | + .renderparams = &toolchooser_rparams_diagmode
|
| | 391 | + },
|
| | 392 | + {
|
| | 393 | + .user = run_rockbox_fallback,
|
| | 394 | + .actionparams = NULL,
|
| | 395 | + .renderparams = &toolchooser_rparams_rockbox_fallback
|
| | 396 | + },
|
| | 397 | + {
|
| | 398 | + .user = run_clearcfg,
|
| | 399 | + .actionparams = NULL,
|
| | 400 | + .renderparams = &toolchooser_rparams_clearcfg
|
| | 401 | + },
|
| | 402 | + {
|
| | 403 | + .user = run_cleardb,
|
| | 404 | + .actionparams = NULL,
|
| | 405 | + .renderparams = &toolchooser_rparams_cleardb
|
| | 406 | + },
|
| | 407 | + {
|
| | 408 | + .user = run_reformat,
|
| | 409 | + .actionparams = NULL,
|
| | 410 | + .renderparams = &toolchooser_rparams_reformat
|
| | 411 | + },
|
| | 412 | + {
|
| | 413 | + .user = run_uninstaller,
|
| | 414 | + .actionparams = NULL,
|
| | 415 | + .renderparams = &toolchooser_rparams_uninstaller
|
| | 416 | + }
|
| | 417 | + }
|
| | 418 | +};
|
| | 419 | +
|
| | 420 | +bool mainchooser_preblit(struct chooser_data* data)
|
| | 421 | +{
|
| 13 | 422 | char buf[4];
|
| 14 | 423 | struct chooser_action_handler_wheel_data* adata;
|
| 15 | 424 | adata = (struct chooser_action_handler_wheel_data*)(data->actionhandlerdata);
|
| — | — | @@ -17,29 +426,53 @@ |
| 18 | 427 | return false;
|
| 19 | 428 | }
|
| 20 | 429 |
|
| 21 | | -
|
| 22 | | -struct chooser_renderer_iconflow_itemdata mychooser_rparams_0 =
|
| | 430 | +struct chooser_renderer_iconflow_itemdata mainchooser_rparams_powerdown =
|
| 23 | 431 | {
|
| 24 | 432 | .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 31)),
|
| 25 | | - LIBUI_POINT(44, 40)),
|
| | 433 | + LIBUI_POINT(44, 44)),
|
| 26 | 434 | .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 31)),
|
| 27 | | - LIBUI_POINT(44, 40)),
|
| | 435 | + LIBUI_POINT(44, 44)),
|
| 28 | 436 | .text = "Power off",
|
| 29 | 437 | .text_color = 0xffffcccc,
|
| 30 | 438 | };
|
| 31 | 439 |
|
| 32 | | -struct chooser_renderer_iconflow_itemdata mychooser_rparams_1 =
|
| | 440 | +void run_powerdown(void** firmware, void** app, int* size)
|
| 33 | 441 | {
|
| 34 | | - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 177)),
|
| | 442 | + shutdown(true);
|
| | 443 | + power_off();
|
| | 444 | +}
|
| | 445 | +
|
| | 446 | +struct chooser_renderer_iconflow_itemdata mainchooser_rparams_crapple =
|
| | 447 | +{
|
| | 448 | + .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 123)),
|
| 35 | 449 | LIBUI_POINT(44, 43)),
|
| 36 | | - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 177)),
|
| | 450 | + .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 123)),
|
| 37 | 451 | LIBUI_POINT(44, 43)),
|
| 38 | 452 | .text = "Original firmware",
|
| 39 | 453 | .text_color = 0xffffcccc,
|
| 40 | 454 | };
|
| 41 | 455 |
|
| 42 | | -struct chooser_renderer_iconflow_itemdata mychooser_rparams_2 =
|
| | 456 | +void run_crapple(void** firmware, void** app, int* size)
|
| 43 | 457 | {
|
| | 458 | + int i;
|
| | 459 | + for (i = 23; i <= 115; i += 23)
|
| | 460 | + {
|
| | 461 | + if (i < 115)
|
| | 462 | + ui->blend(176, 132, 50, framebuf, 0, 0, 176,
|
| | 463 | + framebuf, 0, 0, 176, bg, 0, 0, 176);
|
| | 464 | + else memcpy(framebuf, bg, 176 * 132 * 3);
|
| | 465 | + memcpy(framebuf2, framebuf, 176 * 132 * 3);
|
| | 466 | + ui->blenda(111, i, 255, framebuf2, 32, 0, 176,
|
| | 467 | + framebuf2, 32, 0, 176, crapple, 0, 115 - i, 111);
|
| | 468 | + displaylcd(0, 0, 176, 132, framebuf2, 0, 0, 176);
|
| | 469 | + }
|
| | 470 | + boot->load_from_file(firmware, size, false, "/.boot/appleos.ucl", 0x800000);
|
| | 471 | + if (!*firmware) boot->load_from_file(firmware, size, false, "/.boot/appleos.bin", 0);
|
| | 472 | + if (!*firmware) message(7, "Loading appleos.bin failed!", " Returning to main menu. ");
|
| | 473 | +}
|
| | 474 | +
|
| | 475 | +struct chooser_renderer_iconflow_itemdata mainchooser_rparams_rockbox =
|
| | 476 | +{
|
| 44 | 477 | .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 0)),
|
| 45 | 478 | LIBUI_POINT(44, 14)),
|
| 46 | 479 | .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 0)),
|
| — | — | @@ -48,8 +481,34 @@ |
| 49 | 482 | .text_color = 0xffffcccc,
|
| 50 | 483 | };
|
| 51 | 484 |
|
| 52 | | -struct chooser_renderer_iconflow_itemdata mychooser_rparams_3 =
|
| | 485 | +void run_rockbox(void** firmware, void** app, int* size)
|
| 53 | 486 | {
|
| | 487 | + int i;
|
| | 488 | + for (i = 2; i <= 52; i += 10)
|
| | 489 | + {
|
| | 490 | + if (i < 52)
|
| | 491 | + ui->blend(176, 132, 50, framebuf, 0, 0, 176,
|
| | 492 | + framebuf, 0, 0, 176, bg, 0, 0, 176);
|
| | 493 | + else memcpy(framebuf, bg, 176 * 132 * 3);
|
| | 494 | + ui->blit(154, MIN(47, i), 3, framebuf, 11, MAX(0, i - 47), 176,
|
| | 495 | + rbxlogo, 0, MAX(0, 47 - i), 154);
|
| | 496 | + displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
|
| | 497 | + }
|
| | 498 | + boot->load_from_file(firmware, size, true, "/.rockbox/rockbox.ipod", 0);
|
| | 499 | + if (!*firmware)
|
| | 500 | + {
|
| | 501 | + message(4, "Loading rockbox.ipod failed!", " Trying fallback image... ");
|
| | 502 | + boot->load_from_flash(firmware, size, true, "rockbox ", 0x100000);
|
| | 503 | + }
|
| | 504 | + if (!*firmware)
|
| | 505 | + {
|
| | 506 | + memcpy(framebuf, bg, 176 * 132 * 3);
|
| | 507 | + message(19, "Loading Rockbox failed!", "Returning to main menu.");
|
| | 508 | + }
|
| | 509 | +}
|
| | 510 | +
|
| | 511 | +struct chooser_renderer_iconflow_itemdata mainchooser_rparams_console =
|
| | 512 | +{
|
| 54 | 513 | .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 14)),
|
| 55 | 514 | LIBUI_POINT(44, 17)),
|
| 56 | 515 | .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 14)),
|
| — | — | @@ -58,39 +517,48 @@ |
| 59 | 518 | .text_color = 0xffffcccc,
|
| 60 | 519 | };
|
| 61 | 520 |
|
| 62 | | -struct chooser_renderer_iconflow_itemdata mychooser_rparams_4 =
|
| | 521 | +struct chooser_renderer_iconflow_itemdata mainchooser_rparams_diskmode =
|
| 63 | 522 | {
|
| 64 | | - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 71)),
|
| | 523 | + .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 166)),
|
| 65 | 524 | LIBUI_POINT(44, 31)),
|
| 66 | | - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 71)),
|
| | 525 | + .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 166)),
|
| 67 | 526 | LIBUI_POINT(44, 31)),
|
| 68 | | - .text = "UMSboot",
|
| | 527 | + .text = "Disk mode",
|
| 69 | 528 | .text_color = 0xffffcccc,
|
| 70 | 529 | };
|
| 71 | 530 |
|
| 72 | | -struct chooser_renderer_iconflow_itemdata mychooser_rparams_5 =
|
| | 531 | +void run_diskmode(void** firmware, void** app, int* size)
|
| 73 | 532 | {
|
| 74 | | - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 133)),
|
| 75 | | - LIBUI_POINT(44, 44)),
|
| 76 | | - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 133)),
|
| 77 | | - LIBUI_POINT(44, 44)),
|
| 78 | | - .text = "Diagnostics mode",
|
| 79 | | - .text_color = 0xffffcccc,
|
| 80 | | -};
|
| | 533 | + boot->load_from_flash(firmware, size, false, "diskmode", 0x100000);
|
| | 534 | + if (!*firmware)
|
| | 535 | + {
|
| | 536 | + memcpy(framebuf, bg, 176 * 132 * 3);
|
| | 537 | + message(13, "Loading disk mode failed!", " Returning to main menu. ");
|
| | 538 | + }
|
| | 539 | +}
|
| 81 | 540 |
|
| 82 | | -struct chooser_renderer_iconflow_itemdata mychooser_rparams_6 =
|
| | 541 | +struct chooser_renderer_iconflow_itemdata mainchooser_rparams_toolchooser =
|
| 83 | 542 | {
|
| 84 | | - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 102)),
|
| 85 | | - LIBUI_POINT(44, 31)),
|
| 86 | | - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 102)),
|
| 87 | | - LIBUI_POINT(44, 31)),
|
| 88 | | - .text = "Disk mode",
|
| | 543 | + .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 75)),
|
| | 544 | + LIBUI_POINT(44, 48)),
|
| | 545 | + .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 44), LIBUI_POINT(0, 75)),
|
| | 546 | + LIBUI_POINT(44, 48)),
|
| | 547 | + .text = "Tools",
|
| 89 | 548 | .text_color = 0xffffcccc,
|
| 90 | 549 | };
|
| 91 | 550 |
|
| 92 | | -struct chooser_renderer_iconflow_params mychooser_rparams =
|
| | 551 | +static void run_toolchooser(void** firmware, void** app, int* size)
|
| 93 | 552 | {
|
| 94 | | - .version = CHOOSER_RENDERER_LIST_PARAMS_VERSION,
|
| | 553 | + const struct chooser_item* result = ui->chooser_run(&toolchooser);
|
| | 554 | + if (!result->user) return;
|
| | 555 | + void (*selected_function)(void** firmware, void** app, int* size);
|
| | 556 | + selected_function = (void(*)(void** firmware, void** app, int* size))(result->user);
|
| | 557 | + selected_function(firmware, app, size);
|
| | 558 | +}
|
| | 559 | +
|
| | 560 | +struct chooser_renderer_iconflow_params mainchooser_rparams =
|
| | 561 | +{
|
| | 562 | + .version = CHOOSER_RENDERER_ICONFLOW_PARAMS_VERSION,
|
| 95 | 563 | .copy_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 0)),
|
| 96 | 564 | .copy_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 0)),
|
| 97 | 565 | LIBUI_POINT(176, 132)),
|
| — | — | @@ -110,11 +578,11 @@ |
| 111 | 579 | .smoothness = 500000,
|
| 112 | 580 | .startposition = -3,
|
| 113 | 581 | .iconsinview = 4,
|
| 114 | | - .preblit = mychooser_preblit,
|
| | 582 | + .preblit = mainchooser_preblit,
|
| 115 | 583 | .postblit = NULL
|
| 116 | 584 | };
|
| 117 | 585 |
|
| 118 | | -struct chooser_action_handler_wheel_params mychooser_aparams =
|
| | 586 | +struct chooser_action_handler_wheel_params mainchooser_aparams =
|
| 119 | 587 | {
|
| 120 | 588 | .version = CHOOSER_ACTION_HANDLER_WHEEL_PARAMS_VERSION,
|
| 121 | 589 | .stepsperitem = 512,
|
| — | — | @@ -132,394 +600,115 @@ |
| 133 | 601 | }
|
| 134 | 602 | };
|
| 135 | 603 |
|
| 136 | | -struct chooser_info mychooser =
|
| | 604 | +struct chooser_info mainchooser =
|
| 137 | 605 | {
|
| 138 | 606 | .version = CHOOSER_INFO_VERSION,
|
| 139 | 607 | .actionhandler = NULL,
|
| 140 | | - .actionhandlerparams = &mychooser_aparams,
|
| | 608 | + .actionhandlerparams = &mainchooser_aparams,
|
| 141 | 609 | .renderer = NULL,
|
| 142 | | - .rendererparams = &mychooser_rparams,
|
| | 610 | + .rendererparams = &mainchooser_rparams,
|
| 143 | 611 | .userparams = NULL,
|
| 144 | 612 | .tickinterval = 990000,
|
| 145 | | - .itemcount = 7,
|
| | 613 | + .itemcount = 6,
|
| 146 | 614 | .defaultitem = 2,
|
| 147 | 615 | .items =
|
| 148 | 616 | {
|
| 149 | 617 | {
|
| 150 | | - .user = (void*)0,
|
| | 618 | + .user = run_powerdown,
|
| 151 | 619 | .actionparams = NULL,
|
| 152 | | - .renderparams = &mychooser_rparams_0
|
| | 620 | + .renderparams = &mainchooser_rparams_powerdown
|
| 153 | 621 | },
|
| 154 | 622 | {
|
| 155 | | - .user = (void*)1,
|
| | 623 | + .user = run_crapple,
|
| 156 | 624 | .actionparams = NULL,
|
| 157 | | - .renderparams = &mychooser_rparams_1
|
| | 625 | + .renderparams = &mainchooser_rparams_crapple
|
| 158 | 626 | },
|
| 159 | 627 | {
|
| 160 | | - .user = (void*)2,
|
| | 628 | + .user = run_rockbox,
|
| 161 | 629 | .actionparams = NULL,
|
| 162 | | - .renderparams = &mychooser_rparams_2
|
| | 630 | + .renderparams = &mainchooser_rparams_rockbox
|
| 163 | 631 | },
|
| 164 | 632 | {
|
| 165 | | - .user = (void*)3,
|
| | 633 | + .user = NULL,
|
| 166 | 634 | .actionparams = NULL,
|
| 167 | | - .renderparams = &mychooser_rparams_3
|
| | 635 | + .renderparams = &mainchooser_rparams_console
|
| 168 | 636 | },
|
| 169 | 637 | {
|
| 170 | | - .user = (void*)4,
|
| | 638 | + .user = run_diskmode,
|
| 171 | 639 | .actionparams = NULL,
|
| 172 | | - .renderparams = &mychooser_rparams_4
|
| | 640 | + .renderparams = &mainchooser_rparams_diskmode
|
| 173 | 641 | },
|
| 174 | 642 | {
|
| 175 | | - .user = (void*)5,
|
| | 643 | + .user = run_toolchooser,
|
| 176 | 644 | .actionparams = NULL,
|
| 177 | | - .renderparams = &mychooser_rparams_5
|
| 178 | | - },
|
| 179 | | - {
|
| 180 | | - .user = (void*)6,
|
| 181 | | - .actionparams = NULL,
|
| 182 | | - .renderparams = &mychooser_rparams_6
|
| | 645 | + .renderparams = &mainchooser_rparams_toolchooser
|
| 183 | 646 | }
|
| 184 | 647 | }
|
| 185 | 648 | };
|
| 186 | 649 |
|
| | 650 | +static void run_mainchooser(void** firmware, void** app, int* size)
|
| | 651 | +{
|
| | 652 | + while (!*firmware && !*app)
|
| | 653 | + {
|
| | 654 | + const struct chooser_item* result = ui->chooser_run(&mainchooser);
|
| | 655 | + if (!result->user) return;
|
| | 656 | + void (*selected_function)(void** firmware, void** app, int* size);
|
| | 657 | + selected_function = (void(*)(void** firmware, void** app, int* size))(result->user);
|
| | 658 | + selected_function(firmware, app, size);
|
| | 659 | + }
|
| | 660 | +}
|
| 187 | 661 |
|
| 188 | 662 | static void main()
|
| 189 | 663 | {
|
| 190 | | - struct emcorelib_header* libboot = get_library(LIBBOOT_IDENTIFIER, LIBBOOT_API_VERSION, LIBSOURCE_BOOTFLASH, "libboot ");
|
| 191 | | - if (!libboot) panicf(PANIC_KILLTHREAD, "Could not load booting library!");
|
| 192 | | - struct libboot_api* boot = (struct libboot_api*)libboot->api;
|
| 193 | | - struct emcorelib_header* libpng = get_library(LIBPNG_IDENTIFIER, LIBPNG_API_VERSION, LIBSOURCE_BOOTFLASH, "libpng ");
|
| 194 | | - if (!libpng) panicf(PANIC_KILLTHREAD, "Could not load PNG decoder library!");
|
| 195 | | - struct libpng_api* png = (struct libpng_api*)libpng->api;
|
| 196 | | - struct emcorelib_header* libui = get_library(LIBUI_IDENTIFIER, LIBUI_API_VERSION, LIBSOURCE_BOOTFLASH, "libui ");
|
| 197 | | - if (!libui) panicf(PANIC_KILLTHREAD, "Could not load user interface library!");
|
| 198 | | - struct libui_api* ui = (struct libui_api*)libui->api;
|
| 199 | | - int size = bootflash_filesize("backgrnd");
|
| 200 | | - if (size == -1) panicf(PANIC_KILLTHREAD, "Could not find background image!");
|
| 201 | | - void* buf = memalign(0x10, size);
|
| 202 | | - if (!buf) panicf(PANIC_KILLTHREAD, "Could not allocate buffer for background image!");
|
| 203 | | - bootflash_read("backgrnd", buf, 0, size);
|
| 204 | | - struct png_info* handle = png->png_open(buf, size);
|
| 205 | | - if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse background image!");
|
| 206 | | - struct png_rgb* bg = png->png_decode_rgb(handle);
|
| 207 | | - if (!bg) panicf(PANIC_KILLTHREAD, "Could not decode background image!");
|
| 208 | | - png->png_destroy(handle);
|
| 209 | | - free(buf);
|
| 210 | | - size = bootflash_filesize("iconset ");
|
| 211 | | - if (size == -1) panicf(PANIC_KILLTHREAD, "Could not find icon set!");
|
| 212 | | - buf = memalign(0x10, size);
|
| 213 | | - if (!buf) panicf(PANIC_KILLTHREAD, "Could not allocate buffer for icon set!");
|
| 214 | | - bootflash_read("iconset ", buf, 0, size);
|
| 215 | | - handle = png->png_open(buf, size);
|
| 216 | | - if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse icon set!");
|
| 217 | | - struct png_rgba* icons = png->png_decode_rgba(handle);
|
| 218 | | - if (!icons) panicf(PANIC_KILLTHREAD, "Could not decode icon set!");
|
| 219 | | - png->png_destroy(handle);
|
| 220 | | - free(buf);
|
| 221 | | - size = bootflash_filesize("rbxlogo ");
|
| 222 | | - if (size == -1) panicf(PANIC_KILLTHREAD, "Could not find Rockbox logo!");
|
| 223 | | - buf = memalign(0x10, size);
|
| 224 | | - if (!buf) panicf(PANIC_KILLTHREAD, "Could not allocate buffer for Rockbox logo!");
|
| 225 | | - bootflash_read("rbxlogo ", buf, 0, size);
|
| 226 | | - handle = png->png_open(buf, size);
|
| 227 | | - if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse Rockbox logo!");
|
| 228 | | - struct png_rgb* rbxlogo = png->png_decode_rgb(handle);
|
| 229 | | - if (!rbxlogo) panicf(PANIC_KILLTHREAD, "Could not decode Rockbox logo!");
|
| 230 | | - png->png_destroy(handle);
|
| 231 | | - free(buf);
|
| 232 | | - size = bootflash_filesize("crapple ");
|
| 233 | | - if (size == -1) panicf(PANIC_KILLTHREAD, "Could not find OF logo!");
|
| 234 | | - buf = memalign(0x10, size);
|
| 235 | | - if (!buf) panicf(PANIC_KILLTHREAD, "Could not allocate buffer for OF logo!");
|
| 236 | | - bootflash_read("crapple ", buf, 0, size);
|
| 237 | | - handle = png->png_open(buf, size);
|
| 238 | | - if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse OF logo!");
|
| 239 | | - struct png_rgba* crapple = png->png_decode_rgba(handle);
|
| 240 | | - if (!rbxlogo) panicf(PANIC_KILLTHREAD, "Could not decode OF logo!");
|
| 241 | | - png->png_destroy(handle);
|
| 242 | | - free(buf);
|
| | 664 | + struct emcorelib_header* libpng = loadlib(LIBPNG_IDENTIFIER, LIBPNG_API_VERSION, "libpng ");
|
| | 665 | + png = (struct libpng_api*)libpng->api;
|
| | 666 | + bg = loadpng("backgrnd", (void* (*)(struct png_info*))(png->png_decode_rgb));
|
| | 667 | + icons = loadpng("iconset ", (void* (*)(struct png_info*))(png->png_decode_rgba));
|
| | 668 | + rbxlogo = loadpng("rbxlogo ", (void* (*)(struct png_info*))(png->png_decode_rgb));
|
| | 669 | + crapple = loadpng("crapple ", (void* (*)(struct png_info*))(png->png_decode_rgba));
|
| | 670 | + release_library(libpng);
|
| | 671 | + library_unload(libpng);
|
| | 672 | + struct emcorelib_header* libboot = loadlib(LIBBOOT_IDENTIFIER,
|
| | 673 | + LIBBOOT_API_VERSION, "libboot ");
|
| | 674 | + boot = (struct libboot_api*)libboot->api;
|
| | 675 | + struct emcorelib_header* libui = loadlib(LIBUI_IDENTIFIER, LIBUI_API_VERSION, "libui ");
|
| | 676 | + ui = (struct libui_api*)libui->api;
|
| 243 | 677 | framebuf = malloc(176 * 132 * 3);
|
| 244 | 678 | if (!framebuf) panicf(PANIC_KILLTHREAD, "Could not allocate framebuffer!");
|
| 245 | | - void* framebuf2 = malloc(176 * 132 * 3);
|
| | 679 | + framebuf2 = malloc(176 * 132 * 3);
|
| 246 | 680 | if (!framebuf2) panicf(PANIC_KILLTHREAD, "Could not allocate framebuffer 2!");
|
| 247 | | - mychooser.actionhandler = ui->chooser_action_handler_wheel;
|
| 248 | | - mychooser.renderer = ui->chooser_renderer_iconflow;
|
| 249 | | - mychooser_rparams.copy_dest.buf.addr = framebuf;
|
| 250 | | - mychooser_rparams.copy_src.loc.buf.addr = bg;
|
| 251 | | - mychooser_rparams.viewport.loc.buf.addr = framebuf;
|
| 252 | | - mychooser_rparams.blit_src.loc.buf.addr = framebuf;
|
| 253 | | - mychooser_rparams_0.icon.loc.buf.addr = icons;
|
| 254 | | - mychooser_rparams_0.icon_selected.loc.buf.addr = icons;
|
| 255 | | - mychooser_rparams_1.icon.loc.buf.addr = icons;
|
| 256 | | - mychooser_rparams_1.icon_selected.loc.buf.addr = icons;
|
| 257 | | - mychooser_rparams_2.icon.loc.buf.addr = icons;
|
| 258 | | - mychooser_rparams_2.icon_selected.loc.buf.addr = icons;
|
| 259 | | - mychooser_rparams_3.icon.loc.buf.addr = icons;
|
| 260 | | - mychooser_rparams_3.icon_selected.loc.buf.addr = icons;
|
| 261 | | - mychooser_rparams_4.icon.loc.buf.addr = icons;
|
| 262 | | - mychooser_rparams_4.icon_selected.loc.buf.addr = icons;
|
| 263 | | - mychooser_rparams_5.icon.loc.buf.addr = icons;
|
| 264 | | - mychooser_rparams_5.icon_selected.loc.buf.addr = icons;
|
| 265 | | - mychooser_rparams_6.icon.loc.buf.addr = icons;
|
| 266 | | - mychooser_rparams_6.icon_selected.loc.buf.addr = icons;
|
| | 681 | + mainchooser.actionhandler = ui->chooser_action_handler_wheel;
|
| | 682 | + mainchooser.renderer = ui->chooser_renderer_iconflow;
|
| | 683 | + mainchooser_rparams.copy_dest.buf.addr = framebuf;
|
| | 684 | + mainchooser_rparams.copy_src.loc.buf.addr = bg;
|
| | 685 | + mainchooser_rparams.viewport.loc.buf.addr = framebuf;
|
| | 686 | + mainchooser_rparams.blit_src.loc.buf.addr = framebuf;
|
| | 687 | + mainchooser_rparams_powerdown.icon.loc.buf.addr = icons;
|
| | 688 | + mainchooser_rparams_powerdown.icon_selected.loc.buf.addr = icons;
|
| | 689 | + mainchooser_rparams_crapple.icon.loc.buf.addr = icons;
|
| | 690 | + mainchooser_rparams_crapple.icon_selected.loc.buf.addr = icons;
|
| | 691 | + mainchooser_rparams_rockbox.icon.loc.buf.addr = icons;
|
| | 692 | + mainchooser_rparams_rockbox.icon_selected.loc.buf.addr = icons;
|
| | 693 | + mainchooser_rparams_console.icon.loc.buf.addr = icons;
|
| | 694 | + mainchooser_rparams_console.icon_selected.loc.buf.addr = icons;
|
| | 695 | + mainchooser_rparams_diskmode.icon.loc.buf.addr = icons;
|
| | 696 | + mainchooser_rparams_diskmode.icon_selected.loc.buf.addr = icons;
|
| | 697 | + mainchooser_rparams_toolchooser.icon.loc.buf.addr = icons;
|
| | 698 | + mainchooser_rparams_toolchooser.icon_selected.loc.buf.addr = icons;
|
| | 699 | +
|
| | 700 | + toolchooser.actionhandler = ui->chooser_action_handler_wheel;
|
| | 701 | + toolchooser.renderer = ui->chooser_renderer_list;
|
| | 702 | + toolchooser_rparams.copy_dest.buf.addr = framebuf;
|
| | 703 | + toolchooser_rparams.copy_src.loc.buf.addr = bg;
|
| | 704 | + toolchooser_rparams.viewport.loc.buf.addr = framebuf;
|
| | 705 | + toolchooser_rparams.blit_src.loc.buf.addr = framebuf;
|
| | 706 | +
|
| 267 | 707 | backlight_set_brightness(177);
|
| 268 | 708 | void* firmware = NULL;
|
| 269 | | - while (!firmware)
|
| 270 | | - {
|
| 271 | | - const struct chooser_item* result = ui->chooser_run(&mychooser);
|
| 272 | | - switch ((int)(result->user))
|
| 273 | | - {
|
| 274 | | - case 0:
|
| 275 | | - shutdown(true);
|
| 276 | | - power_off();
|
| 277 | | - break;
|
| 278 | | - case 1:
|
| 279 | | - {
|
| 280 | | - int i;
|
| 281 | | - for (i = 23; i <= 115; i += 23)
|
| 282 | | - {
|
| 283 | | - if (i < 115)
|
| 284 | | - ui->blend(176, 132, 50, framebuf, 0, 0, 176,
|
| 285 | | - framebuf, 0, 0, 176, bg, 0, 0, 176);
|
| 286 | | - else memcpy(framebuf, bg, 176 * 132 * 3);
|
| 287 | | - memcpy(framebuf2, framebuf, 176 * 132 * 3);
|
| 288 | | - ui->blenda(111, i, 255, framebuf2, 32, 0, 176,
|
| 289 | | - framebuf2, 32, 0, 176, crapple, 0, 115 - i, 111);
|
| 290 | | - displaylcd(0, 0, 176, 132, framebuf2, 0, 0, 176);
|
| 291 | | - }
|
| 292 | | - int fd = file_open("/.boot/appleos.bin", O_RDONLY);
|
| 293 | | - if (fd > 0)
|
| 294 | | - {
|
| 295 | | - size = filesize(fd);
|
| 296 | | - if (size > 0)
|
| 297 | | - {
|
| 298 | | - void* buf = memalign(0x10, size);
|
| 299 | | - if (buf)
|
| 300 | | - {
|
| 301 | | - if (read(fd, buf, size) == size) firmware = buf;
|
| 302 | | - else free(buf);
|
| 303 | | - }
|
| 304 | | - }
|
| 305 | | - close(fd);
|
| 306 | | - }
|
| 307 | | - if (!firmware)
|
| 308 | | - {
|
| 309 | | - rendertext(framebuf2, 7, 73, 176, 0xff3333ff, 0xa0000000, "Loading appleos.bin failed!");
|
| 310 | | - rendertext(framebuf2, 7, 81, 176, 0xff3333ff, 0xa0000000, " Returning to main menu. ");
|
| 311 | | - displaylcd(0, 0, 176, 132, framebuf2, 0, 0, 176);
|
| 312 | | - sleep(5000000);
|
| 313 | | - }
|
| 314 | | - break;
|
| 315 | | - }
|
| 316 | | - case 2:
|
| 317 | | - {
|
| 318 | | - int i;
|
| 319 | | - for (i = 2; i <= 52; i += 10)
|
| 320 | | - {
|
| 321 | | - if (i < 52)
|
| 322 | | - ui->blend(176, 132, 50, framebuf, 0, 0, 176,
|
| 323 | | - framebuf, 0, 0, 176, bg, 0, 0, 176);
|
| 324 | | - else memcpy(framebuf, bg, 176 * 132 * 3);
|
| 325 | | - ui->blit(154, MIN(47, i), 3, framebuf, 11, MAX(0, i - 47), 176,
|
| 326 | | - rbxlogo, 0, MAX(0, 47 - i), 154);
|
| 327 | | - displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
|
| 328 | | - }
|
| 329 | | - int fd = file_open("/.rockbox/rockbox.ipod", O_RDONLY);
|
| 330 | | - if (fd > 0)
|
| 331 | | - {
|
| 332 | | - size = filesize(fd);
|
| 333 | | - if (size > 0)
|
| 334 | | - {
|
| 335 | | - void* buf = memalign(0x10, size);
|
| 336 | | - if (buf)
|
| 337 | | - {
|
| 338 | | - if (read(fd, buf, size) == size)
|
| 339 | | - if (!boot->verify_rockbox_checksum(buf, size))
|
| 340 | | - firmware = buf;
|
| 341 | | - if (!firmware) free(buf);
|
| 342 | | - }
|
| 343 | | - }
|
| 344 | | - close(fd);
|
| 345 | | - }
|
| 346 | | - if (!firmware)
|
| 347 | | - {
|
| 348 | | - rendertext(framebuf, 4, 73, 176, 0xff3333ff, 0xa0000000, "Loading rockbox.ipod failed!");
|
| 349 | | - rendertext(framebuf, 4, 81, 176, 0xff3333ff, 0xa0000000, " Trying fallback image... ");
|
| 350 | | - displaylcd(0, 0, 176, 132, framebuf, 0, 0, 132);
|
| 351 | | - sleep(5000000);
|
| 352 | | - size = bootflash_filesize("rockbox ");
|
| 353 | | - if (size > 0)
|
| 354 | | - {
|
| 355 | | - void* buf = memalign(0x10, size);
|
| 356 | | - if (buf)
|
| 357 | | - {
|
| 358 | | - bootflash_read("rockbox ", buf, 0, size);
|
| 359 | | - if (bootflash_attributes("rockbox ") & 0x800)
|
| 360 | | - {
|
| 361 | | - void* buf2 = malloc(0x100000);
|
| 362 | | - if (buf2)
|
| 363 | | - {
|
| 364 | | - if (!ucl_decompress(buf, size, buf2, (uint32_t*)&size))
|
| 365 | | - {
|
| 366 | | - free(buf);
|
| 367 | | - buf = realloc(buf2, size);
|
| 368 | | - if (!buf) buf = buf2;
|
| 369 | | - if (!boot->verify_rockbox_checksum(buf, size))
|
| 370 | | - firmware = buf;
|
| 371 | | - else free(buf);
|
| 372 | | - }
|
| 373 | | - else
|
| 374 | | - {
|
| 375 | | - free(buf2);
|
| 376 | | - free(buf);
|
| 377 | | - }
|
| 378 | | - }
|
| 379 | | - else free(buf);
|
| 380 | | - }
|
| 381 | | - else
|
| 382 | | - {
|
| 383 | | - if (!boot->verify_rockbox_checksum(buf, size)) firmware = buf;
|
| 384 | | - else free(buf);
|
| 385 | | - }
|
| 386 | | - }
|
| 387 | | - }
|
| 388 | | - }
|
| 389 | | - if (!firmware)
|
| 390 | | - {
|
| 391 | | - memcpy(framebuf, bg, 176 * 132 * 3);
|
| 392 | | - rendertext(framebuf, 19, 73, 176, 0xff3333ff, 0xa0000000, "Loading Rockbox failed!");
|
| 393 | | - rendertext(framebuf, 19, 81, 176, 0xff3333ff, 0xa0000000, "Returning to main menu.");
|
| 394 | | - displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
|
| 395 | | - sleep(5000000);
|
| 396 | | - }
|
| 397 | | - break;
|
| 398 | | - }
|
| 399 | | - case 3:
|
| 400 | | - goto leave;
|
| 401 | | - case 4:
|
| 402 | | - size = bootflash_filesize("umsboot ");
|
| 403 | | - if (size > 0)
|
| 404 | | - {
|
| 405 | | - void* buf = memalign(0x10, size);
|
| 406 | | - if (buf)
|
| 407 | | - {
|
| 408 | | - bootflash_read("umsboot ", buf, 0, size);
|
| 409 | | - if (bootflash_attributes("umsboot ") & 0x800)
|
| 410 | | - {
|
| 411 | | - void* buf2 = malloc(0x10000);
|
| 412 | | - if (buf2)
|
| 413 | | - {
|
| 414 | | - if (!ucl_decompress(buf, size, buf2, (uint32_t*)&size))
|
| 415 | | - {
|
| 416 | | - free(buf);
|
| 417 | | - buf = realloc(buf2, size);
|
| 418 | | - if (!buf) buf = buf2;
|
| 419 | | - firmware = buf;
|
| 420 | | - }
|
| 421 | | - else
|
| 422 | | - {
|
| 423 | | - free(buf2);
|
| 424 | | - free(buf);
|
| 425 | | - }
|
| 426 | | - }
|
| 427 | | - else free(buf);
|
| 428 | | - }
|
| 429 | | - else firmware = buf;
|
| 430 | | - }
|
| 431 | | - }
|
| 432 | | - if (!firmware)
|
| 433 | | - {
|
| 434 | | - memcpy(framebuf, bg, 176 * 132 * 3);
|
| 435 | | - rendertext(framebuf, 19, 73, 176, 0xff3333ff, 0xa0000000, "Loading UMSboot failed!");
|
| 436 | | - rendertext(framebuf, 19, 81, 176, 0xff3333ff, 0xa0000000, "Returning to main menu.");
|
| 437 | | - displaylcd(0, 0, 176, 132, framebuf, 0, 0, 132);
|
| 438 | | - sleep(5000000);
|
| 439 | | - }
|
| 440 | | - break;
|
| 441 | | - case 5:
|
| 442 | | - size = bootflash_filesize("diagmode");
|
| 443 | | - if (size > 0)
|
| 444 | | - {
|
| 445 | | - void* buf = memalign(0x10, size);
|
| 446 | | - if (buf)
|
| 447 | | - {
|
| 448 | | - bootflash_read("diagmode", buf, 0, size);
|
| 449 | | - if (bootflash_attributes("diagmode") & 0x800)
|
| 450 | | - {
|
| 451 | | - void* buf2 = malloc(0x80000);
|
| 452 | | - if (buf2)
|
| 453 | | - {
|
| 454 | | - if (!ucl_decompress(buf, size, buf2, (uint32_t*)&size))
|
| 455 | | - {
|
| 456 | | - free(buf);
|
| 457 | | - buf = realloc(buf2, size);
|
| 458 | | - if (!buf) buf = buf2;
|
| 459 | | - firmware = buf;
|
| 460 | | - }
|
| 461 | | - else
|
| 462 | | - {
|
| 463 | | - free(buf2);
|
| 464 | | - free(buf);
|
| 465 | | - }
|
| 466 | | - }
|
| 467 | | - else free(buf);
|
| 468 | | - }
|
| 469 | | - else firmware = buf;
|
| 470 | | - }
|
| 471 | | - }
|
| 472 | | - if (!firmware)
|
| 473 | | - {
|
| 474 | | - memcpy(framebuf, bg, 176 * 132 * 3);
|
| 475 | | - rendertext(framebuf, 13, 73, 176, 0xff3333ff, 0xa0000000, "Loading diag mode failed!");
|
| 476 | | - rendertext(framebuf, 13, 81, 176, 0xff3333ff, 0xa0000000, " Returning to main menu. ");
|
| 477 | | - displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
|
| 478 | | - sleep(5000000);
|
| 479 | | - }
|
| 480 | | - break;
|
| 481 | | - case 6:
|
| 482 | | - size = bootflash_filesize("diskmode");
|
| 483 | | - if (size > 0)
|
| 484 | | - {
|
| 485 | | - void* buf = memalign(0x10, size);
|
| 486 | | - if (buf)
|
| 487 | | - {
|
| 488 | | - bootflash_read("diskmode", buf, 0, size);
|
| 489 | | - if (bootflash_attributes("diskmode") & 0x800)
|
| 490 | | - {
|
| 491 | | - void* buf2 = malloc(0x80000);
|
| 492 | | - if (buf2)
|
| 493 | | - {
|
| 494 | | - if (!ucl_decompress(buf, size, buf2, (uint32_t*)&size))
|
| 495 | | - {
|
| 496 | | - free(buf);
|
| 497 | | - buf = realloc(buf2, size);
|
| 498 | | - if (!buf) buf = buf2;
|
| 499 | | - firmware = buf;
|
| 500 | | - }
|
| 501 | | - else
|
| 502 | | - {
|
| 503 | | - free(buf2);
|
| 504 | | - free(buf);
|
| 505 | | - }
|
| 506 | | - }
|
| 507 | | - else free(buf);
|
| 508 | | - }
|
| 509 | | - else firmware = buf;
|
| 510 | | - }
|
| 511 | | - }
|
| 512 | | - if (!firmware)
|
| 513 | | - {
|
| 514 | | - memcpy(framebuf, bg, 176 * 132 * 3);
|
| 515 | | - rendertext(framebuf, 13, 73, 176, 0xff3333ff, 0xa0000000, "Loading disk mode failed!");
|
| 516 | | - rendertext(framebuf, 13, 81, 176, 0xff3333ff, 0xa0000000, " Returning to main menu. ");
|
| 517 | | - displaylcd(0, 0, 176, 132, framebuf, 0, 0, 176);
|
| 518 | | - sleep(5000000);
|
| 519 | | - }
|
| 520 | | - break;
|
| 521 | | - }
|
| 522 | | - }
|
| 523 | | -leave:
|
| | 709 | + void* app = NULL;
|
| | 710 | + int size;
|
| | 711 | + run_mainchooser(&firmware, &app, &size);
|
| | 712 | +
|
| 524 | 713 | free(framebuf2);
|
| 525 | 714 | free(framebuf);
|
| 526 | 715 | free(crapple);
|
| — | — | @@ -527,16 +716,16 @@ |
| 528 | 717 | free(icons);
|
| 529 | 718 | free(bg);
|
| 530 | 719 | release_library(libui);
|
| 531 | | - release_library(libpng);
|
| 532 | 720 | release_library(libboot);
|
| 533 | 721 | library_unload(libui);
|
| 534 | | - library_unload(libpng);
|
| 535 | 722 | library_unload(libboot);
|
| | 723 | +
|
| 536 | 724 | if (firmware)
|
| 537 | 725 | {
|
| 538 | 726 | shutdown(false);
|
| 539 | 727 | execfirmware((void*)0x08000000, firmware, size);
|
| 540 | 728 | }
|
| | 729 | + else if (app) execimage(app, false);
|
| 541 | 730 | else cputs(3, "Dropped into emCORE console.\n");
|
| 542 | 731 | }
|
| 543 | 732 |
|
| Index: apps/bootmenu-ipodnano2g/Makefile |
| — | — | @@ -6,6 +6,7 @@ |
| 7 | 7 | LIBBOOTDIR ?= ../../libs/boot/
|
| 8 | 8 | LIBPNGDIR ?= ../../libs/png/
|
| 9 | 9 | LIBUIDIR ?= ../../libs/ui/
|
| | 10 | +LIBMKFAT32DIR ?= ../../libs/mkfat32/
|
| 10 | 11 |
|
| 11 | 12 | ifeq ($(shell uname),WindowsNT)
|
| 12 | 13 | CCACHE :=
|
| — | — | @@ -20,13 +21,13 @@ |
| 21 | 22 | OBJCOPY := $(CROSS)objcopy
|
| 22 | 23 | ELF2ECA := $(CROSS)elf2emcoreapp
|
| 23 | 24 |
|
| 24 | | -LIBINCLUDES := -I$(LIBBOOTDIR)/export -I$(LIBPNGDIR)/export -I$(LIBUIDIR)/export
|
| | 25 | +LIBINCLUDES := -I$(LIBBOOTDIR)/export -I$(LIBPNGDIR)/export -I$(LIBUIDIR)/export -I$(LIBMKFAT32DIR)/export
|
| 25 | 26 |
|
| 26 | 27 | CFLAGS += -Os -fno-pie -fno-stack-protector -fomit-frame-pointer -I. -I$(EMCOREDIR)/export $(LIBINCLUDES) -ffunction-sections -fdata-sections -mcpu=arm940t -DARM_ARCH=4
|
| 27 | 28 | LDFLAGS += "$(shell $(CC) -print-libgcc-file-name)" --emit-relocs --gc-sections
|
| 28 | 29 |
|
| 29 | 30 | preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#")
|
| 30 | | -preprocesspaths = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:")
|
| | 31 | +preprocesspaths = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:" | sed -e "s:^\\./::")
|
| 31 | 32 |
|
| 32 | 33 | REVISION := $(shell svnversion .)
|
| 33 | 34 | REVISIONINT := $(shell echo $(REVISION) | sed -e "s/[^0-9].*$$//")
|