Skip to content

Commit

Permalink
Some important fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cacodemon345 committed Feb 28, 2020
1 parent 5d67c47 commit e903700
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 54 deletions.
21 changes: 16 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,24 @@ Instructions:
`SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf`
Also add the path to the inf file of this project in the [Components] list like this:
`AppPkg/Applications/uefidoom/doom.inf`
5. Edit the StdLib.inc file inside StdLib directory; change these lines:
```MSFT:*_VS2015_*_CC_FLAGS = /Wv:11
MSFT:*_VS2015x86_*_CC_FLAGS = /Wv:11
MSFT:*_VS2015xASL_*_CC_FLAGS = /Wv:11
MSFT:*_VS2015x86xASL_*_CC_FLAGS = /Wv:11```
into:
```MSFT:*_VS2015_*_CC_FLAGS = /Wv:11 /W0
MSFT:*_VS2015x86_*_CC_FLAGS = /Wv:11 /W0
MSFT:*_VS2015xASL_*_CC_FLAGS = /Wv:11 /W0
MSFT:*_VS2015x86xASL_*_CC_FLAGS = /Wv:11 /W0```
This will disable the warnings (don't worry, the project will build and run).

5. Move the "uefidoom" folder from this project inside Applications.
6. Download the AudioDxe source code from http://github.com/Goldfish64/AudioPkg. Disable the warnings there too.
7. Open a command prompt, type `edksetup.bat` (assuming you set up the environment properly) and then type `build -t VS2015 -b DEBUG -a X64`
8. If everything goes well, look for a file called "doom.efi" inside this path:
6. Move the "uefidoom" folder from this project inside Applications.
7. Download the AudioDxe source code from http://github.com/Goldfish64/AudioPkg. Disable the warnings there too.
8. Open a command prompt, type `edksetup.bat` (assuming you set up the environment properly) and then type `build -t VS2015 -b DEBUG -a X64`
9. If everything goes well, look for a file called "doom.efi" inside this path:
`path\to\edk2\Build\AppPkg\DEBUG_VS2015\X64\`
9. Now just copy `doom.wad` (the Registered DOOM 1 1.9 IWAD file) into it.
10. Now just copy `doom.wad` (the Registered DOOM 1 1.9 IWAD file) into it.
This should make sure everything is ready for playing.
# Running:
Make sure you have a UEFI environment in your real hardware. Also, make sure the executable resides inside a FAT32 partition and that the DOOM 1 IWAD file resides in the same directory as the executable.
Expand Down
2 changes: 1 addition & 1 deletion uefidoom/d_englsh.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// D_Main.C
//
#define D_DEVSTR "Development mode ON.\n"
#define D_CDROM "CD-ROM Version: default.cfg from c:\\doomdata\n"
#define D_CDROM "CD-ROM Version: default.cfg from FS0:/doomdata/n"

//
// M_Menu.C
Expand Down
44 changes: 24 additions & 20 deletions uefidoom/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ static const char rcsid[] = "$Id: d_main.c,v 1.8 1997/02/03 22:45:09 b1 Exp $";
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <wchar.h>
#include <wctype.h>

//#endif

Expand Down Expand Up @@ -73,7 +75,7 @@ static const char rcsid[] = "$Id: d_main.c,v 1.8 1997/02/03 22:45:09 b1 Exp $";
#include "r_local.h"

#include "d_main.h"

#define R_OK 0
//
// D-DoomLoop()
// Not a globally visible function,
Expand Down Expand Up @@ -353,7 +355,6 @@ void D_DoomLoop(void)
if (singletics)
{
usleep((1000 * 1000) / 35);
//for (int ticstart = 0; ticstart < 6; ticstart++) // Process up to 5 events.
I_StartTic();
D_ProcessEvents();
G_BuildTiccmd(&netcmds[consoleplayer][maketic % BACKUPTICS]);
Expand Down Expand Up @@ -547,31 +548,31 @@ void IdentifyVersion(void)
doomwaddir = ".";

// Commercial.
//doom2wad = malloc(strlen(doomwaddir)+1+9+1);
//sprintf(doom2wad, "%s/doom2.wad", doomwaddir);
doom2wad = malloc(strlen(doomwaddir)+1+18+1);
sprintf(doom2wad, "%s/doom2.wad", doomwaddir);

// Retail.
//doomuwad = malloc(strlen(doomwaddir)+1+8+1);
//sprintf(doomuwad, "%s/doomu.wad", doomwaddir);
doomuwad = malloc(strlen(doomwaddir)+1+18+1);
sprintf(doomuwad, "%s/doomu.wad", doomwaddir);

// Registered.
doomwad = malloc(strlen(doomwaddir) + 1 + 18 + 1);
sprintf(doomwad, "%s/doom.wad", doomwaddir);

// Shareware.
//doom1wad = malloc(strlen(doomwaddir)+1+9+1);
//sprintf(doom1wad, "%s/doom1.wad", doomwaddir);
doom1wad = malloc(strlen(doomwaddir)+1+18+1);
sprintf(doom1wad, "%s/doom1.wad", doomwaddir);

// Bug, dear Shawn.
// Insufficient malloc, caused spurious realloc errors.
//plutoniawad = malloc(strlen(doomwaddir)+1+/*9*/12+1);
//sprintf(plutoniawad, "%s/plutonia.wad", doomwaddir);
plutoniawad = malloc(strlen(doomwaddir)+1+24+1);
sprintf(plutoniawad, "%s/plutonia.wad", doomwaddir);

//tntwad = malloc(strlen(doomwaddir)+1+9+1);
//sprintf(tntwad, "%s/tnt.wad", doomwaddir);
tntwad = malloc(strlen(doomwaddir)+1+18+1);
sprintf(tntwad, "%s/tnt.wad", doomwaddir);

// French stuff.
//doom2fwad = malloc(strlen(doomwaddir)+1+10+1);
//doom2fwad = malloc(strlen(doomwaddir)+1+20+1);
//sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir);

/*
Expand Down Expand Up @@ -634,25 +635,24 @@ void IdentifyVersion(void)
}
*/

/*

if ( 0 == access (doom2wad,R_OK) )
{
gamemode = commercial;
printf("%s\n", doom2wad);
D_AddFile (doom2wad);
return;
}
*/

/*

if ( 0 == access (doomuwad,R_OK) )
{
printf("%s\n", doomuwad);
gamemode = retail;
D_AddFile (doomuwad);
return;
}
*/


if (0 == access(doomwad, R_OK))
{
Expand All @@ -661,15 +661,14 @@ void IdentifyVersion(void)
return;
}

/*
if ( 0 == access (doom1wad,R_OK) )
{
printf("%s\n", doom1wad);
gamemode = shareware;
D_AddFile (doom1wad);
return;
}
*/


Print(L"Game mode indeterminate.\n");
gamemode = indetermined;
Expand Down Expand Up @@ -766,7 +765,12 @@ void D_DoomMain(void)

setbuf(stdout, NULL);
modifiedgame = false;

printf("\nArguments:");
for (int i = 0; i < myargc; i++)
{
printf(" %s",myargv[i]);
}
printf(".\n");
nomonsters = M_CheckParm("-nomonsters");
respawnparm = M_CheckParm("-respawn");
fastparm = M_CheckParm("-fast");
Expand Down
3 changes: 2 additions & 1 deletion uefidoom/doom.inf
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,5 @@ z_zone.c

[BuildOptions]
*:*_*_*_CC_FLAGS = -DNORMALUNIX
MSFT:*_*_*_CC_FLAGS = -DNORMALUNIX /W0
MSFT:*_*_*_CC_FLAGS = -DNORMALUNIX /W2 /WX- /WL

8 changes: 4 additions & 4 deletions uefidoom/efi/i_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ int I_StartSound(int id,
int pitch,
int priority)
{
if (!audioIo) return;
if (!outputFound) return 0;
int *length;
char* sampdata;
char* lumpdata;
Expand All @@ -219,8 +219,8 @@ int I_StartSound(int id,
sampdata = malloc(lumplength - 8);
lumpdata = malloc(lumplength);
W_ReadLump(sfxlumpnum,lumpdata);
memmove(sampdata,lumpdata[0x8],sampLength);
int realvol = 100 * (vol / 127);
memmove(sampdata,lumpdata + 8,sampLength);
unsigned int realvol = 100 * (vol / 127);
char *expandedSampleData = calloc(1, (lumplength) * 4);
char *sfxdata = lumpdata;
for (int sampleByte = 0; sampleByte < lumplength; sampleByte++)
Expand All @@ -232,7 +232,7 @@ int I_StartSound(int id,
}
audioIo->SetupPlayback(audioIo, outputToUse, realvol, EfiAudioIoFreq44kHz, EfiAudioIoBits16, 2);
audioIo->StartPlaybackAsync(audioIo, sfxdata, lumplength * 4, 8 * 4, I_FinishedSound, (void*)calldata); // Blast it out unprocessed.
return;
return 0;
S_sfx[id].data = getsfx(S_sfx[id].name, length);
EFI_STATUS stats;
if (audioIo)
Expand Down
26 changes: 17 additions & 9 deletions uefidoom/efi/i_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#endif
#include "i_system.h"
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiRuntimeLib.h>
#include <Library/UefiBootServicesTableLib.h>
Expand Down Expand Up @@ -67,8 +68,10 @@ int I_GetTime (void)
//struct timezone tzp;
int newtics;
static int basetime=0;
EFI_TIME *time = NULL;
EFI_TIME_CAPABILITIES *timecaps = NULL;
EFI_TIME *time = malloc(sizeof(EFI_TIME));
memset(time,0,sizeof(EFI_TIME));
EFI_TIME_CAPABILITIES *timecaps = malloc(sizeof(EFI_TIME_CAPABILITIES));
memset(timecaps,0,sizeof(EFI_TIME_CAPABILITIES));
if (gST) gST->RuntimeServices->GetTime(time,timecaps);
if (time != NULL)
{
Expand All @@ -79,18 +82,26 @@ int I_GetTime (void)
if (!basetime)
basetime = tp.tv_sec;
newtics = (tp.tv_sec-basetime)*TICRATE + tp.tv_usec*TICRATE/1000000;
free(time);
free(timecaps);
return newtics;
}



int nano100ticks = 0;
void I_TickTime(IN EFI_EVENT Event, IN VOID *Context)
{
nano100ticks++;
AsciiPrint("Ticks passed: %d",nano100ticks);
}
EFI_EVENT timerEvent = 0;
//
// I_Init
//
void I_Init (void)
{
gBS->SetWatchdogTimer(0,0,0,NULL);
I_InitSound();
gBS->CreateEvent(EVT_TIMER | EVT_NOTIFY_SIGNAL | EVT_NOTIFY_WAIT,TPL_CALLBACK,(EFI_EVENT_NOTIFY)&I_TickTime,NULL,&timerEvent);
gBS->SetTimer(&timerEvent,TimerPeriodic,1);
// I_InitGraphics();
}

Expand Down Expand Up @@ -163,9 +174,6 @@ void I_Error (char *error, ...)
printf ("\n");
va_end (argptr);




exit(-1);
}

Expand All @@ -184,7 +192,7 @@ ShellAppMain (
#include <Protocol/DevicePathToText.h>
#include <Protocol/SimplePointer.h>

EFI_STATUS UefiMain(EFI_HANDLE handle, EFI_SYSTEM_TABLE* st)
EFI_STATUS EFIAPI UefiMain(EFI_HANDLE handle, EFI_SYSTEM_TABLE* st)
{
const char* msg = "DOOM: testing serial port\n";
SerialPortInitialize();
Expand Down
7 changes: 4 additions & 3 deletions uefidoom/efi/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ void I_InitGraphics (void)
}
status = gBS->HandleProtocol(gST->ConsoleInHandle,&gEfiSimpleTextInputExProtocolGuid,(void**) &gInputEx);
if (EFI_ERROR(status)) printf("Failed to initialize Extended Input protocol.\n");
else

/*else
{
int i;
for (i = 0; i < 256; i++)
Expand All @@ -252,7 +253,7 @@ void I_InitGraphics (void)
scankeydata.Key.ScanCode = i;
gInputEx->RegisterKeyNotify(gInputEx,&scankeydata,I_ScanKeyNotify,(void**)&ScanNotifHandle);
}
}
}*/
mode = gGOP->Mode;
status = gGOP->SetMode(gGOP, 0);
if (EFI_ERROR(status))
Expand Down Expand Up @@ -352,7 +353,7 @@ void I_SetPalette (byte* palette)
{
if (!palette)
{
printf("No palette!\n");
printf("I_SetPalette: No palette!\n");
}

size_t i = 0;
Expand Down
21 changes: 19 additions & 2 deletions uefidoom/i_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,32 @@ rcsid[] = "$Id: i_main.c,v 1.4 1997/02/03 22:45:10 b1 Exp $";

#include "m_argv.h"
#include "d_main.h"

#include <stdlib.h>
#include <wchar.h>
#include <wctype.h>
char* UCS2toANSI(wchar_t* wstr)
{
char* newchar = calloc(wcslen(wstr) + 1,1);
int i = 0;
for (i = 0; i < wcslen(wstr); i++)
{
newchar[i] = wstr[i];
}
newchar[i] = 0;
return newchar;
}
int
main
( int argc,
char** argv )
{
myargc = argc;
myargv = argv;

mywargv = (wchar_t**)argv;
/*for (int i = 0; i < argc; i++)
{
myargv[i] = UCS2toANSI(mywargv[i]);
}*/
D_DoomMain ();

return 0;
Expand Down
27 changes: 22 additions & 5 deletions uefidoom/m_argv.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,28 @@ rcsid[] = "$Id: m_argv.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";


#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#include <wctype.h>

int myargc;
char** myargv;
wchar_t** mywargv;

mbstate_t convstate;


// Taken from ReactOS.
int wcscasecmp(const wchar_t* cs,const wchar_t * ct)
{
while (towlower(*cs) == towlower(*ct))
{
if (*cs == 0)
return 0;
cs++;
ct++;
}
return towlower(*cs) - towlower(*ct);
}

//
// M_CheckParm
Expand All @@ -41,12 +56,14 @@ char** myargv;
// or 0 if not present
int M_CheckParm (char *check)
{
int i;

int i = 1;
for (i = 1;i<myargc;i++)
{
if ( !strcasecmp(check, myargv[i]) )
return i;
if ( !strcasecmp(check, myargv[i]) )
{
printf("Found parameter: %s\n",check);
return i;
}
}

return 0;
Expand Down
Loading

0 comments on commit e903700

Please sign in to comment.