annotate controler.c @ 0:0fae5658fb0b

Initial revision
author gongo
date Thu, 02 Nov 2006 08:55:19 +0000
parents
children b6a1385f19be
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 #ifdef DEMO_CREATE
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
29 if (game.state == GAME_MAIN)
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
30 setPadValue(pad1);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
31 #endif
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
32
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
33 if (pad1 & SJOY_PS2_START) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
34 pad.st += (pad.st > 100) ? 0 : 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
35 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
36 pad.st = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
37 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
38
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
39 if (game.demo_flg == 1) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
40 pad1 = getPadValue();
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
41 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
42
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
43 if (pad1 & SJOY_PS2_SELECT) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
44 pad.se += (pad.se > 100) ? 0 : 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
45 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
46 pad.se = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
47 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
48 if (pad1 & SJOY_PS2_LEFT) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
49 pad.left += (pad.left > 100) ? 0 : 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
50 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
51 pad.left = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
52 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
53 if (pad1 & SJOY_PS2_RIGHT) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
54 pad.right += (pad.right > 100) ? 0 : 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
55 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
56 pad.right = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
57 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
58 if (pad1 & SJOY_PS2_UP) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
59 pad.up += (pad.up > 100) ? 0 : 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
60 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
61 pad.up = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
62 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
63 if (pad1 & SJOY_PS2_DOWN) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
64 pad.down += (pad.down > 100) ? 0 : 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
65 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
66 pad.down = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
67 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
68 if (pad1 & SJOY_PS2_R1) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
69 pad.r1 += (pad.r1 > 100) ? 0 : 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
70 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
71 pad.r1 = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
72 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
73 if (pad1 & SJOY_PS2_R2) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
74 pad.r2 += (pad.r2 > 100) ? 0 : 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
75 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
76 pad.r2 = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
77 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
78 if (pad1 & SJOY_PS2_L1) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
79 pad.l1 += (pad.l1 > 100) ? 0 : 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
80 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
81 pad.l1 = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
82 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
83 if (pad1 & SJOY_PS2_L2) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
84 pad.l2 += (pad.l2 > 100) ? 0 : 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
85 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
86 pad.l2 = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
87 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
88 if (pad1 & SJOY_PS2_CROSS) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
89 pad.cross += (pad.cross > 100) ? 0 : 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
90 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
91 pad.cross = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
92 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
93 if (pad1 & SJOY_PS2_CIRCLE) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
94 pad.circle += (pad.circle > 100) ? 0 : 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
95 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
96 pad.circle = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
97 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
98 if (pad1 & SJOY_PS2_TRIANGLE) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
99 pad.triangle += (pad.triangle > 100) ? 0 : 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
100 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
101 pad.triangle = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
102 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
103 if (pad1 & SJOY_PS2_SQUARE) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
104 pad.square += (pad.square > 100) ? 0 : 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
105 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
106 pad.square = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
107 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
108
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
109 if ( (pad1 & SJOY_PS2_SELECT) && (pad1 & SJOY_PS2_START) &&
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
110 (pad1 & SJOY_PS2_L1) && (pad1 & SJOY_PS2_R1) &&
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
111 (pad1 & SJOY_PS2_L2) && (pad1 & SJOY_PS2_R2)) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
112 return FALSE;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
113 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
114
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
115 return TRUE;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
116 }