Wednesday, May 29, 2013

Unpacking Saints of Virtue's .WRS Files

For better or worse, I'm probably one of the handful of people out there who takes any interest in Saints of Virtue. But hey, sometimes things just strike a chord. You can hit that HardcoreGaming101 link for all the information regarding the game. No need to repeat any of it - if by some miracle you're interested in this, then you don't need much background. This blog post is a short tutorial on how to open up the game's .WRS files and get at all of the assets - graphics, music, code, sound effects, you name it.


.WRS files are packaged, encrypted assets from Conitec's 3D Gamestudio engine, which Saints uses a very old version of (A3, to be exact). What's funny is that I used to make games in the A5 version of this engine as a kid, so imagine my surprise when my younger self recognized the bootscreen and filetypes Saints used. From that moment I started trying to hack my way in to get at the music and sounds, but no luck. There was some utility I can't remember - had Bread in the name - that was supposed to support .WRS files but it didn't work for these. I gave up, and for years I forgot about it.

Imagine my surprise when I did a random Google search on a whim and came up with this thread, detailing a working way to extract the game's assets. So here we go, what you'll need:
It's pretty simple. The specific steps:
  • Run quickbms.exe.
  • Select the saints_of_virtue_script.txt file you downloaded.
  • Select your desired .WRS file.
  • Select a folder to output to.
And we're done!  QuickBMS will dump all the .PCX, .WAV, and .WDL files to your specified folder for your perusal.

As an extra Saints note, what few people talk about this game online often complain about how you jump so high you hit the ceiling. Or, if they play far enough, they might notice that the Sword Blaster fires cripplingly slow, even with the Rapid-Fire upgrade. Both of these issues are due to the uncapped framerate screwing up the game logic. Use the FRAPS 30FPS locking technique I described in my previous Streets post to fix these problems and enjoy Saints as it was intended to be played.


Running Streets of SimCity on Windows 7 x64

Okay, well, any fan of the game knows that 'running' is a relative term. The game was always prone to crashing, even back in the day on 32-bit Windows 95 and XP operating systems. But if you're reading this then you probably know that some hot Streets action is worth a few "unrecoverable errors", as the familiar in-game popup goes. I'm going to stamp a big sloppy "YMMV" on this technique, so don't bother asking for troubleshooting help or whatever when these steps don't work for you. My guess is that it will probably get the game running on most computers but your graphics card is going to be the deciding factor.  For the record, my machine's vitals:
  • Windows 7 Home Premium x64
  • Mobile Intel 4 Series Express Chipset
  • Pentium Dual-Core T4400 CPU @ 2.20 GHz
  • 4 GB RAM
Obviously that's more than enough to run Streets. In fact, it's a damn sight too much. But more on that later.  Next up, what you'll need to follow this tutorial:
The bare-bones simple version of the tutorial:
  • Copy the Streets disc to your hard drive.
  • Replace \setup\ensetup.exe with the hacked version above.
  • Install the game using the new ensetup.exe.
  • Reboot. (Important!)
  • Replace the streets.exe file with the pre-patched version.
  • Setup FRAPS to record a 30FPS video and lock the framerate while recording.
  • Run the game with 256 color and "Run as administrator" compatibility options.
  • Once in the game, hold down your Video Capture Hotkey button for several seconds until the FRAPS framerate indicator turns pink and indicates that it is in replay recording mode.
  • Enjoy the nostalgia.
And now, the long version.

There's basically two problems that people run into when trying to play Streets on modern Windows XP and 7 systems. The first is the inability to execute a 16-bit installer on an 64-bit system. The second is that even on a 32-bit copy of Windows XP where you can get Streets to install, there's a problem where the uncapped framerate gets ridiculously high and causes problems - most visibly manifested in an AI glitch where the enemies constantly use the Hopper mod instead of actually driving around. This tutorial will fix both problems.

