Skip to content

Commit 58ba3d8

Browse files
author
Pedro Duarte
committed
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.
1 parent c9bd49c commit 58ba3d8

File tree

5 files changed

+139
-60
lines changed

5 files changed

+139
-60
lines changed

Whatsthis.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
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).
1+
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).
22

33
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.
44

@@ -13,14 +13,15 @@ Circle : p / Next weapon
1313
Triangle : Escape
1414
L1 : n
1515
L2 : y
16-
r1 : Fire
17-
r2 : Space / Open doors
16+
R1 : Fire
17+
R2 : Space / Open doors
1818

1919
Start : Enter
20+
Select : Map
2021

21-
Analog Left click : Map
2222
Analog Right click: Brightness (gamma)
2323

24+
2425
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.
2526

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

49+
31/05/2009 - v1.0.4.0
50+
- 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.
51+
4852
01/05/2009 - v1.0.3.0
4953
- 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.
5054
- The Quit option menu now boots back to the OSD PS2 Browser

d_main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,13 @@ void IdentifyVersion (void)
601601
#ifdef _EE
602602
//doomwaddir = "";
603603
//doomwaddir = "mass:";
604+
//printf(">>>>>>>>>>>>>>> myargv[0] %s:\n", myargv[0]);
605+
//printf(">>>>>>>>>>>>>>> GetElfFilename :\n");
604606
GetElfFilename(myargv[0], deviceName, fullPath, elfFilename);
607+
//printf(">>>>>>>>>>>>>>> deviceName %s, fullPath %s, elfFilename %s\n", deviceName, fullPath, elfFilename);
605608
doomwaddir = fullPath;
609+
//scr_printf("myargv[0] = %s\n", myargv[0]);
610+
//printf("%s\n", doomwaddir);
606611
#else
607612
if (!doomwaddir)
608613
doomwaddir = "./";

g_game.c

Lines changed: 76 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ int dclicks2;
203203
// joystick values are repeated
204204
int joyxmove;
205205
int joyymove;
206+
207+
static int joyxside; /// cosmito : for strafe
208+
206209
boolean joyarray[5];
207210
boolean* joybuttons = &joyarray[1]; // allow [-1]
208211

@@ -280,59 +283,70 @@ void G_BuildTiccmd (ticcmd_t* cmd)
280283
// let movement keys cancel each other out
281284
if (strafe)
282285
{
283-
if (gamekeydown[key_right])
284-
{
285-
// fprintf(stderr, "strafe right\n");
286-
side += sidemove[speed];
287-
}
288-
if (gamekeydown[key_left])
289-
{
290-
// fprintf(stderr, "strafe left\n");
291-
side -= sidemove[speed];
292-
}
293-
if (joyxmove > 0)
294-
side += sidemove[speed];
295-
if (joyxmove < 0)
296-
side -= sidemove[speed];
286+
/// lsdldoom strafe nao usa isto
287+
if (gamekeydown[key_right])
288+
{
289+
// fprintf(stderr, "strafe right\n");
290+
side += sidemove[speed];
291+
}
292+
if (gamekeydown[key_left])
293+
{
294+
// fprintf(stderr, "strafe left\n");
295+
side -= sidemove[speed];
296+
}
297+
if (joyxmove > 0)
298+
side += sidemove[speed];
299+
if (joyxmove < 0)
300+
side -= sidemove[speed];
297301

298302
}
299303
else
300304
{
301-
if (gamekeydown[key_right])
302-
cmd->angleturn -= angleturn[tspeed];
303-
if (gamekeydown[key_left])
304-
cmd->angleturn += angleturn[tspeed];
305-
if (joyxmove > 0)
306-
cmd->angleturn -= angleturn[tspeed];
307-
if (joyxmove < 0)
308-
cmd->angleturn += angleturn[tspeed];
305+
if (gamekeydown[key_right])
306+
cmd->angleturn -= angleturn[tspeed];
307+
if (gamekeydown[key_left])
308+
cmd->angleturn += angleturn[tspeed];
309+
310+
//printf("joy_x = %d\n", joy_x);
311+
312+
if (joyxmove > 0)
313+
{
314+
cmd->angleturn -= angleturn[tspeed];
315+
//printf("angleturn ESQ, joy_x = %d\n", joy_x);
316+
}
317+
if (joyxmove < 0)
318+
{
319+
cmd->angleturn += angleturn[tspeed];
320+
//printf("angleturn DIR, joy_x = %d\n", joy_x);
321+
}
322+
309323
}
310324

