Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 195686
Collapse All | Expand All

(-)RefLectBall/Makefile (+17 lines)
Line 0 Link Here
1
DC=gdmd
2
DFLAGS=-g -O -d -release -Iimport -Isrc
3
DOUT=-of
4
5
DSRC=$(shell find src/ -name "*.d")
6
SOURCES=$(DSRC) import/SDL_video.d import/SDL_mixer.d import/SDL_image.d
7
OBJS=$(SOURCES:.d=.o)
8
EXE=reflectball
9
10
all: $(EXE)
11
12
$(EXE): $(OBJS)
13
	gcc -o $@ $(OBJS) -lbulletml_d -lgphobos -lpthread -lm -lSDL -lGL -lGLU -lSDL_mixer
14
15
$(OBJS): %.o: %.d
16
	$(DC) -c $(DOUT)$@ $(DFLAGS) $<
17
(-)RefLectBall/import/SDL.d (-1 / +3 lines)
Lines 31-37 Link Here
31
public import SDL_events;
31
public import SDL_events;
32
public import SDL_video;
32
public import SDL_video;
33
public import SDL_byteorder;
33
public import SDL_byteorder;
34
public import SDL_Version;
34
public import SDL_version;
35
35
36
extern(C):
36
extern(C):
37
37
Lines 73-78 Link Here
73
 */
73
 */
74
void SDL_Quit();
74
void SDL_Quit();
75
75
76
/+
76
void SDL_SetModuleHandle(void *hInst);
77
void SDL_SetModuleHandle(void *hInst);
77
//extern(Windows) void* GetModuleHandle(char*);
78
//extern(Windows) void* GetModuleHandle(char*);
78
extern(Windows) void* GetModuleHandleA(char*);
79
extern(Windows) void* GetModuleHandleA(char*);
Lines 90-92 Link Here
90
{
91
{
91
	SDL_Quit();
92
	SDL_Quit();
92
}
93
}
94
+/
(-)RefLectBall/import/SDL_events.d (-1 / +1 lines)
Lines 105-111 Link Here
105
	Uint8 type;	/* SDL_KEYDOWN or SDL_KEYUP */
105
	Uint8 type;	/* SDL_KEYDOWN or SDL_KEYUP */
106
	Uint8 which;	/* The keyboard device index */
106
	Uint8 which;	/* The keyboard device index */
107
	Uint8 state;	/* SDL_PRESSED or SDL_RELEASED */
107
	Uint8 state;	/* SDL_PRESSED or SDL_RELEASED */
108
	SDL_keysym keysym;
108
	SDL_keysym2 keysym;
109
}
109
}
110
110
111
/* Mouse motion event structure */
111
/* Mouse motion event structure */
(-)RefLectBall/import/SDL_keyboard.d (-2 / +2 lines)
Lines 26-32 Link Here
26
// !!! A hack! struct SDL_keysym is defined in this module,
26
// !!! A hack! struct SDL_keysym is defined in this module,
27
// !!! so we need to resolve the nameclash...
27
// !!! so we need to resolve the nameclash...
28
// !!! Definitely won't work on *NIX but for now will do.
28
// !!! Definitely won't work on *NIX but for now will do.
29
public import SDL_Keysym;
29
public import SDL_keysym;
30
30
31
extern(C):
31
extern(C):
32
32
Lines 46-52 Link Here
46
		An international character..
46
		An international character..
47
	}
47
	}
48
 */
48
 */
