ref: 157725a6018290484cb24f97a1df6ce3e8fb8ce2
parent: 0ef3690cb4508ebbfcc26bb9e227bcb2319d8729
author: Simon Howard <[email protected]>
date: Wed Sep 18 23:51:15 EDT 2013
Fix crash at Heretic E2 end screen (thanks Leitbild). Subversion-branch: /branches/v2-branch Subversion-revision: 2665
--- a/src/heretic/f_finale.c
+++ b/src/heretic/f_finale.c
@@ -29,6 +29,7 @@
#include "deh_str.h"
#include "i_swap.h"
#include "i_video.h"
+#include "i_scale.h"
#include "s_sound.h"
#include "v_video.h"
@@ -304,9 +305,16 @@
void F_DrawUnderwater(void)
{
- static boolean underwawa;
+ static boolean underwawa = false;
extern boolean askforquit;
+ char *lumpname;
+ byte *palette;
+ // The underwater screen has its own palette, which is rather annoying.
+ // The palette doesn't correspond to the normal palette. Because of
+ // this, we must regenerate the lookup tables used in the video scaling
+ // code.
+
switch (finalestage)
{
case 1:
@@ -313,8 +321,12 @@
if (!underwawa)
{
underwawa = true;
- memset((byte *) 0xa0000, 0, SCREENWIDTH * SCREENHEIGHT);
- I_SetPalette(W_CacheLumpName(DEH_String("E2PAL"), PU_CACHE));
+ V_DrawFilledBox(0, 0, SCREENWIDTH, SCREENHEIGHT, 0);
+ lumpname = DEH_String("E2PAL");
+ palette = W_CacheLumpName(lumpname, PU_STATIC);
+ I_SetPalette(palette);
+ I_ResetScaleTables(palette);
+ W_ReleaseLumpName(lumpname);
V_DrawRawScreen(W_CacheLumpName(DEH_String("E2END"), PU_CACHE));
}
paused = false;
@@ -323,6 +335,15 @@
break;
case 2:
+ if (underwawa)
+ {
+ lumpname = DEH_String("PLAYPAL");
+ palette = W_CacheLumpName(lumpname, PU_STATIC);
+ I_SetPalette(palette);
+ I_ResetScaleTables(palette);
+ W_ReleaseLumpName(lumpname);
+ underwawa = false;
+ }
V_DrawRawScreen(W_CacheLumpName(DEH_String("TITLE"), PU_CACHE));
//D_StartTitle(); // go to intro/demo mode.
}
--- a/src/i_scale.c
+++ b/src/i_scale.c
@@ -405,6 +405,32 @@
puts("");
}
+// Destroy the scaling lookup tables. This should only ever be called
+// if switching to a completely different palette from the normal one
+// (in which case the mappings no longer make any sense).
+
+void I_ResetScaleTables(byte *palette)
+{
+ if (stretch_tables[0] != NULL)
+ {
+ Z_Free(stretch_tables[0]);
+ Z_Free(stretch_tables[1]);
+
+ printf("I_ResetScaleTables: Regenerating lookup tables..\n");
+ stretch_tables[0] = GenerateStretchTable(palette, 20);
+ stretch_tables[1] = GenerateStretchTable(palette, 40);
+ }
+
+ if (half_stretch_table != NULL)
+ {
+ Z_Free(half_stretch_table);
+
+ printf("I_ResetScaleTables: Regenerating lookup table..");
+
+ half_stretch_table = GenerateStretchTable(palette, 50);
+ }
+}
+
//
// Aspect ratio correcting scale up functions.
--- a/src/i_scale.h
+++ b/src/i_scale.h
@@ -31,6 +31,7 @@
#include "doomtype.h"
void I_InitScale(byte *_src_buffer, byte *_dest_buffer, int _dest_pitch);
+void I_ResetScaleTables(byte *palette);
// Scaled modes (direct multiples of 320x200)