changeset 6:6541f0bebb81

cerium redering engine main routine.
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 07 Dec 2010 18:11:38 +0900
parents 8afbbe129730
children 972a7f233b23
files Dandy.cc Dandy.h sgoex.c sgoex.h syokika.c syokika.h
diffstat 6 files changed, 757 insertions(+), 187 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Dandy.cc	Tue Dec 07 18:11:38 2010 +0900
@@ -0,0 +1,726 @@
+#include "Dandy.h"
+
+
+const char *usr_help_str = "Usage: ./twice [-length data_length] [-count task_num]\n\
+  -length  Number of data (default DATA_NUM (Func.h))\n\
+  -count   Number of task (default 1)\n";
+
+
+MainLoopPtr
+Dandy::init(Viewer *sgroot, int w, int h)
+{
+    init_charactor(sgroot, w, h);
+    init_game(sgroot, w, h);
+
+    return sgroot;
+}
+
+extern Application *
+Dandy::application() {
+    return new Dandy();
+}
+
+Viewer *sg_root;
+
+static int dandy_closing(int gamef);
+static int dandy_main_lop(int gamef);
+static int dandy_main_init(int gamef);
+
+extern bool 
+Dandy::app_main(Viewer *viewer){
+    sg_root = viewer;
+    // don't use allExecute
+    return 0;
+};
+
+exern HTaskPtr 
+Dandy::application_task(HTaskPtr next, Viewer* viewer){
+    int gamef = 0;
+
+    switch (gamef) {
+    case 0:    gamef= danday_opening(gamef); break;
+    case 1:    gamef= danday_main_loop(gamef); break;
+    case 2:    gamef= danday_closing(gamef); break;
+    }
+    return next;
+}; 
+
+
+
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+static
+task_init() 
+{
+}
+
+int
+TMmain(TaskManager *manager,int argc, char *argv[])
+{
+    task_init();
+    task_initialize();
+    manager->set_TMend(TMend);
+
+    return init(manager,argc, argv);
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("game end\n");
+}
+
+extern "C" {
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+#include <time.h>
+#include <SDL.h>
+#include "SDL_opengl.h"
+#include "object.h"
+#include "tree_controll.h"
+#include "xml.h"
+#include "profile.h"
+#include "syokika.h"
+#include "sankaku.h"
+#include "sgoex.h"
+#include "sound.h"
+#include "bool.h"
+#include "Character.h"
+#include "Character_state.h"
+#include "bom.h"
+#include "count2.h"
+#include "tokuten.h"
+#include "schedule.h"
+#include "tama.h"
+#include "debug.h"
+#include "trace.h"
+#include "LoadSprite.h"
+#include <SDL_mixer.h>
+
+#include "error.h"
+}
+
+int gamef = 0;
+int use_keybord = 0;
+int cdp[20] = { 16, 16, 16, 17, 18, 0 };
+int d, i;
+
+int rswait = 0;
+int cf = 0;
+int cc = 0;
+
+//static SDL_Surface *screen;
+static Uint32 background;
+// static char *pad_trace_file;
+
+extern void schedule();
+extern void tokuten();
+extern void Pad();
+extern void keybord();
+//extern void PutSpriteEx(int number, int x, int y, GLfloat scalex, GLfloat scaley, GLfloat angle);
+//GLuint texture[250] = {0};
+static void gamesyokika();
+static void opening();
+static void pause();
+//static char *pad_trace_file;
+
+/**
+ * runmode:
+ * 0 - normal game                                                         
+ * 1 - capture mode                                                        
+ *     program will capture all pad traces on a play and               
+ *     dump it into a file                                             
+ * 2 - trace mode                                                          
+ *     program will run with a trace file which is generated           
+ *     by capture-mode
+ */
+int runmode;
+
+
+static int 
+dandy_main_init(int gamef)
+{
+    Timeprof timeprof_move;
+    timeprof_move = timeprof_new();
+    dbg_init("/dev/stdout");
+
+    /**
+     * timeprof があるんだけどね
+     */
+
+
+
+
+    //SDL_Joystick *joy=SDL_JoystickOpen(0);
+  
+    sgroot->createFromXMLfile("xml/character.xml");
+    sgroot->createFromXMLfile("xml/font.xml");
+    sgroot->createFromXMLfile("xml/effect.xml");
+    sgroot->createFromXMLfile("xml/boss.xml");
+
+
+    init_sprite(0,0,0,0);
+
+    __debug("syokikaが呼びだされました\n");
+    SDL_Joystick *joy=SDL_JoystickOpen(0);
+    if(!joy) {
+	fprintf(stderr,"failed to open joystick 0\n");
+	use_keybord = 1;
+    }
+
+    opening(joy);
+
+    __debug("openingがよびだされました\n");
+
+    /**
+     * sound.c に移しました
+     * 代わりに InitSdlMixer(void); を使います。
+     * まあ中身一緒なんだけどね
+     */
+    /**
+      if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY,MIX_DEFAULT_FORMAT,2,1024) < 0) {
+        fprintf(stderr,"failed to initialize SDL_mixer.\n");
+        SDL_Quit();
+        exit(-1);
+      }
+    */
+
+    // SDL_mixer とかいろいろ初期化
+    // もし Init に失敗したら
+    // 以後の Mixer 関連の関数を呼び出しても
+    // 中では何も行われないとかいう小細工を入れました。
+    InitSdlMixer();
+
+    // 音楽ファイルの読み込み
+    LoadSdlMixer();
+
+    // ボリューム調整
+    InitVolume();
+	
+    // 音出しテスト
+    PlaySdlMixer(-1, BGM);
+
+    if(!(init_chara_list(1024))){
+	__debug("failed to init_chara_list\n");
+    }
+
+    __debug("finished init_chara_list\n");
+
+    return 1;
+}
+
+static int
+dandy_main_lop(int gamef)
+{
+	if ((pad[0].l1 != 0) && (pad[0].r1 != 0) &&
+	    (pad[0].l2 != 0) && (pad[0].r2 != 0)) {
+	    glFlush();
+	    SDL_GL_SwapBuffers( );
+	    gamesyokika(joy);
+	}
+
+	if (pad[0].quit != 0) {
+	    gamef = 2;
+	}
+
+	//SDL_FillRect(screen, NULL, background);
+	glClear( GL_COLOR_BUFFER_BIT);		
+    
+	schedule();
+	enemyfaste = count;
+    
+	timeprof_begin(timeprof_move);
+	//Move(); //enemy move
+	collision_detect();
+	outofwindow();
+	timeprof_end(timeprof_move);
+	state_update();
+	asteroidi = 0;
+	//charpatern();
+	//bosguage();
+
+	if (jiki.bf == TRUE) {
+	    Player(0);
+	    count++;
+	    PutSprite(count, jiki.x, jiki.y, jiki.ch);
+	}
+
+	Putbom();
+	tokuten();
+    
+	count++;
+	//PutSprite(count, 0, 960 - 96, 10);
+	/*インフレゲージ */
+	count++;
+	//PutSprite(count, 0, 0, 48);
+	obj_draw();
+	pause(joy);
+
+	if (use_keybord) {
+	    keybord();
+	} else {
+	    Pad(joy);
+	}
+
+	count = 0;
+	return gamef;
+}
+
+static int
+dandy_closing(int gamef)
+{
+
+    //_______________________________________________
+    // SDL_mixerの後始末
+    Mix_CloseAudio();
+    Mix_HaltMusic();
+    FreeSdlMixer() ;
+    //_______________________________________________
+    return 0;
+}
+
+
+void gamesyokika(SDL_Joystick *joy)
+{
+    laser_lv3[0].r = 62;
+    laser_lv3[0].r = 62;
+    for (i = 0; i < 3; i++) {
+	tlv3[i].y = -1;
+    }
+    filpcount = 0;
+    stage = 0;
+    //for (i = 0; i < 300; i++)
+    //enemy[i].f = FALSE;
+    jiki.zanki = 3;
+    jiki.x = 60;
+    jiki.y = 200;
+    jiki.ch = 3;
+    jiki.point = 0;
+    jiki.bf = FALSE;
+    jiki.muteki = 120;
+    enemycount = 0;
+    lg.stg = 4096;
+    pg.stg = 4096;
+    infg.stg = 0;
+    infg_level = 0;
+    //kyeenemyno = -1;
+    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;
+    opening(joy);
+}
+
+
+void opening(SDL_Joystick *joy)
+{
+    //for (i = 0; i < 300; i++) {
+    //};
+
+    SoundStop();
+    SoundPlay(7);
+
+    while (1) {
+	if(use_keybord == 1) {
+	    keybord();
+	} else {
+	    Pad(joy);
+	}
+
+	count = 1;
+
+	PutSprite(count, 700, 480, 53); //  put `push start' string on screen.  
+	count++;
+	PutSprite(count, 224, 776, 119); //  put `super dandy'                   
+	count++;
+	//    PutSprite(count, 200, 64, 190);
+	//    PutSpriteEx(count, 8192, 8192, 0);
+        PutSpriteEx(190, 800, 264, 2, 2, 5);
+	count++;
+	PutSprite(count, 396, 432, 191);
+	//PutSpriteEx(count, 8192, 8192, 0);
+	count++;
+	PutSprite(count, 640, 640, 192);
+	//PutSpriteEx(count, 8192, 8192, 0);
+
+	if (pad[0].st > 1) {
+	    jiki.bf = TRUE;
+	    
+	    //CdPlay(1,&cdp[0],0);                                          
+	    SoundStop();
+	    SoundPlay(0);
+
+	    gamef = 1;
+	    pad[0].st = 1;
+	    return;
+	}
+	if ((pad[0].se > 0) && (pad[0].st > 0)) {
+	    gamef = 0;
+	    break;
+	}
+
+
+	SDL_GL_SwapBuffers( );
+    }
+}
+
+void
+pause(SDL_Joystick *joy)
+{
+    if (jiki.zanki != 0 && jiki.bf != FALSE) {
+	if (pad[0].se == 1) {
+	    //Mix_Pause(BGM);
+	    PauseSdlMixer(BGM);
+	    while(1){
+		if(use_keybord == 1) {
+		    keybord();
+		} else {
+		    Pad(joy);
+		}
+		if(pad[0].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;
+		//Mix_Resume(BGM);
+		ResumeSdlMixer(BGM);
+		break;
+	    }
+	}
+    }
+    if (jiki.zanki == 0) {
+	//     RECT *recp;                                                      
+	if ((jiki.ccount > 0) && (cf == 0)) {
+	    cf = 1;
+	    count++;
+	    //cgcg(2);
+	    PutSprite(2, 480, 480, 110);
+	    count++;
+	    //cgcg(1);
+	}
+	if ((jiki.ccount > 0) && (cf == 1)) {
+	    while (1) {
+		if (pad[0].st > 0) {
+		    cf = 0;
+		    jiki.ccount--;
+		    jiki.zanki = 3;
+		    enemycount++;
+		    cc = 0;
+		    for (i = 0; i < 4; i++) {
+			clear_result[i] = 0;
+		    }
+		    goto f;
+		}
+		cc++;
+		if (29 - cc / 60 < 20) {
+		    cc = 0;
+		    cf = 3;
+		    break;
+		}
+		SDL_Delay(100);
+		PutSprite(1, 640, 640, 29 - cc / 60);
+		//      	PutSpriteEx(1, 409 * ((cc % 60) + 1), 409 * ((cc % 60) + 1), 0);
+
+		Pad(joy);
+		SDL_GL_SwapBuffers( );
+	    }
+	}
+	if (rswait > 60 * 6) {
+	    cf = 0;
+	    rswait = 0;
+	    gamesyokika(joy);
+	}
+	rswait++;
+	count++;
+	//cgcg(1);
+	PutSprite(1, 480, 480, 19);
+	return;
+    }
+    if (jiki.bf == FALSE) {
+    f:
+	if (rswait < 80) {
+	    rswait++;
+	    return;
+	} else {
+	    rswait = 0;
+	    jiki.x = 60;
+	    jiki.y = 200;
+	    jiki.bf = TRUE;
+
+	    pad[0].st = 0;
+	    lg.stg = 4096;
+	    pg.stg = 4096;
+	    laser_lv3[0].r = 62;
+	    tlv3[0].r = 0;
+	    tlv3[0].y = -1;
+	    return;
+	    // sb_size = -1;                                                    
+	}
+    }
+}
+
+SpriteTable sptable[DEFOBJ];
+
+
+void DefSpriteEx(int number, short middlex, short middley)
+{
+    sptable[number].mx = middlex;
+    sptable[number].my = middley;
+}
+
+
+void DefSprite(int number, char *name, float w, float h, int color, OBJECT *obj)
+{
+}
+
+void PutSprite(int zorder, short x, short y, int number)
+{
+    SpriteTable *m = &sptable[number];
+    SceneGraphPtr object = sgroot->createSceneGraph(m->name);
+    
+    title->xyz[0] = x;
+    title->xyz[1] = y;
+
+    charactor[number].x = x;
+    charactor[number].y = y;
+    charactor[number].flag = 0;
+    charactor[number].root = (void*)object;
+
+}
+
+void PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle)
+{
+    SpriteTable *m = &sptable[number];
+    x -= m->w;
+    y -= m->h;
+}
+
+
+struct SGO_PAD pad[2];
+
+
+/* コントローラ状態の読み込み */
+void Pad(SDL_Joystick *joy)
+{
+    Sint16 axis;
+
+    SDL_JoystickUpdate();
+  
+    if(SDL_JoystickGetButton(joy,PS2_CROSS)==SDL_PRESSED)
+	pad[0].k0++;
+    else
+	pad[0].k0=0;
+  
+    if(SDL_JoystickGetButton(joy,PS2_CIRCLE)==SDL_PRESSED)
+	pad[0].k1++;
+    else
+	pad[0].k1=0;
+  
+    if(SDL_JoystickGetButton(joy,PS2_SQUARE)==SDL_PRESSED)
+	pad[0].k3++;
+    else
+	pad[0].k3=0;
+  
+    if(SDL_JoystickGetButton(joy,PS2_TRIANGLE)==SDL_PRESSED)
+	pad[0].k4++;
+    else
+	pad[0].k4=0;
+  
+    if(SDL_JoystickGetButton(joy,PS2_L1)==SDL_PRESSED)
+	pad[0].l1++;
+    else
+	pad[0].l1=0;
+  
+    if(SDL_JoystickGetButton(joy,PS2_R1)==SDL_PRESSED)
+	pad[0].r1++;
+    else
+	pad[0].r1=0;
+  
+    if(SDL_JoystickGetButton(joy,PS2_L2)==SDL_PRESSED)
+	pad[0].l2++;
+    else
+	pad[0].l2=0;
+  
+    if(SDL_JoystickGetButton(joy,PS2_R2)==SDL_PRESSED)
+	pad[0].r2++;
+    else
+	pad[0].r2=0;
+  
+    if(SDL_JoystickGetButton(joy,PS2_START)==SDL_PRESSED)
+	pad[0].st++;
+    else
+	pad[0].st=0;
+  
+    if(SDL_JoystickGetButton(joy,PS2_SELECT)==SDL_PRESSED)
+	pad[0].se++;
+    else
+	pad[0].se=0;
+  
+    if(SDL_JoystickGetButton(joy,PS2_L3)==SDL_PRESSED)
+	pad[0].l3++;
+    else
+	pad[0].l3=0;
+  
+    if(SDL_JoystickGetButton(joy,PS2_R3)==SDL_PRESSED)
+	pad[0].r3++;
+    else
+	pad[0].r3=0;
+    //x
+    axis=SDL_JoystickGetAxis(joy,0);
+    if(axis>=3200){
+	pad[0].left=0;
+	pad[0].right++;
+    }
+    else if(axis<=-3200){
+	pad[0].right=0;
+	pad[0].left++;
+    }
+    else {
+	pad[0].right=0;
+	pad[0].left=0;
+    }
+    //y
+    axis=SDL_JoystickGetAxis(joy,1);
+    if(axis>=3200){
+	pad[0].up=0;
+	pad[0].down++;
+    }
+    else if(axis<=-3200){
+	pad[0].down=0;
+	pad[0].up++;
+    }
+    else {
+	pad[0].down=0;
+	pad[0].up=0;
+    }
+
+    if ((pad[0].l1 != 0) && (pad[0].r1 != 0) &&
+	(pad[0].l2 != 0) && (pad[0].r2 != 0) &&
+	(pad[0].st != 0) && (pad[0].se != 0)) {
+	pad[0].quit = 1;
+    } else {
+	pad[0].quit = 0;
+    }
+	
+}
+
+
+void keybord()
+{
+    SDL_PumpEvents();
+    Uint8 *keys = SDL_GetKeyState(NULL);
+
+    if (keys[SDLK_UP]) {
+	pad[0].up++;
+    } else {
+	pad[0].up = 0;
+    }
+    if (keys[SDLK_DOWN]) {
+	pad[0].down++;
+    } else {
+	pad[0].down = 0;
+    }
+
+    if (keys[SDLK_RIGHT]) {
+	pad[0].right++;
+    } else {
+	pad[0].right = 0;
+    }
+
+    if (keys[SDLK_LEFT]) {
+	pad[0].left++;
+    } else {
+	pad[0].left = 0;
+    }
+
+    if (keys[SDLK_a]) {
+	pad[0].k0++;
+    } else {
+	pad[0].k0 = 0;
+    }
+
+    if (keys[SDLK_z]) {
+	pad[0].k1++;
+    } else {
+	pad[0].k1 = 0;
+    }
+
+    if (keys[SDLK_s]) {
+	pad[0].k3++;
+    } else {
+	pad[0].k3 = 0;
+    }
+    
+    if (keys[SDLK_x]) {
+	pad[0].k4++;
+    } else {
+	pad[0].k4 = 0;
+    }
+
+    if (keys[SDLK_r]) {
+	pad[0].r2++;
+    } else {
+	pad[0].r2 = 0;
+    }
+
+    if (keys[SDLK_e]) {
+	pad[0].r1++;
+    } else {
+	pad[0].r1 = 0;
+    }
+
+    if (keys[SDLK_w]) {
+	pad[0].l1++;
+    } else {
+	pad[0].l1 = 0;
+    }
+
+    if (keys[SDLK_q]) {
+	pad[0].l2++;
+    } else {
+	pad[0].l2 = 0;
+    }
+
+    // START ボタンは Return が似合う気がする
+    //if(keys[SDLK_1])
+    if (keys[SDLK_RETURN]) {
+	pad[0].st++;
+    } else {
+	pad[0].st = 0;
+    }
+
+    if (keys[SDLK_2]) {
+	pad[0].se++;
+    } else {
+	pad[0].se = 0;
+    }
+
+    if (keys[SDLK_ESCAPE]) {
+	SDL_Quit();
+	exit(1);
+	//pad[0].st = 1;
+	//pad[0].se = 1;
+    }
+
+    if (keys[SDLK_0]) {
+	pad[0].quit = 1;
+    } else {
+	pad[0].quit = 0;
+    }
+}
+
+
+/* end */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Dandy.h	Tue Dec 07 18:11:38 2010 +0900
@@ -0,0 +1,19 @@
+#ifndef INCLUDE_DANDY_H
+#define INCLUDE_DANDY_H
+
+#include "TaskManager.h"
+#include "SceneGraph.h"
+#include "Application.h"
+#include "MainLoop.h"
+#include "Func.h"
+
+class Dandy : public Application {
+    bool app_main(Viewer *viewer){};
+    HTaskPtr application_task(HTaskPtr next, Viewer* viewer){return next;};
+    MainLoopPtr init(Viewer *viewer, int w, int h);
+};
+
+typedef void (*move)(SceneGraphPtr node, void *sgroot_, int w, int h);
+typedef void (*coll)(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree);
+
+#endif
--- a/sgoex.c	Tue Dec 07 17:02:11 2010 +0900
+++ b/sgoex.c	Tue Dec 07 18:11:38 2010 +0900
@@ -6,7 +6,6 @@
 #include <stdio.h>
 #include <SDL.h>
 #include "SDL_image.h"
