freemyipod r768 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r767‎ | r768 | r769 >
Date:14:01, 31 August 2011
Author:user890104
Status:new
Tags:
Comment:
bootmenu, installer: integrate the graphics into the bootmenu, instead of installing them as separate files on the bootflash
Modified paths:
  • /apps/bootmenu-ipodclassic/Makefile (modified) (history)
  • /apps/bootmenu-ipodclassic/SOURCES (modified) (history)
  • /apps/bootmenu-ipodclassic/main.c (modified) (history)
  • /apps/bootmenu-ipodclassic/resources.S (added) (history)
  • /apps/bootmenu-ipodnano2g/Makefile (modified) (history)
  • /apps/bootmenu-ipodnano2g/SOURCES (modified) (history)
  • /apps/bootmenu-ipodnano2g/main.c (modified) (history)
  • /apps/bootmenu-ipodnano2g/resources.S (added) (history)
  • /apps/installer-ipodclassic/Makefile (modified) (history)
  • /apps/installer-ipodclassic/resources.S (modified) (history)
  • /apps/installer-ipodnano2g/Makefile (modified) (history)
  • /apps/installer-ipodnano2g/resources.S (modified) (history)

Diff [purge]

Index: apps/bootmenu-ipodclassic/SOURCES
@@ -1 +1,2 @@
22 main.c
 3+resources.S
Index: apps/bootmenu-ipodclassic/main.c
@@ -27,6 +27,13 @@
2828 #include "libui.h"
2929 #include "libmkfat32.h"
3030
 31+extern char background_png[];
 32+extern uint32_t background_png_size;
 33+extern char icons_png[];
 34+extern uint32_t icons_png_size;
 35+extern char rockbox_png[];
 36+extern uint32_t rockbox_png_size;
 37+
3138 struct libpng_api* png;
3239 struct libboot_api* boot;
3340 struct libui_api* ui;
@@ -42,19 +49,14 @@
4350 return lib;
4451 }
4552
46 -static void* loadpng(const char* filename, void* (*decoder)(struct png_info* handle))
 53+static void* loadpng(const char* buf, const uint32_t size, void* (*decoder)(struct png_info* handle))
