ADAM'S WEB PRESENCE

26 January 2008

Warcraft II on Windows XP, A step-by-step guide

Filed under: Nerd Notes — adam @ 9:11 pm

Warcraft II - Tides of Darkness. I used to love this old DOS game way back when. But now I want to run it on Windows XP. Yes, it is possible. Here’s how.

DOSBOXDOS Emulation

First you need the very excellent DOSBOX which is a DOS emulator. You can download it from http://www.dosbox.com/.

Once DOSBOX is installed, we need somewhere to put our DOS games. I created a folder called C:\DOSGAMES for this purpose.


Now it is time to run DOSBOX. Once it is going, type the following two commands:

mount c C:\DOSGAMES\

mount d D:\ -t cdrom

NOTE: If your CD-ROM drive is not D:\, modify this accordingly.

Then you can insert your Warcraft II CD. The game can be installed like so:

D:

SETUP

Just select all the default options except for the soundcard and music device which you should set to Soundblaster 16.

Making an icon

At this point you can run the game by typing WAR2. But I don’t want to stop there. Let’s now make a pretty icon so you can launch the game with a mouse-click.

Open the folder C:\Program Files\DOSBox-0.72 and find the file dosbox.conf. Copy it to your C:\DOSGAMES\WAR2 folder.

Edit the copy of dosbox.conf and add the following line to the bottom under the [autoexec] section:

mount d D:\ -t cdrom

I’ve found it is also a good idea to reduce the speed of CPU emulation otherwise the map can scroll too fast. Modify the cycles entry in dosbox.conf like so:

cycles=20000

Now save the changes you made to dosbox.conf.

Warcraft II IconCopy the DOSBOX icon on your desktop. Rename the copy to “Warcraft II”. Now right-click on the icon and select Properties.



Enter the following text (all on one line) into the Target box:

 "C:\Program Files\DOSBox-0.72\dosbox.exe" "C:\DOSGAMES\WAR2\WAR2.EXE"
-conf "C:\DOSGAMES\WAR2\dosbox.conf" -exit -fullscreen

Then finally click on the Change Icon button.

Click Browse and navigate to the folder C:\DOSGAMES\WAR2. Double-click the file WAR2ICON.DLL.

Choose the WarCraft icon and then click OK. Click OK on the shortcut properties window also.

Now we are done. Click the WarCraft icon and enjoy!

Warcraft II


6 January 2008

TP-Link TL-WN550G PCI Wi-fi card in Ubuntu

Filed under: Nerd Notes — adam @ 9:16 pm

TP-Link TL-WN500G I finally got rid of that unreliable NetGear Wireless card and replaced it with a TP-Link card which uses the Atheros chipset. It was only $27 at UMart.

I’ve only had it for a couple of days but in that time I have transferred more than 10GB through it and it has been 100% reliable.

This one was not too difficult to get going on Ubuntu since it is well supported by the MadWifi drivers which are built in to Ubuntu.


However there is a little catch if you want to use WEP. You need to add the iwpriv command to activate your WEP. Here’s my /etc/network/interfaces file with the tricky bit highlighted in bold:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# TP-Link Wi-fi card
auto ath0
iface ath0 inet dhcp
        wireless-mode Managed
        wireless-essid adamnet
        pre-up iwpriv ath0 authmode 2
        wireless-key 1234567890

NOTES: If you are copying this, make sure to change the essid and key to match those of your own network. And if you think this is my real WEP key, you are in for some disappointment.


20 November 2007

A good VHDL tutorial

Filed under: Nerd Notes — adam @ 9:38 am

I had to brush up on my VHDL recently for a project and I discovered the Low-carb VHDL Tutorial by Bryan Mealy.

I really wish I’d read this one back when I was getting started in VHDL. I wouldn’t have found it so hard. This document describes the basics of VHDL in a very clear and readable way. It’s well worth a look if you are wanting to learn VHDL.


15 November 2007

Moving a DirectShow window while paused

Filed under: Nerd Notes — adam @ 2:26 pm

directshowmoveproblem.jpegI’ve been writing a lot of DirectX / DirectShow stuff lately and I’ve come across a problem if I pause a video replay and then move the containing window. The playback window becomes separated from the containing window even though I am handling the WM_MOVE event.

You’d think that the following code would work:

void CMyWindow::OnMove()
{
    CRect r;
    GetClientRect(r);

// _piWindow is a pointer to my filtergraph's IVideoWindow interface.
    _piWindow->SetWindowPosition(r.left, r.top, r.Width(), r.Height());
}

It works fine if the video is playing but if the replay is paused, the active movie window will ignore the window move commands.

The solution was to trick DirectShow into thinking that you want to resize the window like so:

