Friday, October 1, 2010

October Horror Season 2: Day 1

Once again October is upon us and it is my favorite holiday season.  Just as last year myself and my other will be watching one movie each day of the month, broken into 4 week long categories. These are:  Vampires, Monsters, Serious serial killers, and Ghosts.  As an exercise in blogging discipline I will try to include a small review for each one.

Week 1 is Vampires and movie 1 is Fright Night, the 1985 classic vampire camp flick starring Roddy MacDowel as Peter Vincent.



At first glance the camp seemed almost overwhelming, but behind it was a movie that was just smart enough to rise above itself.  The special effects, while ridiculous, were quite good for the age; especially Evil's wolf->human transformation sequence.  MacDowel was pretty fun to watch, as well as his obviously powdered hair.  If I thought about the movie too much, I'd find finer character points to be disappointed with.  However, it's really one of those rare movies that knows exactly what it is and doesn't try to portray itself above that.  Really fun, definitely recommend watching it to anyone.  Also, if you keep in mind that the actor who plays "Evil", eventually went on to do a lot of gay porn throughout the 1990's, a lot of the jokes are a lot funnier.

Tuesday, August 31, 2010

Experiments in HTML5: Recreating Boomshine

My first exposure to the HTML5 drawing canvas was during work on my final project for a class at RIT called Web Client Side programming.  Back then, Firefox 3 was the most recent version, and only supported a subset of the specified canvas features.  Also, the spec was in a far less evolved state than it is now.  Anyway, at the time I was less than impressed with canvas and HTML5.  When Apple fired up everyone against Flash a few months ago HTML5's canvas took front page and everyone start playing with it.  I decided to give it another shot and started playing around myself.

Now, the thing to understand going to canvas from an environment like Flash or even 2D drawing with Java is that there is nothing done for you.  If you want buffers, or mouse events, or object hit detection...you have to do it all yourself.  I thought this sort of thing was going to be very difficult, that my solution would be of so poor quality it would never work well, or that it would just get too annoying.

After doing a little toying around with drawing little animations like Sine curves, and a fun wiggling tentacle mass (which I might publish here later, since it was actually quite fun getting in touch with my high school trigonometry brain), I decided to take on a larger project.  This would involve all sorts of mouse events and hit detection, basically everything I'd need in the future to do anything beyond an HTML5 toy.  One thing I know I have a tendency to do when working on my projects is spend a long time questioning a lot of mundane details, so I decided to preempt myself and work on something that's already had all the finer points worked out.  Since I was going to be doing a game I decided to think about what was fun enough to motivate me, simple enough that I could do it in a few hours, but still looked good.  The first game I thought of that met all those criteria was Boomshine, by Danny Miller (www.K2xL.com).

So I started sometime on Thursday and setup the basic template I'd need to fill in:  The canvas, floating dots, screens with a play button, a way to store levels, etc. And started working.  After setting up the main animation loop and drawing a bunch of dots, I went to go get in touch with the part of my brain that still remembered Trigonometry.

If you're not a developer, or not interested in the technical aspects of the development of the port please skip the next section.  Non technical content resumes at the bold heading.

***BEGIN SKIPPING***

With no source, I basically had to look at the game and engineer a technical description how it worked.  Essentially providing myself with an informal specifications document.

