ref: 0044cf8336b5a623b5a56a2827a938276363770e
parent: bc72291b8270486f7b608a569b9675ab63bd80fb
author: James Haley <haleyjd@hotmail.com>
date: Sun Aug 29 10:50:13 EDT 2010
Added patch clipping callback mechanism, since Strife needs to modify all the V_DrawPatch functions that it uses to return if the patch overlaps the edge of or is completely outside of the framebuffer. This could be extended to handle Final DOOM as well if it proves satisfactory. Subversion-branch: /branches/strife-branch Subversion-revision: 1972
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -65,6 +65,7 @@
#include "i_system.h"
#include "i_timer.h"
#include "i_video.h"
+#include "i_swap.h"
#include "g_game.h"
@@ -1106,7 +1107,46 @@
I_Endoom(endoom);
}
+//=============================================================================
//
+// haleyjd: Chocolate Strife Specifics
+//
+// None of the code in here is from the original executable, but is needed for
+// other reasons.
+
+//
+// D_PatchClipCallback
+//
+// haleyjd 08/28/10: Clip patches to the framebuffer without errors.
+// Returns false if V_DrawPatch should return without drawing.
+//
+static boolean D_PatchClipCallback(patch_t *patch, int x, int y)
+{
+ // note that offsets were already accounted for in V_DrawPatch
+ return (x >= 0 && y >= 0
+ && x + SHORT(patch->width) <= SCREENWIDTH
+ && y + SHORT(patch->height) <= SCREENHEIGHT);
+}
+
+//
+// D_InitChocoStrife
+//
+// haleyjd 08/28/10: Take care of some Strife-specific initialization
+// that is necessitated by Chocolate Doom issues, such as setting global
+// callbacks.
+//
+static void D_InitChocoStrife(void)
+{
+ // set the V_DrawPatch clipping callback
+ V_SetPatchClipCallback(D_PatchClipCallback);
+}
+
+//
+// End Chocolate Strife Specifics
+//
+//=============================================================================
+
+//
// D_DoomMain
//
void D_DoomMain (void)
@@ -1568,7 +1608,7 @@
SetSaveGameDir(iwadfile);
// Check for -file in shareware
- if (0 /*modifiedgame*/) // TEST
+ if (0 /*modifiedgame*/) // STRIFE-FIXME: DISABLED FOR TESTING
{
// These are the lumps that will be checked in IWAD,
// if any one is not present, execution will be aborted.
@@ -1743,6 +1783,9 @@
I_PrintStartupBanner(gamedescription);
PrintDehackedBanners();
+
+ // haleyjd 08/28/10: Init Choco Strife stuff.
+ D_InitChocoStrife();
printf (DEH_String("M_Init: Init miscellaneous info.\n"));
M_Init ();
--- a/src/v_video.c
+++ b/src/v_video.c
@@ -54,6 +54,9 @@
int dirtybox[4];
+// haleyjd 08/28/10: clipping callback function for patches.
+// This is needed for Chocolate Strife, which clips patches to the screen.
+static vpatchclipfunc_t patchclip_callback = NULL;
//
// V_MarkRect
@@ -108,6 +111,20 @@
}
}
+//
+// V_SetPatchClipCallback
+//
+// haleyjd 08/28/10: Added for Strife support.
+// By calling this function, you can setup runtime error checking for patch
+// clipping. Strife never caused errors by drawing patches partway off-screen.
+// Some versions of vanilla DOOM also behaved differently than the default
+// implementation, so this could possibly be extended to those as well for
+// accurate emulation.
+//
+void V_SetPatchClipCallback(vpatchclipfunc_t func)
+{
+ patchclip_callback = func;
+}
//
// V_DrawPatch
@@ -127,6 +144,13 @@
y -= SHORT(patch->topoffset);
x -= SHORT(patch->leftoffset);
+ // haleyjd 08/28/10: Strife needs silent error checking here.
+ if(patchclip_callback)
+ {
+ if(!patchclip_callback(patch, x, y))
+ return;
+ }
+
#ifdef RANGECHECK
if (x < 0
|| x + SHORT(patch->width) > SCREENWIDTH
@@ -183,6 +207,13 @@
y -= SHORT(patch->topoffset);
x -= SHORT(patch->leftoffset);
+
+ // haleyjd 08/28/10: Strife needs silent error checking here.
+ if(patchclip_callback)
+ {
+ if(!patchclip_callback(patch, x, y))
+ return;
+ }
#ifdef RANGECHECK
if (x < 0
--- a/src/v_video.h
+++ b/src/v_video.h
@@ -46,6 +46,13 @@
extern byte *tinttable;
+// haleyjd 08/28/10: implemented for Strife support
+// haleyjd 08/28/10: Patch clipping callback, implemented to support Choco
+// Strife.
+typedef boolean (*vpatchclipfunc_t)(patch_t *, int, int);
+void V_SetPatchClipCallback(vpatchclipfunc_t func);
+
+
// Allocates buffer screens, call before R_Init.
void V_Init (void);