[Info] Freeing Up Memory - A Must Read!

Wolf3d Code & Tutorial Development Area

Moderators: Andy_Nonymous, Adam Biser, BrotherTank

User avatar
Chris
DieHard Wolfer
DieHard Wolfer
Posts: 2279
Joined: Wed Mar 12, 2003 1:03 am
Location: Canada

[Info] Freeing Up Memory - A Must Read!

Post by Chris »

Woah, my computer has so much wolf3d memory it's unbelievable! I'm just curious, everyone, when wolf3d starts up and you see the first screen... what does the left bar usually go up to? I used to have problems with this, but than I got a new laptop in february; and it would always fluxuate between 288 and 256; which was pretty cool... but now (on my new Toshiba 2.66Ghz I bought in September) mine ALWAYS says 320; and the other 2 bars are always stretched to the maximum. :)

I threw a little function into Drawscore() to display the mminfo.mainmem when your score is 0; and here were the results:

333,598 bytes free on root WinXP.
353,940 bytes free with DosBox.

Funny, also, because I was looking through TexZk's webpage for his game (which has some very cool features/ideas to it); and somehow found a link to a tutorial by MCS about getting more memory... so I downloaded his ID* files for fun, and both of those memory statistics I listed went up by another 2,062 bytes; and my bytes free in the source before getting the APT error went from 83 to 574 (and all the commands relative to the usable Tab keys still worked)! I know why it that works out like that, as there's alot of routines that don't have any noticable purposes to the game... but it's still pretty cool.

It's pretty fun trying to manage (or even just analyze) all your different forms of memory, isn't it? I've tried this alot in the past (mostly just removing/reworking functions I thought were unimportant or could be better arranged), but I have a spontanious urge to do it some more for some reason. If you've had any of your own experiences with finding ways to save room, feel free to share them. I'm gonna try playing around with Ripper's theory of removing those C0.ASM, WOLFHACK.C and WHACK_A.ASM files from the source code now. There doesn't see to be a tutorial anywhere, so this should be alot of fun. :mrgreen:
User avatar
Sockman
Don't Hurt Me
Don't Hurt Me
Posts: 67
Joined: Fri Jun 20, 2003 12:11 am
Location: City 17

Re: How much wolf3d memory do you have?

Post by Sockman »

There doesn't see to be a tutorial anywhere
Darkone has the tutorial embedded with his Getting Started Code, but I figured this one out on my own. I'll assume you're using BC3.1 :D and we'll get right to it:

1. Under the Window menu, select Project.
2. A green bar appears at the bottom of the screen. Find C0.ASM, and press the delete key.
3. Repeat step 2 for WHACK_A.ASM and WOLFHACK.C
4. Exit the Project Window.
5. Under the Compile menu, select Build All

That should do it. Downloading MCS' ID_* files also help, but you won't save as much memory as with this. Happy Wolfing!
This isn't revenge; it's punishment.
Image
User avatar
Chris
DieHard Wolfer
DieHard Wolfer
Posts: 2279
Joined: Wed Mar 12, 2003 1:03 am
Location: Canada

My memory is so high that it's overlapping the limit...

Post by Chris »

Thanks man! So how much memory you have anyways?

As much as I love playing around with the wolf3d code itself, there's some options in the Borland C++ program that I haven't even touched yet. It's pretty funny, because everytime I reinstalled the Source Code; that little window you mentioned would pop up... and I'd eventually just close it off; never to be seen again. I sometimes wondered why, but eventually I just forgot about it and never really looked into it enough to figure out how to get it back yet; unlike you - who eventually stumbled across the option on the main choices! Haha.

Thanks to your little 5 step program (and MCS's new ID* files); I now have a whopping 366,788 bytes of Base/Main Memory on my computer and 2,243 bytes left over (before hitting the APT error) to start with. Woah!!! If it wasn't for your cool tutorial, I probably would have been trying to hack into that messy WOLF3D.PRJ file itself for awhile (knowing the way I am) before even realizing that simple option on the menu! LOL. Anyone who does anything with the source code should know about this information you posted Sockman; this is too cool! :)
User avatar
Sockman
Don't Hurt Me
Don't Hurt Me
Posts: 67
Joined: Fri Jun 20, 2003 12:11 am
Location: City 17

