Mercurial > otakunoraifu
annotate scn2k/scn2k.h @ 34:b76a8da75ec3
* Check for SDL_mixer and SDL_gfx
author | thib |
---|---|
date | Sun, 08 Mar 2009 18:06:52 +0000 |
parents | f1fbe5b37a1e |
children | 15a18fbe6f21 |
rev | line source |
---|---|
33 | 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 | |
0 | 28 #ifndef __SCN2k_H__ |
29 #define __SCN2k_H__ | |
30 | |
31 #include<vector> | |
32 #include<string> | |
33 #include<map> | |
34 #include<set> | |
35 | |
36 /* | |
37 namespace Widget { | |
38 class Text; | |
39 class Button; | |
40 class TextButton; | |
41 class Label; | |
42 class Dialog; | |
43 class AnmTime; | |
44 } | |
45 */ | |
46 class WidText; | |
47 class WidButton; | |
48 class WidTextButton; | |
49 class WidLabel; | |
50 class WidDialog; | |
51 class WidAnmTime; | |
52 namespace Event { | |
53 class Container; | |
54 } | |
55 class PicBase; | |
56 class PicContainer; | |
57 class AyuSysConfig; | |
58 class Surface; | |
59 | |
60 void dprintf(const char* fmt, ...); | |
61 void eprintf(const char* fmt, ...); | |
62 | |
63 struct VarInfo { | |
64 #define TYPE_NONSYSVARMAX 5 | |
65 #define TYPE_VARMAX 9 | |
66 #define TYPE_VARLOCSTR 10 | |
67 #define TYPE_VARSYSSTR 12 | |
68 #define TYPE_VARSTR 18 | |
69 #define TYPE_STR 58 | |
70 #define TYPE_VAL 68 | |
71 #define TYPE_SYS 0xc8 | |
72 #define TYPE_END 0x7f | |
73 | |
74 #define TYPE_SYS_SYS 0 | |
75 #define TYPE_SYS_SKIPMODE 1 | |
76 int type; | |
77 int number; | |
78 int value; | |
79 VarInfo() { type = TYPE_VAL; value = 0;} | |
80 VarInfo(int n) { type = TYPE_VAL; value = n;} | |
81 VarInfo(const VarInfo& i) { type = i.type; number = i.number; value = i.value;} | |
82 }; | |
83 class Flags { | |
84 /* flag: | |
85 ** type 0-5 : ローカル整数、各2000個 | |
86 ** type 6, 25 : グローバル整数、2000個 | |
87 ** type 10,11: ローカル整数??、各2000個 | |
88 ** type 12 : グローバル文字列、2000個 (今は無視しても良いが) | |
89 ** type 18 : ローカル文字列、2000個 | |
90 ** type 25: システム変数(マウス座標など?) 1000 個? | |
91 ** type 26-32, 51 : 1-bit access to 0-6, 25 | |
92 ** type 52-58, 77 : 2-bit access to 0-6, 25 | |
93 ** type 78-84, 103 : 4-bit access to 0-6, 25 | |
94 ** type 104-110, 129 : 8-bit access to 0-6, 25 | |
95 */ | |
96 typedef unsigned int uint; | |
97 int sys; | |
98 int var[TYPE_VARMAX+1][2000]; | |
99 std::string str[2000]; | |
100 std::string sys_str[2000]; | |
101 std::string loc_str[3]; | |
102 public: | |
103 Flags(void); | |
104 int operator () () const; | |
105 int operator () (VarInfo info) const; | |
106 void Str(int type, unsigned int number, char* buf, int sz) const; | |
107 std::string Str(int type, unsigned int number) const; | |
108 std::set<int> cgm_data; | |
109 | |
110 bool IsInt(int type) const; | |
111 int MaxIndex(int type) const; | |
112 | |
113 void Set(VarInfo info, int value); | |
114 int Get(int type, int number) const; | |
115 void SetSys(int value); | |
116 void SetStr(VarInfo info, std::string val); | |
117 | |
118 bool Exec(class Cmd& cmd); | |
119 | |
120 void Save(std::string& str); | |
121 void Load(const char* str); | |
122 | |
123 void SaveSys(std::string& str); | |
124 void LoadSys(const char* str); | |
125 }; | |
126 | |
127 /* commands */ | |
128 #define STRHEAP_SIZE 10000 | |
129 enum Cmdtype { | |
130 CMD_NOP, CMD_FLAGS, CMD_JMP, CMD_TEXT, CMD_OTHER, CMD_SYSVAR, | |
131 CMD_TEXTEND, | |
132 CMD_SAVECMDGRP, CMD_SAVECMDGRP_START, CMD_SAVECMDGRP_ONCE, CMD_SAVECMD_ONCE, CMD_WAITFRAMEUPDATE,CMD_SAVEPOINT, CMD_ROLLBACKPOINT, | |
133 CMD_SAVEREQ, CMD_SAVE, | |
134 CMD_LOADREQ, CMD_LOAD, | |
135 CMD_MENUREQ, | |
136 CMD_BACKLOGREQ, CMD_BACKLOGREQ_FWD, | |
137 CMD_END}; | |
138 struct CmdSimplified { // Cmd 保存用 | |
139 int type, cmd1, cmd2, cmd3, cmd4, argc; | |
140 char* args; | |
141 void Save(std::string& save); | |
142 void Load(const char* save, char*& args_buffer); | |
143 void copy(const CmdSimplified& from, char*& args_buffer); | |
144 }; | |
145 class Cmd { | |
146 public: | |
147 Cmdtype cmd_type; | |
148 int cmd1, cmd2, cmd3, cmd4; | |
149 int argc; | |
150 int pos, scn; | |
151 const char* rawdata; | |
152 char cmdstr[1024]; | |
153 std::vector<VarInfo> args; | |
154 | |
155 private: | |
156 const Flags& flags; | |
157 bool errorflag; | |
158 int system_version; | |
159 | |
160 int GetArgs(const char*& d); | |
161 int GetArgsSpecial(int normal_args,const char*& d); | |
162 void GetSelection(const char*& d); | |
163 int GetSwitch(const char*& d); | |
164 int GetSimpleSwitch(const char*& d); | |
165 int GetExpression(const char*& d, struct VarInfo* info = 0); | |
166 int GetExpressionCond(const char*& d); | |
167 int GetLeftToken(const char*& d, struct VarInfo& info); | |
168 int GetString(const char*& d); | |
169 int CopyString(const char* d); | |
170 int StrVar(int type, int number); | |
171 static char strtype[256]; | |
172 static int StrType(const char* d) { return strtype[*(unsigned const char*)d];} | |
173 public: | |
174 const char* Str(const VarInfo& info) const { | |
175 if (info.type != TYPE_STR && info.type != TYPE_VARSTR && info.type != TYPE_VARLOCSTR && info.type != TYPE_VARSYSSTR) return ""; | |
176 int pt = info.value; | |
177 if (pt < 0 || pt >= STRHEAP_SIZE) return ""; | |
178 return strheap + pt; | |
179 } | |
180 int AddStr(char* s) { | |
181 // 1-0a-0064 はこういうものが必要らしい | |
182 int start = strend; | |
183 while (*s) strheap[strend++] = *s++; | |
184 strheap[strend++] = 0; | |
185 return start; | |
186 } | |
187 private: | |
188 char strheap[STRHEAP_SIZE]; | |
189 int strend; | |
190 void SetError(void) { errorflag = true;} | |
191 void ResetString(void) { | |
192 strend = 0; | |
193 } | |
194 public: | |
195 void GetCmd(Flags& f, const char*& d); | |
196 void SetSysvar(int n, int v); | |
197 void SetSysvar(int v) { SetSysvar(TYPE_SYS_SYS, v); } | |
198 void SetFlagvar(VarInfo info, int v); | |
199 void SetStrvar(VarInfo info, const std::string& s); | |
200 bool IsError() { return errorflag;} | |
201 void clear(void); | |
29
d229cce98f50
* no more (or, at least, less) duplicate code between scn2kdump and the rest
thib
parents:
0
diff
changeset
|
202 virtual const char * CmdDescr(int, int, int, int) { return "Not supported"; } |
0 | 203 Cmd(const Flags& f, int _sys_ver) : flags(f), system_version(_sys_ver) { cmd_type = CMD_NOP; argc = 0; errorflag = false; cmdstr[0] = 0; strend = 0; pos = -1;} |
204 void read(const CmdSimplified& cmd); | |
205 void write(CmdSimplified& cmd, char*& args_buffer) const; | |
206 }; | |
207 | |
208 enum SkipMode {SKIP_NO=0, SKIP_TEXT=1, SKIP_GRP_FAST=16, SKIP_GRP_NOEFFEC=32, SKIP_GRP_NODRAW=64, SKIPEND_TEXT=256, SKIPEND_KEY=512, | |
209 SKIP_IN_MENU=1024}; | |
210 | |
211 #include"font/text.h" | |
212 | |
213 struct BacklogItem { | |
214 enum {SaveSelect = -2}; | |
215 int scn, pos; | |
216 int koe; | |
217 std::string face; | |
218 struct TextStream text; | |
219 BacklogItem(void); | |
220 void Clear(void); | |
221 void AddTextPos(Cmd&); | |
222 void DeleteTextPos(); | |
223 void SetSavepos(int pos); | |
224 BacklogItem& operator =(const BacklogItem&); | |
225 }; | |
226 class Text { | |
227 class TextImpl* pimpl; | |
228 public: | |
229 std::vector<BacklogItem> backlog; | |
230 BacklogItem backlog_item; | |
231 Text(Event::Container& _event, PicContainer& _parent, AyuSysConfig& config); | |
232 ~Text(); | |
233 void InitWindow(void); | |
234 void Exec(Cmd& cmd); | |
235 bool Wait(unsigned int current_time, Cmd& cmd); | |
236 void SetSkipMode(SkipMode mode); | |
237 void hide(void); | |
238 void show(void); | |
239 void show(int num); | |
240 void Save(std::string& str, bool rollback_save); | |
241 void Load(const char* str); | |
242 void DrawBacklog(BacklogItem& item, Cmd& cmd); | |
243 }; | |
244 | |
245 #include"../window/rect.h" | |
246 | |
247 class Grp { | |
248 class GrpImpl* pimpl; | |
249 public: | |
250 Grp(Event::Container& _event, PicContainer& _parent, const Flags& f, std::set<int>& _cgm_data, class MuSys& mu, AyuSysConfig& config); | |
251 ~Grp(); | |
252 bool Wait(unsigned int current_time, Cmd& cmd); | |
253 void Exec(Cmd& cmd); | |
254 void SetSkipMode(SkipMode mode); | |
255 void InitSel(AyuSysConfig& config); | |
256 void Save(std::string& str); | |
257 void Load(const char* str); | |
258 void SaveSys(std::string& str); | |
259 void LoadSys(const char* str); | |
260 }; | |
261 | |
262 void dprintf(const char* fmt, ...); // debug 用 | |
263 void eprintf(const char* fmt, ...); // コマンド実行(XXXexec)追跡用 | |
264 #endif |