From dd5d3f652f99096ced7313d3f2179aa36501f1f5 Mon Sep 17 00:00:00 2001 From: Hardeep Sidhu Date: Sun, 29 Jun 2003 23:38:03 +0000 Subject: Changed win32 simulator to use plugin.c git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3784 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugin.c | 15 +++- uisimulator/win32/Makefile | 12 +-- uisimulator/win32/plugin-win32.c | 154 --------------------------------------- uisimulator/win32/plugin-win32.h | 37 ++++++++++ 4 files changed, 56 insertions(+), 162 deletions(-) delete mode 100644 uisimulator/win32/plugin-win32.c create mode 100644 uisimulator/win32/plugin-win32.h 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 @@ #include "lang.h" #ifdef SIMULATOR -#include -#include -#define PREFIX(_x_) x11_ ## _x_ + #include + #ifdef WIN32 + #include "plugin-win32.h" + #define PREFIX(_x_) _x_ + #else + #include + #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 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 \ 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 0809da0e2e..0000000000 --- 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 -#include -#include -#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 - -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, - ¤t_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 0000000000..9e17d425ec --- /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 +#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" -- cgit v1.2.3