Re: How much wolf3d memory do you have?

Post by Sockman »

Just checked on my Windows 98 (a.k.a. SockProjectComputer) and I have:

288 kb of Main memory (MAIN)
1000 kb of Extended Memory (XMS)
0kb of Expanded Memory (EMS)

Thanks for the praise.

BTW: Are you working on Chokage 2? :P
This isn't revenge; it's punishment.
Image
User avatar
wolf3dbreaker
I am Death Incarnate
I am Death Incarnate
Posts: 196
Joined: Tue Jun 10, 2003 5:08 am
Location: Philippines

[Help] Freeing Up More Memory

Post by wolf3dbreaker »

aside from C0.ASM, WHACK_A.asm and WOLFHACK.C, I am using the spear version, What else can I delete? for memory conservation?
Gone from the community for a while. Will be back on July
Guest

Re: filenames

Post by Guest »

If you want to delete some of them, then there's a link for
you to look at this :wink:

http://www.areyep.com/Codingtips/cleansrc.html


Hope that will help you out........ :mrgreen: :cheesy:
User avatar
jamez
I am Death Incarnate
I am Death Incarnate
Posts: 186
Joined: Sun Mar 16, 2003 1:22 pm
Location: Yorkshire, UK

Re: filenames

Post by jamez »

Deleted anything you want :wink: it mite not work after though lol try commenting out things like debug cheats and enemy you dont use to save memory..
~ James
Guest

Removing useless stuff that junks up the code

Post by Guest »

I added a buncha new states and enemies to Operation: Zeitgeist. I just got everything working without any Abnormal Program Terminations. Still, I'd like to clean up some more code. I've deleted most of the cheat codes (God Mode, Warp, Items, and Noclip are all that's left) and commented out the non-essential lines for all of the Spear bosses (I don't think that did anything). Right now, I'm barely passing the _bufferwidth, and I downloaded MCS's id_ files. Those helped a great deal. Still, I can't find Ripper's tutorial on the matter at all. Any ideas?
Guest

Re: Removing useless stuff that junks up the code

Post by Guest »

Look at Ripper's website.

http://www.chaos-software.de.vu/

Or you can find them in this Code Crackers, look under
Code Tutorial Link Listings (within our Forums)

http://diehardwolfers.areyep.com/viewtopic.php?t=826

:wink:
Guest

Re: Removing useless stuff that junks up the code

Post by Guest »

I tried those - the tutorial is nowhere to be found on Ripper's site. The only tutorials I see are:

Directional 3D sprites
Outside Atmosphere
Fullscreen
Shading

