Esempio n. 1
0
//---------------------------------------------------------------------------
static void RegisterDllLoadHook(void)
{
	bool flag = false;
	tTJSVariant val;
	if( TVPGetCommandLine(TJS_W("-_inmm"), &val) ||
		TVPGetCommandLine(TJS_W("-inmm" ), &val) )
	{
		// _inmm support
		ttstr str(val);
		if(str == TJS_W("yes"))
			flag = true;
	}
	if(flag) __pfnDliNotifyHook = DllLoadHook;
}
Esempio n. 2
0
//---------------------------------------------------------------------------
void GDIFontRasterizer::InitChAntialiasMethod() {
	if(ChAntialiasMethodInit) return;

	ChAntialiasMethod = camAPI; // default

	tTJSVariant val;
	if( TVPGetCommandLine(TJS_W("-aamethod"), &val) ) {
		ttstr str(val);
#if 0 // まったく意味のないコード?
		if(str == TJS_W("auto"))
			; // nothing to do
#endif
		if(str == TJS_W("res8"))
			ChAntialiasMethod = camResample8;
		else if(str == TJS_W("res4"))
			ChAntialiasMethod = camResample4;
		else if(str == TJS_W("api"))
			ChAntialiasMethod = camAPI;
		else if(str == TJS_W("rgb"))
			ChAntialiasMethod = camSubpixelRGB;
		else if(str == TJS_W("bgr"))
			ChAntialiasMethod = camSubpixelBGR;
	}

	ChAntialiasMethodInit = true;
}
Esempio n. 3
0
//---------------------------------------------------------------------------
// TVPInitializeBaseSystems
//---------------------------------------------------------------------------
void TVPInitializeBaseSystems()
{
	// set system archive delimiter
	tTJSVariant v;
	if(TVPGetCommandLine(TJS_W("-arcdelim"), &v))
		TVPArchiveDelimiter = ttstr(v)[0];

	// set default current directory
	{
		char drive[MAXDRIVE];
		char dir[MAXDIR];
		fnsplit(_argv[0], drive, dir, NULL, NULL);
		ttstr curdir(ttstr(drive)  + ttstr(dir));
		if(curdir.GetLastChar() != TJS_W('\\')) curdir += TJS_W('\\');
		TVPSetCurrentDirectory(curdir);
	}

	// load message map file
	bool load_msgmap = GetSystemSecurityOption("disablemsgmap") == 0;

	if(load_msgmap)
	{
		const tjs_char name_msgmap [] = TJS_W("msgmap.tjs");
		if(TVPIsExistentStorage(name_msgmap))
			TVPExecuteStorage(name_msgmap, NULL, false, TJS_W(""));
	}
}
Esempio n. 4
0
static bool TVPGetMainThreadPriorityControl()
{
	if(TVPMainThreadPriorityControlInit) return TVPMainThreadPriorityControl;
	tTJSVariant val;
	if( TVPGetCommandLine(TJS_W("-lowpri"), &val) )
	{
		ttstr str(val);
		if(str == TJS_W("yes"))
			TVPMainThreadPriorityControl = true;
	}

	TVPMainThreadPriorityControlInit = true;

	return TVPMainThreadPriorityControl;
}
Esempio n. 5
0
static bool TVPGetDebugSupportShowable()
{
	if(TVPDebugSupportShowableGot) return TVPDebugSupportShowable;
	tTJSVariant val;
	if( TVPGetCommandLine(TJS_W("-debugwin"), &val) )
	{
		ttstr str(val);
		if(str == TJS_W("no"))
			TVPDebugSupportShowable = false;
	}

	TVPDebugSupportShowableGot = true;

	return TVPDebugSupportShowable;
}
Esempio n. 6
0
//---------------------------------------------------------------------------
static void TVPInitGDIOptions()
{
	if(TVPPassThroughOptionsGeneration == TVPGetCommandLineArgumentGeneration()) return;
	TVPPassThroughOptionsGeneration = TVPGetCommandLineArgumentGeneration();

	tTJSVariant val;
	TVPZoomInterpolation = true;
	if(TVPGetCommandLine(TJS_W("-smoothzoom"), &val))
	{
		ttstr str(val);
		if(str == TJS_W("no"))
			TVPZoomInterpolation = false;
		else
			TVPZoomInterpolation = true;
	}
}
Esempio n. 7
0
//---------------------------------------------------------------------------
TShortCut TTVPMainForm::GetHotKeyFromOption(TShortCut def, const tjs_char * optname)
{
	tTJSVariant val;
	if(TVPGetCommandLine(optname, &val))
	{
		TShortCut sc;
		ttstr str(val);
		if(str == TJS_W(""))
		{
			sc = (TShortCut)0;
		}
		else
		{
			sc = TextToShortCut(str.AsAnsiString());
			if(sc == 0)
				TVPThrowExceptionMessage(TVPInvalidCommandLineParam,
					optname, str);
		}
		return sc;
	}
	return def;
}
Esempio n. 8
0
	// 設定された内容を保存する
	void SaveSetting() {
		tTJSVariant val;
		std::wstring path;
		if( TVPGetCommandLine( L"-datapath", &val) ) {
			ttstr str(val);
			path.assign( str.c_str(), str.length() );
		}
		std::wstring exename = ExePath();
		std::wstring filename = ChangeFileExt( ExtractFileName( exename ), L".cfu" );
		filename = ApplicationSpecialPath::GetDataPathDirectory( path, exename ) + filename;
		const char * warnings =
"; ============================================================================\r\n"
"; *DO NOT EDIT* this file unless you are understanding what you are doing.\r\n"
"; FYI:\r\n"
";  Each line consists of NAME=\"VALUE\" pair, VALUE is a series of\r\n"
";  \\xNN, where NN is hexadecimal representation of UNICODE codepoint.\r\n"
";  For example, opt=\"\\x61\\x62\\x63\\x3042\\x3044\\x3046\" means that the\r\n"
";  value of options \"opt\" is alphabets a, b, and c followed by Japanese\r\n"
";  Hiraganas A, I, and U.\r\n"
";  DO NOT PUT non-escaped value like opt=\"abc\". This doesn't work and should\r\n"
";  be like opt=\"\\x61\\x62\\x63\".\r\n"
"; ============================================================================\r\n"
"";
		tTJSBinaryStream *stream = TVPCreateBinaryStreamForWrite( ttstr(filename), L"" );
		if( stream ) {
			try {
				stream->Write( warnings, strlen(warnings) );
				std::string option = ToStringOption();
				stream->Write( option.c_str(), option.length() );
			} catch(...) {
				delete stream;
				throw;
			}
			delete stream;
		}

	}