The major aspects I picked up from looking critical at the game, and the basic technique to implement them are below
  • Pseudo-randomly colored dots of constant size displayed on the play area.  There are too few instances of dark or ugly colors in the game for their selection to be truly random.
    •   I will need a palette of colors to choose randomly from.  A simple 2 dimensional array of hex codes should suffice.
  • These dots will bounce within the play area traveling in random directions at variable speeds.  There is a small amount of variance of the speed of dots traveling in the same direction, so speed is variable around an average.
    • Using a base number add a random percentage of a possible increase to it during object construction.  Also use Math.random() to find an angle between 0 and 360 and convert it to radians.  Using that angle and the speed, I can use Sine and Cosine to determine the x and y speeds to send the dot along the right line.  This works because the x and y speeds are the opposite and adjacent sides of the right triangle formed with the speed as the hypotenuse.  TRIG!
  • The bounce off the wall is done from the center of the dots, and does not slow down the dot.
    • This is simple edge detection, check if the x or y position has over stepped the bounds of the box and then reverse the appropriate axis.
  • There are 12 levels in the game, each level increases the total number of dots, and the amount of dots a player must explode to reach their goal.
    • An array of javascript objects will do this fine, I can then set total and goal properties.
  • The game keeps a running score of the number of dots exploded.
    • Global variable.
  • The player is allowed to click once per level on the play area to add a single exploding dot at the position on the board.
    • If I start the per level dots exploded counter at -1, I can allow the click event to create the initial exploding dot if that value is -1 and count that dot as explosion 0.
  • The dots explode to a certain radius on a non-linear time scale, expanding faster initially than immediately before their maximum size.  They will then shrink faster than they expanded.
    • (max radius-current radius)/max radius gives me an inverse percentage of the maximum, if I multiply that by a constant and force it to the ceiling, then multiply it again by an expansion constant I can get large numbers at low current radii and smaller ones when I'm closer to the maximum.  It's not a true logarithmic or exponential scale, but it doesn't really need to be to be convincing.  I then hold for a given number of frames and multiply the expansion constant by -2, now it will shrink along the same curve but faster.
  • Any regular dot hit by an exploding dot will immediately stop moving and become an exploding dot.  This is the "chain reaction" mechanism that defines the gameplay.
    • Each time I move a dot I can iterate a global list of dots and look for any that are exploding.  For each exploding dot I can compare the distance between the centers of the two to the sum of the radii.  If the sum is smaller than the distance, this dot has hit an exploding dot and needs to start exploding itself.
  • When all exploding dots have vanished, the level is over and the player has either met the goal or not.
    • During the main animation loop that steps each dot, since I'm already iterating the dots, I can see if any of them are exploding.  If the per level exploded count is not -1 and nothing is currently exploding, the level is done.
  • During a level, if the number of exploded dots meets the goal, the player is informed by the background color of the play area becoming lighter.
    • The background's color is broken down into RGB integer values and compared to the target color's RGB values.  The duration is divided by the framerate to compute the number of intervals to step.  The difference between the two RGB values is divided by the number of intervals to determine how far to step each interval.  A function can recursively call setTimeout to call itself only the number of times it needs to in order to change to the target color.
  • When the level ends the play area background fades back to normal if applicable and the level screen is displayed for either the current level or the next level.
    • Same as above.  The recursive function can be setup to accept a callback function to call when it's done using setTimeout to recurse.
  • The game displays up to 3 rectangular buttons on a non-play screen, these buttons will need to respond to mouse over and click events.
    • This was very difficult.  I ended up doing something similar to the dots where I created Button objects and a global controller to manage them.  The global controller attached a single click and mousemove event to the canvas.  During each event handler it would compute the x and y of the mouse within the canvas, then iterate the Button objects it was managing with those coordinates and see if those coordinates are over the Button.  I setup this Button object with a fake "addEventListener" function so I could attach my own events to the custom buttons, the controller calls these events if the hit detection matches.  For a rectangular shape the hit detection uses the isPointInPath() function after tracing a path around the edges using x, y, width, and height.  Later I expanded this to handle the speaker icon used for muting the background music.  The hit detection for that works differently since it's not a geometric shape.  I use an in-memory canvas to draw the image then the ImageData API to examine the pixel at the mouse's x and y.  If the pixel's RGB values match what I had drawn, the mouse is over the shape.

***STOP SKIPPING***


When I had enough of these requirements met, I emailed the original author of Boomshine, Danny Miller.  Danny has blogged about the frustration caused by unauthorized clones of his game, and how these clones hurt his reputation whether they are attributed or not.  I wanted partially to share my work with another developer, but also to show him I had a working port and wanted his approval to publish the game as an academic exercise.  Danny was an excellent fellow and responded to me within a very short time.  He was supportive of the port, and offered to not only cross post my writeup of the development onto his website but also to host the port alongside the original Boomshine.

