DieHard Wolfers Forum Index DieHard Wolfers
A Wolfenstein 3d Fan Community


  Hosted by: MCS & Areyep.com - Designed by: BrotherTank

Original Yahoo Forum - Die Hard Archives

AReyeP HomepageAreyep Homepage DieHard Wolfenstein BunkerDieHard Wolfenstein Bunker Log inLog in RegisterRegister Banlist FAQFAQ Search ForumsSearch

  Username:    Password:      Remember me       

[Info] Freeing Up Memory - A Must Read!
Page 5 of 5 Goto page Previous  1, 2, 3, 4, 5
DieHard Wolfers Forum Index -> Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page BottomView Next Topic
Post new topicReply to topic
Author Message
insurrectionman
DieHard Mutant
DieHard Mutant


Joined: 07 May 2005
Last Visit: 18:04 ago.

Topics: 87
Posts: 759
Location: Wisconsin
usa.gif

PostPosted: Wed May 03, 2006 6:23 pm
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

Thanks for that, Dugtrio17

_________________
I'm back! I missed this community!
Youtube Channel: TreeSapThief

New Site: http://www.treesapthief.com
Twitter: @treesapthief
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Mon Jul 10, 2006 8:20 am
   Subject: Re: my 3 favorite arrays must come together on valentines
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Chris wrote:
Heh. Not sure if you'll find this interesting, but I managed to get 8192 more near bytes by combining spotvis with tilemap, and by compressing actorat into a byte.

Can someone post how to do this? I'm really interested. 'm now at 8286 databytes free.
And can someone tell me how to calculate far and core memory? Or maybe a function to show all
in the signon?

Thanks a lot, y'all, for this great topic!

- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
Zombie_Plan
DieHard Wolfer
DieHard Wolfer


Joined: 12 Oct 2004
Last Visit: 07 Jun 2016

Topics: 101
Posts: 1614
Location: A hole in the wall
australia.gif

PostPosted: Tue Jul 11, 2006 1:07 am
   Subject: Re: my 3 favorite arrays must come together on valentines
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

lwmxynedtodth wrote:
And can someone tell me how to calculate far and core memory?


Ok, yes it is a really great topic. As for the spotvis and tilemap, chris was the person who did it. The calculating is in this topic somewhere if i remember. Well, its somewhere. Anyway, its on the forums somewhere, it was posted by Brothertank, so maybe do a search for it.

ZOMG! I remember it being posted on BT's Tutorial for merging Statetypes. BT's version, not WSJ's.

Hope that helps.

_________________
Zombieskittles

Welcome to 2016, where DHW still thinks it is okay to ban the world's most popular email service provider, and I can't have an avatar over 10kb
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Tue Jul 11, 2006 3:48 am
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Thanks! I add that soon, maybe with a debug-code or so.
Besides, great topic. As you know, i started over again - and now I'm first freeing memory.
And I ask Chris for the spotvis thing.

- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Tue Jul 11, 2006 7:02 am
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Huh! There is a difference between the code shown in the game, and calculated the F000-... way.
Calculated with F000-C922 = 9950 bytes, and the game says almost 12000.
The last way I got from the "merging statetypes" tutorial by BT.
I've read about it in this post, the last one by the game is the most right one.
But why the difference? And can it be solved?

Just a thought:
F000 = 61440 (total mem)
C922 = 51490 (mem by _bufferwidth)
2E80 = 11904 (mem by game)

Considering this, either F000 or C922 is wrong.
Wrong F000:
Unable to achieve

Wrong C922:
F000 minus ... = 2E80 (total minus used = free)
... = C180 = 49536 (mem used)

Maybe somebody can tell me that I am stupid, or maybe someone can tell me why
there is a difference. Or just don't Wink

Greetz,
- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 08 Aug 2018

Topics: 46
Posts: 2313
Location: USA
usa.gif

PostPosted: Tue Jul 11, 2006 10:06 am
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I thought it was FF00, not F000.. but that still doesn't add up for you.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Tue Jul 11, 2006 12:44 pm
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

[quote=areyep_website]
The "EFAD" in there is the magic hexadecimal representation of the last used byte-address in the Data Group.
Now fire up Windows' calculator (CALC.EXE), put it in hexadecimal mode by checking the "HEX" checkbox, and perform the following subtraction:

F000 - EFAD

The calculator will show 53 as a result. Now check the "DEC" checkbox, and the result will change into 83. This means that there are 83 data bytes left.
[/quote]
Got this from the website of MCS and AReyeP, it is F000.
Very strange.

- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.


Last edited by lwmxynedtodth on Tue Jul 11, 2006 1:23 pm; edited 1 time in total
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 08 Aug 2018

Topics: 46
Posts: 2313
Location: USA
usa.gif

PostPosted: Tue Jul 11, 2006 12:58 pm
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

True enough. I was going from memory. It's been awhile since I've worried about data bytes.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Tue Jul 11, 2006 1:24 pm
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

O rly?
I started over again with my source, just to make it better (and it had a weird bug).
It is like a challenge to me, freeing databytes.

- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 29 Jul 2018

Topics: 55
Posts: 2136
Location: Canada
blank.gif

PostPosted: Tue Jul 11, 2006 6:45 pm
   Subject: Re: [Help] Freeing Up More Memory
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

lwmxynedtodth wrote:
Chris wrote:
Heh. Not sure if you'll find this interesting, but I managed to get 8192 more near bytes by combining spotvis with tilemap, and by compressing actorat into a byte.

Can someone post how to do this? I'm really interested. 'm now at 8286 databytes free.

Heh. Well, here's the way I used to get 4096 of that from changing actorat into a byte.
Just search the files below for "actorat" and change these 47 occurances in red... whee... Pizza Cake get it? pizza cake!

In WL_ACT1.C:

::: CODE :::
   switch (statinfo[type].type)
   {
   case block:
      actorat[tilex][tiley] = 1;      // consider it a blocking tile

::: CODE :::
   lastdoorobj->vertical = vertical;
   lastdoorobj->lock = lock;
   lastdoorobj->action = dr_closed;

   actorat[tilex][tiley] = 3;   // consider it a solid wall

::: CODE :::
      check = ACTLINK(actorat[tilex-1][tiley]);
      if (check && ((check->x+MINDIST) >> TILESHIFT) == tilex )
         return;
      check = ACTLINK(actorat[tilex+1][tiley]);
      if (check && ((check->x-MINDIST) >> TILESHIFT) == tilex )
         return;

::: CODE :::
      check = ACTLINK(actorat[tilex][tiley-1]);
      if (check && ((check->y+MINDIST) >> TILESHIFT) == tiley )
         return;
      check = ACTLINK(actorat[tilex][tiley+1]);
      if (check && ((check->y-MINDIST) >> TILESHIFT) == tiley )
         return;

::: CODE :::
//
// make the door space solid
//
   actorat[tilex][tiley]
      = 3;
}

::: CODE :::
   tilex = doorobjlist[door].tilex;
   tiley = doorobjlist[door].tiley;

   if ((actorat[tilex][tiley] > 3)
   || (player->tilex == tilex && player->tiley == tiley) )

::: CODE :::
   case di_north:
      if (actorat[checkx][checky-1])
      {
         SD_PlaySound (NOWAYSND);
         return;
      }
      actorat[checkx][checky-1] = 2;
      tilemap[checkx][checky-1] = oldtile;
      break;

   case di_east:
      if (actorat[checkx+1][checky])
      {
         SD_PlaySound (NOWAYSND);
         return;
      }
      actorat[checkx+1][checky] = 2;
      tilemap[checkx+1][checky] = oldtile;
      break;

   case di_south:
      if (actorat[checkx][checky+1])
      {
         SD_PlaySound (NOWAYSND);
         return;
      }
      actorat[checkx][checky+1] = 2;
      tilemap[checkx][checky+1] = oldtile;
      break;

   case di_west:
      if (actorat[checkx-1][checky])
      {
         SD_PlaySound (NOWAYSND);
         return;
      }
      actorat[checkx-1][checky] = 2;
      tilemap[checkx-1][checky] = oldtile;
      break;[/color]

::: CODE :::
      //
      // the tile can now be walked into
      //
      tilemap[pwallx][pwally] = 0;
      actorat[pwallx][pwally] = 0;
      *(mapsegs[0]+farmapylookup[pwally]+pwallx) = player->areanumber+AREATILE;

