Sunday, December 21, 2008

Simple Shell/Bash RAR Renaming Script

Recently I ran into an issue using Mac OS X and RAR files. Using BetterZip I can use RAR files if they are a single file or spilt using the .rar, .r00, .r01, etc naming convention. I happened to get hold of an archive that was named .001, .002, etc.

So here's my soution to the problem. This will rename .002 onwards to .r00, leaving you to rename .001 to .rar. I could have added that but couldn't be arsed as it's a two second job to do a manual rename on a single file. 46 other files would have taken quite a bit longer.

#!/bin/sh

for i in `ls -a *.0*`
do
EXTENSION="$(echo ${i#*.})"
FNAME="$(echo ${i%.*})"
NEWNUM="$(echo $EXTENSION |sed 's/^0*//')"
NEWNUM="$(($NEWNUM -2))"
FINAME=""
if [ "$NEWNUM" -lt "10" ]; then
FINAME="$(echo $FINAME)0";
fi
FINAME="$(echo $FINAME$NEWNUM)"
FINAME="$(echo ${FNAME}.r$FINAME)"
echo "${i} -> ${FINAME}"
mv "$i" "$FINAME"
done
Probably not the most efficient script, but it works so there :)


Tuesday, May 27, 2008

Adventures in LCD Part I

Ok, recently I sent a +3 Speccy to a guy who lives in Finland. The guy goes by the name of Mr_Spiv (of Scoopex), who decided he'd try his hand at some Speccy coding. The Speccy got to him in one piece and appears to be working fine. Except for one minor problem, his LCD TV gives him a shite picture.

So intrigued by this, I thought I'd help out. We established the problem was not with the Speccy as it gave a good picture when plugged into a normal TV. So next to try some further tests...

First up, try a different device on the LCD TV that uses SCART. So Mr_Spiv attached a PC Engine to his TV. Same thing, bad picture. Ok, so it's the TV doing something odd.

At this point I remembered playing a Wii on a Toshiba 32" LCD TV. It would do some "odd" things with the picture. Difficult to explain what it looks like, but basically, where the picture was motionless, the picture was fine (maybe some scaling, but nothing bad). But where there was movement, an odd effect could be seen. Almost like some kinda "on-the-fly" jpeg compression going on. Very weird. "This is what Mr_Spiv must have been seeing" I thought.

So now this has become almost a challenge for me - find an LCD TV that gives a decent picture on its SCART input. So off I go and buy the cheapest, known brand LCD TV I can from Argos.

A short drive and £110 later and I'm the proud owner of a Samsung SM741MP 17" LCD TV. I bought it from Argos as they have a 30-day money-back guarantee, so if it didn't work right, I could always take it back and get my money back. Magic.

So on to testing this nice new LCD TV. I hooked the Speccy up via the SCART socket and instantly I was shocked at the picture. The first most noticeable thing was it appeared to be interlaced! What? Speccy? Interlaced? Ok, I've seen it in demos but an interlaced +3 menu? The next thing I noticed was some odd discolourations in funny places. Almost the same as you see when using a Speccy via the RF cable, only this was via an RGB cable. Most odd.

So an explanation? The interlaced effect I can explain. The odd colour issue I can not.

My theory for the interlaced look is this. Basically, this LCD TV is an LCD monitor. It can only handle vertical refresh rates in the region of 56-75Hz. So how does it display a 50Hz picture? Easy. It basically turns 3 50Hz frames into 2 75Hz frames. Very clever stuff, but with a static old skool 8-bit picture, it suxx big time, trust me.

Anyhow, this part of the story does have a happy ending. Jojo, the missus, kinda liked the look of the new LCD TV. So as the old Sony one in the bedroom is developing an odd "corrupt settings" issue, I decided to retire the Sony to the loft and the Samsung LCD TV is set up in the bedroom. Happy wife - bonus! ;)

The adventure had only just begun...

Thursday, January 24, 2008

Leopard on a HP Pavilion dv2000 laptop!

Well this certainly took a while, but I've finally got MacOS X working on my HP Pavilion dv2056ea laptop! MacOS X installs fine using the Kalyway 10.5.1 install disc, but a few things were missing.

Firstly, no network. No LAN, no WAN! A bit of research here tells me my network card (Intel Pro 100VE) will work (with some editing of a kext file), but the wireless card (Intel Wireless 3945ABG) has no support. I've found that a driver is in the making, but it's far from finished. This annoyed me slightly, but more on that later.

Another thing, no battery meter. What good is it if I can't see how much charge is left on my battery?!?!? Luckily I found a post that had a version of PowerManagement.bundle that enables the battery meter for my laptop. Yay!

