Ejemplo n.º 1
0
VOID MountFloppy(IN ULONG DiskNumber)
{
// FIXME: This should be present in PSDK commdlg.h
//
// FlagsEx Values
#if (_WIN32_WINNT >= 0x0500)
#define  OFN_EX_NOPLACESBAR         0x00000001
#endif // (_WIN32_WINNT >= 0x0500)

    BOOLEAN Success;
    OPENFILENAMEW ofn;
    WCHAR szFile[MAX_PATH] = L"";

    ASSERT(DiskNumber < ARRAYSIZE(GlobalSettings.FloppyDisks));

    RtlZeroMemory(&ofn, sizeof(ofn));
    ofn.lStructSize  = sizeof(ofn);
    ofn.hwndOwner    = hConsoleWnd;
    ofn.lpstrTitle   = L"Select a virtual floppy image";
    ofn.Flags        = OFN_EXPLORER | OFN_ENABLESIZING | OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
//  ofn.FlagsEx      = OFN_EX_NOPLACESBAR;
    ofn.lpstrFilter  = L"Virtual floppy images (*.vfd;*.img;*.ima;*.dsk)\0*.vfd;*.img;*.ima;*.dsk\0All files (*.*)\0*.*\0\0";
    ofn.lpstrDefExt  = L"vfd";
    ofn.nFilterIndex = 0;
    ofn.lpstrFile    = szFile;
    ofn.nMaxFile     = ARRAYSIZE(szFile);

    if (!GetOpenFileNameW(&ofn))
    {
        DPRINT1("CommDlgExtendedError = %d\n", CommDlgExtendedError());
        return;
    }

    /* Free the old string */
    if (GlobalSettings.FloppyDisks[DiskNumber].Buffer)
        RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber]);

    /* Reinitialize the string */
    Success = RtlCreateUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber], szFile);
    ASSERT(Success);

    /* Mount the disk */
    if (!MountDisk(FLOPPY_DISK, DiskNumber, GlobalSettings.FloppyDisks[DiskNumber].Buffer, !!(ofn.Flags & OFN_READONLY)))
    {
        DisplayMessage(L"An error happened when mounting disk %d", DiskNumber);
        RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber]);
        RtlInitEmptyUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber], NULL, 0);
        return;
    }

    /* Refresh the menu state */
    UpdateVdmMenuDisks();
}
Ejemplo n.º 2
0
/*********************************************************************************
* Description : 储存状况界面
*
* Arguments   :
*
* Returns     :
*
* Notes       :
*
*********************************************************************************/
INT32 SET_StorageSetting(void)
{
	BOOL mem_ok = FALSE;   //主内存是否可用
	BOOL card_ok = FALSE;      //卡是否可用
	UINT64 total1 = 0L, free1 = 0L;    //内存
	UINT8  percent1 = 0;
	UINT64 total2 = 0L, free2 = 0L;    //插卡
	UINT8  percent2 = 0L;
	INT8 toshow = 0;      //要显示那个, 0:main, 1:card
	UINT32 key;
	BOOL need_draw = TRUE;
	INT8 buf[20];    // 1024M<100%>
	
	card_ok = MountDisk(FS_DEV_TYPE_TFLASH);
	
	if(card_ok)
	{
		total2 = FS_GetSpace(FS_DEV_TYPE_TFLASH, FS_GET_SPACE_TOTAL);
		free2  = FS_GetSpace(FS_DEV_TYPE_TFLASH, FS_GET_SPACE_FREE);
		
		//处理<1%
		if(total2 == free2)
		{
			percent2 = 0;
		}
		else
		{
			percent2 = (total2 - free2) * 100 / total2;
			if(percent2 == 0)
			{
				percent2 = 1;
			}
		}
		toshow = 1;
	}
	
#if APP_SUPPORT_USB
	mem_ok = MountDisk(FS_DEV_TYPE_USBDISK);
	
	if(mem_ok)
	{
		total1 = FS_GetSpace(FS_DEV_TYPE_USBDISK, FS_GET_SPACE_TOTAL);
		free1  = FS_GetSpace(FS_DEV_TYPE_USBDISK, FS_GET_SPACE_FREE);
		
		//处理<1%
		if(total1 == free1)
		{
			percent1 = 0;
		}
		else
		{
			percent1 = (total1 - free1) * 100 / total1;
			if(percent1 == 0)
			{
				percent1 = 1;
			}
		}
		toshow = 0;
	}
#endif
	//control
	slider.min = 0;
	slider.max = 100;
	
	while(1)
	{
		if(need_draw)
		{
			GUI_ClearScreen(NULL);
			
			//show progress bar & text//percentage
#if APP_SUPPORT_USB
			if(toshow == 0)
			{
				slider.value = percent1;
				
				//显示主内存图标
				GUI_ResShowImage(GUI_IMG_DEVICE, FS_DEV_TYPE_USBDISK, 0, 0);
				
				//显示箭头
				if(card_ok)
				{
					GUI_ResShowPic(GUI_IMG_CARROWR, 115, 0);
				}
				
				//显示文字
				SET_FmtStorage(buf, total1 / 1024 / 1024, percent1);
				GUI_DisplayTextCenter(0, buf);
				//GUI_UpdateScreen(NULL);
				//GUI_Display_Progress(&progress);
				GUI_Slider(&slider, NULL);
			}
			else if(toshow == 1)
#endif
			{
				slider.value = percent2;//percentage
				
				//显示卡图标
				GUI_ResShowImage(GUI_IMG_DEVICE, FS_DEV_TYPE_TFLASH, 0, 0);
				
				//显示箭头
				if(mem_ok)
				{
					GUI_ResShowPic(GUI_IMG_CARROWL, 115, 0);
				}
				
				//显示文字
				SET_FmtStorage(buf, total2 / 1024 / 1024, percent2);
				GUI_DisplayTextCenter(0, buf);
				//GUI_UpdateScreen(NULL);
				//GUI_Display_Progress(&progress);//progress bar
				GUI_Slider(&slider, NULL);
			}
			
			need_draw = FALSE;
		}//need_draw
		
		
		key = MESSAGE_Wait();
		switch( key )
		{
		case AP_MSG_WAIT_TIMEOUT:           //子菜单界面在8秒后返回系统功能菜单
		case AP_KEY_MODE | AP_KEY_UP:
		case AP_KEY_PLAY | AP_KEY_UP:
			return 0;                       //退出
			
		case AP_KEY_NEXT | AP_KEY_PRESS:
		case AP_KEY_PREV | AP_KEY_PRESS:
			if(toshow == 0 && card_ok)
			{
				toshow = 1;
			}
			else if(toshow == 1 && mem_ok)
			{
				toshow = 0;
			}
			need_draw = TRUE;
			break;
			
		default:
			key = MESSAGE_HandleHotkey(key);
			if(key == RESULT_REDRAW)
			{
				need_draw = TRUE;
			}
			else if(key != 0)
			{
				return key;
			}
		}//switch(key)
		
	}//while(1)
	
}
Ejemplo n.º 3
0
BOOL APP_Read_Sys_Config(void)
{
#if 0
	//////////////////////Set Para Through File//////////////////////////
	INT32 config_file_handle = 0;
	UINT8 buf[READ_BUF_MAX];
	if(MountDisk(FS_DEV_TYPE_TFLASH))
	{
		config_file_handle = FS_Open(L"Config.txt", FS_O_RDONLY, 0);
	}
#if APP_SUPPORT_USB
	else if(MountDisk(FS_DEV_TYPE_USBDISK))
	{
		config_file_handle = FS_Open("Config.txt", FS_O_RDONLY, 0);
	}
#endif
	else
	{
		return FALSE;
	}
	
	if(config_file_handle < 0)
	{
		return FALSE;
	}
	
	///////Scan Param For  Setting/////
	memset(buf, 0, sizeof(buf));
	
	buf[READ_BUF_MAX - 1] = '\n';
	
	if(FS_Read(config_file_handle, buf, (sizeof(buf) - 1)))
	{
		//kval_t kval;
		UINT16 uYear, uMonth, uDay, uHour, uMinute, uSecond, position;
		
		/*First1:parse DATA*/
		{
			INT8 *str = "DATE:" ;
			position =  strstr(buf, str) - buf;
			position += strlen(str);
			uYear	= (buf[position] - '0') * 1000 + (buf[position + 1] - '0') * 100 + (buf[position + 2] - '0') * 10 + (buf[position + 3] - '0'); /*buf[0-3],Year... etc 2011 */
			uMonth	= (buf[position + 4] - '0') * 10 + (buf[position + 5] - '0'); /*buf[4-5],Month... etc 11 */
			uDay	    = (buf[position + 6] - '0') * 10 + (buf[position + 7] - '0'); /*buf[6-7],Day...	etc 11 */
			str = "TIME:" ;
			position =  strstr(buf, str) - buf;
			position += strlen(str);
			uHour	= (buf[position] - '0') * 10  + (buf[position + 1] - '0'); /*buf[8-9],uHour... etc 11 */
			uMinute = (buf[position + 2] - '0') * 10 + (buf[position + 3] - '0'); /*buf[10-11],uMinute... etc 11 */
			uSecond = (buf[position + 4] - '0') * 10 + (buf[position + 5] - '0'); /*buf[12-13],uSecond... etc 21 */
		}
		
		app_trace(APP_MAIN_TRC, "[APP_Read_Sys_Config]:%d,%d,%d,%d,%d,%d\r\n", uYear, uMonth, uDay, uHour, uMinute, uSecond);
		
		
		/*Get Band,FMFREQ*/
#if APP_SUPPORT_FM==1           /*Surport fm*/
		{
			INT8 *str = "BAND:" ;
			position =  strstr(buf, str) - buf;
			position += strlen(str);
			g_comval->fm_value.fm_band = (buf[position] - '0');
			str = "FMSEND:" ;
			position =  strstr(buf, str) - buf;
			position += strlen(str);
			g_comval->fm_value.fm_sendfreq = (buf[position] - '0') * 1000 + (buf[position + 1] - '0') * 100 + (buf[position + 2] - '0') * 10 + (buf[position + 3] - '0');
		}
#endif
		/*Get Loop,Eq*/
		{
			INT8 *str = "LOOP:" ;
			position =	strstr(buf, str) - buf;
			position += strlen(str);
			g_comval->music_cfg.loop_mode = (buf[position] - '0');
			str = "EQ:" ;
			position =	strstr(buf, str) - buf;
			position += strlen(str);
			g_comval->music_cfg.eq_mode   = (buf[position] - '0');
		}
		/*Get repeat ,times*/
		{
			INT8 *str = "REPEAT:" ;
			position =	strstr(buf, str) - buf;
			position += strlen(str);
			g_comval->music_cfg.repeat_count = (buf[position] - '0');
			str = "REPETIME:" ;
			position =	strstr(buf, str) - buf;
			position += strlen(str);
			g_comval->music_cfg.repeat_time	 = (buf[position] - '0') * 10 + (buf[position + 1] - '0');
		}
		
		//将systemtime 和 gwtime写回到VRAM中
		//NVRAMRead(&kval, VM_KERNEL, sizeof(kval_t));
		//kval.systemtime = ((uYear-2000)*365+uMonth*30+uDay)*24*60+uHour*60+uMinute;	 //全局变量
		//NVRAMWrite(&kval, VM_KERNEL, sizeof(kval_t));
		
	}
	
	FS_Close(config_file_handle);
#endif
	return TRUE;
}
Ejemplo n.º 4
0
void APP_Test_Mode(void)
{
	UINT32 key;
	
	g_test_mode = TRUE;
	
	// test leds
	MESSAGE_Sleep(1);
	LED_SetPattern(GUI_LED_TEST_PATTERN1, 1);
	MESSAGE_Sleep(1);
	LED_SetPattern(GUI_LED_TEST_PATTERN2, 1);
	SetPAVolume(0);
	
	hal_HstSendEvent(BOOT_EVENT, 0x7e570100); // 10%
	
	// test lcd
#if APP_SUPPORT_RGBLCD==1
	if(AP_Support_LCD())
	{
		GUI_ClearScreen(NULL);
		GUI_InvertRegion(NULL);
		GUI_UpdateScreen(NULL);
		MESSAGE_Sleep(1);
		GUI_InvertRegion(NULL);
		GUI_UpdateScreen(NULL);
		MESSAGE_Sleep(1);
	}
#elif APP_SUPPORT_LCD==1
	if(AP_Support_LCD())
	{
		GUI_ClearScreen(NULL);
		GUI_InvertRegion(NULL);
		GUI_UpdateScreen(NULL);
		MESSAGE_Sleep(1);
		GUI_InvertRegion(NULL);
		GUI_UpdateScreen(NULL);
		MESSAGE_Sleep(1);
	}
#elif APP_SUPPORT_LED8S==1
	GUI_ClearScreen(NULL);
	GUI_ResShowPic(0xffff, 0, 0);
	GUI_UpdateScreen(NULL);
	COS_Sleep(200);
	GUI_DisplayText(0, 0, "8");
	GUI_UpdateScreen(NULL);
	COS_Sleep(200);
	GUI_DisplayText(1, 0, "8");
	GUI_UpdateScreen(NULL);
	COS_Sleep(200);
	GUI_DisplayText(2, 0, "8");
	GUI_UpdateScreen(NULL);
	COS_Sleep(200);
	GUI_DisplayText(3, 0, "8");
	GUI_UpdateScreen(NULL);
	COS_Sleep(200);
#endif
	
	hal_HstSendEvent(BOOT_EVENT, 0x7e570300); // 30%
	
	// test fm
#if APP_SUPPORT_FM
	hal_HstSendEvent(SYS_EVENT, 0x11220010);
	{
		extern FM_play_status_t    *FMStatus;
		FMStatus = (FM_play_status_t*)NVRAMGetData(VM_AP_RADIO, sizeof(FM_play_status_t));
		FM_SendCommand(MC_OPEN, 0);
		FMStatus->freq = AP_TEST_FM_FREQ1;
		FM_SendCommand(MC_PLAY, 0);
		if(!fmd_ValidStop(FMStatus->freq))
		{
			FMStatus->freq = AP_TEST_FM_FREQ2;
			if(!fmd_ValidStop(FMStatus->freq))
			{
				FMStatus->freq = AP_TEST_FM_FREQ3;
				if(!fmd_ValidStop(FMStatus->freq))
				{
					goto test_fail;
				}
			}
		}
		SetPAVolume(0);
		FM_SendCommand(MC_CLOSE, 0);
	}
#endif
	
	hal_HstSendEvent(BOOT_EVENT, 0x7e570500); // 50%
	
	// test bluetooth
#if APP_SUPPORT_BLUETOOTH==1
	hal_HstSendEvent(SYS_EVENT, 0x11220020);
	{
		extern bt_vars_t *g_pBT_vars;
		extern INT8 g_bt_cur_device;
		g_bt_cur_device = -1;
		g_pBT_vars = (bt_vars_t*)NVRAMGetData(VM_AP_BLUETOOTH, sizeof(bt_vars_t));
		if(BT_Active_Bluetooth() != 0)
		{
			goto test_fail;    // test_fail
		}
	}
#endif
	
	
	hal_HstSendEvent(BOOT_EVENT, 0x7e570800); // 80%
	// test audio
#if APP_SUPPORT_MUSIC==1
	{
		hal_HstSendEvent(SYS_EVENT, 0x11220030);
		if(!MountDisk(FS_DEV_TYPE_TFLASH))
		{
			goto test_fail;    // test_fail
		}
		
		hal_HstSendEvent(SYS_EVENT, 0x11220040);
		if(!fselInit(FSEL_TYPE_MUSIC, FSEL_ALL_SEQUENCE, FSEL_TYPE_COMMONDIR, FS_DEV_TYPE_TFLASH))
		{
			goto test_fail;    // test_fail
		}
		if(!fselGetNextFile(&g_testfile_entry))
		{
			goto test_fail;    // test_fail
		}
		hal_HstSendEvent(SYS_EVENT, 0x11220042);
		hal_HstSendEvent(SYS_EVENT, g_testfile_entry);
		g_current_fd = FS_OpenDirect(g_testfile_entry, FS_O_RDONLY, 0);
		hal_HstSendEvent(SYS_EVENT, g_current_fd);
		if(g_current_fd < 0)
		{
			goto test_fail;    // test_fail
		}
		
		hal_HstSendEvent(SYS_EVENT, 0x11220050);
		if(MCI_ERR_NO != MCI_AudioPlay(0, g_current_fd, MCI_TYPE_DAF, play_finished, 0))
		{
			goto test_fail;
		}
		SetPAVolume(0);
		play_end = FALSE;
		GUI_DisplayMessage(0, 0, "Test Sucess!", GUI_MSG_FLAG_DISPLAY);
		hal_HstSendEvent(SYS_EVENT, 0x11220060);
		hal_HstSendEvent(BOOT_EVENT, 0x7e570a00); // 100%
		hal_HstSendEvent(BOOT_EVENT, 0x7e5752cc); // test success
		LED_SetPattern(GUI_LED_TEST_SUCESS, LED_LOOP_INFINITE);
		
		while(1)
		{
			key =  MESSAGE_Wait();
			if(play_end)
			{
				play_end = FALSE;
				MCI_AudioStop();
				MCI_AudioPlay(0, g_current_fd, MCI_TYPE_DAF, play_finished, 0);
			}
#if 1//warkey //按任意键打开音量播放音乐,MODE键退出并重启
			if(key == (AP_KEY_MODE | AP_KEY_DOWN))
			{
				MCI_AudioStop();
				FS_Close(g_current_fd);
				RestartSystem();
			}
			else if(((key >> 16) > 0) && ((key >> 16) < MAX_KEYS))
			{
				if((key & 0xffff) == AP_KEY_DOWN)
				{
					SetPAVolume(7);
				}
				else if((key & 0xffff) == AP_KEY_UP)
				{
					SetPAVolume(0);
					
					g_test_mode = FALSE;
				}
			}
#else//原始
			if(key == (AP_KEY_PLAY | AP_KEY_DOWN))
			{
				SetPAVolume(7);
			}
			else if(key == (AP_KEY_PLAY | AP_KEY_UP))
			{
				SetPAVolume(0);
				hal_HstSendEvent(BOOT_EVENT, 0x7e5752cc); // test success
				g_test_mode = FALSE;
			}
			else if(key == (AP_KEY_MODE | AP_KEY_DOWN))
			{
				MCI_AudioStop();
				FS_Close(g_current_fd);
				RestartSystem();
			}
#endif
		};
	}
#else
	hal_HstSendEvent(BOOT_EVENT, 0x7e570a00); // 100%
	
	LED_SetPattern(GUI_LED_TEST_SUCESS, LED_LOOP_INFINITE);
	
	hal_HstSendEvent(BOOT_EVENT, 0x7e5752cc); // test success
	g_test_mode = FALSE;
	while(1)
	{
		key =  MESSAGE_Wait();
		if(key == (AP_KEY_MODE | AP_KEY_DOWN))
		{
			RestartSystem();
		}
		if(key == (AP_KEY_POWER | AP_KEY_DOWN))
		{
			DM_DeviceSwithOff();
		}
	};
#endif
	
test_fail:
	GUI_DisplayMessage(0, 0, "Test Fail!", GUI_MSG_FLAG_DISPLAY);
	LED_SetPattern(GUI_LED_TEST_FAIL, LED_LOOP_INFINITE);
	hal_HstSendEvent(BOOT_EVENT, 0x7e57fa11); // test fail
	g_test_mode = FALSE;
	
	while(1)
	{
		key =  MESSAGE_Wait();
		if(key == (AP_KEY_MODE | AP_KEY_DOWN))
		{
			RestartSystem();
		}
		if(key == (AP_KEY_POWER | AP_KEY_DOWN))
		{
			DM_DeviceSwithOff();
		}
	}
}
Ejemplo n.º 5
0
BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput)
{
    USHORT i;

    /* Initialize memory */
    if (!MemInitialize())
    {
        wprintf(L"Memory initialization failed.\n");
        return FALSE;
    }

    /* Initialize I/O ports */
    /* Initialize RAM */

    /* Initialize the CPU */

    /* Initialize the internal clock */
    if (!ClockInitialize())
    {
        wprintf(L"FATAL: Failed to initialize the clock\n");
        EmulatorCleanup();
        return FALSE;
    }

    /* Initialize the CPU */
    CpuInitialize();

    /* Initialize DMA */
    DmaInitialize();

    /* Initialize PIC, PIT, CMOS, PC Speaker and PS/2 */
    PicInitialize();

    PitInitialize();
    PitSetOutFunction(0, NULL, PitChan0Out);
    PitSetOutFunction(1, NULL, PitChan1Out);
    PitSetOutFunction(2, NULL, PitChan2Out);

    CmosInitialize();
    SpeakerInitialize();
    PpiInitialize();

    PS2Initialize();

    /* Initialize the keyboard and mouse and connect them to their PS/2 ports */
    KeyboardInit(0);
    MouseInit(1);

    /**************** ATTACH INPUT WITH CONSOLE *****************/
    /* Create the task event */
    VdmTaskEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
    ASSERT(VdmTaskEvent != NULL);

    /* Start the input thread */
    InputThread = CreateThread(NULL, 0, &ConsoleEventThread, ConsoleInput, 0, NULL);
    if (InputThread == NULL)
    {
        wprintf(L"FATAL: Failed to create the console input thread.\n");
        EmulatorCleanup();
        return FALSE;
    }
    ResumeEventThread();
    /************************************************************/

    /* Initialize the VGA */
    if (!VgaInitialize(ConsoleOutput))
    {
        wprintf(L"FATAL: Failed to initialize VGA support.\n");
        EmulatorCleanup();
        return FALSE;
    }

    /* Initialize the disk controller */
    if (!DiskCtrlInitialize())
    {
        wprintf(L"FATAL: Failed to completely initialize the disk controller.\n");
        EmulatorCleanup();
        return FALSE;
    }

    /* Mount the available floppy disks */
    for (i = 0; i < ARRAYSIZE(GlobalSettings.FloppyDisks); ++i)
    {
        if (GlobalSettings.FloppyDisks[i].Length != 0 &&
            GlobalSettings.FloppyDisks[i].Buffer      &&
            GlobalSettings.FloppyDisks[i].Buffer != '\0')
        {
            if (!MountDisk(FLOPPY_DISK, i, GlobalSettings.FloppyDisks[i].Buffer, FALSE))
            {
                DPRINT1("Failed to mount floppy disk file '%wZ'.\n", &GlobalSettings.FloppyDisks[i]);
                RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[i]);
                RtlInitEmptyUnicodeString(&GlobalSettings.FloppyDisks[i], NULL, 0);
            }
        }
    }

    /*
     * Mount the available hard disks. Contrary to floppies, failing
     * mounting a hard disk is considered as an unrecoverable error.
     */
    for (i = 0; i < ARRAYSIZE(GlobalSettings.HardDisks); ++i)
    {
        if (GlobalSettings.HardDisks[i].Length != 0 &&
            GlobalSettings.HardDisks[i].Buffer      &&
            GlobalSettings.HardDisks[i].Buffer != L'\0')
        {
            if (!MountDisk(HARD_DISK, i, GlobalSettings.HardDisks[i].Buffer, FALSE))
            {
                wprintf(L"FATAL: Failed to mount hard disk file '%wZ'.\n", &GlobalSettings.HardDisks[i]);
                EmulatorCleanup();
                return FALSE;
            }
        }
    }

    /* Refresh the menu state */
    UpdateVdmMenuDisks();

    /* Initialize the software callback system and register the emulator BOPs */
    InitializeInt32();
    RegisterBop(BOP_DEBUGGER  , EmulatorDebugBreakBop);
    // RegisterBop(BOP_UNSIMULATE, CpuUnsimulateBop);

    /* Initialize VDD support */
    VDDSupInitialize();

    return TRUE;
}