I created the hacked x64-compatbile ENSETUP.EXE file using the method outlined in this thread, which also summarizes the underlying problem quite nicely:
From about 1995 to 1998 it was common practice for setup programs to launch using a Windows 3.1 16-bit loader stub. This gave installers the ability to package multiple binaries for Win16, Win32s, Win32, and Windows NT for Alpha CPUs. At the time it was a reasonable thing to do since all of these platforms could execute 16-Bit Windows 3.1 applications. Today...64-bit Microsoft Windows [don't] implement the ability to run 16-bit Windows 3.1 applications. The result is that there are many, many 32-bit programs that would run fine on these OSes, but are prevented from installing. 
Indeed. If you try to run the SETUP.EXE file on the Streets CD-ROM, you'll get an error saying that "ENSETUP.EXE is missing or damaged." That's not entirely accurate, though. It's not missing or damaged, it's just a 16-bit installer! Try to execute that file from D:\setup and you'll get the following error message:


So what I did was run that setup file on an x86 Windows 7 machine and then pull the result ._MP file from the system Temp directory and rename it as an .EXE. Presto, we have an installer compatible with x64 machines.

As mentioned in the short tutorial above, you'll need to copy the entire Streets CD to hard disk and replace the old ENSETUP.EXE file with the new, x64 compatible one.  You'll notice the new one is much larger than the old one, which makes sense because it has been unpacked.  I'd recommend running it as administrator when you install the game. After that, be sure to reboot. I tried to skip the rebooting step the first time and continued through the whole process. The game worked fine...until I rebooted. It stopped launching and it never worked again. Had to uninstall and back all the way up to square one.  Don't suffer through that - reboot!

Once you've back in action, you'll probably want to copy the \sound\radio folder from your local copy of the Streets disc onto the installed version in C:\Program Files.  You can also copy the movie files and a lot of other assets as well, but it's not strictly necessary. For some reason Streets makes my disc drive sound like a buzzsaw when it access content on the D:\ drive, so the more that's on my hard disk the better.  Up to you, though.

The next step is to apply the Voodoo Rush Fix patch.  Normally you would just download it here (or, backed up here for posterity), copy it to the same folder that contains Streets.exe in your C:\Program Files installation directory, and execute it. But since it, too, is a 16-bit executable and doesn't even work with the same Temp folder extract trick as the main installer, you're out of luck. Except you're not, because I've already patched Streets.exe on an x86 system and provided it for upload above. So drop that sucker in place of the original.

A note here. This is all assuming you're using the "1.0" initial release of the game. I think that the later SIM Mania compilations have the Streets.exe file already patched, but I'm not sure. My copy is deep in the closet and I don't feel like digging. For the record, though, my original release version of Streets had a Streets.exe file with a size of 3,321 KB pre-patch. The patched .EXE is 3,338 KB.

Now you have Streets installed and patched. This fixes the first of the two problems mentioned above, but if you set your shortcut to 256 color mode and run as administrator, you'll get the too-familiar crazy hoppy AI glitch. That's where FRAPS comes in. You see, Streets runs at a very high framerate on modern systems - in the hundreds of frames per second, if not thousands. For some reason this wreaks havoc on the AI and also makes the physics and car handling way worse than Streets ever was - and we all know it wasn't too hot to begin with. What we're going to do is use FRAPS as a cheapo CPU stepdown tool to throttle the game down to a sane 30FPS. You could probably use a real CPU stepdown tool, but this method works and I can't be bothered to figure out another method. So, install FRAPS, and set up your options to look like this:


The pertinent options are to set the capture speed to 30FPS and lock framerate while recording. The other settings like fullsize/halfsize and loop buffer length are kind of up to you, but I found those settings stressed out my machine the least. But I haven't tested much. Anyway, you're going to boot up the game and then hold down your video capture hotkey - in my case SHIFT+F9 - for a few seconds until FRAPS starts recording a short replay buffer. The framerate indicator should turn pink in fullscreen mode or a sort of light blue in windowed mode. This is great because it will force Streets to run at 30FPS but it won't consume your hard drive space with a worthless multi-gigabyte video as you play.  The replay buffer feature was added in a recent (at the time of this writing) version of FRAPS, so you may need to update/upgrade if you're running an old version.

Some caveats. The game doesn't run perfectly. Sometimes FRAPS hogs too many resources and the game gets kind of choppy for a few seconds. You still get the occasional "unrecoverable error" just like the good old days. I also haven't done much testing between forcing windowed mode with -w on the shortcut arguments or running in fullscreen. Of course in windowed mode you can see everything in the correct aspect ratio, but my gut instinct is that you get more crashes that way.

But the game works! And for a few nights of mindless mayhem and rocking, thumping, jangling Jerry Martin tunes, isn't it worth it?

You'll see stuff over the internet (thanks to Wikipedia's article on the game) about using a Glide wrapper. To be honest, I had no luck with that route using nGlide - even though the program claims to support Streets once you apply the Voodoo Rush Fix patch. In fact, I had the game working and I tried nGlide to see if it would fix the framerate problem and eliminate the need for FRAPS. nGlide broke the game - it would crash every time it changed from the car garage engine to the in-game 3D engine - and I had to start over. So, yeah, screw Glide wrappers.

Hopefully this guide was helpful to you. Streets 'fans' know that this was a fun game buried beneath a lot of problems. It wasn't perfect, but most people have a skewed image of it due to the Hopper AI bug and the other problems caused by the uncapped framerate. If I'm missing any important steps let me know, but I'm not going to bother helping you with tech support so don't bother. If there's sure-fire ways to improve these steps, though, let me know about that, too.

In the coming weeks I'll hopefully have an article up on HardcoreGaming101, and when that happens that article will probably link here for a more detailed explanation. It will be good to help open the internet's collective eyes and give the game a fair shake.