void C_PrintCompileDate(void) { int day, month, year, hour, minute; static const char *days[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; static const char mths[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; static const char *months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; static char mth[4]; sscanf(__DATE__, "%3s %2d %4d", mth, &day, &year); sscanf(__TIME__, "%2d:%2d:%*d", &hour, &minute); month = (strstr(mths, mth) - mths) / 3; C_Printf(""); C_Printf(" This %i-bit %s binary of %s was built on %s, %s %i, %i at %i:%02i%s\n", (sizeof(intptr_t) == 4 ? 32 : 64), "Linux", PACKAGE_NAMEANDVERSIONSTRING, days[dayofweek(day, month + 1, year)], months[month], day, year, (hour > 12 ? hour - 12 : hour), minute, (hour < 12 ? "am" : "pm")); }
static int InitDriver(opl_driver_t *_driver, unsigned int port_base) { // Initialize the driver. if (!_driver->init_func(port_base)) { return 0; } // The driver was initialized okay, so we now have somewhere // to write to. It doesn't mean there's an OPL chip there, // though. Perform the detection sequence to make sure. // (it's done twice, like how Doom does it). driver = _driver; init_stage_reg_writes = 1; if (!OPL_Detect() || !OPL_Detect()) { C_Printf(" OPL_Init: No OPL detected using '%s' driver.\n", _driver->name); _driver->shutdown_func(); driver = NULL; return 0; } // Initialize all registers. OPL_InitRegisters(); init_stage_reg_writes = 0; //C_Printf(" OPL_Init: Using driver '%s'.\n", driver->name); return 1; }
// // HU_CenterMessage // // haleyjd 04/27/04: rewritten to use qstring // void HU_CenterMessage(const char *s) { static qstring qstr(128); int st_height = GameModeInfo->StatusBar->height; qstr.clear(); // haleyjd 02/28/06: colored center message if(centermsg_color) { qstr += centermsg_color; centermsg_color = NULL; } qstr += s; centermessage_widget.setMessage(qstr.constPtr(), (SCREENWIDTH - V_FontStringWidth(hud_font, s)) / 2, (SCREENHEIGHT - V_FontStringHeight(hud_font, s) - ((scaledwindow.height == SCREENHEIGHT) ? 0 : st_height - 8)) / 2, leveltime + (message_timer * 35) / 1000); // print message to console also C_Printf("%s\n", s); }
void G_LoadDefaults(void) { char *temp = NULL; size_t len; DWFILE dwfile, *file = &dwfile; len = M_StringAlloca(&temp, 1, 18, usergamepath); // haleyjd 11/23/06: use basegamepath // haleyjd 08/29/09: allow use_doom_config override if(GameModeInfo->type == Game_DOOM && use_doom_config) psnprintf(temp, len, "%s/doom/keys.csc", userpath); else psnprintf(temp, len, "%s/keys.csc", usergamepath); cfg_file = estrdup(temp); if(access(cfg_file, R_OK)) { C_Printf("keys.csc not found, using defaults\n"); D_OpenLump(file, W_GetNumForName("KEYDEFS")); } else D_OpenFile(file, cfg_file, "r"); if(!D_IsOpen(file)) I_Error("G_LoadDefaults: couldn't open default key bindings\n"); // haleyjd 03/08/06: test for zero length if(!D_IsLump(file) && D_FileLength(file) == 0) { // try the lump because the file is zero-length... C_Printf("keys.csc is zero length, trying KEYDEFS\n"); D_Fclose(file); D_OpenLump(file, W_GetNumForName("KEYDEFS")); if(!D_IsOpen(file) || D_FileLength(file) == 0) I_Error("G_LoadDefaults: KEYDEFS lump is empty\n"); } C_RunScript(file); D_Fclose(file); }
void C_PrintSDLVersions(void) { C_Printf(" Using version %i.%i.%i of %s\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL, #if defined(SDL20) "SDL2.DLL" #else "libSDL.a" #endif ); C_Printf(" Using version %i.%i.%i of %s\n", SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL, #if defined(SDL20) "SDL2_MIXER.DLL" #else "libSDL_mixer.a" #endif ); }
CONSOLE_COMMAND(ev_mapspecials, cf_level) { for(int i = 0; i < numlines; i++) { auto action = EV_ActionForSpecial(lines[i].special); if(action) { C_Printf("%5d: %3d %3d %s%s\n", i, lines[i].special, lines[i].tag, action->name, action->minversion > 0 ? "*" : ""); } } }
// // G_BindKeyToAction // static void G_BindKeyToAction(const char *key_name, const char *action_name) { int key; keyaction_t *action; // get key if((key = G_KeyForName(key_name)) < 0) { C_Printf("unknown key '%s'\n", key_name); return; } // get action if(!(action = G_KeyActionForName(action_name))) { C_Printf("unknown action '%s'\n", action_name); return; } // haleyjd 07/03/04: support multiple binding classes keybindings[key].bindings[action->bclass] = action; }
int OPL_Init(unsigned int port_base) { char *driver_name; int i; driver_name = getenv("OPL_DRIVER"); if (driver_name != NULL) { // Search the list until we find the driver with this name. for (i=0; drivers[i] != NULL; ++i) { if (!strcmp(driver_name, drivers[i]->name)) { if (InitDriver(drivers[i], port_base)) { return 1; } else { C_Printf("OPL_Init: Failed to initialize " "driver: '%s'.\n", driver_name); return 0; } } } C_Printf("OPL_Init: unknown driver: '%s'.\n", driver_name); return 0; } else { return AutoSelectDriver(port_base); } }
// // Implements Plane_Copy(frontfloortag, frontceiltag, backfloortag, backceiltag, shareslope) // shareslope copies w/ flags: // 1: Front floor copied to back, 2: Back floor copied to front // 4: Front ceil copied to back, 8: Back ceil copied to front // // * ExtraData: 493 // * Hexen: 118 // static void P_copySectorSlopeParam(line_t *line) { // If there's no backsector, only consider args[0] and args[1] for(int i = 0; i <= (line->backsector ? 3 : 1); i++) { if(line->args[i]) { // If i is 2 or 3, backsector is dest, else frontsec is. If i is odd then copy to ceil P_copyPlane(line->args[i], i & 2 ? line->backsector : line->frontsector, i & 1); } } if(line->backsector) { if((line->args[4] & 3) == 1) line->backsector->f_slope = P_CopySlope(line->frontsector->f_slope); else if((line->args[4] & 3) == 2) line->frontsector->f_slope = P_CopySlope(line->backsector->f_slope); else if((line->args[4] & 3) == 3) { C_Printf(FC_ERROR "P_CopySectorSlopeParam: Plane_Copy[4] flags 1 and 2 are mutually" " exclusive.\n"); } if((line->args[4] & 12) == 4) line->backsector->c_slope = P_CopySlope(line->frontsector->c_slope); else if((line->args[4] & 12) == 8) line->frontsector->c_slope = P_CopySlope(line->backsector->c_slope); else if((line->args[4] & 12) == 12) { C_Printf(FC_ERROR "P_CopySectorSlopeParam: Plane_Copy[4] flags 4 and 8 are mutually" " exclusive.\n"); } } line->special = 0; }
// // ev_mapsectorspecs // // List out all the sector specials in use on the current map // CONSOLE_COMMAND(ev_mapsectorspecs, cf_level) { for(int i = 0; i < numsectors; i++) { sector_t *sec = §ors[i]; if(!sec->special) continue; bool isgen = EV_IsGenSectorSpecial(sec->special); auto bind = EV_BindingForSectorSpecial(sec->special); C_Printf("%5d: %5d %3d (%s type)\n", i, sec->special, sec->tag, (isgen || bind) ? "known" : "unknown"); } }
static int AutoSelectDriver(unsigned int port_base) { int i; for (i=0; drivers[i] != NULL; ++i) { if (InitDriver(drivers[i], port_base)) { return 1; } } C_Printf("OPL_Init: Failed to find a working driver.\n"); return 0; }
// // G_BindResponder // // Responder for widget // bool G_BindResponder(event_t *ev) { keyaction_t *action; if(ev->type != ev_keydown) return false; // do not index out of bounds if(ev->data1 >= NUM_KEYS) return false; // got a key - close box MN_PopWidget(); if(action_menu_toggle) // cancel { action_menu_toggle = false; return true; } if(!(action = G_KeyActionForName(binding_action))) { C_Printf(FC_ERROR "unknown action '%s'\n", binding_action); return true; } // bind new key to action, if it is not already bound -- if it is, // remove it if(keybindings[ev->data1].bindings[action->bclass] != action) keybindings[ev->data1].bindings[action->bclass] = action; else keybindings[ev->data1].bindings[action->bclass] = NULL; // haleyjd 10/16/05: clear state of action involved keybindings[ev->data1].keydown[action->bclass] = false; if(action->type == at_variable) *(action->value.variable) = 0; return true; }
// // G_BindResponder // // Responder for widget // static bool G_BindResponder(event_t *ev, int mnaction) { keyaction_t *action; if(ev->type != ev_keydown) return false; // do not index out of bounds if(ev->data1 >= NUMKEYS) return false; // got a key - close box MN_PopWidget(); if(mnaction == ka_menu_toggle) // cancel return true; if(!(action = G_KeyActionForName(binding_action))) { C_Printf(FC_ERROR "unknown action '%s'\n", binding_action); return true; } // bind new key to action, if it is not already bound -- if it is, // remove it if(keybindings[ev->data1].bindings[action->bclass] != action) keybindings[ev->data1].bindings[action->bclass] = action; else keybindings[ev->data1].bindings[action->bclass] = NULL; // haleyjd 10/16/05: clear state of action involved bool wasdown = keybindings[ev->data1].keydown[action->bclass]; keybindings[ev->data1].keydown[action->bclass] = false; if(wasdown) --gGameKeyCount[action->bclass][action->num]; return true; }
void G_SaveDefaults(void) { FILE *file; int i, j; if(!cfg_file) // check defaults have been loaded return; if(!(file = fopen(cfg_file, "w"))) { C_Printf(FC_ERROR"Couldn't open keys.csc for write access.\n"); return; } // write key bindings for(i = 0; i < NUM_KEYS; ++i) { // haleyjd 07/03/04: support multiple binding classes for(j = 0; j < NUMKEYACTIONCLASSES; ++j) { if(keybindings[i].bindings[j]) { const char *keyname = keybindings[i].name; // haleyjd 07/10/09: semicolon requires special treatment. if(keyname[0] == ';') keyname = "\";\""; fprintf(file, "bind %s \"%s\"\n", keyname, keybindings[i].bindings[j]->name); } } } fclose(file); }
// // P_SpawnSlope_Line // // Creates one or more slopes based on the given line type and front/back // sectors. // void P_SpawnSlope_Line(int linenum, int staticFn) { line_t *line = lines + linenum; v3float_t origin, point; v2float_t direction; float dz, extent; bool frontfloor = false, backfloor = false, frontceil = false, backceil = false; P_getSlopeProps(staticFn, frontfloor, backfloor, frontceil, backceil, line->args); // SoM: We don't need the line to retain its special type line->special = 0; if(!(frontfloor || backfloor || frontceil || backceil) && staticFn != EV_STATIC_SLOPE_PARAM) // don't scream on trivial Plane_Align { C_Printf(FC_ERROR "P_SpawnSlope_Line: called with non-slope line special."); return; } if(!line->backsector) { C_Printf(FC_ERROR "P_SpawnSlope_Line: used on one-sided line."); return; } origin.x = (line->v2->fx + line->v1->fx) * 0.5f; origin.y = (line->v2->fy + line->v1->fy) * 0.5f; if(frontfloor || frontceil) { // Do the front sector direction.x = line->nx; direction.y = line->ny; extent = P_GetExtent(line->frontsector, line, &origin, &direction); if(extent < 0.0f) { C_Printf(FC_ERROR "P_SpawnSlope_Line: no frontsector extent for line %d\n", linenum); return; } // reposition the origin according to the extent point.x = origin.x + direction.x * extent; point.y = origin.y + direction.y * extent; direction.x = -direction.x; direction.y = -direction.y; if(frontfloor) { point.z = line->frontsector->floorheightf; dz = (line->backsector->floorheightf - point.z) / extent; line->frontsector->f_slope = P_MakeSlope(&point, &direction, dz, false); } if(frontceil) { point.z = line->frontsector->ceilingheightf; dz = (line->backsector->ceilingheightf - point.z) / extent; line->frontsector->c_slope = P_MakeSlope(&point, &direction, dz, true); } } if(backfloor || backceil) { // Backsector direction.x = -line->nx; direction.y = -line->ny; extent = P_GetExtent(line->backsector, line, &origin, &direction); if(extent < 0.0f) { C_Printf(FC_ERROR "P_SpawnSlope_Line: no backsector extent for line %d\n", linenum); return; } // reposition the origin according to the extent point.x = origin.x + direction.x * extent; point.y = origin.y + direction.y * extent; direction.x = -direction.x; direction.y = -direction.y; if(backfloor) { point.z = line->backsector->floorheightf; dz = (line->frontsector->floorheightf - point.z) / extent; line->backsector->f_slope = P_MakeSlope(&point, &direction, dz, false); } if(backceil) { point.z = line->backsector->ceilingheightf; dz = (line->frontsector->ceilingheightf - point.z) / extent; line->backsector->c_slope = P_MakeSlope(&point, &direction, dz, true); } } /* // haleyjd: what's this?? inconsequential. if(!line->tag) return; */ }
static void R_RenderLinkedPortal(pwindow_t *window) { fixed_t lastx, lasty, lastz; float lastxf, lastyf, lastzf; portal_t *portal = window->portal; // ioanch 20160123: keep track of window portalrender.curwindow = window; if(portal->type != R_LINKED || window->maxx < window->minx) return; // haleyjd: temporary debug if(portal->tainted > 6) { if(showtainted) R_ShowTainted(window); portal->tainted++; C_Printf(FC_ERROR "Refused to draw portal (line=%i) (t=%d)", portal->data.link.maker, portal->tainted); return; } #ifdef RANGECHECK for(int i = 0; i < video.width; i++) { if(window->bottom[i] > window->top[i] && (window->bottom[i] < -1 || window->bottom[i] > viewwindow.height || window->top[i] < -1 || window->top[i] > viewwindow.height)) { I_Error("R_RenderAnchoredPortal: clipping array contained invalid " "information:\n" " x:%i, ytop:%f, ybottom:%f\n", i, window->top[i], window->bottom[i]); } } #endif if(!R_SetupPortalClipsegs(window->minx, window->maxx, window->top, window->bottom)) return; R_ClearSlopeMark(window->minx, window->maxx, window->type); // haleyjd: temporary debug portal->tainted++; floorclip = window->bottom; ceilingclip = window->top; R_ClearOverlayClips(); portalrender.minx = window->minx; portalrender.maxx = window->maxx; ++validcount; R_SetMaskedSilhouette(ceilingclip, floorclip); lastx = viewx; lasty = viewy; lastz = viewz; lastxf = view.x; lastyf = view.y; lastzf = view.z; // SoM 3/10/2005: Use the coordinates stored in the portal struct viewx = window->vx + portal->data.link.deltax; viewy = window->vy + portal->data.link.deltay; viewz = window->vz + portal->data.link.deltaz; view.x = M_FixedToFloat(viewx); view.y = M_FixedToFloat(viewy); view.z = M_FixedToFloat(viewz); R_IncrementFrameid(); R_RenderBSPNode(numnodes - 1); // Only push the overlay if this is the head window R_PushPost(true, window->head == window ? window->portal->poverlay : NULL); floorclip = floorcliparray; ceilingclip = ceilingcliparray; viewx = lastx; viewy = lasty; viewz = lastz; view.x = lastxf; view.y = lastyf; view.z = lastzf; if(window->child) R_RenderLinkedPortal(window->child); }
void R_ProjectSprite (mobj_t* thing) { fixed_t gzt; // killough 3/27/98 fixed_t tx; fixed_t xscale; int x1; int x2; spritedef_t *sprdef; spriteframe_t *sprframe; int lump; boolean flip; vissprite_t *vis; fixed_t iscale; int heightsec; // killough 3/27/98 // transform the origin point fixed_t tr_x = thing->x - viewx; fixed_t tr_y = thing->y - viewy; fixed_t gxt = FixedMul(tr_x,viewcos); fixed_t gyt = -FixedMul(tr_y,viewsin); fixed_t tz = gxt-gyt; // thing is behind view plane? if (tz < MINZ) return; // sf: dont draw the object we are viewing through // client movement prediction - we can be viewing from player position // but outside the body as well if(thing == viewobj) return; xscale = FixedDiv(projection, tz); gxt = -FixedMul(tr_x,viewsin); gyt = FixedMul(tr_y,viewcos); tx = -(gyt+gxt); // too far off the side? if (abs(tx)>(tz<<2)) return; // decide which patch to use for sprite relative to player if ((unsigned) thing->sprite >= numsprites) { C_Printf ("R_ProjectSprite: invalid sprite number %i\n", thing->sprite); C_SetConsole(); return; } sprdef = &sprites[thing->sprite]; if ((thing->frame&FF_FRAMEMASK) >= sprdef->numframes) I_Error ("R_ProjectSprite:invalid frame %i for sprite %s", thing->frame & FF_FRAMEMASK, spritelist[thing->sprite]); sprframe = &sprdef->spriteframes[thing->frame & FF_FRAMEMASK]; if (sprframe->rotate) { // choose a different rotation based on player view angle_t ang = R_PointToAngle(thing->x, thing->y); unsigned rot = (ang-thing->angle+(unsigned)(ANG45/2)*9)>>29; lump = sprframe->lump[rot]; flip = (boolean) sprframe->flip[rot]; }