mgdumppgm
PocketBSDのスクリーンダンプをPGM形式で出力するプログラム
//
// gdumppgm.c
//
// たけむらさんの mgdump.c をPGM用に変更したもの
//
// Copyright (c) 1998 Shin Takemura all rights reserved.
//
#include <stdio.h>
#include <sys/mman.h>
//const unsigned char *intensity[4] = {"240 ","180 ","120 ","0 "};
const unsigned char *intensity[4] = {"189 ","154 ","59 ","23 "};
char buf[100] = " ";
main()
{
char *mem;
int i,j,b,y,val;
mem = mmap(0,0x10000,PROT_READ,MAP_PRIVATE,0,0);
if(mem == MAP_FAILED) exit(1);
printf("P2\n640 240\n255\n"); // PGM header
for(y=0;y<240;y++){
for(i=0;i<40;i++){
for(j=0;j<4;j++){
for(b=0;b<4;b++){
val = (mem[y*0x100+i*4+j]>>(b*2))&0x03;
strcpy(buf+(j*4+b)*4,intensity[val]);
}
}
strcpy(buf+64,"\n");
fwrite(buf,1,65,stdout);
}
}
}