-//#include "libps2.h"
 #include "SDL_opengl.h"
 #include "texture.h"
 #include "object.h"
@@ -17,10 +16,6 @@
 #include "LoadSprite.h"
 
 
-//extern void Back(GsOT * ot);
-extern void Draw_rectangle(void *obj);
-extern void draw_sprite(void *obj);
-
 #define OT_LENGTH	1	/*  オーダリングテーブル */
 #define MAXOBJ    320		/*スプライト表示上限 */
 
@@ -29,17 +24,8 @@
 
 int count;
 
-/*オーダリングテーブル関連*/
-
-//GsOT WorldOT[2];
-//GsOT_TAG OTTags[2][1 << OT_LENGTH];
-
-//PACKET GpuPacketArea[2][MAXOBJ * (20 + 4)];
-
-//GsSPRITE *sp, sprite[MAXOBJ];
 
 u_short tpage;
-//RECT rect;
 SDL_Rect rect;
 
 int nActiveBuff;		/*ばふぁ */
@@ -73,13 +59,6 @@
   関数プロトタイプ
   ---------------------------------------------------------------*/
 
-void Gdraw()
-{
-    SDL_UpdateRect(screen, 0,0,0,0);
-}
-
-
-
 void DefSpriteEx(int number, short middlex, short middley)
 {
     sptable[number].mx = middlex;
@@ -146,11 +125,6 @@
 void DefSprite(int number, char *name, float w, float h, int color, OBJECT *obj)
 {
     SURFACE *surfaces;
-    /*
-      sptable[number].page = page;
-      sptable[number].dx = x;
-      sptable[number].dy = y;
-    */
     surfaces = search_node(obj, name);
     if(surfaces == NULL)
     {
@@ -177,25 +151,6 @@
 
 void PutSprite(int zorder, short x, short y, int number)
 {
-    //static GLuint texture[250] = {0};
-#if 0
-    /*
-      sp = &sprite[zorder];
-    
-      spview[zorder].extend = FALSE;
-      sp->w = sptable[number].w;
-      sp->h = sptable[number].h;
-      sp->u = sptable[number].dx;
-      sp->v = sptable[number].dy;
-      sp->x = x;
-      sp->y = y;
-      sp->cx = 0;
-      sp->cy = 480 + sptable[number].color;
-	
-      spview[zorder].no = number;*/	/* 表示するスプライトの番号の格納 */
-#endif
-
-    //SDL_GL_Enter2DMode();
     glBindTexture(GL_TEXTURE_2D, (GLuint)sptable[number].texture);
     glEnable(GL_BLEND);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -206,7 +161,6 @@
     glTexCoord2f(texMaxX[number],texMinY[number]); glVertex2i((GLuint)(x+sptable[number].tex_w), (GLuint)y);
     glEnd();
     glDisable(GL_BLEND);
-    //SDL_GL_Leave2DMode();
 }
 
 void PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle)
@@ -237,42 +191,7 @@
     //  SDL_GL_SwapBuffers();
 }
 
-/*void PutSpriteEx(int zorder, short scalex, short scaley, long rotate)
-  {
-  sp = &sprite[zorder];
 
-  spview[zorder].extend = TRUE;
-
-  sp->mx = sptable[spview[zorder].no].mx;
-  sp->my = sptable[spview[zorder].no].my;
-  sp->scalex = scalex;
-  sp->scaley = scaley;
-  sp->rotate = rotate;
-  }*/
-
-void init_tim(u_long addr)
-{
-    //RECT rect;
-    /*  SDL_Rect rect;
-	GsIMAGE image;
-
-	GsGetTimInfo((unsigned int *) (addr + 4), &image);
-
-	rect.x = image.px;
-	rect.y = image.py;
-	rect.w = image.pw;
-	rect.h = image.ph;
-	LoadImage(&rect, image.pixel);
-	DrawSync(0);
-
-	rect.x = image.cx;
-	rect.y = image.cy;
-	rect.w = image.cw;
-	rect.h = image.ch;
-	LoadImage(&rect, image.clut);
-	DrawSync(0);
-    */
-}
 
 struct SGO_PAD pad[2];
 
@@ -490,31 +409,3 @@
     }
 }
 