I know he used to have more, but they seem to have gotten displaced or something. :(
Guest

Re: Removing useless stuff that junks up the code

Post by Guest »

what kind of tutorial are you looking for :?:
User avatar
BrotherTank
Forum Administrator
<b>Forum Administrator</b>
Posts: 2203
Joined: Sat Mar 01, 2003 4:34 pm
Location: Ontario

Re: Removing useless stuff that junks up the code

Post by BrotherTank »

Sun Ce wrote:I added a buncha new states and enemies to Operation: Zeitgeist. I just got everything working without any Abnormal Program Terminations. Still, I'd like to clean up some more code. I've deleted most of the cheat codes (God Mode, Warp, Items, and Noclip are all that's left) and commented out the non-essential lines for all of the Spear bosses (I don't think that did anything). Right now, I'm barely passing the _bufferwidth, and I downloaded MCS's id_ files. Those helped a great deal. Still, I can't find Ripper's tutorial on the matter at all. Any ideas?
Those are all of the tutorials on Ripper's site...

What Ripper did mention before (in another thread - somewhere else) was this (from MCS's Tutorial on Abnormal Program Termination):
NOTE: I've been told by Ripper, another member of the Wolf community, that you can save another 1622 bytes (!) by removing the files C0.ASM, WOLFHACK.C and WHACK_A.ASM from your project. Please refer to www.chaos-software.org for more information.
The Please refer to Chaos software refers to looking at the "Directional Sprites Tutorial" which contains the information listed above...

Greg
BrotherTank
User avatar
Sockman
Don't Hurt Me
Don't Hurt Me
Posts: 67
Joined: Fri Jun 20, 2003 12:11 am
Location: City 17

Re: Removing useless stuff that junks up the code

Post by Sockman »

http://www.areyep.com/Codingtips/Idfiles.zip

A link from DHard's very own sponsor, ArEyeP.com that replaces the ID_*.H files with smaller ones, saving even more memory. Just unzip into your project directory.
This isn't revenge; it's punishment.
Image
User avatar
jamez
I am Death Incarnate
I am Death Incarnate
Posts: 186
Joined: Sun Mar 16, 2003 1:22 pm
Location: Yorkshire, UK

Re: Removing useless stuff that junks up the code

Post by jamez »

remove some of the debug functions, and if you cancel something like the death cam, remove it for real, not just a link on the object...

if you ever think u have memory problems because of strange grey patches or small border sizes, its probably because of the wrong definition in the source or too many big images in the vga files...
~ James
User avatar
Kuki
Can I Play Daddy
Can I Play Daddy
Posts: 45
Joined: Sun Mar 16, 2003 12:47 pm
Location: Torun/Olsztyn, Poland

[Info] Far memory - How to define items

Post by Kuki »

At first I'd like to say that I do not understand the memory issues in Wolfenstein (or anywhere else). I'm working on it... slowly. But I would like to know if such a line added to WL_DEF.H would place the array in the far memory cleaned by one of Ripper's latest tutorials?
static const unsigned short far blah[10]={1,2,3,4,5,6,7,8,9,10};
Kuki
User avatar
Ripper
Code Master - Developer
Code Master - Developer
Posts: 527
Joined: Sat Mar 15, 2003 7:39 pm
Location: Germany

Re: Far memory question

Post by Ripper »

To add an far array you should add a line like the following into one WL_*.C file:
unsigned short far blah[10]={3,6,23,7,8,3,34453,562,12,8569};
Of course type ("unsigned short"), name ("blah"), size of array ("10" elements) and the content can be what ever you want (of course if you have enough memory (you can't use an 400 kB array :mrgreen:)).
If you want to use this array in more than one file you can add the following line for the above example into the WL_DEF.H:
extern unsigned short far blah[10];
Type, name and size have to be the same as used in the C file.

Your example defined for EVERY C file using the WL_DEF.H an OWN blah array, so if you modified it in one C file, it would still be the same in another. Also this would take up 20 bytes for every C file ;)
So that's the difference between those two methods :mrgreen:

But now you can use this array whereever you want for everything you want!
User avatar
Hair Machine
DieHard SS
DieHard SS
Posts: 427
Joined: Mon Nov 24, 2003 8:15 pm
Location: editing my profile

Data Bytes! Darn them!

Post by Hair Machine »

I was wondering recently, as the spectre of abnormal program termination looms nearer, whether there is any way to get around the ANNOYING data byte limits of the Wolfenstein code. I assume this problem is based on Borland C++ 3.1... So is there another version of C++ that will compile the source code just as well as Borland 3.1, but also doesn't have this annoying memory limitation thing?
It would be cool to know the cost etc. of any such program. Thanks! :D
Rar rar fiddle di dee
User avatar
Sockman
Don't Hurt Me
Don't Hurt Me
Posts: 67
Joined: Fri Jun 20, 2003 12:11 am
Location: City 17

Re: Data Bytes! Darn them!

Post by Sockman »

If it edits and compiles Wolf as is, it's gotta be free by now. You downloaded BC3.1 for free, right? As did all of us I'm sure. About the abnormal memory issue; do you mean in your game, or in general, as we add more features, eventually we'll hit the wall.

For your case, make sure you've done the following:

1. Delete C0.ASM, WOLFHACK.C, and WHACK_A.ASM from your Wolf3D Project
2. Download the new ID_* files from the Abnormal Termination section of areyep.com
3. Run Ripper's Removing the Scaler's tutorial

and I'd probably remove any cheat codes you don't intend on using as well, but that is my suggestion, do the first 3 there.

If you have done these, and you still encounter the problem, I don't know what to tell you, although I don't think anybodyd can got that far with the features yet.

And in general, about eventually hitting the memory barrier, there are a few things that could be done. And now, another list!

1. Tweak Wolf to use more memory, a combo of DOS, XMS, and EMS memory
2. Go through and fix some problems inherrent to the way Wolf was coded in '91-'92
3. Or the final option, update to a higher compiler version, maybe whatever DOOM uses. But of course it wouldn't be Wolf anymore, it would require mega-changes. Plus these compilers might not be free, staggering the modding community.
This isn't revenge; it's punishment.
Image
User avatar
Dugtrio17
Code Master
Code Master
Posts: 902
Joined: Wed Mar 12, 2003 1:15 am
Location: Seattle

Re: Data Bytes! Darn them!

Post by Dugtrio17 »

Here's one I stumbled upon yesterday (when I could finally get back to the ol' computer to scratch the coding itch): Removal of unnecessary states. What do I mean by extra frames? Well, I whipped up a routine that makes enemies with automatic weapons keep firing if you're still there (since it doesn't make sense for the SS to always shoot exactly 4 times, whether you're there or not). With this implemented, those extra firing frames of Hans, Gretel, Fatface, and of course the SS were removed (though I left Hitler's alone out of pure laziness). Then I took a look at how much memory I had. 1775 bytes, new routine and all. I started out with 1467. And I didn't even remove Hitler's spare sprites!
If you're going to make this routine, be sure to back up your source first, since if messed up even slightly, you can do a lot of damage (sorta...). I won't give a tutorial, since the current code I have isn't as good as the routine I set up in Battlestein, and I can't access the source for it currently because it's on my other computer, which my brother is currently using to test out his new LAN cable-thing. It's not too hard to figure out, just get your states right...
Also, you can easily score more memory by lowering MAX definitions in Wl_def.h, but the only really useful ones are MAXACTORS (LOTS of memory to be gained, but be careful, especially if you like projectiles and lots of guards) and MAXSTATS (Less risky, but not nearly as powerful. Still, lowering it by 50 scores a significant amount of memory). But don't go lowering those until the memory is DIRELY needed, and I mean that you've already seen the abnormal program termination message.

-DAD
Image
User avatar
Hair Machine
DieHard SS
DieHard SS
Posts: 427
Joined: Mon Nov 24, 2003 8:15 pm
Location: editing my profile

Re: Data Bytes! Darn them!

Post by Hair Machine »

Thanks for those replies. Well, I have so far done everything you mentioned Sockman, except the 'removing the scalers' tutorial... Thanks for reminding me about that. I wonder how much that would save? But even with all of those cheats, files etc. wiped out I'm still getting perilously low; with only a fraction of the new sprites and things I wanted actaully added. The main problem is that I seem to call a lot of functions that munch out on my memory; and will need to call on them a lot more yet. I'm sure it's possible to iron out all of my code to save memory and stop this problem from occuring; but I'll need to get a lot better at programming first.
Dugtrio's ideas sound interesting... Thanks for those tips on MAXACTORS! I don't need an enormous amount of enemies, as my game has many RPG-ish elements in it. Also difficulty doesn't have to be achieved simply by filling a room with 40 enemies. I'm almost certain I could easily work with less actors! Thanks for that, I'll bear it in mind.
Your other thing sounds intriguing too. Maybe I'll look into it. But I'm not too hopeful about nailing that one.
Rar rar fiddle di dee
User avatar
Ripper
Code Master - Developer
Code Master - Developer
Posts: 527
Joined: Sat Mar 15, 2003 7:39 pm
Location: Germany

Re: Data Bytes! Darn them!

Post by Ripper »

Don't forget, that "data bytes" don't have anything to do with "functions"! Functions are stored in the code segment and can take up as much memory as DOS will give them. The real problem is the very tough limit to the 64kb big data segment where all non far variables and arrays are saved and also the stack has to take place in! As you know you get that abnormal programm termination if the data part of that data/stack segment becomes more than 0xf000 bytes (thats 65536 - 4096 bytes).
So to get around this problem, there are two ways:

1. Reduce the (near) data (near data is the stuff mentioned above in the data segment) or
2. Use more far data instead or in addition to near data.

But there's one big problem with far data. You may NOT use near pointers for far data! If you do, you'll get very strange results and/or crashes. That's why you can't use this so easily for actor data or something like that, because the engine assumes near pointers there.
User avatar
Hair Machine
DieHard SS
DieHard SS
Posts: 427
Joined: Mon Nov 24, 2003 8:15 pm
Location: editing my profile

Re: Data Bytes! Darn them!

Post by Hair Machine »

:shock: Wow. Now that sounds pretty hardcore to me, heheh. I wouldn't have any idea how to load data into the "far segment" or the "near segment"! What exactly does that mean? How would I go about loading ...er.... "things" into the far memory segment? Whatever, it sounds intriguing.
Rar rar fiddle di dee
User avatar
Zero X. Diamond
DieHard Guard
DieHard Guard
Posts: 268
Joined: Mon Mar 22, 2004 11:31 am
Location: The Planet of the Tiny Hut People

Re: Data Bytes! Darn them!

Post by Zero X. Diamond »

I really like Sockman's idea of tweaking the memory. I had a similar thought recently.

Why not find someone with LOTS of spare time who can program at a professional level and have them work with the source and just remove the whole stupid base memory thing? You know, like in more recent games, where they'll run no matter how much memory you have. It'd be difficult, but it'd make way for a whole new generation of games based off of the engine.

And before anyone says it's impossible, which I have this nagging feeling someone will, I just want to note that Wolfenstein 3D was written from scratch. Anything is possible, it's just that some things would be really difficult and take a lot of time and effort to produce.

I, for one, would love to see this, but sadly don't see it happening.

(And yes, I am new. So if I said something stupid, don't hurt me!)
Hooray for vaporware!
User avatar
Sockman
Don't Hurt Me
Don't Hurt Me
Posts: 67
Joined: Fri Jun 20, 2003 12:11 am
Location: City 17

Re: Data Bytes! Darn them!

Post by Sockman »

Well, I'm no computer expert (I'm pretty damn good but I've got no education in it whatsoever) but I think the main problem with Wolf is DOS. But if you lose DOS, you lose the source compatibility (not everybody can shell out $100s to get VB6) but you also drop the memory barrier.

Times have changed. Nobody needs to load in DOS low memory anymore, and having more than 256MB of ram is not uncommon. When the game was made, 256MB of ram was something the government would have at NORAD in an ENIAC sized room. Also, Windows can run operations much more stably (is stable-y a word?) than DOS, and has more technical functions. If Wolf were to be updated, almost certainly, a host/client multiplayer would be developed, OpenGL or D3D support added, possibly importing Mac graphics, OGG/MP3 support (remix the tunes!), 3D Models (good ones), and 800x600 - 1280x1024 resolutions. Bigger maps could be made. Instead of 8ftx8ft squares, vertices and sectors would be used (almost a BUILD style of game)

But this would require a complete source code rewrite. So, as, Zero X. Diamond said, yes almost from scratch. Most of the enemy AI is shit now, and you wouldn't want it anyway (how detailed is run toward the player, shoot, die for AI? (Then again, that's all the police in Vice City have :wink: )) plus weapons code would be dumped. This sounds like something you would do to experiment with a game that has no released source code, but that's what needs to be done.