void CMyWindow::OnMove()
{
    CRect r;
    GetClientRect(r);

    _piWindow->SetWindowPosition(r.left, r.top, r.Width() + 4, r.Height());
    _piWindow->SetWindowPosition(r.left, r.top, r.Width(), r.Height());
}

28 September 2007

Updates to ARM tutorials

Filed under: Nerd Notes — adam @ 10:08 pm

Dan Ashbrook has noticed a mistake in my example code.

If you try and modify the Flash Memory or the Hello World example code to send the output to the 2nd serial port, it does not work due to some incorrect port assignments in Board.h. I have replaced the original example code with the corrected version so you can download it again.

Thanks Dan for not only spotting the problem, but also for fixing it and sending me the fix!


19 September 2007

Primary interface not eth0

Filed under: Nerd Notes — adam @ 4:11 pm

I’ve seen this happen a couple of times with a Debian 4 “Etch” install where the primary Ethernet interface is eth2 or eth3 instead of eth0. I’ve worked out what it is now.

It can happen when you move a hard drive from one system to another, replace the motherboard or ethernet card, clone a drive or in any way cause the MAC address of the Ethernet interface to change.

You see, there is a script which assigns the device numbers based on the MAC address so that in a machine with multiple cards, the numbers will never change. So if you remove an Ethernet interface, it will reserve its device number in case that card ever re-appears.

So how to fix it ? Very simple. Just delete the MAC address cache and reboot. This command will do it:

rm /etc/udev/rules.d/z25_persistent-net.rules

reboot

8 September 2007

MythTV and the TwinHan remote

Filed under: Nerd Notes — adam @ 12:04 am

TwinHan remote controlToday’s challenge - getting this gizmo to work with MythTV. It turned out to be quite a pain so I am documenting it here in case I need to do it again in the future. Note that I am running Ubuntu 7.04 (Feisty Fawn). The procedure may be slightly different for other platforms.


UPDATE: This article is somewhat out of date now. I have re-written it for the latest version of Mythbuntu, you can read the updated guide here.



STEP 1 - Locate the device node for the remote
This remote has a very nifty USB receiver which presents itself to the PC as a HID keyboard. It is mapped to a device in /dev/input but we need to figure out which one. Type this command:

cat /proc/bus/input/devices

Now look for the TwinHan keyboard device. Beware, it also creates a mouse device which you do not want. The entry will look like this:

I: Bus=0003 Vendor=6253 Product=0100 Version=0110
N: Name="Twinhan Tech Remote Control"
P: Phys=usb-0000:00:11.2-1/input0
S: Sysfs=/class/input/input3
H: Handlers=kbd event3
B: EV=120003
B: KEY=800000 0 e0b0ffdf 1cfffff ffffffff fffffffe
B: LED=1f

Note the Sysfs entry. We will need this for the next step…

STEP 2 - Create a symlink to the device node
Even though we saw the remote was on /class/input/input3, It is not guaranteed to stay there. Next time you reboot it may be a different device so we need to create some method of referring to it which will work every time. We can use UDEV for this. Type this command (replacing inputX with the appropriate event device of course):

 udevinfo -a -p /class/input/inputX

You will get lots of output. We are interested in the first {modalias} line.

  looking at parent device '/class/input/input3':
    KERNELS=="input3"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{modalias}=="input:b0003v6253p0100e0110-e0,1,11,14,k74,75,77,7D,7E,7F,B7,raml0,1,2,3,4,sfw"
    ATTRS{uniq}=="1111111"
    ATTRS{phys}=="usb-0000:00:11.2-1/input0"
    ATTRS{name}=="Twinhan Tech Remote Control"

Create a new file /etc/udev/rules.d/10-local.rules and paste that line into it so it looks like this (this is supposed to be all on one line BTW):

KERNEL=="event*",ATTRS{modalias}=="input:b0003v6253p0100e0110-e0,1,11,14,
k74,75,77,7D,7E,7F,B7,raml0,1,2,3,4,sfw",SYMLINK="input/irremote"

Then simply unplug the USB device and plug it back in again. You should now see a new device called /dev/input/irremote. We can test it by typing the following. You should see data arrive whenever you press a button on the remote. Press Ctrl-C when you are done testing.

hexdump -C /dev/input/irremote

STEP 3 - Configure LIRC
You need to set up /etc/lirc/hardware.conf and lircd.conf. Both of these files are located in /etc/lirc. To save you the trouble of working out all the settings, I have posted mine here:

hardware.conf

lircd.conf

Once you have these files in place, restart the lirc daemon with this command:

/etc/init.d/lirc restart

You can test that it is working by typing this:

irw

