タイトーメモリーズのGZHファイル構造 (2009/08/06)を読む
http://zarala.g2.xrea.com/koneta/taito_memories.html
切り出しツール(crc.c)をつくる
#include <stdio.h> #include <stdlib.h> #include <limits.h> #include <sys/stat.h> static const unsigned int crc32tab[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, }; unsigned int crc32(char *p, int len) { unsigned int crcinit = 0; unsigned int crc = 0; crc = crcinit ^ 0xFFFFFFFF; for (; len--; p++) { crc = ((crc >> 8) & 0x00FFFFFF) ^ crc32tab[(crc ^ (*p)) & 0xFF]; } return crc ^ 0xFFFFFFFF; } int main(int ac, char **av) { struct stat stbuf; unsigned int crc; unsigned int c; unsigned char *p; int size, len, i; FILE *fp; if (ac != 4) return -1; if (-1==stat(av[1], &stbuf)) return -1; if (NULL==(fp=fopen(av[1], "rb"))) return -1; size=stbuf.st_size; sscanf(av[2], "%08x", &crc); sscanf(av[3], "%04x", &len); printf("crc32=%08x,size=%04x\n", crc, len); p=malloc(size); fread(p, 1, size, fp); fclose(fp); for (i=0; i <= size-len; i++) { c=crc32(p+i, len); if (c == crc) goto found; } return -1; found: if (NULL==(fp=fopen(av[2], "wb"))) return -1; fwrite(p+i, 1, len, fp); fclose(fp); printf("crc32=%08x,addr=%04x-%04x\n", c, i, i+len-1); return 0; }
切り出しツール(taito.c)をつくる
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> #include <sys/stat.h> int main(int ac, char **av) { struct stat stbuf; unsigned int start; unsigned int c; unsigned char *p, *q, *r; unsigned int size, len, files, i; FILE *fp; if (ac != 2) { printf("Usage: taito GAMESET.GZH\n"); return -1; } if (-1==stat(av[1], &stbuf)) return -1; if (NULL==(fp=fopen(av[1], "rb"))) return -1; printf("filename: %s\n",av[1]); size=stbuf.st_size; printf("filesize: %08x\n", size); p=malloc(size); fread(p, 1, size, fp); fclose(fp); files=*((short *)p); printf("files: %d\n", files); q=p+*(p+4); r=p+*((short *)(p+12)); for (i=0; i<files; i++) { start = *(r+4); start += *(r+5) * 0x100; start += (*(r+6)-1) * 0x10000; start += *(r+7) * 0x1000000; start *= 0x800; len = *((int *)r); printf("#%d %s size=%08x start=%08x\n", i+1, q, len, start); if (NULL==(fp=fopen(q, "wb"))) return -1; fwrite(p+start, 1, len, fp); fclose(fp); q=q+strlen(q)+1; r=r+16; } return 0; }
切り出す
$ gcc crc.c -o crc $ gcc taito.c -o taito $ mkdir taito4 $ cd taito4 $ ../taito Usage: taito GAMESET.GZH $ ../taito GAMESET2.GZH filename: GAMESET2.GZH filesize: 3a9f7800 files: 201 #1 MENU.SDH size=000000c0 start=00008000 #2 MENU.ZSE size=00004c90 start=00008800 #3 LOGO.PSS size=0054c004 start=0000d800 #4 MENU.BGM size=00430000 start=0055a000 #5 BGFINALB.MPG size=007397b3 start=0098a000 #6 BSHARK.CPU1 size=00080000 start=010c3800 #7 BSHARK.CPU2 size=00080000 start=01143800 #8 BSHARK.GFX1 size=00100000 start=011c3800 #9 BSHARK.GFX2 size=00400000 start=012c3800 #10 BSHARK.GFX3 size=00200000 start=016c3800 #11 BSHARK.RPK size=0005c640 start=018c3800 #12 BSHARK.SDH size=00000a80 start=01920000 #13 BSHARK.USER1 size=00080000 start=01921000 #14 BSHARK.ZSE size=001a7380 start=019a1000 #15 BUBLBOB2.CPU1 size=00200000 start=01b48800 #16 BUBLBOB2.GFX1 size=00400000 start=01d48800 #17 BUBLBOB2.GFX2 size=00400000 start=02148800 #18 BUBLBOB2.NOROM_GFX1 size=00004000 start=02548800 #19 BUBLBOB2.NOROM_GFX2 size=00020000 start=0254c800 #20 BUBLBOB2.NV size=00000080 start=0256c800 #21 BUBLBOB2.RPK size=00065150 start=0256d000 #22 BUBLBOB2.SDH size=000010c0 start=025d2800 #23 BUBLBOB2.ZSE size=001504b0 start=025d4000 #24 BUGGYCHL.BG size=00046610 start=02724800 #25 BUGGYCHL.GFX size=00044050 start=0276b000 #26 BUGGYCHL.ROM size=00020810 start=027af800 #27 BUGGYCHL.RPK size=00000310 start=027d0800 #28 BUGGYCHL.SDH size=00000380 start=027d1000 #29 BUGGYCHL.ZSE size=0007dea0 start=027d1800 #30 CHASEHQ.CPU1 size=00080000 start=0284f800 #31 CHASEHQ.CPU2 size=00020000 start=028cf800 #32 CHASEHQ.GFX1 size=00100000 start=028ef800 #33 CHASEHQ.GFX2 size=00400000 start=029ef800 #34 CHASEHQ.GFX3 size=00200000 start=02def800 #35 CHASEHQ.GFX4 size=00400000 start=02fef800 #36 CHASEHQ.SDH size=00000980 start=033ef800 #37 CHASEHQ.USER1 size=00080000 start=033f0800 #38 CHASEHQ.ZSE size=0018d2e0 start=03470800 #39 DEMOB.PSS size=03c9c004 start=035fe000 #40 FGOAL.BG size=00046610 start=0729a800 #41 FGOAL.GFX size=00002050 start=072e1000 #42 FGOAL.ROM size=00010110 start=072e3800 #43 FGOAL.RPK size=00006030 start=072f4000 #44 FGOAL.SDH size=00000180 start=072fa800 #45 FGOAL.ZSE size=00092440 start=072fb000 #46 FINALB.CPU1 size=00040000 start=0738d800 #47 FINALB.GFX1 size=00080000 start=073cd800 #48 FINALB.GFX2 size=00200000 start=0744d800 #49 FINALB.RPK size=00012510 start=0764d800 #50 FINALB.SDH size=00000880 start=07660000 #51 FINALB.ZSE size=001382c0 start=07661000 #52 GAMEPRV2.RPK size=000d16d0 start=07799800 #53 GSWORD.GFX size=00028078 start=0786b000 #54 GSWORD.ROM size=00020370 start=07893800 #55 GSWORD.RPK size=00006320 start=078b4000 #56 GSWORD.SDH size=00000880 start=078ba800 #57 GSWORD.ZSE size=00097250 start=078bb800 #58 GYRODINE.BG size=00046610 start=07953000 #59 GYRODINE.GFX size=00054078 start=07999800 #60 GYRODINE.ROM size=00020350 start=079ee000 #61 GYRODINE.SDH size=00000240 start=07a0e800 #62 GYRODINE.ZSE size=001196c0 start=07a0f000 #63 HALLEYS.BG size=00046610 start=07b28800 #64 HALLEYS.CPU1 size=00010000 start=07b6f000 #65 HALLEYS.GFX1 size=00020000 start=07b7f000 #66 HALLEYS.PROMS size=00000060 start=07b9f000 #67 HALLEYS.RPK size=00032d20 start=07b9f800 #68 HALLEYS.SDH size=00000500 start=07bd2800 #69 HALLEYS.ZSE size=00195d90 start=07bd3000 #70 LSASQUAD.BG size=00046610 start=07d69000 #71 LSASQUAD.GFX size=00080050 start=07daf800 #72 LSASQUAD.ROM size=00021210 start=07e30000 #73 LSASQUAD.RPK size=0004f450 start=07e51800 #74 LSASQUAD.SDH size=00000480 start=07ea1000 #75 LSASQUAD.ZSE size=00075a30 start=07ea1800 #76 MASTERW.BG size=00046610 start=07f17800 #77 MASTERW.CPU1 size=00080000 start=07f5e000 #78 MASTERW.GFX1 size=00200000 start=07fde000 #79 MASTERW.GFX2 size=00200000 start=081de000 #80 MASTERW.RPK size=00032930 start=083de000 #81 MASTERW.SDH size=00000600 start=08411000 #82 MASTERW.ZSE size=000c67a0 start=08411800 #83 MEGAB.CPU1 size=00080000 start=084d8000 #84 MEGAB.GFX1 size=00100000 start=08558000 #85 MEGAB.GFX2 size=00200000 start=08658000 #86 MEGAB.RPK size=00025740 start=08858000 #87 MEGAB.SDH size=00000900 start=0887d800 #88 MEGAB.ZSE size=00103930 start=0887e800 #89 MSISAAC.BG size=00046610 start=08982800 #90 MSISAAC.GFX size=000400a0 start=089c9000 #91 MSISAAC.ROM size=00010010 start=08a09800 #92 MSISAAC.RPK size=00089b20 start=08a1a000 #93 MSISAAC.SDH size=00000680 start=08aa4000 #94 MSISAAC.ZSE size=00090dc0 start=08aa4800 #95 NIGHTSTR.CPU1 size=00080000 start=08b35800 #96 NIGHTSTR.CPU2 size=00040000 start=08bb5800 #97 NIGHTSTR.GFX1 size=00100000 start=08bf5800 #98 NIGHTSTR.GFX2 size=00400000 start=08cf5800 #99 NIGHTSTR.GFX3 size=00200000 start=090f5800 #100 NIGHTSTR.GFX4 size=00400000 start=092f5800 #101 NIGHTSTR.RPK size=0005ea20 start=096f5800 #102 NIGHTSTR.SDH size=00000cc0 start=09754800 #103 NIGHTSTR.USER1 size=00080000 start=09755800 #104 NIGHTSTR.ZSE size=0019a830 start=097d5800 #105 ONNA34RO.GFX size=00080050 start=09970800 #106 ONNA34RO.ROM size=00010010 start=099f1000 #107 ONNA34RO.RPK size=0002fb20 start=09a01800 #108 ONNA34RO.SDH size=00000c00 start=09a31800 #109 ONNA34RO.ZSE size=001a7ad0 start=09a32800 #110 OPWOLF.CPU1 size=00040000 start=09bda800 #111 OPWOLF.GFX1 size=00100000 start=09c1a800 #112 OPWOLF.GFX2 size=00100000 start=09d1a800 #113 OPWOLF.RPK size=00029830 start=09e1a800 #114 OPWOLF.SDH size=00000700 start=09e44800 #115 OPWOLF.ZSE size=00192950 start=09e45000 #116 PHOENIX.BG size=00046610 start=09fd8000 #117 PHOENIX.CPU1 size=00010000 start=0a01e800 #118 PHOENIX.GFX1 size=00004000 start=0a02e800 #119 PHOENIX.GFX2 size=00004000 start=0a032800 #120 PHOENIX.PROMS size=00000200 start=0a036800 #121 PHOENIX.RPK size=0000c630 start=0a037000 #122 PHOENIX.SDH size=00000680 start=0a043800 #123 PHOENIX.ZSE size=001756d0 start=0a044000 #124 PLUMPPOP.GFX size=00200028 start=0a1b9800 #125 PLUMPPOP.ROM size=00048410 start=0a3ba000 #126 PLUMPPOP.RPK size=00018220 start=0a402800 #127 PLUMPPOP.SDH size=00000580 start=0a41b000 #128 PLUMPPOP.ZSE size=0013db50 start=0a41b800 #129 POLARIS.BG size=00046610 start=0a559800 #130 POLARIS.CPU1 size=00010000 start=0a5a0000 #131 POLARIS.PROMS size=00000400 start=0a5b0000 #132 POLARIS.RPK size=00041220 start=0a5b0800 #133 POLARIS.SDH size=00000100 start=0a5f2000 #134 POLARIS.USER1 size=00000100 start=0a5f2800 #135 POLARIS.ZSE size=00042b90 start=0a5f3000 #136 RAINBOWE.CPU1 size=00080000 start=0a636000 #137 RAINBOWE.GFX1 size=00100000 start=0a6b6000 #138 RAINBOWE.GFX2 size=00140000 start=0a7b6000 #139 RAINBOWE.RPK size=00046740 start=0a8f6000 #140 RAINBOWE.SDH size=00000980 start=0a93c800 #141 RAINBOWE.ZSE size=001a56b0 start=0a93d800 #142 SFPOSEID.GFX size=000100a0 start=0aae3000 #143 SFPOSEID.ROM size=0001a910 start=0aaf3800 #144 SFPOSEID.RPK size=0006e320 start=0ab0e800 #145 SFPOSEID.SDH size=00000400 start=0ab7d000 #146 SFPOSEID.ZSE size=0007f890 start=0ab7d800 #147 THUNDFOX.CPU1 size=00080000 start=0abfd800 #148 THUNDFOX.GFX1 size=00100000 start=0ac7d800 #149 THUNDFOX.GFX2 size=00200000 start=0ad7d800 #150 THUNDFOX.GFX3 size=00100000 start=0af7d800 #151 THUNDFOX.RPK size=00070760 start=0b07d800 #152 THUNDFOX.SDH size=00000b40 start=0b0ee000 #153 THUNDFOX.ZSE size=00151b80 start=0b0ef000 #154 TOPSPEED.CPU1 size=00100000 start=0b241000 #155 TOPSPEED.CPU2 size=00020000 start=0b341000 #156 TOPSPEED.GFX1 size=00080000 start=0b361000 #157 TOPSPEED.GFX2 size=00400000 start=0b3e1000 #158 TOPSPEED.RPK size=0004b110 start=0b7e1000 #159 TOPSPEED.SDH size=00000440 start=0b82c800 #160 TOPSPEED.USER1 size=00010000 start=0b82d000 #161 TOPSPEED.USER2 size=00002000 start=0b83d000 #162 TOPSPEED.ZSE size=00195070 start=0b83f000 #163 VOLFIED.BG size=00046610 start=0b9d4800 #164 VOLFIED.CPU1 size=00100000 start=0ba1b000 #165 VOLFIED.GFX1 size=00180000 start=0bb1b000 #166 VOLFIED.RPK size=0001bf40 start=0bc9b000 #167 VOLFIED.SDH size=00000480 start=0bcb7000 #168 VOLFIED.ZSE size=00112c80 start=0bcb7800 #169 WARRIORB.BG size=00046610 start=0bdca800 #170 WARRIORB.CPU1 size=00200000 start=0be11000 #171 WARRIORB.GFX1 size=00400000 start=0c011000 #172 WARRIORB.GFX2 size=00800000 start=0c411000 #173 WARRIORB.GFX3 size=00400000 start=0cc11000 #174 WARRIORB.RPK size=00056fb0 start=0d011000 #175 WARRIORB.SDH size=000011c0 start=0d068000 #176 WARRIORB.ZSE size=00145b50 start=0d069800 #177 BSHARK.BGM size=01010000 start=0d1af800 #178 BUBLBOB2.BGM size=01d08000 start=0e1bf800 #179 BUGGYCHL.BGM size=005f0000 start=0fec7800 #180 CHASEHQ.BGM size=01570000 start=104b7800 #181 FGOAL.BGM size=00000000 start=11a27800 #182 FINALB.BGM size=00aa0000 start=11a27800 #183 GSWORD.BGM size=01090000 start=124c7800 #184 GYRODINE.BGM size=00370000 start=13557800 #185 HALLEYS.BGM size=00ff0000 start=138c7800 #186 LSASQUAD.BGM size=00b60000 start=148b7800 #187 MASTERW.BGM size=02730000 start=15417800 #188 MEGAB.BGM size=04ac0000 start=17b47800 #189 MSISAAC.BGM size=01fd8000 start=1c607800 #190 NIGHTSTR.BGM size=07530000 start=1e5df800 #191 ONNA34RO.BGM size=03420000 start=25b0f800 #192 OPWOLF.BGM size=00500000 start=28f2f800 #193 PHOENIX.BGM size=000f0000 start=2942f800 #194 PLUMPPOP.BGM size=00e20000 start=2951f800 #195 POLARIS.BGM size=00000000 start=2a33f800 #196 RAINBOWE.BGM size=02e18000 start=2a33f800 #197 SFPOSEID.BGM size=005e0000 start=2d157800 #198 THUNDFOX.BGM size=013c0000 start=2d737800 #199 TOPSPEED.BGM size=01c60000 start=2eaf7800 #200 VOLFIED.BGM size=005f0000 start=30757800 #201 WARRIORB.BGM size=09cb0000 start=30d47800
CRCを調べる
切り出す
$ ../crc FGOAL.ROM 45fd7b03 800 $ ../crc FGOAL.ROM 01891c32 800 $ ../crc FGOAL.ROM c297d509 800 $ ../crc FGOAL.ROM 1b0bfa5c 800 $ ../crc FGOAL.GFX 925b78ab 400 $ ../crc FGOAL.GFX 3d2f007b 400 $ ../crc FGOAL.GFX 0b1d01c4 400 $ ../crc FGOAL.GFX 5cbc7dfd 400 $ mv 45fd7b03 tf04.m28 $ mv 01891c32 tf03.m31 $ mv c297d509 tf02.m38 $ mv 1b0bfa5c tf01.m46 $ mv 925b78ab tf05.m11 $ mv 3d2f007b tf06.m4 $ mv 0b1d01c4 tf07.m12 $ mv 5cbc7dfd tf08.m5
以下は見つからないです。(オール0x00で0x100バイトのファイルをつくります)
ROM_REGION( 0x0100, "proms", ROMREGION_INVERT ) ROM_LOAD_NIB_LOW ( "tf09.m13", 0x0000, 0x0100, CRC(b0fc4b80) SHA1(c6029f6d912275aa65302ca97281e10ccbf63159) ) ROM_LOAD_NIB_HIGH( "tf10.m6", 0x0000, 0x0100, CRC(7b30b15d) SHA1(e9826a107b209e18d891ead341eda3d4523ce195)
MAMEではSOUNDがサポートされていません。