- make DumpCPUInfo return a string instead of letting it print the info itself. Also consolidated I_Init, because both existing versions were identical.

This commit is contained in:
Christoph Oelckers 2020-04-11 13:05:12 +02:00
parent 76352dd9b3
commit d523da1313
8 changed files with 28 additions and 54 deletions

View file

@ -614,7 +614,6 @@ file( GLOB HEADER_FILES
common/thirdparty/*.h common/thirdparty/*.h
common/thirdparty/rapidjson/*.h common/thirdparty/rapidjson/*.h
common/thirdparty/math./*h common/thirdparty/math./*h
utility/sfmt/*.h
utility/*.h utility/*.h
scripting/*.h scripting/*.h
scripting/backend/*.h scripting/backend/*.h

View file

@ -32,8 +32,8 @@
** **
*/ */
#include "doomtype.h" #include <stdlib.h>
#include "doomdef.h" #include <string.h>
#include "x86.h" #include "x86.h"
CPUInfo CPU; CPUInfo CPU;
@ -200,7 +200,7 @@ haveid:
#endif #endif
} }
void DumpCPUInfo(const CPUInfo *cpu) FString DumpCPUInfo(const CPUInfo *cpu)
{ {
char cpustring[4*4*3+1]; char cpustring[4*4*3+1];
@ -227,34 +227,36 @@ void DumpCPUInfo(const CPUInfo *cpu)
} }
*t = '\0'; *t = '\0';
if (cpu->VendorID[0] && !batchrun) FString out;
if (cpu->VendorID[0])
{ {
Printf("CPU Vendor ID: %s\n", cpu->VendorID); out.Format("CPU Vendor ID: %s\n", cpu->VendorID);
if (cpustring[0]) if (cpustring[0])
{ {
Printf(" Name: %s\n", cpustring); out.AppendFormat(" Name: %s\n", cpustring);
} }
if (cpu->bIsAMD) if (cpu->bIsAMD)
{ {
Printf(" Family %d (%d), Model %d, Stepping %d\n", out.AppendFormat(" Family %d (%d), Model %d, Stepping %d\n",
cpu->Family, cpu->AMDFamily, cpu->AMDModel, cpu->AMDStepping); cpu->Family, cpu->AMDFamily, cpu->AMDModel, cpu->AMDStepping);
} }
else else
{ {
Printf(" Family %d, Model %d, Stepping %d\n", out.AppendFormat(" Family %d, Model %d, Stepping %d\n",
cpu->Family, cpu->Model, cpu->Stepping); cpu->Family, cpu->Model, cpu->Stepping);
} }
Printf(" Features:"); out.AppendFormat(" Features:");
if (cpu->bSSE2) Printf(" SSE2"); if (cpu->bSSE2) out += (" SSE2");
if (cpu->bSSE3) Printf(" SSE3"); if (cpu->bSSE3) out += (" SSE3");
if (cpu->bSSSE3) Printf(" SSSE3"); if (cpu->bSSSE3) out += (" SSSE3");
if (cpu->bSSE41) Printf(" SSE4.1"); if (cpu->bSSE41) out += (" SSE4.1");
if (cpu->bSSE42) Printf(" SSE4.2"); if (cpu->bSSE42) out += (" SSE4.2");
if (cpu->b3DNow) Printf(" 3DNow!"); if (cpu->b3DNow) out += (" 3DNow!");
if (cpu->b3DNowPlus) Printf(" 3DNow!+"); if (cpu->b3DNowPlus) out += (" 3DNow!+");
if (cpu->HyperThreading) Printf(" HyperThreading"); if (cpu->HyperThreading) out += (" HyperThreading");
Printf ("\n"); out += ("\n");
} }
return out;
} }
#endif #endif

View file

@ -2,6 +2,7 @@
#define X86_H #define X86_H
#include "basics.h" #include "basics.h"
#include "zstring.h"
struct CPUInfo // 92 bytes struct CPUInfo // 92 bytes
{ {
@ -105,7 +106,7 @@ extern CPUInfo CPU;
struct PalEntry; struct PalEntry;
void CheckCPUID (CPUInfo *cpu); void CheckCPUID (CPUInfo *cpu);
void DumpCPUInfo (const CPUInfo *cpu); FString DumpCPUInfo (const CPUInfo *cpu);
#endif #endif

View file

@ -2542,7 +2542,10 @@ static int D_DoomMain_Internal (void)
if (!restart) if (!restart)
{ {
if (!batchrun) Printf ("I_Init: Setting up machine state.\n"); if (!batchrun) Printf ("I_Init: Setting up machine state.\n");
I_Init (); CheckCPUID(&CPU);
CalculateCPUSpeed();
auto ci = DumpCPUInfo(&CPU);
Printf("%s", ci.GetChars());
} }
// [RH] Initialize palette management // [RH] Initialize palette management

View file

@ -45,9 +45,7 @@ struct WadStuff;
#define SHARE_DIR "/usr/local/share/" #define SHARE_DIR "/usr/local/share/"
#endif #endif
void CalculateCPUSpeed(void);
// Called by DoomMain.
void I_Init (void);
// Return a seed value for the RNG. // Return a seed value for the RNG.
unsigned int I_MakeRNGSeed(); unsigned int I_MakeRNGSeed();

View file

@ -43,19 +43,6 @@ ticcmd_t *I_BaseTiccmd()
return &emptycmd; return &emptycmd;
} }
//
// I_Init
//
void I_Init()
{
extern void CalculateCPUSpeed();
CheckCPUID(&CPU);
CalculateCPUSpeed();
DumpCPUInfo(&CPU);
}
bool I_WriteIniFailed() bool I_WriteIniFailed()
{ {
printf("The config file %s could not be saved:\n%s\n", GameConfig->GetPathName(), strerror(errno)); printf("The config file %s could not be saved:\n%s\n", GameConfig->GetPathName(), strerror(errno));

View file

@ -107,8 +107,6 @@ void DestroyCustomCursor();
// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- // PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
static void CalculateCPUSpeed();
static HCURSOR CreateCompatibleCursor(FBitmap &cursorpic, int leftofs, int topofs); static HCURSOR CreateCompatibleCursor(FBitmap &cursorpic, int leftofs, int topofs);
static HCURSOR CreateAlphaCursor(FBitmap &cursorpic, int leftofs, int topofs); static HCURSOR CreateAlphaCursor(FBitmap &cursorpic, int leftofs, int topofs);
static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP color_mask); static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP color_mask);
@ -309,20 +307,6 @@ void CalculateCPUSpeed()
if (!batchrun) Printf ("CPU speed: %.0f MHz\n", 0.001 / PerfToMillisec); if (!batchrun) Printf ("CPU speed: %.0f MHz\n", 0.001 / PerfToMillisec);
} }
//==========================================================================
//
// I_Init
//
//==========================================================================
void I_Init()
{
CheckCPUID(&CPU);
CalculateCPUSpeed();
DumpCPUInfo(&CPU);
}
//========================================================================== //==========================================================================
// //
// I_PrintStr // I_PrintStr

View file

@ -38,7 +38,7 @@ struct WadStuff;
void I_DetectOS (void); void I_DetectOS (void);
// Called by DoomMain. // Called by DoomMain.
void I_Init (void); void CalculateCPUSpeed (void);
// Return a seed value for the RNG. // Return a seed value for the RNG.
unsigned int I_MakeRNGSeed(); unsigned int I_MakeRNGSeed();