summaryrefslogtreecommitdiff
path: root/uisimulator/win32
diff options
context:
space:
mode:
authorFelix Arends <edx@rockbox.org>2002-04-27 17:02:17 +0000
committerFelix Arends <edx@rockbox.org>2002-04-27 17:02:17 +0000
commitffb9e3a5bd1d9472b0cea2d9fba560ea0c58e58e (patch)
tree4c15d6a4d0878ef7f489506a0c9032f320df7cdf /uisimulator/win32
parenta6ca085a35fc2b1739fc8d1e6cf064b45279e8ee (diff)
downloadrockbox-ffb9e3a5bd1d9472b0cea2d9fba560ea0c58e58e.tar.gz
rockbox-ffb9e3a5bd1d9472b0cea2d9fba560ea0c58e58e.zip
renamed cpp extensions to c, started coding file functions
file functions not working yet git-svn-id: svn://svn.rockbox.org/rockbox/trunk@262 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/win32')
-rw-r--r--uisimulator/win32/lcd-win32.c24
-rw-r--r--uisimulator/win32/lcd-win32.h2
-rw-r--r--uisimulator/win32/main.cpp29
-rw-r--r--uisimulator/win32/uisw32.cpp260
-rw-r--r--uisimulator/win32/uisw32.h3
-rw-r--r--uisimulator/win32/uisw32.suobin10752 -> 10240 bytes
-rw-r--r--uisimulator/win32/uisw32.vcproj26
7 files changed, 35 insertions, 309 deletions
diff --git a/uisimulator/win32/lcd-win32.c b/uisimulator/win32/lcd-win32.c
index 4539696cef..2330d444c5 100644
--- a/uisimulator/win32/lcd-win32.c
+++ b/uisimulator/win32/lcd-win32.c
@@ -28,14 +28,14 @@
28 28
29// varaibles 29// varaibles
30unsigned char display[LCD_WIDTH][LCD_HEIGHT/8]; // the display 30unsigned char display[LCD_WIDTH][LCD_HEIGHT/8]; // the display
31char bitmap[LCD_WIDTH][LCD_HEIGHT]; // the ui display 31char bitmap[LCD_HEIGHT][LCD_WIDTH]; // the ui display
32 32
33BITMAPINFO2 bmi = 33BITMAPINFO2 bmi =
34{ 34{
35 sizeof (BITMAPINFOHEADER), 35 sizeof (BITMAPINFOHEADER),
36 LCD_WIDTH, -LCD_HEIGHT, 1, 8, 36 LCD_WIDTH, -LCD_HEIGHT, 1, 8,
37 BI_RGB, 0, 0, 0, 2, 2, 37 BI_RGB, 0, 0, 0, 2, 2,
38 UI_LCD_COLOR, 0, // green background color 38 UI_LCD_BGCOLOR, 0, // green background color
39 UI_LCD_BLACK, 0 // black color 39 UI_LCD_BLACK, 0 // black color
40}; // bitmap information 40}; // bitmap information
41 41
@@ -63,4 +63,24 @@ void lcd_update()
63 63
64 // natural sleep :) 64 // natural sleep :)
65 Sleep (50); 65 Sleep (50);
66}
67
68// lcd_backlight
69// set backlight state of lcd
70void lcd_backlight (
71 bool on // switch backlight on or off?
72 )
73{
74 if (on)
75 {
76 RGBQUAD blon = {UI_LCD_BGCOLORLIGHT, 0};
77 bmi.bmiColors[0] = blon;
78 }
79 else
80 {
81 RGBQUAD blon = {UI_LCD_BGCOLOR, 0};
82 bmi.bmiColors[0] = blon;
83 }
84
85 InvalidateRect (hGUIWnd, NULL, FALSE);
66} \ No newline at end of file 86} \ No newline at end of file
diff --git a/uisimulator/win32/lcd-win32.h b/uisimulator/win32/lcd-win32.h
index e4b1e3bd8e..1836e40b02 100644
--- a/uisimulator/win32/lcd-win32.h
+++ b/uisimulator/win32/lcd-win32.h
@@ -39,7 +39,7 @@ extern unsigned char display[LCD_WIDTH][LCD_HEIGHT/8]; // the display
39#endif 39#endif
40 40
41 41
42extern char bitmap[LCD_WIDTH][LCD_HEIGHT]; // the ui display 42extern char bitmap[LCD_HEIGHT][LCD_WIDTH]; // the ui display
43extern BITMAPINFO2 bmi; // bitmap information 43extern BITMAPINFO2 bmi; // bitmap information
44 44
45 45
diff --git a/uisimulator/win32/main.cpp b/uisimulator/win32/main.cpp
deleted file mode 100644
index 7c3c66f967..0000000000
--- a/uisimulator/win32/main.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
1#include "uisw32.h"
2#include "lcd-win32.h"
3
4#define FS 6
5
6int main (void)
7{
8 int x;
9 lcd_init ();
10
11 while (1)
12 {
13 for (x = 0; x < 10; x++)
14 {
15 lcd_clear_display ();
16 lcd_position (x, 12, FS);
17 lcd_string ("Hello World!");
18 lcd_position (x, 32, FS);
19 lcd_string ("From the");
20 lcd_position (x, 40, FS);
21 lcd_string (" Open Source ");
22 lcd_position (x, 48, FS);
23 lcd_string ("Jukebox Project");
24 lcd_update ();
25 }
26 }
27
28 return 0;
29} \ No newline at end of file
diff --git a/uisimulator/win32/uisw32.cpp b/uisimulator/win32/uisw32.cpp
deleted file mode 100644
index 529ecbfb4e..0000000000
--- a/uisimulator/win32/uisw32.cpp
+++ /dev/null
@@ -1,260 +0,0 @@
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 <process.h>
22#include "uisw32.h"
23#include "resource.h"
24
25// extern functions
26extern void main (void *); // mod entry point
27
28// variables
29HWND hGUIWnd; // the GUI window handle
30unsigned int uThreadID; // id of mod thread
31PBYTE lpKeys;
32
33// GUIWndProc
34// window proc for GUI simulator
35LRESULT GUIWndProc (
36 HWND hWnd,
37 UINT uMsg,
38 WPARAM wParam,
39 LPARAM lParam
40 )
41{
42 static HBITMAP hBkgnd;
43 static lpBmp [UI_WIDTH * UI_HEIGHT * 3];
44 static HDC hMemDc;
45
46 switch (uMsg)
47 {
48 case WM_CREATE:
49 // load background image
50 hBkgnd = (HBITMAP)LoadImage (GetModuleHandle (NULL), MAKEINTRESOURCE(IDB_UI),
51 IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
52 hMemDc = CreateCompatibleDC (GetDC (hWnd));
53 SelectObject (hMemDc, hBkgnd);
54 return TRUE;
55 case WM_SIZING:
56 {
57 LPRECT r = (LPRECT)lParam;
58 RECT r2;
59 char s[256];
60 int v;
61
62 switch (wParam)
63 {
64 case WMSZ_BOTTOM:
65 v = (r->bottom - r->top) / (UI_HEIGHT / 5);
66 r->bottom = r->top + v * UI_HEIGHT / 5;
67 r->right = r->left + v * UI_WIDTH / 5;
68 r->right += GetSystemMetrics (SM_CXSIZEFRAME) * 2;
69 r->bottom += GetSystemMetrics (SM_CYSIZEFRAME) * 2 + GetSystemMetrics (SM_CYSMCAPTION);
70 break;
71 case WMSZ_RIGHT:
72 v = (r->right - r->left) / (UI_WIDTH / 5);
73 r->bottom = r->top + v * UI_HEIGHT / 5;
74 r->right = r->left + v * UI_WIDTH / 5;
75 r->right += GetSystemMetrics (SM_CXSIZEFRAME) * 2;
76 r->bottom += GetSystemMetrics (SM_CYSIZEFRAME) * 2 + GetSystemMetrics (SM_CYSMCAPTION);
77 break;
78 case WMSZ_TOP:
79 v = (r->bottom - r->top) / (UI_HEIGHT / 5);
80 r->top = r->bottom - v * UI_HEIGHT / 5;
81 r->right = r->left + v * UI_WIDTH / 5;
82 r->right += GetSystemMetrics (SM_CXSIZEFRAME) * 2;
83 r->top -= GetSystemMetrics (SM_CYSIZEFRAME) * 2 + GetSystemMetrics (SM_CYSMCAPTION);
84 break;
85 case WMSZ_LEFT:
86 v = (r->right - r->left) / (UI_WIDTH / 5);
87 r->bottom = r->top + v * UI_HEIGHT / 5;
88 r->left = r->right - v * UI_WIDTH / 5;
89 r->left -= GetSystemMetrics (SM_CXSIZEFRAME) * 2;
90 r->bottom += GetSystemMetrics (SM_CYSIZEFRAME) * 2 + GetSystemMetrics (SM_CYSMCAPTION);
91 break;
92 case WMSZ_BOTTOMRIGHT:
93 GetWindowRect (hWnd, &r2);
94 if (abs(r2.right - r->right) > abs(r2.bottom - r->bottom))
95 v = (r->right - r->left) / (UI_WIDTH / 5);
96 else
97 v = (r->bottom - r->top) / (UI_HEIGHT / 5);
98 r->bottom = r->top + v * UI_HEIGHT / 5;
99 r->right = r->left + v * UI_WIDTH / 5;
100 r->right += GetSystemMetrics (SM_CXSIZEFRAME) * 2;
101 r->bottom += GetSystemMetrics (SM_CYSIZEFRAME) * 2 + GetSystemMetrics (SM_CYSMCAPTION);
102 break;
103 case WMSZ_BOTTOMLEFT:
104 GetWindowRect (hWnd, &r2);
105 if (abs(r2.left - r->left) > abs(r2.bottom - r->bottom))
106 v = (r->right - r->left) / (UI_WIDTH / 5);
107 else
108 v = (r->bottom - r->top) / (UI_HEIGHT / 5);
109 r->bottom = r->top + v * UI_HEIGHT / 5;
110 r->left = r->right - v * UI_WIDTH / 5;
111 r->left -= GetSystemMetrics (SM_CXSIZEFRAME) * 2;
112 r->bottom += GetSystemMetrics (SM_CYSIZEFRAME) * 2 + GetSystemMetrics (SM_CYSMCAPTION);
113 break;
114 case WMSZ_TOPRIGHT:
115 GetWindowRect (hWnd, &r2);
116 if (abs(r2.right - r->right) > abs(r2.top - r->top))
117 v = (r->right - r->left) / (UI_WIDTH / 5);
118 else
119 v = (r->bottom - r->top) / (UI_HEIGHT / 5);
120 r->top = r->bottom - v * UI_HEIGHT / 5;
121 r->right = r->left + v * UI_WIDTH / 5;
122 r->right += GetSystemMetrics (SM_CXSIZEFRAME) * 2;
123 r->top -= GetSystemMetrics (SM_CYSIZEFRAME) * 2 + GetSystemMetrics (SM_CYSMCAPTION);
124 break;
125 case WMSZ_TOPLEFT:
126 GetWindowRect (hWnd, &r2);
127 if (abs(r2.left - r->left) > abs(r2.top - r->top))
128 v = (r->right - r->left) / (UI_WIDTH / 5);
129 else
130 v = (r->bottom - r->top) / (UI_HEIGHT / 5);
131 r->top = r->bottom - v * UI_HEIGHT / 5;
132 r->left = r->right - v * UI_WIDTH / 5;
133 r->left -= GetSystemMetrics (SM_CXSIZEFRAME) * 2;
134 r->top -= GetSystemMetrics (SM_CYSIZEFRAME) * 2 + GetSystemMetrics (SM_CYSMCAPTION);
135 break;
136 }
137
138 wsprintf (s, "RockBox Simulator @%d%%",
139 (r->right - r->left - GetSystemMetrics (SM_CXSIZEFRAME) * 2)
140 * 100 / UI_WIDTH);
141 SetWindowText (hWnd, s);
142
143 return TRUE;
144 }
145 case WM_ERASEBKGND:
146 {
147 PAINTSTRUCT ps;
148 HDC hDc = BeginPaint (hWnd, &ps);
149 RECT r;
150
151 GetClientRect (hWnd, &r);
152 // blit to screen
153 StretchBlt (hDc, 0, 0, r.right, r.bottom,
154 hMemDc, 0, 0, UI_WIDTH, UI_HEIGHT, SRCCOPY);
155 EndPaint (hWnd, &ps);
156 return TRUE;
157 }
158 case WM_PAINT:
159 {
160 PAINTSTRUCT ps;
161 RECT r;
162 HDC hDc = BeginPaint (hWnd, &ps);
163
164 GetClientRect (hWnd, &r);
165 // draw lcd screen
166 StretchDIBits (hDc,
167 UI_LCD_POSX * r.right / UI_WIDTH, UI_LCD_POSY * r.bottom / UI_HEIGHT,
168 LCD_WIDTH * r.right / UI_WIDTH, LCD_HEIGHT * r.bottom / UI_HEIGHT,
169 0, 0, LCD_WIDTH, LCD_HEIGHT,
170 bitmap, (BITMAPINFO *) &bmi, DIB_RGB_COLORS, SRCCOPY);
171
172 EndPaint (hWnd, &ps);
173 return TRUE;
174 }
175 case WM_CLOSE:
176 // close simulator
177 hGUIWnd = NULL;
178 PostQuitMessage (0);
179 break;
180 }
181
182 return DefWindowProc (hWnd, uMsg, wParam, lParam);
183}
184
185// GUIStartup
186// register window class, show window, init GUI
187BOOL GUIStartup ()
188{
189 WNDCLASS wc;
190
191 // create window class
192 ZeroMemory (&wc, sizeof(wc));
193 wc.hbrBackground = GetSysColorBrush (COLOR_WINDOW);
194 wc.hCursor = LoadCursor (NULL, IDC_ARROW);
195 wc.hInstance = GetModuleHandle (NULL);
196 wc.lpfnWndProc = (WNDPROC)GUIWndProc;
197 wc.lpszClassName = "RockBoxUISimulator";
198 wc.style = CS_HREDRAW | CS_VREDRAW;
199
200 if (RegisterClass (&wc) == 0)
201 return FALSE;
202
203 // create window
204 hGUIWnd = CreateWindowEx (
205 WS_EX_TOOLWINDOW | WS_EX_PALETTEWINDOW,
206 "RockBoxUISimulator", "ARCHOS JukeBox",
207 WS_VISIBLE | WS_SYSMENU | WS_OVERLAPPEDWINDOW,
208 CW_USEDEFAULT, CW_USEDEFAULT,
209 UI_WIDTH + GetSystemMetrics (SM_CXSIZEFRAME) * 2,
210 UI_HEIGHT + GetSystemMetrics (SM_CYSIZEFRAME) * 2 + GetSystemMetrics (SM_CYSMCAPTION),
211 NULL, NULL, GetModuleHandle (NULL), NULL);
212
213 if (hGUIWnd == NULL)
214 return FALSE;
215
216 return TRUE;
217}
218
219// GUIDown
220// destroy window, unregister window class
221int GUIDown ()
222{
223 DestroyWindow (hGUIWnd);
224 _endthreadex (uThreadID);
225 return 0;
226}
227
228// GUIMessageLoop
229// standard message loop for GUI window
230void GUIMessageLoop ()
231{
232 MSG msg;
233 while (GetMessage (&msg, hGUIWnd, 0, 0) && hGUIWnd != NULL)
234 {
235 TranslateMessage (&msg);
236 DispatchMessage (&msg);
237 }
238}
239
240
241// WinMain
242// program entry point
243int WINAPI WinMain (
244 HINSTANCE hInstance, // current instance
245 HINSTANCE hPrevInstance, // previous instance
246 LPSTR lpCmd, // command line
247 int nShowCmd // show command
248 )
249{
250 if (!GUIStartup ())
251 return 0;
252
253 uThreadID = _beginthread (main, 0, NULL);
254 if (uThreadID == -0L)
255 return MessageBox (NULL, "Error creating mod thread!", "Error", MB_OK);
256
257 GUIMessageLoop ();
258
259 return GUIDown ();
260} \ No newline at end of file
diff --git a/uisimulator/win32/uisw32.h b/uisimulator/win32/uisw32.h
index d168c8955e..162d925aca 100644
--- a/uisimulator/win32/uisw32.h
+++ b/uisimulator/win32/uisw32.h
@@ -25,7 +25,8 @@
25 25
26#define UI_WIDTH 240 // width of GUI window 26#define UI_WIDTH 240 // width of GUI window
27#define UI_HEIGHT 360 // height of GUI window 27#define UI_HEIGHT 360 // height of GUI window
28#define UI_LCD_COLOR 46, 67, 49 // bkgnd color of LCD 28#define UI_LCD_BGCOLOR 46, 67, 49 // bkgnd color of LCD (no backlight)
29#define UI_LCD_BGCOLORLIGHT 56, 77, 59 // bkgnd color of LCD (backlight)
29#define UI_LCD_BLACK 0, 0, 0 // black 30#define UI_LCD_BLACK 0, 0, 0 // black
30#define UI_LCD_POSX 59 // x position of lcd 31#define UI_LCD_POSX 59 // x position of lcd
31#define UI_LCD_POSY 95 // y position of lcd 32#define UI_LCD_POSY 95 // y position of lcd
diff --git a/uisimulator/win32/uisw32.suo b/uisimulator/win32/uisw32.suo
index 070ca781b2..31b4d3d464 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 afc181d417..cde446b6ad 100644
--- a/uisimulator/win32/uisw32.vcproj
+++ b/uisimulator/win32/uisw32.vcproj
@@ -65,8 +65,8 @@
65 Optimization="2" 65 Optimization="2"
66 InlineFunctionExpansion="1" 66 InlineFunctionExpansion="1"
67 OmitFramePointers="TRUE" 67 OmitFramePointers="TRUE"
68 AdditionalIncludeDirectories="&quot;C:\Programming\CVS Checkout\RockBox\firmware\drivers&quot;;&quot;C:\Programming\CVS Checkout\RockBox\firmware&quot;" 68 AdditionalIncludeDirectories="&quot;C:\Programming\CVS Checkout\RockBox\firmware\drivers&quot;;&quot;C:\Programming\CVS Checkout\RockBox\firmware&quot;;&quot;C:\Programming\CVS Checkout\RockBox\firmware\common&quot;"
69 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;ARCHOS_RECORDER;SIMULATOR" 69 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;ARCHOS_RECORDER;SIMULATOR;WIN32"
70 StringPooling="TRUE" 70 StringPooling="TRUE"
71 RuntimeLibrary="0" 71 RuntimeLibrary="0"
72 EnableFunctionLevelLinking="TRUE" 72 EnableFunctionLevelLinking="TRUE"
@@ -113,6 +113,9 @@
113 RelativePath="..\..\firmware\chartables.c"> 113 RelativePath="..\..\firmware\chartables.c">
114 </File> 114 </File>
115 <File 115 <File
116 RelativePath="file-win32.c">
117 </File>
118 <File
116 RelativePath="kernel.c"> 119 RelativePath="kernel.c">
117 </File> 120 </File>
118 <File 121 <File
@@ -120,30 +123,21 @@
120 </File> 123 </File>
121 <File 124 <File
122 RelativePath="..\..\firmware\drivers\lcd.c"> 125 RelativePath="..\..\firmware\drivers\lcd.c">
123 <FileConfiguration
124 Name="Debug|Win32">
125 <Tool
126 Name="VCCLCompilerTool"
127 ObjectFile="$(IntDir)/$(InputName)1.obj"/>
128 </FileConfiguration>
129 <FileConfiguration
130 Name="Release|Win32">
131 <Tool
132 Name="VCCLCompilerTool"
133 ObjectFile="$(IntDir)/$(InputName)1.obj"/>
134 </FileConfiguration>
135 </File> 126 </File>
136 <File 127 <File
137 RelativePath="tetris.c"> 128 RelativePath="main.c">
138 </File> 129 </File>
139 <File 130 <File
140 RelativePath="uisw32.cpp"> 131 RelativePath="uisw32.c">
141 </File> 132 </File>
142 </Filter> 133 </Filter>
143 <Filter 134 <Filter
144 Name="Header Files" 135 Name="Header Files"
145 Filter="h;hpp;hxx;hm;inl;inc"> 136 Filter="h;hpp;hxx;hm;inl;inc">
146 <File 137 <File
138 RelativePath="file-win32.h">
139 </File>
140 <File
147 RelativePath="lcd-win32.h"> 141 RelativePath="lcd-win32.h">
148 </File> 142 </File>
149 <File 143 <File