Skip to content

Commit

Permalink
Input should now work (one at a time however)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cacodemon345 committed Dec 29, 2019
1 parent 0bcc862 commit 25644d2
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 34 deletions.
9 changes: 6 additions & 3 deletions uefidoom/d_main.c
Expand Up @@ -379,6 +379,7 @@ 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 All @@ -393,7 +394,9 @@ void D_DoomLoop (void)
{
TryRunTics (); // will run at least one tic
}


G_ResetKeycmd ();

S_UpdateSounds (players[consoleplayer].mo);// move positional sounds

// Update display, next frame, with current state.
Expand Down Expand Up @@ -878,8 +881,8 @@ void D_DoomMain (void)
if (M_CheckParm("-cdrom"))
{
printf(D_CDROM);
mkdir("c:\\doomdata",0);
strcpy (basedefault,"c:/doomdata/default.cfg");
mkdir("FS0:\\doomdata",0);
strcpy (basedefault,"FS0:/doomdata/default.cfg");
}

// turbo option
Expand Down
4 changes: 3 additions & 1 deletion uefidoom/doom.inf
Expand Up @@ -5,7 +5,7 @@
FILE_GUID = 6987936E-ED34-44db-AE97-1FA5E4ED2116
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
ENTRY_POINT = UefiMain
ENTRY_POINT = ShellCEntryLib

#
# The following information is for reference only and not required by the build tools.
Expand Down Expand Up @@ -80,6 +80,7 @@ z_zone.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
ShellPkg/ShellPkg.dec
StdLib/StdLib.dec

[LibraryClasses]
Expand All @@ -95,6 +96,7 @@ z_zone.c
gEfiLoadedImageProtocolGuid
gEfiDevicePathToTextProtocolGuid
gEfiSimplePointerProtocolGuid
gEfiSimpleTextInputExProtocolGuid

[BuildOptions]
*:*_*_*_CC_FLAGS = -DNORMALUNIX
Expand Down
28 changes: 17 additions & 11 deletions uefidoom/efi/i_system.c
Expand Up @@ -19,9 +19,10 @@
#pragma implementation "i_system.h"
#endif
#include "i_system.h"



#include <Uefi.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiRuntimeLib.h>
#include <Library/UefiBootServicesTableLib.h>

int mb_used = 20;

Expand Down Expand Up @@ -54,20 +55,28 @@ byte* I_ZoneBase (int* size)
return (byte *) malloc (*size);
}



//
// I_GetTime
// returns time in 1/70th second tics
//
// [Cacodemon345] Rely upon the EFI Runtime Services GetTime function.

int I_GetTime (void)
{
struct timeval tp;
//struct timezone tzp;
int newtics;
static int basetime=0;

gettimeofday(&tp, NULL);
if (gST) gRT = gST->RuntimeServices;
EFI_TIME *time = NULL;
EFI_TIME_CAPABILITIES *timecaps = NULL;
if (gRT) gRT->GetTime(time,timecaps);
if (time != NULL)
{
tp.tv_sec = time->Second;
tp.tv_usec = time->Nanosecond / 1000;
}
else gettimeofday(&tp, NULL);
if (!basetime)
basetime = tp.tv_sec;
newtics = (tp.tv_sec-basetime)*TICRATE + tp.tv_usec*TICRATE/1000000;
Expand Down Expand Up @@ -96,9 +105,7 @@ void I_Quit (void)
M_SaveDefaults ();
I_ShutdownGraphics();

printf("I_Quit: locking\n");
while(1) ;
//exit(0);
exit(0);
}

void I_WaitVBL(int count)
Expand Down Expand Up @@ -179,7 +186,6 @@ EFI_STATUS UefiMain(EFI_HANDLE handle, EFI_SYSTEM_TABLE* st)
const char* msg = "DOOM: testing serial port\n";
SerialPortInitialize();
SerialPortWrite(msg, strlen(msg));

const CHAR16* argv[] = {L"doom.exe", NULL};
return ShellAppMain(1, argv);
}
Expand Down
33 changes: 27 additions & 6 deletions uefidoom/efi/i_video.c
Expand Up @@ -4,12 +4,14 @@
#include <doomdef.h>

// Efi stuff
#include <Uefi.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugLib.h>

#include <Protocol/GraphicsOutput.h>
#include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextInEx.h>
#include <Protocol/SimplePointer.h>

////////////////////////////////////////////////////////////////////

Expand All @@ -19,6 +21,7 @@ typedef void(*FrameRenderFptr)(void);
////////////////////////////////////////////////////////////////////

static EFI_GRAPHICS_OUTPUT_PROTOCOL* gGOP = NULL;
static EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE* mode = NULL;

static UINT32 frameLeft = 0;
static UINT32 frameTop = 0;
Expand All @@ -27,7 +30,8 @@ static UINT32 frameHeight = 0;

static EFI_GRAPHICS_OUTPUT_BLT_PIXEL gPalette[256] = {0};
static EFI_GRAPHICS_OUTPUT_BLT_PIXEL* frameBuffer = NULL;

static EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* gInputEx = NULL;
static EFI_SIMPLE_POINTER_PROTOCOL* gMouseProtocol = NULL;
static FrameRenderFptr gRenderFunc = NULL;

