Threading is working on uisw32 as well now, code is up-to-date, makefile is up-to-date

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@981 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Felix Arends 2002-06-12 15:39:39 +00:00
parent d0b23126f1
commit 0053ec0c72
11 changed files with 189 additions and 53 deletions

View file

@ -34,52 +34,58 @@ void button_init(void)
int button_get(bool block) int button_get(bool block)
{ {
int btn = 0; int btn = 0;
if (bActive) do
{ {
if (KEY (VK_NUMPAD4) || if (bActive)
KEY (VK_LEFT)) // left button {
btn |= BUTTON_LEFT; if (KEY (VK_NUMPAD4) ||
KEY (VK_LEFT)) // left button
btn |= BUTTON_LEFT;
if (KEY (VK_NUMPAD6) || if (KEY (VK_NUMPAD6) ||
KEY (VK_RIGHT)) KEY (VK_RIGHT))
btn |= BUTTON_RIGHT; // right button btn |= BUTTON_RIGHT; // right button
if (KEY (VK_NUMPAD8) || if (KEY (VK_NUMPAD8) ||
KEY (VK_UP)) KEY (VK_UP))
btn |= BUTTON_UP; // up button btn |= BUTTON_UP; // up button
if (KEY (VK_NUMPAD2) || if (KEY (VK_NUMPAD2) ||
KEY (VK_DOWN)) KEY (VK_DOWN))
btn |= BUTTON_DOWN; // down button btn |= BUTTON_DOWN; // down button
if (KEY (VK_ADD)) if (KEY (VK_ADD))
btn |= BUTTON_ON; // on button btn |= BUTTON_ON; // on button
#ifdef HAVE_RECORDER_KEYPAD #ifdef HAVE_RECORDER_KEYPAD
if (KEY (VK_RETURN)) if (KEY (VK_RETURN))
btn |= BUTTON_OFF; // off button btn |= BUTTON_OFF; // off button
if (KEY (VK_DIVIDE)) if (KEY (VK_DIVIDE))
btn |= BUTTON_F1; // F1 button btn |= BUTTON_F1; // F1 button
if (KEY (VK_MULTIPLY)) if (KEY (VK_MULTIPLY))
btn |= BUTTON_F2; // F2 button btn |= BUTTON_F2; // F2 button
if (KEY (VK_SUBTRACT)) if (KEY (VK_SUBTRACT))
btn |= BUTTON_F3; // F3 button btn |= BUTTON_F3; // F3 button
if (KEY (VK_NUMPAD5) || if (KEY (VK_NUMPAD5) ||
KEY (VK_SPACE)) KEY (VK_SPACE))
btn |= BUTTON_PLAY; // play button btn |= BUTTON_PLAY; // play button
#else #else
if (KEY (VK_RETURN)) if (KEY (VK_RETURN))
btn |= BUTTON_MENU; // menu button btn |= BUTTON_MENU; // menu button
#endif #endif
if (btn != 0) { if (btn != 0) {
last_key = 0 ; last_key = 0 ;
} }
}
} }
while (btn == 0 && block);
return btn; return btn;
} }

View file

@ -18,9 +18,17 @@
****************************************************************************/ ****************************************************************************/
#include <windows.h> #include <windows.h>
#include "uisw32.h"
#include "kernel.h" #include "kernel.h"
#include "thread-win32.h"
void sleep(int ticks) void sleep(int ticks)
{ {
Sleep (1000 / HZ * ticks); Sleep (1000 / HZ * ticks);
}
void yield (void)
{
PostThreadMessage (GetWindowThreadProcessId (hGUIWnd,NULL), TM_YIELD, 0, 0);
} }

View file

@ -40,13 +40,6 @@ BITMAPINFO2 bmi =
}; // bitmap information }; // bitmap information
// lcd_init
// init lcd controler
void lcd_init()
{
lcd_clear_display ();
}
// lcd_update // lcd_update
// update lcd // update lcd
void lcd_update() void lcd_update()

View file