-
-/*!
-  \brief PNGシステムの初期化
-*/
-/*
-  void *init_png(char *png_file)
-  {
-  
-  TEXTURE *tex[1];
-
-  tex[0] = read_png_file0(png_file, 1);
-  if (tex[0] == NULL) {
-  fprintf(stderr, "failed to read a texture data. \n");
-  goto INIT_PNG_FAILED;
-  }
-  if (load_textures(1, tex) < 0) {
-  fprintf(stderr, "failed to load a texture to GS-VRAM. \n");
-  goto INIT_PNG_FAILED;
-  }
-
-  return tex[0];
-
-
-  fflush(stderr);
-  return NULL;
-  
-  }
-*/
--- a/sgoex.h	Tue Dec 07 17:02:11 2010 +0900
+++ b/sgoex.h	Tue Dec 07 18:11:38 2010 +0900
@@ -85,50 +85,13 @@
 extern SpriteTable sptable[DEFOBJ];
 
 
-void Ginit();
-void Gfinish(void);
-void Gdraw(void);
-void *init_png(char *png_file);
 void PutSprite(int zorder, short x, short y, int number);
-//void PutSprite();
 void DefSprite(int number, char *name, float w, float h, int color, OBJECT *obj);
 void DefSpriteEx(int number, short middlex, short middley);
