Wednesday, March 10, 2010

Chome and XSLT

I've built a web portal for my own use that integrates search engines, categorized favorite links and custom styled RSS feeds into a single page. It's a hodgepodge of ASP, VBScript and JavaScript with an XML as the backend and jQuery/UI to liven things up.

Initially working with FireFox as my default browser, everything was working fine until I decided to install Chrome. That when I got the error message: Extra content at end of document.


This gave me quite a headache until I traced it to the XSL processing in my JavaScript. I didn't quite understand what was causing the problem until I realized that Chrome didn't like what I was doing inside my {xsl:template}.

It turns out Chrome expects a only single child node (or document if you like) inside an xsl template and was complaining about anything coming after it. So you can't have this: (sorry about the curly braces, it seems blogger doesn't play nicely with code tags)

{xsl:template match="/rdf:RDF|/rss"}
{img src="...."}{/img}
{div}
...
{/div}
{xsl:template}

To fix this problem, all I did was wrap everything in another div.

{xsl:template match="/rdf:RDF|/rss"}
{div}
{img src="...."}
{div}
...
{/div}
{/div}
{xsl:template}

... et voila ...




Thursday, January 21, 2010

Hackintoshing

I installed OSX on my PC last year, and I thought I'd document what I did and what I went through to get it up and running, in case a future me decides to reinstall all over again, or install in another PC.

OSX is visually appealing, and although it's interface might take some getting used to when coming from a Windows background, its responsiveness and intuitiveness wins you over easily.

OSX is based off Darwin, which is a UNIX variant, and while there are many tools to help you setting up, sometimes you might have to go through a command line and sudo your way into the system, so it helps to brush up on unix commands.

Installing OSX on an x86 platform is possible now due to the fact that Apple switched from a PPC architecture to the x86, with Intel as its target. There are subtle differences between PC hardware and a Mac, and OSX is specifically designed for Mac hardware.

iDeneb contains many patches to get OSX running on your system, however as Hackintoshing is a very much experimental field, and with the variety of PC hardware out there, you might have a rig that is not 100% compatible with the distro and you will need to go hunting for drivers for your specific hardware.

Installer: iDeneb v1.1 10.5.4

System:
Intel Core 2 Duo E4500
ASUS P5B-MX WiFi MoBo
3GB RAM
Inno3D GeForce 8500 GT 512MB
Windows XP SP2 on C:\

First off, my DVD-ROM is broken, so I had to resort to using Leopard HD install helper. This tool will dump your ISO into a hard disk and make it bootable.

I partitioned my 2nd hard disk into

8GB - format as FAT32 (through command prompt in XP)
20GB - leave unformatted
The rest - data partition

Using the helper I installed the iDeneb ISO to the 8GB. The default options make the HDD bootable and add a "Mac OS X System" option to your windows XP boot menu.

Rebooting, I chose the second option in the boot menu and it booted into the Mac OSX installer.

Using Tools > Disk Utility I "erased" (formatted in OSX lingo) the 20GB with the Mac OSX Journaled partition type. Close the Disk Utility and select the 20GB from the choice of target HDDs.

Before continuing the installation I clicked the Customize button and set the following:

