Skip to content

Commit

Permalink
31/05/2009 - v1.0.4.0
Browse files Browse the repository at this point in the history
  - Strafe support for right analog stick. Now map button is Select instead of right analog click, using dlanor suggestion as stated over http://psx-scene.com/forums/454723-post22.html.
  • Loading branch information
Pedro Duarte committed Mar 20, 2021
1 parent c9bd49c commit 58ba3d8
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 60 deletions.
12 changes: 8 additions & 4 deletions Whatsthis.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Is is version 1.0.3.0 of PS2Doom, a port of Doom for the PS2, started by Lukasz Bruun (http://lukasz.dk) and currently maintained by me, cosmito (http://ps2homebrewing.wordpress.com). It also features audio support functions by Jason Yu (http://www.jasonyu.net).
Is is version 1.0.4.0 of PS2Doom, a port of Doom for the PS2, started by Lukasz Bruun (http://lukasz.dk) and currently maintained by me, cosmito (http://ps2homebrewing.wordpress.com). It also features audio support functions by Jason Yu (http://www.jasonyu.net).

Run PS2Doom.elf using uLaunchELF and make sure you have a doom1.wad, doom.wad, or doom2.wad copied at the same directory as the ps2doom.elf. Memory cards and USB storage devices can be used and also. Currently HD support is not implemented. Put only one .wad at a time since currently no selector is made yet.

Expand All @@ -13,14 +13,15 @@ Circle : p / Next weapon
Triangle : Escape
L1 : n
L2 : y
r1 : Fire
r2 : Space / Open doors
R1 : Fire
R2 : Space / Open doors

Start : Enter
Select : Map

Analog Left click : Map
Analog Right click: Brightness (gamma)


Please note: Enter key action (required to menu operations like starting new game) is a bit clumsy for now. For bringing up the menu, use the Cross button but to select items, use the Start button. This will be fixed.

You can use any USB compatible keyboard with the PlayStation2 also.
Expand All @@ -45,6 +46,9 @@ cosmito
History:
========

31/05/2009 - v1.0.4.0
- Strafe support for right analog stick. Now map button is Select instead of right analog click, using dlanor suggestion as stated over http://psx-scene.com/forums/454723-post22.html.

01/05/2009 - v1.0.3.0
- Now loads the .wad from current directory. No need to put it at a root of a USB device anymore. As consequence, loads perfectly from memory card.
- The Quit option menu now boots back to the OSD PS2 Browser
Expand Down
5 changes: 5 additions & 0 deletions d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,13 @@ void IdentifyVersion (void)
#ifdef _EE
//doomwaddir = "";
//doomwaddir = "mass:";
//printf(">>>>>>>>>>>>>>> myargv[0] %s:\n", myargv[0]);
//printf(">>>>>>>>>>>>>>> GetElfFilename :\n");
GetElfFilename(myargv[0], deviceName, fullPath, elfFilename);
//printf(">>>>>>>>>>>>>>> deviceName %s, fullPath %s, elfFilename %s\n", deviceName, fullPath, elfFilename);
doomwaddir = fullPath;
//scr_printf("myargv[0] = %s\n", myargv[0]);
//printf("%s\n", doomwaddir);
#else
if (!doomwaddir)
doomwaddir = "./";
Expand Down
119 changes: 76 additions & 43 deletions g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ int dclicks2;
// joystick values are repeated
int joyxmove;
int joyymove;

static int joyxside; /// cosmito : for strafe

boolean joyarray[5];
boolean* joybuttons = &joyarray[1]; // allow [-1]

Expand Down Expand Up @@ -280,59 +283,70 @@ void G_BuildTiccmd (ticcmd_t* cmd)
// let movement keys cancel each other out
if (strafe)
{
if (gamekeydown[key_right])
{
// fprintf(stderr, "strafe right\n");
side += sidemove[speed];
}
if (gamekeydown[key_left])
{
// fprintf(stderr, "strafe left\n");
side -= sidemove[speed];
}
if (joyxmove > 0)
side += sidemove[speed];
if (joyxmove < 0)
side -= sidemove[speed];
/// lsdldoom strafe nao usa isto
if (gamekeydown[key_right])
{
// fprintf(stderr, "strafe right\n");
side += sidemove[speed];
}
if (gamekeydown[key_left])
{
// fprintf(stderr, "strafe left\n");
side -= sidemove[speed];
}
if (joyxmove > 0)
side += sidemove[speed];
if (joyxmove < 0)
side -= sidemove[speed];

}
else
{
if (gamekeydown[key_right])
cmd->angleturn -= angleturn[tspeed];
if (gamekeydown[key_left])
cmd->angleturn += angleturn[tspeed];
if (joyxmove > 0)
cmd->angleturn -= angleturn[tspeed];
if (joyxmove < 0)
cmd->angleturn += angleturn[tspeed];
if (gamekeydown[key_right])
cmd->angleturn -= angleturn[tspeed];
if (gamekeydown[key_left])
cmd->angleturn += angleturn[tspeed];

//printf("joy_x = %d\n", joy_x);

if (joyxmove > 0)
{
cmd->angleturn -= angleturn[tspeed];
//printf("angleturn ESQ, joy_x = %d\n", joy_x);
}
if (joyxmove < 0)
{
cmd->angleturn += angleturn[tspeed];
//printf("angleturn DIR, joy_x = %d\n", joy_x);
}

}

if (gamekeydown[key_up])
{
// fprintf(stderr, "up\n");
forward += forwardmove[speed];
// fprintf(stderr, "up\n");
forward += forwardmove[speed];
}
if (gamekeydown[key_down])
{
// fprintf(stderr, "down\n");
forward -= forwardmove[speed];
// fprintf(stderr, "down\n");
forward -= forwardmove[speed];
}
if (joyymove < 0)
forward += forwardmove[speed];
forward += forwardmove[speed];
if (joyymove > 0)
forward -= forwardmove[speed];
forward -= forwardmove[speed];
if (gamekeydown[key_straferight])
side += sidemove[speed];
side += sidemove[speed];
if (gamekeydown[key_strafeleft])
side -= sidemove[speed];
side -= sidemove[speed];

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

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

if (gamekeydown[key_use] || joybuttons[joybuse] )
{
Expand Down Expand Up @@ -432,23 +446,33 @@ void G_BuildTiccmd (ticcmd_t* cmd)

forward += mousey;
if (strafe)
side += mousex*2;
side += mousex*2;
else
cmd->angleturn -= mousex*0x8;
cmd->angleturn -= mousex*0x8;

mousex = mousey = 0;

/// cosmito : from lsdldoom strafe support
if ( joyxside > 0 )
{
side += sidemove[speed];
}
if ( joyxside < 0 )
{
side -= sidemove[speed];
}

if (forward > MAXPLMOVE)
forward = MAXPLMOVE;
forward = MAXPLMOVE;
else if (forward < -MAXPLMOVE)
forward = -MAXPLMOVE;
forward = -MAXPLMOVE;
if (side > MAXPLMOVE)
side = MAXPLMOVE;
side = MAXPLMOVE;
else if (side < -MAXPLMOVE)
side = -MAXPLMOVE;
side = -MAXPLMOVE;

cmd->forwardmove += forward;
cmd->sidemove += side;
cmd->sidemove += side; /// cosmito : side = amount of strafe

// special buttons
if (sendpause)
Expand Down Expand Up @@ -609,12 +633,21 @@ boolean G_Responder (event_t* ev)
return true; // eat events

case ev_joystick:
joybuttons[0] = ev->data1 & 1;
joybuttons[1] = ev->data1 & 2;
joybuttons[2] = ev->data1 & 4;
joybuttons[3] = ev->data1 & 8;
//joybuttons[0] = ev->data1 & 1; /// cosmito : might interefere with strafe info, so it's commented
//joybuttons[1] = ev->data1 & 2;
//joybuttons[2] = ev->data1 & 4;
//joybuttons[3] = ev->data1 & 8;
joyxmove = ev->data2;
joyymove = ev->data3;

joyxside = ev->data1; /// cosmito : joyxside is a trick for doing strafe in lsdldoom

/// cosmito : note: in lsdldoom, for strafe support joybuttons aren't set. only this is made.
// case ev_joystick:
// joyxside = ev->data1; /// cosmito : joyxside is a trick for doing strafe in lsdldoom
// joyxmove = ev->data2;
// joyymove = ev->data3;

return true; // eat events

default:
Expand Down
63 changes: 50 additions & 13 deletions i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ extern SDL_Joystick *joystick; // cosmito : shared between i_video.c and i_
// According to Dave Taylor, it still is a bonehead thing
// to use ....
static int multiply=1;

static int joy_x=0, joy_y=0;
static int strafe_x=0; /// cosmito

#define JOYVAL 5000

Expand Down Expand Up @@ -145,6 +147,7 @@ void I_GetEvent(SDL_Event *Event)
{
Uint8 buttonstate;
event_t event;

DOMULTITASK;
//printf("Event->type: %i\n", Event->type);

Expand Down Expand Up @@ -174,8 +177,9 @@ DOMULTITASK;
event.data1 = KEY_ESCAPE;
break;

//case 4: // 'Select' PS2 button
// break;
case 4: // 'Select' PS2 button
event.data1 = KEY_TAB; // activates the map
break;
case 5: // 'Start' PS2 button
event.data1 = KEY_ENTER;
break;
Expand All @@ -196,8 +200,8 @@ DOMULTITASK;
event.data1 = SDLK_SPACE;
break;

case 10: // 'Analog Left click' PS2 button
event.data1 = KEY_TAB;
//case 10: /// Using dlanor suggestion : It's easy to knock off this button during gameplay. // 'Analog Left click' PS2 button
// event.data1 = KEY_TAB;
break;

case 11: // 'Analog Right click' PS2 button
Expand Down Expand Up @@ -230,7 +234,9 @@ DOMULTITASK;
case 3:
event.data1 = KEY_ESCAPE;
break;

case 4: // 'Select' PS2 button
event.data1 = KEY_TAB;
break;
case 5: // 'Start' PS2 button
event.data1 = KEY_ENTER;
break;
Expand All @@ -251,8 +257,8 @@ DOMULTITASK;
event.data1 = SDLK_SPACE;
break;

case 10: // 'Analog Left click' PS2 button
event.data1 = KEY_TAB;
//case 10: // 'Analog Left click' PS2 button
// event.data1 = KEY_TAB;
break;

case 11: // 'Analog Right click' PS2 button
Expand All @@ -269,18 +275,21 @@ DOMULTITASK;

case SDL_JOYAXISMOTION:
{
//printf(" event.jaxis.axis : %i value: %i\n", Event->jaxis.axis, Event->jaxis.value);


if( Event->jaxis.axis == 0)
{
joy_x = 0;

if( (Event->jaxis.value > JOYVAL) )
{
joy_x = 1;
//printf(" RIGHT\n");
}
else
if( ( Event->jaxis.value < -JOYVAL) )
joy_x = -1;
{
joy_x = -1;
//printf("LEFT\n");
}
}

if( Event->jaxis.axis == 1)
Expand All @@ -294,10 +303,38 @@ DOMULTITASK;
joy_y = -1;
}

/// strafe with right analog stick
if( Event->jaxis.axis == 2)
{
//event.data1 = 0;

Sint16 val = Event->jaxis.value / 3000;
//printf(" event.jaxis.axis: %i val: %i\n", Event->jaxis.axis, val /*Event->jaxis.value*/);

if (abs(val) < 3) // eixo do strafe. se modulo < 3, nao move
{
strafe_x = 0;
//event.data1 = 0; // se positivo, direita
}
else if ( val > 0 ) // se negativo, esquerda
{
strafe_x = 1;
//event.data1 = 1;
//1printf(" strafe DIR\n");
}
else
{
strafe_x = -1;
//event.data1 = -1;
//1printf(" strafe ESQ\n");
}
}

event.data1 = strafe_x;
event.data2 = joy_x;
event.data3 = joy_y;
event.type = ev_joystick;

//printf("D_PostEvent *%d\n", event.data1);
D_PostEvent(&event);

} break;
Expand Down Expand Up @@ -468,7 +505,7 @@ void I_StartTic (void)
while ( SDL_PollEvent(&Event) )
I_GetEvent(&Event);

//I_PollJoystick(); // cosmito : from lsdldoom, PS2 port
//I_PollJoystick(); // cosmito : from lsdldoom, PS2 port. Not needed and not implemented.
}

//
Expand Down
Binary file modified ps2sdldoom_VS2005/ps2sdldoom_VS2005.suo
Binary file not shown.

0 comments on commit 58ba3d8

Please sign in to comment.