I'll throw an update here whenever that happens.  For now, the port is only available at http://174.143.146.203/html5/boomshine/

Update (7/2/2013): The port has moved for reasons referenced here, the game is now available at: http://192.95.11.89/html5/boomshine/

Friday, June 4, 2010

Ok, finally: An end to my misadventures with AT&T.

I had previously written about an unfortunate turn of events which resulted from my canceling my AT&T service, namely AT&T refusing to address my lack of cell service and then charging me a termination fee when I left them.

When I had written that article in December of 2009 I thought I was over and done with AT&T.  I hadn't been contacted in quite some time, and I no longer had an account on the site.  It turns out that I was mistaken, AT&T was still pursuing my bank account with a burning rage...they just weren't bothering to let me know I had not been forgiven.

I had also made several timeline errors in that post, which I'll try to rectify here.

December, 2008:  Left Verizon and got an AT&T account and an iPhone.
- Several months of bad reception and misadventure later -

June, 2009: I move from Rochester to just outside of Boston, Massachusetts.  I now have no reception unless I walk outside.  The Palm Pre is released on June 6th, and I buy it.  I cancel AT&T because they've told me I'm not getting reception anytime soon.

July, 2009:  I speak to a rep regarding the cancellation fee on the 21st.  I am told that I should pay them, they're totally justified and deserve my money.  This person and this person's immediate supervisor are incredibly rude.  I am told that my complaint will be forwarded to arbitration or somesuch to investigate whether or not I should be allowed to leave without an early termination fee.

- Several months of no contact. -

December, 2009:  I read the article regarding AT&T's poor quality being mocked on SNL and go to check my account, only to find it's not there.  I think I'm free and write a triumphant blog post.

- Several more months of no contact. -

May, 2010:  I get a letter from a collection agency dated April 30th.  It took a few days to get to me since I moved and forwarded my mail.  Since I no longer had an AT&T account I couldn't update my address in their system when I moved.
This letter is a bill for close to $400 on behalf of AT&T.  I call them to complain, and get this bill reduced to $150.  I file a complaint with the Better Business Bureau since AT&T was nothing but rude, unjustified on the termination fee, and sent me to collections without telling me.
The next day I'm called by the collection agency who tells me I need to pay the $150 immediately or else they will charge me $30 more, so I can't even get off the phone and call AT&T again.  I pay them now or pay them more later.  While I'm on the phone with this company they let slip they're the 2nd agency to have received my account.  This is important.  In the 11 months since I last had any contact with AT&T they have hired not 1 but 2 collection agencies, the first of which didn't even try to contact me.  I didn't get a call, letter, email, carrier pigeon...nothing.  All they did was report my outstanding debt to the credit agencies.  Thanks for the black mark, guys.  I now have to watch my credit report like a hawk just to make sure that the debt eventually gets marked as paid and removed.  This absolutely sucks.

As a final little note, since AT&T is again in the news apologizing for almost sending the lawyers after a guy who emailed the CEO.  I called AT&T one last time after I settled with the collection agency and attempted to get someone to apologize for the gross mishandling, rudeness, and lack of communication over the past year.  They refused.  I could not get any formal apology beyond the scripted "I'm so sorry, sir." from the reps. Eventually I got silly.  I tried to get ANYTHING with an AT&T logo on it that said "We're sorry".  Didn't even ask for context, I wanted a stick note, or paper with some letterhead.  I even tried asking for a drawing of a sad face, not even words.  This wouldn't mean anything, it wouldn't be a public statement of anything, but it would make me feel a hell of a lot better.  They still refused.  I'm just a 24 year old kid, AT&T won't say they're sorry to me.  But this guy somehow got the public eye involved and now they're all apologetic.  I hate PR.

Thursday, March 25, 2010

How-to (Part 2): Full read/write access to ReiserFS in Windows 7

A few years ago I did a good bit of hacking and wrote this article: How-to: Full read/write access to ReiserFS in Windows Server 2008 x64

