Archive for the code Category

Old stuff not announced before: these are a couple of small and simple GTK+ tray applications to help hobbyists installing alternative operating systems in the Eeepc and similar netbooks to show capslock or numlock status (in case the hardware lacks the appropriate LEDs) or to logout or shutdown from GUI if you’re running finit with a light desktop environment. Get the code from the git repository with git clone http://helllabs.org/git/tray.git. (You may also be interested in Metalshark’s kbdstatus, which a Xlib-based version of the original Eeepc keyboardstatus application.)

You’ll need to supply a shutdown helper script and allow it to send signals to the init process if executed from the console (registering it with pam_console, for example). The applications are GPLed, so please consider contributing back your enhancements, fixes and changes.

The traditional method of dealing with filesystem images is to mount them as loopback devices, and that is a simple, elegant and universal way to change its contents in any way you feel fit. It has the disadvantage, however, of requiring superuser privileges — which you may not have in every host you frequent, or you wisely don’t wish to grant to anyone using your machine to develop filesystem images. Christian Hohnstädt’s e2fsimage solves the problem allowing one to copy an entire subtree into a image file, but what if you want to extract, examine or manipulate arbitrary content?

(more…)

Slow booting plagues most Linux distributions today, and while this is not a such big issue for systems that are booted once a year, it becomes an annoyance in laptops or other computers you initialize every day. Different solutions for this problem have been proposed, but booting of a typical Linux system today still takes too much time. It has been said that the Asus Eeepc boots remarkably faster than regular Linux distributions, thanks to its “fastinit” system initialization program. A quick analysis of its workings shows what it essentally does, and it’s quite obvious: start the user interface as fast as possible, and initialize the rest later. A more detailed analysis allowed us to rewrite it, and even find a couple of bugs in the original code.

(more…)

XMP goes full circle: earlier this week I merged a patch from Lorence Lombardo that allows the player to work in AHI-compatible Amiga systems. Of course it’s not the most efficient way to play Amiga formats on an Amiga, but a curious development nonetheless. I was surprised to see how easy it is to configure the audio output in this port, even compared to the simple descriptor/ioctl approach used in most Unixes:

    int fd;

    if ((fd = open("AUDIO:B/16/F44100/C/2/BUFFER/358000, O_WRONLY)) < 0)
        return -1;
    write(fd, data, len);
    close(fd);

I also spent some time preparing a Windows port built with MinGW. If the Amiga API above was the simplest to implement, the WinMM API is in the opposite extreme (words like “clumsy” and “design disaster” come quickly to mind). The following code does the exacly same thing using the WinMM API. Don’t read if you have a weak stomach.

(more…)

Following the port of xmp to QNX6 I wiped out Neutrino from the test machine and installed BeOS Max Edition. A new BeOS sound driver was written, based on the OSX CoreAudio driver and documentation found in the Internet. Some tweaking was required to build the driver since the SoundPlayer API is in C++ and the rest of application is C.

BeOS port of xmp

Sound quality is fine, terminal settings work correctly and latency is decent. Should we try Plan9 now?

Following the development of the investigations on the recently reported Mesa problem triggered by Neverball and Metisse, Ademar reports that “the workaround is not effective with at least ATI 9250 video cards, where we now have a crash at a different place”. We set up a system with an ATI Radeon 9250, and, indeed, it still crashes:

Mesa: Mesa 7.0.1 DEBUG build Oct  1 2007 18:52:02
Mesa warning: couldn't open libtxc_dxtn.so, software DXTn compression/
decompression unavailable
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1218062640 (LWP 17221)]
_generic_read_RGBA_span_RGB565_MMX () at x86/read_rgba_span_x86.S:590
590             pushl   MASK_565_H

A segfault in a push instruction sounds very odd. Read on to see what the differential diagnosis session with Boto and Salem lead us into. And unlike the previous patch, this one resulted in a real fix for a real problem:

Don’t read the patch if you want to find the bug yourself based on the scenario description below.

(more…)

Today at lunch boto handled me a QNX Neutrino 6.3.2 CD he was using in virtualization tests for Red Hat. I quickly installed it on a spare machine to see how well xmp would build on it — and it built quite well. After fixing some trivial build problems I examined the new sound system used in QNX6 (since the old drivers for QNX4 didn’t compile), and I was pleased to find that it’s based on the old ALSA 0.5 API. Xmp has an ALSA 0.5 driver written in 2000 by Tijs van Bakel and Rob Adamson, and it worked out of the box in Neutrino 6. Source patch and binary are available in the SF download page.

xmp in QNX Neutrino

Next targets to test/port xmp include Plan9 (new port), BeOS and AIX (drivers exist, but never tested), and OS/2, IRIX, HP-UX and Solaris (used to work, but not tested for a long time). Contact me if you have access to one or more of those (or other) systems and have some free time to test the portability of an old mod player.

anarkey2.png Gustavo Boiko gave it a name so I threw in a couple of additional code lines to justify the name change. Unlike your previously unnamed hack, which generated only simultaneous key combinations, Anarkey handles sequential keystrokes as well. The configuration file format handles key “chords” like lilypond, so with Anarkey you can use

abc <64 102> 38 56 54

in the configuration file to generate a sequence of fake keystrokes ALT+Right, A, B and C when you run ./ak abc. Build with gcc -o ak ak.c -lXtst, ak.c is listed below. The code is released to the public domain, please refer to the original hack for additional details.

(more…)

Suppose that, for some reason, you’d like to have a program that sends a key combination such as <Control+Left Arrow> to your X server. You can do that trivially using the X Test extension and XTestFakeKeyEvent, but if you want something a bit more flexible you can add a configuration file like

fwd     64 102
back    64 100

where the command back would simulate simultaneous keypresses of ALT (keycode 64) and Left Arrow (keycode 100). Don’t ask why would someone want to do something like this — the only thing I can assure you is that we had a good reason. If that’s your case, the following C program is what you need. Released to the public domain, compile and link against libXtst.

Update: a better version is available.

(more…)

Recent rediscovery of xmp and the amount of improvements on the player since then is proof that modplaying is still one of my obsessions favorite idle-time activities. Like coding, or reverse engineering file formats. Put them together, and what you get is a modplayer with support to strange file formats you possibly never heard of, such as STMIK (a precursor of Future Crew’s famous S3M format), MASI (used in some old DOS games such as Epic Pinball and Jazz Jackrabbit), DIGI Booster (Amiga), TCB Tracker (Atari) and so on. This time we had a different and intriguing challenge: a simple module format with a rather strange sound sample encoding. If you’re interested in retrocomputing, reverse engineering, investigative stories, or Python, read on.

(more…)