So far, we've only had a few Windows ports for Wolf. There was DarkOne's NewWolf, which came along for awhile, but it seems support has stopped (does he still go on the forums?) and Adam Biser's WinWolf3D, which is nowhere near full Wolf3D support, or coming out of the beta testing phase.

The main problem is that the source came out at the wrong time. We appreciate it, but this is over 10 years after the original source release. Duke3D source was released on April 1, 2003, and now almost a year later, JonoF's port already has high-res textures and full OpenGL support. DOOM has the Doomsday JDoom engine, and some other games have had decent ports made. Not Wolf.
This isn't revenge; it's punishment.
Image
User avatar
Zero X. Diamond
DieHard Guard
DieHard Guard
Posts: 268
Joined: Mon Mar 22, 2004 11:31 am
Location: The Planet of the Tiny Hut People

Re: Data Bytes! Darn them!

Post by Zero X. Diamond »

Well, actually, all I was insinuating was a memory management rewrite. It wouldn't take Windows or 3D models or any of that to please me. I'm an old-fashioned man, living in times long passed.
Hooray for vaporware!
User avatar
Dugtrio17
Code Master
Code Master
Posts: 902
Joined: Wed Mar 12, 2003 1:15 am
Location: Seattle

Re: Data Bytes! Darn them!

