| MCS' Coding Tips "Success!" |
![]() |
Abnormal Program Termination and what to do about it Written by MCS Tested by myself |
| Main Page News Wolfenstein 3D Texture Library MCS' Coding Tips - "Success"! Utilities Spear Resurrection Wolfendoom Wolf Collection Original Wolf 3D Doom/Duke maps Other Stuff Links Questions? Email us! |
| Once you get familiar with the source code, you might want to add extra stuff to the game, such as static sprites, digital sounds or new enemies and weapons. You will use FloEdit to add these items to your VSWAP file. Also, you will follow the instructions in FloEdit's helptext to make the necessary changes to your project code. You compile and link your extensions, and all goes well without errors. And then.. when you start your new EXE, the program simply bombs out to DOS displaying the infamous message "Abnormal Program Termination" You will examine the changes you just made in the code, looking for errors, but you won't find any. So what's the problem?? The problem is, you exceeded the memory limit available for common variables. I won't go too far into the technical details here. Summarized, every variable consumes memory space in the so-called "data group" (DGROUP). In Wolfenstein, this area is limited to 64K, and only 63K of it is available for user data. In the original code, there are 83 free data bytes available. Let's say you want to add some extra sounds for instance. Each one of them will consume 16 bytes. So if you've added 6 extra sounds, you exceeded the DGROUP limit and the "Abnormal Program Termination" will occur. Does this mean you can only add very few things to the Wolfenstein engine? Well, yes and no. If you want to have more data space, you have to remove some routines that you don't need. In WL_DEBUG.C, for instance, there are a couple of cheats that use lots of data space, but are not very useful (like the Tab-T or Tab-O for instance). By removing the code used for these cheats, you will retrieve about 269 extra data bytes. I had a look into the "core" ID files (the ones in your project directory that start with ID*) and I've found that they contain a lot of functions, variables etc. that were only used for debugging purposes during the development process of the original game. After cleaning up those files, I gained over 500 free bytes in the data group, that can be used for your own extensions. You can download this set of files here. Simply unzip the package into your project directory, and overwrite the files that are already there. Using this set of files, you can add a lot of stuff to your project, without the annoying "Abnormal Program Termination" message. Is there a way to determine how many remaining free data bytes are left? Yes, there is. In your output directory (usually C:\SOURCE\WOLF\OBJ) you will find a file named WOLF3D.MAP. Open this file with a text editor and go to the very last line. The line just above that one should read something like this: 3991:EFAD _bufferwidth 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. These are the figures when using the original source code. Using the modified files mentioned before, you'll start with 574 bytes free. You now should have plenty of room to add your own extensions. 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. Success! MCS. |