typedef signed char  FLAG;   /* 8-bit signed quantity (replaces BOOL) */
typedef signed char  SBYTE;  /* 8-bit signed quantity (replaces Amiga BYTE) */
typedef signed short SWORD;  /* 16-bit signed quantity (replaces Amiga WORD) */
typedef signed long  SLONG;  /* 32-bit signed quantity (same as LONG) */
#define elif         else if
#define AGLOBAL      ;       /* global (project-scope) */
#define MODULE       static  /* external static (file-scope) */
#define PERSIST      static  /* internal static (function-scope) */
#define AUTO         auto    /* automatic (function-scope) */

#define COUNTERWIDTH   2 // in words (24 pixels, rounded up)
#define COUNTERHEIGHT 24 // in pixels
#define DEPTH          7 // in bitplanes
#define CONNECTIONS    7

// types of things
#define HERO       0
#define JARL       1
#define MONSTER    2
#define TREASURE   3
#define SORD       4
#define KINGDOM    5

#define HEROES     5
#define JARLS     17
#define MONSTERS  26
#define SORDS      5
#define TREASURES  3

#define FACEUP     0
#define FACEDOWN   1

#define SLOTS      (HEROES + 1 + JARLS + 1 + MONSTERS + 1 + TREASURES + 1 + SORDS + 1 - 1)
#define ATTACKS    (HEROES + 1 + JARLS + 1 + MONSTERS + 1 + 36)

AGLOBAL struct WorldStruct
{   // initialized

    SLONG  centrex, centrey, tax, type;
    STRPTR name;
    SLONG  connection[CONNECTIONS + 1];

    // uninitialized
    SLONG  hero;
    FLAG   is, visited, slot[SLOTS + 1];
};
AGLOBAL struct HeroStruct
{   // all uninitialized

    STRPTR name;
    SLONG  strength, moves, glory, luck, control, sword, where, homewhere,
           wealth, slot, promoted, rune, god, sea, maidens;
    FLAG   alive, verydead, wounded, foundbob, moved, loseturn, hagall,
           routed;
    SLONG  attacked[ATTACKS + 1], attacktype[ATTACKS + 1];
};
AGLOBAL struct JarlStruct
{   // initialized
    SLONG  strength,
           moves;
    STRPTR name;

    // uninitialized
    FLAG   taken, alive, foundbob, recruitable, loseturn, hagall, routed;
    SLONG  where, homewhere, face, hero, slot, sea,
           attacked[ATTACKS + 1], attacktype[ATTACKS + 1];
};
AGLOBAL struct MonsterStruct
{   // initialized
    SLONG  species, strength, moves;
    STRPTR name;

    // uninitialized
    FLAG   taken, alive, foundbob, loseturn, hagall;
    SLONG  where, slot, wealth, sea;
};
AGLOBAL struct TreasureStruct
{   // initialized
    STRPTR name;

    // uninitialized
    SLONG  possessor, possessortype;
    FLAG   taken, foundbob;
    SLONG  where, slot;
};
AGLOBAL struct SordStruct
{   // initialized
    STRPTR name;

    // uninitialized
    SLONG  possessor, possessortype;
    FLAG   taken, foundbob;
    SLONG  where, slot;
};

// from saga.c
AGLOBAL void cleanexit(SLONG rc);

// from map.c
AGLOBAL void drawmap(void);

// from map2.c
AGLOBAL void drawmap2(void);

// from counters.c
AGLOBAL void init_counters(void);
AGLOBAL void move_hero(SLONG whichhero, FLAG display);
AGLOBAL void move_jarl(SLONG whichjarl, FLAG display);
AGLOBAL void move_monster(SLONG whichmonster, FLAG display);
AGLOBAL void move_treasure(SLONG whichtreasure, FLAG display);
AGLOBAL void move_sord(SLONG whichsord, FLAG display);
AGLOBAL void createcounters(void);
AGLOBAL void destroycounters(void);
AGLOBAL void revealjarl(SLONG whichjarl, FLAG display);
AGLOBAL void hidejarl(SLONG whichjarl, FLAG display);
AGLOBAL void unslot_hero(SLONG whichhero);
AGLOBAL void unslot_jarl(SLONG whichjarl);
AGLOBAL void unslot_monster(SLONG whichmonster);
AGLOBAL void unslot_treasure(SLONG whichtreasure);
AGLOBAL void unslot_sord(SLONG whichsord);
AGLOBAL SLONG checkcounters(SWORD mousex, SWORD mousey, SLONG* countertype);
AGLOBAL void select_hero(SLONG whichhero);
AGLOBAL void deselect_hero(SLONG whichhero, FLAG display);
AGLOBAL void select_jarl(SLONG whichjarl);
AGLOBAL void deselect_jarl(SLONG whichjarl);
AGLOBAL void remove_hero(SLONG whichhero, FLAG display);
AGLOBAL void remove_jarl(SLONG whichjarl, FLAG display);
AGLOBAL void remove_monster(SLONG whichmonster, FLAG display);
AGLOBAL void remove_treasure(SLONG whichtreasure, FLAG display);
AGLOBAL void remove_sord(SLONG whichsord, FLAG display);
AGLOBAL void refreshcounters(void);
AGLOBAL void reset_images(void);
AGLOBAL void hero_to_jarl(SLONG whichhero, SLONG whichjarl);
