add a realtime scheduler class and priority-inheritance mutexes with timeouts and abandonment, add an HDA audio driver and a SYS_AUDIO_* syscall family, flesh out kernel32 with Win32 threads, events, mutexes, critical sections, and condition variables, add SYS_RESUME_THREAD for suspended thread creation, add KeInitializeMemoryTypes to reprogram MTRRs and install a canonical PAT for WB/WC/UC control, rework the display pipeline with a pitched present path and console output flush, bring back disk.vhd with mtools since vvfat fucking sucks, harden AHCI with serialized cache flush, USB mass storage with SCSI sense-data decoding, and xHCI with cleaner DMA teardown, fix the last stray for(;;) in HalStopProcessor to while(true), pile on smoke tests for audio, win32 sync primitives, and thread suspend, implement AHCI timeout, kill readahead since it was desperetaly trying to murder me, fix doom sound x2.
This commit is contained in:
1 parent
8b254f84f4
commit
4add6789ba
177 files changed
+22565
-3070
No files matched your search
+159
-115
@@ -7549,15 +7549,25 @@ void doom_init(int argc, const char** argv, int flags)
|
||||
if (!doom_exit) doom_exit = doom_exit_impl;
|
||||
if (!doom_getenv) doom_getenv = doom_getenv_impl;
|
||||
|
||||
doom_print("doom_init: allocating screen buffer\n");
|
||||
screen_buffer = (unsigned char*)doom_malloc(SCREENWIDTH * SCREENHEIGHT);
|
||||
doom_print("doom_init: screen buffer ready\n");
|
||||
|
||||
doom_print("doom_init: allocating final screen buffer\n");
|
||||
final_screen_buffer = (unsigned char*)doom_malloc(SCREENWIDTH * SCREENHEIGHT * 4);
|
||||
doom_print("doom_init: final screen buffer ready\n");
|
||||
|
||||
doom_print("doom_init: reading initial time\n");
|
||||
last_update_time = I_GetTime();
|
||||
doom_print("doom_init: initial time ready\n");
|
||||
|
||||
myargc = argc;
|
||||
myargv = (char**)argv; // unsafe my ass
|
||||
doom_flags = flags;
|
||||
|
||||
doom_print("doom_init: entering D_DoomMain\n");
|
||||
D_DoomMain();
|
||||
doom_print("doom_init: D_DoomMain returned\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -9790,7 +9800,27 @@ void FindResponseFile(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
doom_print("FindResponseFile: entered\n");
|
||||
if (myargc <= 0)
|
||||
{
|
||||
doom_print("FindResponseFile: argc <= 0\n");
|
||||
return;
|
||||
}
|
||||
if (myargc == 1)
|
||||
{
|
||||
doom_print("FindResponseFile: argc == 1, returning\n");
|
||||
return;
|
||||
}
|
||||
doom_print("FindResponseFile: argc > 1\n");
|
||||
|
||||
for (i = 1; i < myargc; i++)
|
||||
{
|
||||
doom_print("FindResponseFile: checking argument\n");
|
||||
if (!myargv || !myargv[i])
|
||||
{
|
||||
doom_print("FindResponseFile: invalid argv entry\n");
|
||||
return;
|
||||
}
|
||||
if (myargv[i][0] == '@')
|
||||
{
|
||||
void* handle = 0;
|
||||
@@ -9860,6 +9890,9 @@ void FindResponseFile(void)
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
doom_print("FindResponseFile: scan complete\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -9871,9 +9904,13 @@ void D_DoomMain(void)
|
||||
int p;
|
||||
char file[256];
|
||||
|
||||
doom_print("D_DoomMain: FindResponseFile\n");
|
||||
FindResponseFile();
|
||||
doom_print("D_DoomMain: FindResponseFile done\n");
|
||||
|
||||
doom_print("D_DoomMain: IdentifyVersion\n");
|
||||
IdentifyVersion();
|
||||
doom_print("D_DoomMain: IdentifyVersion done\n");
|
||||
|
||||
modifiedgame = doom_false;
|
||||
|
||||
@@ -23741,19 +23778,67 @@ void M_SaveDefaults(void)
|
||||
//
|
||||
// M_LoadDefaults
|
||||
//
|
||||
// Reads one complete defaults line without allowing malformed files to escape the caller's buffer.
|
||||
static int M_ReadDefaultsLine(void* handle, char* line, int capacity)
|
||||
{
|
||||
int length = 0;
|
||||
doom_boolean overflow = doom_false;
|
||||
|
||||
if (!handle || !line || capacity < 2)
|
||||
return 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
char c = 0;
|
||||
int read = doom_read(handle, &c, 1);
|
||||
if (read != 1)
|
||||
{
|
||||
if (!length && !overflow)
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (c == '\n')
|
||||
break;
|
||||
if (c == '\r')
|
||||
continue;
|
||||
|
||||
if (length + 1 < capacity)
|
||||
line[length++] = c;
|
||||
else
|
||||
overflow = doom_true;
|
||||
}
|
||||
|
||||
line[length] = 0;
|
||||
return overflow ? -1 : 1;
|
||||
}
|
||||
|
||||
|
||||
// Returns the first non-whitespace byte in a mutable defaults token.
|
||||
static char* M_SkipDefaultWhitespace(char* text)
|
||||
{
|
||||
while (*text == ' ' || *text == '\t')
|
||||
text++;
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
// Removes horizontal whitespace from the end of a mutable defaults token.
|
||||
static void M_TrimDefaultWhitespace(char* text)
|
||||
{
|
||||
int length = (int)doom_strlen(text);
|
||||
while (length > 0 && (text[length - 1] == ' ' || text[length - 1] == '\t'))
|
||||
text[--length] = 0;
|
||||
}
|
||||
|
||||
|
||||
// Loads bounded name/value records from the optional defaults file.
|
||||
void M_LoadDefaults(void)
|
||||
{
|
||||
char line[384];
|
||||
int i;
|
||||
int len;
|
||||
void* f;
|
||||
char def[80];
|
||||
char strparm[100];
|
||||
char* newstring;
|
||||
int parm;
|
||||
doom_boolean isstring;
|
||||
|
||||
// set everything to base values
|
||||
// numdefaults = sizeof(defaults)/sizeof(defaults[0]);
|
||||
// Set everything to base values.
|
||||
for (i = 0; i < numdefaults; i++)
|
||||
{
|
||||
if (defaults[i].defaultvalue == 0xFFFF)
|
||||
@@ -23762,104 +23847,80 @@ void M_LoadDefaults(void)
|
||||
*defaults[i].location = (int)defaults[i].defaultvalue;
|
||||
}
|
||||
|
||||
// check for a custom default file
|
||||
// Check for a custom default file.
|
||||
i = M_CheckParm((char*)"-config");
|
||||
if (i && i < myargc - 1)
|
||||
{
|
||||
defaultfile = myargv[i + 1];
|
||||
//doom_print(" default file: %s\n", defaultfile);
|
||||
doom_print(" default file: ");
|
||||
doom_print(defaultfile);
|
||||
doom_print("\n");
|
||||
}
|
||||
else
|
||||
defaultfile = basedefault;
|
||||
|
||||
// read the file in, overriding any set defaults
|
||||
f = doom_open(defaultfile, "r");
|
||||
if (f)
|
||||
{
|
||||
while (!doom_eof(f))
|
||||
defaultfile = basedefault;
|
||||
}
|
||||
|
||||
void* f = doom_open(defaultfile, "r");
|
||||
if (!f)
|
||||
return;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int lineStatus = M_ReadDefaultsLine(f, line, (int)sizeof(line));
|
||||
if (!lineStatus)
|
||||
break;
|
||||
if (lineStatus < 0)
|
||||
{
|
||||
// def
|
||||
int arg_read = 0;
|
||||
char c;
|
||||
for (i = 0; i < 79; ++i)
|
||||
{
|
||||
doom_read(f, &c, 1);
|
||||
if (c == ' ' || c == '\n' || c == '\t')
|
||||
{
|
||||
if (i > 0) arg_read++;
|
||||
break;
|
||||
}
|
||||
def[i] = c;
|
||||
}
|
||||
def[i] = '\0';
|
||||
|
||||
// Ignore spaces
|
||||
if (c != '\n')
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
doom_read(f, &c, 1);
|
||||
if (c != ' ' && c != '\t') break;
|
||||
}
|
||||
|
||||
// strparam
|
||||
i = 0;
|
||||
if (c != '\n')
|
||||
{
|
||||
for (; i < 260;)
|
||||
{
|
||||
strparm[i++] = c;
|
||||
doom_read(f, &c, 1);
|
||||
if (c == '\n')
|
||||
{
|
||||
if (i > 0) arg_read++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
strparm[i] = '\0';
|
||||
}
|
||||
|
||||
isstring = doom_false;
|
||||
//if (fscanf(f, "%79s %[^\n]\n", def, strparm) == 2)
|
||||
if (arg_read == 2)
|
||||
{
|
||||
if (strparm[0] == '"')
|
||||
{
|
||||
// get a string default
|
||||
isstring = doom_true;
|
||||
len = (int)doom_strlen(strparm);
|
||||
newstring = (char*)doom_malloc(len);
|
||||
strparm[len - 1] = 0;
|
||||
doom_strcpy(newstring, strparm + 1);
|
||||
}
|
||||
else if (strparm[0] == '0' && strparm[1] == 'x')
|
||||
{
|
||||
//sscanf(strparm + 2, "%x", &parm);
|
||||
parm = doom_atox(strparm + 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
//sscanf(strparm, "%i", &parm);
|
||||
parm = doom_atoi(strparm);
|
||||
}
|
||||
for (i = 0; i < numdefaults; i++)
|
||||
if (!doom_strcmp(def, defaults[i].name))
|
||||
{
|
||||
if (!isstring)
|
||||
*defaults[i].location = parm;
|
||||
else
|
||||
*defaults[i].text_location = newstring;
|
||||
break;
|
||||
}
|
||||
}
|
||||
doom_print("M_LoadDefaults: ignored an overlong defaults line.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
doom_close(f);
|
||||
char* name = M_SkipDefaultWhitespace(line);
|
||||
if (!*name || *name == '#')
|
||||
continue;
|
||||
|
||||
char* value = name;
|
||||
while (*value && *value != ' ' && *value != '\t')
|
||||
value++;
|
||||
if (!*value)
|
||||
continue;
|
||||
*value++ = 0;
|
||||
value = M_SkipDefaultWhitespace(value);
|
||||
M_TrimDefaultWhitespace(value);
|
||||
if (!*value)
|
||||
continue;
|
||||
|
||||
default_t* setting = get_default(name);
|
||||
if (!setting)
|
||||
continue;
|
||||
|
||||
if (value[0] == '"')
|
||||
{
|
||||
int length = (int)doom_strlen(value);
|
||||
if (length < 2 || value[length - 1] != '"' || !setting->text_location)
|
||||
continue;
|
||||
|
||||
int textLength = length - 2;
|
||||
char* newstring = (char*)doom_malloc(textLength + 1);
|
||||
if (!newstring)
|
||||
continue;
|
||||
doom_memcpy(newstring, value + 1, textLength);
|
||||
newstring[textLength] = 0;
|
||||
*setting->text_location = newstring;
|
||||
}
|
||||
else if (setting->location)
|
||||
{
|
||||
int parsed;
|
||||
if (value[0] == '0' && value[1] == 'x')
|
||||
parsed = doom_atox(value + 2);
|
||||
else
|
||||
parsed = doom_atoi(value);
|
||||
*setting->location = parsed;
|
||||
}
|
||||
}
|
||||
|
||||
doom_close(f);
|
||||
}
|
||||
|
||||
|
||||
@@ -37068,10 +37129,6 @@ void R_InitTextures(void)
|
||||
|
||||
int* directory;
|
||||
|
||||
int temp1;
|
||||
int temp2;
|
||||
int temp3;
|
||||
|
||||
// Load the patch names from pnames.lmp.
|
||||
name[8] = 0;
|
||||
names = (char*)W_CacheLumpName((char*)"PNAMES", PU_STATIC);
|
||||
@@ -37118,23 +37175,10 @@ void R_InitTextures(void)
|
||||
|
||||
totalwidth = 0;
|
||||
|
||||
// Really complex printing shit...
|
||||
temp1 = W_GetNumForName((char*)"S_START"); // P_???????
|
||||
temp2 = W_GetNumForName((char*)"S_END") - 1;
|
||||
temp3 = ((temp2 - temp1 + 63) / 64) + ((numtextures + 63) / 64);
|
||||
doom_print("[");
|
||||
for (i = 0; i < temp3; i++)
|
||||
doom_print(" ");
|
||||
doom_print(" ]");
|
||||
for (i = 0; i < temp3; i++)
|
||||
doom_print("\x8");
|
||||
doom_print("\x8\x8\x8\x8\x8\x8\x8\x8\x8\x8");
|
||||
// Cursor-control progress output can block simple platform consoles.
|
||||
|
||||
for (i = 0; i < numtextures; i++, directory++)
|
||||
{
|
||||
if (!(i & 63))
|
||||
doom_print(".");
|
||||
|
||||
if (i == numtextures1)
|
||||
{
|
||||
// Start looking in second texture file.
|
||||
@@ -37285,14 +37329,14 @@ void R_InitColormaps(void)
|
||||
//
|
||||
void R_InitData(void)
|
||||
{
|
||||
R_InitTextures();
|
||||
doom_print("\nInitTextures");
|
||||
R_InitFlats();
|
||||
R_InitTextures();
|
||||
doom_print("\nInitFlats");
|
||||
R_InitSpriteLumps();
|
||||
R_InitFlats();
|
||||
doom_print("\nInitSprites");
|
||||
R_InitColormaps();
|
||||
R_InitSpriteLumps();
|
||||
doom_print("\nInitColormaps");
|
||||
R_InitColormaps();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user