RCS file: /cvsroot/scummvm/tools/Makefile,v
retrieving revision 1.53
diff -u -r1.53 Makefile
|
|
|
58 | 58 | compress_scumm_bun$(EXEEXT): compress_scumm_bun.o compress.o util.o |
59 | 59 | $(CXX) $(LDFLAGS) -o $@ $+ |
60 | 60 | |
61 | | extract_loom_tg16$(EXEEXT): extract_loom_tg16.o |
| 61 | extract_loom_tg16$(EXEEXT): extract_loom_tg16.o util.o |
62 | 62 | $(CC) $(LDFLAGS) -o $@ $+ |
63 | 63 | |
64 | | extract_mm_c64$(EXEEXT): extract_mm_c64.o |
| 64 | extract_mm_c64$(EXEEXT): extract_mm_c64.o util.o |
65 | 65 | $(CC) $(LDFLAGS) -o $@ $+ |
66 | 66 | |
67 | | extract_mm_nes$(EXEEXT): extract_mm_nes.o |
| 67 | extract_mm_nes$(EXEEXT): extract_mm_nes.o util.o |
68 | 68 | $(CC) $(LDFLAGS) -o $@ $+ |
69 | 69 | |
70 | 70 | compress_queen$(EXEEXT): compress_queen.o util.o |
… |
… |
|
79 | 79 | extract_simon1_amiga$(EXEEXT): extract_simon1_amiga.o |
80 | 80 | $(CC) $(LDFLAGS) -o $@ $+ |
81 | 81 | |
82 | | extract_zak_c64$(EXEEXT): extract_zak_c64.o |
| 82 | extract_zak_c64$(EXEEXT): extract_zak_c64.o util.o |
83 | 83 | $(CC) $(LDFLAGS) -o $@ $+ |
84 | 84 | |
85 | 85 | compress_simon$(EXEEXT): compress_simon.o compress.o util.o |
RCS file: /cvsroot/scummvm/tools/extract_loom_tg16.c,v
retrieving revision 1.3
diff -u -r1.3 extract_loom_tg16.c
|
|
|
23 | 23 | #include <stdarg.h> |
24 | 24 | #include <stdlib.h> |
25 | 25 | #include <string.h> |
| 26 | #include "util.h" |
26 | 27 | |
27 | 28 | typedef int BOOL; |
28 | 29 | #define TRUE 1 |
… |
… |
|
32 | 33 | /* if not defined, dumps all resources to separate files */ |
33 | 34 | #define MAKE_LFLS |
34 | 35 | |
35 | | #ifdef WIN32 |
36 | | #define CDECL __cdecl |
37 | | #else |
38 | | #define CDECL |
39 | | #endif |
40 | | |
41 | | void CDECL debug (const char *Text, ...) |
42 | | { |
43 | | va_list marker; |
44 | | va_start(marker,Text); |
45 | | vfprintf(stdout,Text,marker); |
46 | | fprintf(stdout,"\n"); |
47 | | va_end(marker); |
48 | | } |
49 | 36 | |
50 | | void CDECL error (const char *Text, ...) |
51 | | { |
52 | | va_list marker; |
53 | | va_start(marker,Text); |
54 | | vfprintf(stderr,Text,marker); |
55 | | fprintf(stderr,"\n"); |
56 | | va_end(marker); |
57 | | exit(1); |
58 | | } |
| 37 | #ifdef _MSC_VER |
| 38 | #define vsnprintf _vsnprintf |
| 39 | #endif |
59 | 40 | |
60 | | void CDECL _assert (BOOL condition, const char *Text, ...) |
61 | | { |
62 | | va_list marker; |
63 | | if (condition) |
64 | | return; |
65 | | va_start(marker,Text); |
66 | | vfprintf(stderr,Text,marker); |
67 | | fprintf(stderr,"\n"); |
68 | | va_end(marker); |
69 | | /* exit(1); */ |
70 | | } |
| 41 | void notice(const char *s, ...) { |
| 42 | char buf[1024]; |
| 43 | va_list va; |
| 44 | |
| 45 | va_start(va, s); |
| 46 | vsnprintf(buf, 1024, s, va); |
| 47 | va_end(va); |
71 | 48 | |
72 | | unsigned char read_byte (FILE *input) |
73 | | { |
74 | | unsigned char val; |
75 | | _assert(fread(&val,1,1,input) == 1,"read_byte - unexpected EOF"); |
76 | | return val; |
77 | | } |
78 | | unsigned short read_word (FILE *input) |
79 | | { |
80 | | unsigned short val; |
81 | | _assert(fread(&val,2,1,input) == 1,"read_word - unexpected EOF"); |
82 | | return val; |
83 | | } |
84 | | void write_byte (FILE *output, unsigned char val) |
85 | | { |
86 | | fwrite(&val,1,1,output); |
| 49 | fprintf(stdout, "%s\n", buf); |
87 | 50 | } |
88 | | void write_word (FILE *output, unsigned short val) |
89 | | { |
90 | | fwrite(&val,2,1,output); |
91 | | } |
92 | | void write_long (FILE *output, unsigned long val) |
93 | | { |
94 | | fwrite(&val,4,1,output); |
95 | | } |
96 | | |
97 | 51 | |
98 | 52 | unsigned char read_cbyte (FILE *input, short *ctr) |
99 | 53 | { |
100 | | unsigned char val; |
101 | | _assert(fread(&val,1,1,input) == 1,"read_cbyte - unexpected EOF"); |
102 | 54 | (*ctr) += 1; |
103 | | return val; |
| 55 | return readByte(input); |
104 | 56 | } |
105 | 57 | unsigned short read_cword (FILE *input, short *ctr) |
106 | 58 | { |
107 | | unsigned short val; |
108 | | _assert(fread(&val,2,1,input) == 1,"read_cword - unexpected EOF"); |
109 | 59 | (*ctr) += 2; |
110 | | return val; |
| 60 | return readUint16LE(input); |
111 | 61 | } |
112 | 62 | |
113 | | void write_cbyte (FILE *output, unsigned char val, short *ctr) |
| 63 | void write_cbyte (FILE *output, uint8 val, short *ctr) |
114 | 64 | { |
115 | | fwrite(&val,1,1,output); |
| 65 | writeByte(output, val); |
116 | 66 | (*ctr) += 1; |
117 | 67 | } |
118 | | void write_cword (FILE *output, unsigned short val, short *ctr) |
| 68 | void write_cword (FILE *output, uint16 val, short *ctr) |
119 | 69 | { |
120 | | fwrite(&val,2,1,output); |
| 70 | writeUint16LE(output, val); |
121 | 71 | (*ctr) += 2; |
122 | 72 | } |
123 | | void write_clong (FILE *output, unsigned long val, short *ctr) |
| 73 | void write_clong (FILE *output, uint32 val, short *ctr) |
124 | 74 | { |
125 | | fwrite(&val,4,1,output); |
| 75 | writeUint32LE(output, val); |
126 | 76 | (*ctr) += 4; |
127 | 77 | } |
128 | 78 | |
… |
… |
|
761 | 711 | signed short i, rlen; |
762 | 712 | unsigned char junk, rtype, rid; |
763 | 713 | |
764 | | _assert(res != NULL,"extract_resource - no resource specified"); |
| 714 | if (res == NULL) |
| 715 | error("extract_resource - no resource specified"); |
765 | 716 | if ((r_offset(res) == 0) && (r_length(res) == 0)) |
766 | 717 | return; /* if offset/length are both 0, skip it */ |
767 | 718 | fseek(input,r_offset(res),SEEK_SET); |
… |
… |
|
770 | 721 | { |
771 | 722 | case RES_CHARSET: |
772 | 723 | rlen = r_length(res); |
773 | | write_word(output,(unsigned short)(rlen+4)); |
774 | | write_word(output,0); |
| 724 | writeUint16LE(output,(unsigned short)(rlen+4)); |
| 725 | writeUint16LE(output,0); |
775 | 726 | for (i = 0; i < rlen; i++) |
776 | | write_byte(output,read_byte(input)); |
| 727 | writeByte(output,readByte(input)); |
777 | 728 | break; |
778 | 729 | case RES_GLOBDATA: |
779 | 730 | rlen = read_cword(input,&i); |
780 | 731 | junk = read_cbyte(input,&i); |
781 | 732 | rtype = read_cbyte(input,&i); |
782 | 733 | rid = read_cbyte(input,&i); |
783 | | _assert(rlen == r_length(res),"extract_resource(globdata) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res)); |
784 | | _assert(rtype == 0x11,"extract_resource(globdata) - resource tag is incorrect!"); |
785 | | write_long(output,(unsigned short)(rlen + 1)); |
786 | | write_word(output,'O0'); /* 0O - Object Index */ |
| 734 | if (rlen != r_length(res)) |
| 735 | error("extract_resource(globdata) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res)); |
| 736 | if (rtype != 0x11) |
| 737 | error("extract_resource(globdata) - resource tag is incorrect!"); |
| 738 | writeUint32LE(output,(unsigned short)(rlen + 1)); |
| 739 | writeUint16LE(output,'O0'); /* 0O - Object Index */ |
787 | 740 | for (i = 5; i < rlen; i++) |
788 | | write_byte(output,read_byte(input)); |
| 741 | writeByte(output,readByte(input)); |
789 | 742 | break; |
790 | 743 | #ifdef MAKE_LFLS |
791 | 744 | case RES_ROOM: |
… |
… |
|
796 | 749 | rtype = read_cbyte(input,&i); |
797 | 750 | rid = read_cbyte(input,&i); |
798 | 751 | /* |
799 | | debug("room res len %04X, junk %02X, type %02X, id %02X",rlen,junk,rtype,rid); |
| 752 | notice("room res len %04X, junk %02X, type %02X, id %02X",rlen,junk,rtype,rid); |
800 | 753 | */ |
801 | | _assert(rlen == r_length(res),"extract_resource(room) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res)); |
802 | | _assert(rtype == 0x01,"extract_resource(room) - resource tag is incorrect!"); |
| 754 | if (rlen != r_length(res)) |
| 755 | error("extract_resource(room) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res)); |
| 756 | if (rtype != 0x01) |
| 757 | error("extract_resource(room) - resource tag is incorrect!"); |
803 | 758 | off = ftell(output); |
804 | 759 | rlen = 0; |
805 | 760 | write_clong(output,0,&rlen); |
… |
… |
|
809 | 764 | unsigned short slen; |
810 | 765 | unsigned char stype; |
811 | 766 | /* BM, HD, SL, NL, PA - current unknowns |
812 | | debug("reading local resource at offset %04X of %04X",i,len); |
| 767 | notice("reading local resource at offset %04X of %04X",i,len); |
813 | 768 | */ |
814 | 769 | slen = read_cword(input,&i); |
815 | 770 | if (slen == 0xFFFF) |
… |
… |
|
878 | 833 | break; |
879 | 834 | default: |
880 | 835 | fseek(input,slen,SEEK_CUR); |
881 | | debug("extract_resource(room) - unknown resource tag encountered: len %04X type %02X",slen,stype); |
| 836 | warning("extract_resource(room) - unknown resource tag encountered: len %04X type %02X",slen,stype); |
882 | 837 | } |
883 | 838 | } |
884 | 839 | fseek(output,off,SEEK_SET); |
885 | | write_long(output,rlen); |
| 840 | writeUint32LE(output,rlen); |
886 | 841 | fseek(output,0,SEEK_END); |
887 | 842 | } |
888 | 843 | break; |
889 | 844 | case RES_SOUND: |
890 | | _assert(FALSE,"extract_resource(sound) - sound resources are not supported!"); |
| 845 | error("extract_resource(sound) - sound resources are not supported!"); |
891 | 846 | break; |
892 | 847 | case RES_COSTUME: |
893 | 848 | rlen = read_cword(input,&i); |
894 | 849 | junk = read_cbyte(input,&i); |
895 | 850 | rtype = read_cbyte(input,&i); |
896 | 851 | rid = read_cbyte(input,&i); |
897 | | _assert(rlen == r_length(res),"extract_resource(costume) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res)); |
898 | | _assert(rtype == 0x03,"extract_resource(costume) - resource tag is incorrect!"); |
899 | | write_long(output,(unsigned short)(rlen + 1)); |
900 | | write_word(output,'OC'); /* CO - Costume */ |
| 852 | if (rlen != r_length(res)) |
| 853 | error("extract_resource(costume) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res)); |
| 854 | if (rtype != 0x03) |
| 855 | error("extract_resource(costume) - resource tag is incorrect!"); |
| 856 | writeUint32LE(output,(unsigned short)(rlen + 1)); |
| 857 | writeUint16LE(output,'OC'); /* CO - Costume */ |
901 | 858 | for (i = 5; i < rlen; i++) |
902 | | write_byte(output,read_byte(input)); |
| 859 | writeByte(output,readByte(input)); |
903 | 860 | break; |
904 | 861 | case RES_SCRIPT: |
905 | 862 | rlen = read_cword(input,&i); |
906 | 863 | junk = read_cbyte(input,&i); |
907 | 864 | rtype = read_cbyte(input,&i); |
908 | 865 | rid = read_cbyte(input,&i); |
909 | | _assert(rlen == r_length(res),"extract_resource(script) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res)); |
910 | | _assert(rtype == 0x02,"extract_resource(script) - resource tag is incorrect!"); |
911 | | write_long(output,(unsigned short)(rlen + 1)); |
912 | | write_word(output,'CS'); /* SC - Script */ |
| 866 | if (rlen != r_length(res)) |
| 867 | error("extract_resource(script) - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res)); |
| 868 | if (rtype != 0x02) |
| 869 | error("extract_resource(script) - resource tag is incorrect!"); |
| 870 | writeUint32LE(output,(unsigned short)(rlen + 1)); |
| 871 | writeUint16LE(output,'CS'); /* SC - Script */ |
913 | 872 | for (i = 5; i < rlen; i++) |
914 | | write_byte(output,read_byte(input)); |
| 873 | writeByte(output,readByte(input)); |
915 | 874 | break; |
916 | 875 | case RES_UNKNOWN: |
917 | 876 | #else |
… |
… |
|
921 | 880 | case RES_SCRIPT: |
922 | 881 | case RES_UNKNOWN: |
923 | 882 | rlen = read_word(input); |
924 | | _assert(rlen == r_length(res),"extract_resource - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res)); |
925 | | write_word(output,rlen); |
| 883 | if (rlen != r_length(res)) |
| 884 | error("extract_resource - length mismatch while extracting resource (was %04X, expected %04X)",rlen,r_length(res)); |
| 885 | writeUint16LE(output,rlen); |
926 | 886 | for (i = 2; i < rlen; i++) |
927 | | write_byte(output,read_byte(input)); |
| 887 | writeByte(output,readByte(input)); |
928 | 888 | break; |
929 | 889 | break; |
930 | 890 | #endif |
931 | 891 | default: |
932 | | debug("extract_resource - unknown resource type %d specified!",res->type); |
| 892 | warning("extract_resource - unknown resource type %d specified!",res->type); |
933 | 893 | } |
934 | 894 | } |
935 | 895 | |
… |
… |
|
1154 | 1114 | len = ftell(file); |
1155 | 1115 | fseek(file,0,SEEK_SET); |
1156 | 1116 | for (i = 0; i < len; i++) |
1157 | | CRC = (CRC >> 8) ^ CRCtable[(CRC ^ read_byte(file)) & 0xFF]; |
| 1117 | CRC = (CRC >> 8) ^ CRCtable[(CRC ^ readByte(file)) & 0xFF]; |
1158 | 1118 | return CRC ^ 0xFFFFFFFF; |
1159 | 1119 | } |
1160 | 1120 | |
… |
… |
|
1179 | 1139 | { |
1180 | 1140 | case 0x29EED3C5: |
1181 | 1141 | ISO = ISO_USA; |
1182 | | debug("ISO contents verified as Loom USA (track 2)"); |
| 1142 | notice("ISO contents verified as Loom USA (track 2)"); |
1183 | 1143 | break; |
1184 | 1144 | default: |
1185 | 1145 | error("ISO contents not recognized!"); |
… |
… |
|
1194 | 1154 | sprintf(fname,"%02i.LFL",lfl->num); |
1195 | 1155 | if (!(output = fopen(fname,"wb"))) |
1196 | 1156 | error("Error: unable to create %s!",fname); |
1197 | | debug("Creating %s...",fname); |
| 1157 | notice("Creating %s...",fname); |
1198 | 1158 | for (j = 0; lfl->entries[j] != NULL; j++) |
1199 | 1159 | { |
1200 | 1160 | p_resource entry = lfl->entries[j]; |
… |
… |
|
1217 | 1177 | lfl_index.sound_addr[entry - res_sounds] = (unsigned short)ftell(output); |
1218 | 1178 | break; |
1219 | 1179 | default: |
1220 | | debug("Unknown resource type %d detected in LFL index!",entry->type); |
| 1180 | notice("Unknown resource type %d detected in LFL index!",entry->type); |
1221 | 1181 | break; |
1222 | 1182 | } |
1223 | 1183 | extract_resource(input,output,entry); |
… |
… |
|
1226 | 1186 | } |
1227 | 1187 | if (!(output = fopen("00.LFL","wb"))) |
1228 | 1188 | error("Error: unable to create index file!"); |
1229 | | debug("Creating 00.LFL..."); |
| 1189 | notice("Creating 00.LFL..."); |
1230 | 1190 | |
1231 | 1191 | lfl_index.num_rooms = NUM_ROOMS; |
1232 | 1192 | lfl_index.num_costumes = NUM_COSTUMES; |
1233 | 1193 | lfl_index.num_scripts = NUM_SCRIPTS; |
1234 | 1194 | lfl_index.num_sounds = NUM_SOUNDS; |
1235 | 1195 | |
1236 | | write_long(output,8+5*lfl_index.num_rooms); |
1237 | | write_word(output,'R0'); /* 0R - room index */ |
1238 | | write_word(output,lfl_index.num_rooms); |
| 1196 | writeUint32LE(output,8+5*lfl_index.num_rooms); |
| 1197 | writeUint16LE(output,'R0'); /* 0R - room index */ |
| 1198 | writeUint16LE(output,lfl_index.num_rooms); |
1239 | 1199 | for (i = 0; i < lfl_index.num_rooms; i++) |
1240 | 1200 | { |
1241 | | write_byte(output,lfl_index.room_lfl[i]); |
1242 | | write_long(output,lfl_index.room_addr[i]); |
| 1201 | writeByte(output,lfl_index.room_lfl[i]); |
| 1202 | writeUint32LE(output,lfl_index.room_addr[i]); |
1243 | 1203 | } |
1244 | 1204 | |
1245 | | write_long(output,8+5*lfl_index.num_scripts); |
1246 | | write_word(output,'S0'); /* 0S - script index */ |
1247 | | write_word(output,lfl_index.num_scripts); |
| 1205 | writeUint32LE(output,8+5*lfl_index.num_scripts); |
| 1206 | writeUint16LE(output,'S0'); /* 0S - script index */ |
| 1207 | writeUint16LE(output,lfl_index.num_scripts); |
1248 | 1208 | for (i = 0; i < lfl_index.num_scripts; i++) |
1249 | 1209 | { |
1250 | | write_byte(output,lfl_index.script_lfl[i]); |
1251 | | write_long(output,lfl_index.script_addr[i]); |
| 1210 | writeByte(output,lfl_index.script_lfl[i]); |
| 1211 | writeUint32LE(output,lfl_index.script_addr[i]); |
1252 | 1212 | } |
1253 | 1213 | |
1254 | | write_long(output,8+5*lfl_index.num_costumes); |
1255 | | write_word(output,'C0'); /* 0C - costume index */ |
1256 | | write_word(output,lfl_index.num_costumes); |
| 1214 | writeUint32LE(output,8+5*lfl_index.num_costumes); |
| 1215 | writeUint16LE(output,'C0'); /* 0C - costume index */ |
| 1216 | writeUint16LE(output,lfl_index.num_costumes); |
1257 | 1217 | for (i = 0; i < lfl_index.num_costumes; i++) |
1258 | 1218 | { |
1259 | | write_byte(output,lfl_index.costume_lfl[i]); |
1260 | | write_long(output,lfl_index.costume_addr[i]); |
| 1219 | writeByte(output,lfl_index.costume_lfl[i]); |
| 1220 | writeUint32LE(output,lfl_index.costume_addr[i]); |
1261 | 1221 | } |
1262 | 1222 | |
1263 | 1223 | /* |
1264 | | write_long(output,8+5*lfl_index.num_sounds); |
1265 | | write_word(output,'N0'); 0N - sounds index |
1266 | | write_word(output,lfl_index.num_sounds); |
| 1224 | writeUint32LE(output,8+5*lfl_index.num_sounds); |
| 1225 | writeUint16LE(output,'N0'); 0N - sounds index |
| 1226 | writeUint16LE(output,lfl_index.num_sounds); |
1267 | 1227 | for (i = 0; i < lfl_index.num_sounds; i++) |
1268 | 1228 | { |
1269 | | write_byte(output,lfl_index.sound_lfl[i]); |
1270 | | write_long(output,lfl_index.sound_addr[i]); |
| 1229 | writeByte(output,lfl_index.sound_lfl[i]); |
| 1230 | writeUint32LE(output,lfl_index.sound_addr[i]); |
1271 | 1231 | } |
1272 | 1232 | */ |
1273 | 1233 | |
… |
… |
|
1277 | 1237 | |
1278 | 1238 | if (!(output = fopen("97.LFL","wb"))) |
1279 | 1239 | error("Error: unable to create charset file!"); |
1280 | | debug("Creating 97.LFL..."); |
| 1240 | notice("Creating 97.LFL..."); |
1281 | 1241 | extract_resource(input,output,&res_charset); |
1282 | 1242 | fclose(output); |
1283 | 1243 | |
1284 | 1244 | if (!(output = fopen("98.LFL","wb"))) |
1285 | 1245 | error("Error: unable to create charset file!"); |
1286 | | debug("Creating 98.LFL..."); |
| 1246 | notice("Creating 98.LFL..."); |
1287 | 1247 | extract_resource(input,output,&res_charset); |
1288 | 1248 | fclose(output); |
1289 | 1249 | |
1290 | 1250 | if (!(output = fopen("99.LFL","wb"))) |
1291 | 1251 | error("Error: unable to create charset file!"); |
1292 | | debug("Creating 99.LFL..."); |
| 1252 | notice("Creating 99.LFL..."); |
1293 | 1253 | extract_resource(input,output,&res_charset); |
1294 | 1254 | fclose(output); |
1295 | 1255 | |
… |
… |
|
1307 | 1267 | for (i = 0; i < NUM_SOUNDS; i++) |
1308 | 1268 | dump_resource(input,"sound-%d.dmp",i,&res_sounds[i]); |
1309 | 1269 | #endif /* MAKE_LFLS */ |
1310 | | debug("All done!"); |
| 1270 | notice("All done!"); |
1311 | 1271 | return 0; |
1312 | 1272 | } |
RCS file: /cvsroot/scummvm/tools/extract_mm_c64.c,v
retrieving revision 1.1
diff -u -r1.1 extract_mm_c64.c
|
|
|
28 | 28 | #define TRUE 1 |
29 | 29 | #define FALSE 0 |
30 | 30 | |
31 | | #ifdef WIN32 |
32 | | #define CDECL __cdecl |
33 | | #else |
34 | | #define CDECL |
| 31 | #ifdef _MSC_VER |
| 32 | #define vsnprintf _vsnprintf |
35 | 33 | #endif |
36 | 34 | |
37 | | void CDECL debug (const char *Text, ...) |
| 35 | #ifdef MAKE_LFLS |
| 36 | #define writeByte writeByteAlt |
| 37 | #define writeUint16LE writeUint16LEAlt |
| 38 | void writeByte(FILE *fp, uint8 b) |
38 | 39 | { |
39 | | va_list marker; |
40 | | va_start(marker,Text); |
41 | | vfprintf(stdout,Text,marker); |
42 | | fprintf(stdout,"\n"); |
43 | | va_end(marker); |
| 40 | writeByteAlt(fp, (uint8)(b ^ 0xFF)); |
44 | 41 | } |
45 | | |
46 | | void CDECL error (const char *Text, ...) |
| 42 | void writeUint16LE(FILE *fp, uint16 value) |
47 | 43 | { |
48 | | va_list marker; |
49 | | va_start(marker,Text); |
50 | | vfprintf(stderr,Text,marker); |
51 | | fprintf(stderr,"\n"); |
52 | | va_end(marker); |
53 | | exit(1); |
| 44 | writeUint16LEAlt(fp, (uint16)(value ^ 0xFFFF)); |
54 | 45 | } |
| 46 | #endif |
55 | 47 | |
56 | | void CDECL _assert (BOOL condition, const char *Text, ...) |
57 | | { |
58 | | va_list marker; |
59 | | if (condition) |
60 | | return; |
61 | | va_start(marker,Text); |
62 | | vfprintf(stderr,Text,marker); |
63 | | fprintf(stderr,"\n"); |
64 | | va_end(marker); |
65 | | exit(1); |
66 | | } |
| 48 | void notice(const char *s, ...) { |
| 49 | char buf[1024]; |
| 50 | va_list va; |
| 51 | |
| 52 | va_start(va, s); |
| 53 | vsnprintf(buf, 1024, s, va); |
| 54 | va_end(va); |
67 | 55 | |
68 | | unsigned char read_byte (FILE *input) |
69 | | { |
70 | | unsigned char val; |
71 | | _assert(fread(&val,1,1,input) == 1,"read_byte - unexpected EOF"); |
72 | | return val; |
73 | | } |
74 | | unsigned short read_word (FILE *input) |
75 | | { |
76 | | unsigned short val; |
77 | | _assert(fread(&val,2,1,input) == 1,"read_word - unexpected EOF"); |
78 | | return val; |
79 | | } |
80 | | void write_byte (FILE *output, unsigned char val) |
81 | | { |
82 | | val ^= 0xFF; |
83 | | fwrite(&val,1,1,output); |
84 | | } |
85 | | void write_word (FILE *output, unsigned short val) |
86 | | { |
87 | | val ^= 0xFFFF; |
88 | | fwrite(&val,2,1,output); |
| 56 | fprintf(stdout, "%s\n", buf); |
89 | 57 | } |
90 | 58 | |
91 | 59 | unsigned char room_disks[55], room_tracks[55], room_sectors[55]; |
… |
… |
|
109 | 77 | |
110 | 78 | |
111 | 79 | /* check signature */ |
112 | | signature = read_word(input1); |
| 80 | signature = readUint16LE(input1); |
113 | 81 | if (signature != 0x0A31) |
114 | | error("Error: signature not found in disk 1!\n"); |
115 | | signature = read_word(input2); |
| 82 | error("Signature not found in disk 1!"); |
| 83 | signature = readUint16LE(input2); |
116 | 84 | if (signature != 0x0132) |
117 | | error("Error: signature not found in disk 2!\n"); |
| 85 | error("Signature not found in disk 2!"); |
118 | 86 | |
119 | 87 | if (!(output = fopen("00.LFL","wb"))) |
120 | | error("Error: unable to create index file!"); |
121 | | debug("Creating 00.LFL..."); |
| 88 | error("Unable to create index file!"); |
| 89 | notice("Creating 00.LFL..."); |
122 | 90 | |
123 | 91 | /* write signature */ |
124 | | write_word(output, signature); |
| 92 | writeUint16LE(output, signature); |
125 | 93 | |
126 | 94 | /* copy object flags */ |
127 | 95 | for (i = 0; i < 256; i++) |
128 | | write_byte(output, read_byte(input1)); |
| 96 | writeByte(output, readByte(input1)); |
129 | 97 | |
130 | 98 | /* copy room offsets */ |
131 | 99 | for (i = 0; i < 55; i++) |
132 | 100 | { |
133 | | room_disks[i] = read_byte(input1); |
134 | | write_byte(output, room_disks[i]); |
| 101 | room_disks[i] = readByte(input1); |
| 102 | writeByte(output, room_disks[i]); |
135 | 103 | } |
136 | 104 | for (i = 0; i < 55; i++) |
137 | 105 | { |
138 | | room_sectors[i] = read_byte(input1); |
139 | | write_byte(output, room_sectors[i]); |
140 | | room_tracks[i] = read_byte(input1); |
141 | | write_byte(output, room_tracks[i]); |
| 106 | room_sectors[i] = readByte(input1); |
| 107 | writeByte(output, room_sectors[i]); |
| 108 | room_tracks[i] = readByte(input1); |
| 109 | writeByte(output, room_tracks[i]); |
142 | 110 | } |
143 | 111 | for (i = 0; i < 25; i++) |
144 | | write_byte(output, read_byte(input1)); |
| 112 | writeByte(output, readByte(input1)); |
145 | 113 | for (i = 0; i < 25; i++) |
146 | | write_word(output, read_word(input1)); |
| 114 | writeUint16LE(output, readUint16LE(input1)); |
147 | 115 | |
148 | 116 | for (i = 0; i < 160; i++) |
149 | | write_byte(output, read_byte(input1)); |
| 117 | writeByte(output, readByte(input1)); |
150 | 118 | for (i = 0; i < 160; i++) |
151 | | write_word(output, read_word(input1)); |
| 119 | writeUint16LE(output, readUint16LE(input1)); |
152 | 120 | |
153 | 121 | for (i = 0; i < 70; i++) |
154 | | write_byte(output, read_byte(input1)); |
| 122 | writeByte(output, readByte(input1)); |
155 | 123 | for (i = 0; i < 70; i++) |
156 | | write_word(output, read_word(input1)); |
| 124 | writeUint16LE(output, readUint16LE(input1)); |
157 | 125 | fclose(output); |
158 | 126 | |
159 | 127 | for (i = 0; i < 55; i++) |
… |
… |
|
183 | 151 | else continue; |
184 | 152 | |
185 | 153 | sprintf(fname,"%02i.LFL", i); |
186 | | printf("Creating %s...\n",fname); |
187 | 154 | output = fopen(fname, "wb"); |
| 155 | if (output == NULL) |
| 156 | error("Unable to create %s!",fname); |
| 157 | notice("Creating %s...",fname); |
188 | 158 | fseek(input, (SectorOffset[room_tracks[i]] + room_sectors[i]) * 256, SEEK_SET); |
189 | 159 | for (j = 0; j < ResourcesPerFile[i]; j++) |
190 | 160 | { |
191 | | unsigned short len = read_word(input); |
192 | | write_word(output, len); |
| 161 | unsigned short len = readUint16LE(input); |
| 162 | writeUint16LE(output, len); |
193 | 163 | for (len -= 2; len > 0; len--) |
194 | | write_byte(output, read_byte(input)); |
| 164 | writeByte(output, readByte(input)); |
195 | 165 | } |
196 | 166 | rewind(input); |
197 | 167 | } |
198 | 168 | |
199 | | debug("All done!"); |
| 169 | notice("All done!"); |
200 | 170 | return 0; |
201 | 171 | } |
RCS file: /cvsroot/scummvm/tools/extract_mm_nes.c,v
retrieving revision 1.12
diff -u -r1.12 extract_mm_nes.c
|
|
|
19 | 19 | * |
20 | 20 | */ |
21 | 21 | |
22 | | #include <stdio.h> |
| 22 | #include "util.h" |
23 | 23 | #include <stdarg.h> |
24 | | #include <stdlib.h> |
25 | | #include <string.h> |
26 | 24 | |
27 | 25 | typedef int BOOL; |
28 | 26 | #define TRUE 1 |
… |
… |
|
32 | 30 | /* if not defined, dumps all resources to separate files */ |
33 | 31 | #define MAKE_LFLS |
34 | 32 | |
35 | | #ifdef WIN32 |
36 | | #define CDECL __cdecl |
37 | | #else |
38 | | #define CDECL |
| 33 | #ifdef _MSC_VER |
| 34 | #define vsnprintf _vsnprintf |
39 | 35 | #endif |
40 | 36 | |
41 | | void CDECL debug (const char *Text, ...) |
| 37 | #ifdef MAKE_LFLS |
| 38 | #define writeByte writeByteAlt |
| 39 | #define writeUint16LE writeUint16LEAlt |
| 40 | void writeByte(FILE *fp, uint8 b) |
42 | 41 | { |
43 | | va_list marker; |
44 | | va_start(marker,Text); |
45 | | vfprintf(stdout,Text,marker); |
46 | | fprintf(stdout,"\n"); |
47 | | va_end(marker); |
| 42 | writeByteAlt(fp, (uint8)(b ^ 0xFF)); |
48 | 43 | } |
49 | | |
50 | | void CDECL error (const char *Text, ...) |
| 44 | void writeUint16LE(FILE *fp, uint16 value) |
51 | 45 | { |
52 | | va_list marker; |
53 | | va_start(marker,Text); |
54 | | vfprintf(stderr,Text,marker); |
55 | | fprintf(stderr,"\n"); |
56 | | va_end(marker); |
57 | | exit(1); |
| 46 | writeUint16LEAlt(fp, (uint16)(value ^ 0xFFFF)); |
58 | 47 | } |
| 48 | #endif |
59 | 49 | |
60 | | void CDECL _assert (BOOL condition, const char *Text, ...) |
61 | | { |
62 | | va_list marker; |
63 | | if (condition) |
64 | | return; |
65 | | va_start(marker,Text); |
66 | | vfprintf(stderr,Text,marker); |
67 | | fprintf(stderr,"\n"); |
68 | | va_end(marker); |
69 | | exit(1); |
70 | | } |
| 50 | void notice(const char *s, ...) { |
| 51 | char buf[1024]; |
| 52 | va_list va; |
| 53 | |
| 54 | va_start(va, s); |
| 55 | vsnprintf(buf, 1024, s, va); |
| 56 | va_end(va); |
71 | 57 | |
72 | | unsigned char read_byte (FILE *input) |
73 | | { |
74 | | unsigned char val; |
75 | | _assert(fread(&val,1,1,input) == 1,"read_byte - unexpected EOF"); |
76 | | return val; |
77 | | } |
78 | | unsigned short read_word (FILE *input) |
79 | | { |
80 | | unsigned short val; |
81 | | _assert(fread(&val,2,1,input) == 1,"read_word - unexpected EOF"); |
82 | | return val; |
83 | | } |
84 | | void write_byte (FILE *output, unsigned char val) |
85 | | { |
86 | | #ifdef MAKE_LFLS |
87 | | val ^= 0xFF; |
88 | | #endif |
89 | | fwrite(&val,1,1,output); |
90 | | } |
91 | | void write_word (FILE *output, unsigned short val) |
92 | | { |
93 | | #ifdef MAKE_LFLS |
94 | | val ^= 0xFFFF; |
95 | | #endif |
96 | | fwrite(&val,2,1,output); |
| 58 | fprintf(stdout, "%s\n", buf); |
97 | 59 | } |
98 | 60 | |
99 | 61 | typedef enum _res_type { RES_UNKNOWN, RES_GLOBDATA, RES_ROOM, RES_SCRIPT, RES_SOUND, RES_COSTUME, RES_ROOMGFX, RES_COSTUMEGFX, RES_SPRPALS, RES_SPRDESC, RES_SPRLENS, RES_SPROFFS , RES_SPRDATA, RES_CHARSET, RES_PREPLIST } res_type; |
… |
… |
|
104 | 66 | |
105 | 67 | typedef struct _resource |
106 | 68 | { |
107 | | unsigned long offset[NUM_ROMSETS]; |
108 | | unsigned short length[NUM_ROMSETS]; |
| 69 | uint32 offset[NUM_ROMSETS]; |
| 70 | uint16 length[NUM_ROMSETS]; |
109 | 71 | res_type type; |
110 | 72 | } t_resource, *p_resource; |
111 | 73 | t_resource res_roomgfx[40] = { |
… |
… |
|
531 | 493 | { {0x3FB5A,0x3FB90,0x3FBA9,0x3FBAF}, {0x000E,0x000E,0x000E,0x0010}, RES_PREPLIST }; |
532 | 494 | |
533 | 495 | |
534 | | unsigned long r_offset (p_resource res) |
| 496 | uint32 r_offset (p_resource res) |
535 | 497 | { |
536 | 498 | return res->offset[ROMset]; |
537 | 499 | } |
538 | | unsigned short r_length (p_resource res) |
| 500 | uint16 r_length (p_resource res) |
539 | 501 | { |
540 | 502 | return res->length[ROMset]; |
541 | 503 | } |
542 | 504 | |
543 | 505 | void extract_resource (FILE *input, FILE *output, p_resource res) |
544 | 506 | { |
545 | | unsigned short len, i, j; |
546 | | unsigned char val; |
547 | | unsigned char cnt; |
| 507 | uint16 len, i, j; |
| 508 | uint8 val; |
| 509 | uint8 cnt; |
548 | 510 | |
549 | | _assert(res != NULL,"extract_resource - no resource specified"); |
| 511 | if (res == NULL) |
| 512 | error("extract_resource - no resource specified"); |
550 | 513 | if ((r_offset(res) == 0) && (r_length(res) == 0)) |
551 | 514 | return; /* there are 8 scripts that are zero bytes long, so we should skip them */ |
552 | 515 | fseek(input,16 + r_offset(res),SEEK_SET); |
… |
… |
|
556 | 519 | case RES_GLOBDATA: |
557 | 520 | len = r_length(res); |
558 | 521 | for (i = 0; i < len; i++) |
559 | | write_byte(output,read_byte(input)); |
| 522 | writeByte(output,readByte(input)); |
560 | 523 | break; |
561 | 524 | case RES_ROOMGFX: |
562 | 525 | case RES_COSTUMEGFX: |
563 | | write_word(output,(unsigned short)(r_length(res) + 2)); |
564 | | len = read_byte(input); |
565 | | write_byte(output,(unsigned char)len); |
| 526 | writeUint16LE(output,(uint16)(r_length(res) + 2)); |
| 527 | len = readByte(input); |
| 528 | writeByte(output,(uint8)len); |
566 | 529 | if (!len) |
567 | 530 | len = 256; |
568 | 531 | len = len << 4; |
569 | 532 | for (i = 0; i < len;) |
570 | 533 | { |
571 | | write_byte(output,cnt = read_byte(input)); |
| 534 | writeByte(output,cnt = readByte(input)); |
572 | 535 | for (j = 0; j < (cnt & 0x7F); j++, i++) |
573 | 536 | if ((cnt & 0x80) || (j == 0)) |
574 | | write_byte(output,read_byte(input)); |
| 537 | writeByte(output,readByte(input)); |
575 | 538 | } |
576 | | _assert(ftell(input) - r_offset(res) - 16 == r_length(res),"extract_resource - length mismatch while extracting graphics resource (was %04X, should be %04X)",ftell(input) - r_offset(res) - 16,r_length(res)); |
| 539 | if (ftell(input) - r_offset(res) - 16 != r_length(res)) |
| 540 | error("extract_resource - length mismatch while extracting graphics resource (was %04X, should be %04X)",ftell(input) - r_offset(res) - 16,r_length(res)); |
577 | 541 | break; |
578 | 542 | case RES_ROOM: |
579 | 543 | case RES_SCRIPT: |
580 | | len = read_word(input); |
581 | | _assert(len == r_length(res),"extract_resource - length mismatch while extracting room/script resource (was %04X, should be %04X)",len,r_length(res)); |
| 544 | len = readUint16LE(input); |
| 545 | if (len != r_length(res)) |
| 546 | error("extract_resource - length mismatch while extracting room/script resource (was %04X, should be %04X)",len,r_length(res)); |
582 | 547 | fseek(input,-2,SEEK_CUR); |
583 | 548 | for (i = 0; i < len; i++) |
584 | | write_byte(output,read_byte(input)); |
| 549 | writeByte(output,readByte(input)); |
585 | 550 | break; |
586 | 551 | case RES_SOUND: |
587 | 552 | len = r_length(res) + 2; |
588 | | val = read_byte(input); |
589 | | cnt = read_byte(input); |
| 553 | val = readByte(input); |
| 554 | cnt = readByte(input); |
590 | 555 | if ((val == 2) && (cnt == 100)) |
591 | 556 | { |
592 | | write_word(output,len); |
593 | | write_byte(output,val); |
594 | | write_byte(output,cnt); |
595 | | cnt = read_byte(input); |
596 | | write_byte(output,cnt); |
| 557 | writeUint16LE(output,len); |
| 558 | writeByte(output,val); |
| 559 | writeByte(output,cnt); |
| 560 | cnt = readByte(input); |
| 561 | writeByte(output,cnt); |
597 | 562 | for (i = 0; i < cnt; i++) |
598 | | write_byte(output,read_byte(input)); |
| 563 | writeByte(output,readByte(input)); |
599 | 564 | for (i = 0; i < cnt; i++) |
600 | | write_byte(output,read_byte(input)); |
| 565 | writeByte(output,readByte(input)); |
601 | 566 | while (1) |
602 | 567 | { |
603 | | write_byte(output,val = read_byte(input)); |
| 568 | writeByte(output,val = readByte(input)); |
604 | 569 | if (val >= 0xFE) |
605 | 570 | break; |
606 | 571 | } |
607 | 572 | } |
608 | 573 | else if (((val == 0) || (val == 1) || (val == 4)) && (cnt == 10)) |
609 | 574 | { |
610 | | write_word(output,len); |
611 | | write_byte(output,val); |
612 | | write_byte(output,cnt); |
| 575 | writeUint16LE(output,len); |
| 576 | writeByte(output,val); |
| 577 | writeByte(output,cnt); |
613 | 578 | while (1) |
614 | 579 | { |
615 | | write_byte(output,val = read_byte(input)); |
| 580 | writeByte(output,val = readByte(input)); |
616 | 581 | if (val >= 0xFE) |
617 | 582 | break; |
618 | 583 | if (val >= 0x10) |
619 | | write_byte(output,read_byte(input)); |
| 584 | writeByte(output,readByte(input)); |
620 | 585 | else |
621 | 586 | { |
622 | | write_byte(output,read_byte(input)); |
623 | | write_byte(output,read_byte(input)); |
624 | | write_byte(output,read_byte(input)); |
625 | | write_byte(output,read_byte(input)); |
| 587 | writeByte(output,readByte(input)); |
| 588 | writeByte(output,readByte(input)); |
| 589 | writeByte(output,readByte(input)); |
| 590 | writeByte(output,readByte(input)); |
626 | 591 | } |
627 | 592 | } |
628 | 593 | } |
629 | 594 | else error("extract_resource - unknown sound type %d/%d detected",val,cnt); |
630 | | _assert(ftell(input) - r_offset(res) - 16 == r_length(res),"extract_resource - length mismatch while extracting sound resource (was %04X, should be %04X)",ftell(input) - r_offset(res) - 16,r_length(res)); |
| 595 | if (ftell(input) - r_offset(res) - 16 != r_length(res)) |
| 596 | error("extract_resource - length mismatch while extracting sound resource (was %04X, should be %04X)",ftell(input) - r_offset(res) - 16,r_length(res)); |
631 | 597 | break; |
632 | 598 | case RES_COSTUME: |
633 | 599 | case RES_SPRPALS: |
… |
… |
|
637 | 603 | case RES_SPRDATA: |
638 | 604 | case RES_CHARSET: |
639 | 605 | len = r_length(res); |
640 | | write_word(output,(unsigned short)(len + 2)); |
| 606 | writeUint16LE(output,(uint16)(len + 2)); |
641 | 607 | for (i = 0; i < len; i++) |
642 | | write_byte(output,read_byte(input)); |
| 608 | writeByte(output,readByte(input)); |
643 | 609 | break; |
644 | 610 | case RES_PREPLIST: |
645 | 611 | len = r_length(res); |
646 | | write_word(output,0x002A); |
647 | | write_byte(output,' '); |
| 612 | writeUint16LE(output,0x002A); |
| 613 | writeByte(output,' '); |
648 | 614 | for (i = 1; i < 8; i++) |
649 | | write_byte(output,0); |
| 615 | writeByte(output,0); |
650 | 616 | for (j = 0; j < 4; j++) |
651 | 617 | { |
652 | | write_byte(output,' '); |
653 | | for (i = 1; (val = read_byte(input)); i++) |
654 | | write_byte(output,val); |
| 618 | writeByte(output,' '); |
| 619 | for (i = 1; (val = readByte(input)); i++) |
| 620 | writeByte(output,val); |
655 | 621 | for (; i < 8; i++) |
656 | | write_byte(output,0); |
| 622 | writeByte(output,0); |
657 | 623 | } |
658 | 624 | break; |
659 | 625 | default: |
… |
… |
|
794 | 760 | #endif |
795 | 761 | struct _lfl_index |
796 | 762 | { |
797 | | unsigned char room_lfl[55]; |
798 | | unsigned short room_addr[55]; |
799 | | unsigned char costume_lfl[80]; |
800 | | unsigned short costume_addr[80]; |
801 | | unsigned char script_lfl[200]; |
802 | | unsigned short script_addr[200]; |
803 | | unsigned char sound_lfl[100]; |
804 | | unsigned short sound_addr[100]; |
| 763 | uint8 room_lfl[55]; |
| 764 | uint16 room_addr[55]; |
| 765 | uint8 costume_lfl[80]; |
| 766 | uint16 costume_addr[80]; |
| 767 | uint8 script_lfl[200]; |
| 768 | uint16 script_addr[200]; |
| 769 | uint8 sound_lfl[100]; |
| 770 | uint16 sound_addr[100]; |
805 | 771 | } GCC_PACK lfl_index; |
806 | 772 | #if defined(_MSC_VER) |
807 | 773 | #pragma pack(pop) |
… |
… |
|
814 | 780 | sprintf(fname,fn_template,num); |
815 | 781 | if (!(output = fopen(fname,"wb"))) |
816 | 782 | error("Error: unable to create %s!",fname); |
817 | | debug("Extracting resource to %s",fname); |
| 783 | notice("Extracting resource to %s",fname); |
818 | 784 | extract_resource(input,output,res); |
819 | 785 | fclose(output); |
820 | 786 | } |
821 | 787 | #endif /* MAKE_LFLS */ |
822 | 788 | |
823 | | unsigned long CRCtable[256]; |
| 789 | uint32 CRCtable[256]; |
824 | 790 | void InitCRC (void) |
825 | 791 | { |
826 | | const unsigned long poly = 0xEDB88320; |
| 792 | const uint32 poly = 0xEDB88320; |
827 | 793 | int i, j; |
828 | | unsigned long n; |
| 794 | uint32 n; |
829 | 795 | for (i = 0; i < 256; i++) |
830 | 796 | { |
831 | 797 | n = i; |
… |
… |
|
834 | 800 | CRCtable[i] = n; |
835 | 801 | } |
836 | 802 | } |
837 | | unsigned long CheckROM (FILE *file) |
| 803 | uint32 CheckROM (FILE *file) |
838 | 804 | { |
839 | | unsigned long CRC = 0xFFFFFFFF; |
840 | | unsigned long i; |
841 | | unsigned char header[16]; |
| 805 | uint32 CRC = 0xFFFFFFFF; |
| 806 | uint32 i; |
| 807 | uint8 header[16]; |
842 | 808 | fread(header,16,1,file); |
843 | 809 | if (memcmp("NES\x1A",header,4)) |
844 | 810 | error("Selected file is not a valid NES ROM image!"); |
845 | 811 | for (i = 0; i < header[4] << 14; i++) |
846 | | CRC = (CRC >> 8) ^ CRCtable[(CRC ^ read_byte(file)) & 0xFF]; |
| 812 | CRC = (CRC >> 8) ^ CRCtable[(CRC ^ readByte(file)) & 0xFF]; |
847 | 813 | return CRC ^ 0xFFFFFFFF; |
848 | 814 | } |
849 | 815 | |
… |
… |
|
852 | 818 | FILE *input, *output; |
853 | 819 | char fname[256]; |
854 | 820 | int i, j; |
855 | | unsigned long CRC; |
| 821 | uint32 CRC; |
856 | 822 | |
857 | 823 | if (argc < 2) |
858 | 824 | { |
… |
… |
|
870 | 836 | { |
871 | 837 | case 0x0D9F5BD1: |
872 | 838 | ROMset = ROMSET_USA; |
873 | | debug("ROM contents verified as Maniac Mansion (USA)"); |
| 839 | notice("ROM contents verified as Maniac Mansion (USA)"); |
874 | 840 | break; |
875 | 841 | case 0xF59CFC3D: |
876 | 842 | ROMset = ROMSET_EUROPE; |
877 | | debug("ROM contents verified as Maniac Mansion (Europe)"); |
| 843 | notice("ROM contents verified as Maniac Mansion (Europe)"); |
878 | 844 | break; |
879 | 845 | case 0x3F2BDA65: |
880 | 846 | ROMset = ROMSET_SWEDEN; |
881 | | debug("ROM contents verified as Maniac Mansion (Sweden)"); |
| 847 | notice("ROM contents verified as Maniac Mansion (Sweden)"); |
882 | 848 | break; |
883 | 849 | case 0xF4B70BFE: |
884 | 850 | ROMset = ROMSET_FRANCE; |
885 | | debug("ROM contents verified as Maniac Mansion (France)"); |
| 851 | notice("ROM contents verified as Maniac Mansion (France)"); |
886 | 852 | break; |
887 | 853 | case 0x3DA2085E: |
888 | 854 | error("Maniac Mansion (Japan) is not supported!"); |
… |
… |
|
900 | 866 | sprintf(fname,"%02i.LFL",lfl->num); |
901 | 867 | if (!(output = fopen(fname,"wb"))) |
902 | 868 | error("Error: unable to create %s!",fname); |
903 | | debug("Creating %s...",fname); |
| 869 | notice("Creating %s...",fname); |
904 | 870 | for (j = 0; lfl->entries[j] != NULL; j++) |
905 | 871 | { |
906 | 872 | p_resource entry = lfl->entries[j]; |
… |
… |
|
908 | 874 | { |
909 | 875 | case RES_ROOM: |
910 | 876 | lfl_index.room_lfl[entry - res_rooms] = lfl->num; |
911 | | lfl_index.room_addr[entry - res_rooms] = (unsigned short)ftell(output); |
| 877 | lfl_index.room_addr[entry - res_rooms] = (uint16)ftell(output); |
912 | 878 | break; |
913 | 879 | case RES_COSTUME: |
914 | 880 | lfl_index.costume_lfl[entry - res_costumes] = lfl->num; |
915 | | lfl_index.costume_addr[entry - res_costumes] = (unsigned short)ftell(output); |
| 881 | lfl_index.costume_addr[entry - res_costumes] = (uint16)ftell(output); |
916 | 882 | break; |
917 | 883 | case RES_SPRDESC: |
918 | 884 | lfl_index.costume_lfl[entry - res_sprdesc + 25] = lfl->num; |
919 | | lfl_index.costume_addr[entry - res_sprdesc + 25] = (unsigned short)ftell(output); |
| 885 | lfl_index.costume_addr[entry - res_sprdesc + 25] = (uint16)ftell(output); |
920 | 886 | break; |
921 | 887 | case RES_SPRLENS: |
922 | 888 | lfl_index.costume_lfl[entry - res_sprlens + 27] = lfl->num; |
923 | | lfl_index.costume_addr[entry - res_sprlens + 27] = (unsigned short)ftell(output); |
| 889 | lfl_index.costume_addr[entry - res_sprlens + 27] = (uint16)ftell(output); |
924 | 890 | break; |
925 | 891 | case RES_SPROFFS: |
926 | 892 | lfl_index.costume_lfl[entry - res_sproffs + 29] = lfl->num; |
927 | | lfl_index.costume_addr[entry - res_sproffs + 29] = (unsigned short)ftell(output); |
| 893 | lfl_index.costume_addr[entry - res_sproffs + 29] = (uint16)ftell(output); |
928 | 894 | break; |
929 | 895 | case RES_SPRDATA: |
930 | 896 | lfl_index.costume_lfl[entry - res_sprdata + 31] = lfl->num; |
931 | | lfl_index.costume_addr[entry - res_sprdata + 31] = (unsigned short)ftell(output); |
| 897 | lfl_index.costume_addr[entry - res_sprdata + 31] = (uint16)ftell(output); |
932 | 898 | break; |
933 | 899 | case RES_COSTUMEGFX: |
934 | 900 | lfl_index.costume_lfl[entry - res_costumegfx + 33] = lfl->num; |
935 | | lfl_index.costume_addr[entry - res_costumegfx + 33] = (unsigned short)ftell(output); |
| 901 | lfl_index.costume_addr[entry - res_costumegfx + 33] = (uint16)ftell(output); |
936 | 902 | break; |
937 | 903 | case RES_SPRPALS: |
938 | 904 | lfl_index.costume_lfl[entry - res_sprpals + 35] = lfl->num; |
939 | | lfl_index.costume_addr[entry - res_sprpals + 35] = (unsigned short)ftell(output); |
| 905 | lfl_index.costume_addr[entry - res_sprpals + 35] = (uint16)ftell(output); |
940 | 906 | break; |
941 | 907 | case RES_ROOMGFX: |
942 | 908 | lfl_index.costume_lfl[entry - res_roomgfx + 37] = lfl->num; |
943 | | lfl_index.costume_addr[entry - res_roomgfx + 37] = (unsigned short)ftell(output); |
| 909 | lfl_index.costume_addr[entry - res_roomgfx + 37] = (uint16)ftell(output); |
944 | 910 | break; |
945 | 911 | case RES_SCRIPT: |
946 | 912 | lfl_index.script_lfl[entry - res_scripts] = lfl->num; |
947 | | lfl_index.script_addr[entry - res_scripts] = (unsigned short)ftell(output); |
| 913 | lfl_index.script_addr[entry - res_scripts] = (uint16)ftell(output); |
948 | 914 | break; |
949 | 915 | case RES_SOUND: |
950 | 916 | lfl_index.sound_lfl[entry - res_sounds] = lfl->num; |
951 | | lfl_index.sound_addr[entry - res_sounds] = (unsigned short)ftell(output); |
| 917 | lfl_index.sound_addr[entry - res_sounds] = (uint16)ftell(output); |
952 | 918 | break; |
953 | 919 | case RES_CHARSET: |
954 | 920 | lfl_index.costume_lfl[77] = lfl->num; |
955 | | lfl_index.costume_addr[77] = (unsigned short)ftell(output); |
| 921 | lfl_index.costume_addr[77] = (uint16)ftell(output); |
956 | 922 | break; |
957 | 923 | case RES_PREPLIST: |
958 | 924 | lfl_index.costume_lfl[78] = lfl->num; |
959 | | lfl_index.costume_addr[78] = (unsigned short)ftell(output); |
| 925 | lfl_index.costume_addr[78] = (uint16)ftell(output); |
960 | 926 | break; |
961 | 927 | default: |
962 | 928 | error("Unindexed entry found!"); |
… |
… |
|
964 | 930 | } |
965 | 931 | extract_resource(input,output,entry); |
966 | 932 | } |
967 | | write_word(output,0xF5D1); |
| 933 | writeUint16LE(output,0xF5D1); |
968 | 934 | fclose(output); |
969 | 935 | } |
970 | 936 | if (!(output = fopen("00.LFL","wb"))) |
971 | 937 | error("Error: unable to create index file!"); |
972 | | debug("Creating 00.LFL..."); |
973 | | write_word(output,0x4643); |
| 938 | notice("Creating 00.LFL..."); |
| 939 | writeUint16LE(output,0x4643); |
974 | 940 | extract_resource(input,output,&res_globdata); |
975 | 941 | for (i = 0; i < (int)sizeof(lfl_index); i++) |
976 | | write_byte(output,((unsigned char *)&lfl_index)[i]); |
| 942 | writeByte(output,((uint8 *)&lfl_index)[i]); |
977 | 943 | fclose(output); |
978 | 944 | #else /* !MAKE_LFLS */ |
979 | 945 | dump_resource(input,"globdata.dmp",0,&res_globdata); |
… |
… |
|
1000 | 966 | for (i = 0; i < 2; i++) |
1001 | 967 | dump_resource(input,"sproffs-%d.dmp",i,&res_sproffs[i]); |
1002 | 968 | #endif /* MAKE_LFLS */ |
1003 | | debug("All done!"); |
| 969 | notice("All done!"); |
1004 | 970 | |
1005 | 971 | return 0; |
1006 | 972 | } |
RCS file: /cvsroot/scummvm/tools/extract_zak_c64.c,v
retrieving revision 1.1
diff -u -r1.1 extract_zak_c64.c
|
|
|
1 | | /* MM_C64_Extract - Extract data files from C64 version of Maniac Mansion |
| 1 | /* Zak_C64_Extract - Extract data files from C64 version of Zak McKracken |
2 | 2 | * Copyright (C) 2004-2005 The ScummVM Team |
3 | 3 | * |
4 | 4 | * This program is free software; you can redistribute it and/or |
… |
… |
|
28 | 28 | #define TRUE 1 |
29 | 29 | #define FALSE 0 |
30 | 30 | |
31 | | #ifdef WIN32 |
32 | | #define CDECL __cdecl |
33 | | #else |
34 | | #define CDECL |
| 31 | #ifdef _MSC_VER |
| 32 | #define vsnprintf _vsnprintf |
35 | 33 | #endif |
36 | 34 | |
37 | | void CDECL debug (const char *Text, ...) |
| 35 | #ifdef MAKE_LFLS |
| 36 | #define writeByte writeByteAlt |
| 37 | #define writeUint16LE writeUint16LEAlt |
| 38 | void writeByte(FILE *fp, uint8 b) |
38 | 39 | { |
39 | | va_list marker; |
40 | | va_start(marker,Text); |
41 | | vfprintf(stdout,Text,marker); |
42 | | fprintf(stdout,"\n"); |
43 | | va_end(marker); |
| 40 | writeByteAlt(fp, (uint8)(b ^ 0xFF)); |
44 | 41 | } |
45 | | |
46 | | void CDECL error (const char *Text, ...) |
| 42 | void writeUint16LE(FILE *fp, uint16 value) |
47 | 43 | { |
48 | | va_list marker; |
49 | | va_start(marker,Text); |
50 | | vfprintf(stderr,Text,marker); |
51 | | fprintf(stderr,"\n"); |
52 | | va_end(marker); |
53 | | exit(1); |
| 44 | writeUint16LEAlt(fp, (uint16)(value ^ 0xFFFF)); |
54 | 45 | } |
| 46 | #endif |
55 | 47 | |
56 | | void CDECL _assert (BOOL condition, const char *Text, ...) |
57 | | { |
58 | | va_list marker; |
59 | | if (condition) |
60 | | return; |
61 | | va_start(marker,Text); |
62 | | vfprintf(stderr,Text,marker); |
63 | | fprintf(stderr,"\n"); |
64 | | va_end(marker); |
65 | | exit(1); |
66 | | } |
| 48 | void notice(const char *s, ...) { |
| 49 | char buf[1024]; |
| 50 | va_list va; |
| 51 | |
| 52 | va_start(va, s); |
| 53 | vsnprintf(buf, 1024, s, va); |
| 54 | va_end(va); |
67 | 55 | |
68 | | unsigned char read_byte (FILE *input) |
69 | | { |
70 | | unsigned char val; |
71 | | _assert(fread(&val,1,1,input) == 1,"read_byte - unexpected EOF"); |
72 | | return val; |
73 | | } |
74 | | unsigned short read_word (FILE *input) |
75 | | { |
76 | | unsigned short val; |
77 | | _assert(fread(&val,2,1,input) == 1,"read_word - unexpected EOF"); |
78 | | return val; |
79 | | } |
80 | | void write_byte (FILE *output, unsigned char val) |
81 | | { |
82 | | val ^= 0xFF; |
83 | | fwrite(&val,1,1,output); |
84 | | } |
85 | | void write_word (FILE *output, unsigned short val) |
86 | | { |
87 | | val ^= 0xFFFF; |
88 | | fwrite(&val,2,1,output); |
| 56 | fprintf(stdout, "%s\n", buf); |
89 | 57 | } |
90 | 58 | |
91 | 59 | unsigned char room_disks[59], room_tracks[59], room_sectors[59]; |
… |
… |
|
103 | 71 | return 1; |
104 | 72 | } |
105 | 73 | if (!(input1 = fopen(argv[1],"rb"))) |
106 | | error("Error: unable to open file %s for input!",argv[1]); |
| 74 | error("Unable to open file %s for input!",argv[1]); |
107 | 75 | if (!(input2 = fopen(argv[2],"rb"))) |
108 | | error("Error: unable to open file %s for input!",argv[2]); |
| 76 | error("Unable to open file %s for input!",argv[2]); |
109 | 77 | |
110 | 78 | /* check signature */ |
111 | | signature = read_word(input1); |
| 79 | signature = readUint16LE(input1); |
112 | 80 | if (signature != 0x0A31) |
113 | | error("Error: signature not found in disk 1!\n"); |
114 | | signature = read_word(input2); |
| 81 | error("Signature not found in disk 1!"); |
| 82 | signature = readUint16LE(input2); |
115 | 83 | if (signature != 0x0132) |
116 | | error("Error: signature not found in disk 2!\n"); |
| 84 | error("Signature not found in disk 2!"); |
117 | 85 | |
118 | 86 | if (!(output = fopen("00.LFL","wb"))) |
119 | | error("Error: unable to create index file!"); |
120 | | debug("Creating 00.LFL..."); |
| 87 | error("Unable to create index file!"); |
| 88 | notice("Creating 00.LFL..."); |
121 | 89 | |
122 | 90 | /* write signature */ |
123 | | write_word(output, signature); |
| 91 | writeUint16LE(output, signature); |
124 | 92 | |
125 | 93 | /* copy object flags */ |
126 | 94 | for (i = 0; i < 775; i++) |
127 | | write_byte(output, read_byte(input1)); |
| 95 | writeByte(output, readByte(input1)); |
128 | 96 | |
129 | 97 | /* copy room offsets */ |
130 | 98 | for (i = 0; i < 59; i++) |
131 | 99 | { |
132 | | room_disks[i] = read_byte(input1); |
133 | | write_byte(output, room_disks[i]); |
| 100 | room_disks[i] = readByte(input1); |
| 101 | writeByte(output, room_disks[i]); |
134 | 102 | } |
135 | 103 | for (i = 0; i < 59; i++) |
136 | 104 | { |
137 | | room_sectors[i] = read_byte(input1); |
138 | | room_tracks[i] = read_byte(input1); |
139 | | write_byte(output, room_sectors[i]); |
140 | | write_byte(output, room_tracks[i]); |
| 105 | room_sectors[i] = readByte(input1); |
| 106 | room_tracks[i] = readByte(input1); |
| 107 | writeByte(output, room_sectors[i]); |
| 108 | writeByte(output, room_tracks[i]); |
141 | 109 | } |
142 | 110 | |
143 | 111 | for (i = 0; i < 38; i++) |
144 | | write_byte(output, read_byte(input1)); |
| 112 | writeByte(output, readByte(input1)); |
145 | 113 | for (i = 0; i < 38; i++) |
146 | | write_word(output, read_word(input1)); |
| 114 | writeUint16LE(output, readUint16LE(input1)); |
147 | 115 | |
148 | 116 | for (i = 0; i < 155; i++) |
149 | | write_byte(output, read_byte(input1)); |
| 117 | writeByte(output, readByte(input1)); |
150 | 118 | for (i = 0; i < 155; i++) |
151 | | write_word(output, read_word(input1)); |
| 119 | writeUint16LE(output, readUint16LE(input1)); |
152 | 120 | |
153 | 121 | for (i = 0; i < 127; i++) |
154 | | write_byte(output, read_byte(input1)); |
| 122 | writeByte(output, readByte(input1)); |
155 | 123 | for (i = 0; i < 127; i++) |
156 | | write_word(output, read_word(input1)); |
| 124 | writeUint16LE(output, readUint16LE(input1)); |
157 | 125 | fclose(output); |
158 | 126 | |
159 | 127 | for (i = 0; i < 59; i++) |
… |
… |
|
183 | 151 | else continue; |
184 | 152 | |
185 | 153 | sprintf(fname,"%02i.LFL", i); |
186 | | printf("Creating %s...\n",fname); |
187 | 154 | output = fopen(fname, "wb"); |
| 155 | if (output == NULL) |
| 156 | error("Unable to create %s!",fname); |
| 157 | notice("Creating %s...",fname); |
188 | 158 | fseek(input, (SectorOffset[room_tracks[i]] + room_sectors[i]) * 256, SEEK_SET); |
189 | 159 | for (j = 0; j < ResourcesPerFile[i]; j++) |
190 | 160 | { |
191 | | unsigned short len = read_word(input); |
192 | | write_word(output, len); |
| 161 | unsigned short len = readUint16LE(input); |
| 162 | writeUint16LE(output, len); |
193 | 163 | for (len -= 2; len > 0; len--) |
194 | | write_byte(output, read_byte(input)); |
| 164 | writeByte(output, readByte(input)); |
195 | 165 | } |
196 | 166 | rewind(input); |
197 | 167 | } |
198 | 168 | |
199 | | debug("All done!"); |
| 169 | notice("All done!"); |
200 | 170 | return 0; |
201 | 171 | } |
RCS file: /cvsroot/scummvm/tools/util.c,v
retrieving revision 1.8
diff -u -r1.8 util.c
|
|
|
22 | 22 | #include "util.h" |
23 | 23 | #include <stdarg.h> |
24 | 24 | |
| 25 | #ifdef _MSC_VER |
| 26 | #define vsnprintf _vsnprintf |
| 27 | #endif |
| 28 | |
25 | 29 | void error(const char *s, ...) { |
26 | 30 | char buf[1024]; |
27 | 31 | va_list va; |