This St. Patrick's day I was at a bar with a friend of mine from my old Community College days and we were discussion virtualization software.  Yes.  I am that nerdy.  I was bemoaning my usual complaint that VMWare Server 1.x, which I used in the original article since it supported raw disk access, takes an absurdly long time to start a VM on Windows Server 2008, and also Windows 7 (presumably Windows Vista as well).  This startup time is on the order of 6-8 minutes during which the entire system is hung and unusable.  He was curious why I didn't use something like VirtualBox.  I had been under the impression that VirtualBox didn't do this since it wasn't in the GUI or listed as a feature.  However, I was wrong.

My enlightened friend shared with me this manual page. So I finally had some options, it seemed.  It took a few hours of poking but I finally got everything working with VirtualBox and it is absolutely wonderful.

So here is how I did it on Windows 7:
  1. Install VirtualBox as normal.
  2. I copied the .vmdk files I'd used to set this up with VMWare.  If you don't have these files to copy then create a new VM in VirtualBox of the appropriate flavor of linux and do the installation as per the original article.
    1. You will need to support ReiserFS and Samba, make sure your setup includes these.
    2. Create the new .vmdk as per the linked page from the VirtualBox.  You can find the drive # by populating volume properties from the device manager.
  3. In order for the raw disk access to work under Windows 7 you will need to set the compatibility options on C:\Program Files\Sun\VirtualBox\VirtualBox.exe to run it as administrator.
  4. Link the new vmdk first to VirtualBox with the Virtual Media Manager, open the VMM and click "Add" to add the vmdk(s)
  5. Create a new virtual machine of the appropriate flavor of linux. If you copied files from a VMWare installation you will need to add a SATA bus to the VM's storage configuration and add the vmdk's to that controller.  If you installed from scratch in VirtualBox don't do this now, it will only complicate your life.
At this point you should have everything installed and be able to boot your VM, and share your files back to Windows.  The only problem with this is that VirtualBox is geared more to run as a consumer level virtualizer.  If you close the window the machine starts in, the machine will be forced to shut down.  This means that you would need to keep a window open, wasting space in your taskbar, just to access your files.  Fortunately, there's a way around that as well.

  1. Set the options on C:\Program Files\Sun\VirtualBox\VBoxHeadless.exe to run as administrator.
  2. Create a new text file on your desktop, name it "Start VM.vbs"
  3. In the file, paste:



    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run chr(34) & "C:\Program Files\Sun\VirtualBox\VBoxHeadless.exe" & chr(34) & " --startvm VBoxReiser", 0
    Set WshShell = Nothing
  4. Replace VBoxReiser with the name of the VM you created above
  5. Save this file
This is why you need to set VBoxHeadless to run as administrator.  You will be prompted to allow the program to run as admin, but then you will see no further windows.  Your VM will be running in the background without.  Since you've started this headlessly you will not be able to use the standard GUI to shut down the VM later, so you will need to create another VBS or BAT file, executing:
 
VBoxManage controlvm VMNAME acpipowerbutton