49
struct SDL_keysym {
49
struct SDL_keysym2 {
50
	Uint8 scancode;			/* hardware specific scancode */
50
	Uint8 scancode;			/* hardware specific scancode */
51
	SDLKey sym;			/* SDL virtual keysym */
51
	SDLKey sym;			/* SDL virtual keysym */
52
	SDLMod mod;			/* current key modifiers */
52
	SDLMod mod;			/* current key modifiers */
(-)RefLectBall/import/SDL_syswm.d (-1 / +1 lines)
Lines 22-28 Link Here
22
22
23
/* Include file for SDL custom system window manager hooks */
23
/* Include file for SDL custom system window manager hooks */
24
24
25
public import SDL_Version;
25
public import SDL_version;
26
26
27
extern(C):
27
extern(C):
28
28
(-)RefLectBall/import/opengl.d (-8 / +2 lines)
Lines 1-10 Link Here
1
version (Win32) {
2
	private import std.c.windows.windows;
3
	extern(Windows):
4
}
5
version (linux) {
6
	extern(C):
1
	extern(C):
7
}
8
2
9
alias uint GLenum;
3
alias uint GLenum;
10
alias ubyte GLboolean;
4
alias ubyte GLboolean;
Lines 1116-1122 Link Here
1116
/*************************************************************/
1110
/*************************************************************/
1117
1111
1118
void /*APIENTRY*/glAccum (GLenum op, GLfloat value);
1112
void /*APIENTRY*/glAccum (GLenum op, GLfloat value);
1119
void /*APIENTRY*/glAlphaFunc (GLenum func, GLclampf ref);
1113
void /*APIENTRY*/glAlphaFunc (GLenum func, GLclampf);
1120
GLboolean /*APIENTRY*/glAreTexturesResident (GLsizei n, GLuint *textures, GLboolean *residences);
1114
GLboolean /*APIENTRY*/glAreTexturesResident (GLsizei n, GLuint *textures, GLboolean *residences);
1121
void /*APIENTRY*/glArrayElement (GLint i);
1115
void /*APIENTRY*/glArrayElement (GLint i);
1122
void /*APIENTRY*/glBegin (GLenum mode);
1116
void /*APIENTRY*/glBegin (GLenum mode);
Lines 1369-1375 Link Here
1369
void /*APIENTRY*/glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
1363
void /*APIENTRY*/glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
1370
void /*APIENTRY*/glSelectBuffer (GLsizei size, GLuint *buffer);
1364
void /*APIENTRY*/glSelectBuffer (GLsizei size, GLuint *buffer);
1371
void /*APIENTRY*/glShadeModel (GLenum mode);
1365
void /*APIENTRY*/glShadeModel (GLenum mode);
1372
void /*APIENTRY*/glStencilFunc (GLenum func, GLint ref, GLuint mask);
1366
void /*APIENTRY*/glStencilFunc (GLenum func, GLint, GLuint mask);
1373
void /*APIENTRY*/glStencilMask (GLuint mask);
1367
void /*APIENTRY*/glStencilMask (GLuint mask);
1374
void /*APIENTRY*/glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
1368
void /*APIENTRY*/glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
1375
void /*APIENTRY*/glTexCoord1d (GLdouble s);
1369
void /*APIENTRY*/glTexCoord1d (GLdouble s);
(-)RefLectBall/import/openglu.d (-5 lines)
Lines 1-11 Link Here
1
public import opengl;
1
public import opengl;
2
2
3
version (Win32) {
4
	extern(Windows):
5
}
6
version (linux) {
7
	extern(C):
3
	extern(C):
8
}
9
4
10
GLubyte* gluErrorString (
5
GLubyte* gluErrorString (
11
    GLenum   errCode);
6
    GLenum   errCode);
(-)RefLectBall/src/bulletcommand.d (-2 / +3 lines)
Lines 36-42 Link Here
36
36
37
	buf.length = 256;
37
	buf.length = 256;
38
	buf = fname ~ "\0";
38
	buf = fname ~ "\0";
39
	parser[bank] = BulletMLParserTinyXML_new(buf);
39
	parser[bank] = BulletMLParserTinyXML_new(buf.ptr);
40
	if(parser[bank]) BulletMLParserTinyXML_parse(parser[bank]);
40
	if(parser[bank]) BulletMLParserTinyXML_parse(parser[bank]);
41
	buf.length = 0;
41
	buf.length = 0;
42
}
42
}
Lines 169-175 Link Here
169
		if(eid != -1){
169
		if(eid != -1){
170
			TskBuf[eid].parent = BulletCommand.now.id;
170
			TskBuf[eid].parent = BulletCommand.now.id;
171
			d = (d <= 180.0f ? d : -(360.0f - d));
171
			d = (d <= 180.0f ? d : -(360.0f - d));
172
			d = d / ROTVAL;
172
			d = d / ROTVAL;
173
			TskBuf[eid].roll = 0;
173
			TskBuf[eid].bullet_speed = s;
174
			TskBuf[eid].bullet_speed = s;
174
			TskBuf[eid].bullet_direction = d;
175
			TskBuf[eid].bullet_direction = d;
175
			TskBuf[eid].bullet_velx = (sin(d) * (-s * VEL_SDM_SS_RATIO));
176
			TskBuf[eid].bullet_velx = (sin(d) * (-s * VEL_SDM_SS_RATIO));
(-)RefLectBall/src/gctrl.d (-6 / +22 lines)
Lines 66-71 Link Here
66
	GCTRL_RANKING_EXEC,
66
	GCTRL_RANKING_EXEC,
67
	GCTRL_RANKING_EXIT,
67
	GCTRL_RANKING_EXIT,
68
}
68
}
69
70
public static char[] pref_dir()
71
{
72
	char * home = getenv("HOME");
73
	if (home is null)
74
		throw new Error("HOME environment variable not defined");
75
	char[] dir = std.string.toString(home) ~ "/.reflectball";
76
	char[] dir2 = std.string.toString(home) ~ "/.reflectball/replay";
77
	try {
78
		mkdir(dir);
79
		mkdir(dir2);
80
	} catch (FileException e) {
81
	}
82
	return dir;
83
}
84
69
85
70
void TSKgctrl(int id)
86
void TSKgctrl(int id)
71
{
87
{
Lines 78-84 Link Here
78
			replay_data.length = 8;
94
			replay_data.length = 8;
79
		}
95
		}
