Wednesday, November 30, 2016

A native Windows port of Moria

About 8 years ago, I did a proof of concept for porting the classic text-based adventure game Moria to a native Windows application.  I had some beta test help from other fans of the game (thanks Jou), and I had the blessing of David Grabiner for the project, based on the Umoria 5.5.2 core.  As is the case with so many projects, however, the effort ended up being shelved after the initial PoC.  I recently became interested again in the game and in finishing up the port, so that's what I've done with Win32Moria 5.5.3.  Combining the Moria core with PDCurses and SDL, I've been able to build a native Windows binary without the need for emulation, CygWin, or other compatibility layers.  It's possible there are similar efforts out there already, but this is mine.

Over the past 8 years, of course David released Moria 5.6.  The core source code is just different enough from 5.5.2 that I have not yet attempted to integrate those changes into the Win32 port, but it is on my list of to-dos along with releasing the final code changes for public consumption.  For now, I'm making the binary package available and would appreciate any feedback from folks who give it a try, especially if you find any bugs!  Also, if anyone would like to submit a good icon to use (maybe of the Balrog), I'd be glad to make an update.  I'm no artist.

Bits can be downloaded here:

A couple useful new hotkeys:
- Alt-F toggles between fullscreen and windowed mode.
- Alt-D toggles between double and single resolution when in windowed mode.
* Alt isn't currently recognized more than once if kept held down because SDL needs to reset the keyboard when changing video modes, so it must be released and pressed each time for multiple toggles.

A few features that may keep this from becoming an official Moria port:
- Optional auto-rolling for hero stats.
- Optional auto-haggling for store prices.
- Optional colors for monsters, treasure, and mineral seams.

Some screenshots:

And a completed quest:

 Name        : Slor                    Age          :     15   STR : 18/100
 Race        : Human                   Height       :     73   INT : 18/100
 Sex         : Male                    Weight       :    214   WIS : 18/100
 Class       : Ranger                  Social Class :     49   DEX : 18/100
 Title       : **KING**                                        CON : 18/100
                                                               CHR : 18/100

 + To Hit    :     20       Level      :      78    Max Hit Points :    417
 + To Damage :     24       Experience : 8072780    Cur Hit Points :    417
 + To AC     :     47       Max Exp    : 8072780    Max Mana       :    145
   Total AC  :     78       Exp to Adv : *******    Cur Mana       :    145
                            Gold       :  811536

(Miscellaneous Abilities)

 Fighting    : Superb       Stealth     : Excellent    Perception  : Superb
 Bows/Throw  : Superb       Disarming   : Superb       Searching   : Very Good
 Saving Throw: Superb       Magic Device: Superb       Infra-Vision: 30 feet

Character Background
 You are one of several children of a Townsman.  You are a
 well liked child.  You have dark brown eyes, straight blond
 hair, and an average complexion.

  [Character's Equipment List]

  a) You are wielding   : a Battle Axe (Balestarius) (HA) (2d8) (+10,+14) [+2] (+1 to STR).
  b) Worn on head       : a Steel Helm of Infra-Vision [6,+7] (+3).
  c) Worn around neck   : an Amulet of the Magi [+3] (+15).
  d) Worn on body       : Augmented Chain Mail (R) (-2) [16,+12].
  e) Worn on shield arm : a Large Metal Shield [5,+7].
  f) Worn on hands      : a Set of Gauntlets of Slaying (+3,+4) [2,+3].
  g) Right ring finger  : a Ring of Speed (+1).
  h) Left  ring finger  : a Ring of Speed (+1).
  i) Worn on feet       : a Pair of Soft Leather Shoes of Stealth [1,+5] (+3).
  j) Worn about body    : a Cloak of Stealth [1,+3] (+1).
  k) Light source is    : a Brass Lantern with 10745 turns of light.
  l) Secondary weapon   : an Executioner's Sword (SD) (4d5) (+10,+19).

  [General Inventory List]

a) 3 Books of Magic Spells [Beginners-Magick].
b) 3 Books of Magic Spells [Magick I].
c) 3 Books of Magic Spells [Magick II].
d) 3 Books of Magic Spells [The Mages' Guide to Power].
e) 10 Rations of Food.
f) 20 Flasks of Oil.
g) 11 Potions of Restore Life Levels.
h) 27 Potions of Restore Intelligence.
i) 19 Potions of Restore Dexterity.
j) 20 Scrolls of Word-of-Recall.
k) 2 Scrolls of Rune of Protection.
l) 2 Scrolls of Mass Genocide.
m) a Wand of Acid Balls (3 charges).
n) a Wand of Cold Balls (4 charges).
o) a Wand of Lightning Balls (3 charges).
p) a Wand of Fire Balls (6 charges).
q) a Wand of Drain Life (4 charges).
r) a Staff of Teleportation (6 charges).
s) a Staff of Teleportation (4 charges).
t) a Staff of Speed (3 charges).
u) a Staff of Speed (5 charges).

