summaryrefslogtreecommitdiff
path: root/apps/plugins/rockboy.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/rockboy.c')
-rw-r--r--apps/plugins/rockboy.c71
1 files changed, 4 insertions, 67 deletions
diff --git a/apps/plugins/rockboy.c b/apps/plugins/rockboy.c
index f571894717..9ff176cd25 100644
--- a/apps/plugins/rockboy.c
+++ b/apps/plugins/rockboy.c
@@ -9,7 +9,7 @@
9 * 9 *
10 * Copyright (C) 2005 Jens Arnold 10 * Copyright (C) 2005 Jens Arnold
11 * 11 *
12 * Overlay loader for rockboy on Archos 12 * Overlay loader stub plugin for rockboy on Archos
13 * 13 *
14 * All files in this archive are subject to the GNU General Public License. 14 * All files in this archive are subject to the GNU General Public License.
15 * See the file COPYING in the source tree root for full license agreement. 15 * See the file COPYING in the source tree root for full license agreement.
@@ -22,76 +22,13 @@
22 22
23#if MEM <= 8 && !defined(SIMULATOR) 23#if MEM <= 8 && !defined(SIMULATOR)
24 24
25PLUGIN_HEADER 25#include "overlay.h"
26
27#define OVL_NAME "/.rockbox/viewers/rockboy.ovl"
28#define OVL_DISPLAYNAME "RockBoy"
29 26
30struct plugin_api* rb; 27PLUGIN_HEADER
31unsigned char *audiobuf;
32int audiobuf_size;
33 28
34/* this is the plugin entry point */ 29/* this is the plugin entry point */
35enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 30enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
36{ 31{
37 int fd, readsize; 32 return run_overlay(api, parameter, "/.rockbox/viewers/rockboy.ovl", "RockBoy");
38 struct plugin_header header;
39
40 rb = api;
41
42 fd = rb->open(OVL_NAME, O_RDONLY);
43 if (fd < 0)
44 {
45 rb->splash(2*HZ, true, "Can't open " OVL_NAME);
46 return PLUGIN_ERROR;
47 }
48 readsize = rb->read(fd, &header, sizeof(header));
49 rb->close(fd);
50 /* Close for now. Less code than doing it in all error checks.
51 * Would need to seek back anyway. */
52
53 if (readsize != sizeof(header))
54 {
55 rb->splash(2*HZ, true, "Reading" OVL_DISPLAYNAME " overlay failed.");
56 return PLUGIN_ERROR;
57 }
58 if (header.magic != PLUGIN_MAGIC || header.target_id != TARGET_ID)
59 {
60 rb->splash(2*HZ, true, OVL_DISPLAYNAME
61 " overlay: Incompatible model.");
62 return PLUGIN_ERROR;
63 }
64 if (header.api_version != PLUGIN_API_VERSION)
65 {
66 rb->splash(2*HZ, true, OVL_DISPLAYNAME
67 " overlay: Incompatible version.");
68 return PLUGIN_ERROR;
69 }
70
71 audiobuf = rb->plugin_get_audio_buffer(&audiobuf_size);
72 if (header.load_addr < audiobuf ||
73 header.end_addr > audiobuf + audiobuf_size)
74 {
75 rb->splash(2*HZ, true, OVL_DISPLAYNAME
76 " overlay doesn't fit into memory.");
77 return PLUGIN_ERROR;
78 }
79 rb->memset(header.load_addr, 0, header.end_addr - header.load_addr);
80
81 fd = rb->open(OVL_NAME, O_RDONLY);
82 if (fd < 0)
83 {
84 rb->splash(2*HZ, true, "Can't open " OVL_NAME);
85 return PLUGIN_ERROR;
86 }
87 readsize = rb->read(fd, header.load_addr, header.end_addr - header.load_addr);
88 rb->close(fd);
89
90 if (readsize < 0)
91 {
92 rb->splash(2*HZ, true, "Reading" OVL_DISPLAYNAME " overlay failed.");
93 return PLUGIN_ERROR;
94 }
95 return header.entry_point(api, parameter);
96} 33}
97#endif 34#endif