main.c revision 1.51 1 1.51 takemura /* $NetBSD: main.c,v 1.51 2001/02/25 12:58:38 takemura Exp $ */
2 1.21 takemura
3 1.21 takemura /*-
4 1.41 takemura * Copyright (c) 1999, 2000 Shin Takemura.
5 1.21 takemura * All rights reserved.
6 1.21 takemura *
7 1.21 takemura * This software is part of the PocketBSD.
8 1.21 takemura *
9 1.21 takemura * Redistribution and use in source and binary forms, with or without
10 1.21 takemura * modification, are permitted provided that the following conditions
11 1.21 takemura * are met:
12 1.21 takemura * 1. Redistributions of source code must retain the above copyright
13 1.21 takemura * notice, this list of conditions and the following disclaimer.
14 1.21 takemura * 2. Redistributions in binary form must reproduce the above copyright
15 1.21 takemura * notice, this list of conditions and the following disclaimer in the
16 1.21 takemura * documentation and/or other materials provided with the distribution.
17 1.21 takemura * 3. All advertising materials mentioning features or use of this software
18 1.21 takemura * must display the following acknowledgement:
19 1.21 takemura * This product includes software developed by the PocketBSD project
20 1.21 takemura * and its contributors.
21 1.21 takemura * 4. Neither the name of the project nor the names of its contributors
22 1.21 takemura * may be used to endorse or promote products derived from this software
23 1.21 takemura * without specific prior written permission.
24 1.21 takemura *
25 1.21 takemura * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 1.21 takemura * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 1.21 takemura * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 1.21 takemura * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 1.21 takemura * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 1.21 takemura * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 1.21 takemura * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 1.21 takemura * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 1.21 takemura * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 1.21 takemura * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 1.21 takemura * SUCH DAMAGE.
36 1.21 takemura *
37 1.21 takemura */
38 1.21 takemura #include <pbsdboot.h>
39 1.21 takemura #include <commctrl.h>
40 1.21 takemura #include <res/resource.h>
41 1.21 takemura
42 1.33 takemura /*
43 1.33 takemura * If you modify this program and update pbsdboot.uu,
44 1.33 takemura * change version string which is coded in main.c
45 1.33 takemura * appropriately.
46 1.33 takemura *
47 1.33 takemura * The version string is in format:
48 1.33 takemura *
49 1.33 takemura * Version A.B.C YYYY.MM.DD
50 1.33 takemura *
51 1.33 takemura * in where:
52 1.33 takemura *
53 1.33 takemura * A: Don't change this.
54 1.33 takemura * B: Increment this number if you change program's behavior,
55 1.33 takemura * fix some bugs or add new features.
56 1.33 takemura * C: Increment this number if you change/add some
57 1.33 takemura * parameters, constants, windows' resources.
58 1.33 takemura * YYYY.MM.DD: date
59 1.33 takemura */
60 1.33 takemura TCHAR *version_string =
61 1.33 takemura TEXT("PocketBSD boot loader\r\n")
62 1.51 takemura TEXT("Version 1.17.1 2001.02.25\r\n")
63 1.33 takemura #if ( _WIN32_WCE < 200 )
64 1.33 takemura TEXT("Compiled for WinCE 1.01\r\n")
65 1.33 takemura #else
66 1.33 takemura TEXT("Compiled for WinCE 2.00\r\n")
67 1.33 takemura #endif
68 1.33 takemura TEXT("\r\n")
69 1.33 takemura TEXT("Copyright(C) 1999 Shin Takemura,\r\n")
70 1.33 takemura TEXT("All rights reserved.\r\n")
71 1.33 takemura TEXT("\r\n")
72 1.33 takemura TEXT("http://www.netbsd.org/Ports/hpcmips\r\n");
73 1.33 takemura
74 1.21 takemura /*-----------------------------------------------------------------------------
75 1.21 takemura
76 1.21 takemura type difinitions
77 1.21 takemura
78 1.21 takemura -----------------------------------------------------------------------------*/
79 1.21 takemura enum {
80 1.21 takemura UPDATE_DLGBOX,
81 1.21 takemura UPDATE_DATA,
82 1.21 takemura };
83 1.21 takemura
84 1.21 takemura struct fb_type {
85 1.21 takemura int type;
86 1.21 takemura TCHAR *name;
87 1.21 takemura };
88 1.21 takemura
89 1.44 takemura
90 1.44 takemura
91 1.21 takemura struct fb_setting {
92 1.21 takemura TCHAR *name;
93 1.21 takemura int type;
94 1.21 takemura int width, height, linebytes;
95 1.21 takemura long addr;
96 1.21 takemura unsigned long platid_cpu, platid_machine;
97 1.21 takemura };
98 1.21 takemura
99 1.21 takemura /*-----------------------------------------------------------------------------
100 1.21 takemura
101 1.21 takemura variable declarations
102 1.21 takemura
103 1.21 takemura -----------------------------------------------------------------------------*/
104 1.21 takemura HINSTANCE hInst = NULL;
105 1.44 takemura HWND hDlgMain;
106 1.45 takemura HWND hBack;
107 1.21 takemura HWND hWndCB = NULL;
108 1.21 takemura HWND hDlgLoad = NULL;
109 1.21 takemura unsigned int dlgStatus;
110 1.21 takemura int user_define_idx;
111 1.39 takemura int osversion;
112 1.44 takemura BOOL booting = FALSE;
113 1.44 takemura int how_long_to_boot = -1;
114 1.21 takemura
115 1.21 takemura /*-----------------------------------------------------------------------------
116 1.21 takemura
117 1.21 takemura data
118 1.21 takemura
119 1.21 takemura -----------------------------------------------------------------------------*/
120 1.21 takemura TCHAR szAppName[ ] = TEXT("PocketBSD boot");
121 1.21 takemura TCHAR szTitle[ ] = TEXT("Welcome to PocketBSD!");
122 1.48 takemura int errno;
123 1.21 takemura
124 1.33 takemura /*
125 1.33 takemura * Wince_conf identify executable binary file.
126 1.33 takemura */
127 1.33 takemura #if ( _WIN32_WCE < 200 )
128 1.33 takemura static char *wince_conf = "Compiled for WinCE 1.01";
129 1.33 takemura #else
130 1.33 takemura static char *wince_conf = "Compiled for WinCE 2.00";
131 1.33 takemura #endif
132 1.33 takemura
133 1.44 takemura #define IDD_TIMER 300
134 1.44 takemura
135 1.21 takemura struct fb_type fb_types[] = {
136 1.21 takemura { BIFB_D2_M2L_3, TEXT(BIFBN_D2_M2L_3) },
137 1.21 takemura { BIFB_D2_M2L_3x2, TEXT(BIFBN_D2_M2L_3x2) },
138 1.21 takemura { BIFB_D2_M2L_0, TEXT(BIFBN_D2_M2L_0) },
139 1.50 takemura { BIFB_D2_M2L_0x2, TEXT(BIFBN_D2_M2L_0x2) },
140 1.50 takemura { BIFB_D4_M2L_F, TEXT(BIFBN_D4_M2L_F) },
141 1.50 takemura { BIFB_D4_M2L_Fx2, TEXT(BIFBN_D4_M2L_Fx2) },
142 1.50 takemura { BIFB_D4_M2L_0, TEXT(BIFBN_D4_M2L_0) },
143 1.50 takemura { BIFB_D4_M2L_0x2, TEXT(BIFBN_D4_M2L_0x2) },
144 1.21 takemura { BIFB_D8_00, TEXT(BIFBN_D8_00) },
145 1.21 takemura { BIFB_D8_FF, TEXT(BIFBN_D8_FF) },
146 1.21 takemura { BIFB_D16_0000, TEXT(BIFBN_D16_0000) },
147 1.21 takemura { BIFB_D16_FFFF, TEXT(BIFBN_D16_FFFF) },
148 1.21 takemura };
149 1.21 takemura
150 1.21 takemura int fb_size[] = {
151 1.21 takemura 160, 240, 320, 400, 480, 600, 640,
152 1.21 takemura 768, 800, 1024, 1150, 1280, 1600
153 1.21 takemura };
154 1.21 takemura
155 1.44 takemura int boot_times[] = {
156 1.44 takemura 30,25,20,15,10,5
157 1.44 takemura };
158 1.44 takemura
159 1.21 takemura int fb_bpl[] = {
160 1.21 takemura 40, 80, 128, 160, 240, 256, 320,
161 1.21 takemura 384, 400, 480, 512, 600, 640, 768, 800, 1024, 1150, 1280, 1600
162 1.21 takemura };
163 1.21 takemura
164 1.21 takemura struct fb_setting fb_settings[] = {
165 1.25 takemura /*
166 1.25 takemura * You must choose fb_type to make the screen look black-on-white.
167 1.25 takemura * (Foreground color is black and background color is white.)
168 1.25 takemura */
169 1.21 takemura { NULL, BIFB_D2_M2L_3,
170 1.21 takemura 320, 240, 80, 0xa000000,
171 1.21 takemura PLATID_UNKNOWN, PLATID_UNKNOWN },
172 1.21 takemura { TEXT("FreeStyle"), BIFB_D2_M2L_3,
173 1.21 takemura 320, 240, 80, 0xa000000,
174 1.21 takemura PLATID_CPU_MIPS_VR_41XX, PLATID_MACH_EVEREX_FREESTYLE_AXX },
175 1.21 takemura { TEXT("FreeStyle(Small Font)"), BIFB_D2_M2L_3x2,
176 1.21 takemura 640, 240, 80, 0xa000000,
177 1.21 takemura PLATID_CPU_MIPS_VR_41XX, PLATID_MACH_EVEREX_FREESTYLE_AXX },
178 1.30 takemura { TEXT("MobileGear MC-CS11"), BIFB_D2_M2L_0,
179 1.21 takemura 480, 240, 256, 0xa000000,
180 1.30 takemura PLATID_CPU_MIPS_VR_4102, PLATID_MACH_NEC_MCCS_11 },
181 1.30 takemura { TEXT("MobileGear MC-CS12"), BIFB_D2_M2L_0,
182 1.30 takemura 480, 240, 256, 0xa000000,
183 1.30 takemura PLATID_CPU_MIPS_VR_4102, PLATID_MACH_NEC_MCCS_12 },
184 1.30 takemura { TEXT("MobileGear MC-CS13"), BIFB_D2_M2L_0,
185 1.30 takemura 480, 240, 256, 0xa000000,
186 1.30 takemura PLATID_CPU_MIPS_VR_4102, PLATID_MACH_NEC_MCCS_13 },
187 1.35 jun { TEXT("Mobile Pro 700"), BIFB_D2_M2L_0,
188 1.35 jun 640, 240, 256, 0xa000000,
189 1.35 jun PLATID_CPU_MIPS_VR_4102, PLATID_MACH_NEC_MCR_MPRO700 },
190 1.21 takemura { TEXT("MobileGearII MC-R300"), BIFB_D2_M2L_0,
191 1.21 takemura 640, 240, 256, 0xa000000,
192 1.21 takemura PLATID_CPU_MIPS_VR_4111, PLATID_MACH_NEC_MCR_300 },
193 1.21 takemura { TEXT("MobileGearII for DoCoMo"), BIFB_D2_M2L_0,
194 1.21 takemura 640, 240, 256, 0xa000000,
195 1.21 takemura PLATID_CPU_MIPS_VR_4111, PLATID_MACH_NEC_MCR_FORDOCOMO },
196 1.21 takemura { TEXT("MobileGearII MC-R320"), BIFB_D2_M2L_0,
197 1.21 takemura 640, 240, 160, 0xa000000,
198 1.21 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_320 },
199 1.46 sato { TEXT("MobileGearII MC/R330"), BIFB_D2_M2L_0,
200 1.46 sato 640, 240, 160, 0xa000000,
201 1.46 sato PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_330 },
202 1.25 takemura { TEXT("MobileGearII MC/R430"), BIFB_D16_0000,
203 1.23 takemura 640, 240, 1280, 0xa180100,
204 1.23 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_430 },
205 1.25 takemura { TEXT("MobileGearII MC-R500"), BIFB_D8_00,
206 1.21 takemura 640, 240, 1024, 0x13000000,
207 1.21 takemura PLATID_CPU_MIPS_VR_4111, PLATID_MACH_NEC_MCR_500 },
208 1.25 takemura { TEXT("Mobile Pro 750c"), BIFB_D8_00,
209 1.21 takemura 640, 240, 1024, 0x13000000,
210 1.21 takemura PLATID_CPU_MIPS_VR_4111, PLATID_MACH_NEC_MCR_500A },
211 1.21 takemura { TEXT("MobileGearII MC-R510"), BIFB_D8_00,
212 1.21 takemura 640, 240, 1024, 0xa000000,
213 1.21 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_510 },
214 1.21 takemura { TEXT("NEC MC-R510(15bit color)"), BIFB_D16_0000,
215 1.21 takemura 640, 240, 1600, 0xa000000,
216 1.21 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_510 },
217 1.21 takemura { TEXT("MobileGearII MC-R520"), BIFB_D16_0000,
218 1.21 takemura 640, 240, 1600, 0xa000000,
219 1.21 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_520 },
220 1.40 takemura { TEXT("NEC MC/R530(256 colors)"), BIFB_D8_00,
221 1.40 takemura 640, 240, 640, 0xa1d4c00,
222 1.40 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_530 },
223 1.25 takemura { TEXT("MobileGearII MC/R530"), BIFB_D16_0000,
224 1.21 takemura 640, 240, 1280, 0xa180100,
225 1.21 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_530 },
226 1.46 sato { TEXT("DoCoMo sigmarion"), BIFB_D16_0000,
227 1.46 sato 640, 240, 1280, 0xa000000,
228 1.46 sato PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_SIGMARION },
229 1.21 takemura { TEXT("Mobile Pro 770"), BIFB_D16_0000,
230 1.21 takemura 640, 240, 1600, 0xa000000,
231 1.21 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_520A },
232 1.41 takemura { TEXT("Mobile Pro 780"), BIFB_D16_0000,
233 1.41 takemura 640, 240, 1280, 0xa180100,
234 1.41 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_530A },
235 1.21 takemura { TEXT("MobileGearII MC-R700"), BIFB_D16_0000,
236 1.21 takemura 800, 600, 1600, 0xa000000,
237 1.21 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_700 },
238 1.21 takemura { TEXT("Mobile Pro 800"), BIFB_D16_0000,
239 1.21 takemura 800, 600, 1600, 0xa000000,
240 1.21 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_700A },
241 1.24 shin { TEXT("MobileGearII MC/R730"), BIFB_D16_0000,
242 1.24 shin 800, 600, 1600, 0xa0ea600,
243 1.24 shin PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_730 },
244 1.41 takemura { TEXT("Mobile Pro 880"), BIFB_D16_0000,
245 1.41 takemura 800, 600, 1600, 0xa0ea600,
246 1.41 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_730A },
247 1.32 shin { TEXT("Tripad PV-6000"), BIFB_D8_00,
248 1.21 takemura 640, 480, 640, 0xa000000,
249 1.21 takemura PLATID_CPU_MIPS_VR_4111, PLATID_MACH_SHARP_TRIPAD_PV6000 },
250 1.41 takemura { TEXT("Vadem Clio C-1000"), BIFB_D8_00,
251 1.21 takemura 640, 480, 640, 0xa000000,
252 1.21 takemura PLATID_CPU_MIPS_VR_4111, PLATID_MACH_SHARP_TRIPAD_PV6000 },
253 1.41 takemura { TEXT("Vadem Clio C-1050"), BIFB_D16_FFFF,
254 1.41 takemura 640, 480, 1280, 0xa200000,
255 1.41 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_SHARP_TRIPAD_PV6000 },
256 1.21 takemura { TEXT("E-55"), BIFB_D2_M2L_0,
257 1.21 takemura 240, 320, 256, 0xa000000,
258 1.21 takemura PLATID_CPU_MIPS_VR_4111, PLATID_MACH_CASIO_CASSIOPEIAE_E55 },
259 1.21 takemura { TEXT("E-55(Small Font)"), BIFB_D2_M2L_0x2,
260 1.21 takemura 480, 320, 256, 0xa000000,
261 1.21 takemura PLATID_CPU_MIPS_VR_4111, PLATID_MACH_CASIO_CASSIOPEIAE_E55 },
262 1.21 takemura { TEXT("E-100"), BIFB_D16_FFFF,
263 1.21 takemura 240, 320, 512, 0xa200000,
264 1.21 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_CASIO_CASSIOPEIAE_E100 },
265 1.21 takemura { TEXT("E-500"), BIFB_D16_FFFF,
266 1.21 takemura 240, 320, 512, 0xa200000,
267 1.21 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_CASIO_CASSIOPEIAE_E500 },
268 1.32 shin { TEXT("INTERTOP CX300"), BIFB_D8_00,
269 1.21 takemura 640, 480, 640, 0xa000000,
270 1.47 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_FUJITSU_INTERTOP_IT300 },
271 1.47 takemura { TEXT("INTERTOP CX300(16bpp)"), BIFB_D16_0000,
272 1.47 takemura 640, 480, 1280, 0xa000000,
273 1.21 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_FUJITSU_INTERTOP_IT300 },
274 1.32 shin { TEXT("INTERTOP CX310"), BIFB_D8_00,
275 1.21 takemura 640, 480, 640, 0xa000000,
276 1.21 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_FUJITSU_INTERTOP_IT310 },
277 1.21 takemura { TEXT("IBM WorkPad z50"), BIFB_D16_0000,
278 1.21 takemura 640, 480, 1280, 0xa000000,
279 1.27 takemura PLATID_CPU_MIPS_VR_4121, PLATID_MACH_IBM_WORKPAD_26011AU },
280 1.21 takemura { TEXT("Philips Nino 312"), BIFB_D2_M2L_0,
281 1.21 takemura 240, 320, 0, 0,
282 1.21 takemura PLATID_CPU_MIPS_TX_3912, PLATID_MACH_PHILIPS_NINO_312 },
283 1.21 takemura { TEXT("Compaq C-series 810"), BIFB_D2_M2L_0,
284 1.21 takemura 640, 240, 0, 0,
285 1.21 takemura PLATID_CPU_MIPS_TX_3912, PLATID_MACH_COMPAQ_C_810 },
286 1.32 shin { TEXT("Compaq C-series 2010c"), BIFB_D8_00,
287 1.21 takemura 640, 240, 0, 0,
288 1.21 takemura PLATID_CPU_MIPS_TX_3912, PLATID_MACH_COMPAQ_C_2010 },
289 1.32 shin { TEXT("Compaq C-series 2015c"), BIFB_D8_00,
290 1.21 takemura 640, 240, 0, 0,
291 1.21 takemura PLATID_CPU_MIPS_TX_3912, PLATID_MACH_COMPAQ_C_2015 },
292 1.21 takemura { TEXT("Compaq PRESARIO 213"), BIFB_D8_00,
293 1.21 takemura 320, 240, 0, 0,
294 1.21 takemura PLATID_CPU_MIPS_VR_4111, PLATID_MACH_COMPAQ_PRESARIO_213 },
295 1.50 takemura { TEXT("Compaq Aero 1530"), BIFB_D4_M2L_F,
296 1.50 takemura 320, 240, 160, 0x0a000000,
297 1.50 takemura PLATID_CPU_MIPS_VR_4111, PLATID_MACH_COMPAQ_AERO_1530 },
298 1.50 takemura { TEXT("Aero1530(Small Font)"), BIFB_D4_M2L_Fx2,
299 1.50 takemura 640, 240, 160, 0x0a000000,
300 1.21 takemura PLATID_CPU_MIPS_VR_4111, PLATID_MACH_COMPAQ_AERO_1530 },
301 1.21 takemura { TEXT("Victor InterLink MP-C101"), BIFB_D16_0000,
302 1.21 takemura 640, 480, 0, 0,
303 1.21 takemura PLATID_CPU_MIPS_TX_3922, PLATID_MACH_VICTOR_INTERLINK_MPC101},
304 1.42 uch { TEXT("Sharp Telios HC-AJ1/AJ2"), BIFB_D16_0000,
305 1.21 takemura 800, 600, 0, 0,
306 1.21 takemura PLATID_CPU_MIPS_TX_3922, PLATID_MACH_SHARP_TELIOS_HCAJ1},
307 1.42 uch { TEXT("Sharp Telios HC-VJ1C (Japanese)"), BIFB_D16_0000,
308 1.42 uch 800, 480, 0, 0,
309 1.42 uch PLATID_CPU_MIPS_TX_3922, PLATID_MACH_SHARP_TELIOS_HCVJ1C_JP},
310 1.42 uch { TEXT("Sharp Mobilon HC-4100/4500"), BIFB_D2_M2L_0, /* XXX 4bit greyscale */
311 1.21 takemura 640, 240, 0, 0,
312 1.21 takemura PLATID_CPU_MIPS_TX_3912, PLATID_MACH_SHARP_MOBILON_HC4100},
313 1.28 jun { TEXT("Sharp HC-1200"), BIFB_D2_M2L_0, /* XXX 4bit greyscale */
314 1.28 jun 640, 240, 0, 0,
315 1.28 jun PLATID_CPU_MIPS_TX_3912, PLATID_MACH_SHARP_MOBILON_HC1200},
316 1.21 takemura };
317 1.21 takemura
318 1.21 takemura #define ARRAYSIZEOF(a) (sizeof(a)/sizeof(*(a)))
319 1.21 takemura
320 1.21 takemura #ifdef UNDER_CE
321 1.21 takemura /* 'memory card' in HANKAKU KANA */
322 1.21 takemura #define UNICODE_MEMORY_CARD \
323 1.21 takemura TEXT('\\'), 0xff92, 0xff93, 0xff98, TEXT(' '), 0xff76, 0xff70, \
324 1.21 takemura 0xff84, 0xff9e
325 1.21 takemura TCHAR unicode_memory_card[] = { UNICODE_MEMORY_CARD, TEXT('\\') };
326 1.21 takemura TCHAR unicode_memory_card1[] = { UNICODE_MEMORY_CARD, TEXT('1'), TEXT('\\') };
327 1.21 takemura TCHAR unicode_memory_card2[] = { UNICODE_MEMORY_CARD, TEXT('2'), TEXT('\\') };
328 1.21 takemura #endif
329 1.21 takemura
330 1.33 takemura #define LANGID_DEFAULT MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT)
331 1.33 takemura struct path_s path_list[] = {
332 1.33 takemura { TEXT("/"),
333 1.33 takemura LANGID_DEFAULT, 0 },
334 1.33 takemura { TEXT("2:/"),
335 1.33 takemura LANGID_DEFAULT, 0 },
336 1.33 takemura { TEXT("\\"),
337 1.33 takemura LANGID_DEFAULT, 0 },
338 1.33 takemura { TEXT("\\My Documents\\"),
339 1.33 takemura LANGID_DEFAULT, 0 },
340 1.33 takemura { TEXT("\\Storage Card\\"),
341 1.33 takemura LANGID_DEFAULT, PATH_SAVE },
342 1.33 takemura { TEXT("\\Storage Card1\\"),
343 1.33 takemura LANGID_DEFAULT, PATH_SAVE },
344 1.33 takemura { TEXT("\\Storage Card2\\"),
345 1.33 takemura LANGID_DEFAULT, PATH_SAVE },
346 1.21 takemura #ifdef UNDER_CE
347 1.33 takemura { unicode_memory_card,
348 1.33 takemura MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), PATH_SAVE },
349 1.33 takemura { unicode_memory_card1,
350 1.33 takemura MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), PATH_SAVE },
351 1.33 takemura { unicode_memory_card2,
352 1.33 takemura MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), PATH_SAVE },
353 1.21 takemura #endif
354 1.21 takemura };
355 1.21 takemura int path_list_items = ARRAYSIZEOF(path_list);
356 1.21 takemura
357 1.21 takemura #ifdef ADDITIONAL_KERNELS
358 1.21 takemura TCHAR* kernel_list[] = {
359 1.21 takemura
360 1.21 takemura };
361 1.21 takemura int kernel_list_items = ARRAYSIZEOF(kernel_list);
362 1.21 takemura #endif
363 1.21 takemura
364 1.21 takemura /*-----------------------------------------------------------------------------
365 1.21 takemura
366 1.21 takemura function prototypes
367 1.21 takemura
368 1.21 takemura -----------------------------------------------------------------------------*/
369 1.44 takemura BOOL CALLBACK MainDlgProc(HWND, UINT, WPARAM, LPARAM);
370 1.45 takemura LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
371 1.21 takemura void SetBootInfo(struct bootinfo *bi, struct fb_setting *fbs);
372 1.21 takemura void wstrcpy(TCHAR* dst, TCHAR* src);
373 1.26 cgd int reverse_fb_type(int type);
374 1.21 takemura
375 1.21 takemura /*-----------------------------------------------------------------------------
376 1.21 takemura
377 1.21 takemura function definitions
378 1.21 takemura
379 1.21 takemura -----------------------------------------------------------------------------*/
380 1.21 takemura void wstrcpy(TCHAR* dst, TCHAR* src)
381 1.21 takemura {
382 1.21 takemura while (*src) {
383 1.21 takemura *dst++ = *src++;
384 1.21 takemura }
385 1.21 takemura *dst = *src;
386 1.26 cgd }
387 1.26 cgd
388 1.26 cgd int reverse_fb_type(int type)
389 1.26 cgd {
390 1.26 cgd int i;
391 1.26 cgd struct {
392 1.26 cgd int type0, type1;
393 1.26 cgd } types[] = {
394 1.26 cgd { BIFB_D2_M2L_3, BIFB_D2_M2L_0 },
395 1.26 cgd { BIFB_D2_M2L_3x2, BIFB_D2_M2L_0x2 },
396 1.50 takemura { BIFB_D4_M2L_F, BIFB_D4_M2L_0 },
397 1.50 takemura { BIFB_D4_M2L_Fx2, BIFB_D4_M2L_0x2 },
398 1.26 cgd { BIFB_D8_FF, BIFB_D8_00 },
399 1.26 cgd { BIFB_D16_FFFF, BIFB_D16_0000, },
400 1.26 cgd };
401 1.26 cgd
402 1.26 cgd for (i = 0; i < ARRAYSIZEOF(types); i++) {
403 1.26 cgd if (types[i].type0 == type) {
404 1.26 cgd return (types[i].type1);
405 1.26 cgd }
406 1.26 cgd if (types[i].type1 == type) {
407 1.26 cgd return (types[i].type0);
408 1.26 cgd }
409 1.26 cgd }
410 1.26 cgd debug_printf(TEXT("reverse_fb_type(): unknown type %d\n"), type);
411 1.26 cgd return (type);
412 1.21 takemura }
413 1.21 takemura
414 1.21 takemura int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
415 1.21 takemura LPTSTR lpCmdLine, int nCmdShow )
416 1.21 takemura {
417 1.21 takemura MSG msg;
418 1.21 takemura WNDCLASS wc;
419 1.44 takemura HDC hdc;
420 1.44 takemura int i, idx,width,height;
421 1.51 takemura
422 1.39 takemura #if ( 200 <= _WIN32_WCE )
423 1.39 takemura OSVERSIONINFO osverinfo;
424 1.39 takemura
425 1.39 takemura osverinfo.dwOSVersionInfoSize = sizeof(osverinfo);
426 1.39 takemura if (!GetVersionEx(&osverinfo)) {
427 1.39 takemura msg_printf(MSG_ERROR,
428 1.39 takemura TEXT("Error"),
429 1.39 takemura TEXT("GetVersionEx() failed"));
430 1.39 takemura }
431 1.39 takemura osversion = osverinfo.dwMajorVersion * 100 + osverinfo.dwMinorVersion;
432 1.39 takemura #else
433 1.39 takemura osversion = 100;
434 1.39 takemura #endif
435 1.21 takemura
436 1.43 takemura /*
437 1.43 takemura * create log file for debugging
438 1.43 takemura */
439 1.43 takemura for (i = 0; i < path_list_items; i++) {
440 1.43 takemura TCHAR filenamebuf[1024];
441 1.43 takemura if (!(path_list[i].flags & PATH_SAVE)) {
442 1.43 takemura continue;
443 1.43 takemura }
444 1.43 takemura wsprintf(filenamebuf, TEXT("%s%s"),
445 1.43 takemura path_list[i].name, LOGNAME);
446 1.43 takemura if (set_debug_log(filenamebuf) == 0) {
447 1.43 takemura msg_printf(MSG_INFO,
448 1.43 takemura TEXT("Debug"),
449 1.43 takemura TEXT("%s was created"), LOGNAME);
450 1.43 takemura break;
451 1.43 takemura }
452 1.43 takemura }
453 1.43 takemura
454 1.43 takemura debug_printf(TEXT("%s"), version_string);
455 1.43 takemura debug_printf(TEXT("Compiled for %d, Runtime OS version %d\n"),
456 1.43 takemura _WIN32_WCE, osversion);
457 1.43 takemura
458 1.21 takemura wc.style = (UINT)NULL;
459 1.45 takemura wc.lpfnWndProc = (WNDPROC) WndProc;
460 1.21 takemura wc.cbClsExtra = 0;
461 1.21 takemura wc.cbWndExtra = 0;
462 1.21 takemura wc.hInstance = hInstance;
463 1.21 takemura wc.hIcon = NULL;
464 1.21 takemura wc.hCursor = NULL;
465 1.45 takemura wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
466 1.21 takemura wc.lpszMenuName = NULL;
467 1.21 takemura wc.lpszClassName = whoami;
468 1.21 takemura
469 1.21 takemura RegisterClass(&wc);
470 1.21 takemura
471 1.21 takemura InitCommonControls(); // Initialize common controls - command bar
472 1.21 takemura hInst = hInstance; // Save handle to create command bar
473 1.21 takemura
474 1.21 takemura hardware_test();
475 1.21 takemura
476 1.45 takemura
477 1.45 takemura hBack = CreateWindowEx(0,
478 1.45 takemura szAppName,
479 1.45 takemura szTitle,
480 1.45 takemura WS_VISIBLE,
481 1.45 takemura CW_USEDEFAULT,
482 1.45 takemura CW_USEDEFAULT,
483 1.45 takemura CW_USEDEFAULT,
484 1.45 takemura CW_USEDEFAULT,
485 1.45 takemura NULL,
486 1.45 takemura NULL,
487 1.45 takemura hInstance,
488 1.45 takemura NULL);
489 1.45 takemura
490 1.45 takemura
491 1.44 takemura hdc = GetDC(0);
492 1.44 takemura width = GetDeviceCaps(hdc,HORZRES);
493 1.44 takemura height = GetDeviceCaps(hdc,VERTRES);
494 1.44 takemura ReleaseDC(0,hdc);
495 1.21 takemura
496 1.44 takemura if(width > height){
497 1.45 takemura hDlgMain = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_MAIN_320X240),hBack,MainDlgProc);
498 1.44 takemura }
499 1.44 takemura else{
500 1.45 takemura hDlgMain = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_MAIN_240X320),hBack,MainDlgProc);
501 1.21 takemura }
502 1.44 takemura
503 1.44 takemura SetFocus(GetDlgItem(hDlgMain, IDC_BOOT));
504 1.44 takemura SetForegroundWindow(hDlgMain);
505 1.21 takemura
506 1.21 takemura /*
507 1.21 takemura * load preferences
508 1.21 takemura */
509 1.21 takemura pref_init(&pref);
510 1.21 takemura if (pref_load(path_list, path_list_items) == 0) {
511 1.43 takemura stat_printf(TEXT("%s is loaded."), where_pref_load_from);
512 1.21 takemura
513 1.21 takemura fb_settings[0].type = pref.fb_type;
514 1.21 takemura fb_settings[0].width = pref.fb_width;
515 1.21 takemura fb_settings[0].height = pref.fb_height;
516 1.21 takemura fb_settings[0].linebytes = pref.fb_linebytes;
517 1.21 takemura fb_settings[0].addr = pref.fb_addr;
518 1.21 takemura fb_settings[0].platid_cpu = pref.platid_cpu;
519 1.21 takemura fb_settings[0].platid_machine = pref.platid_machine;
520 1.21 takemura } else {
521 1.21 takemura TCHAR tmpbuf[PATHBUFLEN];
522 1.33 takemura wsprintf(tmpbuf, TEXT("%s%S"), path_list[0].name, "netbsd");
523 1.43 takemura stat_printf(TEXT("preferences not loaded."));
524 1.21 takemura
525 1.21 takemura pref.setting_idx = 1;
526 1.21 takemura pref.fb_type = fb_settings[0].type;
527 1.21 takemura pref.fb_width = fb_settings[0].width;
528 1.21 takemura pref.fb_height = fb_settings[0].height;
529 1.21 takemura pref.fb_linebytes = fb_settings[0].linebytes;
530 1.21 takemura pref.fb_addr = fb_settings[0].addr;
531 1.21 takemura pref.platid_cpu = fb_settings[0].platid_cpu;
532 1.21 takemura pref.platid_machine = fb_settings[0].platid_machine;
533 1.21 takemura wstrcpy(pref.setting_name, TEXT("User defined"));
534 1.21 takemura wstrcpy(pref.kernel_name, tmpbuf);
535 1.21 takemura wstrcpy(pref.options, TEXT(""));
536 1.21 takemura pref.check_last_chance = FALSE;
537 1.21 takemura pref.load_debug_info = FALSE;
538 1.21 takemura pref.serial_port = FALSE;
539 1.25 takemura pref.reverse_video = FALSE;
540 1.21 takemura }
541 1.21 takemura fb_settings[0].name = pref.setting_name;
542 1.21 takemura
543 1.21 takemura /*
544 1.21 takemura * initialize kernel file name list.
545 1.21 takemura */
546 1.21 takemura for (i = 0; i < path_list_items; i++) {
547 1.33 takemura if (path_list[i].langid == LANGID_DEFAULT ||
548 1.33 takemura path_list[i].langid == GetSystemDefaultLangID()) {
549 1.33 takemura TCHAR tmpbuf[1024];
550 1.33 takemura wsprintf(tmpbuf, TEXT("%s%S"),
551 1.33 takemura path_list[i].name, "netbsd");
552 1.44 takemura SendDlgItemMessage(hDlgMain, IDC_KERNEL,
553 1.33 takemura CB_ADDSTRING, 0, (LPARAM)tmpbuf);
554 1.33 takemura }
555 1.21 takemura }
556 1.21 takemura #ifdef ADDITIONAL_KERNELS
557 1.21 takemura for (i = 0; i < kernel_list_items; i++) {
558 1.44 takemura SendDlgItemMessage(hDlgMain, IDC_KERNEL, CB_ADDSTRING, 0,
559 1.21 takemura (LPARAM)kernel_list[i]);
560 1.21 takemura }
561 1.21 takemura #endif
562 1.21 takemura /*
563 1.44 takemura SendDlgItemMessage(hDlgMain, IDC_KERNEL, CB_SETCURSEL, 0,
564 1.21 takemura (LPARAM)NULL);
565 1.21 takemura */
566 1.44 takemura SetDlgItemText(hDlgMain, IDC_KERNEL, pref.kernel_name);
567 1.44 takemura SetDlgItemText(hDlgMain, IDC_OPTIONS, pref.options);
568 1.21 takemura
569 1.21 takemura /*
570 1.21 takemura * Frame Buffer setting names.
571 1.21 takemura */
572 1.21 takemura for (i = 0; i < ARRAYSIZEOF(fb_settings); i++) {
573 1.44 takemura idx = SendDlgItemMessage(hDlgMain, IDC_FBSELECT, CB_ADDSTRING,
574 1.21 takemura 0, (LPARAM)fb_settings[i].name);
575 1.44 takemura SendDlgItemMessage(hDlgMain, IDC_FBSELECT,
576 1.21 takemura CB_SETITEMDATA, idx, (LPARAM)i);
577 1.21 takemura if (i == 0) {
578 1.21 takemura user_define_idx = idx;
579 1.21 takemura }
580 1.21 takemura }
581 1.44 takemura SendDlgItemMessage(hDlgMain, IDC_FBSELECT, CB_SETCURSEL,
582 1.21 takemura pref.setting_idx, (LPARAM)NULL);
583 1.21 takemura
584 1.44 takemura if(pref.autoboot){
585 1.44 takemura if(pref.boot_time > 0){/* 0 can't use */
586 1.44 takemura booting = TRUE;
587 1.44 takemura how_long_to_boot = pref.boot_time;
588 1.44 takemura SetTimer(hDlgMain,IDD_TIMER,1000,NULL);
589 1.44 takemura stat_printf(
590 1.44 takemura TEXT("autoboot after %d second,tap or hit any key to interrupt"),
591 1.44 takemura pref.boot_time);
592 1.44 takemura }
593 1.44 takemura }
594 1.21 takemura /*
595 1.21 takemura * Map window and message loop
596 1.21 takemura */
597 1.44 takemura ShowWindow(hDlgMain, SW_SHOW);
598 1.44 takemura UpdateWindow(hDlgMain);
599 1.44 takemura
600 1.44 takemura
601 1.37 takemura while (GetMessage(&msg, NULL, 0, 0)) {
602 1.44 takemura // if (osversion < 211 ||
603 1.44 takemura if(booting){
604 1.44 takemura if(msg.message == WM_KEYDOWN || msg.message == WM_LBUTTONDOWN){
605 1.44 takemura booting = FALSE;
606 1.44 takemura how_long_to_boot = -1;
607 1.44 takemura KillTimer(hDlgMain,IDD_TIMER);
608 1.44 takemura stat_printf(TEXT("interrupt"));
609 1.44 takemura continue;
610 1.44 takemura }
611 1.44 takemura }
612 1.44 takemura
613 1.44 takemura if(!IsDialogMessage(hDlgMain, &msg)) {
614 1.44 takemura
615 1.37 takemura TranslateMessage(&msg);
616 1.37 takemura DispatchMessage(&msg);
617 1.37 takemura }
618 1.21 takemura }
619 1.21 takemura
620 1.21 takemura return(msg.wParam);
621 1.21 takemura }
622 1.21 takemura
623 1.21 takemura BOOL CALLBACK DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
624 1.21 takemura {
625 1.21 takemura switch (message) {
626 1.45 takemura
627 1.21 takemura case WM_INITDIALOG:
628 1.21 takemura return (1);
629 1.21 takemura
630 1.33 takemura case WM_PALETTECHANGED:
631 1.33 takemura palette_check(hWnd);
632 1.33 takemura break;
633 1.33 takemura
634 1.21 takemura case WM_COMMAND:
635 1.21 takemura switch (LOWORD(wParam)) {
636 1.21 takemura case IDCANCEL:
637 1.21 takemura dlgStatus = IDCANCEL;
638 1.21 takemura break;
639 1.21 takemura }
640 1.21 takemura break;
641 1.21 takemura default:
642 1.21 takemura return (0);
643 1.21 takemura }
644 1.21 takemura }
645 1.21 takemura
646 1.21 takemura BOOL CALLBACK DlgProc2(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
647 1.21 takemura {
648 1.21 takemura switch (message) {
649 1.21 takemura case WM_INITDIALOG:
650 1.33 takemura SetDlgItemText(hWnd, IDC_ABOUT_EDIT, version_string);
651 1.21 takemura return (1);
652 1.21 takemura
653 1.33 takemura case WM_PALETTECHANGED:
654 1.33 takemura palette_check(hWnd);
655 1.33 takemura break;
656 1.33 takemura
657 1.21 takemura case WM_COMMAND:
658 1.44 takemura
659 1.21 takemura switch (LOWORD(wParam)) {
660 1.21 takemura case IDC_ABOUT_EDIT:
661 1.21 takemura switch (HIWORD(wParam)) {
662 1.21 takemura case EN_SETFOCUS:
663 1.21 takemura //SendDlgItemMessage(hWnd, IDC_ABOUT_EDIT, EM_SETSEL, -1, 0);
664 1.21 takemura SetFocus(GetDlgItem(hWnd, IDC_ABOUT_BITMAP));
665 1.21 takemura break;
666 1.21 takemura }
667 1.21 takemura break;
668 1.21 takemura
669 1.21 takemura case IDCANCEL:
670 1.21 takemura EndDialog(hWnd, LOWORD(wParam));
671 1.21 takemura return (1);
672 1.21 takemura }
673 1.21 takemura break;
674 1.21 takemura default:
675 1.21 takemura return (0);
676 1.21 takemura }
677 1.21 takemura }
678 1.21 takemura
679 1.44 takemura
680 1.44 takemura
681 1.44 takemura BOOL CALLBACK PropDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
682 1.44 takemura {
683 1.44 takemura HWND hwnd;
684 1.44 takemura TCHAR tempbuf[PATHBUFLEN];
685 1.44 takemura static BOOL autop;
686 1.44 takemura int i;
687 1.44 takemura switch (message) {
688 1.44 takemura case WM_INITDIALOG:
689 1.44 takemura autop = pref.autoboot;
690 1.44 takemura
691 1.44 takemura SendDlgItemMessage(hWnd, IDC_PAUSE, BM_SETCHECK,
692 1.44 takemura pref.check_last_chance, 0);
693 1.44 takemura SendDlgItemMessage(hWnd, IDC_DEBUG, BM_SETCHECK,
694 1.44 takemura pref.load_debug_info, 0);
695 1.44 takemura SendDlgItemMessage(hWnd, IDC_COMM, BM_SETCHECK,
696 1.44 takemura pref.serial_port, 0);
697 1.44 takemura SendDlgItemMessage(hWnd, IDC_REVERSEVIDEO, BM_SETCHECK,
698 1.44 takemura pref.reverse_video, 0);
699 1.44 takemura SendDlgItemMessage(hWnd,IDC_AUTOBOOT,BM_SETCHECK,pref.autoboot,0);
700 1.44 takemura
701 1.44 takemura for (i = 0; i < ARRAYSIZEOF(boot_times); i++) {
702 1.44 takemura wsprintf(tempbuf, TEXT("%d"), boot_times[i]);
703 1.44 takemura SendDlgItemMessage(hWnd, IDC_BOOT_TIME, CB_ADDSTRING,
704 1.44 takemura 0, (LPARAM)tempbuf);
705 1.44 takemura }
706 1.44 takemura
707 1.44 takemura if(pref.boot_time){
708 1.44 takemura wsprintf(tempbuf,TEXT("%d"),pref.boot_time);
709 1.44 takemura SetDlgItemText(hWnd,IDC_BOOT_TIME,tempbuf);
710 1.44 takemura }
711 1.44 takemura else{
712 1.44 takemura wsprintf(tempbuf, TEXT("%d"), boot_times[0]);
713 1.44 takemura SendDlgItemMessage(hWnd, IDC_BOOT_TIME, CB_ADDSTRING,
714 1.44 takemura 0, (LPARAM)tempbuf);
715 1.44 takemura }
716 1.44 takemura
717 1.44 takemura
718 1.44 takemura hwnd = GetDlgItem(hWnd,IDC_BOOT_TIME);
719 1.44 takemura EnableWindow(hwnd,pref.autoboot);
720 1.44 takemura
721 1.44 takemura return (1);
722 1.44 takemura
723 1.44 takemura case WM_PALETTECHANGED:
724 1.44 takemura palette_check(hWnd);
725 1.44 takemura break;
726 1.44 takemura
727 1.44 takemura case WM_COMMAND:
728 1.44 takemura switch (LOWORD(wParam)) {
729 1.44 takemura case IDC_AUTOBOOT:
730 1.44 takemura autop = !autop;
731 1.44 takemura SendDlgItemMessage(hWnd,IDC_AUTOBOOT,BM_SETCHECK,
732 1.44 takemura autop,0);
733 1.44 takemura
734 1.44 takemura hwnd = GetDlgItem(hWnd,IDC_BOOT_TIME);
735 1.44 takemura EnableWindow(hwnd,autop);
736 1.44 takemura
737 1.44 takemura break;
738 1.44 takemura case IDPROPOK:
739 1.44 takemura if (SendDlgItemMessage(hWnd, IDC_PAUSE,
740 1.44 takemura BM_GETCHECK, 0, 0) ==
741 1.44 takemura BST_CHECKED) {
742 1.44 takemura pref.check_last_chance = TRUE;
743 1.44 takemura } else {
744 1.44 takemura pref.check_last_chance = FALSE;
745 1.44 takemura }
746 1.44 takemura
747 1.44 takemura if (SendDlgItemMessage(hWnd, IDC_DEBUG,
748 1.44 takemura BM_GETCHECK, 0, 0) ==
749 1.44 takemura BST_CHECKED) {
750 1.44 takemura pref.load_debug_info = TRUE;
751 1.44 takemura } else {
752 1.44 takemura pref.load_debug_info = FALSE;
753 1.44 takemura }
754 1.44 takemura
755 1.44 takemura if (SendDlgItemMessage(hWnd, IDC_COMM,
756 1.44 takemura BM_GETCHECK, 0, 0) ==
757 1.44 takemura BST_CHECKED) {
758 1.44 takemura pref.serial_port = TRUE;
759 1.44 takemura } else {
760 1.44 takemura pref.serial_port = FALSE;
761 1.44 takemura }
762 1.44 takemura
763 1.44 takemura if (SendDlgItemMessage(hWnd, IDC_REVERSEVIDEO,
764 1.44 takemura BM_GETCHECK, 0, 0) ==
765 1.44 takemura BST_CHECKED) {
766 1.44 takemura pref.reverse_video = TRUE;
767 1.44 takemura } else {
768 1.44 takemura pref.reverse_video = FALSE;
769 1.44 takemura }
770 1.44 takemura
771 1.44 takemura if (SendDlgItemMessage(hWnd, IDC_AUTOBOOT,
772 1.44 takemura BM_GETCHECK, 0, 0) ==
773 1.44 takemura BST_CHECKED) {
774 1.44 takemura pref.autoboot = TRUE;
775 1.44 takemura } else {
776 1.44 takemura pref.autoboot = FALSE;
777 1.44 takemura }
778 1.44 takemura GetDlgItemText(hWnd,IDC_BOOT_TIME,tempbuf,PATHBUFLEN);
779 1.44 takemura pref.boot_time = _wtoi(tempbuf);
780 1.44 takemura
781 1.44 takemura EndDialog(hWnd, 0);
782 1.44 takemura return (1);
783 1.44 takemura case IDCANCEL:
784 1.44 takemura EndDialog(hWnd,0);
785 1.44 takemura return(1);
786 1.44 takemura }
787 1.44 takemura break;
788 1.44 takemura default:
789 1.44 takemura return (0);
790 1.44 takemura }
791 1.44 takemura }
792 1.44 takemura
793 1.21 takemura void
794 1.21 takemura SetBootInfo(struct bootinfo *bi, struct fb_setting *fbs)
795 1.21 takemura {
796 1.21 takemura TIME_ZONE_INFORMATION tz;
797 1.21 takemura
798 1.21 takemura GetTimeZoneInformation(&tz);
799 1.21 takemura memset(bi, 0, sizeof(struct bootinfo));
800 1.21 takemura bi->length = sizeof(struct bootinfo);
801 1.21 takemura bi->reserved = 0;
802 1.21 takemura bi->magic = BOOTINFO_MAGIC;
803 1.21 takemura bi->fb_addr = (unsigned char*)(fbs->addr + 0xA0000000);
804 1.21 takemura bi->fb_type = fbs->type;
805 1.21 takemura bi->fb_line_bytes = fbs->linebytes;
806 1.21 takemura bi->fb_width = fbs->width;
807 1.21 takemura bi->fb_height = fbs->height;
808 1.21 takemura bi->platid_cpu = fbs->platid_cpu;
809 1.21 takemura bi->platid_machine = fbs->platid_machine;
810 1.21 takemura bi->timezone = tz.Bias;
811 1.21 takemura
812 1.21 takemura debug_printf(TEXT("fb setting: %s fb_type=%d 0x%X %dx%d %d\n"),
813 1.21 takemura fbs->name,
814 1.21 takemura bi->fb_type, bi->fb_addr,
815 1.21 takemura bi->fb_width, bi->fb_height, bi->fb_line_bytes);
816 1.21 takemura debug_printf(TEXT("timezone: %02ld:00\n"), (bi->timezone / 60));
817 1.21 takemura }
818 1.21 takemura
819 1.21 takemura
820 1.21 takemura void
821 1.21 takemura UpdateFbDlg(HWND hWnd, struct fb_setting *fbs, int direction)
822 1.21 takemura {
823 1.21 takemura int i;
824 1.21 takemura TCHAR tmpbuf[PATHBUFLEN];
825 1.21 takemura int type, width, height, linebytes;
826 1.21 takemura long addr;
827 1.21 takemura
828 1.21 takemura switch (direction) {
829 1.21 takemura case UPDATE_DLGBOX:
830 1.21 takemura SetDlgItemText(hWnd, IDC_FB_NAME, fbs->name);
831 1.21 takemura
832 1.21 takemura for (i = 0; i < ARRAYSIZEOF(fb_types); i++) {
833 1.21 takemura if (fb_types[i].type == fbs->type) break;
834 1.21 takemura }
835 1.21 takemura if (ARRAYSIZEOF(fb_types) <= i) {
836 1.21 takemura MessageBox(NULL, TEXT("Unknown FrameBuffer type."),
837 1.21 takemura szAppName, MB_OK);
838 1.21 takemura return;
839 1.21 takemura }
840 1.21 takemura debug_printf(TEXT("UpdateFbDlg(%s)\n"), fbs->name);
841 1.21 takemura i = SendDlgItemMessage(hWnd, IDC_FB_TYPE, CB_FINDSTRINGEXACT,
842 1.21 takemura 0, (LPARAM)fb_types[i].name);
843 1.21 takemura SendDlgItemMessage(hWnd, IDC_FB_TYPE, CB_SETCURSEL, i, 0);
844 1.21 takemura
845 1.21 takemura wsprintf(tmpbuf, TEXT("%X"), fbs->addr);
846 1.21 takemura SetDlgItemText(hWnd, IDC_FB_ADDR, tmpbuf);
847 1.21 takemura wsprintf(tmpbuf, TEXT("%d"), fbs->width);
848 1.21 takemura SetDlgItemText(hWnd, IDC_FB_WIDTH, tmpbuf);
849 1.21 takemura wsprintf(tmpbuf, TEXT("%d"), fbs->height);
850 1.21 takemura SetDlgItemText(hWnd, IDC_FB_HEIGHT, tmpbuf);
851 1.21 takemura wsprintf(tmpbuf, TEXT("%d"), fbs->linebytes);
852 1.21 takemura SetDlgItemText(hWnd, IDC_FB_LINEBYTES, tmpbuf);
853 1.21 takemura wsprintf(tmpbuf, TEXT("%08X"), fbs->platid_cpu);
854 1.21 takemura SetDlgItemText(hWnd, IDC_FB_CPU, tmpbuf);
855 1.21 takemura wsprintf(tmpbuf, TEXT("%08X"), fbs->platid_machine);
856 1.21 takemura SetDlgItemText(hWnd, IDC_FB_MACHINE, tmpbuf);
857 1.21 takemura break;
858 1.21 takemura case UPDATE_DATA:
859 1.21 takemura GetDlgItemText(hWnd, IDC_FB_NAME, fbs->name, PATHBUFLEN);
860 1.21 takemura type = SendDlgItemMessage(hWnd, IDC_FB_TYPE,
861 1.21 takemura CB_GETCURSEL, 0, 0);
862 1.21 takemura type = SendDlgItemMessage(hWnd, IDC_FB_TYPE,
863 1.21 takemura CB_GETITEMDATA, type, 0);
864 1.21 takemura GetDlgItemText(hWnd, IDC_FB_WIDTH, tmpbuf, sizeof(tmpbuf));
865 1.21 takemura width = _tcstol(tmpbuf, NULL, 10);
866 1.21 takemura GetDlgItemText(hWnd, IDC_FB_HEIGHT, tmpbuf, sizeof(tmpbuf));
867 1.21 takemura height = _tcstol(tmpbuf, NULL, 10);
868 1.21 takemura GetDlgItemText(hWnd, IDC_FB_LINEBYTES, tmpbuf, sizeof(tmpbuf));
869 1.21 takemura linebytes = _tcstol(tmpbuf, NULL, 10);
870 1.21 takemura GetDlgItemText(hWnd, IDC_FB_ADDR, tmpbuf, sizeof(tmpbuf));
871 1.21 takemura addr = _tcstoul(tmpbuf, NULL, 16);
872 1.21 takemura GetDlgItemText(hWnd, IDC_FB_CPU, tmpbuf, sizeof(tmpbuf));
873 1.21 takemura fbs->platid_cpu = _tcstoul(tmpbuf, NULL, 16);
874 1.21 takemura GetDlgItemText(hWnd, IDC_FB_MACHINE, tmpbuf, sizeof(tmpbuf));
875 1.21 takemura fbs->platid_machine = _tcstoul(tmpbuf, NULL, 16);
876 1.21 takemura fbs->type = type;
877 1.21 takemura fbs->addr = addr;
878 1.21 takemura fbs->width = width;
879 1.21 takemura fbs->height = height;
880 1.21 takemura fbs->linebytes = linebytes;
881 1.21 takemura
882 1.21 takemura debug_printf(TEXT("type=%d %dx%d %d bytes/line %08x %08x\n"),
883 1.21 takemura type, width, height, linebytes,
884 1.21 takemura fbs->platid_cpu,
885 1.21 takemura fbs->platid_machine);
886 1.21 takemura break;
887 1.21 takemura default:
888 1.21 takemura debug_printf(TEXT("UpdateFbDlg(): internal error!\n"));
889 1.21 takemura break;
890 1.21 takemura }
891 1.21 takemura }
892 1.21 takemura
893 1.21 takemura BOOL CALLBACK FbDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
894 1.21 takemura {
895 1.21 takemura int idx, i;
896 1.21 takemura TCHAR tmpbuf[100];
897 1.21 takemura
898 1.21 takemura switch (message) {
899 1.21 takemura case WM_INITDIALOG:
900 1.21 takemura {
901 1.21 takemura UDACCEL uda;
902 1.21 takemura for (i = 0; i < ARRAYSIZEOF(fb_settings); i++) {
903 1.21 takemura idx = SendDlgItemMessage(hWnd, IDC_FB_NAME,
904 1.21 takemura CB_ADDSTRING, 0,
905 1.21 takemura (LPARAM)fb_settings[i].name);
906 1.21 takemura SendDlgItemMessage(hWnd, IDC_FB_NAME,
907 1.21 takemura CB_SETITEMDATA, idx, (LPARAM)i);
908 1.21 takemura }
909 1.21 takemura for (i = 0; i < ARRAYSIZEOF(fb_size); i++) {
910 1.21 takemura wsprintf(tmpbuf, TEXT("%d"), fb_size[i]);
911 1.21 takemura SendDlgItemMessage(hWnd, IDC_FB_WIDTH, CB_ADDSTRING,
912 1.21 takemura 0, (LPARAM)tmpbuf);
913 1.21 takemura SendDlgItemMessage(hWnd, IDC_FB_HEIGHT, CB_ADDSTRING,
914 1.21 takemura 0, (LPARAM)tmpbuf);
915 1.21 takemura }
916 1.21 takemura for (i = 0; i < ARRAYSIZEOF(fb_bpl); i++) {
917 1.21 takemura wsprintf(tmpbuf, TEXT("%d"), fb_bpl[i]);
918 1.21 takemura SendDlgItemMessage(hWnd, IDC_FB_LINEBYTES,
919 1.21 takemura CB_ADDSTRING, 0,
920 1.21 takemura (LPARAM)tmpbuf);
921 1.21 takemura }
922 1.21 takemura for (i = 0; i < ARRAYSIZEOF(fb_types); i++) {
923 1.21 takemura idx = SendDlgItemMessage(hWnd, IDC_FB_TYPE,
924 1.21 takemura CB_ADDSTRING, 0,
925 1.21 takemura (LPARAM)fb_types[i].name);
926 1.21 takemura SendDlgItemMessage(hWnd, IDC_FB_TYPE, CB_SETITEMDATA,
927 1.21 takemura idx, (LPARAM)fb_types[i].type);
928 1.21 takemura }
929 1.21 takemura UpdateFbDlg(hWnd, &fb_settings[0], UPDATE_DLGBOX);
930 1.21 takemura
931 1.21 takemura uda.nSec = 1;
932 1.21 takemura uda.nInc = 0x100;
933 1.21 takemura /*
934 1.21 takemura SendDlgItemMessage(hWnd, IDC_FB_ADDRSPIN, UDM_SETACCEL,
935 1.21 takemura 0, (LPARAM)&uda);
936 1.21 takemura */
937 1.21 takemura /*
938 1.21 takemura SendDlgItemMessage(hWnd, IDC_FB_ADDRSPIN, UDM_SETRANGE,
939 1.21 takemura 0, MAKELPARAM(UD_MAXVAL, UD_MINVAL));
940 1.21 takemura */
941 1.21 takemura }
942 1.21 takemura return (1);
943 1.21 takemura
944 1.33 takemura case WM_PALETTECHANGED:
945 1.33 takemura palette_check(hWnd);
946 1.33 takemura break;
947 1.33 takemura
948 1.21 takemura case WM_VSCROLL:
949 1.21 takemura if ((HWND)lParam == GetDlgItem(hWnd, IDC_FB_ADDRSPIN)) {
950 1.21 takemura long addr;
951 1.21 takemura switch (LOWORD(wParam)) {
952 1.21 takemura case SB_THUMBPOSITION:
953 1.21 takemura case SB_THUMBTRACK:
954 1.21 takemura GetDlgItemText(hWnd, IDC_FB_ADDR, tmpbuf, 100);
955 1.21 takemura addr = _tcstoul(tmpbuf, NULL, 16);
956 1.21 takemura if (50 < HIWORD(wParam)) {
957 1.21 takemura addr -= 0x400;
958 1.21 takemura } else {
959 1.21 takemura addr += 0x400;
960 1.21 takemura }
961 1.21 takemura SendDlgItemMessage(hWnd, IDC_FB_ADDRSPIN,
962 1.21 takemura UDM_SETPOS, 0,
963 1.21 takemura MAKELPARAM(50, 0));
964 1.21 takemura wsprintf(tmpbuf, TEXT("%X"), addr);
965 1.21 takemura SetDlgItemText(hWnd, IDC_FB_ADDR, tmpbuf);
966 1.21 takemura return (1);
967 1.21 takemura }
968 1.21 takemura }
969 1.21 takemura break;
970 1.21 takemura
971 1.21 takemura case WM_COMMAND:
972 1.21 takemura switch (LOWORD(wParam)) {
973 1.21 takemura case IDC_FB_NAME:
974 1.21 takemura switch (HIWORD(wParam)) {
975 1.21 takemura case CBN_SELCHANGE:
976 1.21 takemura idx = SendDlgItemMessage(hWnd, IDC_FB_NAME,
977 1.21 takemura CB_GETCURSEL, 0, 0);
978 1.21 takemura i = SendDlgItemMessage(hWnd, IDC_FB_NAME,
979 1.21 takemura CB_GETITEMDATA, idx, 0);
980 1.21 takemura if (0 <= i && i < ARRAYSIZEOF(fb_settings)) {
981 1.21 takemura fb_settings[0] = fb_settings[i];
982 1.21 takemura UpdateFbDlg(hWnd, &fb_settings[0],
983 1.21 takemura UPDATE_DLGBOX);
984 1.21 takemura }
985 1.21 takemura return (1);
986 1.21 takemura }
987 1.21 takemura break;
988 1.21 takemura case IDOK:
989 1.21 takemura UpdateFbDlg(hWnd, &fb_settings[0], UPDATE_DATA);
990 1.21 takemura
991 1.21 takemura EndDialog(hWnd, IDOK);
992 1.21 takemura return (1);
993 1.21 takemura
994 1.21 takemura case IDCANCEL:
995 1.21 takemura EndDialog(hWnd, IDCANCEL);
996 1.21 takemura return (1);
997 1.21 takemura }
998 1.21 takemura break;
999 1.21 takemura }
1000 1.21 takemura return (0);
1001 1.21 takemura }
1002 1.21 takemura
1003 1.21 takemura
1004 1.21 takemura BOOL SerialPort(BOOL on)
1005 1.21 takemura {
1006 1.21 takemura static HANDLE hPort = INVALID_HANDLE_VALUE;
1007 1.21 takemura BOOL res = (hPort != INVALID_HANDLE_VALUE);
1008 1.21 takemura
1009 1.21 takemura if (on != res) {
1010 1.21 takemura if (on) {
1011 1.21 takemura hPort = CreateFile(TEXT("COM1:"),
1012 1.21 takemura GENERIC_READ | GENERIC_WRITE,
1013 1.21 takemura 0, NULL, OPEN_EXISTING,
1014 1.21 takemura 0,
1015 1.21 takemura NULL);
1016 1.21 takemura debug_printf(TEXT("serial port ON\n"));
1017 1.21 takemura if ( hPort == INVALID_HANDLE_VALUE ) {
1018 1.21 takemura debug_printf(TEXT("open failed\n"));
1019 1.21 takemura } else {
1020 1.21 takemura #if 0
1021 1.21 takemura DWORD Len;
1022 1.21 takemura BYTE x = 'X';
1023 1.21 takemura WriteFile (hPort, &x, 1, &Len, 0);
1024 1.21 takemura WriteFile (hPort, &x, 1, &Len, 0);
1025 1.21 takemura WriteFile (hPort, &x, 1, &Len, 0);
1026 1.21 takemura WriteFile (hPort, &x, 1, &Len, 0);
1027 1.21 takemura #endif
1028 1.21 takemura }
1029 1.21 takemura } else {
1030 1.21 takemura debug_printf(TEXT("serial port OFF\n"));
1031 1.21 takemura CloseHandle(hPort);
1032 1.21 takemura hPort = INVALID_HANDLE_VALUE;
1033 1.21 takemura }
1034 1.21 takemura }
1035 1.21 takemura
1036 1.21 takemura return (res);
1037 1.21 takemura }
1038 1.21 takemura
1039 1.21 takemura
1040 1.21 takemura BOOL CheckCancel(int progress)
1041 1.21 takemura {
1042 1.21 takemura MSG msg;
1043 1.21 takemura
1044 1.21 takemura if (0 <= progress) {
1045 1.21 takemura SendDlgItemMessage(hDlgLoad, IDC_PROGRESS,
1046 1.21 takemura PBM_SETPOS, (WPARAM)progress, (LPARAM)NULL);
1047 1.33 takemura } else {
1048 1.33 takemura if (pref.check_last_chance) {
1049 1.33 takemura if (msg_printf(MB_YESNO | MB_ICONHAND,
1050 1.33 takemura TEXT("Last chance..."),
1051 1.33 takemura TEXT("Push OK to boot.")) != IDYES) {
1052 1.33 takemura dlgStatus = IDCANCEL;
1053 1.33 takemura }
1054 1.33 takemura }
1055 1.33 takemura palette_set(hDlgLoad);
1056 1.33 takemura if (palette_succeeded == -1) {
1057 1.33 takemura msg_printf(MSG_ERROR,
1058 1.33 takemura TEXT("Warning"),
1059 1.33 takemura TEXT("Sorry, palette failed"));
1060 1.21 takemura }
1061 1.21 takemura }
1062 1.21 takemura
1063 1.21 takemura /*
1064 1.21 takemura * Put WM_TIMER in my message queue.
1065 1.21 takemura * (WM_TIMER has lowest priority.)
1066 1.21 takemura */
1067 1.21 takemura SetTimer(hDlgLoad, 1, 1, NULL);
1068 1.21 takemura
1069 1.21 takemura /*
1070 1.21 takemura * I tried PeekMessage() but it does not work.
1071 1.21 takemura */
1072 1.21 takemura while (GetMessage(&msg, NULL, 0, 0)) {
1073 1.21 takemura if (msg.hwnd == hDlgLoad && msg.message == WM_TIMER) {
1074 1.21 takemura break;
1075 1.21 takemura }
1076 1.21 takemura TranslateMessage(&msg);
1077 1.21 takemura DispatchMessage(&msg);
1078 1.21 takemura }
1079 1.21 takemura
1080 1.21 takemura return (dlgStatus != 0);
1081 1.21 takemura }
1082 1.21 takemura
1083 1.44 takemura BOOL BootKernel(int directboot)
1084 1.44 takemura {
1085 1.44 takemura int argc;
1086 1.44 takemura int i;
1087 1.44 takemura TCHAR wkernel_name[PATHBUFLEN];
1088 1.44 takemura TCHAR woptions[PATHBUFLEN];
1089 1.44 takemura
1090 1.44 takemura char options[PATHBUFLEN*2], kernel_name[PATHBUFLEN*2];
1091 1.44 takemura
1092 1.44 takemura platid_t platid;
1093 1.44 takemura
1094 1.44 takemura char *p, *argv[32];
1095 1.44 takemura struct bootinfo bi;
1096 1.45 takemura
1097 1.44 takemura if (GetDlgItemText(hDlgMain, IDC_KERNEL, wkernel_name,
1098 1.44 takemura sizeof(wkernel_name)) == 0) {
1099 1.44 takemura MessageBox (NULL, TEXT("Kernel name required"),
1100 1.44 takemura szAppName, MB_OK);
1101 1.44 takemura return FALSE;
1102 1.44 takemura }
1103 1.44 takemura GetDlgItemText(hDlgMain, IDC_OPTIONS,
1104 1.44 takemura woptions, sizeof(woptions));
1105 1.44 takemura if (wcstombs(options, woptions, sizeof(options)) < 0 ||
1106 1.44 takemura wcstombs(kernel_name, wkernel_name,
1107 1.44 takemura sizeof(kernel_name)) < 0) {
1108 1.44 takemura MessageBox (NULL, TEXT("invalid character"),
1109 1.44 takemura szAppName, MB_OK);
1110 1.44 takemura return FALSE;
1111 1.44 takemura }
1112 1.44 takemura
1113 1.44 takemura argc = 0;
1114 1.44 takemura argv[argc++] = kernel_name;
1115 1.44 takemura p = options;
1116 1.44 takemura while (*p) {
1117 1.44 takemura while (*p == ' ' || *p == '\t') {
1118 1.44 takemura p++;
1119 1.44 takemura }
1120 1.44 takemura if (*p == '\0')
1121 1.44 takemura return FALSE;
1122 1.44 takemura if (ARRAYSIZEOF(argv) <= argc) {
1123 1.44 takemura MessageBox (NULL,
1124 1.44 takemura TEXT("too many options"),
1125 1.44 takemura szAppName, MB_OK);
1126 1.44 takemura argc++;
1127 1.44 takemura break;
1128 1.44 takemura } else {
1129 1.44 takemura argv[argc++] = p;
1130 1.44 takemura }
1131 1.44 takemura while (*p != ' ' && *p != '\t' && *p != '\0') {
1132 1.44 takemura p++;
1133 1.44 takemura }
1134 1.44 takemura if (*p == '\0') {
1135 1.44 takemura break;
1136 1.44 takemura } else {
1137 1.44 takemura *p++ = '\0';
1138 1.44 takemura }
1139 1.44 takemura }
1140 1.44 takemura if (ARRAYSIZEOF(argv) < argc) {
1141 1.44 takemura return FALSE;
1142 1.44 takemura }
1143 1.44 takemura
1144 1.44 takemura
1145 1.44 takemura EnableWindow(hDlgMain, FALSE);
1146 1.44 takemura
1147 1.44 takemura if (directboot || (MessageBox (hDlgMain,
1148 1.44 takemura TEXT("Data in memory will be lost.\nAre you sure?"),
1149 1.44 takemura szAppName,
1150 1.44 takemura MB_YESNO | MB_DEFBUTTON2 | MB_ICONHAND) == IDYES)) {
1151 1.44 takemura booting = FALSE;
1152 1.44 takemura dlgStatus = 0;
1153 1.44 takemura hDlgLoad =
1154 1.44 takemura CreateDialog(hInst,
1155 1.44 takemura MAKEINTRESOURCE(IDD_LOAD),
1156 1.44 takemura hDlgMain, DlgProc);
1157 1.44 takemura ShowWindow(hDlgLoad, SW_SHOWNORMAL);
1158 1.44 takemura BringWindowToTop(hDlgLoad);
1159 1.44 takemura
1160 1.44 takemura /*
1161 1.44 takemura * save settings.
1162 1.44 takemura */
1163 1.44 takemura pref.fb_type = fb_settings[0].type;
1164 1.44 takemura pref.fb_width = fb_settings[0].width;
1165 1.44 takemura pref.fb_height = fb_settings[0].height;
1166 1.44 takemura pref.fb_linebytes = fb_settings[0].linebytes;
1167 1.44 takemura pref.fb_addr = fb_settings[0].addr;
1168 1.44 takemura pref.platid_cpu = fb_settings[0].platid_cpu;
1169 1.44 takemura pref.platid_machine = fb_settings[0].platid_machine;
1170 1.44 takemura wstrcpy(pref.kernel_name, wkernel_name);
1171 1.44 takemura wstrcpy(pref.options, woptions);
1172 1.44 takemura
1173 1.44 takemura pref_save(path_list, path_list_items);
1174 1.44 takemura
1175 1.44 takemura SetBootInfo(&bi, &fb_settings[pref.setting_idx]);
1176 1.44 takemura debug_printf(TEXT("Args: "));
1177 1.44 takemura for (i = 0; i < argc; i++) {
1178 1.44 takemura debug_printf(TEXT("'%S' "), argv[i]);
1179 1.44 takemura }
1180 1.44 takemura debug_printf(TEXT("\n"));
1181 1.44 takemura debug_printf(TEXT("Bootinfo: fb_type=%d 0x%X %dx%d %d\n"),
1182 1.44 takemura bi.fb_type, bi.fb_addr,
1183 1.44 takemura bi.fb_width, bi.fb_height,
1184 1.44 takemura bi.fb_line_bytes);
1185 1.44 takemura
1186 1.44 takemura if (pref.serial_port) {
1187 1.44 takemura SerialPort(TRUE);
1188 1.44 takemura }
1189 1.44 takemura if (pref.reverse_video) {
1190 1.44 takemura bi.fb_type = reverse_fb_type(bi.fb_type);
1191 1.44 takemura }
1192 1.44 takemura /*
1193 1.44 takemura * Set system infomation
1194 1.44 takemura */
1195 1.44 takemura platid.dw.dw0 = bi.platid_cpu;
1196 1.44 takemura platid.dw.dw1 = bi.platid_machine;
1197 1.44 takemura if (set_system_info(&platid)) {
1198 1.44 takemura /*
1199 1.44 takemura * boot !
1200 1.44 takemura */
1201 1.44 takemura pbsdboot(wkernel_name, argc, argv, &bi);
1202 1.44 takemura }
1203 1.44 takemura /*
1204 1.44 takemura * Not return.
1205 1.44 takemura */
1206 1.44 takemura
1207 1.44 takemura if (pref.serial_port) {
1208 1.44 takemura SerialPort(FALSE);
1209 1.44 takemura }
1210 1.44 takemura
1211 1.44 takemura DestroyWindow(hDlgLoad);
1212 1.44 takemura }
1213 1.44 takemura EnableWindow(hDlgMain, TRUE);
1214 1.44 takemura
1215 1.44 takemura return FALSE;
1216 1.44 takemura }
1217 1.44 takemura
1218 1.45 takemura LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
1219 1.45 takemura WPARAM wParam, LPARAM lParam ){
1220 1.45 takemura switch (message) {
1221 1.45 takemura case WM_CREATE:
1222 1.45 takemura palette_init(hWnd);
1223 1.45 takemura break;
1224 1.45 takemura
1225 1.45 takemura case WM_PALETTECHANGED:
1226 1.45 takemura palette_check(hWnd);
1227 1.45 takemura break;
1228 1.45 takemura
1229 1.45 takemura case WM_QUERYNEWPALETTE:
1230 1.45 takemura return(TRUE);
1231 1.45 takemura
1232 1.45 takemura case WM_CLOSE:
1233 1.45 takemura sndPlaySound(TEXT("Close"), SND_NODEFAULT | SND_ASYNC);
1234 1.45 takemura
1235 1.45 takemura DestroyWindow(hWnd);
1236 1.45 takemura break;
1237 1.45 takemura
1238 1.45 takemura case WM_DESTROY:
1239 1.45 takemura PostQuitMessage(0);
1240 1.45 takemura break;
1241 1.45 takemura
1242 1.45 takemura default:
1243 1.45 takemura return (DefWindowProc(hWnd, message, wParam, lParam));
1244 1.45 takemura
1245 1.45 takemura }
1246 1.45 takemura return 0;
1247 1.45 takemura }
1248 1.45 takemura
1249 1.44 takemura BOOL CALLBACK MainDlgProc(HWND hWnd, UINT message,
1250 1.21 takemura WPARAM wParam, LPARAM lParam )
1251 1.21 takemura {
1252 1.21 takemura int i, idx;
1253 1.21 takemura
1254 1.21 takemura switch (message) {
1255 1.21 takemura case WM_CREATE:
1256 1.21 takemura sndPlaySound(TEXT("OpenProg"), SND_NODEFAULT | SND_ASYNC);
1257 1.21 takemura hWndCB = CommandBar_Create(hInst, hWnd, 1);
1258 1.21 takemura CommandBar_AddAdornments(hWndCB, STD_HELP, (DWORD)NULL);
1259 1.21 takemura break;
1260 1.21 takemura case WM_PAINT:
1261 1.21 takemura {
1262 1.21 takemura HDC hdc;
1263 1.21 takemura PAINTSTRUCT ps;
1264 1.21 takemura
1265 1.21 takemura hdc = BeginPaint(hWnd, &ps);
1266 1.21 takemura EndPaint(hWnd, &ps);
1267 1.21 takemura }
1268 1.21 takemura break;
1269 1.21 takemura
1270 1.33 takemura case WM_PALETTECHANGED:
1271 1.33 takemura palette_check(hWnd);
1272 1.33 takemura break;
1273 1.33 takemura
1274 1.21 takemura case WM_HELP:
1275 1.21 takemura /*
1276 1.21 takemura MessageBox (NULL, TEXT("HELP NOT AVAILABLE"),
1277 1.21 takemura szAppName, MB_OK);
1278 1.21 takemura */
1279 1.21 takemura DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), hWnd, DlgProc2);
1280 1.21 takemura break;
1281 1.21 takemura
1282 1.44 takemura
1283 1.44 takemura case WM_TIMER:
1284 1.44 takemura if(!booting){/* ignore! */
1285 1.44 takemura KillTimer(hWnd,IDD_TIMER);
1286 1.44 takemura stat_printf(TEXT("interrupt2"));
1287 1.44 takemura return (1);
1288 1.44 takemura }
1289 1.44 takemura if(how_long_to_boot > 0){
1290 1.44 takemura how_long_to_boot--;
1291 1.44 takemura stat_printf(
1292 1.44 takemura TEXT("autoboot after %d second,tap or hit any key to interrupt"),
1293 1.44 takemura how_long_to_boot);
1294 1.44 takemura }
1295 1.44 takemura else{
1296 1.44 takemura KillTimer(hWnd,IDD_TIMER);
1297 1.44 takemura BootKernel(1);
1298 1.44 takemura }
1299 1.44 takemura break;
1300 1.44 takemura
1301 1.21 takemura case WM_COMMAND:
1302 1.21 takemura switch (LOWORD(wParam)) {
1303 1.21 takemura case IDC_BOOT:
1304 1.44 takemura BootKernel(0);
1305 1.21 takemura break;
1306 1.21 takemura case IDC_FBSETTING:
1307 1.21 takemura if (DialogBox(hInst, MAKEINTRESOURCE(IDD_FB),
1308 1.44 takemura hDlgMain, FbDlgProc) == IDOK) {
1309 1.21 takemura /* User defined */
1310 1.21 takemura pref.setting_idx = 0;
1311 1.44 takemura SendDlgItemMessage(hDlgMain, IDC_FBSELECT,
1312 1.21 takemura CB_DELETESTRING,
1313 1.21 takemura (WPARAM)user_define_idx, 0);
1314 1.44 takemura SendDlgItemMessage(hDlgMain, IDC_FBSELECT,
1315 1.21 takemura CB_INSERTSTRING,
1316 1.21 takemura (WPARAM)user_define_idx,
1317 1.21 takemura (LPARAM)fb_settings[0].name);
1318 1.21 takemura SendDlgItemMessage(hWnd, IDC_FBSELECT,
1319 1.21 takemura CB_SETCURSEL, 0, 0);
1320 1.21 takemura }
1321 1.21 takemura break;
1322 1.44 takemura case IDC_PROPERTY:
1323 1.44 takemura DialogBox(hInst, MAKEINTRESOURCE(IDD_PROP), hWnd, PropDlgProc);
1324 1.44 takemura break;
1325 1.21 takemura case IDC_FBSELECT:
1326 1.21 takemura switch (HIWORD(wParam)) {
1327 1.21 takemura case CBN_SELCHANGE:
1328 1.21 takemura idx = SendDlgItemMessage(hWnd, IDC_FBSELECT,
1329 1.21 takemura CB_GETCURSEL, 0, 0);
1330 1.21 takemura i = SendDlgItemMessage(hWnd, IDC_FBSELECT,
1331 1.21 takemura CB_GETITEMDATA, idx, 0);
1332 1.21 takemura if (0 <= i && i < ARRAYSIZEOF(fb_settings)) {
1333 1.21 takemura debug_printf(TEXT("fb_setting=%d\n"), i);
1334 1.21 takemura pref.setting_idx = i;
1335 1.21 takemura }
1336 1.21 takemura break;
1337 1.21 takemura }
1338 1.21 takemura break;
1339 1.21 takemura }
1340 1.21 takemura break;
1341 1.21 takemura
1342 1.21 takemura case WM_HIBERNATE:
1343 1.21 takemura MessageBox(NULL, TEXT("MEMORY IS LOW"), szAppName, MB_OK);
1344 1.21 takemura //Additional code to handle a low memory situation
1345 1.21 takemura
1346 1.21 takemura case WM_CLOSE:
1347 1.21 takemura sndPlaySound(TEXT("Close"), SND_NODEFAULT | SND_ASYNC);
1348 1.21 takemura
1349 1.21 takemura DestroyWindow(hWnd);
1350 1.21 takemura break;
1351 1.21 takemura
1352 1.21 takemura case WM_DESTROY:
1353 1.21 takemura PostQuitMessage(0);
1354 1.21 takemura break;
1355 1.21 takemura
1356 1.21 takemura }
1357 1.21 takemura
1358 1.21 takemura return (0);
1359 1.21 takemura }
1360 1.21 takemura
1361 1.21 takemura
1362