Skip to content

Commit e903700

Browse files
committed
Some important fixes
1 parent 5d67c47 commit e903700

File tree

11 files changed

+113
-54
lines changed

11 files changed

+113
-54
lines changed

readme.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,24 @@ Instructions:
1717
`SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf`
1818
Also add the path to the inf file of this project in the [Components] list like this:
1919
`AppPkg/Applications/uefidoom/doom.inf`
20+
5. Edit the StdLib.inc file inside StdLib directory; change these lines:
21+
```MSFT:*_VS2015_*_CC_FLAGS = /Wv:11
22+
MSFT:*_VS2015x86_*_CC_FLAGS = /Wv:11
23+
MSFT:*_VS2015xASL_*_CC_FLAGS = /Wv:11
24+
MSFT:*_VS2015x86xASL_*_CC_FLAGS = /Wv:11```
25+
into:
26+
```MSFT:*_VS2015_*_CC_FLAGS = /Wv:11 /W0
27+
MSFT:*_VS2015x86_*_CC_FLAGS = /Wv:11 /W0
28+
MSFT:*_VS2015xASL_*_CC_FLAGS = /Wv:11 /W0
29+
MSFT:*_VS2015x86xASL_*_CC_FLAGS = /Wv:11 /W0```
30+
This will disable the warnings (don't worry, the project will build and run).
2031

21-
5. Move the "uefidoom" folder from this project inside Applications.
22-
6. Download the AudioDxe source code from http://github.com/Goldfish64/AudioPkg. Disable the warnings there too.
23-
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`
24-
8. If everything goes well, look for a file called "doom.efi" inside this path:
32+
6. Move the "uefidoom" folder from this project inside Applications.
33+
7. Download the AudioDxe source code from http://github.com/Goldfish64/AudioPkg. Disable the warnings there too.
34+
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`
35+
9. If everything goes well, look for a file called "doom.efi" inside this path:
2536
`path\to\edk2\Build\AppPkg\DEBUG_VS2015\X64\`
26-
9. Now just copy `doom.wad` (the Registered DOOM 1 1.9 IWAD file) into it.
37+
10. Now just copy `doom.wad` (the Registered DOOM 1 1.9 IWAD file) into it.
2738
This should make sure everything is ready for playing.
2839
# Running:
2940
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.

uefidoom/d_englsh.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
// D_Main.C
3232
//
3333
#define D_DEVSTR "Development mode ON.\n"
34-
#define D_CDROM "CD-ROM Version: default.cfg from c:\\doomdata\n"
34+
#define D_CDROM "CD-ROM Version: default.cfg from FS0:/doomdata/n"
3535

3636
//
3737
// M_Menu.C

uefidoom/d_main.c

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ static const char rcsid[] = "$Id: d_main.c,v 1.8 1997/02/03 22:45:09 b1 Exp $";
3737
#include <sys/stat.h>
3838
#include <fcntl.h>
3939
#include <errno.h>
40+
#include <wchar.h>
41+
#include <wctype.h>
4042

4143
//#endif
4244

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

7577
#include "d_main.h"
76-
78+
#define R_OK 0
7779
//
7880
// D-DoomLoop()
7981
// Not a globally visible function,
@@ -353,7 +355,6 @@ void D_DoomLoop(void)
353355
if (singletics)
354356
{
355357
usleep((1000 * 1000) / 35);
356-
//for (int ticstart = 0; ticstart < 6; ticstart++) // Process up to 5 events.
357358
I_StartTic();
358359
D_ProcessEvents();
359360
G_BuildTiccmd(&netcmds[consoleplayer][maketic % BACKUPTICS]);
@@ -547,31 +548,31 @@ void IdentifyVersion(void)
547548
doomwaddir = ".";
548549

549550
// Commercial.
550-
//doom2wad = malloc(strlen(doomwaddir)+1+9+1);
551-
//sprintf(doom2wad, "%s/doom2.wad", doomwaddir);
551+
doom2wad = malloc(strlen(doomwaddir)+1+18+1);
552+
sprintf(doom2wad, "%s/doom2.wad", doomwaddir);
552553

553554
// Retail.
554-
//doomuwad = malloc(strlen(doomwaddir)+1+8+1);
555-
//sprintf(doomuwad, "%s/doomu.wad", doomwaddir);
555+
doomuwad = malloc(strlen(doomwaddir)+1+18+1);
556+
sprintf(doomuwad, "%s/doomu.wad", doomwaddir);
556557

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

561562
// Shareware.
562-
//doom1wad = malloc(strlen(doomwaddir)+1+9+1);
563-
//sprintf(doom1wad, "%s/doom1.wad", doomwaddir);
563+
doom1wad = malloc(strlen(doomwaddir)+1+18+1);
564+
sprintf(doom1wad, "%s/doom1.wad", doomwaddir);
564565

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

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

573574
// French stuff.
574-
//doom2fwad = malloc(strlen(doomwaddir)+1+10+1);
575+
//doom2fwad = malloc(strlen(doomwaddir)+1+20+1);
575576
//sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir);
576577

577578
/*
@@ -634,25 +635,24 @@ void IdentifyVersion(void)
634635
}
635636
*/
636637

637-
/*
638+
638639
if ( 0 == access (doom2wad,R_OK) )
639640
{
640641
gamemode = commercial;
641642
printf("%s\n", doom2wad);
642643
D_AddFile (doom2wad);
643644
return;
644645
}
645-
*/
646646

647-
/*
647+
648648
if ( 0 == access (doomuwad,R_OK) )
649649
{
650650
printf("%s\n", doomuwad);
651651
gamemode = retail;
652652
D_AddFile (doomuwad);
653653
return;
654654
}
655-
*/
655+
656656

657657
if (0 == access(doomwad, R_OK))
658658
{
@@ -661,15 +661,14 @@ void IdentifyVersion(void)
661661
return;
662662
}
663663

664-
/*
665664
if ( 0 == access (doom1wad,R_OK) )
666665
{
667666
printf("%s\n", doom1wad);
668667
gamemode = shareware;
669668
D_AddFile (doom1wad);
670669
return;
671670
}
672-
*/
671+
673672

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

767766
setbuf(stdout, NULL);
768767
modifiedgame = false;
769-
768+
printf("\nArguments:");
769+
for (int i = 0; i < myargc; i++)
770+
{
771+
printf(" %s",myargv[i]);
772+
}
773+
printf(".\n");
770774
nomonsters = M_CheckParm("-nomonsters");
771775
respawnparm = M_CheckParm("-respawn");
772776
fastparm = M_CheckParm("-fast");

uefidoom/doom.inf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,5 @@ z_zone.c
101101

102102
[BuildOptions]
103103
*:*_*_*_CC_FLAGS = -DNORMALUNIX
104-
MSFT:*_*_*_CC_FLAGS = -DNORMALUNIX /W0
104+
MSFT:*_*_*_CC_FLAGS = -DNORMALUNIX /W2 /WX- /WL
105+

uefidoom/efi/i_sound.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ int I_StartSound(int id,
209209
int pitch,
210210
int priority)
211211
{
212-
if (!audioIo) return;
212+
if (!outputFound) return 0;
213213
int *length;
214214
char* sampdata;
215215
char* lumpdata;
@@ -219,8 +219,8 @@ int I_StartSound(int id,
219219
sampdata = malloc(lumplength - 8);
220220
lumpdata = malloc(lumplength);
221221
W_ReadLump(sfxlumpnum,lumpdata);
222-
memmove(sampdata,lumpdata[0x8],sampLength);
223-
int realvol = 100 * (vol / 127);
222+
memmove(sampdata,lumpdata + 8,sampLength);
223+
unsigned int realvol = 100 * (vol / 127);
224224
char *expandedSampleData = calloc(1, (lumplength) * 4);
225225
char *sfxdata = lumpdata;
226226
for (int sampleByte = 0; sampleByte < lumplength; sampleByte++)
@@ -232,7 +232,7 @@ int I_StartSound(int id,
232232
}
233233
audioIo->SetupPlayback(audioIo, outputToUse, realvol, EfiAudioIoFreq44kHz, EfiAudioIoBits16, 2);
234234
audioIo->StartPlaybackAsync(audioIo, sfxdata, lumplength * 4, 8 * 4, I_FinishedSound, (void*)calldata); // Blast it out unprocessed.
235-
return;
235+
return 0;
236236
S_sfx[id].data = getsfx(S_sfx[id].name, length);
237237
EFI_STATUS stats;
238238
if (audioIo)

uefidoom/efi/i_system.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#endif
2121
#include "i_system.h"
2222
#include <Uefi.h>
23+
#include <Library/UefiLib.h>
2324
#include <Library/UefiRuntimeServicesTableLib.h>
2425
#include <Library/UefiRuntimeLib.h>
2526
#include <Library/UefiBootServicesTableLib.h>
@@ -67,8 +68,10 @@ int I_GetTime (void)
6768
//struct timezone tzp;
6869
int newtics;
6970
static int basetime=0;
70-
EFI_TIME *time = NULL;
71-
EFI_TIME_CAPABILITIES *timecaps = NULL;
71+
EFI_TIME *time = malloc(sizeof(EFI_TIME));
72+
memset(time,0,sizeof(EFI_TIME));
73+
EFI_TIME_CAPABILITIES *timecaps = malloc(sizeof(EFI_TIME_CAPABILITIES));
74+
memset(timecaps,0,sizeof(EFI_TIME_CAPABILITIES));
7275
if (gST) gST->RuntimeServices->GetTime(time,timecaps);
7376
if (time != NULL)
7477
{
@@ -79,18 +82,26 @@ int I_GetTime (void)
7982
if (!basetime)
8083
basetime = tp.tv_sec;
8184
newtics = (tp.tv_sec-basetime)*TICRATE + tp.tv_usec*TICRATE/1000000;
85+
free(time);
86+
free(timecaps);
8287
return newtics;
8388
}
84-
85-
86-
89+
int nano100ticks = 0;
90+
void I_TickTime(IN EFI_EVENT Event, IN VOID *Context)
91+
{
92+
nano100ticks++;
93+
AsciiPrint("Ticks passed: %d",nano100ticks);
94+
}
95+
EFI_EVENT timerEvent = 0;
8796
//
8897
// I_Init
8998
//
9099
void I_Init (void)
91100
{
92101
gBS->SetWatchdogTimer(0,0,0,NULL);
93102
I_InitSound();
103+
gBS->CreateEvent(EVT_TIMER | EVT_NOTIFY_SIGNAL | EVT_NOTIFY_WAIT,TPL_CALLBACK,(EFI_EVENT_NOTIFY)&I_TickTime,NULL,&timerEvent);
104+
gBS->SetTimer(&timerEvent,TimerPeriodic,1);
94105
// I_InitGraphics();
95106
}
96107

@@ -163,9 +174,6 @@ void I_Error (char *error, ...)
163174
printf ("\n");
164175
va_end (argptr);
165176

166-
167-
168-
169177
exit(-1);
170178
}
171179

@@ -184,7 +192,7 @@ ShellAppMain (
184192
#include <Protocol/DevicePathToText.h>
185193
#include <Protocol/SimplePointer.h>
186194

187-
EFI_STATUS UefiMain(EFI_HANDLE handle, EFI_SYSTEM_TABLE* st)
195+
EFI_STATUS EFIAPI UefiMain(EFI_HANDLE handle, EFI_SYSTEM_TABLE* st)
188196
{
189197
const char* msg = "DOOM: testing serial port\n";
190198
SerialPortInitialize();

uefidoom/efi/i_video.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ void I_InitGraphics (void)
237237
}
238238
status = gBS->HandleProtocol(gST->ConsoleInHandle,&gEfiSimpleTextInputExProtocolGuid,(void**) &gInputEx);
239239
if (EFI_ERROR(status)) printf("Failed to initialize Extended Input protocol.\n");
240-
else
240+
241+
/*else
241242
{
242243
int i;
243244
for (i = 0; i < 256; i++)
@@ -252,7 +253,7 @@ void I_InitGraphics (void)
252253
scankeydata.Key.ScanCode = i;
253254
gInputEx->RegisterKeyNotify(gInputEx,&scankeydata,I_ScanKeyNotify,(void**)&ScanNotifHandle);
254255
}
255-
}
256+
}*/
256257
mode = gGOP->Mode;
257258
status = gGOP->SetMode(gGOP, 0);
258259
if (EFI_ERROR(status))
@@ -352,7 +353,7 @@ void I_SetPalette (byte* palette)
352353
{
353354
if (!palette)
354355
{
355-
printf("No palette!\n");
356+
printf("I_SetPalette: No palette!\n");
356357
}
357358

358359
size_t i = 0;

uefidoom/i_main.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,32 @@ rcsid[] = "$Id: i_main.c,v 1.4 1997/02/03 22:45:10 b1 Exp $";
3030

3131
#include "m_argv.h"
3232
#include "d_main.h"
33-
33+
#include <stdlib.h>
34+
#include <wchar.h>
35+
#include <wctype.h>
36+
char* UCS2toANSI(wchar_t* wstr)
37+
{
38+
char* newchar = calloc(wcslen(wstr) + 1,1);
39+
int i = 0;
40+
for (i = 0; i < wcslen(wstr); i++)
41+
{
42+
newchar[i] = wstr[i];
43+
}
44+
newchar[i] = 0;
45+
return newchar;
46+
}
3447
int
3548
main
3649
( int argc,
3750
char** argv )
3851
{
3952
myargc = argc;
4053
myargv = argv;
41-
54+
mywargv = (wchar_t**)argv;
55+
/*for (int i = 0; i < argc; i++)
56+
{
57+
myargv[i] = UCS2toANSI(mywargv[i]);
58+
}*/
4259
D_DoomMain ();
4360

4461
return 0;

uefidoom/m_argv.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,28 @@ rcsid[] = "$Id: m_argv.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
2525

2626

2727
#include <string.h>
28+
#include <stdlib.h>
2829
#include <wchar.h>
30+
#include <wctype.h>
2931

3032
int myargc;
3133
char** myargv;
34+
wchar_t** mywargv;
3235

36+
mbstate_t convstate;
3337

34-
38+
// Taken from ReactOS.
39+
int wcscasecmp(const wchar_t* cs,const wchar_t * ct)
40+
{
41+
while (towlower(*cs) == towlower(*ct))
42+
{
43+
if (*cs == 0)
44+
return 0;
45+
cs++;
46+
ct++;
47+
}
48+
return towlower(*cs) - towlower(*ct);
49+
}
3550

3651
//
3752
// M_CheckParm
@@ -41,12 +56,14 @@ char** myargv;
4156
// or 0 if not present
4257
int M_CheckParm (char *check)
4358
{
44-
int i;
45-
59+
int i = 1;
4660
for (i = 1;i<myargc;i++)
4761
{
48-
if ( !strcasecmp(check, myargv[i]) )
49-
return i;
62+
if ( !strcasecmp(check, myargv[i]) )
63+
{
64+
printf("Found parameter: %s\n",check);
65+
return i;
66+
}
5067
}
5168

5269
return 0;

0 commit comments

Comments
 (0)