-void sound_init(void);
-void view_init(int p);
-void view_move(int x, int y, int z, int rx, int ry, int rz);
-void model_init(int model_no, unsigned long *dop, int m1_x, int m1_y,
-		int m1_z, int m2_x, int m2_y, int m2_z);
-char xml_model_init(int model_no, void *template_obj, int m1_x, int m1_y,
-		    int m1_z, int m2_x, int m2_y, int m2_z);
-void m2move(int model_no, int x, int y, int z, int rx, int ry, int rz);
-void PutPolygon(int number);
 void PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle);
-//void PutSpriteEx(int zorder, short scalex, short scaley, long rotate);
-
-void sgoex_ps2_Set_camera(void);
-void sgoex_ps2_Put_sprite(int num, float x, float y);
-char sgoex_ps2_Create_sprites(void);
-char sgoex_ps2_Init_xmlCube(char *redCube_file,
-			    char *blueCube_file,
-			    char *greenCube_file, char *yellowCube_file);
-char sgoex_ps2_Init_xmlFloor(char *file_name);
-void *sgoex_ps2_Get_redCube(void);
-void *sgoex_ps2_Get_blueCube(void);
-void *sgoex_ps2_Get_greenCube(void);
-void *sgoex_ps2_Get_yellowCube(void);
-void *sgoex_ps2_Get_xmlFloor(void);
-void xml_floor_Finish(void);
 
 
 /* Joypad - Below member are implemented in sgoex_ps2.c */
 extern SGO_PAD pad[2];
