OSDN Git Service

#xxxxx DTXViewerのプロジェクトを追加。
[dtxmania/dtxmania.git] / DTXViewerプロジェクト / @FDK10プロジェクト / stdafx.h
1 // stdafx.h
2 // FDK \82Æ\97\98\97p\83A\83v\83\8a\82Ì\97¼\95û\82Å\95s\95Ï\93I\82È\81i\82ß\82Á\82½\82É\8fC\90³\82³\82ê\82È\82¢\81j\82à\82Ì\81B
3 // FDK \93à\95\94\82Ì\83N\83\89\83X\82Í stdafx.h \82¾\82¯\82ð include \82µ\81A\97\98\97p\83A\83v\83\8a\82Í fdk10.h \82ð include \82·\82é\81B
4
5 #pragma once
6
7 #define WIN32_LEAN_AND_MEAN             // Windows \83w\83b\83_\81[\82©\82ç\8eg\97p\82³\82ê\82Ä\82¢\82È\82¢\95\94\95ª\82ð\8f\9c\8aO\82µ\82Ü\82·\81B
8 #define _CRTDBG_MAP_ALLOC               // malloc \82Æ free \82Ì\83f\83o\83b\83O\94Å\82ð\8eg\82¤\81i_DEBUG\8e\9e\82Ì\82Ý\81j
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <windows.h>
13 #include <windowsx.h>
14 #include <malloc.h>
15 #include <mmsystem.h>
16 #include <mmreg.h>
17 #include <msacm.h>
18 #include <vfw.h>
19 #include <tchar.h>
20 #include <process.h>
21 #include <time.h>
22 #include <direct.h>                     // for _tmkdir(), etc.
23 #include <winnls32.h>           // for WINNLSEnableIME()
24 #include <crtdbg.h>                     // for _ASSERT(), malloc_dbg, free_dbg
25
26 #define DIRECTINPUT_VERSION 0x0700
27
28 #include <ddraw.h>
29 #include <d3d.h>
30 #include <d3dx.h>
31 #include <dinput.h>
32 #include <dsound.h>
33
34 #ifndef bDEBUG
35  #ifdef _DEBUG
36   #define bDEBUG        true
37  #else
38   #define bDEBUG        false
39  #endif
40 #endif
41
42 #pragma warning( disable:4312 )         // \82æ\82è\91å\82«\82¢\8c^\82Ö\82Ì\95Ï\8a·\8cx\8d\90\82ð\97}\90§
43
44 #define APPENDLIST(f,l,c)        {if(l==NULL)f=l=c;else{(l)->next=c;(c)->prev=l;l=c;}}
45 #define REMOVELIST(f,l,c)        {if((c)->prev==NULL)f=(c)->next;else(c)->prev->next=(c)->next; if((c)->next==NULL)l=(c)->prev;else(c)->next->prev=(c)->prev;}
46 #define SAFE_DELETE(p)       { if(p) { delete (p);       (p)=NULL; } }
47 #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p);     (p)=NULL; } }
48 #define SAFE_RELEASE(p)      { if(p) { (p)->Release();   (p)=NULL; } }
49 #define SAFE_FREE(p)             { if(p) { free((void*)(p)); (p)=NULL; } }
50 #define ABS(a)                           (((a)<0)?-(a):(a))
51 #define MIN(a,b)                         (((a)<(b))?(a):(b))
52 #define MAX(a,b)                         (((a)>(b))?(a):(b))
53 #define SKIPSP(p)                       {while(*p==_T(' ')||*p==_T('\t'))p++;}
54 #define SKIPDEC(p)                      {while((*p>=_T('0')&&*p<=_T('9'))||*p==_T('-')||*p==_T('+'))p++;}
55 #define SKIPHEX(p)                      {while((*p>=_T('0')&&*p<=_T('9'))||(*p>=_T('a')&&*p<=_T('f'))||(*p>=_T('A')&&*p<=_T('F'))||*p==_T('-')||*p==_T('+'))p++;}
56 #define SKIPZEX(p)                      {while((*p>=_T('0')&&*p<=_T('9'))||(*p>=_T('a')&&*p<=_T('z'))||(*p>=_T('A')&&*p<=_T('Z'))||*p==_T('-')||*p==_T('+'))p++;}
57
58 #ifndef PI
59 #define PI                      3.1415926535898
60 #endif
61
62 // STL \8aÖ\8cW
63 #include <string>
64 using namespace std;
65 typedef basic_string<TCHAR> tstring;
66 #pragma warning( disable:4786 )         // STL\82Ì\8cx\8d\90\95\95\82
67
68 // \83L\81[\83\8a\83s\81[\83g\8f\88\97\9d\83}\83N\83\8d\87@
69 // m ... \8fó\91Ô\95Ï\90\94(int; 0..2; \8f\89\8aú\92l 0)
70 // t ... \83^\83C\83}\92l(double; \8f\89\8aú\89»\95s\97v)
71 // i ... \83L\81[\82ª\89\9f\82³\82ê\82Ä\82¢\82é\82È\82ç true \82É\82È\82é\8fð\8c\8f\8e®
72 // f ... \83L\81[\8f\88\97\9d\8aÖ\90\94
73 #define KEYREPEAT(m,t,i,f) \
74 if(i){\
75         switch(m){\
76         case 0: f;m=1;t=g_Timer.Get();break;\
77         case 1: if(g_Timer.Get()-t>200.0){f;t=g_Timer.Get();m=2;}break;\
78         case 2: if(g_Timer.Get()-t>30.0){f;t=g_Timer.Get();}break;\
79     }\
80 }else{\
81         m=0;\
82 }
83
84 // \83L\81[\83\8a\83s\81[\83g\8f\88\97\9d\83}\83N\83\8d\87A CCounter\91Î\89\9e\94Å; \81¦\96{\97\88\82ÌCCounter\82Ì\8eg\82¢\95û\82Å\82Í\82È\82¢\82Ì\82Å\92\8d\88Ó
85 // c ... CCtimer \95Ï\90\94
86 // i ... \83L\81[\82ª\89\9f\82³\82ê\82Ä\82¢\82é\82È\82ç true \82É\82È\82é\8fð\8c\8f\8e®
87 // f ... \83L\81[\8f\88\97\9d\8aÖ\90\94
88 #define KEYREPEATCT(c,i,f) \
89 if(i){\
90         switch(c.nValue){\
91         case 0: f; c.nValue=1; c.dbTimer=g_Timer.Get();break;\
92         case 1: if(g_Timer.Get()-c.dbTimer > 200.0){f; c.dbTimer=g_Timer.Get(); c.nValue=2;}break;\
93         case 2: if(g_Timer.Get()-c.dbTimer > 30.0) {f; c.dbTimer=g_Timer.Get();}break;\
94     }\
95 }else{\
96         c.nValue=0;\
97 }
98
99 // \83A\83j\83\81\90i\8ds\83}\83N\83\8d\87\83J\83E\83\93\83g\95Ï\90\94\83\8b\81[\83v\83^\83C\83v\81ic = b\81¨h, b\81¨h, ...\81j
100 // c ... \83J\83E\83\93\83g\95Ï\90\94(int\81G\8f\89\8aú\92l b\81j
101 // t ... \83^\83C\83}\95Ï\90\94(double)
102 // b ... \83J\83E\83\93\83g\82Ì\8dÅ\8f¬\92l
103 // h ... \83J\83E\83\93\83g\82Ì\8dÅ\91å\92l
104 // i ... \83C\83\93\83^\81[\83o\83\8b(ms\81j
105 #define COUNTLOOP(c,t,b,h,i) \
106 if( t != INIT_TIME ) {\
107         if( g_Timer.Get() < t ) t = g_Timer.Get();\
108         while( g_Timer.Get() - t >= (double) i ) {\
109                 if( ++c > h ) c = b;\
110                 t += (double) i;\
111         }\
112 }
113
114 // \83A\83j\83\81\90i\8ds\83}\83N\83\8d\87\83J\83E\83\93\83g\95Ï\90\94\8fã\8cÀ\82Å\92â\8e~\83^\83C\83v\81ic = b\81¨h,h,h,h,h,....\81j
115 #define COUNT(c,t,b,h,i) \
116 if( t != INIT_TIME ) {\
117         if( g_Timer.Get() < t ) t = g_Timer.Get();\
118         while( g_Timer.Get() - t >= (double) i ) {\
119                 if (++c > h) c = h;\
120                 t += (double) i;\
121         }\
122 }
123