Now every time you press a key, you should see it printed on the screen. Press Ctrl-C when you are done.

STEP 4 - Configure MythTV commands
We are getting closer now. The next step is to set up a file called /home/mythtv/.mythtv/lircrc which contains the mappings between the keys on the remote and the functions in MythTV. Once again, I have already prepared this file which you can download here:

lircrc-mythtv

Rename this file to lircrc and move it to /home/mythtv/.mythtv/. Once that is done, restart MythTV. Here are the key mappings you will end up with:

Key Function
REC Record
TELETEXT OSD
RECALL MENU
PREVIEW INFO
REW/FFWD Forward/backward in MythMusic
CAPTURE Previous playlist item in MythMusic
RECORDLIST Next playlist item in MythMusic

STEP 5 - Configure MPlayer
The final step is to configure the mapping between the remote and the commands in MPlayer. Since MPlayer is a separate program, it needs to be configured separately to MythTV. To configure it, we need another lircrc file but this time is has to be called /home/mythtv/.lircrc. Download it from here:

lircrc-mplayer

Rename it to .lircrc and put it in /home/mythtv and that should be that! Here are the key mappings for MPlayer:

Key Function
MUTE Mute
VOL+/- Adjust volume
CH+/- Skip fwd/back 60 seconds
REW/FFWD Skip fwd/back 10 seconds
PREVIEW Show/hide subtitles
TELETEXT Show/hide OSD
TAB Cycle through audio tracks

If you do not like the key mappings I have chosen, you may edit the lircrc files. The format should be fairly easy to follow.


28 August 2007

NetGear WG311v2 Wireless LAN and Ubuntu Feisty

Filed under: Nerd Notes — adam @ 1:44 pm

I wrote a while back on getting my ACX based wireless LAN card working in Ubuntu version 6.06. Now I have upgraded my machine and find that it is a bit different getting it to work under Ubuntu 7.04 (A.K.A. “Feisty Fawn”).

Essentially, the built-in ACX100 driver now correctly loads the firmware so you don’t need to fiddle with its parameters any more.

However, Fiesty introduces a new tool called “Network Manager” which does not get along with this driver. Network manager is installed by default so the first thing we need to do is get rid of it:

sudo dpkg -P network-manager network-manager-gnome

Then the card can be configured by editing the interfaces file:

sudo gedit /etc/network/interfaces

Here is my file. WEP keys have been changed to protect the innocent.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# Wireless network
auto wlan0
iface wlan0 inet dhcp
        wireless-mode Managed
        wireless-essid MyNetwork # Replace with the name of your wireless network.
        wireless-key 23BA7823B4  # Replace with your own key or omit if not using WEP.

Then reboot and you should be good to go!

One more thing before I finish. Be aware that although this card supports WEP authentication, it does not support WPA so make sure your wireless router is not set to WPA.

 Update

I have just replaced this card with a TP-Link one. It is sooo much faster and more reliable than the NetGear card. Read my article on setting up the TP-Link.


21 July 2007

Concatenating AVI files

Filed under: Nerd Notes — adam @ 6:10 pm

Here’s a small but useful shell script to concatenate any number of AVI files. It works great on Ubuntu and should also work on other UNIX-based systems as long as you have mencoder installed.

To use it, just put the name of each file on the command line in order and they will be all joined together into one big file called joined.avi

#!/bin/sh

# catavi - Script to concatenate multiple AVI files.
# by Adam Pierce http://www.doctort.org/adam
#
# Note: The AVI files must be of the same format (eg. same codec, frame size etc).
#
# This script is freeware. You can use it, copy it, change it, whatever.

TEMPFILE=/tmp/avitmp

cat "$@" > $TEMPFILE

mencoder -forceidx -oac copy -ovc copy $TEMPFILE -o joined.avi

rm $TEMPFILE

Usage example:

./catavi movie-part1.avi movie-part2.avi


18 July 2007

NCURSES Weirdness on Linux Console

Filed under: Nerd Notes — adam @ 5:15 pm

I’ve been writing an application using ncurses under Linux. Everything was going fine until I tried to run it on the Linux console (all my testing had been in an xterm). Suddenly all my borders and fields were all over the place and stuff was not being rendered correctly.

After a lot of research, I found that there are some problems with the Linux TERM settings. To cut a long story short, there is a real simple fix. you just need to print a certain magic escape code and the problem goes away.

So as the first line of my program, I put this:

cout << "\\033c";

In C, that would be:

printf("\\033c");

You can even do it from a script:

echo -ne "\\033c"

It took a lot of Googling to figure that out. I’m not sure exactly why it works but there you go.

For the record, I am using Debian “stable” with kernel 2.6.18.


« Previous PageNext Page »

Powered by WordPress