diff --git a/Makefile b/Makefile index 80b8ef1..573c443 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC=gcc CFLAGS=-DHAVE_LIBPNG -Iinclude -Wall -Wl,--enable-stdcall-fixup -O3 -s -LIBS=lib/libpng14.a lib/libz.a -lgdi32 -lopengl32 +LIBS=lib/libpng14.a lib/libz.a -lgdi32 -lopengl32 -lwinmm all: $(CC) $(CFLAGS) -shared -o ddraw.dll main.c mouse.c palette.c surface.c clipper.c render.c render_soft.c render_dummy.c screenshot.c ddraw.def $(LIBS) diff --git a/ddraw video stretching stuff.txt b/ddraw video stretching stuff.txt index 0acc13a..074c180 100644 --- a/ddraw video stretching stuff.txt +++ b/ddraw video stretching stuff.txt @@ -1,2 +1,3 @@ -0x00665F58 = InMovie -0x0065D7BC = IsVQA640 \ No newline at end of file +0x00607D78 = InMovie +0x0065D7BC = IsVQA640 +0x00607D78 = ShouldStretch BYTE (added by 3.03p-iran) \ No newline at end of file diff --git a/ddraw.dll b/ddraw.dll index e4fd344..0f87748 100644 Binary files a/ddraw.dll and b/ddraw.dll differ diff --git a/render.c b/render.c index 6bfdfd8..024515e 100644 --- a/render.c +++ b/render.c @@ -14,6 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + #include #include @@ -86,12 +87,16 @@ DWORD WINAPI render_main(void) } glEnable(GL_TEXTURE_2D); + + timeBeginPeriod(1); + + while(ddraw->render.run && WaitForSingleObject(ddraw->render.sem, INFINITE) != WAIT_FAILED) { - scale_w = (float)ddraw->width/tex_width; - scale_h = (float)ddraw->height/tex_height; - + scale_w = (float)ddraw->width/tex_width; + scale_h = (float)ddraw->height/tex_height; + if(ddraw->render.maxfps > 0) { tick_start = GetTickCount(); @@ -144,22 +149,23 @@ DWORD WINAPI render_main(void) glTexCoord2f(scale_w,scale_h); glVertex2f( 1, -1); glTexCoord2f(0,scale_h); glVertex2f(-1, -1); glEnd(); + + SwapBuffers(ddraw->render.hDC); - SwapBuffers(ddraw->render.hDC); - - if(ddraw->render.maxfps > 0) - { - tick_end = GetTickCount(); - - if(tick_end - tick_start < frame_len) - { - Sleep( frame_len - (tick_end - tick_start) ); + if((ddraw->render.maxfps > 0)) + { + tick_end = GetTickCount(); + + if(tick_end - tick_start < frame_len) + { + Sleep( frame_len - (tick_end - tick_start)); } } SetEvent(ddraw->render.ev); } - + timeEndPeriod(1); + HeapFree(GetProcessHeap(), 0, tex); wglMakeCurrent(NULL, NULL); @@ -167,18 +173,3 @@ DWORD WINAPI render_main(void) return 0; } - - - -//BOOL detect_cutscene() -//{ -// if(ddraw->width <= CUTSCENE_WIDTH || ddraw->height <= CUTSCENE_HEIGHT) -// return FALSE; -// -// return getPixel(CUTSCENE_WIDTH + 1, 0) == 0 || getPixel(CUTSCENE_WIDTH + 5, 1) == 0 ? TRUE : FALSE; -//} - -#define DECLARE_VAR(name, type, address) type name = address - -//DECLARE_VAR(InMovie, int*, 0x00665F58); -//DECLARE_VAR(IsVQA640, int*, 0x0065D7BC); \ No newline at end of file diff --git a/render_soft.c b/render_soft.c index 534a934..3ad42f9 100644 --- a/render_soft.c +++ b/render_soft.c @@ -30,7 +30,7 @@ static unsigned char getPixel(int x, int y) int* InMovie = (int*)0x00665F58; int* IsVQA640 = (int*)0x0065D7BC; -BYTE* ShouldStretch = (BYTE*)0x006ED235; +BYTE* ShouldStretch = (BYTE*)0x00607D78; BOOL detect_cutscene() { @@ -49,7 +49,6 @@ BOOL detect_cutscene() return getPixel(CUTSCENE_WIDTH + 1, 0) == 0 || getPixel(CUTSCENE_WIDTH + 5, 1) == 0 ? TRUE : FALSE; } - DWORD WINAPI render_soft_main(void) { PBITMAPINFO bmi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256); @@ -69,6 +68,8 @@ DWORD WINAPI render_soft_main(void) DWORD tick_start = 0; DWORD tick_end = 0; DWORD frame_len = 0; + + timeBeginPeriod(1); if (ddraw->boxing) { @@ -152,17 +153,18 @@ DWORD WINAPI render_soft_main(void) LeaveCriticalSection(&ddraw->cs); - if(ddraw->render.maxfps > 0) + if((ddraw->render.maxfps > 0) && !detect_cutscene()) { tick_end = GetTickCount(); if(tick_end - tick_start < frame_len) { - Sleep( frame_len - (tick_end - tick_start) ); + Sleep( frame_len - (tick_end - tick_start) + 1); } } SetEvent(ddraw->render.ev); } + timeEndPeriod(1); HeapFree(GetProcessHeap(), 0, bmi);