- Integrated xlatcc into ZDoom.exe so that the linedef translation files

don't need to be compiled and can be stored as text in zdoom.pk3.


SVN r815 (trunk)
This commit is contained in:
Christoph Oelckers 2008-03-19 21:09:53 +00:00
parent ee69e7bf03
commit 8ea316e33b
29 changed files with 2952 additions and 4830 deletions

View file

@ -91,7 +91,7 @@ $(OBJDIR)/fmopl.o: src/oplsynth/fmopl.cpp
$(OBJDIR):
mkdir $(OBJDIR)
toolsandpk3: ccdv tools/makewad/makewad tools/dehsupp/dehsupp tools/xlatcc/xlatcc
toolsandpk3: ccdv tools/makewad/makewad tools/dehsupp/dehsupp
$(MAKE) -C wadsrc/
zdoom.pk3: toolsandpk3
@ -106,9 +106,6 @@ tools/makewad/makewad:
tools/dehsupp/dehsupp:
$(MAKE) -C tools/dehsupp/
tools/xlatcc/xlatcc:
$(MAKE) -C tools/xlatcc/
updaterev: tools/updaterevision/updaterevision
@tools/updaterevision/updaterevision . src/svnrevision.h

View file

@ -24,7 +24,6 @@ basetools: ccdv.exe
$(MAKE) -C zlib -f Makefile.mgw
$(MAKE) -C tools/makewad
$(MAKE) -C tools/dehsupp
$(MAKE) -C tools/xlatcc
$(MAKE) -C tools/fixrtext
$(MAKE) -C wadsrc -f Makefile.mgw
$(MAKE) -C jpeg-6b -f Makefile.mgw
@ -38,7 +37,6 @@ clean:
@$(MAKE) -C tools/re2c clean
@$(MAKE) -C tools/dehsupp clean
@$(MAKE) -C tools/makewad clean
@$(MAKE) -C tools/xlatcc clean
@$(MAKE) -C tools/fixrtext clean
@$(MAKE) -C wadsrc -f Makefile.mgw clean
@$(MAKE) -C . -f Makefile.mingw clean

View file

@ -1,4 +1,6 @@
March 19, 2008 (Changes by Graf Zahl)
- Integrated xlatcc into ZDoom.exe so that the linedef translation files
don't need to be compiled and can be stored as text in zdoom.pk3.
- Removed thingdef_specials.h and thingdef_specials.gperf and replaced
line special definition with something that automatically gets updated
if new specials are added.

View file

@ -30,9 +30,6 @@
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
** The linedef translations are read from a WAD lump (DOOMX or HERETICX),
** so most of this file's behavior can be easily customized without
** recompiling.
*/
#include "doomtype.h"
@ -48,6 +45,7 @@
#include "w_wad.h"
#include "sc_man.h"
#include "cmdlib.h"
#include "xlat/xlat.h"
// define names for the TriggerType field of the general linedefs
@ -66,12 +64,10 @@ typedef enum
void P_TranslateLineDef (line_t *ld, maplinedef_t *mld)
{
static FMemLump tlatebase;
const BYTE *tlate;
short special = LittleShort(mld->special);
unsigned short special = (unsigned short) LittleShort(mld->special);
short tag = LittleShort(mld->tag);
DWORD flags = LittleShort(mld->flags);
INTBOOL passthrough;
int i;
if (flags & ML_TRANSLUCENT_STRIFE)
{
@ -79,9 +75,6 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld)
}
if (gameinfo.gametype == GAME_Strife)
{
// It might be useful to make these usable by all games.
// Unfortunately, there aren't enough flag bits left to do that,
// so they're Strife-only.
if (flags & ML_RAILING_STRIFE)
{
flags |= ML_RAILING;
@ -125,72 +118,45 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld)
return;
}
// The translation lump is cached across calls to P_TranslateLineDef.
if (tlatebase.GetMem() == NULL)
FLineTrans *linetrans = NULL;
if (special < SimpleLineTranslations.Size()) linetrans = &SimpleLineTranslations[special];
if (linetrans != NULL && linetrans->special != 0)
{
if (gameinfo.gametype == GAME_Doom)
{
tlatebase = Wads.ReadLump ("DOOMX");
}
else if (gameinfo.gametype == GAME_Strife)
{
tlatebase = Wads.ReadLump ("STRIFEX");
}
else
{
tlatebase = Wads.ReadLump ("HERETICX");
}
}
tlate = (const BYTE *)tlatebase.GetMem();
ld->special = linetrans->special;
ld->args[0] = linetrans->args[0];
ld->args[1] = linetrans->args[1];
ld->args[2] = linetrans->args[2];
ld->args[3] = linetrans->args[3];
ld->args[4] = linetrans->args[4];
// Check if this is a regular linetype
if (tlate[0] == 'N' && tlate[1] == 'O' && tlate[2] == 'R' && tlate[3] == 'M')
{
int count = (tlate[4] << 8) | tlate[5];
tlate += 6;
while (count)
{
int low = (tlate[0] << 8) | tlate[1];
int high = (tlate[2] << 8) | tlate[3];
tlate += 4;
if (special >= low && special <= high)
{ // found it, so use the LUT
const BYTE *specialmap = tlate + (special - low) * 7;
ld->flags = flags | ((specialmap[0] & 0x1f) << 9);
ld->flags = flags | ((linetrans->flags & 0x1f) << 9);
if (passthrough && (GET_SPAC(ld->flags) == SPAC_USE))
{
ld->flags &= ~ML_SPAC_MASK;
ld->flags |= SPAC_USETHROUGH << ML_SPAC_SHIFT;
}
ld->special = specialmap[1];
ld->args[0] = specialmap[2];
ld->args[1] = specialmap[3];
ld->args[2] = specialmap[4];
ld->args[3] = specialmap[5];
ld->args[4] = specialmap[6];
switch (specialmap[0] & 0xe0)
switch (linetrans->flags & 0xe0)
{
case 7<<5: // First two arguments are tags
case LINETRANS_HAS2TAGS: // First two arguments are tags
ld->args[1] = tag;
case 1<<5: case 6<<5: // First argument is a tag
case LINETRANS_HASTAGAT1: // First argument is a tag
ld->args[0] = tag;
break;
case 2<<5: // Second argument is a tag
case LINETRANS_HASTAGAT2: // Second argument is a tag
ld->args[1] = tag;
break;
case 3<<5: // Third argument is a tag
case LINETRANS_HASTAGAT3: // Third argument is a tag
ld->args[2] = tag;
break;
case 4<<5: // Fourth argument is a tag
case LINETRANS_HASTAGAT4: // Fourth argument is a tag
ld->args[3] = tag;
break;
case 5<<5: // Fifth argument is a tag
case LINETRANS_HASTAGAT5: // Fifth argument is a tag
ld->args[4] = tag;
break;
}
@ -200,52 +166,15 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld)
}
return;
}
tlate += (high - low + 1) * 7;
count--;
}
}
// Check if this is a BOOM generalized linetype
if (tlate[0] == 'B' && tlate[1] == 'O' && tlate[2] == 'O' && tlate[3] == 'M')
for(int i=0;i<NumBoomish;i++)
{
int count = (tlate[4] << 8) | tlate[5];
tlate += 6;
FBoomTranslator *b = &Boomish[i];
// BOOM translators are stored on disk as:
//
// WORD <first linetype in range>
// WORD <last linetype in range>
// BYTE <new special>
// repeat [BYTE op BYTES parms]
//
// op consists of some bits:
//
// 76543210
// ||||||++-- Dest is arg[(op&3)+1] (arg[0] is always tag)
// |||||+---- 0 = store, 1 = or with existing value
// ||||+----- 0 = this is normal, 1 = x-op in next byte
// ++++------ # of elements in list, or 0 to always use a constant value
//
// If a constant value is used, parms is a single byte containing that value.
// Otherwise, parms has the format:
//
// WORD <value to AND with linetype>
// repeat [WORD <if result is this> BYTE <use this>]
//
// These x-ops are defined:
//
// 0 = end of this BOOM translator
// 1 = dest is flags
while (count)
if (special >= b->FirstLinetype && special <= b->LastLinetype)
{
int low = (tlate[0] << 8) | tlate[1];
int high = (tlate[2] << 8) | tlate[3];
tlate += 4;
ld->special = b->NewSpecial;
DWORD oflags = flags;
// Assume we found it and translate
switch (special & 0x0007)
{
case WalkMany:
@ -275,60 +204,43 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld)
ld->args[0] = tag;
ld->args[1] = ld->args[2] = ld->args[3] = ld->args[4] = 0;
ld->special = *tlate++;
for (;;)
for(unsigned j=0; j < b->Args.Size(); j++)
{
FBoomArg *arg = &b->Args[j];
int *destp;
int flagtemp;
BYTE op = *tlate++;
BYTE dest;
BYTE val = 0; // quiet, GCC
bool found;
int lsize;
dest = op & 3;
if (op & 8)
if (arg->ArgNum < 4)
{
BYTE xop = *tlate++;
if (xop == 0)
break;
else if (xop == 1)
dest = 4;
}
if (dest < 4)
{
destp = &ld->args[dest+1];
destp = &ld->args[arg->ArgNum+1];
}
else
{
flagtemp = ((flags >> 9) & 0x3f);
destp = &flagtemp;
}
lsize = op >> 4;
if (lsize == 0)
if (arg->ListSize == 0)
{
val = *tlate++;
val = arg->ConstantValue;
found = true;
}
else
{
WORD mask = (tlate[0] << 8) | tlate[1];
tlate += 2;
found = false;
for (i = 0; i < lsize; i++)
for (int k = 0; k < arg->ListSize; k++)
{
WORD filter = (tlate[0] << 8) | tlate[1];
if ((special & mask) == filter)
if ((special & arg->AndValue) == arg->ResultFilter[k])
{
val = tlate[2];
val = arg->ResultValue[k];
found = true;
}
tlate += 3;
}
}
if (found)
{
if (op & 4)
if (arg->bOrExisting)
{
*destp |= val;
}
@ -336,14 +248,12 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld)
{
*destp = val;
}
if (dest == 4)
if (arg->ArgNum == 4)
{
flags = (flags & ~0x7e00) | (flagtemp << 9);
}
}
}
if (special >= low && special <= high)
{ // Really found it, so we're done
// We treat push triggers like switch triggers with zero tags.
if ((special & 7) == PushMany || (special & 7) == PushOnce)
{
@ -359,12 +269,7 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld)
ld->flags = flags;
return;
}
flags = oflags;
count--;
}
}
// Don't know what to do, so 0 it
ld->special = 0;
ld->flags = flags;
@ -557,3 +462,4 @@ int P_TranslateSectorSpecial (int special)
return sectortables[1][special] | high;
}

View file

