annotate controler.c @ 33:8d4fdf454a2f

*** empty log message ***
author gongo
date Sun, 05 Nov 2006 02:49:45 +0000
parents 41d3037c34c8
children a1908b83f8fa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
1 /*
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
2 * $Id$
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
3 */
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
4 #include <stdio.h>
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
5 #include <stdlib.h>
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
6 #include "libps2.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
7 #include "ps2util.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
8 #include "col.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
9 #include "field.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
10 #include "car.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
11 #include "controler.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
12 #include "game.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
13
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
14 SGO_PAD pad;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
15
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
16 #ifdef DEMO_CREATE
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
17 extern void setPadValue(int pad);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
18 #endif
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
19 extern int getPadValue();
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
20
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
21 Bool
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
22 padCheck()
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
23 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
24 int pad1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
25
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
26 pad1 = sjoy_get_ps2_button( JOYPAD_1 );
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
27
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
28 if (pad1 & SJOY_PS2_START) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
29 pad.st += (pad.st < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
30 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
31 pad.st = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
32 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
33
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
34 if (pad1 & SJOY_PS2_SELECT) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
35 pad.se += (pad.se < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
36 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
37 pad.se = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
38 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
39 if (pad1 & SJOY_PS2_LEFT) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
40 pad.left += (pad.left < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
41 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
42 pad.left = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
43 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
44 if (pad1 & SJOY_PS2_RIGHT) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
45 pad.right += (pad.right < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
46 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
47 pad.right = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
48 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
49 if (pad1 & SJOY_PS2_UP) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
50 pad.up += (pad.up < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
51 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
52 pad.up = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
53 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
54 if (pad1 & SJOY_PS2_DOWN) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
55 pad.down += (pad.down < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
56 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
57 pad.down = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
58 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
59 if (pad1 & SJOY_PS2_R1) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
60 pad.r1 += (pad.r1 < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
61 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
62 pad.r1 = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
63 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
64 if (pad1 & SJOY_PS2_R2) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
65 pad.r2 += (pad.r2 < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
66 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
67 pad.r2 = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
68 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
69 if (pad1 & SJOY_PS2_L1) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
70 pad.l1 += (pad.l1 < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
71 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
72 pad.l1 = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
73 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
74 if (pad1 & SJOY_PS2_L2) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
75 pad.l2 += (pad.l2 < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
76 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
77 pad.l2 = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
78 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
79 if (pad1 & SJOY_PS2_CROSS) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
80 pad.cross += (pad.cross < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
81 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
82 pad.cross = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
83 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
84 if (pad1 & SJOY_PS2_CIRCLE) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
85 pad.circle += (pad.circle < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
86 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
87 pad.circle = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
88 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
89 if (pad1 & SJOY_PS2_TRIANGLE) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
90 pad.triangle += (pad.triangle < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
91 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
92 pad.triangle = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
93 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
94 if (pad1 & SJOY_PS2_SQUARE) {
2
b6a1385f19be *** empty log message ***
gongo
parents: 0
diff changeset
95 pad.square += (pad.square < 2) ? 1 : 0;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
96 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
97 pad.square = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
98 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
99
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
100 if ( (pad1 & SJOY_PS2_SELECT) && (pad1 & SJOY_PS2_START) &&
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
101 (pad1 & SJOY_PS2_L1) && (pad1 & SJOY_PS2_R1) &&
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
102 (pad1 & SJOY_PS2_L2) && (pad1 & SJOY_PS2_R2)) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
103 return FALSE;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
104 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
105
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
106 return TRUE;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
107 }