X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=babel%2Fagt.c;fp=babel%2Fagt.c;h=66b6575ae40884206850ac6e1458ebbf806567c2;hb=fb72f54c425e715d804b6b90cd3f622c81dcd050;hp=0000000000000000000000000000000000000000;hpb=7eda771842a214ee6c9b60aee0a982253fcc29e6;p=projects%2Fchimara%2Fchimara.git diff --git a/babel/agt.c b/babel/agt.c new file mode 100644 index 0000000..66b6575 --- /dev/null +++ b/babel/agt.c @@ -0,0 +1,59 @@ +/* agt.c Treaty of Babel module for AGX-encapsulated AGT 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 agt +#define HOME_PAGE "http://www.ifarchive.org/indexes/if-archiveXprogrammingXagt" +#define FORMAT_EXT ".agx" +#define NO_METADATA +#define NO_COVER + +#include "treaty_builder.h" +#include +#include + + +static char AGX_MAGIC[4] = { 0x58, 0xC7, 0xC1, 0x51 }; + +/* Helper functions to unencode integers from AGT source */ +static int32 read_agt_short(unsigned char *sf) +{ + return sf[0] | (int32) sf[1]<<8; +} +static int32 read_agt_int(unsigned char *sf) +{ + return (read_agt_short(sf+2) << 16) | read_agt_short(sf); + +} + +static int32 get_story_file_IFID(void *story_file, int32 extent, char *output, int32 output_extent) +{ + int32 l, game_version, game_sig; + unsigned char *sf=(unsigned char *)story_file; + + /* Read the position of the game desciption block */ + l=read_agt_int(sf+32); + if (extent