1 /*
2 * screen_quake.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: screen_quake.c,v 1.1 2003/04/22 16:29:52 chikama Exp $ */
23
24 #include "config.h"
25
26 #include <stdio.h>
27 #include <string.h>
28 #include <math.h>
29 #include <glib.h>
30
31 #include "portab.h"
32 #include "system.h"
33 // #include "LittleEndian.h"
34 #include "ags.h"
35 #include "imput.h"
36 #include "sact.h"
37 #include "surface.h"
38 #include "ngraph.h"
39 #include "sprite.h"
40 #include "counter.h"
41 #include "randMT.h"
42
43 typedef void entrypoint (double step, int p1, int p2, int *retx, int *rety);
44
45 // �岼�����������ɤ餷
quake0(double step,int ampx,int ampy,int * adjx,int * adjy)46 static void quake0(double step, int ampx, int ampy, int *adjx, int *adjy) {
47 static int i = 0;
48
49 *adjx = (int)(genrand() * ampx/2);
50 *adjy = (int)(genrand() * ampy/2);
51 *adjx *= ((-1)*(i%2) + ((i+1)%2));
52 *adjy *= ((-1)*((i+1)%2) + (i%2));
53 i++;
54 }
55
56 // ��ž���ɤ餷
quake1(double curstep,int diam,int round,int * adjx,int * adjy)57 static void quake1(double curstep, int diam, int round, int *adjx, int *adjy) {
58 double R = (1 - curstep) * diam / 2;
59 double th = curstep * 2 * M_PI * round;
60
61 *adjx = (int)(R * cos(th));
62 *adjy = (int)(R * sin(th));
63 }
64
65 /*
66 �����ɤ餷
67 @param wType: 0=�IJ�, 1:��ž
68 @param wParam1: wType=0�ΤȤ�x�����ο���
69 wType=1�ΤȤ�����
70 @param wParam2: wType=0�ΤȤ�y�����ο���
71 wType=1�ΤȤ���ž��
72 @param wCount: ����(1/100��)
73 @param nfKeyEnable: ����ȴ�� (1��ͭ��)
74 */
sp_quake_screen(int type,int p1,int p2,int time,int cancel)75 int sp_quake_screen(int type, int p1, int p2, int time, int cancel) {
76 int sttime, edtime, curtime;
77 int key;
78 entrypoint *cb[2] = {quake0, quake1};
79
80 if (type > 1) return OK;
81
82 sttime = get_high_counter(SYSTEMCOUNTER_MSEC);
83 edtime = time * 10 + sttime;
84 while ((curtime = get_high_counter(SYSTEMCOUNTER_MSEC)) < edtime) {
85 int adjx, adjy;
86
87 cb[type]((double)(curtime - sttime)/(edtime - sttime), p1, p2, &adjx, &adjy);
88 ags_setViewArea(adjx, adjy, sf0->width, sf0->height);
89 ags_updateFull();
90
91 key = sys_keywait(10, cancel);
92 if (cancel && key) break;
93 }
94
95 ags_setViewArea(0, 0, sf0->width, sf0->height);
96 ags_updateFull();
97
98 return OK;
99 }
100
101