summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/strife/d_main.c45
-rw-r--r--src/v_video.c31
-rw-r--r--src/v_video.h7
3 files changed, 82 insertions, 1 deletions
diff --git a/src/strife/d_main.c b/src/strife/d_main.c
index c888438a..1bfaad65 100644
--- 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,6 +1107,45 @@ static void D_Endoom(void)
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
//
@@ -1568,7 +1608,7 @@ void D_DoomMain (void)
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.
@@ -1744,6 +1784,9 @@ void D_DoomMain (void)
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 ();
diff --git a/src/v_video.c b/src/v_video.c
index 6549a81b..b6c621ba 100644
--- a/src/v_video.c
+++ b/src/v_video.c
@@ -54,6 +54,9 @@ static byte *dest_screen = NULL;
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 @@ void V_CopyRect(int srcx, int srcy, byte *source,
}
}
+//
+// 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 @@ void V_DrawPatch(int x, int y, patch_t *patch)
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
@@ -184,6 +208,13 @@ void V_DrawPatchFlipped(int x, int y, patch_t *patch)
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
diff --git a/src/v_video.h b/src/v_video.h
index 0c722478..f7952eaa 100644
--- a/src/v_video.h
+++ b/src/v_video.h
@@ -46,6 +46,13 @@ extern int dirtybox[4];
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);