311325
if (gamekeydown[key_up])
312326
{
313-
// fprintf(stderr, "up\n");
314-
forward += forwardmove[speed];
327+
// fprintf(stderr, "up\n");
328+
forward += forwardmove[speed];
315329
}
316330
if (gamekeydown[key_down])
317331
{
318-
// fprintf(stderr, "down\n");
319-
forward -= forwardmove[speed];
332+
// fprintf(stderr, "down\n");
333+
forward -= forwardmove[speed];
320334
}
321335
if (joyymove < 0)
322-
forward += forwardmove[speed];
336+
forward += forwardmove[speed];
323337
if (joyymove > 0)
324-
forward -= forwardmove[speed];
338+
forward -= forwardmove[speed];
325339
if (gamekeydown[key_straferight])
326-
side += sidemove[speed];
340+
side += sidemove[speed];
327341
if (gamekeydown[key_strafeleft])
328-
side -= sidemove[speed];
342+
side -= sidemove[speed];
329343

330344
// buttons
331345
cmd->chatchar = HU_dequeueChatChar();
332346

333347
if (gamekeydown[key_fire] || mousebuttons[mousebfire]
334-
|| joybuttons[joybfire])
335-
cmd->buttons |= BT_ATTACK;
348+
|| joybuttons[joybfire])
349+
cmd->buttons |= BT_ATTACK;
336350

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

433447
forward += mousey;
434448
if (strafe)
435-
side += mousex*2;
449+
side += mousex*2;
436450
else
437-
cmd->angleturn -= mousex*0x8;
451+
cmd->angleturn -= mousex*0x8;
438452

439453
mousex = mousey = 0;
454+
455+
/// cosmito : from lsdldoom strafe support
456+
if ( joyxside > 0 )
457+
{
458+
side += sidemove[speed];
459+
}
460+
if ( joyxside < 0 )
461+
{
462+
side -= sidemove[speed];
463+
}
440464

441465
if (forward > MAXPLMOVE)
442-
forward = MAXPLMOVE;
466+
forward = MAXPLMOVE;
443467
else if (forward < -MAXPLMOVE)
444-
forward = -MAXPLMOVE;
468+
forward = -MAXPLMOVE;
445469
if (side > MAXPLMOVE)
446-
side = MAXPLMOVE;
470+
side = MAXPLMOVE;
447471
else if (side < -MAXPLMOVE)
448-
side = -MAXPLMOVE;
472+
side = -MAXPLMOVE;
449473

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

453477
// special buttons
454478
if (sendpause)
@@ -609,12 +633,21 @@ boolean G_Responder (event_t* ev)
609633
return true; // eat events
610634

611635
case ev_joystick:
612-
joybuttons[0] = ev->data1 & 1;
613-
joybuttons[1] = ev->data1 & 2;
614-
joybuttons[2] = ev->data1 & 4;
615-
joybuttons[3] = ev->data1 & 8;
636+
//joybuttons[0] = ev->data1 & 1; /// cosmito : might interefere with strafe info, so it's commented
637+
//joybuttons[1] = ev->data1 & 2;
638+
//joybuttons[2] = ev->data1 & 4;
639+
//joybuttons[3] = ev->data1 & 8;
616640
joyxmove = ev->data2;
617641
joyymove = ev->data3;
642+
643+
joyxside = ev->data1; /// cosmito : joyxside is a trick for doing strafe in lsdldoom
644+
645+
/// cosmito : note: in lsdldoom, for strafe support joybuttons aren't set. only this is made.
646+
// case ev_joystick:
647+
// joyxside = ev->data1; /// cosmito : joyxside is a trick for doing strafe in lsdldoom
648+
// joyxmove = ev->data2;
649+
// joyymove = ev->data3;
650+
618651
return true; // eat events
619652

620653
default:

i_video.c

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ extern SDL_Joystick *joystick; // cosmito : shared between i_video.c and i_
5050
// According to Dave Taylor, it still is a bonehead thing
5151
// to use ....
5252
static int multiply=1;
53+
5354
static int joy_x=0, joy_y=0;
55+
static int strafe_x=0; /// cosmito
5456

5557
#define JOYVAL 5000
5658

