0
|
1 /*
|
|
2 * 2006/07/24 16:46:19 sugiyama
|
|
3 */
|
|
4 #include <stdio.h>
|
|
5 #include <stdlib.h>
|
|
6 #include "libps2.h"
|
|
7 #include "ps2util.h"
|
|
8 #include "col.h"
|
|
9 #include "field.h"
|
|
10 #include "car.h"
|
|
11 #include "game.h"
|
|
12 #include "gSprite.h"
|
|
13
|
|
14 #define DEFOBJ 100
|
|
15 #define SPRITE_COL 0x4f
|
|
16 #define SCREEN_HALF_W 320
|
|
17 #define SCREEN_HALF_H 240
|
|
18
|
|
19 static SpriteTable sptable[DEFOBJ];
|
|
20 static ps2utilSprite sp[DEFOBJ]; // 表示スプライト用スタック
|
|
21 static unsigned int sp_counter;
|
|
22 static Bool flag_spriteInited = FALSE; // スプライトロードフラグ
|
|
23
|
|
24 static TEXTURE *sprite_tex;
|
|
25
|
|
26 extern CarPtr car;
|
|
27
|
|
28 void
|
|
29 gSprite_DefSprite(int number, int tx, int ty, int tw, int th)
|
|
30 {
|
|
31 sptable[number].tx = tx;
|
|
32 sptable[number].ty = ty;
|
|
33 sptable[number].tw = tw;
|
|
34 sptable[number].th = th;
|
|
35 }
|
|
36
|
|
37 void
|
|
38 gSprite_PutSprite(int number, int x, int y)
|
|
39 {
|
|
40 ps2utilSprite *p = &sp[sp_counter];
|
|
41
|
|
42 ps2util_sprite_Set_basicAttribute(
|
|
43 p,
|
|
44 (ushort)x, (ushort)y,
|
|
45 (ushort)sptable[number].tw*2, (ushort)sptable[number].th*2,
|
|
46 (ushort)sptable[number].tx, (ushort)sptable[number].ty,
|
|
47 (ushort)sptable[number].tw, (ushort)sptable[number].th,
|
|
48 SPRITE_PRIO_FOREGROUND);
|
|
49
|
|
50 ps2util_sprite_Request(p);
|
|
51 sp_counter++;
|
|
52 }
|
|
53
|
|
54 void
|
|
55 gSprite_PutSpriteEx(int number, int x, int y, float w, float h)
|
|
56 {
|
|
57 ps2utilSprite *p = &sp[sp_counter];
|
|
58
|
|
59 ps2util_sprite_Set_basicAttribute(
|
|
60 p,
|
|
61 (ushort)x, (ushort)y,
|
|
62 (ushort)sptable[number].tw*w, (ushort)sptable[number].th*h,
|
|
63 (ushort)sptable[number].tx, (ushort)sptable[number].ty,
|
|
64 (ushort)sptable[number].tw, (ushort)sptable[number].th,
|
|
65 SPRITE_PRIO_FOREGROUND);
|
|
66
|
|
67 ps2util_sprite_Request(p);
|
|
68 sp_counter++;
|
|
69 }
|
|
70
|
|
71 static void
|
|
72 gSprite_Init_Png(char *texname)
|
|
73 {
|
|
74 if (!(sprite_tex = read_png_file(texname))) {
|
|
75 fprintf(stderr,
|
|
76 "cannot creat texture - init_png().\n");
|
|
77 fflush(stderr);
|
|
78 exit(EXIT_FAILURE);
|
|
79 }
|
|
80
|
|
81 if (ps2util_tex_Set(sprite_tex) == -1) {
|
|
82 fprintf(stderr,
|
|
83 "cannot set texture - init_png().\n");
|
|
84 fflush(stderr);
|
|
85 exit(EXIT_FAILURE);
|
|
86 }
|
|
87
|
|
88 }
|
|
89
|
|
90 static void
|
|
91 gSprite_Create()
|
|
92 {
|
|
93 int i;
|
|
94
|
|
95 for (i=0; i<DEFOBJ; i++) {
|
|
96 if (ps2util_sprite_Create(&sp[i], sprite_tex) == -1) {
|
|
97 fprintf(stderr,
|
|
98 "cannot create sprite No.%d - create_sprite()\n", i);
|
|
99 fflush(stderr);
|
|
100 exit(EXIT_FAILURE);
|
|
101 }
|
|
102 ps2util_sprite_Unuse_alpha(&sp[i]);
|
|
103 }
|
|
104
|
|
105 flag_spriteInited = TRUE;
|
|
106 }
|
|
107
|
|
108 void
|
|
109 gSprite_Init()
|
|
110 {
|
|
111 ps2util_graphic_Init();
|
|
112 gSprite_Init_Png("img/main2.png");
|
|
113 gSprite_Create(); // スプライト生成
|
|
114
|
|
115 /* スプライトの登録 */
|
|
116 gSprite_DefSprite(10, 1, 1, 512, 666); /* タイトル */
|
|
117 gSprite_DefSprite(17, 1, 35, 33, 33); /* 選択マーク */
|
|
118 gSprite_DefSprite(23, 1, 1, 106, 34); /* スピードメーター */
|
|
119 gSprite_DefSprite(24, 51, 40, 18, 20); /* 右矢印 */
|
|
120 gSprite_DefSprite(25, 33, 40, 17, 20); /* 左矢印 */
|
|
121 gSprite_DefSprite(26, 56, 89, 55, 26); /* km/h */
|
|
122 gSprite_DefSprite(27, 62, 62, 39, 26); /* Rap */
|
|
123 gSprite_DefSprite(28, 430, 62, 53, 46); /* 1P */
|
|
124 gSprite_DefSprite(29, 460, 6, 53, 46); /* 2P */
|
|
125 gSprite_DefSprite(51, 333, 116, 165, 140); /* 選択画面の車 */
|
|
126 gSprite_DefSprite(52, 181, 116, 165, 140);
|
|
127 gSprite_DefSprite(53, 12, 116, 165, 140);
|
|
128 gSprite_DefSprite(81, 115, 1, 148, 114); /* 選択画面のコース */
|
|
129 // 本当は (82, 272,...)です。二つ目のコース絵がないので
|
|
130 gSprite_DefSprite(82, 272, 1, 148, 114);
|
|
131 }
|
|
132
|
|
133 static void
|
|
134 gSprite_Clear()
|
|
135 {
|
|
136 int i;
|
|
137
|
|
138 for (i=0; i<DEFOBJ; i++) {
|
|
139 sprite_disappear(&sp[i].attribute);
|
|
140 }
|
|
141 sp_counter = 0;
|
|
142 }
|
|
143
|
|
144 void
|
|
145 gSprite_Draw_Reset()
|
|
146 {
|
|
147 if (flag_spriteInited == TRUE) {
|
|
148 gSprite_Clear();
|
|
149 }
|
|
150 }
|
|
151
|
|
152 void
|
|
153 gSprite_PutSprite_Pause()
|
|
154 {
|
|
155 }
|