Difference between revisions of "MS-Edit"

From UFOpaedia
Jump to navigation Jump to search
m (added Fixing the Difficulty Bug with MS-Edit)
Line 43: Line 43:
  
 
To use MS-Edit to fix the difficulty bug in X-Com UFO Defense/Enemy Unknown follow these easy steps:  
 
To use MS-Edit to fix the difficulty bug in X-Com UFO Defense/Enemy Unknown follow these easy steps:  
 +
 +
'''Step 0''
 +
 +
Before anything else, as a safety precaution, make a backup copy of the '''ufoexe\geoscape.ex'''e file in your game folder.
  
 
'''Step 1'''  
 
'''Step 1'''  
Line 112: Line 116:
 
'''File > Save''' and finish up with '''File > Exit'''  
 
'''File > Save''' and finish up with '''File > Exit'''  
  
And you're done. Launch the game and enjoy it on the proper difficulty levels.  
+
And you're done. Launch the game and enjoy it on the proper difficulty levels.
  
 
==See Also==
 
==See Also==
 
*[[Game_Files]]
 
*[[Game_Files]]

Revision as of 09:49, 19 July 2012

MS-Edit is an old simple text editor that was introduced as an offshoot of the QBasic IDE (integrated development environment) that came bundled with some of the tools in MS-Dos 6.0. In fact, MS-Edit was Qbasic but run with a separate switch so that only its plain text editing abilities were available. As of version 2.0.026, MS-Edit was no longer tied to Qbasic and was its own separate program and came with various improvements.

One of the improvements that it gained was the ability to read and write binary files at varying line widths. This allows you to use MS-Edit to open binary files as tables of information. This doesn't work with binary files that have varying structures of information such as the executables. In such a case, you can open files with line widths of 100 and use decimal file offsets (offset by 1) to get to the part of the file you wish to work on.

Though unorthodox, particularly with entering the offsets, it's easy to master and is prepackaged with a lot of the legacy programs that come with many versions from Windows 95 to XP.


To use it

  • /Start /Run then type EDIT. Alternatively, navigate to Start --> Programs --> Accessories --> Command Prompt, then type EDIT. If you use this tool a lot for editing, you can make a shortcut to it and place it on your desktop or start menu for easy access.
    • If you want MS-Edit to display the maximum number of horizontal lines as your hardware is capable of, type EDIT /H instead.
  • Point to the game file of interest. This DOS tool uses some old established directroy conventions such as the two periods (..) at the top of the Directory list. This moves you up one directory level. Use Help (F1) for more info.
  • Once you've highlighted the file of interest, checkmark "Open Binary"
  • If you know the record length for your file of interest, enter it on "Line Width". For example, SOLDIER.DAT has record lengths of 68. This causes file entries to "line up" and makes patterns obvious like a spreadsheet.
  • If you're new to hacking, checkmark "Open Read-Only". This prevents you from making changes.


Editing

  • The "Col" and "Value" info along the bottom bar show you the current byte column you're in, and its value. Use this when comparing your file against e.g. the SOLDIER.DAT and UNITREF.DAT wiki entries.
  • Many folks talk about byte positions using offsets (starts at 0, and is indicated by [square brackets]) whereas EDIT does not (starts with column 1). If the values don't seem to be jiving, try looking one column to the right (or left!).
  • WARNING: When you first start to edit, hit the Insert key once to get the big block cursor. This puts you in Overwrite mode instead of Insert mode (the small underline cursor). Be VERY CAREFUL about hitting the Insert key again. Insert mode is a Very Bad Thing(tm) for binary files. Inserting a byte moves every subsequent byte over by one, thus nuking position-based files (i.e., most XCOM files). If your game has gone south and you're SOL though, you might give it a shot... you never know what might happen!
    DOS Characters in MS-Edit
  • Likewise, be VERY CAREFUL about hitting keys like Delete, Backspace, or Enter. All these (and more!) mess with positionality. If you ever see that records aren't lining up, Close without saving!!
  • To enter numeric values into a byte:
    • Hold down an Alt key (either one)
    • Using the NUMERIC KEYPAD (the numbers on right side of keyboard, not the ones along the top of keyboard), type in the number you want to enter. It doesn't matter if Numlock is on or off.
    • Let go of the Alt key. In the case where your computer doesn't have a numeric keypad such as a laptop, you must press the function (Fn) key along with ALT in order to enter these values.
    • The number will now be entered. However, for values less than 28, you have to go through special gyrations (these were "control characters" for DOS). First, hit Control-P (^P). Then:
      • For 0, hit ^2 (don't ask why)
      • For 1-26, hit ^A to ^Z. For example, ^A is 1, ^M is 13, ^Z is 26.
      • For 27, hit ^[
  • A handy lookup table for numbers versus characters can be found as a .GIF (see right) or the same thing in a .PDF here
  • If you see that your number makes a "regular" character (e.g. 65=A), you can also simply type in that character. However, the space character (number 32) looks just like a null character (number 0); don't use a space to mean zero!
  • Make a copy of the file if you're unsure of what you're doing. EDIT prompts you about making a .BAK backup file when you save edits, which is a nice convenience.


Misc Notes

  • Some savegame files store 'rubbish' in a field that's not being used. For example, not all soldier and alien names are 25 characters long (26 including the null byte, value 00, that shows where it ends). You'll usually find rubbish stored in the columns past the name end. It can be the remains of old (longer) names, or might even be e.g. random Windows crap that was in that position in RAM when the file was last in memory. Garbage characters may also show up in e.g. fields that an alien doesn't use (but soldiers do). Don't worry about them... if there's no reason for the game to use them, they're meaningless.
  • If you have a file open in EDIT, it is not locked by the system. You can keep the file open indefinitely even when the game is running and nothing strange will happen. Just make sure to save your changes so that they show up. In the case if the executable, it is always best to save and restart.


Fixing the Difficult Bug with MS-Edit

To use MS-Edit to fix the difficulty bug in X-Com UFO Defense/Enemy Unknown follow these easy steps:

'Step 0

Before anything else, as a safety precaution, make a backup copy of the ufoexe\geoscape.exe file in your game folder.

Step 1


Open Geoscape.exe in binary mode with a column setting of 100.

To do this, you can do it from the Dos console. Change into your UFO Defense/Enemy Unknown folder and type the following:

edit /100 ufoexe\geoscape.exe

Alternately, open MS-Edit, go to File then Open... and look for geoscape.exe in the game's ufoexe\ directory. Select it, then check Open Binary and set the Line Width to 100. Finally hit OK.


Step 2


The next step is to locate the affected byte and alter it. Refer to the bottom right corner of the screen for the Row, Column and Value information.

Ms edit Screen.png


Use the Page Up, Page Down and cursor keys to change the cursor so that the row and column values match the following. Pick the one appropriate to your version of the game.


Game Version Row Column
DOS Version 1.0 973 29
DOS Version 1.2 1011 69
DOS Version 1.3 1011 69
DOS Version 1.4 957 77

Note that many CD-ROM versions of the the game are v1.4 by default. The dos portion of the Steam release is 1.4.

Once you are at the specified row and column, your cursor will be resting on a < symbol and the value field should read 60. If not, you might have a different version - try referring to the other row/col values until you find this symbol.

If it's showing an @ symbol and a value of 64 - then your bug is fixed and you don't need to do anything further.


Step 3


Press Insert to switch your cursor to the block cursor.

Now the moment of truth: you need to replace the value of 60 with 64. To do this, type an @ symbol to replace the <.

Alternately, hold down alt and type 064 on the numeric keypad.

Important: If you weren't using the block cursor, make absolutely sure you use delete or backspace to remove the < symbol after entering the @. Not doing this will increase the size of the executable by 1 byte and really mess it up.


Step 4


File > Save and finish up with File > Exit

And you're done. Launch the game and enjoy it on the proper difficulty levels.

See Also