changeset 22:f1fb248bf997

Get rid of the swapping and legacy far etc. memory handling code.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 24 Sep 2011 13:03:13 +0300
parents 527056430be8
children ad9685c8cef1
files GNUmakefile src/checks.cc src/drawmap.cc src/editloop.cc src/editobj.cc src/gcolour1.cc src/gotoobj.cc src/l_align.cc src/l_misc.cc src/l_prop.cc src/l_unlink.cc src/levels.cc src/memory.cc src/mkpalette.cc src/objects.cc src/objinfo.cc src/pic2img.cc src/s_door.cc src/s_lift.cc src/s_merge.cc src/s_misc.cc src/s_prop.cc src/s_split.cc src/selrect.cc src/swapmem.cc src/v_merge.cc src/wads.cc src/wstructs.h src/x_hover.cc src/x_rotate.cc src/yadex.cc src/yadex.h src/ymemory.h
diffstat 33 files changed, 61 insertions(+), 679 deletions(-) [+]
line wrap: on
line diff
--- a/GNUmakefile	Sat Sep 24 12:43:19 2011 +0300
+++ b/GNUmakefile	Sat Sep 24 13:03:13 2011 +0300
@@ -159,7 +159,7 @@
 	s_misc		s_prop		s_slice		s_split		\
 	s_swapf		s_vertices	sanity		scrnshot	\
 	selbox		selectn		selpath		selrect		\
-	serialnum	spritdir	sticker		swapmem		\
+	serialnum	spritdir	sticker		\
 	t_centre	t_flags		t_prop		t_spin		\
 	textures	things		trace		v_centre	\
 	v_merge		v_polyg		vectext		verbmsg		\
--- a/src/checks.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/checks.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -241,14 +241,13 @@
 void CheckSectors () /* SWAP! */
 {
 int        s, n, sd;
-char huge *ends;
+char *ends;
 char       msg1[80], msg2[80];
 bool       first_time = true;
 
 CheckingObjects ();
 LogMessage ("\nVerifying Sectors...\n");
-ObjectsNeeded (OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
-ends = (char huge *) GetFarMemory (NumVertices);
+ends = (char *) GetMemory (NumVertices);
 for (s = 0; s < NumSectors; s++)
    {
    /* clear the "ends" array */
@@ -296,7 +295,7 @@
 	 }
       }
    }
-FreeFarMemory (ends);
+FreeMemory (ends);
 
 /*
    Note from RQ:
@@ -317,12 +316,10 @@
 /* now check if all SideDefs are facing a sidedef with the same Sector number */
 for (n = 0; n < NumLineDefs; n++)
    {
-   ObjectsNeeded (OBJ_LINEDEFS, 0);
    sd = LineDefs[n].sidedef1;
    if (sd >= 0)
       {
       s = GetOppositeSector (n, 1);
-      ObjectsNeeded (OBJ_SIDEDEFS, 0);
       if (s < 0 || SideDefs[sd].sector != s)
 	 {
 	 if (s < 0)
@@ -344,12 +341,10 @@
 	    }
 	 }
       }
-   ObjectsNeeded (OBJ_LINEDEFS, 0);
    sd = LineDefs[n].sidedef2;
    if (sd >= 0)
       {
       s = GetOppositeSector (n, 0);
-      ObjectsNeeded (OBJ_SIDEDEFS, 0);
       if (s < 0 || SideDefs[sd].sector != s)
 	 {
 	 if (s < 0)
@@ -388,7 +383,6 @@
 
 CheckingObjects ();
 LogMessage ("\nVerifying cross-references...\n");
-ObjectsNeeded (OBJ_LINEDEFS, 0);
 for (n = 0; n < NumLineDefs; n++)
    {
    /* Check for missing first sidedefs */
@@ -526,7 +520,6 @@
 			"Do you want to delete these unused Vertices?")))
    {
    DeleteObjects (OBJ_VERTICES, &cur);
-   ObjectsNeeded (OBJ_LINEDEFS, 0);
    }
 else
    ForgetSelection (&cur);