This will shut the VM down, assuming it is responding to ACPI signals.
    Any network configurations you had in VMWare should be relatively simple to set back up in VirtualBox.

    I've been running this for a few days now and it is so much better.  I no longer need to dread rebooting because of the horrifying start times from VMWare.  It was fun to do a nice bit of tech stuff out of work.

    --PXA

    Wednesday, March 10, 2010

    Perverting Common Wisdom (A stock market tale)

    "Perverting common wisdom, Nephew, is the mark of all great conspiracies" - Baron Vladimir Harkonnen (Dune, Frank Herbet)

    It's an accepted premise that to make money you need to spend money. And to spend money you need to have money. So by syllogism, to make money you need to have money. This applies to the stock market quite sensibly, and most people agree that you should start an investment account with $2,000 or else you simply won't be able to make the aggregate gains required to counter commission fees. Aggregate gains is very important, because it is really how you are to play the game correctly. Most stocks will not jump several hundred dollars, or for that matter several dozen dollars, in anything resembling a sensible period of time to hold a stock. Not without some major news coming out of that company.  So you're looking to make a few cents to a few bucks on hundreds of shares.

    But what if you don't have this $2,000 to invest, is it still possible to make money? With, say, $700? If you are careful, subtle, and lucky can you make not-enough into enough?
    To this end I'm starting a new blogspot site:  A Stock Market Tale
    Hello, Readers. I'd like to play a game.

    First, my rules:
    • I can only use my initial investment of $700, and any money earned from this initial investment
    • As I only have $700 and want to make the absolute most of it, I cannot pay for any service beyond my broker.  Everything I use for my research will have to be free.  No trials either, that's just lamesauce.
    • Every purchase will be my own decision, I will not overtly take tips.  I will be required to justify each decision based on clear and rational criteria.  This isn't to say I might not ask my friends for opinions on things, but I will never ask "What should I buy?" or accept "Hey, you should buy ____, I think it'll go big."
    • Sometimes I will have to stay in cash, but if I haven't made a move in 2 weeks I will declare game over.  Temporarily, at least.
    • If I lose too much I will declare defeat.
    Now your rules: (otherwise known as a disclaimer)
    • I have absolutely no idea what I am doing.  I am in no way implying that I have developed some super secret methods or intuition.  You will not, under any circumstances, consider what I say as any form of advice.  If I write that I am doing something it is in the interest of disclosure.  If you make any decisions based on what I say, that is your own fault and I cannot be held responsible because this is not advice.
    • What I am doing I am doing as my own personal interest.  It is obviously not my job and outside of any profits I make I am not being paid for any of it.  If AdSense on the side of the official blog make any money, it's a plus but it is not the point.
    • I am not doing this as an endorsement of any official broker or any companies I might invest in.  I do not intend to reflect onto my employer or any related entity.  
    • Please understand that I'm just a dude writing about stocks with no formal training or inside information.

    The plan of attack:


    Since I have a limited amount of money to invest I'm going to be looking exclusively at stocks priced at less than $10 a share.  This is the only way I can make a net profit, any higher and I won't make enough aggregated over the number of shares to amount to counter commissions.

    Since I have no news information other than what is freely available, and most of the companies I'll be looking at just don't make news, I will be relying purely on technical analysis to pick my stocks.  I will also be mitigating my risks using stop loss orders to sell my positions if they drop too far past a level based solely upon an analysis of the chart.

    As I buy and sell positions I will sporadically update the new site (A Stock Market Tale) with details of how I'm doing, and also why I'm moving the way I've decided to.  Hopefully it'll be interesting.

    --PXA

    Thursday, February 25, 2010

    Mac's iPad and other related musings, Part 2

    And we're back...
    This was a somewhat less depressing thought I had yesterday morning when I was walking to my morning train.

    I am a huge fan of Palm's WebOS on their 2 new smartphones, the Pre and the Pixi. I've had a Pre since June and despite the fact mine is physically wrecked I still think the OS is great. I hope Palm makes more money so they can use better hardware and QA. But I was thinking about WebOS applications, being written primarily in Javascript and also the new gaming capable APIs which I believe are in Java for direct hardware access. Java is a desktop language...and Yahoo! widgets are written in Javascript. Unfortunately, Yahoo! widgets suck. I haven't really seen anyone using them out in the wild, and of course they're only available on the PC.

    But what if it were possible to use certain WebOS applications AS widgets? The Palm Application Catalog could be extended to the desktop, and you could run the same games and utilities on both. I'd written an application to scrape the mbta_alerts twitter feed and show me if my train was delayed, wouldn't it be cool to have that on my computer and take advantage of the better network connection? This also creates a 2nd distribution channel for developers.

    The way I read it, Apple's trying to put the iPad somewhere between a laptop and a device like the iPod touch. Unfortunately that space is currently occupied by netbooks. For all their shortcomings, they have one major leg up on the iPad: They are a real computer. So if Palm were to create a system which would allow their WebOS apps to run on real computers, they can not only grab desktop space but can also invade that contested area for lightweight applications running on lightweight computers.

    As far as I know, no one's created anything that can run the same applications on a mobile device, on a low-power computer, and on a full desktop. Also, Palm has been pushing the idea of reliance on the "cloud", in WebOS devices information like installed applications, device settings, and contact lists are automatically synchronized to the internet. This capability is already there, wouldn't it be EVEN COOLER if you could log in to this desktop WebOS system and get all your installed applications?

    Garsh, I hope someone at Palm is paying attention 'cause I totally want this now.

    Wednesday, February 24, 2010

    Mac's iPad and other related musings

    MaxiPad. Moving on.
    When I'd heard about Apple's tablet announcement, I thought it was a joke. Everyone wanted a Mac tablet. For YEARS I'd hear about people wanting Mac to finally make a tablet or a netbook computer. What they finally put out was an oversized iPod Touch with an extra chromosome and gimpier than Lt. Dan, and while the usual sections of the computing industry immediately engaged in fellating the device a lot of people were left scratching their heads. It has 3G but is locked to AT&T, it won't multi-task, you can't install your own software on it (App store only), you need an adapter just to get a USB port, it has no camera, no flash support, won't play widescreen video, I'd imagine it has no microphone as well, no video out either. So...what do I use this thing for?

    Anyway, it did get me to thinking, which I guess is good.

    Over the past few years I've been watching as most of the last generation of evil empires try to rescue their public image by adopting transparent processes, on the surface at least. As contrast Apple operates in complete opacity, under a shroud of darkness. Hidden away from the world in his dungeon fortress, Barad-dûr, Sauron -- I mean Steve Jobs -- steers Apple in his single-minded quest for domination. Or something. Honestly, do you know what goes on there, 'cause I don't.


    This leads into my next thought. Over at Defective By Design (The anti-DRM folks who I love dearly), they made up some great posters for the iPad launch.

    This tagline: Your computer is our computer, is a theme I've seen slowly spreading through the industry over the past few years. The players are beginning to realize the surest way to ensure continued profits is to execute control. On the other hand you can also ensure a measure of quality, as Apple demonstrated by the stranglehold they've kept on what hardware their OS will run on. Microsoft plays the side of the coin where they give the customers a measure of freedom, they want to control the industry more than the customers. I'm sure they have aspirations to get there eventually but they're gonna start at the top and work their way down. They've started with the driver signing requirements in Vista and Windows 7. For now you can turn off the verification, but you have to do it on each boot. This is already causing problems for a set of end users and spells certain doom for alternative Windows drivers. It also paves the way for increased hardware costs as manufacturers are forced to submit drivers for approval just so their hardware is compatible with Windows Future-Version. Virtualization software, which often uses system drivers to provide more direct access to system resources and better performance, will be effectively required to ask Microsoft for permission to compete with Microsoft as they product their own virtualization software. This seems like a tremendous conflict of interest. A few years ago Microsoft filed a patent for a method of building DRM control into an OS kernel, I think this is the first step towards that end.

    Apple's interests, it seems, lay in squeezing their consumer base for cash. They've already begun teaching people to expect less capability for the same price. The iPad does less than an iPhone or iPod Touch and costs much more. The MacBook Air was a bad machine, and didn't even have an optical drive but cost more than any other laptop of similar capability. And they've been hiding configuration options on their OS since its inception. And as an amusing aside, one of the reasons cited for rejecting the Google Voice app from the the App Store was that having another phone application on the device might confuse their users. This is probably why all their hardware has rounded corners -- so their users won't hurt themselves by chewing the edges, because they clearly think people are that stupid.
    Their recent patent is for displaying advertisements through the OS. The filing includes a flow chart for how the OS could determine when to play an ad, and it includes checking to see if the user has pre-bought time. That's exactly how it sounds...Apple thinks there is a strong possibility that sometime in the future people will be willing to rent ad-free time on their own computers. The patent also specifies that the OS could disable key features such as the mouse or keyboard except when prompting for interaction to make it impossible to not watch the advertisements. The only way this will work is if people accept the idea that what they have paid for is not theirs. That a computer is similar to the digital tuner box that TV companies will rent you and that your use of the OS is just a service you pay for.

    Wow, I hope neither of these folks get what they want. I like being able to choose things about my computer, and I like the idea that I own it and can beat it into doing what I want provided I'm clever enough.

    More upbeat musing coming soon.