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

(-)psyno/src/common.d (-4 / +3 lines)
Lines 1-4 Link Here
1
import mymath;
1
public import mymath;
2
import myio;
2
public import myio;
3
import log;
3
public import std.math;
4
import std.math;
(-)psyno/src/enemy.d (-1 / +1 lines)
Lines 50-56 Link Here
50
        else { 
50
        else { 
51
            static const int CO_STACK_SIZE = (16 * 1024);
51
            static const int CO_STACK_SIZE = (16 * 1024);
52
       }
52
       }
53
        coro_ = co_create(&enemy_spawn, this, null, CO_STACK_SIZE);
53
        coro_ = co_create(&enemy_spawn,  cast(void*)this, null, CO_STACK_SIZE);
54
54
55
        move_.init(this);
55
        move_.init(this);
56
    }
56
    }
(-)psyno/src/game.d (-3 / +5 lines)
Lines 37-42 Link Here
37
    static Game obj() {
37
    static Game obj() {
38
        return obj_;
38
        return obj_;
39
    }
39
    }
40
    PatternMgr patternmgr;
40
41
41
public:
42
public:
42
    this(char[] replayFile) {
43
    this(char[] replayFile) {
Lines 166-173 Link Here
166
167
167
        std.gc.fullCollect();
168
        std.gc.fullCollect();
168
//        std.gc.disable();
169
//        std.gc.disable();
170
        patternmgr = new PatternMgr;
169
171
170
        PatternMgr.init();
172
        patternmgr.init();
171
173
172
        Particle.init();
174
        Particle.init();
173
175
Lines 221-233 Link Here
221
        addPatternWait_--;
223
        addPatternWait_--;
222
        if (addPatternWait_ < 0 && patterns_.length < 5 &&
224
        if (addPatternWait_ < 0 && patterns_.length < 5 &&
223
            player_.comboCnt() == 0) {
225
            player_.comboCnt() == 0) {
224
            if (!PatternMgr.addNextPattern() && enemyMgr_.objNum == 0) {
226
            if (!patternmgr.addNextPattern() && enemyMgr_.objNum == 0) {
225
                isEnd_ = true;
227
                isEnd_ = true;
226
            }
228
            }
227
        }
229
        }
228
/*
230
/*
229
        if (enemyMgr_.objNum() < 5 || rnd(300) == 0) {
231
        if (enemyMgr_.objNum() < 5 || rnd(300) == 0) {
230
            PatternMgr.addRandomPattern();
232
            patternmgr.addRandomPattern();
231
        }
233
        }
232
*/
234
*/
233
/*
235
/*
(-)psyno/src/glbf.d (-1 / +1 lines)
Lines 8-14 Link Here
8
import std.math;
8
import std.math;
9
import std.c.stdio;
9
import std.c.stdio;
10
import std.c.stdlib;
10
import std.c.stdlib;
11
import std.string;
11
import std.c.string;
12
import opengl;
12
import opengl;
13
import openglu;
13
import openglu;
14
import SDL;
14
import SDL;
(-)psyno/src/http.d (-1 / +1 lines)
Lines 324-330 Link Here
324
        return res;
324
        return res;
325
    }
325
    }
326
326
327
    bool alive() { return ss_ !== null; }
327
    bool alive() { return ss_ !is null; }
328
328
329
    bool close() { return close; }
329
    bool close() { return close; }
330
    void close(bool c) { close_ = c; }
330
    void close(bool c) { close_ = c; }
(-)psyno/src/http_thread.d (-2 / +2 lines)
Lines 24-31 Link Here
24
            isEnd_ = true;
24
            isEnd_ = true;
25
        }
25
        }
26
        catch (Object o) {
26
        catch (Object o) {
27
            Log.warn("cannot connect score server: " ~ o.toString());
27
//            Log.warn("cannot connect score server: " ~ o.toString());
28
            isError_ = true;
28
  //          isError_ = true;
29
        }
29
        }
30
30
31
        return 0;
31
        return 0;
(-)psyno/src/log.d (-59 lines)
Lines 1-59 Link Here
1
private import std.stream;
2
private import std.string;
3
private import std.c.stdlib;
4
5
private import SDL;
6
7
class Log {
8
    static void init() {
9
        version (Win32) {
10
            s = new File("out.txt", FileMode.OutNew);
11
        }
12
        else {
13
            s = stdout;
14
        }
15
    }
16
    static void quit() {
17
        version (Win32) {
18
            s.close();
19
        }
20
        s = null;
21
    }
22
    static Stream s;
23
24
    static bit errored = false;
25
    static void report(char[] tag, char[] msg) {
26
        s.writeLine("[" ~ tag ~ "] " ~ msg);
27
    }
28
    static void error(char[] msg) {
29
        report("ERROR", msg);
30
        errored = true;
31
        assert(false);
32
    }
33
    static void errorSDL(char[] msg) {
34
        error("[SDL] " ~ msg ~ ": " ~ std.string.toString(SDL_GetError()));
35
    }
36
    static void warn(char[] msg) {
37
        report("WARN", msg);
38
    }
39
    static void warnSDL(char[] msg) {
40
        warn("[SDL] " ~ msg ~ ": " ~ std.string.toString(SDL_GetError()));
41
    }
42
    static void info(char[] msg) {
43
        report("INFO", msg);
44
    }
45
    static void dbg(char[] msg) {
46
        debug {
47
            report("DBG", msg);
48
        }
49
    }
50
    static void dbg(int msg) {
51
        debug {
52
            report("DBG", std.string.toString(msg));
53
        }
54
    }
55
    static bit isErrored() {
56
        return errored;
57
    }
58
59
}
(-)psyno/src/Makefile (-10 / +10 lines)
Lines 1-21 Link Here
1
BUILDTYPE=Release
1
#BUILDTYPE=Release
2
#BUILDTYPE=Debug
2
BUILDTYPE=Debug
3
3
4
DC=dmd
4
#DC=dmd
5
#DC=gdc
5
DC=gdc
6
EXE=sino
6
EXE=../psyno
7
7
8
include Makefile.init
8
include Makefile.init
9
9
10
CFLAGS += `sdl-config --cflags`
10
11
11
12
INCLUDES += -Isdl -Iopengl 
12
INCLUDES += -Isdl -Iopengl 
13
LIBS += `sdl-config --libs` -lpthread -lm -lSDL_pad -lGL -lGLU -lSDL_mixer pcl-1.3/pcl/pcl.o -lSDL_pad -lSDL_net
13
LIBS += `sdl-config --libs` -lpthread -lm -lGL -lGLU -lSDL_mixer pcl-1.3/pcl/pcl.o SDL_pad/.libs/libSDL_pad.a -lSDL_net
14
ifeq ($(DC), dmd)
14
ifeq ($(DC), dmd)
15
DFLAGS += -op
15
DFLAGS += -op
16
LIBS += -lphobos
16
LIBS += -lgphobos
17
else
17
else
18
LIBS += /usr/local/stow/gcc-gdc-3.4.0/lib/libphobos.a
18
LIBS += -lgphobos
19
endif
19
endif
20
20
21
SDLSOURCES=sdl/SDL_joystick.d sdl/SDL_video.d sdl/SDL_pad.d sdl/SDL_mixer.d sdl/SDL_net.d
21
SDLSOURCES=sdl/SDL_joystick.d sdl/SDL_video.d sdl/SDL_pad.d sdl/SDL_mixer.d sdl/SDL_net.d
Lines 30-36 Link Here
30
#	ruby gen_iointer.rb
30
#	ruby gen_iointer.rb
31
31
32
$(SDLOBJS): %.o:%.d
32
$(SDLOBJS): %.o:%.d
33
	$(DC) $(OUT) -c $(DFLAGS) $(INCLUDES) $<
33
	$(DC) $(OUT) -c $(DFLAGS) $(INCLUDES) $< && mv SDL*.o ./sdl
34
34
35
pcl-1.3/Makefile:
35
pcl-1.3/Makefile:
36
	cd pcl-1.3; ./configure
36
	cd pcl-1.3; ./configure
(-)psyno/src/Makefile.init (-4 / +4 lines)
Lines 45-60 Link Here
45
endif
45
endif
46
46
47
ifeq ($(BUILDTYPE), Release)
47
ifeq ($(BUILDTYPE), Release)
48
	GCCFLAGS+=-O2 -W -Wall -DNDEBUG -ffast-math -fomit-frame-pointer -D$(PLATFORM)
48
	GCCFLAGS+=-O2 -W -DNDEBUG -ffast-math -fomit-frame-pointer -D$(PLATFORM)
49
	DMDFLAGS+=-O -release
49
	DMDFLAGS+=-O -release
50
	GDCFLAGS+=-frelease
50
	GDCFLAGS+=-d -frelease
51
endif
51
endif
52
52
53
ifeq ($(BUILDTYPE), Debug)
53
ifeq ($(BUILDTYPE), Debug)
54
	GCCFLAGS+=-g -W -Wall -D$(PLATFORM)
54
	GCCFLAGS+=-g -W  -D$(PLATFORM)
55
	DMDFLAGS+=-g -debug
55
	DMDFLAGS+=-g -debug
56
	DMDFLAGS+=-unittest
56
	DMDFLAGS+=-unittest
57
	GDCFLAGS+=-fdebug
57
	GDCFLAGS+=-fdebug -ffast-math -fdeprecated
58
endif
58
endif
59
59
60
CFLAGS+=$(GCCFLAGS)
60
CFLAGS+=$(GCCFLAGS)
(-)psyno/src/myglbf.d (-2 / +2 lines)
Lines 9-17 Link Here
9
void initLetter() {
9
void initLetter() {
10
    int ret = glbfInit(&font, `data/kochi.bmp`, 12, 14, 21);
10
    int ret = glbfInit(&font, `data/kochi.bmp`, 12, 14, 21);
11
    if (ret != 0) {
11
    if (ret != 0) {
12
        Log.errorSDL("failed initialize font");
12
 //       Log.errorSDL("failed initialize font");
13
    }
13
    }
14
    Log.info("initialize font");
14
 //   Log.info("initialize font");
15
}
15
}
16
16
17
void drawNum(int num, float x, float y, float sx, float sy,
17
void drawNum(int num, float x, float y, float sx, float sy,
(-)psyno/src/mygl.d (-3 / +3 lines)
Lines 1-5 Link Here
1
import opengl;
1
public import opengl;
2
import openglu;
2
public import openglu;
3
private import game;
3
private import game;
4
4
5
void myglCircle(float x, float y, float r, float[] xs, float[] ys) {
5
void myglCircle(float x, float y, float r, float[] xs, float[] ys) {
Lines 96-102 Link Here
96
    glVertex3f(x2, y2, z2);
96
    glVertex3f(x2, y2, z2);
97
}
97
}
98
98
99
// 3, 4 °ú¿ô¤Î¤ß clip
99
// 3, 4 clip
100
void myglClippedLine2(float x1, float y1, float x2, float y2) {
100
void myglClippedLine2(float x1, float y1, float x2, float y2) {
101
    myglClippedLine2(x1, y1, x2, y2, 0);
101
    myglClippedLine2(x1, y1, x2, y2, 0);
102
}
102
}
(-)psyno/src/mymath.d (-2 / +2 lines)
Lines 49-55 Link Here
49
    return x*x+y*y;
49
    return x*x+y*y;
50
}
50
}
51
51
52
float length(float x, float y) {
52
float lengthy(float x, float y) {
53
    return std.math.sqrt(length2(x, y));
53
    return std.math.sqrt(length2(x, y));
54
}
54
}
55
55
Lines 84-90 Link Here
84
}
84
}
85
85
86
void normalize(inout float x, inout float y) {
86
void normalize(inout float x, inout float y) {
87
    float d = length(x, y);
87
    float d = lengthy(x, y);
88
    x /= d;
88
    x /= d;
89
    y /= d;
89
    y /= d;
90
}
90
}
(-)psyno/src/opengl/opengl.d (-8 / +3 lines)
Lines 1-10 Link Here
1
version (Win32) {
2
	private import std.c.windows.windows;
3
	extern(Windows):
4
}
5
else {
6
	extern(C):
1
	extern(C):
7
}
2
8
3
9
alias uint GLenum;
4
alias uint GLenum;
10
alias ubyte GLboolean;
5
alias ubyte GLboolean;
Lines 1116-1122 Link Here
1116
/*************************************************************/
1111
/*************************************************************/
1117
1112
1118
void /*APIENTRY*/glAccum (GLenum op, GLfloat value);
1113
void /*APIENTRY*/glAccum (GLenum op, GLfloat value);
1119
void /*APIENTRY*/glAlphaFunc (GLenum func, GLclampf ref);
1114
void /*APIENTRY*/glAlphaFunc (GLenum func, GLclampf);
1120
GLboolean /*APIENTRY*/glAreTexturesResident (GLsizei n, GLuint *textures, GLboolean *residences);
1115
GLboolean /*APIENTRY*/glAreTexturesResident (GLsizei n, GLuint *textures, GLboolean *residences);
1121
void /*APIENTRY*/glArrayElement (GLint i);
1116
void /*APIENTRY*/glArrayElement (GLint i);
1122
void /*APIENTRY*/glBegin (GLenum mode);
1117
void /*APIENTRY*/glBegin (GLenum mode);
Lines 1369-1375 Link Here
1369
void /*APIENTRY*/glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
1364
void /*APIENTRY*/glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
1370
void /*APIENTRY*/glSelectBuffer (GLsizei size, GLuint *buffer);
1365
void /*APIENTRY*/glSelectBuffer (GLsizei size, GLuint *buffer);
1371
void /*APIENTRY*/glShadeModel (GLenum mode);
1366
void /*APIENTRY*/glShadeModel (GLenum mode);
1372
void /*APIENTRY*/glStencilFunc (GLenum func, GLint ref, GLuint mask);
1367
void /*APIENTRY*/glStencilFunc (GLenum func, GLint, GLuint mask);
1373
void /*APIENTRY*/glStencilMask (GLuint mask);
1368
void /*APIENTRY*/glStencilMask (GLuint mask);
1374
void /*APIENTRY*/glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
1369
void /*APIENTRY*/glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
1375
void /*APIENTRY*/glTexCoord1d (GLdouble s);
1370
void /*APIENTRY*/glTexCoord1d (GLdouble s);
(-)psyno/src/opengl/openglu.d (-5 lines)
Lines 1-11 Link Here
1
import opengl;
1
import opengl;
2
2
3
version (Win32) {
4
	extern(Windows):
5
}
6
else {
7
	extern(C):
3
	extern(C):
8
}
9
4
10
GLubyte* gluErrorString (
5
GLubyte* gluErrorString (
11
    GLenum   errCode);
6
    GLenum   errCode);
(-)psyno/src/pattern.d (-1 / +1 lines)
Lines 6-12 Link Here
6
private import pversion;
6
private import pversion;
7
7
8
class PatternMgr {
8
class PatternMgr {
9
    static void init() {
9
    void init() {
10
        patterns_.length = 0;
10
        patterns_.length = 0;
11
        patternIte_ = 0;
11
        patternIte_ = 0;
12
        patternLevel_ = 0;
12
        patternLevel_ = 0;
(-)psyno/src/player.d (-12 / +12 lines)
Lines 3-9 Link Here
3
3
4
private import common;
4
private import common;
5
private import sino;
5
private import sino;
6
private import log;
6
private import SDL_pad;
7
private import charactor;
7
private import charactor;
8
private import shot;
8
private import shot;
9
private import sound;
9
private import sound;
Lines 80-86 Link Here
80
        if (isQdInvisible()) {
80
        if (isQdInvisible()) {
81
            static float prevAngle = float.nan;
81
            static float prevAngle = float.nan;
82
82
83
            if (nearest_ === null ||
83
            if (nearest_ is null ||
84
                (prevAngle != a_ && state_ == State.ATACKED)) {
84
                (prevAngle != a_ && state_ == State.ATACKED)) {
85
                prevAngle = a_;
85
                prevAngle = a_;
86
86
Lines 150-156 Link Here
150
        }
150
        }
151
151
152
        void atackCommon() {
152
        void atackCommon() {
153
            if (nearest_ === null) return;
153
            if (nearest_ is null) return;
154
154
155
            float d2 = distance2(x_, y_, nearest_.x, nearest_.y);
155
            float d2 = distance2(x_, y_, nearest_.x, nearest_.y);
156
            float a = angle(x_, y_, nearest_.x, nearest_.y);
156
            float a = angle(x_, y_, nearest_.x, nearest_.y);
Lines 172-178 Link Here
172
                    foreach (Shot s; Game.obj.shots()) {
172
                    foreach (Shot s; Game.obj.shots()) {
173
                        if (!s.alive()) continue;
173
                        if (!s.alive()) continue;
174
174
175
                        // @@@ ¥³¥Ô¥Ú¤Ç¥³¡¼¥É¤ò½ñ¤¯¤Ê
175
                        //
176
                        if (distance2(nearest_.x, nearest_.y,
176
                        if (distance2(nearest_.x, nearest_.y,
177
                                      s.x, s.y) < 10000) {
177
                                      s.x, s.y) < 10000) {
178
                            s.die();
178
                            s.die();
Lines 234-242 Link Here
234
                    comboScore_ += fscore;
234
                    comboScore_ += fscore;
235
                    Game.obj.addScore(fscore);
235
                    Game.obj.addScore(fscore);
236
236
237
                    Log.info("score: " ~ tostr(score) ~ "*" ~ tostr(comboCnt_)
237
//                    Log.info("score: " ~ tostr(score) ~ "*" ~ tostr(comboCnt_)
238
                             ~ " = " ~ tostr(fscore)
238
  //                           ~ " = " ~ tostr(fscore)
239
                             ~ " (vanished: " ~ tostr(vanishShotCnt_) ~ ")" );
239
    //                         ~ " (vanished: " ~ tostr(vanishShotCnt_) ~ ")" );
240
                }
240
                }
241
241
242
                Game.obj.setMoveWait(14);
242
                Game.obj.setMoveWait(14);
Lines 289-295 Link Here
289
289
290
        case State.SQD:
290
        case State.SQD:
291
        case State.QD:
291
        case State.QD:
292
            if (nearest_ === null) {
292
            if (nearest_ is null) {
293
                state_ = State.FREE;
293
                state_ = State.FREE;
294
                break;
294
                break;
295
            }
295
            }
Lines 422-435 Link Here
422
422
423
        if (!isnan(a_)) lastAngle_ = a_;
423
        if (!isnan(a_)) lastAngle_ = a_;
424
424
425
        // ¤á¤ó¤É¤¦¤À¤·Åö¤êȽÄê¤â¤³¤³¤Ç¤ä¤Ã¤Á¤Þ¤¨
425
        // 
426
        if (isDamage()) {
426
        if (isDamage()) {
427
        }
427
        }
428
        else if (isQdInvisible()) {
428
        else if (isQdInvisible()) {
429
            foreach (Shot s; Game.obj.shots()) {
429
            foreach (Shot s; Game.obj.shots()) {
430
                if (distance2(x_, y_, s.x, s.y) < size_*size_) {
430
                if (distance2(x_, y_, s.x, s.y) < size_*size_) {
431
                    s.die();
431
                    s.die();
432
                    /* ¥¤¥é¥Í
432
                    /*
433
                    float rs() { return rnd(20.0)-10.0; }
433
                    float rs() { return rnd(20.0)-10.0; }
434
                    float[3] col;
434
                    float[3] col;
435
                    setRndColor(col);
435
                    setRndColor(col);
Lines 580-586 Link Here
580
        glColor4f(1, 0, 0, 0.5);
580
        glColor4f(1, 0, 0, 0.5);
581
581
582
        foreach (Enemy e; Game.obj.enemies()) {
582
        foreach (Enemy e; Game.obj.enemies()) {
583
            if (e === nearest_) {
583
            if (e is nearest_) {
584
                static const int PERIOD = 4;
584
                static const int PERIOD = 4;
585
                int r = turn_ % (PERIOD*3);
585
                int r = turn_ % (PERIOD*3);
586
                if (r < PERIOD) {
586
                if (r < PERIOD) {
Lines 674-680 Link Here
674
674
675
    float lastAngle_;
675
    float lastAngle_;
676
676
677
    // ÈÆÍÑÍÑÅÓ¤ÎÄä»ß¥«¥¦¥ó¥¿
677
    //
678
    int holdCnt_;
678
    int holdCnt_;
679
    int swordCnt_;
679
    int swordCnt_;
680
    int damageDashCnt_;
680
    int damageDashCnt_;
(-)psyno/src/pversion.d (-1 / +1 lines)
Lines 24-30 Link Here
24
        initVersion(toInt(ver[0]), toInt(ver[1]), toInt(ver[2]));
24
        initVersion(toInt(ver[0]), toInt(ver[1]), toInt(ver[2]));
25
    }
25
    }
26
    else {
26
    else {
27
        Log.warn(`corrupt replay version!, trying current version...`);
27
    //    Log.warn(`corrupt replay version!, trying current version...`);
28
        initVersion();
28
        initVersion();
29
    }
29
    }
30
}
30
}
(-)psyno/src/rc.d (-15 / +15 lines)
Lines 1-7 Link Here
1
private import std.conv;
1
private import std.conv;
2
private import std.stream;
2
private import std.stream;
3
private import std.string;
3
private import std.string;
4
private import log;
4
private import std.stdio;
5
private import myio;
5
private import myio;
6
6
7
extern(C) void exit(int status);
7
extern(C) void exit(int status);
Lines 23-29 Link Here
23
            input = new File(file);
23
            input = new File(file);
24
        }
24
        }
25
        catch (Error e) {
25
        catch (Error e) {
26
            Log.error(e.toString());
26
//            Log.error(e.toString());
27
        }
27
        }
28
28
29
        while (!input.eof()) {
29
        while (!input.eof()) {
Lines 31-37 Link Here
31
            if (line.length == 0 || line[0] == '#') continue;
31
            if (line.length == 0 || line[0] == '#') continue;
32
            char[][] tok = split(line);
32
            char[][] tok = split(line);
33
            if (tok.length < 1) {
33
            if (tok.length < 1) {
34
                Log.warn(file ~  ": resource file broken. (" ~ line ~ ")");
34
         //       Log.warn(file ~  ": resource file broken. (" ~ line ~ ")");
35
                continue;
35
                continue;
36
            }
36
            }
37
37
Lines 52-80 Link Here
52
            }
52
            }
53
            else {
53
            else {
54
                if (args[i] != "-h") {
54
                if (args[i] != "-h") {
55
                    dout.writeLine(args[i] ~ ": invalid option");
55
                    writefln(args[i] ~ ": invalid option");
56
                }
56
                }
57
                dout.writeLine("usage: " ~ args[0] ~ " [options]");
57
                writefln("usage: " ~ args[0] ~ " [options]");
58
                dout.writeLine("options:");
58
                writefln("options:");
59
                dout.writeLine("  -w    \tnowait");
59
                writefln("  -w    \tnowait");
60
                dout.writeLine("  -m    \tnosound (yet)");
60
                writefln("  -m    \tnosound (yet)");
61
                dout.writeLine("  -l    \tlow resolution (yet)");
61
                writefln("  -l    \tlow resolution (yet)");
62
                dout.writeLine("  -b    \tno background (yet)");
62
                writefln("  -b    \tno background (yet)");
63
                dout.writeLine("  -w    \twindow (yet)");
63
                writefln("  -w    \twindow (yet)");
64
                dout.writeLine("  -h    \thelp");
64
                writefln("  -h    \thelp");
65
                exit(1);
65
                exit(1);
66
            } 
66
            }
67
        }
67
        }
68
    }
68
    }
69
69
70
public:
70
public:
71
    bool hasKey(char[] key) {
71
    bool hasKey(char[] key) {
72
        return (key in rc_) !== null;
72
        return (key in rc_) !is null;
73
    }
73
    }
74
74
75
    char[] get(char[] key) {
75
    char[] get(char[] key) {
76
        if (!(key in rc_)) {
76
        if (!(key in rc_)) {
77
            Log.warn(key ~ " is not in resource");
77
//            Log.warn(key ~ " is not in resource");
78
            return "";
78
            return "";
79
        }
79
        }
80
        return rc_[key];
80
        return rc_[key];
(-)psyno/src/replaydb.d (-279 lines)
Lines 1-279 Link Here
1
private import common;
2
private import scene_select;
3
4
private import std.thread;
5
private import std.conv;
6
private import std.string;
7
8
class ReplayEntry {
9
    int gameScore;
10
    int turnScore;
11
    int clearScore;
12
    int leftScore;
13
    int nomissScore;
14
    int allScore;
15
    long utcTime;
16
    int patterns;
17
18
    int endTurn;
19
    int[] scoreStat;
20
    enum ScoreStatEnc {
21
        CSV, DIV_PRINTABLE95
22
    }
23
    ScoreStatEnc scoreStatEnc;
24
25
    char[] mode;
26
    long seed;
27
    char[] inputs;
28
29
    char[] pversion;
30
    char[] name;
31
    char[] date;
32
33
    char[] filename;
34
35
    int opCmp(Object o) {
36
        ReplayEntry e = cast(ReplayEntry)o;
37
        return (allScore < e.allScore) - (allScore > e.allScore);
38
    }
39
40
    void addHeaderLine(char[] line, char[] errmsg) {
41
        char[][] kv = line.split(`: `);
42
        char[] k = kv[0];
43
        char[] v = join(kv[1..length], `: `);
44
        switch (k) {
45
        case `version`:
46
            pversion = v; break;
47
        case `score`:
48
            allScore = toInt(v); break;
49
        case `name`:
50
            name = v; break;
51
        case `date`:
52
            date = v; break;
53
        case `gameScore`:
54
            gameScore = toInt(v); break;
55
        case `turnScore`:
56
            turnScore = toInt(v); break;
57
        case `clearScore`:
58
            clearScore = toInt(v); break;
59
        case `leftScore`:
60
            leftScore = toInt(v); break;
61
        case `nomissScore`:
62
            nomissScore = toInt(v); break;
63
        case `turn`:
64
            endTurn = toInt(v); break;
65
        case `patterns`:
66
            patterns = toInt(v); break;
67
        case `seed`:
68
            seed = toLong(v); break;
69
        case `utcTime`:
70
            utcTime = toLong(v); break;
71
        case `mode`:
72
            mode = v; break;
73
        case `filename`:
74
            filename = v; break;
75
        case `inputEnc`:
76
            break;
77
        case `scoreStatEnc`:
78
            if (v == `divPrintable95`)
79
                scoreStatEnc = ScoreStatEnc.DIV_PRINTABLE95;
80
            break;
81
        case `scoreStat`:
82
            if (scoreStatEnc == ScoreStatEnc.DIV_PRINTABLE95) {
83
                int prev = 0;
84
                for (int i = 0; i < v.length; i += 4) {
85
                    int s = prev +
86
                        (v[i+0]-32) +
87
                        (v[i+1]-32)*95 +
88
                        (v[i+2]-32)*95*95 +
89
                        (v[i+3]-32)*95*95*95;
90
                    scoreStat ~= s;
91
                    prev = s;
92
                }
93
            }
94
            else {
95
                foreach (char[] s; v.split(`,`)) {
96
                    if (s.length == 0) break;
97
                    scoreStat ~= toInt(s);
98
                }
99
            }
100
            break;
101
        default:
102
            Log.warn(k ~ `: unknown key in replay ` ~ errmsg);
103
        }
104
    }
105
}
106
107
abstract class ReplayDB {
108
    void setSort(char[] mode, SceneSelect scene) {
109
        sorted.length = 0;
110
        foreach (ReplayEntry e; entries) {
111
            if (e.mode == mode) sorted ~= e;
112
        }
113
        sorted.sort;
114
115
        scene.setResultDisplay();
116
    }
117
118
    void prepareReplayFile(ReplayEntry entry) {}
119
120
    bool isOk() { return ok_; }
121
    bool isError() { return error_; }
122
123
    ReplayEntry[] entries;
124
    ReplayEntry[] sorted;
125
126
    bool ok_;
127
    bool error_;
128
129
}
130
131
private import std.stream;
132
private import std.file;
133
private import std.regexp;
134
135
class LocalReplayDB : ReplayDB {
136
    int load() {
137
        RegExp rpyReg =
138
            new RegExp(`^\d\d\d\d\d\d\d\d\d\d\d\d_[a-zA-Z0-9%]+\.rpy$`, ``);
139
        foreach (char[] fname; listdir(`replay`)) {
140
            if (!rpyReg.test(fname)) continue;
141
142
            try {
143
                ReplayEntry entry = new ReplayEntry();
144
145
                File ifile = new File(`replay/` ~ fname);
146
                char[] line;
147
                while ((line = ifile.readLine).length != 0) {
148
                    entry.addHeaderLine(line, fname);
149
                }
150
151
                ifile.close();
152
153
                entries ~= entry;
154
            }
155
            catch (Object o) {
156
                Log.warn(fname~": broken replay file ("~o.toString()~").");
157
            }
158
        }
159
160
        ok_ = true;
161
162
        error_ = entries.length == 0;
163
164
        return 0;
165
    }
166
167
    this() {
168
        ok_ = false;
169
        thread_ = new Thread(&load);
170
        thread_.start();
171
    }
172
173
    Thread thread_;
174
}
175
176
private import http;
177
private import sino;
178
private import rc;
179
180
class NetReplayDB : ReplayDB {
181
    this() {
182
        ok_ = true;
183
    }
184
185
    override void setSort(char[] mode, SceneSelect scene) {
186
        mode_ = mode;
187
        ok_ = false;
188
        scene_ = scene;
189
        thread_ = new Thread(&load);
190
        thread_.start();
191
    }
192
193
    int load() {
194
        try {
195
            char[] host = Sino.rc.get(`scoreServer`);
196
            int port = Sino.rc.getInt(`scorePort`);
197
            char[] dir = Sino.rc.get(`scorePath`);
198
199
            Http h = new Http10(host, port);
200
            char[] path = dir ~ `/scores_` ~ mode_ ~ `.txt`;
201
            HttpResponse res = h.get(path);
202
203
            Log.info(`score server status: ` ~ res.statusLine);
204
205
            sorted.length = 0;
206
            ReplayEntry e = new ReplayEntry();
207
            foreach (char[] line; res.messageBody.split("\n")) {
208
                if (line.length > 0) {
209
                    e.addHeaderLine(line, path);
210
                }
211
                else {
212
                    if (e.name) {
213
                        sorted ~= e;
214
                        e = new ReplayEntry();
215
                    }
216
                }
217
            }
218
219
            sorted.sort;
220
221
            error_ = false;
222
223
            scene_.setResultDisplay();
224
        }
225
        catch (Object o) {
226
            Log.info(`cannot connect score server: ` ~ o.toString());
227
            error_ = true;
228
        }
229
230
        ok_ = true;
231
232
        return 0;
233
    }
234
235
    override void prepareReplayFile(ReplayEntry entry) {
236
        ok_ = false;
237
        entry_ = entry;
238
        thread_ = new Thread(&prepare);
239
        thread_.start();
240
    }
241
242
    private int prepare() {
243
        try {
244
            char[] rpyfile = `replay/` ~ entry_.filename;
245
            if (std.file.exists(rpyfile)) {
246
                ok_ = true;
247
                return 0;
248
            }
249
250
            Log.info(rpyfile ~ `: get from score server`);
251
252
            char[] host = Sino.rc.get(`scoreServer`);
253
            int port = Sino.rc.getInt(`scorePort`);
254
            char[] dir = Sino.rc.get(`scorePath`);
255
256
            Http h = new Http10(host, port);
257
            char[] path = dir ~ `/` ~ rpyfile;
258
            path = path.replace(`%`, `%25`);
259
            HttpResponse res = h.get(path);
260
261
            char[] rpy = res.messageBody;
262
            std.file.write(rpyfile, rpy);
263
        }
264
        catch (Object o) {
265
            Log.info(`cannot get replay file: ` ~ o.toString());
266
            error_ = true;
267
        }
268
269
        ok_ = true;
270
271
        return 0;
272
    }
273
274
private:
275
    Thread thread_;
276
    char[] mode_;
277
    SceneSelect scene_;
278
    ReplayEntry entry_;
279
}
(-)psyno/src/scene_game.d (-2 / +3 lines)
Lines 1-11 Link Here
1
private import game;
1
private import game;
2
private import scene;
2
private import scene;
3
private import log;
3
private import scene_result;
4
private import scene_select;
4
5
5
class SceneGame : Scene {
6
class SceneGame : Scene {
6
public:
7
public:
7
    this() {
8
    this() {
8
        Log.info("scene game");
9
      //  Log.info("scene game");
9
        game_ = new Game();
10
        game_ = new Game();
10
    }
11
    }
11
12
(-)psyno/src/scene_result.d (-8 / +9 lines)
Lines 1-5 Link Here
1
private import game;
1
private import game;
2
private import scene;
2
private import scene;
3
private import scene_select;
3
private import mygl;
4
private import mygl;
4
private import myglbf;
5
private import myglbf;
5
private import sound;
6
private import sound;
Lines 21-27 Link Here
21
class SceneResult : Scene {
22
class SceneResult : Scene {
22
public:
23
public:
23
    this(Game game) {
24
    this(Game game) {
24
        Log.info("scene result");
25
    //    Log.info("scene result");
25
        Sound.obj.fadeMusic();
26
        Sound.obj.fadeMusic();
26
27
27
        game_ = game;
28
        game_ = game;
Lines 231-246 Link Here
231
        if (httpThread.isEnd()) {
232
        if (httpThread.isEnd()) {
232
            HttpResponse res = httpThread.response;
233
            HttpResponse res = httpThread.response;
233
234
234
            Log.info(`score server status: ` ~ res.statusLine);
235
//            Log.info(`score server status: ` ~ res.statusLine);
235
            status_ = strip(res.messageBody);
236
            status_ = strip(res.messageBody);
236
            Log.info(status_);
237
//            Log.info(status_);
237
        }
238
        }
238
        else if (httpThread.isError()) {
239
        else if (httpThread.isError()) {
239
            Log.info("err");
240
  //          Log.info("err");
240
            status_ = `ERROR`;
241
            status_ = `ERROR`;
241
        }
242
        }
242
        else if (httpThread.isTimeout()) {
243
        else if (httpThread.isTimeout()) {
243
            Log.info("timeout");
244
    //        Log.info("timeout");
244
            status_ = `TIMEOUT`;
245
            status_ = `TIMEOUT`;
245
        }
246
        }
246
        else {
247
        else {
Lines 408-414 Link Here
408
            }
409
            }
409
        }
410
        }
410
        catch (Object o) {
411
        catch (Object o) {
411
            Log.warn("exception in name entry: " ~ o.toString());
412
//            Log.warn("exception in name entry: " ~ o.toString());
412
        }
413
        }
413
    }
414
    }
414
415
Lines 432-438 Link Here
432
        char[] dt = formatDate(d);
433
        char[] dt = formatDate(d);
433
        char[] encname = fnEncode(name_);
434
        char[] encname = fnEncode(name_);
434
        fname_ = dt ~ "_" ~ encname ~ ".rpy";
435
        fname_ = dt ~ "_" ~ encname ~ ".rpy";
435
        Log.info("replay save to replay/" ~ fname_);
436
//        Log.info("replay save to replay/" ~ fname_);
436
437
437
        File ofile = new File("replay/" ~ fname_, FileMode.OutNew);
438
        File ofile = new File("replay/" ~ fname_, FileMode.OutNew);
438
        with (result_) {
439
        with (result_) {
Lines 470-476 Link Here
470
        game_.saveReplay(ofile);
471
        game_.saveReplay(ofile);
471
        ofile.close();
472
        ofile.close();
472
473
473
        Log.info("replay save end");
474
//        Log.info("replay save end");
474
    }
475
    }
475
476
476
private:
477
private:
(-)psyno/src/scene_select.d (-11 / +13 lines)
Lines 1-11 Link Here
1
private import scene;
1
private import scene;
2
private import scene_game;
2
private import common;
3
private import common;
3
private import sino;
4
private import sino;
4
private import rc;
5
private import rc;
5
private import mygl;
6
private import mygl;
6
private import myglbf;
7
private import myglbf;
7
private import game;
8
private import game;
8
private import replaydb;
9
private import result_display;
9
private import result_display;
10
private import sound;
10
private import sound;
11
11
Lines 17-23 Link Here
17
class SceneSelect : Scene {
17
class SceneSelect : Scene {
18
public:
18
public:
19
    this() {
19
    this() {
20
        Log.info("scene select");
20
    //    Log.info("scene select");
21
        isEnd_ = false;
21
        isEnd_ = false;
22
22
23
        origNoSound_ = Sino.rc.get(`noSound`);
23
        origNoSound_ = Sino.rc.get(`noSound`);
Lines 79-85 Link Here
79
            state_ == State.REPLAY_PREPARE)
79
            state_ == State.REPLAY_PREPARE)
80
        {
80
        {
81
            draws_.draw();
81
            draws_.draw();
82
            doReplay();
82
//            doReplay();
83
            return;
83
            return;
84
        }
84
        }
85
85
Lines 126-132 Link Here
126
            doMenu();
126
            doMenu();
127
        }
127
        }
128
    }
128
    }
129
129
/*
130
    void setResultDisplay() {
130
    void setResultDisplay() {
131
        if (replayDB_.sorted.length == 0) {
131
        if (replayDB_.sorted.length == 0) {
132
            return;
132
            return;
Lines 154-165 Link Here
154
            dst.date = src.date;
154
            dst.date = src.date;
155
        }
155
        }
156
        copyEntry(replayDB_.sorted[replayIte_], result_);
156
        copyEntry(replayDB_.sorted[replayIte_], result_);
157
*/
157
/*
158
/*
158
        copyEntry!(ReplayDB.Entry, ResultDisplay)
159
        copyEntry!(ReplayDB.Entry, ResultDisplay)
159
            (replayDB_.sorted[replayIte_], result_);
160
            (replayDB_.sorted[replayIte_], result_);
160
*/
161
*/
161
        result_.init();
162
//        result_.init();
162
    }
163
//    }
163
164
164
    private void doMsg(char[] msg) {
165
    private void doMsg(char[] msg) {
165
        glDisable(GL_TEXTURE_2D);
166
        glDisable(GL_TEXTURE_2D);
Lines 203-209 Link Here
203
204
204
        drawStringC(msg, 240, 260, 14, 18, 1,1,1, elapsed/30);
205
        drawStringC(msg, 240, 260, 14, 18, 1,1,1, elapsed/30);
205
    }
206
    }
206
207
/*
207
    void doReplay() {
208
    void doReplay() {
208
        drawString(`Select mode`, 50, 50, 10, 12, 1, 1, 1, 0.9);
209
        drawString(`Select mode`, 50, 50, 10, 12, 1, 1, 1, 0.9);
209
        char[][] modes;
210
        char[][] modes;
Lines 352-358 Link Here
352
            }
353
            }
353
        }
354
        }
354
    }
355
    }
355
356
*/
356
    void doMenu() {
357
    void doMenu() {
357
        char[][] menu;
358
        char[][] menu;
358
        menu ~= `EASY MODE`;
359
        menu ~= `EASY MODE`;
Lines 396-402 Link Here
396
                    Sino.rc.set(`gameMode`, `endless`);
397
                    Sino.rc.set(`gameMode`, `endless`);
397
                }
398
                }
398
            }
399
            }
399
            else if (h_ == 3) {
400
/*            else if (h_ == 3) {
400
                replayDB_ = new LocalReplayDB();
401
                replayDB_ = new LocalReplayDB();
401
                state_ = State.REPLAY_MODE;
402
                state_ = State.REPLAY_MODE;
402
                stateStartTurn_ = Sino.obj.timer.getTurn;
403
                stateStartTurn_ = Sino.obj.timer.getTurn;
Lines 406-411 Link Here
406
                state_ = State.REPLAY_MODE;
407
                state_ = State.REPLAY_MODE;
407
                stateStartTurn_ = Sino.obj.timer.getTurn;
408
                stateStartTurn_ = Sino.obj.timer.getTurn;
408
            }
409
            }
410
*/
409
        }
411
        }
410
412
411
/*
413
/*
Lines 452-459 Link Here
452
    State state_;
454
    State state_;
453
    int stateStartTurn_;
455
    int stateStartTurn_;
454
456
455
    ReplayDB replayDB_;
457
//    ReplayDB replayDB_;
456
    int replayIte_;
458
//    int replayIte_;
457
459
458
    ResultDisplay result_;
460
    ResultDisplay result_;
459
    int replayMode_;
461
    int replayMode_;
(-)psyno/src/sdl/SDL.d (-68 / +73 lines)
Lines 20-90 Link Here
20
    slouken@devolution.com
20
    slouken@devolution.com
21
*/
21
*/
22
22
23
import SDL_types;
23
public import SDL_types;
24
import SDL_getenv;
24
public import SDL_getenv;
25
import SDL_error;
25
public import SDL_error;
26
import SDL_rwops;
26
public import SDL_rwops;
27
import SDL_timer;
27
public import SDL_timer;
28
import SDL_audio;
28
public import SDL_audio;
29
import SDL_cdrom;
29
public import SDL_cdrom;
30
import SDL_joystick;
30
public import SDL_joystick;
31
import SDL_events;
31
public import SDL_events;
32
import SDL_video;
32
public import SDL_video;
33
import SDL_byteorder;
33
public import SDL_byteorder;
34
import SDL_Version;
34
public import SDL_Version;
35
35
public import SDL_Keysym;
36
extern(C):
36
public import SDL_keyboard;
37
37
public import SDL_mouse;
38
/* As of version 0.5, SDL is loaded dynamically into the application */
38
39
39
extern(C):
40
/* These are the flags which may be passed to SDL_Init() -- you should
40
41
   specify the subsystems which you will be using in your application.
41
/* As of version 0.5, SDL is loaded dynamically into the application */
42
*/
42
43
const uint SDL_INIT_TIMER		= 0x00000001;
43
/* These are the flags which may be passed to SDL_Init() -- you should
44
const uint SDL_INIT_AUDIO		= 0x00000010;
44
   specify the subsystems which you will be using in your application.
45
const uint SDL_INIT_VIDEO		= 0x00000020;
45
*/
46
const uint SDL_INIT_CDROM		= 0x00000100;
46
const uint SDL_INIT_TIMER		= 0x00000001;
47
const uint SDL_INIT_JOYSTICK	= 0x00000200;
47
const uint SDL_INIT_AUDIO		= 0x00000010;
48
const uint SDL_INIT_NOPARACHUTE	= 0x00100000;	/* Don't catch fatal signals */
48
const uint SDL_INIT_VIDEO		= 0x00000020;
49
const uint SDL_INIT_EVENTTHREAD	= 0x01000000;	/* Not supported on all OS's */
49
const uint SDL_INIT_CDROM		= 0x00000100;
50
const uint SDL_INIT_EVERYTHING	= 0x0000FFFF;
50
const uint SDL_INIT_JOYSTICK	= 0x00000200;
51
51
const uint SDL_INIT_NOPARACHUTE	= 0x00100000;	/* Don't catch fatal signals */
52
/* This function loads the SDL dynamically linked library and initializes 
52
const uint SDL_INIT_EVENTTHREAD	= 0x01000000;	/* Not supported on all OS's */
53
 * the subsystems specified by 'flags' (and those satisfying dependencies)
53
const uint SDL_INIT_EVERYTHING	= 0x0000FFFF;
54
 * Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
54
55
 * signal handlers for some commonly ignored fatal signals (like SIGSEGV)
55
/* This function loads the SDL dynamically linked library and initializes 
56
 */
56
 * the subsystems specified by 'flags' (and those satisfying dependencies)
57
int SDL_Init(Uint32 flags);
57
 * Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
58
58
 * signal handlers for some commonly ignored fatal signals (like SIGSEGV)
59
/* This function initializes specific SDL subsystems */
59
 */
60
int SDL_InitSubSystem(Uint32 flags);
60
int SDL_Init(Uint32 flags);
61
61
62
/* This function cleans up specific SDL subsystems */
62
/* This function initializes specific SDL subsystems */
63
void SDL_QuitSubSystem(Uint32 flags);
63
int SDL_InitSubSystem(Uint32 flags);
64
64
65
/* This function returns mask of the specified subsystems which have
65
/* This function cleans up specific SDL subsystems */
66
   been initialized.
66
void SDL_QuitSubSystem(Uint32 flags);
67
   If 'flags' is 0, it returns a mask of all initialized subsystems.
67
68
*/
68
/* This function returns mask of the specified subsystems which have
69
Uint32 SDL_WasInit(Uint32 flags);
69
   been initialized.
70
70
   If 'flags' is 0, it returns a mask of all initialized subsystems.
71
/* This function cleans up all initialized subsystems and unloads the
71
*/
72
 * dynamically linked library.  You should call it upon all exit conditions.
72
Uint32 SDL_WasInit(Uint32 flags);
73
 */
73
74
void SDL_Quit();
74
/* This function cleans up all initialized subsystems and unloads the
75
75
 * dynamically linked library.  You should call it upon all exit conditions.
76
void SDL_SetModuleHandle(void *hInst);
76
 */
77
extern(Windows) void* GetModuleHandle(char*);
77
void SDL_Quit();
78
78
79
static this()
79
/+
80
{
80
void SDL_SetModuleHandle(void *hInst);
81
	/* Load SDL dynamic link library */
81
extern(Windows) void* GetModuleHandle(char*);
82
	if (SDL_Init(SDL_INIT_NOPARACHUTE) < 0)
82
83
		throw new Error("Error loading SDL");
83
static this()
84
	SDL_SetModuleHandle(GetModuleHandle(null));
84
{
85
}
85
	/* Load SDL dynamic link library */
86
86
	if (SDL_Init(SDL_INIT_NOPARACHUTE) < 0)
87
static ~this()
87
		throw new Error("Error loading SDL");
88
{
88
	SDL_SetModuleHandle(GetModuleHandle(null));
89
	SDL_Quit();
89
}
90
}
90
91
static ~this()
92
{
93
	SDL_Quit();
94
}
95
+/
(-)psyno/src/sdl/SDL_endian.d (-6 / +6 lines)
Lines 22-28 Link Here
22
22
23
/* Functions for reading and writing endian-specific values */
23
/* Functions for reading and writing endian-specific values */
24
24
25
/* These functions read and write data of the specified endianness, 
25
/* These functions read and write data of the specified endianness,
26
   dynamically translating to the host machine endianness.
26
   dynamically translating to the host machine endianness.
27
27
28
   e.g.: If you want to read a 16 bit value on big-endian machine from
28
   e.g.: If you want to read a 16 bit value on big-endian machine from
Lines 30-36 Link Here
30
		value = SDL_ReadLE16(rp);
30
		value = SDL_ReadLE16(rp);
31
         Note that the read/write functions use SDL_RWops pointers
31
         Note that the read/write functions use SDL_RWops pointers
32
         instead of FILE pointers.  This allows you to read and write
32
         instead of FILE pointers.  This allows you to read and write
33
         endian values from large chunks of memory as well as files 
33
         endian values from large chunks of memory as well as files
34
         and other data sources.
34
         and other data sources.
35
*/
35
*/
36
36
Lines 46-54 Link Here
46
   header should only be included in files that actually use them.
46
   header should only be included in files that actually use them.
47
*/
47
*/
48
48
49
Uint16 SDL_Swap16(Uint16 D) {
49
//Uint16 SDL_Swap16(Uint16 D) {
50
	return((D<<8)|(D>>8));
50
//	return((D<<8)|(D>>8));
51
}
51
//}
52
52
53
Uint32 SDL_Swap32(Uint32 D) {
53
Uint32 SDL_Swap32(Uint32 D) {
54
	return((D<<24)|((D<<8)&0x00FF0000)|((D>>8)&0x0000FF00)|(D>>24));
54
	return((D<<24)|((D<<8)&0x00FF0000)|((D>>8)&0x0000FF00)|(D>>24));
Lines 73-79 Link Here
73
//#define SDL_SwapBE16(X)	SDL_Swap16(X)
73
//#define SDL_SwapBE16(X)	SDL_Swap16(X)
74
//#define SDL_SwapBE32(X)	SDL_Swap32(X)
74
//#define SDL_SwapBE32(X)	SDL_Swap32(X)
75
//#define SDL_SwapBE64(X)	SDL_Swap64(X)
75
//#define SDL_SwapBE64(X)	SDL_Swap64(X)
76
Uint16 SDL_SwapLE16(Uint16 X) { return SDL_Swap16(X); }
76
//Uint16 SDL_SwapLE16(Uint16 X) { return SDL_Swap16(X); }
77
Uint32 SDL_SwapLE32(Uint32 X) { return SDL_Swap32(X); }
77
Uint32 SDL_SwapLE32(Uint32 X) { return SDL_Swap32(X); }
78
Uint64 SDL_SwapLE64(Uint64 X) { return SDL_Swap64(X); }
78
Uint64 SDL_SwapLE64(Uint64 X) { return SDL_Swap64(X); }
79
Uint16 SDL_SwapBE16(Uint16 X) { return (X); }
79
Uint16 SDL_SwapBE16(Uint16 X) { return (X); }
(-)psyno/src/sdl/SDL_events.d (-4 / +4 lines)
Lines 304-311 Link Here
304
  If 'state' is set to SDL_QUERY, SDL_EventState() will return the 
304
  If 'state' is set to SDL_QUERY, SDL_EventState() will return the 
305
  current processing state of the specified event.
305
  current processing state of the specified event.
306
*/
306
*/
307
const int SDL_QUERY	= -1;
307
const uint SDL_QUERY	= -1;
308
const int SDL_IGNORE	= 0;
308
const uint SDL_IGNORE	= 0;
309
const int SDL_DISABLE	= 0;
309
const uint SDL_DISABLE	= 0;
310
const int SDL_ENABLE	= 1;
310
const uint SDL_ENABLE	= 1;
311
Uint8 SDL_EventState(Uint8 type, int state);
311
Uint8 SDL_EventState(Uint8 type, int state);
(-)psyno/src/sdl/SDL_image.d (+84 lines)
Line 0 Link Here
1
/*
2
  SDL_image:  An example image loading library for use with SDL
3
  Copyright (C) 1999, 2000, 2001  Sam Lantinga
4
5
  This library is free software; you can redistribute it and/or
6
  modify it under the terms of the GNU Library General Public
7
  License as published by the Free Software Foundation; either
8
  version 2 of the License, or (at your option) any later version.
9
10
  This library is distributed in the hope that it will be useful,
11
  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
  Library General Public License for more details.
14
15
  You should have received a copy of the GNU Library General Public
16
  License along with this library; if not, write to the Free
17
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
19
  Sam Lantinga
20
  slouken@libsdl.org
21
*/
22
23
/* $Id: SDL_image.h,v 1.13 2002/04/13 15:06:00 slouken Exp $ */
24
25
// convert to D by shinichiro.h
26
27
/* A simple library to load images of various formats as SDL surfaces */
28
29
import SDL;
30
31
extern (C) {
32
33
/* Load an image from an SDL data source.
34
   The 'type' may be one of: "BMP", "GIF", "PNG", etc.
35
36
   If the image format supports a transparent pixel, SDL will set the
37
   colorkey for the surface.  You can enable RLE acceleration on the
38
   surface afterwards by calling:
39
   SDL_SetColorKey(image, SDL_RLEACCEL, image->format->colorkey);
40
*/
41
	SDL_Surface * IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, char *type);
42
/* Convenience functions */
43
	SDL_Surface * IMG_Load(char *file);
44
	SDL_Surface * IMG_Load_RW(SDL_RWops *src, int freesrc);
45
46
/* Invert the alpha of a surface for use with OpenGL
47
   This function is now a no-op, and only provided for backwards compatibility.
48
*/
49
	int IMG_InvertAlpha(int on);
50
51
/* Functions to detect a file type, given a seekable source */
52
	int IMG_isBMP(SDL_RWops *src);
53
	int IMG_isPNM(SDL_RWops *src);
54
	int IMG_isXPM(SDL_RWops *src);
55
	int IMG_isXCF(SDL_RWops *src);
56
	int IMG_isPCX(SDL_RWops *src);
57
	int IMG_isGIF(SDL_RWops *src);
58
	int IMG_isJPG(SDL_RWops *src);
59
	int IMG_isTIF(SDL_RWops *src);
60
	int IMG_isPNG(SDL_RWops *src);
61
	int IMG_isLBM(SDL_RWops *src);
62
63
/* Individual loading functions */
64
	SDL_Surface * IMG_LoadBMP_RW(SDL_RWops *src);
65
	SDL_Surface * IMG_LoadPNM_RW(SDL_RWops *src);
66
	SDL_Surface * IMG_LoadXPM_RW(SDL_RWops *src);
67
	SDL_Surface * IMG_LoadXCF_RW(SDL_RWops *src);
68
	SDL_Surface * IMG_LoadPCX_RW(SDL_RWops *src);
69
	SDL_Surface * IMG_LoadGIF_RW(SDL_RWops *src);
70
	SDL_Surface * IMG_LoadJPG_RW(SDL_RWops *src);
71
	SDL_Surface * IMG_LoadTIF_RW(SDL_RWops *src);
72
	SDL_Surface * IMG_LoadPNG_RW(SDL_RWops *src);
73
	SDL_Surface * IMG_LoadTGA_RW(SDL_RWops *src);
74
	SDL_Surface * IMG_LoadLBM_RW(SDL_RWops *src);
75
76
	SDL_Surface * IMG_ReadXPMFromArray(char **xpm);
77
78
/* We'll use SDL for reporting errors */
79
//#define IMG_SetError	SDL_SetError
80
	char* IMG_GetError() {
81
		return SDL_GetError();
82
	}
83
84
}
(-)psyno/src/sdl/SDL_mixer.d (-1 / +1 lines)
Lines 22-28 Link Here
22
22
23
// convert to D by shinichiro.h
23
// convert to D by shinichiro.h
24
24
25
/* $Id: SDL_mixer.d,v 1.1 2003/12/21 15:17:50 i Exp $ */
25
/* $Id: SDL_mixer.h,v 1.24 2002/05/21 05:45:59 slouken Exp $ */
26
26
27
import SDL;
27
import SDL;
28
28
(-)psyno/src/sdl/SDL_pad.d (-71 / +18 lines)
Lines 1-7 Link Here
1
/** @@@
1
/**
2
 * @@@ ¤¬ÉÕ¤¤¤Æ¤ë¤Î¤Ï°ì»þŪ¤Ê¥³¥á¥ó¥È
2
 * 
3
 * SDL_pad ¤È̾Á°¤òÉÕ¤±¤ë¤Î¤Ï´èÄ¥¤Ã¤Æºî¤ë¤È¤¤¤¦µ¤¹ç¤¤¤Î¤¢¤é¤ï¤ì
3
 * SDL_pad 
4
 * ¥Ç¥¶¥¤¥óŪ¤Ë¤Ï¶òľ¤ËÉáÄ̤ˤòÌܻؤ¹
4
 *
5
 */
5
 */
6
6
7
private import SDL;
7
private import SDL;
Lines 18-26 Link Here
18
}
18
}
19
19
20
enum {
20
enum {
21
	/** @@@
21
	/**
22
	 * ¤â¤Ã¤Èµ¤¤Î¤­¤¤¤¿Ì¾Á°¤¬¤¤¤¤¤Ê¤¢¡Ä
22
	 * 
23
	 * ¤¢¤È¤³¤ì¤é¤ÎÃͤϤɤ¦¤¹¤ë¡©
23
	 * 
24
	 * 0, 1, 2, 3, 4, 5, 6, 7, 8 ?
24
	 * 0, 1, 2, 3, 4, 5, 6, 7, 8 ?
25
	 * 0, 1, 5, 4, 6, 2, 10, 8, 9 ?
25
	 * 0, 1, 5, 4, 6, 2, 10, 8, 9 ?
26
	 */
26
	 */
Lines 374-486 Link Here
374
	PAD_END_BUTTON
374
	PAD_END_BUTTON
375
}
375
}
376
376
377
/** @@@
378
 * ¤Þ¤º¥Ü¥¿¥ó¤Î³µÇ°¤Ë¤Ä¤¤¤Æ
379
 * ¥­¡¼¥Ü¡¼¥É¡¢¥¸¥ç¥¤¥¹¥Æ¥£¥Ã¥¯¡¢¥Þ¥¦¥¹º¸Ã汦¡¢SDL_QUIT ¤ò¥Ü¥¿¥ó¤È¸Æ¤Ö
380
 * ¥æ¡¼¥¶¥Ü¥¿¥ó¤Ï²¡¤µ¤ì¤Æ¤¤¤ë¤«²¡¤µ¤ì¤Æ¤¤¤Ê¤¤¤«¤Ç 0 ¤« 1 ¤ÎÃͤò»ý¤Ä
381
 * ¥æ¡¼¥¶¥Ü¥¿¥ó¤ÏÊ£¿ô¤Î¥Ü¥¿¥ó¤ÎÏÀÍý OR ¤Ë¤è¤Ã¤Æ¼Â¸½¤µ¤ì¤ë
382
 * ¥æ¡¼¥¶¥Ü¥¿¥ó¤Ë¤Ï ID ¤¬¤¢¤ê¤³¤ì¤é¤Ï¼«Æ°Åª¤Ë³äÅö¤Æ¤é¤ì¤ë
383
 * ¥Ç¥Õ¥©¥ë¥È¤Î ID ¤Ïñ°ì¤Î¥Ü¥¿¥ó¤Ë¤è¤Ã¤Æ¤¤¤ë
384
 */
385
377
386
/** @@@
387
 * ½é´ü²½
388
 */
389
int Pad_Init();
378
int Pad_Init();
390
379
391
/** @@@
380
392
 * ¹¹¿·
393
 * @param flags PAD_PUMP_* ¤ÎÏÀÍýÏ¡£
394
 */
395
void Pad_Pump(Uint32 flags);
381
void Pad_Pump(Uint32 flags);
396
382
397
/**
383
398
 * @return Àµ¤Ê¤é²¡¤µ¤ì¤Æ¤¤¤ë¡£ 1 ¤Ê¤éº£²ó²¡¤µ¤ì¤¿¡£
399
 *         ÈóÀµ¤Ê¤éÎ¥¤µ¤ì¤Æ¤¤¤ë¡£ 0 ¤Ê¤éº£²óÎ¥¤µ¤ì¤¿¡£
400
 */
401
int Pad_GetButton(int id);
384
int Pad_GetButton(int id);
402
385
403
/**
386
404
 * Push ¤È Pull ¤Ï½Ö´Ö
405
 */
406
int Pad_GetButtonPushed(int id);
387
int Pad_GetButtonPushed(int id);
407
int Pad_GetButtonPressed(int id);
388
int Pad_GetButtonPressed(int id);
408
int Pad_GetButtonPulled(int id);
389
int Pad_GetButtonPulled(int id);
409
int Pad_GetButtonReleased(int id);
390
int Pad_GetButtonReleased(int id);
410
391
411
/** @@@
392
412
 * Àµ¤Î ID ¤Ï¥æ¡¼¥¶¤¬ÅÐÏ¿¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë
413
 * ¤è¤Ã¤Æ°ú¿ô id ¤ÏÀµ¤Ç¤¢¤ëɬÍפ¬¤¢¤ë
414
 * °ú¿ô addid ¤ÏÉé¤Ç¤¢¤ëɬÍפ¬¤¢¤Ã¤Æ¤âÎɤ¤¤È»×¤¦
415
 * °ì¤Ä¤Î¥æ¡¼¥¶¥Ü¥¿¥ó¤Ë 8 ¸Ä°Ê¾å¥Ü¥¿¥ó¤ÏÅÐÏ¿¤Ç¤­¤Þ¤»¤ó
416
 * ¤¢¤È¥æ¡¼¥¶¥Ü¥¿¥ó¤Ï 80 ¸Ä¤Þ¤Ç
417
 */
418
int Pad_AddButton(int id, int addid);
393
int Pad_AddButton(int id, int addid);
419
394
420
int Pad_GetAxis(int id);
395
int Pad_GetAxis(int id);
421
396
422
void Pad_AddAxis(int id, int upid, int rightid, int downid, int leftid);
397
void Pad_AddAxis(int id, int upid, int rightid, int downid, int leftid);
423
398
424
/** @@@
399
425
 * ¤¤¤¯¤Ä¤«¤Î¥Ø¥ë¥Ñ
426
 * ÁȤ߹ç¤ï¤»¤¬»È¤¨¤Ê¤¤¤«¤éÉÔÊØ
427
 */
428
void Pad_AddAxisKeyboardArrow(int id);
400
void Pad_AddAxisKeyboardArrow(int id);
429
void Pad_AddAxisKeyboardRogue(int id);
401
void Pad_AddAxisKeyboardRogue(int id);
430
void Pad_AddAxisKeyboardWASD(int id);
402
void Pad_AddAxisKeyboardWASD(int id);
431
void Pad_AddAxisJoystick1(int id);
403
void Pad_AddAxisJoystick1(int id);
432
void Pad_AddAxisJoystick2(int id);
404
void Pad_AddAxisJoystick2(int id);
433
405
434
/** @@@
406
435
 * ÀßÄêÆɤ߽Ф·
436
 */
437
int Pad_LoadDefault(char* file);
407
int Pad_LoadDefault(char* file);
438
/** @@@
408
439
 * ¥Þ¥Ã¥Ô¥ó¥°¤Ä¤­ÀßÄêÆɤ߽Ф·
440
 */
441
int Pad_Load(char* file, char** bnames, char** anames);
409
int Pad_Load(char* file, char** bnames, char** anames);
442
410
443
int Pad_LoadRW(SDL_RWops* op, char** bnames, char** anames);
411
int Pad_LoadRW(SDL_RWops* op, char** bnames, char** anames);
444
412
445
/** @@@
413
446
 * ÀßÄê½ñ¤­½Ð¤·
447
 */
448
int Pad_SaveDefault(char* file);
414
int Pad_SaveDefault(char* file);
449
/** @@@
415
450
 * ¥Þ¥Ã¥Ô¥ó¥°¤Ä¤­ÀßÄê½ñ¤­½Ð¤·
451
 */
452
int Pad_Save(char* file, char** bnames, char** anames);
416
int Pad_Save(char* file, char** bnames, char** anames);
453
417
454
int Pad_SaveRW(SDL_RWops* op, char** bnames, char** anames);
418
int Pad_SaveRW(SDL_RWops* op, char** bnames, char** anames);
455
419
456
/** @@@
457
 * °Ê¾å¤ÎÀßÄê¤ò¤¤¤í¤ó¤Ê PAD ¥¢¥×¥ê¤Ç¶¦Ä̤˹Ԥ¦µ¡¹½¤¬Íߤ·¤¤
458
 * Î㤨¤Ð A ¥Ü¥¿¥ó¤Ï Z ¡¢ B ¥Ü¥¿¥ó¤Ï X ¤¬¹¥¤ß¤Ê¥æ¡¼¥¶¤Ï
459
 * ¾¤Î¥²¡¼¥à¤Ç¤â¤½¤ÎÇÛÃÖ¤ò»È¤¤¤¿¤¤¡£
460
 * .sdlpad ¤Î¥¯¥í¥¹¥×¥é¥Ã¥È¥Û¡¼¥à¤Ê°ÌÃÖÆÃÄê¤ò¼«Æ°¤Ç¤¹¤ëɬÍפ¬¤¢¤ë
461
 * ¸å NES ¤Ê¤ó¤«¤Ï±¦¤«¤é A, B ¤ÈÈó¾ï¼±¤ÊʤӤʤΤǤ¹¤±¤É¡¢
462
 * ¤½¤Î¤Ø¤ó¤ÏÌäÂê¤Ë¤Ê¤é¤Ê¤¤¤«¤Ê¡©
463
 */
464
420
465
/** @@@
466
 * ¥é¥Ã¥×¥ì¥¤¥ä
467
 */
468
Sint16 Pad_JoystickGetAxis(SDL_Joystick* joystick, int axis, Uint32 mode);
421
Sint16 Pad_JoystickGetAxis(SDL_Joystick* joystick, int axis, Uint32 mode);
469
Uint8 Pad_JoystickGetButton(SDL_Joystick* joystick, int button);
422
Uint8 Pad_JoystickGetButton(SDL_Joystick* joystick, int button);
470
423
471
/** @@@
424
472
 * ¥¸¥ç¥¤¥¹¥Æ¥£¥Ã¥¯¤Î threshold ¤òÀßÄꤹ¤ë
473
 * @param val Àµ¿ô¤ÇÆþÎÏ
474
 */
475
void Pad_SetJoystickThresholdUp(int val);
425
void Pad_SetJoystickThresholdUp(int val);
476
void Pad_SetJoystickThresholdRight(int val);
426
void Pad_SetJoystickThresholdRight(int val);
477
void Pad_SetJoystickThresholdDown(int val);
427
void Pad_SetJoystickThresholdDown(int val);
478
void Pad_SetJoystickThresholdLeft(int val);
428
void Pad_SetJoystickThresholdLeft(int val);
479
429
480
/** @@@
430
481
 * ¥¤¥Ù¥ó¥È¤«¤é PadKey ¤ò¼è¤ê½Ð¤¹
482
 * Event handling ¥â¥Ç¥ë¤Ç°·¤¦¾ì¹ç¤Ï¸³°ÊØÍø¤À¤Ã¤¿¤Î¤Ç
483
 */
484
PadKey Pad_PadKeyFromEvent(SDL_Event* ev);
431
PadKey Pad_PadKeyFromEvent(SDL_Event* ev);
485
432
486
char* Pad_GetError() {
433
char* Pad_GetError() {
(-)psyno/src/sdl/SDL_sound.d (+651 lines)
Line 0 Link Here
1
/** \file SDL_sound.h */
2
3
/*
4
 * SDL_sound -- An abstract sound format decoding API.
5
 * Copyright (C) 2001  Ryan C. Gordon.
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * This library is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with this library; if not, write to the Free Software
19
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
 */
21
22
/**
23
 * \mainpage SDL_sound
24
 *
25
 * The latest version of SDL_sound can be found at:
26
 *     http://icculus.org/SDL_sound/
27
 *
28
 * The basic gist of SDL_sound is that you use an SDL_RWops to get sound data
29
 *  into this library, and SDL_sound will take that data, in one of several
30
 *  popular formats, and decode it into raw waveform data in the format of
31
 *  your choice. This gives you a nice abstraction for getting sound into your
32
 *  game or application; just feed it to SDL_sound, and it will handle
33
 *  decoding and converting, so you can just pass it to your SDL audio
34
 *  callback (or whatever). Since it gets data from an SDL_RWops, you can get
35
 *  the initial sound data from any number of sources: file, memory buffer,
36
 *  network connection, etc.
37
 *
38
 * As the name implies, this library depends on SDL: Simple Directmedia Layer,
39
 *  which is a powerful, free, and cross-platform multimedia library. It can
40
 *  be found at http://www.libsdl.org/
41
 *
42
 * Support is in place or planned for the following sound formats:
43
 *   - .WAV  (Microsoft WAVfile RIFF data, internal.)
44
 *   - .VOC  (Creative Labs' Voice format, internal.)
45
 *   - .MP3  (MPEG-1 Layer 3 support, via the SMPEG and mpglib libraries.)
46
 *   - .MID  (MIDI music converted to Waveform data, internal.)
47
 *   - .MOD  (MOD files, via MikMod and ModPlug.)
48
 *   - .OGG  (Ogg files, via Ogg Vorbis libraries.)
49
 *   - .SHN  (Shorten files, internal.)
50
 *   - .RAW  (Raw sound data in any format, internal.)
51
 *   - .AU   (Sun's Audio format, internal.)
52
 *   - .AIFF (Audio Interchange format, internal.)
53
 *   - .FLAC (Lossless audio compression, via libFLAC.)
54
 *
55
 *   (...and more to come...)
56
 *
57
 * Please see the file COPYING in the source's root directory.
58
 *
59
 * \author Ryan C. Gordon (icculus@clutteredmind.org)
60
 * \author many others, please see CREDITS in the source's root directory.
61
 */
62
63
// convert to D by shinichiro.h
64
65
import SDL;
66
67
extern (C) {
68
	const int SOUND_VER_MAJOR = 1;
69
	const int SOUND_VER_MINOR = 0;
70
	const int SOUND_VER_PATCH = 0;
71
72
73
/**
74
 * \enum Sound_SampleFlags
75
 * \brief Flags that are used in a Sound_Sample to show various states.
76
 *
77
 * To use:
78
 * \code
79
 * if (sample->flags & SOUND_SAMPLEFLAG_ERROR) { dosomething(); }
80
 * \endcode
81
 *
82
 * \sa Sound_SampleNew
83
 * \sa Sound_SampleNewFromFile
84
 * \sa Sound_SampleDecode
85
 * \sa Sound_SampleDecodeAll
86
 * \sa Sound_SampleSeek
87
 */
88
	enum {
89
		SOUND_SAMPLEFLAG_NONE    = 0,       /**< No special attributes. */
90
91
		/* these are set at sample creation time... */
92
		SOUND_SAMPLEFLAG_CANSEEK = 1,       /**< Sample can seek to arbitrary points. */
93
94
		/* these are set during decoding... */
95
		SOUND_SAMPLEFLAG_EOF     = 1 << 29, /**< End of input stream. */
96
		SOUND_SAMPLEFLAG_ERROR   = 1 << 30, /**< Unrecoverable error. */
97
		SOUND_SAMPLEFLAG_EAGAIN  = 1 << 31  /**< Function would block, or temp error. */
98
	}
99
	alias int Sound_SampleFlags;
100
101
102
/**
103
 * \struct Sound_AudioInfo
104
 * \brief Information about an existing sample's format.
105
 *
106
 * These are the basics of a decoded sample's data structure: data format
107
 *  (see AUDIO_U8 and friends in SDL_audio.h), number of channels, and sample
108
 *  rate. If you need more explanation than that, you should stop developing
109
 *  sound code right now.
110
 *
111
 * \sa Sound_SampleNew
112
 * \sa Sound_SampleNewFromFile
113
 */
114
	struct Sound_AudioInfo
115
	{
116
		Uint16 format;  /**< Equivalent of SDL_AudioSpec.format. */
117
		Uint8 channels; /**< Number of sound channels. 1 == mono, 2 == stereo. */
118
		Uint32 rate;    /**< Sample rate; frequency of sample points per second. */
119
	}
120
121
122
/**
123
 * \struct Sound_DecoderInfo
124
 * \brief Information about available soudn decoders.
125
 *
126
 * Each decoder sets up one of these structs, which can be retrieved via
127
 *  the Sound_AvailableDecoders() function. EVERY FIELD IN THIS IS READ-ONLY.
128
 *
129
 * The extensions field is a NULL-terminated list of ASCIZ strings. You
130
 *  should read it like this:
131
 *
132
 * \code
133
 * const char **ext;
134
 * for (ext = info->extensions; *ext != NULL; ext++) {
135
 *     printf("   File extension \"%s\"\n", *ext);
136
 * }
137
 * \endcode
138
 *
139
 * \sa Sound_AvailableDecoders
140
 */
141
	struct Sound_DecoderInfo
142
	{
143
		const char **extensions; /**< File extensions, list ends with NULL. */
144
		const char *description; /**< Human readable description of decoder. */
145
		const char *author;      /**< "Name Of Author \<email@emailhost.dom\>" */
146
		const char *url;         /**< URL specific to this decoder. */
147
	}
148
149
150
151
/**
152
 * \struct Sound_Sample
153
 * \brief Represents sound data in the process of being decoded.
154
 *
155
 * The Sound_Sample structure is the heart of SDL_sound. This holds
156
 *  information about a source of sound data as it is being decoded.
157
 *  EVERY FIELD IN THIS IS READ-ONLY. Please use the API functions to
158
 *  change them.
159
 */
160
	struct Sound_Sample
161
	{
162
		void *opaque;  /**< Internal use only. Don't touch. */
163
		const Sound_DecoderInfo *decoder;  /**< Decoder used for this sample. */
164
		Sound_AudioInfo desired;  /**< Desired audio format for conversion. */
165
		Sound_AudioInfo actual;  /**< Actual audio format of sample. */
166
		void *buffer;  /**< Decoded sound data lands in here. */
167
		Uint32 buffer_size;  /**< Current size of (buffer), in bytes (Uint8). */
168
		Sound_SampleFlags flags;  /**< Flags relating to this sample. */
169
	}
170
171
172
/**
173
 * \struct Sound_Version
174
 * \brief Information the version of SDL_sound in use.
175
 *
176
 * Represents the library's version as three levels: major revision
177
 *  (increments with massive changes, additions, and enhancements),
178
 *  minor revision (increments with backwards-compatible changes to the
179
 *  major revision), and patchlevel (increments with fixes to the minor
180
 *  revision).
181
 *
182
 * \sa SOUND_VERSION
183
 * \sa Sound_GetLinkedVersion
184
 */
185
	struct Sound_Version
186
	{
187
		int major; /**< major revision */
188
		int minor; /**< minor revision */
189
		int patch; /**< patchlevel */
190
	}
191
192
193
/* functions and macros... */
194
195
/**
196
 * \def SOUND_VERSION(x)
197
 * \brief Macro to determine SDL_sound version program was compiled against.
198
 *
199
 * This macro fills in a Sound_Version structure with the version of the
200
 *  library you compiled against. This is determined by what header the
201
 *  compiler uses. Note that if you dynamically linked the library, you might
202
 *  have a slightly newer or older version at runtime. That version can be
203
 *  determined with Sound_GetLinkedVersion(), which, unlike SOUND_VERSION,
204
 *  is not a macro.
205
 *
206
 * \param x A pointer to a Sound_Version struct to initialize.
207
 *
208
 * \sa Sound_Version
209
 * \sa Sound_GetLinkedVersion
210
 */
211
	void SOUND_VERSION(Sound_Version x) {
212
		x.major = SOUND_VER_MAJOR;
213
		x.minor = SOUND_VER_MINOR;
214
		x.patch = SOUND_VER_PATCH;
215
	}
216
217
218
/**
219
 * \fn void Sound_GetLinkedVersion(Sound_Version *ver)
220
 * \brief Get the version of SDL_sound that is linked against your program.
221
 *
222
 * If you are using a shared library (DLL) version of SDL_sound, then it is
223
 *  possible that it will be different than the version you compiled against.
224
 *
225
 * This is a real function; the macro SOUND_VERSION tells you what version
226
 *  of SDL_sound you compiled against:
227
 *
228
 * \code
229
 * Sound_Version compiled;
230
 * Sound_Version linked;
231
 *
232
 * SOUND_VERSION(&compiled);
233
 * Sound_GetLinkedVersion(&linked);
234
 * printf("We compiled against SDL_sound version %d.%d.%d ...\n",
235
 *           compiled.major, compiled.minor, compiled.patch);
236
 * printf("But we linked against SDL_sound version %d.%d.%d.\n",
237
 *           linked.major, linked.minor, linked.patch);
238
 * \endcode
239
 *
240
 * This function may be called safely at any time, even before Sound_Init().
241
 *
242
 * \param ver Sound_Version structure to fill with shared library's version.
243
 *
244
 * \sa Sound_Version
245
 * \sa SOUND_VERSION
246
 */
247
	void Sound_GetLinkedVersion(Sound_Version *ver);
248
249
250
/**
251
 * \fn Sound_Init()
252
 * \brief Initialize SDL_sound.
253
 *
254
 * This must be called before any other SDL_sound function (except perhaps
255
 *  Sound_GetLinkedVersion()). You should call SDL_Init() before calling this.
256
 *  Sound_Init() will attempt to call SDL_Init(SDL_INIT_AUDIO), just in case.
257
 *  This is a safe behaviour, but it may not configure SDL to your liking by
258
 *  itself.
259
 *
260
 * \return nonzero on success, zero on error. Specifics of the
261
 *         error can be gleaned from Sound_GetError().
262
 *
263
 * \sa Sound_Quit
264
 */
265
	int Sound_Init();
266
267
268
/**
269
 * \fn Sound_Quit()
270
 * \brief Shutdown SDL_sound.
271
 *
272
 * This closes any SDL_RWops that were being used as sound sources, and frees
273
 *  any resources in use by SDL_sound.
274
 *
275
 * All Sound_Sample pointers you had prior to this call are INVALIDATED.
276
 *
277
 * Once successfully deinitialized, Sound_Init() can be called again to
278
 *  restart the subsystem. All default API states are restored at this
279
 *  point.
280
 *
281
 * You should call this BEFORE SDL_Quit(). This will NOT call SDL_Quit()
282
 *  for you!
283
 *
284
 *  \return nonzero on success, zero on error. Specifics of the error
285
 *          can be gleaned from Sound_GetError(). If failure, state of
286
 *          SDL_sound is undefined, and probably badly screwed up.
287
 *
288
 * \sa Sound_Init
289
 */
290
	int Sound_Quit();
291
292
293
/**
294
 * \fn const Sound_DecoderInfo **Sound_AvailableDecoders()
295
 * \brief Get a list of sound formats supported by this version of SDL_sound.
296
 *
297
 * This is for informational purposes only. Note that the extension listed is
298
 *  merely convention: if we list "MP3", you can open an MPEG-1 Layer 3 audio
299
 *  file with an extension of "XYZ", if you like. The file extensions are
300
 *  informational, and only required as a hint to choosing the correct
301
 *  decoder, since the sound data may not be coming from a file at all, thanks
302
 *  to the abstraction that an SDL_RWops provides.
303
 *
304
 * The returned value is an array of pointers to Sound_DecoderInfo structures,
305
 *  with a NULL entry to signify the end of the list:
306
 *
307
 * \code
308
 * Sound_DecoderInfo **i;
309
 *
310
 * for (i = Sound_AvailableDecoders(); *i != NULL; i++)
311
 * {
312
 *     printf("Supported sound format: [%s], which is [%s].\n",
313
 *              i->extension, i->description);
314
 *     // ...and other fields...
315
 * }
316
 * \endcode
317
 *
318
 * The return values are pointers to static internal memory, and should
319
 *  be considered READ ONLY, and never freed.
320
 *
321
 * \return READ ONLY Null-terminated array of READ ONLY structures.
322
 *
323
 * \sa Sound_DecoderInfo
324
 */
325
	Sound_DecoderInfo ** Sound_AvailableDecoders();
326
327
328
/**
329
 * \fn const char *Sound_GetError()
330
 * \brief Get the last SDL_sound error message as a null-terminated string.
331
 *
332
 * This will be NULL if there's been no error since the last call to this
333
 *  function. The pointer returned by this call points to an internal buffer,
334
 *  and should not be deallocated. Each thread has a unique error state
335
 *  associated with it, but each time a new error message is set, it will
336
 *  overwrite the previous one associated with that thread. It is safe to call
337
 *  this function at anytime, even before Sound_Init().
338
 *
339
 * \return READ ONLY string of last error message.
340
 *
341
 * \sa Sound_ClearError
342
 */
343
	char * Sound_GetError();
344
345
346
/**
347
 * \fn void Sound_ClearError()
348
 * \brief Clear the current error message.
349
 *
350
 * The next call to Sound_GetError() after Sound_ClearError() will return NULL.
351
 *
352
 * \sa Sound_GetError
353
 */
354
	void Sound_ClearError();
355
356
357
/**
358
 * \fn Sound_Sample *Sound_NewSample(SDL_RWops *rw, const char *ext, Sound_AudioInfo *desired, Uint32 bufferSize)
359
 * \brief Start decoding a new sound sample.
360
 *
361
 * The data is read via an SDL_RWops structure (see SDL_rwops.h in the SDL
362
 *  include directory), so it may be coming from memory, disk, network stream,
363
 *  etc. The (ext) parameter is merely a hint to determining the correct
364
 *  decoder; if you specify, for example, "mp3" for an extension, and one of
365
 *  the decoders lists that as a handled extension, then that decoder is given
366
 *  first shot at trying to claim the data for decoding. If none of the
367
 *  extensions match (or the extension is NULL), then every decoder examines
368
 *  the data to determine if it can handle it, until one accepts it. In such a
369
 *  case your SDL_RWops will need to be capable of rewinding to the start of
370
 *  the stream.
371
 *
372
 * If no decoders can handle the data, a NULL value is returned, and a human
373
 *  readable error message can be fetched from Sound_GetError().
374
 *
375
 * Optionally, a desired audio format can be specified. If the incoming data
376
 *  is in a different format, SDL_sound will convert it to the desired format
377
 *  on the fly. Note that this can be an expensive operation, so it may be
378
 *  wise to convert data before you need to play it back, if possible, or
379
 *  make sure your data is initially in the format that you need it in.
380
 *  If you don't want to convert the data, you can specify NULL for a desired
381
 *  format. The incoming format of the data, preconversion, can be found
382
 *  in the Sound_Sample structure.
383
 *
384
 * Note that the raw sound data "decoder" needs you to specify both the
385
 *  extension "RAW" and a "desired" format, or it will refuse to handle
386
 *  the data. This is to prevent it from catching all formats unsupported
387
 *  by the other decoders.
388
 *
389
 * Finally, specify an initial buffer size; this is the number of bytes that
390
 *  will be allocated to store each read from the sound buffer. The more you
391
 *  can safely allocate, the more decoding can be done in one block, but the
392
 *  more resources you have to use up, and the longer each decoding call will
393
 *  take. Note that different data formats require more or less space to
394
 *  store. This buffer can be resized via Sound_SetBufferSize() ...
395
 *
396
 * The buffer size specified must be a multiple of the size of a single
397
 *  sample point. So, if you want 16-bit, stereo samples, then your sample
398
 *  point size is (2 channels * 16 bits), or 32 bits per sample, which is four
399
 *  bytes. In such a case, you could specify 128 or 132 bytes for a buffer,
400
 *  but not 129, 130, or 131 (although in reality, you'll want to specify a
401
 *  MUCH larger buffer).
402
 *
403
 * When you are done with this Sound_Sample pointer, you can dispose of it
404
 *  via Sound_FreeSample().
405
 *
406
 * You do not have to keep a reference to (rw) around. If this function
407
 *  suceeds, it stores (rw) internally (and disposes of it during the call
408
 *  to Sound_FreeSample()). If this function fails, it will dispose of the
409
 *  SDL_RWops for you.
410
 *
411
 *    \param rw SDL_RWops with sound data.
412
 *    \param ext File extension normally associated with a data format.
413
 *               Can usually be NULL.
414
 *    \param desired Format to convert sound data into. Can usually be NULL,
415
 *                   if you don't need conversion.
416
 *    \param bufferSize Size, in bytes, to allocate for the decoding buffer.
417
 *   \return Sound_Sample pointer, which is used as a handle to several other
418
 *           SDL_sound APIs. NULL on error. If error, use
419
 *           Sound_GetError() to see what went wrong.
420
 *
421
 * \sa Sound_NewSampleFromFile
422
 * \sa Sound_SetBufferSize
423
 * \sa Sound_Decode
424
 * \sa Sound_DecodeAll
425
 * \sa Sound_Seek
426
 * \sa Sound_Rewind
427
 * \sa Sound_FreeSample
428
 */
429
	Sound_Sample * Sound_NewSample(SDL_RWops *rw,
430
								   char *ext,
431
								   Sound_AudioInfo *desired,
432
								   Uint32 bufferSize);
433
434
/**
435
 * \fn Sound_Sample *Sound_NewSampleFromFile(const char *filename, Sound_AudioInfo *desired, Uint32 bufferSize)
436
 * \brief Start decoding a new sound sample from a file on disk.
437
 *
438
 * This is identical to Sound_NewSample(), but it creates an SDL_RWops for you
439
 *  from the file located in (filename). Note that (filename) is specified in
440
 *  platform-dependent notation. ("C:\\music\\mysong.mp3" on windows, and
441
 *  "/home/icculus/music/mysong.mp3" or whatever on Unix, etc.)
442
 * Sound_NewSample()'s "ext" parameter is gleaned from the contents of
443
 *  (filename).
444
 *
445
 *    \param filename file containing sound data.
446
 *    \param desired Format to convert sound data into. Can usually be NULL,
447
 *                   if you don't need conversion.
448
 *    \param bufferSize size, in bytes, of initial read buffer.
449
 *   \return Sound_Sample pointer, which is used as a handle to several other
450
 *           SDL_sound APIs. NULL on error. If error, use
451
 *           Sound_GetError() to see what went wrong.
452
 *
453
 * \sa Sound_NewSample
454
 * \sa Sound_SetBufferSize
455
 * \sa Sound_Decode
456
 * \sa Sound_DecodeAll
457
 * \sa Sound_Seek
458
 * \sa Sound_Rewind
459
 * \sa Sound_FreeSample
460
 */
461
	Sound_Sample * Sound_NewSampleFromFile(char *fname,
462
										   Sound_AudioInfo *desired,
463
										   Uint32 bufferSize);
464
465
/**
466
 * \fn void Sound_FreeSample(Sound_Sample *sample)
467
 * \brief Dispose of a Sound_Sample.
468
 *
469
 * This will also close/dispose of the SDL_RWops that was used at creation
470
 *  time, so there's no need to keep a reference to that around.
471
 * The Sound_Sample pointer is invalid after this call, and will almost
472
 *  certainly result in a crash if you attempt to keep using it.
473
 *
474
 *    \param sample The Sound_Sample to delete.
475
 *
476
 * \sa Sound_NewSample
477
 * \sa Sound_NewSampleFromFile
478
 */
479
	void Sound_FreeSample(Sound_Sample *sample);
480
481
482
/**
483
 * \fn int Sound_SetBufferSize(Sound_Sample *sample, Uint32 new_size)
484
 * \brief Change the current buffer size for a sample.
485
 *
486
 * If the buffer size could be changed, then the sample->buffer and
487
 *  sample->buffer_size fields will reflect that. If they could not be
488
 *  changed, then your original sample state is preserved. If the buffer is
489
 *  shrinking, the data at the end of buffer is truncated. If the buffer is
490
 *  growing, the contents of the new space at the end is undefined until you
491
 *  decode more into it or initialize it yourself.
492
 *
493
 * The buffer size specified must be a multiple of the size of a single
494
 *  sample point. So, if you want 16-bit, stereo samples, then your sample
495
 *  point size is (2 channels * 16 bits), or 32 bits per sample, which is four
496
 *  bytes. In such a case, you could specify 128 or 132 bytes for a buffer,
497
 *  but not 129, 130, or 131 (although in reality, you'll want to specify a
498
 *  MUCH larger buffer).
499
 *
500
 *    \param sample The Sound_Sample whose buffer to modify.
501
 *    \param new_size The desired size, in bytes, of the new buffer.
502
 *   \return non-zero if buffer size changed, zero on failure.
503
 *
504
 * \sa Sound_Decode
505
 * \sa Sound_DecodeAll
506
 */
507
	int Sound_SetBufferSize(Sound_Sample *sample,
508
							   Uint32 new_size);
509
510
511
/**
512
 * \fn Uint32 Sound_Decode(Sound_Sample *sample)
513
 * \brief Decode more of the sound data in a Sound_Sample.
514
 *
515
 * It will decode at most sample->buffer_size bytes into sample->buffer in the
516
 *  desired format, and return the number of decoded bytes.
517
 * If sample->buffer_size bytes could not be decoded, then please refer to
518
 *  sample->flags to determine if this was an end-of-stream or error condition.
519
 *
520
 *    \param sample Do more decoding to this Sound_Sample.
521
 *   \return number of bytes decoded into sample->buffer. If it is less than
522
 *           sample->buffer_size, then you should check sample->flags to see
523
 *           what the current state of the sample is (EOF, error, read again).
524
 *
525
 * \sa Sound_DecodeAll
526
 * \sa Sound_SetBufferSize
527
 * \sa Sound_Seek
528
 * \sa Sound_Rewind
529
 */
530
	Uint32 Sound_Decode(Sound_Sample *sample);
531
532
533
/**
534
 * \fn Uint32 Sound_DecodeAll(Sound_Sample *sample)
535
 * \brief Decode the remainder of the sound data in a Sound_Sample.
536
 *
537
 * This will dynamically allocate memory for the ENTIRE remaining sample.
538
 *  sample->buffer_size and sample->buffer will be updated to reflect the
539
 *  new buffer. Please refer to sample->flags to determine if the decoding
540
 *  finished due to an End-of-stream or error condition.
541
 *
542
 * Be aware that sound data can take a large amount of memory, and that
543
 *  this function may block for quite awhile while processing. Also note
544
 *  that a streaming source (for example, from a SDL_RWops that is getting
545
 *  fed from an Internet radio feed that doesn't end) may fill all available
546
 *  memory before giving up...be sure to use this on finite sound sources
547
 *  only!
548
 *
549
 * When decoding the sample in its entirety, the work is done one buffer at a
550
 *  time. That is, sound is decoded in sample->buffer_size blocks, and
551
 *  appended to a continually-growing buffer until the decoding completes.
552
 *  That means that this function will need enough RAM to hold approximately
553
 *  sample->buffer_size bytes plus the complete decoded sample at most. The
554
 *  larger your buffer size, the less overhead this function needs, but beware
555
 *  the possibility of paging to disk. Best to make this user-configurable if
556
 *  the sample isn't specific and small.
557
 *
558
 *    \param sample Do all decoding for this Sound_Sample.
559
 *   \return number of bytes decoded into sample->buffer. You should check
560
 *           sample->flags to see what the current state of the sample is
561
 *           (EOF, error, read again).
562
 *
563
 * \sa Sound_Decode
564
 * \sa Sound_SetBufferSize
565
 */
566
	Uint32 Sound_DecodeAll(Sound_Sample *sample);
567
568
569
/**
570
 * \fn int Sound_Rewind(Sound_Sample *sample)
571
 * \brief Rewind a sample to the start.
572
 *
573
 * Restart a sample at the start of its waveform data, as if newly
574
 *  created with Sound_NewSample(). If successful, the next call to
575
 *  Sound_Decode[All]() will give audio data from the earliest point
576
 *  in the stream.
577
 *
578
 * Beware that this function will fail if the SDL_RWops that feeds the
579
 *  decoder can not be rewound via it's seek method, but this can
580
 *  theoretically be avoided by wrapping it in some sort of buffering
581
 *  SDL_RWops.
582
 *
583
 * This function should ONLY fail if the RWops is not seekable, or
584
 *  SDL_sound is not initialized. Both can be controlled by the application,
585
 *  and thus, it is up to the developer's paranoia to dictate whether this
586
 *  function's return value need be checked at all.
587
 *
588
 * If this function fails, the state of the sample is undefined, but it
589
 *  is still safe to call Sound_FreeSample() to dispose of it.
590
 *
591
 * On success, ERROR, EOF, and EAGAIN are cleared from sample->flags. The
592
 *  ERROR flag is set on error.
593
 *
594
 *    \param sample The Sound_Sample to rewind.
595
 *   \return nonzero on success, zero on error. Specifics of the
596
 *           error can be gleaned from Sound_GetError().
597
 *
598
 * \sa Sound_Seek
599
 */
600
	int Sound_Rewind(Sound_Sample *sample);
601
602
603
/**
604
 * \fn int Sound_Seek(Sound_Sample *sample, Uint32 ms)
605
 * \brief Seek to a different point in a sample.
606
 *
607
 * Reposition a sample's stream. If successful, the next call to
608
 *  Sound_Decode[All]() will give audio data from the offset you
609
 *  specified.
610
 *
611
 * The offset is specified in milliseconds from the start of the
612
 *  sample.
613
 *
614
 * Beware that this function can fail for several reasons. If the
615
 *  SDL_RWops that feeds the decoder can not seek, this call will almost
616
 *  certainly fail, but this can theoretically be avoided by wrapping it
617
 *  in some sort of buffering SDL_RWops. Some decoders can never seek,
618
 *  others can only seek with certain files. The decoders will set a flag
619
 *  in the sample at creation time to help you determine this.
620
 *
621
 * You should check sample->flags & SOUND_SAMPLEFLAG_CANSEEK
622
 *  before attempting. Sound_Seek() reports failure immediately if this
623
 *  flag isn't set. This function can still fail for other reasons if the
624
 *  flag is set.
625
 *
626
 * This function can be emulated in the application with Sound_Rewind()
627
 *  and predecoding a specific amount of the sample, but this can be
628
 *  extremely inefficient. Sound_Seek() accelerates the seek on a
629
 *  with decoder-specific code.
630
 *
631
 * If this function fails, the sample should continue to function as if
632
 *  this call was never made. If there was an unrecoverable error,
633
 *  sample->flags & SOUND_SAMPLEFLAG_ERROR will be set, which you regular
634
 *  decoding loop can pick up.
635
 *
636
 * On success, ERROR, EOF, and EAGAIN are cleared from sample->flags.
637
 *
638
 *    \param sample The Sound_Sample to seek.
639
 *    \param ms The new position, in milliseconds from start of sample.
640
 *   \return nonzero on success, zero on error. Specifics of the
641
 *           error can be gleaned from Sound_GetError().
642
 *
643
 * \sa Sound_Rewind
644
 */
645
	int Sound_Seek(Sound_Sample *sample, Uint32 ms);
646
647
}
648
649
650
/* end of SDL_sound.h ... */
651
(-)psyno/src/shot.d (-1 lines)
Lines 3-9 Link Here
3
private import SDL;
3
private import SDL;
4
4
5
private import charactor;
5
private import charactor;
6
private import log;
7
private import mymath;
6
private import mymath;
8
private import mygl;
7
private import mygl;
9
private import objspecs;
8
private import objspecs;
(-)psyno/src/sino.d (-30 / +29 lines)
Lines 12-18 Link Here
12
private import openglu;
12
private import openglu;
13
13
14
private import rc;
14
private import rc;
15
private import log;
16
private import fpstimer;
15
private import fpstimer;
17
private import scene;
16
private import scene;
18
private import scene_select;
17
private import scene_select;
Lines 33-56 Link Here
33
public:
32
public:
34
    this(char args[][]) {
33
    this(char args[][]) {
35
        obj_ = this;
34
        obj_ = this;
36
        Log.info("init");
35
 //      Log.info("init");
37
        initResource(args);
36
        initResource(args);
38
        initMisc();
37
        initMisc();
39
        initSDL();
38
        initSDL();
40
        initGL();
39
        initGL();
41
        Log.info("init done");
40
 //       Log.info("init done");
42
    }
41
    }
43
42
44
    ~this() {
43
    ~this() {
45
        Log.info("quit");
44
//        Log.info("quit");
46
        delete sound_;
45
        delete sound_;
47
        SDLNet_Quit();
46
        SDLNet_Quit();
48
        SDL_Quit();
47
        SDL_Quit();
49
        Log.info("quit done");
48
  //      Log.info("quit done");
50
    }
49
    }
51
50
52
    void initResource(char args[][]) {
51
    void initResource(char args[][]) {
53
        Log.info("init resource");
52
  //      Log.info("init resource");
54
53
55
        rc_ = new Rc();
54
        rc_ = new Rc();
56
        rc().addResourceFile();
55
        rc().addResourceFile();
Lines 58-64 Link Here
58
    }
57
    }
59
58
60
    void initMisc() {
59
    void initMisc() {
61
        Log.info("init misc");
60
  //      Log.info("init misc");
62
61
63
        rand_seed(getUTCtime(), 0);
62
        rand_seed(getUTCtime(), 0);
64
63
Lines 79-98 Link Here
79
    }
78
    }
80
79
81
    void initSDL() {
80
    void initSDL() {
82
        Log.info("init SDL");
81
//        Log.info("init SDL");
83
82
84
        int ret = SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE);
83
        int ret = SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE);
85
        if (ret != 0) Log.errorSDL("cannot init SDL");
84
//        if (ret != 0) Log.errorSDL("cannot init SDL");
86
85
87
        ret = SDL_InitSubSystem(SDL_INIT_JOYSTICK);
86
        ret = SDL_InitSubSystem(SDL_INIT_JOYSTICK);
88
        if (ret != 0) {
87
        if (ret != 0) {
89
            Log.warnSDL("cannot init joystick");
88
//            Log.warnSDL("cannot init joystick");
90
        }
89
        }
91
90
92
        useAudio_ = true;
91
        useAudio_ = true;
93
        ret = SDL_InitSubSystem(SDL_INIT_AUDIO);
92
        ret = SDL_InitSubSystem(SDL_INIT_AUDIO);
94
        if (ret != 0) {
93
        if (ret != 0) {
95
            Log.warnSDL("cannot init audio");
94
//            Log.warnSDL("cannot init audio");
96
            useAudio_ = false;
95
            useAudio_ = false;
97
        }
96
        }
98
97
Lines 105-118 Link Here
105
104
106
        if (bpp == -1) {
105
        if (bpp == -1) {
107
            bpp = info.vfmt.BitsPerPixel;
106
            bpp = info.vfmt.BitsPerPixel;
108
            Log.info("using the \"best\" bpp: " ~ tostr(bpp));
107
//            Log.info("using the \"best\" bpp: " ~ tostr(bpp));
109
        }
108
        }
110
        else if (bpp == 0) {
109
        else if (bpp == 0) {
111
            bpp = info.vfmt.BitsPerPixel;
110
            bpp = info.vfmt.BitsPerPixel;
112
            Log.info("using current bpp");
111
//            Log.info("using current bpp");
113
        }
112
        }
114
        else {
113
        else {
115
            Log.info("using user set bpp: " ~ tostr(bpp));
114
//            Log.info("using user set bpp: " ~ tostr(bpp));
116
        }
115
        }
117
116
118
        SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );  
117
        SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );  
Lines 130-148 Link Here
130
            flags |= SDL_FULLSCREEN;
129
            flags |= SDL_FULLSCREEN;
131
        }
130
        }
132
131
133
        Log.info("set video mode " ~
132
//        Log.info("set video mode " ~
134
                 "size = " ~ tostr(screenWidth_) ~
133
//                 "size = " ~ tostr(screenWidth_) ~
135
                 "x" ~ tostr(screenHeight_) ~
134
//                 "x" ~ tostr(screenHeight_) ~
136
                 ", bpp = " ~ tostr(bpp) ~
135
//                 ", bpp = " ~ tostr(bpp) ~
137
                 ", flags = " ~ tostr(flags));
136
//                 ", flags = " ~ tostr(flags));
138
        if (SDL_SetVideoMode(screenWidth_, screenHeight_,
137
        if (SDL_SetVideoMode(screenWidth_, screenHeight_,
139
                             bpp, flags) == null)
138
                             bpp, flags) == null)
140
        {
139
        {
141
            Log.errorSDL("cannot create screen");
140
//            Log.errorSDL("cannot create screen");
142
        }
141
        }
143
142
144
        info = SDL_GetVideoInfo();
143
        info = SDL_GetVideoInfo();
145
        Log.info("set bpp: " ~ tostr(cast(int)info.vfmt.BitsPerPixel));
144
//        Log.info("set bpp: " ~ tostr(cast(int)info.vfmt.BitsPerPixel));
146
145
147
        Pad_Init();
146
        Pad_Init();
148
        Pad_LoadDefault("save/key.conf");
147
        Pad_LoadDefault("save/key.conf");
Lines 180-200 Link Here
180
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
179
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
181
180
182
        if (glGetError()) {
181
        if (glGetError()) {
183
            Log.error(tostr(gluErrorString(glGetError())));
182
//            Log.error(tostr(gluErrorString(glGetError())));
184
        }
183
        }
185
184
186
        initLetter();
185
        initLetter();
187
    }
186
    }
188
187
189
    void run() {
188
    void run() {
190
        Log.info("run");
189
//        Log.info("run");
191
190
192
        Scene.init();
191
        Scene.init();
193
        scene_ = new SceneSelect();
192
        scene_ = new SceneSelect();
194
193
195
        timer_.start();
194
        timer_.start();
196
195
197
        while (scene_ !== null) {
196
        while (scene_ !is null) {
198
            Pad_Pump(PAD_PUMP_EVERYTHING);
197
            Pad_Pump(PAD_PUMP_EVERYTHING);
199
198
200
            scene_.run();
199
            scene_.run();
Lines 225-231 Link Here
225
            endCheck();
224
            endCheck();
226
        }
225
        }
227
226
228
        Log.info("run done");
227
//        Log.info("run done");
229
    }
228
    }
230
229
231
    void drawSystemInfo() {
230
    void drawSystemInfo() {
Lines 258-264 Link Here
258
257
259
    void endCheck() {
258
    void endCheck() {
260
        if (Pad_GetButtonPressed(PAD_END_BUTTON)) {
259
        if (Pad_GetButtonPressed(PAD_END_BUTTON)) {
261
            Log.info("quit event catched");
260
//            Log.info("quit event catched");
262
            quit();
261
            quit();
263
        }
262
        }
264
        if (Pad_GetButtonPushed(PAD_C_BUTTON)) {
263
        if (Pad_GetButtonPushed(PAD_C_BUTTON)) {
Lines 274-285 Link Here
274
    }
273
    }
275
274
276
    void quit() {
275
    void quit() {
277
        Log.info("FPS: " ~ std.string.toString(timer_.getTrueFps()));
276
//        Log.info("FPS: " ~ std.string.toString(timer_.getTrueFps()));
278
        scene_ = null;
277
        scene_ = null;
279
    }
278
    }
280
279
281
    void end() {
280
    void end() {
282
        Log.info("FPS: " ~ std.string.toString(timer_.getTrueFps()));
281
//        Log.info("FPS: " ~ std.string.toString(timer_.getTrueFps()));
283
        scene_ = scene_.getNext();
282
        scene_ = scene_.getNext();
284
    }
283
    }
285
284
Lines 317-327 Link Here
317
316
318
317
319
extern(C) int doit(char args[][]) {
318
extern(C) int doit(char args[][]) {
320
    Log.init();
319
//    Log.init();
321
    Sino c = new Sino(args);
320
    Sino c = new Sino(args);
322
    c.run();
321
    c.run();
323
    delete c;
322
    delete c;
324
    Log.quit();
323
//    Log.quit();
325
324
326
    return 0;
325
    return 0;
327
}
326
}
(-)psyno/src/sound.d (-6 / +5 lines)
Lines 1-10 Link Here
1
private import std.string;
1
private import std.string;
2
2
private import SDL;
3
private import SDL_mixer;
3
private import SDL_mixer;
4
4
5
private import sino;
5
private import sino;
6
private import rc;
6
private import rc;
7
private import log;
8
private import sound_phase;
7
private import sound_phase;
9
8
10
enum Se {
9
enum Se {
Lines 63-69 Link Here
63
62
64
        if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
63
        if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
65
            noSound_ = 1;
64
            noSound_ = 1;
66
            Log.warnSDL("Unable to initialize SDL_AUDIO");
65
//            Log.warnSDL("Unable to initialize SDL_AUDIO");
67
            return;
66
            return;
68
        }
67
        }
69
68
Lines 74-80 Link Here
74
        if (Mix_OpenAudio(audio_rate, audio_format,
73
        if (Mix_OpenAudio(audio_rate, audio_format,
75
                          audio_channels, audio_buffers) < 0) {
74
                          audio_channels, audio_buffers) < 0) {
76
            noSound_ = 1;
75
            noSound_ = 1;
77
            Log.warnSDL("Couldn't open audio");
76
//            Log.warnSDL("Couldn't open audio");
78
            return;
77
            return;
79
        }
78
        }
80
        Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
79
        Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
Lines 130-136 Link Here
130
        music_ = Mix_LoadMUS(toStringz(fileName));
129
        music_ = Mix_LoadMUS(toStringz(fileName));
131
        if (!music_) {
130
        if (!music_) {
132
//            noSound_ = true;
131
//            noSound_ = true;
133
            Log.warnSDL("Couldn't load: " ~ fileName);
132
//            Log.warnSDL("Couldn't load: " ~ fileName);
134
        }
133
        }
135
    }
134
    }
136
  
135
  
Lines 183-189 Link Here
183
            char[] seFileName = chunksDir ~ Sino.rc.get(seName);
182
            char[] seFileName = chunksDir ~ Sino.rc.get(seName);
184
            chunk_[i] = Mix_LoadWAV(toStringz(seFileName));
183
            chunk_[i] = Mix_LoadWAV(toStringz(seFileName));
185
            if (!chunk_[i]) {
184
            if (!chunk_[i]) {
186
                Log.warnSDL("Couldn't load: " ~ seFileName);
185
//                Log.warnSDL("Couldn't load: " ~ seFileName);
187
            }
186
            }
188
        }
187
        }
189
    }
188
    }
(-)psyno/src/texture.d (-3 / +2 lines)
Lines 2-10 Link Here
2
private import opengl;
2
private import opengl;
3
private import std.c.stdio;
3
private import std.c.stdio;
4
private import std.c.stdlib;
4
private import std.c.stdlib;
5
private import std.string;
5
private import std.c.string;
6
6
7
private import log;
8
7
9
// rough texture manager
8
// rough texture manager
10
enum TextureID {
9
enum TextureID {
Lines 28-34 Link Here
28
    }
27
    }
29
28
30
    this(char[] filename) {
29
    this(char[] filename) {
31
        Log.info(filename ~ ": loading texture");
30
//        Log.info(filename ~ ": loading texture");
32
31
33
        SDL_Surface* surf = SDL_LoadBMP(filename);
32
        SDL_Surface* surf = SDL_LoadBMP(filename);
34
        SDL_SetColorKey(surf, SDL_SRCCOLORKEY, 0);
33
        SDL_SetColorKey(surf, SDL_SRCCOLORKEY, 0);
(-)psyno/src/thunder.d (-1 / +1 lines)
Lines 33-39 Link Here
33
        x_ += sx_;
33
        x_ += sx_;
34
        y_ += sy_;
34
        y_ += sy_;
35
35
36
        if (moveFunc_ === null) {
36
        if (moveFunc_ is null) {
37
            float rs() { return rnd(15)-7; }
37
            float rs() { return rnd(15)-7; }
38
            sx_ += rs;
38
            sx_ += rs;
39
            sy_ += rs;
39
            sy_ += rs;
(-)psyno/src/winmain.d (-7 / +7 lines)
Lines 17-29 Link Here
17
{
17
{
18
    int result;
18
    int result;
19
19
20
    gc_init();          // ¥¬¥Ù¡¼¥¸¥³¥ì¥¯¥¿½é´ü²½
20
    gc_init();          //
21
    _minit();           // ¥â¥¸¥å¡¼¥ë¥³¥ó¥¹¥È¥é¥¯¥¿¥Æ¡¼¥Ö¥ë½é´ü²½
21
    _minit();           // 
22
    
22
    
23
    try
23
    try
24
    {
24
    {
25
        _moduleCtor();      // ¥â¥¸¥å¡¼¥ë¥³¥ó¥¹¥È¥é¥¯¥¿¸Æ¤Ó½Ð¤·
25
        _moduleCtor();      //
26
        _moduleUnitTests(); // ñÂΥƥ¹¥È¼Â¹Ô (¥ª¥×¥·¥ç¥ó)
26
        _moduleUnitTests(); // 
27
27
28
        char[] arg = std.string.toString(lpCmdLine);
28
        char[] arg = std.string.toString(lpCmdLine);
29
        char exe[4096];
29
        char exe[4096];
Lines 32-48 Link Here
32
        args ~= std.string.toString(exe);
32
        args ~= std.string.toString(exe);
33
        args ~= split(arg);
33
        args ~= split(arg);
34
34
35
        result = doit(args);    // ¤³¤³¤Ë¥æ¡¼¥¶¡¼¥³¡¼¥É¤òÃÖ¤­¤Þ¤¹
35
        result = doit(args);    //
36
    }
36
    }
37
    
37
    
38
    catch (Object o)        // ¥­¥ã¥Ã¥Á¤µ¤ì¤Æ¤¤¤Ê¤¤Îã³°¤òÁ´¤Æ¥­¥ã¥Ã¥Á
38
    catch (Object o)        // 
39
    {
39
    {
40
        MessageBoxA(null, cast(char *)o.toString(), "Error",
40
        MessageBoxA(null, cast(char *)o.toString(), "Error",
41
                    MB_OK | MB_ICONEXCLAMATION);
41
                    MB_OK | MB_ICONEXCLAMATION);
42
        result = 0;     // failed
42
        result = 0;     // failed
43
    }
43
    }
44
   
44
   
45
    gc_term();          // ¥Õ¥¡¥¤¥Ê¥é¥¤¥¶¤Î¼Â¹Ô¡¢¥¬¥Ù¡¼¥¸¥³¥ì¥¯¥¿½ªÎ»
45
    gc_term();          //
46
    return result;
46
    return result;
47
}
47
}
48
}
48
}

Return to bug 193788