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; }
int main(int argn, char **argv) { int sound = 1; int jump = 0; if (argn >= 2) { switch (argv[1][0]) { case 'n' : sound = 0; break; case '1' : jump = 1; break; case '2' : jump = 2; break; case '3' : jump = 3; break; case '4' : jump = 4; break; } } memset(vesa,0,modes*sizeof(tvesa)); //vesa[3].flags = 1; //erz-effekt kann 8 bit readconfig(); if ((dflags & dfNosound)) sound = 0; initvesa(vesa,modes); tarjstream s("fulcrum.dat"); // tstream s; if ( SDL_Init (SDL_INIT_VIDEO) != 0 ) exit("Error: Couldn't initialize SDL"); atexit(SDL_Quit); i8_init(); if (sound) initxm(); int memsize = vesa[1].xres*vesa[1].yres*28 + 16000000; if (sound == 0) memsize -= 1000000; initmem(memsize); if (jump == 1) goto main; if (jump == 2) goto pic; if (jump == 3) goto extro; if (jump == 4) goto erz; //intro part setmode(0); initcredits(s,vesa[0]); initmese(s,vesa[0],1 ,0 ,0 ,0); //camera,tracks,ambient,debug); if (sound) loadxm(s,"fx.rxm",0); startmese(0/*frame*/); if (keypressed()) { if (sound) rxmstop(xmStop); goto weg; } if (sound) rxmstop(xmFade); //goto weg; //if (keypressed()) getch(); emptymem(); main: //main part setmode(1); initmoove(s,vesa[1]); if (sound) loadxm(s,"looping.rxm",0); startmoove(); if (keypressed()) { if (sound) rxmstop(xmStop); goto weg; } if (sound) rxmstop(xmStop); emptymem(); pic: //adler pic setmode(2); ShowPic(s, vesa[2]); if (delay(8000)) goto weg; emptymem(); extro: //extro setmode(0); // initcredits(s,vesa[0]); initmese(s,vesa[0],0 ,1 ,1 ,0); //camera,tracks,ambient,debug); if (sound) loadxm(s,"fx.rxm",0x20); startmese(/*60000*/0/*frame*/); if (keypressed()) { if (sound) rxmstop(xmStop); goto weg; } if (sound) rxmstop(xmFade); emptymem(); erz: //erzeffekt setmode(3); initerz(s,vesa[3]); if (sound) loadxm(s,"bunga.rxm",0); starterz(); if (keypressed()) { if (sound) rxmstop(xmStop); goto weg; } if (sound) rxmstop(xmFade); weg: if (sound) donexm(); i8_done(); textmode(); //checkit(); return 0; };