Tuesday, December 3, 2013

Quick and dirty social media links

If you're looking for a quick way to get a few social media sharing links on your site without messing with JavaScript and remotely hosted widgets, here is a simple solution.  Below are some HTML snippets and images you can throw together in just a few minutes.

Sample link bar:

Facebook code:
<a href="" target="_blank" title="Share on Facebook"><img src="" /></a>

Twitter code:
<a href="" target="_blank" title="Share on Twitter"><img src="" /></a>

Google+ code:
<a href="" target="_blank" title="Share on Google+"><img src="" /></a>

Thursday, September 26, 2013

Turning your Raspberri Pi into a wireless bridge

I recently found myself in need of a wireless bridge.  Having also recently purchased a Raspberry Pi and not wanting to spend money on a dedicated bridge (costing as much or more than the Pi), I decided I'd figure out how to make my Pi serve that function for me.  It took a little searching and piecing together of web articles to find the simplest formula to get there, and it works pretty well.

Here's what you need to get started:
- Raspberry Pi (duh) - I recommend model B revision 2.0.
- MicroUSB power supply - The more mA the better.
- USB wireless network adapter - Mine happens to be a generic RTL8192CU-based unit that came as part of a starter kit with my Pi.
- USB keyboard.
- HDMI or video monitor.
- Pi case (optional).
- 4 GB or larger SDHC card - I used a Wintec 16 GB MicroSDHC with adapter.
- Raspbian distribution image - The latest raw image can be obtained from the Raspberry Pi website.
- A way to write Pi images to the SD card - For Windows, Win32 Disk Imager is a great choice.

Step 1: Copy Raspbian image to SD card

If you own a Raspberry Pi, you probably already know how to do this.  Using Win32 Disk Imager, it is a simple matter of browsing to the downloaded Raspbian image file, making sure the correct device is selected to write to, and then clicking the Write button.

Assuming no errors during the write process, you should now have a bootable SD card to put in your Pi.

Step 2: Hook up your system and set up Raspbian

It doesn't get much easier than this.  If you own a Pi, you certainly already know how to hook up your peripherals and power it up.  At the end of first boot, you'll be presented with the raspi-config screen and can do any customization you need there.  I recommend at least using the first item to expand your file system to fill available space.  Once you're done, you'll be able to log into the terminal session.

Step 3: Enable both network interfaces

You'll need to update your network configuration so that both the wired and wireless interfaces are enabled automatically at boot time.  First file to edit (as superuser) is /etc/wpa_supplicant/wpa_supplicant.conf.  Assuming your wireless access point uses WPA2 pre-shared keys, replace the contents of the file with this:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

    ssid="Your SSID Here"
    pairwise=CCMP TKIP
    group=CCMP TKIP

Make sure you use your own SSID and pre-shared key where appropriate.  If you are not using WPA2, you'll need to find and use the correct parameters for your access point.  Next file you need to mess with is /etc/network/interfaces.  Replace the contents of the file with this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Before moving on, you should test this configuration to make sure the wireless is connecting properly.  Run these two commands:

# sudo ifdown wlan0
# sudo ifup wlan0

You'll likely see three ioctl warnings during the ifup command.  Those are ok and can be ignored.  From there, you can use the "ifconfig" command to check on status of both eth0 and wlan0 or "iwconfig" command to get detailed status for wlan0.  Finally, if you want to make sure things will be enabled properly at boot time, this is a good time to reboot the Pi and see.

Step 4: Create the bridge

Run the following commands to install bridge-utils and create the bridge br0 between wlan0 and eth0:

# sudo apt-get install bridge-utils
# sudo brctl addbr br0
# sudo brctl addif br0 wlan0 eth0

After making a backup copy of /etc/network/interfaces, update its contents to this:

auto lo
iface lo inet loopback

iface eth0 inet manual

auto wlan0
iface wlan0 inet manual

auto br0
iface br0 inet dhcp
   bridge_ports wlan0 eth0
   bridge_stp off
   bridge_maxwait 5

wpa-iface wlan0
wpa-bridge br0
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

That should do it.  With the wpa-bridge line, you don't need to mess with ebtables or anything to spoof mac incoming and outgoing MAC addresses for the wireless side.

Step 5: Make it so

