annotate music2/music.h @ 58:0aaa5bb3dde5

Moved all opcodes from scn2k_text.cc to scn2k_textimpl.cc
author Thibaut GIRKA <thib@sitedethib.com>
date Fri, 18 Dec 2009 14:25:56 +0100
parents ddbcbd000206
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
1 /*
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
2 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
3 * All rights reserved.
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
4 *
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
5 * Redistribution and use in source and binary forms, with or without
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
6 * modification, are permitted provided that the following conditions
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
7 * are met:
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
8 * 1. Redistributions of source code must retain the above copyright
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
9 * notice, this list of conditions and the following disclaimer.
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
10 * 2. Redistributions in binary form must reproduce the above copyright
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
11 * notice, this list of conditions and the following disclaimer in the
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
12 * documentation and/or other materials provided with the distribution.
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
13 * 3. The name of the author may not be used to endorse or promote products
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
14 * derived from this software without specific prior written permission.
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
15 *
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
26 */
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
27
5ae5533b3a9a * Added some license headers
thib
parents: 26
diff changeset
28
0
223b71206888 Initial import
thib
parents:
diff changeset
29 #ifndef __MUSIC__ /* __MUSIC__ */
223b71206888 Initial import
thib
parents:
diff changeset
30 #define __MUSIC__
223b71206888 Initial import
thib
parents:
diff changeset
31
223b71206888 Initial import
thib
parents:
diff changeset
32 #ifdef HAVE_CONFIG_H
223b71206888 Initial import
thib
parents:
diff changeset
33 # include "config.h"
223b71206888 Initial import
thib
parents:
diff changeset
34 #endif
223b71206888 Initial import
thib
parents:
diff changeset
35
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
36 #include <sys/types.h>
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
37 #include <sys/time.h>
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
38 #include <SDL_mixer.h>
0
223b71206888 Initial import
thib
parents:
diff changeset
39
223b71206888 Initial import
thib
parents:
diff changeset
40 #define MIX_PCM_BGM 4
223b71206888 Initial import
thib
parents:
diff changeset
41 #define MIX_PCM_EFFEC 5
223b71206888 Initial import
thib
parents:
diff changeset
42 #define MIX_PCM_KOE 6
223b71206888 Initial import
thib
parents:
diff changeset
43 #define MIX_PCM_SIZE 8
223b71206888 Initial import
thib
parents:
diff changeset
44
223b71206888 Initial import
thib
parents:
diff changeset
45 #define DEFAULT_AUDIOBUF 4096
223b71206888 Initial import
thib
parents:
diff changeset
46
2
422f3cb3614b Enabled voice playing with "%04d/%04d%05d.ogg" format. Don't use a cache for this
thib
parents: 0
diff changeset
47 enum KoeType { koe_unknown, koe_nwk, koe_ovk, koe_ogg};
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
48
0
223b71206888 Initial import
thib
parents:
diff changeset
49 typedef struct {
223b71206888 Initial import
thib
parents:
diff changeset
50 FILE* stream;
223b71206888 Initial import
thib
parents:
diff changeset
51 int length;
223b71206888 Initial import
thib
parents:
diff changeset
52 int offset;
223b71206888 Initial import
thib
parents:
diff changeset
53 int rate;
223b71206888 Initial import
thib
parents:
diff changeset
54 KoeType type;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
55 } AvgKoeInfo;
0
223b71206888 Initial import
thib
parents:
diff changeset
56
223b71206888 Initial import
thib
parents:
diff changeset
57 /* koedec.cc */
223b71206888 Initial import
thib
parents:
diff changeset
58 extern AvgKoeInfo OpenKoeFile(const char* path);
223b71206888 Initial import
thib
parents:
diff changeset
59 extern char* decode_koe(AvgKoeInfo info, int* len);
223b71206888 Initial import
thib
parents:
diff changeset
60 extern char* decode_koe_nwa(AvgKoeInfo info, int* len);
223b71206888 Initial import
thib
parents:
diff changeset
61 extern const char* MakeWavHeader(int rate, int ch, int bps, int size);
223b71206888 Initial import
thib
parents:
diff changeset
62 extern AvgKoeInfo FindKoe(int file_number, int index);
223b71206888 Initial import
thib
parents:
diff changeset
63
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
64 #include <unistd.h>
0
223b71206888 Initial import
thib
parents:
diff changeset
65
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
66 class MuSys {
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
67 public:
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
68 static MuSys* GetInstance(void);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
69 static void Quit(void);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
70 void PlayCDROM(char* name, int play_count);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
71 void StopCDROM(int time);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
72 void PlaySE(const char* name, int loop_flag=0, int channel=0);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
73 void PlaySE(int number);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
74 void StopSE(int time = 0);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
75 bool IsStopSE(void);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
76 void PlayKoe(const char* fname);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
77 void StopKoe(int time);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
78 void PlayMovie(const char* fname, int x1, int y1, int x2, int y2, int loop_count);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
79 void StopMovie(void);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
80 bool IsStopMovie(void);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
81 void InitMusic(void);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
82 void FinalizeMusic(void);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
83
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
84 private:
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
85 MuSys();
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
86
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
87 public:
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
88 int volmod[4]; // BGM, KOE, PCM, Se
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
89 int pcm_enable;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
90 Mix_Chunk *play_chunk[MIX_PCM_SIZE];
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
91
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
92 private:
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
93 class AyuSysConfig *config;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
94 char cdrom_track[128]; char effec_track[128];
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
95 int movie_id;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
96 int music_enable;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
97 static MuSys *_singleton;
0
223b71206888 Initial import
thib
parents:
diff changeset
98 };
223b71206888 Initial import
thib
parents:
diff changeset
99
223b71206888 Initial import
thib
parents:
diff changeset
100 #endif /* __MUSIC__ */