| 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 = AyuSysConfig::GetInstance(); |
|---|
| 62 | int opt = 0, end = 0, screenmode = 0; |
|---|
| 63 | char rootPath[1024] = "/mnt/KEY/CLANNAD"; |
|---|
| 64 | char font[1024] = "msgothic.ttc"; |
|---|
| 65 | char* xor_key = NULL; |
|---|
| 66 | Uint32 videoOptions = SDL_HWSURFACE; |
|---|
| 67 | |
|---|
| 68 | while(1) { |
|---|
| 69 | opt = getopt(argc, argv, "fdt:c:r:k:vh?"); |
|---|
| 70 | if(opt == -1) {break;} |
|---|
| 71 | |
|---|
| 72 | switch(opt) { |
|---|
| 73 | case 'f': |
|---|
| 74 | videoOptions |= SDL_FULLSCREEN; |
|---|
| 75 | break; |
|---|
| 76 | case 'd': |
|---|
| 77 | videoOptions |= SDL_DOUBLEBUF; |
|---|
| 78 | break; |
|---|
| 79 | case 't': |
|---|
| 80 | strncpy(font, optarg, 1023); |
|---|
| 81 | break; |
|---|
| 82 | case 'r': |
|---|
| 83 | strncpy(rootPath, optarg, 1023); |
|---|
| 84 | break; |
|---|
| 85 | case 'v': |
|---|
| 86 | printf("otakunoraifu %s\n", VERSION); |
|---|
| 87 | end = 1; |
|---|
| 88 | break; |
|---|
| 89 | case 'k': |
|---|
| 90 | if (xor_key == NULL) |
|---|
| 91 | xor_key = new char[33]; |
|---|
| 92 | strncpy(xor_key, optarg, 32); |
|---|
| 93 | break; |
|---|
| 94 | case 'h': |
|---|
| 95 | case '?': |
|---|
| 96 | printf("\nUsage: %s [OPTIONS]\n\n", argv[0]); |
|---|
| 97 | printf(" -f : full screen mode\n"); |
|---|
| 98 | printf(" -d : double buffer mode\n"); |
|---|
| 99 | printf(" -t : set font (typeface)\n"); |
|---|
| 100 | printf(" -r : set root path (default /mnt/KEY/CLANNAD)\n"); |
|---|
| 101 | printf(" -k : set xor key, if needed\n"); |
|---|
| 102 | printf(" -v : show version and exit\n"); |
|---|
| 103 | printf(" -h -? : show help and exit\n\n"); |
|---|
| 104 | end = 1; |
|---|
| 105 | break; |
|---|
| 106 | } |
|---|
| 107 | } |
|---|
| 108 | if(end == 1) return 0; |
|---|
| 109 | |
|---|
| 110 | printf("Settings:\n"); |
|---|
| 111 | printf(" Locale : %s\n", setlocale(LC_ALL, "")); |
|---|
| 112 | printf(" Root Path : %s\n", rootPath); |
|---|
| 113 | printf(" Font : %s\n", font); |
|---|
| 114 | printf("\n"); |
|---|
| 115 | |
|---|
| 116 | FileSearcher::GetInstance()->InitRoot(rootPath); |
|---|
| 117 | config->LoadInitFile(); |
|---|
| 118 | const char* regname = config->GetParaStr("#REGNAME"); |
|---|
| 119 | if (strcmp(regname, key_lb_orig) == 0) { // "ãªãã«ãã¹ã¿ãŒãºïŒ -> LittleBustersã«#REGNAMEãå€æŽ |
|---|
| 120 | config->SetParaStr("#REGNAME", key_lb_new); |
|---|
| 121 | } |
|---|
| 122 | if (xor_key == NULL) |
|---|
| 123 | KeyHolder::GetInstance()->GuessKey((char*)regname); |
|---|
| 124 | else { |
|---|
| 125 | KeyHolder::GetInstance()->SetKey2(xor_key); |
|---|
| 126 | delete[] xor_key; |
|---|
| 127 | } |
|---|
| 128 | SetFont(font); |
|---|
| 129 | |
|---|
| 130 | MuSys::GetInstance()->InitMusic(); |
|---|
| 131 | |
|---|
| 132 | if(SDL_Init(SDL_INIT_VIDEO)) { |
|---|
| 133 | printf("Unable to init SDL: %s\n", SDL_GetError()); |
|---|
| 134 | return 1; |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | config->GetParam("#SCREENSIZE_MOD", 1, &screenmode); |
|---|
| 138 | if (screenmode == 1) { |
|---|
| 139 | SDL_SetVideoMode(800, 600, 0, videoOptions); |
|---|
| 140 | } else { |
|---|
| 141 | SDL_SetVideoMode(640, 480, 0, videoOptions); |
|---|
| 142 | } |
|---|
| 143 | // SDL_SetVideoMode(640, 480, 0, videoOptions); |
|---|
| 144 | // SDL_SetVideoMode(800, 600, 0, SDL_HWSURFACE /*| SDL_FULLSCREEN */); |
|---|
| 145 | |
|---|
| 146 | System::Main main_sys; |
|---|
| 147 | PicContainer* main_panel = main_sys.root.create_node(Rect(0, 0, main_sys.root.width, main_sys.root.height), 0); |
|---|
| 148 | main_panel->show(); |
|---|
| 149 | try { |
|---|
| 150 | Scn2k scn(main_sys.event, *main_panel); |
|---|
| 151 | main_sys.Mainloop(); |
|---|
| 152 | } catch(...) { |
|---|
| 153 | fprintf(stderr,"System faulted; exit now.\n"); |
|---|
| 154 | } |
|---|
| 155 | delete main_panel; |
|---|
| 156 | |
|---|
| 157 | MuSys::Quit(); |
|---|
| 158 | KeyHolder::Quit(); |
|---|
| 159 | AyuSysConfig::Quit(); |
|---|
| 160 | FileSearcher::Quit(); |
|---|
| 161 | |
|---|
| 162 | SDL_Quit(); |
|---|
| 163 | } |
|---|
| 164 | |
|---|