Wednesday, February 25, 2015

Take Flight with Fly! II

When people talk about flight simulators for Macs, they mostly talk about X-Plane, but there was another somewhat overlooked flight sim for PowerPCs called Fly! by Terminal Reality. Actually that was the name of the first incarnation, but the sequel which we'll mostly focus on here was called Fly! II and ran on both OS 9 and X. I had the original Fly!, but when Fly! II came out I didn't give it much thought as it was met by a bunch of negative reviews for being incomplete and rushed. The distributors apparently thought it was more important to compete with a new Microsoft Flight Simulator release at the time than it was to put out a finished product.

Fast forward a few years and I see Fly! II is abandonware on Macintosh Garden, so I decided to check it out. While the interface was less polished than the original Fly!, it offered better graphics and made for a potentially better development platform for creating custom scenery and additional aircraft--if you could get the editing functions to work. And this illustrated one of the biggest problems with Fly! II. It was buggy, and on Macs the built-in editor didn't work. It turns out there were several patches released, coalescing into one grand final patch, but the Mac version of it seemed to have completely disappeared from the web. It was supposedly available at the AVSIM Library, but they had a hacker attack a few years ago and didn't keep backups, so they suffered massive data loss including the Mac patch.

So we were kind of stuck. But then, just recently, a random good samaritan uploaded the final Mac patch to Macintosh Garden and rescued us from our doldrums. I ran the patch, and suddenly the editor works. I can import elevation meshes without it crashing, 3 arc second elevations that address one of my biggest problems with Fly! II graphically.

When you first run Fly! II, you get just the default scenery and elevations. The generic scenery isn't bad, but the elevations have so few data points it makes everything look like rolling hills. So I downloaded a bunch of 3 arc second elevation tiles from the USGS website (one data point every 90 meters), imported them into Fly! II, and what a difference it makes. Everything looks more realistic, and familiar geographic features look familiar again. Here's an example of Washington's Mt. Rainier with the default elevations and the enhanced (click to enlarge):

Fly! II default elevations

Fly! II enhanced elevations

 So now with these new elevations, I can finally enjoy Fly! II with all its other advantages over X-Plane, including its superior plane and flight models and overall realism in flight procedures. The enhanced elevations I made cover the US West Coast (most of Washington and Oregon, all of California, and parts of Nevada), and if you want to download them I've made them available here. But all that would be kind of useless if you live somewhere else, so here's a quick tutorial on how to make your own elevations in Fly! II.

First, go to USGS's Earth Explorer website and choose the area you want on the map (click to enlarge):

Earth Explorer screencap

Then click the "Data Sets" tab and expand "NASA LPDAAC Collections", then "NASA SRTM (SRTM3) Collections", where you can finally choose "NASA SRTM3 SRTMGL3". Click the "Results" button and you can download the files.

When you unzip them on your hard drive, you get a bunch of .hgt files that you must rename to a .ras extension. Now you can import them into Fly! II by launching the program and pressing Command - e to enter the editor. Under the scenery editor's Tools menu, select "Import Scenery...", then check "Generate Elevations", choose your DEM file to import, and fill in the necessary data. The example below is for the SRTM3 file N32W115.hgt which I renamed N32W115.ras (click to enlarge):

Fly! II editor

The first row latitude and longitude is for the lower left corner of the tile, and the second row is for the upper right corner (the longitudes go backwards when counting from west to east). The samples width and height are always 1201 x 1201 for single tiles. For "Subdivide Tolerance" the default is 500 feet, but I changed it to 200. Some people recommended going all the way down to 50, but you'll pay a price in framerates. For even better detail, change the "Maximum Density" from 4x4 to 8x8, though that may cost you a few frames per second, too. Experiment with what works best! Finally, click "Import" and let it do its thing.