AMD patch: Not needed (Intel CPU)
Audio: AC97 (from mobo's built-in audio)
Fix: AppleSMBIOS: 800 (an article suggested ASUS mobos need this)
Video: None for now
Network: none for now:
Chipset: ICHx and JMicron
Other: OSX86Tools

I found out that the version of Firefox included was Italian, so I wouldn't recommend installing that right now.

Installer took 10-15 minutes then rebooted.

The chipset is important and should match your chipset, otherwise your OS will hang when booting.

Booting successfully into the OS you are greeted with the Mac "Welcome" video, after which you go through a wizard to adjust settings.

However (for me), when prompted whether to restore data from another Mac or from Time Machine, I of course chose not to do so, and the disk whirred and the busy icon came up and I was thrown all the way back to the Welcome video.

Some people say that you can get past this by re-enabling the serial and parallel ports and legacy usb in the BIOS.

If that doesn't work, you can bypass the first time setup by doing this:

When booting into OSX, you have 5 seconds to press any key to get the boot options command line. At the boot prompt, enter the option for single-user mode (with command line) and press enter.

> -s

At the root commandline, enter the following, waiting for the prompt to appear again before typing the next line:

> sbin/fsck -fy
> sbin/mount -uw /
> passwd root

Now enter the new root password and the confirmation. You won't see the password being typed.

This ensures the password is set so that we can login later. Now we create the file that notifies OSX that setup is complete:

> touch /var/db/.AppleSetupDone

Now reboot with the command:

> reboot

Instead of the welcome screen we get the login prompt for root. Go ahead and enter your password to login as Administrator. Since we skipped the user account creation in setup make sure to create your own Admin account in System Prefs > Accounts.

Now I have a working OSX installation, all I need to do is install the correct drivers. A bit of googling got me the drivers for my AttansicL1 ethernet. Drivers come in the form of Kernel Extensions (kext) which you can install using Applications > iDeneb tools > OSX86Tools.

I downloaded FireFox and Adobe Flash and got that working seamlessly, and I was browsing, facebooking and even playing FarmVille in no time, and with no problems.

Tuesday, April 7, 2009

Excel Office 2003 Documents opening as read-only in SharePoint

Recently I've been getting issues with users complaining that their old Excel files are now opening as Read-Only, and that in order to update the document they have to Save-As to their desktop then re-upload - which kind of defeats the purpose of SharePoint.

I've tried some of the recommended fixes from various sites, including the one from Microsoft which says that it won't work for Sharepoint (but other users say it does), and they just don't work on my machine. I don't want to try to do those fixes manually on the user's machines either.

In desperation I tried to find out exactly what was going on, using RegMon from Sysinternals.

What I found is that when a user clicks on a Document URL from the web, IE launches Excel using the OpenAsReadOnly shell command (by default).

By modifying the registry so that the command to Open as Read Only would essentially do the same thing as the regular Open command, I was able to workaround the situation, although for some users this was temporary - the next day something restored the settings back, and they had to run the registry hack again.

I don't know when Microsoft decided to change this policy of how documents are opened from the web, or how it was distributed to our network or our users. There are sites that say that this is by design, which begs the question, why did it work the way it did before?

I do agree that it should be fixed by using the Edit in Microsoft link, which incidentally launches an ActiveX object to open the document in Read/Write mode, but it just doesn't satisfy my curiosity as to how things were before they started working "as they should".

For anyone interested, I am on WinXP SP3, MS Office 2003 Standard Edition, with Compatibility Pack for the 2007 Office system (KB923505) installed.

Copy and paste the below into a text file and save as .REG:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Excel.Sheet.8\shell\OpenAsReadOnly\command]@="\"C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE\" /e"




Monday, March 23, 2009

Hiatus

I haven't done any programming in a while now. It's probably because the PSP plugin I was trying to make was totally pwned by another person's plugin.

The plugin is another attempt to allow a user to organize games and applications into folders on the PSP, and it does the job in a much better way both interactively and programatically, and I wave the white flag and now use it myself.

It's also because I can seem to find the time I need to really get into programming. I really don't want to break my time down for you in order to illustrate, but four hours of programming sometimes just doesn't seem to cut it in order to learn or make something useful.

Perhaps it's just that I don't have a focus right now.

So I've dropped programming for a while and now I'm going back to playing games.

Recently I've started playing Final Fantasy VIII again. It's one of the RPGs I've already finished, but more or less enjoyed enough the first time around to warrant a second playthrough.

The first time I played it, I was in college, and I only rented to play the game, so I didn't have much time to really get into it, nor did I finish it.

The savegame slept on my memory card until the day PSX emulation became feasible, and following instructions, I made a memory card reader out of a floppy disk connector and some instructions on the web.

The second time I played it, I between jobs and had so many games to play that I didn't really bother to spend the time to get to know the game that well.

I'm playing it on my PSP nowadays, more or less for nostalgia than the need to finish it. I could be spending more time on Patapon 2, but I've grown a bit tired of killing bosses over and over again in order to level up my army so I can go back to killing bosses over and over again.

Maybe it's my video card, but Resident Evil 4 gets me motion sick after a few minutes of play. Then again I was never really a fan of first-person-shooters.

