1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
/* Bink! player, KJL 99/4/30 */
#include "bink.h"
#include "3dc.h"
#include "d3_func.h"
#define UseLocalAssert 1
#include "ourasert.h"
extern char *ScreenBuffer;
extern LPDIRECTSOUND DSObject;
extern int GotAnyKey;
extern int IntroOutroMoviesAreActive;
extern DDPIXELFORMAT DisplayPixelFormat;
extern void DirectReadKeyboard(void);
static int BinkSurfaceType;
void PlayBinkedFMV(char *filenamePtr)
{
BINK* binkHandle;
int playing = 1;
if (!IntroOutroMoviesAreActive) return;
// if (!IntroOutroMoviesAreActive) return;
BinkSurfaceType = GetBinkPixelFormat();
/* skip FMV if surface type not supported */
if (BinkSurfaceType == -1) return;
/* use Direct sound */
BinkSoundUseDirectSound(DSObject);
/* open smacker file */
binkHandle = BinkOpen(filenamePtr,0);
if (!binkHandle)
{
char message[100];
sprintf(message,"Unable to access file: %s\n",filenamePtr);
MessageBox(NULL,message,"AvP Error",MB_OK+MB_SYSTEMMODAL);
exit(0x111);
return;
}
while(playing)
{
CheckForWindowsMessages();
if (!BinkWait(binkHandle))
playing = NextBinkFrame(binkHandle);
FlipBuffers();
DirectReadKeyboard();
if (GotAnyKey) playing = 0;
}
/* close file */
BinkClose(binkHandle);
}
static int NextBinkFrame(BINK *binkHandle)
{
/* unpack frame */
BinkDoFrame(binkHandle);
BinkCopyToBuffer(binkHandle,(void*)ScreenBuffer,640*2,480,(640-binkHandle->Width)/2,(480-binkHandle->Height)/2,BinkSurfaceType);
//BinkToBuffer(binkHandle,(640-binkHandle->Width)/2,(480-binkHandle->Height)/2,640*2,480,(void*)ScreenBuffer,GetBinkPixelFormat(&DisplayPixelFormat));
/* are we at the last frame yet? */
if ((binkHandle->FrameNum==(binkHandle->Frames-1))) return 0;
/* next frame, please */
BinkNextFrame(binkHandle);
return 1;
}
static int GetBinkPixelFormat(void)
{
if( (DisplayPixelFormat.dwFlags & DDPF_RGB) && !(DisplayPixelFormat.dwFlags & DDPF_PALETTEINDEXED8) )
{
int m;
int redShift=0;
int greenShift=0;
int blueShift=0;
m = DisplayPixelFormat.dwRBitMask;
LOCALASSERT(m);
while(!(m&1)) m>>=1;
while(m&1)
{
m>>=1;
redShift++;
}
m = DisplayPixelFormat.dwGBitMask;
LOCALASSERT(m);
while(!(m&1)) m>>=1;
while(m&1)
{
m>>=1;
greenShift++;
}
m = DisplayPixelFormat.dwBBitMask;
LOCALASSERT(m);
while(!(m&1)) m>>=1;
while(m&1)
{
m>>=1;
blueShift++;
}
if(redShift == 5)
{
if (greenShift == 5)
{
if (blueShift == 5)
{
return BINKSURFACE555;
}
else // not supported
{
return -1;
}
}
else if (greenShift == 6)
{
if (blueShift == 5)
{
return BINKSURFACE565;
}
else // not supported
{
return -1;
}
}
}
else if (redShift == 6)
{
if (greenShift == 5)
{
if (blueShift == 5)
{
return BINKSURFACE655;
}
else // not supported
{
return -1;
}
}
else if (greenShift == 6)
{
if (blueShift == 4)
{
return BINKSURFACE664;
}
else // not supported
{
return -1;
}
}
}
else
{
return -1;
}
}
return -1;
}
BINK *MenuBackground = 0;
extern void StartMenuBackgroundBink(void)
{
char *filenamePtr = "fmvs/menubackground.bik";//newer.bik";
/* open smacker file */
MenuBackground = BinkOpen(filenamePtr,0);
BinkSurfaceType = GetBinkPixelFormat();
BinkDoFrame(MenuBackground);
}
extern int PlayMenuBackgroundBink(void)
{
int newframe = 0;
if(!MenuBackground) return 0;
if (!BinkWait(MenuBackground)&&IntroOutroMoviesAreActive) newframe=1;
if(newframe) BinkDoFrame(MenuBackground);
BinkCopyToBuffer(MenuBackground,(void*)ScreenBuffer,640*2,480,(640-MenuBackground->Width)/2,(480-MenuBackground->Height)/2,BinkSurfaceType|BINKSURFACECOPYALL);
/* next frame, please */
if(newframe)BinkNextFrame(MenuBackground);
return 1;
}
extern void EndMenuBackgroundBink(void)
{
if(!MenuBackground) return;
BinkClose(MenuBackground);
MenuBackground = 0;
}
|