::: CODE :::
         case di_north:
            pwally--;
            if (actorat[pwallx][pwally-1])
            {
               pwallstate = 0;
               return;
            }
            actorat[pwallx][pwally-1] = 2;
            tilemap[pwallx][pwally-1] = oldtile;
            break;

         case di_east:
            pwallx++;
            if (actorat[pwallx+1][pwally])
            {
               pwallstate = 0;
               return;
            }
            actorat[pwallx+1][pwally] = 2;
            tilemap[pwallx+1][pwally] = oldtile;
            break;

         case di_south:
            pwally++;
            if (actorat[pwallx][pwally+1])
            {
               pwallstate = 0;
               return;
            }
            actorat[pwallx][pwally+1] = 2;
            tilemap[pwallx][pwally+1] = oldtile;
            break;

         case di_west:
            pwallx--;
            if (actorat[pwallx-1][pwally])
            {
               pwallstate = 0;
               return;
            }
            actorat[pwallx-1][pwally] = 2;
            tilemap[pwallx-1][pwally] = oldtile;
            break;


In WL_ACT2.C:

::: CODE :::
boolean ProjectileTryMove (objtype *ob)
{
   int         xl,yl,xh,yh,x,y;
   //objtype      *check;
   long      deltax,deltay;

::: CODE :::
//
// check for solid walls
//
   for (y=yl;y<=yh;y++)
      for (x=xl;x<=xh;x++)
      {
         if (actorat[x][y] && actorat[x][y] < 4)
            return false;
      }

::: CODE :::
   new->flags |= FL_SHOOTABLE;
   new->active = true;

   actorat[new->tilex][new->tiley] = 0;      // don't use original spot

::: CODE :::
   case 3:
      new->tiley++;
      break;
   }

   actorat[new->tilex][new->tiley] = ACTNUM(new);

