From ModdingWiki
Jump to navigation Jump to search
IQ-Balls screenshot

IQ-Balls is a cracktro used in a number of releases by The Dream Team. It consists of a scrolling message with four bouncing balls, each of which jumps in time to one of the four channels in the background music.

The main .exe file is compressed with PK-Lite, and the music is stored encrypted in HCMUSIC.BIN. The encryption is a simple XOR cipher applied to the first 10,000 bytes of the file, with the key being a string of 100 bytes containing the values from 1 to 100 inclusive (0x01 0x02 0x03 etc.)

The code below can both encrypt and decrypt files. If it is saved into hcmusic-decode.c and compiled, it is used as a filter:

hcmusic-decode < hcmusic.bin > out.mod

#include <unistd.h>

#define BLOCK_SIZE        100
#define ENCRYPTED_AMOUNT  10000

int main(int argc, char* argv[])
	char key[BLOCK_SIZE];
	char data[BLOCK_SIZE];
	int i, n, total;

	for (i = 0; i < BLOCK_SIZE; i++) key[i] = i+1;

	total = 0;
	while ((n = read(STDIN_FILENO, data, BLOCK_SIZE))) {
		if (total < ENCRYPTED_AMOUNT) {
			for (i = 0; i < n; i++) {
				data[i] = data[i] ^ key[i];
		write(STDOUT_FILENO, data, n);
		total += n;

	return 0;