Archive for the 'Programming/Technology' Category

Compiling SDL_gfx (2.0.17) on Visual Studio 2008 (VS9)

Saturday, July 12th, 2008

Sadly there are no officially provided binaries for SDL_gfx (unlike most other SDL_* libraries), and so I had to compile it myself. SDL_gfx, however has just about no documentation telling you how to do this - and the methods provided doesn’t even work.

Since it took me a while to get this working, so I thought I’d write it down for future reference.

1. Download and unpack the source package.
2. Rename *.c to *.cpp. This is to solve what seems to be this bug, that supposedly was fixed in VS6.
3. Extract sdlgfx.vcproj from ‘Other Builds\VisualC7.zip’ into the source directory and open it, and go through the Conversion Wizard.
4. Remove the source files from the project, and then add the *.cpp files and the *.h files to the project. This is needed because the paths in the original project file are incorrect.
5. Change target to Release.
6. Add SDL.lib to Linker -> Input -> Additional Dependencies in the project properties.
7. Add BUILD_DLL to C/C++ -> Preprocessor -> Preprocessor Definitions.
8. In SDL_gfxPrimitives, replace

#ifdef WIN32

__inline long int
lrint (double ftl)
{
int intgr;
_asm
{
fld flt
fistp intgr
};
return intgr;
}

#endif

with

#define lrint(x) (floor(x+(x>0) ? 0.5 : -0.5))

(As per this site)
9. Compile, and save the solution somewhere when asked to.
10. There should be 4 compilation errors, all of which can be solved by using static_cast<>():
SDL_rotozoom.cpp (Line 501) becomes:
pc = static_cast<tColorRGBA*>(dst->pixels);
SDL_rotozoom.cpp (Line 657) becomes:
pc = static_cast<tColorY*>(dst->pixels);
SDL_gfxPrimitives.cpp (Line 3105) becomes:
sab = sqrt(static_cast<double>(a2 + b2));
SDL_gfxPrimitives.cpp (Line 4289) becomes:
currentFontdata = static_cast<const unsigned char*>(fontdata);
11. Compile. The project should now compile correctly, and you will find sdlgfx.dll and sdlgfx.lib in the Release sub-folder of your source directory.

Now, this is all good, but I would really prefer either official binaries, *or* fixes to the code problems, and instructions that are actually up to date.

Flash cycler

Sunday, June 15th, 2008

Since I had a some time on my hands I decided to make a web page that cycles through a collection of flash movies and shows each one for a specified amount of time.

It should work in most modern browsers - I’ve verified with Opera and Firefox (Internet Explorer doesn’t work).

You can find the source of the page here, and a sample of it in use here.

Super smash bros: Brawl (USA) on PAL Wii

Thursday, April 17th, 2008

I finally got SSBB working, and here’s how. But let’s start with what does NOT work.

First, my setup:
PAL Wii with latest firmware (Bought on the release date)
WiiKey (Firmware 1.9s)

Try 1 (No go):
Enabling update blocker on the WiiKey:
Doesn’t work, from reading a litte on the net I found out that you have to enable dev mode as well.

Try 2 (A bit better):
Enabled dev mode as well as the update blocker on the WiiKey. The disc loads correctly, but when you try to start it you just get a black screen.

Try 3 (Almost there):
Got a tip to try it in 50hz mode. Did that, and… it works. However the game runs awfully slow, and you get audio artefacts from some sounds which means it’s not really playable.

Try 4 (Success!):
Decided to try FreeLoader for Wii. I disabled update blocker and dev mode on the WiiKey, and changed back to 60hz.
First I went to the disc screen and inserted the FreeLoader disc and waited for it to load (you may see some graphic artefacts during this time). Then I ejected the FreeLoader disc and inserted my SMBB disc and started it. And it worked fine.

If you get a white screen saying the disc can’t be read after the “Loading…” message you’re propably suffering from a bad burn.

Ruby’s GNU readline module

Monday, February 25th, 2008

One thing I really don’t like is libraries that lacks documentation. Which, incidentally, is exactly what ruby’s readline module does.

Happily, however, I found this post which explains at least the basic usage - thank you, Adam!

ryara.net v3

Sunday, December 2nd, 2007

I’ve yet again remade my website (second time this year), and I think it looks better than the older two.
New for this version is a new PHP backend for the portfolio part, which I’m quite happy with. Eventually I’ll probably release the source for it, too.

I’d also like to thank Andreas Viklund for the template I used, and friends of mine for help with a few design decisions.

SvsG source released

Tuesday, September 4th, 2007

Yep, I’ve decided to release the source of the game SvsG that I made together with a classmate quite a long time ago. It’s released under the MIT license, and you can find it here.

I haven’t cleaned up the directories, but it should still be usable (otherwise you could just import the important files into a new project).

It should also be noted that I consider most of the code not to be very well written. But it’s still usable. ;)

Now playing for irssi using Last.fm

Monday, August 20th, 2007

You sometimes want announce what music you’re playing on IRC, but when using irssi on a remote server this becomes something of a problem. Therefore I wrote a script for irssi that track info for the currently playing track from last.fm, and prints it to the current channel.

To use the script:
1. Get it and place it in your ~/.irssi/scripts folder.
2. Optionally place a symlink to it in ~/.irssi/scripts/autorun directory to load it automatically when you start irssi.
3. Edit the file and change the $lastfmuser variable to your Last.fm username.
4. Load the script in irssi: /RUN npScriptLastFm.pl
5. You can now use the script by using the command /np

As written in the file itselft it’s distributed under the MIT license.
Hope you’ll find it useful.

Edit: Thanks to Salminen (see comments), the script should now be working, I’ve updated the link so it points to the working version.

Challenge: Last clue

Monday, August 20th, 2007

Yes, it’s now time for the last clue, here and it is (the original unenciphered text). The text is from Wikipedia (Credit given where credit is due).

And so, as stated before, getting the cipher key should now be a question of brute force ;)

Challenge: Continued

Saturday, August 11th, 2007

Seeing that I’ve once again have access to the files related to the challenge, it’s time for the next part.
As promised before I’ve now released the source code of the cipher, and you may aquire it from my projects page.

It should now be at least a little bit easier to take on the challenge, but as said before: if no-one manages to beat it, I’ll post the unencrypted text in one week. And after that it should only be a matter of brute force to beat it ;) .

Good luck!

A challenge

Thursday, July 12th, 2007

I’ve constructed a weak cipher and made a sample implementation of it, and now I have a challenge for you: Find the key with which this file has been enciphered. You can find the characters supported by the cipher in this file.

To help you out a bit you’ll also get the sample program which can encipher and decipher text using a specified key. Please note that it’s not intended to reverse engineer the program.

If no-one has reported progress (or success) after one week I’ll post the source code to the librarary, and if there’s still no progress after yet another week I’ll also post the non-enciphered version of the text. Then I’ll wait a month or so untill I post the answer.

I intend to release the library and sample application later, but for now you are not allowed to modify or redistribute them.

Good luck!