I haven't touched Final Fantasy X in a while. I'm using PCSX2 to emulate it (I don't own a PS2), and fortunately my video card can crank enough polygons per second to make it playable.

It'd be nice to own a PS2 and play all those great games, but I can't bring myself to shell out some money to buy a second hand unit and some games with scratched or second-rate DVDs.

Maybe if someone sold me one for Php 4,000, I'd bite. But that's almost a new Inno3D GForce 9600 GTS DDR3.

Thing is, I'm not even much of an avid PC gamer.

*sigh*

Tuesday, March 10, 2009

Hitched!

After five years, we finally got married!

My dear Fransly and I tied the knot on February 28, 2009 at the Hearts of Jesus and Mary Parish Church, at West Triangle subdivision in Quezon City.

My father decided to come late to the church, but I didn't let that ruin the day for me. The road leading to the front of the church was torn up for repairs/renewal, but I didn't let that ruin the day for me.

The cloudless day brought a heat wave but also gave perfect lighting for picture-taking. Hats off to the Ariel Javelosa team for grabbing such lovely pictures. Thank you Max!

Reception was held at the Gazebo Royale's Champagne hall, where we surprised everyone (photographers especially) by running down the red carpet to the front of the pavillion where we had our first dance that rocked the crowd and really set the mood. I have Donna to thank for coreographing, and Tina and Onchit for joining us in the dance.

Dinner was quickly served. We didn't get to eat much with all the photos being taken, but everyone seemed to enjoy the food served by Eloquente, while Seren8 played our choice of music.

After the AVPs, the games, and everything to everyone's surprise I sang "Beautiful in My Eyes" and though I botched it a bit at the second stanza, nobody seemed to notice.

The deal was, Fransly wanted me to sing either that or "Danny's Song" (I really didn't want to sing the part "I think I'm gonna have a son" because then people might interpret it literally), but wanted it to be a "surprise", so she didn't know when I was going to sing.

I would have wanted to sing "The Way You Look Tonight" using Steve Tyrell's version, which IMO is more jaunty than the original or Buble's, since I know the lyrics better, I might not have botched it. Oh well.

Hitched! provided us with on-the-day wedding coordination and lots of help hooking us up with the wedding band and other details we missed. We couldn't have done it without you.

Partypics provided the photobooth which doubled as our souvenirs.

Overall, it was the best wedding I could have wished for.

To cap it off, we spent another day at the Linden suites, which I didn't really get to enjoy all that much as I had a really bad cough.

Finally, I must thank my dear wifey for rubbing her nose against mine and stealing that kiss (I know it was you!) If not for that fateful day, none of this would have happened, and I wouldn't be as happy as I am now.

Tuesday, December 30, 2008

Plugins for the PSP - 2

My efforts to ask for any help of the QJ.Net forums on hacking the PSP to add something similar to folders in the GAME menu created a rather lengthy thread that was filled with a lot of critiscm.

Eventually I posted some information that more or less showed that I knew what I was doing, and then the tides turned. Those who were telling me that what I was doing (disassembling the game_plugin module) was next to impossible, was silly, and was clearly the wrong approach, now nodded and said that what I had found was correct, and that they knew that information all along, and even offered me to join a group they were building devoted to hacking the VSH modules.

I don't really see why they are so uptight about sharing that information, when all the stuff they can actually do to hack the PSP was made possible by the sharing of information.

Anyway, I'm once again on my own. I've been a bit busy and I haven't had time to work on this. I shouldn't be spending so much time working on this project, as I'm about to get married in 2 months and there's a still lot of things that need planning and preparation.

With the slightest bit of help I have found the code that executes when the user selects a game, so I'm that much closer to realizing my goal. All I need to find know is how the code passes around the information containing the selected game, but finding this is a bit harder than I expected.

Wednesday, December 10, 2008

Plugins for the PSP

I've been working on a pet project of mine that I thought would be fun to do. I've been able to write and compile code for running on custom firmware on the PSP for a while now, but I haven't decided on what to do.

I've wanted to make a decent game, perhaps a bike-physics game clone of the one on teagames that I enjoyed so much playing during dull hours at the office, or a tower defense game with nice graphics and interesting weapons.

I've finally got more or less of a hang on the use of makefiles, enough that tweaking them a bit doesn't faze me like it used to. I don't exactly bother to write one from scratch though, as there are still some things I don't fully understand.

I've also enjoyed using plugins, which are really fantastic as it really lets you do so many more things with the PSP than what it can out-of-the-box.

So now I've tried to write my own plugin, based on an existing one, but with different features. It's been considered by some extremely difficult to put folders for games in the XMB. And I wholly agree.

But I've come up with an idea that might work.

When you place a folder in your /PSP/GAME folder that doesn't contain an EBOOT.PBP (the executable) , the XMB will display it as "Corrupted Data". This is just the way it's designed, zero levels deep.

There are plugins that allow you to categorize your games, and by placing them in different folders, you can select which category is currently active, and it displays only those games in the xmb.

These plugins use a button combination or a menu to select the category.

I thought of a way to let a folder show up in GAME, by spoofing an EBOOT when the firmware is trying to read the name and icon for the EBOOT.

The firmware tries to load an EBOOT for each folder it sees in /PSP/GAME. In the empty folder, it tries to load an EBOOT.PBP and as there is none, it fails and tells the firmware that the game is probably corrupt.

With my plugin in place, the code fails, but the plugin catches it and instead generates a fake EBOOT on the fly using the name of the folder and a default icon stored somewhere accessible, and tells the firmware everything is OK, don't worry, there is an EBOOT here.

Right now this is all the plugin does - it just allows folders to be displayed as EBOOTs in the XMB.

[screenshot goes here]

Now comes the hard part - intercepting when the user tries to open my fake EBOOT.

Normally the firmware tries to load the game, displaying the gameboot intro before launching the game.

What I need to do is catch the keypress before the firmware does, figure out what EBOOT the user is pointed at, check if it is one of mine, and if so, cancel loading the EBOOT and switch "categories" - folders really - and flush the memory stick cache.

This is where it gets interesting.

The PSP firmware is made up of several modules that load other modules as needed. The vshmain module (?) is the module that displays the top-level menu, the XMB.

When you select a top level item, vshmain (?) loads the approriate module - game_plugin in my case.

game_plugin is now responsible for reading the memory stick, drawing the icons, handling the menu. I'm not sure if it is entirely responsible though, it probably makes calls to other existing modules.

I makes sense that the game_plugin module contains a subroutine for checking if the user has pressed a button, or acting on button presses. What I need to do is patch the module to jump to my own code for checking button presses, before I call the original code.

As of now, I only have a fleeting understanding of how this can be done. With my previous knowlege of patching ROM code, I have some idea, but this is a 32-bit RISC platform with relocatable code, making things much more difficult for someone from a 8/16-bit fixed code background. There is probably some mechanism to locate the module's base entry point, and offset from there to some function.

I don't know how to find that function yet. But I have some ideas.

Learn MIPS assembly.

The module loads gameboot.pmf prior to launching the game. Look for the string gameboot.pmf, and to the code that references it and backtrack until you can find where the button presses are. Hopefully button polling/testing can be easily identified in assembly. (HAH!) NOPping out code is a time-honored method of isolating code.

Patch the code somewhere appropriate to jump to a function in my plugin.

This function needs to know what EBOOT the game_plugin module is currently "looking" at. Even after finding the right place to patch and patching the code, this is much more difficult to do. Perhaps the module's memory space contains an array of paths, and an index to the current entry.

Or perhaps there is a function that does this. With the caching that the XMB implements, this makes things much more difficult. Perhaps recoding a game_plugin is easier in the long run.

One thing fir sure, I would have learned a lot more by the time I'm done with this project, whether it is complete or not.

Tuesday, October 14, 2008

Dead and Alive

Few things that I can really count as strange happen to me.

I would have ignored the fact that my PSP inexplicably died on me, only to have it suddenly return to life, then intermittently work, and finally start working again. I would have relegated it to the perversity of the inanimate.

So it only served to raise the event to even higher levels of mystery when the same thing happened to someone else, at around the same time, and stranger still, to someone sharing my first name.

I'm just glad that my PSP is back and better (except for that piece of tape holding the LCD backlight flex cable to the connector)

Thursday, October 2, 2008

WiiMote in Action

As you know I got a WiiMote a few months a go for my birthday, but I haven't been using it lately. The lack of buttons makes it difficult to play Final Fantasy X, which is what I'm spending my gaming time on nowadays.

Well, here's a couple of videos of my WiiMote setup in action.

I hadn't setup the Wii "sensor" bar I DIY'd when I made these videos, so there's no point n' click action here yet.



TrackMania Sunrise



Portal

Wednesday, October 1, 2008

Doh!

Fans of Point-and-click games would do well to be aware that Broken Sword 2.5 is out! And it's totally free!

I love point-and-click games (and their precursor, the click-and-type games?) Never mind that I probably haven't solved one yet without the help of a walkthrough.

In fact, I can't wait to have kids, have them grow up a bit and so I can install a PC-based media center with a 42-inch LCD, (or will OLED be the display of choice in the far future?) WiiMotes and ScummVM installed, and introduce them to Those Games Their Father Played Back In Those Days, encouraging them to play them as they will be the only games installed on the PC, and declaring lazy Saturday afternoons as Family Point-and-Click Time.

Oh they will hate me.

When I heard Broken Sword 2.5 even existed, my first thought was - is it ScummVM compatible? Does it use the same engine even?

My second thought was - if it did, maybe I could play it on my...

PSP...

Doh!

(The happy music playing in my head slowed to a stop like an audio tape stuck in the mechanism. Audio tapes? How archaic...)