If you have your wireless and wired ports currently hooked up to the same LAN, unplug the wired connection now.  Reboot.  Once your system reboots, you should have a Raspberry Pi bridge running in your environment.  You can plug a single machine or switch into the wired ethernet port, and anything there will be bridged through the wireless access point on the other side.

Hope this helps someone.  If it doesn't, though, don't blame me.

Tuesday, August 20, 2013

Installing Mac OS X Lion 10.7.5 on a Lenovo ThinkPad X61

So you want an Intel-based Mac to play with but all you have laying around are a bunch of old non-Mac PCs.  If one of those happens to be a Lenovo ThinkPad X61 laptop, you are in luck.

Disclaimer: Under no circumstances do I guarantee that you will not brick your system by following the instructions below.  You follow this guide at your own risk, I will not be held responsible for any damages resulting from your efforts to build a Hackintosh.  Only YOU can prevent forest fires.  I suggest taking a first pass through the documented instructions to get a feel for the process and also to get some file downloads started before you get to work on the X61.

My target machine's configuration:

- Model: Lenovo ThinkPad X61 laptop
- CPU: 2 GHz Intel Core 2 Duo SV T7300
- Memory: 4 GB PC-5300 RAM
- Disk: Seagate ST500LT012 5400 RPM SATA-II hard drive
- Graphics: Intel GMA X3100
- Sound: Intel High-Definition Audio (SoundMAX AD1981HD)
- Network: Intel 82566MM Gb Ethernet
- Network: Intel PRO/Wireless 3945ABG
- Expansion: ThinkPad X6 UltraBase

What you will need:

- Your X61, with or without UltraBase.
- USB keyboard and mouse for temporary use with the X61.
- Readily accessible PC.  Doesn't really matter what operating system, as long as it can burn .ISO and .DMG files.  For Windows, a great utility for this is TransMac.
- Blank CD and DVD media (one of each).
- USB drive for transferring files.
- A lot of patience.

Step 1: Update your BIOS (optional)

One annoying quirk with the stock X61 BIOS is that it only supports SATA I disk transfer speeds.  The hardware, on the other hand, can support SATA II.  If you have upgraded your internal hard drive like I have, you will benefit from updating to a third party BIOS.  You can read all about the Middleton BIOS here.

- To get started, grab the archive here.
- Burn the included .ISO file to CD-ROM and boot your X61 from it.  The BIOS update will take place immediately without any prompting.  It won't look like it's doing anything for a while, so be patient until you see the notice of completion.
- Reboot your X61 and make sure it still works.  If not, then you're probably done early with this project.

Step 2: Install Lion

You'll need to obtain a copy of the iATKOS L2 installation media.  You can read all about iATKOS L2 here, but we're not going to follow all the instructions listed.

- Grab the .torrent file for the L2 archive here and put your favorite torrent client to work.
- Burn the included .DMG file to DVD-ROM and boot your X61 from it.  The OS X installation procedure will start after a good amount of whirring by the DVD drive.
- Once you get to the Disk Selection page, go to the Utilities menu and run Disk Utility.  This has been known to occasionally lock up the X61.  If that happens, just start this step over and you're likely to succeed the next time.
- In Disk Utility, select the hard drive you want to install OS X onto.
- Click to the Partition section of the right pane.
- In the Partition Layout dropdown list, select 1 Partition.  Multiple partition support is doable but is beyond the scope of this guide.
- Open the Options dialog and select GUID Partition Table for the partition scheme.
- Use Lion for the partition name.  It can be changed later if you like.
- Select Mac OS Extended (Journaled) from the Format list.
- Click Apply, make sure you're about to destroy the correct disk, then click Partition.
- Once partitioning is done, quit Disk Utility.
- In the installer's Disk Selection page, make sure to tag the Lion volume as your installation target.
- Open the Customize dialog.  Most things should be left as default.
- The only change to make is to put a check on Drivers -> Main Hardware -> SATA/IDE -> AHCI SATA.  Then click OK.
- Now you should be ready.  Click Install!
- Kick back and relax.  It will take a while.
- After installation is complete, your X61 will reboot.  You will want to make sure it boots from the hard drive this time.

Did it boot into OS X?  If so, continue on.  If not, repeat this entire step until it does.

Step 3: Update some system files

On first boot, many system devices will be unavailable or not working properly.  This is where that gets fixed.

- Grab a few extras from here.
- And a bunch of .kext files from here.
- And tonymacx86's KextBeast from here.
- Put all of these on a USB drive and plug it into the X61.
- On the X61, extract
- Copy the two .plist files into /Extra, overwriting the existing files.
- Copy DSDT.aml into /.
- Extract
- Copy all of the .kext files to your Desktop.
- Extract
- Run KextBeast and follow the prompts through completion to install kernel extensions specific to the X61.
- Restart the X61.

