Home | History | Annotate | Line # | Download | only in pbsdboot
main.c revision 1.41
      1  1.41  takemura /*	$NetBSD: main.c,v 1.41 2000/05/20 07:11:25 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.41  takemura 	TEXT("Version 1.13.4 2000.05.20\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.21  takemura struct fb_setting {
     90  1.21  takemura 	TCHAR *name;
     91  1.21  takemura 	int type;
     92  1.21  takemura 	int width, height, linebytes;
     93  1.21  takemura 	long addr;
     94  1.21  takemura 	unsigned long platid_cpu, platid_machine;
     95  1.21  takemura };
     96  1.21  takemura 
     97  1.21  takemura /*-----------------------------------------------------------------------------
     98  1.21  takemura 
     99  1.21  takemura   variable declarations
    100  1.21  takemura 
    101  1.21  takemura -----------------------------------------------------------------------------*/
    102  1.21  takemura HINSTANCE  hInst = NULL;
    103  1.21  takemura HWND		hWndMain;
    104  1.21  takemura HWND		hWndCB = NULL;
    105  1.21  takemura HWND		hDlgLoad = NULL;
    106  1.21  takemura unsigned int	dlgStatus;
    107  1.21  takemura int		user_define_idx;
    108  1.39  takemura int		osversion;
    109  1.21  takemura 
    110  1.21  takemura /*-----------------------------------------------------------------------------
    111  1.21  takemura 
    112  1.21  takemura   data
    113  1.21  takemura 
    114  1.21  takemura -----------------------------------------------------------------------------*/
    115  1.21  takemura TCHAR szAppName[ ] = TEXT("PocketBSD boot");
    116  1.21  takemura TCHAR szTitle[ ]   = TEXT("Welcome to PocketBSD!");
    117  1.21  takemura 
    118  1.33  takemura /*
    119  1.33  takemura  * Wince_conf  identify executable binary file.
    120  1.33  takemura  */
    121  1.33  takemura #if ( _WIN32_WCE < 200 )
    122  1.33  takemura static char *wince_conf = "Compiled for WinCE 1.01";
    123  1.33  takemura #else
    124  1.33  takemura static char *wince_conf = "Compiled for WinCE 2.00";
    125  1.33  takemura #endif
    126  1.33  takemura 
    127  1.21  takemura struct fb_type fb_types[] = {
    128  1.21  takemura 	{ BIFB_D2_M2L_3,	TEXT(BIFBN_D2_M2L_3)	},
    129  1.21  takemura 	{ BIFB_D2_M2L_3x2,	TEXT(BIFBN_D2_M2L_3x2)	},
    130  1.21  takemura 	{ BIFB_D2_M2L_0,	TEXT(BIFBN_D2_M2L_0)	},
    131  1.21  takemura 	{ BIFB_D8_00,		TEXT(BIFBN_D8_00)	},
    132  1.21  takemura 	{ BIFB_D8_FF,		TEXT(BIFBN_D8_FF)	},
    133  1.21  takemura 	{ BIFB_D16_0000,	TEXT(BIFBN_D16_0000)	},
    134  1.21  takemura 	{ BIFB_D16_FFFF,	TEXT(BIFBN_D16_FFFF)	},
    135  1.21  takemura };
    136  1.21  takemura 
    137  1.21  takemura int fb_size[] = {
    138  1.21  takemura 	160, 240, 320, 400, 480, 600, 640,
    139  1.21  takemura 	768, 800, 1024, 1150, 1280, 1600
    140  1.21  takemura };
    141  1.21  takemura 
    142  1.21  takemura int fb_bpl[] = {
    143  1.21  takemura 	40, 80, 128, 160, 240, 256, 320,
    144  1.21  takemura 	384, 400, 480, 512, 600, 640, 768, 800, 1024, 1150, 1280, 1600
    145  1.21  takemura };
    146  1.21  takemura 
    147  1.21  takemura struct fb_setting fb_settings[] = {
    148  1.25  takemura 	/*
    149  1.25  takemura 	 * You must choose fb_type to make the screen look black-on-white.
    150  1.25  takemura 	 * (Foreground color is black and background color is white.)
    151  1.25  takemura 	 */
    152  1.21  takemura 	{ NULL, BIFB_D2_M2L_3,
    153  1.21  takemura 		320, 240, 80, 0xa000000,
    154  1.21  takemura 		PLATID_UNKNOWN, PLATID_UNKNOWN },
    155  1.21  takemura 	{ TEXT("FreeStyle"), BIFB_D2_M2L_3,
    156  1.21  takemura 		320, 240, 80, 0xa000000,
    157  1.21  takemura 		PLATID_CPU_MIPS_VR_41XX, PLATID_MACH_EVEREX_FREESTYLE_AXX },
    158  1.21  takemura 	{ TEXT("FreeStyle(Small Font)"), BIFB_D2_M2L_3x2,
    159  1.21  takemura 		640, 240, 80, 0xa000000,
    160  1.21  takemura 		PLATID_CPU_MIPS_VR_41XX, PLATID_MACH_EVEREX_FREESTYLE_AXX },
    161  1.30  takemura 	{ TEXT("MobileGear MC-CS11"), BIFB_D2_M2L_0,
    162  1.21  takemura 		480, 240, 256, 0xa000000,
    163  1.30  takemura 		PLATID_CPU_MIPS_VR_4102, PLATID_MACH_NEC_MCCS_11 },
    164  1.30  takemura 	{ TEXT("MobileGear MC-CS12"), BIFB_D2_M2L_0,
    165  1.30  takemura 		480, 240, 256, 0xa000000,
    166  1.30  takemura 		PLATID_CPU_MIPS_VR_4102, PLATID_MACH_NEC_MCCS_12 },
    167  1.30  takemura 	{ TEXT("MobileGear MC-CS13"), BIFB_D2_M2L_0,
    168  1.30  takemura 		480, 240, 256, 0xa000000,
    169  1.30  takemura 		PLATID_CPU_MIPS_VR_4102, PLATID_MACH_NEC_MCCS_13 },
    170  1.35       jun 	{ TEXT("Mobile Pro 700"), BIFB_D2_M2L_0,
    171  1.35       jun 		640, 240, 256, 0xa000000,
    172  1.35       jun 		PLATID_CPU_MIPS_VR_4102, PLATID_MACH_NEC_MCR_MPRO700 },
    173  1.21  takemura 	{ TEXT("MobileGearII MC-R300"), BIFB_D2_M2L_0,
    174  1.21  takemura 		640, 240, 256, 0xa000000,
    175  1.21  takemura 		PLATID_CPU_MIPS_VR_4111, PLATID_MACH_NEC_MCR_300 },
    176  1.21  takemura 	{ TEXT("MobileGearII for DoCoMo"), BIFB_D2_M2L_0,
    177  1.21  takemura 		640, 240, 256, 0xa000000,
    178  1.21  takemura 		PLATID_CPU_MIPS_VR_4111, PLATID_MACH_NEC_MCR_FORDOCOMO },
    179  1.21  takemura 	{ TEXT("MobileGearII MC-R320"), BIFB_D2_M2L_0,
    180  1.21  takemura 		640, 240, 160, 0xa000000,
    181  1.21  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_320 },
    182  1.25  takemura 	{ TEXT("MobileGearII MC/R430"), BIFB_D16_0000,
    183  1.23  takemura 		640, 240, 1280, 0xa180100,
    184  1.23  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_430 },
    185  1.25  takemura 	{ TEXT("MobileGearII MC-R500"), BIFB_D8_00,
    186  1.21  takemura 		640, 240, 1024, 0x13000000,
    187  1.21  takemura 		PLATID_CPU_MIPS_VR_4111, PLATID_MACH_NEC_MCR_500 },
    188  1.25  takemura 	{ TEXT("Mobile Pro 750c"), BIFB_D8_00,
    189  1.21  takemura 		640, 240, 1024, 0x13000000,
    190  1.21  takemura 		PLATID_CPU_MIPS_VR_4111, PLATID_MACH_NEC_MCR_500A },
    191  1.21  takemura 	{ TEXT("MobileGearII MC-R510"), BIFB_D8_00,
    192  1.21  takemura 		640, 240, 1024, 0xa000000,
    193  1.21  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_510 },
    194  1.21  takemura 	{ TEXT("NEC MC-R510(15bit color)"), BIFB_D16_0000,
    195  1.21  takemura 		640, 240, 1600, 0xa000000,
    196  1.21  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_510 },
    197  1.21  takemura 	{ TEXT("MobileGearII MC-R520"), BIFB_D16_0000,
    198  1.21  takemura 		640, 240, 1600, 0xa000000,
    199  1.21  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_520 },
    200  1.40  takemura 	{ TEXT("NEC MC/R530(256 colors)"), BIFB_D8_00,
    201  1.40  takemura 		640, 240, 640, 0xa1d4c00,
    202  1.40  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_530 },
    203  1.25  takemura 	{ TEXT("MobileGearII MC/R530"), BIFB_D16_0000,
    204  1.21  takemura 		640, 240, 1280, 0xa180100,
    205  1.21  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_530 },
    206  1.21  takemura 	{ TEXT("Mobile Pro 770"), BIFB_D16_0000,
    207  1.21  takemura 		640, 240, 1600, 0xa000000,
    208  1.21  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_520A },
    209  1.41  takemura 	{ TEXT("Mobile Pro 780"), BIFB_D16_0000,
    210  1.41  takemura 		640, 240, 1280, 0xa180100,
    211  1.41  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_530A },
    212  1.21  takemura 	{ TEXT("MobileGearII MC-R700"), BIFB_D16_0000,
    213  1.21  takemura 		800, 600, 1600, 0xa000000,
    214  1.21  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_700 },
    215  1.21  takemura 	{ TEXT("Mobile Pro 800"), BIFB_D16_0000,
    216  1.21  takemura 		800, 600, 1600, 0xa000000,
    217  1.21  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_700A },
    218  1.24      shin 	{ TEXT("MobileGearII MC/R730"), BIFB_D16_0000,
    219  1.24      shin 		800, 600, 1600, 0xa0ea600,
    220  1.24      shin 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_730 },
    221  1.41  takemura 	{ TEXT("Mobile Pro 880"), BIFB_D16_0000,
    222  1.41  takemura 		800, 600, 1600, 0xa0ea600,
    223  1.41  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_NEC_MCR_730A },
    224  1.32      shin 	{ TEXT("Tripad PV-6000"), BIFB_D8_00,
    225  1.21  takemura 		640, 480, 640, 0xa000000,
    226  1.21  takemura 		PLATID_CPU_MIPS_VR_4111, PLATID_MACH_SHARP_TRIPAD_PV6000 },
    227  1.41  takemura 	{ TEXT("Vadem Clio C-1000"), BIFB_D8_00,
    228  1.21  takemura 		640, 480, 640, 0xa000000,
    229  1.21  takemura 		PLATID_CPU_MIPS_VR_4111, PLATID_MACH_SHARP_TRIPAD_PV6000 },
    230  1.41  takemura 	{ TEXT("Vadem Clio C-1050"), BIFB_D16_FFFF,
    231  1.41  takemura 		640, 480, 1280, 0xa200000,
    232  1.41  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_SHARP_TRIPAD_PV6000 },
    233  1.21  takemura 	{ TEXT("E-55"), BIFB_D2_M2L_0,
    234  1.21  takemura 		240, 320, 256, 0xa000000,
    235  1.21  takemura 		PLATID_CPU_MIPS_VR_4111, PLATID_MACH_CASIO_CASSIOPEIAE_E55 },
    236  1.21  takemura 	{ TEXT("E-55(Small Font)"), BIFB_D2_M2L_0x2,
    237  1.21  takemura 		480, 320, 256, 0xa000000,
    238  1.21  takemura 		PLATID_CPU_MIPS_VR_4111, PLATID_MACH_CASIO_CASSIOPEIAE_E55 },
    239  1.21  takemura 	{ TEXT("E-100"), BIFB_D16_FFFF,
    240  1.21  takemura 		240, 320, 512, 0xa200000,
    241  1.21  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_CASIO_CASSIOPEIAE_E100 },
    242  1.21  takemura 	{ TEXT("E-500"), BIFB_D16_FFFF,
    243  1.21  takemura 		240, 320, 512, 0xa200000,
    244  1.21  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_CASIO_CASSIOPEIAE_E500 },
    245  1.32      shin 	{ TEXT("INTERTOP CX300"), BIFB_D8_00,
    246  1.21  takemura 		640, 480, 640, 0xa000000,
    247  1.21  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_FUJITSU_INTERTOP_IT300 },
    248  1.32      shin 	{ TEXT("INTERTOP CX310"), BIFB_D8_00,
    249  1.21  takemura 		640, 480, 640, 0xa000000,
    250  1.21  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_FUJITSU_INTERTOP_IT310 },
    251  1.21  takemura 	{ TEXT("IBM WorkPad z50"), BIFB_D16_0000,
    252  1.21  takemura 		640, 480, 1280, 0xa000000,
    253  1.27  takemura 		PLATID_CPU_MIPS_VR_4121, PLATID_MACH_IBM_WORKPAD_26011AU },
    254  1.21  takemura 	{ TEXT("Philips Nino 312"), BIFB_D2_M2L_0,
    255  1.21  takemura 		240, 320, 0, 0,
    256  1.21  takemura 		PLATID_CPU_MIPS_TX_3912, PLATID_MACH_PHILIPS_NINO_312 },
    257  1.21  takemura 	{ TEXT("Compaq C-series 810"), BIFB_D2_M2L_0,
    258  1.21  takemura 		640, 240, 0, 0,
    259  1.21  takemura 		PLATID_CPU_MIPS_TX_3912, PLATID_MACH_COMPAQ_C_810 },
    260  1.32      shin 	{ TEXT("Compaq C-series 2010c"), BIFB_D8_00,
    261  1.21  takemura 		640, 240, 0, 0,
    262  1.21  takemura 		PLATID_CPU_MIPS_TX_3912, PLATID_MACH_COMPAQ_C_2010 },
    263  1.32      shin 	{ TEXT("Compaq C-series 2015c"), BIFB_D8_00,
    264  1.21  takemura 		640, 240, 0, 0,
    265  1.21  takemura 		PLATID_CPU_MIPS_TX_3912, PLATID_MACH_COMPAQ_C_2015 },
    266  1.21  takemura 	{ TEXT("Compaq PRESARIO 213"), BIFB_D8_00,
    267  1.21  takemura 		320, 240, 0, 0,
    268  1.21  takemura 		PLATID_CPU_MIPS_VR_4111, PLATID_MACH_COMPAQ_PRESARIO_213 },
    269  1.21  takemura 	{ TEXT("Compaq Aero 1530"), BIFB_D2_M2L_0,
    270  1.21  takemura 		320, 240, 0, 0,
    271  1.21  takemura 		PLATID_CPU_MIPS_VR_4111, PLATID_MACH_COMPAQ_AERO_1530 },
    272  1.21  takemura 	{ TEXT("Victor InterLink MP-C101"), BIFB_D16_0000,
    273  1.21  takemura 		640, 480, 0, 0,
    274  1.21  takemura 		PLATID_CPU_MIPS_TX_3922, PLATID_MACH_VICTOR_INTERLINK_MPC101},
    275  1.32      shin 	{ TEXT("Sharp Telios HC-AJ1"), BIFB_D16_0000,
    276  1.21  takemura 		800, 600, 0, 0,
    277  1.21  takemura 		PLATID_CPU_MIPS_TX_3922, PLATID_MACH_SHARP_TELIOS_HCAJ1},
    278  1.21  takemura 	{ TEXT("Sharp Mobilon HC-4100"), BIFB_D2_M2L_0, /* XXX 4bit greyscale */
    279  1.21  takemura 		640, 240, 0, 0,
    280  1.21  takemura 		PLATID_CPU_MIPS_TX_3912, PLATID_MACH_SHARP_MOBILON_HC4100},
    281  1.28       jun 	{ TEXT("Sharp HC-1200"), BIFB_D2_M2L_0, /* XXX 4bit greyscale */
    282  1.28       jun 		640, 240, 0, 0,
    283  1.28       jun 		PLATID_CPU_MIPS_TX_3912, PLATID_MACH_SHARP_MOBILON_HC1200},
    284  1.21  takemura };
    285  1.21  takemura 
    286  1.21  takemura #define ARRAYSIZEOF(a)	(sizeof(a)/sizeof(*(a)))
    287  1.21  takemura 
    288  1.21  takemura #ifdef UNDER_CE
    289  1.21  takemura 	/* 'memory card' in HANKAKU KANA */
    290  1.21  takemura #define UNICODE_MEMORY_CARD \
    291  1.21  takemura 	TEXT('\\'), 0xff92, 0xff93, 0xff98, TEXT(' '), 0xff76, 0xff70, \
    292  1.21  takemura 	0xff84, 0xff9e
    293  1.21  takemura TCHAR unicode_memory_card[] = { UNICODE_MEMORY_CARD,  TEXT('\\') };
    294  1.21  takemura TCHAR unicode_memory_card1[] = { UNICODE_MEMORY_CARD,  TEXT('1'), TEXT('\\') };
    295  1.21  takemura TCHAR unicode_memory_card2[] = { UNICODE_MEMORY_CARD,  TEXT('2'), TEXT('\\') };
    296  1.21  takemura #endif
    297  1.21  takemura 
    298  1.33  takemura #define LANGID_DEFAULT MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT)
    299  1.33  takemura struct path_s path_list[] = {
    300  1.33  takemura 	{ TEXT("/"),
    301  1.33  takemura 	  LANGID_DEFAULT, 0 },
    302  1.33  takemura 	{ TEXT("2:/"),
    303  1.33  takemura 	  LANGID_DEFAULT, 0 },
    304  1.33  takemura 	{ TEXT("\\"),
    305  1.33  takemura 	  LANGID_DEFAULT, 0 },
    306  1.33  takemura 	{ TEXT("\\My Documents\\"),
    307  1.33  takemura 	  LANGID_DEFAULT, 0 },
    308  1.33  takemura 	{ TEXT("\\Storage Card\\"),
    309  1.33  takemura 	  LANGID_DEFAULT, PATH_SAVE },
    310  1.33  takemura 	{ TEXT("\\Storage Card1\\"),
    311  1.33  takemura 	  LANGID_DEFAULT, PATH_SAVE },
    312  1.33  takemura 	{ TEXT("\\Storage Card2\\"),
    313  1.33  takemura 	  LANGID_DEFAULT, PATH_SAVE },
    314  1.21  takemura #ifdef UNDER_CE
    315  1.33  takemura 	{ unicode_memory_card,
    316  1.33  takemura 	  MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), PATH_SAVE },
    317  1.33  takemura 	{ unicode_memory_card1,
    318  1.33  takemura 	  MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), PATH_SAVE },
    319  1.33  takemura 	{ unicode_memory_card2,
    320  1.33  takemura 	  MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), PATH_SAVE },
    321  1.21  takemura #endif
    322  1.21  takemura };
    323  1.21  takemura int path_list_items = ARRAYSIZEOF(path_list);
    324  1.21  takemura 
    325  1.21  takemura #ifdef ADDITIONAL_KERNELS
    326  1.21  takemura TCHAR* kernel_list[] = {
    327  1.21  takemura 
    328  1.21  takemura };
    329  1.21  takemura int kernel_list_items = ARRAYSIZEOF(kernel_list);
    330  1.21  takemura #endif
    331  1.21  takemura 
    332  1.21  takemura /*-----------------------------------------------------------------------------
    333  1.21  takemura 
    334  1.21  takemura   function prototypes
    335  1.21  takemura 
    336  1.21  takemura -----------------------------------------------------------------------------*/
    337  1.21  takemura LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    338  1.21  takemura void SetBootInfo(struct bootinfo *bi, struct fb_setting *fbs);
    339  1.21  takemura void wstrcpy(TCHAR* dst, TCHAR* src);
    340  1.26       cgd int reverse_fb_type(int type);
    341  1.21  takemura 
    342  1.21  takemura /*-----------------------------------------------------------------------------
    343  1.21  takemura 
    344  1.21  takemura   function definitions
    345  1.21  takemura 
    346  1.21  takemura -----------------------------------------------------------------------------*/
    347  1.21  takemura void wstrcpy(TCHAR* dst, TCHAR* src)
    348  1.21  takemura {
    349  1.21  takemura 	while (*src) {
    350  1.21  takemura 		*dst++ = *src++;
    351  1.21  takemura 	}
    352  1.21  takemura 	*dst = *src;
    353  1.26       cgd }
    354  1.26       cgd 
    355  1.26       cgd int reverse_fb_type(int type)
    356  1.26       cgd {
    357  1.26       cgd 	int i;
    358  1.26       cgd 	struct {
    359  1.26       cgd 		int type0, type1;
    360  1.26       cgd 	} types[] = {
    361  1.26       cgd 		{ BIFB_D2_M2L_3,	BIFB_D2_M2L_0	},
    362  1.26       cgd 		{ BIFB_D2_M2L_3x2,	BIFB_D2_M2L_0x2	},
    363  1.26       cgd 		{ BIFB_D8_FF,		BIFB_D8_00		},
    364  1.26       cgd 		{ BIFB_D16_FFFF,	BIFB_D16_0000,	},
    365  1.26       cgd 	};
    366  1.26       cgd 
    367  1.26       cgd 	for (i = 0; i < ARRAYSIZEOF(types); i++) {
    368  1.26       cgd 		if (types[i].type0 == type) {
    369  1.26       cgd 			return (types[i].type1);
    370  1.26       cgd 		}
    371  1.26       cgd 		if (types[i].type1 == type) {
    372  1.26       cgd 			return (types[i].type0);
    373  1.26       cgd 		}
    374  1.26       cgd 	}
    375  1.26       cgd 	debug_printf(TEXT("reverse_fb_type(): unknown type %d\n"), type);
    376  1.26       cgd 	return (type);
    377  1.21  takemura }
    378  1.21  takemura 
    379  1.21  takemura int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    380  1.21  takemura                     LPTSTR lpCmdLine, int nCmdShow )
    381  1.21  takemura {
    382  1.21  takemura 	MSG          msg;
    383  1.21  takemura 	WNDCLASS     wc;
    384  1.21  takemura 	int i, idx;
    385  1.21  takemura 	RECT rect;
    386  1.39  takemura #if ( 200 <= _WIN32_WCE )
    387  1.39  takemura 	OSVERSIONINFO	osverinfo;
    388  1.39  takemura 
    389  1.39  takemura 	osverinfo.dwOSVersionInfoSize = sizeof(osverinfo);
    390  1.39  takemura 	if (!GetVersionEx(&osverinfo)) {
    391  1.39  takemura 		msg_printf(MSG_ERROR,
    392  1.39  takemura 			   TEXT("Error"),
    393  1.39  takemura 			   TEXT("GetVersionEx() failed"));
    394  1.39  takemura 	}
    395  1.39  takemura 	osversion = osverinfo.dwMajorVersion * 100 + osverinfo.dwMinorVersion;
    396  1.39  takemura #else
    397  1.39  takemura 	osversion = 100;
    398  1.39  takemura #endif
    399  1.21  takemura 
    400  1.21  takemura 	wc.style          = (UINT)NULL;
    401  1.21  takemura 	wc.lpfnWndProc    = (WNDPROC) WndProc;
    402  1.21  takemura 	wc.cbClsExtra     = 0;
    403  1.21  takemura 	wc.cbWndExtra     = 0;
    404  1.21  takemura 	wc.hInstance      = hInstance;
    405  1.21  takemura 	wc.hIcon          = NULL;
    406  1.21  takemura 	wc.hCursor        = NULL;
    407  1.21  takemura 	wc.hbrBackground  = (HBRUSH) GetStockObject(WHITE_BRUSH);
    408  1.21  takemura 	wc.lpszMenuName   = NULL;
    409  1.21  takemura 	wc.lpszClassName  = whoami;
    410  1.21  takemura 
    411  1.21  takemura 	RegisterClass(&wc);
    412  1.21  takemura 
    413  1.21  takemura 	InitCommonControls();   // Initialize common controls - command bar
    414  1.21  takemura 	hInst = hInstance;      // Save handle to create command bar
    415  1.21  takemura 
    416  1.21  takemura 	hardware_test();
    417  1.21  takemura 
    418  1.21  takemura 	/*
    419  1.21  takemura 	 *	Main Window
    420  1.21  takemura          */
    421  1.37  takemura #define WS_EX_CONTROLPARENT     0x00010000L
    422  1.37  takemura 	hWndMain = CreateWindowEx(WS_EX_CONTROLPARENT,
    423  1.37  takemura 				  szAppName,
    424  1.37  takemura 				  szTitle,
    425  1.37  takemura 				  WS_VISIBLE,
    426  1.37  takemura 				  CW_USEDEFAULT,
    427  1.37  takemura 				  CW_USEDEFAULT,
    428  1.37  takemura 				  CW_USEDEFAULT,
    429  1.37  takemura 				  CW_USEDEFAULT,
    430  1.37  takemura 				  NULL,
    431  1.37  takemura 				  NULL,
    432  1.37  takemura 				  hInstance,
    433  1.37  takemura 				  NULL);
    434  1.21  takemura 
    435  1.21  takemura 	GetClientRect(hWndMain, &rect);
    436  1.21  takemura 	if (rect.right < rect.bottom) {
    437  1.21  takemura 		/*
    438  1.21  takemura 		 *	portrait
    439  1.21  takemura 		 */
    440  1.21  takemura 		CreateMainWindow(hInst, hWndMain,
    441  1.21  takemura 				 MAKEINTRESOURCE(IDD_MAIN_240X320),
    442  1.21  takemura 				 CommandBar_Height(hWndCB));
    443  1.21  takemura 	} else {
    444  1.21  takemura 		/*
    445  1.21  takemura 		 *	landscape
    446  1.21  takemura 		 */
    447  1.21  takemura 		CreateMainWindow(hInst, hWndMain,
    448  1.21  takemura 				 MAKEINTRESOURCE(IDD_MAIN_640X240),
    449  1.21  takemura 				 CommandBar_Height(hWndCB));
    450  1.21  takemura 	}
    451  1.37  takemura 	SetFocus(GetDlgItem(hWndMain, IDC_BOOT));
    452  1.21  takemura 
    453  1.21  takemura 	/*
    454  1.21  takemura 	 *  load preferences
    455  1.21  takemura 	 */
    456  1.21  takemura 	pref_init(&pref);
    457  1.21  takemura 	if (pref_load(path_list, path_list_items) == 0) {
    458  1.21  takemura 		TCHAR tmp[256];
    459  1.21  takemura 		wsprintf(tmp, TEXT("%s is loaded."), where_pref_load_from);
    460  1.21  takemura 		SetDlgItemText(hWndMain, IDC_STATUS, tmp);
    461  1.21  takemura 
    462  1.21  takemura 		fb_settings[0].type = pref.fb_type;
    463  1.21  takemura 		fb_settings[0].width = pref.fb_width;
    464  1.21  takemura 		fb_settings[0].height = pref.fb_height;
    465  1.21  takemura 		fb_settings[0].linebytes = pref.fb_linebytes;
    466  1.21  takemura 		fb_settings[0].addr = pref.fb_addr;
    467  1.21  takemura 		fb_settings[0].platid_cpu = pref.platid_cpu;
    468  1.21  takemura 		fb_settings[0].platid_machine = pref.platid_machine;
    469  1.21  takemura 	} else {
    470  1.21  takemura 		TCHAR tmpbuf[PATHBUFLEN];
    471  1.33  takemura 		wsprintf(tmpbuf, TEXT("%s%S"), path_list[0].name, "netbsd");
    472  1.21  takemura 		SetDlgItemText(hWndMain, IDC_STATUS,
    473  1.21  takemura 			       TEXT("preferences not loaded."));
    474  1.21  takemura 
    475  1.21  takemura 		pref.setting_idx = 1;
    476  1.21  takemura 		pref.fb_type = fb_settings[0].type;
    477  1.21  takemura 		pref.fb_width = fb_settings[0].width;
    478  1.21  takemura 		pref.fb_height = fb_settings[0].height;
    479  1.21  takemura 		pref.fb_linebytes = fb_settings[0].linebytes;
    480  1.21  takemura 		pref.fb_addr = fb_settings[0].addr;
    481  1.21  takemura 		pref.platid_cpu = fb_settings[0].platid_cpu;
    482  1.21  takemura 		pref.platid_machine = fb_settings[0].platid_machine;
    483  1.21  takemura 		wstrcpy(pref.setting_name, TEXT("User defined"));
    484  1.21  takemura 		wstrcpy(pref.kernel_name, tmpbuf);
    485  1.21  takemura 		wstrcpy(pref.options, TEXT(""));
    486  1.21  takemura 		pref.check_last_chance = FALSE;
    487  1.21  takemura 		pref.load_debug_info = FALSE;
    488  1.21  takemura 		pref.serial_port = FALSE;
    489  1.25  takemura 		pref.reverse_video = FALSE;
    490  1.21  takemura 	}
    491  1.21  takemura 	fb_settings[0].name = pref.setting_name;
    492  1.21  takemura 
    493  1.21  takemura 	/*
    494  1.21  takemura 	 *  initialize kernel file name list.
    495  1.21  takemura 	 */
    496  1.21  takemura 	for (i = 0; i < path_list_items; i++) {
    497  1.33  takemura 		if (path_list[i].langid == LANGID_DEFAULT ||
    498  1.33  takemura 		    path_list[i].langid == GetSystemDefaultLangID()) {
    499  1.33  takemura 			TCHAR tmpbuf[1024];
    500  1.33  takemura 			wsprintf(tmpbuf, TEXT("%s%S"),
    501  1.33  takemura 			    path_list[i].name, "netbsd");
    502  1.33  takemura 			SendDlgItemMessage(hWndMain, IDC_KERNEL,
    503  1.33  takemura 			    CB_ADDSTRING, 0, (LPARAM)tmpbuf);
    504  1.33  takemura 		}
    505  1.21  takemura 	}
    506  1.21  takemura #ifdef ADDITIONAL_KERNELS
    507  1.21  takemura 	for (i = 0; i < kernel_list_items; i++) {
    508  1.21  takemura 		SendDlgItemMessage(hWndMain, IDC_KERNEL, CB_ADDSTRING, 0,
    509  1.21  takemura 				   (LPARAM)kernel_list[i]);
    510  1.21  takemura 	}
    511  1.21  takemura #endif
    512  1.21  takemura 	/*
    513  1.21  takemura 	SendDlgItemMessage(hWndMain, IDC_KERNEL, CB_SETCURSEL, 0,
    514  1.21  takemura 			   (LPARAM)NULL);
    515  1.21  takemura 	*/
    516  1.21  takemura 	SetDlgItemText(hWndMain, IDC_KERNEL, pref.kernel_name);
    517  1.21  takemura 	SetDlgItemText(hWndMain, IDC_OPTIONS, pref.options);
    518  1.21  takemura 
    519  1.21  takemura 	/*
    520  1.21  takemura 	 *  Frame Buffer setting names.
    521  1.21  takemura 	 */
    522  1.21  takemura 	for (i = 0; i < ARRAYSIZEOF(fb_settings); i++) {
    523  1.21  takemura 		idx = SendDlgItemMessage(hWndMain, IDC_FBSELECT, CB_ADDSTRING,
    524  1.21  takemura 					 0, (LPARAM)fb_settings[i].name);
    525  1.21  takemura 		SendDlgItemMessage(hWndMain, IDC_FBSELECT,
    526  1.21  takemura 				   CB_SETITEMDATA, idx, (LPARAM)i);
    527  1.21  takemura 		if (i == 0) {
    528  1.21  takemura 			user_define_idx = idx;
    529  1.21  takemura 		}
    530  1.21  takemura 	}
    531  1.21  takemura 	SendDlgItemMessage(hWndMain, IDC_FBSELECT, CB_SETCURSEL,
    532  1.21  takemura 			   pref.setting_idx, (LPARAM)NULL);
    533  1.21  takemura 	/*
    534  1.21  takemura 	 *  Check box, 'Pause before boot'
    535  1.21  takemura 	 */
    536  1.21  takemura 	SendDlgItemMessage(hWndMain, IDC_PAUSE, BM_SETCHECK,
    537  1.21  takemura 			   pref.check_last_chance, 0);
    538  1.21  takemura 	SendDlgItemMessage(hWndMain, IDC_DEBUG, BM_SETCHECK,
    539  1.21  takemura 			   pref.load_debug_info, 0);
    540  1.21  takemura 	SendDlgItemMessage(hWndMain, IDC_COMM, BM_SETCHECK,
    541  1.21  takemura 			   pref.serial_port, 0);
    542  1.25  takemura 	SendDlgItemMessage(hWndMain, IDC_REVERSEVIDEO, BM_SETCHECK,
    543  1.25  takemura 			   pref.reverse_video, 0);
    544  1.21  takemura 
    545  1.21  takemura 	/*
    546  1.21  takemura 	 *  Map window and message loop
    547  1.21  takemura 	 */
    548  1.21  takemura 	ShowWindow(hWndMain, SW_SHOW);
    549  1.21  takemura 	UpdateWindow(hWndMain);
    550  1.37  takemura 	while (GetMessage(&msg, NULL, 0, 0)) {
    551  1.39  takemura 		if (osversion < 211 ||
    552  1.39  takemura 		    hWndMain == 0 || !IsDialogMessage(hWndMain, &msg)) {
    553  1.37  takemura 			TranslateMessage(&msg);
    554  1.37  takemura 			DispatchMessage(&msg);
    555  1.37  takemura 		}
    556  1.21  takemura 	}
    557  1.21  takemura 
    558  1.21  takemura 	return(msg.wParam);
    559  1.21  takemura }
    560  1.21  takemura 
    561  1.21  takemura BOOL CALLBACK DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    562  1.21  takemura {
    563  1.21  takemura 	switch (message) {
    564  1.21  takemura 	case WM_INITDIALOG:
    565  1.21  takemura 		return (1);
    566  1.21  takemura 
    567  1.33  takemura 	case WM_PALETTECHANGED:
    568  1.33  takemura 		palette_check(hWnd);
    569  1.33  takemura 		break;
    570  1.33  takemura 
    571  1.21  takemura 	case WM_COMMAND:
    572  1.21  takemura 		switch (LOWORD(wParam)) {
    573  1.21  takemura 		case IDCANCEL:
    574  1.21  takemura 			dlgStatus = IDCANCEL;
    575  1.21  takemura 			break;
    576  1.21  takemura 		}
    577  1.21  takemura 		break;
    578  1.21  takemura 	default:
    579  1.21  takemura 		return (0);
    580  1.21  takemura 	}
    581  1.21  takemura }
    582  1.21  takemura 
    583  1.21  takemura BOOL CALLBACK DlgProc2(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    584  1.21  takemura {
    585  1.21  takemura 	switch (message) {
    586  1.21  takemura 	case WM_INITDIALOG:
    587  1.33  takemura 		SetDlgItemText(hWnd, IDC_ABOUT_EDIT, version_string);
    588  1.21  takemura 		return (1);
    589  1.21  takemura 
    590  1.33  takemura 	case WM_PALETTECHANGED:
    591  1.33  takemura 		palette_check(hWnd);
    592  1.33  takemura 		break;
    593  1.33  takemura 
    594  1.21  takemura 	case WM_COMMAND:
    595  1.21  takemura 		switch (LOWORD(wParam)) {
    596  1.21  takemura 		case IDC_ABOUT_EDIT:
    597  1.21  takemura 			switch (HIWORD(wParam)) {
    598  1.21  takemura 			case EN_SETFOCUS:
    599  1.21  takemura 				//SendDlgItemMessage(hWnd, IDC_ABOUT_EDIT, EM_SETSEL, -1, 0);
    600  1.21  takemura 				SetFocus(GetDlgItem(hWnd, IDC_ABOUT_BITMAP));
    601  1.21  takemura 				break;
    602  1.21  takemura 			}
    603  1.21  takemura 			break;
    604  1.21  takemura 
    605  1.21  takemura 		case IDCANCEL:
    606  1.21  takemura 			EndDialog(hWnd, LOWORD(wParam));
    607  1.21  takemura 			return (1);
    608  1.21  takemura 		}
    609  1.21  takemura 		break;
    610  1.21  takemura 	default:
    611  1.21  takemura 		return (0);
    612  1.21  takemura 	}
    613  1.21  takemura }
    614  1.21  takemura 
    615  1.21  takemura void
    616  1.21  takemura SetBootInfo(struct bootinfo *bi, struct fb_setting *fbs)
    617  1.21  takemura {
    618  1.21  takemura 	TIME_ZONE_INFORMATION tz;
    619  1.21  takemura 
    620  1.21  takemura 	GetTimeZoneInformation(&tz);
    621  1.21  takemura 	memset(bi, 0, sizeof(struct bootinfo));
    622  1.21  takemura 	bi->length = sizeof(struct bootinfo);
    623  1.21  takemura 	bi->reserved = 0;
    624  1.21  takemura 	bi->magic = BOOTINFO_MAGIC;
    625  1.21  takemura 	bi->fb_addr = (unsigned char*)(fbs->addr + 0xA0000000);
    626  1.21  takemura 	bi->fb_type = fbs->type;
    627  1.21  takemura 	bi->fb_line_bytes = fbs->linebytes;
    628  1.21  takemura 	bi->fb_width = fbs->width;
    629  1.21  takemura 	bi->fb_height = fbs->height;
    630  1.21  takemura 	bi->platid_cpu = fbs->platid_cpu;
    631  1.21  takemura 	bi->platid_machine = fbs->platid_machine;
    632  1.21  takemura 	bi->timezone = tz.Bias;
    633  1.21  takemura 
    634  1.21  takemura 	debug_printf(TEXT("fb setting: %s fb_type=%d 0x%X %dx%d %d\n"),
    635  1.21  takemura 		     fbs->name,
    636  1.21  takemura 		     bi->fb_type, bi->fb_addr,
    637  1.21  takemura 		     bi->fb_width, bi->fb_height, bi->fb_line_bytes);
    638  1.21  takemura 	debug_printf(TEXT("timezone: %02ld:00\n"), (bi->timezone / 60));
    639  1.21  takemura }
    640  1.21  takemura 
    641  1.21  takemura 
    642  1.21  takemura void
    643  1.21  takemura UpdateFbDlg(HWND hWnd, struct fb_setting *fbs, int direction)
    644  1.21  takemura {
    645  1.21  takemura 	int i;
    646  1.21  takemura 	TCHAR tmpbuf[PATHBUFLEN];
    647  1.21  takemura 	int type, width, height, linebytes;
    648  1.21  takemura 	long addr;
    649  1.21  takemura 
    650  1.21  takemura 	switch (direction) {
    651  1.21  takemura 	case UPDATE_DLGBOX:
    652  1.21  takemura 		SetDlgItemText(hWnd, IDC_FB_NAME, fbs->name);
    653  1.21  takemura 
    654  1.21  takemura 		for (i = 0; i < ARRAYSIZEOF(fb_types); i++) {
    655  1.21  takemura 			if (fb_types[i].type == fbs->type) break;
    656  1.21  takemura 		}
    657  1.21  takemura 		if (ARRAYSIZEOF(fb_types) <= i) {
    658  1.21  takemura 			MessageBox(NULL, TEXT("Unknown FrameBuffer type."),
    659  1.21  takemura 				   szAppName, MB_OK);
    660  1.21  takemura 			return;
    661  1.21  takemura 		}
    662  1.21  takemura 		debug_printf(TEXT("UpdateFbDlg(%s)\n"), fbs->name);
    663  1.21  takemura 		i = SendDlgItemMessage(hWnd, IDC_FB_TYPE, CB_FINDSTRINGEXACT,
    664  1.21  takemura 				       0, (LPARAM)fb_types[i].name);
    665  1.21  takemura 		SendDlgItemMessage(hWnd, IDC_FB_TYPE, CB_SETCURSEL, i, 0);
    666  1.21  takemura 
    667  1.21  takemura 		wsprintf(tmpbuf, TEXT("%X"), fbs->addr);
    668  1.21  takemura 		SetDlgItemText(hWnd, IDC_FB_ADDR, tmpbuf);
    669  1.21  takemura 		wsprintf(tmpbuf, TEXT("%d"), fbs->width);
    670  1.21  takemura 		SetDlgItemText(hWnd, IDC_FB_WIDTH, tmpbuf);
    671  1.21  takemura 		wsprintf(tmpbuf, TEXT("%d"), fbs->height);
    672  1.21  takemura 		SetDlgItemText(hWnd, IDC_FB_HEIGHT, tmpbuf);
    673  1.21  takemura 		wsprintf(tmpbuf, TEXT("%d"), fbs->linebytes);
    674  1.21  takemura 		SetDlgItemText(hWnd, IDC_FB_LINEBYTES, tmpbuf);
    675  1.21  takemura 		wsprintf(tmpbuf, TEXT("%08X"), fbs->platid_cpu);
    676  1.21  takemura 		SetDlgItemText(hWnd, IDC_FB_CPU, tmpbuf);
    677  1.21  takemura 		wsprintf(tmpbuf, TEXT("%08X"), fbs->platid_machine);
    678  1.21  takemura 		SetDlgItemText(hWnd, IDC_FB_MACHINE, tmpbuf);
    679  1.21  takemura 		break;
    680  1.21  takemura 	case UPDATE_DATA:
    681  1.21  takemura 		GetDlgItemText(hWnd, IDC_FB_NAME, fbs->name, PATHBUFLEN);
    682  1.21  takemura 		type = SendDlgItemMessage(hWnd, IDC_FB_TYPE,
    683  1.21  takemura 					  CB_GETCURSEL, 0, 0);
    684  1.21  takemura 		type = SendDlgItemMessage(hWnd, IDC_FB_TYPE,
    685  1.21  takemura 					  CB_GETITEMDATA, type, 0);
    686  1.21  takemura 		GetDlgItemText(hWnd, IDC_FB_WIDTH, tmpbuf, sizeof(tmpbuf));
    687  1.21  takemura 		width = _tcstol(tmpbuf, NULL, 10);
    688  1.21  takemura 		GetDlgItemText(hWnd, IDC_FB_HEIGHT, tmpbuf, sizeof(tmpbuf));
    689  1.21  takemura 		height = _tcstol(tmpbuf, NULL, 10);
    690  1.21  takemura 		GetDlgItemText(hWnd, IDC_FB_LINEBYTES, tmpbuf, sizeof(tmpbuf));
    691  1.21  takemura 		linebytes = _tcstol(tmpbuf, NULL, 10);
    692  1.21  takemura 		GetDlgItemText(hWnd, IDC_FB_ADDR, tmpbuf, sizeof(tmpbuf));
    693  1.21  takemura 		addr = _tcstoul(tmpbuf, NULL, 16);
    694  1.21  takemura 		GetDlgItemText(hWnd, IDC_FB_CPU, tmpbuf, sizeof(tmpbuf));
    695  1.21  takemura 		fbs->platid_cpu = _tcstoul(tmpbuf, NULL, 16);
    696  1.21  takemura 		GetDlgItemText(hWnd, IDC_FB_MACHINE, tmpbuf, sizeof(tmpbuf));
    697  1.21  takemura 		fbs->platid_machine = _tcstoul(tmpbuf, NULL, 16);
    698  1.21  takemura 		fbs->type = type;
    699  1.21  takemura 		fbs->addr = addr;
    700  1.21  takemura 		fbs->width = width;
    701  1.21  takemura 		fbs->height = height;
    702  1.21  takemura 		fbs->linebytes = linebytes;
    703  1.21  takemura 
    704  1.21  takemura 		debug_printf(TEXT("type=%d  %dx%d  %d bytes/line %08x %08x\n"),
    705  1.21  takemura 			     type, width, height, linebytes,
    706  1.21  takemura 			     fbs->platid_cpu,
    707  1.21  takemura 			     fbs->platid_machine);
    708  1.21  takemura 		break;
    709  1.21  takemura 	default:
    710  1.21  takemura 		debug_printf(TEXT("UpdateFbDlg(): internal error!\n"));
    711  1.21  takemura 		break;
    712  1.21  takemura 	}
    713  1.21  takemura }
    714  1.21  takemura 
    715  1.21  takemura BOOL CALLBACK FbDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    716  1.21  takemura {
    717  1.21  takemura 	int idx, i;
    718  1.21  takemura 	TCHAR tmpbuf[100];
    719  1.21  takemura 
    720  1.21  takemura 	switch (message) {
    721  1.21  takemura 	case WM_INITDIALOG:
    722  1.21  takemura 		{
    723  1.21  takemura 		UDACCEL uda;
    724  1.21  takemura 		for (i = 0; i < ARRAYSIZEOF(fb_settings); i++) {
    725  1.21  takemura 			idx = SendDlgItemMessage(hWnd, IDC_FB_NAME,
    726  1.21  takemura 						 CB_ADDSTRING, 0,
    727  1.21  takemura 						 (LPARAM)fb_settings[i].name);
    728  1.21  takemura 			SendDlgItemMessage(hWnd, IDC_FB_NAME,
    729  1.21  takemura 					   CB_SETITEMDATA, idx, (LPARAM)i);
    730  1.21  takemura 		}
    731  1.21  takemura 		for (i = 0; i < ARRAYSIZEOF(fb_size); i++) {
    732  1.21  takemura 			wsprintf(tmpbuf, TEXT("%d"), fb_size[i]);
    733  1.21  takemura 			SendDlgItemMessage(hWnd, IDC_FB_WIDTH, CB_ADDSTRING,
    734  1.21  takemura 					   0, (LPARAM)tmpbuf);
    735  1.21  takemura 			SendDlgItemMessage(hWnd, IDC_FB_HEIGHT, CB_ADDSTRING,
    736  1.21  takemura 					   0, (LPARAM)tmpbuf);
    737  1.21  takemura 		}
    738  1.21  takemura 		for (i = 0; i < ARRAYSIZEOF(fb_bpl); i++) {
    739  1.21  takemura 			wsprintf(tmpbuf, TEXT("%d"), fb_bpl[i]);
    740  1.21  takemura 			SendDlgItemMessage(hWnd, IDC_FB_LINEBYTES,
    741  1.21  takemura 					   CB_ADDSTRING, 0,
    742  1.21  takemura 					   (LPARAM)tmpbuf);
    743  1.21  takemura 		}
    744  1.21  takemura 		for (i = 0; i < ARRAYSIZEOF(fb_types); i++) {
    745  1.21  takemura 			idx = SendDlgItemMessage(hWnd, IDC_FB_TYPE,
    746  1.21  takemura 						 CB_ADDSTRING, 0,
    747  1.21  takemura 						 (LPARAM)fb_types[i].name);
    748  1.21  takemura 			SendDlgItemMessage(hWnd, IDC_FB_TYPE, CB_SETITEMDATA,
    749  1.21  takemura 					   idx, (LPARAM)fb_types[i].type);
    750  1.21  takemura 		}
    751  1.21  takemura 		UpdateFbDlg(hWnd, &fb_settings[0], UPDATE_DLGBOX);
    752  1.21  takemura 
    753  1.21  takemura 		uda.nSec = 1;
    754  1.21  takemura 		uda.nInc = 0x100;
    755  1.21  takemura 		/*
    756  1.21  takemura 		SendDlgItemMessage(hWnd, IDC_FB_ADDRSPIN, UDM_SETACCEL,
    757  1.21  takemura 				   0, (LPARAM)&uda);
    758  1.21  takemura 		*/
    759  1.21  takemura 		/*
    760  1.21  takemura 		SendDlgItemMessage(hWnd, IDC_FB_ADDRSPIN, UDM_SETRANGE,
    761  1.21  takemura 		                   0, MAKELPARAM(UD_MAXVAL, UD_MINVAL));
    762  1.21  takemura 		*/
    763  1.21  takemura 		}
    764  1.21  takemura 		return (1);
    765  1.21  takemura 
    766  1.33  takemura 	case WM_PALETTECHANGED:
    767  1.33  takemura 		palette_check(hWnd);
    768  1.33  takemura 		break;
    769  1.33  takemura 
    770  1.21  takemura 	case WM_VSCROLL:
    771  1.21  takemura 		if ((HWND)lParam == GetDlgItem(hWnd, IDC_FB_ADDRSPIN)) {
    772  1.21  takemura 			long addr;
    773  1.21  takemura 			switch (LOWORD(wParam)) {
    774  1.21  takemura 			case SB_THUMBPOSITION:
    775  1.21  takemura 			case SB_THUMBTRACK:
    776  1.21  takemura 				GetDlgItemText(hWnd, IDC_FB_ADDR, tmpbuf, 100);
    777  1.21  takemura 				addr = _tcstoul(tmpbuf, NULL, 16);
    778  1.21  takemura 				if (50 < HIWORD(wParam)) {
    779  1.21  takemura 					addr -= 0x400;
    780  1.21  takemura 				} else {
    781  1.21  takemura 					addr += 0x400;
    782  1.21  takemura 				}
    783  1.21  takemura 				SendDlgItemMessage(hWnd, IDC_FB_ADDRSPIN,
    784  1.21  takemura 						   UDM_SETPOS, 0,
    785  1.21  takemura 						   MAKELPARAM(50, 0));
    786  1.21  takemura 				wsprintf(tmpbuf, TEXT("%X"), addr);
    787  1.21  takemura 				SetDlgItemText(hWnd, IDC_FB_ADDR, tmpbuf);
    788  1.21  takemura 				return (1);
    789  1.21  takemura 			}
    790  1.21  takemura 		}
    791  1.21  takemura 		break;
    792  1.21  takemura 
    793  1.21  takemura 	case WM_COMMAND:
    794  1.21  takemura 		switch (LOWORD(wParam)) {
    795  1.21  takemura 		case IDC_FB_NAME:
    796  1.21  takemura 			switch (HIWORD(wParam)) {
    797  1.21  takemura 			case CBN_SELCHANGE:
    798  1.21  takemura 				idx = SendDlgItemMessage(hWnd, IDC_FB_NAME,
    799  1.21  takemura 							 CB_GETCURSEL, 0, 0);
    800  1.21  takemura 				i = SendDlgItemMessage(hWnd, IDC_FB_NAME,
    801  1.21  takemura 						       CB_GETITEMDATA, idx, 0);
    802  1.21  takemura 				if (0 <= i && i < ARRAYSIZEOF(fb_settings)) {
    803  1.21  takemura 					fb_settings[0] = fb_settings[i];
    804  1.21  takemura 					UpdateFbDlg(hWnd, &fb_settings[0],
    805  1.21  takemura 						    UPDATE_DLGBOX);
    806  1.21  takemura 				}
    807  1.21  takemura 				return (1);
    808  1.21  takemura 			}
    809  1.21  takemura 			break;
    810  1.21  takemura 		case IDOK:
    811  1.21  takemura 			UpdateFbDlg(hWnd, &fb_settings[0], UPDATE_DATA);
    812  1.21  takemura 
    813  1.21  takemura 			EndDialog(hWnd, IDOK);
    814  1.21  takemura 			return (1);
    815  1.21  takemura 
    816  1.21  takemura 		case IDCANCEL:
    817  1.21  takemura 			EndDialog(hWnd, IDCANCEL);
    818  1.21  takemura 			return (1);
    819  1.21  takemura 		}
    820  1.21  takemura 		break;
    821  1.21  takemura 	}
    822  1.21  takemura 	return (0);
    823  1.21  takemura }
    824  1.21  takemura 
    825  1.21  takemura 
    826  1.21  takemura BOOL SerialPort(BOOL on)
    827  1.21  takemura {
    828  1.21  takemura 	static HANDLE hPort = INVALID_HANDLE_VALUE;
    829  1.21  takemura 	BOOL res = (hPort != INVALID_HANDLE_VALUE);
    830  1.21  takemura 
    831  1.21  takemura 	if (on != res) {
    832  1.21  takemura 		if (on) {
    833  1.21  takemura 			hPort = CreateFile(TEXT("COM1:"),
    834  1.21  takemura 					   GENERIC_READ | GENERIC_WRITE,
    835  1.21  takemura 					   0, NULL, OPEN_EXISTING,
    836  1.21  takemura 					   0,
    837  1.21  takemura 					   NULL);
    838  1.21  takemura 			debug_printf(TEXT("serial port ON\n"));
    839  1.21  takemura 			if ( hPort == INVALID_HANDLE_VALUE ) {
    840  1.21  takemura 				debug_printf(TEXT("open failed\n"));
    841  1.21  takemura 			} else {
    842  1.21  takemura #if 0
    843  1.21  takemura 				DWORD Len;
    844  1.21  takemura 				BYTE x = 'X';
    845  1.21  takemura 				WriteFile (hPort, &x, 1, &Len, 0);
    846  1.21  takemura 				WriteFile (hPort, &x, 1, &Len, 0);
    847  1.21  takemura 				WriteFile (hPort, &x, 1, &Len, 0);
    848  1.21  takemura 				WriteFile (hPort, &x, 1, &Len, 0);
    849  1.21  takemura #endif
    850  1.21  takemura 			}
    851  1.21  takemura 		} else {
    852  1.21  takemura 			debug_printf(TEXT("serial port OFF\n"));
    853  1.21  takemura 			CloseHandle(hPort);
    854  1.21  takemura 			hPort = INVALID_HANDLE_VALUE;
    855  1.21  takemura 		}
    856  1.21  takemura 	}
    857  1.21  takemura 
    858  1.21  takemura 	return (res);
    859  1.21  takemura }
    860  1.21  takemura 
    861  1.21  takemura 
    862  1.21  takemura BOOL CheckCancel(int progress)
    863  1.21  takemura {
    864  1.21  takemura 	MSG msg;
    865  1.21  takemura 
    866  1.21  takemura 	if (0 <= progress) {
    867  1.21  takemura 		SendDlgItemMessage(hDlgLoad, IDC_PROGRESS,
    868  1.21  takemura 				   PBM_SETPOS, (WPARAM)progress, (LPARAM)NULL);
    869  1.33  takemura 	} else {
    870  1.33  takemura 		if (pref.check_last_chance) {
    871  1.33  takemura 			if (msg_printf(MB_YESNO | MB_ICONHAND,
    872  1.33  takemura 			    TEXT("Last chance..."),
    873  1.33  takemura 			    TEXT("Push OK to boot.")) != IDYES) {
    874  1.33  takemura 				dlgStatus = IDCANCEL;
    875  1.33  takemura 			}
    876  1.33  takemura 		}
    877  1.33  takemura 		palette_set(hDlgLoad);
    878  1.33  takemura 		if (palette_succeeded == -1) {
    879  1.33  takemura 			msg_printf(MSG_ERROR,
    880  1.33  takemura 			    TEXT("Warning"),
    881  1.33  takemura 			    TEXT("Sorry, palette failed"));
    882  1.21  takemura 		}
    883  1.21  takemura 	}
    884  1.21  takemura 
    885  1.21  takemura 	/*
    886  1.21  takemura 	 *  Put WM_TIMER in my message queue.
    887  1.21  takemura 	 *  (WM_TIMER has lowest priority.)
    888  1.21  takemura 	 */
    889  1.21  takemura 	SetTimer(hDlgLoad, 1, 1, NULL);
    890  1.21  takemura 
    891  1.21  takemura 	/*
    892  1.21  takemura 	 *  I tried PeekMessage() but it does not work.
    893  1.21  takemura 	 */
    894  1.21  takemura 	while (GetMessage(&msg, NULL, 0, 0)) {
    895  1.21  takemura 		if (msg.hwnd == hDlgLoad && msg.message == WM_TIMER) {
    896  1.21  takemura 			break;
    897  1.21  takemura 		}
    898  1.21  takemura 		TranslateMessage(&msg);
    899  1.21  takemura 		DispatchMessage(&msg);
    900  1.21  takemura 	}
    901  1.21  takemura 
    902  1.21  takemura 	return (dlgStatus != 0);
    903  1.21  takemura }
    904  1.21  takemura 
    905  1.21  takemura LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
    906  1.21  takemura                           WPARAM wParam, LPARAM lParam )
    907  1.21  takemura {
    908  1.21  takemura 	int i, idx;
    909  1.21  takemura 
    910  1.21  takemura 	switch (message) {
    911  1.21  takemura 	case WM_CREATE:
    912  1.21  takemura 		sndPlaySound(TEXT("OpenProg"), SND_NODEFAULT | SND_ASYNC);
    913  1.21  takemura 		hWndCB = CommandBar_Create(hInst, hWnd, 1);
    914  1.21  takemura 		CommandBar_AddAdornments(hWndCB, STD_HELP, (DWORD)NULL);
    915  1.33  takemura 		palette_init(hWnd);
    916  1.21  takemura 		break;
    917  1.21  takemura 
    918  1.21  takemura 	case WM_PAINT:
    919  1.21  takemura 		{
    920  1.21  takemura 		HDC          hdc;
    921  1.21  takemura 		PAINTSTRUCT  ps;
    922  1.21  takemura 
    923  1.21  takemura 		hdc = BeginPaint(hWnd, &ps);
    924  1.21  takemura 		EndPaint(hWnd, &ps);
    925  1.21  takemura 		}
    926  1.21  takemura 		break;
    927  1.21  takemura 
    928  1.33  takemura 	case WM_PALETTECHANGED:
    929  1.33  takemura 		palette_check(hWnd);
    930  1.33  takemura 		break;
    931  1.33  takemura 
    932  1.21  takemura 	case WM_HELP:
    933  1.21  takemura 		/*
    934  1.21  takemura 		MessageBox (NULL, TEXT("HELP NOT AVAILABLE"),
    935  1.21  takemura 			    szAppName, MB_OK);
    936  1.21  takemura 		*/
    937  1.21  takemura 		DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), hWnd, DlgProc2);
    938  1.21  takemura         break;
    939  1.21  takemura 
    940  1.21  takemura 	case WM_COMMAND:
    941  1.21  takemura 		switch (LOWORD(wParam)) {
    942  1.21  takemura 		case IDC_BOOT:
    943  1.21  takemura 			{
    944  1.21  takemura 		       	int argc;
    945  1.21  takemura 		       	TCHAR wkernel_name[PATHBUFLEN];
    946  1.21  takemura 			TCHAR woptions[PATHBUFLEN];
    947  1.21  takemura 			char options[PATHBUFLEN*2], kernel_name[PATHBUFLEN*2];
    948  1.21  takemura 			platid_t platid;
    949  1.21  takemura 
    950  1.21  takemura 			char *p, *argv[32];
    951  1.21  takemura 			struct bootinfo bi;
    952  1.21  takemura 
    953  1.21  takemura 			if (SendDlgItemMessage(hWndMain, IDC_PAUSE,
    954  1.21  takemura 					       BM_GETCHECK, 0, 0) ==
    955  1.21  takemura 								BST_CHECKED) {
    956  1.21  takemura 				pref.check_last_chance = TRUE;
    957  1.21  takemura 			} else {
    958  1.21  takemura 				pref.check_last_chance = FALSE;
    959  1.21  takemura 			}
    960  1.21  takemura 
    961  1.21  takemura 			if (SendDlgItemMessage(hWndMain, IDC_DEBUG,
    962  1.21  takemura 					       BM_GETCHECK, 0, 0) ==
    963  1.21  takemura 								BST_CHECKED) {
    964  1.21  takemura 				pref.load_debug_info = TRUE;
    965  1.21  takemura 			} else {
    966  1.21  takemura 				pref.load_debug_info = FALSE;
    967  1.21  takemura 			}
    968  1.21  takemura 
    969  1.21  takemura 			if (SendDlgItemMessage(hWndMain, IDC_COMM,
    970  1.21  takemura 					       BM_GETCHECK, 0, 0) ==
    971  1.21  takemura 								BST_CHECKED) {
    972  1.21  takemura 				pref.serial_port = TRUE;
    973  1.21  takemura 			} else {
    974  1.21  takemura 				pref.serial_port = FALSE;
    975  1.21  takemura 			}
    976  1.21  takemura 
    977  1.25  takemura 			if (SendDlgItemMessage(hWndMain, IDC_REVERSEVIDEO,
    978  1.25  takemura 					       BM_GETCHECK, 0, 0) ==
    979  1.25  takemura 								BST_CHECKED) {
    980  1.25  takemura 				pref.reverse_video = TRUE;
    981  1.25  takemura 			} else {
    982  1.25  takemura 				pref.reverse_video = FALSE;
    983  1.25  takemura 			}
    984  1.25  takemura 
    985  1.21  takemura 			if (GetDlgItemText(hWndMain, IDC_KERNEL, wkernel_name,
    986  1.21  takemura 					   sizeof(wkernel_name)) == 0) {
    987  1.21  takemura 				MessageBox (NULL, TEXT("Kernel name required"),
    988  1.21  takemura 					    szAppName, MB_OK);
    989  1.21  takemura 				break;
    990  1.21  takemura 			}
    991  1.21  takemura 			GetDlgItemText(hWndMain, IDC_OPTIONS,
    992  1.21  takemura 				       woptions, sizeof(woptions));
    993  1.21  takemura 			if (wcstombs(options, woptions, sizeof(options)) < 0 ||
    994  1.21  takemura 			    wcstombs(kernel_name, wkernel_name,
    995  1.21  takemura 				     sizeof(kernel_name)) < 0) {
    996  1.21  takemura 				MessageBox (NULL, TEXT("invalid character"),
    997  1.21  takemura 					    szAppName, MB_OK);
    998  1.21  takemura 				break;
    999  1.21  takemura 			}
   1000  1.21  takemura 
   1001  1.21  takemura 			argc = 0;
   1002  1.21  takemura 			argv[argc++] = kernel_name;
   1003  1.21  takemura 			p = options;
   1004  1.21  takemura 			while (*p) {
   1005  1.21  takemura 				while (*p == ' ' || *p == '\t') {
   1006  1.21  takemura 					p++;
   1007  1.21  takemura 				}
   1008  1.21  takemura 				if (*p == '\0')
   1009  1.21  takemura 					break;
   1010  1.21  takemura 				if (ARRAYSIZEOF(argv) <= argc) {
   1011  1.21  takemura 					MessageBox (NULL,
   1012  1.21  takemura 						    TEXT("too many options"),
   1013  1.21  takemura 						    szAppName, MB_OK);
   1014  1.21  takemura 					argc++;
   1015  1.21  takemura 					break;
   1016  1.21  takemura 				} else {
   1017  1.21  takemura 					argv[argc++] = p;
   1018  1.21  takemura 				}
   1019  1.21  takemura 				while (*p != ' ' && *p != '\t' && *p != '\0') {
   1020  1.21  takemura 					p++;
   1021  1.21  takemura 				}
   1022  1.21  takemura 				if (*p == '\0') {
   1023  1.21  takemura 					break;
   1024  1.21  takemura 				} else {
   1025  1.21  takemura 					*p++ = '\0';
   1026  1.21  takemura 				}
   1027  1.21  takemura 			}
   1028  1.21  takemura 			if (ARRAYSIZEOF(argv) < argc) {
   1029  1.21  takemura 				break;
   1030  1.21  takemura 			}
   1031  1.21  takemura 
   1032  1.21  takemura 			EnableWindow(hWndMain, FALSE);
   1033  1.21  takemura 			if (MessageBox (hWndMain,
   1034  1.21  takemura 					TEXT("Data in memory will be lost.\nAre you sure?"),
   1035  1.21  takemura 					szAppName,
   1036  1.21  takemura 					MB_YESNO | MB_DEFBUTTON2 | MB_ICONHAND) == IDYES) {
   1037  1.21  takemura 				dlgStatus = 0;
   1038  1.21  takemura 				hDlgLoad =
   1039  1.21  takemura 				  CreateDialog(hInst,
   1040  1.21  takemura 					       MAKEINTRESOURCE(IDD_LOAD),
   1041  1.21  takemura 					       hWndMain, DlgProc);
   1042  1.21  takemura 				ShowWindow(hDlgLoad, SW_SHOWNORMAL);
   1043  1.21  takemura 				BringWindowToTop(hDlgLoad);
   1044  1.21  takemura 
   1045  1.21  takemura 				/*
   1046  1.21  takemura 				 *  save settings.
   1047  1.21  takemura 				 */
   1048  1.21  takemura 				pref.fb_type		= fb_settings[0].type;
   1049  1.21  takemura 				pref.fb_width		= fb_settings[0].width;
   1050  1.21  takemura 				pref.fb_height		= fb_settings[0].height;
   1051  1.21  takemura 				pref.fb_linebytes	= fb_settings[0].linebytes;
   1052  1.21  takemura 				pref.fb_addr		= fb_settings[0].addr;
   1053  1.21  takemura 				pref.platid_cpu		= fb_settings[0].platid_cpu;
   1054  1.21  takemura 				pref.platid_machine	= fb_settings[0].platid_machine;
   1055  1.21  takemura 				wstrcpy(pref.kernel_name, wkernel_name);
   1056  1.21  takemura 				wstrcpy(pref.options, woptions);
   1057  1.21  takemura 
   1058  1.33  takemura 				pref_save(path_list, path_list_items);
   1059  1.21  takemura 
   1060  1.21  takemura 				SetBootInfo(&bi, &fb_settings[pref.setting_idx]);
   1061  1.21  takemura 				debug_printf(TEXT("Args: "));
   1062  1.21  takemura 				for (i = 0; i < argc; i++) {
   1063  1.21  takemura 					debug_printf(TEXT("'%S' "), argv[i]);
   1064  1.21  takemura 				}
   1065  1.21  takemura 				debug_printf(TEXT("\n"));
   1066  1.21  takemura 				debug_printf(TEXT("Bootinfo: fb_type=%d 0x%X %dx%d %d\n"),
   1067  1.21  takemura 					     bi.fb_type, bi.fb_addr,
   1068  1.21  takemura 					     bi.fb_width, bi.fb_height,
   1069  1.21  takemura 					     bi.fb_line_bytes);
   1070  1.21  takemura 
   1071  1.21  takemura 				if (pref.serial_port) {
   1072  1.21  takemura 					SerialPort(TRUE);
   1073  1.25  takemura 				}
   1074  1.25  takemura 				if (pref.reverse_video) {
   1075  1.25  takemura 					bi.fb_type = reverse_fb_type(bi.fb_type);
   1076  1.21  takemura 				}
   1077  1.21  takemura 				/*
   1078  1.21  takemura 				 * Set system infomation
   1079  1.21  takemura 				 */
   1080  1.21  takemura 				platid.dw.dw0 = bi.platid_cpu;
   1081  1.21  takemura 				platid.dw.dw1 = bi.platid_machine;
   1082  1.21  takemura 				if (set_system_info(&platid)) {
   1083  1.21  takemura 					/*
   1084  1.21  takemura 					*  boot !
   1085  1.21  takemura 					*/
   1086  1.21  takemura 					pbsdboot(wkernel_name, argc, argv, &bi);
   1087  1.21  takemura 				}
   1088  1.21  takemura 				/*
   1089  1.21  takemura 				 *  Not return.
   1090  1.21  takemura 				 */
   1091  1.21  takemura 
   1092  1.21  takemura 				if (pref.serial_port) {
   1093  1.21  takemura 					SerialPort(FALSE);
   1094  1.21  takemura 				}
   1095  1.21  takemura 
   1096  1.21  takemura 				DestroyWindow(hDlgLoad);
   1097  1.21  takemura 			}
   1098  1.21  takemura 			EnableWindow(hWndMain, TRUE);
   1099  1.21  takemura 			}
   1100  1.21  takemura 			break;
   1101  1.21  takemura 		case IDC_FBSETTING:
   1102  1.21  takemura 			if (DialogBox(hInst, MAKEINTRESOURCE(IDD_FB),
   1103  1.21  takemura 				      hWndMain, FbDlgProc) == IDOK) {
   1104  1.21  takemura 				/* User defined */
   1105  1.21  takemura 				pref.setting_idx = 0;
   1106  1.21  takemura 				SendDlgItemMessage(hWndMain, IDC_FBSELECT,
   1107  1.21  takemura 						   CB_DELETESTRING,
   1108  1.21  takemura 						   (WPARAM)user_define_idx, 0);
   1109  1.21  takemura 				SendDlgItemMessage(hWndMain, IDC_FBSELECT,
   1110  1.21  takemura 						   CB_INSERTSTRING,
   1111  1.21  takemura 						   (WPARAM)user_define_idx,
   1112  1.21  takemura 						   (LPARAM)fb_settings[0].name);
   1113  1.21  takemura 				SendDlgItemMessage(hWnd, IDC_FBSELECT,
   1114  1.21  takemura 						   CB_SETCURSEL, 0, 0);
   1115  1.21  takemura 			}
   1116  1.21  takemura 			break;
   1117  1.21  takemura 		case IDC_FBSELECT:
   1118  1.21  takemura 			switch (HIWORD(wParam)) {
   1119  1.21  takemura 			case CBN_SELCHANGE:
   1120  1.21  takemura 				idx = SendDlgItemMessage(hWnd, IDC_FBSELECT,
   1121  1.21  takemura 							 CB_GETCURSEL, 0, 0);
   1122  1.21  takemura 				i = SendDlgItemMessage(hWnd, IDC_FBSELECT,
   1123  1.21  takemura 						       CB_GETITEMDATA, idx, 0);
   1124  1.21  takemura 				if (0 <= i && i < ARRAYSIZEOF(fb_settings)) {
   1125  1.21  takemura 					debug_printf(TEXT("fb_setting=%d\n"), i);
   1126  1.21  takemura 					pref.setting_idx = i;
   1127  1.21  takemura 				}
   1128  1.21  takemura 				break;
   1129  1.21  takemura 			}
   1130  1.21  takemura 			break;
   1131  1.21  takemura 		}
   1132  1.21  takemura 		break;
   1133  1.21  takemura 
   1134  1.21  takemura 	case WM_HIBERNATE:
   1135  1.21  takemura 		MessageBox(NULL, TEXT("MEMORY IS LOW"), szAppName, MB_OK);
   1136  1.21  takemura 		//Additional code to handle a low memory situation
   1137  1.21  takemura 
   1138  1.21  takemura 	case WM_CLOSE:
   1139  1.21  takemura 	        sndPlaySound(TEXT("Close"), SND_NODEFAULT | SND_ASYNC);
   1140  1.21  takemura 
   1141  1.21  takemura 		DestroyWindow(hWnd);
   1142  1.21  takemura 		break;
   1143  1.21  takemura 
   1144  1.21  takemura 	case WM_DESTROY:
   1145  1.21  takemura 	        PostQuitMessage(0);
   1146  1.21  takemura 		break;
   1147  1.21  takemura 
   1148  1.21  takemura 	default:
   1149  1.21  takemura         	return (DefWindowProc(hWnd, message, wParam, lParam));
   1150  1.21  takemura 	}
   1151  1.21  takemura 
   1152  1.21  takemura 	return (0);
   1153  1.21  takemura }
   1154  1.21  takemura 
   1155  1.21  takemura 
   1156