-//void Pad(void);
 void Pad();
 void keybord();
-//void Pad1(SGO_PAD * padls);
-//void Pad2(SGO_PAD * padls);
-
-//void GsSortBoxFill(GsBOXF * bp, GsOT * otp, unsigned int pri);
-
-/* dummies */
-// void init_tim( int tim_addr );
--- a/syokika.c	Tue Dec 07 17:02:11 2010 +0900
+++ b/syokika.c	Tue Dec 07 18:11:38 2010 +0900
@@ -38,9 +38,6 @@
     Uint8  video_bpp = 32;
     Uint32 videoflags;
 
-    laser_lv3[0].r = 62;
-    laser_lv3[0].r = 62;
-
     /* Initialize SDL */
     if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0 ) {
 	fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
@@ -95,6 +92,16 @@
     all_object_load_texture(boss);
     all_object_load_texture(chara);
     all_object_load_texture(effect);
+    init_sprite();
+}
+
+void
+init_sprite(OBJECT *font, OBJECT *boss, OBJECT *chara, OBJECT *effect)
+{
+    int i, i2;
+
+    laser_lv3[0].r = 62;
+    laser_lv3[0].r = 62;
 
     /*
       for (i = 0; i < BOX_NUM; i++) {
@@ -250,42 +257,4 @@
     DefSprite(203, "rank_a_pla", 64, 32, 480, font);
     DefSprite(202, "rank_s", 64, 32, 480, font);
 	
-    //SDL_Joystick *joy=SDL_JoystickOpen(0);
-  
-    /*
-      GetPadBuf(&bb0, &bb1);
-      SsSetSerialAttr(SS_CD, SS_MIX, SS_SON);
-
-      Soundss();
-      SsSetSerialVol(SS_CD, 127, 127);
-      SsUtSetReverbType(SS_REV_TYPE_STUDIO_C);
-      SsUtReverbOn();
-  
-	
-      for (i = 0; i < 10; i++) {
-      buf = (unsigned char *) vh_addr[i] ;
-      if ((buf[0] != 'p') || (buf[1] != 'B') || (buf[2] != 'A')|| (buf[3] != 'V')) {
-      printf( "VAB not ready on the address at %lX\n",vh_addr[0]);
-      return;
-      }
-
-      vab[i] =
-      SsVabTransfer((unsigned char *) vh_addr[i],
-      (unsigned char *) vb_addr[i]
-      VH1_ADDR, VB1_ADDR 
-      , -1, 1);
-    
-      if (vab[i] < 0) {
-      printf( "VAB open failed(vab[i] = %d)\n", vab[i] );             
-      return;
-      }
-      }
-
-  
-      SsSetMVol(127, 127);
-      SsUtSetReverbDepth(40, 40);
-      SoundStop();
-      SoundPlay(0);
-      SoundStop();
-    */
 }
--- a/syokika.h	Tue Dec 07 17:02:11 2010 +0900
+++ b/syokika.h	Tue Dec 07 18:11:38 2010 +0900
@@ -114,3 +114,5 @@
 } CharImageNumber;
 
 extern void syokika(int argc, char *argv[]);
+extern void init_sprite(OBJECT *font, OBJECT *boss, OBJECT *chara, OBJECT *effect);
+