@@ -562,14 +555,10 @@
 /* unselect Sectors bound to a sidedef */
 for (n = 0; n < NumLineDefs; n++)
    {
-   ObjectsNeeded (OBJ_LINEDEFS, 0);
    m = LineDefs[n].sidedef1;
-   ObjectsNeeded (OBJ_SIDEDEFS, 0);
    if (cur && m >= 0 /* && SideDefs[m].sector >= 0 AYM 1998-06-13 */)
       UnSelectObject (&cur, SideDefs[m].sector);
-   ObjectsNeeded (OBJ_LINEDEFS, 0);
    m = LineDefs[n].sidedef2;
-   ObjectsNeeded (OBJ_SIDEDEFS, 0);
    if (cur && m >= 0 /* && SideDefs[m].sector >= 0 AYM 1998-06-13 */)
       UnSelectObject (&cur, SideDefs[m].sector);
    continue;
@@ -599,7 +588,6 @@
 
 CheckingObjects ();
 LogMessage ("\nVerifying textures...\n");
-ObjectsNeeded (OBJ_SECTORS, 0);
 for (n = 0; n < NumSectors; n++)
    {
    if (strcmp (Sectors[n].ceilt, "-") == 0
@@ -646,10 +634,8 @@
 
 for (n = 0; n < NumLineDefs; n++)
    {
-   ObjectsNeeded (OBJ_LINEDEFS, 0);
    sd1 = LineDefs[n].sidedef1;
    sd2 = LineDefs[n].sidedef2;
-   ObjectsNeeded (OBJ_SIDEDEFS, OBJ_SECTORS, 0);
    if (sd1 >= 0)
       s1 = SideDefs[sd1].sector;
    else
@@ -786,7 +772,6 @@
 if (! FindMasterDir (MasterDir, "F2_START"))
    NumThings--;
 
-ObjectsNeeded (OBJ_SECTORS, 0);
 for (n = 0; n < NumSectors; n++)
    {
    if (! is_flat_name_in_list (Sectors[n].ceilt))
@@ -814,7 +799,6 @@
       CheckingObjects ();
       }
    }
-ObjectsNeeded (OBJ_SIDEDEFS, 0);
 for (n = 0; n < NumSideDefs; n++)
    {
    if (! IsTextureNameInList (SideDefs[n].tex1, WTexture, NumWTexture))
@@ -871,7 +855,6 @@
 size_t dm = 0;
 int  t;
 
-ObjectsNeeded (OBJ_THINGS, 0);
 for (t = 0; t < NumThings; t++)
    {
    if (Things[t].type == THING_PLAYER1)
--- a/src/drawmap.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/drawmap.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -366,7 +366,6 @@
       int current_colour = INT_MIN;  /* Some impossible colour no. */
       int new_colour;
       
-      ObjectsNeeded (OBJ_LINEDEFS, OBJ_VERTICES, 0);
       for (int n = 0; n < NumLineDefs; n++)
       {
 	register int x1 = Vertices[LineDefs[n].start].x;
@@ -390,7 +389,6 @@
     }
 
     case OBJ_VERTICES:
-      ObjectsNeeded (OBJ_LINEDEFS, OBJ_VERTICES, 0);
       set_colour (LIGHTGREY);
       for (int n = 0; n < NumLineDefs; n++)
       {
@@ -412,7 +410,6 @@
       int current_colour = INT_MIN;  /* Some impossible colour no. */
       int new_colour;
 
-      ObjectsNeeded (OBJ_LINEDEFS, OBJ_VERTICES, 0);
       for (int n = 0; n < NumLineDefs; n++)
       {
 	register int x1 = Vertices[LineDefs[n].start].x;
--- a/src/editloop.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/editloop.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -1519,7 +1519,6 @@
 	       {
 	       int l, sd;
 
-	       ObjectsNeeded (OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
 	       NewSel = 0;
 	       for (l = 0; l < NumLineDefs; l++)
 	          {
@@ -1539,7 +1538,6 @@
 	    /* select all Vertices bound to the selected linedefs */
 	    else if (PrevMode == OBJ_LINEDEFS && e.obj_type == OBJ_VERTICES)
 	       {
-	       ObjectsNeeded (OBJ_LINEDEFS, 0);
 	       NewSel = 0;
 	       while (e.Selected)
 	          {
@@ -1556,7 +1554,6 @@
 	       {
 	       int l, sd;
 
-	       ObjectsNeeded (OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
 	       NewSel = 0;
 	       /* select all sectors... */
 	       for (l = 0; l < NumSectors; l++)
@@ -1580,7 +1577,6 @@
 	       {
 	       int l;
 
-	       ObjectsNeeded (OBJ_LINEDEFS, 0);
 	       NewSel = 0;
 	       for (l = 0; l < NumLineDefs; l++)
 		  if (IsSelected (e.Selected, LineDefs[l].start)
@@ -2042,7 +2038,6 @@
 	    int firstv;
             int obj_no = OBJ_NO_NONE;
 
-	    ObjectsNeeded (OBJ_LINEDEFS, 0);
 	    if (e.Selected->next->next)
 	       firstv = e.Selected->objnum;
 	    else
@@ -2101,7 +2096,6 @@
 	    add new sidedefs and one sector */
 	 else if (e.obj_type == OBJ_LINEDEFS && e.Selected)
 	    {
-	    ObjectsNeeded (OBJ_LINEDEFS, 0);
 	    for (cur = e.Selected; cur; cur = cur->next)
 	       if (LineDefs[cur->objnum].sidedef1 >= 0
 		&& LineDefs[cur->objnum].sidedef2 >= 0)
@@ -2123,7 +2117,6 @@
 		  {
 		  InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
 		  SideDefs[NumSideDefs - 1].sector = e.highlighted.num;
-		  ObjectsNeeded (OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
 		  if (LineDefs[cur->objnum].sidedef1 >= 0)
 		     {
 		     int s;
--- a/src/editobj.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/editobj.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -281,7 +281,6 @@
 SelPtr cur;
 int    subwin_y0;
 
-ObjectsNeeded (objtype, 0);
 if (! obj)
    return;
 switch (objtype)
@@ -516,7 +515,6 @@
 	    if (sector >= 0)
 	       SideDefs[NumSideDefs - 1].sector = sector;
 	    }
-	 ObjectsNeeded (OBJ_LINEDEFS, 0);
 	 if (sector >= 0)
 	    {
 	    LineDefs[NumLineDefs - 4].start = NumVertices - 4;
@@ -561,7 +559,6 @@
 	    if (sector >= 0)
 	       SideDefs[NumSideDefs - 1].sector = sector;
 	    }
-	 ObjectsNeeded (OBJ_LINEDEFS, 0);
 	 if (sector >= 0)
 	    {
 	    LineDefs[NumLineDefs - 1].start = NumVertices - 1;
@@ -592,7 +589,6 @@
 	 {
 	 if (a < 2)
 	    a = 2;
-	 ObjectsNeeded (OBJ_SECTORS, 0);
 	 n = Sectors[sector].ceilh;
 	 h = Sectors[sector].floorh;
 	 if (a * b < n - h)
@@ -621,7 +617,6 @@
 	    SideDefs[NumSideDefs - 1].sector = sector;
 	    InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
 
-	    ObjectsNeeded (OBJ_LINEDEFS, 0);
 	    LineDefs[NumLineDefs - 4].start = NumVertices - 4;
 	    LineDefs[NumLineDefs - 4].end = NumVertices - 3;
 	    LineDefs[NumLineDefs - 3].start = NumVertices - 3;
@@ -859,7 +854,6 @@
 	 SelPtr sdlist, cur;
 
 	 /* select all sidedefs */
-	 ObjectsNeeded (OBJ_LINEDEFS);
 	 sdlist = 0;
 	 for (cur = *list; cur; cur = cur->next)
 	    {
@@ -885,7 +879,6 @@
 	 SelPtr sdlist, cur;
 
 	 /* select all sidedefs */
-	 ObjectsNeeded (OBJ_LINEDEFS,0);
 	 sdlist = 0;
 	 for (cur = *list; cur; cur = cur->next)
 	    {
@@ -910,7 +903,6 @@
       if (objtype == OBJ_LINEDEFS)
 	 {
 	 SelPtr cur;
-	 ObjectsNeeded (OBJ_LINEDEFS, 0);
 	 for (cur = *list; cur; cur = cur->next)
 	    {
 	    struct LineDef *l = LineDefs + cur->objnum;
--- a/src/gcolour1.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/gcolour1.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -74,7 +74,7 @@
    playpalnum = 0;
    }
 
-dpal = (u8 *) GetFarMemory (3 * DOOM_COLOURS);
+dpal = (u8 *) GetMemory (3 * DOOM_COLOURS);
 dir->wadfile->seek (dir->dir.start);
 if (dir->wadfile->error ())
    {
@@ -130,7 +130,7 @@
 }
 
 #endif
-FreeFarMemory (dpal);
+FreeMemory (dpal);
 return game_colours;
 }
 
--- a/src/gotoobj.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/gotoobj.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -127,10 +127,8 @@
    Scale = oldscale;
    for (int n = 0; n < NumLineDefs; n++)
       {
-      ObjectsNeeded (OBJ_LINEDEFS, 0);
       sd1 = LineDefs[n].sidedef1;
       sd2 = LineDefs[n].sidedef2;
-      ObjectsNeeded (OBJ_SIDEDEFS, 0);
       if (sd1 >= 0 && SideDefs[sd1].sector == objid.num
 	|| sd2 >= 0 && SideDefs[sd2].sector == objid.num)
 	 {
--- a/src/l_align.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/l_align.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -49,7 +49,6 @@
 int otherside = OBJ_NO_NONE;
 
 /* find the sidedef on the other side of the LineDef, if any */
-ObjectsNeeded (OBJ_LINEDEFS, 0);
 for (l = 0; l < NumLineDefs; l++)
   {
   if (LineDefs[l].sidedef1 == sidedef)
@@ -64,7 +63,6 @@
     }
   }
 /* get the Sector number */
-ObjectsNeeded (OBJ_SIDEDEFS, 0);
 sector = SideDefs[sidedef].sector;
 /* if the upper texture is displayed,
    then the reference is taken from the other Sector */
@@ -73,14 +71,12 @@
   l = SideDefs[otherside].sector;
   if (l > 0)
     {
-    ObjectsNeeded (OBJ_SECTORS, 0);
     if (Sectors[l].ceilh < Sectors[sector].ceilh
      && Sectors[l].ceilh > Sectors[sector].floorh)
       sector = l;
     }
   }
 /* return the altitude of the ceiling */
-ObjectsNeeded (OBJ_SECTORS, 0);
 if (sector >= 0)
   return Sectors[sector].ceilh; /* textures are drawn from the ceiling down */
 else
@@ -110,7 +106,6 @@
 
 /* get the reference height from the first sidedef */
 refh = GetTextureRefHeight ((*sdlist)->objnum);
-ObjectsNeeded (OBJ_SIDEDEFS, 0);
 SideDefs[(*sdlist)->objnum].yoff = 0;
 UnSelectObject (sdlist, (*sdlist)->objnum);
 
@@ -118,7 +113,6 @@
 while (*sdlist)
   {
   h = GetTextureRefHeight ((*sdlist)->objnum);
-  ObjectsNeeded (OBJ_SIDEDEFS, 0);
   SideDefs[(*sdlist)->objnum].yoff = (refh - h) % 128;
   UnSelectObject (sdlist, (*sdlist)->objnum);
   }
@@ -259,8 +253,6 @@
     }
   }
 
-ObjectsNeeded (OBJ_SIDEDEFS, 0);
-
 /* get texture name of the sidedef in the *sdlist) */
 strncpy (texname, SideDefs[(*sdlist)->objnum].tex3, WAD_TEX_NAME);
 
@@ -338,7 +330,6 @@
    /* do we test for same textures for the sidedef in question?? */
    if (type_tex == 1)
      {
-     ObjectsNeeded (OBJ_SIDEDEFS, 0);
      if (strncmp (SideDefs[(*sdlist)->objnum].tex3, texname,WAD_TEX_NAME))
        {
        Beep ();
@@ -351,8 +342,6 @@
    sd1 = (*sdlist)->objnum;
    ldef = 0;
 
-   ObjectsNeeded (OBJ_LINEDEFS,0);
-
    /* find out which linedef holds that sidedef */
    if (type_sd == 1)
      {
@@ -391,7 +380,6 @@
 
    /* calculate length of linedef */
    vert2 = LineDefs[ldef].end;
-   ObjectsNeeded (OBJ_VERTICES, 0);
    length = ComputeDist (Vertices[vert2].x - Vertices[vert1].x,
 			 Vertices[vert2].y - Vertices[vert1].y);
 
--- a/src/l_misc.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/l_misc.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -48,7 +48,6 @@
 SelPtr cur;
 int    tmp;
 
-ObjectsNeeded ( OBJ_LINEDEFS, 0);
 for (cur = obj; cur; cur = cur->next)
 {
    if (swapvertices)
@@ -77,7 +76,6 @@
 SelPtr cur;
 int    vstart, vend;
 
-ObjectsNeeded ( OBJ_LINEDEFS, 0);
 for (cur = obj; cur; cur = cur->next)
   {
   vstart = LineDefs[cur->objnum].start;
@@ -108,7 +106,6 @@
 {
 SelPtr cur;
 
-ObjectsNeeded (OBJ_LINEDEFS, 0);
 for (cur = obj; cur; cur = cur->next)
   {
   int vstart, vend;
@@ -188,14 +185,12 @@
   if (sd >= 0)
     {
     InsertObject (OBJ_SIDEDEFS, sd, 0, 0);
-    ObjectsNeeded (OBJ_LINEDEFS, 0);
     LineDefs[NumLineDefs-1].sidedef1 = NumSideDefs - 1;
     }
   sd = LineDefs[linedefno].sidedef2;
   if (sd >= 0)
     {
     InsertObject (OBJ_SIDEDEFS, sd, 0, 0);
-    ObjectsNeeded (OBJ_LINEDEFS, 0);
     LineDefs[NumLineDefs-1].sidedef2 = NumSideDefs - 1;
     }
   }
@@ -210,7 +205,6 @@
 {
 SelPtr cur;
 
-ObjectsNeeded (OBJ_LINEDEFS, 0);
 for (cur = obj; cur; cur = cur->next)
   {
   VPtr vertex1 = Vertices + LineDefs[cur->objnum].start;
--- a/src/l_prop.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/l_prop.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -274,7 +274,6 @@
 
     // Edit or add the first sidedef
     case 2:
-      ObjectsNeeded (OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
       if (LineDefs[obj->objnum].sidedef1 >= 0)
       {
 	// Build a new selection list with the first sidedefs
@@ -319,7 +318,6 @@
 	    if (LineDefs[cur->objnum].sidedef1 == -1)
 	    {
 	      InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
-	      ObjectsNeeded (OBJ_LINEDEFS, 0);
 	      LineDefs[cur->objnum].sidedef1 = NumSideDefs - 1;
 	    }
 	    else if (LineDefs[cur->objnum].sidedef2 == -1)
@@ -328,7 +326,6 @@
 	      InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
 	      strncpy (SideDefs[NumSideDefs - 1].tex3, "-", WAD_TEX_NAME);
 	      strncpy (SideDefs[n].tex3, "-", WAD_TEX_NAME);
-	      ObjectsNeeded (OBJ_LINEDEFS, 0);
 	      LineDefs[cur->objnum].sidedef2 = NumSideDefs - 1;
 	      LineDefs[cur->objnum].flags ^= 4;  // Set the 2S bit
 	      LineDefs[cur->objnum].flags &= ~1;  // Clear the Im bit
@@ -336,7 +333,6 @@
 	  break;
 	}
       }
-      ObjectsNeeded (OBJ_SIDEDEFS, 0);
       for (n = 0; n < 7; n++)
 	menustr[n] = (char *) GetMemory (60);
       sprintf (menustr[6], "Edit sidedef #%d", sdlist->objnum);
@@ -368,10 +364,8 @@
       {
 	case 1:
 	  strncpy (texname, SideDefs[sdlist->objnum].tex3, WAD_TEX_NAME);
-	  ObjectsNeeded (0);
 	  ChooseWallTexture (x0 + 84, subsubwin_y0 ,
 	    "Choose a wall texture", NumWTexture, WTexture, texname);
-	  ObjectsNeeded (OBJ_SIDEDEFS, 0);
 	  if (strlen (texname) > 0)
 	  {
 	    for (cur = sdlist; cur; cur = cur->next)
@@ -383,10 +377,8 @@
 
 	case 2:
 	  strncpy (texname, SideDefs[sdlist->objnum].tex1, WAD_TEX_NAME);
-	  ObjectsNeeded (0);
 	  ChooseWallTexture (x0 + 84, subsubwin_y0,
 	     "Choose a wall texture", NumWTexture, WTexture, texname);
-	  ObjectsNeeded (OBJ_SIDEDEFS, 0);
 	  if (strlen (texname) > 0)
 	  {
 	    for (cur = sdlist; cur; cur = cur->next)
@@ -398,10 +390,8 @@
 
 	case 3:
 	  strncpy (texname, SideDefs[sdlist->objnum].tex2, WAD_TEX_NAME);
-	  ObjectsNeeded (0);
 	  ChooseWallTexture (x0 + 84, subsubwin_y0,
 	    "Choose a wall texture", NumWTexture, WTexture, texname);
-	  ObjectsNeeded (OBJ_SIDEDEFS, 0);
 	  if (strlen (texname) > 0)
 	  {
 	    for (cur = sdlist; cur; cur = cur->next)
--- a/src/l_unlink.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/l_unlink.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -61,8 +61,6 @@
 SelPtr cur;
 int n;
 
-ObjectsNeeded (OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
-
 // Put in sd_used_in a list of all sidedefs
 // that are used by linedefs in <linedefs>.
 // and in sd_used_out a list of all sidedefs
--- a/src/levels.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/levels.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -149,9 +149,6 @@
 MDirPtr dir;
 int OldNumVertices;
 
-/* No objects are needed: they may be swapped after they have been read */
-ObjectsNeeded (0);
-
 /* Find the various level information from the master directory */
 DisplayMessage (-1, -1, "Reading data for level %s...", levelname);
 Level = FindMasterDir (MasterDir, levelname);
@@ -224,7 +221,7 @@
 things_types++;
 if (NumThings > 0)
    {
-   Things = (TPtr) GetFarMemory ((unsigned long) NumThings
+   Things = (TPtr) GetMemory ((unsigned long) NumThings
       * sizeof (struct Thing));
    const Wad_file *wf = dir->wadfile;
    wf->seek (offset);
@@ -300,7 +297,7 @@
       }
    if (NumLineDefs > 0)
       {
-      LineDefs = (LDPtr) GetFarMemory ((unsigned long) NumLineDefs
+      LineDefs = (LDPtr) GetMemory ((unsigned long) NumLineDefs
 	 * sizeof (struct LineDef));
       const Wad_file *wf = dir->wadfile;
       wf->seek (dir->dir.start);
@@ -365,7 +362,7 @@
    NumSideDefs = 0;
 if (NumSideDefs > 0)
    {
-   SideDefs = (SDPtr) GetFarMemory ((unsigned long) NumSideDefs
+   SideDefs = (SDPtr) GetMemory ((unsigned long) NumSideDefs
       * sizeof (struct SideDef));
    const Wad_file *wf = dir->wadfile;
    wf->seek (dir->dir.start);
@@ -444,9 +441,9 @@
       const size_t nlines = dir->dir.size / 36;
       NumLineDefs = nlines;
       NumSideDefs = 2 * nlines;  // Worst case. We'll adjust later.
-      LineDefs = (LDPtr) GetFarMemory ((unsigned long) NumLineDefs
+      LineDefs = (LDPtr) GetMemory ((unsigned long) NumLineDefs
 	 * sizeof (struct LineDef));
-      SideDefs = (SDPtr) GetFarMemory ((unsigned long) NumSideDefs
+      SideDefs = (SDPtr) GetMemory ((unsigned long) NumSideDefs
 	 * sizeof (struct SideDef));
       // Read TEXTURES
       if (yg_texture_format != YGTF_NAMELESS)
@@ -588,7 +585,7 @@
       if ((size_t) NumSideDefs > s)  // Almost always true.
          {
 	 NumSideDefs = s;
-         SideDefs = (SDPtr) ResizeFarMemory (SideDefs,
+         SideDefs = (SDPtr) ResizeMemory (SideDefs,
 	     (unsigned long) NumSideDefs * sizeof (struct SideDef));
          }
       if (tex_list)
@@ -669,7 +666,7 @@
 if (NumVertices > 0)
    {
    const char *lump_name = "BUG";
-   Vertices = (VPtr) GetFarMemory ((unsigned long) NumVertices
+   Vertices = (VPtr) GetMemory ((unsigned long) NumVertices
       * sizeof (struct Vertex));
    if (yg_level_format == YGLF_ALPHA)  // Doom alpha
       lump_name = "POINTS";
@@ -739,7 +736,7 @@
       NumSectors = 0;
    if (NumSectors > 0)
       {
-      Sectors = (SPtr) GetFarMemory ((unsigned long) NumSectors
+      Sectors = (SPtr) GetMemory ((unsigned long) NumSectors
 	 * sizeof (struct Sector));
       const Wad_file *wf = dir->wadfile;
       wf->seek (dir->dir.start);
@@ -800,7 +797,7 @@
       nsectors = 0;
       }
    NumSectors = nsectors;
-   Sectors = (SPtr) GetFarMemory ((unsigned long) NumSectors
+   Sectors = (SPtr) GetMemory ((unsigned long) NumSectors
       * sizeof (struct Sector));
    offset_table = new i32[nsectors];
    for (size_t n = 0; n < (size_t) nsectors; n++)
@@ -942,42 +939,36 @@
 void ForgetLevelData () /* SWAP! */
 {
 /* forget the things */
-ObjectsNeeded (OBJ_THINGS, 0);
 NumThings = 0;
 if (Things != 0)
-   FreeFarMemory (Things);
+   FreeMemory (Things);
 Things = 0;
 things_angles++;
 things_types++;
 
 /* forget the vertices */
-ObjectsNeeded (OBJ_VERTICES, 0);
 NumVertices = 0;
 if (Vertices != 0)
-   FreeFarMemory (Vertices);
+   FreeMemory (Vertices);
 Vertices = 0;
 
 /* forget the linedefs */
-ObjectsNeeded (OBJ_LINEDEFS, 0);
 NumLineDefs = 0;
 if (LineDefs != 0)
-   FreeFarMemory (LineDefs);
+   FreeMemory (LineDefs);
 LineDefs = 0;
 
 /* forget the sidedefs */
-ObjectsNeeded (OBJ_SIDEDEFS, 0);
 NumSideDefs = 0;
 if (SideDefs != 0)
-   FreeFarMemory (SideDefs);
+   FreeMemory (SideDefs);
 SideDefs = 0;
 
 /* forget the sectors */
-ObjectsNeeded (OBJ_SECTORS, 0);
 NumSectors = 0;
 if (Sectors != 0)
-   FreeFarMemory (Sectors);
+   FreeMemory (Sectors);
 Sectors = 0;
-ObjectsNeeded (0);
 }
 
 
@@ -1064,7 +1055,6 @@
 // Write the THINGS lump
 l = WAD_LL_THINGS;
 lump_offset[l] = ftell (file);
-ObjectsNeeded (OBJ_THINGS, 0);
 for (n = 0; n < NumThings; n++)
    {
    file_write_i16 (file, Things[n].xpos );
@@ -1080,7 +1070,6 @@
 // Write the LINEDEFS lump
 l = WAD_LL_LINEDEFS;
 lump_offset[WAD_LL_LINEDEFS] = ftell (file);
-ObjectsNeeded (OBJ_LINEDEFS, 0);
 for (n = 0; n < NumLineDefs; n++)
    {
    file_write_i16 (file, LineDefs[n].start   );
@@ -1098,7 +1087,6 @@
 // Write the SIDEDEFS lump
 l = WAD_LL_SIDEDEFS;
 lump_offset[l] = ftell (file);
-ObjectsNeeded (OBJ_SIDEDEFS, 0);
 for (n = 0; n < NumSideDefs; n++)
    {
    file_write_i16 (file, SideDefs[n].xoff);
@@ -1118,7 +1106,6 @@
 if (reuse_nodes)
    {
    /* Copy the vertices */
-   ObjectsNeeded (0);
    const Wad_file *wf = dir->wadfile;
    wf->seek (dir->dir.start);
    if (wf->error ())
@@ -1130,7 +1117,6 @@
 else
    {
    /* Write the vertices */
-   ObjectsNeeded (OBJ_VERTICES, 0);
    for (n = 0; n < NumVertices; n++)
       {
       file_write_i16 (file, Vertices[n].x);
@@ -1169,7 +1155,6 @@
 // Write the SECTORS lump
 l = WAD_LL_SECTORS;
 lump_offset[l] = ftell (file);
-ObjectsNeeded (OBJ_SECTORS, 0);
 for (n = 0; n < NumSectors; n++)
    {
    file_write_i16 (file, Sectors[n].floorh);
@@ -1190,7 +1175,6 @@
 if (reuse_nodes)
    {
    /* Copy the REJECT data */
-   ObjectsNeeded (0);
    const Wad_file *wf = dir->wadfile;
    wf->seek (dir->dir.start);
    if (wf->error ())
@@ -1208,7 +1192,6 @@
 lump_offset[l] = ftell (file);
 if (reuse_nodes)
    {
-   ObjectsNeeded (0);
    const Wad_file *wf = dir->wadfile;
    wf->seek (dir->dir.start);
    if (wf->error ())
@@ -1262,7 +1245,6 @@
    remind_to_build_nodes = 1;
 MadeChanges = 0;
 MadeMapChanges = 0;
-ObjectsNeeded (0);
 
 /* Update pointers in Master Directory */
 OpenPatchWad (outfile);
@@ -1272,7 +1254,6 @@
 
 /* Update MapMinX, MapMinY, MapMaxX, MapMaxY */
 // Probably not necessary anymore -- AYM 1999-04-05
-ObjectsNeeded (OBJ_VERTICES, 0);
 update_level_bounds ();
 return 0;
 }
--- a/src/memory.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/memory.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -68,7 +68,6 @@
 if (!ret)
    {
    /* retry after having freed some memory, if possible */
-   FreeSomeMemory ();
    ret = malloc ((size_t) size);
    }
 if (!ret)
@@ -96,7 +95,6 @@
 ret = realloc (old, (size_t) size);
 if (!ret)
    {
-   FreeSomeMemory ();
    ret = realloc (old, (size_t) size);
    }
 if (!ret)
@@ -117,65 +115,4 @@
 }
 
 
-/*
-   allocate memory from the far heap with error checking
-*/
-
-void huge *GetFarMemory (unsigned long size)
-{
-void huge *ret;
-
-/* limit fragmentation on large blocks */
-if (size >= SIZE_THRESHOLD)
-   size = (size +  SIZE_OF_BLOCK) & ~SIZE_OF_BLOCK;
-ret = farmalloc (size);
-if (!ret)
-   {
-   /* retry after having freed some memory, if possible */
-   FreeSomeMemory ();
-   ret = farmalloc (size);
-   }
-if (!ret)
-   fatal_error ("out of memory (cannot allocate %lu far bytes)", size);
-return ret;
-}
-
-
-
-/*
-   reallocate memory from the far heap with error checking
-*/
-
-void huge *ResizeFarMemory (void huge *old, unsigned long size)
-{
-void huge *ret;
-
-/* limit fragmentation on large blocks */
-if (size >= SIZE_THRESHOLD)
-   size = (size + SIZE_OF_BLOCK) & ~SIZE_OF_BLOCK;
-ret = farrealloc (old, size);
-if (!ret)
-   {
-   FreeSomeMemory ();
-   ret = farrealloc (old, size);
-   }
-if (!ret)
-   fatal_error ("out of memory (cannot reallocate %lu far bytes)", size);
-return ret;
-}
-
-
-
-/*
-   free memory from the far heap
-*/
-
-void FreeFarMemory (void huge *ptr)
-{
-/* just a wrapper around farfree(), but provide an entry point */
-/* for memory debugging routines... */
-farfree (ptr);
-}
-
-
 /* end of file */
--- a/src/mkpalette.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/mkpalette.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -75,7 +75,7 @@
      "GIMP Palette\n"
      "# Generated by Yadex %s\n", yadex_version);
 
-  dpal = (u8 *) GetFarMemory (3 * DOOM_COLOURS);
+  dpal = (u8 *) GetMemory (3 * DOOM_COLOURS);
   const Wad_file *wf = dir->wadfile;
   wf->seek (dir->dir.start + (long) playpalnum * 3 * DOOM_COLOURS);
   if (wf->error ())
@@ -104,7 +104,7 @@
 
   byebye:
   if (dpal != 0)
-    FreeFarMemory (dpal);
+    FreeMemory (dpal);
   if (output_fp != 0)
     if (fclose (output_fp))
       return 1;
@@ -163,7 +163,7 @@
   int rect_w = width / columns;
   int rect_h = height / (DOOM_COLOURS / columns);
 
-  dpal = (u8 *) GetFarMemory (3 * DOOM_COLOURS);
+  dpal = (u8 *) GetMemory (3 * DOOM_COLOURS);
   const Wad_file *wf = dir->wadfile;
   wf->seek (dir->dir.start + (long) playpalnum * 3 * DOOM_COLOURS);
   if (wf->error ())
@@ -200,7 +200,7 @@
 
   byebye:
   if (dpal != 0)
-    FreeFarMemory (dpal);
+    FreeMemory (dpal);
   if (output_fp != 0)
     if (fclose (output_fp))
       return 1;
@@ -254,7 +254,7 @@
   fnewline (output_fp);
   fputs ("255\n", output_fp);  // Always \n (must be a single character)
 
-  dpal = (u8 *) GetFarMemory (3 * DOOM_COLOURS);
+  dpal = (u8 *) GetMemory (3 * DOOM_COLOURS);
   const Wad_file *wf = dir->wadfile;
   wf->seek (dir->dir.start + (long) playpalnum * 3 * DOOM_COLOURS);
   if (wf->error ())
@@ -280,7 +280,7 @@
 
   byebye:
   if (dpal != 0)
-    FreeFarMemory (dpal);
+    FreeMemory (dpal);
   if (output_fp != 0)
     if (fclose (output_fp))
       return 1;
--- a/src/objects.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/objects.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -90,7 +90,6 @@
 switch (objtype)
    {
    case OBJ_THINGS:
-      ObjectsNeeded (OBJ_THINGS, 0);
       m = (get_thing_radius (Things[objnum].type) * 3) / 2;
       DrawMapLine (Things[objnum].xpos - m, Things[objnum].ypos - m,
 		   Things[objnum].xpos - m, Things[objnum].ypos + m);
@@ -105,7 +104,6 @@
       break;
 
    case OBJ_LINEDEFS:
-      ObjectsNeeded (OBJ_LINEDEFS, OBJ_VERTICES, 0);
       n = (Vertices[LineDefs[objnum].start].x
 	 + Vertices[LineDefs[objnum].end].x) / 2;
       m = (Vertices[LineDefs[objnum].start].y
@@ -129,7 +127,6 @@
       break;
 
    case OBJ_VERTICES:
-      ObjectsNeeded (OBJ_VERTICES, 0);
       {
       int r = vertex_radius (Scale) * 3 / 2;
       int scrx0 = SCREENX (Vertices[objnum].x) - r;
@@ -145,7 +142,6 @@
 
    case OBJ_SECTORS:
       {
-      ObjectsNeeded (OBJ_LINEDEFS, OBJ_SIDEDEFS, OBJ_VERTICES, 0);
       SetLineThickness (1);
       const int mapx0 = MAPX (0);
       const int mapy0 = MAPY (ScrMaxY);
@@ -208,7 +204,6 @@
 switch (objtype)
    {
    case OBJ_THINGS:
-      ObjectsNeeded (OBJ_THINGS, 0);
       if (*list)
 	 {
 	 things_angles++;
@@ -228,12 +223,12 @@
 	    {
 	    for (n = objnum; n < NumThings; n++)
 	       Things[n] = Things[n + 1];
-	    Things = (TPtr) ResizeFarMemory (Things,
+	    Things = (TPtr) ResizeMemory (Things,
 	       NumThings * sizeof (struct Thing));
 	    }
 	 else
 	    {
-	    FreeFarMemory (Things);
+	    FreeMemory (Things);
 	    Things = 0;
 	    }
 	 for (cur = (*list)->next; cur; cur = cur->next)
@@ -256,7 +251,6 @@
 	    goto next_vertex;
 	 }
 	 // Delete the linedefs bound to this vertex and change the references
-	 ObjectsNeeded (OBJ_LINEDEFS, 0);
 	 for (n = 0; n < NumLineDefs; n++)
 	    {
 	    if (LineDefs[n].start == objnum || LineDefs[n].end == objnum)
@@ -270,18 +264,17 @@
 	       }
 	    }
 	 // Delete the vertex
-	 ObjectsNeeded (OBJ_VERTICES, 0);
 	 NumVertices--;
 	 if (NumVertices > 0)
 	    {
 	    for (n = objnum; n < NumVertices; n++)
 	       Vertices[n] = Vertices[n + 1];
-	    Vertices = (VPtr) ResizeFarMemory (Vertices,
+	    Vertices = (VPtr) ResizeMemory (Vertices,
 	      NumVertices * sizeof (struct Vertex));
 	    }
 	 else
 	    {
-	    FreeFarMemory (Vertices);
+	    FreeMemory (Vertices);
 	    Vertices = 0;
 	    }
 	 for (cur = (*list)->next; cur; cur = cur->next)
@@ -306,7 +299,6 @@
          take care of that. */
       while (*list)
 	 {
-	 ObjectsNeeded (OBJ_LINEDEFS, 0);
 	 objnum = (*list)->objnum;
 	 if (objnum < 0 || objnum >= NumLineDefs)  // Paranoia
 	 {
@@ -319,12 +311,12 @@
 	    {
 	    for (n = objnum; n < NumLineDefs; n++)
 	       LineDefs[n] = LineDefs[n + 1];
-	    LineDefs = (LDPtr) ResizeFarMemory (LineDefs,
+	    LineDefs = (LDPtr) ResizeMemory (LineDefs,
 	      NumLineDefs * sizeof (struct LineDef));
 	    }
 	 else
 	    {
-	    FreeFarMemory (LineDefs);
+	    FreeMemory (LineDefs);
 	    LineDefs = 0;
 	    }
 	 for (cur = (*list)->next; cur; cur = cur->next)
@@ -347,7 +339,6 @@
 	    goto next_sidedef;
 	 }
 	 /* change the linedefs references */
-	 ObjectsNeeded (OBJ_LINEDEFS, 0);
 	 for (n = 0; n < NumLineDefs; n++)
 	    {
 	    if (LineDefs[n].sidedef1 == objnum)
@@ -360,18 +351,17 @@
 	       LineDefs[n].sidedef2--;
 	    }
 	 /* delete the sidedef */
-	 ObjectsNeeded (OBJ_SIDEDEFS, 0);
 	 NumSideDefs--;
 	 if (NumSideDefs > 0)
 	    {
 	    for (n = objnum; n < NumSideDefs; n++)
 	       SideDefs[n] = SideDefs[n + 1];
-	    SideDefs = (SDPtr) ResizeFarMemory (SideDefs,
+	    SideDefs = (SDPtr) ResizeMemory (SideDefs,
 	       NumSideDefs * sizeof (struct SideDef));
 	    }
 	 else
 	    {
-	    FreeFarMemory (SideDefs);
+	    FreeMemory (SideDefs);
 	    SideDefs = 0;
 	    }
 	 for (cur = (*list)->next; cur; cur = cur->next)
@@ -392,25 +382,23 @@
 	 }
 	// Delete the sidedefs bound to this sector and change the references
 	// AYM 19980203: Hmm, hope this is OK with multiply used sidedefs...
-	ObjectsNeeded (OBJ_SIDEDEFS, 0);
 	for (n = 0; n < NumSideDefs; n++)
 	   if (SideDefs[n].sector == objnum)
 	      DeleteObject (Objid (OBJ_SIDEDEFS, n--));
 	   else if (SideDefs[n].sector >= objnum)
 	      SideDefs[n].sector--;
 	/* delete the sector */
-	ObjectsNeeded (OBJ_SECTORS, 0);
 	NumSectors--;
 	if (NumSectors > 0)
 	   {
 	   for (n = objnum; n < NumSectors; n++)
 	      Sectors[n] = Sectors[n + 1];
-	   Sectors = (SPtr) ResizeFarMemory (Sectors,
+	   Sectors = (SPtr) ResizeMemory (Sectors,
 	      NumSectors * sizeof (struct Sector));
 	   }
 	else
 	   {
-	   FreeFarMemory (Sectors);
+	   FreeMemory (Sectors);
 	   Sectors = 0;
 	   }
 	for (cur = (*list)->next; cur; cur = cur->next)
@@ -445,17 +433,16 @@
 {
 int last;
 
-ObjectsNeeded (objtype, 0);
 MadeChanges = 1;
 switch (objtype)
    {
    case OBJ_THINGS:
       last = NumThings++;
       if (last > 0)
-	 Things = (TPtr) ResizeFarMemory (Things,
+	 Things = (TPtr) ResizeMemory (Things,
 	   (unsigned long) NumThings * sizeof (struct Thing));
       else
-	 Things = (TPtr) GetFarMemory (sizeof (struct Thing));
+	 Things = (TPtr) GetMemory (sizeof (struct Thing));
       Things[last].xpos = xpos;
       Things[last].ypos = ypos;
       things_angles++;
@@ -477,10 +464,10 @@
    case OBJ_VERTICES:
       last = NumVertices++;
       if (last > 0)
-	 Vertices = (VPtr) ResizeFarMemory (Vertices,
+	 Vertices = (VPtr) ResizeMemory (Vertices,
 	   (unsigned long) NumVertices * sizeof (struct Vertex));
       else
-	 Vertices = (VPtr) GetFarMemory (sizeof (struct Vertex));
+	 Vertices = (VPtr) GetMemory (sizeof (struct Vertex));
       Vertices[last].x = xpos;
       Vertices[last].y = ypos;
       if (Vertices[last].x < MapMinX)
@@ -497,10 +484,10 @@
    case OBJ_LINEDEFS:
       last = NumLineDefs++;
       if (last > 0)
-	 LineDefs = (LDPtr) ResizeFarMemory (LineDefs,
+	 LineDefs = (LDPtr) ResizeMemory (LineDefs,
 	   (unsigned long) NumLineDefs * sizeof (struct LineDef));
       else
-	 LineDefs = (LDPtr) GetFarMemory (sizeof (struct LineDef));
+	 LineDefs = (LDPtr) GetMemory (sizeof (struct LineDef));
       if (is_obj (copyfrom))
 	 {
 	 LineDefs[last].start = LineDefs[copyfrom].start;
@@ -524,10 +511,10 @@
    case OBJ_SIDEDEFS:
       last = NumSideDefs++;
       if (last > 0)
-	 SideDefs = (SDPtr) ResizeFarMemory (SideDefs,
+	 SideDefs = (SDPtr) ResizeMemory (SideDefs,
 	   (unsigned long) NumSideDefs * sizeof (struct SideDef));
       else
-	 SideDefs = (SDPtr) GetFarMemory (sizeof (struct SideDef));
+	 SideDefs = (SDPtr) GetMemory (sizeof (struct SideDef));
       if (is_obj (copyfrom))
 	 {
 	 SideDefs[last].xoff = SideDefs[copyfrom].xoff;
@@ -552,10 +539,10 @@
    case OBJ_SECTORS:
       last = NumSectors++;
       if (last > 0)
-	 Sectors = (SPtr) ResizeFarMemory (Sectors,
+	 Sectors = (SPtr) ResizeMemory (Sectors,
 			  (unsigned long) NumSectors * sizeof (struct Sector));
       else
-	 Sectors = (SPtr) GetFarMemory (sizeof (struct Sector));
+	 Sectors = (SPtr) GetMemory (sizeof (struct Sector));
       if (is_obj (copyfrom))
 	 {
 	 Sectors[last].floorh  = Sectors[copyfrom].floorh;
@@ -643,7 +630,6 @@
 int bestld, bestdist, bestmdist;
 
 /* get the coords for this LineDef */
-ObjectsNeeded (OBJ_LINEDEFS, OBJ_VERTICES, 0);
 x0  = Vertices[LineDefs[ld1].start].x;
 y0  = Vertices[LineDefs[ld1].start].y;
 dx0 = Vertices[LineDefs[ld1].end].x - x0;
@@ -791,7 +777,6 @@
    return -1;
 
 /* OK, we got it -- return the Sector number */
-ObjectsNeeded (OBJ_SIDEDEFS, 0);
 return SideDefs[x0].sector;
 }
 
@@ -809,7 +794,7 @@
 
 if (! obj)
    return;
-ObjectsNeeded (objtype, 0);
+
 /* copy the object(s) */
 switch (objtype)
    {
@@ -888,7 +873,6 @@
 
       // Create the vertices
       CopyObjects (OBJ_VERTICES, list2);
-      ObjectsNeeded (OBJ_LINEDEFS, 0);
 
       // Update the references to the vertices
       for (ref1 = list1, ref2 = list2;
@@ -908,7 +892,6 @@
       break;
 
    case OBJ_SECTORS:
-      ObjectsNeeded (OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
       list1 = 0;
       list2 = 0;
       // Create the linedefs (and vertices)
@@ -927,7 +910,6 @@
 	 }
       CopyObjects (OBJ_LINEDEFS, list2);
       /* create the sidedefs */
-      ObjectsNeeded (OBJ_LINEDEFS, 0);
       for (ref1 = list1, ref2 = list2;
 	   ref1 && ref2;
 	   ref1 = ref1->next, ref2 = ref2->next)
@@ -936,14 +918,12 @@
 	    {
 	    InsertObject (OBJ_SIDEDEFS, n, 0, 0);
 	    n = NumSideDefs - 1;
-	    ObjectsNeeded (OBJ_LINEDEFS, 0);
 	    LineDefs[ref2->objnum].sidedef1 = n;
 	    }
 	 if ((m = LineDefs[ref1->objnum].sidedef2) >= 0)
 	    {
 	    InsertObject (OBJ_SIDEDEFS, m, 0, 0);
 	    m = NumSideDefs - 1;
-	    ObjectsNeeded (OBJ_LINEDEFS, 0);
 	    LineDefs[ref2->objnum].sidedef2 = m;
 	    }
 	 ref1->objnum = n;
@@ -953,7 +933,6 @@
       for (cur = obj; cur; cur = cur->next)
 	 {
 	 InsertObject (OBJ_SECTORS, cur->objnum, 0, 0);
-	 ObjectsNeeded (OBJ_SIDEDEFS, 0);
 	 for (ref1 = list1, ref2 = list2;
 	      ref1 && ref2;
 	      ref1 = ref1->next, ref2 = ref2->next)
@@ -999,7 +978,6 @@
 SelPtr     cur, vertices;
 static int refx, refy; /* previous position */
 
-ObjectsNeeded (objtype, 0);
 if (grid > 0)
    {
    newx = (newx + grid / 2) & ~(grid - 1);
@@ -1054,7 +1032,6 @@
       break;
 
    case OBJ_SECTORS:
-      ObjectsNeeded (OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
       vertices = list_vertices_of_sectors (obj);
       MoveObjectsToCoords (OBJ_VERTICES, vertices, newx, newy, grid);
       ForgetSelection (&vertices);
@@ -1083,7 +1060,6 @@
 	 *ypos = 0;
 	 return;
 	 }
-      ObjectsNeeded (OBJ_THINGS, 0);
       *xpos = Things[objnum].xpos;
       *ypos = Things[objnum].ypos;
       break;
@@ -1096,7 +1072,6 @@
 	 *ypos = 0;
 	 return;
 	 }
-      ObjectsNeeded (OBJ_VERTICES, 0);
       *xpos = Vertices[objnum].x;
       *ypos = Vertices[objnum].y;
       break;
@@ -1109,10 +1084,8 @@
 	 *ypos = 0;
 	 return;
 	 }
-      ObjectsNeeded (OBJ_LINEDEFS, 0);
       v1 = LineDefs[objnum].start;
       v2 = LineDefs[objnum].end;
-      ObjectsNeeded (OBJ_VERTICES, 0);
       *xpos = (Vertices[v1].x + Vertices[v2].x) / 2;
       *ypos = (Vertices[v1].y + Vertices[v2].y) / 2;
       break;
@@ -1125,13 +1098,11 @@
 	 *ypos = 0;
 	 return;
 	 }
-      ObjectsNeeded (OBJ_LINEDEFS, 0);
       for (n = 0; n < NumLineDefs; n++)
 	 if (LineDefs[n].sidedef1 == objnum || LineDefs[n].sidedef2 == objnum)
 	    {
 	    v1 = LineDefs[n].start;
 	    v2 = LineDefs[n].end;
-	    ObjectsNeeded (OBJ_VERTICES, 0);
 	    *xpos = (Vertices[v1].x + Vertices[v2].x) / 2;
 	    *ypos = (Vertices[v1].y + Vertices[v2].y) / 2;
 	    return;
@@ -1153,16 +1124,13 @@
       num = 0L;
       for (n = 0; n < NumLineDefs; n++)
 	 {
-	 ObjectsNeeded (OBJ_LINEDEFS, 0);
 	 sd1 = LineDefs[n].sidedef1;
 	 sd2 = LineDefs[n].sidedef2;
 	 v1 = LineDefs[n].start;
 	 v2 = LineDefs[n].end;
-	 ObjectsNeeded (OBJ_SIDEDEFS, 0);
 	 if ((sd1 >= 0 && SideDefs[sd1].sector == objnum)
 	       || (sd2 >= 0 && SideDefs[sd2].sector == objnum))
 	    {
-	    ObjectsNeeded (OBJ_VERTICES, 0);
 	    /* if the Sector is closed, all Vertices will be counted twice */
 	    accx += (long) Vertices[v1].x;
 	    accy += (long) Vertices[v1].y;
@@ -1201,7 +1169,6 @@
 int  tag, n;
 bool ok;
 
-ObjectsNeeded (OBJ_LINEDEFS, OBJ_SECTORS, 0);
 tag = 1;
 ok = false;
 while (! ok)
--- a/src/objinfo.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/objinfo.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -118,7 +118,6 @@
   if (! out_y1)
     return;
 
-  ObjectsNeeded (obj_type, 0);
   switch (obj_type)
   {
     case OBJ_THINGS:
@@ -255,7 +254,6 @@
 	DrawScreenText (-1, -1, "\1Type:\2 %3d %.19s",
 			LineDefs[obj_no].type,
 			GetLineDefTypeName (LineDefs[obj_no].type));
-	ObjectsNeeded (OBJ_SIDEDEFS, OBJ_SECTORS, 0);
 	{
 	  int tag           = LineDefs[obj_no].tag;
 	  int first_sector  = NumSectors;
@@ -284,7 +282,6 @@
 	s1 = LineDefs[obj_no].start;
 	s2 = LineDefs[obj_no].end;
 	DrawScreenText (-1, -1, "\1Vertices:\2 (#%d, #%d)", s1, s2);
-	ObjectsNeeded (OBJ_VERTICES, 0);
 	n = ComputeDist (Vertices[s2].x - Vertices[s1].x,
 			 Vertices[s2].y - Vertices[s1].y);
 	DrawScreenText (-1, -1, "\1Length:\2   %d", n);
@@ -570,7 +567,6 @@
 	int first_ld  = NumLineDefs;
 	int second_ld = NumLineDefs;
 
-	ObjectsNeeded (OBJ_LINEDEFS, 0);
 	if (tag != 0)
 	{
 	  for (n = 0; n < NumLineDefs; n++)
@@ -680,7 +676,6 @@
 	  }
 	  DrawScreenText (-1, -1, "\1Shadow:\2 %d",   dsec->light);
 	  DrawScreenText (-1, -1, "\1Type:\2   %d",   dsec->special);
-	  ObjectsNeeded (OBJ_LINEDEFS, 0);
 	  if (thick)
 	    DrawScreenText (-1, -1, "\1Side:\2   %.*s", WAD_TEX_NAME, i.tex);
 	  {
--- a/src/pic2img.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/pic2img.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -261,12 +261,12 @@
       Column = ColumnData + CurrentOffset - NeededOffsets[0];
    else
       {
-      Column = (u8 *) GetFarMemory (TEX_COLUMNSIZE);
+      Column = (u8 *) GetMemory (TEX_COLUMNSIZE);
       dir->wadfile->seek (dir->dir.start + CurrentOffset);
       if (dir->wadfile->error ())
          {
 	 int too_many = add_msg (_MT_BADOFS, (short) pic_x);
-	 FreeFarMemory (Column);
+	 FreeMemory (Column);
 	 if (too_many)		// This picture has too many errors. Give up.
 	    goto pic_end;
 	 continue;			// Give up on this column
@@ -296,7 +296,7 @@
 	 if (too_many)		// This picture has too many errors. Give up.
 	    {
 	    if (! ColumnInMemory)
-	       FreeFarMemory (Column);
+	       FreeMemory (Column);
 	    goto pic_end;
 	    }
 	 break;				// Give up on this column
@@ -351,7 +351,7 @@
 next_column :
 #endif
    if (!ColumnInMemory)
-      FreeFarMemory (Column);
+      FreeMemory (Column);
    }  // Column loop
 
 pic_end:
--- a/src/s_door.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/s_door.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -52,12 +52,10 @@
 /* build lists of linedefs that border the sector */
 for (n = 0; n < NumLineDefs; n++)
 {
-   ObjectsNeeded (OBJ_LINEDEFS, 0);
    sd1 = LineDefs[n].sidedef1;
    sd2 = LineDefs[n].sidedef2;
    if (sd1 >= 0 && sd2 >= 0)
    {
-      ObjectsNeeded (OBJ_SIDEDEFS, 0);
       if (SideDefs[sd2].sector == sector)
       {
 	 SelectObject (&ldok, n); /* already ok */
@@ -71,7 +69,6 @@
    }
    else if (sd1 >= 0 && sd2 < 0)
    {
-      ObjectsNeeded (OBJ_SIDEDEFS, 0);
       if (SideDefs[sd1].sector == sector)
 	 SelectObject (&ld1s, n); /* wall (one-sided) */
    }
@@ -107,14 +104,12 @@
 while (ldok != NULL)
 {
    /* give the "normal door" type and flags to the linedef */
-   ObjectsNeeded (OBJ_LINEDEFS, 0);
    n = ldok->objnum;
    LineDefs[n].type = 1;
    LineDefs[n].flags = 0x04;
    sd1 = LineDefs[n].sidedef1; /* outside */
    sd2 = LineDefs[n].sidedef2; /* inside */
    /* adjust the textures for the sidedefs */
-   ObjectsNeeded (OBJ_SIDEDEFS, 0);
    if (strncmp (SideDefs[sd1].tex3, "-", WAD_TEX_NAME))
    {
       if (!strncmp (SideDefs[sd1].tex1, "-", WAD_TEX_NAME))
@@ -129,12 +124,10 @@
 while (ld1s != NULL)
 {
    /* give the "door side" flags to the linedef */
-   ObjectsNeeded (OBJ_LINEDEFS, 0);
    n = ld1s->objnum;
    LineDefs[n].flags = 0x11;
    sd1 = LineDefs[n].sidedef1;
    /* adjust the textures for the sidedef */
-   ObjectsNeeded (OBJ_SIDEDEFS, 0);
    if (!strncmp (SideDefs[sd1].tex3, "-", WAD_TEX_NAME))
       strncpy (SideDefs[sd1].tex3, "DOORTRAK", WAD_TEX_NAME);
    strncpy (SideDefs[sd1].tex1, "-", WAD_TEX_NAME);
@@ -142,7 +135,6 @@
    UnSelectObject (&ld1s, n);
 }
 /* adjust the ceiling height */
-ObjectsNeeded (OBJ_SECTORS, 0);
 Sectors[sector].ceilh = Sectors[sector].floorh;
 }
 
--- a/src/s_lift.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/s_lift.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -55,12 +55,10 @@
 /* build lists of linedefs that border the Sector */
 for (n = 0; n < NumLineDefs; n++)
 {
-   ObjectsNeeded (OBJ_LINEDEFS, 0);
    sd1 = LineDefs[n].sidedef1;
    sd2 = LineDefs[n].sidedef2;
    if (sd1 >= 0 && sd2 >= 0)
    {
-      ObjectsNeeded (OBJ_SIDEDEFS, 0);
       if (SideDefs[sd2].sector == sector)
       {
 	 SelectObject (&ldok, n); /* already ok */
@@ -78,7 +76,6 @@
    }
    else if (sd1 >= 0 && sd2 < 0)
    {
-      ObjectsNeeded (OBJ_SIDEDEFS, 0);
       if (SideDefs[sd1].sector == sector)
 	 SelectObject (&ld1s, n); /* wall (one-sided) */
    }
@@ -108,7 +105,6 @@
 tag = FindFreeTag ();
 
 /* find the minimum and maximum altitudes */
-ObjectsNeeded (OBJ_SECTORS, 0);
 minh = 32767;
 maxh = -32767;
 for (curs = sect; curs; curs = curs->next)
@@ -135,7 +131,6 @@
 while (ldok != NULL)
    {
    /* give the "lower lift" type and flags to the linedef */
-   ObjectsNeeded (OBJ_LINEDEFS, 0);
    n = ldok->objnum;
    LineDefs[n].type = 62; /* lower lift (switch) */
    LineDefs[n].flags = 0x04;
@@ -143,7 +138,6 @@
    sd1 = LineDefs[n].sidedef1; /* outside */
    sd2 = LineDefs[n].sidedef2; /* inside */
    /* adjust the textures for the sidedef visible from the outside */
-   ObjectsNeeded (OBJ_SIDEDEFS, 0);
    if (strncmp (SideDefs[sd1].tex3, "-", WAD_TEX_NAME))
       {
       if (!strncmp (SideDefs[sd1].tex2, "-", WAD_TEX_NAME))
@@ -155,10 +149,8 @@
    /* adjust the textures for the sidedef visible from the lift */
    strncpy (SideDefs[sd2].tex3, "-", WAD_TEX_NAME);
    s = SideDefs[sd1].sector;
-   ObjectsNeeded (OBJ_SECTORS, 0);
    if (Sectors[s].floorh > minh)
       {
-      ObjectsNeeded (OBJ_SIDEDEFS, 0);
       if (strncmp (SideDefs[sd2].tex3, "-", WAD_TEX_NAME))
       {
 	 if (!strncmp (SideDefs[sd2].tex2, "-", WAD_TEX_NAME))
@@ -170,23 +162,18 @@
       }
    else
       {
-      ObjectsNeeded (OBJ_SIDEDEFS, 0);
       strncpy (SideDefs[sd2].tex2, "-", WAD_TEX_NAME);
       }
    strncpy (SideDefs[sd2].tex3, "-", WAD_TEX_NAME);
-   ObjectsNeeded (OBJ_SECTORS, 0);
    /* if the ceiling of the sector is lower than that of the lift */
    if (Sectors[s].ceilh < Sectors[sector].ceilh)
       {
-      ObjectsNeeded (OBJ_SIDEDEFS, 0);
       if (strncmp (SideDefs[sd2].tex1, "-", WAD_TEX_NAME))
 	 strncpy (SideDefs[sd2].tex1, default_upper_texture, WAD_TEX_NAME);
       }
-   ObjectsNeeded (OBJ_SECTORS, 0);
    /* if the floor of the sector is above the lift */
    if (Sectors[s].floorh >= Sectors[sector].floorh)
       {
-      ObjectsNeeded (OBJ_LINEDEFS, 0);
       LineDefs[n].type = 88; /* lower lift (walk through) */
       /* flip it, just for fun */
       curs = NULL;
@@ -201,12 +188,10 @@
 while (ld1s != NULL)
    {
    /* these are the lift walls (one-sided) */
-   ObjectsNeeded (OBJ_LINEDEFS, 0);
    n = ld1s->objnum;
    LineDefs[n].flags = 0x01;
    sd1 = LineDefs[n].sidedef1;
    /* adjust the textures for the sidedef */
-   ObjectsNeeded (OBJ_SIDEDEFS, 0);
    if (!strncmp (SideDefs[sd1].tex3, "-", WAD_TEX_NAME))
       strncpy (SideDefs[sd1].tex3, default_middle_texture, WAD_TEX_NAME);
    strncpy (SideDefs[sd1].tex1, "-", WAD_TEX_NAME);
--- a/src/s_merge.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/s_merge.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -48,7 +48,6 @@
 /* save the first Sector number */
 news = (*slist)->objnum;
 UnSelectObject (slist, news);
-ObjectsNeeded (OBJ_SIDEDEFS, 0);
 
 /* change all SideDefs references to the other Sectors */
 for (cur = *slist; cur; cur = cur->next)
@@ -84,7 +83,6 @@
 /* first, do the tests for all LineDefs */
 for (cur = *ldlist; cur; cur = cur->next)
    {
-   ObjectsNeeded (OBJ_LINEDEFS, 0);
    sd1 = LineDefs[cur->objnum].sidedef1;
    sd2 = LineDefs[cur->objnum].sidedef2;
    if (sd1 < 0 || sd2 < 0)
@@ -94,7 +92,6 @@
       Notify (-1, -1, msg, NULL);
       return;
       }
-   ObjectsNeeded (OBJ_SIDEDEFS, 0);
    s1 = SideDefs[sd1].sector;
    s2 = SideDefs[sd2].sector;
    if (s1 < 0 || s2 < 0)
@@ -109,10 +106,8 @@
 /* then join the Sectors and delete the LineDefs */
 for (cur = *ldlist; cur; cur = cur->next)
    {
-   ObjectsNeeded (OBJ_LINEDEFS, 0);
    sd1 = LineDefs[cur->objnum].sidedef1;
    sd2 = LineDefs[cur->objnum].sidedef2;
-   ObjectsNeeded (OBJ_SIDEDEFS, 0);
    s1 = SideDefs[sd1].sector;
    s2 = SideDefs[sd2].sector;
    slist = NULL;
--- a/src/s_misc.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/s_misc.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -49,8 +49,6 @@
 SelPtr cur;
 int    n, num, floor1h, floor2h;
 
-ObjectsNeeded (OBJ_SECTORS, 0);
-
 num = 0;
 for (cur = obj; cur->next; cur = cur->next)
    num++;
@@ -78,8 +76,6 @@
 SelPtr cur;
 int    n, num, ceil1h, ceil2h;
 
-ObjectsNeeded (OBJ_SECTORS, 0);
-
 num = 0;
 for (cur = obj; cur->next; cur = cur->next)
    num++;
@@ -127,7 +123,6 @@
 if (key == YK_ESC)
   return;
 
-ObjectsNeeded (OBJ_SECTORS, 0);
 for (cur = obj; cur != NULL; cur = cur->next)
   {
   Sectors[cur->objnum].ceilh += delta;
@@ -167,7 +162,6 @@
 if (key == YK_ESC)
   return;
 
-ObjectsNeeded (OBJ_SECTORS, 0);
 for (cur = obj; cur != NULL; cur = cur->next)
   {
   int light;
--- a/src/s_prop.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/s_prop.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -166,7 +166,6 @@
       {
 	*texname = '\0';
 	strncat (texname, Sectors[obj->objnum].floort, WAD_FLAT_NAME);
-	ObjectsNeeded (0);
 	char **flat_names =
 	  (char **) GetMemory (NumFTexture * sizeof *flat_names);
 	for (size_t n = 0; n < NumFTexture; n++)
@@ -174,7 +173,6 @@
 	ChooseFloorTexture (x0 + 42, subwin_y0, "Choose a floor texture",
 	  NumFTexture, flat_names, texname);
 	FreeMemory (flat_names);
-	ObjectsNeeded (OBJ_SECTORS, 0);
 	if (strlen (texname) > 0)
 	{
 	  for (cur = obj; cur; cur = cur->next)
@@ -188,7 +186,6 @@
       {
       *texname = '\0';
       strncat (texname, Sectors[obj->objnum].ceilt, WAD_FLAT_NAME);
-      ObjectsNeeded (0);
       char **flat_names =
 	(char **) GetMemory (NumFTexture * sizeof *flat_names);
       for (size_t n = 0; n < NumFTexture; n++)
@@ -196,7 +193,6 @@
       ChooseFloorTexture (x0 + 42, subwin_y0, "Choose a ceiling texture",
 	NumFTexture, flat_names, texname);
       FreeMemory (flat_names);
-      ObjectsNeeded (OBJ_SECTORS, 0);
       if (strlen (texname) > 0)
       {
 	for (cur = obj; cur; cur = cur->next)
--- a/src/s_split.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/s_split.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -70,7 +70,6 @@
 /* Check if there is a closed path from <vertex1> to <vertex2>,
    along the edge of sector <s>. To make it faster, I scan only
    the set of linedefs that face sector <s>. */
-ObjectsNeeded (OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
 obj_no_t *ld_numbers;
 int nlinedefs = linedefs_of_sector (s, ld_numbers);
 if (nlinedefs < 1)  // Can't happen
@@ -145,7 +144,6 @@
 strncpy (SideDefs[NumSideDefs - 1].tex3, "-", WAD_TEX_NAME);
 InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
 strncpy (SideDefs[NumSideDefs - 1].tex3, "-", WAD_TEX_NAME);
-ObjectsNeeded (OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
 LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs - 2;
 LineDefs[NumLineDefs - 1].sidedef2 = NumSideDefs - 1;
 
@@ -160,14 +158,12 @@
 }
 
 /* second check... useful for sectors within sectors */
-ObjectsNeeded (OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
 for (l = 0; l < NumLineDefs; l++)
 {
    sd = LineDefs[l].sidedef1;
    if (sd >= 0 && SideDefs[sd].sector == s)
    {
       curv = GetOppositeSector (l, 1);
-      ObjectsNeeded (OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
       if (curv == NumSectors - 1)
 	 SideDefs[sd].sector = NumSectors - 1;
    }
@@ -175,7 +171,6 @@
    if (sd >= 0 && SideDefs[sd].sector == s)
    {
       curv = GetOppositeSector (l, 0);
-      ObjectsNeeded (OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
       if (curv == NumSectors - 1)
 	 SideDefs[sd].sector = NumSectors - 1;
    }
@@ -198,12 +193,10 @@
 char   msg[80];
 
 /* check if the two linedefs are adjacent to the same sector */
-ObjectsNeeded (OBJ_LINEDEFS, 0);
 s1 = LineDefs[linedef1].sidedef1;
 s2 = LineDefs[linedef1].sidedef2;
 s3 = LineDefs[linedef2].sidedef1;
 s4 = LineDefs[linedef2].sidedef2;
-ObjectsNeeded (OBJ_SIDEDEFS, 0);
 if (s1 >= 0)
    s1 = SideDefs[s1].sector;
 if (s2 >= 0)
--- a/src/selrect.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/selrect.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -58,21 +58,18 @@
 switch (objtype)
    {
    case OBJ_THINGS:
-      ObjectsNeeded (OBJ_THINGS, 0);
       for (n = 0; n < NumThings; n++)
 	 if (Things[n].xpos >= x0 && Things[n].xpos <= x1
 	  && Things[n].ypos >= y0 && Things[n].ypos <= y1)
             select_unselect_obj (list, n);
       break;
    case OBJ_VERTICES:
-      ObjectsNeeded (OBJ_VERTICES, 0);
       for (n = 0; n < NumVertices; n++)
 	 if (Vertices[n].x >= x0 && Vertices[n].x <= x1
 	  && Vertices[n].y >= y0 && Vertices[n].y <= y1)
             select_unselect_obj (list, n);
       break;
    case OBJ_LINEDEFS:
-      ObjectsNeeded (OBJ_LINEDEFS, OBJ_VERTICES, 0);
       for (n = 0; n < NumLineDefs; n++)
 	 {
 	 /* the two ends of the line must be in the box */
--- a/src/swapmem.cc	Sat Sep 24 12:43:19 2011 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,345 +0,0 @@
-/*
-   Memory swapping by Raphaël Quinet <quinet@montefiore.ulg.ac.be>
-   and Christian Johannes Schladetsch <s924706@yallara.cs.rmit.OZ.AU>
-
-   You are allowed to use any parts of this code in another program, as
-   long as you give credits to the authors in the documentation and in
-   the program itself.  Read the file README.1ST for more information.
-
-   This program comes with absolutely no warranty.
-
-   SWAPMEM.C - When the memory is low....
-
-   Note from RQ:
-      Yuck!  I don't like this horrible thing.  The program should be
-      able to swap almost anything to XMS or to disk, not only the
-      five objects used here (Things, LineDefs, SideDefs, Vertices and
-      Sectors).  That was a quick and dirty hack...  I didn't have the
-      time to write a cleaner code...
-
-   Note2 from RQ:
-      After having tested these routines, I see that they are not very
-      useful...  I'm still getting "out of memory" errors while editing
-      E2M7 and other huge levels.  I should rewrite all this for GCC,
-      use a flat memory model and a DOS extender, then just delete all
-      this code...  I will have to do that anyway if I want to port it
-      to other systems (Unix, Linux), so why not?
-      Moral of the story: never waste long hours writing high-level
-      memory swapping routines on a deficient OS.  Use a real OS with
-      a better memory management instead.
-
-   Note for CJS:
-      It should be easy to include your XMS code in this file.  Just
-      add the necessary lines in InitSwap(), SwapIn() and SwapOut().
-      You won't need to edit any other file.  Put all your routines
-      in XMS.C, with the necessary includes in XMS.H.  Please keep it
-      short and simple... :-)
-      ... And delete this note once you're done.
-*/
-
-
-/*
-This file is part of Yadex.
-
-Yadex incorporates code from DEU 5.21 that was put in the public domain in
-1994 by Raphaël Quinet and Brendon Wyber.
-
-The rest of Yadex is Copyright © 1997-2003 André Majorel and others.
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free Software
-Foundation; either version 2 of the License, or (at your option) any later
-version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-#include "yadex.h"
-#include "levels.h"
-#include "objid.h"
-#ifdef SWAP_TO_XMS
-#include "xms.h"
-typedef XMSHandle SwapHandle;	/* XMS handle */
-#define INVALID_HANDLE		-1
-#else
-typedef char SwapHandle[128];	/* name of the temporary disk file */
-#define INVALID_HANDLE		"..."
-#endif /* SWAP_TO_XMS */
-
-/* global variables */
-bool NeedThings = false;
-bool NeedLineDefs = false;
-bool NeedSideDefs = false;
-bool NeedVertices = false;
-bool NeedSectors = false;
-SwapHandle ThingsH;
-SwapHandle LineDefsH;
-SwapHandle SideDefsH;
-SwapHandle VerticesH;
-SwapHandle SectorsH;
-
-
-/*
-   do the necessary initialisation for the secondary storage
-*/
-
-void InitSwap ()
-{
-#ifdef SWAP_TO_XMS
-/* Init XMS */
-...
-#else
-strcpy (ThingsH, INVALID_HANDLE);
-strcpy (LineDefsH, INVALID_HANDLE);
-strcpy (SideDefsH, INVALID_HANDLE);
-strcpy (VerticesH, INVALID_HANDLE);
-strcpy (SectorsH, INVALID_HANDLE);
-#endif /* SWAP_TO_XMS */
-}
-
-
-
-/*
-   moves an object from secondary storage to lower RAM
-*/
-
-void huge *SwapIn (SwapHandle handle, unsigned long size)
-{
-void huge *ptr;
-#ifdef SWAP_TO_XMS
-/* allocate a new memory block (in lower RAM) */
-ptr = GetFarMemory (size);
-/* read the data from XMS */
-...
-/* free the XMS memory block */
-...
-/* delete the handle */
-...
-#else
-FILE      *file;
-char huge *data;
-SwapHandle oldhandle;
-
-/* Note from RQ:
-      the following test is there to prevent an infinite loop when
-      SwapIn calls GetFarMemory, which calls FreeSomeMemory, which
-      in turn calls SwapOut, then SwapIn...
- */
-if (! strcmp (handle, INVALID_HANDLE))
-   return NULL;
-#ifdef DEBUG
-LogMessage ("swapping in %lu bytes from %s\n", size, handle);
-#endif /* DEBUG */
-strcpy (oldhandle, handle);
-/* invalidate the handle (must be before "GetFarMemory") */
-strcpy (handle, INVALID_HANDLE);
-/* allocate a new memory block (in lower RAM) */
-ptr = GetFarMemory (size);
-/* read the data from the temporary file */
-file = fopen (oldhandle, "rb");
-data = (char huge *) ptr;
-if (file == NULL)
-{
-#ifdef DEBUG
-   LogMessage ("\nFree memory before crash: %lu bytes.", farcoreleft ());
-#endif /* DEBUG */
-   fatal_error ("error opening temporary file \"%s\"", oldhandle);
-}
-while (size > 0x8000)
-{
-   if (fread (data, 1, 0x8000, file) != 0x8000)
-      fatal_error ("error reading from temporary file \"%s\"", oldhandle);
-   data = data + 0x8000;
-   size -= 0x8000;
-}
-if (fread (data, 1, size, file) != size)
-   fatal_error ("error reading from temporary file \"%s\"", oldhandle);
-fclose (file);
-/* delete the file */
-unlink (oldhandle);
-#endif /* !SWAP_TO_XMS */
-return ptr;
-}
-
-
-
-/*
-   moves an object from lower RAM to secondary storage
-*/
-
-void SwapOut (void huge *ptr, SwapHandle handle, unsigned long size)
-{
-#ifdef SWAP_TO_XMS
-/* get a new XMS handle */
-...
-/* write the data to XMS */
-...
-#else
-FILE      *file;
-char huge *data;
-
-// get a new (unique) file name
-const char *basename = "yadexswpXXXXXX";  // 14 characters
-const char *dir      = getenv ("TMPDIR");
-if (dir == 0 || strlen (dir) + 1 + strlen (basename) >= sizeof (SwapHandle))
-   dir = "/tmp";
-y_snprintf (handle, sizeof (SwapHandle), "%s/%s", dir, basename);
-if (mkstemp (handle) == -1)
-{
-#ifdef DEBUG
-   LogMessage ("\nFree memory before crash: %lu bytes.", farcoreleft ());
-#endif
-   fatal_error ("cannot create a temporary file from \"%s\" (%s)",
-      handle, strerror (errno));
-}
-#ifdef DEBUG
-LogMessage ("swapping out %lu bytes to %s\n", size, handle);
-#endif /* DEBUG */
-// write the data to the temporary file
-data = (char huge *) ptr;
-file = fopen (handle, "wb");
-if (file == NULL)
-{
-#ifdef DEBUG
-   LogMessage ("\nFree memory before crash: %lu bytes.", farcoreleft ());
-#endif /* DEBUG */
-   fatal_error ("error creating temporary file \"%s\" (%s)",
-      handle, strerror (errno));
-}
-while (size > 0x8000)
-{
-   if (fwrite (data, 1, 0x8000, file) != 0x8000)
-      fatal_error ("error writing to temporary file \"%s\"", handle);
-   data = data + 0x8000;
-   size -= 0x8000;
-}
-if (fwrite (data, 1, size, file) != size)
-   fatal_error ("error writing to temporary file \"%s\"", handle);
-if (fclose (file))
-   fatal_error ("error writing to temporary file \"%s\" (%s)",
-      handle, strerror (errno));
-#endif /* !SWAP_TO_XMS */
-/* free the data block (in lower RAM) */
-FreeFarMemory (ptr);
-}
-
-
-
-/*
-   get the objects needed (if they aren't already in memory)
-*/
-
-void SwapInObjects (void)
-{
-if (NeedThings && NumThings > 0 && Things == NULL)
-   Things = (TPtr) SwapIn (ThingsH,
-   			(unsigned long) NumThings * sizeof (struct Thing));
-if (NeedLineDefs && NumLineDefs > 0 && LineDefs == NULL)
-   LineDefs = (LDPtr) SwapIn (LineDefsH,
-   			(unsigned long) NumLineDefs * sizeof (struct LineDef));
-if (NeedSideDefs && NumSideDefs > 0 && SideDefs == NULL)
-   SideDefs = (SDPtr) SwapIn (SideDefsH,
-   			(unsigned long) NumSideDefs * sizeof (struct SideDef));
-if (NeedVertices && NumVertices > 0 && Vertices == NULL)
-   Vertices = (VPtr) SwapIn (VerticesH,
-   			(unsigned long) NumVertices * sizeof (struct Vertex));
-if (NeedSectors && NumSectors > 0 && Sectors == NULL)
-   Sectors = (SPtr) SwapIn (SectorsH,
-   			(unsigned long) NumSectors * sizeof (struct Sector));
-}
-
-
-/*
-   mark the objects that should be in lower RAM
-*/
-
-void ObjectsNeeded (int objtype, ...)
-{
-va_list args;
-
-/* get the list of objects */
-NeedThings = false;
-NeedLineDefs = false;
-NeedSideDefs = false;
-NeedVertices = false;
-NeedSectors = false;
-va_start (args, objtype);
-while (objtype > 0)
-{
-   switch (objtype)
-   {
-   case OBJ_THINGS:
-      NeedThings = true;
-      break;
-   case OBJ_LINEDEFS:
-      NeedLineDefs = true;
-      break;
-   case OBJ_SIDEDEFS:
-      NeedSideDefs = true;
-      break;
-   case OBJ_VERTICES:
-      NeedVertices = true;
-      break;
-   case OBJ_SECTORS:
-      NeedSectors = true;
-      break;
-   }
-   objtype = va_arg (args, int);
-}
-va_end (args);
-/* get the objects if they aren't already in memory */
-SwapInObjects ();
-}
-
-
-
-/*
-   free as much memory as possible by moving some objects out of lower RAM
-*/
-
-void FreeSomeMemory (void)
-{
-/* move everything to secondary storage */
-if (NumSectors > 0 && Sectors != NULL)
-{
-   SwapOut (Sectors, SectorsH,
-   	(unsigned long) NumSectors * sizeof (struct Sector));
-   Sectors = NULL;
-}
-if (NumVertices > 0 && Vertices != NULL)
-{
-   SwapOut (Vertices, VerticesH,
-   	(unsigned long) NumVertices * sizeof (struct Vertex));
-   Vertices = NULL;
-}
-if (NumSideDefs > 0 && SideDefs != NULL)
-{
-   SwapOut (SideDefs, SideDefsH,
-	(unsigned long) NumSideDefs * sizeof (struct SideDef));
-   SideDefs = NULL;
-}
-if (NumLineDefs > 0 && LineDefs != NULL)
-{
-   SwapOut (LineDefs, LineDefsH,
-   	(unsigned long) NumLineDefs * sizeof (struct LineDef));
-   LineDefs = NULL;
-}
-if (NumThings > 0 && Things != NULL)
-{
-   SwapOut (Things, ThingsH,
-   	(unsigned long) NumThings * sizeof (struct Thing));
-   Things = NULL;
-}
-/* re-load the objects that are needed */
-SwapInObjects ();
-}
-
-
-/* end of file */
--- a/src/v_merge.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/v_merge.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -57,7 +57,6 @@
 SelPtr cur;
 char   msg[80];
 
-ObjectsNeeded (OBJ_LINEDEFS, 0);
 while (obj != NULL)
    {
    cur = obj;
@@ -108,7 +107,6 @@
 {
 int    v, l;
 
-ObjectsNeeded (OBJ_LINEDEFS, 0);
 v = (*list)->objnum;
 UnSelectObject (list, v);
 if (*list == NULL)
@@ -170,7 +168,6 @@
 if (obj_type != OBJ_VERTICES)
    return false;
 
-ObjectsNeeded (OBJ_VERTICES, 0);
 redraw = false;
 mergedone = false;
 isldend = false;
@@ -205,8 +202,6 @@
 	    SelectObject (&cur, refv);
 	    SelectObject (&cur, v);
 	    MergeVertices (&cur);
-	    /* not useful but safer... */
-	    ObjectsNeeded (OBJ_VERTICES, 0);
 	    /* update the references in the selection list */
 	    for (cur = *list; cur; cur = cur->next)
 	       if (cur->objnum > refv)
@@ -245,7 +240,6 @@
    /* check if this vertex is on a linedef */
    for (ld = 0; ld < oldnumld; ld++)
       {
-      ObjectsNeeded (OBJ_VERTICES, OBJ_LINEDEFS, 0);
       if (LineDefs[ld].start == refv || LineDefs[ld].end == refv)
          {
 	 /* one vertex had a linedef bound to it -- check it later */
@@ -272,14 +266,12 @@
 	    if (sd >= 0)
 	       {
 	       InsertObject (OBJ_SIDEDEFS, sd, 0, 0);
-	       ObjectsNeeded (OBJ_LINEDEFS, 0);
 	       LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs - 1;
 	       }
  	    sd = LineDefs[ld].sidedef2;
 	    if (sd >= 0)
 	       {
 	       InsertObject (OBJ_SIDEDEFS, sd, 0, 0);
-	       ObjectsNeeded (OBJ_LINEDEFS, 0);
 	       LineDefs[NumLineDefs - 1].sidedef2 = NumSideDefs - 1;
 	       }
 	    MadeChanges = 1;
--- a/src/wads.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/wads.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -236,7 +236,7 @@
   void        *data    = 0;
   const size_t chunksz = 0x4000;
 
-  data = GetFarMemory (chunksz + 2);
+  data = GetMemory (chunksz + 2);
   while (size > chunksz)
   {
     if (fread (data, 1, chunksz, source) != chunksz)
@@ -264,7 +264,7 @@
 
 byebye:
   if (data != 0)
-    FreeFarMemory (data);
+    FreeMemory (data);
   return rc;
 }
 
--- a/src/wstructs.h	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/wstructs.h	Sat Sep 24 13:03:13 2011 +0300
@@ -41,7 +41,7 @@
 // Directory
 const size_t WAD_NAME = 8;		// Length of a directory entry name
 typedef char wad_name_t[WAD_NAME];
-typedef struct Directory huge *DirPtr;
+typedef struct Directory *DirPtr;
 struct Directory
 {
   i32        start;			// Offset to start of data
@@ -106,7 +106,7 @@
   u8               arg4;
   u8               arg5;
 } wad_hexen_thing_t;
-typedef struct Thing huge *TPtr;
+typedef struct Thing *TPtr;
 
 
 // Linedefs
@@ -138,7 +138,7 @@
   wad_sdn_t     sidedef1;
   wad_sdn_t     sidedef2;
 } wad_hexen_linedef_t;
-typedef struct LineDef huge *LDPtr;
+typedef struct LineDef *LDPtr;
 
 
 // Sidedefs
@@ -153,7 +153,7 @@
   wad_sn_t       sector;		// # of adjacent sector
 };
 // (it's the same for Hexen)
-typedef struct SideDef huge *SDPtr;
+typedef struct SideDef *SDPtr;
 
 
 // Vertices
@@ -164,7 +164,7 @@
   wad_coord_t y;
 };
 // (it's the same for Hexen)
-typedef struct Vertex huge *VPtr;
+typedef struct Vertex *VPtr;
 
 
 // Sectors
@@ -180,7 +180,7 @@
   wad_stype_t     special;		// FIXME rename to "type"
   wad_tag_t       tag;
 };
-typedef struct Sector huge *SPtr;
+typedef struct Sector *SPtr;
 
 
 // The 11 lumps that constitute a Doom/Heretic/Strife level
--- a/src/x_hover.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/x_hover.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -164,7 +164,6 @@
   int xmax = (int) (x + mapslack + 0.5);
   int ymin = (int) (y - mapslack + 0.5);
   int ymax = (int) (y + mapslack + 0.5);
-  ObjectsNeeded (OBJ_LINEDEFS, OBJ_VERTICES, 0);
   object.nil ();
   for (int n = 0; n < NumLineDefs; n++)
   {
@@ -268,7 +267,6 @@
   static Close_obj object;
   int best_match = -1;
   int curx = 32767;  // Oh yes, one more hard-coded constant!
-  ObjectsNeeded (OBJ_LINEDEFS, OBJ_VERTICES, 0);
   for (int n = 0; n < NumLineDefs; n++)
     if ((Vertices[LineDefs[n].start].y > y)
      != (Vertices[LineDefs[n].end].y > y))
@@ -297,7 +295,6 @@
       best_match = LineDefs[best_match].sidedef2;
     if (best_match >= 0)
     {
-      ObjectsNeeded (OBJ_SIDEDEFS, 0);
       object.obj.type = OBJ_SECTORS;
       object.obj.num  = SideDefs[best_match].sector;
       object.distance = 0;	// Not meaningful for sectors
@@ -327,7 +324,6 @@
   int ymin = y - max_radius;
   int ymax = y + max_radius;
 
-  ObjectsNeeded (OBJ_THINGS, 0);
   closest.nil ();
   for (int n = 0; n < NumThings; n++)
   {
@@ -394,7 +390,6 @@
   int ymin = (int) (y - mapslack + 0.5);
   int ymax = (int) (y + mapslack + 0.5);
 
-  ObjectsNeeded (OBJ_VERTICES, 0);
   object.nil ();
   for (int n = 0; n < NumVertices; n++)
   {
--- a/src/x_rotate.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/x_rotate.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -69,7 +69,6 @@
 
   if (obj == NULL)
     return;
-  ObjectsNeeded (objtype, 0);
 
   switch (objtype)
   {
@@ -107,7 +106,6 @@
       break;
 
     case OBJ_SECTORS:
-      ObjectsNeeded (OBJ_LINEDEFS, OBJ_SIDEDEFS, 0);
       vertices = list_vertices_of_sectors (obj);
       RotateAndScaleObjects (OBJ_VERTICES, vertices, angle, scale);
       ForgetSelection (&vertices);
--- a/src/yadex.cc	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/yadex.cc	Sat Sep 24 13:03:13 2011 +0300
@@ -204,9 +204,6 @@
 if (screen_lines == 0)
    screen_lines = 24;
 
-// InitSwap must be called before any call to GetMemory(), etc.
-InitSwap ();
-
 // First detect manually --help and --version
 // because parse_command_line_options() cannot.
 if (argc == 2 && strcmp (argv[1], "--help") == 0)
--- a/src/yadex.h	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/yadex.h	Sat Sep 24 13:03:13 2011 +0300
@@ -50,20 +50,10 @@
 #include <ctype.h>
 #include <limits.h>
 #include <errno.h>
-#ifdef Y_DOS
-#include <alloc.h>
-#include <dos.h>
-#include <bios.h>
-#elif defined Y_UNIX
+#ifdef Y_UNIX
 #include <unistd.h>
-#define far
-#define huge
-#define farmalloc  malloc
-#define farrealloc realloc
-#define farfree    free
 #endif
 
-
 /*
  *	Additional libraries
  */
@@ -164,7 +154,7 @@
 
 /* The master directory structure is used to build a complete directory
    of all the data blocks from all the various wad files. */
-typedef struct MasterDirectory huge *MDirPtr;
+typedef struct MasterDirectory *MDirPtr;
 struct MasterDirectory
    {
    MDirPtr next;		// Next in list
@@ -514,11 +504,6 @@
 void SplitLineDefsAndSector (int, int); /* SWAP! */
 void MultiSplitLineDefsAndSector (int, int); /* SWAP! */
 
-// swapmem.cc
-void InitSwap (void);
-void FreeSomeMemory (void);
-void ObjectsNeeded (int, ...);
-
 // scrnshot.cc
 void ScreenShot (void);
 
--- a/src/ymemory.h	Sat Sep 24 12:43:19 2011 +0300
+++ b/src/ymemory.h	Sat Sep 24 13:03:13 2011 +0300
@@ -8,8 +8,3 @@
 void *GetMemory (unsigned long size);
 void *ResizeMemory (void *, unsigned long size);
 void FreeMemory (void *);
-void huge *GetFarMemory (unsigned long size);
-void huge *ResizeFarMemory (void huge *old, unsigned long size);
-void FreeFarMemory (void huge *);
-
-