Post by Dugtrio17 »

Just found another: In the thinking actor structure (in Wl_def.h; pretty easy to find, since it has "thinking actor structure" above it- you can't miss it), you'll see
int         temp1,temp2,temp3;
Delete temp3 (leave temp1 and temp2). I dug through the code and couldn't find it used once, plus when I tested, everything worked just fine.
How much can ditching 4 letters, a number, and a comma give you? Well, perhaps I should explain something. The thinking actor structure is the stuff for things like guards, rockets, you, etc. It has to hold all that stuff for every single actor, hence the reason each increment of MAXACTORS takes up so damn much memory. When you remove temp3, that's one less thing that every single actor has to deal with.
So now to the bottom line. Just how much memory do you score? It depends on your project. The actual amount is (MAXACTORS + 1) x 2. But to save you needless calculation, for just about every TC in the world, you'll net...
302 bytes. Damn.

-DAD
Image
User avatar
wolf3dbreaker
I am Death Incarnate
I am Death Incarnate
Posts: 196
Joined: Tue Jun 10, 2003 5:08 am
Location: Philippines

Re: Data Bytes! Darn them!

Post by wolf3dbreaker »

But when I deleted that line, every time I start the wolf game, My game bombs out. What's wrong?
Gone from the community for a while. Will be back on July
User avatar
Dugtrio17
Code Master
Code Master
Posts: 902
Joined: Wed Mar 12, 2003 1:15 am
Location: Seattle

Re: Data Bytes! Darn them!

Post by Dugtrio17 »

I was waiting for someone to ask this.
First, MAKE SURE that you used Make to recompile everything (or compiled every file manually) or you'll get a crapload of bugs, such as the ceiling flashing every time you fire. This is something that can happen any time after you modify Wl_def.h without hitting Make.
Also, make sure you just got rid of temp3! Not the other 2! (though I don't think it would make the game bomb out... I don't think it would even compile if you did...)

-DAD
Image
User avatar
TexZK
DieHard SS
DieHard SS
Posts: 369
Joined: Sat Feb 07, 2004 7:24 pm
Location: Northern Italy

Re: Data Bytes! Darn them!

Post by TexZK »

2 more tips:

1. Open WL_MENU.H and search for:
typedef struct {
		int active;
		char string[32];
		void (* routine)(int temp1);
		} CP_itemtype;
replace it with:
typedef struct {
		int active;
		char *string;
		void (* routine)(int temp1);
		} CP_itemtype;
Now the string can eat less memory... even if you son't write directly on the string... In this case, use "strcat()" and "strcpy()" to shut up memory errors (or you'll write on other variables...). However, menu strings are defined in the source, so it isn't a big problem...

2. Open WL_MENU.C and search for:
char far endStrings[6][75]=
{
#ifndef SPEAR
	{"Dost thou wish to\nleave with such hasty\nabandon?"},
	{"Chickening out...\nalready?"},
replace it with this:
char far *endStrings[6]=
{
#ifndef SPEAR
	{"Dost thou wish to\nleave with such hasty\nabandon?"},
	{"Chickening out...\nalready?"},
It's the same thing of the previous tip. This will preserve some memory (strings eat MUCH of it!), but take care with real-time string editing!!!
User avatar
Codetech84
Code Master
Code Master
Posts: 1282
Joined: Wed Mar 12, 2003 4:38 pm
Location: Rauma - Finland

Re: Data Bytes! Darn them!

Post by Codetech84 »

Have you tried my databyte calculator?
I urge you to try... :mrgreen: