X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=babel%2Fzcode.c;fp=babel%2Fzcode.c;h=fb1d6bab642820b38afd70e94851196e6554fb73;hb=6fd0347f330cb24ef6145662023053a1c0f81a64;hp=0000000000000000000000000000000000000000;hpb=7d14a66ee234db0898de6fabb8f850ebc4bb733a;p=projects%2Fchimara%2Fchimara.git diff --git a/babel/zcode.c b/babel/zcode.c new file mode 100644 index 0000000..fb1d6ba --- /dev/null +++ b/babel/zcode.c @@ -0,0 +1,97 @@ +/* zcode.c Treaty of Babel module for Z-code files + * 2006 By L. Ross Raszewski + * + * This file depends on treaty_builder.h + * + * This file is public domain, but note that any changes to this file + * may render it noncompliant with the Treaty of Babel + */ + +#define FORMAT zcode +#define HOME_PAGE "http://www.inform-fiction.org" +#define FORMAT_EXT ".z3,.z4,.z5,.z6,.z7,.z8" +#define NO_METADATA +#define NO_COVER +#define CUSTOM_EXTENSION +#include "treaty_builder.h" +#include +#include + +static int32 get_story_file_IFID(void *story_file, int32 extent, char *output, int32 output_extent) +{ + int32 i,j; + char ser[7]; + char buffer[32]; + + + if (extent<0x1D) return INVALID_STORY_FILE_RV; + memcpy(ser, (char *) story_file+0x12, 6); + ser[6]=0; + /* Detect vintage story files */ + if (!(ser[0]=='8' || ser[0]=='9' || + (ser[0]=='0' && ser[1]>='0' && ser[1]<='5'))) + { + for(i=0;i 8 + ) return INVALID_STORY_FILE_RV; + for(i=4;i<=14;i+=2) + { + j=read_zint(sf+i); + if (j>extent || j < 0x40) return INVALID_STORY_FILE_RV; + } + + return VALID_STORY_FILE_RV; +} +static int32 get_story_file_extension(void *sf, int32 extent, char *out, int32 output_extent) +{ + int v; + if (!extent) return INVALID_STORY_FILE_RV; + v= ((char *) sf)[0]; + if (v>9) ASSERT_OUTPUT_SIZE(5); + else ASSERT_OUTPUT_SIZE(4); + sprintf(out,".z%d",v); + return 3+(v>9); + +}