void gr_restore_mode() { int i; //gr_set_text_25(); #ifndef NOGRAPH gr_palette_fade_out( gr_palette, 32, 0 ); gr_palette_set_gamma(0); if ( gr_saved_screen.video_mode == 3 ) { switch( gr_saved_screen.height ) { case 43: gr_set_text_43(); break; case 50: gr_set_text_50(); break; default: gr_set_text_25(); break; } } else { gr_set_misc_mode(gr_saved_screen.video_mode); } if (gr_saved_screen.is_graphics==0) { gr_sync_display(); gr_sync_display(); gr_palette_read( gr_pal_default ); gr_palette_clear(); for (i=0; i < gr_saved_screen.width*gr_saved_screen.height; i++ ) pTextMemory[i]=gr_saved_screen.video_memory[i]; gr_setcursor( gr_saved_screen.cursor_x, gr_saved_screen.cursor_y, gr_saved_screen.cursor_sline, gr_saved_screen.cursor_eline ); gr_palette_faded_out = 1; gr_palette_fade_in( gr_pal_default, 32, 0 ); } #endif }
void joydef_menuset(int nitems, newmenu_item * items, int *last_key, int citem ) { nitems=nitems; *last_key = *last_key; if ( citem==2) { gr_palette_set_gamma(items[2].value); } }
void joydef_menuset(int nitems, newmenu_item * items, int *last_key, int citem ) { nitems=nitems; *last_key = *last_key; if ( citem==4) { gr_palette_set_gamma(items[4].value); } if ( Config_digi_volume != items[0].value ) { Config_digi_volume = items[0].value; digi_set_digi_volume( (Config_digi_volume*32768)/8 ); digi_play_sample_once( SOUND_DROP_BOMB, F1_0 ); } if (Config_midi_volume != items[1].value ) { Config_midi_volume = items[1].value; digi_set_midi_volume( (Config_midi_volume*128)/8 ); } }
int ReadConfigFile() { PHYSFS_file *infile; char *line, *token, *value, *ptr; // set defaults GameCfg.DigiVolume = 8; GameCfg.MusicVolume = 8; GameCfg.ReverseStereo = 0; GameCfg.OrigTrackOrder = 0; #if defined(__APPLE__) && defined(__MACH__) GameCfg.MusicType = MUSIC_TYPE_REDBOOK; #else GameCfg.MusicType = MUSIC_TYPE_BUILTIN; #endif GameCfg.CMLevelMusicPlayOrder = MUSIC_CM_PLAYORDER_CONT; GameCfg.CMLevelMusicTrack[0] = -1; GameCfg.CMLevelMusicTrack[1] = -1; memset(GameCfg.CMLevelMusicPath,0,PATH_MAX+1); memset(GameCfg.CMMiscMusic[SONG_TITLE],0,PATH_MAX+1); memset(GameCfg.CMMiscMusic[SONG_BRIEFING],0,PATH_MAX+1); memset(GameCfg.CMMiscMusic[SONG_ENDLEVEL],0,PATH_MAX+1); memset(GameCfg.CMMiscMusic[SONG_ENDGAME],0,PATH_MAX+1); memset(GameCfg.CMMiscMusic[SONG_CREDITS],0,PATH_MAX+1); #if defined(__APPLE__) && defined(__MACH__) GameCfg.OrigTrackOrder = 1; GameCfg.CMLevelMusicPlayOrder = MUSIC_CM_PLAYORDER_LEVEL; snprintf(GameCfg.CMLevelMusicPath, PATH_MAX, "%s", "descent.m3u"); snprintf(GameCfg.CMMiscMusic[SONG_TITLE], PATH_MAX, "%s%s", PHYSFS_getUserDir(), "Music/iTunes/iTunes Music/Insanity/Descent/02 Primitive Rage.mp3"); snprintf(GameCfg.CMMiscMusic[SONG_BRIEFING], PATH_MAX, "%s%s", PHYSFS_getUserDir(), "Music/iTunes/iTunes Music/Insanity/Descent/03 Outerlimits.mp3"); snprintf(GameCfg.CMMiscMusic[SONG_ENDLEVEL], PATH_MAX, "%s%s", PHYSFS_getUserDir(), "Music/iTunes/iTunes Music/Insanity/Descent/04 Close Call.mp3"); snprintf(GameCfg.CMMiscMusic[SONG_ENDGAME], PATH_MAX, "%s%s", PHYSFS_getUserDir(), "Music/iTunes/iTunes Music/Insanity/Descent/14 Insanity.mp3"); snprintf(GameCfg.CMMiscMusic[SONG_CREDITS], PATH_MAX, "%s%s", PHYSFS_getUserDir(), "Music/iTunes/iTunes Music/Insanity/Descent/05 The Darkness Of Space.mp3"); #endif GameCfg.GammaLevel = 0; memset(GameCfg.LastPlayer,0,CALLSIGN_LEN+1); memset(GameCfg.LastMission,0,MISSION_NAME_LEN+1); GameCfg.ResolutionX = 640; GameCfg.ResolutionY = 480; GameCfg.AspectX = 3; GameCfg.AspectY = 4; GameCfg.WindowMode = 0; GameCfg.TexFilt = 0; GameCfg.VSync = 0; GameCfg.Multisample = 0; GameCfg.FPSIndicator = 0; GameCfg.Grabinput = 1; infile = PHYSFSX_openReadBuffered("descent.cfg"); if (infile == NULL) { return 1; } while (!PHYSFS_eof(infile)) { int max_len = PHYSFS_fileLength(infile); // to be fully safe, assume the whole cfg consists of one big line MALLOC(line, char, max_len); memset(line, 0, max_len); PHYSFSX_gets(infile, line); ptr = &(line[0]); while (isspace(*ptr)) ptr++; if (*ptr != '\0') { token = strtok(ptr, "="); value = strtok(NULL, "="); if (!value) value = ""; if (!strcmp(token, DigiVolumeStr)) GameCfg.DigiVolume = strtol(value, NULL, 10); else if (!strcmp(token, MusicVolumeStr)) GameCfg.MusicVolume = strtol(value, NULL, 10); else if (!strcmp(token, ReverseStereoStr)) GameCfg.ReverseStereo = strtol(value, NULL, 10); else if (!strcmp(token, OrigTrackOrderStr)) GameCfg.OrigTrackOrder = strtol(value, NULL, 10); else if (!strcmp(token, MusicTypeStr)) GameCfg.MusicType = strtol(value, NULL, 10); else if (!strcmp(token, CMLevelMusicPlayOrderStr)) GameCfg.CMLevelMusicPlayOrder = strtol(value, NULL, 10); else if (!strcmp(token, CMLevelMusicTrack0Str)) GameCfg.CMLevelMusicTrack[0] = strtol(value, NULL, 10); else if (!strcmp(token, CMLevelMusicTrack1Str)) GameCfg.CMLevelMusicTrack[1] = strtol(value, NULL, 10); else if (!strcmp(token, CMLevelMusicPathStr)) { char * p; strncpy( GameCfg.CMLevelMusicPath, value, PATH_MAX ); p = strchr( GameCfg.CMLevelMusicPath, '\n'); if ( p ) *p = 0; } else if (!strcmp(token, CMMiscMusic0Str)) { char * p; strncpy( GameCfg.CMMiscMusic[SONG_TITLE], value, PATH_MAX ); p = strchr( GameCfg.CMMiscMusic[SONG_TITLE], '\n'); if ( p ) *p = 0; } else if (!strcmp(token, CMMiscMusic1Str)) { char * p; strncpy( GameCfg.CMMiscMusic[SONG_BRIEFING], value, PATH_MAX ); p = strchr( GameCfg.CMMiscMusic[SONG_BRIEFING], '\n'); if ( p ) *p = 0; } else if (!strcmp(token, CMMiscMusic2Str)) { char * p; strncpy( GameCfg.CMMiscMusic[SONG_ENDLEVEL], value, PATH_MAX ); p = strchr( GameCfg.CMMiscMusic[SONG_ENDLEVEL], '\n'); if ( p ) *p = 0; } else if (!strcmp(token, CMMiscMusic3Str)) { char * p; strncpy( GameCfg.CMMiscMusic[SONG_ENDGAME], value, PATH_MAX ); p = strchr( GameCfg.CMMiscMusic[SONG_ENDGAME], '\n'); if ( p ) *p = 0; } else if (!strcmp(token, CMMiscMusic4Str)) { char * p; strncpy( GameCfg.CMMiscMusic[SONG_CREDITS], value, PATH_MAX ); p = strchr( GameCfg.CMMiscMusic[SONG_CREDITS], '\n'); if ( p ) *p = 0; } else if (!strcmp(token, GammaLevelStr)) { GameCfg.GammaLevel = strtol(value, NULL, 10); gr_palette_set_gamma( GameCfg.GammaLevel ); } else if (!strcmp(token, LastPlayerStr)) { char * p; strncpy( GameCfg.LastPlayer, value, CALLSIGN_LEN ); p = strchr( GameCfg.LastPlayer, '\n'); if ( p ) *p = 0; } else if (!strcmp(token, LastMissionStr)) { char * p; strncpy( GameCfg.LastMission, value, MISSION_NAME_LEN ); p = strchr( GameCfg.LastMission, '\n'); if ( p ) *p = 0; } else if (!strcmp(token, ResolutionXStr)) GameCfg.ResolutionX = strtol(value, NULL, 10); else if (!strcmp(token, ResolutionYStr)) GameCfg.ResolutionY = strtol(value, NULL, 10); else if (!strcmp(token, AspectXStr)) GameCfg.AspectX = strtol(value, NULL, 10); else if (!strcmp(token, AspectYStr)) GameCfg.AspectY = strtol(value, NULL, 10); else if (!strcmp(token, WindowModeStr)) GameCfg.WindowMode = strtol(value, NULL, 10); else if (!strcmp(token, TexFiltStr)) GameCfg.TexFilt = strtol(value, NULL, 10); else if (!strcmp(token, VSyncStr)) GameCfg.VSync = strtol(value, NULL, 10); else if (!strcmp(token, MultisampleStr)) GameCfg.Multisample = strtol(value, NULL, 10); else if (!strcmp(token, FPSIndicatorStr)) GameCfg.FPSIndicator = strtol(value, NULL, 10); else if (!strcmp(token, GrabinputStr)) GameCfg.Grabinput = strtol(value, NULL, 10); } d_free(line); } PHYSFS_close(infile); if ( GameCfg.DigiVolume > 8 ) GameCfg.DigiVolume = 8; if ( GameCfg.MusicVolume > 8 ) GameCfg.MusicVolume = 8; if (GameCfg.ResolutionX >= 320 && GameCfg.ResolutionY >= 200) Game_screen_mode = SM(GameCfg.ResolutionX,GameCfg.ResolutionY); return 0; }
int ReadConfigFile() { FILE *infile; char line[80], *token, *value, *ptr; ubyte gamma; int joy_axis_min[4]; int joy_axis_center[4]; int joy_axis_max[4]; int i; strcpy( config_last_player, "" ); joy_axis_min[0] = joy_axis_min[1] = joy_axis_min[2] = joy_axis_min[3] = 0; joy_axis_max[0] = joy_axis_max[1] = joy_axis_max[2] = joy_axis_max[3] = 0; joy_axis_center[0] = joy_axis_center[1] = joy_axis_center[2] = joy_axis_center[3] = 0; joy_set_cal_vals(joy_axis_min, joy_axis_center, joy_axis_max); digi_driver_board = 0; digi_driver_port = 0; digi_driver_irq = 0; digi_driver_dma = 0; digi_midi_type = 0; digi_midi_port = 0; Config_digi_volume = 4; Config_midi_volume = 4; Config_control_type = 0; Config_channels_reversed = 0; infile = fopen("descent.cfg", "rt"); if (infile == NULL) { return 1; } while (!feof(infile)) { memset(line, 0, 80); fgets(line, 80, infile); ptr = &(line[0]); while (isspace(*ptr)) ptr++; if (*ptr != '\0') { token = strtok(ptr, "="); value = strtok(NULL, "="); if (!strcmp(token, digi_dev_str)) digi_driver_board = strtol(value, NULL, 16); else if (!strcmp(token, digi_port_str)) digi_driver_port = strtol(value, NULL, 16); else if (!strcmp(token, digi_irq_str)) digi_driver_irq = strtol(value, NULL, 10); else if (!strcmp(token, digi_dma_str)) digi_driver_dma = strtol(value, NULL, 10); else if (!strcmp(token, digi_volume_str)) Config_digi_volume = strtol(value, NULL, 10); else if (!strcmp(token, midi_dev_str)) digi_midi_type = strtol(value, NULL, 16); else if (!strcmp(token, midi_port_str)) digi_midi_port = strtol(value, NULL, 16); else if (!strcmp(token, midi_volume_str)) Config_midi_volume = strtol(value, NULL, 10); else if (!strcmp(token, stereo_rev_str)) Config_channels_reversed = strtol(value, NULL, 10); else if (!strcmp(token, gamma_level_str)) { gamma = strtol(value, NULL, 10); gr_palette_set_gamma( gamma ); } else if (!strcmp(token, detail_level_str)) { Detail_level = strtol(value, NULL, 10); if (Detail_level == NUM_DETAIL_LEVELS-1) { int count,dummy,oc,od,wd,wrd,da,sc; count = sscanf (value, "%d,%d,%d,%d,%d,%d,%d\n",&dummy,&oc,&od,&wd,&wrd,&da,&sc); if (count == 7) { Object_complexity = oc; Object_detail = od; Wall_detail = wd; Wall_render_depth = wrd; Debris_amount = da; SoundChannels = sc; set_custom_detail_vars(); } } } else if (!strcmp(token, joystick_min_str)) { sscanf( value, "%d,%d,%d,%d", &joy_axis_min[0], &joy_axis_min[1], &joy_axis_min[2], &joy_axis_min[3] ); } else if (!strcmp(token, joystick_max_str)) { sscanf( value, "%d,%d,%d,%d", &joy_axis_max[0], &joy_axis_max[1], &joy_axis_max[2], &joy_axis_max[3] ); } else if (!strcmp(token, joystick_cen_str)) { sscanf( value, "%d,%d,%d,%d", &joy_axis_center[0], &joy_axis_center[1], &joy_axis_center[2], &joy_axis_center[3] ); } else if (!strcmp(token, last_player_str)) { char * p; strncpy( config_last_player, value, CALLSIGN_LEN ); p = strchr( config_last_player, '\n'); if ( p ) *p = 0; } else if (!strcmp(token, last_mission_str)) { char * p; strncpy( config_last_mission, value, MISSION_NAME_LEN ); p = strchr( config_last_mission, '\n'); if ( p ) *p = 0; } else if (!strcmp(token, config_vr_type_str)) { Config_vr_type = strtol(value, NULL, 10); } else if (!strcmp(token, config_vr_tracking_str)) { Config_vr_tracking = strtol(value, NULL, 10); } } } fclose(infile); i = FindArg( "-volume" ); if ( i > 0 ) { i = atoi( Args[i+1] ); if ( i < 0 ) i = 0; if ( i > 100 ) i = 100; Config_digi_volume = (i*8)/100; Config_midi_volume = (i*8)/100; } if ( Config_digi_volume > 8 ) Config_digi_volume = 8; if ( Config_midi_volume > 8 ) Config_midi_volume = 8; joy_set_cal_vals(joy_axis_min, joy_axis_center, joy_axis_max); digi_set_volume( (Config_digi_volume*32768)/8, (Config_midi_volume*128)/8 ); /* printf( "DigiDeviceID: 0x%x\n", digi_driver_board ); printf( "DigiPort: 0x%x\n", digi_driver_port ); printf( "DigiIrq: 0x%x\n", digi_driver_irq ); printf( "DigiDma: 0x%x\n", digi_driver_dma ); printf( "MidiDeviceID: 0x%x\n", digi_midi_type ); printf( "MidiPort: 0x%x\n", digi_midi_port ); key_getch(); */ Config_midi_type = digi_midi_type; Config_digi_type = digi_driver_board; // HACK!!! //Hack to make the Crytal Lake look like Microsoft Sound System if ( digi_driver_board == 0xe200 ) { ubyte tmp; tmp = CrystalLakeReadMCP( CL_MC1 ); if ( !(tmp & 0x80) ) atexit( CrystalLakeSetSB ); // Restore to SB when done. CrystalLakeSetWSS(); digi_driver_board = 0;//_MICROSOFT_8_ST;<was this microsoft thing, but its irrelevant, because we have no sound here yet,being that its also undefined, I set it to 0 -KRB } return 0; }
int gr_init(void) { int org_gamma; int retcode; int mode = SM(320,200); // Only do this function once! if (gr_installed==1) return 3; #ifdef __DJGPP__ if (!__djgpp_nearptr_enable()) { printf("nearptr enable=%x\n", __dpmi_error); return 10; } #ifndef SAVEGR gr_video_memory = (unsigned char *)(__djgpp_conventional_base + 0xa0000); #else gr_video_memory=(unsigned char *)-1; #endif pVideoMode = (volatile ubyte *)(__djgpp_conventional_base+0x449); pNumColumns = (volatile ushort *)(__djgpp_conventional_base+0x44a); pNumRows = (volatile ubyte *)(__djgpp_conventional_base+0x484); pCharHeight = (volatile ushort *)(__djgpp_conventional_base+0x485); pCursorPos = (volatile ushort *)(__djgpp_conventional_base+0x450); pCursorType = (volatile ushort *)(__djgpp_conventional_base+0x460); pTextMemory = (volatile ushort *)(__djgpp_conventional_base+0xb8000); #endif #ifndef __DJGPP__ if (gr_init_A0000()) return 10; #endif // Save the current text screen mode if (gr_save_mode()==1) return 2; #ifndef NOGRAPH // Save the current palette, and fade it out to black. gr_palette_read( gr_pal_default ); gr_palette_faded_out = 0; org_gamma = gr_palette_get_gamma(); gr_palette_set_gamma( 0 ); gr_palette_fade_out( gr_pal_default, 32, 0 ); gr_palette_clear(); gr_palette_set_gamma( org_gamma ); gr_sync_display(); gr_sync_display(); #endif #ifdef __DJGPP__ #ifdef SAVEGR __djgpp_nearptr_disable(); #endif #endif MALLOC( grd_curscreen,grs_screen,1 ); memset( grd_curscreen, 0, sizeof(grs_screen)); // Set the mode. if ((retcode=gr_set_mode(mode))) { gr_restore_mode(); return retcode; } //JOHNgr_disable_default_palette_loading(); // Set all the screen, canvas, and bitmap variables that // aren't set by the gr_set_mode call: grd_curscreen->sc_canvas.cv_color = 0; grd_curscreen->sc_canvas.cv_drawmode = 0; grd_curscreen->sc_canvas.cv_font = NULL; grd_curscreen->sc_canvas.cv_font_fg_color = 0; grd_curscreen->sc_canvas.cv_font_bg_color = 0; gr_set_current_canvas( &grd_curscreen->sc_canvas ); #if 0 if (!dpmi_allocate_selector( &gr_fade_table, 256*GR_FADE_LEVELS, &gr_fade_table_selector )) Error( "Error allocating fade table selector!" ); if (!dpmi_allocate_selector( &gr_palette, 256*3, &gr_palette_selector )) Error( "Error allocating palette selector!" ); #endif // if (!dpmi_allocate_selector( &gr_inverse_table, 32*32*32, &gr_inverse_table_selector )) // Error( "Error allocating inverse table selector!" ); // Set flags indicating that this is installed. gr_installed = 1; #ifdef __GNUC__ atexit((void (*)) gr_close); #else atexit(gr_close); #endif return 0; }