# HG changeset patch # User Mychaela Falconia # Date 1516481168 0 # Node ID f233f0a012c9f63fec37076da5978df455e6387c # Parent 8f08645901a0cb8bb90ede390876b18ab4d96440 miscprog: fbdump2ppm program written, compiles diff -r 8f08645901a0 -r f233f0a012c9 .hgignore --- a/.hgignore Sat Jan 20 00:38:51 2018 +0000 +++ b/.hgignore Sat Jan 20 20:46:08 2018 +0000 @@ -30,6 +30,7 @@ ^miscprog/calextract$ ^miscprog/cinitdump$ ^miscprog/factdiff$ +^miscprog/fbdump2ppm$ ^miscprog/ftmdump$ ^miscprog/grokdsn$ ^miscprog/imeibrute$ diff -r 8f08645901a0 -r f233f0a012c9 miscprog/Makefile --- a/miscprog/Makefile Sat Jan 20 00:38:51 2018 +0000 +++ b/miscprog/Makefile Sat Jan 20 20:46:08 2018 +0000 @@ -1,8 +1,8 @@ CC= gcc CFLAGS= -O2 -STD= atsc calextract cinitdump factdiff ftmdump grokdsn memwrite-grep \ - mokosrec2bin osmo2psi pirbattextr pircalextr pircksum pircksum2 \ - rfcap-grep +STD= atsc calextract cinitdump factdiff fbdump2ppm ftmdump grokdsn \ + memwrite-grep mokosrec2bin osmo2psi pirbattextr pircalextr pircksum \ + pircksum2 rfcap-grep CRYPTO= imeibrute pirimei PROGS= ${STD} ${CRYPTO} @@ -18,6 +18,7 @@ calextract: calextract.c cinitdump: cinitdump.c factdiff: factdiff.c +fbdump2ppm: fbdump2ppm.c ftmdump: ftmdump.c grokdsn: grokdsn.c imeibrute: imeibrute.c diff -r 8f08645901a0 -r f233f0a012c9 miscprog/fbdump2ppm.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/miscprog/fbdump2ppm.c Sat Jan 20 20:46:08 2018 +0000 @@ -0,0 +1,60 @@ +/* + * This program converts a dump of TI's R2D framebuffer (176x220 pix, 16-bit) + * captured via fc-memdump into PPM format for viewing. + */ + +#include +#include +#include + +#define NPIX (176*220) + +FILE *inf, *outf; + +convert_pixel() +{ + int i, c; + u_char inb[2]; + unsigned pix16, r, g, b; + + for (i = 0; i < 2; i++) { + c = getc(inf); + if (c < 0) { + fprintf(stderr, "error: input is too short\n"); + exit(1); + } + inb[i] = c; + } + pix16 = (inb[0] | (inb[1] << 8)) ^ 0xFFFF; + r = pix16 >> 11; + g = (pix16 >> 5) & 0x3F; + b = pix16 & 0x1F; + putc(r << 3, outf); + putc(g << 2, outf); + putc(b << 3, outf); +} + +main(argc, argv) + char **argv; +{ + unsigned n; + + if (argc != 3) { + fprintf(stderr, "usage: %s infile outfile\n", argv[0]); + exit(1); + } + inf = fopen(argv[1], "r"); + if (!inf) { + perror(argv[1]); + exit(1); + } + outf = fopen(argv[2], "w"); + if (!outf) { + perror(argv[2]); + exit(1); + } + fprintf(outf, "P6\n176 220\n255\n"); + for (n = 0; n < NPIX; n++) + convert_pixel(); + exit(0); +}