Still booting up OK?  You should now be able to use most system devices and unplug the USB keyboard and mouse if you like.  If you do unplug them, you'll want to disable the Bluetooth Assistant in your advanced Bluetooth preferences.  Your machine is now a stable OS X 10.7.2 Hackintosh.  You can pause here to set preferences as desired for networking and other aspects of the system.

Step 4: Update OS to 10.7.5

Do NOT use Software Updater to update your OS.  Instead, you'll want to download the standalone OS X 10.7.5 Combo Update.

- Grab the update from here.
- And a fixer-upper script from here.
- And make sure you still have the .kext files and KextBeast from Step 3.
- Install the 10.7.5 Combo Update, but do NOT restart the machine yet.
- Prior to allowing the updater to restart your machine,
- Extract
- Open up a Terminal session and change to the directory containing the fixer files.
- Use this command to run the fixer-upper:
sudo ./
- At this point, you need to put all those .kext files from Step 3 back on the desktop.
- Run KextBeast again to put your X61-specific files extensions where they need to be.
- Now you can Restart you X61.

If it booted back up, you Hackintosh is now updated to OS X version 10.7.5!  If not, I'm afraid you're back to Step 2.

Step 5: Prevent CMOS corruption

There's an issue in the stock AppleRTC extension that will cause corruption in you CMOS settings after allowing your computer to go to sleep.  This is very annoying because it causes all your settings to be set back to default and also turns off your bluetooth device.

- To correct the issue, open a Terminal session on the X61 and use the following command to find and replace the offending bits:
sudo perl -pi -e 's|\x75\x30\x44\x89\xf8|\xeb\x30\x44\x89\xf8|; s|\x75\x3d\x8b\x75\x08|\xeb\x3d\x8b\x75\x08|' /System/Library/Extensions/AppleRTC.kext/Contents/MacOS/AppleRTC
- Reboot your X61.

You should now have a Hackintosh that is safe to put to sleep on occasion.

Step 6: Update the rest of the system software

You can now safely check for system updates using OS X's built-in updater.  Everything should install fine and leave your X61 in a still-working state.  If not, you know where Step 2 starts.

Step 7: Enjoy your Hackintosh!

You are now the proud owner of a Hackintosh X61.  You'll be the envy of all your friends.  Girls won't like you any more than they do now.


- If your X61's bluetooth doesn't work or disappears after a future startup, reboot the X61 with a Linux LiveCD like Knoppix.  Once the bluetooth device has been activated in the BIOS, it will be available to OS X again next time it's booted.
- You'll notice the wireless networking, PCMCIA card reader, and SD card reader still do not work.  At this time, I don't have answers for supporting those devices.  This post will be updated if and when I make further progress.
- You'll also notice your Hackintosh is running the OS in 32-bit mode.  You can change it to 64-bit by editing org.Chameleon.boot.plist, but you will lose support for some of the built-in devices such as sound, keyboard, and trackpoint.
- I recommend turning off automatic system updates, just in case something comes along that could cause issues.  Hopefully that isn't likely, but you may want to ability to control the update process and check on any suspicious-looking updates.

Useful tools:

TransMac - A great app for managing Mac disk images on a Windows computer.  I used it to burn my iATKOS install DVD.
Carbon Copy Cloner - Very useful for duplicating disk content on your Hackintosh.  After preparing a second hard drive's boot loader with iATKOS, I use CCC to keep an exact copy of my system drive in case I screw it up and need a quick restore.
Vine VNC - Way better than Lion's built-in VNC server, and it's FREE!
Xcode - I don't know much about developing apps for OS X, but I do know Xcode is an easy way to get GCC and related build tools installed on my Hackintosh.
MacPorts - It can't get any easier to install many of the open source tools I'm used to using on other *nix-based platforms.

Final notes:

I hope this guide has helped someone.  Please purchase your own copy of OS X Lion before attempting your build.  I cannot vouch for the legalities of running OS X on alternative hardware, but I'm pretty sure Apple would like you to pay for any software you use.  No Apple software is, or ever will be, provided by this site.

Thanks to the iATKOS, tonymacx86, and OSx86 teams for making this doable!

Thursday, October 18, 2012

Support your local Slor

If you have any need for domain name registration and/or web hosting, please check out these two sites:

eHostDirect - for web hosting (and domain names if needed)
Ikon Domains - for standalone domain name registration