0
|
1 /*
|
|
2 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno
|
|
3 * All rights reserved.
|
|
4 *
|
|
5 * Redistribution and use in source and binary forms, with or without
|
|
6 * modification, are permitted provided that the following conditions
|
|
7 * are met:
|
|
8 * 1. Redistributions of source code must retain the above copyright
|
|
9 * notice, this list of conditions and the following disclaimer.
|
|
10 * 2. Redistributions in binary form must reproduce the above copyright
|
|
11 * notice, this list of conditions and the following disclaimer in the
|
|
12 * documentation and/or other materials provided with the distribution.
|
|
13 * 3. The name of the author may not be used to endorse or promote products
|
|
14 * derived from this software without specific prior written permission.
|
|
15 *
|
|
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26 */
|
|
27
|
|
28 // #define ROOTPATH "/mnt/KEY/CLANNAD"
|
|
29 // #define ROOTPATH "/home/uenok/pb"
|
|
30 // #define FONT "msgothic.ttc"
|
|
31 /* kochi-mincho-subst.ttf あるいは -*-*-*-r-*--24-*-*-*-*-*-jisx0208.1983-* など */
|
|
32 /* TrueType Font は /usr/X11R6/lib/X11/fonts/TrueType/ などに存在する必要がある */
|
|
33
|
|
34 #include<stdio.h>
|
|
35 #include<stdlib.h>
|
|
36 #include<unistd.h>
|
|
37 #include<locale.h>
|
|
38
|
|
39 #include<SDL.h>
|
|
40 #include<vector>
|
|
41 #include<getopt.h>
|
|
42
|
|
43 #include"system/file.h"
|
|
44 #include"system/system_config.h"
|
|
45 #include"window/widget.h"
|
|
46 #include"window/system.h"
|
|
47
|
|
48 #include"music2/music.h"
|
|
49
|
|
50 #include"scn2k/scn2k.h"
|
|
51 #include"scn2k/scn2k_impl.h"
|
|
52
|
|
53 const char key_lb_orig[] = {0x4b, 0x45, 0x59, 0x5c, 0x83, 0x8a, 0x83, 0x67, 0x83, 0x8b, 0x83, 0x6f, 0x83, 0x58, 0x83, 0x5e, 0x81, 0x5b, 0x83, 0x59, 0x81, 0x49, 0};
|
|
54
|
|
55 const char key_lb_new[] = "KEY\\LittleBusters";
|
|
56
|
|
57
|
|
58 extern "C" int main(int argc, char* argv[]); /* SDL.h で定義されるので必要ないはずなんだけど…… */
|
|
59
|
|
60 int main(int argc, char *argv[]) {
|
|
61 AyuSysConfig config;
|
|
62 int opt = 0, end = 0, screenmode = 0;
|
|
63 char rootPath[1024] = "/mnt/KEY/CLANNAD";
|
|
64 char font[1024] = "msgothic.ttc";
|
|
65 Uint32 videoOptions = SDL_HWSURFACE;
|
|
66
|
|
67 while(1) {
|
|
68 opt = getopt(argc, argv, "fdt:c:r:vh?");
|
|
69 if(opt == -1) {break;}
|
|
70
|
|
71 switch(opt) {
|
|
72 case 'f':
|
|
73 videoOptions |= SDL_FULLSCREEN;
|
|
74 break;
|
|
75 case 'd':
|
|
76 videoOptions |= SDL_DOUBLEBUF;
|
|
77 break;
|
|
78 case 't':
|
|
79 strncpy(font, optarg, 1023);
|
|
80 break;
|
|
81 case 'r':
|
|
82 strncpy(rootPath, optarg, 1023);
|
|
83 break;
|
|
84 case 'v':
|
|
85 // FIXME: "VERSION" undeclared?
|
|
86 // printf("xclannad %s\n", VERSION);
|
|
87 printf("xclannad 0.05e\n");
|
|
88 end = 1;
|
|
89 break;
|
|
90 case 'h':
|
|
91 case '?':
|
|
92 printf("\nUsage: %s [OPTIONS]\n\n", argv[0]);
|
|
93 printf(" -f : full screen mode\n");
|
|
94 printf(" -d : double buffer mode\n");
|
|
95 printf(" -t : set font (typeface)\n");
|
|
96 printf(" -r : set root path (default /mnt/KEY/CLANNAD)\n");
|
|
97 printf(" -v : show version and exit\n");
|
|
98 printf(" -h -? : show help and exit\n\n");
|
|
99 end = 1;
|
|
100 break;
|
|
101 }
|
|
102 }
|
|
103 if(end == 1) return 0;
|
|
104
|
|
105 printf("Settings:\n");
|
|
106 printf(" Locale : %s\n", setlocale(LC_ALL, ""));
|
|
107 printf(" Root Path : %s\n", rootPath);
|
|
108 printf(" Font : %s\n", font);
|
|
109 printf("\n");
|
|
110
|
|
111 file_searcher.InitRoot(rootPath);
|
|
112 config.LoadInitFile();
|
|
113 const char* regname = config.GetParaStr("#REGNAME");
|
|
114 if (strcmp(regname, key_lb_orig) == 0) { // "リトルバスターズ! -> LittleBustersに#REGNAMEを変更
|
|
115 config.SetParaStr("#REGNAME", key_lb_new);
|
|
116 }
|
30
|
117 file_searcher.GuessXorKey((char*)regname);
|
0
|
118 SetFont(font);
|
|
119
|
|
120 MuSys mu(config);
|
|
121 mu.InitMusic();
|
|
122
|
|
123 if(SDL_Init(SDL_INIT_VIDEO)) {
|
|
124 printf("Unable to init SDL: %s\n", SDL_GetError());
|
|
125 return 1;
|
|
126 }
|
|
127 atexit(SDL_Quit);
|
|
128
|
|
129 config.GetParam("#SCREENSIZE_MOD", 1, &screenmode);
|
|
130 if (screenmode == 1) {
|
|
131 SDL_SetVideoMode(800, 600, 0, videoOptions);
|
|
132 } else {
|
|
133 SDL_SetVideoMode(640, 480, 0, videoOptions);
|
|
134 }
|
|
135 // SDL_SetVideoMode(640, 480, 0, videoOptions);
|
|
136 // SDL_SetVideoMode(800, 600, 0, SDL_HWSURFACE /*| SDL_FULLSCREEN */);
|
|
137 {
|
|
138 System::Main main_sys;
|
|
139 PicContainer* main_panel = main_sys.root.create_node(Rect(0, 0, main_sys.root.width, main_sys.root.height), 0);
|
|
140 main_panel->show();
|
|
141 try {
|
|
142 Scn2k scn(main_sys.event, *main_panel, mu, config);
|
|
143 main_sys.Mainloop();
|
|
144 } catch(...) {
|
|
145 fprintf(stderr,"System faulted; exit now.\n");
|
|
146 }
|
|
147 delete main_panel;
|
|
148 }
|
|
149
|
|
150 mu.FinalizeMusic();
|
|
151
|
|
152 SDL_Quit();
|
|
153 }
|
|
154
|