1 diff -aur Generic/defs.h Generic.garg/defs.h
2 --- Generic/defs.h 2008-08-12 19:56:48.000000000 +0200
3 +++ Generic.garg/defs.h 2011-10-20 05:38:40.000000000 +0200
6 * You should have received a copy of the GNU General Public License
7 * along with this program; if not, write to the Free Software
8 -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
9 +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
11 \****************************************************************************/
14 * correct number of bits on your system !!!
15 \*****************************************************************************/
17 -typedef unsigned char type8;
18 -typedef signed char type8s;
19 -typedef unsigned short type16;
20 -typedef signed short type16s;
21 -typedef unsigned long type32;
22 -typedef signed long type32s;
26 +typedef unsigned char type8;
27 +typedef signed char type8s;
29 +#error "Can't find an 8-bit integer type"
33 +typedef unsigned short type16;
34 +typedef signed short type16s;
35 +#elif INT_MAX==0x7fff
36 +typedef unsigned int type16;
37 +typedef signed int type16s;
39 +#error "Can't find a 16-bit integer type"
42 +#if INT_MAX==0x7fffffff
43 +typedef unsigned int type32;
44 +typedef signed int type32s;
45 +#elif LONG_MAX==0x7fffffff
46 +typedef unsigned long type32;
47 +typedef signed long type32s;
49 +#error "Can't find a 32-bit integer type"
52 /****************************************************************************\
53 * Compile time switches
54 diff -aur Generic/emu.c Generic.garg/emu.c
55 --- Generic/emu.c 2008-08-21 07:10:40.000000000 +0200
56 +++ Generic.garg/emu.c 2011-10-04 11:35:14.000000000 +0200
59 * You should have received a copy of the GNU General Public License
60 * along with this program; if not, write to the Free Software
61 -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
62 +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
67 if ((hints != 0) && (hint_contents != 0))
69 /* Read number of blocks */
70 - fread(&buf, 1, 2, hnt_fp);
71 + if (fread(&buf, 1, 2, hnt_fp) != 2 && !feof(hnt_fp)) return 0;
72 blkcnt = read_w2(buf);
74 out2("Blocks: %d\n",blkcnt);
76 out2("\nBlock No. %d\n",i);
78 /* Read number of elements */
79 - fread(&buf, 1, 2, hnt_fp);
80 + if (fread(&buf, 1, 2, hnt_fp) != 2 && !feof(hnt_fp)) return 0;
83 out2("Elements: %d\n",elcnt);
85 hints[i].elcount = elcnt;
88 - fread(&buf, 1, 2, hnt_fp);
89 + if (fread(&buf, 1, 2, hnt_fp) != 2 && !feof(hnt_fp)) return 0;
95 for (j = 0; j < elcnt; j++)
97 - fread(&buf, 1, 2, hnt_fp);
98 + if (fread(&buf, 1, 2, hnt_fp) != 2 && !feof(hnt_fp)) return 0;
99 elsize = read_w2(buf);
100 - fread(hint_contents+conidx, 1, elsize, hnt_fp);
101 + if (fread(hint_contents+conidx, 1, elsize, hnt_fp) != elsize && !feof(hnt_fp)) return 0;
102 hint_contents[conidx+elsize-1] = '\0';
104 out2("%s\n",hint_contents+conidx);
107 for (j = 0; j < elcnt; j++)
109 - fread(&buf, 1, 2, hnt_fp);
110 + if (fread(&buf, 1, 2, hnt_fp) != 2 && !feof(hnt_fp)) return 0;
111 hints[i].links[j] = read_w2(buf);
113 out2("%d\n",hints[i].links[j]);
117 /* Read the parent block */
118 - fread(&buf, 1, 2, hnt_fp);
119 + if (fread(&buf, 1, 2, hnt_fp) != 2 && !feof(hnt_fp)) return 0;
120 hints[i].parent = read_w2(buf);
122 out2("Parent: %d\n",hints[i].parent);
123 diff -aur Generic/gfxlink2.c Generic.garg/gfxlink2.c
124 --- Generic/gfxlink2.c 2010-10-25 17:32:11.000000000 +0200
125 +++ Generic.garg/gfxlink2.c 2011-06-07 22:21:27.000000000 +0200
127 Written by David Kinder.
134 diff -aur Generic/gfxlink.c Generic.garg/gfxlink.c
135 --- Generic/gfxlink.c 1998-01-09 21:35:42.000000000 +0100
136 +++ Generic.garg/gfxlink.c 2011-06-07 22:21:27.000000000 +0200
141 -typedef unsigned char type8;
142 -typedef unsigned short type16;
143 -typedef unsigned long int type32;
147 +typedef unsigned char type8;
149 +#error "Can't find an 8-bit integer type"
152 +#if SHRT_MAX==0x7fff
153 +typedef unsigned short type16;
154 +#elif INT_MAX==0x7fff
155 +typedef unsigned int type16;
157 +#error "Can't find a 16-bit integer type"
160 +#if INT_MAX==0x7fffffff
161 +typedef unsigned int type32;
162 +#elif LONG_MAX==0x7fffffff
163 +typedef unsigned long type32;
165 +#error "Can't find a 32-bit integer type"
168 int fdi, fdo_temp, fdo_gfx;
169 char infilemask[FILENAMELENGTH];
170 diff -aur Generic/main.c Generic.garg/main.c
171 --- Generic/main.c 2010-10-25 17:32:25.000000000 +0200
172 +++ Generic.garg/main.c 2011-10-04 11:35:14.000000000 +0200
175 * You should have received a copy of the GNU General Public License
176 * along with this program; if not, write to the Free Software
177 -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
178 +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
180 * Simple ANSI interface main.c
185 type8 buffer[80], xpos = 0, bufpos = 0, log_on = 0, ms_gfx_enabled, filename[256];
186 -FILE *logfile1 = 0, *logfile2 = 0;
187 +FILE *log1 = 0, *log2 = 0;
189 type8 ms_load_file(type8s *name, type8 *ptr, type16 size)
193 void script_write(type8 c)
195 - if (log_on == 2 && fputc(c,logfile1) == EOF)
196 + if (log_on == 2 && fputc(c,log1) == EOF)
198 printf("[Problem with script file - closing]\n");
205 void transcript_write(type8 c)
207 - if (logfile2 && c == 0x08 && ftell(logfile2) > 0)
208 - fseek(logfile2,-1,SEEK_CUR);
209 - else if (logfile2 && fputc(c,logfile2) == EOF)
210 + if (log2 && c == 0x08 && ftell(log2) > 0)
211 + fseek(log2,-1,SEEK_CUR);
212 + else if (log2 && fputc(c,log2) == EOF)
214 printf("[Problem with transcript file - closing]\n");
222 @@ -187,11 +187,11 @@
225 /* Reading from logfile */
226 - if ((c = fgetc(logfile1)) == EOF)
227 + if ((c = fgetc(log1)) == EOF)
229 /* End of log? - turn off */
235 else printf("%c",c); /* print the char as well */
238 printf("[Closing script file]\n");
243 else if (!strcmp(buf,"undo"))
245 @@ -311,17 +311,17 @@
249 - if (!(logfile2 = fopen(&argv[i][2],"w")))
250 + if (!(log2 = fopen(&argv[i][2],"w")))
251 printf("Failed to open \"%s\" for writing.\n",&argv[i][2]);
254 - if (logfile1 = fopen(&argv[i][2],"r"))
255 + if (log1 = fopen(&argv[i][2],"r"))
258 printf("Failed to open \"%s\" for reading.\n",&argv[i][2]);
261 - if (logfile1 = fopen(&argv[i][2],"w"))
262 + if (log1 = fopen(&argv[i][2],"w"))
265 printf("Failed to open \"%s\" for writing.\n",&argv[i][2]);
276 printf("\nExiting.\n");
279 diff -aur Generic/passwd.c Generic.garg/passwd.c
280 --- Generic/passwd.c 2000-12-06 23:33:06.000000000 +0100
281 +++ Generic.garg/passwd.c 2011-06-07 22:21:27.000000000 +0200
288 -typedef unsigned char type8;
289 -typedef unsigned long type32;
291 -type8 obfuscate(type8 c) {
292 - static type8 state;
298 - for (i=0;i<13;i++) {
299 - if ((state & 1) ^ ((state>>1) & 1)) state|=0x80;
307 -int main(int argc, char **argv) {
309 - type8 tmp,name[128],result[128],pad[]="MAGNETICSCR";
313 - printf("Usage: %s string\n",argv[0]);
317 - for (i=j=0;i<strlen(argv[1]);i++) {
318 - if (argv[1][i]!=0x20) name[j++]=toupper(argv[1][i]);
322 - tmp=name[strlen(name)-1];
323 - if ((tmp=='#') || (tmp==']')) name[strlen(name)-1]=0;
325 - if (strlen(name)<12) {
326 - for (i=strlen(name),j=0;i<12;i++,j++) name[i]=pad[j];
333 - tmp=obfuscate(name[i++]);
334 - if (name[i]) tmp+=obfuscate(name[i++]);
336 - if (tmp<26) tmp+='A';
348 +typedef unsigned char type8;
350 +#error "Can't find an 8-bit integer type"
353 +#if INT_MAX==0x7fffffff
354 +typedef unsigned int type32;
355 +#elif LONG_MAX==0x7fffffff
356 +typedef unsigned long type32;
358 +#error "Can't find a 32-bit integer type"
361 +type8 obfuscate(type8 c) {
362 + static type8 state;
368 + for (i=0;i<13;i++) {
369 + if ((state & 1) ^ ((state>>1) & 1)) state|=0x80;
377 +int main(int argc, char **argv) {
379 + type8 tmp,name[128],result[128],pad[]="MAGNETICSCR";
383 + printf("Usage: %s string\n",argv[0]);
387 + for (i=j=0;i<strlen(argv[1]);i++) {
388 + if (argv[1][i]!=0x20) name[j++]=toupper(argv[1][i]);
392 + tmp=name[strlen(name)-1];
393 + if ((tmp=='#') || (tmp==']')) name[strlen(name)-1]=0;
395 + if (strlen(name)<12) {
396 + for (i=strlen(name),j=0;i<12;i++,j++) name[i]=pad[j];
403 + tmp=obfuscate(name[i++]);
404 + if (name[i]) tmp+=obfuscate(name[i++]);
406 + if (tmp<26) tmp+='A';
411 printf("The password for \"%s\" is: %s\n",argv[1],result);
416 diff -aur Generic/sndlink.c Generic.garg/sndlink.c
417 --- Generic/sndlink.c 2009-06-06 18:22:59.000000000 +0200
418 +++ Generic.garg/sndlink.c 2011-06-07 22:21:27.000000000 +0200
421 v1.1 added option for tempo patching
422 v1.2 fixed tempo patching
423 - v1.3 remove garbage bytes at end of original data
428 FILE* OutputFile = NULL;
429 unsigned long OutOffset = 0;
433 void WriteLong(unsigned char* p, unsigned long v)
437 void WriteSndFile(int Index)
439 - unsigned long offset, length, j = 0;
440 + unsigned long offset, length;
441 unsigned short tsize;
445 length = BUFFER_SIZE;
446 ReadFile(Buffer1,&offset,length);
448 - // Remove garbage bytes if present
451 - while ((j <= length-1) && !(Buffer1[j]==0xFF && Buffer1[j+1]==0x2F && Buffer1[j+2]==0x00))
457 - SndFiles[Index].Length = j+3;
466 @@ -356,25 +339,14 @@
468 int main(int argc, char** argv)
471 - ((argc == 3 && ((strcmp(argv[1],"-p")==0) || strcmp(argv[1],"-r")==0))) ||
472 - ((argc == 4 && ((strcmp(argv[1],"-p")==0) && strcmp(argv[2],"-r")==0))))
473 + if (argc == 2 || (argc == 3 && strcmp(argv[1],"-p")==0))
479 - if (strcmp(argv[1],"-p")==0)
481 - if (strcmp(argv[1],"-r")==0)
494 @@ -385,18 +357,17 @@
498 - printf("SndLink v1.3 by Stefan Meier.\n\n"
499 + printf("SndLink v1.2 by Stefan Meier.\n\n"
500 "Extractor for the music scores in Magnetic Scrolls' Wonderland\n"
501 "Amiga, Atari ST, PC versions.\n\n"
502 - "Usage: SndLink [-p] [-r] all.rsc\n\n"
503 + "Usage: SndLink [-p] all.rsc\n\n"
504 "\"all.rsc\" is taken from an installed game. Depending on your\n"
505 "game version, the resource file might be split into several files\n"
506 "named e.g. all.1, all.2,... or TWO,THREE,FOUR...\n"
507 "Before running the extractor, you need to merge these parts into\n"
508 "one file, e.g. with the DOS command copy /B ONE+TWO+THREE+... all.rsc\n"
509 "If the extraction is successfull, the file wonder.snd is created\n\n"
510 - "The optional -p switch adds tempo data to the music score\n"
511 - "The optional -r switch removes garbage bytes from the PC versions");
512 + "The optional -p switch adds tempo data to the music score");
516 diff -aur Generic/xtract64.c Generic.garg/xtract64.c
517 --- Generic/xtract64.c 2000-05-06 16:30:00.000000000 +0200
518 +++ Generic.garg/xtract64.c 2011-06-07 22:21:27.000000000 +0200
525 #define size_d64 ((type32)(174848))
526 #define NL ((type32) -1)
528 -typedef unsigned char type8;
529 -typedef unsigned long type32;
531 +typedef unsigned char type8;
533 +#error "Can't find an 8-bit integer type"
536 +#if INT_MAX==0x7fffffff
537 +typedef unsigned int type32;
538 +#elif LONG_MAX==0x7fffffff
539 +typedef unsigned long type32;
541 +#error "Can't find a 32-bit integer type"
545 typedef unsigned char huge * type8ptr;
547 diff -aur Generic/xtractpc.c Generic.garg/xtractpc.c
548 --- Generic/xtractpc.c 2010-10-25 17:32:32.000000000 +0200
549 +++ Generic.garg/xtractpc.c 2011-06-07 22:21:27.000000000 +0200
551 Written by Niclas Karlsson and David Kinder.