4754 {
48 - int size = bootflash_filesize(filename);
49 - if (size == -1) panicf(PANIC_KILLTHREAD, "Could not load %s", filename);
50 - void* buf = memalign(0x10, size);
51 - if (!buf) panicf(PANIC_KILLTHREAD, "Could not allocate buffer for %s", filename);
52 - bootflash_read(filename, buf, 0, size);
 55+ if (size == 0) panicf(PANIC_KILLTHREAD, "Could not load PNG at 0x%08X", buf);
5356 struct png_info* handle = png->png_open(buf, size);
54 - if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse %s", filename);
 57+ if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse PNG at 0x%08X", buf);
5558 void* out = decoder(handle);
56 - if (!out) panicf(PANIC_KILLTHREAD, "Could not decode %s", filename);
 59+ if (!out) panicf(PANIC_KILLTHREAD, "Could not decode PNG at 0x%08X", buf);
5760 png->png_destroy(handle);
58 - free(buf);
5961 return out;
6062 }
6163
@@ -550,9 +552,9 @@
551553 {
552554 struct emcorelib_header* libpng = loadlib(LIBPNG_IDENTIFIER, LIBPNG_API_VERSION, "libpng ");
553555 png = (struct libpng_api*)libpng->api;
554 - bg = loadpng("backgrnd", (void* (*)(struct png_info*))(png->png_decode_rgb));
555 - icons = loadpng("iconset ", (void* (*)(struct png_info*))(png->png_decode_rgba));
556 - rbxlogo = loadpng("rbxlogo ", (void* (*)(struct png_info*))(png->png_decode_rgb));
 556+ bg = loadpng(background_png, background_png_size, (void* (*)(struct png_info*))(png->png_decode_rgb));
 557+ icons = loadpng(icons_png, icons_png_size, (void* (*)(struct png_info*))(png->png_decode_rgba));
 558+ rbxlogo = loadpng(rockbox_png, rockbox_png_size, (void* (*)(struct png_info*))(png->png_decode_rgb));
557559 release_library(libpng);
558560 library_unload(libpng);
559561 struct emcorelib_header* libboot = loadlib(LIBBOOT_IDENTIFIER,
Index: apps/bootmenu-ipodclassic/resources.S
@@ -0,0 +1,53 @@
 2+//
 3+//
 4+// Copyright 2011 TheSeven, user890104
 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+
 25+.global background_png
 26+.global background_png_size
 27+.global icons_png
 28+.global icons_png_size
 29+.global rockbox_png
 30+.global rockbox_png_size
 31+
 32+background_png_size:
 33+.word background_png_end - background_png
 34+
 35+icons_png_size:
 36+.word icons_png_end - icons_png
 37+
 38+rockbox_png_size:
 39+.word rockbox_png_end - rockbox_png
 40+
 41+
 42+background_png:
 43+.incbin "images/background.png"
 44+background_png_end:
 45+
 46+icons_png:
 47+.incbin "images/icons.png"
 48+icons_png_end:
 49+
 50+rockbox_png:
 51+.incbin "images/rockbox.png"
 52+rockbox_png_end:
 53+
 54+.align 2
Index: apps/bootmenu-ipodclassic/Makefile
@@ -8,6 +8,8 @@
99 LIBUIDIR ?= ../../libs/ui/
1010 LIBMKFAT32DIR ?= ../../libs/mkfat32/
1111
 12+RESOURCES = images/background.png images/icons.png images/rockbox.png
 13+
1214 ifeq ($(shell uname),WindowsNT)
1315 CCACHE :=
1416 else
@@ -52,6 +54,8 @@
5355 @$(ELF2ECA) -s $(STACKSIZE) -o $@ $^
5456 endif
5557
 58+build/resources.o: $(RESOURCES)
 59+
5660 build/$(NAME).elf: ls.x $(OBJ)
5761 @echo [LD] $@
5862 @$(LD) $(LDFLAGS) -o $@ -T ls.x $(OBJ)
Index: apps/bootmenu-ipodnano2g/SOURCES
@@ -1 +1,2 @@
22 main.c
 3+resources.S
Index: apps/bootmenu-ipodnano2g/main.c
@@ -27,6 +27,15 @@
2828 #include "libui.h"
2929 #include "libmkfat32.h"
3030
 31+extern char background_png[];
 32+extern uint32_t background_png_size;
 33+extern char icons_png[];
 34+extern uint32_t icons_png_size;
 35+extern char rockbox_png[];
 36+extern uint32_t rockbox_png_size;
 37+extern char crapple_png[];
 38+extern uint32_t crapple_png_size;
 39+
3140 struct libpng_api* png;
3241 struct libboot_api* boot;
3342 struct libui_api* ui;
@@ -44,19 +53,14 @@
4554 return lib;
4655 }
4756
48 -static void* loadpng(const char* filename, void* (*decoder)(struct png_info* handle))
 57+static void* loadpng(const char* buf, const uint32_t size, void* (*decoder)(struct png_info* handle))
4958 {
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);
 59+ if (size == 0) panicf(PANIC_KILLTHREAD, "Could not load PNG at 0x%08X", buf);
5560 struct png_info* handle = png->png_open(buf, size);
56 - if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse %s", filename);
 61+ if (!handle) panicf(PANIC_KILLTHREAD, "Could not parse PNG at 0x%08X", buf);
5762 void* out = decoder(handle);
58 - if (!out) panicf(PANIC_KILLTHREAD, "Could not decode %s", filename);
 63+ if (!out) panicf(PANIC_KILLTHREAD, "Could not decode PNG at 0x%08X", buf);
5964 png->png_destroy(handle);
60 - free(buf);
6165 return out;
6266 }
6367
@@ -679,10 +683,10 @@
680684 {
681685 struct emcorelib_header* libpng = loadlib(LIBPNG_IDENTIFIER, LIBPNG_API_VERSION, "libpng ");
682686 png = (struct libpng_api*)libpng->api;
683 - bg = loadpng("backgrnd", (void* (*)(struct png_info*))(png->png_decode_rgb));
684 - icons = loadpng("iconset ", (void* (*)(struct png_info*))(png->png_decode_rgba));
685 - rbxlogo = loadpng("rbxlogo ", (void* (*)(struct png_info*))(png->png_decode_rgb));
686 - crapple = loadpng("crapple ", (void* (*)(struct png_info*))(png->png_decode_rgba));
 687+ bg = loadpng(background_png, background_png_size, (void* (*)(struct png_info*))(png->png_decode_rgb));
 688+ icons = loadpng(icons_png, icons_png_size, (void* (*)(struct png_info*))(png->png_decode_rgba));
 689+ rbxlogo = loadpng(rockbox_png, rockbox_png_size, (void* (*)(struct png_info*))(png->png_decode_rgb));
 690+ crapple = loadpng(crapple_png, crapple_png_size, (void* (*)(struct png_info*))(png->png_decode_rgba));
687691 release_library(libpng);
688692 library_unload(libpng);
689693 struct emcorelib_header* libboot = loadlib(LIBBOOT_IDENTIFIER,
Index: apps/bootmenu-ipodnano2g/resources.S
@@ -0,0 +1,62 @@
 2+//
 3+//
 4+// Copyright 2011 TheSeven, user890104
 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+
 25+.global background_png
 26+.global background_png_size
 27+.global icons_png
 28+.global icons_png_size
 29+.global rockbox_png
 30+.global rockbox_png_size
 31+.global crapple_png
 32+.global crapple_png_size
 33+
 34+background_png_size:
 35+.word background_png_end - background_png
 36+
 37+icons_png_size:
 38+.word icons_png_end - icons_png
 39+
 40+rockbox_png_size:
 41+.word rockbox_png_end - rockbox_png
 42+
 43+crapple_png_size:
 44+.word crapple_png_end - crapple_png
 45+
 46+
 47+background_png:
 48+.incbin "images/background.png"
 49+background_png_end:
 50+
 51+icons_png:
 52+.incbin "images/icons.png"
 53+icons_png_end:
 54+
 55+rockbox_png:
 56+.incbin "images/rockbox.png"
 57+rockbox_png_end:
 58+
 59+crapple_png:
 60+.incbin "images/crapple.png"
 61+crapple_png_end:
 62+
 63+.align 2
Index: apps/bootmenu-ipodnano2g/Makefile
@@ -8,6 +8,8 @@
99 LIBUIDIR ?= ../../libs/ui/
1010 LIBMKFAT32DIR ?= ../../libs/mkfat32/
1111
 12+RESOURCES = images/background.png images/crapple.png images/icons.png images/rockbox.png
 13+
1214 ifeq ($(shell uname),WindowsNT)
1315 CCACHE :=
1416 else
@@ -52,6 +54,8 @@
5355 @$(ELF2ECA) -s $(STACKSIZE) -o $@ $^
5456 endif
5557
 58+build/resources.o: $(RESOURCES)
 59+
5660 build/$(NAME).elf: ls.x $(OBJ)
5761 @echo [LD] $@
5862 @$(LD) $(LDFLAGS) -o $@ -T ls.x $(OBJ)
Index: apps/installer-ipodclassic/resources.S
@@ -118,30 +118,6 @@
119119 .ascii "bootmenu"
120120
121121 .byte 0
122 -.byte 0
123 -.byte 0
124 -.byte 1
125 -.word f_background_png
126 -.word f_background_png_end - f_background_png
127 -.ascii "backgrnd"
128 -
129 -.byte 0
130 -.byte 0
131 -.byte 0
132 -.byte 1
133 -.word f_icons_png
134 -.word f_icons_png_end - f_icons_png
135 -.ascii "iconset "
136 -
137 -.byte 0
138 -.byte 0
139 -.byte 0
140 -.byte 1
141 -.word f_rockbox_png
142 -.word f_rockbox_png_end - f_rockbox_png
143 -.ascii "rbxlogo "
144 -
145 -.byte 0
146122 .byte 2
147123 .byte 0
148124 .byte 1
@@ -179,21 +155,6 @@
180156 actions_png_end:
181157
182158 .align 4
183 -f_background_png:
184 -.incbin "flashfiles/background.png"
185 -f_background_png_end:
186 -
187 -.align 4
188 -f_icons_png:
189 -.incbin "flashfiles/icons.png"
190 -f_icons_png_end:
191 -
192 -.align 4
193 -f_rockbox_png:
194 -.incbin "flashfiles/rockbox.png"
195 -f_rockbox_png_end:
196 -
197 -.align 4
198159 f_boot_emcorelib:
199160 .incbin "flashfiles/boot.emcorelib"
200161 f_boot_emcorelib_end:
Index: apps/installer-ipodclassic/Makefile
@@ -13,8 +13,8 @@
1414 TOOLSDIR ?= ../../tools/
1515
1616 FLASHFILES = flashfiles/boot.emcorelib flashfiles/png.emcorelib flashfiles/ui.emcorelib flashfiles/mkfat32.emcorelib \
17 - flashfiles/bootmenu-ipodclassic.emcoreapp flashfiles/background.png flashfiles/icons.png flashfiles/rockbox.png \
18 - flashfiles/emcoreldr-ipodclassic.bin flashfiles/emcore-ipodclassic.ucl flashfiles/umsboot-ipodclassic.ucl
 17+ flashfiles/bootmenu-ipodclassic.emcoreapp flashfiles/emcoreldr-ipodclassic.bin \
 18+ flashfiles/emcore-ipodclassic.ucl flashfiles/umsboot-ipodclassic.ucl
1919
2020 ifeq ($(shell uname),WindowsNT)
2121 CCACHE :=
@@ -202,18 +202,6 @@
203203 @echo [CP] $@
204204 @cp $< $@
205205
206 -flashfiles/background.png: $(BOOTMENUDIR)/images/background.png
207 - @echo [CP] $@
208 - @cp $< $@
209 -
210 -flashfiles/icons.png: $(BOOTMENUDIR)/images/icons.png
211 - @echo [CP] $@
212 - @cp $< $@
213 -
214 -flashfiles/rockbox.png: $(BOOTMENUDIR)/images/rockbox.png
215 - @echo [CP] $@
216 - @cp $< $@
217 -
218206 $(EMCOREDIR)/loader/ipodclassic/build/emcoreldr-ipodclassic.bin: emcoreldr-ipodclassic
219207 @$(MAKE) -C $(EMCOREDIR)/loader/ipodclassic
220208
Index: apps/installer-ipodnano2g/resources.S
@@ -136,38 +136,6 @@
137137 .ascii "bootmenu"
138138
139139 .byte 0
140 -.byte 0
141 -.byte 0
142 -.byte 1
143 -.word f_background_png
144 -.word f_background_png_end - f_background_png
145 -.ascii "backgrnd"
146 -
147 -.byte 0
148 -.byte 0
149 -.byte 0
150 -.byte 1
151 -.word f_icons_png
152 -.word f_icons_png_end - f_icons_png
153 -.ascii "iconset "
154 -
155 -.byte 0
156 -.byte 0
157 -.byte 0
158 -.byte 1
159 -.word f_rockbox_png
160 -.word f_rockbox_png_end - f_rockbox_png
161 -.ascii "rbxlogo "
162 -
163 -.byte 0
164 -.byte 0
165 -.byte 0
166 -.byte 1
167 -.word f_crapple_png
168 -.word f_crapple_png_end - f_crapple_png
169 -.ascii "crapple "
170 -
171 -.byte 0
172140 .byte 2
173141 .byte 0
174142 .byte 1
@@ -219,26 +187,6 @@
220188 .ascii "/.boot/appleos.bin\0"
221189
222190 .align 4
223 -f_background_png:
224 -.incbin "flashfiles/background.png"
225 -f_background_png_end:
226 -
227 -.align 4
228 -f_icons_png:
229 -.incbin "flashfiles/icons.png"
230 -f_icons_png_end:
231 -
232 -.align 4
233 -f_rockbox_png:
234 -.incbin "flashfiles/rockbox.png"
235 -f_rockbox_png_end:
236 -
237 -.align 4
238 -f_crapple_png:
239 -.incbin "flashfiles/crapple.png"
240 -f_crapple_png_end:
241 -
242 -.align 4
243191 f_boot_emcorelib:
244192 .incbin "flashfiles/boot.emcorelib"
245193 f_boot_emcorelib_end:
Index: apps/installer-ipodnano2g/Makefile
@@ -17,9 +17,8 @@
1818 TOOLSDIR ?= ../../tools/
1919
2020 FLASHFILES = flashfiles/boot.emcorelib flashfiles/png.emcorelib flashfiles/ui.emcorelib flashfiles/mkfat32.emcorelib \
21 - flashfiles/crapple.png flashfiles/uninstaller-ipodnano2g.emcoreapp flashfiles/bootmenu-ipodnano2g.emcoreapp \
22 - flashfiles/background.png flashfiles/icons.png flashfiles/rockbox.png flashfiles/emcoreldr-ipodnano2g.dfu \
23 - flashfiles/emcore-ipodnano2g.ucl flashfiles/umsboot-ipodnano2g.ucl
 21+ flashfiles/uninstaller-ipodnano2g.emcoreapp flashfiles/bootmenu-ipodnano2g.emcoreapp \
 22+ flashfiles/emcoreldr-ipodnano2g.dfu flashfiles/emcore-ipodnano2g.ucl flashfiles/umsboot-ipodnano2g.ucl
2423
2524 ifeq ($(shell uname),WindowsNT)
2625 CCACHE :=
@@ -228,22 +227,6 @@
229228 @echo [CP] $@
230229 @cp $< $@
231230
232 -flashfiles/background.png: $(BOOTMENUDIR)/images/background.png
233 - @echo [CP] $@
234 - @cp $< $@
235 -
236 -flashfiles/icons.png: $(BOOTMENUDIR)/images/icons.png
237 - @echo [CP] $@
238 - @cp $< $@
239 -
240 -flashfiles/rockbox.png: $(BOOTMENUDIR)/images/rockbox.png
241 - @echo [CP] $@
242 - @cp $< $@
243 -
244 -flashfiles/crapple.png: $(BOOTMENUDIR)/images/crapple.png
245 - @echo [CP] $@
246 - @cp $< $@
247 -
248231 $(EMCOREDIR)/loader/ipodnano2g/build/emcoreldr-ipodnano2g.dfu: emcoreldr-ipodnano2g
249232 @$(MAKE) -C $(EMCOREDIR)/loader/ipodnano2g
250233