80
		replay_fmax = 0;
96
		replay_fmax = 0;
81
		fpath = listdir(std.path.curdir ~ "/replay");
97
		fpath = listdir(pref_dir() ~ "/" ~ "replay");
82
		for(int i = 0; i < fpath.length; i++){
98
		for(int i = 0; i < fpath.length; i++){
83
			if(fnmatch(fpath[i], "rlb??????????????.rep")){
99
			if(fnmatch(fpath[i], "rlb??????????????.rep")){
84
				replay_file.length = fcnt + 1;
100
				replay_file.length = fcnt + 1;
Lines 118-124 Link Here
118
				replay_data[i] = replay[i];
134
				replay_data[i] = replay[i];
119
			}
135
			}
120
			char[] fname;
136
			char[] fname;
121
			fname = format("./replay/rlb%04d%02d%02d%02d%02d%02d.rep"
137
			fname = format(pref_dir() ~ "/" ~ "/replay/rlb%04d%02d%02d%02d%02d%02d.rep"
122
							,year
138
							,year
123
							,month
139
							,month
124
							,date
140
							,date
Lines 152-159 Link Here
152
	}
168
	}
153
169
154
	void init_highscore(){
170
	void init_highscore(){
155
		if(exists("score.dat")){
171
		if(exists(pref_dir() ~ "/" ~ "score.dat")){
156
			hi_score = cast(int[])read("score.dat");
172
			hi_score = cast(int[])read(pref_dir() ~ "/" ~ "score.dat");
157
		}else{
173
		}else{
158
			hi_score.length = RANKING_MAX * RANKING_RECORD;
174
			hi_score.length = RANKING_MAX * RANKING_RECORD;
159
			for(int i = 0; i < RANKING_MAX; i++){
175
			for(int i = 0; i < RANKING_MAX; i++){
Lines 161-167 Link Here
161
				hi_score[i * RANKING_RECORD + RANKING_BREAK] = 0;
177
				hi_score[i * RANKING_RECORD + RANKING_BREAK] = 0;
162
				hi_score[i * RANKING_RECORD + RANKING_DESTR] = 0;
178
				hi_score[i * RANKING_RECORD + RANKING_DESTR] = 0;
163
			}
179
			}
164
			write("score.dat", cast(void[])hi_score);
180
			write(pref_dir() ~ "/" ~ "score.dat", cast(void[])hi_score);
165
		}
181
		}
166
	}
182
	}
167
183
Lines 178-184 Link Here
178
				hi_score[i * RANKING_RECORD + RANKING_SCORE] = score;
194
				hi_score[i * RANKING_RECORD + RANKING_SCORE] = score;
179
				hi_score[i * RANKING_RECORD + RANKING_BREAK] = brk_ship;
195
				hi_score[i * RANKING_RECORD + RANKING_BREAK] = brk_ship;
180
				hi_score[i * RANKING_RECORD + RANKING_DESTR] = enemy_dst;
196
				hi_score[i * RANKING_RECORD + RANKING_DESTR] = enemy_dst;
181
				write("score.dat", cast(void[])hi_score);
197
				write(pref_dir() ~ "/" ~ "score.dat", cast(void[])hi_score);
182
				break;
198
				break;
183
			}
199
			}
184
		}
200
		}
(-)RefLectBall/src/luminous.d (-4 / +4 lines)
Lines 7-13 Link Here
7
*/
7
*/
8
8
9
private	import std.math;
9
private	import std.math;
10
private	import std.string;
10
private	import std.c.string;
11
private	import opengl;
11
private	import opengl;
12
private	import util_sdl;
12
private	import util_sdl;
13
private	import task;
13
private	import task;
Lines 36-42 Link Here
36
		    glDisable(GL_CULL_FACE);
