Plugins now work with win32 simulator (.rock files are built as dll's)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3781 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
b2a2022cc3
commit
b421750102
3 changed files with 149 additions and 28 deletions
|
@ -20,6 +20,7 @@
|
|||
APPDIR = ../../apps
|
||||
RECDIR = $(APPDIR)/recorder
|
||||
PLAYDIR = $(APPDIR)/player
|
||||
PLUGINDIR = $(APPDIR)/plugins
|
||||
|
||||
ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP)
|
||||
MACHINEDIR = $(RECDIR)
|
||||
|
@ -66,11 +67,13 @@ DEFINES += -DWIN32
|
|||
CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) -W -Wall -mno-cygwin
|
||||
|
||||
APPCFLAGS = $(DEBUG) $(DEFINES) $(APPINCLUDES) -W -Wall -mno-cygwin
|
||||
DLLFLAGS = -s --entry _DllMain@12 --target=i386-mingw32 --def plugin.def
|
||||
|
||||
UNAME := $(shell uname|sed -e "s/CYGWIN.*/CYGWIN/")
|
||||
ifeq ($(UNAME),CYGWIN)
|
||||
CC = gcc
|
||||
WINDRES = windres
|
||||
DLL = dllwrap
|
||||
DEFINES += -DNOCYGWIN
|
||||
CFLAGS += -mno-cygwin
|
||||
LDFLAGS += -mno-cygwin
|
||||
|
@ -78,6 +81,7 @@ ifeq ($(UNAME),CYGWIN)
|
|||
else
|
||||
CC = i386-mingw32msvc-gcc
|
||||
WINDRES = i386-mingw32msvc-windres
|
||||
DLL = i386-mingw32msvc-dllwrap
|
||||
CFLAGS += -mwindows
|
||||
LDFLAGS += -mwindows
|
||||
APPCFLAGS += -mwindows
|
||||
|
@ -108,7 +112,12 @@ SRCS = button.c dir-win32.c lcd-win32.c panic-win32.c thread-win32.c \
|
|||
|
||||
OBJS := $(OBJDIR)/lang.o $(SRCS:%.c=$(OBJDIR)/%.o) $(OBJDIR)/uisw32-res.o
|
||||
|
||||
all: $(TARGET)
|
||||
ROCKSRCS = bounce.c cube.c flipit.c helloworld.c sliding_puzzle.c snow.c \
|
||||
sokoban.c star.c tetris.c viewer.c wormlet.c
|
||||
|
||||
ROCKS := $(ROCKSRCS:%.c=$(OBJDIR)/%.rock)
|
||||
|
||||
all: $(TARGET) $(ROCKS)
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CC) $(OBJS) -o $(TARGET) $(LDFLAGS)
|
||||
|
@ -119,7 +128,7 @@ $(OBJDIR)/uisw32-res.o: uisw32.rc
|
|||
clean:
|
||||
$(RM) $(OBJS) *~ core $(TARGET) $(CLIENTS) $(OBJDIR)/uisw32-res.o \
|
||||
$(OBJDIR)/lang.[cho] $(OBJDIR)/build.lang $(OBJDIR)/*.o \
|
||||
$(OBJDIR)/sysfont.c $(OBJDIR)/credits.raw
|
||||
$(OBJDIR)/*.rock $(OBJDIR)/sysfont.c $(OBJDIR)/credits.raw
|
||||
$(RM) -r $(DEPS)
|
||||
|
||||
distclean: clean
|
||||
|
@ -161,24 +170,6 @@ $(OBJDIR)/widgets.o: $(RECDIR)/widgets.c
|
|||
$(OBJDIR)/keyboard.o: $(MACHINEDIR)/keyboard.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/tetris.o: $(RECDIR)/tetris.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/wormlet.o: $(RECDIR)/wormlet.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/sokoban.o: $(RECDIR)/sokoban.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/bounce.o: $(RECDIR)/bounce.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/cube.o: $(RECDIR)/cube.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/snow.o: $(RECDIR)/snow.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/main.o: $(APPDIR)/main.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
|
@ -191,9 +182,6 @@ $(OBJDIR)/wps.o: $(APPDIR)/wps.c
|
|||
$(OBJDIR)/sleeptimer.o: $(APPDIR)/sleeptimer.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/viewer.o: $(APPDIR)/viewer.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/wps-display.o: $(APPDIR)/wps-display.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
|
@ -300,6 +288,12 @@ $(OBJDIR)/lcd-player.o: $(DRIVERS)/lcd-player.c
|
|||
$(OBJDIR)/%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/%.po : $(PLUGINDIR)/%.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/%.rock : $(OBJDIR)/%.po
|
||||
$(DLL) $(DLLFLAGS) $< -o $@
|
||||
|
||||
DEPS:=$(OBJDIR)/.deps
|
||||
|
||||
$(DEPS)/%.d: %.c
|
||||
|
|
|
@ -17,14 +17,138 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "plugin.h"
|
||||
#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)
|
||||
{
|
||||
(void)plugin;
|
||||
(void)parameter;
|
||||
plugin_fn plugin_start;
|
||||
int rc;
|
||||
char buf[64];
|
||||
void* pd;
|
||||
|
||||
splash(HZ*2, 0, true, "Not implemented");
|
||||
return PLUGIN_ERROR;
|
||||
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;
|
||||
}
|
||||
|
|
3
uisimulator/win32/plugin.def
Executable file
3
uisimulator/win32/plugin.def
Executable file
|
@ -0,0 +1,3 @@
|
|||
EXPORTS
|
||||
plugin_start
|
||||
|
Loading…
Reference in a new issue