When doing these one at a time, the results aren't perfect. Sometimes data from neighboring tiles gets overwritten and some blank spots will occur where it falls back to the default elevations. A better way is to combine the .hgt files into one big .ras file, but for that you need two Windows programs, 3DEM and 3DEMBin2Ras (available at the AVSIM Library), and either Virtual PC or an actual Windows computer. I have Virtual PC 4, and it worked but since Virtual PC 4 has a 512 MB memory ceiling, I was limited to combining only 6 x 6 squares. In any event, the process is simple. Open the multiple .hgt files in 3DEM, wait for it to render, then choose "Save Terrain Matrix" from the file menu. From the save options that pop up, choose "Binary Signed Integer. This will give you one big .BIN file which you then use 3DEMBin2Ras to make a minor endian conversion so the file can be imported into Fly! II. The resulting file will have a .RAS extension which you must rename to a lower case .ras. Apparently Fly! II only likes lower case extensions.

When importing a combined .ras file into Fly! II, the procedure's the same as a single tile, except the sample width and height will be some factor of 1200 plus one. For example, a 2 x 2 square (2 tiles across horizontally) will be 2 X 1200 + 1. So the sample width and height will be 2401 x 2401. For a 4 x 4 square, the width and height will be 4801 x 4801, and a 6 x 6 square will be 7201 x 7201. And for this I only tried perfect squares--I don't know if 3DEMBin2Ras conversions work on rectangles.

Finally, be mindful that you get the lower left and upper right corner coordinates correct on the combined files.

Online resources for Fly! II are starting to dry up. For a long time there was the site Fly.Simvol, but lately it's giving an "Internal Server Error." (looks like it's back up now) It's still accessible with the Internet Wayback Machine. Also, their downloads are still available at including some cool planes and France scenery add-ons, but I don't know how long that'll last so grab them while you can.

Another good resource is the AVSIM Library (free registration required). There you can find all kinds of user-created scenery add-ons and utilities, etc, of which I plucked many taxiways and airport sceneries. There's also a file library at which has "Fly!II Blue Sky", a sky.ini replacement that looks much better than the stock sky, especially with water reflections turned off.

On the subject of performance tweaks, there are a couple of hand edits you can make to improve framerates. The simulator itself has several scenery sliders and sound options you can adjust, but beyond that you'll want to open fly.ini in Fly! II's "System" folder and change the "popBuildingsIntoView" value from 0 to 1, and "popBuildingsTolerance" to something like 8 or 10. These changes make 3D buildings pop into view only when you get close, and increasing the "popBuildingsTolerance" value decreases the distance at which they become visible.

Also, open render.ini in the same folder and you'll see about a dozen MaxTextures lines. I changed "maxTextures128" from 64 to 250 and got a modest boost in framerates, but more importantly the simulation became much smoother and less herky jerky. This has to do with the slots Fly! II allocates to your graphics card, and flying with the debug info turned on, I saw that there was a logjam with the 128 x 128 textures. You can read more about render.ini settings at the Fly.Simvol FAQ.

Your Mac's menubar will present somewhat of a complication. In the original Fly!, the space key could hide it, but in Fly! II it's always there in the way. To hide the menubar with the space key in Fly! II, you need to add the line "allowHiddenMenubar=1" to your fly.ini, and this will only work in Mac OS 9, not in OS X. And it's a bit glitchy when unhiding, which is probably why it's not there by default. Though OS X users can't hide the menubar, they can run the simulation in windowed mode to get the full 1024 x 768 resolution without the menubar blocking its portion of it. To do so, have "autoFullScreen" equal 0 in fly.ini.

Though it's getting long in the tooth, Fly! II is definitely still the best flight simulator for Macs running OS 9, and may even be the best for PowerPC Macs on OS X. Hardware requirements are somewhat different depending on which system you have. Framerates are better in OS 9, so there you may want a 733 MHz chip or higher with a decent graphics card. OS X users will need a higher end PowerPC. It runs reasonably well on my aluminum Powerbook, but I wouldn't want to use it on anything less.