::: CODE :::
moveok:

   xl = (ob->x-MINDIST) >> TILESHIFT;
   xh = (ob->x+MINDIST) >> TILESHIFT;
   yl = (ob->y-MINDIST) >> TILESHIFT;
   yh = (ob->y+MINDIST) >> TILESHIFT;

   for (y=yl ; y<=yh ; y++)
      for (x=xl ; x<=xh ; x++)
      {
         tile = ACTLINK(actorat[x][y]);
         if (!actorat[x][y])
            continue;
         if (actorat[x][y]<4)
            return;
         if (((objtype *)tile)->flags&FL_SHOOTABLE)
            return;

::: CODE :::
boolean   CheckPosition (objtype *ob)
{
   int   x,y,xl,yl,xh,yh;
   //objtype *check;

::: CODE :::
//
// check for solid walls
//
   for (y=yl;y<=yh;y++)
      for (x=xl;x<=xh;x++)
      {
         if (actorat[x][y] && actorat[x][y] < 4)
            return false;
      }


In WL_AGENT.C:

::: CODE :::
//
// check for solid walls
//
   for (y=yl;y<=yh;y++)
      for (x=xl;x<=xh;x++)
      {
         if (actorat[x][y] && actorat[x][y] < 4)
            return false;
      }

//
// check for actors
//
   if (yl>0)
      yl--;
   if (yh<MAPSIZE-1)
      yh++;
   if (xl>0)
      xl--;
   if (xh<MAPSTRETCH-1)
      xh++;

   for (y=yl;y<=yh;y++)
      for (x=xl;x<=xh;x++)
      {
            check = ACTLINK(actorat[x][y]);
         if (actorat[x][y] > 3
         && (check->flags & FL_SHOOTABLE) )
         {
            deltax = ob->x - check->x;


In WL_DEF.H:

::: CODE :::
#define SIGN(x)    ((x)>0?1:-1)
#define ABS(x)       ((int)(x)>0?(x):-(x))
#define LABS(x)    ((long)(x)>0?(x):-(x))

#define ACTNUM(x)   (((unsigned)x-obstart)/obsize)
#define ACTLINK(x)   ((objtype *)((unsigned)x*obsize+obstart))

::: CODE :::
typedef   enum   {
   ex_stillplaying,
   ex_completed,
   ex_died,
   ex_warped,
   ex_resetgame,
   ex_loadedgame,
   ex_victorious,
   ex_abort,
   ex_demodone,
   ex_secretlevel
} exit_t;

#define obsize      (sizeof(objtype))
#define obstart      ((unsigned)objlist - obsize*3)

::: CODE :::
extern   byte      tilemap[MAPSIZE][MAPSIZE];   // wall values only
extern   byte      spotvis[MAPSIZE][MAPSIZE];
extern   byte      actorat[MAPSIZE][MAPSIZE];


In WL_GAME.C:

::: CODE :::
//
// copy the wall data to a data segment array
//
   memset (tilemap,0,sizeof(tilemap));
   memset (actorat,0,sizeof(actorat));
   map = mapsegs[0];
   for (y=0;y<mapheight;y++)
      for (x=0;x<mapwidth;x++)
      {
         tile = *map++;
         if (tile<AREATILE)
         {
         // solid wall
            tilemap[x][y] = tile;
            actorat[x][y] = 2;
         }
         else
         {
         // area floor
            tilemap[x][y] = 0;
            actorat[x][y] = 0;
         }
      }

::: CODE :::
//
// take out the ambush markers
//
   map = mapsegs[0];
   for (y=0;y<mapheight;y++)
      for (x=0;x<mapwidth;x++)
      {
         tile = *map++;
         if (tile == AMBUSHTILE)
         {
            tilemap[x][y] = 0;
            actorat[x][y] = 0;

            if (*map >= AREATILE)
               tile = *map;
            if (*(map-1-mapwidth) >= AREATILE)
               tile = *(map-1-mapwidth);
            if (*(map-1+mapwidth) >= AREATILE)
               tile = *(map-1+mapwidth);
            if ( *(map-2) >= AREATILE)
               tile = *(map-2);

            *(map-1) = tile;
         }
      }


In WL_PLAY.C:

::: CODE :::
byte      tilemap[MAPSIZE][MAPSIZE];   // wall values only
byte      spotvis[MAPSIZE][MAPSIZE];
byte      actorat[MAPSIZE][MAPSIZE];

::: CODE :::
void DoActor (objtype *ob)
{
   void (*think)(objtype *);

   if (!ob->active && !areabyplayer[ob->areanumber])
      return;
   if (!(ob->flags&(FL_NONMARK|FL_NEVERMARK)) )
      actorat[ob->tilex][ob->tiley] = 0;

::: CODE :::
      if ( (ob->flags&FL_NONMARK) && actorat[ob->tilex][ob->tiley])
         return;

      actorat[ob->tilex][ob->tiley] = ACTNUM(ob);
      return;
   }

::: CODE :::
   if ( (ob->flags&FL_NONMARK) && actorat[ob->tilex][ob->tiley])
      return;

   actorat[ob->tilex][ob->tiley] = ACTNUM(ob);
}


In WL_STATE.C:

::: CODE :::
   new->x = ((long)tilex<<TILESHIFT)+TILEGLOBAL/2;
   new->y = ((long)tiley<<TILESHIFT)+TILEGLOBAL/2;
   new->dir = nodir;

   actorat[tilex][tiley] = ACTNUM(new);
   new->areanumber =
      *(mapsegs[0] + farmapylookup[new->tiley]+new->tilex) - AREATILE;

::: CODE :::
#define CHECKDIAG(x,y)                        \
{                                                   \
   temp=actorat[x][y];                          \
   if (temp)                                       \
   {                                               \
      if (temp<4)                               \
         return false;                           \
      if (ACTLINK(temp)->flags&FL_SHOOTABLE)  \
         return false;                           \
   }                                               \
}


#define CHECKSIDE(x,y)                        \
{                                                   \
   temp=actorat[x][y];                           \
   if (temp)                                       \
   {                                               \
      if (temp<3)                              \
         return false;                          \
      if (temp == 3)                             \
         doornum = (tilemap[x][y])&63;       \
      else if (ACTLINK(temp)->flags&FL_SHOOTABLE) \
         return false;                           \
   }                                               \
}

::: CODE :::
   gamestate.killcount++;
   ob->flags &= ~FL_SHOOTABLE;
   actorat[ob->tilex][ob->tiley] = 0;
   ob->flags |= FL_NONMARK;

It looks complicating, but it really isn't in concept. Since tilemap and actorat uses alot of the same defines for textures/doors, you don't really need them in actorat. I just made 0 walk-through, 1 solid objects, 2 solid walls, 3 solid doors, and 4-255 guards (so technically, you can still have 250 actors in a level if you increase MAXACTORS). The ACTNUM and ACTLINK defines just link the guard number to their memory location and back, to avoid needing the pointer information directly on the actorat.

For the spotvis question, each tile takes 8-bits, but it really only needs one (true or false). What I did was just make both byte 0 and 254 walk-throughable on the tilemap (254 being the one used to keep track of where you can see to replace spotvis). You can probably just look at the memboost code for some ideas on how to do that if you really want (most of the tricky stuff was in WL_DRAW.C, from what I remember, but there is some asm and special things for opening doors involved). Eh, fun times.

lwmxynedtodth wrote:
I've read about it in this post, the last one by the game is the most right one.
But why the difference? And can it be solved?

Interesting. All I know for sure is that the way MCS describes is how much memory you have left before hitting the "Abnormal Program Termination" message, which is the only near memory related error I think I've ever encountered, so I always look at the end of the MAP file when I'm curious. I did get a "Program too big to fit in memory" message once when adding a ton of large functions into WL_MAIN.C, but haven't looked into why it did that yet, and if there's a certain number you can't go over before that message comes up. Maybe there's a third number we should be watching too? Laughing

wolf3dbreaker wrote:
aside from C0.ASM, WHACK_A.asm and WOLFHACK.C, I am using the spear version, What else can I delete? for memory conservation?

Quoting stuff from page 1 for the win. I'm pretty sure you can delete WL_TEXT.C if you're using Spear.


Last edited by Chris on Wed Jul 12, 2006 3:26 am; edited 1 time in total
Zombie_Plan
DieHard Wolfer
DieHard Wolfer


Joined: 12 Oct 2004
Last Visit: 07 Jun 2016

Topics: 101
Posts: 1614
Location: A hole in the wall
australia.gif

PostPosted: Wed Jul 12, 2006 3:25 am
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

The numbers pumped out by the code are the memory available upon loading the game while the numbers in the map file are produced by the compiler. The code is more reliable. BT said this somewhere in response to Haasboy.

_________________
Zombieskittles

Welcome to 2016, where DHW still thinks it is okay to ban the world's most popular email service provider, and I can't have an avatar over 10kb
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 29 Jul 2018

Topics: 55
Posts: 2136
Location: Canada
blank.gif

PostPosted: Wed Jul 12, 2006 4:39 am
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Deathwish wrote:
The code is more reliable. BT said this somewhere in response to Haasboy.

So, if I say "spending your money on 7 toilets is better than saving for a car", does that automatically give my comment your undeniable approval as the best solution for every situation? I'd like to think you would have more initiative to research the choices before making such a supporting claim, even though I'm glad you would buy my 7 toilets... no questions asked. By the way, coming to my house to clean my room is more important than replying to this message. See you soon! Laughing
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Wed Jul 12, 2006 1:23 pm
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Quote:

BT said this somewhere in response to Haasboy.

I already said that. Duh.

Thanks for posting the code, Chris.
*ping* *incominggoodideastaysharp*
But hey, is there a quick way to write as much memory in the game as possible?
Just try where it crashes, at the one or the other. *ping* *endofgoodidea* *shuting down sound*
To declare an very big thingy and write it full of stuff.

- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
Dugtrio17
Code Master
Code Master


Joined: 11 Mar 2003
Last Visit: 03 Oct 2013

Topics: 49
Posts: 903
Location: Seattle
usa.gif

PostPosted: Thu Jul 13, 2006 5:04 pm
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

EDIT: Scratch this whole post, I'm an idiot. I've really gotta test these things more... I got a "Priority without a sound" error message using this bit of brilliance... here's the post in quote form:

Some guy wrote:
Okay, I've tested this out and haven't found any problems, but if anybody finds any then let me know.
I'm using MCS' priority system, and I scored a good bit of free memory (about 128 bytes and half of the soundpriority[] array) by changing the soundpriority array to a character array (char soundpriority instead of int soundpriority). Then I made necessary changes to ID_SD.H...
::: CODE :::
      typedef   struct
      {
         longword   length;
         word      priority;
      } SoundCommon;

to
::: CODE :::
      typedef   struct
      {
         longword   length;
         char      priority;
      } SoundCommon;

...and ID_SD.C...
::: CODE :::
static   void         (*SoundUserHook)(void);
      soundnames      SoundNumber,DigiNumber;
      word         SoundPriority,DigiPriority;
      int            LeftPosition,RightPosition;
      void interrupt   (*t0OldService)(void);
      long         LocalTime;
      word         TimerRate;

to
::: CODE :::
static   void         (*SoundUserHook)(void);
      soundnames      SoundNumber,DigiNumber;
      char         SoundPriority,DigiPriority;
      int            LeftPosition,RightPosition;
      void interrupt   (*t0OldService)(void);
      long         LocalTime;
      word         TimerRate;

Though now that I think about it... I guess it'd be easier to replace all calls to a sound's priority from the file with a direct call to the soundpriorities array. Then again, that'd probably make a few headaches once going far enough to remove the s->priority variable... Think I dunno, I'm not at my thinking best at the moment.

_________________
Guest




Last Visit:





PostPosted: Fri Sep 25, 2009 3:18 am
   Subject: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I've been trudging through a tougher level of mine, with many guards who emerge from more rooms with the same floor code. But sometimes the game crashes without clearing the screen, still on 320x200, printing garbled Divide Error, followed by the command prompt. DOSBox locks up, but probably it's DOSBox. Is Divide Error caused by memory overflow? Notably I only added a function called by Playloop (or PlayLoop?), that checks if a global tag variable is on, so it can push properly tagged walls (via PushWall)...
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 11 Aug 2018

Topics: 163
Posts: 8165
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Fri Sep 25, 2009 9:25 pm
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

No, a Divide Error has nothing to do with memory overflow. AFAIK, the only way you get an error when dividing is if you're dividing a number by Zero.
Guest




Last Visit:





PostPosted: Sat Sep 26, 2009 1:59 am
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Which I didn't. The error appeared randomly. But I didn't add myself any division myself. I could investigate, if it continues to appear. But it annoys the hell out of me that it crashes on /0. W/e. I posted this here because searches of it showed posts with APT issues too...
Codetech84
Code Master
Code Master


Joined: 12 Mar 2003
Last Visit: 10 Aug 2018

Topics: 22
Posts: 1283
Location: Rauma - Finland
finland.gif

PostPosted: Sat Sep 26, 2009 3:03 pm
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Tricob wrote:
No, a Divide Error has nothing to do with memory overflow. AFAIK, the only way you get an error when dividing is if you're dividing a number by Zero.

So you know that when memory leak occurs it will overflow the write to the next address, or something along those lines. So basically if you're unlucky enough, the variable you're dividing some other variable with, might get an arbitrary value from memory leak which could cause a divide by zero error randomly.

What causes weird, unpredictable and random glitches even more, are uninitialized variables. Something like this for example where "c" is unitialized:
::: CODE :::
int a,b=1,c;
a = b/c;

_________________
Click here to visit KFH Games website!
*UPDATED* Spear of Destiny Reloaded
KFH Games on Facebook
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 11 Aug 2018

Topics: 163
Posts: 8165
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Sat Sep 26, 2009 6:10 pm
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

True enough, Codetech. And if you misspell a variable just once, you could end up with the Divide By Zero scenario as well, for the reasons you've just posted. Smile
bitshifter
Can I Play Daddy
Can I Play Daddy


Joined: 16 Dec 2009
Last Visit: 01 Jul 2015

Topics: 7
Posts: 33
Location: Massachusetts
usa.gif

PostPosted: Sun Dec 27, 2009 12:28 pm
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Hello
Tricob suggested i leave a link to my post for saving some code bytes...
http://diehardwolfers.areyep.com/viewtopic.php?t=5577
Have fun!
lemm
Registered User
Registered User


Joined: 04 Feb 2012
Last Visit: 13 Oct 2012

Topics: None
Posts: 2

blank.gif

PostPosted: Mon Feb 06, 2012 7:52 am
   Subject: Re: [Info] Freeing Up Memory - A Must Read!
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Thanks for memboost.zip. This was extraordinarily useful. I would like to know if anyone has kept this up to date and added any more bug fixes / memory savers.
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page TopView Next Topic
Page 5 of 5 Goto page Previous  1, 2, 3, 4, 5
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts Sticky: [Info] Help for newbie coders! C++ Tutorial
Author: Dugtrio17
20 9234 Sun Jan 10, 2010 12:26 pm
Fragstein3D View latest post
No new posts [Info] Tricks - Dogs that shoot - Modifying Behaviour
Author: Guest
19 288 Sat Mar 20, 2004 7:31 am
Dugtrio17 View latest post
No new posts [Info] Alarm Sounding in game?? WSJ...??
Author: Guest
7 309 Tue Jun 17, 2003 10:04 pm
Reivax44 View latest post
No new posts [Info] Silent Gun? - Adding a Silencer
Author: Guest
4 194 Fri Apr 18, 2003 8:34 am
BrotherTank View latest post
No new posts [Info] Adding Locked Doors
Author: Guest
3 244 Thu Apr 17, 2003 6:30 am
Ripper View latest post
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
   You cannot delete your posts in this forum
You cannot vote in polls in this forum


Copyright ©2003-2008 DieHard Wolfers
A Modified subBunker Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group