36
		    glDisable(GL_CULL_FACE);
37
		    glDisable(GL_DEPTH_TEST);
37
		    glDisable(GL_DEPTH_TEST);
38
		    glDisable(GL_TEXTURE_2D);
38
		    glDisable(GL_TEXTURE_2D);
39
		    glDisable(GL_COLOR_MATERIAL);    
39
		    glDisable(GL_COLOR_MATERIAL);
40
			init(0.0f, SCREEN_X, SCREEN_Y);
40
			init(0.0f, SCREEN_X, SCREEN_Y);
41
			TskBuf[id].fp_draw = &TSKluminousDraw;
41
			TskBuf[id].fp_draw = &TSKluminousDraw;
42
			TskBuf[id].step++;
42
			TskBuf[id].step++;
Lines 68-78 Link Here
68
68
69
static void makeLuminousTexture()
69
static void makeLuminousTexture()
70
{
70
{
71
	uint *data = td;
71
	uint *data = td.ptr;
72
	int i;
72
	int i;
73
73
74
	td[0..length] = 0;
74
	td[0..length] = 0;
75
	//memset(data, 0, luminousTextureWidth * luminousTextureHeight * 4 * uint.sizeof);
75
	memset(data, 0, luminousTextureWidth * luminousTextureHeight * 4 * uint.sizeof);
76
	glGenTextures(1, &luminousTexture);
76
	glGenTextures(1, &luminousTexture);
77
	glBindTexture(GL_TEXTURE_2D, luminousTexture);
77
	glBindTexture(GL_TEXTURE_2D, luminousTexture);
78
	glTexImage2D(GL_TEXTURE_2D, 0, 4, luminousTextureWidth, luminousTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
78
	glTexImage2D(GL_TEXTURE_2D, 0, 4, luminousTextureWidth, luminousTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
(-)RefLectBall/src/main.d (-5 / +5 lines)
Lines 4-17 Link Here
4
		'main.d'
4
		'main.d'
5
*/
5
*/
6
6
7
private import std.c.windows.windows;
7
//private import std.c.windows.windows;
8
private import std.stdio;
8
private import std.stdio;
9
private import std.string;
9
private import std.string;
10
private import std.random;
10
private import std.random;
11
private	import std.math;
11
private	import std.math;
12
private import SDL;
12
private import SDL;
13
private import opengl;
13
private import opengl;
14
private import reflection;
14
//private import reflection;
15
private import util_sdl;
15
private import util_sdl;
16
private import util_glbf;
16
private import util_glbf;
17
private import util_pad;
17
private import util_pad;
Lines 65-72 Link Here
65
				str_buf[i] = lpCmdLine[i];
65
				str_buf[i] = lpCmdLine[i];
66
			}
66
			}
67
			split_buf = split(str_buf);
67
			split_buf = split(str_buf);
68
			if(split_buf[0].length > 1) Reflection.init(split_buf[0]);
68
		//	if(split_buf[0].length > 1) Reflection.init(split_buf[0]);
69
			else						Reflection.init("main.exe");
69
		//	else						Reflection.init("main.exe");
70
		}
70
		}
71
71
72
		try{
72
		try{
Lines 84-90 Link Here
84
}else{
84
}else{
85
	int main(char[][] argv)
85
	int main(char[][] argv)
86
	{
86
	{
87
		Reflection.init(argv[argv.length-1]);
87
	//	Reflection.init(argv[argv.length-1]);
88
		return boot();
88
		return boot();
89
	}
89
	}
90
}
90
}
(-)RefLectBall/src/task.d (-2 / +4 lines)
Lines 175-181 Link Here
175
		TskBuf[i].fp_draw = null;
175
		TskBuf[i].fp_draw = null;
176
		TskBuf[i].fp_exit = null;
176
		TskBuf[i].fp_exit = null;
177
		TskBuf[i].bullet_command = null;
177
		TskBuf[i].bullet_command = null;
178
		TskBuf[i].bullet_state = null;
178
		TskBuf[i].bullet_state = null;
179
	        TskBuf[i].bullet_accx = 0;
180
	        TskBuf[i].bullet_accy = 0;
179
	}
181
	}
180
	TskBuf[i].tskid = TSKID_NONE;
182
	TskBuf[i].tskid = TSKID_NONE;
181
	TskBuf[i].entry = -1;
183
	TskBuf[i].entry = -1;
Lines 186-192 Link Here
186
	TskBuf[i].fp_draw = null;
188
	TskBuf[i].fp_draw = null;
187
	TskBuf[i].fp_exit = null;
