//仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩
//
//    HEBORIS [僿儃儕僗] 2001 Ver0.00 / 2000.11.05 (Sun) 乣 ????.??.?? (????)
//
//                         (c) 1998-2000 Kenji Hoshimoto
//
//仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭

import "string.dll"
int screenMode, colorMode, systemmem;

//仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱
//   弶婜愝掕
//仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯
void main() {
	if(LoadConfig()) {	//CONFIG.SAV傛傝愝掕傪儘乕僪
		CallScript("script/readdef.c");	//撉傒崬傒幐攕偟偨傜option.def丒keyconf.def偐傜CONFIG.SAV嶌惉
		halt;
		LoadConfig();
	}

	/* 050825 夋柺儌乕僪奼挘夵憿晹暘 -- 偙偙偐傜 */
	if(screenMode == 0)
		SetWindow (0, 320, 240, colorMode);
	else if(screenMode == 1)
		SetWindow (1, 320, 240, colorMode);
	else if(screenMode == 2)
		SetWindow (1, 640, 480, colorMode);
	else if(screenMode == 3)
		SetWindow (0, 640, 480, colorMode);
	else if(screenMode == 4)
		SetWindow (1, 800, 600, colorMode);
	else if(screenMode == 5)
		SetWindow (1, 1024, 768, colorMode);
	else if(screenMode == 6)
		SetWindow (1, 1280, 960, colorMode);
	else
		SetWindow (1, 640, 480, colorMode);
	/* 偙偙傑偱 */

	// 60fps
	SetFPS (60);

	// YGS2000屌桳偺愝掕
	SetConstParam("Caption", "Please Wait...");
	SetConstParam("EnablePause", 0);		//弶婜壔偑廔傢傞傑偱億乕僘偟側偄#1.60c7p9ex
	SetConstParam("USE_XZ_FOR_BUTTON", 1);
	SetConstParam("StringMax", 123);

	SetDebugMode(0);

	// 僔僗僥儉儊儌儕傪巊偆偐?
	SetSystemMemoryUse(systemmem);
}


int LoadConfig(void) {
	int i, cfgbuf[24];

	FillMemory(&cfgbuf, 24, 0);
	LoadFile("CONFIG.SAV", &cfgbuf, 24);
	if(cfgbuf[0] != 0x4F424550) return (1);
	if(cfgbuf[1] != 0x20534953) return (1);
	if(cfgbuf[2] != 0x464E4F44) return (1);
	if(cfgbuf[3] != 0x31764750) return (1);

	screenMode = cfgbuf[4] & 0xff;
	colorMode = (cfgbuf[4] >> 8 + 1) * 16;
	systemmem = cfgbuf[5];
	return (0);
}