summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugin.c15
-rw-r--r--uisimulator/win32/Makefile12
-rw-r--r--uisimulator/win32/plugin-win32.c154
-rw-r--r--uisimulator/win32/plugin-win32.h37
4 files changed, 56 insertions, 162 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index 020bf61b1a..7f91415755 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -32,9 +32,14 @@
32#include "lang.h" 32#include "lang.h"
33 33
34#ifdef SIMULATOR 34#ifdef SIMULATOR
35#include <dlfcn.h> 35 #include <debug.h>
36#include <debug.h> 36 #ifdef WIN32
37#define PREFIX(_x_) x11_ ## _x_ 37 #include "plugin-win32.h"
38 #define PREFIX(_x_) _x_
39 #else
40 #include <dlfcn.h>
41 #define PREFIX(_x_) x11_ ## _x_
42 #endif
38#else 43#else
39#define PREFIX(_x_) _x_ 44#define PREFIX(_x_) _x_
40#endif 45#endif
@@ -141,7 +146,11 @@ int plugin_load(char* plugin, void* parameter)
141 lcd_update(); 146 lcd_update();
142#endif 147#endif
143#ifdef SIMULATOR 148#ifdef SIMULATOR
149#ifdef WIN32
150 snprintf(path, sizeof path, "%s", plugin);
151#else
144 snprintf(path, sizeof path, "archos%s", plugin); 152 snprintf(path, sizeof path, "archos%s", plugin);
153#endif
145 pd = dlopen(path, RTLD_NOW); 154 pd = dlopen(path, RTLD_NOW);
146 if (!pd) { 155 if (!pd) {
147 snprintf(buf, sizeof buf, "Can't open %s", plugin); 156 snprintf(buf, sizeof buf, "Can't open %s", plugin);
diff --git a/uisimulator/win32/Makefile b/uisimulator/win32/Makefile
index a0fd6e8a56..d66fa6b2c4 100644
--- a/uisimulator/win32/Makefile
+++ b/uisimulator/win32/Makefile
@@ -98,7 +98,7 @@ FIRMSRCS = $(LCDSRSC) id3.c mp3data.c usb.c mpeg.c powermgmt.c power.c \
98APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \ 98APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \
99 playlist.c wps.c wps-display.c settings.c status.c \ 99 playlist.c wps.c wps-display.c settings.c status.c \
100 screens.c peakmeter.c sleeptimer.c keyboard.c onplay.c\ 100 screens.c peakmeter.c sleeptimer.c keyboard.c onplay.c\
101 misc.c 101 misc.c plugin.c
102 102
103MENUS = games_menu.c demo_menu.c settings_menu.c sound_menu.c 103MENUS = games_menu.c demo_menu.c settings_menu.c sound_menu.c
104 104
@@ -108,12 +108,11 @@ endif
108 108
109SRCS = button.c dir-win32.c lcd-win32.c panic-win32.c thread-win32.c \ 109SRCS = button.c dir-win32.c lcd-win32.c panic-win32.c thread-win32.c \
110 debug-win32.c kernel.c string-win32.c uisw32.c stubs.c \ 110 debug-win32.c kernel.c string-win32.c uisw32.c stubs.c \
111 $(APPS) $(MENUS) $(FIRMSRCS) strtok.c sim_icons.c io.c plugin-win32.c 111 $(APPS) $(MENUS) $(FIRMSRCS) strtok.c sim_icons.c io.c
112 112
113OBJS := $(OBJDIR)/lang.o $(SRCS:%.c=$(OBJDIR)/%.o) $(OBJDIR)/uisw32-res.o 113OBJS := $(OBJDIR)/lang.o $(SRCS:%.c=$(OBJDIR)/%.o) $(OBJDIR)/uisw32-res.o
114 114
115ROCKSRCS = bounce.c cube.c flipit.c helloworld.c sliding_puzzle.c snow.c \ 115ROCKSRCS := $(patsubst $(PLUGINDIR)/%.c,%.c,$(wildcard $(PLUGINDIR)/*.c))
116 sokoban.c star.c tetris.c viewer.c wormlet.c
117 116
118ROCKS := $(ROCKSRCS:%.c=$(OBJDIR)/%.rock) 117ROCKS := $(ROCKSRCS:%.c=$(OBJDIR)/%.rock)
119 118
@@ -197,6 +196,9 @@ $(OBJDIR)/onplay.o: $(APPDIR)/onplay.c
197$(OBJDIR)/playlist.o: $(APPDIR)/playlist.c 196$(OBJDIR)/playlist.o: $(APPDIR)/playlist.c
198 $(CC) $(APPCFLAGS) -c $< -o $@ 197 $(CC) $(APPCFLAGS) -c $< -o $@
199 198
199$(OBJDIR)/plugin.o: $(APPDIR)/plugin.c plugin-win32.h
200 $(CC) $(APPCFLAGS) -c $< -o $@
201
200$(OBJDIR)/build.lang: $(APPDIR)/lang/$(LANGUAGE).lang 202$(OBJDIR)/build.lang: $(APPDIR)/lang/$(LANGUAGE).lang
201 perl $(TOOLSDIR)/uplang $(APPDIR)/lang/english.lang $< > $@ 203 perl $(TOOLSDIR)/uplang $(APPDIR)/lang/english.lang $< > $@
202 204
@@ -292,7 +294,7 @@ $(OBJDIR)/%.po : $(PLUGINDIR)/%.c
292 $(CC) $(CFLAGS) -c $< -o $@ 294 $(CC) $(CFLAGS) -c $< -o $@
293 295
294$(OBJDIR)/%.rock : $(OBJDIR)/%.po 296$(OBJDIR)/%.rock : $(OBJDIR)/%.po
295 $(DLL) $(DLLFLAGS) $< -o $@ 297 -$(DLL) $(DLLFLAGS) $< -o $@
296 298
297DEPS:=$(OBJDIR)/.deps 299DEPS:=$(OBJDIR)/.deps
298 300
diff --git a/uisimulator/win32/plugin-win32.c b/uisimulator/win32/plugin-win32.c
deleted file mode 100644
index 0809da0e2e..0000000000
--- a/uisimulator/win32/plugin-win32.c
+++ /dev/null
@@ -1,154 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Björn Stenberg
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include <stdbool.h>
21#include <string.h>
22#include <stdio.h>
23#include "button.h"
24#include "lcd.h"
25#include "dir.h"
26#include "file.h"
27#include "kernel.h"
28#include "sprintf.h"
29#include "screens.h"
30#include "misc.h"
31#include "mas.h"
32#include "plugin.h"
33
34#include <windows.h>
35
36static int plugin_test(int api_version, int model);
37
38static struct plugin_api rockbox_api = {
39 PLUGIN_API_VERSION,
40
41 plugin_test,
42
43 /* lcd */
44 lcd_clear_display,
45 lcd_puts,
46 lcd_puts_scroll,
47 lcd_stop_scroll,
48#ifdef HAVE_LCD_CHARCELLS
49 lcd_define_pattern,
50#else
51 lcd_putsxy,
52 lcd_bitmap,
53 lcd_drawline,
54 lcd_clearline,
55 lcd_drawpixel,
56 lcd_clearpixel,
57 lcd_setfont,
58 lcd_clearrect,
59 lcd_fillrect,
60 lcd_drawrect,
61 lcd_invertrect,
62 lcd_getstringsize,
63 lcd_update,
64 lcd_update_rect,
65#endif
66
67 /* button */
68 button_get,
69 button_get_w_tmo,
70
71 /* file */
72 open,
73 close,
74 read,
75 lseek,
76 creat,
77 write,
78 remove,
79 rename,
80 NULL, /* ftruncate */
81 win32_filesize,
82 fprintf,
83 read_line,
84
85 /* dir */
86 opendir,
87 closedir,
88 readdir,
89
90 /* kernel */
91 sleep,
92 usb_screen,
93 &current_tick,
94
95 /* strings and memory */
96 snprintf,
97 strcpy,
98 strlen,
99 memset,
100 memcpy,
101
102 /* misc */
103 srand,
104 rand,
105 splash,
106 qsort,
107};
108
109typedef enum plugin_status (*plugin_fn)(struct plugin_api* api, void* param);
110
111int plugin_load(char* plugin, void* parameter)
112{
113 plugin_fn plugin_start;
114 int rc;
115 char buf[64];
116 void* pd;
117
118 lcd_clear_display();
119#ifdef HAVE_LCD_BITMAP
120 lcd_setmargins(0,0);
121 lcd_update();
122#endif
123
124 pd = LoadLibrary(plugin);
125 if (!pd) {
126 snprintf(buf, sizeof buf, "Can't open %s", plugin);
127 splash(HZ*2, 0, true, buf);
128 return -1;
129 }
130
131 plugin_start = (plugin_fn)GetProcAddress(pd, "plugin_start");
132 if (!plugin_start) {
133 splash(HZ*2, 0, true, "Can't find entry point");
134 FreeLibrary(pd);
135 return -1;
136 }
137
138 rc = plugin_start(&rockbox_api, parameter);
139
140 FreeLibrary(pd);
141
142 return rc;
143}
144
145int plugin_test(int api_version, int model)
146{
147 if (api_version != PLUGIN_API_VERSION)
148 return PLUGIN_WRONG_API_VERSION;
149
150 if (model != MODEL)
151 return PLUGIN_WRONG_MODEL;
152
153 return PLUGIN_OK;
154}
diff --git a/uisimulator/win32/plugin-win32.h b/uisimulator/win32/plugin-win32.h
new file mode 100644
index 0000000000..9e17d425ec
--- /dev/null
+++ b/uisimulator/win32/plugin-win32.h
@@ -0,0 +1,37 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Björn Stenberg
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include <windows.h>
21#include "plugin.h"
22#include "file.h"
23
24#define RTLD_NOW 0
25
26#undef filesize
27#define filesize win32_filesize
28
29#undef ftruncate
30#define ftruncate NULL
31
32typedef enum plugin_status (*plugin_fn)(struct plugin_api* api, void* param);
33
34#define dlopen(_x_, _y_) LoadLibrary(_x_)
35#define dlsym(_x_, _y_) (plugin_fn)GetProcAddress(_x_, _y_)
36#define dlclose(_x_) FreeLibrary(_x_)
37#define dlerror() "Unknown"