home *** CD-ROM | disk | FTP | other *** search
/ Fun CD 26 / OTACD26.ISO / etc / nawkk / yane0310 / ygs2k156.lzh / source / TScript.h < prev   
C/C++ Source or Header  |  2000-03-26  |  16KB  |  350 lines

  1. // TScript.h
  2. //
  3. //        programmed by yaneurao(M.Isozaki) '99/07/29-'99/12/1
  4. //
  5. //    スクリプト機能を使用して、ゲーム専用の関数を用意するサンプル
  6. //
  7.  
  8. #ifndef __TScript_h__
  9. #define __TScript_h__
  10.  
  11. #define WIN32_LEAN_AND_MEAN
  12. #include <windows.h>
  13.  
  14. // The debugger can't handle symbols more than 255 characters long.
  15. // STL often creates symbols longer than that.
  16. // When symbols are longer than 255 characters, the warning is disabled.
  17. #pragma warning(disable:4786)
  18.  
  19. #include <string>                //    STL
  20. #include <set>                    //    STL
  21. using namespace std;
  22. typedef set<BYTE*> CBytePtrArray;        // for new,delete
  23. typedef multiset<HINSTANCE> CLibraryArray;    // for LoadLibrary,FreeLibrary
  24.  
  25. //#include "yaneSDK.h"
  26.  
  27. #include "../yaneSDK/yaneSDK.h"
  28.  
  29. /////////////////////////////////////////////////////////////////
  30. //    このスクリプトは、そのゲーム専用に開発したもので、
  31. //    以下の識別子を定義しておけば、そのゲーム専用の関数が
  32. //    インストールされ、そのゲーム専用の定数が設定される。
  33.  
  34. //    #define TMANIA        //    『盗撮マニア act1.テレビ局』(works of yaneurao '99/05/01-'99/08/28)
  35.                         //    『夜這いマニア』            (works of yaneurao '99/10/22-'00/02/05)    
  36.     //    これが設定されていれば、TMania.hという外部ヘッダーの設定に従う。
  37.  
  38. //    各種定数はイニシャライザのなかで設定可能にしたので、すべてYGS共通で良い。
  39.     #define YGS            //    yaneGameScript 2000            (works of yaneurao '99/08/20-'99/10/23)
  40.                         //    『懇願』                    (works of yaneurao '99/09/15-'99/11/06)    
  41.  
  42. /////////////////////////////////////////////////////////////////
  43. //    ユーザー定数(各ゲームに応じて、設定する:p)
  44. /////////////////////////////////////////////////////////////////
  45.  
  46. #ifdef TMANIA
  47. #include "TMania.h"                        //    ゲームヘッダー
  48. #ifndef TUSE_XZ_FOR_BUTTON                //    added by らうーる
  49. #define    TUSE_XZ_FOR_BUTTON    (true)
  50. #endif
  51. #endif
  52.  
  53. #ifdef YGS
  54. #define StartUp                            //    スタートアップルーチンが必要
  55. #define DefaultTScript                    //    ディフォルトイニシャライザが必要
  56. #define TSoundMax             512        //    総Soundチャンネル数
  57. #define TPlaneMax             512        //    総プレーン数
  58. #define TGameTimeMax          16        //    総GameTime数
  59. #define TTextLayerMax          64        //    総テキストレイヤー数
  60. #define TStringMax              16        //    string配列の数
  61. #define TStringLength         512        //    string配列の大きさ
  62. #define TGameFlagMax        1024        //    gameflag配列の大きさ
  63. #define TGameFlagMax2        1024        //    gameflag2配列の大きさ
  64. #define TUSE_XZ_FOR_BUTTON    (false)        //    XとZキーをスペース、リターンに割り当てる
  65. #define TInstructionArea       0        //    命令エリアサイズ非制限
  66. #endif
  67.  
  68. /////////////////////////////////////////////////////////////////
  69.  
  70. class TScript : public CScriptCompiler {
  71. protected:
  72.  
  73. //    各種定数は、途中変更可能にした
  74. static    int        m_nSoundMax;                    //    総Soundチャンネル数
  75. static    int        m_nPlaneMax;                    //    総プレーン数
  76. static    int        m_nGameTimeMax;                    //    総GameTime数
  77. static    int        m_nTextLayerMax;                //    総テキストレイヤー数
  78. static    int        m_nStringMax;                    //    string配列の数
  79. static    int        m_nStringLength;                //    string配列の大きさ
  80. static    bool    m_bUSE_XZ_FOR_BUTTON;            //    XとZキーをスペース、リターンに割り当てる
  81. static    DWORD    m_dwInstructionArea;            //    命令エリアサイズ非制限
  82.  
  83. public:
  84.     TScript(void);
  85.     ~TScript();
  86. /////////////////////////////////////////////////////////////////
  87.     void Initialize(void);    //    各ゲームスクリプト専用初期化処理
  88.     void Terminate(void);    //    各ゲームスクリプト専用終了処理
  89. /////////////////////////////////////////////////////////////////
  90. //    以下は、スクリプトの関数としてユーザーに公開しているもの
  91. /////////////////////////////////////////////////////////////////
  92.  
  93. //    デバッグ用
  94. static TUserFunc(InnerLog);                    //    (long)
  95. static TUserFunc(InnerLogMes);                //    (LPSTR)
  96.  
  97. //    Wave関連
  98. static CSound* m_sound;
  99.  
  100. static TUserFunc(LoadWave);                    //    (LPSTR filename,long chno)
  101. static TUserFunc(PlayWave);                    //    (long chno)
  102. static TUserFunc(StopWave);                    //    (long chno)
  103. static TUserFunc(PauseWave);                //    (long chno)
  104. static TUserFunc(ReplayWave);                //    (long chno)
  105. static TUserFunc(IsPlayWave);                //    (long chno) : bool
  106. static TUserFunc(ReleaseWave);                //    (long chno)
  107. static TUserFunc(ReleaseWaveAll);            //    (void)
  108. static TUserFunc(SetLoopModeWave);            //    (long chno,bool)
  109. static TUserFunc(SetVolumeWave);            //    (long chno,long volume)
  110. static TUserFunc(SetVolumeWaveAll);            //    (long volume)
  111. static TUserFunc(SetWaveFormat);            //    (int type)
  112.  
  113. //    MIDI再生関連
  114. static TUserFunc(LoadMIDI);                    //    (LPSTR filename)
  115. static TUserFunc(PlayMIDI);                    //    (void)
  116. static TUserFunc(StopMIDI);                    //    (void)
  117. static TUserFunc(PauseMIDI);                //    (void)
  118. static TUserFunc(ReplayMIDI);                //    (void)
  119. static TUserFunc(ReleaseMIDI);                //    (void)
  120. static TUserFunc(IsPlayMIDI);                //    (void) : bool
  121. static TUserFunc(SetLoopModeMIDI);            //    (bool)
  122.  
  123. //    CD関連
  124. static TUserFunc(OpenCD);                    //    (void)
  125. static TUserFunc(CloseCD);                    //    (void)
  126. static TUserFunc(StopCD);                    //    (void)
  127. static TUserFunc(PauseCD);                    //    (void)
  128. static TUserFunc(ReplayCD);                    //    (void)
  129. static TUserFunc(PlayCDFromStart);            //    (void)        曲頭から
  130. static TUserFunc(PlayCD);                    //    (int)        曲番号
  131. static TUserFunc(PlayCDFromTo);                //    (int,int)    曲間セレクト
  132. static TUserFunc(PlayCDPos);                //    (int,int)    pos間
  133. static TUserFunc(IsPlayCD);                    //    (void) : bool
  134. static TUserFunc(SetLoopModeCD);            //    (bool)
  135. static TUserFunc(GetSongMaxCD);                //    () : int
  136. static TUserFunc(GetCurrentPosCD);            //    () : DWORD
  137. static TUserFunc(EjectCD);                    //    (bool bEject)
  138.  
  139. //    Bitmap関連
  140. static CPlane* m_plane;
  141.  
  142. static TUserFunc(GetBpp);                    //    (void) : int
  143.     // この2つはLoadBitmapだとWinAPIとかぶるので名前を変更している
  144. static TUserFunc(LoadBitmapFile);            //    (LPSTR,int,bool)
  145. static TUserFunc(LoadBitmapFileW);            //    (LPSTR,LPSTR,int,bool)
  146. static TUserFunc(SaveBitmapFile);            //    (LPSTR filename,int planeNo,int x,int y,int sx,int sy)
  147. static TUserFunc(ReleaseBitmap);            //    (int)
  148. static TUserFunc(GetPlaneSize);                //    (int,int&,int&)
  149. static TUserFunc(SetColorKeyRGB);            //    (int plane,int r,int g,int b)
  150. static TUserFunc(SetColorKeyPos);            //    (int plane,int x,int y)
  151. static TUserFunc(ClearSecondary);            //    (void)
  152. static TUserFunc(ClearSecondaryRect);        //    (int x1,int y1,int x2,int y2)
  153. static TUserFunc(SetFillColor);                //    (DWORD)
  154. static TUserFunc(SetFillColorRGB);            //    (int r,int g,int b)
  155.  
  156. static TUserFunc(Blt);                        //    (int plane,int x,int y)
  157. static TUserFunc(BltRect);                    //    (int plane,int x,int y,int sx,int sy,int hx,int hy)
  158. static TUserFunc(BltFast);                    //    (int plane,int x,int y)
  159. static TUserFunc(BltFastRect);                //    (int plane,int x,int y,int sx,int sy,int hx,int hy)
  160. static TUserFunc(BlendBlt);                    //    (int plane,int x,int y,int ar,int ag,int ab,int br,int bg,int bb)
  161. static TUserFunc(BlendBltRect);                //    (int plane,int x,int y,int sx,int sy,int hx,int hy,int ar,int ag,int ab,int br,int bg,int bb)
  162. static TUserFunc(ClipBlt);                    //    (int plane,int x,int y,int cx,int cy,int chx,int chy)
  163. static TUserFunc(ClipBltRect);                //    (int plane,int x,int y,int sx,int sy,int hx,int hy,int cx,int cy,int chx,int chy)
  164. static TUserFunc(ClipBltFast);                //    (int plane,int x,int y,int cx,int cy,int chx,int chy)
  165. static TUserFunc(ClipBltFastRect);            //    (int plane,int x,int y,int sx,int sy,int hx,int hy,int cx,int cy,int chx,int chy)
  166. static TUserFunc(ClipBlendBlt);                //    (int plane,int x,int y,int cx,int cy,int chx,int chy,int ar,int ag,int ab,int br,int bg,int bb)
  167. static TUserFunc(ClipBlendBltRect);            //    (int plane,int x,int y,int sx,int sy,int hx,int hy,int cx,int cy,int chx,int chy,int ar,int ag,int ab,int br,int bg,int bb)
  168.  
  169. static TUserFunc(EnableBlendColorKey);        //    (int plane,bool b);
  170.  
  171. //    拡大縮小機能付
  172. static TUserFunc(BltR);                        //    (int plane,int x,int y,double r)
  173. static TUserFunc(BltRectR);                    //    (int plane,int x,int y,int sx,int sy,int hx,int hy,double r)
  174. static TUserFunc(BltFastR);                    //    (int plane,int x,int y,double r)
  175. static TUserFunc(BltFastRectR);                //    (int plane,int x,int y,int sx,int sy,int hx,int hy,double r)
  176. static TUserFunc(BlendBltR);                //    (int plane,int x,int y,int ar,int ag,int ab,int br,int bg,int bb,double r)
  177. static TUserFunc(BlendBltRectR);            //    (int plane,int x,int y,int sx,int sy,int hx,int hy,int ar,int ag,int ab,int br,int bg,int bb,double r)
  178. static TUserFunc(ClipBltR);                    //    (int plane,int x,int y,int cx,int cy,int chx,int chy,double r)
  179. static TUserFunc(ClipBltRectR);                //    (int plane,int x,int y,int sx,int sy,int hx,int hy,int cx,int cy,int chx,int chy,double r)
  180. static TUserFunc(ClipBltFastR);                //    (int plane,int x,int y,int cx,int cy,int chx,int chy,double r)
  181. static TUserFunc(ClipBltFastRectR);            //    (int plane,int x,int y,int sx,int sy,int hx,int hy,int cx,int cy,int chx,int chy,double r)
  182. static TUserFunc(ClipBlendBltR);            //    (int plane,int x,int y,int cx,int cy,int chx,int chy,int ar,int ag,int ab,int br,int bg,int bb,double r)
  183. static TUserFunc(ClipBlendBltRectR);        //    (int plane,int x,int y,int sx,int sy,int hx,int hy,int cx,int cy,int chx,int chy,int ar,int ag,int ab,int br,int bg,int bb,double r)
  184.  
  185. //    効果
  186. static TUserFunc(FlushBlt);                    //    (int plane,int x,int y,int sx,int sy);
  187. static TUserFunc(MosaicBlt);                //    (int plane,int x,int y,int sx,int sy,int d);
  188.  
  189. static TUserFunc(CreateSurface);            //    (int plane,int sx,int sy);
  190. static TUserFunc(SwapToSecondary);            //    (int);
  191. static TUserFunc(SetSecondaryOffset);        //    (int ox,int oy);
  192.  
  193. // FPS関連
  194. static CGameTime* m_gametime;
  195.  
  196. static TUserFunc(SetFPS);                    //    (DWORD)
  197. static TUserFunc(GetFPS);                    //    (void) DWORD
  198. static TUserFunc(GetRealFPS);                //    (void) DWORD
  199. static TUserFunc(ResetTime);                //    (int)
  200. static TUserFunc(GetTime);                    //    (int) DWORD
  201. static TUserFunc(PauseTime);                //    (int)
  202. static TUserFunc(RestartTime);                //    (int)
  203. static TUserFunc(PauseTimeAll);                //    bool
  204. static TUserFunc(RestartTimeAll);            //    bool
  205.  
  206. // FPS表示関連
  207. static CFPSLayer*    m_fpslayer;
  208. static TUserFunc(FPSLayerOn);                //    (int x,int y);
  209. static TUserFunc(FPSLayerOff);                //    (void);
  210.  
  211. // 画面のフェードイン・フェードアウト関連
  212. static TUserFunc(SetBrightness);            //    (int);
  213. static TUserFunc(RealizePalette);            //    (int);
  214. static TUserFunc(FlushPalette);                //    (void);
  215. static TUserFunc(SetSystemMemoryUse);        //    (bool);
  216.  
  217. // 文字表示関連
  218. static CTextLayer*    m_textlayer;
  219. static TUserFunc(TextLayerOn);                //    (int n,int x,int y);
  220. static TUserFunc(TextLayerOff);                //    (int n);
  221. static TUserFunc(TextMove);                    //    (int n,int x,int y);
  222. static TUserFunc(TextOut);                    //    (int n,LPSTR);
  223. static TUserFunc(TextSize);                    //    (int n,int size);
  224. static TUserFunc(TextHeight);                //    (int n,int height);
  225. static TUserFunc(TextColor);                //    (int n,int r,int g,int b);
  226. static TUserFunc(TextBackColor);            //    (int n,int r,int g,int b);
  227. static TUserFunc(TextBackColorDisable);        //    (int n);
  228. static TUserFunc(TextFont);                    //    (int n); (LPSTR);
  229. static TUserFunc(TextBlend);                //    (int n);
  230. static TUserFunc(TextBlt);                    //    (int n);
  231. static TUserFunc(TextGetSize);                //    (int n,int &x,int &y);
  232.  
  233. //    文字列操作関連
  234. static LPSTR* m_alpString;                    //    無駄かなぁ...
  235. static TUserFunc(strcpy);                    //    (LPSTR,LPSTR);
  236. static TUserFunc(strcat);                    //    (LPSTR,LPSTR);
  237. static TUserFunc(strncpy);                    //    (LPSTR,LPSTR,size_t n);
  238. static TUserFunc(sprintf);                    //    (LPSTR,LPSTR,vpara...);
  239.  
  240. static TUserFunc(sprintf0);                    //    (互換性のため)
  241. static TUserFunc(sprintf1);
  242. static TUserFunc(sprintf2);
  243. static TUserFunc(sprintf3);
  244.  
  245. //    キー入力関連
  246. static TUserFunc(KeyInput);                    //    ()
  247. static TUserFunc(IsPressUpKey);                //    () bool
  248. static TUserFunc(IsPressDownKey);            //    () bool
  249. static TUserFunc(IsPressLeftKey);            //    () bool
  250. static TUserFunc(IsPressRightKey);            //    () bool
  251. static TUserFunc(IsPressReturnKey);            //    () bool
  252. static TUserFunc(IsPressSpaceKey);            //    () bool
  253. static TUserFunc(IsPressEscKey);            //    () bool
  254. static TUserFunc(IsPushUpKey);                //    () bool
  255. static TUserFunc(IsPushDownKey);            //    () bool
  256. static TUserFunc(IsPushLeftKey);            //    () bool
  257. static TUserFunc(IsPushRightKey);            //    () bool
  258. static TUserFunc(IsPushReturnKey);            //    () bool
  259. static TUserFunc(IsPushSpaceKey);            //    () bool
  260. static TUserFunc(IsPushEscKey);                //    () bool
  261. static TUserFunc(IsPressKey);                //    (int DIK)
  262. static TUserFunc(IsPushKey);                //    (int DIK)
  263. //    ジョイスティック
  264. static TUserFunc(IsPressJoyKey);            //    (int n) : bool
  265. static TUserFunc(IsPushJoyKey);                //    (int n) : bool
  266. static TUserFunc(SetJoyButtonMax);            //    (int buttonmax)
  267. //    MIDI入力
  268. static TUserFunc(IsPressMIDIKey);            //    (int n) : bool
  269. static TUserFunc(IsPushMIDIKey);            //    (int n) : bool
  270. static TUserFunc(GetVelocityMIDIKey);        //    (int buttonmax) : byte
  271. //    MOUSE入力
  272. static CMouseLayer* m_mouselayer;
  273. static CMouseInput* m_mouseinput;
  274. static TUserFunc(MouseLayerOn);                //    (int planeNo,int x,int y)
  275. static TUserFunc(MouseLayerOff);            //    ()
  276. static TUserFunc(GetMouseInfo);                //    (int *x,int *y,int *b)
  277. static TUserFunc(SetMouseInfo);                //    (int x,int y)
  278.  
  279. //    バックアッププレーン機能
  280. static TUserFunc(EnableBackupPlane);        //    ()
  281. static TUserFunc(DisableBackupPlane);        //    ()
  282. static TUserFunc(SnapToBackupPlane);        //    ()
  283. static TUserFunc(BltFromBackupPlane);        //    ()
  284. static TUserFunc(SaveBackupPlane);            //    (LPSTR filename)
  285.  
  286. //    シナリオ機能
  287. static TUserFunc(OpenSenario);                //    (LPSTR filename,int TextLayerNo) bool
  288. static TUserFunc(ReadSenario);                //    () bool
  289. static TUserFunc(OpenSenario2);                //    (LPSTR filename) bool
  290. static TUserFunc(ReadSenarioToString);        //    (LPSTR string) bool
  291. static TUserFunc(ReadLineToString);            //    (LPSTR string) bool
  292. static CYFile* m_yfpSenario;
  293. static int    m_nSenarioTextLayerNo;
  294. static LPSTR m_lpszSenarioString;
  295. static long ReadSenario2(void);
  296.  
  297. //    ディスプレイモードの変更
  298. static TUserFunc(SetDisplayMode);            //    (int d1,int d2)
  299. static TUserFunc(ChangeDisplayMode);        //    (int n)
  300. static int m_nDisplayMode1;
  301. static int m_nDisplayMode2;
  302.  
  303. //    ファイル入出力
  304. static TUserFunc(SaveFile);                    //    (LPSTR,BYTE*,size_t) LRESULT
  305. static TUserFunc(LoadFile);                    //    (LPSTR,BYTE*,size_t) LRESULT
  306.  
  307. //    new,delete
  308. static CBytePtrArray TMemory;                //    メモリチェイン
  309. static TUserFunc(NewMemory);                //    (size_t) BYTE*
  310. static TUserFunc(DeleteMemory);                //    (BYTE*) LRESULT
  311.  
  312. //    LoadLibrary,FreeLibrary
  313. static CLibraryArray TLibrary;                //    読み込みDLLリスト
  314. static TUserFunc(LoadLibrary);                //    (LPSTR) HANDLE
  315. static TUserFunc(FreeLibrary);                //    (HANDLE) LRESULT
  316. static TUserFunc(GetFunction);                //    (HANDLE,LPSTR) function
  317.  
  318. //    その他
  319. static TUserFunc(Rand);                        //    (long)
  320. static TUserFunc(GetCurrentDirectory);        //    (LPSTR)
  321. static TUserFunc(SetCurrentDirectory);        //    (LPSTR)
  322.  
  323. //    user変数
  324. static TUserFunc(LoadGameFlag);                //    (LPSTR) LRESULT
  325. static TUserFunc(SaveGameFlag);                //    (LPSTR) LRESULT
  326. static TUserFunc(LoadGameFlag2);            //    (LPSTR) LRESULT
  327. static TUserFunc(SaveGameFlag2);            //    (LPSTR) LRESULT
  328. static TUserFunc(ResetGameFlag);            //    ()
  329. static TUserFunc(ResetGameFlag2);            //    ()
  330.  
  331. //    これ本当は良くないけど、クラス外部から参照する可能性があるので…
  332. static LONG m_GameFlag[TGameFlagMax];
  333. static LONG m_GameFlag2[TGameFlagMax2];
  334.  
  335. ////////////////////////////////////////////////////////////////////////////////////
  336. //    gameinit.cから呼び出される関数
  337. static    TUserFunc(SetWindow);                //    (EScreenMode,int x,int y,int colorbits) LRESULT
  338.  
  339. static    int m_nDebugMode;
  340. static    TUserFunc(TSetDebugMode);            //    (int)
  341.  
  342. static    TUserFunc(SetConstParam);            //    (LPSTR,param) LRESULT
  343. static    TUserFunc(GetConstParam);            //    (LPSTR,¶m) LRESULT
  344.  
  345. static    void ToUpperStr(LPSTR q2,LPCSTR q);        //    大文字に変換する
  346. ////////////////////////////////////////////////////////////////////////////////////
  347. static    TScript* m_this;                    //    掟破り?
  348. };
  349.  
  350. #endif