-/* Split ROM data Program for CqREEK SH-3 (Thanks Yamanaka-san) */\r
-/* Nihon Cygnus Solutions KASHIWAYA Haruki '00-4-13 */\r
-\r
-/* This program separate ROM data for one ROM socket.\r
- The cq board has two ROM sockets, and those bus size can\r
- switch to 8bit or 16bit with JP6.\r
- If your program is smaller than 32kByte, you can use\r
- a 256k bit ROM with 8bit bus mode.\r
- However, the board curcuit connection is peculiar.\r
- A0 is connected to A14 in 8bit bus mode (See the curcuit diagram),\r
- this mean's all odd data are assigned from 0x4000 offset.\r
- You must use this program and separate ROM data when you use\r
- a 256k bit ROM with 8bit bus mode.\r
-\r
- If your program is bigger than 32kByte, simply, you can use\r
- two 256k bit(or bigger) ROM with 16bit bus mode.\r
- You do *not* need to use this program.\r
- (Details, separate ROM data to odd and even, and write each data to\r
- each ROMs, and attach odd's ROM to IC4, even's ROM to IC8.)\r
-\r
-*/\r
-\r
-#include <stdio.h>\r
-#include <errno.h>\r
-\r
-#define ROMSIZE (32 * 1024)\r
-\r
-main(int argc, char **argv)\r
-{\r
- FILE *fpr, *fpw;\r
- int i, c;\r
- char *s, *p;\r
-\r
- if(argc != 3) {\r
- printf("Usage: mkcqrom <input-filename> <output-filename>\n Please see comments in mkcqrom.c.\n");\r
- exit(1);\r
- }\r
-\r
- p = (char *)malloc(ROMSIZE);\r
- if(p == NULL) {\r
- printf("malloc error\n");\r
- exit(1);\r
- }\r
- fpr = fopen(*++argv, "rb");\r
- if(fpr == NULL) {\r
- printf("open error %s %d\n", *argv, errno);\r
- exit(1);\r
- }\r
- memset(p, 0xff, ROMSIZE);\r
-\r
- /* split even data to 0x4000 offset (A0 is assigned to A14) */\r
- i = 0;\r
- while(1) {\r
- c = getc(fpr);\r
- if(c == EOF) break;\r
- s = p + (i / 2) + (i % 2) * 0x4000;\r
- *s = (char)c;\r
- i++;\r
- }\r
- fclose(fpr);\r
-\r
- fpw = fopen(*++argv, "wb");\r
- if(fpw == NULL) {\r
- printf("open error %s %d\n", *argv, errno);\r
- exit(1);\r
- }\r
- fwrite(p, ROMSIZE, sizeof(char), fpw);\r
- fclose(fpw);\r
-}\r
+/* Split ROM data Program for CqREEK SH-3 (Thanks Yamanaka-san) */
+/* Nihon Cygnus Solutions KASHIWAYA Haruki '00-4-13 */
+
+/* This program separate ROM data for one ROM socket.
+ The cq board has two ROM sockets, and those bus size can
+ switch to 8bit or 16bit with JP6.
+ If your program is smaller than 32kByte, you can use
+ a 256k bit ROM with 8bit bus mode.
+ However, the board curcuit connection is peculiar.
+ A0 is connected to A14 in 8bit bus mode (See the curcuit diagram),
+ this mean's all odd data are assigned from 0x4000 offset.
+ You must use this program and separate ROM data when you use
+ a 256k bit ROM with 8bit bus mode.
+
+ If your program is bigger than 32kByte, simply, you can use
+ two 256k bit(or bigger) ROM with 16bit bus mode.
+ You do *not* need to use this program.
+ (Details, separate ROM data to odd and even, and write each data to
+ each ROMs, and attach odd's ROM to IC4, even's ROM to IC8.)
+
+*/
+
+#include <stdio.h>
+#include <errno.h>
+
+#define ROMSIZE (32 * 1024)
+
+main(int argc, char **argv)
+{
+ FILE *fpr, *fpw;
+ int i, c;
+ char *s, *p;
+
+ if(argc != 3) {
+ printf("Usage: mkcqrom <input-filename> <output-filename>\n Please see comments in mkcqrom.c.\n");
+ exit(1);
+ }
+
+ p = (char *)malloc(ROMSIZE);
+ if(p == NULL) {
+ printf("malloc error\n");
+ exit(1);
+ }
+ fpr = fopen(*++argv, "rb");
+ if(fpr == NULL) {
+ printf("open error %s %d\n", *argv, errno);
+ exit(1);
+ }
+ memset(p, 0xff, ROMSIZE);
+
+ /* split even data to 0x4000 offset (A0 is assigned to A14) */
+ i = 0;
+ while(1) {
+ c = getc(fpr);
+ if(c == EOF) break;
+ s = p + (i / 2) + (i % 2) * 0x4000;
+ *s = (char)c;
+ i++;
+ }
+ fclose(fpr);
+
+ fpw = fopen(*++argv, "wb");
+ if(fpw == NULL) {
+ printf("open error %s %d\n", *argv, errno);
+ exit(1);
+ }
+ fwrite(p, ROMSIZE, sizeof(char), fpw);
+ fclose(fpw);
+}
\1a
\ No newline at end of file