view Magoroku.cc @ 116:ed702e49cc6c

conpile
author e085768
date Thu, 16 Jun 2011 04:05:33 +0900
parents 31dd5c07f7c1
children 9e4100c5d7ec
line wrap: on
line source

//magoroku 関係ココから
#include "Magoroku.h"

#include <stdio.h>
#include "game.h"
#include "libps2.h"
#include "ps2util.h"

#include "sjoy.h"
//magoroku 関係ココまで

#include "SgoexCerium.h"
#include <ctype.h>
#include <math.h>
#include <time.h>
#include <SDL.h>
#include "SDL_opengl.h"

//#include "tree_controll.h"
#include "xml.h"
#include "profile.h"
//#include "syokika.h"
//#include "sankaku.h"

#include "sound.h"
//#include "bom.h"
//#include "count2.h"
//#include "tokuten.h"
//#include "tama.h"
//#include "debug.h"
//#include "trace.h"
#include "LoadSprite.h"
#include <SDL_mixer.h>
#include "error.h"
#include "matrix_calc.h"

//#include "Character.h"
//#include "Character_state.h"

#include "Light.h"


//static SDL_Surface *screen;
// static Uint32 background;
// static char *pad_trace_file;


// tree_Dandy の schedule3.c 
//extern void schedule();


//extern void tokuten();
extern bool padCheck(SDL_Joystick *joy);
extern bool keybord(void);
//static int gamesyokika(int gamef);
//static int game_pause(int);
//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;

SDL_Joystick *joy;

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";

Viewer *droot;

static    int screen_w;
static    int screen_h;

//ウィンドウのサイズとかを指定?
MainLoopPtr
Magoroku::init(Viewer *sgroot_, int w, int h)
{
  screen_w = w;
  screen_h = h;
  droot = sgroot_;
  return droot;
}

Application *application() {
  return new Magoroku();
}


//Magoroku の初期化など
/* timer */
//static int start_time,time_count;
//static int RUNNIG=0;
//char raptime[10];

//static int ranking = 0;
//static LIGHT l;
//static int i=0;
// schedule.ccで使用してる
void linda_env_init( void );


extern int init(TaskManager *manager, int argc, char *argv[]);
extern void task_initialize();
static void TMend(TaskManager *manager);


//class Application の中の virtual bool app_loop( return 1 だけの関数?) を継承
bool 
Magoroku::app_loop(Viewer *viewer){
    // don't use allExecute
    return 0;
};


/*
  ゲームの分岐。magoroku の schedule の処理と同等と考えてオッケーかな?
*/
HTaskPtr 
Magoroku::application_task(HTaskPtr next, Viewer* viewer){

  // magoroku_racing                                                                                                        
  game_main();

  /*
  // Dandy
  printf("gamef = %d\n",gamef);
  switch (gamef) {
  case 0:    gamef= magoroku_main_init(gamef); break;
  case 1:    gamef= gamesyokika(gamef); break;
  case 2:    gamef= opening(gamef); break;
  case 3:    gamef= magoroku_main_loop(gamef); break;
  case 4:    gamef= magoroku_closing(gamef); break;
  }
  */
  return next;
}; 


static void
task_init() 
{
  printf("task_init\n");
}

FILE *main_fp;

int
TMmain(TaskManager *manager,int argc, char *argv[])
{
  main_fp = fopen("/dev/stdout", "w");
  if (!main_fp) {
    perror("main");
  }

  printf("trace_TMmain\n");

  for(int i = 1; i<argc ; i++) {
    if (strcmp(argv[i],"-t")) {
      if (i+1<argc && argv[i+1]) {
	i++;
      }
    }
  }

  task_init();
  task_initialize();
  manager->set_TMend(TMend);

  // magoroku_racing の main.ccから
  //game_main();
    
  return init(manager,argc, argv);
}

void
TMend(TaskManager *manager)
{
  printf("game end\n");
}

//static int light_sysswitch = 0;
//static int light_num = 4;


// ceriumuで同じ変数名があるから _2 って付け足しました
/*
static void 
LightSysSwitch_2(Viewer *sgroot) {
  if (light_sysswitch == 1) {
    sgroot->OnLightSysSwitch();
    for (int i = 0; i < light_num; i++) {
        SceneGraphPtr light = sgroot->getLight(i);
        sgroot->OnLightSwitch(i);
        light->xyz[0] = screen_w / 2;
        light->xyz[1] = screen_h / 2;
        light->xyz[2] = -100;
    }
  } else if (light_sysswitch == 0) {
    sgroot->OffLightSysSwitch();
  }
}
*/