8 #define MAPNAME "Diagonal"
\r
9 #define FILENAME "%s.MAP"
\r
10 char fn[100] = FILENAME;
\r
11 typedef unsigned char BYTE;
\r
12 typedef unsigned short int WORD;
\r
13 typedef BYTE ROW[WIDTH];
\r
17 #define MAGIC_NUM 100
\r
18 #define SQUARE_WIDTH 16
\r
19 #define SQUARE_HEIGHT 16
\r
20 #define SCREEN_WIDTH 320
\r
21 #define SCREEN_HEIGHT 200
\r
22 #define VIRTUAL_WIDTH 352
\r
23 #define VIRTUAL_HEIGHT 240
\r
24 typedef struct MAPHEADER {
\r
25 BYTE name[12]; /* 12 Includes [n]=0 and [n+1]=26 */
\r
27 WORD height; /* 2 */
\r
28 WORD extent; /* 2 */
\r
29 WORD off_x1; /* 2 */
\r
30 WORD off_y1; /* 2 */
\r
31 WORD off_x2; /* 2 */
\r
32 WORD off_y2; /* 2 */
\r
33 WORD x_wrap; /* 2 */
\r
34 WORD y_wrap; /* 2 */
\r
36 } MAPHEADER, far *LPMAPHEADER;
\r
39 void main(int argc, char *argv[])
\r
48 width = atoi(argv[1]);
\r
51 printf("Width = %d\n",width);
\r
54 height = atoi(argv[2]);
\r
57 printf("Height = %d\n",height);
\r
61 sprintf(fn,FILENAME,MAPNAME);
\r
62 fp = fopen(fn,"wb");
\r
64 printf("Couldn't open %s for write.\n",fn);
\r
68 memset(&mh, 0xFF, sizeof(MAPHEADER)); /* Will reveal missing initializing */
\r
69 strcpy((char *)mh.name,MAPNAME);
\r
71 mh.name[9]=26; /* Ctrl-Z */
\r
72 mh.width = (WORD)width;
\r
73 mh.height = (WORD)height;
\r
74 mh.extent = (WORD)((WORD)width * (WORD)height);
\r
75 mh.off_x1 = (WORD)0;
\r
76 mh.off_y1 = (WORD)0;
\r
77 mh.off_x2 = (WORD)(((VIRTUAL_WIDTH / SQUARE_WIDTH) - 1) % width);
\r
78 mh.off_y2 = (WORD)((((VIRTUAL_HEIGHT / SQUARE_HEIGHT) - 1) % height) * width);
\r
79 mh.x_wrap = (WORD)width;
\r
80 mh.y_wrap = (WORD)height;
\r
81 mh.magic = MAGIC_NUM;
\r
82 fwrite(&mh, 1, sizeof(MAPHEADER), fp);
\r
84 for (i = 0; i<width; i++) {
\r
85 b = (BYTE)(i%width);
\r
86 for (j = 0; j<width; j++) {
\r
88 b = (BYTE)(((int)b+1) % width);
\r
92 fwrite(r, width,1, fp);
\r
93 printf("Map row %d\r",i);
\r
96 printf("All done! \n");
\r