@ -1,568 +0,0 @@
/* ANSI-C code produced by gperf version 3.0.1 */
/* Command-line: gperf -m10000 -tE -LANSI-C -Hspecialhash -Nis_special -C --null-strings thingdef_specials.gperf */
/* Computed positions: -k'1,7,9,14,17' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
/* The character set is not based on ISO-646. */
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
#endif
#line 10 "thingdef_specials.gperf"
struct ACSspecials { const char *name; unsigned char Special; unsigned char MinArgs; unsigned char MaxArgs; };
/* maximum key range = 326, duplicates = 0 */
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static unsigned int
specialhash (register const char *str, register unsigned int len)
{
static const unsigned short asso_values[] =
{
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 53, 356, 20, 85, 15,
107, 13, 88, 10, 68, 95, 10, 10, 13, 136,
72, 84, 44, 356, 10, 11, 12, 28, 53, 69,
10, 75, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356, 356, 356, 356, 356,
356, 356, 356, 356, 356, 356
};
register int hval = len;
switch (hval)
{
default:
hval += asso_values[(unsigned char)str[16]];
/*FALLTHROUGH*/
case 16:
case 15:
case 14:
hval += asso_values[(unsigned char)str[13]];
/*FALLTHROUGH*/
case 13:
case 12:
case 11:
case 10:
case 9:
hval += asso_values[(unsigned char)str[8]];
/*FALLTHROUGH*/
case 8:
case 7:
hval += asso_values[(unsigned char)str[6]];
/*FALLTHROUGH*/
case 6:
case 5:
case 4:
case 3:
case 2:
case 1:
hval += asso_values[(unsigned char)str[0]];
break;
}
return hval;
}
#ifdef __GNUC__
__inline
#endif
const struct ACSspecials *
is_special (register const char *str, register unsigned int len)
{
enum
{
TOTAL_KEYWORDS = 169,
MIN_WORD_LENGTH = 8,
MAX_WORD_LENGTH = 29,
MIN_HASH_VALUE = 30,
MAX_HASH_VALUE = 355
};
static const struct ACSspecials wordlist[] =
{
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0},
#line 76 "thingdef_specials.gperf"
{"teleport",70,1},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0},
#line 93 "thingdef_specials.gperf"
{"teleportgroup",77,5},
#line 49 "thingdef_specials.gperf"
{"light_strobe",116,5},
#line 160 "thingdef_specials.gperf"
{"exit_secret",244,1},
#line 145 "thingdef_specials.gperf"
{"thing_setgoal",229,3},
{(char*)0},
#line 126 "thingdef_specials.gperf"
{"generic_lift",203,5},
{(char*)0}, {(char*)0}, {(char*)0},
#line 88 "thingdef_specials.gperf"
{"thing_spawn",135,3,4},
#line 13 "thingdef_specials.gperf"
{"acs_suspend",81,2},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0},
#line 127 "thingdef_specials.gperf"
{"generic_stairs",204,5},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0},
#line 128 "thingdef_specials.gperf"
{"generic_crusher",205,5},
{(char*)0}, {(char*)0},
#line 82 "thingdef_specials.gperf"
{"thing_activate",130,1},
#line 12 "thingdef_specials.gperf"
{"acs_execute",80,1,5},
{(char*)0}, {(char*)0}, {(char*)0},
#line 107 "thingdef_specials.gperf"
{"line_alignceiling",183,2},
{(char*)0},
#line 105 "thingdef_specials.gperf"
{"thing_settranslation",180,2},
{(char*)0}, {(char*)0}, {(char*)0},
#line 168 "thingdef_specials.gperf"
{"ceiling_raisetonearest",252,2},
#line 170 "thingdef_specials.gperf"
{"ceiling_lowertofloor",254,2},
{(char*)0},
#line 99 "thingdef_specials.gperf"
{"thing_spawnfacing",139,2,4},
#line 21 "thingdef_specials.gperf"
{"ceiling_crushraiseandstay",45,3},
#line 118 "thingdef_specials.gperf"
{"ceiling_crushraiseandstaya",195,4},
#line 135 "thingdef_specials.gperf"
{"teleport_line",215,2},
#line 141 "thingdef_specials.gperf"
{"scroll_floor",223,4},
#line 171 "thingdef_specials.gperf"
{"ceiling_crushraiseandstaysila",255,4},
#line 16 "thingdef_specials.gperf"
{"ceiling_crushandraise",42,3},
#line 119 "thingdef_specials.gperf"
{"ceiling_crushandraisea",196,4},
#line 15 "thingdef_specials.gperf"
{"acs_lockedexecute",83,5},
#line 18 "thingdef_specials.gperf"
{"ceiling_lowerandcrush",43,3},
{(char*)0}, {(char*)0},
#line 180 "thingdef_specials.gperf"
{"acs_lockedexecutedoor",85,5},
#line 120 "thingdef_specials.gperf"
{"ceiling_crushandraisesilenta",197,4},
#line 77 "thingdef_specials.gperf"
{"teleport_nofog",71,1,2},
{(char*)0},
#line 142 "thingdef_specials.gperf"
{"scroll_ceiling",224,4},
#line 102 "thingdef_specials.gperf"
{"thing_hate",177,2,3},
#line 70 "thingdef_specials.gperf"
{"radius_quake",120,5},
#line 133 "thingdef_specials.gperf"
{"sector_setfade",213,4},
#line 177 "thingdef_specials.gperf"
{"noisealert",173,2},
#line 63 "thingdef_specials.gperf"
{"polyobj_rotateright",3,3},
#line 175 "thingdef_specials.gperf"
{"acs_executewithresult",84,1,4},
{(char*)0},
#line 59 "thingdef_specials.gperf"
{"plat_stop",61,1},
#line 78 "thingdef_specials.gperf"
{"teleport_newmap",74,2},
#line 79 "thingdef_specials.gperf"
{"teleport_endgame",75,0},
#line 17 "thingdef_specials.gperf"
{"ceiling_crushstop",44,1},
#line 134 "thingdef_specials.gperf"
{"sector_setdamage",214,3},
{(char*)0}, {(char*)0},
#line 139 "thingdef_specials.gperf"
{"sector_setcurrent",220,4},
#line 47 "thingdef_specials.gperf"
{"light_glow",114,4},
#line 50 "thingdef_specials.gperf"
{"light_stop",117,1},
#line 92 "thingdef_specials.gperf"
{"teleportother",76,3},
{(char*)0},
#line 91 "thingdef_specials.gperf"
{"ceiling_waggle",38,5},
#line 112 "thingdef_specials.gperf"
{"sector_setceilingscale",188,5},
{(char*)0},
#line 110 "thingdef_specials.gperf"
{"sector_setceilingpanning",186,5},
{(char*)0},
#line 123 "thingdef_specials.gperf"
{"generic_floor",200,5},
#line 124 "thingdef_specials.gperf"
{"generic_ceiling",201,5},
#line 178 "thingdef_specials.gperf"
{"thing_raise",17,1},
#line 106 "thingdef_specials.gperf"
{"line_mirror",182,0},
#line 80 "thingdef_specials.gperf"
{"thrustthing",72,2,4},
#line 98 "thingdef_specials.gperf"
{"thrustthingz",128,4},
#line 104 "thingdef_specials.gperf"
{"changeskill",179,1},
{(char*)0},
#line 148 "thingdef_specials.gperf"
{"light_strobedoom",232,3},
#line 108 "thingdef_specials.gperf"
{"line_alignfloor",184,2},
{(char*)0},
#line 51 "thingdef_specials.gperf"
{"pillar_build",29,3},
#line 14 "thingdef_specials.gperf"
{"acs_terminate",82,2},
{(char*)0},
#line 131 "thingdef_specials.gperf"
{"translucentline",208,2,3},
#line 23 "thingdef_specials.gperf"
{"door_close",10,2},
#line 173 "thingdef_specials.gperf"
{"clearforcefield",34,1},
#line 84 "thingdef_specials.gperf"
{"thing_destroy",133,1,2},
#line 125 "thingdef_specials.gperf"
{"generic_door",202,5},
#line 94 "thingdef_specials.gperf"
{"teleportinsector",78,4,5},
#line 97 "thingdef_specials.gperf"
{"thing_setspecial",127,5},
#line 89 "thingdef_specials.gperf"
{"thing_spawnnofog",137,3,4},
#line 25 "thingdef_specials.gperf"
{"door_raise",12,3},
{(char*)0},
#line 73 "thingdef_specials.gperf"
{"stairs_buildup",27,5},
{(char*)0},
#line 53 "thingdef_specials.gperf"
{"pillar_open",30,4},
{(char*)0}, {(char*)0},
#line 169 "thingdef_specials.gperf"
{"ceiling_lowertolowest",253,2},
{(char*)0},
#line 101 "thingdef_specials.gperf"
{"thing_changetid",176,2},
#line 143 "thingdef_specials.gperf"
{"acs_executealways",226,1,5},
{(char*)0},
#line 20 "thingdef_specials.gperf"
{"ceiling_raisebyvalue",41,3},
{(char*)0},
#line 117 "thingdef_specials.gperf"
{"ceiling_raiseinstant",194,3},
#line 19 "thingdef_specials.gperf"
{"ceiling_lowerbyvalue",40,3},
#line 45 "thingdef_specials.gperf"
{"light_changetovalue",112,2},
#line 116 "thingdef_specials.gperf"
{"ceiling_lowerinstant",193,3},
#line 121 "thingdef_specials.gperf"
{"ceiling_raisebyvaluetimes8",198,3},
{(char*)0}, {(char*)0},
#line 122 "thingdef_specials.gperf"
{"ceiling_lowerbyvaluetimes8",199,3},
#line 87 "thingdef_specials.gperf"
{"thing_remove",132,1},
{(char*)0},
#line 115 "thingdef_specials.gperf"
{"ceiling_lowertohighestfloor",192,2},
{(char*)0},
#line 165 "thingdef_specials.gperf"
{"door_closewaitopen",249,3},
#line 83 "thingdef_specials.gperf"
{"thing_deactivate",131,1},
#line 132 "thingdef_specials.gperf"
{"sector_setcolor",212,4,5},
{(char*)0},
#line 153 "thingdef_specials.gperf"
{"changecamera",237,3},
#line 90 "thingdef_specials.gperf"
{"floor_waggle",138,5},
{(char*)0},
#line 144 "thingdef_specials.gperf"
{"plat_raiseandstaytx0",228,2},
#line 164 "thingdef_specials.gperf"
{"healthing",248,1,2},
#line 62 "thingdef_specials.gperf"
{"polyobj_rotateleft",2,3},
#line 68 "thingdef_specials.gperf"
{"polyobj_or_rotateleft",90,3},
#line 69 "thingdef_specials.gperf"
{"polyobj_or_rotateright",91,3},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 57 "thingdef_specials.gperf"
{"plat_upbyvalue",65,4},
{(char*)0},
#line 72 "thingdef_specials.gperf"
{"stairs_builddown",26,5},
#line 140 "thingdef_specials.gperf"
{"scroll_texture_both",221,5},
#line 44 "thingdef_specials.gperf"
{"light_lowerbyvalue",111,2},
#line 162 "thingdef_specials.gperf"
{"elevator_movetofloor",246,2},
#line 113 "thingdef_specials.gperf"
{"sector_setfloorscale",189,5},
{(char*)0},
#line 138 "thingdef_specials.gperf"
{"sector_setwind",218,4},
#line 109 "thingdef_specials.gperf"
{"sector_setrotation",185,3},
{(char*)0},
#line 114 "thingdef_specials.gperf"
{"setplayerproperty",191,3},
#line 61 "thingdef_specials.gperf"
{"polyobj_move",4,4},
#line 111 "thingdef_specials.gperf"
{"sector_setfloorpanning",187,5},
#line 65 "thingdef_specials.gperf"
{"polyobj_doorslide",8,5},
{(char*)0},
#line 67 "thingdef_specials.gperf"
{"polyobj_or_move",92,4},
#line 74 "thingdef_specials.gperf"
{"stairs_builddownsync",31,4},
#line 56 "thingdef_specials.gperf"
{"plat_upwaitdownstay",64,3},
#line 48 "thingdef_specials.gperf"
{"light_flicker",115,3},
{(char*)0},
#line 96 "thingdef_specials.gperf"
{"thing_move",125,2},
{(char*)0},
#line 42 "thingdef_specials.gperf"
{"light_forcelightning",109,1},
{(char*)0},
#line 31 "thingdef_specials.gperf"
{"floor_lowertolowest",21,2},
#line 146 "thingdef_specials.gperf"
{"plat_upbyvaluestaytx",230,3},
#line 43 "thingdef_specials.gperf"
{"light_raisebyvalue",110,2},
#line 46 "thingdef_specials.gperf"
{"light_fade",113,3},
#line 157 "thingdef_specials.gperf"
{"floor_lowertolowesttxty",241,2},
{(char*)0}, {(char*)0},
#line 136 "thingdef_specials.gperf"
{"sector_setgravity",216,3},
{(char*)0}, {(char*)0},
#line 81 "thingdef_specials.gperf"
{"damagething",73,1},
#line 75 "thingdef_specials.gperf"
{"stairs_buildupsync",32,4},
#line 52 "thingdef_specials.gperf"
{"pillar_buildandcrush",94,4},
#line 58 "thingdef_specials.gperf"
{"plat_perpetualraise",60,3},
#line 55 "thingdef_specials.gperf"
{"plat_downbyvalue",63,4},
#line 41 "thingdef_specials.gperf"
{"floor_crushstop",46,1},
#line 130 "thingdef_specials.gperf"
{"plat_perpetualraiselip",207,4},
#line 24 "thingdef_specials.gperf"
{"door_open",11,2},
#line 71 "thingdef_specials.gperf"
{"sector_changesound",140,2},
#line 176 "thingdef_specials.gperf"
{"plat_upnearestwaitdownstay",172,3},
{(char*)0}, {(char*)0},
#line 156 "thingdef_specials.gperf"
{"floor_raisebytexture",240,2},
#line 137 "thingdef_specials.gperf"
{"stairs_buildupdoom",217,5},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0},
#line 159 "thingdef_specials.gperf"
{"exit_normal",243,1},
#line 154 "thingdef_specials.gperf"
{"floor_raisetolowestceiling",238,2},
#line 151 "thingdef_specials.gperf"
{"floor_transfertrigger",235,1},
{(char*)0}, {(char*)0},
#line 179 "thingdef_specials.gperf"
{"startconversation",18,1,2},
{(char*)0},
#line 85 "thingdef_specials.gperf"
{"thing_projectile",134,5},
{(char*)0}, {(char*)0},
#line 150 "thingdef_specials.gperf"
{"light_maxneighbor",234,1},
#line 163 "thingdef_specials.gperf"
{"elevator_lowertonearest",247,2},
{(char*)0},
#line 64 "thingdef_specials.gperf"
{"polyobj_doorswing",7,4},
#line 161 "thingdef_specials.gperf"
{"elevator_raisetonearest",245,2},
#line 54 "thingdef_specials.gperf"
{"plat_downwaitupstay",62,3},
#line 174 "thingdef_specials.gperf"
{"teleport_zombiechanger",39,2},
{(char*)0},
#line 129 "thingdef_specials.gperf"
{"plat_downwaitupstaylip",206,4},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 95 "thingdef_specials.gperf"
{"thing_damage",119,2,3},
#line 86 "thingdef_specials.gperf"
{"thing_projectilegravity",136,5},
#line 27 "thingdef_specials.gperf"
{"floor_lowerbyvalue",20,3},
{(char*)0},
#line 29 "thingdef_specials.gperf"
{"floor_lowerinstant",66,3},
#line 32 "thingdef_specials.gperf"
{"floor_lowertonearest",22,2},
{(char*)0}, {(char*)0},
#line 28 "thingdef_specials.gperf"
{"floor_lowerbyvaluetimes8",36,3},
#line 103 "thingdef_specials.gperf"
{"thing_projectileaimed",178,4,5},
{(char*)0},
#line 166 "thingdef_specials.gperf"
{"floor_donut",250,3},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 22 "thingdef_specials.gperf"
{"ceiling_movetovaluetimes8",69,4},
{(char*)0},
#line 40 "thingdef_specials.gperf"
{"floorandceiling_raisebyvalue",96,3},
#line 167 "thingdef_specials.gperf"
{"floorandceiling_lowerraise",251,3},
#line 152 "thingdef_specials.gperf"
{"floor_transfernumeric",236,1},
#line 39 "thingdef_specials.gperf"
{"floorandceiling_lowerbyvalue",95,3},
{(char*)0}, {(char*)0}, {(char*)0},
#line 34 "thingdef_specials.gperf"
{"floor_raisebyvalue",23,3},
{(char*)0},
#line 36 "thingdef_specials.gperf"
{"floor_raiseinstant",67,3},
#line 38 "thingdef_specials.gperf"
{"floor_raisetonearest",25,2},
#line 155 "thingdef_specials.gperf"
{"floor_raisebyvaluetxty",239,3},
{(char*)0},
#line 35 "thingdef_specials.gperf"
{"floor_raisebyvaluetimes8",35,3},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 66 "thingdef_specials.gperf"
{"polyobj_or_movetimes8",93,4},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 26 "thingdef_specials.gperf"
{"door_lockedraise",13,4},
{(char*)0},
#line 60 "thingdef_specials.gperf"
{"polyobj_movetimes8",6,4},
{(char*)0},
#line 149 "thingdef_specials.gperf"
{"light_minneighbor",233,1},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0},
#line 147 "thingdef_specials.gperf"
{"plat_toggleceiling",231,1},
{(char*)0}, {(char*)0},
#line 158 "thingdef_specials.gperf"
{"floor_lowertohighest",242,3},
{(char*)0},
#line 172 "thingdef_specials.gperf"
{"door_animated",14,3},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
#line 30 "thingdef_specials.gperf"
{"floor_movetovaluetimes8",68,4},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0},
#line 33 "thingdef_specials.gperf"
{"floor_raiseandcrush",28,3},
{(char*)0},
#line 37 "thingdef_specials.gperf"
{"floor_raisetohighest",24,2},
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
{(char*)0},
#line 100 "thingdef_specials.gperf"
{"thing_projectileintercept",175,5}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = specialhash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
{
register const char *s = wordlist[key].name;
if (s && *str == *s && !strcmp (str + 1, s + 1))
return &wordlist[key];
}
}
return 0;
}

