shithub: choc

Download patch

ref: a64aec204b31884506af334bca9984c1183b442a
parent: 4963848a8f9324336450def14a119d60abdacb4e
author: Simon Howard <[email protected]>
date: Fri Sep 1 16:07:25 EDT 2006

Better spechits emulation. Remove support for emulating the higher-memory
spechits overruns, as they will overwrite pointers with garbage and crash
the game. Change the spechits base address to one from doom2.exe, which
seems to work better in more cases. Add -spechit command-line parameter
to allow the base address to be explicitly specified if necessary.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 592

--- a/src/p_map.c
+++ b/src/p_map.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: p_map.c 261 2006-01-07 19:16:39Z fraggle $
+// $Id: p_map.c 592 2006-09-01 20:07:25Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard, Andrey Budko
@@ -46,7 +46,7 @@
 //-----------------------------------------------------------------------------
 
 static const char
-rcsid[] = "$Id: p_map.c 261 2006-01-07 19:16:39Z fraggle $";
+rcsid[] = "$Id: p_map.c 592 2006-09-01 20:07:25Z fraggle $";
 
 #include <stdlib.h>
 
@@ -57,6 +57,7 @@
 #include "i_system.h"
 
 #include "doomdef.h"
+#include "m_argv.h"
 #include "p_local.h"
 
 #include "s_sound.h"
@@ -276,7 +277,7 @@
     if (ld->special)
     {
         // fraggle: spechits overrun emulation code from prboom-plus
-        if (numspechit >= MAXSPECIALCROSS_ORIGINAL)
+        if (numspechit > MAXSPECIALCROSS_ORIGINAL)
         {
             SpechitOverrun(ld);
         }
@@ -1390,8 +1391,41 @@
 
 static void SpechitOverrun(line_t *ld)
 {
-    int addr = 0x01C09C98 + (ld - lines) * 0x3E;
+    static unsigned int baseaddr = 0;
+    unsigned int addr;
+   
+    if (baseaddr == 0)
+    {
+        int p;
 
+        // This is the first time we have had an overrun.  Work out
+        // what base address we are going to use.
+        // Allow a spechit value to be specified on the command line.
+
+        p = M_CheckParm("-spechit");
+        
+        if (p > 0)
+        {
+            baseaddr = atoi(myargv[p+1]);
+        }
+        else
+        {
+            // This is from a post by myk on the Doomworld forums, 
+            // outputted from entryway's spechit_magic generator for
+            // s205n546.lmp.  The _exact_ value of this isn't too
+            // important; as long as it is in the right general
+            // range, it will usually work.  Otherwise, we can use
+            // the generator (hacked doom2.exe) and provide it 
+            // with -spechit.
+
+            baseaddr = 0x84f968e8;
+        }
+    }
+    
+    // Calculate address used in doom2.exe
+
+    addr = baseaddr + (ld - lines) * 0x3E;
+
     switch(numspechit)
     {
         case 9: 
@@ -1405,24 +1439,6 @@
             break;
         case 14: 
             nofit = addr; 
-            break;
-        case 15: 
-            bombsource = (mobj_t*)addr; 
-            break;
-        case 16: 
-            bombdamage = addr; 
-            break;
-        case 17: 
-            bombspot = (mobj_t*)addr; 
-            break;
-        case 18: 
-            usething = (mobj_t*)addr; 
-            break;
-        case 19: 
-            attackrange = addr; 
-            break;
-        case 20: 
-            la_damage = addr; 
             break;
         default:
             fprintf(stderr, "SpechitOverrun: Warning: unable to emulate"