The next thing I noticed was I had no sound. Well, to be more specific, no sound from the internal speakers. Audio from the headphones was ok (volume should be set lowish otherwise it distorts - something I've found with linux on this laptop too). As I rarely use the internal speakers, I'm fine with them not working. Hopefully a fix will appear for this soon as a lot of work has already been done on this.

You may be pleased to know that the graphics worked fine using the nvidia drivers that came on the Kalyway install disc.

Ok, now back to the wireless card issue. So no proper drivers have been made. I'd read on forums that a lot of people had replaced the intel cards with broadcom ones. So I started reading into this.

From what I've found out, HP, Compaq and IBM follow some stupid requirement set down by various regulatory organizations, that says they must restrict what wireless devices can be put in to the laptop! I stumbled across this HP forum discussion, which states kind of why the BIOSLock is there. Scroll about half way down and find a post by Philip Doragh which is a reply to a user, MiSp.

Ok, so there's a high possibility my laptop has some kinda restriction on which wireless cards can be put into it. I must add at this point that the wireless cards I'm talking about are Mini PCI Express cards. Not PCMCIA, Cardbus or ExpressCard ones.

So I decided to see exactly what I have in my laptop, an Intel Wireless 3945ABG Mini PCI Express card (Rev.2). I happen to have (at work) a Toshiba with the same model card (also Rev.2). So thinking these cards MUST be identical, I put the Toshiba card into my HP and switched it on. This is what I saw:

104-Unsupported wireless network device detected. System Halted. Remove device and restart.

"Great" I thought. So these two cards, that on paper, are the same, are infact different.

After a little research it turns out that the cards have Vendor, Device and SubSystem ID codes in them. Looking at their properties in device manager, it turns out both had the same Vendor and Device ID's (Ven: 8086 - Device: 4222), but the SubSystem ID's where different.

To cut a long story a little shorter, I found this page of someone else having the same problem. I did basically the same thing, but had a few issues along the way. Here's what happened, my issues, and how I fixed them.

  1. Find Phoenix Bios Editor Pro (it's not free) - Find it on this blog (this guy has hacked his hp too).
  2. Get the latest BIOS for your laptop but don't install it. UK dv2056ea is here.
  3. Unpack the contents to a folder using WinRAR or a similar program that can unpack compressed exe's.
  4. You should find a file called 'WFLASH.EXE'. Run this, it will start the program, but not flash the bios yet. Part of it running will backup your existing bios to a file called BIOS.BAK. We need this file. Once it's backed up it will then ask you if you want to flash you bios. Click No.
  5. Now use a file chopping utility or hex editor to chop off all contents after 100000h of your backup bios file (BIOS.BAK). You should have a file of 1024k (1048576 bytes). Keep the reminder (chopped off part) in a separate file - we'll need it later.
  6. Install Phoenix Bios Editor Pro and open up the chopped bios file.
  7. Once the bios has been loaded, go to the directory where Bios Editor is installed. In there you should find a directory called TEMP. This is where your decompressed bios image is.
  8. Using a good file searching tool, look for the files containing your cards Vendor ID and Device ID. Mine were Ven: 8086 and Dev: 4222 so I searched for files with the following hex sequence: 86 80 22 42. This came up with a few results. So I then searched for the SubSys ID (135c103c) in reverse (3c 10 5c 13) within the results. It came up with just one file - MOD_5100.ROM.
  9. Using a decent HEX editor now search this file for the same reverse hex sequences as above. So first search for 86 80 22 42. Found @ f2b6h - this may differ to yours depending on what bios version you have installed. In the section you find this, you should see a few other Vendor and Device ID's in reverse. Like E414 1143 (Ven: 14E4 Dev: 4311 - Broadcom 4311). After these should FF FF FF FF followed by a list of SubSystem ID's. These are then followed by FF FF FF FF.
  10. Hex edit these codes correctly (remember all ID's are in reverse). Save your edited hex files as the same name.
  11. Back in Phoenix Bios Editor, make a minor change and change it back (eg. add a space to an error message and then remove the space). This should then give you the option to build the bios. It will ask you where to save it and name it. Save it in the winphlash directory of the HP bios download you extracted earlier.
  12. Now create a new file containing your edited and resaved bios and the chopped off section. Do this easily by entering "copy /b bios.wph + chopped.file newbios.wph" at the command prompt that's in the same directory as all the needed files.
  13. The new bios file you've created should be renamed to that of the same name as the new HP bios update (rename the existing one).
  14. Run WFLASH.EXE again. It should attempt to backup your bios again and then ask if you wish to flash with the new file. It should list bios revisions for the current bios and the new bios. They should be exactly the same as we've been editing your current bios.
If all goes to plan, you should have no more 104 errors for the card you have entered the Device, Vendor and SubSystem ID's for. I hope this helps someone out there...