111
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 #include <stdio.h>
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 #include <SDL.h>
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 #include <SDL_mixer.h> //追加
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 #include "sound.h"
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 #include "Ss.h"
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 #include "error.h"
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 //#include "libps.h"
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 //int vh_addr[10]={0x80140000,0x80141a00,0x80143000,0x80144400,0x80148200,
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 // 0x80149300,0x8014f300,0x80130000,0x80130000,0x80130000};
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 //_________________________________________________________
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 Mix_Chunk *chunk[8]; // 音楽ファイルの読み込み変数
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 int channel[8];
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 //_________________________________________________________
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 #if 0
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 static char buf0[] = "pBAV";
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 long vh_addr[10] =
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 { (long) buf0, (long) buf0, (long) buf0, (long) buf0, (long) buf0,
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 (long) buf0 };
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 #endif
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 int vb_addr[10] =
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 { 0x80140d00, 0x80142700, 0x80143d00, 0x80145100, 0x80148f00,
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 0x8014a100, 0x80150000, 0x80140000, 0x80140000, 0x80140000
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 };
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 int vab[10]; /* SE 用 VAB */
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 unsigned char *buf;
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 int cnt;
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
34 int seqno = -1;
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
35
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36 int seq[4]; /* SEQ data id */
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 int sdvab; /* 常駐 SE.VAB */
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 //CdlFILE vhfile, vbfile;
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
41 int SQ[10] = { 0x80155000, 0x8015f000, 0x80168000, 0x8016e000, 0x80175000,
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 0x80177000, 0xa00d0000, 0xa00e0000, 0x801e0000
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 };
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
44
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
45 void Soundss()
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46 {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 /*
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
48 int i;
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 //Set Sound Reverb @@@ リバーブの設定
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51 printf("音源データをCDから読み込み中");
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
52 SsUtSetReverbType(SS_REV_TYPE_STUDIO_C);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 SsUtReverbOn();
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
54
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
55
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
56 // 音源データのCDからの読み込み
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
57 // 標準音源(VH属性部)の読み込み
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
58 for (i = 0; i < 10; i++) { // リトライループ
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
59 if (CdSearchFile(&vhfile, VH_NAME) != 0)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
60 break; //正常終了ならばリトライループ中断
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
61 else
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
62 printf("%s not found.\n", VH_NAME);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
63 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
64 printf("♪");
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
65 for (i = 0; i < 10; i++) { // リトライループ
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
66 CdReadFile(VH_NAME, (void *) SQVH_ADDR, vhfile.size);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
67
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
68 // リードの裏で通常の処理は実行できる。
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
69 // ここでは、Read が終了するまで残りのセクタ数を監視
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
70 while ((cnt = CdReadSync(1, 0)) > 0)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
71 VSync(0); // 垂直同期割り込み待ち(時間調整用)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
72 if (cnt == 0)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
73 break; // 正常終了ならばリトライループ中断
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
74 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
75 // 標準音源(VB波形部)の読み込み
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
76 for (i = 0; i < 10; i++) { // リトライループ
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
77 if (CdSearchFile(&vbfile, VB_NAME) != 0)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
78 break; // 正常終了ならばリトライループ中断
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
79 else
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
80 printf("%s not found.\n", VB_NAME);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
81 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
82 printf("♪");
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
83 for (i = 0; i < 10; i++) { // リトライループ
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
84 CdReadFile(VB_NAME, (void *) SQVB_ADDR, vbfile.size);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
85
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
86 // リードの裏で通常の処理は実行できる。
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
87 // ここでは、Read が終了するまで残りのセクタ数を監視
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
88 while ((cnt = CdReadSync(1, 0)) > 0)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
89 VSync(0); // 垂直同期割り込み待ち(時間調整用)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
90
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
91 if (cnt == 0)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
92 break; // 正常終了ならばリトライループ中断
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
93 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
94 printf("♪");
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
95 // Open & transfer VAB data @@@ *VAB データのオープン,転送
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
96 sdvab = SsVabTransfer(SQVH_ADDR, SQVB_ADDR, -1, 1);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
97 if (sdvab < 0) {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
98 printf("VAB open failed(sdvab = %d)\n", sdvab);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
99 return;
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
100 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
101 printf("完了。\n");
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
102 // seq[0] = SsSeqOpen (SQ_ADDR, sdvab);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
103 // for (i=0;i<8;i++)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
104 // seq[i] = SsSeqOpen ((unsigned long*)SQ[i], sdvab);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
105 */
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
106 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
107
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
108 void SoundPlay(int no)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
109 {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
110 // Open SEQ/SEP datas @@@ * SEQ/SEP データのオープン
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
111 // SsSetMVol (127, 127);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
112 // SsUtSetReverbDepth( 40, 40 );
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
113
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
114 seq[no] = SsSeqOpen((unsigned int *) SQ[no], sdvab);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
115 seqno = no;
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
116 //SsSeqPlay(seq[no], SSPLAY_PLAY, 0);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
117
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
118 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
119
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
120 void SoundStop()
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
121 {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
122 if (seqno == -1)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
123 return;
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
124 //SsSeqStop(seq[seqno]);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
125 //SsSeqClose(seq[seqno]);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
126 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
127
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
128 //__________________________________________________________________
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
129 /**
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
130 * 全部これで判定するのはおかしい。
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
131 * んだけど、時間がががががが
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
132 */
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
133 int no_useSDLMixer = 0;
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
134
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
135 void
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
136 InitSdlMixer(void)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
137 {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
138 if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY,MIX_DEFAULT_FORMAT,2,1024) < 0) {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
139 __debug("failed to initialize SDL_mixer.\n");
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
140 no_useSDLMixer = 1;
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
141 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
142 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
143
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
144
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
145 // 音楽ファイル読み込み関数
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
146 void LoadSdlMixer()
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
147 {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
148 if (no_useSDLMixer) {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
149 __debug("%s is not executed because no_useSDLMixer is set\n",
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
150 __FUNCTION__);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
151 } else {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
152 chunk[BGM]=Mix_LoadWAV("./sound/sample.wav");
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
153 chunk[SHOT_A]=Mix_LoadWAV("./sound/shota.wav");
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
154 chunk[SHOT_B]=Mix_LoadWAV("./sound/shotb.wav");
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
155 chunk[SHOT_C]=Mix_LoadWAV("./sound/shotc.wav");
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
156 chunk[RING]=Mix_LoadWAV("./sound/ring.wav");
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
157 chunk[NEW]=Mix_LoadWAV("./sound/powerdown.wav");
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
158 chunk[JIKIOUT]=Mix_LoadWAV("./sound/jikiout.wav");
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
159 chunk[BOM]=Mix_LoadWAV("./sound/bomber.wav");
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
160
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
161 // 読み込めないファイルがあればエラーで終了
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
162 if(!chunk[BGM] || !chunk[SHOT_A] || !chunk[SHOT_B] || !chunk[SHOT_C]
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
163 ||!chunk[RING] || !chunk[NEW] || !chunk[JIKIOUT] || !chunk[BOM]) {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
164 fprintf(stderr,"failed to load sound.\n");
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
165 //return -1;
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
166 return;
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
167 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
168 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
169 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
170
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
171 /* 音楽再生関数
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
172 int fleg ... 再生回数。-1でループします。
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
173 int ch ... 再生する音の番号*/
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
174 void
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
175 PlaySdlMixer(int fleq, int ch)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
176 {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
177 if (no_useSDLMixer) {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
178 __debug("%s is not executed because no_useSDLMixer is set\n",
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
179 __FUNCTION__);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
180 } else {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
181 channel[ch]=Mix_PlayChannel( ch ,chunk[ch], fleq);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
182 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
183 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
184
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
185 void
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
186 PauseSdlMixer(int ch)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
187 {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
188 if (no_useSDLMixer) {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
189 __debug("%s is not executed because no_useSDLMixer is set\n",
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
190 __FUNCTION__);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
191 } else {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
192 Mix_Pause(ch);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
193 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
194 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
195
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
196 void
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
197 ResumeSdlMixer(int ch)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
198 {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
199 if (no_useSDLMixer) {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
200 __debug("%s is not executed because no_useSDLMixer is set\n",
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
201 __FUNCTION__);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
202 } else {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
203 Mix_Resume(ch);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
204 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
205 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
206
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
207 void
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
208 TimeSdlMixer(int fleq, int ch, int time)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
209 {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
210 if (no_useSDLMixer) {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
211 __debug("%s is not executed because no_useSDLMixer is set\n",
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
212 __FUNCTION__);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
213 } else {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
214 channel[ch]=Mix_PlayChannelTimed( ch ,chunk[ch], fleq, time);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
215 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
216 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
217
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
218
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
219 // 音の解放関数
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
220 void
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
221 FreeSdlMixer()
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
222 {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
223 int i ;
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
224
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
225 if (no_useSDLMixer) {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
226 __debug("%s is not executed because no_useSDLMixer is set\n",
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
227 __FUNCTION__);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
228 } else {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
229 for(i =0; i < 8; ++i) {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
230 Mix_FreeChunk(chunk[i]);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
231 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
232 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
233 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
234
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
235 void
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
236 InitVolume(void)
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
237 {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
238 if (no_useSDLMixer) {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
239 __debug("%s is not executed because no_useSDLMixer is set\n",
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
240 __FUNCTION__);
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
241 } else {
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
242 Mix_Volume( 0, 255); // BGM
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
243 Mix_Volume( 1, SE_VOLUME); // SHOT_A
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
244 Mix_Volume( 2, SE_VOLUME); // SHOT_B
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
245 Mix_Volume( 3, 100); // SHOT_C
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
246 Mix_Volume( 4, 40); // RING
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
247 Mix_Volume( 5, SE_VOLUME); // NEW
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
248 Mix_Volume( 6, SE_VOLUME); // JIKIOUT
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
249 Mix_Volume( 7, 100); // BOM
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
250 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
251 }
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
252
|
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
253 //_________________________________________________________________
|