1 /*
2 * sprite.c: ���ץ饤�ȴ��ܳƼ����
3 *
4 * Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
5 * 1998- <masaki-c@is.aist-nara.ac.jp>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22 /* $Id: sprite.c,v 1.5 2003/11/16 15:29:52 chikama Exp $ */
23
24 #include "config.h"
25
26 #include <stdio.h>
27 #include <string.h>
28 #include <glib.h>
29
30 #include "portab.h"
31 #include "system.h"
32 #include "ngraph.h"
33 #include "ags.h"
34 #include "nact.h"
35 #include "sact.h"
36 #include "sprite.h"
37 #include "surface.h"
38 #include "sactcg.h"
39 #include "sactsound.h"
40
41 static gint compare_spriteno_smallfirst(gconstpointer a, gconstpointer b);
42
43
44 #define sp_assert_no(no) G_STMT_START{ \
45 if ((no) >= SPRITEMAX) { \
46 WARNING("no is too large (should be %d < %d)\n", no, SPRITEMAX); \
47 return NG; \
48 } \
49 }G_STMT_END
50
51 #define sp_assert_null(no) G_STMT_START{ \
52 if (sact.sp[no] == NULL) { \
53 WARNING("sprite %d is NULL\n", no); \
54 return NG; \
55 } \
56 }G_STMT_END
57
58
59 // ���ץ饤�Ȥ��ֹ��˹������뤿��˥ꥹ�Ȥ˽��֤��פ�뤿���callbck
compare_spriteno_smallfirst(gconstpointer a,gconstpointer b)60 static gint compare_spriteno_smallfirst(gconstpointer a, gconstpointer b) {
61 sprite_t *sp1 = (sprite_t *)a;
62 sprite_t *sp2 = (sprite_t *)b;
63
64 if (sp1->no < sp2->no) {
65 return -1;
66 }
67 if (sp1->no > sp2->no) {
68 return 1;
69 }
70 return 0;
71 }
72
73 // �ǥե���Ȥ��ɻ�update
sp_draw_wall(sprite_t * sp)74 static int sp_draw_wall(sprite_t *sp) {
75 int sx, sy, w, h;
76
77 sx = sact.updaterect.x;
78 sy = sact.updaterect.y;
79 w = sact.updaterect.width;
80 h = sact.updaterect.height;
81 gr_fill(sf0, sx, sy, w, h, 0, 0, 0);
82
83 WARNING("do update no=%d, sx=%d, sy=%d, w=%d, h=%d, \n",
84 sp->no, sx, sy, w, h);
85
86 return OK;
87 }
88
89 /**
90 * sprite ��Ϣ�ν����
91 * @param none
92 * @return OK:����, NG:����
93 */
sp_init()94 int sp_init() {
95 int i;
96
97 // DLL�ѥ�å�����ɽ��
98 nact->msgout = smsg_add;
99
100 // mouse/key event handler
101 nact->ags.eventcb = spev_callback;
102
103 // main callback
104 nact->callback = spev_main;
105
106 // ���������ͳ�������ƤΥ��ץ饤�Ȥ餫����������Ƥ���
107 for (i = 0; i < SPRITEMAX; i++) {
108 sact.sp[i] = g_new0(sprite_t, 1);
109 sact.sp[i]->no = i;
110 sact.sp[i]->type = SPRITE_NONE;
111 sact.sp[i]->show = FALSE;
112 }
113
114 // �ɻ�(���ץ饤���ֹ棰)�ϥǥե���Ȥ�
115 sp_set_wall_paper(0);
116
117 // �ɻ�� update�ꥹ�Ȥ��ɲ�
118 sact.updatelist = g_slist_append(sact.updatelist, sact.sp[0]);
119
120 return OK;
121 }
122
123 /**
124 * �������ץ饤�Ȥκ���
125 * @param no: ���ץ饤���ֹ�
126 * @param cg1: 1���ܤ�CG
127 * @param cg2: 2���ܤ�CG (�ʤ�����0)
128 * @param cg3: 3���ܤ�CG (�ʤ�����0)
129 * @param type: ���ץ饤�Ȥμ���
130 */
sp_new(int no,int cg1,int cg2,int cg3,int type)131 int sp_new(int no, int cg1, int cg2, int cg3, int type) {
132 sprite_t *sp;
133
134 sp_assert_no(no);
135
136 sp = sact.sp[no];
137
138 if (sp->type != SPRITE_NONE) {
139 sp_free(no);
140 }
141
142 // �����ꥹ�Ȥ���Ͽ
143 sact.updatelist = g_slist_insert_sorted(sact.updatelist, sp, compare_spriteno_smallfirst);
144
145 sp->type = type;
146 sp->no = no;
147
148 // set�����Ǥ�cg�����Ѥ����(draw���ǤϤʤ�)
149 if (cg1) sp->cg1 = scg_loadcg_no(cg1, TRUE); else sp->cg1 = NULL;
150 if (cg2) sp->cg2 = scg_loadcg_no(cg2, TRUE); else sp->cg2 = NULL;
151 if (cg3) sp->cg3 = scg_loadcg_no(cg3, TRUE); else sp->cg3 = NULL;
152
153 //�����curcg��cg1
154 sp->curcg = sp->cg1;
155
156 sp->show = TRUE; // ������֤�ɽ��
157 sp->blendrate = 255; // �֥���̵��
158 sp->loc.x = 0; // ���ɽ�����֤�(0,0)
159 sp->loc.y = 0;
160 sp->cur = sp->loc;
161
162 // cg1���礭���ץ饤�Ȥ��礭���Ȥ���
163 if (sp->curcg == NULL) {
164 sp->cursize.width = 0;
165 sp->cursize.height = 0;
166 } else {
167 sp->cursize.width = sp->curcg->sf->width;
168 sp->cursize.height = sp->curcg->sf->height;
169 }
170
171 sp->freezed_state = 0; // ���ָ����̵��
172 sp->update = DEFAULT_UPDATE; // default �� update�롼����
173
174 // �ƥ��ץ饤�ȥ�������ν����
175 switch(type) {
176 case SPRITE_SWITCH:
177 sp_sw_setup(sp);
178 break;
179
180 case SPRITE_GETA:
181 case SPRITE_GETB:
182 sp_get_setup(sp);
183 break;
184
185 case SPRITE_PUT:
186 case SPRITE_SWPUT:
187 sp_put_setup(sp);
188 break;
189
190 case SPRITE_ANIME:
191 sp_anime_setup(sp);
192 break;
193 }
194
195 return OK;
196 }
197
198 // ��å��������ץ饤�Ȥκ���
sp_new_msg(int no,int x,int y,int width,int height)199 int sp_new_msg(int no, int x, int y, int width, int height) {
200 sprite_t *sp;
201
202 sp_assert_no(no);
203
204 sp = sact.sp[no];
205
206 if (sp->type != SPRITE_NONE) {
207 sp_free(no);
208 }
209 // �����ꥹ�Ȥ���Ͽ
210 sact.updatelist = g_slist_insert_sorted(sact.updatelist, sp, compare_spriteno_smallfirst);
211
212
213 sp->type = SPRITE_MSG;
214 sp->no = no;
215 sp->show = TRUE; // ������֤�ɽ��
216 sp->blendrate = 255; // �֥���̵��
217 sp->freezed_state = 0; // ���ָ���̵��
218 sp->loc.x = x - sact.origin.x; // ���ɽ������
219 sp->loc.y = y - sact.origin.y;
220 sp->u.msg.dspcur.x = 0; // ʸ�����賫�ϰ���
221 sp->u.msg.dspcur.y = 0;
222 sp->cursize.width = width; // ���ץ饤�Ȥ��礭��
223 sp->cursize.height = height;
224 sp->cur = sp->loc;
225 sp->u.msg.buf = NULL;
226
227 // ʸ�������ѥ����Х�
228 sp->u.msg.canvas = sf_create_surface(width, height, sf0->depth);
229
230 // ���ץ饤�Ⱥ������ѥ�����Хå�
231 sp->update = smsg_update;
232
233 return OK;
234 }
235
236 // �ɻ������
sp_set_wall_paper(int no)237 int sp_set_wall_paper(int no) {
238 sprite_t *sp = sact.sp[0];
239
240 if (sp->curcg) {
241 scg_free_cgobj(sp->curcg);
242 }
243
244 if (no) { // �����CG��ɽ��
245 sp->curcg = scg_loadcg_no(no, TRUE);
246 sp->update = DEFAULT_UPDATE;
247 sp->cursize.width = sp->curcg->sf->width;
248 sp->cursize.height = sp->curcg->sf->height;
249 } else { // ����
250 sp->cursize.width = sf0->width;
251 sp->cursize.height = sf0->height;
252 sp->curcg = NULL;
253 sp->update = sp_draw_wall;
254 }
255
256 sp->type = SPRITE_WP;
257 sp->show = TRUE;
258 sp->blendrate = 255;
259 sp->cur.x = 0;
260 sp->cur.y = 0;
261
262 return OK;
263 }
264
265 // ���Ƥ� sprite ��õ�
sp_free_all()266 int sp_free_all() {
267 int i;
268
269 for (i = 1; i < SPRITEMAX; i++) {
270 sp_free(i);
271 }
272 return OK;
273 }
274
275 // �����sprite ��õ�
sp_free(int no)276 int sp_free(int no) {
277 sprite_t *sp;
278
279 sp_assert_no(no);
280
281 sp = sact.sp[no];
282
283 // ��ư���Ϥ��Ƥ��ʤ����ϥꥹ�Ȥ�����
284 if (!sp->move.moving) {
285 sact.movelist = g_slist_remove(sact.movelist, sp);
286 }
287
288 // CG���֥������Ȥκ��
289 if (sp->cg1) scg_free_cgobj(sp->cg1);
290 if (sp->cg2) scg_free_cgobj(sp->cg2);
291 if (sp->cg3) scg_free_cgobj(sp->cg3);
292
293 // remove���ν���������м¹�
294 if (sp->remove) {
295 sp->remove(sp);
296 }
297
298 // �������ץ饤�Ȥκ��
299 // �����Ǿä�����ޤ�������
300 g_slist_free(sp->expsp);
301 sp->expsp = NULL;
302
303 if (sp->type == SPRITE_MSG) {
304 g_slist_free(sp->u.msg.buf);
305 sf_free(sp->u.msg.canvas);
306 }
307 sact.updatelist = g_slist_remove(sact.updatelist, sp);
308
309 // SACT.Numeral_XXX �ϻĤ��Ƥ���
310 {
311 sprite_t back;
312 memcpy(&(back.numeral), &(sp->numeral), sizeof(sp->numeral));
313 memset(sp, 0, sizeof(sprite_t));
314 sp->type = SPRITE_NONE;
315 sp->no = no;
316 sp->show = FALSE;
317 memcpy(&(sp->numeral), &(back.numeral), sizeof(sp->numeral));
318 }
319 return OK;
320 }
321
322 // ɽ�����֤��ѹ�
sp_set_show(int wNum,int wCount,int sShow)323 int sp_set_show(int wNum, int wCount, int sShow) {
324 int i;
325 boolean oldstate;
326 sprite_t *sp;
327
328 sp_assert_no(wNum);
329
330 for (i = wNum; i < (wNum + wCount); i++) {
331 if (i >= (SPRITEMAX -1)) break;
332 sp = sact.sp[i];
333 oldstate = sp->show;
334
335 sp->show = (sShow == 1 ? TRUE : FALSE);
336 }
337 return OK;
338 }
339
340 // ɽ�����֤�����
sp_set_pos(int wNum,int wX,int wY)341 int sp_set_pos(int wNum, int wX, int wY) {
342 sprite_t *sp;
343
344 sp_assert_no(wNum);
345
346 sp = sact.sp[wNum];
347 sp->loc.x = wX - sact.origin.x;
348 sp->loc.y = wY - sact.origin.y;
349 sp->cur.x = sp->loc.x;
350 sp->cur.y = sp->loc.y;
351 return OK;
352
353 }
354
355 // ���ץ饤�Ȥΰ�ư
sp_set_move(int wNum,int wX,int wY)356 int sp_set_move(int wNum, int wX, int wY) {
357 sprite_t *sp;
358
359 sp_assert_no(wNum);
360
361 sp = sact.sp[wNum];
362 sp->move.to.x = wX - sact.origin.x;
363 sp->move.to.y = wY - sact.origin.y;
364
365 if (sp->move.time == 0) {
366 sp->move.time = -1;
367 sp->move.speed = 100;
368 }
369
370 sp->cur = sp->loc;
371
372 // move���륹�ץ饤�ȥꥹ�Ȥ���Ͽ
373 // �ºݤ� move �Ϥ���Τ� ~SP_DRAW(sp_update_all)���ƤФ줿�Ȥ�
374 sact.movelist = g_slist_append(sact.movelist, sp);
375
376 return OK;
377 }
378
379 // ���ץ饤�Ȱ�ư���֤�����
sp_set_movetime(int wNum,int wTime)380 int sp_set_movetime(int wNum, int wTime) {
381 sp_assert_no(wNum);
382
383 sact.sp[wNum]->move.time = wTime * 10;
384 return OK;
385 }
386
387 // ���ץ饤�Ȱ�ư®�٤�����
sp_set_movespeed(int wNum,int wTime)388 int sp_set_movespeed(int wNum, int wTime) {
389 sp_assert_no(wNum);
390
391 if (wTime == 0) wTime = 1;
392
393 sact.sp[wNum]->move.speed = wTime ;
394 sact.sp[wNum]->move.time = -1;
395
396 return OK;
397 }
398
399 // Z���������Ȥ��˱������ץ饤�Ȥ���Ͽ
sp_add_zkey_hidesprite(int wNum)400 int sp_add_zkey_hidesprite(int wNum) {
401 sprite_t *sp;
402
403 sp_assert_no(wNum);
404 sp = sact.sp[wNum];
405
406 // ��Ͽ�����Ǥޤ��������Ƥ��ʤ����ץ饤�Ȥϱ����ʤ�
407 // �����륯�쥤��Ǥޤ����Τ����ä��Τ����
408 // if (sp->type == SPRITE_NONE) return NG;
409
410 sact.sp_zhide = g_slist_append(sact.sp_zhide, sp);
411 return OK;
412 }
413
414 // �����Ͽ�������ץ饤�Ȥκ��
sp_clear_zkey_hidesprite_all()415 int sp_clear_zkey_hidesprite_all() {
416 g_slist_free(sact.sp_zhide);
417 sact.sp_zhide = NULL;
418 return OK;
419 }
420
421 // ���ץ饤�Ⱦ��֤θDz�
sp_freeze_sprite(int wNum,int wIndex)422 int sp_freeze_sprite(int wNum, int wIndex) {
423 sprite_t *sp;
424 void *oldstate;
425
426 sp_assert_no(wNum);
427
428 sp = sact.sp[wNum];
429 sp->freezed_state = wIndex;
430
431 oldstate = (void *)sp->curcg;
432 switch(wIndex) {
433 case 1:
434 sp->curcg = sp->cg1; break;
435 case 2:
436 sp->curcg = sp->cg2; break;
437 case 3:
438 sp->curcg = sp->cg3; break;
439 }
440 return OK;
441 }
442
443 // ��ǸDz��������֤β��
sp_thaw_sprite(int wNum)444 int sp_thaw_sprite(int wNum) {
445 sp_assert_no(wNum);
446
447 sact.sp[wNum]->freezed_state = 0;
448 return OK;
449 }
450
451 // SP_QUAKE���ɤ餹���ץ饤�Ȥ���Ͽ
sp_add_quakesprite(int wNum)452 int sp_add_quakesprite(int wNum) {
453 sp_assert_no(wNum);
454
455 sact.sp_quake = g_slist_append(sact.sp_quake, sact.sp[wNum]);
456 return OK;
457 }
458
459 // �����Ͽ�������ץ饤�Ȥκ��
sp_clear_quakesprite_all()460 int sp_clear_quakesprite_all() {
461 g_slist_free(sact.sp_quake);
462 sact.sp_quake = NULL;
463 return OK;
464 }
465
466 // ���˥����ץ饤�Ȥδֳ֤�����
sp_set_animeinterval(int wNum,int wTime)467 int sp_set_animeinterval(int wNum, int wTime) {
468 sp_assert_no(wNum);
469
470 if (sact.sp[wNum]->type != SPRITE_ANIME) return NG;
471
472 sact.sp[wNum]->u.anime.interval = wTime * 10;
473
474 return OK;
475 }
476
477 // ���ץ饤�ȤΥ֥���Ψ������
sp_set_blendrate(int wNum,int wCount,int rate)478 int sp_set_blendrate(int wNum, int wCount, int rate) {
479 int i;
480 sprite_t *sp;
481
482 sp_assert_no(wNum);
483
484 for (i = wNum; i < (wNum + wCount); i++) {
485 if (i >= (SPRITEMAX -1)) break;
486 sp = sact.sp[i];
487 sp->blendrate = rate;
488 }
489
490 return OK;
491 }
492
493 // ���ץ饤�Ȥ� create ����Ƥ��뤫�ɤ����μ���
sp_query_isexist(int wNum,int * ret)494 int sp_query_isexist(int wNum, int *ret) {
495 if (wNum >= SPRITEMAX) goto errexit;
496 if (sact.sp[wNum]->type == SPRITE_NONE) goto errexit;
497
498 *ret = 1;
499 return OK;
500
501 errexit:
502 *ret = 0;
503 return NG;
504 }
505
506 // ���ץ饤�ȤΥ����פȲ��֤�CG�����åȤ���Ƥ��뤫�μ���
sp_query_info(int wNum,int * vtype,int * vcg1,int * vcg2,int * vcg3)507 int sp_query_info(int wNum, int *vtype, int *vcg1, int *vcg2, int *vcg3) {
508 sprite_t *sp;
509
510 if (wNum >= SPRITEMAX) goto errexit;
511
512 sp = sact.sp[wNum];
513 if (sp->type == SPRITE_NONE) goto errexit;
514
515 *vtype = sp->type;
516 *vcg1 = sp->cg1 ? sp->cg1->no : 0;
517 *vcg2 = sp->cg2 ? sp->cg2->no : 0;
518 *vcg3 = sp->cg3 ? sp->cg3->no : 0;
519
520 return OK;
521
522 errexit:
523 *vtype = 0;
524 *vcg1 = 0;
525 *vcg2 = 0;
526 *vcg3 = 0;
527 return NG;
528 }
529
530 // ���ץ饤�Ȥ�ɽ�����֤μ���
sp_query_show(int wNum,int * vShow)531 int sp_query_show(int wNum, int *vShow) {
532 if (wNum >= SPRITEMAX) goto errexit;
533 if (sact.sp[wNum]->type == SPRITE_NONE) goto errexit;
534
535 *vShow = sact.sp[wNum]->show ? 1: 0;
536 return OK;
537
538 errexit:
539 *vShow = 0;
540 return NG;
541 }
542
543 // ���ץ饤�Ȥ�ɽ�����֤μ���
sp_query_pos(int wNum,int * vx,int * vy)544 int sp_query_pos(int wNum, int *vx, int *vy) {
545 if (wNum >= SPRITEMAX) goto errexit;
546 if (sact.sp[wNum]->type == SPRITE_NONE) goto errexit;
547
548 *vx = sact.sp[wNum]->loc.x;
549 *vy = sact.sp[wNum]->loc.y;
550 return OK;
551
552 errexit:
553 *vx = 0;
554 *vy = 0;
555 return NG;
556 }
557
558 // ���ץ饤�Ȥ��礭���μ���
sp_query_size(int wNum,int * vw,int * vh)559 int sp_query_size(int wNum, int *vw, int *vh) {
560 sprite_t *sp;
561
562 if (wNum >= SPRITEMAX) goto errexit;
563
564 sp = sact.sp[wNum];
565
566 if (sp->type == SPRITE_NONE) goto errexit;
567
568 *vw = sp->cursize.width;
569 *vh = sp->cursize.height;
570
571 return OK;
572
573 errexit:
574 *vw = 0;
575 *vh = 0;
576 return NG;
577 }
578
579 // �ƥ����ȥ��ץ饤�Ȥθ��ߤ�ʸ��ɽ�����֤μ���
sp_query_textpos(int wNum,int * vx,int * vy)580 int sp_query_textpos(int wNum, int *vx, int *vy) {
581 if (wNum >= SPRITEMAX) goto errexit;
582 if (sact.sp[wNum]->type != SPRITE_MSG) goto errexit;
583
584 *vx = sact.sp[wNum]->u.msg.dspcur.x;
585 *vy = sact.sp[wNum]->u.msg.dspcur.y;
586 return OK;
587
588 errexit:
589 *vx = 0;
590 *vy = 0;
591 return NG;
592 }
593
594 // NumeralXXX��CG�Υ��å�
sp_num_setcg(int nNum,int nIndex,int nCG)595 int sp_num_setcg(int nNum, int nIndex, int nCG) {
596 sp_assert_no(nNum);
597
598 sact.sp[nNum]->numeral.cg[nIndex] = nCG;
599
600 return OK;
601 }
602
603 // NumeralXXX��CG���
sp_num_getcg(int nNum,int nIndex,int * vCG)604 int sp_num_getcg(int nNum, int nIndex, int *vCG) {
605 sp_assert_no(nNum);
606
607 *vCG = sact.sp[nNum]->numeral.cg[nIndex];
608
609 return OK;
610 }
611
612 // NumeralXXX�ΰ��֤Υ��å�
sp_num_setpos(int nNum,int nX,int nY)613 int sp_num_setpos(int nNum, int nX, int nY) {
614 sp_assert_no(nNum);
615
616 sact.sp[nNum]->numeral.pos.x = nX;
617 sact.sp[nNum]->numeral.pos.y = nY;
618
619 return OK;
620 }
621
622 // NumeralXXX�ΰ��֤μ���
sp_num_getpos(int nNum,int * vX,int * vY)623 int sp_num_getpos(int nNum, int *vX, int *vY) {
624 sp_assert_no(nNum);
625
626 *vX = sact.sp[nNum]->numeral.pos.x;
627 *vY = sact.sp[nNum]->numeral.pos.y;
628
629 return OK;
630 }
631
632 // NumeralXXX�Υ��ѥ�Υ��å�
sp_num_setspan(int nNum,int nSpan)633 int sp_num_setspan(int nNum, int nSpan) {
634 sp_assert_no(nNum);
635
636 sact.sp[nNum]->numeral.span = nSpan;
637
638 return OK;
639 }
640
641 // NumeralXXX�Υ��ѥ�μ���
sp_num_getspan(int nNum,int * vSpan)642 int sp_num_getspan(int nNum, int *vSpan) {
643 sp_assert_no(nNum);
644
645 *vSpan = sact.sp[nNum]->numeral.span;
646
647 return OK;
648 }
649
650 // ���٤Ƥ��������ץ饤�Ȥκ��
sp_exp_clear()651 int sp_exp_clear() {
652 GSList *node;
653
654 for (node = sact.updatelist; node; node = node->next) {
655 sprite_t *sp = (sprite_t *)node->data;
656 if (sp == NULL) continue;
657 sp_exp_del(sp->no);
658 }
659
660 return OK;
661 }
662
663 // �������ץ饤�Ȥ���Ͽ
sp_exp_add(int nNumSP1,int nNumSP2)664 int sp_exp_add(int nNumSP1, int nNumSP2) {
665 sprite_t *swsp, *expsp;
666 sp_assert_no(nNumSP1);
667 sp_assert_no(nNumSP2);
668
669 swsp = sact.sp[nNumSP1];
670 expsp = sact.sp[nNumSP2];
671
672 swsp->expsp = g_slist_append(swsp->expsp, expsp);
673
674 return OK;
675 }
676
677 // �������ץ饤�Ȥκ��
sp_exp_del(int nNum)678 int sp_exp_del(int nNum) {
679 sprite_t *sp;
680
681 sp_assert_no(nNum);
682
683 sp = sact.sp[nNum];
684
685 g_slist_free(sp->expsp);
686 sp->expsp = NULL;
687
688 return OK;
689 }
690
691 // ���ץ饤�ȥ�����ɤΥ��å�
sp_sound_set(int wNumSP,int wNumWave1,int wNumWave2,int wNumWave3)692 int sp_sound_set(int wNumSP, int wNumWave1, int wNumWave2, int wNumWave3) {
693 sprite_t *sp;
694
695 sp_assert_no(wNumSP);
696
697 sp = sact.sp[wNumSP];
698 sp->numsound1 = wNumWave1;
699 sp->numsound2 = wNumWave2;
700 sp->numsound3 = wNumWave3;
701
702 return OK;
703 }
704
705 // ���٤ƤΥ��ץ饤�ȥ�����ɤν�λ���Ԥ�
sp_sound_wait()706 int sp_sound_wait() {
707 WARNING("NOT IMPLEMENTED\n");
708 return OK;
709 }
710
711 // �ϰϳ���å������Ȥ��Υ�����ɤ�����
sp_sound_ob(int wNumWave)712 int sp_sound_ob(int wNumWave) {
713 sact.numsoundob = wNumWave;
714 return OK;
715 }
716
717 /**
718 * ����κ�ɸ�����ߤΥ��ץ饤�Ȥΰ��֤��ϰϤ����äƤ��뤫��
719 * @param sp: Ĵ�٤��оݤΥ��ץ饤��
720 * @param x,y: ��ɸ
721 * @return: TRUE:���äƤ���, FALSE: ���äƤ��ʤ�
722 */
sp_is_insprite(sprite_t * sp,int x,int y)723 boolean sp_is_insprite(sprite_t *sp, int x, int y) {
724 BYTE *dp;
725
726 if (x < 0 || y < 0 || x >= sf0->width || y >= sf0->height) return FALSE;
727
728 dp = GETOFFSET_PIXEL(sact.dmap, x, y);
729 return (*(WORD *)dp == sp->no);
730 }
731