summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHardeep Sidhu <dyp@pobox.com>2003-06-29 23:38:03 +0000
committerHardeep Sidhu <dyp@pobox.com>2003-06-29 23:38:03 +0000
commitdd5d3f652f99096ced7313d3f2179aa36501f1f5 (patch)
tree5b8abf7c7995023132499beedc9ae7e9af088d74
parentba5dfbd71ef9ea1a1c786d02e10311decc9ced64 (diff)
downloadrockbox-dd5d3f652f99096ced7313d3f2179aa36501f1f5.zip
rockbox-dd5d3f652f99096ced7313d3f2179aa36501f1f5.tar.gz
rockbox-dd5d3f652f99096ced7313d3f2179aa36501f1f5.tar.bz2
rockbox-dd5d3f652f99096ced7313d3f2179aa36501f1f5.tar.xz
Changed win32 simulator to use plugin.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3784 a1c6a512-1295-4272-9138-f99709370657
-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 020bf61..7f91415 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -32,9 +32,14 @@
#include "lang.h"
#ifdef SIMULATOR
-#include <dlfcn.h>
-#include <debug.h>
-#define PREFIX(_x_) x11_ ## _x_
+ #include <debug.h>
+ #ifdef WIN32
+ #include "plugin-win32.h"
+ #define PREFIX(_x_) _x_
+ #else
+ #include <dlfcn.h>
+ #define PREFIX(_x_) x11_ ## _x_
+ #endif
#else
#define PREFIX(_x_) _x_
#endif
@@ -141,7 +146,11 @@ int plugin_load(char* plugin, void* parameter)
lcd_update();
#endif
#ifdef SIMULATOR
+#ifdef WIN32
+ snprintf(path, sizeof path, "%s", plugin);
+#else
snprintf(path, sizeof path, "archos%s", plugin);
+#endif
pd = dlopen(path, RTLD_NOW);
if (!pd) {
snprintf(buf, sizeof buf, "Can't open %s", plugin);
diff --git a/uisimulator/win32/Makefile b/uisimulator/win32/Makefile
index a0fd6e8..d66fa6b 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 \
APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \
playlist.c wps.c wps-display.c settings.c status.c \
screens.c peakmeter.c sleeptimer.c keyboard.c onplay.c\
- misc.c
+ misc.c plugin.c
MENUS = games_menu.c demo_menu.c settings_menu.c sound_menu.c
@@ -108,12 +108,11 @@ endif
SRCS = button.c dir-win32.c lcd-win32.c panic-win32.c thread-win32.c \
debug-win32.c kernel.c string-win32.c uisw32.c stubs.c \
- $(APPS) $(MENUS) $(FIRMSRCS) strtok.c sim_icons.c io.c plugin-win32.c
+ $(APPS) $(MENUS) $(FIRMSRCS) strtok.c sim_icons.c io.c
OBJS := $(OBJDIR)/lang.o $(SRCS:%.c=$(OBJDIR)/%.o) $(OBJDIR)/uisw32-res.o
-ROCKSRCS = bounce.c cube.c flipit.c helloworld.c sliding_puzzle.c snow.c \
- sokoban.c star.c tetris.c viewer.c wormlet.c
+ROCKSRCS := $(patsubst $(PLUGINDIR)/%.c,%.c,$(wildcard $(PLUGINDIR)/*.c))
ROCKS := $(ROCKSRCS:%.c=$(OBJDIR)/%.rock)
@@ -197,6 +196,9 @@ $(OBJDIR)/onplay.o: $(APPDIR)/onplay.c
$(OBJDIR)/playlist.o: $(APPDIR)/playlist.c
$(CC) $(APPCFLAGS) -c $< -o $@
+$(OBJDIR)/plugin.o: $(APPDIR)/plugin.c plugin-win32.h
+ $(CC) $(APPCFLAGS) -c $< -o $@
+
$(OBJDIR)/build.lang: $(APPDIR)/lang/$(LANGUAGE).lang
perl $(TOOLSDIR)/uplang $(APPDIR)/lang/english.lang $< > $@
@@ -292,7 +294,7 @@ $(OBJDIR)/%.po : $(PLUGINDIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
$(OBJDIR)/%.rock : $(OBJDIR)/%.po
- $(DLL) $(DLLFLAGS) $< -o $@
+ -$(DLL) $(DLLFLAGS) $< -o $@
DEPS:=$(OBJDIR)/.deps
diff --git a/uisimulator/win32/plugin-win32.c b/uisimulator/win32/plugin-win32.c
deleted file mode 100644
index 0809da0..0000000
--- a/uisimulator/win32/plugin-win32.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 Björn Stenberg
- *
- * All files in this archive are subject to the GNU General Public License.
- * See the file COPYING in the source tree root for full license agreement.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#include <stdbool.h>
-#include <string.h>
-#include <stdio.h>
-#include "button.h"
-#include "lcd.h"
-#include "dir.h"
-#include "file.h"
-#include "kernel.h"
-#include "sprintf.h"
-#include "screens.h"
-#include "misc.h"
-#include "mas.h"
-#include "plugin.h"
-
-#include <windows.h>
-
-static int plugin_test(int api_version, int model);
-
-static struct plugin_api rockbox_api = {
- PLUGIN_API_VERSION,
-
- plugin_test,
-
- /* lcd */
- lcd_clear_display,
- lcd_puts,
- lcd_puts_scroll,
- lcd_stop_scroll,
-#ifdef HAVE_LCD_CHARCELLS
- lcd_define_pattern,
-#else
- lcd_putsxy,
- lcd_bitmap,
- lcd_drawline,
- lcd_clearline,
- lcd_drawpixel,
- lcd_clearpixel,
- lcd_setfont,
- lcd_clearrect,
- lcd_fillrect,
- lcd_drawrect,
- lcd_invertrect,
- lcd_getstringsize,
- lcd_update,
- lcd_update_rect,
-#endif
-
- /* button */
- button_get,
- button_get_w_tmo,
-
- /* file */
- open,
- close,
- read,
- lseek,
- creat,
- write,
- remove,
- rename,
- NULL, /* ftruncate */
- win32_filesize,
- fprintf,
- read_line,
-
- /* dir */
- opendir,
- closedir,
- readdir,
-
- /* kernel */
- sleep,
- usb_screen,
- &current_tick,
-
- /* strings and memory */
- snprintf,
- strcpy,
- strlen,
- memset,
- memcpy,
-
- /* misc */
- srand,
- rand,
- splash,
- qsort,
-};
-
-typedef enum plugin_status (*plugin_fn)(struct plugin_api* api, void* param);
-
-int plugin_load(char* plugin, void* parameter)
-{
- plugin_fn plugin_start;
- int rc;
- char buf[64];
- void* pd;
-
- lcd_clear_display();
-#ifdef HAVE_LCD_BITMAP
- lcd_setmargins(0,0);
- lcd_update();
-#endif
-
- pd = LoadLibrary(plugin);
- if (!pd) {
- snprintf(buf, sizeof buf, "Can't open %s", plugin);
- splash(HZ*2, 0, true, buf);
- return -1;
- }
-
- plugin_start = (plugin_fn)GetProcAddress(pd, "plugin_start");
- if (!plugin_start) {
- splash(HZ*2, 0, true, "Can't find entry point");
- FreeLibrary(pd);
- return -1;
- }
-
- rc = plugin_start(&rockbox_api, parameter);
-
- FreeLibrary(pd);
-
- return rc;
-}
-
-int plugin_test(int api_version, int model)
-{
- if (api_version != PLUGIN_API_VERSION)
- return PLUGIN_WRONG_API_VERSION;
-
- if (model != MODEL)
- return PLUGIN_WRONG_MODEL;
-
- return PLUGIN_OK;
-}
diff --git a/uisimulator/win32/plugin-win32.h b/uisimulator/win32/plugin-win32.h
new file mode 100644
index 0000000..9e17d42
--- /dev/null
+++ b/uisimulator/win32/plugin-win32.h
@@ -0,0 +1,37 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 Björn Stenberg
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <windows.h>
+#include "plugin.h"
+#include "file.h"
+
+#define RTLD_NOW 0
+
+#undef filesize
+#define filesize win32_filesize
+
+#undef ftruncate
+#define ftruncate NULL
+
+typedef enum plugin_status (*plugin_fn)(struct plugin_api* api, void* param);
+
+#define dlopen(_x_, _y_) LoadLibrary(_x_)
+#define dlsym(_x_, _y_) (plugin_fn)GetProcAddress(_x_, _y_)
+#define dlclose(_x_) FreeLibrary(_x_)
+#define dlerror() "Unknown"