changeset 112:5106d8d12ded

Changing Magoroku.cc
author Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
date Thu, 09 Jun 2011 14:59:24 +0900
parents 7600cdfa8779
children 8c96cadde050
files Magoroku.cc Makefile Ss.cc Ss.h TAGS sound.c sound.cc
diffstat 7 files changed, 608 insertions(+), 371 deletions(-) [+]
line wrap: on
line diff
--- a/Magoroku.cc	Thu Jun 09 02:23:21 2011 +0900
+++ b/Magoroku.cc	Thu Jun 09 14:59:24 2011 +0900
@@ -8,13 +8,19 @@
 #include <time.h>
 #include <SDL.h>
 #include "SDL_opengl.h"
-#include "object.h"
+
+//#include "object.h"
+#include "libps2.h"
+
 #include "tree_controll.h"
 #include "xml.h"
 #include "profile.h"
 #include "syokika.h"
 #include "sankaku.h"
+
 //#include "sgoex.h"
+#include "controler.h"
+
 #include "sound.h"
 #include <stdbool.h>
 #include "bom.h"
@@ -49,7 +55,7 @@
 
 extern void schedule();
 extern void tokuten();
-extern void Pad();
+extern void padCheck();
 extern void keybord();
 static int gamesyokika(int gamef);
 static int game_pause(int);
@@ -114,7 +120,9 @@
 //ゲームの分岐に使用
 static int gamef = 0;
 
