summaryrefslogtreecommitdiff
path: root/uisimulator
diff options
context:
space:
mode:
authorHardeep Sidhu <dyp@pobox.com>2003-06-29 21:57:31 +0000
committerHardeep Sidhu <dyp@pobox.com>2003-06-29 21:57:31 +0000
commitb421750102f6cf6a93b16d994274eb13304d15ab (patch)
treedbcf1d37896d1208a23755a021d85b50d8c7e9bd /uisimulator
parentb2a2022cc3b9809b5548236dcfcf7bb4dabf7985 (diff)
downloadrockbox-b421750102f6cf6a93b16d994274eb13304d15ab.tar.gz
rockbox-b421750102f6cf6a93b16d994274eb13304d15ab.zip
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
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/win32/Makefile40
-rw-r--r--uisimulator/win32/plugin-win32.c134
-rwxr-xr-xuisimulator/win32/plugin.def3
3 files changed, 149 insertions, 28 deletions
diff --git a/uisimulator/win32/Makefile b/uisimulator/win32/Makefile
index 3ba223d7bd..a0fd6e8a56 100644
--- a/uisimulator/win32/Makefile
+++ b/uisimulator/win32/Makefile
@@ -20,6 +20,7 @@
20APPDIR = ../../apps 20APPDIR = ../../apps
21RECDIR = $(APPDIR)/recorder 21RECDIR = $(APPDIR)/recorder
22PLAYDIR = $(APPDIR)/player 22PLAYDIR = $(APPDIR)/player
23PLUGINDIR = $(APPDIR)/plugins
23 24
24ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP) 25ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP)
25 MACHINEDIR = $(RECDIR) 26 MACHINEDIR = $(RECDIR)
@@ -66,11 +67,13 @@ DEFINES += -DWIN32
66CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) -W -Wall -mno-cygwin 67CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) -W -Wall -mno-cygwin
67 68
68APPCFLAGS = $(DEBUG) $(DEFINES) $(APPINCLUDES) -W -Wall -mno-cygwin 69APPCFLAGS = $(DEBUG) $(DEFINES) $(APPINCLUDES) -W -Wall -mno-cygwin
70DLLFLAGS = -s --entry _DllMain@12 --target=i386-mingw32 --def plugin.def
69 71
70UNAME := $(shell uname|sed -e "s/CYGWIN.*/CYGWIN/") 72UNAME := $(shell uname|sed -e "s/CYGWIN.*/CYGWIN/")
71ifeq ($(UNAME),CYGWIN) 73ifeq ($(UNAME),CYGWIN)
72 CC = gcc 74 CC = gcc
73 WINDRES = windres 75 WINDRES = windres
76 DLL = dllwrap
74 DEFINES += -DNOCYGWIN 77 DEFINES += -DNOCYGWIN
75 CFLAGS += -mno-cygwin 78 CFLAGS += -mno-cygwin
76 LDFLAGS += -mno-cygwin 79 LDFLAGS += -mno-cygwin
@@ -78,6 +81,7 @@ ifeq ($(UNAME),CYGWIN)
78else 81else
79 CC = i386-mingw32msvc-gcc 82 CC = i386-mingw32msvc-gcc
80 WINDRES = i386-mingw32msvc-windres 83 WINDRES = i386-mingw32msvc-windres
84 DLL = i386-mingw32msvc-dllwrap
81 CFLAGS += -mwindows 85 CFLAGS += -mwindows
82 LDFLAGS += -mwindows 86 LDFLAGS += -mwindows
83 APPCFLAGS += -mwindows 87 APPCFLAGS += -mwindows
@@ -108,7 +112,12 @@ SRCS = button.c dir-win32.c lcd-win32.c panic-win32.c thread-win32.c \
108 112
109OBJS := $(OBJDIR)/lang.o $(SRCS:%.c=$(OBJDIR)/%.o) $(OBJDIR)/uisw32-res.o 113OBJS := $(OBJDIR)/lang.o $(SRCS:%.c=$(OBJDIR)/%.o) $(OBJDIR)/uisw32-res.o
110 114
111all: $(TARGET) 115ROCKSRCS = bounce.c cube.c flipit.c helloworld.c sliding_puzzle.c snow.c \
116 sokoban.c star.c tetris.c viewer.c wormlet.c
117
118ROCKS := $(ROCKSRCS:%.c=$(OBJDIR)/%.rock)
119
120all: $(TARGET) $(ROCKS)
112 121
113$(TARGET): $(OBJS) 122$(TARGET): $(OBJS)
114 $(CC) $(OBJS) -o $(TARGET) $(LDFLAGS) 123 $(CC) $(OBJS) -o $(TARGET) $(LDFLAGS)
@@ -119,7 +128,7 @@ $(OBJDIR)/uisw32-res.o: uisw32.rc
119clean: 128clean:
120 $(RM) $(OBJS) *~ core $(TARGET) $(CLIENTS) $(OBJDIR)/uisw32-res.o \ 129 $(RM) $(OBJS) *~ core $(TARGET) $(CLIENTS) $(OBJDIR)/uisw32-res.o \
121 $(OBJDIR)/lang.[cho] $(OBJDIR)/build.lang $(OBJDIR)/*.o \ 130 $(OBJDIR)/lang.[cho] $(OBJDIR)/build.lang $(OBJDIR)/*.o \
122 $(OBJDIR)/sysfont.c $(OBJDIR)/credits.raw 131 $(OBJDIR)/*.rock $(OBJDIR)/sysfont.c $(OBJDIR)/credits.raw
123 $(RM) -r $(DEPS) 132 $(RM) -r $(DEPS)
124 133
125distclean: clean 134distclean: clean
@@ -161,24 +170,6 @@ $(OBJDIR)/widgets.o: $(RECDIR)/widgets.c
161$(OBJDIR)/keyboard.o: $(MACHINEDIR)/keyboard.c 170$(OBJDIR)/keyboard.o: $(MACHINEDIR)/keyboard.c
162 $(CC) $(APPCFLAGS) -c $< -o $@ 171 $(CC) $(APPCFLAGS) -c $< -o $@
163 172
164$(OBJDIR)/tetris.o: $(RECDIR)/tetris.c
165 $(CC) $(APPCFLAGS) -c $< -o $@
166
167$(OBJDIR)/wormlet.o: $(RECDIR)/wormlet.c
168 $(CC) $(APPCFLAGS) -c $< -o $@
169
170$(OBJDIR)/sokoban.o: $(RECDIR)/sokoban.c
171 $(CC) $(APPCFLAGS) -c $< -o $@
172
173$(OBJDIR)/bounce.o: $(RECDIR)/bounce.c
174 $(CC) $(APPCFLAGS) -c $< -o $@
175
176$(OBJDIR)/cube.o: $(RECDIR)/cube.c
177 $(CC) $(APPCFLAGS) -c $< -o $@
178
179$(OBJDIR)/snow.o: $(RECDIR)/snow.c
180 $(CC) $(APPCFLAGS) -c $< -o $@
181
182$(OBJDIR)/main.o: $(APPDIR)/main.c 173$(OBJDIR)/main.o: $(APPDIR)/main.c
183 $(CC) $(APPCFLAGS) -c $< -o $@ 174 $(CC) $(APPCFLAGS) -c $< -o $@
184 175
@@ -191,9 +182,6 @@ $(OBJDIR)/wps.o: $(APPDIR)/wps.c
191$(OBJDIR)/sleeptimer.o: $(APPDIR)/sleeptimer.c 182$(OBJDIR)/sleeptimer.o: $(APPDIR)/sleeptimer.c
192 $(CC) $(APPCFLAGS) -c $< -o $@ 183 $(CC) $(APPCFLAGS) -c $< -o $@
193 184
194$(OBJDIR)/viewer.o: $(APPDIR)/viewer.c
195 $(CC) $(APPCFLAGS) -c $< -o $@
196
197$(OBJDIR)/wps-display.o: $(APPDIR)/wps-display.c 185$(OBJDIR)/wps-display.o: $(APPDIR)/wps-display.c
198 $(CC) $(APPCFLAGS) -c $< -o $@ 186 $(CC) $(APPCFLAGS) -c $< -o $@
199 187
@@ -300,6 +288,12 @@ $(OBJDIR)/lcd-player.o: $(DRIVERS)/lcd-player.c
300$(OBJDIR)/%.o: %.c 288$(OBJDIR)/%.o: %.c
301 $(CC) $(CFLAGS) -c $< -o $@ 289 $(CC) $(CFLAGS) -c $< -o $@
302 290
291$(OBJDIR)/%.po : $(PLUGINDIR)/%.c
292 $(CC) $(CFLAGS) -c $< -o $@
293
294$(OBJDIR)/%.rock : $(OBJDIR)/%.po
295 $(DLL) $(DLLFLAGS) $< -o $@
296
303DEPS:=$(OBJDIR)/.deps 297DEPS:=$(OBJDIR)/.deps
304 298
305$(DEPS)/%.d: %.c 299$(DEPS)/%.d: %.c
diff --git a/uisimulator/win32/plugin-win32.c b/uisimulator/win32/plugin-win32.c
index b3c3e0489b..0809da0e2e 100644
--- a/uisimulator/win32/plugin-win32.c
+++ b/uisimulator/win32/plugin-win32.c
@@ -17,14 +17,138 @@
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19 19
20#include "plugin.h" 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"
21#include "screens.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);
22 110
23int plugin_load(char* plugin, void* parameter) 111int plugin_load(char* plugin, void* parameter)
24{ 112{
25 (void)plugin; 113 plugin_fn plugin_start;
26 (void)parameter; 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;
27 152
28 splash(HZ*2, 0, true, "Not implemented"); 153 return PLUGIN_OK;
29 return PLUGIN_ERROR;
30} 154}
diff --git a/uisimulator/win32/plugin.def b/uisimulator/win32/plugin.def
new file mode 100755
index 0000000000..403b2d1ff4
--- /dev/null
+++ b/uisimulator/win32/plugin.def
@@ -0,0 +1,3 @@
1EXPORTS
2 plugin_start
3