diff options
Diffstat (limited to 'uisimulator/win32')
-rw-r--r-- | uisimulator/win32/Makefile | 40 | ||||
-rw-r--r-- | uisimulator/win32/plugin-win32.c | 134 | ||||
-rwxr-xr-x | uisimulator/win32/plugin.def | 3 |
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 @@ | |||
20 | APPDIR = ../../apps | 20 | APPDIR = ../../apps |
21 | RECDIR = $(APPDIR)/recorder | 21 | RECDIR = $(APPDIR)/recorder |
22 | PLAYDIR = $(APPDIR)/player | 22 | PLAYDIR = $(APPDIR)/player |
23 | PLUGINDIR = $(APPDIR)/plugins | ||
23 | 24 | ||
24 | ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP) | 25 | ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP) |
25 | MACHINEDIR = $(RECDIR) | 26 | MACHINEDIR = $(RECDIR) |
@@ -66,11 +67,13 @@ DEFINES += -DWIN32 | |||
66 | CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) -W -Wall -mno-cygwin | 67 | CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) -W -Wall -mno-cygwin |
67 | 68 | ||
68 | APPCFLAGS = $(DEBUG) $(DEFINES) $(APPINCLUDES) -W -Wall -mno-cygwin | 69 | APPCFLAGS = $(DEBUG) $(DEFINES) $(APPINCLUDES) -W -Wall -mno-cygwin |
70 | DLLFLAGS = -s --entry _DllMain@12 --target=i386-mingw32 --def plugin.def | ||
69 | 71 | ||
70 | UNAME := $(shell uname|sed -e "s/CYGWIN.*/CYGWIN/") | 72 | UNAME := $(shell uname|sed -e "s/CYGWIN.*/CYGWIN/") |
71 | ifeq ($(UNAME),CYGWIN) | 73 | ifeq ($(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) | |||
78 | else | 81 | else |
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 | ||
109 | OBJS := $(OBJDIR)/lang.o $(SRCS:%.c=$(OBJDIR)/%.o) $(OBJDIR)/uisw32-res.o | 113 | OBJS := $(OBJDIR)/lang.o $(SRCS:%.c=$(OBJDIR)/%.o) $(OBJDIR)/uisw32-res.o |
110 | 114 | ||
111 | all: $(TARGET) | 115 | ROCKSRCS = 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 | |||
118 | ROCKS := $(ROCKSRCS:%.c=$(OBJDIR)/%.rock) | ||
119 | |||
120 | all: $(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 | |||
119 | clean: | 128 | clean: |
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 | ||
125 | distclean: clean | 134 | distclean: 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 | |||
303 | DEPS:=$(OBJDIR)/.deps | 297 | DEPS:=$(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 | |||
36 | static int plugin_test(int api_version, int model); | ||
37 | |||
38 | static 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 | ¤t_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 | |||
109 | typedef enum plugin_status (*plugin_fn)(struct plugin_api* api, void* param); | ||
22 | 110 | ||
23 | int plugin_load(char* plugin, void* parameter) | 111 | int 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 | |||
145 | int 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 @@ | |||
1 | EXPORTS | ||
2 | plugin_start | ||
3 | |||