Esempio n. 9
0
// 本体とプラグインの設定情報を読込み、ツリーに反映する
void ConfigFormUnit::LoadOptionTree() {
	tTVPCommandOptionList* options = TVPGetEngineCommandDesc();
	if( options ) {
		LoadPluginOptionDesc( options, L"\\", L"dll" );
		LoadPluginOptionDesc( options, L"\\", L"tpm" );
		LoadPluginOptionDesc( options, L"plugin\\", L"dll" );
		LoadPluginOptionDesc( options, L"plugin\\", L"tpm" );

		tTJSVariant val;
		HTREEITEM hFirst = NULL;
		// 有効なアイテム数をカウント
		tjs_uint itemcount = 0;
		tjs_uint count = options->Categories.size();
		for( tjs_uint i = 0; i < count; i++ ) {
			const tTVPCommandOptionCategory& category = options->Categories[i];
			tjs_uint optcount = category.Options.size();
			for( tjs_uint j = 0; j < optcount; j++ ) {
				if( category.Options[j].User ) itemcount++;
			}
		}
		TreeItems.resize(itemcount);

		tjs_uint itemidx = 0;
		for( tjs_uint i = 0; i < count; i++ ) {
			const tTVPCommandOptionCategory& category = options->Categories[i];
			tjs_uint optcount = category.Options.size();
			// まずはカテゴリに有効なアイテムがあるかチェックする
			bool hasitem = false;
			for( tjs_uint j = 0; j < optcount; j++ ) {
				if( category.Options[j].User ) {
					hasitem = true;
					break;
				}
			}
			if( hasitem == false ) continue;
			HTREEITEM hItem = InsertTreeItem( TVI_ROOT, category.Name );
			if( hFirst == NULL ) hFirst = hItem;
			for( tjs_uint j = 0; j < optcount; j++ ) {
				const tTVPCommandOption& option = category.Options[j];
				if( option.User ) {
					TreeItem& curitem = TreeItems[itemidx];
					curitem.Text = option.Caption;
					curitem.Parameter = option.Name;
					curitem.Description = std::wstring(L"-")+option.Name+std::wstring(L"\n")+option.Description;
					ConvertReturnCode( curitem.Description );
					tjs_uint valcount = option.Values.size();
					curitem.Select.resize( valcount );
					curitem.Defalut = -1;
					std::wstring argname( std::wstring(L"-") + option.Name );
					std::wstring selectvalue;
					if( TVPGetCommandLine( argname.c_str(), &val) ) {
						ttstr str(val);
						selectvalue.assign( str.c_str(), str.length() );
					}
					tjs_int selectindex = -1;
					for( tjs_uint k = 0; k < valcount; k++ ) {
						std::pair<std::wstring, std::wstring>& sel = curitem.Select[k];
						const tTVPCommandOptionsValue& val = option.Values[k];
						sel.first = val.Value;
						sel.second = val.Description;
						if( val.IsDefault ) {
							curitem.Defalut = k;
						}
						if( selectindex < 0 && !selectvalue.empty() && selectvalue == val.Value ) {
							selectindex = k;
						}
					}
					if( selectindex >= 0 ) {
						curitem.Value = selectindex;
					} else if( curitem.Defalut >= 0 ) {
						curitem.Value = curitem.Defalut;
					} else {
						curitem.Value = 0;
					}

					if( curitem.Defalut != curitem.Value ) {
						curitem.Caption = std::wstring(L"* ") + curitem.Text + std::wstring(L" : ") + curitem.Select[curitem.Value].second;
					} else {
						curitem.Caption = curitem.Text + std::wstring(L" : ") + curitem.Select[curitem.Value].second;
					}
					curitem.ItemHandle = InsertTreeItem( hItem, curitem.Caption );
					itemidx++;
				}
			}
			TreeView_Expand( TreeControl, hItem, TVE_EXPAND );
		}
		TreeView_SelectItem( TreeControl, hFirst );
		delete options;
	}
}
Esempio n. 10
0
void TVPBeforeSystemInit()
{
	RegisterDllLoadHook();
		// register DLL delayed import hook to support _inmm.dll

	TVPInitProgramArgumentsAndDataPath(false); // ensure command line

#ifdef TVP_REPORT_HW_EXCEPTION
	__dee_hacked_set_getExceptionObjectHook(TVP__dee_hacked_getExceptionObjectHook);
		// register hook function for hardware exceptions
#endif

	Application->HintHidePause = 24*60*60*1000;
		// not to hide tool tip hint immediately
	Application->ShowHint = false;
	Application->ShowHint = true;
		// to ensure assigning new HintWindow Class defined in HintWindow.cpp 


	// randomize
	TVPInitRandomGenerator();

	// memory usage
	{
		MEMORYSTATUS status;
		status.dwLength = sizeof(status);
		GlobalMemoryStatus(&status);

		TVPPushEnvironNoise(&status, sizeof(status));

		TVPTotalPhysMemory = status.dwTotalPhys;

		TVPAddImportantLog(TJS_W("(info) Total physical memory : ") +
			ttstr((int)TVPTotalPhysMemory) );

		tTJSVariant opt;
		if(TVPGetCommandLine(TJS_W("-memusage"), &opt))
		{
			ttstr str(opt);
			if(str == TJS_W("low"))
				TVPTotalPhysMemory = 0; // assumes zero
		}

		if(TVPTotalPhysMemory <= 36*1024*1024)
		{
			// very very low memory, forcing to assume zero memory
			TVPTotalPhysMemory = 0;
		}

		if(TVPTotalPhysMemory < 48*1024*1024)
		{
			// extra low memory
			if(TJSObjectHashBitsLimit > 0)
				TJSObjectHashBitsLimit = 0;
			TVPSegmentCacheLimit = 0;
			TVPFreeUnusedLayerCache = true; // in LayerIntf.cpp
		}
		else if(TVPTotalPhysMemory < 64*1024*1024)
		{
			// low memory
			if(TJSObjectHashBitsLimit > 4)
				TJSObjectHashBitsLimit = 4;
		}
	}


	char buf[MAX_PATH];
	bool bufset = false;
	bool nosel = false;
	bool forcesel = false;

	bool forcedataxp3 = GetSystemSecurityOption("forcedataxp3") != 0;
	bool acceptfilenameargument = GetSystemSecurityOption("acceptfilenameargument") != 0;

	if(!forcedataxp3 && !acceptfilenameargument)
	{
		if(TVPGetCommandLine(TJS_W("-nosel")) || TVPGetCommandLine(TJS_W("-about")))
		{
			nosel = true;
		}
		else
		{
			for(tjs_int i = 1; i<_argc; i++)
			{
				if(_argv[i][0] == '-' &&
					_argv[i][1] == '-' && _argv[i][2] == 0)
					break;

				if(_argv[i][0] != '-')
				{
					// TODO: set the current directory
					strncpy(buf, _argv[i], MAX_PATH-1);
					buf[MAX_PATH-1] = '\0';
					if(DirectoryExists(buf)) // is directory?
						strcat(buf, "\\");

					TVPProjectDirSelected = true;
					bufset = true;
					nosel = true;
				}
			}
		}
	}

	// check "-sel" option, to force show folder selection window
	if(!forcedataxp3 && TVPGetCommandLine(TJS_W("-sel")))
	{
		// sel option was set
		if(bufset)
		{
			char path[MAX_PATH];
			char *dum = 0;
			GetFullPathName(buf, MAX_PATH-1, path, &dum);
			strcpy(buf, path);
			TVPProjectDirSelected = false;
			bufset = true;
		}
		nosel = true;
		forcesel = true;
	}

	// check "content-data" directory
	if(!forcedataxp3 && !nosel)
	{
		char tmp[MAX_PATH];
		strcpy(tmp, IncludeTrailingBackslash(ExtractFileDir(ParamStr(0))).c_str());
		strcat(tmp, "content-data");
		if(DirectoryExists(tmp))
		{
			strcat(tmp, "\\");
			strcpy(buf, tmp);
			TVPProjectDirSelected = true;
			bufset = true;
			nosel = true;
		}
	}

	// check "data.xp3" archive
 	if(!nosel)
	{
		char tmp[MAX_PATH];
		strcpy(tmp, IncludeTrailingBackslash(ExtractFileDir(ParamStr(0))).c_str());
		strcat(tmp, "data.xp3");
		if(FileExists(tmp))
		{
			strcpy(buf, tmp);
			TVPProjectDirSelected = true;
			bufset = true;
			nosel = true;
		}
	}

	// check "data.exe" archive
 	if(!nosel)
	{
		char tmp[MAX_PATH];
		strcpy(tmp, IncludeTrailingBackslash(ExtractFileDir(ParamStr(0))).c_str());
		strcat(tmp, "data.exe");
		if(FileExists(tmp))
		{
			strcpy(buf, tmp);
			TVPProjectDirSelected = true;
			bufset = true;
			nosel = true;
		}
	}

	// check self combined xpk archive
	if(!nosel)
	{
		if(TVPIsXP3Archive(TVPNormalizeStorageName(ParamStr(0))))
		{
			strcpy(buf, ParamStr(0).c_str());
			TVPProjectDirSelected = true;
			bufset = true;
			nosel = true;
		}
	}


	// check "data" directory
	if(!forcedataxp3 && !nosel)
	{
		char tmp[MAX_PATH];
		strcpy(tmp, IncludeTrailingBackslash(ExtractFileDir(ParamStr(0))).c_str());
		strcat(tmp, "data");
		if(DirectoryExists(tmp))
		{
			strcat(tmp, "\\");
			strcpy(buf, tmp);
			TVPProjectDirSelected = true;
			bufset = true;
			nosel = true;
		}
	}

	// decide a directory to execute or to show folder selection
	if(!bufset)
	{
		if(forcedataxp3) throw EAbort("Aborted");
		strcpy(buf, ExtractFileDir(ParamStr(0)).c_str());
		int curdirlen = strlen(buf);
		if(buf[curdirlen-1] != '\\') buf[curdirlen] = '\\', buf[curdirlen+1] = 0;
	}

	if(!forcedataxp3 && (!nosel || forcesel))
	{
		// load krdevui.dll ( TVP[KiRikiri] Development User Interface )
		HMODULE krdevui = LoadLibrary("krdevui.dll");
		if(!krdevui)
		{
			AnsiString toolspath = (IncludeTrailingBackslash(
					ExtractFilePath(ParamStr(0))) + "tools\\krdevui.dll");
			krdevui = LoadLibrary(toolspath.c_str());
		}

		if(!krdevui)
		{
			// cannot locate the dll
			throw Exception(
				ttstr(TVPCannnotLocateUIDLLForFolderSelection).AsAnsiString());
		}

		typedef int PASCAL (*UIShowFolderSelectorForm_t)(void *reserved, char *buf);
		typedef void PASCAL (*UIGetVersion_t)(DWORD *hi, DWORD *low);

		UIShowFolderSelectorForm_t	UIShowFolderSelectorForm;
		UIGetVersion_t				UIGetVersion;

		UIShowFolderSelectorForm =
			(UIShowFolderSelectorForm_t)GetProcAddress(krdevui, "UIShowFolderSelectorForm");
		UIGetVersion =
			(UIGetVersion_t)GetProcAddress(krdevui, "UIGetVersion");

		if(!UIShowFolderSelectorForm || !UIGetVersion)
		{
			FreeLibrary(krdevui);
			throw Exception(ttstr(TVPInvalidUIDLL).AsAnsiString());
		}

		DWORD h, l;
		UIGetVersion(&h, &l);
		if(h != TVP_NEED_UI_VERSION)
		{
			FreeLibrary(krdevui);
			throw Exception(ttstr(TVPInvalidUIDLL).AsAnsiString());
		}


		int result = UIShowFolderSelectorForm(Application->Handle, buf);

//		FreeLibrary(krdevui);
		// FIXME: the library should be freed as soon as finishing to use it.

		if(result == mrAbort)
		{
			// display the main window
		}
		else
		if(result == mrCancel)
		{
			// cancel
			throw EAbort("Canceled");
		}
		else
		if(result == mrOk)
		{
			// ok, prepare to execute the script
			TVPProjectDirSelected = true;
		}
	}

	// check project dir and store some environmental variables
	if(TVPProjectDirSelected)
	{
		Application->ShowMainForm=false;
	}

	tjs_int buflen = strlen(buf);
	if(buflen >= 1)
	{
		if(buf[buflen-1] != '\\') buf[buflen] = TVPArchiveDelimiter, buf[buflen+1] = 0;
	}

	TVPProjectDir = TVPNormalizeStorageName(buf);
	TVPSetCurrentDirectory(TVPProjectDir);
	TVPNativeProjectDir = buf;

	if(TVPProjectDirSelected)
	{
		TVPAddImportantLog(TJS_W("(info) Selected project directory : ") +
			TVPProjectDir);
	}
}
Esempio n. 11
0
//---------------------------------------------------------------------------
static void TVPInitProgramArgumentsAndDataPath(bool stop_after_datapath_got)
{
	if(!TVPProgramArgumentsInit)
	{
		TVPProgramArgumentsInit = true;


		// find options from self executable image
		const int num_option_layers = 3;
		TStringList * options[num_option_layers];
		for(int i = 0; i < num_option_layers; i++) options[i] = NULL;
		try
		{
			// read embedded options and default configuration file
			options[0] = TVPGetEmbeddedOptions();
			options[1] = TVPGetConfigFileOptions(TConfMainFrame::GetConfigFileName(ParamStr(0)));

			// at this point, we need to push all exsting known options
			// to be able to see datapath
			PushAllCommandlineArguments();
			PushConfigFileOptions(options[1]); // has more priority
			PushConfigFileOptions(options[0]); // has lesser priority

			// read datapath
			tTJSVariant val;
			AnsiString config_datapath;
			if(TVPGetCommandLine(TJS_W("-datapath"), &val))
				config_datapath = ((ttstr)val).AsAnsiString();
			TVPNativeDataPath = TConfMainFrame::GetDataPathDirectory(config_datapath, ParamStr(0));

			if(stop_after_datapath_got) return;

			// read per-user configuration file
			options[2] = TVPGetConfigFileOptions(TConfMainFrame::GetUserConfigFileName(config_datapath, ParamStr(0)));

			// push each options into option stock
			// we need to clear TVPProgramArguments first because of the
			// option priority order.
			TVPProgramArguments.clear();
			PushAllCommandlineArguments();
			PushConfigFileOptions(options[2]); // has more priority
			PushConfigFileOptions(options[1]); // has more priority
			PushConfigFileOptions(options[0]); // has lesser priority
		}
		__finally
		{
			for(int i = 0; i < num_option_layers; i++)
				if(options[i]) delete options[i];
		}


		// set data path
		TVPDataPath = TVPNormalizeStorageName(TVPNativeDataPath);
		TVPAddImportantLog(ttstr("(info) Data path : ") + TVPDataPath);

		// set log output directory
		TVPSetLogLocation(TVPNativeDataPath);

		// increment TVPCommandLineArgumentGeneration
		TVPCommandLineArgumentGeneration++;
	}
Esempio n. 12
0
//---------------------------------------------------------------------------
void TVPAfterSystemInit()
{
	// ensure datapath directory
	TVPEnsureDataPathDirectory();

	// check CPU type
	TVPDetectCPU();

	// determine OS type
	OSVERSIONINFO osinfo;
	osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	GetVersionEx(&osinfo);
	TVPPushEnvironNoise(&osinfo, sizeof(osinfo));


	bool nt = osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT;

	TVPSystemIsBasedOnNT = nt;


	TVPAllocGraphicCacheOnHeap = false; // always false since beta 20

	// determine maximum graphic cache limit
	tTJSVariant opt;
	tjs_int limitmb = -1;
	if(TVPGetCommandLine(TJS_W("-gclim"), &opt))
	{
		ttstr str(opt);
		if(str == TJS_W("auto"))
			limitmb = -1;
		else
			limitmb = (tjs_int)opt;
	}


	if(limitmb == -1)
	{
		if(TVPTotalPhysMemory <= 32*1024*1024)
			TVPGraphicCacheSystemLimit = 0;
		else if(TVPTotalPhysMemory <= 48*1024*1024)
			TVPGraphicCacheSystemLimit = 0;
		else if(TVPTotalPhysMemory <= 64*1024*1024)
			TVPGraphicCacheSystemLimit = 0;
		else if(TVPTotalPhysMemory <= 96*1024*1024)
			TVPGraphicCacheSystemLimit = 4;
		else if(TVPTotalPhysMemory <= 128*1024*1024)
			TVPGraphicCacheSystemLimit = 8;
		else if(TVPTotalPhysMemory <= 192*1024*1024)
			TVPGraphicCacheSystemLimit = 12;
		else if(TVPTotalPhysMemory <= 256*1024*1024)
			TVPGraphicCacheSystemLimit = 20;
		else if(TVPTotalPhysMemory <= 512*1024*1024)
			TVPGraphicCacheSystemLimit = 40;
		else
			TVPGraphicCacheSystemLimit = int(TVPTotalPhysMemory / (1024*1024*10));	// cachemem = physmem / 10
		TVPGraphicCacheSystemLimit *= 1024*1024;
	}
	else
	{
		TVPGraphicCacheSystemLimit = limitmb * 1024*1024;
	}


	if(TVPTotalPhysMemory <= 64*1024*1024)
		TVPSetFontCacheForLowMem();

//	TVPGraphicCacheSystemLimit = 1*1024*1024; // DEBUG 


	// check TVPGraphicSplitOperation option
	if(TVPGetCommandLine(TJS_W("-gsplit"), &opt))
	{
		ttstr str(opt);
		if(str == TJS_W("no"))
			TVPGraphicSplitOperationType = gsotNone;
		else if(str == TJS_W("int"))
			TVPGraphicSplitOperationType = gsotInterlace;
		else if(str == TJS_W("yes") || str == TJS_W("simple"))
			TVPGraphicSplitOperationType = gsotSimple;
		else if(str == TJS_W("bidi"))
			TVPGraphicSplitOperationType = gsotBiDirection;

	}

	// check TVPDefaultHoldAlpha option
	if(TVPGetCommandLine(TJS_W("-holdalpha"), &opt))
	{
		ttstr str(opt);
		if(str == TJS_W("yes") || str == TJS_W("true"))
			TVPDefaultHoldAlpha = true;
		else
			TVPDefaultHoldAlpha = false;
	}

	// check TVPJPEGFastLoad option
	if(TVPGetCommandLine(TJS_W("-jpegdec"), &opt)) // this specifies precision for JPEG decoding
	{
		ttstr str(opt);
		if(str == TJS_W("normal"))
			TVPJPEGLoadPrecision = jlpMedium;
		else if(str == TJS_W("low"))
			TVPJPEGLoadPrecision = jlpLow;
		else if(str == TJS_W("high"))
			TVPJPEGLoadPrecision = jlpHigh;

	}

	// dump option
	TVPDumpOptions();

	// initilaize x86 graphic routines
	TVPGL_IA32_Init();

	// load HBeam cursor
	Screen->Cursors[1] = LoadCursor(HInstance, "HBEAM");

	// timer precision
	UINT prectick = 1;
	if(TVPGetCommandLine(TJS_W("-timerprec"), &opt))
	{
		ttstr str(opt);
		if(str == TJS_W("high")) prectick = 1;
		if(str == TJS_W("higher")) prectick = 5;
		if(str == TJS_W("normal")) prectick = 10;
	}

        // draw thread num
        tjs_int drawThreadNum = 1;
        if (TVPGetCommandLine(TJS_W("-drawthread"), &opt)) {
          ttstr str(opt);
          if (str == TJS_W("auto"))
            drawThreadNum = 0;
          else
            drawThreadNum = (tjs_int)opt;
        }
        TVPDrawThreadNum = drawThreadNum;

	if(prectick)
	{
		// retrieve minimum timer resolution
		TIMECAPS tc;
		timeGetDevCaps(&tc, sizeof(tc));
		if(prectick < tc.wPeriodMin)
			TVPTimeBeginPeriodRes = tc.wPeriodMin;
		else
			TVPTimeBeginPeriodRes = prectick;
		if(TVPTimeBeginPeriodRes > tc.wPeriodMax)
			TVPTimeBeginPeriodRes = tc.wPeriodMax;
		// set timer resolution
		timeBeginPeriod(TVPTimeBeginPeriodRes);
		TVPHighTimerPeriod = true;
	}

	TVPPushEnvironNoise(&TVPCPUType, sizeof(TVPCPUType));

}