int main() { char empName[40]; char empAge[40]; char empSal[40]; char dnameAge[40]; char deptName[40]; char errStr[200]; strcpy(empName,"EMP-NAME"); strcpy(empAge,"EMP-AGE"); strcpy(empSal,"EMP-SAL"); strcpy(dnameAge, "DNAME-AGE"); strcpy(deptName,"DEPT-NAME"); /******************************************************************************** * Αρχικοποίηση των εσωτερικών δομών του λογισμικού των ΒΔ * ********************************************************************************/ AM_Init(); /******************************************************************************** * Διαγραφή των b+-δένδρων , για παράδειγμα λόγω της διαγραφής * * ολόκληρης της βάσης * ********************************************************************************/ if (AM_DestroyIndex(empName) != AME_OK) { sprintf(errStr,"Error in AM_DestroyIndex called on %s \n",empName); AM_PrintError(errStr); } if (AM_DestroyIndex(empAge) != AME_OK) { sprintf(errStr,"Error in AM_DestroyIndex called on %s \n",empAge); AM_PrintError(errStr); } if (AM_DestroyIndex(empSal) != AME_OK) { sprintf(errStr,"Error in AM_DestroyIndex called on %s \n",empSal); AM_PrintError(errStr); } if (AM_DestroyIndex(dnameAge) != AME_OK) { sprintf(errStr,"Error in AM_DestroyIndex called on %s \n",dnameAge); AM_PrintError(errStr); } if (AM_DestroyIndex(deptName) != AME_OK) { sprintf(errStr,"Error in AM_DestroyIndex called on %s \n",deptName); AM_PrintError(errStr); } return 0; }
int UT_Init( char * dbname ) { /* Arxikopoioume ta katwtera epipeda */ HF_Init(); AM_Init(); /* kai metaferomaste sto fakelo ths database */ if ( chdir( dbname ) ) { printf( "Error: Database %s does not exist", dbname ); return AMINIREL_GE; } /* initialize twn fileDescriptors se non valid timh */ this_db.attrCatDesc = this_db.relCatDesc = this_db.viewAttrCatDesc = this_db.viewCatDesc = AMINIREL_INVALID; /* Anoigma twn 4 vasikwn arxeiwn mias database pou tha mas xreiastoun argotera */ if (( this_db.attrCatDesc = HF_OpenFile( "attrCat" ) ) < HFE_OK ) { HF_PrintError( "Couldn't open attrCat" ); return AMINIREL_GE; } if (( this_db.relCatDesc = HF_OpenFile( "relCat" ) ) < HFE_OK ) { HF_PrintError( "Couldn't open relCat" ); return AMINIREL_GE; } if (( this_db.viewAttrCatDesc = HF_OpenFile( "viewAttrCat" ) ) < HFE_OK ) { HF_PrintError( "Couldn't open viewAttrCat" ); return AMINIREL_GE; } if (( this_db.viewCatDesc = HF_OpenFile( "viewCat" ) ) < HFE_OK ) { HF_PrintError( "Couldn't open viewCat" ); return AMINIREL_GE; } return AMINIREL_OK; }
int main(int argc, char* argv[]){ char* dbname; if(argc!=2){ printf("Usage: %s dbname \n",argv[0]); return 1; } dbname=argv[1]; if(chdir(dbname)){ printf("Cannot open database!\n"); return 1; } BF_Init(); HF_Init(); AM_Init(); if ((relCatFd = HF_OpenFile("relCat")) < 0) { printf("Cannot open file relCat\n"); return 1; } if ((attrCatFd = HF_OpenFile("attrCat")) < 0) { printf("Cannot open file relCat\n"); return 1; } /* Κλήση της συνάρτησης yyparse ή οποία */ /* θα καλεί αυτόματα τις συναρτήσεις σας */ while(yyparse() == RESTART); system("Pause"); return 0; }
int main() { int scan1; int eNentry; int eAentry; int eSentry; int dAentry; int eage; float esal; char edname[40]; empName[9] = '\0'; char fltname[40]; int recordid = 1; char errStr[200]; int* ivalue = NULL; char* cvalue = NULL; AM_Init(); strcpy(empAge, "TestDb3"); if (AM_CreateIndex(empAge, STRING, sizeof(empName) - 1, INTEGER, sizeof(int)) != AME_OK) { sprintf(errStr, "Error in AM_CreateIndex called on %s \n", empAge); AM_PrintError(errStr); return 1; } if ((eAentry = AM_OpenIndex(empAge)) < 0) { sprintf(errStr, "Error in AM_OpenIndex called on %s \n", empAge); AM_PrintError(errStr); return 1; } srand(time(NULL)); int i, j; recordid = 0; int count = 0; for (i = 1; i <= 100000; ++i) { for (j = 0; j < 9; ++j) { empName[j] = (char) abs(rand()%(122-97) + 97); } if(empName[0] == 'a') count++; insertEntries(eAentry, empName, ++recordid); // printf("record id : %d\n", recordid); } strcpy(empName, "bla"); insertEntries(eAentry, empName, ++recordid); printf("names starting with a : %d\n", count); empName[0] = 'b'; empName[1] = '\0'; int scan = AM_OpenIndexScan(eAentry, LESS_THAN, empName); i = 0; while(AM_FindNextEntry(scan) != NULL) i++; printf("Names with less than b : %d\n", i); AM_CloseIndexScan(scan); empName[0] = 'b'; empName[1] = '\0'; scan = AM_OpenIndexScan(eAentry, GREATER_THAN, empName); i = 0; while(AM_FindNextEntry(scan) != NULL) i++; printf("Names with more than b : %d\n", i); AM_CloseIndexScan(scan); strcpy(empName, "bla"); scan = AM_OpenIndexScan(eAentry, EQUAL, empName); i = 0; int * kappa = NULL; while((kappa = (int *) AM_FindNextEntry(scan) )!= NULL) { printf("%d\n", *kappa); i++; } printf("Names equal with bla : %d\n", i); AM_CloseIndexScan(scan); printf("record id : %d\n", recordid); AM_CloseIndex(eAentry); AM_DestroyIndex(empAge); return 0; }
int main() { int athletesFd; int eventsFd; int partsFd; int athletesIndexFd0; int athletesIndexFd1; int athletesIndexFd2; int eventsIndexFd0; int eventsIndexFd1; int partsIndexFd0; int partsIndexFd1; int partsIndexFd2; int recId; char *athleteRec; char *eventRec; char *partRec; int athId; char surname[AM_MAIN_NAME_SIZE]; char name[AM_MAIN_NAME_SIZE]; int eventId; char eventName[AM_MAIN_EVENT_NAME_SIZE]; char partDate[AM_MAIN_DATE_SIZE]; /* Αρχικοποίηση Επιπέδου HF */ HF_Init(); /* Αρχικοποίηση Επιπέδου AM */ AM_Init(); /* ’νοιγμα Αρχείου ATHLETES */ athletesFd = HF_OpenFile("ATHLETES"); if (athletesFd < 0) { HF_PrintError("Error in HF_OpenFile called on ATHLETES."); return -1; } /* ’νοιγμα Αρχείου EVENTS */ eventsFd = HF_OpenFile("EVENTS"); if (eventsFd < 0) { HF_PrintError("Error in HF_OpenFile called on EVENTS."); return -1; } /* ’νοιγμα Αρχείου PARTICIPATIONS */ partsFd = HF_OpenFile("PARTICIPATIONS"); if (partsFd < 0) { HF_PrintError("Error in HF_OpenFile called on PARTICIPATIONS."); return -1; } /*Δημιουργία ευρετηρίου στο 1ο πεδίο του αρχείου ATHLETES*/ if (AM_CreateIndex("ATHLETES", 0, 'i', sizeof(int)) != AME_OK) { AM_PrintError("Error in AM_CreateIndex called on ATHLETES.0."); } /*’νοιγμα του 1ου ευρετηρίου στο αρχείο ATHLETES*/ athletesIndexFd0 = AM_OpenIndex("ATHLETES", 0); if (athletesIndexFd0 < 0) { AM_PrintError("Error in AM_OpenIndex called on ATHLETES.0."); return -1; } /*Δημιουργία ευρετηρίου στο 2ο πεδίο του αρχείου ATHLETES*/ if (AM_CreateIndex("ATHLETES", 1, 'c', AM_MAIN_NAME_SIZE) != AME_OK) { AM_PrintError("Error in AM_CreateIndex called on ATHLETES.1."); } /* //’νοιγμα του 2ου ευρετηρίου στο αρχείο ATHLETES*/ athletesIndexFd1 = AM_OpenIndex("ATHLETES", 1); if (athletesIndexFd1 < 0) { AM_PrintError("Error in AM_OpenIndex called on ATHLETES.1."); return -1; } /* //Δημιουργία ευρετηρίου στο 3ο πεδίο του αρχείου ATHLETES */ if (AM_CreateIndex("ATHLETES", 2, 'c', AM_MAIN_NAME_SIZE) != AME_OK) { AM_PrintError("Error in AM_CreateIndex called on ATHLETES.2."); } /* //’νοιγμα του 3ου ευρετηρίου στο αρχείο ATHLETES*/ athletesIndexFd2 = AM_OpenIndex("ATHLETES", 2); if (athletesIndexFd2 < 0) { AM_PrintError("Error in AM_OpenIndex called on ATHLETES.2."); return -1; } athleteRec = (char *) malloc(AM_MAIN_ATHLETE_REC_SIZE); if (athleteRec == NULL) { printf("Athlete record malloc failed\n"); return -1; } /* // Εισαγωγή δεδομένων στα ευρετήρια του αρχείου ATHLETES*/ recId = HF_GetFirstRec(athletesFd, athleteRec, AM_MAIN_ATHLETE_REC_SIZE); while (recId >= 0) { memcpy((void *) &athId, (void *) athleteRec, sizeof(int)); athleteRec += sizeof(int); strcpy(surname, athleteRec); athleteRec += AM_MAIN_NAME_SIZE; strcpy(name, athleteRec); athleteRec += AM_MAIN_NAME_SIZE; athleteRec -= AM_MAIN_ATHLETE_REC_SIZE; if (AM_InsertEntry(athletesIndexFd0, 'i', sizeof(int), (char *) &athId, recId) != AME_OK) AM_PrintError("Failed to insert entry."); if (AM_InsertEntry(athletesIndexFd1, 'c', AM_MAIN_NAME_SIZE, surname, recId) != AME_OK) AM_PrintError("Failed to insert entry."); if (AM_InsertEntry(athletesIndexFd2, 'c', AM_MAIN_NAME_SIZE, name, recId) != AME_OK) AM_PrintError("Failed to insert entry."); recId = HF_GetNextRec(athletesFd, recId, athleteRec, AM_MAIN_ATHLETE_REC_SIZE); } /* //Δημιουργία ευρετηρίου στο 1ο πεδίο του αρχείου EVENTS*/ if (AM_CreateIndex("EVENTS", 0, 'i', sizeof(int)) != AME_OK) { AM_PrintError("Error in AM_CreateIndex called on EVENTS.0."); } /* //’νοιγμα του 1ου ευρετηρίου στο αρχείο EVENTS*/ eventsIndexFd0 = AM_OpenIndex("EVENTS", 0); if (eventsIndexFd0 < 0) { AM_PrintError("Error in AM_OpenIndex called on EVENTS.0."); return -1; } /* //Δημιουργία ευρετηρίου στο 2ο πεδίο του αρχείου EVENTS*/ if (AM_CreateIndex("EVENTS", 1, 'c', AM_MAIN_EVENT_NAME_SIZE) != AME_OK) { AM_PrintError("Error in AM_CreateIndex called on EVENTS.1."); } /* //’νοιγμα του 2ου ευρετηρίου στο αρχείο EVENTS*/ eventsIndexFd1 = AM_OpenIndex("EVENTS", 1); if (eventsIndexFd1 < 0) { AM_PrintError("Error in AM_OpenIndex called on EVENTS.1."); return -1; } eventRec = (char *) malloc(AM_MAIN_EVENT_REC_SIZE); if (eventRec == NULL) { printf("Event record malloc failed\n"); return -1; } /* // Εισαγωγή δεδομένων στα ευρετήρια του αρχείου EVENTS*/ recId = HF_GetFirstRec(eventsFd, eventRec, AM_MAIN_EVENT_REC_SIZE); while (recId >= 0) { memcpy((void *) &eventId, (void *) eventRec, sizeof(int)); eventRec += sizeof(int); strcpy(eventName, eventRec); eventRec += AM_MAIN_EVENT_NAME_SIZE; eventRec -= AM_MAIN_EVENT_REC_SIZE; if (AM_InsertEntry(eventsIndexFd0, 'i', sizeof(int), (char *) &eventId, recId) != AME_OK) AM_PrintError("Failed to insert entry."); if (AM_InsertEntry(eventsIndexFd1, 'c', AM_MAIN_EVENT_NAME_SIZE, eventName, recId) != AME_OK) AM_PrintError("Failed to insert entry."); recId = HF_GetNextRec(eventsFd, recId, eventRec, AM_MAIN_ATHLETE_REC_SIZE); } /* //Δημιουργία ευρετηρίου στο 1ο πεδίο του αρχείου PARTICIPATIONS*/ if (AM_CreateIndex("PARTICIPATIONS", 0, 'i', sizeof(int)) != AME_OK) { AM_PrintError("Error in AM_CreateIndex called on PARTICIPATIONS.0."); } /* //’νοιγμα του 1ου ευρετηρίου στο αρχείο PARTICIPATIONS*/ partsIndexFd0 = AM_OpenIndex("PARTICIPATIONS", 0); if (partsIndexFd0 < 0) { AM_PrintError("Error in AM_OpenIndex called on PARTICIPATIONS.0."); return -1; } /* //Δημιουργία ευρετηρίου στο 2ο πεδίο του αρχείου PARTICIPATIONS*/ if (AM_CreateIndex("PARTICIPATIONS", 1, 'i', sizeof(int)) != AME_OK) { AM_PrintError("Error in AM_CreateIndex called on PARTICIPATIONS.1."); } /* //’νοιγμα του 2ου ευρετηρίου στο αρχείο PARTICIPATIONS*/ partsIndexFd1 = AM_OpenIndex("PARTICIPATIONS", 1); if (partsIndexFd1 < 0) { AM_PrintError("Error in AM_OpenIndex called on PARTICIPATIONS.1."); return -1; } /* //Δημιουργία ευρετηρίου στο 3ο πεδίο του αρχείου PARTICIPATIONS*/ if (AM_CreateIndex("PARTICIPATIONS", 2, 'c', AM_MAIN_DATE_SIZE) != AME_OK) { AM_PrintError("Error in AM_CreateIndex called on PARTICIPATIONS.2."); } /* //’νοιγμα του 3ου ευρετηρίου στο αρχείο PARTICIPATIONS*/ partsIndexFd2 = AM_OpenIndex("PARTICIPATIONS", 2); if (partsIndexFd2 < 0) { AM_PrintError("Error in AM_OpenIndex called on PARTICIPATIONS.2."); return -1; } partRec = (char *) malloc(AM_MAIN_PARTICIPATION_REC_SIZE); if (partRec == NULL) { printf("Participation record malloc failed\n"); return -1; } /* // Εισαγωγή δεδομένων στα ευρετήρια του αρχείου PARTICIPATIONS*/ recId = HF_GetFirstRec(partsFd, partRec, AM_MAIN_PARTICIPATION_REC_SIZE); while (recId >= 0) { memcpy((void *) &athId, (void *) partRec, sizeof(int)); partRec += sizeof(int); memcpy((void *) &eventId, (void *) partRec, sizeof(int)); partRec += sizeof(int); strcpy(partDate, partRec); partRec += AM_MAIN_DATE_SIZE; partRec -= AM_MAIN_PARTICIPATION_REC_SIZE; if (AM_InsertEntry(partsIndexFd0, 'i', sizeof(int), (char *) &athId, recId) != AME_OK) AM_PrintError("Failed to insert entry."); if (AM_InsertEntry(partsIndexFd1, 'i', sizeof(int), (char *) &eventId, recId) != AME_OK) AM_PrintError("Failed to insert entry."); if (AM_InsertEntry(partsIndexFd2, 'c', AM_MAIN_DATE_SIZE, partDate, recId) != AME_OK) AM_PrintError("Failed to insert entry."); recId = HF_GetNextRec(partsFd, recId, partRec, AM_MAIN_PARTICIPATION_REC_SIZE); } free(athleteRec); free(eventRec); free(partRec); /* //Κλείσιμο Αρχείων*/ if (HF_CloseFile(athletesFd) != HFE_OK) HF_PrintError("Error in HF_CloseFile called on ATHLETES."); if (HF_CloseFile(eventsFd) != HFE_OK) HF_PrintError("Error in HF_CloseFile called on EVENTS."); if (HF_CloseFile(partsFd) != HFE_OK) HF_PrintError("Error in HF_CloseFile called on PARTICIPATIONS."); if (AM_CloseIndex(athletesIndexFd0) != AME_OK) AM_PrintError("Error in AM_CloseIndex called on ATHLETES.0."); if (AM_CloseIndex(athletesIndexFd1) != AME_OK) AM_PrintError("Error in AM_CloseIndex called on ATHLETES.1."); if (AM_CloseIndex(athletesIndexFd2) != AME_OK) AM_PrintError("Error in AM_CloseIndex called on ATHLETES.2."); if (AM_CloseIndex(eventsIndexFd0) != AME_OK) AM_PrintError("Error in AM_CloseIndex called on EVENTS.0."); if (AM_CloseIndex(eventsIndexFd1) != AME_OK) AM_PrintError("Error in AM_CloseIndex called on EVENTS.1."); if (AM_CloseIndex(partsIndexFd0) != AME_OK) AM_PrintError("Error in AM_CloseIndex called on PARTICIPATIONS.0."); if (AM_CloseIndex(partsIndexFd1) != AME_OK) AM_PrintError("Error in AM_CloseIndex called on PARTICIPATIONS.1."); if (AM_CloseIndex(partsIndexFd2) != AME_OK) AM_PrintError("Error in AM_CloseIndex called on PARTICIPATIONS.2."); return 0; }
/* ------------------------------------------------------------------------------ */ void L1Audio_Task(unsigned argc, void *argv) { uint32 retrieved_events; uint32 I; uint16 tempID; l1audio.aud_events = kal_create_event_group("L1Audio"); l1audio.hisr = kal_init_hisr(L1AUDIO_HISR); GET_SLEEP_HANDLE(); #if ( defined( __CENTRALIZED_SLEEP_MANAGER__ ) && defined(MTK_SLEEP_ENABLE) && !defined(__AUDIO_POWERON_RESET_DSP__) ) l1audio.md2g_pdn_handle = L1D_MD2G_PWD_GetHandle(); l1audio.l1sm_handle = L1SM_IntGetHandle(); #endif l1audio.runningState = 0; l1audio.disallowSleepState = 0; l1audio.dsp_slow_idle_counter = 0; l1audio.event_flag = 0; l1audio.id_flag = 0; l1audio.media_flag = 0; l1audio.postHisrHandler = (L1Audio_EventHandler)0; l1audio.sema = kal_create_sem( "Aud_Sema", 1 ); l1audio.hisrMagicFlag = 0; for( I = 0; I < MAX_HISR_HANDLER; I++ ) l1audio.hisrMagicNo[I] = 0; tempID = L1Audio_GetAudioID(); L1Audio_SetFlag(tempID); DSP_DynamicDownload_Init(); #ifndef L1D_TEST /// Dynamic download for A/V sync #if defined( DSP_WT_SYN ) && !defined(__AUDIO_COMPONENT_SUPPORT__) DSP_DynamicDownload( DDID_WAVETABLE ); #endif #endif AM_Init(); #if APM_SUPPORT APM_Init(); #endif /// AFE_Init will invoke L1Audio_GetAudioID /// and expect to get the id 0 to make sure /// it has the highest priority in the event group AFE_Init(); #if !defined(__SMART_PHONE_MODEM__) && !defined(__L1_STANDALONE__) && !defined( MED_MODEM ) AVsync_Init(); #endif #if defined(__AUDIO_POWERON_RESET_DSP__) { uint32 _savedMask; _savedMask = SaveAndSetIRQMask(); AFE_Init_status(KAL_TRUE); AFE_RegisterBackup(); RestoreIRQMask(_savedMask); } #endif L1SP_Init(); ktInit( L1Audio_GetAudioID() ); toneInit( L1Audio_GetAudioID() ); mediaInit( L1Audio_GetAudioID() ); #if defined(VR_CYBERON) vrsdInit(); #elif defined(VRSI_CYBERON) vrsiInit(); #endif toneLoopbackRecInit(); #if ( defined(__BT_A2DP_PROFILE__) || defined(SBC_UNIT_TEST) ) //&& !(APM_SUPPORT) SBC_Init(); #endif #if defined(__BES_TS_SUPPORT__) AudioPP_TS_Init(); #endif #ifdef __CTM_SUPPORT__ l1ctm_init(); #endif #ifdef __TWOMICNR_SUPPORT__ Two_Mic_NR_chip_Init(); #endif #if VMI_SUPPORT || defined(VORTP_UNIT_TEST) VMI_Init(); #endif #if VORTP_SUPPORT || defined(VORTP_UNIT_TEST) VoRTP_Init(); #endif #if defined(CYBERON_DIC_TTS) || defined(IFLY_TTS) || defined(SINOVOICE_TTS) ttsInit(); #endif #if defined( DSP_WT_SYN ) && !defined(__AUDIO_COMPONENT_SUPPORT__) DSPSYN_HW_Init(); #endif #if defined( __I2S_INPUT_MODE_SUPPORT__ ) I2S_init(); #endif #if defined(__VOICE_CHANGER_SUPPORT__) VCHG_Initialize(); #endif #if defined(__AUDIO_COMPONENT_SUPPORT__) && !defined(__L1_STANDALONE__) && !defined(MED_MODEM) // KH : for audio component ACU_Init(); #endif #if defined(__CVSD_CODEC_SUPPORT__) { extern void BT_SCO_Init(void); BT_SCO_Init(); } #endif memset( &(l1audio.debug_info), 0, sizeof(l1audio.debug_info) ); AFE_TurnOnFIR( L1SP_SPEECH ); AFE_TurnOnFIR( L1SP_VOICE ); L1Audio_ClearFlag(tempID); L1Audio_FreeAudioID(tempID); l1audio.isInitiated = KAL_TRUE; while( 1 ) { #if VERIFY_DATA_TO_DSP VERIFY_DATA_TO_DSP_SAVE_DATA(); #endif kal_retrieve_eg_events(l1audio.aud_events,0xFFFF,KAL_OR_CONSUME,&retrieved_events,KAL_SUSPEND); l1audio.retrieved_events = retrieved_events; l1audio.events_l1FN = L1I_GetTimeStamp(); for( I = 0; I < MAX_AUDIO_FUNCTIONS; I++ ) { if ( l1audio.retrieved_events & (1<<I) ) { l1audio.evHandler[I]( l1audio.evData[I] ); } } //if( (l1audio.runningState & l1audio.disallowSleepState) == 0 ) if( l1audio.runningState == 0 ) SLEEP_UNLOCK(); } }
// // D_DoomMainSetup // // CPhipps - the old contents of D_DoomMain, but moved out of the main // line of execution so its stack space can be freed static void D_DoomMainSetup(void) { int p; char file[256]; int temp; int choseniwad; SDL_Init(0); M_FindResponseFile(); iwadfile = D_FindIWAD(); modifiedgame = false; nomonsters = M_CheckParm("-nomonsters"); respawnparm = M_CheckParm("-respawn"); fastparm = M_CheckParm("-fast"); devparm = M_CheckParm("-devparm"); if (M_CheckParm("-altdeath")) deathmatch = 2; else if (M_CheckParm("-deathmatch")) deathmatch = 1; M_SetConfigDir(); // turbo option p = M_CheckParm("-turbo"); if (p) { int scale = 200; extern int forwardmove[2]; extern int sidemove[2]; if (p < myargc - 1) scale = atoi(myargv[p + 1]); if (scale < 10) scale = 10; if (scale > 400) scale = 400; forwardmove[0] = forwardmove[0] * scale / 100; forwardmove[1] = forwardmove[1] * scale / 100; sidemove[0] = sidemove[0] * scale / 100; sidemove[1] = sidemove[1] * scale / 100; } // init subsystems V_Init(); // Load configuration files before initialising other subsystems. M_LoadDefaults(); if (!M_FileExists("doomretro.wad")) if (!M_FileExists("doomretro.wad.temp")) I_Error("Can't find doomretro.wad."); if (iwadfile) { if (D_AddFile(iwadfile)) if (runcount < RUNCOUNT_MAX) runcount++; } else { if (!runcount) D_FirstUse(); rename("doomretro.wad", "doomretro.wad.temp"); do { choseniwad = D_ChooseIWAD(); if (choseniwad == -1) { rename("doomretro.wad.temp", "doomretro.wad"); I_Quit(false); } else if (!choseniwad) PlaySound((LPCTSTR)SND_ALIAS_SYSTEMHAND, NULL, SND_ALIAS_ID | SND_ASYNC); } while (!choseniwad); rename("doomretro.wad.temp", "doomretro.wad"); if (runcount < RUNCOUNT_MAX) runcount++; } M_SaveDefaults(); if (!W_MergeFile("doomretro.wad")) if (!W_MergeFile("doomretro.wad.temp")) I_Error("Can't find doomretro.wad."); if (W_CheckNumForName("BLD2A0") < 0 || W_CheckNumForName("MEDBA0") < 0 || W_CheckNumForName("STBAR2") < 0) I_Error("Wrong version of doomretro.wad."); p = M_CheckParmsWithArgs("-file", "-pwad", 1); if (p > 0) { for (p = p + 1; p < myargc && myargv[p][0] != '-'; ++p) { char *filename = uppercase(D_TryFindWADByName(myargv[p])); if (W_MergeFile(filename)) { modifiedgame = true; if (D_CheckFilename(filename, "NERVE.WAD")) nerve = true; } } } if (FREEDOOM && W_CheckNumForName("FREEDM") < 0 && !modifiedgame) I_Error("FREEDOOM requires a BOOM-compatible source port, and is therefore" "unable to be opened by DOOM RETRO."); DMENUPIC = (W_CheckNumForName("DMENUPIC") >= 0); M_DOOM = (W_CheckMultipleLumps("M_DOOM") > 1); M_EPISOD = (W_CheckMultipleLumps("M_EPISOD") > 1); M_GDHIGH = (W_CheckMultipleLumps("M_GDHIGH") > 1); M_GDLOW = (W_CheckMultipleLumps("M_GDLOW") > 1); M_LOADG = (W_CheckMultipleLumps("M_LOADG") > 1); M_LSCNTR = (W_CheckMultipleLumps("M_LSCNTR") > 1); M_MSENS = (W_CheckMultipleLumps("M_MSENS") > 1); M_MSGOFF = (W_CheckMultipleLumps("M_MSGOFF") > 1); M_MSGON = (W_CheckMultipleLumps("M_MSGON") > 1); M_NEWG = (W_CheckMultipleLumps("M_NEWG") > 1); M_NMARE = (W_CheckMultipleLumps("M_NMARE") > 1); M_OPTTTL = (W_CheckMultipleLumps("M_OPTTTL") > 1); M_PAUSE = (W_CheckMultipleLumps("M_PAUSE") > 1); M_SAVEG = (W_CheckMultipleLumps("M_SAVEG") > 1); M_SKILL = (W_CheckMultipleLumps("M_SKILL") > 1); M_SKULL1 = (W_CheckMultipleLumps("M_SKULL1") > 1); M_SVOL = (W_CheckMultipleLumps("M_SVOL") > 1); STARMS = (W_CheckMultipleLumps("STARMS") > 2); STBAR = (W_CheckMultipleLumps("STBAR") > 2); STCFN034 = (W_CheckMultipleLumps("STCFN034") > 1); STCFN039 = (W_CheckMultipleLumps("STCFN039") > 1); STCFN121 = (W_CheckMultipleLumps("STCFN121") > 1); STYSNUM0 = (W_CheckMultipleLumps("STYSNUM0") > 1); TITLEPIC = (W_CheckNumForName("TITLEPIC") >= 0); WISCRT2 = (W_CheckMultipleLumps("WISCRT2") > 1); bfgedition = (DMENUPIC && W_CheckNumForName("M_ACPT") >= 0); // Generate the WAD hash table. Speed things up a bit. W_GenerateHashTable(); D_IdentifyVersion(); InitGameVersion(); D_SetGameDescription(); D_SetSaveGameDir(); // Check for -file in shareware if (modifiedgame) { // These are the lumps that will be checked in IWAD, // if any one is not present, execution will be aborted. char name[23][9] = { "e2m1", "e2m2", "e2m3", "e2m4", "e2m5", "e2m6", "e2m7", "e2m8", "e2m9", "e3m1", "e3m3", "e3m3", "e3m4", "e3m5", "e3m6", "e3m7", "e3m8", "e3m9", "dphoof", "bfgga0", "heada1", "cybra1", "spida1d1" }; int i; if (gamemode == shareware) I_Error("You cannot use -FILE with the shareware version.\n" "Please purchase the full version."); // Check for fake IWAD with right name, // but w/o all the lumps of the registered version. if (gamemode == registered) for (i = 0; i < 23; i++) if (W_CheckNumForName(name[i]) < 0) I_Error("This is not the registered version."); } // get skill / episode / map from parms startskill = sk_medium; startepisode = 1; startmap = 1; autostart = false; p = M_CheckParmWithArgs("-skill", 1); if (p) { temp = myargv[p + 1][0] - '1'; if (temp >= sk_baby && temp <= sk_nightmare) { startskill = (skill_t)temp; autostart = true; } } p = M_CheckParmWithArgs("-episode", 1); if (p) { temp = myargv[p + 1][0] - '0'; if ((gamemode == shareware && temp == 1) || (temp >= 1 && ((gamemode == registered && temp <= 3) || (gamemode == retail && temp <= 4)))) { startepisode = temp; startmap = 1; autostart = true; } } p = M_CheckParmWithArgs("-expansion", 1); if (p) { temp = myargv[p + 1][0] - '0'; if (gamemode == commercial && temp <= (nerve ? 2 : 1)) { gamemission = (temp == 1 ? doom2 : pack_nerve); selectedexpansion = temp - 1; startepisode = 1; startmap = 1; autostart = true; } } timelimit = 0; p = M_CheckParmWithArgs("-timer", 1); if (p) timelimit = atoi(myargv[p + 1]); p = M_CheckParm("-avg"); if (p) timelimit = 20; p = M_CheckParmWithArgs("-warp", 1); if (p) { static char lumpname[6]; if (gamemode == commercial) { if (strlen(myargv[p + 1]) == 5 && toupper(myargv[p + 1][0]) == 'M' && toupper(myargv[p + 1][1]) == 'A' && toupper(myargv[p + 1][2]) == 'P') startmap = (myargv[p + 1][3] - '0') * 10 + myargv[p + 1][4] - '0'; else startmap = atoi(myargv[p + 1]); sprintf(lumpname, "MAP%02i", startmap); } else { if (strlen(myargv[p + 1]) == 4 && toupper(myargv[p + 1][0]) == 'E' && toupper(myargv[p + 1][2]) == 'M') { startepisode = myargv[p + 1][1] - '0'; startmap = myargv[p + 1][3] - '0'; } else { startepisode = myargv[p + 1][0] - '0'; if (p + 2 < myargc) startmap = myargv[p + 2][0] - '0'; else startmap = 1; } sprintf(lumpname, "E%iM%i", startepisode, startmap); } if (W_CheckNumForName(lumpname) >= 0) autostart = true; } p = M_CheckParmWithArgs("-loadgame", 1); if (p) startloadgame = atoi(myargv[p + 1]); else startloadgame = -1; if (mouseSensitivity < MOUSESENSITIVITY_MIN || mouseSensitivity > MOUSESENSITIVITY_MAX) mouseSensitivity = MOUSESENSITIVITY_DEFAULT; if (mouseSensitivity == MOUSESENSITIVITY_MIN) mouseSensitivity = -5; gamepadSensitivity = (!mouseSensitivity ? 0.0f : (2.0f + mouseSensitivity / (float)MOUSESENSITIVITY_MAX)); if (sfxVolume < SFXVOLUME_MIN || sfxVolume > SFXVOLUME_MAX) sfxVolume = SFXVOLUME_DEFAULT; if (musicVolume < MUSICVOLUME_MIN || musicVolume > MUSICVOLUME_MAX) musicVolume = MUSICVOLUME_DEFAULT; if (screensize < SCREENSIZE_MIN || screensize > SCREENSIZE_MAX) screensize = SCREENSIZE_DEFAULT; if (widescreen && !fullscreen) { widescreen = false; screensize = SCREENSIZE_MAX; } if (!widescreen) hud = true; if (fullscreen && screensize == SCREENSIZE_MAX) { widescreen = true; screensize = SCREENSIZE_MAX - 1; } if (widescreen) { returntowidescreen = true; widescreen = false; } if (screenwidth && screenheight && (screenwidth < SCREENWIDTH || screenheight < SCREENHEIGHT * 3 / 4)) { screenwidth = SCREENWIDTH; screenheight = SCREENWIDTH * 3 / 4; } if (windowwidth < SCREENWIDTH || windowheight < SCREENWIDTH * 3 / 4) { windowwidth = SCREENWIDTH; windowheight = SCREENWIDTH * 3 / 4; } if (gammalevel < GAMMALEVEL_MIN || gammalevel > GAMMALEVEL_MAX) gammalevel = GAMMALEVEL_DEFAULT; gammalevelindex = 0; while (gammalevelindex < GAMMALEVELS) if (gammalevels[gammalevelindex++] == gammalevel) break; if (gammalevelindex == GAMMALEVELS) { gammalevelindex = 0; while (gammalevels[gammalevelindex++] != GAMMALEVEL_DEFAULT); } gammalevelindex--; if (bloodsplats < BLOODSPLATS_MIN || bloodsplats > BLOODSPLATS_MAX) bloodsplats = BLOODSPLATS_DEFAULT; bloodSplatSpawner = ((bloodsplats == UNLIMITED ? P_SpawnBloodSplat : (bloodsplats ? P_SpawnBloodSplat2 : P_SpawnBloodSplat3))); if (pixelwidth < PIXELWIDTH_MIN || pixelwidth > PIXELWIDTH_MAX) pixelwidth = PIXELWIDTH_DEFAULT; while (SCREENWIDTH % pixelwidth) pixelwidth--; if (pixelheight < PIXELHEIGHT_MIN || pixelheight > PIXELHEIGHT_MAX) pixelheight = PIXELHEIGHT_DEFAULT; while (SCREENHEIGHT % pixelheight) pixelheight--; M_Init(); R_Init(); P_Init(); I_Init(); S_Init((int)(sfxVolume * (127.0f / 15.0f)), (int)(musicVolume * (127.0f / 15.0f))); D_CheckNetGame(); HU_Init(); ST_Init(); AM_Init(); if (startloadgame >= 0) { M_StringCopy(file, P_SaveGameFile(startloadgame), sizeof(file)); G_LoadGame(file); } if (gameaction != ga_loadgame) { if (autostart || netgame) G_DeferredInitNew(startskill, startepisode, startmap); else D_StartTitle(); // start up intro loop } }