@ -27,11 +27,11 @@ APPDIR = ../../apps/
RECDIR = $(APPDIR)recorder/ RECDIR = $(APPDIR)recorder/
RM = del RM = del
#DISPLAY = -DHAVE_LCD_CHARCELLS DISPLAY = -DHAVE_LCD_CHARCELLS
DISPLAY = -DHAVE_LCD_BITMAP #DISPLAY = -DHAVE_LCD_BITMAP
#KEYPAD = -DHAVE_PLAYER_KEYPAD KEYPAD = -DHAVE_PLAYER_KEYPAD
KEYPAD = -DHAVE_RECORDER_KEYPAD #KEYPAD = -DHAVE_RECORDER_KEYPAD
CC = cl CC = cl
DEFINES = -DWIN32 -DHAVE_CONFIG_H -DGETTIMEOFDAY_TWO_ARGS -DSIMULATOR \ DEFINES = -DWIN32 -DHAVE_CONFIG_H -DGETTIMEOFDAY_TWO_ARGS -DSIMULATOR \
@ -46,7 +46,7 @@ CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) /MD /Fd"Release/vc70.pdb"
SRCS = lcd-win32.c uisw32.c lcd.c button.c tree.c main.c \ SRCS = lcd-win32.c uisw32.c lcd.c button.c tree.c main.c \
chartables.c kernel.c uisw32.res dir-win32.c main_menu.c \ chartables.c kernel.c uisw32.res dir-win32.c main_menu.c \
play.c debug-win32.c menu.c credits.c sound_menu.c mpeg.c \ play.c debug-win32.c menu.c credits.c sound_menu.c mpeg.c \
id3.c settings.c sprintf.c id3.c settings.c sprintf.c thread-win32.c playlist.c
!IF ("$(DISPLAY)" == "-DHAVE_LCD_BITMAP") !IF ("$(DISPLAY)" == "-DHAVE_LCD_BITMAP")
SRCS = $(SRCS) tetris.c screensaver.c icons.c bmp.c SRCS = $(SRCS) tetris.c screensaver.c icons.c bmp.c
@ -105,5 +105,8 @@ settings.obj: $(FIRMWAREDIR)/settings.c
sprintf.obj: $(FIRMWAREDIR)/common/sprintf.c sprintf.obj: $(FIRMWAREDIR)/common/sprintf.c
$(CC) $(CFLAGS) -c $(FIRMWAREDIR)/common/sprintf.c -osprintf.obj $(CC) $(CFLAGS) -c $(FIRMWAREDIR)/common/sprintf.c -osprintf.obj
playlist.obj: ../../apps/playlist.c
$(CC) $(CFLAGS) -c ../../apps/playlist.c -oplaylist.obj
clean: clean:
$(RM) *.obj $(RM) *.obj

View file

@ -20,6 +20,8 @@
/* This file is for emulating some of the mpeg controlling functions of /* This file is for emulating some of the mpeg controlling functions of
the target */ the target */
#include "debug.h"
void mpeg_volume(void) void mpeg_volume(void)
{ {
} }
@ -35,3 +37,12 @@ void mpeg_treble(void)
void mpeg_stop(void) void mpeg_stop(void)
{ {
} }
#ifndef MPEGPLAY
void mpeg_play(char *tune)
{
DEBUGF("We instruct the MPEG thread to play %s for us\n",
tune);
}
#endif

View file

@ -0,0 +1,53 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Felix Arends
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include <windows.h>
#include "thread-win32.h"
HANDLE lpThreads[256];
int nThreads = 0,
nPos = 0;
DWORD WINAPI runthread (LPVOID lpParameter)
{
((void(*)())lpParameter) ();
return 0;
}
int create_thread(void* fp, void* sp, int stk_size)
{
DWORD dwThreadID;
if (nThreads == 256)
return -1;
lpThreads[nThreads++] = CreateThread (NULL,
0,
runthread,
fp,
0,
&dwThreadID);
return 0;
}
void init_threads(void)
{
}

View file

@ -0,0 +1,22 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Felix Arends
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
extern HANDLE lpThreads[256];
extern int nPos,
nThreads;

View file

