summaryrefslogtreecommitdiff
path: root/uisimulator/win32
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator/win32')
-rw-r--r--uisimulator/win32/button.c74
-rw-r--r--uisimulator/win32/kernel.c8
-rw-r--r--uisimulator/win32/lcd-win32.c7
-rw-r--r--uisimulator/win32/makefile15
-rw-r--r--uisimulator/win32/mpeg.c11
-rw-r--r--uisimulator/win32/thread-win32.c53
-rw-r--r--uisimulator/win32/thread-win32.h22
-rw-r--r--uisimulator/win32/uisw32.c36
-rw-r--r--uisimulator/win32/uisw32.h2
-rw-r--r--uisimulator/win32/uisw32.suobin12800 -> 12800 bytes
-rw-r--r--uisimulator/win32/uisw32.vcproj14
11 files changed, 189 insertions, 53 deletions
diff --git a/uisimulator/win32/button.c b/uisimulator/win32/button.c
index a2edbde9a3..9f3c324077 100644
--- a/uisimulator/win32/button.c
+++ b/uisimulator/win32/button.c
@@ -34,52 +34,58 @@ void button_init(void)
34 34
35int button_get(bool block) 35int button_get(bool block)
36{ 36{
37
37 int btn = 0; 38 int btn = 0;
38 if (bActive) 39 do
39 { 40 {
40 if (KEY (VK_NUMPAD4) || 41 if (bActive)
41 KEY (VK_LEFT)) // left button 42 {
42 btn |= BUTTON_LEFT; 43 if (KEY (VK_NUMPAD4) ||
44 KEY (VK_LEFT)) // left button
45 btn |= BUTTON_LEFT;
43 46
44 if (KEY (VK_NUMPAD6) || 47 if (KEY (VK_NUMPAD6) ||
45 KEY (VK_RIGHT)) 48 KEY (VK_RIGHT))
46 btn |= BUTTON_RIGHT; // right button 49 btn |= BUTTON_RIGHT; // right button
47 50
48 if (KEY (VK_NUMPAD8) || 51 if (KEY (VK_NUMPAD8) ||
49 KEY (VK_UP)) 52 KEY (VK_UP))
50 btn |= BUTTON_UP; // up button 53 btn |= BUTTON_UP; // up button
51 54
52 if (KEY (VK_NUMPAD2) || 55 if (KEY (VK_NUMPAD2) ||
53 KEY (VK_DOWN)) 56 KEY (VK_DOWN))
54 btn |= BUTTON_DOWN; // down button 57 btn |= BUTTON_DOWN; // down button
55 58
56 if (KEY (VK_ADD)) 59 if (KEY (VK_ADD))
57 btn |= BUTTON_ON; // on button 60 btn |= BUTTON_ON; // on button
58 61
59 #ifdef HAVE_RECORDER_KEYPAD 62 #ifdef HAVE_RECORDER_KEYPAD
60 if (KEY (VK_RETURN)) 63 if (KEY (VK_RETURN))
61 btn |= BUTTON_OFF; // off button 64 btn |= BUTTON_OFF; // off button
62 65
63 if (KEY (VK_DIVIDE)) 66 if (KEY (VK_DIVIDE))
64 btn |= BUTTON_F1; // F1 button 67 btn |= BUTTON_F1; // F1 button
65 68
66 if (KEY (VK_MULTIPLY)) 69 if (KEY (VK_MULTIPLY))
67 btn |= BUTTON_F2; // F2 button 70 btn |= BUTTON_F2; // F2 button
68 71
69 if (KEY (VK_SUBTRACT)) 72 if (KEY (VK_SUBTRACT))
70 btn |= BUTTON_F3; // F3 button 73 btn |= BUTTON_F3; // F3 button
71 74
72 if (KEY (VK_NUMPAD5) || 75 if (KEY (VK_NUMPAD5) ||
73 KEY (VK_SPACE)) 76 KEY (VK_SPACE))
74 btn |= BUTTON_PLAY; // play button 77 btn |= BUTTON_PLAY; // play button
75 #else 78 #else
76 if (KEY (VK_RETURN)) 79 if (KEY (VK_RETURN))
77 btn |= BUTTON_MENU; // menu button 80 btn |= BUTTON_MENU; // menu button
78 #endif 81 #endif
79 82
80 if (btn != 0) { 83 if (btn != 0) {
81 last_key = 0 ; 84 last_key = 0 ;
82 } 85 }
86 }
83 } 87 }
88 while (btn == 0 && block);
89
84 return btn; 90 return btn;
85} \ No newline at end of file 91} \ No newline at end of file
diff --git a/uisimulator/win32/kernel.c b/uisimulator/win32/kernel.c
index b6d36e3fa8..102bb6c82a 100644
--- a/uisimulator/win32/kernel.c
+++ b/uisimulator/win32/kernel.c
@@ -18,9 +18,17 @@
18 ****************************************************************************/ 18 ****************************************************************************/
19 19
20#include <windows.h> 20#include <windows.h>
21#include "uisw32.h"
21#include "kernel.h" 22#include "kernel.h"
23#include "thread-win32.h"
22 24
23void sleep(int ticks) 25void sleep(int ticks)
24{ 26{
25 Sleep (1000 / HZ * ticks); 27 Sleep (1000 / HZ * ticks);
28}
29
30
31void yield (void)
32{
33 PostThreadMessage (GetWindowThreadProcessId (hGUIWnd,NULL), TM_YIELD, 0, 0);
26} \ No newline at end of file 34} \ No newline at end of file
diff --git a/uisimulator/win32/lcd-win32.c b/uisimulator/win32/lcd-win32.c
index 2330d444c5..2eef2d5646 100644
--- a/uisimulator/win32/lcd-win32.c
+++ b/uisimulator/win32/lcd-win32.c
@@ -40,13 +40,6 @@ BITMAPINFO2 bmi =
40}; // bitmap information 40}; // bitmap information
41 41
42 42
43// lcd_init
44// init lcd controler
45void lcd_init()
46{
47 lcd_clear_display ();
48}
49
50// lcd_update 43// lcd_update
51// update lcd 44// update lcd
52void lcd_update() 45void lcd_update()
diff --git a/uisimulator/win32/makefile b/uisimulator/win32/makefile
index cc5098b89b..0e93dcd855 100644
--- a/uisimulator/win32/makefile
+++ b/uisimulator/win32/makefile
@@ -27,11 +27,11 @@ APPDIR = ../../apps/
27RECDIR = $(APPDIR)recorder/ 27RECDIR = $(APPDIR)recorder/
28RM = del 28RM = del
29 29
30#DISPLAY = -DHAVE_LCD_CHARCELLS 30DISPLAY = -DHAVE_LCD_CHARCELLS
31DISPLAY = -DHAVE_LCD_BITMAP 31#DISPLAY = -DHAVE_LCD_BITMAP
32 32
33#KEYPAD = -DHAVE_PLAYER_KEYPAD 33KEYPAD = -DHAVE_PLAYER_KEYPAD
34KEYPAD = -DHAVE_RECORDER_KEYPAD 34#KEYPAD = -DHAVE_RECORDER_KEYPAD
35 35
36CC = cl 36CC = cl
37DEFINES = -DWIN32 -DHAVE_CONFIG_H -DGETTIMEOFDAY_TWO_ARGS -DSIMULATOR \ 37DEFINES = -DWIN32 -DHAVE_CONFIG_H -DGETTIMEOFDAY_TWO_ARGS -DSIMULATOR \
@@ -46,7 +46,7 @@ CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) /MD /Fd"Release/vc70.pdb"
46SRCS = lcd-win32.c uisw32.c lcd.c button.c tree.c main.c \ 46SRCS = lcd-win32.c uisw32.c lcd.c button.c tree.c main.c \
47 chartables.c kernel.c uisw32.res dir-win32.c main_menu.c \ 47 chartables.c kernel.c uisw32.res dir-win32.c main_menu.c \
48 play.c debug-win32.c menu.c credits.c sound_menu.c mpeg.c \ 48 play.c debug-win32.c menu.c credits.c sound_menu.c mpeg.c \
49 id3.c settings.c sprintf.c 49 id3.c settings.c sprintf.c thread-win32.c playlist.c
50 50
51!IF ("$(DISPLAY)" == "-DHAVE_LCD_BITMAP") 51!IF ("$(DISPLAY)" == "-DHAVE_LCD_BITMAP")
52SRCS = $(SRCS) tetris.c screensaver.c icons.c bmp.c 52SRCS = $(SRCS) tetris.c screensaver.c icons.c bmp.c
@@ -105,5 +105,8 @@ settings.obj: $(FIRMWAREDIR)/settings.c
105sprintf.obj: $(FIRMWAREDIR)/common/sprintf.c 105sprintf.obj: $(FIRMWAREDIR)/common/sprintf.c
106 $(CC) $(CFLAGS) -c $(FIRMWAREDIR)/common/sprintf.c -osprintf.obj 106 $(CC) $(CFLAGS) -c $(FIRMWAREDIR)/common/sprintf.c -osprintf.obj
107 107
108playlist.obj: ../../apps/playlist.c
109 $(CC) $(CFLAGS) -c ../../apps/playlist.c -oplaylist.obj
110
108clean: 111clean:
109 $(RM) *.obj \ No newline at end of file 112 $(RM) *.obj
diff --git a/uisimulator/win32/mpeg.c b/uisimulator/win32/mpeg.c
index 7f7b76aacb..1ff9bce3ff 100644
--- a/uisimulator/win32/mpeg.c
+++ b/uisimulator/win32/mpeg.c
@@ -20,6 +20,8 @@
20/* This file is for emulating some of the mpeg controlling functions of 20/* This file is for emulating some of the mpeg controlling functions of
21 the target */ 21 the target */
22 22
23#include "debug.h"
24
23void mpeg_volume(void) 25void mpeg_volume(void)
24{ 26{
25} 27}
@@ -35,3 +37,12 @@ void mpeg_treble(void)
35void mpeg_stop(void) 37void mpeg_stop(void)
36{ 38{
37} 39}
40
41#ifndef MPEGPLAY
42void mpeg_play(char *tune)
43{
44 DEBUGF("We instruct the MPEG thread to play %s for us\n",
45 tune);
46}
47
48#endif
diff --git a/uisimulator/win32/thread-win32.c b/uisimulator/win32/thread-win32.c
new file mode 100644
index 0000000000..466567c535
--- /dev/null
+++ b/uisimulator/win32/thread-win32.c
@@ -0,0 +1,53 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Felix Arends
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 "thread-win32.h"
22
23HANDLE lpThreads[256];
24int nThreads = 0,
25 nPos = 0;
26
27
28DWORD WINAPI runthread (LPVOID lpParameter)
29{
30 ((void(*)())lpParameter) ();
31 return 0;
32}
33
34int create_thread(void* fp, void* sp, int stk_size)
35{
36 DWORD dwThreadID;
37
38 if (nThreads == 256)
39 return -1;
40
41 lpThreads[nThreads++] = CreateThread (NULL,
42 0,
43 runthread,
44 fp,
45 0,
46 &dwThreadID);
47
48 return 0;
49}
50
51void init_threads(void)
52{
53}
diff --git a/uisimulator/win32/thread-win32.h b/uisimulator/win32/thread-win32.h
new file mode 100644
index 0000000000..edaab83448
--- /dev/null
+++ b/uisimulator/win32/thread-win32.h
@@ -0,0 +1,22 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Felix Arends
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
20extern HANDLE lpThreads[256];
21extern int nPos,
22 nThreads; \ No newline at end of file
diff --git a/uisimulator/win32/uisw32.c b/uisimulator/win32/uisw32.c
index 0b2f88066c..77ad917461 100644
--- a/uisimulator/win32/uisw32.c
+++ b/uisimulator/win32/uisw32.c
@@ -22,6 +22,8 @@
22#include "uisw32.h" 22#include "uisw32.h"
23#include "resource.h" 23#include "resource.h"
24#include "button.h" 24#include "button.h"
25#include "thread.h"
26#include "thread-win32.h"
25 27
26// extern functions 28// extern functions
27extern void app_main (void *); // mod entry point 29extern void app_main (void *); // mod entry point
@@ -32,6 +34,7 @@ HWND hGUIWnd; // the GUI window handle
32unsigned int uThreadID; // id of mod thread 34unsigned int uThreadID; // id of mod thread
33PBYTE lpKeys; 35PBYTE lpKeys;
34bool bActive; // window active? 36bool bActive; // window active?
37HANDLE hGUIThread; // thread for GUI
35 38
36// GUIWndProc 39// GUIWndProc
37// window proc for GUI simulator 40// window proc for GUI simulator
@@ -186,6 +189,11 @@ LRESULT GUIWndProc (
186 hGUIWnd = NULL; 189 hGUIWnd = NULL;
187 PostQuitMessage (0); 190 PostQuitMessage (0);
188 break; 191 break;
192 case WM_DESTROY:
193 // close simulator
194 hGUIWnd = NULL;
195 PostQuitMessage (0);
196 break;
189 } 197 }
190 198
191 return DefWindowProc (hWnd, uMsg, wParam, lParam); 199 return DefWindowProc (hWnd, uMsg, wParam, lParam);
@@ -229,8 +237,16 @@ BOOL GUIStartup ()
229// destroy window, unregister window class 237// destroy window, unregister window class
230int GUIDown () 238int GUIDown ()
231{ 239{
240 int i;
241
232 DestroyWindow (hGUIWnd); 242 DestroyWindow (hGUIWnd);
233 _endthreadex (uThreadID); 243 CloseHandle (hGUIThread);
244 for (i = 0; i < nThreads; i++)
245 {
246 ResumeThread (lpThreads[i]);
247 WaitForSingleObject (lpThreads[i], 1);
248 CloseHandle (lpThreads[i]);
249 }
234 return 0; 250 return 0;
235} 251}
236 252
@@ -239,10 +255,17 @@ int GUIDown ()
239void GUIMessageLoop () 255void GUIMessageLoop ()
240{ 256{
241 MSG msg; 257 MSG msg;
242 while (GetMessage (&msg, hGUIWnd, 0, 0) && hGUIWnd != NULL) 258 while (GetMessage (&msg, NULL, 0, 0))
243 { 259 {
244 TranslateMessage (&msg); 260 TranslateMessage (&msg);
245 DispatchMessage (&msg); 261 DispatchMessage (&msg);
262 if (msg.message == TM_YIELD)
263 {
264 SuspendThread (lpThreads[nPos]);
265 if (++nPos >= nThreads)
266 nPos = 0;
267 ResumeThread (lpThreads[nPos]);
268 }
246 } 269 }
247} 270}
248 271
@@ -256,12 +279,15 @@ int WINAPI WinMain (
256 int nShowCmd // show command 279 int nShowCmd // show command
257 ) 280 )
258{ 281{
282 DWORD dwThreadID;
259 if (!GUIStartup ()) 283 if (!GUIStartup ())
260 return 0; 284 return 0;
261 285
262 uThreadID = _beginthread (app_main, 0, NULL); 286 hGUIThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)app_main,
263 if (uThreadID == -0L) 287 NULL, 0, &dwThreadID);
264 return MessageBox (NULL, "Error creating mod thread!", "Error", MB_OK); 288
289 if (hGUIThread == NULL)
290 return MessageBox (NULL, "Error creating gui thread!", "Error", MB_OK);
265 291
266 GUIMessageLoop (); 292 GUIMessageLoop ();
267 293
diff --git a/uisimulator/win32/uisw32.h b/uisimulator/win32/uisw32.h
index d709e207f2..fd778e9182 100644
--- a/uisimulator/win32/uisw32.h
+++ b/uisimulator/win32/uisw32.h
@@ -32,6 +32,8 @@
32#define UI_LCD_POSX 59 // x position of lcd 32#define UI_LCD_POSX 59 // x position of lcd
33#define UI_LCD_POSY 95 // y position of lcd 33#define UI_LCD_POSY 95 // y position of lcd
34 34
35#define TM_YIELD WM_USER + 101 // thread message for yield
36
35extern HWND hGUIWnd; // the GUI window handle 37extern HWND hGUIWnd; // the GUI window handle
36extern unsigned int uThreadID; // id of mod thread 38extern unsigned int uThreadID; // id of mod thread
37extern bool bActive; 39extern bool bActive;
diff --git a/uisimulator/win32/uisw32.suo b/uisimulator/win32/uisw32.suo
index f17bb723c3..b18805cf4a 100644
--- a/uisimulator/win32/uisw32.suo
+++ b/uisimulator/win32/uisw32.suo
Binary files differ
diff --git a/uisimulator/win32/uisw32.vcproj b/uisimulator/win32/uisw32.vcproj
index f5a17cc431..99222a64a8 100644
--- a/uisimulator/win32/uisw32.vcproj
+++ b/uisimulator/win32/uisw32.vcproj
@@ -182,7 +182,10 @@
182 </FileConfiguration> 182 </FileConfiguration>
183 </File> 183 </File>
184 <File 184 <File
185 RelativePath="..\..\firmware\playlist.c"> 185 RelativePath="..\..\apps\playlist.c">
186 </File>
187 <File
188 RelativePath="..\..\apps\recorder\screensaver.c">
186 </File> 189 </File>
187 <File 190 <File
188 RelativePath="..\..\firmware\settings.c"> 191 RelativePath="..\..\firmware\settings.c">
@@ -194,6 +197,12 @@
194 RelativePath="..\..\firmware\common\sprintf.c"> 197 RelativePath="..\..\firmware\common\sprintf.c">
195 </File> 198 </File>
196 <File 199 <File
200 RelativePath="..\..\apps\recorder\tetris.c">
201 </File>
202 <File
203 RelativePath="thread-win32.c">
204 </File>
205 <File
197 RelativePath="..\..\apps\tree.c"> 206 RelativePath="..\..\apps\tree.c">
198 </File> 207 </File>
199 <File 208 <File
@@ -222,6 +231,9 @@
222 RelativePath="..\screensaver.h"> 231 RelativePath="..\screensaver.h">
223 </File> 232 </File>
224 <File 233 <File
234 RelativePath="thread-win32.h">
235 </File>
236 <File
225 RelativePath="..\tree.h"> 237 RelativePath="..\tree.h">
226 </File> 238 </File>
227 <File 239 <File