#define FRAME_SCALE 2
Expand Down Expand Up @@ -143,7 +147,9 @@ void I_InitGraphics (void)
printf("I_InitGraphics: no graphics output: 0x%x\n", status);
return;
}

status = gBS->HandleProtocol(gST->ConsoleInHandle,&gEfiSimplePointerProtocolGuid, (void**) &gMouseProtocol);
if (EFI_ERROR(status)) printf("Failed to initialize mouse pointer.\n");
mode = gGOP->Mode;
status = gGOP->SetMode(gGOP, 0);
if (EFI_ERROR(status))
{
Expand Down Expand Up @@ -225,6 +231,7 @@ void I_FinishUpdate (void)

void I_ShutdownGraphics(void)
{
gGOP->SetMode(gGOP,mode->Mode);
free(frameBuffer);
free(screens[0]);

Expand Down Expand Up @@ -421,10 +428,24 @@ void I_StartTic (void)
event.data1 = xlatekey(&inputKey);
D_PostEvent(&event);

event.type = ev_keyup;
event.data1 = xlatekey(&inputKey);
D_PostEvent(&event);

if (gMouseProtocol)
{
EFI_SIMPLE_POINTER_STATE state;
EFI_STATUS status = gMouseProtocol->GetState(gMouseProtocol,&state);
if (EFI_ERROR(status))
{

}
else
{
event.type = ev_mouse;
event.data1 = (state.LeftButton == 1);
event.data1 |= (state.RightButton == 1 ? 2 : 0);
event.data2 = state.RelativeMovementX << 2;
event.data3 = state.RelativeMovementY << 2;
D_PostEvent(&event);
}
}
}
}

Expand Down
33 changes: 20 additions & 13 deletions uefidoom/g_game.c
Expand Up @@ -92,6 +92,7 @@ void G_DoCompleted (void);
void G_DoVictory (void);
void G_DoWorldDone (void);
void G_DoSaveGame (void);
void G_ResetKeycmd (void);


gameaction_t gameaction;
Expand Down Expand Up @@ -214,7 +215,13 @@ int bodyqueslot;

void* statcopy; // for statistics driver


void G_ResetKeycmd()
{
for (int i = 0; i < 255; i++)
{
gamekeydown[i] = false;
}
}

int G_CmdChecksum (ticcmd_t* cmd)
{
Expand Down Expand Up @@ -263,8 +270,8 @@ void G_BuildTiccmd (ticcmd_t* cmd)
// on the keyboard and joystick
if (joyxmove < 0
|| joyxmove > 0
|| gamekeydown[key_right]
|| gamekeydown[key_left])
|| gamekeydown[KEY_RIGHTARROW]
|| gamekeydown[KEY_LEFTARROW])
turnheld += ticdup;
else
turnheld = 0;
Expand All @@ -277,12 +284,12 @@ void G_BuildTiccmd (ticcmd_t* cmd)
// let movement keys cancel each other out
if (strafe)
{
if (gamekeydown[key_right])
if (gamekeydown[KEY_RIGHTARROW])
{
// fprintf(stderr, "strafe right\n");
side += sidemove[speed];
}
if (gamekeydown[key_left])
if (gamekeydown[KEY_LEFTARROW])
{
// fprintf(stderr, "strafe left\n");
side -= sidemove[speed];
Expand All @@ -295,22 +302,22 @@ void G_BuildTiccmd (ticcmd_t* cmd)
}
else
{
if (gamekeydown[key_right])
if (gamekeydown[KEY_RIGHTARROW])
cmd->angleturn -= angleturn[tspeed];
if (gamekeydown[key_left])
if (gamekeydown[KEY_LEFTARROW])
cmd->angleturn += angleturn[tspeed];
if (joyxmove > 0)
cmd->angleturn -= angleturn[tspeed];
if (joyxmove < 0)
cmd->angleturn += angleturn[tspeed];
}

if (gamekeydown[key_up])
if (gamekeydown[KEY_UPARROW])
{
// fprintf(stderr, "up\n");
forward += forwardmove[speed];
}
if (gamekeydown[key_down])
if (gamekeydown[KEY_DOWNARROW])
{
// fprintf(stderr, "down\n");
forward -= forwardmove[speed];
Expand All @@ -319,19 +326,19 @@ void G_BuildTiccmd (ticcmd_t* cmd)
forward += forwardmove[speed];
if (joyymove > 0)
forward -= forwardmove[speed];
if (gamekeydown[key_straferight])
if (gamekeydown['.'])
side += sidemove[speed];
if (gamekeydown[key_strafeleft])
if (gamekeydown[','])
side -= sidemove[speed];

// buttons
cmd->chatchar = HU_dequeueChatChar();

if (gamekeydown[key_fire] || mousebuttons[mousebfire]
if (gamekeydown[' '] || mousebuttons[mousebfire]
|| joybuttons[joybfire])
cmd->buttons |= BT_ATTACK;

if (gamekeydown[key_use] || joybuttons[joybuse] )
if (gamekeydown['e'] || joybuttons[joybuse] )
{
cmd->buttons |= BT_USE;
// clear double clicks if hit use button
Expand Down

0 comments on commit 25644d2

Please sign in to comment.