annotate sgoex.c @ 16:5e10d43156bd

Makefile fix.
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Wed, 15 Dec 2010 19:06:42 +0900
parents 435ac1cdb64e
children 00c3272a801f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /*
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 スプライト管理関数
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 */
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 //#include<libps.h>
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include <stdio.h>
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include <SDL.h>
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #include "SDL_image.h"
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #include "SDL_opengl.h"
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #include "texture.h"
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 #include "object.h"
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #include "tree_controll.h"
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 #include "sgoex.h"
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #include "trace.h"
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 #include "syokika.h"
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 #include "LoadSprite.h"
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 #define OT_LENGTH 1 /* オーダリングテーブル */
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 #define MAXOBJ 320 /*スプライト表示上限 */
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #define TRUE 1
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #define FALSE 0
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 //static u_short tpage;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 //static SDL_Rect rect;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 //static int nActiveBuff; /*ばふぁ */
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 // int i; /* Multi-purpose */
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 //static int pageno;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 //static int padd;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 static const int sgo_tpx[12] =
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 { 0, 64, 128, 192, 256, 320, 0, 64, 128, 192, 256, 320 };
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 static const int sgo_tpy[12] = { 0, 0, 0, 0, 0, 0, 256, 256, 256, 256, 256, 256 };
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 /* sgo.h 独自の変数形 */
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 SpriteTable sptable[DEFOBJ];
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 // static SpriteView spview[MAXOBJ];
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 #define IMAGE_ADJUSTMENT (0)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 /**
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 * 一つの画像をpageno(page number)で区切るtexture_page_offsetで
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 * pagenoに対応した領域のx,yを用意しておく。PlayStationではpageno
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 * で区切る必要があったのだろうが、PS2では全く意味はなさない。
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 */
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 static const struct texture_page_offset {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 int x;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 int y;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 } texpage_offset[] = {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 {0, 0}, {128 + IMAGE_ADJUSTMENT, 0}, {256 + IMAGE_ADJUSTMENT, 0}, {384 + IMAGE_ADJUSTMENT, 0}};
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 /*-------------------------------------------------------------
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 関数プロトタイプ
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 ---------------------------------------------------------------*/
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 void DefSpriteEx(int number, short middlex, short middley)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 sptable[number].mx = middlex;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 sptable[number].my = middley;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 void SDL_GL_Enter2DMode()
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 // SDL_Surface *sc = SDL_GetVideoSurface();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 /* Note, there may be other things you need to change,
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 depending on how you have your OpenGL state set up.
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 */
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 glPushAttrib(GL_ENABLE_BIT);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 glDisable(GL_DEPTH_TEST);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 glDisable(GL_CULL_FACE);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 glEnable(GL_TEXTURE_2D);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 /* This allows alpha blending of 2D textures with the scene */
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 glEnable(GL_BLEND);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 glViewport(0, 0, screen->w, screen->h);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 glMatrixMode(GL_PROJECTION);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 glPushMatrix();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 glLoadIdentity();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 glMatrixMode(GL_MODELVIEW);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 glPushMatrix();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 glLoadIdentity();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 // glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 void SDL_GL_Leave2DMode()
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 glMatrixMode(GL_MODELVIEW);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 glPopMatrix();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 glMatrixMode(GL_PROJECTION);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 glPopMatrix();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 glPopAttrib();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 static int power_of_two(int input)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 int value = 1;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 while ( value < input ) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 value <<= 1;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 return value;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 void DefSprite(int number, const char *name, float w, float h, int color, OBJECT *obj)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 SURFACE *surfaces;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 surfaces = search_node(obj, name);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 if(surfaces == NULL)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 fprintf(stderr, "can't get node\n");
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 printf("%s", name);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 SDL_Quit();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 exit(1);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 sptable[number].w = w;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 sptable[number].h = h;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 sptable[number].color = (color & 32);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 sptable[number].mx = w / 2;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 sptable[number].my = h / 2;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 sptable[number].tex_w = power_of_two(sptable[number].w);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 sptable[number].tex_h = power_of_two(sptable[number].h);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 texMinX[number] = 0.0f;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 texMinY[number] = 0.0f;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 texMaxX[number] = (GLfloat)sptable[number].w / sptable[number].tex_w;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 texMaxY[number] = (GLfloat)sptable[number].h / sptable[number].tex_h;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 printf("texMaxX = %f, w = %d, tex_w = %d\n",
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 texMaxX[number], sptable[number].w, sptable[number].tex_w);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 sptable[number].texture = surfaces->texture;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 void PutSprite(int zorder, short x, short y, int number)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 glBindTexture(GL_TEXTURE_2D, (GLuint)sptable[number].texture);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 glEnable(GL_BLEND);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 glBegin(GL_QUADS);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 glTexCoord2f(texMinX[number],texMinY[number]); glVertex2i((GLuint)x, (GLuint)y );
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 glTexCoord2f(texMinX[number],texMaxY[number]); glVertex2i((GLuint)x, (GLuint)(y+sptable[number].tex_h) );
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 glTexCoord2f(texMaxX[number],texMaxY[number]); glVertex2i((GLuint)(x+sptable[number].tex_w), (GLuint)(y+sptable[number].tex_h));
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 glTexCoord2f(texMaxX[number],texMinY[number]); glVertex2i((GLuint)(x+sptable[number].tex_w), (GLuint)y);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 glEnd();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 glDisable(GL_BLEND);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 void PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 SpriteTable *m = &sptable[number];
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 x -= m->w;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 y -= m->h;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 SDL_GL_Enter2DMode();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 glEnable(GL_TEXTURE_2D);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 glEnable(GL_BLEND);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 glBindTexture(GL_TEXTURE_2D, (GLuint)sptable[number].texture);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 glTranslatef(x + m->w/2, y + m->h/2, 0.0);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 glRotatef(angle, 0.0, 0.0, 1.0);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 glScalef(scalex, scaley, 1.0);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 glBegin(GL_TRIANGLE_STRIP);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 glTexCoord2f(texMinX[number], texMinY[number]); glVertex2i(-m->w/2, -m->h/2);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 glTexCoord2f(texMaxX[number], texMinY[number]); glVertex2i( m->w/2, -m->h/2);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 glTexCoord2f(texMinX[number], texMaxY[number]); glVertex2i(-m->w/2, m->h/2);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 glTexCoord2f(texMaxX[number], texMaxY[number]); glVertex2i( m->w/2, m->h/2);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 glEnd();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 glDisable(GL_TEXTURE_2D);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 glDisable(GL_BLEND);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 SDL_GL_Leave2DMode();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 // SDL_GL_SwapBuffers();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 struct SGO_PAD pad[2];
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 #ifdef ENABLE_TRACEMODE
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 extern int runmode;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 #endif //ENABLE_TRACEMODE
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 /* コントローラ状態の読み込み */
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 void Pad(SDL_Joystick *joy)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 Sint16 axis;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
204
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 SDL_JoystickUpdate();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 if(SDL_JoystickGetButton(joy,PS2_CROSS)==SDL_PRESSED)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 pad[0].k0++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 else
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 pad[0].k0=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 if(SDL_JoystickGetButton(joy,PS2_CIRCLE)==SDL_PRESSED)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 pad[0].k1++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 else
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 pad[0].k1=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
216
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 if(SDL_JoystickGetButton(joy,PS2_SQUARE)==SDL_PRESSED)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 pad[0].k3++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 else
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 pad[0].k3=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
221
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 if(SDL_JoystickGetButton(joy,PS2_TRIANGLE)==SDL_PRESSED)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 pad[0].k4++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 else
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 pad[0].k4=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 if(SDL_JoystickGetButton(joy,PS2_L1)==SDL_PRESSED)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 pad[0].l1++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 else
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 pad[0].l1=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 if(SDL_JoystickGetButton(joy,PS2_R1)==SDL_PRESSED)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 pad[0].r1++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 else
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 pad[0].r1=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 if(SDL_JoystickGetButton(joy,PS2_L2)==SDL_PRESSED)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 pad[0].l2++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 else
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 pad[0].l2=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
241
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 if(SDL_JoystickGetButton(joy,PS2_R2)==SDL_PRESSED)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 pad[0].r2++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 else
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 pad[0].r2=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 if(SDL_JoystickGetButton(joy,PS2_START)==SDL_PRESSED)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 pad[0].st++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 else
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 pad[0].st=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 if(SDL_JoystickGetButton(joy,PS2_SELECT)==SDL_PRESSED)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 pad[0].se++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 else
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 pad[0].se=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 if(SDL_JoystickGetButton(joy,PS2_L3)==SDL_PRESSED)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 pad[0].l3++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 else
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 pad[0].l3=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 if(SDL_JoystickGetButton(joy,PS2_R3)==SDL_PRESSED)
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 pad[0].r3++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 else
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 pad[0].r3=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
266 //x
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 axis=SDL_JoystickGetAxis(joy,0);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 if(axis>=3200){
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 pad[0].left=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 pad[0].right++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 else if(axis<=-3200){
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 pad[0].right=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 pad[0].left++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 pad[0].right=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 pad[0].left=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 //y
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 axis=SDL_JoystickGetAxis(joy,1);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 if(axis>=3200){
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 pad[0].up=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 pad[0].down++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 else if(axis<=-3200){
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 pad[0].down=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 pad[0].up++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 pad[0].down=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 pad[0].up=0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 if ((pad[0].l1 != 0) && (pad[0].r1 != 0) &&
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 (pad[0].l2 != 0) && (pad[0].r2 != 0) &&
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 (pad[0].st != 0) && (pad[0].se != 0)) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 pad[0].quit = 1;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 pad[0].quit = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 void keybord()
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 SDL_PumpEvents();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 Uint8 *keys = SDL_GetKeyState(NULL);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
310
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 if (keys[SDLK_UP]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 pad[0].up++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 pad[0].up = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 if (keys[SDLK_DOWN]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 pad[0].down++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 pad[0].down = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
321
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 if (keys[SDLK_RIGHT]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
323 pad[0].right++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 pad[0].right = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
327
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 if (keys[SDLK_LEFT]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 pad[0].left++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
331 pad[0].left = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
332 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
333
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 if (keys[SDLK_a]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 pad[0].k0++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 pad[0].k0 = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
338 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
339
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
340 if (keys[SDLK_z]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 pad[0].k1++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 pad[0].k1 = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
345
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
346 if (keys[SDLK_s]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
347 pad[0].k3++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
348 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 pad[0].k3 = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
350 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
351
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
352 if (keys[SDLK_x]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 pad[0].k4++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 pad[0].k4 = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
357
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 if (keys[SDLK_r]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 pad[0].r2++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
360 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
361 pad[0].r2 = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
363
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
364 if (keys[SDLK_e]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
365 pad[0].r1++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
366 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
367 pad[0].r1 = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
368 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
369
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
370 if (keys[SDLK_w]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 pad[0].l1++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
372 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 pad[0].l1 = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
375
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 if (keys[SDLK_q]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 pad[0].l2++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 pad[0].l2 = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
381
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 // START ボタンは Return が似合う気がする
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 //if(keys[SDLK_1])
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 if (keys[SDLK_RETURN]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 pad[0].st++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 pad[0].st = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
389
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 if (keys[SDLK_2]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
391 pad[0].se++;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 pad[0].se = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
395
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 if (keys[SDLK_ESCAPE]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
397 SDL_Quit();
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
398 exit(1);
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
399 //pad[0].st = 1;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
400 //pad[0].se = 1;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
401 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
402
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 if (keys[SDLK_0]) {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 pad[0].quit = 1;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 } else {
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 pad[0].quit = 0;
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 }
435ac1cdb64e create task dandy directry.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
409