diff options
author | Hardeep Sidhu <dyp@pobox.com> | 2003-06-29 23:38:03 +0000 |
---|---|---|
committer | Hardeep Sidhu <dyp@pobox.com> | 2003-06-29 23:38:03 +0000 |
commit | dd5d3f652f99096ced7313d3f2179aa36501f1f5 (patch) | |
tree | 5b8abf7c7995023132499beedc9ae7e9af088d74 /uisimulator/win32 | |
parent | ba5dfbd71ef9ea1a1c786d02e10311decc9ced64 (diff) | |
download | rockbox-dd5d3f652f99096ced7313d3f2179aa36501f1f5.tar.gz rockbox-dd5d3f652f99096ced7313d3f2179aa36501f1f5.zip |
Changed win32 simulator to use plugin.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3784 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/win32')
-rw-r--r-- | uisimulator/win32/Makefile | 12 | ||||
-rw-r--r-- | uisimulator/win32/plugin-win32.c | 154 | ||||
-rw-r--r-- | uisimulator/win32/plugin-win32.h | 37 |
3 files changed, 44 insertions, 159 deletions
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 \ | |||
98 | APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \ | 98 | APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \ |
99 | playlist.c wps.c wps-display.c settings.c status.c \ | 99 | playlist.c wps.c wps-display.c settings.c status.c \ |
100 | screens.c peakmeter.c sleeptimer.c keyboard.c onplay.c\ | 100 | screens.c peakmeter.c sleeptimer.c keyboard.c onplay.c\ |
101 | misc.c | 101 | misc.c plugin.c |
102 | 102 | ||
103 | MENUS = games_menu.c demo_menu.c settings_menu.c sound_menu.c | 103 | MENUS = games_menu.c demo_menu.c settings_menu.c sound_menu.c |
104 | 104 | ||
@@ -108,12 +108,11 @@ endif | |||
108 | 108 | ||
109 | SRCS = button.c dir-win32.c lcd-win32.c panic-win32.c thread-win32.c \ | 109 | SRCS = button.c dir-win32.c lcd-win32.c panic-win32.c thread-win32.c \ |
110 | debug-win32.c kernel.c string-win32.c uisw32.c stubs.c \ | 110 | debug-win32.c kernel.c string-win32.c uisw32.c stubs.c \ |
111 | $(APPS) $(MENUS) $(FIRMSRCS) strtok.c sim_icons.c io.c plugin-win32.c | 111 | $(APPS) $(MENUS) $(FIRMSRCS) strtok.c sim_icons.c io.c |
112 | 112 | ||
113 | 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 |
114 | 114 | ||
115 | ROCKSRCS = bounce.c cube.c flipit.c helloworld.c sliding_puzzle.c snow.c \ | 115 | ROCKSRCS := $(patsubst $(PLUGINDIR)/%.c,%.c,$(wildcard $(PLUGINDIR)/*.c)) |
116 | sokoban.c star.c tetris.c viewer.c wormlet.c | ||
117 | 116 | ||
118 | ROCKS := $(ROCKSRCS:%.c=$(OBJDIR)/%.rock) | 117 | ROCKS := $(ROCKSRCS:%.c=$(OBJDIR)/%.rock) |
119 | 118 | ||
@@ -197,6 +196,9 @@ $(OBJDIR)/onplay.o: $(APPDIR)/onplay.c | |||
197 | $(OBJDIR)/playlist.o: $(APPDIR)/playlist.c | 196 | $(OBJDIR)/playlist.o: $(APPDIR)/playlist.c |
198 | $(CC) $(APPCFLAGS) -c $< -o $@ | 197 | $(CC) $(APPCFLAGS) -c $< -o $@ |
199 | 198 | ||
199 | $(OBJDIR)/plugin.o: $(APPDIR)/plugin.c plugin-win32.h | ||
200 | $(CC) $(APPCFLAGS) -c $< -o $@ | ||
201 | |||
200 | $(OBJDIR)/build.lang: $(APPDIR)/lang/$(LANGUAGE).lang | 202 | $(OBJDIR)/build.lang: $(APPDIR)/lang/$(LANGUAGE).lang |
201 | perl $(TOOLSDIR)/uplang $(APPDIR)/lang/english.lang $< > $@ | 203 | perl $(TOOLSDIR)/uplang $(APPDIR)/lang/english.lang $< > $@ |
202 | 204 | ||
@@ -292,7 +294,7 @@ $(OBJDIR)/%.po : $(PLUGINDIR)/%.c | |||
292 | $(CC) $(CFLAGS) -c $< -o $@ | 294 | $(CC) $(CFLAGS) -c $< -o $@ |
293 | 295 | ||
294 | $(OBJDIR)/%.rock : $(OBJDIR)/%.po | 296 | $(OBJDIR)/%.rock : $(OBJDIR)/%.po |
295 | $(DLL) $(DLLFLAGS) $< -o $@ | 297 | -$(DLL) $(DLLFLAGS) $< -o $@ |
296 | 298 | ||
297 | DEPS:=$(OBJDIR)/.deps | 299 | DEPS:=$(OBJDIR)/.deps |
298 | 300 | ||
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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Björn Stenberg | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
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" | ||
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); | ||
110 | |||
111 | int plugin_load(char* plugin, void* parameter) | ||
112 | { | ||
113 | plugin_fn plugin_start; | ||
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; | ||
152 | |||
153 | return PLUGIN_OK; | ||
154 | } | ||
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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Björn Stenberg | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include <windows.h> | ||
21 | #include "plugin.h" | ||
22 | #include "file.h" | ||
23 | |||
24 | #define RTLD_NOW 0 | ||
25 | |||
26 | #undef filesize | ||
27 | #define filesize win32_filesize | ||
28 | |||
29 | #undef ftruncate | ||
30 | #define ftruncate NULL | ||
31 | |||
32 | typedef enum plugin_status (*plugin_fn)(struct plugin_api* api, void* param); | ||
33 | |||
34 | #define dlopen(_x_, _y_) LoadLibrary(_x_) | ||
35 | #define dlsym(_x_, _y_) (plugin_fn)GetProcAddress(_x_, _y_) | ||
36 | #define dlclose(_x_) FreeLibrary(_x_) | ||
37 | #define dlerror() "Unknown" | ||