View file

@ -916,7 +916,7 @@ int FWadCollection::GetNumForName (const char *name, int space)
//
//==========================================================================
int FWadCollection::CheckNumForFullName (const char *name)
int FWadCollection::CheckNumForFullName (const char *name, bool trynormal)
{
WORD i;
@ -932,7 +932,13 @@ int FWadCollection::CheckNumForFullName (const char *name)
i = NextLumpIndex_FullName[i];
}
return i != NULL_INDEX ? i : -1;
if (i != NULL_INDEX) return i;
if (trynormal && strlen(name) <= 8 && !strpbrk(name, "./"))
{
return CheckNumForName(name, ns_global);
}
return -1;
}
int FWadCollection::CheckNumForFullName (const char *name, int wadnum)

View file

@ -181,7 +181,7 @@ public:
inline int GetNumForName (const BYTE *name) { return GetNumForName ((const char *)name); }
inline int GetNumForName (const BYTE *name, int ns) { return GetNumForName ((const char *)name, ns); }
int CheckNumForFullName (const char *name);
int CheckNumForFullName (const char *name, bool trynormal = false);
int CheckNumForFullName (const char *name, int wadfile);
int GetNumForFullName (const char *name);

464
src/xlat/parse_xlat.cpp Normal file
View file

@ -0,0 +1,464 @@
/*
** parse_xlat.cpp
** Translation definition compiler
**
**---------------------------------------------------------------------------
** Copyright 1998-2008 Randy Heit
** Copyright 2008 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#include "doomtype.h"
#include "tarray.h"
#include "w_wad.h"
#include "c_console.h"
#include "p_lnspec.h"
#include "info.h"
#include "gi.h"
#include "xlat_parser.h"
#include "xlat.h"
TAutoGrowArray<FLineTrans> SimpleLineTranslations;
FBoomTranslator Boomish[MAX_BOOMISH];
int NumBoomish;
// Token types not used in the grammar
enum
{
INCLUDE=128,
STRING,
};
struct Symbol
{
int Value;
char Sym[80];
};
union XlatToken
{
int val;
char sym[80];
char string[80];
Symbol *symval;
};
struct SpecialArgs
{
int addflags;
int args[5];
};
struct ListFilter
{
WORD filter;
BYTE value;
};
struct MoreFilters
{
MoreFilters *next;
ListFilter filter;
};
struct MoreLines
{
MoreLines *next;
FBoomArg arg;
};
struct ParseBoomArg
{
BYTE constant;
WORD mask;
MoreFilters *filters;
};
struct XlatParseContext
{
TArray<Symbol> symbols;
int SourceLine;
const char *SourceFile;
int EnumVal;
XlatParseContext()
{
SourceLine = 0;
SourceFile = NULL;
}
//==========================================================================
//
//
//
//==========================================================================
void AddSym (char *sym, int val)
{
Symbol syme;
syme.Value = val;
strncpy (syme.Sym, sym, 79);
syme.Sym[79]=0;
symbols.Push(syme);
}
//==========================================================================
//
//
//
//==========================================================================
bool FindSym (char *sym, Symbol **val)
{
for(unsigned i=0;i<symbols.Size(); i++)
{
if (strcmp (symbols[i].Sym, sym) == 0)
{
*val = &symbols[i];
return true;
}
}
return false;
}
//==========================================================================
//
//
//
//==========================================================================
bool FindToken (char *tok, int *type)
{
static const char tokens[][8] =
{
"include", "define", "enum",
"arg5", "arg4", "arg3", "arg2", "flags", "lineid", "tag"
};
static const short types[] =
{
INCLUDE, DEFINE, ENUM,
ARG5, ARG4, ARG3, ARG2, FLAGS, TAG, TAG
};
int i;
for (i = sizeof(tokens)/sizeof(tokens[0])-1; i >= 0; i--)
{
if (strcmp (tok, tokens[i]) == 0)
{
*type = types[i];
return 1;
}
}
return 0;
}
//==========================================================================
//
//
//
//==========================================================================
int GetToken (char *&sourcep, XlatToken *yylval)
{
char token[80];
int toksize;
int c;
loop:
while (isspace (c = *sourcep++) && c != 0)
{
if (c == '\n')
SourceLine++;
}
if (c == 0)
{
return 0;
}
if (isdigit (c))
{
int buildup = c - '0';
if (c == '0')
{
c = *sourcep++;
if (c == 'x' || c == 'X')
{
for (;;)
{
c = *sourcep++;
if (isdigit (c))
{
buildup = (buildup<<4) + c - '0';
}
else if (c >= 'a' && c <= 'f')
{
buildup = (buildup<<4) + c - 'a' + 10;
}
else if (c >= 'A' && c <= 'F')
{
buildup = (buildup<<4) + c - 'A' + 10;
}
else
{
sourcep--;
yylval->val = buildup;
return NUM;
}
}
}
else
{
sourcep--;
}
}
while (isdigit (c = *sourcep++))
{
buildup = buildup*10 + c - '0';
}
sourcep--;
yylval->val = buildup;
return NUM;
}
if (isalpha (c))
{
int buildup = 0;
token[0] = c;
toksize = 1;
while (toksize < 79 && (isalnum (c = *sourcep++) || c == '_'))
{
token[toksize++] = c;
}
token[toksize] = 0;
if (toksize == 79 && isalnum (c))
{
while (isalnum (c = *sourcep++))
;
}
sourcep--;
if (FindToken (token, &buildup))
{
return buildup;
}
if (FindSym (token, &yylval->symval))
{
return SYMNUM;
}
if ((yylval->val = P_FindLineSpecial(token)) != 0)
{
return NUM;
}
strcpy (yylval->sym, token);
return SYM;
}
if (c == '/')
{
c = *sourcep++;;
if (c == '*')
{
for (;;)
{
while ((c = *sourcep++) != '*' && c != 0)
{
if (c == '\n')
SourceLine++;
}
if (c == 0)
return 0;
if ((c = *sourcep++) == '/')
goto loop;
if (c == 0)
return 0;
sourcep--;
}
}
else if (c == '/')
{
while ((c = *sourcep++) != '\n' && c != 0)
;
if (c == '\n')
SourceLine++;
else if (c == EOF)
return 0;
goto loop;
}
else
{
sourcep--;
return DIVIDE;
}
}
if (c == '"')
{
int tokensize = 0;
while ((c = *sourcep++) != '"' && c != EOF)
{
yylval->string[tokensize++] = c;
}
yylval->string[tokensize] = 0;
return STRING;
}
if (c == '|')
{
c = *sourcep++;
if (c == '=')
return OR_EQUAL;
sourcep--;
return OR;
}
switch (c)
{
case '^': return XOR;
case '&': return AND;
case '-': return MINUS;
case '+': return PLUS;
case '*': return MULTIPLY;
case '(': return LPAREN;
case ')': return RPAREN;
case ',': return COMMA;
case '{': return LBRACE;
case '}': return RBRACE;
case '=': return EQUALS;
//case ';': return SEMICOLON;
case ':': return COLON;
case '[': return LBRACKET;
case ']': return RBRACKET;
default: return 0;
}
}
int PrintError (char *s)
{
if (SourceFile != NULL)
Printf ("%s, line %d: %s\n", SourceFile, SourceLine, s);
else
Printf ("%s\n", s);
return 0;
}
};
#include "xlat_parser.c"
//==========================================================================
//
//
//
//==========================================================================
void ParseXlatLump(const char *lumpname, void *pParser, XlatParseContext *context)
{
int tokentype;
int SavedSourceLine = context->SourceLine;
const char *SavedSourceFile = context->SourceFile;
XlatToken token;
int lumpno = Wads.CheckNumForFullName(lumpname, true);
if (lumpno == -1)
{
Printf ("%s, line %d: Lump '%s' not found\n", context->SourceFile, context->SourceLine, lumpname);
return;
}
// Read the lump into a buffer and add a 0-terminator
int lumplen = Wads.LumpLength(lumpno);
char *lumpdata = new char[lumplen+1];
Wads.ReadLump(lumpno, lumpdata);
lumpdata[lumplen] = 0;
context->SourceLine = 0;
context->SourceFile = lumpname;
char *sourcep = lumpdata;
while (tokentype = context->GetToken(sourcep, &token))
{
// It is much easier to handle include statements outside the main parser.
if (tokentype == INCLUDE)
{
if (context->GetToken(sourcep, &token) != STRING)
{
Printf("%s, line %d: Include: String parameter expected\n", context->SourceFile, context->SourceLine);
return;
}
ParseXlatLump(token.string, pParser, context);
}
else
{
XlatParse(pParser, tokentype, token, context);
}
}
delete [] lumpdata;
context->SourceLine = SavedSourceLine;
context->SourceFile = SavedSourceFile;
}
//==========================================================================
//
//
//
//==========================================================================
void ParseXlat(const char *lumpname)
{
void *pParser = XlatParseAlloc(malloc);
XlatParseContext context;
ParseXlatLump(lumpname, pParser, &context);
XlatToken tok;
tok.val=0;
XlatParse(pParser, 0, tok, &context);
XlatParseFree(pParser, free );
}
//==========================================================================
//
//
//
//==========================================================================
AT_GAME_SET(Translators)
{
if (gameinfo.gametype == GAME_Doom)
{
ParseXlat("xlat/doom.txt");
}
else if (gameinfo.gametype == GAME_Strife)
{
ParseXlat("xlat/strife.txt");
}
else
{
ParseXlat("xlat/heretic.txt");
}
}

67
src/xlat/xlat.h Normal file
View file

@ -0,0 +1,67 @@
#ifndef __XLAT_H
#define __XLAT_H
#include "doomtype.h"
#include "tarray.h"
enum
{
LINETRANS_HASTAGAT1 = (1<<5), // (tag, x, x, x, x)
LINETRANS_HASTAGAT2 = (2<<5), // (x, tag, x, x, x)
LINETRANS_HASTAGAT3 = (3<<5), // (x, x, tag, x, x)
LINETRANS_HASTAGAT4 = (4<<5), // (x, x, x, tag, x)
LINETRANS_HASTAGAT5 = (5<<5), // (x, x, x, x, tag)
LINETRANS_HAS2TAGS = (7<<5), // (tag, tag, x, x, x)
};
struct FLineTrans
{
int special;
int flags;
int args[5];
FLineTrans()
{
special = flags = args[0] = args[1] = args[2] = args[3] = args[4] = 0;
}
FLineTrans(int _special, int _flags, int arg1, int arg2, int arg3, int arg4, int arg5)
{
special = _special;
flags = _flags;
args[0] = arg1;
args[1] = arg2;
args[2] = arg3;
args[3] = arg4;
args[4] = arg5;
}
};
#define MAX_BOOMISH 16
struct FBoomArg
{
bool bOrExisting;
bool bUseConstant;
BYTE ListSize;
BYTE ArgNum;
BYTE ConstantValue;
WORD AndValue;
WORD ResultFilter[15];
BYTE ResultValue[15];
};
struct FBoomTranslator
{
WORD FirstLinetype;
WORD LastLinetype;
BYTE NewSpecial;
TArray<FBoomArg> Args;
} ;
extern TAutoGrowArray<FLineTrans> SimpleLineTranslations;
extern FBoomTranslator Boomish[MAX_BOOMISH];
extern int NumBoomish;
#endif

1806
src/xlat/xlat_parser.c Normal file

File diff suppressed because it is too large Load diff

30
src/xlat/xlat_parser.h Normal file
View file

@ -0,0 +1,30 @@
#define NOP 1
#define OR 2
#define XOR 3
#define AND 4
#define MINUS 5
#define PLUS 6
#define MULTIPLY 7
#define DIVIDE 8
#define NEG 9
#define NUM 10
#define SYMNUM 11
#define LPAREN 12
#define RPAREN 13
#define DEFINE 14
#define SYM 15
#define RBRACE 16
#define ENUM 17
#define LBRACE 18
#define COMMA 19
#define EQUALS 20
#define TAG 21
#define LBRACKET 22
#define RBRACKET 23
#define FLAGS 24
#define ARG2 25
#define ARG3 26
#define ARG4 27
#define ARG5 28
#define OR_EQUAL 29
#define COLON 30

451
src/xlat/xlat_parser.y Normal file
View file

@ -0,0 +1,451 @@
%token_type {XlatToken}
%token_destructor {} // just to avoid a compiler warning
%name XlatParse
%extra_argument { XlatParseContext *context }
%syntax_error { context->PrintError("syntax error");}
main ::= translation_unit.
translation_unit ::= . /* empty */
translation_unit ::= translation_unit external_declaration.
external_declaration ::= define_statement.
external_declaration ::= enum_statement.
external_declaration ::= linetype_declaration.
external_declaration ::= boom_declaration.
external_declaration ::= NOP.
%left OR.
%left XOR.
%left AND.
%left MINUS PLUS.
%left MULTIPLY DIVIDE.
%left NEG.
%type exp {int}
exp(A) ::= NUM(B). { A = B.val; }
exp(A) ::= SYMNUM(B). { A = B.symval->Value; }
exp(A) ::= exp(B) PLUS exp(C). { A = B + C; }
exp(A) ::= exp(B) MINUS exp(C). { A = B - C; }
exp(A) ::= exp(B) MULTIPLY exp(C). { A = B * C; }
exp(A) ::= exp(B) DIVIDE exp(C). { A = B / C; }
exp(A) ::= exp(B) OR exp(C). { A = B | C; }
exp(A) ::= exp(B) AND exp(C). { A = B & C; }
exp(A) ::= exp(B) XOR exp(C). { A = B ^ C; }
exp(A) ::= MINUS exp(B). [NEG] { A = -B; }
exp(A) ::= LPAREN exp(B) RPAREN. { A = B; }
//==========================================================================
//
// define
//
//==========================================================================
define_statement ::= DEFINE SYM(A) LPAREN exp(B) RPAREN.
{
context->AddSym (A.sym, B);
}
//==========================================================================
//
// enum
//
//==========================================================================
enum_statement ::= enum_open enum_list RBRACE.
enum_open ::= ENUM LBRACE.
{
context->EnumVal = 0;
}
enum_list ::= . /* empty */
enum_list ::= single_enum.
enum_list ::= single_enum COMMA enum_list.
single_enum ::= SYM(A).
{
context->AddSym (A.sym, context->EnumVal++);
}
single_enum ::= SYM(A) EQUALS exp(B).
{
context->AddSym (A.sym, context->EnumVal = B);
}
//==========================================================================
//
// standard linetype
//
//==========================================================================
linetype_declaration ::= exp(linetype) EQUALS exp(flags) COMMA exp(special) LPAREN special_args(arg) RPAREN.
{
SimpleLineTranslations.SetVal(linetype,
FLineTrans(special&0xffff, flags+arg.addflags, arg.args[0], arg.args[1], arg.args[2], arg.args[3], arg.args[4]));
}
linetype_declaration ::= exp EQUALS exp COMMA SYM(S) LPAREN special_args RPAREN.
{
Printf ("%s, line %d: %s is undefined\n", context->SourceFile, context->SourceLine, S.sym);
}
%type special_args {SpecialArgs}
special_args(Z) ::= . /* empty */
{
Z.addflags = 0;
Z.args[0] = 0;
Z.args[1] = 0;
Z.args[2] = 0;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= TAG.
{
Z.addflags = LINETRANS_HASTAGAT1;
Z.args[0] = 0;
Z.args[1] = 0;
Z.args[2] = 0;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= TAG COMMA exp(B).
{
Z.addflags = LINETRANS_HASTAGAT1;
Z.args[0] = 0;
Z.args[1] = B;
Z.args[2] = 0;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= TAG COMMA exp(B) COMMA exp(C).
{
Z.addflags = LINETRANS_HASTAGAT1;
Z.args[0] = 0;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= TAG COMMA exp(B) COMMA exp(C) COMMA exp(D).
{
Z.addflags = LINETRANS_HASTAGAT1;
Z.args[0] = 0;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = 0;
}
special_args(Z) ::= TAG COMMA exp(B) COMMA exp(C) COMMA exp(D) COMMA exp(E).
{
Z.addflags = LINETRANS_HASTAGAT1;
Z.args[0] = 0;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = E;
}
special_args(Z) ::= TAG COMMA TAG.
{
Z.addflags = LINETRANS_HAS2TAGS;
Z.args[0] = Z.args[1] = 0;
Z.args[2] = 0;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= TAG COMMA TAG COMMA exp(C).
{
Z.addflags = LINETRANS_HAS2TAGS;
Z.args[0] = Z.args[1] = 0;
Z.args[2] = C;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= TAG COMMA TAG COMMA exp(C) COMMA exp(D).
{
Z.addflags = LINETRANS_HAS2TAGS;
Z.args[0] = Z.args[1] = 0;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = 0;
}
special_args(Z) ::= TAG COMMA TAG COMMA exp(C) COMMA exp(D) COMMA exp(E).
{
Z.addflags = LINETRANS_HAS2TAGS;
Z.args[0] = Z.args[1] = 0;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = E;
}
special_args(Z) ::= exp(A).
{
Z.addflags = 0;
Z.args[0] = A;
Z.args[1] = 0;
Z.args[2] = 0;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA exp(B).
{
Z.addflags = 0;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = 0;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C).
{
Z.addflags = 0;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA exp(D).
{
Z.addflags = 0;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA exp(D) COMMA exp(E).
{
Z.addflags = 0;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = E;
}
special_args(Z) ::= exp(A) COMMA TAG.
{
Z.addflags = LINETRANS_HASTAGAT2;
Z.args[0] = A;
Z.args[1] = 0;
Z.args[2] = 0;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA TAG COMMA exp(C).
{
Z.addflags = LINETRANS_HASTAGAT2;
Z.args[0] = A;
Z.args[1] = 0;
Z.args[2] = C;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA TAG COMMA exp(C) COMMA exp(D).
{
Z.addflags = LINETRANS_HASTAGAT2;
Z.args[0] = A;
Z.args[1] = 0;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA TAG COMMA exp(C) COMMA exp(D) COMMA exp(E).
{
Z.addflags = LINETRANS_HASTAGAT2;
Z.args[0] = A;
Z.args[1] = 0;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = E;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA TAG.
{
Z.addflags = LINETRANS_HASTAGAT3;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = 0;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA TAG COMMA exp(D).
{
Z.addflags = LINETRANS_HASTAGAT3;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = 0;
Z.args[3] = D;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA TAG COMMA exp(D) COMMA exp(E).
{
Z.addflags = LINETRANS_HASTAGAT3;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = 0;
Z.args[3] = D;
Z.args[4] = E;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA TAG.
{
Z.addflags = LINETRANS_HASTAGAT4;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA TAG COMMA exp(E).
{
Z.addflags = LINETRANS_HASTAGAT4;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = 0;
Z.args[4] = E;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA exp(D) COMMA TAG.
{
Z.addflags = LINETRANS_HASTAGAT5;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = 0;
}
//==========================================================================
//
// boom generalized linetypes
//
//==========================================================================
%type list_val {ListFilter}
%type arg_list {MoreFilters *}
%type boom_args {ParseBoomArg}
%type boom_op {int}
%type boom_selector {int}
%type boom_line {FBoomArg}
%type boom_body {MoreLines *}
boom_declaration ::= LBRACKET exp(special) RBRACKET LPAREN exp(firsttype) COMMA exp(lasttype) RPAREN LBRACE boom_body(stores) RBRACE.
{
int i;
MoreLines *probe;
if (NumBoomish == MAX_BOOMISH)
{
MoreLines *probe = stores;
while (probe != NULL)
{
MoreLines *next = probe->next;
delete probe;
probe = next;
}
Printf ("%s, line %d: Too many BOOM translators\n", context->SourceFile, context->SourceLine);
}
else
{
Boomish[NumBoomish].FirstLinetype = firsttype;
Boomish[NumBoomish].LastLinetype = lasttype;
Boomish[NumBoomish].NewSpecial = special;
for (i = 0, probe = stores; probe != NULL; i++)
{
MoreLines *next = probe->next;
Boomish[NumBoomish].Args.Push(probe->arg);
delete probe;
probe = next;
}
NumBoomish++;
}
}
boom_body(A) ::= . /* empty */
{
A = NULL;
}
boom_body(A) ::= boom_line(B) boom_body(C).
{
A = new MoreLines;
A->next = C;
A->arg = B;
}
boom_line(A) ::= boom_selector(sel) boom_op(op) boom_args(args).
{
A.bOrExisting = (op == OR_EQUAL);
A.bUseConstant = (args.filters == NULL);
A.ArgNum = sel;
A.ConstantValue = args.constant;
A.AndValue = args.mask;
if (args.filters != NULL)
{
int i;
MoreFilters *probe;
for (i = 0, probe = args.filters; probe != NULL; i++)
{
MoreFilters *next = probe->next;
if (i < 15)
{
A.ResultFilter[i] = probe->filter.filter;
A.ResultValue[i] = probe->filter.value;
}
else if (i == 15)
{
context->PrintError ("Lists can only have 15 elements");
}
delete probe;
probe = next;
}
A.ListSize = i > 15 ? 15 : i;
}
}
boom_selector(A) ::= FLAGS. { A = 4; }
boom_selector(A) ::= ARG2. { A = 0; }
boom_selector(A) ::= ARG3. { A = 1; }
boom_selector(A) ::= ARG4. { A = 2; }
boom_selector(A) ::= ARG5. { A = 3; }
boom_op(A) ::= EQUALS. { A = '='; }
boom_op(A) ::= OR_EQUAL. { A = OR_EQUAL; }
boom_args(A) ::= exp(B).
{
A.constant = B;
A.filters = NULL;
}
boom_args(A) ::= exp(B) LBRACKET arg_list(C) RBRACKET.
{
A.mask = B;
A.filters = C;
}
arg_list(A) ::= list_val(B).
{
A = new MoreFilters;
A->next = NULL;
A->filter = B;
}
arg_list(A) ::= list_val(B) COMMA arg_list(C).
{
A = new MoreFilters;
A->next = C;
A->filter = B;
}
list_val(A) ::= exp(B) COLON exp(C).
{
A.filter = B;
A.value = C;
}

View file

@ -1,50 +0,0 @@
ifeq (Windows_NT,$(OS))
WIN=1
WINCMD=1
endif
ifeq ($(findstring msys,$(shell sh --version 2>nul)),msys)
WIN=1
WINCMD=0
endif
ifeq (1,$(WIN))
EXE = xlatcc.exe
CFLAGS = $(LOC) -Os -Wall -fomit-frame-pointer
else
EXE = xlatcc
CFLAGS = -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp $(LOC) -Os -Wall -fomit-frame-pointer
endif
CCDV = @../../ccdv
CC = gcc
LDFLAGS= -s
LEMON = ../lemon/lemon
LEMONFLAGS =
OBJS = gen.o xlat-parse.o
all: $(EXE)
$(EXE): $(OBJS)
$(CCDV) $(CC) $(LDFLAGS) -o $(EXE) $(OBJS)
.PHONY: clean
clean:
ifeq (1,$(WINCMD))
-del /q /f $(EXE) 2>nul
-del /q /f *.o 2>nul
else
rm -f $(EXE)
rm -f *.o
endif
xlat-parse.o: xlat-parse.c xlat.h xlat-parse.h
$(CCDV) $(CC) $(CFLAGS) -c -o $@ $<
xlat-parse.c xlat-parse.h: xlat-parse.y
$(CCDV) $(LEMON) $(LEMONFLAGS) $<
gen.o: gen.c xlat.h
$(CCDV) $(CC) $(CFLAGS) -c -o $@ $<

View file

@ -1,275 +0,0 @@
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include "xlat.h"
#define FILE_STACK 32
SimpleTranslator Simple[65536];
BoomTranslator Boomish[MAX_BOOMISH];
int NumBoomish;
FILE *Source;
char *SourceName;
int SourceLine;
static FILE *SourceStack[FILE_STACK];
static char *NameStack[FILE_STACK];
static int LineStack[FILE_STACK];
static int SourceStackSize;
void yyparse (void);
int CountSimpleTranslators (void)
{
int i, count;
for (i = 1, count = 0; i < 65536; i++)
{
if (Simple[i].NewSpecial != 0)
{
count++;
for ( ; i < 65536 && Simple[i].NewSpecial != 0; i++)
;
}
}
return count;
}
void WriteSimpleTranslators (FILE *file)
{
int i, start, count;
for (count = 0, i = 1; i < 65536; i++)
{
if (Simple[i].NewSpecial != 0)
{
start = i;
for ( ; i < 65536; i++)
{
if (Simple[i].NewSpecial == 0)
{
break;
}
}
i--;
// start = first linetype #
// i = last linetype #
putc (start >> 8, file);
putc (start & 255, file);
putc (i >> 8, file);
putc (i & 255, file);
for (; start <= i; start++)
{
putc (Simple[start].Flags, file);
putc (Simple[start].NewSpecial, file);
putc (Simple[start].Args[0], file);
putc (Simple[start].Args[1], file);
putc (Simple[start].Args[2], file);
putc (Simple[start].Args[3], file);
putc (Simple[start].Args[4], file);
count++;
}
}
}
printf ("Wrote %d normal linetypes\n", count);
}
// BOOM translators are stored on disk as:
//
// WORD <first linetype in range>
// WORD <last linetype in range>
// BYTE <new special>
// repeat [BYTE op BYTES parms]
//
// op consists of some bits:
//
// 76543210
// ||||||++-- Dest is arg[(op&3)+1] (arg[0] is always tag)
// |||||+---- 0 = store, 1 = or with existing value
// ||||+----- 0 = this is normal, 1 = x-op in next byte
// ++++------ # of elements in list, or 0 to always use a constant value
//
// If a constant value is used, parms is a single byte containing that value.
// Otherwise, parms has the format:
//
// WORD <value to AND with linetype>
// repeat [WORD <if result is this> BYTE <use this>]
//
// These x-ops are defined:
//
// 0 = end of this BOOM translator
// 1 = dest is flags
void WriteBoomTranslators (FILE *file)
{
int i, j, k;
for (i = 0; i < NumBoomish; i++)
{
putc (Boomish[i].FirstLinetype >> 8, file);
putc (Boomish[i].FirstLinetype & 255, file);
putc (Boomish[i].LastLinetype >> 8, file);
putc (Boomish[i].LastLinetype & 255, file);
putc (Boomish[i].NewSpecial, file);
for (j = 0; j < MAX_BOOMISH_EXEC; j++)
{
if (Boomish[i].Args[j].bDefined)
{
BYTE op;
if (Boomish[i].Args[j].ArgNum < 4)
{
op = Boomish[i].Args[j].ArgNum;
}
else
{
op = 8;
}
if (Boomish[i].Args[j].bOrExisting)
{
op |= 4;
}
if (!Boomish[i].Args[j].bUseConstant)
{
op |= Boomish[i].Args[j].ListSize << 4;
}
putc (op, file);
if (op & 8)
{
putc (Boomish[i].Args[j].ArgNum - 3, file);
}
if (Boomish[i].Args[j].bUseConstant)
{
putc (Boomish[i].Args[j].ConstantValue, file);
}
else
{
putc (Boomish[i].Args[j].AndValue >> 8, file);
putc (Boomish[i].Args[j].AndValue & 255, file);
for (k = 0; k < Boomish[i].Args[j].ListSize; k++)
{
putc (Boomish[i].Args[j].ResultFilter[k] >> 8, file);
putc (Boomish[i].Args[j].ResultFilter[k] & 255, file);
putc (Boomish[i].Args[j].ResultValue[k], file);
}
}
}
}
putc (8, file);
putc (0, file);
}
printf ("Wrote %d BOOM-style generalized linetypes\n", NumBoomish);
}
void WriteTranslatorFile (FILE *file, int count)
{
putc ('N', file);
putc ('O', file);
putc ('R', file);
putc ('M', file);
putc (count >> 8, file);
putc (count & 255, file);
WriteSimpleTranslators (file);
putc ('B', file);
putc ('O', file);
putc ('O', file);
putc ('M', file);
putc (NumBoomish >> 8, file);
putc (NumBoomish & 255, file);
WriteBoomTranslators (file);
}
void IncludeFile (const char *name)
{
FILE *newsource;
if (Source != NULL)
{
if (SourceStackSize == FILE_STACK)
{
printf ("Too many files included. Skipping %s\n", name);
return;
}
SourceStack[SourceStackSize] = Source;
LineStack[SourceStackSize] = SourceLine;
NameStack[SourceStackSize] = SourceName;
SourceStackSize++;
}
newsource = fopen (name, "r");
if (newsource == NULL)
{
printf ("Cannot open %s\n", name);
if (Source != NULL)
{
SourceStackSize--;
}
return;
}
Source = newsource;
SourceLine = 1;
SourceName = strdup (name);
}
bool EndFile ()
{
if (Source != NULL)
{
fclose (Source);
}
if (SourceName != NULL)
{
free (SourceName);
}
if (SourceStackSize)
{
Source = SourceStack[--SourceStackSize];
SourceName = NameStack[SourceStackSize];
SourceLine = LineStack[SourceStackSize];
return 1;
}
return 0;
}
int main (int argc, char **argv)
{
FILE *output;
int count;
if (argc != 3)
{
printf ("Usage: %s <source file> <output file>\n", argv[0]);
return -1;
}
#if !defined(NDEBUG) && 0
ParseTrace(fopen("trace.txt", "w"), ":");
#endif
IncludeFile (argv[1]);
yyparse ();
count = CountSimpleTranslators ();
if ((count | NumBoomish) != 0)
{
output = fopen (argv[2], "wb");
if (output == NULL)
{
printf ("Could not open %s\n", argv[2]);
return -2;
}
WriteTranslatorFile (output, count);
fclose (output);
}
else
{
printf ("No linedef types to translate\n");
}
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -1,37 +0,0 @@
#define OR 1
#define XOR 2
#define AND 3
#define MINUS 4
#define PLUS 5
#define MULTIPLY 6
#define DIVIDE 7
#define NEG 8
#define NUM 9
#define SYMNUM 10
#define LPAREN 11
#define RPAREN 12
#define NOP 13
#define PRINT 14
#define COMMA 15
#define STRING 16
#define ENDL 17
#define DEFINE 18
#define SYM 19
#define INCLUDE 20
#define RBRACE 21
#define ENUM 22
#define LBRACE 23
#define EQUALS 24
#define SPECIAL 25
#define SEMICOLON 26
#define COLON 27
#define LBRACKET 28
#define RBRACKET 29
#define FLAGS 30
#define ARG2 31
#define ARG3 32
#define ARG4 33
#define ARG5 34
#define OR_EQUAL 35
#define TAG 36
#define LINEID 37

View file

@ -1,852 +0,0 @@
%include{
#include "xlat.h"
#include "xlat-parse.h"
#include <malloc.h>
#include <string.h>
int yyerror (char *s);
typedef struct _Symbol
{
struct _Symbol *Next;
int Value;
char Sym[1];
} Symbol;
static bool FindToken (char *tok, int *type);
static void AddSym (char *sym, int val);
static bool FindSym (char *sym, Symbol **val);
static int EnumVal;
struct ListFilter
{
WORD filter;
BYTE value;
};
typedef struct _morefilters
{
struct _morefilters *next;
struct ListFilter filter;
} MoreFilters;
typedef struct _morelines
{
struct _morelines *next;
BoomArg arg;
} MoreLines;
typedef struct _specialargs
{
BYTE addflags;
BYTE args[5];
} SpecialArgs;
typedef struct _boomarg
{
BYTE constant;
WORD mask;
MoreFilters *filters;
} ParseBoomArg;
typedef union YYSTYPE
{
int val;
char sym[80];
char string[80];
Symbol *symval;
} YYSTYPE;
#include <ctype.h>
#include <stdio.h>
int yylex (YYSTYPE *yylval)
{
char token[80];
int toksize;
int c;
loop:
while (Source == NULL)
{
if (!EndFile ())
return 0;
}
while (isspace (c = fgetc (Source)) && c != EOF)
{
if (c == '\n')
SourceLine++;
}
if (c == EOF)
{
if (EndFile ())
goto loop;
return 0;
}
if (isdigit (c))
{
int buildup = c - '0';
if (c == '0')
{
c = fgetc (Source);
if (c == 'x' || c == 'X')
{
for (;;)
{
c = fgetc (Source);
if (isdigit (c))
{
buildup = (buildup<<4) + c - '0';
}
else if (c >= 'a' && c <= 'f')
{
buildup = (buildup<<4) + c - 'a' + 10;
}
else if (c >= 'A' && c <= 'F')
{
buildup = (buildup<<4) + c - 'A' + 10;
}
else
{
ungetc (c, Source);
yylval->val = buildup;
return NUM;
}
}
}
else
{
ungetc (c, Source);
}
}
while (isdigit (c = fgetc (Source)))
{
buildup = buildup*10 + c - '0';
}
ungetc (c, Source);
yylval->val = buildup;
return NUM;
}
if (isalpha (c))
{
int buildup = 0;
token[0] = c;
toksize = 1;
while (toksize < 79 && (isalnum (c = fgetc (Source)) || c == '_'))
{
token[toksize++] = c;
}
token[toksize] = 0;
if (toksize == 79 && isalnum (c))
{
while (isalnum (c = fgetc (Source)))
;
}
ungetc (c, Source);
if (FindToken (token, &buildup))
{
return buildup;
}
if (FindSym (token, &yylval->symval))
{
return SYMNUM;
}
strcpy (yylval->sym, token);
return SYM;
}
if (c == '/')
{
c = fgetc (Source);
if (c == '*')
{
for (;;)
{
while ((c = fgetc (Source)) != '*' && c != EOF)
{
if (c == '\n')
SourceLine++;
}
if (c == EOF)
return 0;
if ((c = fgetc (Source)) == '/')
goto loop;
if (c == EOF)
return 0;
ungetc (c, Source);
}
}
else if (c == '/')
{
while ((c = fgetc (Source)) != '\n' && c != EOF)
;
if (c == '\n')
SourceLine++;
else if (c == EOF)
return 0;
goto loop;
}
else
{
ungetc (c, Source);
return DIVIDE;
}
}
if (c == '"')
{
int tokensize = 0;
while ((c = fgetc (Source)) != '"' && c != EOF)
{
yylval->string[tokensize++] = c;
}
yylval->string[tokensize] = 0;
return STRING;
}
if (c == '|')
{
c = fgetc (Source);
if (c == '=')
return OR_EQUAL;
ungetc (c, Source);
return OR;
}
switch (c)
{
case '^': return XOR;
case '&': return AND;
case '-': return MINUS;
case '+': return PLUS;
case '*': return MULTIPLY;
case '(': return LPAREN;
case ')': return RPAREN;
case ',': return COMMA;
case '{': return LBRACE;
case '}': return RBRACE;
case '=': return EQUALS;
case ';': return SEMICOLON;
case ':': return COLON;
case '[': return LBRACKET;
case ']': return RBRACKET;
default: return 0;
}
}
void *ParseAlloc(void *(*mallocProc)(size_t));
void Parse(void *yyp, int yymajor, YYSTYPE yyminor);
void ParseFree(void *p, void (*freeProc)(void*));
void ParseTrace(FILE *TraceFILE, char *zTracePrompt);
void yyparse (void)
{
void *pParser = ParseAlloc (malloc);
YYSTYPE token;
int tokentype;
int include_state = 0;
while ((tokentype = yylex(&token)) != 0)
{
/* Whenever the sequence INCLUDE STRING is encountered in the token
* stream, feed a dummy NOP token to the parser so that it will
* reduce the include_statement before grabbing any more tokens
* from the current file.
*/
if (tokentype == INCLUDE && include_state == 0)
{
include_state = 1;
}
else if (tokentype == STRING && include_state == 1)
{
include_state = 2;
}
else
{
include_state = 0;
}
Parse (pParser, tokentype, token);
if (include_state == 2)
{
include_state = 0;
Parse (pParser, NOP, token);
}
}
memset (&token, 0, sizeof(token));
Parse (pParser, 0, token);
ParseFree (pParser, free);
}
static Symbol *FirstSym;
static void AddSym (char *sym, int val)
{
Symbol *syme = malloc (strlen (sym) + sizeof(Symbol));
syme->Next = FirstSym;
syme->Value = val;
strcpy (syme->Sym, sym);
FirstSym = syme;
}
static bool FindSym (char *sym, Symbol **val)
{
Symbol *syme = FirstSym;
while (syme != NULL)
{
if (strcmp (syme->Sym, sym) == 0)
{
*val = syme;
return 1;
}
syme = syme->Next;
}
return 0;
}
static bool FindToken (char *tok, int *type)
{
static const char tokens[][8] =
{
"endl", "print", "include", "special", "define", "enum",
"arg5", "arg4", "arg3", "arg2", "flags", "lineid", "tag"
};
static const short types[] =
{
ENDL, PRINT, INCLUDE, SPECIAL, DEFINE, ENUM,
ARG5, ARG4, ARG3, ARG2, FLAGS, LINEID, TAG
};
int i;
for (i = sizeof(tokens)/sizeof(tokens[0])-1; i >= 0; i--)
{
if (strcmp (tok, tokens[i]) == 0)
{
*type = types[i];
return 1;
}
}
return 0;
}
int yyerror (char *s)
{
if (SourceName != NULL)
printf ("%s, line %d: %s\n", SourceName, SourceLine, s);
else
printf ("%s\n", s);
return 0;
}
}
%token_type {YYSTYPE}
%syntax_error {yyerror("syntax error");}
%type exp {int}
%type special_args {SpecialArgs}
%type list_val {struct ListFilter}
%type arg_list {MoreFilters *}
%type boom_args {ParseBoomArg}
%type boom_op {int}
%type boom_selector {int}
%type boom_line {BoomArg}
%type boom_body {MoreLines *}
%type maybe_argcount {int}
%left OR.
%left XOR.
%left AND.
%left MINUS PLUS.
%left MULTIPLY DIVIDE.
%left NEG.
main ::= translation_unit.
exp(A) ::= NUM(B). { A = B.val; }
exp(A) ::= SYMNUM(B). { A = B.symval->Value; }
exp(A) ::= exp(B) PLUS exp(C). { A = B + C; }
exp(A) ::= exp(B) MINUS exp(C). { A = B - C; }
exp(A) ::= exp(B) MULTIPLY exp(C). { A = B * C; }
exp(A) ::= exp(B) DIVIDE exp(C). { A = B / C; }
exp(A) ::= exp(B) OR exp(C). { A = B | C; }
exp(A) ::= exp(B) AND exp(C). { A = B & C; }
exp(A) ::= exp(B) XOR exp(C). { A = B ^ C; }
exp(A) ::= MINUS exp(B). [NEG] { A = -B; }
exp(A) ::= LPAREN exp(B) RPAREN. { A = B; }
translation_unit ::= . /* empty */
translation_unit ::= translation_unit external_declaration.
external_declaration ::= define_statement.
external_declaration ::= include_statement.
external_declaration ::= print_statement.
external_declaration ::= enum_statement.
external_declaration ::= linetype_declaration.
external_declaration ::= boom_declaration.
external_declaration ::= special_declaration.
external_declaration ::= NOP.
print_statement ::= PRINT LPAREN print_list RPAREN.
{
printf ("\n");
}
print_list ::= . /* EMPTY */
print_list ::= print_item.
print_list ::= print_item COMMA print_list.
print_item ::= STRING(A). { printf ("%s", A.string); }
print_item ::= exp(A). { printf ("%d", A); }
print_item ::= ENDL. { printf ("\n"); }
define_statement ::= DEFINE SYM(A) LPAREN exp(B) RPAREN.
{
AddSym (A.sym, B);
}
include_statement ::= INCLUDE STRING(A).
{
IncludeFile (A.string);
}
enum_statement ::= enum_open enum_list RBRACE.
enum_open ::= ENUM LBRACE.
{
EnumVal = 0;
}
enum_list ::= . /* empty */
enum_list ::= single_enum.
enum_list ::= single_enum COMMA enum_list.
single_enum ::= SYM(A).
{
AddSym (A.sym, EnumVal++);
}
single_enum ::= SYM(A) EQUALS exp(B).
{
AddSym (A.sym, EnumVal = B);
}
/* special declarations work just like they do for ACS, so
* specials can be defined just by including zspecial.acs
*/
special_declaration ::= SPECIAL special_list SEMICOLON.
special_list ::= special_def.
special_list ::= special_list COMMA special_def.
special_def ::= exp(A) COLON SYM(B) LPAREN maybe_argcount RPAREN.
{
AddSym (B.sym, A);
}
special_def ::= exp COLON SYMNUM(B) LPAREN maybe_argcount RPAREN.
{
printf ("%s, line %d: %s is already defined\n", SourceName, SourceLine, B.symval->Sym);
}
maybe_argcount ::= . /* empty */
maybe_argcount ::= exp.
maybe_argcount ::= exp COMMA exp.
linetype_declaration ::= exp(linetype) EQUALS exp(flags) COMMA exp(special) LPAREN special_args(arg) RPAREN.
{
Simple[linetype].NewSpecial = special;
Simple[linetype].Flags = flags | arg.addflags;
Simple[linetype].Args[0] = arg.args[0];
Simple[linetype].Args[1] = arg.args[1];
Simple[linetype].Args[2] = arg.args[2];
Simple[linetype].Args[3] = arg.args[3];
Simple[linetype].Args[4] = arg.args[4];
}
linetype_declaration ::= exp EQUALS exp COMMA SYM(S) LPAREN special_args RPAREN.
{
printf ("%s, line %d: %s is undefined\n", SourceName, SourceLine, S.sym);
}
boom_declaration ::= LBRACKET exp(special) RBRACKET LPAREN exp(firsttype) COMMA exp(lasttype) RPAREN LBRACE boom_body(stores) RBRACE.
{
if (NumBoomish == MAX_BOOMISH)
{
MoreLines *probe = stores;
while (probe != NULL)
{
MoreLines *next = probe->next;
free (probe);
probe = next;
}
printf ("%s, line %d: Too many BOOM translators\n", SourceName, SourceLine);
}
else
{
int i;
MoreLines *probe;
Boomish[NumBoomish].FirstLinetype = firsttype;
Boomish[NumBoomish].LastLinetype = lasttype;
Boomish[NumBoomish].NewSpecial = special;
for (i = 0, probe = stores; probe != NULL; i++)
{
MoreLines *next = probe->next;;
if (i < MAX_BOOMISH_EXEC)
{
Boomish[NumBoomish].Args[i] = probe->arg;
}
else if (i == MAX_BOOMISH_EXEC)
{
printf ("%s, line %d: Too many commands for this BOOM translator\n", SourceName, SourceLine);
}
free (probe);
probe = next;
}
if (i < MAX_BOOMISH_EXEC)
{
Boomish[NumBoomish].Args[i].bDefined = 0;
}
NumBoomish++;
}
}
boom_body(A) ::= . /* empty */
{
A = NULL;
}
boom_body(A) ::= boom_line(B) boom_body(C).
{
A = malloc (sizeof(MoreLines));
A->next = C;
A->arg = B;
}
boom_line(A) ::= boom_selector(sel) boom_op(op) boom_args(args).
{
A.bDefined = 1;
A.bOrExisting = (op == OR_EQUAL);
A.bUseConstant = (args.filters == NULL);
A.ArgNum = sel;
A.ConstantValue = args.constant;
A.AndValue = args.mask;
if (args.filters != NULL)
{
int i;
MoreFilters *probe;
for (i = 0, probe = args.filters; probe != NULL; i++)
{
MoreFilters *next = probe->next;
if (i < 15)
{
A.ResultFilter[i] = probe->filter.filter;
A.ResultValue[i] = probe->filter.value;
}
else if (i == 15)
{
yyerror ("Lists can only have 15 elements");
}
free (probe);
probe = next;
}
A.ListSize = i > 15 ? 15 : i;
}
}
boom_selector(A) ::= FLAGS. { A = 4; }
boom_selector(A) ::= ARG2. { A = 0; }
boom_selector(A) ::= ARG3. { A = 1; }
boom_selector(A) ::= ARG4. { A = 2; }
boom_selector(A) ::= ARG5. { A = 3; }
boom_op(A) ::= EQUALS. { A = '='; }
boom_op(A) ::= OR_EQUAL. { A = OR_EQUAL; }
boom_args(A) ::= exp(B).
{
A.constant = B;
A.filters = NULL;
}
boom_args(A) ::= exp(B) LBRACKET arg_list(C) RBRACKET.
{
A.mask = B;
A.filters = C;
}
arg_list(A) ::= list_val(B).
{
A = malloc (sizeof(MoreFilters));
A->next = NULL;
A->filter = B;
}
arg_list(A) ::= list_val(B) COMMA arg_list(C).
{
A = malloc (sizeof(MoreFilters));
A->next = C;
A->filter = B;
}
list_val(A) ::= exp(B) COLON exp(C).
{
A.filter = B;
A.value = C;
}
special_args(Z) ::= . /* empty */
{
Z.addflags = 0;
memset (Z.args, 0, 5);
}
special_args(Z) ::= TAG.
{
Z.addflags = SIMPLE_HASTAGAT1;
memset (Z.args, 0, 5);
}
special_args(Z) ::= TAG COMMA exp(B).
{
Z.addflags = SIMPLE_HASTAGAT1;
Z.args[0] = 0;
Z.args[1] = B;
Z.args[2] = 0;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= TAG COMMA exp(B) COMMA exp(C).
{
Z.addflags = SIMPLE_HASTAGAT1;
Z.args[0] = 0;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= TAG COMMA exp(B) COMMA exp(C) COMMA exp(D).
{
Z.addflags = SIMPLE_HASTAGAT1;
Z.args[0] = 0;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = 0;
}
special_args(Z) ::= TAG COMMA exp(B) COMMA exp(C) COMMA exp(D) COMMA exp(E).
{
Z.addflags = SIMPLE_HASTAGAT1;
Z.args[0] = 0;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = E;
}
special_args(Z) ::= TAG COMMA TAG.
{
Z.addflags = SIMPLE_HAS2TAGS;
Z.args[0] = Z.args[1] = 0;
Z.args[2] = 0;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= TAG COMMA TAG COMMA exp(C).
{
Z.addflags = SIMPLE_HAS2TAGS;
Z.args[0] = Z.args[1] = 0;
Z.args[2] = C;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= TAG COMMA TAG COMMA exp(C) COMMA exp(D).
{
Z.addflags = SIMPLE_HAS2TAGS;
Z.args[0] = Z.args[1] = 0;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = 0;
}
special_args(Z) ::= TAG COMMA TAG COMMA exp(C) COMMA exp(D) COMMA exp(E).
{
Z.addflags = SIMPLE_HAS2TAGS;
Z.args[0] = Z.args[1] = 0;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = E;
}
special_args(Z) ::= LINEID.
{
Z.addflags = SIMPLE_HASLINEID;
memset (Z.args, 0, 5);
}
special_args(Z) ::= LINEID COMMA exp(B).
{
Z.addflags = SIMPLE_HASLINEID;
Z.args[0] = 0;
Z.args[1] = B;
Z.args[2] = 0;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= LINEID COMMA exp(B) COMMA exp(C).
{
Z.addflags = SIMPLE_HASLINEID;
Z.args[0] = 0;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= LINEID COMMA exp(B) COMMA exp(C) COMMA exp(D).
{
Z.addflags = SIMPLE_HASLINEID;
Z.args[0] = 0;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = 0;
}
special_args(Z) ::= LINEID COMMA exp(B) COMMA exp(C) COMMA exp(D) COMMA exp(E).
{
Z.addflags = SIMPLE_HASLINEID;
Z.args[0] = 0;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = E;
}
special_args(Z) ::= exp(A).
{
Z.addflags = 0;
Z.args[0] = A;
Z.args[1] = 0;
Z.args[2] = 0;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA exp(B).
{
Z.addflags = 0;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = 0;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C).
{
Z.addflags = 0;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA exp(D).
{
Z.addflags = 0;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA exp(D) COMMA exp(E).
{
Z.addflags = 0;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = E;
}
special_args(Z) ::= exp(A) COMMA TAG.
{
Z.addflags = SIMPLE_HASTAGAT2;
Z.args[0] = A;
Z.args[1] = 0;
Z.args[2] = 0;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA TAG COMMA exp(C).
{
Z.addflags = SIMPLE_HASTAGAT2;
Z.args[0] = A;
Z.args[1] = 0;
Z.args[2] = C;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA TAG COMMA exp(C) COMMA exp(D).
{
Z.addflags = SIMPLE_HASTAGAT2;
Z.args[0] = A;
Z.args[1] = 0;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA TAG COMMA exp(C) COMMA exp(D) COMMA exp(E).
{
Z.addflags = SIMPLE_HASTAGAT2;
Z.args[0] = A;
Z.args[1] = 0;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = E;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA TAG.
{
Z.addflags = SIMPLE_HASTAGAT3;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = 0;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA TAG COMMA exp(D).
{
Z.addflags = SIMPLE_HASTAGAT3;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = 0;
Z.args[3] = D;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA TAG COMMA exp(D) COMMA exp(E).
{
Z.addflags = SIMPLE_HASTAGAT3;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = 0;
Z.args[3] = D;
Z.args[4] = E;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA TAG.
{
Z.addflags = SIMPLE_HASTAGAT4;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = 0;
Z.args[4] = 0;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA TAG COMMA exp(E).
{
Z.addflags = SIMPLE_HASTAGAT4;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = 0;
Z.args[4] = E;
}
special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA exp(D) COMMA TAG.
{
Z.addflags = SIMPLE_HASTAGAT5;
Z.args[0] = A;
Z.args[1] = B;
Z.args[2] = C;
Z.args[3] = D;
Z.args[4] = 0;
}

View file

@ -1,59 +0,0 @@
#include <stdio.h>
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned char bool;
#define MAX_BOOMISH 16
#define MAX_BOOMISH_EXEC 32
#define SIMPLE_HASTAGAT1 (1<<5) // (tag, x, x, x, x)
#define SIMPLE_HASTAGAT2 (2<<5) // (x, tag, x, x, x)
#define SIMPLE_HASTAGAT3 (3<<5) // (x, x, tag, x, x)
#define SIMPLE_HASTAGAT4 (4<<5) // (x, x, x, tag, x)
#define SIMPLE_HASTAGAT5 (5<<5) // (x, x, x, x, tag)
#define SIMPLE_HASLINEID (6<<5) // (tag, lineid, x, x, x, x)
#define SIMPLE_HAS2TAGS (7<<5) // (tag, tag, x, x, x)
typedef struct
{
BYTE Flags;
BYTE NewSpecial;
BYTE Args[5];
} SimpleTranslator;
typedef struct
{
bool bDefined;
bool bOrExisting;
bool bUseConstant;
BYTE ListSize;
BYTE ArgNum;
BYTE ConstantValue;
WORD AndValue;
WORD ResultFilter[15];
BYTE ResultValue[15];
} BoomArg;
typedef struct
{
WORD FirstLinetype;
WORD LastLinetype;
BYTE NewSpecial;
BoomArg Args[MAX_BOOMISH_EXEC];
} BoomTranslator;
extern SimpleTranslator Simple[65536];
extern BoomTranslator Boomish[MAX_BOOMISH];
extern int NumBoomish;
extern FILE *Source;
extern char *SourceName;
extern int SourceLine;
void IncludeFile (const char *name);
bool EndFile ();
int yyerror (char *s);

View file

@ -1,411 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="xlatcc"
ProjectGUID="{3FFA68B3-9449-4B03-ADEE-194C3638623B}"
RootNamespace="xlatcc"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/xlatcc.exe"
LinkIncremental="2"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/xlatcc.pdb"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy &quot;$(TargetPath)&quot; &quot;$(ProjectDir)\$(TargetFileName)&quot;"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
DisableSpecificWarnings="4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/xlatcc.exe"
LinkIncremental="2"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/xlatcc.pdb"
SubSystem="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy &quot;$(TargetPath)&quot; &quot;$(ProjectDir)\$(TargetFileName)&quot;"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
DisableSpecificWarnings="4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/xlatcc.exe"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy &quot;$(TargetPath)&quot; &quot;$(ProjectDir)\$(TargetFileName)&quot;"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
DisableSpecificWarnings="4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/xlatcc.exe"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy &quot;$(TargetPath)&quot; &quot;$(ProjectDir)\$(TargetFileName)&quot;"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\gen.c"
>
</File>
<File
RelativePath=".\xlat-parse.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\xlat-parse.h"
>
</File>
<File
RelativePath=".\xlat.h"
>
</File>
</Filter>
<Filter
Name="Grammar"
>
<File
RelativePath=".\xlat-parse.y"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Generating xlat-parse.c from xlat-parse.y..."
CommandLine="..\lemon\lemon.exe -s &quot;$(InputFileName)&quot;"
Outputs="$(InputDir)xlat-parse.c;$(InputDir)xlat-parse.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="bison xlat-parse.y&#x0D;&#x0A;"
Outputs="xlat-parse.tab.c"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Generating xlat-parse.c from xlat-parse.y..."
CommandLine="..\lemon\lemon.exe -s &quot;$(InputFileName)&quot;"
Outputs="$(InputDir)xlat-parse.c;$(InputDir)xlat-parse.h"
/>
</FileConfiguration>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -10,17 +10,16 @@
RM=rm -f
SLASH=/
MAKEWAD=..$(SLASH)tools$(SLASH)makewad$(SLASH)makewad
XLATCC=..$(SLASH)tools$(SLASH)xlatcc$(SLASH)xlatcc
DEHSUPP=..$(SLASH)tools$(SLASH)dehsupp$(SLASH)dehsupp
makethewad: wadmake Makefile2
$(MAKE) $(NOLOGO) XLATCC=$(XLATCC) DEHSUPP=$(DEHSUPP) -f Makefile2
$(MAKE) $(NOLOGO) DEHSUPP=$(DEHSUPP) -f Makefile2
wadmake: zdoom.lst
$(MAKEWAD) -make wadmake zdoom.lst
clean:
$(RM) wadmake zdoom.pk3 xlat$(SLASH)*.x dehsupp.lmp
$(RM) wadmake zdoom.pk3 dehsupp.lmp
# This target is for Visual C++'s Rebuild All command
nrebuild: clean

View file

@ -1,14 +1,5 @@
include wadmake
xlat/doom.x: xlat/doomxlat.txt xlat/defines.i
$(XLATCC) xlat/doomxlat.txt xlat/doom.x
xlat/heretic.x: xlat/hereticxlat.txt xlat/doomxlat.txt xlat/defines.i
$(XLATCC) xlat/hereticxlat.txt xlat/heretic.x
xlat/strife.x: xlat/strifexlat.txt xlat/defines.i
$(XLATCC) xlat/strifexlat.txt xlat/strife.x
dehsupp.lmp: dehsupp.txt
$(DEHSUPP) dehsupp.txt dehsupp.lmp

View file

@ -1,23 +1,3 @@
include "xlat/specials.i"
// Not all specials are accessible from ACS, so define those here
special
50:ExtraFloor_LightOnly(),
100:Scroll_Texture_Left(),
101:Scroll_Texture_Right(),
102:Scroll_Texture_Up(),
103:Scroll_Texture_Down(),
121:Line_SetIdentification(),
181:Plane_Align(),
190:Static_Init(),
209:Transfer_Heights(),
210:Transfer_FloorLight(),
211:Transfer_CeilingLight(),
219:Sector_SetFriction(),
222:Scroll_Texture_Model(),
225:Scroll_Texture_Offsets(),
227:PointPush_SetForce()
;
// Static_Init types
enum

View file

@ -395,6 +395,7 @@ include "xlat/defines.i"
* <destination>.
*/
// Generalized crusher (tag, dnspeed, upspeed, silent, damage)
[Generic_Crusher] (0x2f80, 0x2fff)
{

View file

@ -1,190 +0,0 @@
//**************************************************************************
//**
//** zspecials.acs
//**
//** This version is not kept up to date, but it has enough to make the
//** translators compile.
//**
//**************************************************************************
special
80:ACS_Execute(2,5),
81:ACS_Suspend(2),
82:ACS_Terminate(2),
83:ACS_LockedExecute(5),
42:Ceiling_CrushAndRaise(3),
44:Ceiling_CrushStop(1),
43:Ceiling_LowerAndCrush(3),
40:Ceiling_LowerByValue(3),
41:Ceiling_RaiseByValue(3),
45:Ceiling_CrushRaiseAndStay(3),
69:Ceiling_MoveToValueTimes8(4),
10:Door_Close(2),
11:Door_Open(2,3),
12:Door_Raise(3,4),
13:Door_LockedRaise(4,5),
20:Floor_LowerByValue(3),
36:Floor_LowerByValueTimes8(3),
66:Floor_LowerInstant(3),
68:Floor_MoveToValueTimes8(4),
21:Floor_LowerToLowest(2),
22:Floor_LowerToNearest(2),
28:Floor_RaiseAndCrush(3),
23:Floor_RaiseByValue(3),
35:Floor_RaiseByValueTimes8(3),
67:Floor_RaiseInstant(3),
24:Floor_RaiseToHighest(2),
25:Floor_RaiseToNearest(2),
95:FloorAndCeiling_LowerByValue(3),
96:FloorAndCeiling_RaiseByValue(3),
46:Floor_CrushStop(1),
109:Light_ForceLightning(1),
110:Light_RaiseByValue(2),
111:Light_LowerByValue(2),
112:Light_ChangeToValue(2),
113:Light_Fade(3),
114:Light_Glow(4),
115:Light_Flicker(3),
116:Light_Strobe(5),
117:Light_Stop(1),
29:Pillar_Build(3),
94:Pillar_BuildAndCrush(4),
30:Pillar_Open(4),
62:Plat_DownWaitUpStay(3),
63:Plat_DownByValue(4),
64:Plat_UpWaitDownStay(3),
65:Plat_UpByValue(4),
60:Plat_PerpetualRaise(3),
61:Plat_Stop(1),
6:Polyobj_MoveTimes8(4),
4:Polyobj_Move(4),
2:Polyobj_RotateLeft(3),
3:Polyobj_RotateRight(3),
7:Polyobj_DoorSwing(4),
8:Polyobj_DoorSlide(5),
93:Polyobj_OR_MoveTimes8(4),
92:Polyobj_OR_Move(4),
90:Polyobj_OR_RotateLeft(3),
91:Polyobj_OR_RotateRight(3),
120:Radius_Quake(5),
140:Sector_ChangeSound(2),
26:Stairs_BuildDown(5),
27:Stairs_BuildUp(5),
31:Stairs_BuildDownSync(4),
32:Stairs_BuildUpSync(4),
70:Teleport(1,3),
71:Teleport_NoFog(1,3),
74:Teleport_NewMap(2,3),
75:Teleport_EndGame(0),
72:ThrustThing(2,3),
73:DamageThing(1),
130:Thing_Activate(1),
131:Thing_Deactivate(1),
133:Thing_Destroy(1,2),
134:Thing_Projectile(5),
136:Thing_ProjectileGravity(5),
132:Thing_Remove(1),
135:Thing_Spawn(3,4),
137:Thing_SpawnNoFog(3,4),
138:Floor_Waggle(5),
9:Line_Horizon(0),
14:Door_Animated(3),
15:Autosave(0),
33:ForceField(0),
34:ClearForceField(1),
38:Ceiling_Waggle(5),
39:Teleport_ZombieChanger(2),
49:GlassBreak(0),
76:TeleportOther(3),
77:TeleportGroup(5),
78:TeleportInSector(4,5),
84:ACS_ExecuteWithResult(1,4),
119:Thing_Damage(2,3),
125:Thing_Move(2),
127:Thing_SetSpecial(5),
128:ThrustThingZ(4),
139:Thing_SpawnFacing(2,4),
172:Plat_UpNearestWaitDownStay(3),
173:NoiseAlert(2),
174:SendToCommunicator(4),
175:Thing_ProjectileIntercept(5),
176:Thing_ChangeTID(2),
177:Thing_Hate(2,3),
178:Thing_ProjectileAimed(4,5),
179:ChangeSkill(1),
180:Thing_SetTranslation(2),
// 181:Plane_Align,
182:Line_Mirror(0),
183:Line_AlignCeiling(2),
184:Line_AlignFloor(2),
185:Sector_SetRotation(3),
186:Sector_SetCeilingPanning(5),
187:Sector_SetFloorPanning(5),
188:Sector_SetCeilingScale(5),
189:Sector_SetFloorScale(5),
191:SetPlayerProperty(3),
192:Ceiling_LowerToHighestFloor(2),
193:Ceiling_LowerInstant(3),
194:Ceiling_RaiseInstant(3),
195:Ceiling_CrushRaiseAndStayA(4),
196:Ceiling_CrushAndRaiseA(4),
197:Ceiling_CrushAndRaiseSilentA(4),
198:Ceiling_RaiseByValueTimes8(3),
199:Ceiling_LowerByValueTimes8(3),
200:Generic_Floor(5),
201:Generic_Ceiling(5),
202:Generic_Door(5),
203:Generic_Lift(5),
204:Generic_Stairs(5),
205:Generic_Crusher(5),
206:Plat_DownWaitUpStayLip(4,5),
207:Plat_PerpetualRaiseLip(4),
208:TranslucentLine(2,3),
// 209:Transfer_Heights,
// 210:Transfer_FloorLight,
// 211:Transfer_CeilingLight,
212:Sector_SetColor(4,5),
213:Sector_SetFade(4),
214:Sector_SetDamage(3),
215:Teleport_Line(2),
216:Sector_SetGravity(3),
217:Stairs_BuildUpDoom(5),
218:Sector_SetWind(4),
// 219:Sector_SetFriction(4),
220:Sector_SetCurrent(4),
221:Scroll_Texture_Both(5),
// 222:Scroll_Texture_Model,
223:Scroll_Floor(4),
224:Scroll_Ceiling(4),
// 225:Scroll_Texture_Offsets,
226:ACS_ExecuteAlways(2,5),
// 227:PointPush_SetForce,
228:Plat_RaiseAndStayTx0(2),
229:Thing_SetGoal(3),
230:Plat_UpByValueStayTx(3),
231:Plat_ToggleCeiling(1),
232:Light_StrobeDoom(3),
233:Light_MinNeighbor(1),
234:Light_MaxNeighbor(1),
235:Floor_TransferTrigger(1),
236:Floor_TransferNumeric(1),
237:ChangeCamera(3),
238:Floor_RaiseToLowestCeiling(2),
239:Floor_RaiseByValueTxTy(3),
240:Floor_RaiseByTexture(2),
241:Floor_LowerToLowestTxTy(2),
242:Floor_LowerToHighest(3),
243:Exit_Normal(1),
244:Exit_Secret(1),
245:Elevator_RaiseToNearest(2),
246:Elevator_MoveToFloor(2),
247:Elevator_LowerToNearest(2),
248:HealThing(1,2),
249:Door_CloseWaitOpen(3),
250:Floor_Donut(3),
251:FloorAndCeiling_LowerRaise(3),
252:Ceiling_RaiseToNearest(2),
253:Ceiling_LowerToLowest(2),
254:Ceiling_LowerToFloor(2),
255:Ceiling_CrushRaiseAndStaySilA(4);

View file

@ -63,14 +63,20 @@ teaminfo.txt teaminfo.txt
althudcf.txt althudcf.txt
sbarinfo.txt sbarinfo.txt
========
# Doom map format translators
xlat/doom.txt xlat/doom.txt
xlat/heretic.txt xlat/heretic.txt
xlat/strife.txt xlat/strife.txt
xlat/defines.i xlat/defines.i
========
# Support lumps
dehsupp.lmp dehsupp.lmp
doomx.lmp xlat/doom.x
hereticx.lmp xlat/heretic.x
strifex.lmp xlat/strife.x
sectorx.txt sectorx.txt
animated.lmp animated.lmp

View file

@ -1,13 +1,15 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zdoom", "zdoom.vcproj", "{8049475B-5C87-46F9-9358-635218A4EF18}"
ProjectSection(ProjectDependencies) = postProject
{E83FD370-2E72-4D4C-9427-FF9D9DED1E88} = {E83FD370-2E72-4D4C-9427-FF9D9DED1E88}
{AC3F5340-40CB-4C3A-8AA7-CB7158DB4466} = {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}
{1D179D4B-F008-431B-8C72-111F8372584F} = {1D179D4B-F008-431B-8C72-111F8372584F}
{DA47396F-60C1-4BDE-A977-7F7DE461CF77} = {DA47396F-60C1-4BDE-A977-7F7DE461CF77}
{F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} = {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}
{0F80ACBF-460E-44F0-B28E-B3272D1774A7} = {0F80ACBF-460E-44F0-B28E-B3272D1774A7}
{667D2EE7-C357-49E2-9BAB-0A4A45F0F76E} = {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}
{6077B7D6-349F-4077-B552-3BC302EF5859} = {6077B7D6-349F-4077-B552-3BC302EF5859}
{F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} = {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}
{E83FD370-2E72-4D4C-9427-FF9D9DED1E88} = {E83FD370-2E72-4D4C-9427-FF9D9DED1E88}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib\zlib.vcproj", "{F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}"
@ -18,7 +20,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "re2c", "tools\re2c\re2c.vcp
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wadsrc", "wadsrc\wadsrc.vcproj", "{1D179D4B-F008-431B-8C72-111F8372584F}"
ProjectSection(ProjectDependencies) = postProject
{3FFA68B3-9449-4B03-ADEE-194C3638623B} = {3FFA68B3-9449-4B03-ADEE-194C3638623B}
{AC64EE8F-F019-4A3E-BCAF-BD1FD072B9C8} = {AC64EE8F-F019-4A3E-BCAF-BD1FD072B9C8}
{24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} = {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}
EndProjectSection
@ -28,8 +29,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "makewad", "tools\makewad\ma
{F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} = {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xlatcc", "tools\xlatcc\xlatcc.vcproj", "{3FFA68B3-9449-4B03-ADEE-194C3638623B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dehsupp", "tools\dehsupp\dehsupp.vcproj", "{AC64EE8F-F019-4A3E-BCAF-BD1FD072B9C8}"
ProjectSection(ProjectDependencies) = postProject
{667D2EE7-C357-49E2-9BAB-0A4A45F0F76E} = {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}
@ -100,14 +99,6 @@ Global
{24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Release|Win32.Build.0 = Release|Win32
{24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Release|x64.ActiveCfg = Debug|x64
{24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Release|x64.Build.0 = Debug|x64
{3FFA68B3-9449-4B03-ADEE-194C3638623B}.Debug|Win32.ActiveCfg = Debug|Win32
{3FFA68B3-9449-4B03-ADEE-194C3638623B}.Debug|Win32.Build.0 = Debug|Win32
{3FFA68B3-9449-4B03-ADEE-194C3638623B}.Debug|x64.ActiveCfg = Release|Win32
{3FFA68B3-9449-4B03-ADEE-194C3638623B}.Debug|x64.Build.0 = Release|Win32
{3FFA68B3-9449-4B03-ADEE-194C3638623B}.Release|Win32.ActiveCfg = Release|Win32
{3FFA68B3-9449-4B03-ADEE-194C3638623B}.Release|Win32.Build.0 = Release|Win32
{3FFA68B3-9449-4B03-ADEE-194C3638623B}.Release|x64.ActiveCfg = Release|Win32
{3FFA68B3-9449-4B03-ADEE-194C3638623B}.Release|x64.Build.0 = Release|Win32
{AC64EE8F-F019-4A3E-BCAF-BD1FD072B9C8}.Debug|Win32.ActiveCfg = Debug|Win32
{AC64EE8F-F019-4A3E-BCAF-BD1FD072B9C8}.Debug|Win32.Build.0 = Debug|Win32
{AC64EE8F-F019-4A3E-BCAF-BD1FD072B9C8}.Debug|x64.ActiveCfg = Release|Win32

View file

@ -6331,6 +6331,42 @@
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Xlat"
>
<File
RelativePath=".\src\xlat\parse_xlat.cpp"
>
</File>
<File
RelativePath=".\src\xlat\xlat.h"
>
</File>
<File
RelativePath=".\src\xlat\xlat_parser.y"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Processing grammar file"
CommandLine="tools\lemon\lemon.exe -s &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="$(InputDir)xlat_parser.c;$(InputDir)xlat_parser.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Processing grammar file"
CommandLine="tools\lemon\lemon.exe -s &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="$(InputDir)xlat_parser.c;$(InputDir)xlat_parser.h"
/>
</FileConfiguration>
</File>
</Filter>
</Files>
<Globals>
</Globals>