189
	TskBuf[i].fp_exit = null;
188
	TskBuf[i].bullet_command = null;
190
	TskBuf[i].bullet_command = null;
189
	TskBuf[i].bullet_state = null;
191
	TskBuf[i].bullet_state = null;
190
}
192
}
191
193
192
int	setTSK(int group,void function(int) func)
194
int	setTSK(int group,void function(int) func)
(-)RefLectBall/src/util_glbf.d (-1 / +1 lines)
Lines 156-162 Link Here
156
{
156
{
157
	glBindTexture(GL_TEXTURE_2D, font.texture);				// Select Our Font Texture
157
	glBindTexture(GL_TEXTURE_2D, font.texture);				// Select Our Font Texture
158
	glListBase(font.base-32);								// Choose The Font Set (0 or 1)
158
	glListBase(font.base-32);								// Choose The Font Set (0 or 1)
159
	glCallLists(str.length, GL_BYTE, str);					// Write The Text To The Screen
159
	glCallLists(str.length, GL_BYTE, str.ptr);					// Write The Text To The Screen
160
}
160
}
161
161
162
int glbfInit(GLBitmapFont* font, char* filename, GLfloat xsize, GLfloat xdots, GLfloat ydots)
162
int glbfInit(GLBitmapFont* font, char* filename, GLfloat xsize, GLfloat xdots, GLfloat ydots)
(-)RefLectBall/src/util_rand.d (-2 / +2 lines)
Lines 112-125 Link Here
112
112
113
void next_state()
113
void next_state()
114
{
114
{
115
	uint *p=state;
115
	uint *p=state.ptr;
116
116
117
	/* if init_genrand() has not been called, */
117
	/* if init_genrand() has not been called, */
118
	/* a default initial seed is used		  */
118
	/* a default initial seed is used		  */
119
	if (initf==0) init_genrand(5489);
119
	if (initf==0) init_genrand(5489);
120
120
121
	left = N;
121
	left = N;
122
	next = state;
122
	next = state.ptr;
123
	
123
	
124
	for (int j=N-M+1; --j; p++) 
124
	for (int j=N-M+1; --j; p++) 
125
		*p = p[M] ^ TWIST(p[0], p[1]);
125
		*p = p[M] ^ TWIST(p[0], p[1]);
(-)RefLectBall/src/util_sdl.d (-2 / +2 lines)
Lines 105-111 Link Here
105
    resizedSDL(width, height);
105
    resizedSDL(width, height);
106
	SDL_ShowCursor(SDL_DISABLE);
106
	SDL_ShowCursor(SDL_DISABLE);
107
107
108
	SDL_WM_SetCaption(PROJECT_NAME, null);
108
	SDL_WM_SetCaption(PROJECT_NAME.ptr, null);
109
	SDL_WM_SetIcon(SDL_LoadBMP("icon.bmp"), null);
109
	SDL_WM_SetIcon(SDL_LoadBMP("icon.bmp"), null);
110
110
111
	return	1;
111
	return	1;
Lines 142-148 Link Here
142
{
142
{
143
	SDL_Surface* tmp;
143
	SDL_Surface* tmp;
144
144
145
	tmp = IMG_Load(toStringz(fname));
145
//	tmp = IMG_Load(toStringz(fname));
146
	if(tmp){
146
	if(tmp){
147
		SDL_Surface* tmp2;
147
		SDL_Surface* tmp2;
148
		int bpp = getBPP(tmp);
148
		int bpp = getBPP(tmp);
(-)RefLectBall/src/util_snd.d (-2 / +2 lines)
Lines 99-105 Link Here
99
99
100
	char[] fileName = name ~ "\0";
100
	char[] fileName = name ~ "\0";
101
101
102
	music[ch] = Mix_LoadMUS(fileName);
102
	music[ch] = Mix_LoadMUS(fileName.ptr);
103
	if(!music[ch]){
103
	if(!music[ch]){
104
		writefln("snd load error %s", name);
104
		writefln("snd load error %s", name);
105
		sound_use = false;
105
		sound_use = false;
Lines 119-125 Link Here
119
119
120
	char[] fileName = name ~ "\0";
120
	char[] fileName = name ~ "\0";
121
121
122
	chunk[bank] = Mix_LoadWAV(fileName);
122
	chunk[bank] = Mix_LoadWAV(fileName.ptr);
123
	if(!chunk[bank]){
123
	if(!chunk[bank]){
124
		sound_use = false;
124
		sound_use = false;
125
	}
125
	}

Return to bug 195686