伝説の脱衣麻雀の絵を取り出すコード

発掘できた。

/*mbmpg.c このファイル名が何の略かはおぼえてない*/
#include <stdio.h>
#include <stdlib.h>

int tekito = 0;
typedef unsigned char byte;

long getfilesize(char *filename)
{
	FILE *fp;
	long size;
	
	fp = fopen(filename, "rb");
	if (!fp) {
		printf("error cannot read %s.\n", filename);
		return 0;
	}
	fseek(fp, 0, SEEK_END);
	size = ftell(fp);
	printf("%sのサイズは%ldバイト\n", filename, size);
	fclose(fp);
	return size;
}

int isbmphead(byte *s)
{
	if (s[0] == 'B' && s[1] == 'M')
	{
		if (tekito)
			return 1;
		if (s[6] == 0 && s[7] == 0)
			return 1;
	}
	return 0;
}

void dofile(char *filename, char *zen)
{
	long filesize, curpos;
	int cnt;
	byte *buf, *s;
	FILE *f;
	filesize = getfilesize(filename);
	if (!filesize) {
		printf("error empty %s.\n", filename);
		return;
	}
	f = fopen(filename, "rb");
	if (!f) {
		printf("error cannot read %s.\n", filename);
		return;
	}

	buf = (byte *) malloc(filesize + 256);
	if (!buf) {
		printf("No enough mem.\n");
		fclose(f);
		return;
	}
	else {
		printf("filesize = %d (%08x).\n", filesize, filesize);
		printf("mem arokeiteddo.\n");
	}

	fread(buf, filesize, 1, f);

	curpos = 0;
	cnt = 0;
	while(curpos < filesize)
	{
		s = &buf[curpos];
		if (isbmphead(s))
		{
			char outfilename[1024];
			FILE *outfile;
			printf("curpos = %8x\n", curpos);
			cnt++;
			sprintf(outfilename, "%s%03d.bmp", zen, cnt);
			outfile = fopen(outfilename, "wb");
			do 
			{
				fwrite(s, 1, 1, outfile);
				s++;
				curpos++;
				if (curpos >= filesize) break;
			} while (!isbmphead(s));
			fclose(outfile);
			
			if (cnt > 200) {
				printf ("error too much file.\n");
				break;
			}
		}
		else
		{
			curpos++;
		}
	}

	free(buf);
	fclose(f);
}

int main(int argc,char *argv[])
{
	if (argc <= 2) {
		printf("usage : mbmpg <filename> <head>\n");
		return 1;
	}
	dofile(argv[1], argv[2]);
	return 0;
}

そんでコンパイルしてmbmpg.exeができたら
binsフォルダにデータファイルを入れてから
↓のようなバッチファイルを書いて実行する。

mbmpg bins/MOEJAN01.BIN m01
mbmpg bins/MOEJAN02.BIN m02
...