One last note about the elevations I made, there's a hole in the Earth off the coast at San Simeon, CA, near where Hearst Castle is. This is due to that particular SRTM file having the ocean at an elevation of -9 meters, which the Fly! II editor interprets as a bottomless fathom. I suppose you can edit the data files to fix it, but I decided to leave it in as a monument to weirdness.

And since this post is approaching terrorist-manifesto-length, I think I'll sign off now.

Thursday, February 5, 2015

Adblock Plus vs. uBlock vs. Bluhell Firewall

It's been awhile since I did one of these Spy vs. Spy posts, but with a couple of new ad blocking extensions on the scene, what better occasion for a good old-fashioned deathmatch? The two new kids on the block are uBlock (now called uBlock Origin, see update at bottom) and Bluhell Firewall, both Firefox extensions with uBlock also available for Chrome and Safari. They'll be taking on the gorilla in the room, Adblock Plus, the ad blocker practically everybody has on their computer. But do they know what lurks beneath?

Adblock Plus has had its share of controversies, but one of the main ones has been its performance. It's been accused of slowing the browser launch and being a memory hog, even if it does eliminate more ads than the competition. Bluhell Firewall and uBlock advertise themselves as being significantly lighter on resources, so let's put them to the test and see who's truly worthy.

I'll be testing for browser startup time, RAM usage on startup, and RAM usage with three tabs open (the three being IMDB, OS X Daily, and Gawker). The tests will be done on my Powerbook with TenFourFox 31 running a fresh profile with no other extensions. As a frame of reference, let's start out with no ad blocking:

startup time -- 8.5 seconds
RAM on startup -- 122 MB
RAM with three tabs open -- 265 MB

Those numbers are rough averages after a couple of run-throughs. Since the results were consistent, I didn't bother with more than two. Now let's get to Adblock Plus:

startup time -- 15 seconds
RAM on startup -- 200 MB
RAM with three tabs open -- 375 MB

The startup time includes about five seconds of a spinning beach ball while the ad blocker initializes. As you can see the memory went way up. Now let's see how uBlock does:

startup time -- 8.5 seconds
RAM on startup -- 165 MB
RAM with three tabs open -- 280 MB

No impact on startup time and modest bumps in memory usage. Finally, here's Bluhell Firewall:

startup time -- 8.5 seconds
RAM on startup -- 123 MB
RAM with three tabs open -- 215 MB

If memory is what you're going by, Bluhell is the clear winner. But does that mean it's the best? Its filters not being as extensive as Adblock Plus's, it lets the occasional ad through. It also lacks a whitelist feature, so you can't make exceptions for websites you want to support. Some people also report some site breakage.

In my opinion, uBlock is the more interesting alternative. It supports whitelists and is available on all major browsers. And as far as ad blocking goes, it's no slacker compared to Adblock Plus. In fact, Adblock Plus was overly aggressive, filtering out all of Gawker's "Promoted by..." posts. Most of those are embedded ads, but some are guest essays that, no matter how pretentious, should never be blocked.

I've always used NoScript combined with CSS rules based on floppymoose (the one shipped with Camino, to be exact) for ad blocking, but it's kind of a pain to edit your UserContent.css to include new rules for ads that get through. UBlock seems the more up-to-date option. In any event, NoScript should remain an essential item in your PowerPC toolbox to keep the Web loading fast and smooth while avoiding javascript catastrophes like this one, or this particular holocaust. I know there are a lot of about:config tweaks out there that promise big speed benefits (pipelining, etc), but they don't deliver much. To enhance the speed of your browser, it's really all about NoScript and a good ad blocker.

(UPDATE: Since the writing of this post, uBlock's original developer has left and begun a fork called uBlock Origin. UBlock will continue with new maintainers they seem to have stopped development. UBlock Origin has dropped support for Safari, so Safari users should stick with uBlock.)