Beispiel #1
0
Datei: rbtest.c Projekt: btb/d2x
int main()
{
	fix fsecs;
	int oldmin=-1, oldsec=-1;

	error_init(NULL, NULL);
	dpmi_init(0);
	timer_init();
	key_init();
	RBAInit();
	RBARegisterCD();
	RBAPlayTrack(2);

	fsecs = timer_get_fixed_seconds();
	do
	{
		int min, sec, frame;
		long headloc;

		if ((timer_get_fixed_seconds() - fsecs) >= F2_0) {
			headloc = RBAGetHeadLoc(&min, &sec, &frame);
			printf("Head loc: %d (%d:%d:%d)\n", headloc, min, sec, frame);
			if (min==oldmin && sec==oldsec) {
				printf("\nRepeating track..\n");
				RBAPlayTrack(2);
			}
			oldmin = min; oldsec = sec;
			fsecs = timer_get_fixed_seconds();
		}
		if (key_inkey()) {
			RBAStop();
			printf("\nCD stopped.\n");
			break;
		}
	}
	while (1); 

	key_close();
	timer_close();

	return 0;
}
Beispiel #2
0
int main(int argc, const char *argv[])
// return values:
//  1 == error init dpmi / couldn't lock
//  2 == error initing log buffers
//  3 == error installing lammcall rmcode
//  4 == useipxlink requested, but couldn't install
//  5 == error while linking
//  6 == error loading gp2.exe
{
	char *fullname = NULL;
	DWORD *pULongCfg = NULL;
	char *pStrCfg = NULL;
	char cfgnamebuf[_MAX_PATH];
	char *cfgname = NULL;
	char *gp2exename = GP2_EXE_FILENAME;
	char *gp2logname = GP2LOG_DEBUG_FILENAME;
	DWORD dpmicode;
	ubyte log_flags = 0, i /* count var */;
	char tmpbuf[128];


#ifndef TEST
			//----- invoked by our own stub? --------
			// ACHTUNG: "GP2LINT" muss ungerade Anzahl Buchstaben haben (wegen updown & gamma)
	if (strcmp(getenv(updown("GP2LINT")), updown("GAMMA")) != 0) {
							//--- it's not defined, so leave quiet ---
#ifdef TEST
		fprintf(stderr, "GP2LINT not defined!\n");
#endif
		return 140;
	}
#endif

	printf(GP2LAP_BANNER_STR);
#ifdef SOCKCLNT
	printf("This version of GP2Lap was compiled as a socket client.\n");
#endif
#ifndef AUTH
	printf("This version of GP2Lap cannot be used for online leagues that require authentication.\n");
#endif
	//------- Init configuration
	if (GetConfigFileNameOpt(cfgnamebuf, _MAX_PATH, argc, (void*)argv)) {
		cfgname = cfgnamebuf;
		if (!strchr(cfgname, '.'))
			strcat(cfgname, ".cfg");
	} else
		cfgname = GP2LAP_CFG_FILENAME;

	switch (InitCfgValues(cfgname, &paths_to_check, &items, &fullname)) {
		case 0: printf("- Configuration read from: %s\n", fullname); break;
		case 1: fprintf(stderr, "*** can't open %s\n", fullname); break;
		case 2: fprintf(stderr, "*** can't locate %s\n", fullname); break;
	}

	pULongCfg = GetCfgULong("logDebug");
	if (pULongCfg)
		setbits(log_flags, BLF_DISABLED, !*pULongCfg);
	pULongCfg = GetCfgULong("logDebugFlush");
	if (pULongCfg)
		setbits(log_flags, BLF_FLUSHALWAYS, *pULongCfg);
	pStrCfg = GetCfgString("logDebugName");
	if (pStrCfg && strlen(pStrCfg) > 0)     // strlen doesn't seem to do nullptr chk
		gp2logname = pStrCfg;
	if (isoff(log_flags, BLF_DISABLED))
		printf("- Logging debug output to: %s\n", gp2logname);
	pULongCfg = GetCfgULong("hof25Enable");
	if (pULongCfg)
		opt_hof25 = *pULongCfg;
	if (opt_hof25)
		printf("- HOF2.5 mode enabled\n");
	pULongCfg = GetCfgULong("logPerf");
	if (pULongCfg)
		opt_log_perf = *pULongCfg;
	if (opt_log_perf)
		printf("- Extended perfing enabled\n");
	pULongCfg = GetCfgULong("logGLX");
	if (pULongCfg)
		opt_log_glx = *pULongCfg;
	if (opt_log_glx) {
		printf("- GLX log file enabled\n");
		// only enable opt_log_cc if opt_log_glx is TRUE
		pULongCfg = GetCfgULong("logCC");
		if (pULongCfg)
			opt_log_cc = *pULongCfg;
		if (opt_log_cc)
			printf("- Computer car logging enabled\n");
	}
	pULongCfg = GetCfgULong("Spa98");
	if (pULongCfg)
		opt_spa98 = *pULongCfg;
	if (opt_spa98)
		printf("- Spa '98 enabled\n");

	if (!LogStart(log_flags, gp2logname) && isoff(log_flags, BLF_DISABLED))
		fprintf(stderr, "*** error opening logfile '%s'\n", gp2logname);
	atexit(LogEnd);

#ifdef SOCKCLNT
	sockInit();
	atexit(sockExit);
#endif

	//--- init Frank's stuff ------
	init_new_gp2strings();  // init our strings
	FrankSoftInit();  // atexit'ed

	//---- init dpmi before all other stuff now ------
	dpmicode = dpmi_init(0 /* no verbose */); // atexit'ed
	if (dpmicode) {
		fprintf(stderr, "*** dpmi: error %04u\n", dpmicode);
		return 1;
	}

	initvesa();
 
	//---- lock my int9 handler ------
	if (!dpmi_lock_region((void near *)(MyInt9), 4096)) {  // should be enough
		 if (GetLogDpmiInfo())
			 LogLine("- dpmi: error: MI9 can't be locked!\n");
	} else {
		 if (GetLogDpmiInfo())
			 LogLine("- dpmis: MI9 locked\n");
	}

	//============================================
	//======== the complete logging stuff ========
	//============================================
	// Warning: don't change options after starting the log system!
	if (!Log_Create()) {
		fprintf(stderr, "*** error initing log buffers\n");
		return 2;
	}
	atexit(Log_Kill);

	if (!PrfLog_Create()) {
		fprintf(stderr, "*** error initing perf log buffers\n");
		return 2;
	}
	atexit(PrfLog_Kill);

	//=================================================
	//======== RM-Code fuer int21h vorbereiten =========
	//=================================================
	if ( !install_int21_hook() ) { // atexit'ed
		fprintf(stderr, "*** lowp: error e004");
		return 3;
	}

	//============================================
	//======== the complete network stuff ========
	//============================================
	if ( UseIpxLink ) {
		if ( !ipx_basic_init(0) ) // init the ipx  // atexit'ed
			return 4;
		if ( !start_ipx_link() )  // init the link
			return 5;
	}

	CloserInit();   // atexit'ed  // the very last

	//---- ok, send alive to logfile -----------
	_strdate(&tmpbuf);
	sprintf(strbuf,"\n"GP2LAP_NAME" started on %s ", tmpbuf);
	_strtime(&tmpbuf);
	strcat(strbuf, tmpbuf);
	strcat(strbuf, "\n");
	LogLine(strbuf);

	sprintf(strbuf, "- Code start at 0x%08x\n", &__begtext);
	LogLine(strbuf);

	//----- 08/99  for solving the int2F prob---------------
	InitFixInt2F();

	//----- Fremdapplikation starten -------
	putenv("DOS4G=QUIET");
	sprintf(strbuf, "Loading %s...\n", gp2exename);
	LogLine(strbuf);
	printf(strbuf);
	argv[0] = gp2exename;
	if (spawnv(P_WAIT, gp2exename, (void*)argv) < 0) {      // cast to void* to avoid warning about double indirection constness
		sprintf(strbuf, "*** error loading %s: %s\n", gp2exename, strerror(errno));
		LogLine(strbuf);
		fprintf(stderr, strbuf);
	}

#ifdef TEST
	sprintf(strbuf, "flagfield = 0x%08x\n", flagfield);
	LogLine(strbuf);
	if (GP2_Found && ((flagfield & 0xFFF) != 0x7))
		printf("\nflags == 0x%08X\n*** error flag field incorrect\n", flagfield);
#endif

	//--- saying bye now ------
	_strdate(&tmpbuf);
	sprintf(strbuf, GP2LAP_NAME" exiting on %s ", tmpbuf);
	_strtime(&tmpbuf);
	strcat(strbuf, tmpbuf);
	strcat(strbuf, "\n");
	LogLine(strbuf);

	return 0;
}