@ -22,6 +22,8 @@
#include "uisw32.h" #include "uisw32.h"
#include "resource.h" #include "resource.h"
#include "button.h" #include "button.h"
#include "thread.h"
#include "thread-win32.h"
// extern functions // extern functions
extern void app_main (void *); // mod entry point extern void app_main (void *); // mod entry point
@ -32,6 +34,7 @@ HWND hGUIWnd; // the GUI window handle
unsigned int uThreadID; // id of mod thread unsigned int uThreadID; // id of mod thread
PBYTE lpKeys; PBYTE lpKeys;
bool bActive; // window active? bool bActive; // window active?
HANDLE hGUIThread; // thread for GUI
// GUIWndProc // GUIWndProc
// window proc for GUI simulator // window proc for GUI simulator
@ -186,6 +189,11 @@ LRESULT GUIWndProc (
hGUIWnd = NULL; hGUIWnd = NULL;
PostQuitMessage (0); PostQuitMessage (0);
break; break;
case WM_DESTROY:
// close simulator
hGUIWnd = NULL;
PostQuitMessage (0);
break;
} }
return DefWindowProc (hWnd, uMsg, wParam, lParam); return DefWindowProc (hWnd, uMsg, wParam, lParam);
@ -229,8 +237,16 @@ BOOL GUIStartup ()
// destroy window, unregister window class // destroy window, unregister window class
int GUIDown () int GUIDown ()
{ {
int i;
DestroyWindow (hGUIWnd); DestroyWindow (hGUIWnd);
_endthreadex (uThreadID); CloseHandle (hGUIThread);
for (i = 0; i < nThreads; i++)
{
ResumeThread (lpThreads[i]);
WaitForSingleObject (lpThreads[i], 1);
CloseHandle (lpThreads[i]);
}
return 0; return 0;
} }
@ -239,10 +255,17 @@ int GUIDown ()
void GUIMessageLoop () void GUIMessageLoop ()
{ {
MSG msg; MSG msg;
while (GetMessage (&msg, hGUIWnd, 0, 0) && hGUIWnd != NULL) while (GetMessage (&msg, NULL, 0, 0))
{ {
TranslateMessage (&msg); TranslateMessage (&msg);
DispatchMessage (&msg); DispatchMessage (&msg);
if (msg.message == TM_YIELD)
{
SuspendThread (lpThreads[nPos]);
if (++nPos >= nThreads)
nPos = 0;
ResumeThread (lpThreads[nPos]);
}
} }
} }
@ -256,12 +279,15 @@ int WINAPI WinMain (
int nShowCmd // show command int nShowCmd // show command
) )
{ {
DWORD dwThreadID;
if (!GUIStartup ()) if (!GUIStartup ())
return 0; return 0;
uThreadID = _beginthread (app_main, 0, NULL); hGUIThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)app_main,
if (uThreadID == -0L) NULL, 0, &dwThreadID);
return MessageBox (NULL, "Error creating mod thread!", "Error", MB_OK);
if (hGUIThread == NULL)
return MessageBox (NULL, "Error creating gui thread!", "Error", MB_OK);
GUIMessageLoop (); GUIMessageLoop ();

View file

@ -32,6 +32,8 @@
#define UI_LCD_POSX 59 // x position of lcd #define UI_LCD_POSX 59 // x position of lcd
#define UI_LCD_POSY 95 // y position of lcd #define UI_LCD_POSY 95 // y position of lcd
#define TM_YIELD WM_USER + 101 // thread message for yield
extern HWND hGUIWnd; // the GUI window handle extern HWND hGUIWnd; // the GUI window handle
extern unsigned int uThreadID; // id of mod thread extern unsigned int uThreadID; // id of mod thread
extern bool bActive; extern bool bActive;

Binary file not shown.

View file

@ -182,7 +182,10 @@
</FileConfiguration> </FileConfiguration>
</File> </File>
<File <File
RelativePath="..\..\firmware\playlist.c"> RelativePath="..\..\apps\playlist.c">
</File>
<File
RelativePath="..\..\apps\recorder\screensaver.c">
</File> </File>
<File <File
RelativePath="..\..\firmware\settings.c"> RelativePath="..\..\firmware\settings.c">
@ -193,6 +196,12 @@
<File <File
RelativePath="..\..\firmware\common\sprintf.c"> RelativePath="..\..\firmware\common\sprintf.c">
</File> </File>
<File
RelativePath="..\..\apps\recorder\tetris.c">
</File>
<File
RelativePath="thread-win32.c">
</File>
<File <File
RelativePath="..\..\apps\tree.c"> RelativePath="..\..\apps\tree.c">
</File> </File>
@ -221,6 +230,9 @@
<File <File
RelativePath="..\screensaver.h"> RelativePath="..\screensaver.h">
</File> </File>
<File
RelativePath="thread-win32.h">
</File>
<File <File
RelativePath="..\tree.h"> RelativePath="..\tree.h">
</File> </File>