@@ -145,6 +147,7 @@ void I_GetEvent(SDL_Event *Event)
145147
{
146148
Uint8 buttonstate;
147149
event_t event;
150+
148151
DOMULTITASK;
149152
//printf("Event->type: %i\n", Event->type);
150153

@@ -174,8 +177,9 @@ DOMULTITASK;
174177
event.data1 = KEY_ESCAPE;
175178
break;
176179

177-
//case 4: // 'Select' PS2 button
178-
// break;
180+
case 4: // 'Select' PS2 button
181+
event.data1 = KEY_TAB; // activates the map
182+
break;
179183
case 5: // 'Start' PS2 button
180184
event.data1 = KEY_ENTER;
181185
break;
@@ -196,8 +200,8 @@ DOMULTITASK;
196200
event.data1 = SDLK_SPACE;
197201
break;
198202

199-
case 10: // 'Analog Left click' PS2 button
200-
event.data1 = KEY_TAB;
203+
//case 10: /// Using dlanor suggestion : It's easy to knock off this button during gameplay. // 'Analog Left click' PS2 button
204+
// event.data1 = KEY_TAB;
201205
break;
202206

203207
case 11: // 'Analog Right click' PS2 button
@@ -230,7 +234,9 @@ DOMULTITASK;
230234
case 3:
231235
event.data1 = KEY_ESCAPE;
232236
break;
233-
237+
case 4: // 'Select' PS2 button
238+
event.data1 = KEY_TAB;
239+
break;
234240
case 5: // 'Start' PS2 button
235241
event.data1 = KEY_ENTER;
236242
break;
@@ -251,8 +257,8 @@ DOMULTITASK;
251257
event.data1 = SDLK_SPACE;
252258
break;
253259

254-
case 10: // 'Analog Left click' PS2 button
255-
event.data1 = KEY_TAB;
260+
//case 10: // 'Analog Left click' PS2 button
261+
// event.data1 = KEY_TAB;
256262
break;
257263

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

270276
case SDL_JOYAXISMOTION:
271277
{
272-
//printf(" event.jaxis.axis : %i value: %i\n", Event->jaxis.axis, Event->jaxis.value);
273-
274-
275278
if( Event->jaxis.axis == 0)
276279
{
277280
joy_x = 0;
278281

279282
if( (Event->jaxis.value > JOYVAL) )
283+
{
280284
joy_x = 1;
285+
//printf(" RIGHT\n");
286+
}
281287
else
282288
if( ( Event->jaxis.value < -JOYVAL) )
283-
joy_x = -1;
289+
{
290+
joy_x = -1;
291+
//printf("LEFT\n");
292+
}
284293
}
285294

286295
if( Event->jaxis.axis == 1)
@@ -294,10 +303,38 @@ DOMULTITASK;
294303
joy_y = -1;
295304
}
296305

306+
/// strafe with right analog stick
307+
if( Event->jaxis.axis == 2)
308+
{
309+
//event.data1 = 0;
310+
311+
Sint16 val = Event->jaxis.value / 3000;
312+
//printf(" event.jaxis.axis: %i val: %i\n", Event->jaxis.axis, val /*Event->jaxis.value*/);
313+
314+
if (abs(val) < 3) // eixo do strafe. se modulo < 3, nao move
315+
{
316+
strafe_x = 0;
317+
//event.data1 = 0; // se positivo, direita
318+
}
319+
else if ( val > 0 ) // se negativo, esquerda
320+
{
321+
strafe_x = 1;
322+
//event.data1 = 1;
323+
//1printf(" strafe DIR\n");
324+
}
325+
else
326+
{
327+
strafe_x = -1;
328+
//event.data1 = -1;
329+
//1printf(" strafe ESQ\n");
330+
}
331+
}
332+
333+
event.data1 = strafe_x;
297334
event.data2 = joy_x;
298335
event.data3 = joy_y;
299336
event.type = ev_joystick;
300-
337+
//printf("D_PostEvent *%d\n", event.data1);
301338
D_PostEvent(&event);
302339

303340
} break;
@@ -468,7 +505,7 @@ void I_StartTic (void)
468505
while ( SDL_PollEvent(&Event) )
469506
I_GetEvent(&Event);
470507

471-
//I_PollJoystick(); // cosmito : from lsdldoom, PS2 port
508+
//I_PollJoystick(); // cosmito : from lsdldoom, PS2 port. Not needed and not implemented.
472509
}
473510

474511
//
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)