-//ゲームの分岐っぽそう。magoroku の schedule の処理と同等と考えてオッケーかな?
+/*
+  ゲームの分岐。magoroku の schedule の処理と同等と考えてオッケーかな?
+*/
 HTaskPtr 
 Magoroku::application_task(HTaskPtr next, Viewer* viewer){
     // printf("gamef = %d\n",gamef);
@@ -184,6 +192,10 @@
 */
 
 
+/*
+  初期化の処理
+  初期化成功で return 1 だから、次の処理にいくっぽい
+*/
 static int 
 dandy_main_init(int gamef)
 {
@@ -194,7 +206,7 @@
     /**
      * timeprof があるんだけどね
      */
-
+    //xml file 読み込む
     droot->createFromXMLfile("xml/character.xml");
     droot->createFromXMLfile("xml/font.xml");
     droot->createFromXMLfile("xml/effect.xml");
@@ -250,17 +262,18 @@
 }
 
 
+//メインループ
 static int
 dandy_main_loop(int gamef)
 {
 	
 
-	if ((pad[0].l1 != 0) && (pad[0].r1 != 0) &&
-	    (pad[0].l2 != 0) && (pad[0].r2 != 0)) {
+	if ((pad.l1 != 0) && (pad.r1 != 0) &&
+	    (pad.l2 != 0) && (pad.r2 != 0)) {
 	    gamef = gamesyokika(gamef);
 	}
 
-	if (pad[0].quit != 0) {
+	if (pad.se != 0) {
 	    gamef = 4;
 	}
 	flip();
@@ -301,7 +314,7 @@
 	if (use_keybord) {
 	    keybord();
 	} else {
-	    Pad(joy);
+	    padCheck(joy);
 	}
 	filpcount++;
 	count = 0;
@@ -351,12 +364,12 @@
     fastebos = 0;
     jiki.ccount = 99;
     p_extend = 200000;
-    pad[0].up=0;
-    pad[0].down=0;
-    pad[0].right=0;
-    pad[0].left=0;
-    pad[0].st=0;
-    pad[0].se=0;
+    pad.up=0;
+    pad.down=0;
+    pad.right=0;
+    pad.left=0;
+    pad.st=0;
+    pad.se=0;
 
     SoundStop();
     SoundPlay(7);
@@ -371,7 +384,7 @@
     if(use_keybord == 1) {
 	keybord();
     } else {
-	Pad(joy);
+	padCheck(joy);
     }
 
     count = 1;
@@ -390,7 +403,7 @@
     PutSprite(count, 640, 640, 192);
     //PutSpriteEx(count, 8192, 8192, 0);
 
-    if (pad[0].st > 1) {
+    if (pad.st > 1) {
 	jiki.bf = true;
 	
 	//CdPlay(1,&cdp[0],0);                                          
@@ -398,8 +411,8 @@
 	SoundPlay(0);
 
 	gamef = 3;
-	pad[0].st = 1;
-    } else if ((pad[0].se > 0) && (pad[0].st > 0)) {
+	pad.st = 1;
+    } else if ((pad.se > 0) && (pad.st > 0)) {
 	gamef = 2;
     }
     flip();  
@@ -411,23 +424,23 @@
 {
     gamef = 3;
     if (jiki.zanki != 0 && jiki.bf != false) {
-	if (pad[0].se == 1) {
+	if (pad.se == 1) {
 	    //Mix_Pause(BGM);
 	    PauseSdlMixer(BGM);
 	    while(1){
 		if(use_keybord == 1) {
 		    keybord();
 		} else {
-		    Pad(joy);
+		    padCheck(joy);
 		}
-		if(pad[0].st == 0)
+		if(pad.st == 0)
 		    continue;
-		pad[0].up=0;
-		pad[0].down=0;
-		pad[0].right=0;
-		pad[0].left=0;
-		pad[0].se=0;
-		pad[0].st=0;
+		pad.up=0;
+		pad.down=0;
+		pad.right=0;
+		pad.left=0;
+		pad.se=0;
+		pad.st=0;
 		//Mix_Resume(BGM);
 		ResumeSdlMixer(BGM);
 		break;
@@ -445,8 +458,9 @@
 	    //cgcg(1);
 	}
 	if ((jiki.ccount > 0) && (cf == 1)) {
+	  //スタートを押すまでココで止まり続けるから、これは最初のスタート画面か?
 	    while (1) {
-		if (pad[0].st > 0) {
+		if (pad.st > 0) {
 		    cf = 0;
 		    jiki.ccount--;
 		    jiki.zanki = 3;
@@ -464,14 +478,14 @@
 		    break;
 		}
 		SDL_Delay(100);
-		PutSprite(1, 640, 640, 29 - cc / 60);
+		PutSprite(1, 640, 640, 29 - CC / 60);
 		//      	PutSpriteEx(1, 409 * ((cc % 60) + 1), 409 * ((cc % 60) + 1), 0);
-
-		Pad(joy);
-		flip();  // this is not correct
+		
+		padCheck(joy);
+		flip();  // THIS IS NOT CORRECT
 	    }
 	}
-	if (rswait > 60 * 6) {
+	IF (rswait > 60 * 6) {
 	    cf = 0;
 	    rswait = 0;
 	    gamef = gamesyokika(gamef);
@@ -493,7 +507,7 @@
 	    jiki.y = 200;
 	    jiki.bf = true;
 
-	    pad[0].st = 0;
+	    pad.st = 0;
 	    lg.stg = 4096;
 	    pg.stg = 4096;
 	    laser_lv3[0].r = 62;
--- a/Makefile	Thu Jun 09 02:23:21 2011 +0900
+++ b/Makefile	Thu Jun 09 14:59:24 2011 +0900
@@ -4,7 +4,7 @@
 srcdir  = .
 ABI = -m$(ABIBIT)
 
-SRCS = main.cc game.cc car.cc col.cc quotanion.cc controler.cc field.cc camera.cc gSprite.cc schedule.cc mytype.cc gFont.cc carNode.cc light.cc title_scene.cc game_time.cc ps2util.cc sjoy.cc name_dictionary.cc Magoroku.cc
+SRCS = main.cc game.cc car.cc col.cc quotanion.cc controler.cc field.cc camera.cc gSprite.cc schedule.cc mytype.cc gFont.cc carNode.cc light.cc title_scene.cc game_time.cc ps2util.cc sjoy.cc name_dictionary.cc sound.cc Ss.cc Magoroku.cc
 
 CFLAGS  += -DINVISIBLE_MODE -g $(ABI) -Wall `sdl-config --cflags` `xml2-config --cflags` $(INCLUDE)
 LIBS	+=  `sdl-config --libs`,-framework,OpenGL -lSDL_mixer -lSDL_image `xml2-config --libs`
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Ss.cc	Thu Jun 09 14:59:24 2011 +0900
@@ -0,0 +1,125 @@
+/*
+ *    Ss is an omission which means Sound Synthesizer. But, this version, for PS2,
+ *    isn't implemented the realities. We think that the Sc module can be implemented 
+ *    with SDLaudio-library-for-PS2.
+ */
+
+//#include "libps.h"
+#include <SDL.h>
+
+
+int SsUtKeyOn(int vabId, int prog, int tone, int note, int fine, int voll, int vlor)
+{
+    return 0;
+}
+
+
+int SsUtKeyOff(int voice, int vabId, int prog, int tone, int note)
+{
+    return 0;
+}
+
+
+void SsSetSerialAttr(char s_num, char attr, char mode)
+{
+}
+
+
+void SsSetSerialVol(char a, int b, int c)
+{
+}
+
+
+int SsUtSetReverbType(int type)
+{
+    return type;
+}
+
+
+
+void SsSetMVol(int voll, int volr)
+{
+}
+
+
+
+
+
+void SsUtReverbOn(void)
+{
+}
+
+
+
+#if 0
+int VSync(int mode)
+{
+    return 59;
+}
+#endif
+
+
+
+int SsVabTransfer(unsigned char *vh_addr, unsigned char *vd_addr,
+		  int vabid, int i_flag)
+{
+    return vabid;
+}
+
+
+
+int SsSeqOpen(unsigned int *addr, int vad_id)
+{
+    return 1;
+}
+
+
+
+void SsSeqPlay(int seq_access_num, char play_mode, int count)
+{
+}
+
+
+
+void SsSeqStop(int seq_access_num)
+{
+}
+
+
+
+void SsSeqClose(int seq_access_num)
+{
+}
+
+/*
+int CdReadFile(char *file, u_int * addr, int nbyte)
+{
+    return 0;
+}
+
+
+int CdReadSync(int mode, u_char * result)
+{
+    return 0;
+}
+
+
+CdlFILE *CdSearchFile(CdlFILE * fp, char *name)
+{
+    return 0;
+}
+*/
+
+void SsSetTempo(int a, int b, int c)
+{
+}
+
+
+void GetPadBuf(volatile unsigned char **a, volatile unsigned char **b)
+{
+}
+
+
+void SsUtSetReverbDepth(int a, int b)
+{
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Ss.h	Thu Jun 09 14:59:24 2011 +0900
@@ -0,0 +1,15 @@
+extern int SsUtKeyOn(int vabId, int prog, int tone, int note, int fine, int voll, int vlor);
+extern int SsUtKeyOff(int voice, int vabId, int prog, int tone, int note);
+extern void SsSetSerialAttr(char s_num, char attr, char mode);
+extern void SsSetSerialVol(char a, int b, int c);
+extern int SsUtSetReverbType(int type);
+extern void SsSetMVol(int voll, int volr);
+extern void SsUtReverbOn(void);
+extern int SsVabTransfer(unsigned char *vh_addr, unsigned char *vd_addr, int vabid, int i_flag);
+extern int SsSeqOpen(unsigned int *addr, int vad_id);
+extern void SsSeqPlay(int seq_access_num, char play_mode, int count);
+extern void SsSeqStop(int seq_access_num);
+extern void SsSeqClose(int seq_access_num);
+extern void SsSetTempo(int a, int b, int c);
+extern void GetPadBuf(volatile unsigned char **a, volatile unsigned char **b);
+extern void SsUtSetReverbDepth(int a, int b);
--- a/TAGS	Thu Jun 09 02:23:21 2011 +0900
+++ b/TAGS	Thu Jun 09 14:59:24 2011 +0900
@@ -1,35 +1,52 @@
 
-Magoroku.cc,815
-static int use_keybord 35,666
-static int i;37,745
-static int rswait 39,760
-static int cf 40,783
-static int cc 41,802
-static int test_mode 43,822
-static const char *test_object test_object44,848
-int runmode;68,1651
-SDL_Joystick *joy;joy70,1665
-const char *usr_help_str usr_help_str74,1687
-Viewer *droot;droot78,1873
-static    int screen_w;80,1889
-static    int screen_h;81,1913
-Magoroku::init(85,1998
-application(94,2138
-Magoroku::app_loop(109,2565
-static int gamef 115,2677
-Magoroku::application_task(119,2819
-task_init(135,3230
-TMmain(140,3252
-TMend(160,3586
-static int light_sysswitch 165,3645
-static int light_num 166,3677
-LightSysSwitch(169,3717
-dandy_main_init(186,4141
-dandy_main_loop(252,5664
-dandy_closing(311,6573
-gamesyokika(325,6831
-opening(367,7576
-game_pause(408,8460
+Magoroku.cc,791
+static int use_keybord 41,720
+static int i;43,799
+static int rswait 45,814
+static int cf 46,837
+static int cc 47,856
+static int test_mode 49,876
+static const char *test_object test_object50,902
+int runmode;74,1710
+SDL_Joystick *joy;joy76,1724
+const char *usr_help_str usr_help_str80,1746
+Viewer *droot;droot84,1932
+static    int screen_w;86,1948
+static    int screen_h;87,1972
+Magoroku::init(91,2057
+application(100,2197
+Magoroku::app_loop(115,2624
+static int gamef 121,2736
+Magoroku::application_task(125,2878
+task_init(141,3289
+TMmain(146,3311
+TMend(166,3645
+static int light_sysswitch 171,3704
+static int light_num 172,3736
+dandy_main_init(198,4306
+dandy_main_loop(264,5829
+dandy_closing(323,6726
+gamesyokika(337,6984
+opening(379,7711
+game_pause(420,8588
+
+Ss.cc,403
+int SsUtKeyOn(11,255
+int SsUtKeyOff(17,360
+void SsSetSerialAttr(23,447
+void SsSetSerialVol(28,508
+int SsUtSetReverbType(33,556
+void SsSetMVol(40,612
+void SsUtReverbOn(48,656
+int VSync(55,693
+int SsVabTransfer(63,742
+int SsSeqOpen(71,860
+void SsSeqPlay(78,927
+void SsSeqStop(84,996
+void SsSeqClose(90,1038
+void SsSetTempo(113,1286
+void GetPadBuf(118,1329
+void SsUtSetReverbDepth(123,1406
 
 camera.cc,138
 static CAMERA camera,13,214
@@ -67,9 +84,10 @@
 col_detect(71,1818
 col_init(105,2584
 
-controler.cc,42
-SGO_PAD pad;21,329
-bool padCheck(23,343
+controler.cc,72
+struct SGO_PAD pad;18,274
+bool padCheck(24,409
+bool keybord(115,2715
 
 field.cc,419
 #define BUFSIZE 13,222
@@ -243,52 +261,52 @@
 void free_texture(289,7461
 int malloc_align16(305,7793
 void ps2util_tex_Exclude(329,8321
-void ps2util_sprite_Draw(334,8394
-void ps2util_graphic_Finish(339,8463
-void ps2util_sprite_Use_alpha(346,8565
+void ps2util_sprite_Draw(334,8396
+void ps2util_graphic_Finish(339,8465
+void ps2util_sprite_Use_alpha(346,8567
 
 quotanion.cc,69
 quotanion(11,226
 quotanion_rotmatrix(25,529
 degree2radian(47,1167
 
-schedule.cc,1007
-#define linda_update(31,521
-#define MAXCAR 34,575
-#define MAXFIELD 35,616
-#define MAXRAP 36,660
-#define SP_SEL_CAR 37,695
-#define SP_SEL_COURSE 38,720
-static int start_time,63,1507
-static int start_time,time_count;63,1507
-static int RUNNIG=64,1541
-char raptime[raptime65,1562
-static int ranking 67,1581
-static LIGHT l;68,1605
-static int i=69,1621
-static int change_state 73,1733
-set_schedule_assumption(79,1837
-unset_schedule(86,1953
-set_schedule(92,2007
-graphic_init(99,2105
-play_init(106,2248
-void linda_env_init(114,2402
-static void game_env_init 119,2465
-sche_game_init(136,2698
-sche_game_opening(191,3755
-sche_game_select_car(224,4276
-sche_game_select_course(255,4915
-sche_game_ready(286,5586
-sche_game_main_init(313,6202
-sche_game_main_ready(323,6353
-sche_game_main(330,6490
-sche_game_main_pause(396,8016
-sche_game_main_goal(430,8716
-sche_game_main_finish(460,9394
-sche_game_main_finish2(470,9553
-void wait_sync(482,9743
-void swap_dbuff(488,9813
-schedule(494,9869
+schedule.cc,1008
+#define linda_update(32,538
+#define MAXCAR 35,592
+#define MAXFIELD 36,633
+#define MAXRAP 37,677
+#define SP_SEL_CAR 38,712
+#define SP_SEL_COURSE 39,737
+static int start_time,64,1524
+static int start_time,time_count;64,1524
+static int RUNNIG=65,1558
+char raptime[raptime66,1579
+static int ranking 68,1598
+static LIGHT l;69,1622
+static int i=70,1638
+static int change_state 74,1750
+set_schedule_assumption(80,1855
+unset_schedule(87,1971
+set_schedule(93,2025
+graphic_init(100,2123
+play_init(107,2266
+void linda_env_init(115,2420
+static void game_env_init 120,2483
+sche_game_init(137,2716
+sche_game_opening(192,3773
+sche_game_select_car(225,4294
+sche_game_select_course(256,4933
+sche_game_ready(287,5604
+sche_game_main_init(314,6220
+sche_game_main_ready(324,6371
+sche_game_main(331,6508
+sche_game_main_pause(397,8034
+sche_game_main_goal(431,8734
+sche_game_main_finish(461,9412
+sche_game_main_finish2(471,9571
+void wait_sync(483,9761
+void swap_dbuff(489,9831
+schedule(495,9887
 
 sjoy.cc,437
 #define N_JOY 14,195
@@ -307,6 +325,32 @@
 int sjoy_get_axis(125,2445
 int sjoy_get_ps2_button(131,2588
 
+sound.cc,578
+Mix_Chunk *chunk[chunk14,355
+int channel[channel15,419
+static char buf0[buf019,502
+long vh_addr[vh_addr21,532
+int vb_addr[vb_addr26,643
+int vab[vab31,788
+unsigned char *buf;buf32,820
+int cnt;33,840
+int seqno 34,849
+int seq[seq36,866
+int sdvab;37,898
+int SQ[SQ41,959
+void Soundss(45,1093
+void SoundPlay(108,3399
+void SoundStop(120,3682
+int no_useSDLMixer 133,3965
+InitSdlMixer(136,3995
+void LoadSdlMixer(146,4219
+PlaySdlMixer(175,5174
+PauseSdlMixer(186,5392
+ResumeSdlMixer(197,5565
+TimeSdlMixer(208,5740
+FreeSdlMixer(221,6002
+InitVolume(236,6223
+
 test_vector.cc,157
 int main(16,358
 void init_FVECTOR(134,2887
@@ -340,10 +384,12 @@
 typedef struct camera{camera7,74
 } CAMERA;12,158
 
-car.h,74
+car.h,135
 #define CAR_H4,27
-typedef struct car 8,63
-} Car, *CarPtr;CarPtr21,460
+typedef struct car 9,83
+} Car, *CarPtr;CarPtr22,480
+typedef struct game 28,576
+} Game, *GamePtr;GamePtr35,760
 
 carNode.h,23
 #define CARNODE_H2,18
@@ -355,9 +401,26 @@
 typedef struct col_face_handler 15,189
 } ColFaceHd;19,285
 
-controler.h,48
-typedef struct SGO_PAD 9,131
-} SGO_PAD;24,376
+controler.h,467
+#define CONTROLER_H2,20
+#define PS2_CROSS 6,70
+#define PS2_CIRCLE 7,90
+#define PS2_SQUARE 8,111
+#define PS2_TRIANGLE 9,132
+#define PS2_L1 11,156
+#define PS2_R1 12,173
+#define PS2_L2 13,190
+#define PS2_R2 14,207
+#define PS2_START 15,224
+#define PS2_SELECT 16,244
+#define PS2_L3 17,265
+#define PS2_R3 18,283
+#define PS2_LEFT 20,302
+#define PS2_RIGHT 21,322
+#define PS2_UP 22,343
+#define PS2_DOWN 23,361
+typedef struct SGO_PAD 34,514
+} SGO_PAD;49,759
 
 field.h,225
 #define FIELD_H2,16
@@ -374,10 +437,8 @@
 typedef struct sptable 7,115
 } SpriteTable;12,188
 
-game.h,81
+game.h,20
 #define GAME_H4,29
-typedef struct game 14,148
-} Game, *GamePtr;GamePtr21,332
 
 libps2.h,360
 #define LIBPS2_H3,18
@@ -473,6 +534,26 @@
 #define SJOY_PS2_UP 32,1105
 #define SJOY_PS2_RIGHT 33,1147
 
+sound.h,412
+#define _SOUND_H_2,18
+#define BGM 4,37
+#define SHOT_A 5,51
+#define SHOT_B 6,68
+#define SHOT_C 7,85
+#define RING 8,102
+#define NEW 9,117
+#define JIKIOUT 10,131
+#define BOM 11,149
+#define SE_VOLUME 13,164
+ #define LASER_A 15,186
+ #define LASER_C 16,205
+ #define JIKIOUT 17,224
+#define VH_NAME 19,244
+#define VB_NAME 20,287
+#define SQVH_ADDR 21,330
+#define SQVB_ADDR 22,376
+#define SQ_ADDR 23,422
+
 sprite.h,508
 #define FRAME_ANGLE_NORMAL 1,0
 #define FRAME_ANGLE_REVERSE_HORIZON 2,39
@@ -496,3 +577,5 @@
 game_time.h,0
 
 gFont.h,0
+
+Ss.h,0
--- a/sound.c	Thu Jun 09 02:23:21 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,253 +0,0 @@
-#include <stdio.h>
-#include <SDL.h>
-#include <SDL_mixer.h> //追加
-#include "sound.h"
-#include "Ss.h"
-
-#include "error.h"
-//#include "libps.h"
-
-//int vh_addr[10]={0x80140000,0x80141a00,0x80143000,0x80144400,0x80148200,
-//               0x80149300,0x8014f300,0x80130000,0x80130000,0x80130000};
-
-//_________________________________________________________
-Mix_Chunk *chunk[8]; // 音楽ファイルの読み込み変数
-int channel[8];
-//_________________________________________________________
-
-#if 0
-static char buf0[] = "pBAV";
-
-long vh_addr[10] =
-{ (long) buf0, (long) buf0, (long) buf0, (long) buf0, (long) buf0,
-  (long) buf0 };
-#endif
-
-int vb_addr[10] =
-{ 0x80140d00, 0x80142700, 0x80143d00, 0x80145100, 0x80148f00,
-  0x8014a100, 0x80150000, 0x80140000, 0x80140000, 0x80140000
-};
-
-int vab[10];			/* SE 用 VAB */
-unsigned char *buf;
-int cnt;
-int seqno = -1;
-
-int seq[4];			/* SEQ data id */
-int sdvab;			/* 常駐 SE.VAB */
-
-//CdlFILE vhfile, vbfile;
-
-int SQ[10] = { 0x80155000, 0x8015f000, 0x80168000, 0x8016e000, 0x80175000,
-	       0x80177000, 0xa00d0000, 0xa00e0000, 0x801e0000
-};
-
-void Soundss()
-{
-    /*
-      int i;
-
-      //Set Sound Reverb @@@  リバーブの設定 
-      printf("音源データをCDから読み込み中");
-      SsUtSetReverbType(SS_REV_TYPE_STUDIO_C);
-      SsUtReverbOn();
-
-
-      // 音源データのCDからの読み込み 
-      // 標準音源(VH属性部)の読み込み 
-      for (i = 0; i < 10; i++) {	// リトライループ 
-      if (CdSearchFile(&vhfile, VH_NAME) != 0)
-      break;		//正常終了ならばリトライループ中断 
-      else
-      printf("%s not found.\n", VH_NAME);
-      }
-      printf("♪");
-      for (i = 0; i < 10; i++) {	// リトライループ 
-      CdReadFile(VH_NAME, (void *) SQVH_ADDR, vhfile.size);
-
-      // リードの裏で通常の処理は実行できる。
-      // ここでは、Read が終了するまで残りのセクタ数を監視 
-      while ((cnt = CdReadSync(1, 0)) > 0)
-      VSync(0);		// 垂直同期割り込み待ち(時間調整用)
-      if (cnt == 0)
-      break;		// 正常終了ならばリトライループ中断 
-      }
-      // 標準音源(VB波形部)の読み込み 
-      for (i = 0; i < 10; i++) {	// リトライループ 
-      if (CdSearchFile(&vbfile, VB_NAME) != 0)
-      break;		// 正常終了ならばリトライループ中断 
-      else
-      printf("%s not found.\n", VB_NAME);
-      }
-      printf("♪");
-      for (i = 0; i < 10; i++) {	// リトライループ 
-      CdReadFile(VB_NAME, (void *) SQVB_ADDR, vbfile.size);
-
-      // リードの裏で通常の処理は実行できる。
-      // ここでは、Read が終了するまで残りのセクタ数を監視 
-      while ((cnt = CdReadSync(1, 0)) > 0)
-      VSync(0);		// 垂直同期割り込み待ち(時間調整用)
-
-      if (cnt == 0)
-      break;		// 正常終了ならばリトライループ中断 
-      }
-      printf("♪");
-      // Open & transfer VAB data @@@ *VAB データのオープン,転送 
-      sdvab = SsVabTransfer(SQVH_ADDR, SQVB_ADDR, -1, 1);
-      if (sdvab < 0) {
-      printf("VAB open failed(sdvab = %d)\n", sdvab);
-      return;
-      }
-      printf("完了。\n");
-      //      seq[0] = SsSeqOpen (SQ_ADDR, sdvab);
-      //      for (i=0;i<8;i++)
-      //      seq[i] = SsSeqOpen ((unsigned long*)SQ[i], sdvab);
-      */
-}
-
-void SoundPlay(int no)
-{
-    // Open SEQ/SEP datas @@@ * SEQ/SEP データのオープン 
-    //    SsSetMVol (127, 127);
-    //    SsUtSetReverbDepth( 40, 40 );
-
-    seq[no] = SsSeqOpen((unsigned int *) SQ[no], sdvab);
-    seqno = no;
-    //SsSeqPlay(seq[no], SSPLAY_PLAY, 0);
-
-}
-
-void SoundStop()
-{
-    if (seqno == -1)
-	return;
-    //SsSeqStop(seq[seqno]);
-    //SsSeqClose(seq[seqno]);
-}
-
-//__________________________________________________________________
-/**
- * 全部これで判定するのはおかしい。
- * んだけど、時間がががががが
- */
-int no_useSDLMixer = 0;
-
-void
-InitSdlMixer(void)
-{
-    if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY,MIX_DEFAULT_FORMAT,2,1024) < 0) {
-        __debug("failed to initialize SDL_mixer.\n");
-	no_useSDLMixer = 1;
-    }
-}
-
-
-// 音楽ファイル読み込み関数
-void LoadSdlMixer()
-{
-    if (no_useSDLMixer) {
-	__debug("%s is not executed because no_useSDLMixer is set\n",
-		__FUNCTION__);
-    } else {
-	chunk[BGM]=Mix_LoadWAV("./sound/sample.wav");
-	chunk[SHOT_A]=Mix_LoadWAV("./sound/shota.wav");
-	chunk[SHOT_B]=Mix_LoadWAV("./sound/shotb.wav");
-	chunk[SHOT_C]=Mix_LoadWAV("./sound/shotc.wav");
-	chunk[RING]=Mix_LoadWAV("./sound/ring.wav");
-	chunk[NEW]=Mix_LoadWAV("./sound/powerdown.wav");
-	chunk[JIKIOUT]=Mix_LoadWAV("./sound/jikiout.wav");
-	chunk[BOM]=Mix_LoadWAV("./sound/bomber.wav");
-	
-	// 読み込めないファイルがあればエラーで終了
-	if(!chunk[BGM] || !chunk[SHOT_A] || !chunk[SHOT_B] || !chunk[SHOT_C]
-	   ||!chunk[RING] || !chunk[NEW] || !chunk[JIKIOUT] || !chunk[BOM]) {
-	    fprintf(stderr,"failed to load sound.\n");
-	    //return -1;
-	    return;
-	}
-    }
-}
-
-/* 音楽再生関数
-   int fleg ... 再生回数。-1でループします。
-   int ch ... 再生する音の番号*/
-void
-PlaySdlMixer(int fleq, int ch)
-{
-    if (no_useSDLMixer) {
-	__debug("%s is not executed because no_useSDLMixer is set\n",
-		__FUNCTION__);
-    } else {
-	channel[ch]=Mix_PlayChannel( ch ,chunk[ch], fleq);
-    }
-}
-
-void
-PauseSdlMixer(int ch)
-{
-    if (no_useSDLMixer) {
-	__debug("%s is not executed because no_useSDLMixer is set\n",
-		__FUNCTION__);
-    } else {
-	Mix_Pause(ch);
-    }
-}
-
-void
-ResumeSdlMixer(int ch)
-{
-    if (no_useSDLMixer) {
-	__debug("%s is not executed because no_useSDLMixer is set\n",
-		__FUNCTION__);
-    } else {
-	Mix_Resume(ch);
-    }
-}
-
-void
-TimeSdlMixer(int fleq, int ch, int time)
-{
-    if (no_useSDLMixer) {
-	__debug("%s is not executed because no_useSDLMixer is set\n",
-		__FUNCTION__);
-    } else {
-	channel[ch]=Mix_PlayChannelTimed( ch ,chunk[ch], fleq, time);
-    }
-}
-
-
-// 音の解放関数
-void
-FreeSdlMixer()
-{
-    int i ;
-
-    if (no_useSDLMixer) {
-	__debug("%s is not executed because no_useSDLMixer is set\n",
-		__FUNCTION__);
-    } else {
-	for(i =0; i < 8; ++i) {
-	    Mix_FreeChunk(chunk[i]);
-	}
-    }
-}
-
-void
-InitVolume(void)
-{
-    if (no_useSDLMixer) {
-	__debug("%s is not executed because no_useSDLMixer is set\n",
-		__FUNCTION__);
-    } else {
-	Mix_Volume( 0, 255);       // BGM
-	Mix_Volume( 1, SE_VOLUME); // SHOT_A
-	Mix_Volume( 2, SE_VOLUME); // SHOT_B
-	Mix_Volume( 3, 100);       // SHOT_C
-	Mix_Volume( 4, 40);        // RING
-	Mix_Volume( 5, SE_VOLUME); // NEW
-	Mix_Volume( 6, SE_VOLUME); // JIKIOUT
-	Mix_Volume( 7, 100);       // BOM
-    }
-}
-
-//_________________________________________________________________
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sound.cc	Thu Jun 09 14:59:24 2011 +0900
@@ -0,0 +1,253 @@
+#include <stdio.h>
+#include <SDL.h>
+#include <SDL_mixer.h> //追加
+#include "sound.h"
+#include "Ss.h"
+
+#include "error.h"
+//#include "libps.h"
+
+//int vh_addr[10]={0x80140000,0x80141a00,0x80143000,0x80144400,0x80148200,
+//               0x80149300,0x8014f300,0x80130000,0x80130000,0x80130000};
+
+//_________________________________________________________
+Mix_Chunk *chunk[8]; // 音楽ファイルの読み込み変数
+int channel[8];
+//_________________________________________________________
+
+#if 0
+static char buf0[] = "pBAV";
+
+long vh_addr[10] =
+{ (long) buf0, (long) buf0, (long) buf0, (long) buf0, (long) buf0,
+  (long) buf0 };
+#endif
+
+int vb_addr[10] =
+{ 0x80140d00, 0x80142700, 0x80143d00, 0x80145100, 0x80148f00,
+  0x8014a100, 0x80150000, 0x80140000, 0x80140000, 0x80140000
+};
+
+int vab[10];			/* SE 用 VAB */
+unsigned char *buf;
+int cnt;
+int seqno = -1;
+
+int seq[4];			/* SEQ data id */
+int sdvab;			/* 常駐 SE.VAB */
+
+//CdlFILE vhfile, vbfile;
+
+int SQ[10] = { 0x80155000, 0x8015f000, 0x80168000, 0x8016e000, 0x80175000,
+	       0x80177000, 0xa00d0000, 0xa00e0000, 0x801e0000
+};
+
+void Soundss()
+{
+    /*
+      int i;
+
+      //Set Sound Reverb @@@  リバーブの設定 
+      printf("音源データをCDから読み込み中");
+      SsUtSetReverbType(SS_REV_TYPE_STUDIO_C);
+      SsUtReverbOn();
+
+
+      // 音源データのCDからの読み込み 
+      // 標準音源(VH属性部)の読み込み 
+      for (i = 0; i < 10; i++) {	// リトライループ 
+      if (CdSearchFile(&vhfile, VH_NAME) != 0)
+      break;		//正常終了ならばリトライループ中断 
+      else
+      printf("%s not found.\n", VH_NAME);
+      }
+      printf("♪");
+      for (i = 0; i < 10; i++) {	// リトライループ 
+      CdReadFile(VH_NAME, (void *) SQVH_ADDR, vhfile.size);
+
+      // リードの裏で通常の処理は実行できる。
+      // ここでは、Read が終了するまで残りのセクタ数を監視 
+      while ((cnt = CdReadSync(1, 0)) > 0)
+      VSync(0);		// 垂直同期割り込み待ち(時間調整用)
+      if (cnt == 0)
+      break;		// 正常終了ならばリトライループ中断 
+      }
+      // 標準音源(VB波形部)の読み込み 
+      for (i = 0; i < 10; i++) {	// リトライループ 
+      if (CdSearchFile(&vbfile, VB_NAME) != 0)
+      break;		// 正常終了ならばリトライループ中断 
+      else
+      printf("%s not found.\n", VB_NAME);
+      }
+      printf("♪");
+      for (i = 0; i < 10; i++) {	// リトライループ 
+      CdReadFile(VB_NAME, (void *) SQVB_ADDR, vbfile.size);
+
+      // リードの裏で通常の処理は実行できる。
+      // ここでは、Read が終了するまで残りのセクタ数を監視 
+      while ((cnt = CdReadSync(1, 0)) > 0)
+      VSync(0);		// 垂直同期割り込み待ち(時間調整用)
+
+      if (cnt == 0)
+      break;		// 正常終了ならばリトライループ中断 
+      }
+      printf("♪");
+      // Open & transfer VAB data @@@ *VAB データのオープン,転送 
+      sdvab = SsVabTransfer(SQVH_ADDR, SQVB_ADDR, -1, 1);
+      if (sdvab < 0) {
+      printf("VAB open failed(sdvab = %d)\n", sdvab);
+      return;
+      }
+      printf("完了。\n");
+      //      seq[0] = SsSeqOpen (SQ_ADDR, sdvab);
+      //      for (i=0;i<8;i++)
+      //      seq[i] = SsSeqOpen ((unsigned long*)SQ[i], sdvab);
+      */
+}
+
+void SoundPlay(int no)
+{
+    // Open SEQ/SEP datas @@@ * SEQ/SEP データのオープン 
+    //    SsSetMVol (127, 127);
+    //    SsUtSetReverbDepth( 40, 40 );
+
+    seq[no] = SsSeqOpen((unsigned int *) SQ[no], sdvab);
+    seqno = no;
+    //SsSeqPlay(seq[no], SSPLAY_PLAY, 0);
+
+}
+
+void SoundStop()
+{
+    if (seqno == -1)
+	return;
+    //SsSeqStop(seq[seqno]);
+    //SsSeqClose(seq[seqno]);
+}
+
+//__________________________________________________________________
+/**
+ * 全部これで判定するのはおかしい。
+ * んだけど、時間がががががが
+ */
+int no_useSDLMixer = 0;
+
+void
+InitSdlMixer(void)
+{
+    if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY,MIX_DEFAULT_FORMAT,2,1024) < 0) {
+        __debug("failed to initialize SDL_mixer.\n");
+	no_useSDLMixer = 1;
+    }
+}
+
+
+// 音楽ファイル読み込み関数
+void LoadSdlMixer()
+{
+    if (no_useSDLMixer) {
+	__debug("%s is not executed because no_useSDLMixer is set\n",
+		__FUNCTION__);
+    } else {
+	chunk[BGM]=Mix_LoadWAV("./sound/sample.wav");
+	chunk[SHOT_A]=Mix_LoadWAV("./sound/shota.wav");
+	chunk[SHOT_B]=Mix_LoadWAV("./sound/shotb.wav");
+	chunk[SHOT_C]=Mix_LoadWAV("./sound/shotc.wav");
+	chunk[RING]=Mix_LoadWAV("./sound/ring.wav");
+	chunk[NEW]=Mix_LoadWAV("./sound/powerdown.wav");
+	chunk[JIKIOUT]=Mix_LoadWAV("./sound/jikiout.wav");
+	chunk[BOM]=Mix_LoadWAV("./sound/bomber.wav");
+	
+	// 読み込めないファイルがあればエラーで終了
+	if(!chunk[BGM] || !chunk[SHOT_A] || !chunk[SHOT_B] || !chunk[SHOT_C]
+	   ||!chunk[RING] || !chunk[NEW] || !chunk[JIKIOUT] || !chunk[BOM]) {
+	    fprintf(stderr,"failed to load sound.\n");
+	    //return -1;
+	    return;
+	}
+    }
+}
+
+/* 音楽再生関数
+   int fleg ... 再生回数。-1でループします。
+   int ch ... 再生する音の番号*/
+void
+PlaySdlMixer(int fleq, int ch)
+{
+    if (no_useSDLMixer) {
+	__debug("%s is not executed because no_useSDLMixer is set\n",
+		__FUNCTION__);
+    } else {
+	channel[ch]=Mix_PlayChannel( ch ,chunk[ch], fleq);
+    }
+}
+
+void
+PauseSdlMixer(int ch)
+{
+    if (no_useSDLMixer) {
+	__debug("%s is not executed because no_useSDLMixer is set\n",
+		__FUNCTION__);
+    } else {
+	Mix_Pause(ch);
+    }
+}
+
+void
+ResumeSdlMixer(int ch)
+{
+    if (no_useSDLMixer) {
+	__debug("%s is not executed because no_useSDLMixer is set\n",
+		__FUNCTION__);
+    } else {
+	Mix_Resume(ch);
+    }
+}
+
+void
+TimeSdlMixer(int fleq, int ch, int time)
+{
+    if (no_useSDLMixer) {
+	__debug("%s is not executed because no_useSDLMixer is set\n",
+		__FUNCTION__);
+    } else {
+	channel[ch]=Mix_PlayChannelTimed( ch ,chunk[ch], fleq, time);
+    }
+}
+
+
+// 音の解放関数
+void
+FreeSdlMixer()
+{
+    int i ;
+
+    if (no_useSDLMixer) {
+	__debug("%s is not executed because no_useSDLMixer is set\n",
+		__FUNCTION__);
+    } else {
+	for(i =0; i < 8; ++i) {
+	    Mix_FreeChunk(chunk[i]);
+	}
+    }
+}
+
+void
+InitVolume(void)
+{
+    if (no_useSDLMixer) {
+	__debug("%s is not executed because no_useSDLMixer is set\n",
+		__FUNCTION__);
+    } else {
+	Mix_Volume( 0, 255);       // BGM
+	Mix_Volume( 1, SE_VOLUME); // SHOT_A
+	Mix_Volume( 2, SE_VOLUME); // SHOT_B
+	Mix_Volume( 3, 100);       // SHOT_C
+	Mix_Volume( 4, 40);        // RING
+	Mix_Volume( 5, SE_VOLUME); // NEW
+	Mix_Volume( 6, SE_VOLUME); // JIKIOUT
+	Mix_Volume( 7, 100);       // BOM
+    }
+}
+
+//_________________________________________________________________