Mercurial > hg > old > magoroku_racing
changeset 115:31dd5c07f7c1
class OBJECT:SceanGraph
author | e085768 |
---|---|
date | Wed, 15 Jun 2011 23:31:59 +0900 |
parents | 8c96cadde050 |
children | ed702e49cc6c |
files | LoadSprite.c LoadSprite.h Magoroku.cc Magoroku.h Makefile Makefile.def SgoexCerium.cc SgoexCerium.h TAGS car.cc car.h field.cc gSprite.cc gSprite.h game.h libps2.h ps2util.cc ps2util.h schedule.cc schedule.h sgoex.c sgoex.h title_scene.cc |
diffstat | 23 files changed, 1705 insertions(+), 854 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LoadSprite.c Wed Jun 15 23:31:59 2011 +0900 @@ -0,0 +1,50 @@ +#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 "SDL_image.h" +#include "object.h" +#include "xml.h" +#include "tree_controll.h" +#include "LoadSprite.h" + +//#define bmp_file "./s-dandy.bmp" + +SDL_Surface *sprite; + +SDL_Surface *LoadSprite(SURFACE *surfaces) +{ + SDL_Surface *image; + SDL_Surface *temp; + + /* Load the sprite image */ + image = IMG_Load(surfaces->image_name); + + if ( image == NULL ) { + fprintf(stderr, "Couldn't load %s: %s", surfaces->image_name, SDL_GetError()); + printf("can't not load image_file\n"); + return NULL; + } + + /* Set transparent pixel as the pixel at (0,0) */ + /* if ( image->format->palette ) { + SDL_SetColorKey(image, (SDL_SRCCOLORKEY|SDL_RLEACCEL), *(Uint8 *)image->pixels); + }*/ + SDL_SetColorKey(image, (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(image->format, 0, 0, 0)); + + /* Convert sprite to video format */ + temp = SDL_DisplayFormat(image); + SDL_FreeSurface(image); + if ( temp == NULL ) { + fprintf(stderr, "Couldn't convert background: %s\n", SDL_GetError()); + return NULL; + } + image = temp; + return image; + + /* We're ready to roll. */ +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LoadSprite.h Wed Jun 15 23:31:59 2011 +0900 @@ -0,0 +1,2 @@ +//extern SDL_Surface *LoadSprite(SURFACE *surfaces); +extern SDL_Surface *sprite;
--- a/Magoroku.cc Thu Jun 09 18:07:46 2011 +0900 +++ b/Magoroku.cc Wed Jun 15 23:31:59 2011 +0900 @@ -2,28 +2,9 @@ #include "Magoroku.h" #include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdbool.h> +#include "game.h" #include "libps2.h" #include "ps2util.h" -#include "field.h" -#include "car.h" -#include "gSprite.h" -#include "gFont.h" -#include "game.h" -#include "controler.h" -#include "camera.h" -#include "carNode.h" -#include "car.h" -#include "light.h" -#include "title_scene.h" -#include "game_time.h" -#include "schedule.h" -#include "game.h" - -#include "mytype.h" -#include "linda.h" #include "sjoy.h" //magoroku 関係ココまで @@ -56,18 +37,23 @@ //#include "Character.h" //#include "Character_state.h" +#include "Light.h" //static SDL_Surface *screen; // static Uint32 background; // static char *pad_trace_file; -extern void schedule(); -extern void tokuten(); + +// 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 int gamesyokika(int gamef); +//static int game_pause(int); //static char *pad_trace_file; /** @@ -84,8 +70,6 @@ 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"; @@ -99,15 +83,14 @@ MainLoopPtr Magoroku::init(Viewer *sgroot_, int w, int h) { - screen_w = w; - screen_h = h; - droot = sgroot_; - return droot; + screen_w = w; + screen_h = h; + droot = sgroot_; + return droot; } -Application * -application() { - return new Magoroku(); +Application *application() { + return new Magoroku(); } @@ -125,22 +108,6 @@ void linda_env_init( void ); -//Magoroku の処理 -static void set_schedule(Game *game); -static void sche_game_init(Game *game); -static void sche_game_opening(Game *game); -static void sche_game_select_car(Game *game); -static void sche_game_select_course(Game *game); -static void sche_game_ready(Game *game); -static void sche_game_main_init(Game *game); -static void sche_game_main_ready(Game *game); -static void sche_game_main(Game *game); -static void sche_game_main_pause(Game *game); -static void sche_game_main_goal(Game *game); -static void sche_game_main_finish(Game *game); -static void sche_game_main_finish2(Game *game); - - extern int init(TaskManager *manager, int argc, char *argv[]); extern void task_initialize(); static void TMend(TaskManager *manager); @@ -153,25 +120,30 @@ return 0; }; -//ゲームの分岐に使用(コールバック) -//static int gamef = 0; -static void (*sche_func_assumption)(Game*); -static void (*sche_func)(Game*) = &sche_game_init; -static int change_state = 0; /* ゲームの分岐。magoroku の schedule の処理と同等と考えてオッケーかな? */ HTaskPtr Magoroku::application_task(HTaskPtr next, Viewer* viewer){ - // printf("gamef = %d\n",gamef); - schedule(&game); - return next; + + // 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() { @@ -180,33 +152,34 @@ int TMmain(TaskManager *manager,int argc, char *argv[]) { - for(int i = 1; i<argc ; i++) { - if (strcmp(argv[i],"-t")) { - test_mode=1; - if (i+1<argc && argv[i+1]) { - i++; - test_object=argv[i]; - } - } + 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); + task_init(); + task_initialize(); + manager->set_TMend(TMend); - return init(manager,argc, argv); + // magoroku_racing の main.ccから + //game_main(); + + return init(manager,argc, argv); } void TMend(TaskManager *manager) { - printf("game end\n"); + printf("game end\n"); } static int light_sysswitch = 0; static int light_num = 4; -/* + static void LightSysSwitch(Viewer *sgroot) { if (light_sysswitch == 1) { @@ -222,400 +195,3 @@ sgroot->OffLightSysSwitch(); } } -*/ - - - - -static void -set_schedule(Game *game) -{ - sche_func = sche_func_assumption; - change_state = 0; -} - -static void -graphic_init() -{ - gSprite_Init(); // グラフィック関連の初期化 - gFont_Init(); // フォント関連の初期化 -} - -static void -play_init( Game *game ) -{ - game->jiki = car_init(game->car_id); - carNode_append(game->jiki); - field_init(game->course_id); -} - -// 適当に自作 :miya -void linda_env_init( void ) -{ - printf("linda_env_init\n"); -} - -static void game_env_init ( Game *game ) -{ - game->car_id = 1; - game->course_id = 1; - game->camera_type = 0; - game->rap = 1; - game->jiki = NULL; - - ranking = 0; - - wait_init(); - linda_env_init(); -} - - - -void -sche_game_init(Game *game) -{ - game_env_init(game); - graphic_init(); - camera_init(); - -#ifdef LINDA - //sche_func = &sche_game_wait; - //set_schedule_assumption(sche_game_wait); -#else - set_schedule_assumption(sche_game_opening); -#endif -} - -/** - * 通信対戦専用 - * 全ユーザが接続するまで待つ - * ・・・だったんだけど、現在 linda を切っているため worning が出る。 - * ので cut する。 - */ - -/* linda を使用しないのでカットした -static void -sche_game_wait(Game *game) -{ - gFont_SetString("WAITING...", 200, 100); - set_schedule_assumption(sche_game_wait_ready); -} -*/ - - -/** - * 通信対戦専用 - * 全ユーザの接続を確認したら呼び出す - * こいつも、linda がないので cut -*/ - /* -static void -sche_game_wait_ready(Game *game) -{ - gFont_SetString("CONNECT OK!!", 170, 300); - if (game->play_id == 1) { - gFont_SetString(" PUSH START ", 170, 400); - if (pad.st != 1) { goto WAIT_READY; } - } - - set_schedule_assumption(sche_game_opening); - - WAIT_READY: - return; -} - */ - - -void -sche_game_opening(Game *game) -{ - static int blink_count = 0; - if (game->play_id==1){ - if (blink_count < 35) { - gFont_SetString("PUSH START !!", 170, 380); - } - blink_count = (blink_count > 70) ? 0 : blink_count + 1; - - if (pad.st != 1) { goto OPENING; } - } - - - set_schedule_assumption(sche_game_select_car); - - OPENING: - return; - - - if (game->play_id == 1) { - if (title_scene() < 0){ - } - } else if (game->play_id == 2) { - if (i==0){ - title_init_call(); - i=1; - } - } - - -} - -void -sche_game_select_car(Game *game) -{ - if (i==1){ - title_finish_call(); - i=2; - } - gSprite_PutSpriteEx(SP_SEL_CAR+game->car_id, 190, 200, 1.5, 1.5); - gSprite_PutSprite(24, 460, 300); - gSprite_PutSprite(25, 120, 300); - gFont_SetString("SELECT CAR", 180, 50); - - if (pad.right == 1) { - game->car_id = - (game->car_id > MAXCAR-1) ? 1 : game->car_id + 1; - } - if (pad.left == 1) { - game->car_id = - (game->car_id < 2) ? MAXCAR : game->car_id - 1; - } - - if (game->play_id == 1) - if (pad.circle != 1) { goto SELECT_CAR; } - - - set_schedule_assumption(sche_game_select_course); - - SELECT_CAR: - return; -} - -void -sche_game_select_course(Game *game) -{ - gSprite_PutSpriteEx(SP_SEL_COURSE+game->course_id, 190, 200, 1.7, 1.8); - gSprite_PutSprite(24, 460, 300); - gSprite_PutSprite(25, 120, 300); - - gFont_SetString("SELECT COURSE", 150, 50); - - if (game->play_id == 1) { - if (pad.right == 1) { - game->course_id = - (game->course_id > MAXFIELD-1) ? 1 : game->course_id + 1; - goto SELECT_COURSE; - } - if (pad.left == 1) { - game->course_id = - (game->course_id < 2) ? MAXFIELD : game->course_id - 1; - goto SELECT_COURSE; - } - - if (pad.circle != 1) { goto SELECT_COURSE; } - } - - set_schedule_assumption(sche_game_ready); - - SELECT_COURSE: - return; - -} - -void -sche_game_ready(Game *game) -{ - static int blink_count = 0;// - - gSprite_PutSprite(27+game->play_id,265,10); - gSprite_PutSpriteEx(SP_SEL_CAR+game->car_id, 50, 120, 1.5, 1.5); - gSprite_PutSpriteEx(SP_SEL_COURSE+game->course_id, 340, 120, 1.7, 1.8); - - /* 点滅 */ - if (blink_count < 35) { - gFont_SetString("GAME START !!", 170, 380); - } - blink_count = (blink_count > 70) ? 0 : blink_count + 1; - - set_schedule_assumption(sche_game_main_init); - - - if (pad.st == 1) { - set_schedule_assumption(sche_game_main_init); - } - if (pad.cross > 0) { - set_schedule_assumption(sche_game_select_car); - } - -} - -void -sche_game_main_init(Game *game) -{ - if (!game->jiki) - play_init(game); - RUNNIG=0; - - set_schedule_assumption(sche_game_main_ready); -} - -static void -sche_game_main_ready(Game *game) -{ - gFont_SetString("Loading....", 180, 100); - set_schedule_assumption(sche_game_main); -} - -static void -sche_game_main(Game *game) -{ - //flip - - /** begin: dispaly RAP TIME **/ - if(RUNNIG==0){ - start_time = game_time_get_msec(); - RUNNIG=1; - } - - time_count = game_time_get_msec() - start_time; - game_time_set_raptime(raptime,time_count); - gFont_SetString("TIME",300,20); - gFont_SetString(raptime,400,20); - /** end: dispaly RAP TIME **/ - - // light_init と init_lightの書き間違え? - init_light(&l); - set_light(&l); - - car_id_update(game, game->jiki); - - field_update(game->jiki); - camera_update(game,game->jiki->body->transfer); - carNode_draw(); - - gFont_SetStringInt(game->rap, 50, 100); - - /* スピードメーター */ - gSprite_DefSprite(23, 1, 1,(int)(106.0*(game->jiki->speed/game->jiki->speed_max)), 34); - gSprite_PutSprite(23, 400, 400); - /* km/h */ - gSprite_PutSprite(26, 470, 350); - /* Rap */ - gSprite_PutSprite(27, 80, 100); - - if (game->rap > MAXRAP) { - ranking = 1; - set_schedule_assumption(sche_game_main_goal); - } - - gFont_SetStringInt((int)(100.0*game->jiki->speed), 380, 350); - - - if ((pad.right > 0) && ((game->jiki->speed != 0) || (pad.circle > 0))) { - car_swerve(game->jiki, 1); - } - if ((pad.left > 0) && ((game->jiki->speed != 0) || (pad.circle > 0))) { - car_swerve(game->jiki, -1); - } - if (pad.circle > 0) { - car_accelerate(game->jiki, 1); - } - if (pad.cross > 0) { - car_accelerate(game->jiki, -1); - } - - if (pad.r1 == 1) { - game->camera_type = !game->camera_type; - } - if (pad.st == 1) { - set_schedule_assumption(sche_game_main_pause); - } - - //S-dandy の obj てきな -} - - -void -sche_game_main_pause(Game *game) -{ - static int select = 0; - - field_update(game->jiki); - carNode_draw(); - - if (game->play_id == 1) { - // 選択マーク - gSprite_PutSprite(17, 100, 190+select*100); - - gFont_SetString("BACK TO GAME", 200, 200); - gFont_SetString("GO TO TITLE", 200, 300); - } else { - gFont_SetString("Pause ...", 200, 200); - } - - - if (pad.circle == 1) { - if (select == 0) { - set_schedule_assumption(sche_game_main); - } else { - set_schedule_assumption(sche_game_main_finish); - } - } else if (pad.st == 1) { - set_schedule_assumption(sche_game_main); - } else if (pad.up == 1 || pad.down == 1) { - select = !select; - } - -} - - -void -sche_game_main_goal(Game *game) -{ - /** dispaly TOTAL TIME **/ - game_time_set_raptime(raptime,time_count); - - gFont_SetString("TOTAL TIME",150,20); - gFont_SetString(raptime,400,20); - gFont_SetString("GOAL !!", 220, 150); - -#ifdef LINDA - if (ranking == 1) - gFont_SetString("You WIN!!", 200, 250); - else - gFont_SetString("You Lose...", 200, 250); -#endif - - - // 宣言では引数が二つだったから、第一引数に game を入れてみた - car_update(game, game->jiki); - field_update(game->jiki); - carNode_draw(); - camera_update(game,game->jiki->body->transfer); - - if (pad.st == 1) { - set_schedule_assumption(sche_game_main_finish); - } - -} - -void -sche_game_main_finish(Game *game) -{ - field_destroy(); - carNode_destroy(); - game_env_init(game); - - set_schedule_assumption(sche_game_main_finish2); -} - -void -sche_game_main_finish2(Game *game) -{ - gFont_SetString("GAME OVER ...", 200, 200); - - - if (pad.st == 1) { - set_schedule_assumption(sche_game_opening); - } - -}
--- a/Magoroku.h Thu Jun 09 18:07:46 2011 +0900 +++ b/Magoroku.h Wed Jun 15 23:31:59 2011 +0900 @@ -8,13 +8,14 @@ #include "Func.h" class Magoroku : public Application { - bool app_loop(Viewer *viewer); - HTaskPtr application_task(HTaskPtr next, Viewer* viewer); - MainLoopPtr init(Viewer *viewer, int w, int h); + bool app_loop(Viewer *viewer); + HTaskPtr application_task(HTaskPtr next, Viewer* viewer); + MainLoopPtr init(Viewer *viewer, int w, int h); }; extern Viewer *droot; + typedef void (*move)(SceneGraphPtr node, void *sgroot_, int w, int h); typedef void (*coll)(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree);
--- a/Makefile Thu Jun 09 18:07:46 2011 +0900 +++ b/Makefile Wed Jun 15 23:31:59 2011 +0900 @@ -10,25 +10,16 @@ LIBS += `sdl-config --libs`,-framework,OpenGL -lSDL_mixer -lSDL_image `xml2-config --libs` LIBS += -lCerium -lFifoManager -TARGET = demo #dandy test1 +TARGET = magoroku #dandy test1 OBJS = ${SRCS:.cc=.o} all: $(TARGET) -test: $(TARGET) - ./demo -test - -demo: $(OBJS) - $(CC) $(ABI) -o $@ $(OBJS) $(LIBS) - -magoroku: $(OBJS) Dandy.o SgoexCerium.o - $(CC) $(ABI) -o $@ $(OBJS) Dandy.o SgoexCerium.o $(LIBS) - -test1: $(OBJS) Test.o SgoexCerium.o - $(CC) $(ABI) -o $@ $(OBJS) Test.o SgoexCerium.o $(LIBS) +magoroku: $(OBJS) Magoroku.o SgoexCerium.o + $(CC) $(ABI) -o $@ $(OBJS) Magoroku.o SgoexCerium.o $(LIBS) clean: - rm -f $(TARGET) $(OBJS) #main.o sgoex.o Dandy.o SgoexCerium.o Test.o + rm -f $(TARGET) $(OBJS) main.o sgoex.o Magoroku.o SgoexCerium.o Test.o .c.o: $(CC) $(CFLAGS) $(INCLUDES) -c $<
--- a/Makefile.def Thu Jun 09 18:07:46 2011 +0900 +++ b/Makefile.def Wed Jun 15 23:31:59 2011 +0900 @@ -15,6 +15,3 @@ LIBS += `sdl-config --libs`, -framework, OpenGL -lSDL_mixer -lSDL_image `xml2-config --libs` LIBS += -lCerium -lFifoManager - - -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SgoexCerium.cc Wed Jun 15 23:31:59 2011 +0900 @@ -0,0 +1,347 @@ + +#include "matrix_calc.h" +#include "TaskManager.h" +#include "SceneGraph.h" +#include "Application.h" + +#include "SgoexCerium.h" + +#include "gSprite.h" + +extern Viewer *droot; + +static SceneGraphPtr root; + +void +flip() +{ + CameraPtr camera = droot->sgroot->getCamera(); + + droot->sgroot->flip(); + droot->sgroot->lightCalc(); + + root = droot->createSceneGraph(); + //root->xyz[0] = screen_w/2; + //root->xyz[1] = screen_h/2;; + root->xyz[0] = 0; + root->xyz[1] = 0; + root->xyz[2] = 30.0f; + + /*親の回転、座標から、子の回転、座標を算出*/ + get_matrix(root->matrix, root->angle, root->xyz, camera->matrix); + /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ + get_matrix(root->real_matrix, root->angle, root->xyz, camera->real_matrix); + + droot->setSceneData(root); +} + + +SpriteTable sptable[DEFOBJ]; + + +void +DefSpriteEx(int number, short middlex, short middley) +{ + sptable[number].mx = middlex; + sptable[number].my = middley; +} + + +void +DefSprite(int number, const char *name, float w, float h, int color, OBJECT *obj) +{ + SpriteTable *m = &sptable[number]; + m->w = w; + m->h = h; + m->color = (color & 32); + m->mx = w / 2; + m->my = h / 2; + m->tex_w = power_of_two(m->w); + m->tex_h = power_of_two(m->h); + m->texture = (int *)name; +} + +static float my_scale = 5; + +void +PutSprite(int zorder, short x, short y, int number) +{ + SpriteTable *m = &sptable[number]; + char *name = (char *) m->texture; + if (!name) { + printf("PutSprite %d unknown\n",number); + return; + } + SceneGraphPtr object = droot->createSceneGraph(name); + //object->c_xyz[0] = m->mx; + //object->c_xyz[1] = m->my; + root->addChild(object); + + object->xyz[0] -= object->c_xyz[0]*my_scale; + object->xyz[1] -= object->c_xyz[1]*my_scale; + object->xyz[2] -= object->c_xyz[2]; + + object->xyz[0] += x+m->mx; + object->xyz[1] += y+m->my; + object->xyz[2] += zorder * 0.01; + + float scale[] = {my_scale,my_scale,1}; + //float c_xyz[] = {0,0,0}; + //scale_matrix(object->matrix, scale, c_xyz); + + /*親の回転、座標から、子の回転、座標を算出*/ + // get_matrix_scale(object->matrix, object->angle, object->xyz, scale, root->matrix); + + /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ + // get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); +} + +void +PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle) +{ + if (1) { + PutSprite(1, x, y, number); + return; + } + + SpriteTable *m = &sptable[number]; + char *name = (char *) m->texture; + if (!name) { + printf("PutSpriteEx %d unknown\n",number); + return; + } + SceneGraphPtr object = droot->createSceneGraph(name); + root->addChild(object); + + float scale[] = {my_scale*scalex*4,my_scale*scaley*4,1}; + + /*親の回転、座標から、子の回転、座標を算出*/ + object->xyz[0] = x - object->c_xyz[0] * my_scale - m->w*my_scale; + object->xyz[1] = y - object->c_xyz[1] * my_scale - m->h*my_scale; + object->xyz[2] = number * 0.01; + //object->c_xyz[0] = m->mx; + //object->c_xyz[1] = m->my; + object->angle[3] = angle * (3.1415926*2/4096); + get_matrix(object->matrix, object->angle, object->xyz, root->matrix); + float c_xyz[] = {0,0,0}; + scale_matrix(object->matrix, scale, c_xyz); + /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ + // get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); +} + + +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/SgoexCerium.h Wed Jun 15 23:31:59 2011 +0900 @@ -0,0 +1,28 @@ +#ifndef SgoexCerium_h +#define SgoexCerium_h + +//#include "sgoex.h" +#include "controler.h" +//#incldue "gSprite.h" + +#include "libps2.h" + +//extern SpriteTable sptable[DEFOBJ]; + +extern void flip(); +extern void DefSpriteEx(int number, short middlex, short middley); +extern void DefSprite(int number, const char *name, float w, float h, int color, OBJECT *obj); +extern void PutSprite(int zorder, short x, short y, int number); +extern void PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle); + +extern struct SGO_PAD pad[2]; +//extern struct SGO_PAD pad; + +/* コントローラ状態の読み込み */ +extern void Pad(SDL_Joystick *joy); + + +//extern void keybord(); +extern bool keybord( void ); + +#endif
--- a/TAGS Thu Jun 09 18:07:46 2011 +0900 +++ b/TAGS Wed Jun 15 23:31:59 2011 +0900 @@ -1,34 +1,281 @@ -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 +Magoroku.h,121 +#define INCLUDE_MAGOROKU_H2,27 +class Magoroku 10,170 +typedef void (*move)move18,378 +typedef void (*coll)coll19,449 + +SgoexCerium.h,27 +#define SgoexCerium_h2,22 + +camera.h,74 +#define CAMERA_H2,17 +typedef struct camera{camera7,74 +} CAMERA;12,158 + +car.h,74 +#define CAR_H4,27 +typedef struct car 9,83 +} Car, *CarPtr;CarPtr22,479 + +carNode.h,23 +#define CARNODE_H2,18 + +col.h,157 +#define COL_H2,14 +typedef struct detection_face 8,72 +} ColFace, *ColFacePtr;ColFacePtr13,164 +typedef struct col_face_handler 15,189 +} ColFaceHd;19,285 + +controler.h,580 +#define CONTROLER_H4,22 +#define DEFOBJ 8,61 +#define MAXOBJ 9,113 +#define BOOL 10,162 +#define TRUE 11,201 +#define FALSE 12,236 +#define PS2_CROSS 16,286 +#define PS2_CIRCLE 17,306 +#define PS2_SQUARE 18,327 +#define PS2_TRIANGLE 19,348 +#define PS2_L1 21,372 +#define PS2_R1 22,389 +#define PS2_L2 23,406 +#define PS2_R2 24,423 +#define PS2_START 25,440 +#define PS2_SELECT 26,460 +#define PS2_L3 27,481 +#define PS2_R3 28,499 +#define PS2_LEFT 30,518 +#define PS2_RIGHT 31,538 +#define PS2_UP 32,559 +#define PS2_DOWN 33,577 +typedef struct SGO_PAD 44,730 +} SGO_PAD;59,947 + +field.h,225 +#define FIELD_H2,16 +#define EFFECT_TEXTURE_USE 14,336 +#define EFFECT_ALPHABLEND_UNUSE 15,365 +#define EFFECT_SHADING_FLAT 16,399 +#define DEFAULT_SET 18,430 +typedef struct field 19,519 +} Field, *FieldPtr;FieldPtr27,705 + +gSprite.h,112 +#define GSPRITE_H2,18 +#define SPRITE_PRIO_FOREGROUND 5,81 +typedef struct sptable 7,115 +} SpriteTable;27,378 + +game.h,81 +#define GAME_H4,29 +typedef struct game 14,148 +} Game, *GamePtr;GamePtr21,332 + +libps2.h,301 +#define LIBPS2_H3,18 +typedef float FVECTOR[FVECTOR9,75 +typedef float FMATRIX[FMATRIX10,131 +typedef SceneGraph OBJECT;51,1640 +typedef struct texture 53,1668 +} TEXTURE;61,2074 +} GsPrim;75,2253 +} GsSpritePacket;84,2373 +} SPRITE;96,2675 +typedef struct popygon 105,2771 +} PolygonInfo;108,2823 + +light.h,16 +} LIGHT;11,159 + +linda.h,723 +#define LINDA_H2,16 +#define MODE_INIT 21,547 +#define MODE_WAIT 22,579 +#define MODE_WAIT_READY 23,611 +#define MODE_OPENING 24,643 +#define MODE_SELECT_CAR 25,675 +#define MODE_SELECT_COURSE 26,707 +#define MODE_READY 27,739 +#define MODE_MAIN_INIT 28,771 +#define MODE_MAIN_READY 29,803 +#define MODE_MAIN 30,835 +#define MODE_MAIN_PAUSE 31,867 +#define MODE_MAIN_GOAL 32,899 +#define MODE_MAIN_FINISH 33,931 +#define MODE_FINISH 34,963 +#define PLAYER_1P 36,996 +#define CLIENT_MAX 38,1017 +#define LINDA_ASK_ID 39,1038 +#define LINDA_HOST 40,1065 +#define PKT_MODE_OFFSET 43,1117 +#define PKT_CARID_OFFSET 44,1148 +#define PKT_COURSEID_OFFSET 45,1179 +#define PKT_DATA_OFFSET 46,1210 +#define PKT_HEADER_SIZE 48,1242 + +mytype.h,211 +#define RADIAN(4,33 +#define INIT_VECTOR(5,68 +#define NORM(6,137 +enum { X_AXIS=8,215 +enum { X_AXIS=0, Y_AXIS=8,215 +enum { X_AXIS=0, Y_AXIS=1, Z_AXIS=8,215 +enum { X_AXIS=0, Y_AXIS=1, Z_AXIS=2, W_AXIS=8,215 + +name_dictionary.h,31 +#define NAME_DICTIONARY_H2,26 + +object.h,250 +#define OBJECT_H2,17 +typedef float FVECTOR[FVECTOR5,36 +typedef float FMATRIX[FMATRIX6,62 +typedef struct width_height{width_height8,92 +} WX;11,143 +typedef struct surface 13,151 +} SURFACE;28,480 +typedef struct object 30,492 +} OBJECT;36,706 + +ps2util.h,142 +#define JOYPAD_1 4,48 +#define PS2UTIL_H8,87 +#define ALIGN_16BYTE 14,153 +typedef struct ps2sprite{ps2sprite28,427 +} ps2utilSprite;30,473 + +quotanion.h,25 +#define QUOTANION_H2,20 + +schedule.h,24 +#define SCHEDULE_H3,36 + +sgoex.h,592 +#define SGOEX_H2,16 +#define DEFOBJ 6,51 +#define MAXOBJ 7,103 +#define BOOL 8,152 +#define TRUE 9,191 +#define FALSE 10,226 +#define PS2_CROSS 13,275 +#define PS2_CIRCLE 14,295 +#define PS2_SQUARE 15,316 +#define PS2_TRIANGLE 16,337 +#define PS2_L1 17,360 +#define PS2_R1 18,377 +#define PS2_L2 19,394 +#define PS2_R2 20,411 +#define PS2_START 21,428 +#define PS2_SELECT 22,448 +#define PS2_L3 23,469 +#define PS2_R3 24,487 +typedef struct SGO_PAD 42,759 +} SGO_PAD;62,1058 +typedef struct SpriteView 64,1070 +} SpriteView;72,1202 +typedef struct SpriteTable 75,1218 +} SpriteTable;88,1414 + +sjoy.h,681 +#define SJOY_PS2_R_LEFT 10,273 +#define SJOY_PS2_R_DOWN 11,309 +#define SJOY_PS2_R_UP 12,350 +#define SJOY_PS2_R_RIGHT 13,391 +#define SJOY_PS2_L1 14,432 +#define SJOY_PS2_R1 15,473 +#define SJOY_PS2_L2 16,514 +#define SJOY_PS2_R2 17,555 +#define SJOY_PS2_SELECT 18,596 +#define SJOY_PS2_START 19,637 +#define SJOY_PS2_L_LEFT 20,678 +#define SJOY_PS2_L_DOWN 21,720 +#define SJOY_PS2_L_UP 22,762 +#define SJOY_PS2_L_RIGHT 23,804 +#define SJOY_PS2_SQUARE 26,862 +#define SJOY_PS2_CROSS 27,898 +#define SJOY_PS2_TRIANGLE 28,939 +#define SJOY_PS2_CIRCLE 29,980 +#define SJOY_PS2_LEFT 30,1021 +#define SJOY_PS2_DOWN 31,1063 +#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 +#define FRAME_ANGLE_REVERSE_VERTICAL 3,78 +#define FRAME_ANGLE_ROTATE_180 4,117 +#define UNVISIBLE 7,190 +#define VISIBLE 8,210 +typedef struct sprite_frame 11,237 +} SPRITE_FRAME;21,401 +typedef struct sprite_polygon 23,418 +} SPRITE_POLYGON;36,679 +typedef struct sprite_polygon_head 38,698 +} SPRITE_POLYGON_HEAD;44,897 +#define free_sprite_frame 49,1067 +} GsPrim;69,1649 +} GsSpritePacket;87,2043 +} SpritePacketHeader;102,2557 + +Magoroku.cc,660 +int runmode;69,1563 +SDL_Joystick *joy;joy71,1577 +const char *usr_help_str usr_help_str75,1599 +Viewer *droot;droot79,1785 +static int screen_w;81,1801 +static int screen_h;82,1825 +Magoroku::init(86,1910 +Application *application(application94,2028 +static int start_time,101,2128 +static int start_time,time_count;101,2128 +static int RUNNIG=102,2162 +char raptime[raptime103,2183 +static int ranking 105,2202 +static LIGHT l;106,2226 +static int i=107,2242 +Magoroku::app_loop(137,3160 +Magoroku::application_task(147,3356 +task_init(156,3509 +TMmain(161,3531 +TMend(179,3819 +static int light_sysswitch 184,3878 +static int light_num 185,3910 + +SgoexCerium.cc,269 +static SceneGraphPtr root;13,172 +flip(16,205 +SpriteTable sptable[sptable39,857 +DefSpriteEx(43,893 +DefSprite(51,1022 +static float my_scale 64,1325 +PutSprite(67,1358 +PutSpriteEx(100,2428 +struct SGO_PAD pad[pad133,3569 +void Pad(137,3640 +void keybord(242,5533 Ss.cc,403 int SsUtKeyOn(11,255 @@ -227,43 +474,37 @@ void delete_name_dictionary(62,1356 int init_name_dictionary(87,1914 -ps2util.cc,1294 +ps2util.cc,1098 OBJECT *ps2util_obj_Create_fromXML(ps2util_obj_Create_fromXML16,366 void ps2util_obj_Set_effect(33,645 void ps2_vu0_copy_vector(39,767 void ps2util_obj_Renew_transMatrix(45,889 -TEXTURE* read_png_file(53,987 -int ps2util_tex_Set(64,1159 -int ps2util_sprite_Create(69,1211 -void ps2util_obj_Set_texture(75,1296 -void ps2_vu0_unit_matrix(81,1426 -void ps2_vu0_rot_matrix_y(95,2019 -void ps2_vu0_apply_matrix(119,2653 -void ps2_vu0_scale_vector(128,3051 -void ps2_vu0_add_vector(138,3402 -void ps2_vu0_outer_product(148,3622 -float ps2_vu0_inner_product(157,3859 -void ps2_vu0_mul_matrix(163,3973 -void ps2_vu0_copy_matrix(187,5710 -void ps2util_obj_Free(192,5815 -void ps2_vu0_sub_vector(199,5870 -void ps2_vu0_normalize(209,6060 -void xml_free(220,6307 -void ps2util_obj_Draw(226,6353 -void ps2util_sprite_Destroy(232,6406 -void ps2util_sprite_Set_basicAttribute(240,6482 -void ps2util_sprite_Request(250,6788 -void ps2util_sprite_Unuse_alpha(256,6849 -void ps2util_graphic_Init(261,6914 -#define SPRITE_HAS_4VERTEXIS 270,7010 -#define PS2_GS_XYZ3 272,7042 -sprite_disappear(275,7134 -void free_texture(289,7461 -int malloc_align16(305,7793 -void ps2util_tex_Exclude(329,8321 -void ps2util_sprite_Draw(334,8396 -void ps2util_graphic_Finish(339,8465 -void ps2util_sprite_Use_alpha(346,8567 +void ps2_vu0_unit_matrix(83,1491 +void ps2_vu0_rot_matrix_y(97,2084 +void ps2_vu0_apply_matrix(121,2718 +void ps2_vu0_scale_vector(130,3116 +void ps2_vu0_add_vector(140,3467 +void ps2_vu0_outer_product(150,3687 +float ps2_vu0_inner_product(159,3924 +void ps2_vu0_mul_matrix(165,4038 +void ps2_vu0_copy_matrix(189,5775 +void ps2util_obj_Free(194,5880 +void ps2_vu0_sub_vector(201,5935 +void ps2_vu0_normalize(211,6125 +void xml_free(222,6372 +void ps2util_obj_Draw(228,6428 +void ps2util_sprite_Destroy(236,6575 +void ps2util_sprite_Set_basicAttribute(244,6681 +void ps2util_sprite_Request(254,6987 +void ps2util_sprite_Unuse_alpha(260,7048 +void ps2util_graphic_Init(265,7113 +#define SPRITE_HAS_4VERTEXIS 274,7209 +#define PS2_GS_XYZ3 276,7241 +sprite_disappear(279,7333 +int malloc_align16(313,8039 +void ps2util_sprite_Draw(344,8675 +void ps2util_graphic_Finish(349,8744 +void ps2util_sprite_Use_alpha(356,8846 quotanion.cc,69 quotanion(11,226 @@ -300,13 +541,13 @@ 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 +sche_game_main_pause(399,8067 +sche_game_main_goal(433,8767 +sche_game_main_finish(463,9445 +sche_game_main_finish2(473,9604 +void wait_sync(485,9794 +void swap_dbuff(491,9864 +schedule(497,9920 sjoy.cc,437 #define N_JOY 14,195 @@ -373,205 +614,6 @@ title_finish_call(58,919 title_scene(64,966 -Magoroku.h,121 -#define INCLUDE_MAGOROKU_H2,27 -class Magoroku 10,170 -typedef void (*move)move18,384 -typedef void (*coll)coll19,455 - -camera.h,74 -#define CAMERA_H2,17 -typedef struct camera{camera7,74 -} CAMERA;12,158 - -car.h,135 -#define CAR_H4,27 -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 - -col.h,157 -#define COL_H2,14 -typedef struct detection_face 8,72 -} ColFace, *ColFacePtr;ColFacePtr13,164 -typedef struct col_face_handler 15,189 -} ColFaceHd;19,285 - -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 -#define EFFECT_TEXTURE_USE 14,336 -#define EFFECT_ALPHABLEND_UNUSE 15,365 -#define EFFECT_SHADING_FLAT 16,399 -#define DEFAULT_SET 18,430 -typedef struct field 19,519 -} Field, *FieldPtr;FieldPtr27,705 - -gSprite.h,112 -#define GSPRITE_H2,18 -#define SPRITE_PRIO_FOREGROUND 5,81 -typedef struct sptable 7,115 -} SpriteTable;12,188 - -game.h,20 -#define GAME_H4,29 - -libps2.h,360 -#define LIBPS2_H3,18 -typedef float FVECTOR[FVECTOR7,50 -typedef float FMATRIX[FMATRIX8,106 -typedef struct texture 13,195 -} TEXTURE;21,601 -typedef struct surface 25,648 -} SURFACE;34,1191 -typedef struct object 38,1244 -} OBJECT;45,1513 -} GsPrim;58,1690 -} GsSpritePacket;67,1810 -} SPRITE;79,2112 -typedef struct popygon 88,2208 -} PolygonInfo;91,2260 - -light.h,16 -} LIGHT;11,159 - -linda.h,723 -#define LINDA_H2,16 -#define MODE_INIT 21,547 -#define MODE_WAIT 22,579 -#define MODE_WAIT_READY 23,611 -#define MODE_OPENING 24,643 -#define MODE_SELECT_CAR 25,675 -#define MODE_SELECT_COURSE 26,707 -#define MODE_READY 27,739 -#define MODE_MAIN_INIT 28,771 -#define MODE_MAIN_READY 29,803 -#define MODE_MAIN 30,835 -#define MODE_MAIN_PAUSE 31,867 -#define MODE_MAIN_GOAL 32,899 -#define MODE_MAIN_FINISH 33,931 -#define MODE_FINISH 34,963 -#define PLAYER_1P 36,996 -#define CLIENT_MAX 38,1017 -#define LINDA_ASK_ID 39,1038 -#define LINDA_HOST 40,1065 -#define PKT_MODE_OFFSET 43,1117 -#define PKT_CARID_OFFSET 44,1148 -#define PKT_COURSEID_OFFSET 45,1179 -#define PKT_DATA_OFFSET 46,1210 -#define PKT_HEADER_SIZE 48,1242 - -mytype.h,211 -#define RADIAN(4,33 -#define INIT_VECTOR(5,68 -#define NORM(6,137 -enum { X_AXIS=8,215 -enum { X_AXIS=0, Y_AXIS=8,215 -enum { X_AXIS=0, Y_AXIS=1, Z_AXIS=8,215 -enum { X_AXIS=0, Y_AXIS=1, Z_AXIS=2, W_AXIS=8,215 - -name_dictionary.h,31 -#define NAME_DICTIONARY_H2,26 - -ps2util.h,142 -#define JOYPAD_1 4,48 -#define PS2UTIL_H8,87 -#define ALIGN_16BYTE 14,153 -typedef struct ps2sprite{ps2sprite28,427 -} ps2utilSprite;30,473 - -quotanion.h,25 -#define QUOTANION_H2,20 - -schedule.h,24 -#define SCHEDULE_H3,36 - -sjoy.h,681 -#define SJOY_PS2_R_LEFT 10,273 -#define SJOY_PS2_R_DOWN 11,309 -#define SJOY_PS2_R_UP 12,350 -#define SJOY_PS2_R_RIGHT 13,391 -#define SJOY_PS2_L1 14,432 -#define SJOY_PS2_R1 15,473 -#define SJOY_PS2_L2 16,514 -#define SJOY_PS2_R2 17,555 -#define SJOY_PS2_SELECT 18,596 -#define SJOY_PS2_START 19,637 -#define SJOY_PS2_L_LEFT 20,678 -#define SJOY_PS2_L_DOWN 21,720 -#define SJOY_PS2_L_UP 22,762 -#define SJOY_PS2_L_RIGHT 23,804 -#define SJOY_PS2_SQUARE 26,862 -#define SJOY_PS2_CROSS 27,898 -#define SJOY_PS2_TRIANGLE 28,939 -#define SJOY_PS2_CIRCLE 29,980 -#define SJOY_PS2_LEFT 30,1021 -#define SJOY_PS2_DOWN 31,1063 -#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 -#define FRAME_ANGLE_REVERSE_VERTICAL 3,78 -#define FRAME_ANGLE_ROTATE_180 4,117 -#define UNVISIBLE 7,190 -#define VISIBLE 8,210 -typedef struct sprite_frame 11,237 -} SPRITE_FRAME;21,401 -typedef struct sprite_polygon 23,418 -} SPRITE_POLYGON;36,679 -typedef struct sprite_polygon_head 38,698 -} SPRITE_POLYGON_HEAD;44,897 -#define free_sprite_frame 49,1067 -} GsPrim;69,1649 -} GsSpritePacket;87,2043 -} SpritePacketHeader;102,2557 - title_scene.h,0 game_time.h,0 @@ -579,3 +621,5 @@ gFont.h,0 Ss.h,0 + +LoadSprite.h,0
--- a/car.cc Thu Jun 09 18:07:46 2011 +0900 +++ b/car.cc Wed Jun 15 23:31:59 2011 +0900 @@ -27,7 +27,7 @@ { CarPtr car; OBJECT *body; - TEXTURE* tex; + //TEXTURE* tex; void *free_addr; body = ps2util_obj_Create_fromXML(filename); @@ -56,11 +56,13 @@ ps2util_obj_Renew_transMatrix(car->body); ps2util_obj_Set_effect(car->body, DEFAULT_SET); + /* if (*texname != 'n') { tex = read_png_file(texname); ps2util_tex_Set(tex); ps2util_obj_Set_texture(car->body, tex); } + */ #ifdef DEBUG fprintf(main_fp, "malloc car addr = %x\n", (int)free_addr); @@ -98,7 +100,7 @@ sscanf(bufp, " %s %s %f %f %f %f\n", carImg, texImg, &speed_accel, &speed_max, &rot, &brake); newCar = car_create(id, carImg, texImg, - speed_accel, speed_max, rot, brake); + speed_accel, speed_max, rot, brake); return newCar; } break; @@ -278,12 +280,15 @@ void car_destroy(CarPtr p) { + /* TEXTURE *t; if ((t = p->body->surfaces->texture)) { - ps2util_tex_Exclude(t); + //ps2util_tex_Exclude(t); free_texture(t); } + */ + ps2util_obj_Free(p->body); free(p->free_addr);
--- a/car.h Thu Jun 09 18:07:46 2011 +0900 +++ b/car.h Wed Jun 15 23:31:59 2011 +0900 @@ -18,13 +18,14 @@ float y_angle; // 角度 void *free_addr; struct car *next; - OBJECT* body; + OBJECT* body; } Car, *CarPtr; /* game.h から 相互に読み込むのを禁止するために移動 */ +/* typedef struct game { CarPtr jiki; int course_id; // コースID @@ -33,7 +34,7 @@ int play_id; int rap; } Game, *GamePtr; - +*/ //extern Game *game; @@ -42,10 +43,10 @@ void car_swerve(CarPtr, int); // ここで宣言したらgame.hと相互にincludeしちゃうからschedule.hのほうに書いてしまいました -extern void car_update( Game*, CarPtr ); +//void car_update( Game*, CarPtr ); -//自作関数 -void car_id_update(Game*, CarPtr ); +//game.hに既存? //自作関数 +//void car_id_update( Game*, CarPtr ); #endif
--- a/field.cc Thu Jun 09 18:07:46 2011 +0900 +++ b/field.cc Wed Jun 15 23:31:59 2011 +0900 @@ -32,7 +32,7 @@ static FieldPtr -field_create(char *fieldImg, char *colImg, TEXTURE *tex) +field_create(char *fieldImg, char *colImg, OBJECT *tex) { FieldPtr self; OBJECT *obj; @@ -86,7 +86,8 @@ FieldPtr prevField = NULL; char buff[BUFSIZE], *bufp; char fieldImg[BUFSIZE], colImg[BUFSIZE], texname[BUFSIZE]; - TEXTURE *tex = NULL; + + //TEXTURE *tex = NULL; int course_id; bool flag = false; @@ -104,6 +105,8 @@ goto FINISH_LOAD; } break; + + /* case 't': // テクスチャのロード if (flag) { sscanf(bufp, " %s\n", texname); @@ -111,6 +114,9 @@ ps2util_tex_Set(tex); } break; + */ + + case 'c': // コースのロード if (flag) { sscanf(bufp, " %s %s\n", fieldImg, colImg); @@ -150,15 +156,15 @@ void field_init(int id) { - FILE *fp; - const char *filename = "course/course.dat"; + FILE *fp; + const char *filename = "course/course.dat"; - if (!(fp = fopen(filename, "r"))) { - fprintf(main_fp, "error read file %s\n", filename); - exit(EXIT_FAILURE); - } - field_new_readCSV(fp, id); - fclose(fp); + if (!(fp = fopen(filename, "r"))) { + fprintf(main_fp, "error read file %s\n", filename); + exit(EXIT_FAILURE); + } + field_new_readCSV(fp, id); + fclose(fp); } @@ -213,6 +219,8 @@ { FieldPtr p = field_list; FieldPtr d; + + /* TEXTURE *t; p->prev->next = NULL; @@ -234,6 +242,8 @@ field_num_max = 0; field_num = 1; + + */ } /*
--- a/gSprite.cc Thu Jun 09 18:07:46 2011 +0900 +++ b/gSprite.cc Wed Jun 15 23:31:59 2011 +0900 @@ -15,7 +15,7 @@ static unsigned int sp_counter; static bool flag_spriteInited = false; // スプライトロードフラグ -static TEXTURE *sprite_tex; +//static TEXTURE *sprite_tex; void @@ -27,41 +27,43 @@ sptable[number].th = th; } +// DandyのPutSprite関数 void gSprite_PutSprite(int number, int x, int y) { - ps2utilSprite *p = &sp[sp_counter]; + ps2utilSprite *p = &sp[sp_counter]; - ps2util_sprite_Set_basicAttribute( - p, - (unsigned short)x, (unsigned short)y, - (unsigned short)sptable[number].tw*2, (unsigned short)sptable[number].th*2, - (unsigned short)sptable[number].tx, (unsigned short)sptable[number].ty, - (unsigned short)sptable[number].tw, (unsigned short)sptable[number].th, - SPRITE_PRIO_FOREGROUND); + // テクスチャの設定 + ps2util_sprite_Set_basicAttribute( + p, + (unsigned short)x, (unsigned short)y, + (unsigned short)sptable[number].tw*2, (unsigned short)sptable[number].th*2, + (unsigned short)sptable[number].tx, (unsigned short)sptable[number].ty, + (unsigned short)sptable[number].tw, (unsigned short)sptable[number].th, + SPRITE_PRIO_FOREGROUND); - ps2util_sprite_Request(p); - sp_counter++; + // 表示 + ps2util_sprite_Request(p); + sp_counter++; } void gSprite_PutSpriteEx(int number, int x, int y, float w, float h) { - ps2utilSprite *p = &sp[sp_counter]; + ps2utilSprite *p = &sp[sp_counter]; - ps2util_sprite_Set_basicAttribute( - p, - (unsigned short)x, (unsigned short)y, - (unsigned short)sptable[number].tw*w, (unsigned short)sptable[number].th*h, - (unsigned short)sptable[number].tx, (unsigned short)sptable[number].ty, - (unsigned short)sptable[number].tw, (unsigned short)sptable[number].th, - SPRITE_PRIO_FOREGROUND); + ps2util_sprite_Set_basicAttribute( + p, + (unsigned short)x, (unsigned short)y, + (unsigned short)sptable[number].tw*w, (unsigned short)sptable[number].th*h, + (unsigned short)sptable[number].tx, (unsigned short)sptable[number].ty, + (unsigned short)sptable[number].tw, (unsigned short)sptable[number].th, + SPRITE_PRIO_FOREGROUND); - ps2util_sprite_Request(p); - sp_counter++; + ps2util_sprite_Request(p); + sp_counter++; } - static void gSprite_Init_Png(const char *texname) { @@ -78,7 +80,6 @@ fflush(stderr); exit(EXIT_FAILURE); } - } static void @@ -139,8 +140,6 @@ sp_counter = 0; } - - void gSprite_Draw_Reset() { @@ -150,7 +149,6 @@ } - void gSprite_PutSprite_Pause() {
--- a/gSprite.h Thu Jun 09 18:07:46 2011 +0900 +++ b/gSprite.h Wed Jun 15 23:31:59 2011 +0900 @@ -1,22 +1,290 @@ -#ifndef GSPRITE_H -#define GSPRITE_H +//SgoexCerium.ccより +#include "matrix_calc.h" +#include "TaskManager.h" +#include "SceneGraph.h" +#include "Application.h" + +#include <stdio.h> +#include <stdlib.h> +#include "libps2.h" +#include "ps2util.h" +#include <stdbool.h> + +#define DEFOBJ 100 +#define SPRITE_COL 0x4f +#define SCREEN_HALF_W 320 +#define SCREEN_HALF_H 240 + +static SpriteTable sptable[DEFOBJ]; +static ps2utilSprite sp[DEFOBJ]; // 表示スプライト用スタック +static unsigned int sp_counter; +static bool flag_spriteInited = false; // スプライトロードフラグ + +static TEXTURE *sprite_tex; + + + +extern Viewer *droot; -//スプライトの優先順位らしい ? -#define SPRITE_PRIO_FOREGROUND 1 +static SceneGraphPtr root; + + +//SgoexCerium.ccより +void +flip() +{ + CameraPtr camera = droot->sgroot->getCamera(); + + droot->sgroot->flip(); + droot->sgroot->lightCalc(); + + root = droot->createSceneGraph(); + //root->xyz[0] = screen_w/2; + //root->xyz[1] = screen_h/2;; + root->xyz[0] = 0; + root->xyz[1] = 0; + root->xyz[2] = 30.0f; + + /*親の回転、座標から、子の回転、座標を算出*/ + get_matrix(root->matrix, root->angle, root->xyz, camera->matrix); + /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ + get_matrix(root->real_matrix, root->angle, root->xyz, camera->real_matrix); + //出力して、次のものを出力するための準備 + droot->setSceneData(root); +} + + + + -typedef struct sptable { - int tx; - int ty; - int tw; - int th; -} SpriteTable; +/*void +gSprite_DefSprite(int number, int tx, int ty, int tw, int th) +{ + sptable[number].tx = tx; + sptable[number].ty = ty; + sptable[number].tw = tw; + sptable[number].th = th; +}*/ +void +gSprite_DefSprite(int number, const char *name, float w, float h, int color, OBJECT *obj) +{ + SpriteTable *m = &sptable[number]; + m->w = w; + m->h = h; + m->color = (color & 32); + m->mx = w / 2; //画像の中心を座標としたいらしい。 + m->my = h / 2; + m->tex_w = power_of_two(m->w); + m->tex_h = power_of_two(m->h); + m->texture = (int *)name; + +} + + + + + +/*void +gSprite_PutSprite(int number, int x, int y) +{ + ps2utilSprite *p = &sp[sp_counter]; + + ps2util_sprite_Set_basicAttribute( + p, + (unsigned short)x, (unsigned short)y, + (unsigned short)sptable[number].tw*2, (unsigned short)sptable[number].th*2, + (unsigned short)sptable[number].tx, (unsigned short)sptable[number].ty, + (unsigned short)sptable[number].tw, (unsigned short)sptable[number].th, + SPRITE_PRIO_FOREGROUND); + + ps2util_sprite_Request(p); + sp_counter++; +}*/ +void +gSprite_PutSprite(int number, short x, short y, int zorder) +{ + SpriteTable *m = &sptable[number]; + char *name = (char *) m->texture; +if (!name) { + printf("PutSprite %d unknown\n",number); + return; +} + SceneGraphPtr object = droot->createSceneGraph(name); + //object->c_xyz[0] = m->mx; + //object->c_xyz[1] = m->my; + root->addChild(object); + + object->xyz[0] -= object->c_xyz[0]*my_scale; + object->xyz[1] -= object->c_xyz[1]*my_scale; + object->xyz[2] -= object->c_xyz[2]; + + object->xyz[0] += x+m->mx; + object->xyz[1] += y+m->my; + object->xyz[2] += zorder * 0.01; + + float scale[] = {my_scale,my_scale,1}; + //float c_xyz[] = {0,0,0}; + //scale_matrix(object->matrix, scale, c_xyz); + + /*親の回転、座標から、子の回転、座標を算出*/ + //get_matrix_scale(object->matrix, object->angle, object->xyz, scale, root->matrix); + + /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ + // get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); +} + + + + -// extern とってみたけど、なにか不都合ありますか?:miya -void gSprite_Init(); -void gSprite_Draw_Reset(); -void gSprite_PutSprite(int number, int x, int y); -void gSprite_PutSpriteEx(int number, int x, int y, float w, float h); -void gSprite_DefSprite(int number, int tx, int ty, int tw, int th); +/*void +gSprite_PutSpriteEx(int number, int x, int y, float w, float h) +{ + ps2utilSprite *p = &sp[sp_counter]; + + ps2util_sprite_Set_basicAttribute( + p, + (unsigned short)x, (unsigned short)y, + (unsigned short)sptable[number].tw*w, (unsigned short)sptable[number].th*h, + (unsigned short)sptable[number].tx, (unsigned short)sptable[number].ty, + (unsigned short)sptable[number].tw, (unsigned short)sptable[number].th, + SPRITE_PRIO_FOREGROUND); + + ps2util_sprite_Request(p); + sp_counter++; +}*/ +void +PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle) +{ + if (1) { + PutSprite(1, x, y, number); + return; + } + + SpriteTable *m = &sptable[number]; + char *name = (char *) m->texture; +if (!name) { + printf("PutSpriteEx %d unknown\n",number); + return; +} + SceneGraphPtr object = droot->createSceneGraph(name); + root->addChild(object); + + float scale[] = {my_scale*scalex*4,my_scale*scaley*4,1}; + + /*親の回転、座標から、子の回転、座標を算出*/ + object->xyz[0] = x - object->c_xyz[0] * my_scale - m->w*my_scale; + object->xyz[1] = y - object->c_xyz[1] * my_scale - m->h*my_scale; + object->xyz[2] = number * 0.01; + //object->c_xyz[0] = m->mx; + //object->c_xyz[1] = m->my; + object->angle[3] = angle * (3.1415926*2/4096); + get_matrix(object->matrix, object->angle, object->xyz, root->matrix); + float c_xyz[] = {0,0,0}; + scale_matrix(object->matrix, scale, c_xyz); + /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ + // get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); +} + + + + + + + +//ここいらはどうやら、スプライトを取得する部分。 + +static void +gSprite_Init_Png(const char *texname) +{ + if (!(sprite_tex = read_png_file(texname))) { + fprintf(stderr, + "cannot creat texture - init_png().\n"); + fflush(stderr); + exit(EXIT_FAILURE); + } + + if (ps2util_tex_Set(sprite_tex) == -1) { + fprintf(stderr, + "cannot set texture - init_png().\n"); + fflush(stderr); + exit(EXIT_FAILURE); + } -#endif +} + +static void +gSprite_Create() +{ + int i; + + for (i=0; i<DEFOBJ; i++) { + if (ps2util_sprite_Create(&sp[i], sprite_tex) == -1) { + fprintf(stderr, + "cannot create sprite No.%d - create_sprite()\n", i); + fflush(stderr); + exit(EXIT_FAILURE); + } + ps2util_sprite_Unuse_alpha(&sp[i]); + } + + flag_spriteInited = false; +} + + +void +gSprite_Init() +{ + ps2util_graphic_Init(); + //gSprite_Init_Png("img/main2.png"); + //gSprite_Create(); // スプライト生成 + + sgroot->createFromXMLfile("./xml_files/boss.xml"); + + /* gSprite_DefSprite(10, 1, 1, 512, 666); // タイトル + gSprite_DefSprite(17, 1, 35, 33, 33); // 選択マーク + gSprite_DefSprite(23, 1, 1, 106, 34); // スピードメーター + gSprite_DefSprite(24, 51, 40, 18, 20); // 右矢印 + gSprite_DefSprite(25, 33, 40, 17, 20); // 左矢印 + gSprite_DefSprite(26, 56, 89, 55, 26); // km/h + gSprite_DefSprite(27, 62, 62, 39, 26); // Rap + gSprite_DefSprite(28, 430, 62, 53, 46); // 1p + gSprite_DefSprite(29, 460, 6, 53, 46); // 2P + gSprite_DefSprite(51, 333, 116, 165, 140); // 選択画面の車 + gSprite_DefSprite(52, 181, 116, 165, 140); + gSprite_DefSprite(53, 12, 116, 165, 140); + gSprite_DefSprite(81, 115, 1, 148, 114); // 選択画面のコース + // 本当は (82, 272,...)です。二つ目のコース絵がないので + gSprite_DefSprite(82, 272, 1, 148, 114);*/ + +} + + +static void +gSprite_Clear() +{ + int i; + + for (i=0; i<DEFOBJ; i++) { + sprite_disappear(&sp[i].attribute); + } + sp_counter = 0; +} + + + +void +gSprite_Draw_Reset() +{ + if (flag_spriteInited == true) { + gSprite_Clear(); + } +} + + + +void +gSprite_PutSprite_Pause() +{ +}
--- a/game.h Thu Jun 09 18:07:46 2011 +0900 +++ b/game.h Wed Jun 15 23:31:59 2011 +0900 @@ -11,12 +11,21 @@ int linda_init(); void psx_sync_n(); - +typedef struct game { + CarPtr jiki; + int course_id; // コースID + int car_id; // 自機ID + int camera_type; // カメラのタイプ + int play_id; + int rap; +} Game, *GamePtr; extern Game *game; -extern void schedule(Game *game); +//extern void schedule(Game *game); + +// car.hに書くと、game.hとお互いにincludeしてしまう +void car_id_update(Game *game, CarPtr jiki); + #endif -// car.hに書くと、game.hとお互いにincludeしてしまう -//void car_id_update(Game *game, CarPtr jiki);
--- a/libps2.h Thu Jun 09 18:07:46 2011 +0900 +++ b/libps2.h Wed Jun 15 23:31:59 2011 +0900 @@ -2,6 +2,8 @@ #ifndef LIBPS2_H #define LIBPS2_H +#include "SceneGraph.h" + //dummy file typedef float FVECTOR[4] __attribute__((aligned (16))); @@ -46,8 +48,13 @@ } OBJECT; */ -typedef SceneGraph OBJECT; + +//typedef SceneGraph OBJECT; +class OBJECT : public SceneGraph{ + public: + FMATRIX transfer; // transfer matrix +}; // sprite.hから typedef struct { //__u64 rgbaq; @@ -61,6 +68,7 @@ } GsPrim; + typedef struct { //ps2_giftag giftag; //__u64 prim; @@ -70,6 +78,7 @@ int x; } GsSpritePacket; + //ps2 依存関係内の libps2.h からもってきた typedef struct { GsSpritePacket* gs_packet; @@ -83,8 +92,6 @@ } SPRITE; - - /* 構造体 PolygonInfo が見当たらないので自作 作りは適当 @@ -96,7 +103,4 @@ int malloc_align16(void *head, void *aligned, int size); - - - #endif
--- a/ps2util.cc Thu Jun 09 18:07:46 2011 +0900 +++ b/ps2util.cc Wed Jun 15 23:31:59 2011 +0900 @@ -47,9 +47,11 @@ } + /* ps2 内の texture.c から */ + TEXTURE* read_png_file(const char *texname) { printf("trace\n"); @@ -59,8 +61,6 @@ return tex; } - - int ps2util_tex_Set(TEXTURE* tex) { return -1; @@ -77,6 +77,7 @@ //none } + // 与えられた行列を単位行列に変換する void ps2_vu0_unit_matrix(FMATRIX m) { @@ -237,7 +238,6 @@ } - //putSprite で置き換え? void ps2util_sprite_Set_basicAttribute(ps2utilSprite *p, unsigned short x, unsigned short y, @@ -299,6 +299,7 @@ } + /* ps2 依存関係内の、texture.c から拝借 この malloc によるメモリ取得をあちこちで行っているっぽい @@ -327,12 +328,12 @@ -// miya void ps2util_tex_Exclude( TEXTURE* t ) { //const char *test = "test"; } + void ps2util_sprite_Draw() { printf("ps2util_sprite_Draw()\n");
--- a/ps2util.h Thu Jun 09 18:07:46 2011 +0900 +++ b/ps2util.h Wed Jun 15 23:31:59 2011 +0900 @@ -41,9 +41,18 @@ void ps2_vu0_copy_vector( FVECTOR a, FVECTOR b); void ps2util_obj_Renew_transMatrix(OBJECT*); -TEXTURE* read_png_file(const char *texname); -int ps2util_tex_Set(TEXTURE*); -void ps2util_obj_Set_texture(OBJECT*, TEXTURE*); + +//TEXTURE* read_png_file(const char *texname); +OBJECT* read_png_file(const char *texname); + +//int ps2util_tex_Set(TEXTURE*); +int ps2util_tex_Set(OBJECT*); + + +//void ps2util_obj_Set_texture(OBJECT*, TEXTURE*); +void ps2util_obj_Set_texture(OBJECT*, OBJECT*); + + void ps2_vu0_unit_matrix( FMATRIX ); void ps2_vu0_rot_matrix_y( FMATRIX , FMATRIX , float); @@ -63,10 +72,9 @@ void ps2_vu0_copy_matrix(FMATRIX transfer, FMATRIX pose); // 一個目の引数がポインタだとコンパイル通らなかった。なんで? -void ps2util_tex_Exclude( TEXTURE* t ); +//void ps2util_tex_Exclude( TEXTURE* t ); - -void free_texture(TEXTURE *tex); +//void free_texture(TEXTURE *tex); void ps2util_obj_Free(OBJECT* p_body); @@ -83,7 +91,6 @@ void ps2util_sprite_Destroy(ps2utilSprite *title_sprite); - void ps2util_sprite_Set_basicAttribute(ps2utilSprite *p, unsigned short x, unsigned short y, unsigned short sptable_tw1, unsigned short sptable_th1, @@ -92,7 +99,9 @@ int sprite_prio_foreground); void ps2util_sprite_Request(ps2utilSprite *p); -int ps2util_sprite_Create(ps2utilSprite *sp, TEXTURE *sprite_tex); + +//int ps2util_sprite_Create(ps2utilSprite *sp, TEXTURE *sprite_tex); + void ps2util_sprite_Unuse_alpha(ps2utilSprite *sp); void ps2util_graphic_Init(); @@ -108,4 +117,3 @@ void ps2util_sprite_Use_alpha( ps2utilSprite *title ); #endif -
--- a/schedule.cc Thu Jun 09 18:07:46 2011 +0900 +++ b/schedule.cc Wed Jun 15 23:31:59 2011 +0900 @@ -59,7 +59,6 @@ static void sche_game_main_finish2(Game *game); - /* timer */ static int start_time,time_count; static int RUNNIG=0; @@ -132,7 +131,6 @@ } - void sche_game_init(Game *game) { @@ -185,7 +183,7 @@ WAIT_READY: return; } - */ +*/ void @@ -200,7 +198,6 @@ if (pad.st != 1) { goto OPENING; } } - set_schedule_assumption(sche_game_select_car); @@ -390,6 +387,8 @@ set_schedule_assumption(sche_game_main_pause); } + //S-dandy の obj てきな + } @@ -449,8 +448,8 @@ car_update(game, game->jiki); field_update(game->jiki); carNode_draw(); - camera_update(game,game->jiki->body->transfer); - + camera_update(game,game->jiki->body); + if (pad.st == 1) { set_schedule_assumption(sche_game_main_finish); } @@ -472,7 +471,6 @@ { gFont_SetString("GAME OVER ...", 200, 200); - if (pad.st == 1) { set_schedule_assumption(sche_game_opening); }
--- a/schedule.h Thu Jun 09 18:07:46 2011 +0900 +++ b/schedule.h Wed Jun 15 23:31:59 2011 +0900 @@ -3,12 +3,11 @@ #define SCHEDULE_H - // game.hからここに移動 -//void schedule(Game *game); +void schedule(Game *game); // car.hから。 -//void car_update( Game *game, CarPtr car ); +void car_update( Game *game, CarPtr car ); #endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sgoex.c Wed Jun 15 23:31:59 2011 +0900 @@ -0,0 +1,410 @@ +/* + スプライト管理関数 +*/ + +//#include<libps.h> +#include <stdio.h> +#include <SDL.h> +#include "SDL_image.h" +#include "SDL_opengl.h" +#include "texture.h" +#include "object.h" +#include "tree_controll.h" +#include "sgoex.h" +#include "trace.h" +#include "syokika.h" +#include "LoadSprite.h" + + +#define OT_LENGTH 1 /* オーダリングテーブル */ +#define MAXOBJ 320 /*スプライト表示上限 */ + +#define TRUE 1 +#define FALSE 0 + + +//static u_short tpage; +//static SDL_Rect rect; + +//static int nActiveBuff; /*ばふぁ */ +// int i; /* Multi-purpose */ +//static int pageno; + +//static int padd; + +static const int sgo_tpx[12] = +{ 0, 64, 128, 192, 256, 320, 0, 64, 128, 192, 256, 320 }; +static const int sgo_tpy[12] = { 0, 0, 0, 0, 0, 0, 256, 256, 256, 256, 256, 256 }; + +/* sgo.h 独自の変数形 */ +SpriteTable sptable[DEFOBJ]; +// static SpriteView spview[MAXOBJ]; + +#define IMAGE_ADJUSTMENT (0) + +/** + * 一つの画像をpageno(page number)で区切るtexture_page_offsetで + * pagenoに対応した領域のx,yを用意しておく。PlayStationではpageno + * で区切る必要があったのだろうが、PS2では全く意味はなさない。 + */ +static const struct texture_page_offset { + int x; + int y; +} texpage_offset[] = { + {0, 0}, {128 + IMAGE_ADJUSTMENT, 0}, {256 + IMAGE_ADJUSTMENT, 0}, {384 + IMAGE_ADJUSTMENT, 0}}; + +/*------------------------------------------------------------- + 関数プロトタイプ + ---------------------------------------------------------------*/ + +void SDL_GL_Enter2DMode() +{ + // SDL_Surface *sc = SDL_GetVideoSurface(); + + /* Note, there may be other things you need to change, + depending on how you have your OpenGL state set up. + */ + glPushAttrib(GL_ENABLE_BIT); + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); + glEnable(GL_TEXTURE_2D); + + /* This allows alpha blending of 2D textures with the scene */ + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glViewport(0, 0, screen->w, screen->h); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + + glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + // glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); +} + + +void SDL_GL_Leave2DMode() +{ + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + + glPopAttrib(); +} + + +static int power_of_two(int input) +{ + int value = 1; + + while ( value < input ) { + value <<= 1; + } + return value; +} + +void +DefSpriteEx(int number, short middlex, short middley) +{ + sptable[number].mx = middlex; + sptable[number].my = middley; +} + +void +DefSprite(int number, const char *name, float w, float h, int color, OBJECT *obj) +{ + SURFACE *surfaces; + surfaces = search_node(obj, name); + if(surfaces == NULL) + { + fprintf(stderr, "can't get node\n"); + printf("%s", name); + SDL_Quit(); + exit(1); + } + sptable[number].w = w; + sptable[number].h = h; + sptable[number].color = (color & 32); + sptable[number].mx = w / 2; + sptable[number].my = h / 2; + sptable[number].tex_w = power_of_two(sptable[number].w); + sptable[number].tex_h = power_of_two(sptable[number].h); + texMinX[number] = 0.0f; + texMinY[number] = 0.0f; + texMaxX[number] = (GLfloat)sptable[number].w / sptable[number].tex_w; + texMaxY[number] = (GLfloat)sptable[number].h / sptable[number].tex_h; +// printf("texMaxX = %f, w = %d, tex_w = %d\n", texMaxX[number], sptable[number].w, sptable[number].tex_w); + sptable[number].texture = surfaces->texture; +} + +void +PutSprite(int zorder, short x, short y, int number) +{ + glBindTexture(GL_TEXTURE_2D, (GLuint&)sptable[number].texture); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBegin(GL_QUADS); + glTexCoord2f(texMinX[number],texMinY[number]); glVertex2i((GLuint)x, (GLuint)y ); + glTexCoord2f(texMinX[number],texMaxY[number]); glVertex2i((GLuint)x, (GLuint)(y+sptable[number].tex_h) ); + glTexCoord2f(texMaxX[number],texMaxY[number]); glVertex2i((GLuint)(x+sptable[number].tex_w), (GLuint)(y+sptable[number].tex_h)); + glTexCoord2f(texMaxX[number],texMinY[number]); glVertex2i((GLuint)(x+sptable[number].tex_w), (GLuint)y); + glEnd(); + glDisable(GL_BLEND); +} + +void +PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle) +{ + SpriteTable *m = &sptable[number]; + x -= m->w; + y -= m->h; + + SDL_GL_Enter2DMode(); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, (GLuint&)sptable[number].texture); + glTranslatef(x + m->w/2, y + m->h/2, 0.0); + glRotatef(angle, 0.0, 0.0, 1.0); + glScalef(scalex, scaley, 1.0); + glBegin(GL_TRIANGLE_STRIP); + { + glTexCoord2f(texMinX[number], texMinY[number]); glVertex2i(-m->w/2, -m->h/2); + glTexCoord2f(texMaxX[number], texMinY[number]); glVertex2i( m->w/2, -m->h/2); + glTexCoord2f(texMinX[number], texMaxY[number]); glVertex2i(-m->w/2, m->h/2); + glTexCoord2f(texMaxX[number], texMaxY[number]); glVertex2i( m->w/2, m->h/2); + } + glEnd(); + glDisable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + SDL_GL_Leave2DMode(); + // SDL_GL_SwapBuffers(); +} + + + +struct SGO_PAD pad[2]; + +#ifdef ENABLE_TRACEMODE +extern int runmode; +#endif //ENABLE_TRACEMODE + +/* コントローラ状態の読み込み */ +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; + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sgoex.h Wed Jun 15 23:31:59 2011 +0900 @@ -0,0 +1,106 @@ +#ifndef SGOEX_H +#define SGOEX_H +#include <SDL.h> + + +#define DEFOBJ 320 // sprite definition max num +#define MAXOBJ 320 // sprite drawing max num +#define BOOL char // define bool +#define TRUE 1 // TRUE value +#define FALSE 0 // FALSE value + +/*PS2_PAD*/ +#define PS2_CROSS 0 +#define PS2_CIRCLE 1 +#define PS2_SQUARE 2 +#define PS2_TRIANGLE 3 +#define PS2_L1 4 +#define PS2_R1 5 +#define PS2_L2 6 +#define PS2_R2 7 +#define PS2_START 8 +#define PS2_SELECT 9 +#define PS2_L3 10 +#define PS2_R3 11 + +/*PS3_PAD*/ +/* +#define PS2_CROSS 14 +#define PS2_CIRCLE 13 +#define PS2_SQUARE 15 +#define PS2_TRIANGLE 12 +#define PS2_L1 10 +#define PS2_R1 11 +#define PS2_L2 8 +#define PS2_R2 9 +#define PS2_START 3 +#define PS2_SELECT 0 +#define PS2_L3 1 +#define PS2_R3 2 +*/ + +typedef struct SGO_PAD { + short up; + short down; + short right; + short left; + short k0; + short k1; + short k3; + short k4; + short r1; + short r2; + short r3; + short l1; + short l2; + short l3; + short se; + short st; + + // 勝手に付けた + short quit; +} SGO_PAD; + +typedef struct SpriteView { + int x; + int y; + BOOL extend; + short scalex; + short scaley; + long rotate; + int no; +} SpriteView; + + +typedef struct SpriteTable { + short dx; + short dy; + short w; + short h; + short mx; + short my; + int color; + int page; + int tex_w; + int tex_h; + int *texture; + int tex_id; // for open gl +} SpriteTable; + +//extern GsSPRITE sprite[MAXOBJ]; +extern SpriteTable sptable[DEFOBJ]; + + +void PutSprite(int zorder, short x, short y, int number); +void DefSprite(int number, const char *name, float w, float h, int color, OBJECT *obj); +void DefSpriteEx(int number, short middlex, short middley); +void PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle); + + +/* Joypad - Below member are implemented in sgoex_ps2.c */ +extern SGO_PAD pad[2]; +void Pad(SDL_Joystick *joy); + +void keybord(); + +#endif // SGOEX_H