home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- * *
- * Archimedes sprite information *
- * *
- * Version 1.00 (09-Mar-1989) *
- * 2.00 (17-Jun-1993) - New sprite library routines used *
- * 2.10 (17-Aug-1993) *
- * 3.00 (14-Sep-1993) - Colour statisitics added *
- * 4.02 (13-Jan-1994) - Deep sprite info added *
- * *
- * (C) 1989-1994 DEEJ Technology PLC *
- * *
- ************************************************************************/
-
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include "io.h"
- #include "sprite.h"
- #include "palette.h"
-
- /* uncomment to get stats on hash table usage */
- /*
- #define HASH_STAT
- */
-
- int main(int argc, char** argv)
- {
- int i;
- int xres, yres, type;
- FILE *file;
-
- spr_info_str spr;
-
- if(argc>1 && argv[argc-1][0]!='-')
- file = fopen(argv[argc-1],"r");
- else
- file = stdin;
-
- if(file == 0)
- {
- fprintf(stderr,"Could not open file\n");
- return(1);
- }
-
- read_sprite_header(&spr,file);
-
- type = (unsigned)spr.mode >> 27;
- xres = (spr.mode >> 1) & 0xFFF;
- yres = (spr.mode >> 14) & 0xFFF;
-
- if(type==0)
- {
- printf("Mode : %d (0x%X)\n", spr.mode, spr.mode);
- }
- else
- {
- printf("Mode (deep) : 0x%X (%d:%dx%d)\n", spr.mode,
- type,xres,yres);
- }
- printf("Resolution : %dx%d\n", spr.X, spr.Y);
- printf("Pixel apsect: %dx%d\n", spr.Xasp, spr.Yasp);
- printf("Line size : %d\n", spr.line_size);
- printf("BPP/spacing : %d/%d\n", spr.bpp, spr.pix);
- printf("Colours : %d\n", spr.cols);
- printf("Palette : %s (%d)\n", spr.has_palette ? "Yes":"No",
- spr.has_palette);
-
- if(argc>1 && strcmp(argv[1],"-c")==0)
- {
- printf("\n");
- if(spr.has_palette)
- {
- printf("Palette BBGGRRXX red,green,blue\n");
-
- for(i=0; i<spr.cols; i++)
- {
- printf("%5d : %08X %3d %3d %3d\n",
- i, spr.palette[i],
- (spr.palette[i] >> 8) & 0xFF,
- (spr.palette[i] >> 16) & 0xFF,
- (spr.palette[i] >> 24) & 0xFF);
- }
- }
- else
- {
- printf("Sprite has no palette\n");
- }
- }
-
- if(argc>1 && strcmp(argv[1],"-s")==0)
- {
- hist_info *hist;
-
- /* read sprite data */
-
- alloc_spr_data(&spr);
- fread(spr.spr_data, spr.line_size, spr.Y, file);
-
- /* build and report on histogram */
-
- #ifdef HASH_STAT
- printf("\n");
- #endif
- hist = build_histogram(&spr);
- #ifdef HASH_STAT
- printf("\n");
-
- printf("Hash used : %-7d %3d%%\n",hist->hash_used,
- hist->hash_used*
- 100/HASH_SIZE);
- printf("Hash hits : %-7d %3d%%\n",hist->hash_hits,
- hist->hash_hits*
- 100/(spr.X*spr.Y));
- printf("Hash misses : %-7d %3d%%\n",hist->hash_miss,
- hist->hash_miss*
- 100/(spr.X*spr.Y));
- printf("Hash chain : %-7d\n", hist->hash_chain);
- printf("\n");
- #endif
- printf("Colours used: %d\n",hist->colours);
- printf("used > 1 : %d\n",hist->more1);
- printf("used > 10 : %d\n",hist->more10);
- printf("used > 100 : %d\n",hist->more100);
- printf("used > %.2f%%: %-5d (%d pixels)\n",
- 100.0/(float)FILTER_FRAC,
- hist->more_frac,
- hist->fraction);
- printf("Maximum use : %d\n",hist->max_use);
- printf("Average use : %d\n",hist->avg_use);
- }
- fclose(file);
- }
-