# HG changeset patch # User Shinji KONO # Date 1291730625 -32400 # Node ID 972a7f233b23a40754e7ce37078a8ff1c84d960c # Parent 6541f0bebb81c308d813306ddde4aa3ff1c908bf g++ compile diff -r 6541f0bebb81 -r 972a7f233b23 Bom.c --- a/Bom.c Tue Dec 07 18:11:38 2010 +0900 +++ b/Bom.c Tue Dec 07 23:03:45 2010 +0900 @@ -8,9 +8,7 @@ int sb_x, sb_y; int sb_size = -1; -int count; int se_voice[9]; -int vab[10]; bomchar bchar[100]; bomchar *bom_p; diff -r 6541f0bebb81 -r 972a7f233b23 Character.c --- a/Character.c Tue Dec 07 18:11:38 2010 +0900 +++ b/Character.c Tue Dec 07 23:03:45 2010 +0900 @@ -19,6 +19,10 @@ #define CHARACTER_MAX_POOL_SIZE 2048 +CHARACTER *active_chara_list; +CHARACTER *free_chara_list; + + const table enemystate[] = ENEMY_STATUS_TABLE; int filpcount = 0; diff -r 6541f0bebb81 -r 972a7f233b23 Character.h --- a/Character.h Tue Dec 07 18:11:38 2010 +0900 +++ b/Character.h Tue Dec 07 23:03:45 2010 +0900 @@ -50,8 +50,8 @@ } CHARACTER; -CHARACTER *active_chara_list; -CHARACTER *free_chara_list; +extern CHARACTER *active_chara_list; +extern CHARACTER *free_chara_list; extern CHARACTER *kyeenemyno; extern CHARACTER *tekino0; extern CHARACTER *enemy_part1; diff -r 6541f0bebb81 -r 972a7f233b23 Dandy.cc --- a/Dandy.cc Tue Dec 07 18:11:38 2010 +0900 +++ b/Dandy.cc Tue Dec 07 23:03:45 2010 +0900 @@ -217,10 +217,12 @@ static int dandy_main_lop(int gamef) { + viewer->sgroot->flip(); + viewer->sgroot->lightCalc(); + + if ((pad[0].l1 != 0) && (pad[0].r1 != 0) && (pad[0].l2 != 0) && (pad[0].r2 != 0)) { - glFlush(); - SDL_GL_SwapBuffers( ); gamesyokika(joy); } @@ -258,6 +260,7 @@ /*インフレゲージ */ count++; //PutSprite(count, 0, 0, 48); + obj_draw(); pause(joy); @@ -481,31 +484,52 @@ sptable[number].my = middley; } +static int power_of_two(int input) +{ + int value = 1; + + while ( value < input ) { + value <<= 1; + } + return value; +} + void DefSprite(int number, char *name, float w, float h, int color, OBJECT *obj) { + SpriteTable *m = &sptable[number]; + 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 = (int *)name; + } void PutSprite(int zorder, short x, short y, int number) { SpriteTable *m = &sptable[number]; + char *name = (char *) m->texture; 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; - + object->x = x; + object->y = y; } void PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle) { SpriteTable *m = &sptable[number]; - x -= m->w; - y -= m->h; + char *name = (char *) m->texture; + SceneGraphPtr object = sgroot->createSceneGraph(m->name); + object->x = x; + object->y = y; } diff -r 6541f0bebb81 -r 972a7f233b23 LoadSprite.c --- a/LoadSprite.c Tue Dec 07 18:11:38 2010 +0900 +++ b/LoadSprite.c Tue Dec 07 23:03:45 2010 +0900 @@ -14,6 +14,8 @@ //#define bmp_file "./s-dandy.bmp" +SDL_Surface *sprite; + SDL_Surface *LoadSprite(SURFACE *surfaces) { SDL_Surface *image; diff -r 6541f0bebb81 -r 972a7f233b23 LoadSprite.h --- a/LoadSprite.h Tue Dec 07 18:11:38 2010 +0900 +++ b/LoadSprite.h Tue Dec 07 23:03:45 2010 +0900 @@ -1,2 +1,2 @@ -SDL_Surface *LoadSprite(SURFACE *surfaces); -SDL_Surface *sprite; +extern SDL_Surface *LoadSprite(SURFACE *surfaces); +extern SDL_Surface *sprite; diff -r 6541f0bebb81 -r 972a7f233b23 Makefile --- a/Makefile Tue Dec 07 18:11:38 2010 +0900 +++ b/Makefile Tue Dec 07 23:03:45 2010 +0900 @@ -1,21 +1,26 @@ # Makefile to build the SDL tests +include ./Makefile.def srcdir = . ABI = -m32 -CC = gcc -CFLAGS = -g $(ABI) -O2 -Wall `sdl-config --cflags` `xml2-config --cflags` -LIBS = `sdl-config --libs`,-framework,OpenGL -lSDL_mixer -lSDL_image `xml2-config --libs` -TARGET = demo -OBJS = sgoex.o Character.o Bom.o tokuten.o collision.o count2.o Character_state.o schedule3.o tama2.o syokika.o Ss.o sound.o main.o profile.o debug.o trace.o LoadSprite.o xml.o b64_de.o tree_controll.o object.o sys.o +CFLAGS += -g $(ABI) -O2 -Wall `sdl-config --cflags` `xml2-config --cflags` -I../Cerium/include +LIBS += `sdl-config --libs`,-framework,OpenGL -lSDL_mixer -lSDL_image `xml2-config --libs` +LIBS += -lCerium -lFifoManager + +TARGET = demo dandy +OBJS = Character.o Bom.o tokuten.o collision.o count2.o Character_state.o schedule3.o tama2.o syokika.o Ss.o sound.o main.o profile.o debug.o trace.o LoadSprite.o xml.o b64_de.o tree_controll.o object.o sys.o all: $(TARGET) test: $(TARGET) - ./$(TARGET) -test + ./demo -test -$(TARGET): $(OBJS) - $(CC) $(ABI) -o $@ $(OBJS) $(LIBS) +demo: $(OBJS) sgoex.o + $(CC) $(ABI) -o $@ sgoex.o $(OBJS) $(LIBS) + +dandy: $(OBJS) Dandy.o + $(CC) $(ABI) -o $@ $(OBJS) Dandy.o $(LIBS) clean: rm -f $(TARGET) $(OBJS) @@ -23,4 +28,7 @@ .c.o: $(CC) $(CFLAGS) $(INCLUDES) -c $< +.cc.o: + $(CC) $(CFLAGS) $(INCLUDES) -c $< + debug.o:debug.h diff -r 6541f0bebb81 -r 972a7f233b23 b64_de.c --- a/b64_de.c Tue Dec 07 18:11:38 2010 +0900 +++ b/b64_de.c Tue Dec 07 23:03:45 2010 +0900 @@ -14,7 +14,7 @@ int decode(char *cont, FILE *outfile) { - unsigned int rw; + int rw; struct tagTT work; work.buf = 0; diff -r 6541f0bebb81 -r 972a7f233b23 bom.h --- a/bom.h Tue Dec 07 18:11:38 2010 +0900 +++ b/bom.h Tue Dec 07 23:03:45 2010 +0900 @@ -10,7 +10,7 @@ extern void Bom(int x, int y); extern void Putbom(); -extern void Superbom(); +void Superbom(int x, int y); extern int count; diff -r 6541f0bebb81 -r 972a7f233b23 collision.c --- a/collision.c Tue Dec 07 18:11:38 2010 +0900 +++ b/collision.c Tue Dec 07 23:03:45 2010 +0900 @@ -7,12 +7,9 @@ #include "Character_state.h" #include "tokuten.h" #include "collision.h" -//#include "atari.h" #include "bom.h" #include "count2.h" #include "sound.h" -//#include "Enemy.h" -//#include "libps.h" #include "sgoex.h" extern SpriteTable sptable[DEFOBJ]; diff -r 6541f0bebb81 -r 972a7f233b23 debug.c --- a/debug.c Tue Dec 07 18:11:38 2010 +0900 +++ b/debug.c Tue Dec 07 23:03:45 2010 +0900 @@ -2,16 +2,15 @@ #include #include #include "count2.h" -#include "Enemy.h" static FILE *dbg_fp; -void dbg_init(char *fname) +void dbg_init(const char *fname) { dbg_fp = fopen(fname, "w"); } -int dbg_printf(char *format, ...) +int dbg_printf(const char *format, ...) { va_list ap; va_start(ap, format); diff -r 6541f0bebb81 -r 972a7f233b23 debug.h --- a/debug.h Tue Dec 07 18:11:38 2010 +0900 +++ b/debug.h Tue Dec 07 23:03:45 2010 +0900 @@ -38,8 +38,8 @@ } #endif -extern void dbg_init(char *); -extern int dbg_printf(char *, ...); +extern void dbg_init(const char *); +extern int dbg_printf(const char *, ...); #ifdef USE_MYRAND extern int myrand(void); diff -r 6541f0bebb81 -r 972a7f233b23 main.c --- a/main.c Tue Dec 07 18:11:38 2010 +0900 +++ b/main.c Tue Dec 07 23:03:45 2010 +0900 @@ -11,21 +11,17 @@ #include "xml.h" #include "profile.h" #include "syokika.h" -//#include "libps.h" #include "sankaku.h" #include "sgoex.h" #include "sound.h" #include "bool.h" -//#include "move.h" #include "Character.h" #include "Character_state.h" #include "bom.h" #include "count2.h" -//#include "Enemy.h" #include "tokuten.h" #include "schedule.h" #include "tama.h" -//#include"profile.h" #include "debug.h" #include "trace.h" #include "LoadSprite.h" @@ -42,19 +38,17 @@ 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 void gamesyokika(SDL_Joystick *joy); +static void opening(SDL_Joystick *joy); +static void pause(SDL_Joystick *joy); //static char *pad_trace_file; extern void SDL_GL_Enter2DMode(); extern void SDL_GL_Leave2DMode(); diff -r 6541f0bebb81 -r 972a7f233b23 object.h --- a/object.h Tue Dec 07 18:11:38 2010 +0900 +++ b/object.h Tue Dec 07 23:03:45 2010 +0900 @@ -1,3 +1,7 @@ +#ifndef OBJECT_H +#define OBJECT_H + + typedef float FVECTOR[4]; typedef float FMATRIX[4][4]; @@ -34,7 +38,10 @@ void init_object(OBJECT *obj); void free_object(OBJECT *obj); -OBJECT *font; -OBJECT *chara; -OBJECT *effect; -OBJECT *boss; + +extern OBJECT *font; +extern OBJECT *chara; +extern OBJECT *effect; +extern OBJECT *boss; + +#endif diff -r 6541f0bebb81 -r 972a7f233b23 profile.c --- a/profile.c Tue Dec 07 18:11:38 2010 +0900 +++ b/profile.c Tue Dec 07 23:03:45 2010 +0900 @@ -40,7 +40,7 @@ return etime; } -void timeprof_sprint(char *s, char *profname, Timeprof t) +void timeprof_sprint(char *s, const char *profname, Timeprof t) { sprintf(s, "%s: average:%dusec, peak:%dusec", profname, t->average, t->peak); @@ -55,7 +55,7 @@ Timeprof timeprof_new() { - Timeprof t = malloc(sizeof(struct time_profile)); + Timeprof t = (Timeprof) malloc(sizeof(struct time_profile)); memset(t, 0, sizeof(struct time_profile)); return t; } diff -r 6541f0bebb81 -r 972a7f233b23 profile.h --- a/profile.h Tue Dec 07 18:11:38 2010 +0900 +++ b/profile.h Tue Dec 07 23:03:45 2010 +0900 @@ -11,7 +11,7 @@ extern Timeprof timeprof_new(); // extern unsigned long timeprof_get(Timeprof t); -extern void timeprof_sprint(char *s, char *profname, Timeprof t); +extern void timeprof_sprint(char *s, const char *profname, Timeprof t); // #define timeprof_begin(t) timeprof_set_point(&((t)->begin)) // #define timeprof_end(t) timeprof_set_point(&((t)->end)) diff -r 6541f0bebb81 -r 972a7f233b23 sgoex.c --- a/sgoex.c Tue Dec 07 18:11:38 2010 +0900 +++ b/sgoex.c Tue Dec 07 23:03:45 2010 +0900 @@ -22,25 +22,23 @@ #define TRUE 1 #define FALSE 0 -int count; - -u_short tpage; -SDL_Rect rect; +//static u_short tpage; +//static SDL_Rect rect; -int nActiveBuff; /*ばふぁ */ -int i; /* Multi-purpose */ +//static int nActiveBuff; /*ばふぁ */ +// int i; /* Multi-purpose */ //static int pageno; //static int padd; -const int sgo_tpx[12] = +static const int sgo_tpx[12] = { 0, 64, 128, 192, 256, 320, 0, 64, 128, 192, 256, 320 }; -const int sgo_tpy[12] = { 0, 0, 0, 0, 0, 0, 256, 256, 256, 256, 256, 256 }; +static const int sgo_tpy[12] = { 0, 0, 0, 0, 0, 0, 256, 256, 256, 256, 256, 256 }; /* sgo.h 独自の変数形 */ SpriteTable sptable[DEFOBJ]; -SpriteView spview[MAXOBJ]; +// static SpriteView spview[MAXOBJ]; #define IMAGE_ADJUSTMENT (0) @@ -49,7 +47,7 @@ * pagenoに対応した領域のx,yを用意しておく。PlayStationではpageno * で区切る必要があったのだろうが、PS2では全く意味はなさない。 */ -const struct texture_page_offset { +static const struct texture_page_offset { int x; int y; } texpage_offset[] = { @@ -122,7 +120,7 @@ } -void DefSprite(int number, char *name, float w, float h, int color, OBJECT *obj) +void DefSprite(int number, const char *name, float w, float h, int color, OBJECT *obj) { SURFACE *surfaces; surfaces = search_node(obj, name); diff -r 6541f0bebb81 -r 972a7f233b23 sgoex.h --- a/sgoex.h Tue Dec 07 18:11:38 2010 +0900 +++ b/sgoex.h Tue Dec 07 23:03:45 2010 +0900 @@ -1,3 +1,7 @@ +#ifndef SGOEX_H +#define SGOEX_H +#include + #define DEFOBJ 320 // sprite definition max num #define MAXOBJ 320 // sprite drawing max num @@ -86,12 +90,15 @@ void PutSprite(int zorder, short x, short y, int number); -void DefSprite(int number, char *name, float w, float h, int color, OBJECT *obj); +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(); +void Pad(SDL_Joystick *joy); + void keybord(); + +#endif SGOEX_H diff -r 6541f0bebb81 -r 972a7f233b23 syokika.c --- a/syokika.c Tue Dec 07 18:11:38 2010 +0900 +++ b/syokika.c Tue Dec 07 23:03:45 2010 +0900 @@ -7,11 +7,9 @@ #include "object.h" #include "xml.h" #include "tree_controll.h" -//#include "Enemy.h" #include "count2.h" #include "sgoex.h" #include "sankaku.h" -//#include "back.h" #include "bom.h" #include "sound.h" #include "syokika.h" @@ -29,9 +27,17 @@ #define SEED_VALUE 1 +struct SDL_Surface *screen; + +OBJECT *font; +OBJECT *chara; +OBJECT *effect; +OBJECT *boss; + + void syokika(int argc, char *argv[]) { - int i, i2; + int i; //volatile unsigned char *bb0, *bb1; int width = 740; int height = 480; @@ -81,7 +87,6 @@ srand(SEED_VALUE); //LoadSprite(); - // sankakuf(); font = read_xml_3d_file(FONT_FILE); boss = read_xml_3d_file(BOSS_FILE); @@ -92,7 +97,7 @@ all_object_load_texture(boss); all_object_load_texture(chara); all_object_load_texture(effect); - init_sprite(); + init_sprite(font, boss, chara, effect); } void diff -r 6541f0bebb81 -r 972a7f233b23 syokika.h --- a/syokika.h Tue Dec 07 18:11:38 2010 +0900 +++ b/syokika.h Tue Dec 07 23:03:45 2010 +0900 @@ -1,4 +1,7 @@ -struct SDL_Surface *screen; +#ifndef SYOKIKA_H +#define SYOKIKA_H + +extern struct SDL_Surface *screen; typedef enum { PLAYER_LEFTMOVE = 1, @@ -113,6 +116,10 @@ BOSS_CORPSE = 196, } CharImageNumber; +#include "object.h" + extern void syokika(int argc, char *argv[]); extern void init_sprite(OBJECT *font, OBJECT *boss, OBJECT *chara, OBJECT *effect); + +#endif diff -r 6541f0bebb81 -r 972a7f233b23 tokuten.c --- a/tokuten.c Tue Dec 07 18:11:38 2010 +0900 +++ b/tokuten.c Tue Dec 07 23:03:45 2010 +0900 @@ -10,6 +10,7 @@ int enemycount = 0; int higecount = 0; int stcount = 0; +int count = 0; /*エンヂング集計用*/ int clear_result[4]; diff -r 6541f0bebb81 -r 972a7f233b23 tree_controll.c --- a/tree_controll.c Tue Dec 07 18:11:38 2010 +0900 +++ b/tree_controll.c Tue Dec 07 23:03:45 2010 +0900 @@ -148,7 +148,7 @@ } } -SURFACE *search_node(OBJECT *top, char *name) +SURFACE *search_node(OBJECT *top, const char *name) { SURFACE *node; SURFACE *ret_node = NULL; diff -r 6541f0bebb81 -r 972a7f233b23 tree_controll.h --- a/tree_controll.h Tue Dec 07 18:11:38 2010 +0900 +++ b/tree_controll.h Tue Dec 07 23:03:45 2010 +0900 @@ -1,8 +1,8 @@ GLuint SDL_GL_LoadTexture(SDL_Surface *surface, GLfloat *texcoord); SURFACE *next_draw_node(SURFACE *surface); //void obj_draw(SURFACE *surfaces); -SURFACE *search_node(OBJECT *top, char *name); +SURFACE *search_node(OBJECT *top, const char *name); SURFACE *next_node(SURFACE *surfaces); //void node_draw(OBJECT *top, char *name); -void node_prameter_change(OBJECT *top, char *name, float x, float y, float z, float ax, float ay, float az); +void node_prameter_change(OBJECT *top, const char *name, float x, float y, float z, float ax, float ay, float az); //void all_object_load_texture(OBJECT *top);