Review some mve video playback routines
This commit is contained in:
+40
-63
@@ -31,8 +31,8 @@ typedef struct MovieSubtitleListNode {
|
||||
static void* movieMallocImpl(size_t size);
|
||||
static void movieFreeImpl(void* ptr);
|
||||
static bool movieReadImpl(void* handle, void* buf, int count);
|
||||
static void movieDirectImpl(SDL_Surface* surface, int srcWidth, int srcHeight, int srcX, int srcY, int destWidth, int destHeight, int a8, int a9);
|
||||
static void movieBufferedImpl(SDL_Surface* surface, int srcWidth, int srcHeight, int srcX, int srcY, int destWidth, int destHeight, int a8, int a9);
|
||||
static void movieDirectImpl(unsigned char* pixels, int src_width, int src_height, int src_x, int src_y, int dst_width, int dst_height, int dst_x, int dst_y);
|
||||
static void movieBufferedImpl(unsigned char* pixels, int src_width, int src_height, int src_x, int src_y, int dst_width, int dst_height, int dst_x, int dst_y);
|
||||
static int _movieScaleSubRect(int win, unsigned char* data, int width, int height, int pitch);
|
||||
static int _movieScaleSubRectAlpha(int win, unsigned char* data, int width, int height, int pitch);
|
||||
static int _movieScaleWindowAlpha(int win, unsigned char* data, int width, int height, int pitch);
|
||||
@@ -184,7 +184,7 @@ static File* _alphaHandle;
|
||||
// 0x638EC0
|
||||
static unsigned char* _alphaBuf;
|
||||
|
||||
static SDL_Surface* gMovieSdlSurface = nullptr;
|
||||
static unsigned char* MVE_lastBuffer = nullptr;
|
||||
|
||||
// 0x4865FC
|
||||
static void* movieMallocImpl(size_t size)
|
||||
@@ -205,16 +205,16 @@ static bool movieReadImpl(void* handle, void* buf, int count)
|
||||
}
|
||||
|
||||
// 0x486654
|
||||
static void movieDirectImpl(SDL_Surface* surface, int srcWidth, int srcHeight, int srcX, int srcY, int destWidth, int destHeight, int a8, int a9)
|
||||
static void movieDirectImpl(unsigned char* pixels, int src_width, int src_height, int src_x, int src_y, int dst_width, int dst_height, int dst_x, int dst_y)
|
||||
{
|
||||
int v14;
|
||||
int v15;
|
||||
|
||||
SDL_Rect srcRect;
|
||||
srcRect.x = srcX;
|
||||
srcRect.y = srcY;
|
||||
srcRect.w = srcWidth;
|
||||
srcRect.h = srcHeight;
|
||||
srcRect.x = src_x;
|
||||
srcRect.y = src_y;
|
||||
srcRect.w = src_width;
|
||||
srcRect.h = src_height;
|
||||
|
||||
v14 = gMovieWindowRect.right - gMovieWindowRect.left;
|
||||
v15 = gMovieWindowRect.right - gMovieWindowRect.left + 1;
|
||||
@@ -223,35 +223,35 @@ static void movieDirectImpl(SDL_Surface* surface, int srcWidth, int srcHeight, i
|
||||
|
||||
if (_movieScaleFlag) {
|
||||
if ((gMovieFlags & MOVIE_EXTENDED_FLAG_0x08) != 0) {
|
||||
destRect.y = (gMovieWindowRect.bottom - gMovieWindowRect.top + 1 - destHeight) / 2;
|
||||
destRect.x = (v15 - 4 * srcWidth / 3) / 2;
|
||||
destRect.y = (gMovieWindowRect.bottom - gMovieWindowRect.top + 1 - dst_height) / 2;
|
||||
destRect.x = (v15 - 4 * src_width / 3) / 2;
|
||||
} else {
|
||||
destRect.y = _movieY + gMovieWindowRect.top;
|
||||
destRect.x = gMovieWindowRect.left + _movieX;
|
||||
}
|
||||
|
||||
destRect.w = 4 * srcWidth / 3;
|
||||
destRect.h = destHeight;
|
||||
destRect.w = 4 * src_width / 3;
|
||||
destRect.h = dst_height;
|
||||
} else {
|
||||
if ((gMovieFlags & MOVIE_EXTENDED_FLAG_0x08) != 0) {
|
||||
destRect.y = (gMovieWindowRect.bottom - gMovieWindowRect.top + 1 - destHeight) / 2;
|
||||
destRect.x = (v15 - destWidth) / 2;
|
||||
destRect.y = (gMovieWindowRect.bottom - gMovieWindowRect.top + 1 - dst_height) / 2;
|
||||
destRect.x = (v15 - dst_width) / 2;
|
||||
} else {
|
||||
destRect.y = _movieY + gMovieWindowRect.top;
|
||||
destRect.x = gMovieWindowRect.left + _movieX;
|
||||
}
|
||||
destRect.w = destWidth;
|
||||
destRect.h = destHeight;
|
||||
destRect.w = dst_width;
|
||||
destRect.h = dst_height;
|
||||
}
|
||||
|
||||
_lastMovieSX = srcX;
|
||||
_lastMovieSY = srcY;
|
||||
_lastMovieSX = src_x;
|
||||
_lastMovieSY = src_y;
|
||||
_lastMovieX = destRect.x;
|
||||
_lastMovieY = destRect.y;
|
||||
_lastMovieBH = srcHeight;
|
||||
_lastMovieBH = src_height;
|
||||
_lastMovieW = destRect.w;
|
||||
gMovieSdlSurface = surface;
|
||||
_lastMovieBW = srcWidth;
|
||||
MVE_lastBuffer = pixels;
|
||||
_lastMovieBW = src_width;
|
||||
_lastMovieH = destRect.h;
|
||||
|
||||
// The code above assumes `gMovieWindowRect` is always at (0,0) which is not
|
||||
@@ -261,42 +261,31 @@ static void movieDirectImpl(SDL_Surface* surface, int srcWidth, int srcHeight, i
|
||||
destRect.x += gMovieWindowRect.left;
|
||||
destRect.y += gMovieWindowRect.top;
|
||||
|
||||
// TODO: This is a super-ugly hack. The reason is that surfaces managed by
|
||||
// MVE does not have palette. If we blit from these internal surfaces into
|
||||
// backbuffer surface (with palette set), all we get is shiny white box.
|
||||
SDL_SetSurfacePalette(surface, gSdlSurface->format->palette);
|
||||
SDL_BlitSurface(surface, &srcRect, gSdlSurface, &destRect);
|
||||
SDL_BlitSurface(gSdlSurface, nullptr, gSdlTextureSurface, nullptr);
|
||||
_scr_blit(pixels, src_width, src_height, src_x, src_y, dst_width, dst_height, dst_x, dst_y);
|
||||
renderPresent();
|
||||
}
|
||||
|
||||
// 0x486900
|
||||
static void movieBufferedImpl(SDL_Surface* a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
|
||||
static void movieBufferedImpl(unsigned char* pixels, int src_width, int src_height, int src_x, int src_y, int dst_width, int dst_height, int dst_x, int dst_y)
|
||||
{
|
||||
if (gMovieWindow == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
_lastMovieBW = a2;
|
||||
gMovieSdlSurface = a1;
|
||||
_lastMovieBH = a2;
|
||||
_lastMovieW = a6;
|
||||
_lastMovieH = a7;
|
||||
_lastMovieX = a4;
|
||||
_lastMovieY = a5;
|
||||
_lastMovieSX = a4;
|
||||
_lastMovieSY = a5;
|
||||
|
||||
if (SDL_LockSurface(a1) != 0) {
|
||||
return;
|
||||
}
|
||||
_lastMovieBW = src_width;
|
||||
MVE_lastBuffer = pixels;
|
||||
_lastMovieBH = src_width;
|
||||
_lastMovieW = dst_width;
|
||||
_lastMovieH = dst_height;
|
||||
_lastMovieX = src_x;
|
||||
_lastMovieY = src_y;
|
||||
_lastMovieSX = src_x;
|
||||
_lastMovieSY = src_y;
|
||||
|
||||
MovieBlitFunc* func = gMovieBlitFuncs[_movieAlphaFlag][_movieScaleFlag][_movieSubRectFlag];
|
||||
if (func(gMovieWindow, static_cast<unsigned char*>(a1->pixels), a2, a3, a1->pitch) != 0) {
|
||||
if (func(gMovieWindow, pixels, src_width, src_height, src_width) != 0) {
|
||||
windowRefreshRect(gMovieWindow, &_movieRect);
|
||||
}
|
||||
|
||||
SDL_UnlockSurface(a1);
|
||||
}
|
||||
|
||||
// 0x486B68
|
||||
@@ -431,20 +420,14 @@ static void _cleanupMovie(int a1)
|
||||
_lastMovieBuffer = nullptr;
|
||||
}
|
||||
|
||||
if (gMovieSdlSurface != nullptr) {
|
||||
if (SDL_LockSurface(gMovieSdlSurface) == 0) {
|
||||
_lastMovieBuffer = (unsigned char*)internal_malloc_safe(_lastMovieBH * _lastMovieBW, __FILE__, __LINE__); // "..\\int\\MOVIE.C", 802
|
||||
blitBufferToBuffer((unsigned char*)gMovieSdlSurface->pixels + gMovieSdlSurface->pitch * _lastMovieSX + _lastMovieSY, _lastMovieBW, _lastMovieBH, gMovieSdlSurface->pitch, _lastMovieBuffer, _lastMovieBW);
|
||||
SDL_UnlockSurface(gMovieSdlSurface);
|
||||
} else {
|
||||
debugPrint("Couldn't lock movie surface\n");
|
||||
}
|
||||
|
||||
gMovieSdlSurface = nullptr;
|
||||
if (MVE_lastBuffer != nullptr) {
|
||||
_lastMovieBuffer = (unsigned char*)internal_malloc_safe(_lastMovieBH * _lastMovieBW, __FILE__, __LINE__); // "..\\int\\MOVIE.C", 802
|
||||
memcpy(_lastMovieBuffer, MVE_lastBuffer, _lastMovieBW * _lastMovieBH);
|
||||
MVE_lastBuffer = nullptr;
|
||||
}
|
||||
|
||||
if (a1) {
|
||||
_MVE_rmEndMovie();
|
||||
MVE_rmEndMovie();
|
||||
}
|
||||
|
||||
MVE_ReleaseMem();
|
||||
@@ -521,16 +504,10 @@ int movieSetFlags(int flags)
|
||||
|
||||
if ((flags & MOVIE_FLAG_0x01) != 0) {
|
||||
_movieScaleFlag = 1;
|
||||
|
||||
if ((gMovieFlags & MOVIE_EXTENDED_FLAG_0x04) != 0) {
|
||||
_sub_4F4BB(3);
|
||||
}
|
||||
} else {
|
||||
_movieScaleFlag = 0;
|
||||
|
||||
if ((gMovieFlags & MOVIE_EXTENDED_FLAG_0x04) != 0) {
|
||||
_sub_4F4BB(4);
|
||||
} else {
|
||||
if ((gMovieFlags & MOVIE_EXTENDED_FLAG_0x04) == 0) {
|
||||
gMovieFlags &= ~MOVIE_EXTENDED_FLAG_0x08;
|
||||
}
|
||||
}
|
||||
@@ -564,7 +541,7 @@ static void _cleanupLast()
|
||||
_lastMovieBuffer = nullptr;
|
||||
}
|
||||
|
||||
gMovieSdlSurface = nullptr;
|
||||
MVE_lastBuffer = nullptr;
|
||||
}
|
||||
|
||||
// 0x48731C
|
||||
|
||||
+77
-236
@@ -49,11 +49,9 @@ static int syncWaitLevel(int wait);
|
||||
static void _CallsSndBuff_Loc(unsigned char* a1, int a2);
|
||||
static int _MVE_sndAdd(unsigned char* dest, unsigned char** src_ptr, int a3, int a4, int a5);
|
||||
static void _MVE_sndResume();
|
||||
static int _nfConfig(int a1, int a2, int a3, int is_16_bpp);
|
||||
static bool movieLockSurfaces();
|
||||
static void movieUnlockSurfaces();
|
||||
static int nfConfig(int a1, int a2, int a3, int is_16_bpp);
|
||||
static void movieSwapSurfaces();
|
||||
static void _sfShowFrame(int a1, int a2, int a3);
|
||||
static void sfShowFrame(int a1, int a2, int a3);
|
||||
static void _do_nothing_(int a1, int a2, unsigned short* a3);
|
||||
static void palSetPalette(int start, int count);
|
||||
static void palClrPalette(int start, int count);
|
||||
@@ -62,18 +60,12 @@ static void palLoadPalette(unsigned char* palette, int start, int count);
|
||||
static void syncRelease();
|
||||
static void ioRelease();
|
||||
static void _MVE_sndRelease();
|
||||
static void _nfRelease();
|
||||
static void nfRelease();
|
||||
static int _MVE_sndDecompM16(unsigned short* a1, unsigned char* a2, int a3, int a4);
|
||||
static int _MVE_sndDecompS16(unsigned short* a1, unsigned char* a2, int a3, int a4);
|
||||
static void _nfPkConfig();
|
||||
static void _nfPkDecomp(unsigned char* buf, unsigned char* a2, int a3, int a4, int a5, int a6);
|
||||
|
||||
// 0x51EBD8
|
||||
static int dword_51EBD8 = 0;
|
||||
|
||||
// 0x51EBDC
|
||||
static int dword_51EBDC = 4;
|
||||
|
||||
// 0x51EBE0
|
||||
static unsigned short word_51EBE0[256] = {
|
||||
// clang-format off
|
||||
@@ -381,7 +373,7 @@ static int dword_6B3CEC;
|
||||
static int dword_6B3CF8;
|
||||
|
||||
// 0x6B3CFC
|
||||
static int _mveBW;
|
||||
static int nf_width;
|
||||
|
||||
// 0x6B3D00
|
||||
static int dword_6B3D00;
|
||||
@@ -408,16 +400,13 @@ static int dword_6B4023;
|
||||
static int dword_6B402B;
|
||||
|
||||
// 0x6B402F
|
||||
static int _mveBH;
|
||||
static int nf_height;
|
||||
|
||||
// 0x6B4033
|
||||
static unsigned char* gMovieDirectDrawSurfaceBuffer1;
|
||||
static MveMem nf_mem_cur;
|
||||
static unsigned char* nf_buf_cur;
|
||||
static MveMem nf_mem_prv;
|
||||
static unsigned char* nf_buf_prv;
|
||||
|
||||
// 0x6B4037
|
||||
static unsigned char* gMovieDirectDrawSurfaceBuffer2;
|
||||
|
||||
static SDL_Surface* gMovieSdlSurface1;
|
||||
static SDL_Surface* gMovieSdlSurface2;
|
||||
static int gMveSoundBuffer = -1;
|
||||
static unsigned int gMveBufferBytes;
|
||||
|
||||
@@ -493,16 +482,6 @@ static int _sub_4F4B5()
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 0x4F4BB0
|
||||
void _sub_4F4BB(int a1)
|
||||
{
|
||||
if (a1 == 3) {
|
||||
dword_51EBDC = 3;
|
||||
} else {
|
||||
dword_51EBDC = 4;
|
||||
}
|
||||
}
|
||||
|
||||
// 0x4F4BD0
|
||||
void MVE_rmFrameCounts(int* frame_count_ptr, int* frame_drop_count_ptr)
|
||||
{
|
||||
@@ -522,7 +501,7 @@ int MVE_rmPrepMovie(void* handle, int dx, int dy, unsigned char track)
|
||||
}
|
||||
|
||||
if (!ioReset(handle)) {
|
||||
_MVE_rmEndMovie();
|
||||
MVE_rmEndMovie();
|
||||
return -8;
|
||||
}
|
||||
|
||||
@@ -530,7 +509,7 @@ int MVE_rmPrepMovie(void* handle, int dx, int dy, unsigned char track)
|
||||
rm_len = 0;
|
||||
|
||||
if (rm_p == NULL) {
|
||||
_MVE_rmEndMovie();
|
||||
MVE_rmEndMovie();
|
||||
return -2;
|
||||
}
|
||||
|
||||
@@ -662,9 +641,6 @@ int _MVE_rmStepMovie()
|
||||
int v8;
|
||||
int v9;
|
||||
int v10;
|
||||
int v11;
|
||||
int v12;
|
||||
int v13;
|
||||
unsigned short* v3;
|
||||
unsigned short* v21;
|
||||
int v18;
|
||||
@@ -684,7 +660,7 @@ LABEL_5:
|
||||
v3 = nullptr;
|
||||
if (!v1) {
|
||||
v6 = -2;
|
||||
_MVE_rmEndMovie();
|
||||
MVE_rmEndMovie();
|
||||
return v6;
|
||||
}
|
||||
|
||||
@@ -738,31 +714,15 @@ LABEL_5:
|
||||
v10 = v1[2];
|
||||
}
|
||||
|
||||
if (!_nfConfig(v1[0], v1[1], v10, v9)) {
|
||||
v6 = -5;
|
||||
break;
|
||||
if (!nfConfig(v1[0], v1[1], v10, v9)) {
|
||||
MVE_rmEndMovie();
|
||||
return -5;
|
||||
}
|
||||
|
||||
v11 = 4 * _mveBW / dword_51EBDC & 0xFFFFFFF0;
|
||||
|
||||
v12 = rm_dx;
|
||||
if (v12 < 0) {
|
||||
v12 = 0;
|
||||
}
|
||||
|
||||
if (v11 + v12 > sf_ScreenWidth) {
|
||||
v6 = -6;
|
||||
break;
|
||||
}
|
||||
|
||||
v13 = rm_dy;
|
||||
if (v13 < 0) {
|
||||
v13 = 0;
|
||||
}
|
||||
|
||||
if (_mveBH + v13 > sf_ScreenHeight) {
|
||||
v6 = -6;
|
||||
break;
|
||||
if (rm_dx + nf_width > sf_ScreenWidth
|
||||
|| rm_dy + nf_height > sf_ScreenHeight) {
|
||||
MVE_rmEndMovie();
|
||||
return -6;
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -784,7 +744,7 @@ LABEL_5:
|
||||
if (v21) {
|
||||
_do_nothing_(rm_dx, rm_dy, v21);
|
||||
} else if (!sync_late || v1[1]) {
|
||||
_sfShowFrame(rm_dx, rm_dy, v18);
|
||||
sfShowFrame(rm_dx, rm_dy, v18);
|
||||
} else {
|
||||
sync_FrameDropped = 1;
|
||||
++rm_FrameDropCount;
|
||||
@@ -841,48 +801,8 @@ LABEL_5:
|
||||
movieSwapSurfaces();
|
||||
}
|
||||
|
||||
if ((dword_51EBD8 & 3) == 1) {
|
||||
// lock
|
||||
if (!movieLockSurfaces()) {
|
||||
v6 = -12;
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: Incomplete.
|
||||
assert(false);
|
||||
// _nfPkDecompH(v3, v1[7], v1[2], v1[3], v1[4], v1[5]);
|
||||
|
||||
// unlock
|
||||
movieUnlockSurfaces();
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((dword_51EBD8 & 3) == 2) {
|
||||
// lock
|
||||
if (!movieLockSurfaces()) {
|
||||
v6 = -12;
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: Incomplete.
|
||||
assert(false);
|
||||
// _nfPkDecompH(v3, v1[7], v1[2], v1[3], v1[4], v1[5]);
|
||||
|
||||
// unlock
|
||||
movieUnlockSurfaces();
|
||||
continue;
|
||||
}
|
||||
|
||||
// lock
|
||||
if (!movieLockSurfaces()) {
|
||||
v6 = -12;
|
||||
break;
|
||||
}
|
||||
|
||||
_nfPkDecomp((unsigned char*)v3, (unsigned char*)&v1[7], v1[2], v1[3], v1[4], v1[5]);
|
||||
|
||||
// unlock
|
||||
movieUnlockSurfaces();
|
||||
continue;
|
||||
default:
|
||||
// unknown chunk
|
||||
@@ -890,7 +810,7 @@ LABEL_5:
|
||||
}
|
||||
}
|
||||
|
||||
_MVE_rmEndMovie();
|
||||
MVE_rmEndMovie();
|
||||
return v6;
|
||||
}
|
||||
|
||||
@@ -1267,121 +1187,46 @@ static void _MVE_sndResume()
|
||||
}
|
||||
|
||||
// 0x4F5CB0
|
||||
static int _nfConfig(int a1, int a2, int a3, int is_16_bpp)
|
||||
static int nfConfig(int width, int height, int a3, int is_16_bpp)
|
||||
{
|
||||
if (gMovieSdlSurface1 != nullptr) {
|
||||
SDL_FreeSurface(gMovieSdlSurface1);
|
||||
gMovieSdlSurface1 = nullptr;
|
||||
}
|
||||
|
||||
if (gMovieSdlSurface2 != nullptr) {
|
||||
SDL_FreeSurface(gMovieSdlSurface2);
|
||||
gMovieSdlSurface2 = nullptr;
|
||||
}
|
||||
|
||||
byte_6B4016 = a3;
|
||||
_mveBW = 8 * a1;
|
||||
_mveBH = 8 * a2 * a3;
|
||||
nf_width = 8 * width;
|
||||
nf_height = 8 * height * a3;
|
||||
|
||||
if (dword_51EBD8) {
|
||||
_mveBH >>= 1;
|
||||
}
|
||||
|
||||
gMovieSdlSurface1 = SDL_CreateRGBSurface(0, _mveBW, _mveBH, 8, 0, 0, 0, 0);
|
||||
if (gMovieSdlSurface1 == nullptr) {
|
||||
nf_buf_cur = (unsigned char*)MVE_MemAlloc(&nf_mem_cur, nf_width * nf_height);
|
||||
if (nf_buf_cur == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
gMovieSdlSurface2 = SDL_CreateRGBSurface(0, _mveBW, _mveBH, 8, 0, 0, 0, 0);
|
||||
if (gMovieSdlSurface2 == nullptr) {
|
||||
nf_buf_prv = (unsigned char*)MVE_MemAlloc(&nf_mem_prv, nf_width * nf_height);
|
||||
if (nf_buf_prv == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
dword_6B3D00 = 8 * a3 * _mveBW;
|
||||
dword_6B3CEC = 7 * a3 * _mveBW;
|
||||
dword_6B3D00 = 8 * a3 * nf_width;
|
||||
dword_6B3CEC = 7 * a3 * nf_width;
|
||||
|
||||
_nfPkConfig();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 0x4F5E60
|
||||
static bool movieLockSurfaces()
|
||||
{
|
||||
if (gMovieSdlSurface1 != nullptr && gMovieSdlSurface2 != nullptr) {
|
||||
if (SDL_LockSurface(gMovieSdlSurface1) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
gMovieDirectDrawSurfaceBuffer1 = (unsigned char*)gMovieSdlSurface1->pixels;
|
||||
|
||||
if (SDL_LockSurface(gMovieSdlSurface2) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
gMovieDirectDrawSurfaceBuffer2 = (unsigned char*)gMovieSdlSurface2->pixels;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// 0x4F5EF0
|
||||
static void movieUnlockSurfaces()
|
||||
{
|
||||
SDL_UnlockSurface(gMovieSdlSurface1);
|
||||
SDL_UnlockSurface(gMovieSdlSurface2);
|
||||
}
|
||||
|
||||
// 0x4F5F20
|
||||
static void movieSwapSurfaces()
|
||||
{
|
||||
SDL_Surface* tmp = gMovieSdlSurface2;
|
||||
gMovieSdlSurface2 = gMovieSdlSurface1;
|
||||
gMovieSdlSurface1 = tmp;
|
||||
unsigned char* tmp = nf_buf_prv;
|
||||
nf_buf_prv = nf_buf_cur;
|
||||
nf_buf_cur = tmp;
|
||||
}
|
||||
|
||||
// 0x4F5F40
|
||||
static void _sfShowFrame(int a1, int a2, int a3)
|
||||
static void sfShowFrame(int dst_x, int dst_y, int a3)
|
||||
{
|
||||
int v3;
|
||||
int v4;
|
||||
int v5;
|
||||
int v6;
|
||||
int v7;
|
||||
dst_x = (sf_ScreenWidth - nf_width) / 2;
|
||||
dst_y = (sf_ScreenHeight - nf_height) / 2;
|
||||
|
||||
v4 = ((4 * _mveBW / dword_51EBDC - 12) & 0xFFFFFFF0) + 12;
|
||||
|
||||
dword_6B3CF8 = _mveBW - dword_51EBDC * (v4 >> 2);
|
||||
|
||||
v3 = a1;
|
||||
if (a1 < 0) {
|
||||
v3 = (sf_ScreenWidth - v4) >> 1;
|
||||
}
|
||||
|
||||
v5 = a2;
|
||||
if (a2 >= 0) {
|
||||
v6 = _mveBH;
|
||||
} else {
|
||||
v6 = _mveBH;
|
||||
if (dword_51EBD8 & 4) {
|
||||
v5 = (sf_ScreenHeight - 2 * _mveBH) >> 1;
|
||||
} else {
|
||||
v5 = (sf_ScreenHeight - _mveBH) >> 1;
|
||||
}
|
||||
}
|
||||
|
||||
v7 = v3 & 0xFFFFFFFC;
|
||||
if (dword_51EBD8 & 4) {
|
||||
v5 >>= 1;
|
||||
}
|
||||
|
||||
if (a3) {
|
||||
// TODO: Incomplete.
|
||||
// _mve_ShowFrameField(off_6B4033, _mveBW, v6, dword_6B401B, dword_6B401F, dword_6B4017, dword_6B4023, v7, v5, a3);
|
||||
} else if (dword_51EBDC == 4) {
|
||||
sf_ShowFrame(gMovieSdlSurface1, _mveBW, v6, dword_6B401B, dword_6B401F, dword_6B4017, dword_6B4023, v7, v5);
|
||||
} else {
|
||||
sf_ShowFrame(gMovieSdlSurface1, _mveBW, v6, 0, dword_6B401F, ((4 * _mveBW / dword_51EBDC - 12) & 0xFFFFFFF0) + 12, dword_6B4023, v7, v5);
|
||||
if (a3 == 0) {
|
||||
sf_ShowFrame(nf_buf_cur, nf_width, nf_height, 0, 0, nf_width, nf_height, dst_x, dst_y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1435,7 +1280,7 @@ static void palLoadPalette(unsigned char* palette, int start, int count)
|
||||
}
|
||||
|
||||
// 0x4F6240
|
||||
void _MVE_rmEndMovie()
|
||||
void MVE_rmEndMovie()
|
||||
{
|
||||
if (rm_active) {
|
||||
syncWait();
|
||||
@@ -1454,10 +1299,10 @@ static void syncRelease()
|
||||
// 0x4F6350
|
||||
void MVE_ReleaseMem()
|
||||
{
|
||||
_MVE_rmEndMovie();
|
||||
MVE_rmEndMovie();
|
||||
ioRelease();
|
||||
_MVE_sndRelease();
|
||||
_nfRelease();
|
||||
nfRelease();
|
||||
}
|
||||
|
||||
// 0x4F6370
|
||||
@@ -1472,17 +1317,13 @@ static void _MVE_sndRelease()
|
||||
}
|
||||
|
||||
// 0x4F6390
|
||||
static void _nfRelease()
|
||||
static void nfRelease()
|
||||
{
|
||||
if (gMovieSdlSurface1 != nullptr) {
|
||||
SDL_FreeSurface(gMovieSdlSurface1);
|
||||
gMovieSdlSurface1 = nullptr;
|
||||
}
|
||||
MVE_MemFree(&nf_mem_cur);
|
||||
nf_buf_cur = nullptr;
|
||||
|
||||
if (gMovieSdlSurface2 != nullptr) {
|
||||
SDL_FreeSurface(gMovieSdlSurface2);
|
||||
gMovieSdlSurface2 = nullptr;
|
||||
}
|
||||
MVE_MemFree(&nf_mem_prv);
|
||||
nf_buf_prv = nullptr;
|
||||
}
|
||||
|
||||
// 0x4F697C
|
||||
@@ -1540,7 +1381,7 @@ static void _nfPkConfig()
|
||||
int v5;
|
||||
|
||||
ptr = dword_51F018;
|
||||
v1 = _mveBW;
|
||||
v1 = nf_width;
|
||||
v2 = 0;
|
||||
|
||||
v3 = 128;
|
||||
@@ -1588,12 +1429,12 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
dword_6B4023 = 8 * a6 * byte_6B4016;
|
||||
|
||||
var_8 = dword_6B3D00 - dword_6B4017;
|
||||
dest = gMovieDirectDrawSurfaceBuffer1;
|
||||
dest = nf_buf_cur;
|
||||
|
||||
var_10 = dword_6B3CEC - 8;
|
||||
|
||||
if (a3 || a4) {
|
||||
dest = gMovieDirectDrawSurfaceBuffer1 + dword_6B401B + _mveBW * dword_6B401F;
|
||||
dest = nf_buf_cur + dword_6B401B + nf_width * dword_6B401F;
|
||||
}
|
||||
|
||||
while (a6--) {
|
||||
@@ -1616,7 +1457,7 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
case 5:
|
||||
switch (v7) {
|
||||
case 0:
|
||||
v10 = gMovieDirectDrawSurfaceBuffer2 - gMovieDirectDrawSurfaceBuffer1;
|
||||
v10 = nf_buf_prv - nf_buf_cur;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
@@ -1639,11 +1480,11 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
a2 += 2;
|
||||
}
|
||||
|
||||
v10 = ((v13 << 24) >> 24) + dword_51F018[v13 >> 8] + (gMovieDirectDrawSurfaceBuffer2 - gMovieDirectDrawSurfaceBuffer1);
|
||||
v10 = ((v13 << 24) >> 24) + dword_51F018[v13 >> 8] + (nf_buf_prv - nf_buf_cur);
|
||||
break;
|
||||
}
|
||||
|
||||
value2 = _mveBW;
|
||||
value2 = nf_width;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
src_ptr = (unsigned int*)(dest + v10);
|
||||
@@ -1695,7 +1536,7 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
map2[0xC1] = (a2[1] << 8) | a2[1]; // cx
|
||||
map2[0xC3] = (a2[0] << 8) | a2[0]; // bx
|
||||
|
||||
value2 = _mveBW;
|
||||
value2 = nf_width;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
dest_ptr = (unsigned int*)dest;
|
||||
@@ -1733,7 +1574,7 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
map2[0xC2] = (a2[0] << 8) | a2[1]; // dx
|
||||
map2[0xC5] = (a2[1] << 8) | a2[1]; // bp
|
||||
|
||||
value2 = _mveBW;
|
||||
value2 = nf_width;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
dest_ptr = (unsigned int*)dest;
|
||||
@@ -1770,7 +1611,7 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
map1[16 + i * 4 + 3] = (value1 >> 24) & 0xFF;
|
||||
}
|
||||
|
||||
value2 = _mveBW;
|
||||
value2 = nf_width;
|
||||
|
||||
map2[0xC1] = (a2[1] << 8) | a2[0]; // cx
|
||||
map2[0xC3] = (a2[0] << 8) | a2[0]; // bx
|
||||
@@ -1820,7 +1661,7 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
map1[16 + i * 4 + 3] = (value1 >> 24) & 0xFF;
|
||||
}
|
||||
|
||||
value2 = _mveBW;
|
||||
value2 = nf_width;
|
||||
|
||||
map2[0xC1] = (a2[1] << 8) | a2[0]; // cx
|
||||
map2[0xC3] = (a2[0] << 8) | a2[0]; // bx
|
||||
@@ -1895,7 +1736,7 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
map1[24 + i * 4 + 3] = (value1 >> 24) & 0xFF;
|
||||
}
|
||||
|
||||
value2 = _mveBW;
|
||||
value2 = nf_width;
|
||||
|
||||
map2[0xC1] = (a2[1] << 8) | a2[0]; // cx
|
||||
map2[0xC3] = (a2[0] << 8) | a2[0]; // bx
|
||||
@@ -1989,7 +1830,7 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
map2[0xE5] = a2[3]; // mov ah, ch
|
||||
map2[0xE7] = a2[1]; // mov ah, bh
|
||||
|
||||
value2 = _mveBW;
|
||||
value2 = nf_width;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
dest_ptr = (unsigned int*)dest;
|
||||
@@ -2027,7 +1868,7 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
map2[0xE5] = a2[3]; // mov ah, ch
|
||||
map2[0xE7] = a2[1]; // mov ah, bh
|
||||
|
||||
value2 = _mveBW;
|
||||
value2 = nf_width;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
dest_ptr = (unsigned int*)dest;
|
||||
@@ -2063,7 +1904,7 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
map2[0xE5] = a2[3]; // mov ah, ch
|
||||
map2[0xE7] = a2[1]; // mov ah, bh
|
||||
|
||||
value2 = _mveBW;
|
||||
value2 = nf_width;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
dest_ptr = (unsigned int*)dest;
|
||||
@@ -2103,7 +1944,7 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
map2[0xE5] = a2[3]; // mov ah, ch
|
||||
map2[0xE7] = a2[1]; // mov ah, bh
|
||||
|
||||
value2 = _mveBW;
|
||||
value2 = nf_width;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
dest_ptr = (unsigned int*)dest;
|
||||
@@ -2140,7 +1981,7 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
map1[32 + i * 4 + 3] = (value1 >> 24) & 0xFF;
|
||||
}
|
||||
|
||||
value2 = _mveBW;
|
||||
value2 = nf_width;
|
||||
|
||||
map2[0xC1] = a2[2]; // mov al, cl
|
||||
map2[0xC3] = a2[0]; // mov al, bl
|
||||
@@ -2197,7 +2038,7 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
map1[32 + i * 4 + 3] = (value1 >> 24) & 0xFF;
|
||||
}
|
||||
|
||||
value2 = _mveBW;
|
||||
value2 = nf_width;
|
||||
|
||||
map2[0xC1] = a2[2]; // mov al, cl
|
||||
map2[0xC3] = a2[0]; // mov al, bl
|
||||
@@ -2280,7 +2121,7 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
map1[48 + i * 4 + 3] = (value1 >> 24) & 0xFF;
|
||||
}
|
||||
|
||||
value2 = _mveBW;
|
||||
value2 = nf_width;
|
||||
|
||||
map2[0xC1] = a2[2]; // mov al, cl
|
||||
map2[0xC3] = a2[0]; // mov al, bl
|
||||
@@ -2368,7 +2209,7 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
value2 = _mveBW;
|
||||
value2 = nf_width;
|
||||
|
||||
src_ptr = (unsigned int*)a2;
|
||||
for (i = 0; i < 8; i++) {
|
||||
@@ -2384,7 +2225,7 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
dest -= var_10;
|
||||
break;
|
||||
case 12:
|
||||
value2 = _mveBW;
|
||||
value2 = nf_width;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
byte = a2[i * 4 + 0];
|
||||
@@ -2403,14 +2244,14 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
dest_ptr[0] = value1;
|
||||
dest_ptr[1] = value2;
|
||||
|
||||
dest_ptr = (unsigned int*)(dest + _mveBW);
|
||||
dest_ptr = (unsigned int*)(dest + nf_width);
|
||||
dest_ptr[0] = value1;
|
||||
dest_ptr[1] = value2;
|
||||
|
||||
dest += _mveBW * 2;
|
||||
dest += nf_width * 2;
|
||||
}
|
||||
|
||||
dest -= _mveBW;
|
||||
dest -= nf_width;
|
||||
|
||||
a2 += 16;
|
||||
dest -= var_10;
|
||||
@@ -2427,11 +2268,11 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
dest_ptr[0] = value1;
|
||||
dest_ptr[1] = value2;
|
||||
|
||||
dest_ptr = (unsigned int*)(dest + _mveBW);
|
||||
dest_ptr = (unsigned int*)(dest + nf_width);
|
||||
dest_ptr[0] = value1;
|
||||
dest_ptr[1] = value2;
|
||||
|
||||
dest += _mveBW * 2;
|
||||
dest += nf_width * 2;
|
||||
}
|
||||
|
||||
byte = a2[2];
|
||||
@@ -2445,14 +2286,14 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
dest_ptr[0] = value1;
|
||||
dest_ptr[1] = value2;
|
||||
|
||||
dest_ptr = (unsigned int*)(dest + _mveBW);
|
||||
dest_ptr = (unsigned int*)(dest + nf_width);
|
||||
dest_ptr[0] = value1;
|
||||
dest_ptr[1] = value2;
|
||||
|
||||
dest += _mveBW * 2;
|
||||
dest += nf_width * 2;
|
||||
}
|
||||
|
||||
dest -= _mveBW;
|
||||
dest -= nf_width;
|
||||
|
||||
a2 += 4;
|
||||
dest -= var_10;
|
||||
@@ -2475,15 +2316,15 @@ static void _nfPkDecomp(unsigned char* a1, unsigned char* a2, int a3, int a4, in
|
||||
dest_ptr = (unsigned int*)dest;
|
||||
dest_ptr[0] = value1;
|
||||
dest_ptr[1] = value1;
|
||||
dest += _mveBW;
|
||||
dest += nf_width;
|
||||
|
||||
dest_ptr = (unsigned int*)dest;
|
||||
dest_ptr[0] = value2;
|
||||
dest_ptr[1] = value2;
|
||||
dest += _mveBW;
|
||||
dest += nf_width;
|
||||
}
|
||||
|
||||
dest -= _mveBW;
|
||||
dest -= nf_width;
|
||||
|
||||
dest -= var_10;
|
||||
break;
|
||||
|
||||
+3
-4
@@ -1,14 +1,14 @@
|
||||
#ifndef MOVIE_LIB_H
|
||||
#define MOVIE_LIB_H
|
||||
|
||||
#include <SDL.h>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace fallout {
|
||||
|
||||
typedef void*(MveMallocFunc)(size_t size);
|
||||
typedef void(MveFreeFunc)(void* ptr);
|
||||
typedef bool(MveReadFunc)(void* handle, void* buffer, int count);
|
||||
typedef void(MveShowFrameFunc)(SDL_Surface*, int, int, int, int, int, int, int, int);
|
||||
typedef void(MveShowFrameFunc)(unsigned char* pixels, int src_width, int src_height, int src_x, int src_y, int dst_width, int dst_height, int dst_x, int dst_y);
|
||||
typedef void(MveSetPaletteFunc)(unsigned char* palette, int start, int count);
|
||||
|
||||
void MveSetMemory(MveMallocFunc* malloc_func, MveFreeFunc* free_func);
|
||||
@@ -17,11 +17,10 @@ void MveSetVolume(int volume);
|
||||
void MveSetScreenSize(int width, int height);
|
||||
void MveSetShowFrame(MveShowFrameFunc* proc);
|
||||
void MveSetPalette(MveSetPaletteFunc* set_palette_func);
|
||||
void _sub_4F4BB(int a1);
|
||||
void MVE_rmFrameCounts(int* frame_count_ptr, int* frame_drop_count_ptr);
|
||||
int MVE_rmPrepMovie(void* handle, int dx, int dy, unsigned char track);
|
||||
int _MVE_rmStepMovie();
|
||||
void _MVE_rmEndMovie();
|
||||
void MVE_rmEndMovie();
|
||||
void MVE_ReleaseMem();
|
||||
|
||||
} // namespace fallout
|
||||
|
||||
Reference in New Issue
Block a user