forked from len0rd/rockbox
Changed win32 simulator to use plugin.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3784 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
ba5dfbd71e
commit
dd5d3f652f
4 changed files with 56 additions and 162 deletions
|
|
@ -32,9 +32,14 @@
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
|
|
||||||
#ifdef SIMULATOR
|
#ifdef SIMULATOR
|
||||||
#include <dlfcn.h>
|
#include <debug.h>
|
||||||
#include <debug.h>
|
#ifdef WIN32
|
||||||
#define PREFIX(_x_) x11_ ## _x_
|
#include "plugin-win32.h"
|
||||||
|
#define PREFIX(_x_) _x_
|
||||||
|
#else
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#define PREFIX(_x_) x11_ ## _x_
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#define PREFIX(_x_) _x_
|
#define PREFIX(_x_) _x_
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -141,7 +146,11 @@ int plugin_load(char* plugin, void* parameter)
|
||||||
lcd_update();
|
lcd_update();
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIMULATOR
|
#ifdef SIMULATOR
|
||||||
|
#ifdef WIN32
|
||||||
|
snprintf(path, sizeof path, "%s", plugin);
|
||||||
|
#else
|
||||||
snprintf(path, sizeof path, "archos%s", plugin);
|
snprintf(path, sizeof path, "archos%s", plugin);
|
||||||
|
#endif
|
||||||
pd = dlopen(path, RTLD_NOW);
|
pd = dlopen(path, RTLD_NOW);
|
||||||
if (!pd) {
|
if (!pd) {
|
||||||
snprintf(buf, sizeof buf, "Can't open %s", plugin);
|
snprintf(buf, sizeof buf, "Can't open %s", plugin);
|
||||||
|
|
|
||||||
|
|
@ -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 \
|
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 \
|
playlist.c wps.c wps-display.c settings.c status.c \
|
||||||
screens.c peakmeter.c sleeptimer.c keyboard.c onplay.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
|
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 \
|
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 \
|
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
|
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 \
|
ROCKSRCS := $(patsubst $(PLUGINDIR)/%.c,%.c,$(wildcard $(PLUGINDIR)/*.c))
|
||||||
sokoban.c star.c tetris.c viewer.c wormlet.c
|
|
||||||
|
|
||||||
ROCKS := $(ROCKSRCS:%.c=$(OBJDIR)/%.rock)
|
ROCKS := $(ROCKSRCS:%.c=$(OBJDIR)/%.rock)
|
||||||
|
|
||||||
|
|
@ -197,6 +196,9 @@ $(OBJDIR)/onplay.o: $(APPDIR)/onplay.c
|
||||||
$(OBJDIR)/playlist.o: $(APPDIR)/playlist.c
|
$(OBJDIR)/playlist.o: $(APPDIR)/playlist.c
|
||||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(OBJDIR)/plugin.o: $(APPDIR)/plugin.c plugin-win32.h
|
||||||
|
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||||
|
|
||||||
$(OBJDIR)/build.lang: $(APPDIR)/lang/$(LANGUAGE).lang
|
$(OBJDIR)/build.lang: $(APPDIR)/lang/$(LANGUAGE).lang
|
||||||
perl $(TOOLSDIR)/uplang $(APPDIR)/lang/english.lang $< > $@
|
perl $(TOOLSDIR)/uplang $(APPDIR)/lang/english.lang $< > $@
|
||||||
|
|
||||||
|
|
@ -292,7 +294,7 @@ $(OBJDIR)/%.po : $(PLUGINDIR)/%.c
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
$(OBJDIR)/%.rock : $(OBJDIR)/%.po
|
$(OBJDIR)/%.rock : $(OBJDIR)/%.po
|
||||||
$(DLL) $(DLLFLAGS) $< -o $@
|
-$(DLL) $(DLLFLAGS) $< -o $@
|
||||||
|
|
||||||
DEPS:=$(OBJDIR)/.deps
|
DEPS:=$(OBJDIR)/.deps
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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,
|
|
||||||
¤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;
|
|
||||||
}
|
|
||||||
37
uisimulator/win32/plugin-win32.h
Normal file
37
uisimulator/win32/plugin-win32.h
Normal file
|
|
@ -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"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue