home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- * *
- * Changes the mode number of a sprite *
- * for use with non standard modes, doesnt affect sprite data. *
- * *
- * Version 1.00 (10-Sep-1993) *
- * 1.50 (21-Jun-1994) New sprite type,xres,yres added *
- * *
- * (C) 1993,4 DEEJ Technology PLC *
- * *
- ************************************************************************/
-
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include "io.h"
- #include "sprite.h"
-
- int main(int argc, char** argv)
- {
- FILE *file;
- int mode;
- spritefile sprite;
-
- if(argc!=3 && argc!=5)
- {
- fprintf(stderr,"%s: <sprite file> "
- "{ <new mode> | <type> <xres> <yres> }\n",
- argv[0]);
- return(0);
- }
-
- if(argc == 3)
- {
- mode = atoi(argv[2]);
- }
- else
- {
- int type, xres, yres;
-
- type = atoi(argv[2]);
- xres = atoi(argv[3]);
- yres = atoi(argv[4]);
-
- if(type<0 || type>8)
- {
- fprintf(stderr, "Bad type\n");
- return(1);
- }
- if(xres!=90 && xres!=45)
- {
- fprintf(stderr, "Bad xres\n");
- return(1);
- }
- if(yres!=90 && yres!=45)
- {
- fprintf(stderr, "Bad yres\n");
- return(1);
- }
-
- mode = ((unsigned)type << 27) |
- (xres << 1) |
- (yres << 14) | 1;
- }
-
- if((file = fopen(argv[1],"r+"))==0)
- {
- fprintf(stderr,"Could not open sprite file\n");
- return(1);
- }
-
- read_struct(LE, (BYTE*)&sprite, spritefile_descr, file);
-
- sprite.mode = mode;
-
- rewind(file);
-
- write_struct(LE, (BYTE*)&sprite, spritefile_descr, file);
-
- fclose(file);
- }
-