---------------------------------------------------------------------------------------------------
About this:
    This was an old file used early on during reverse engineering, which is no longer maintained.
    All of this address information pertains to the "Greatest Hits" edition of NTSC-U Doom.
---------------------------------------------------------------------------------------------------

The $gp register appears to be set to the following in main() and kept at that value:
    800775E0

Stack:
    - The end address ('00200000' or 2 MiB) is stored at '80077BF8'
    - The max stack size ('00008000' or 32 KiB) is stored at '80077BFC'
    - Therefore the minimium stack address (to hold a 64-bit value) is '1F7FF8'

Heap:
    - Initialized to a base address of '800A9EC4'
    - Size is set to '14E134' (1,368,372 bytes)
    - End of the heap is at '801F7FF8'

Zeroed globals memory region:
    - The loaded program ends at '80078000'.
    - The heap begins at '800A9EC4'.
    - Therefore there is a gap of '31EC4' (204,484 bytes)
    - Some globals appear to be stored in this region.
        - But they are not a part of the executable image itself.
    - main() appears to zero the memory for this area before initializing the heap and a little bit before that.

Sprite lumps in PC DOOM which are NOT in the PSX:
    VILE, FIRE, SSWV, KEEN, BBRN, BOSF

Sprite lumps in PSX DOOM which are NOT in the PC version:
    HANC, BLCH, HANL, DED1, DED2, DED3, DED4, DED5, DED6

Apparent structure sizes on PSX Doom (bytes):
    - player_t: 300
    - line_t: 76

To access an unused scrolling copyright notice, change the instruction at '80012334' from 'F9 48 00 0C' to 'E9 48 00 0C'. This appears to be similar to the copyright notice that is drawn by the initial 'SLUS_000.77' executable, but scrolling and with a shotgun sound played at the start. Was it used in the Demo verison perhaps?

Cheats quick ref:
    - Weapons, keys and ammo:   X, Triangle, L1, Up, Down, R2, Left, Left
    - Reveal automap:           Triangle, Triangle, L2, R2, L2, R2, R1, Square
    - God mode:                 Down, L2, Square, R1, Right, L1, Left, Circle
    - Warp:                     Right, Left, R2, R1, Triangle, L1, Circle, X
    - Show map objs:            Triangle, Triangle, L2, R2, L2, R2, R1, Circle
    - X-Ray vision:             L1, R2, L2, R1, Right, Triangle, X, Right

CD Map array:
    - Appears to be from 80074C04 - 800754D4 (exclusive).
    - Each entry consists of two words, one specifying the start CD sector of the file.
    - The other word specifies the size of the file.
    - This is used to read files on disk.

VRAM viewer:
    - Adding the flag 0x10 to player cheats flags @ 800A88AC will activate the VRAM viewer on the pause screen.

Texture cache:
    - The first 5 pages are reserved, 4 for the two 16-bit framebuffers, 1 for UI/text sprites.
    - 11 pages can be used by maps, textures, flats and sprites.
    - A certain number of those appear to be 'locked' and not unloadable during playthrough.
    - 256 cache entries are allowed for each page.

---------------------------------------------------------------------------------------------------
Data structures
---------------------------------------------------------------------------------------------------

mapthing_t (10 bytes):
    struct mapthing_t {
        000     int16_t     x;
        002     int16_t     y;
        004     uint16_t    angle;
        006     uint16_t    type;
        008     uint16_t    options;
    };

state_t (28 bytes):
    struct state_t {
        000     uint32_t    sprite;
        004     uint32_t    frame;
        008     uint32_t    tics;
        00C     actionf_t   action;
        010     uint32_t    nextstate;
        014     uint32_t    misc1;
        018     uint32_t    misc2;
    };

anim_t (24 bytes):
    struct anim_t {
        000     uint32_t    istexture;
        004     int32_t     picnum;
        008     int32_t     basepic;
        00C     int32_t     numpics;
        010     int32_t     current;
        014     uint32_t    ticmask;    // Determines how frequently anim updates (new field for PSX)
    };

stbar_t (52 bytes):
    struct stbar_t {
        000     u32         face;
        004     spclface_e  specialFace;
        008     u32         tryopen[NUMCARDS];  // (NUMCARDS=6)
        020     u32         gotgibbed;
        024     i32         gibframe;
        028     i32         gibframeTicsLeft;
        02C     char*       message;
        030     int         messageTicsLeft;
    };

mobjinfo_t (88 bytes):
    struct mobjinfo_t {
        000     int32_t     doomednum;
        004     int32_t     spawnstate;
        008     int32_t     spawnhealth;
        00C     uint32_t    seestate;
        010     uint32_t    seesound;
        014     int32_t     reactiontime;
        018     uint32_t    attacksound;
        01C     uint32_t    painstate;
        020     int32_t     painchance;
        024     uint32_t    painsound;
        028     uint32_t    meleestate;
        02C     uint32_t    missilestate;
        030     uint32_t    deathstate;
        034     uint32_t    xdeathstate;
        038     uint32_t    deathsound;
        03C     int32_t     speed;
        040     int32_t     radius;
        044     int32_t     height;
        048     int32_t     mass;
        04C     int32_t     damage;
        050     uint32_t    activesound;
        054     uint32_t    flags;
    };

mobj_t (148 bytes):
    struct mobj_t {
        000     fixed_t         x;
        004     fixed_t         y;
        008     fixed_t         z;
        00C     subsector_t*    subsector;
        010     mobj_t*         prev;           // Linked list of things
        014     mobj_t*         next;
        018     latecall_t      latecall;
        01C     mobj_t*         snext,          // Linked list of things in this sector
        020     mobj_t*         sprev;
        024     angle_t         angle;
        028     uint32_t        sprite;         // used to find patch_t and flip value
        02C     uint32_t        frame;          // might be ord with FF_FULLBRIGHT
        030     mobj_t*         bnext;          // Linked list of things in this blockmap block
        034     mobj_t*         bprev;          
        038     fixed_t         floorz;         // Closest together of contacted secs
        03C     fixed_t         ceilingz;       // Closest together of contacted secs
        040     fixed_t         radius;         // For movement checking
        044     fixed_t         height;         // For movement checking
        048     fixed_t         momx;           // Momentums
        04C     fixed_t         momy;
        050     fixed_t         momz;
        054     mobjtype_t      type;
        058     mobjinfo_t*     info;           // &mobjinfo[mobj->type]
        05C     int32_t         tics;           // State tic counter
        060     state_t*        state;
        064     uint32_t        flags;
        068     int32_t         health;
        06C     int32_t         movedir;        // 0-7
        070     int32_t         movecount;      // When 0, select a new dir
        074     mobj_t*         target;         // Thing being chased/attacked (or NULL)
        078     int32_t         reactiontime;   // If != 0, don't attack yet
        07C     int32_t         threshold;      // If > 0, the target will be chased
        080     player_t*       player;         // Only valid if type == MT_PLAYER
        084     uint32_t        extradata;      // For latecall functions
        088     int16_t         spawnx;
        08A     int16_t         spawny;
        08C     uint16_t        spawntype;
        08E     int16_t         spawnangle;
        090     mobj_t*         tracer;
    };

sector_t (92 bytes):
    struct sector_t {
        000     fixed_t     floorheight;
        004     fixed_t     ceilingheight;
        008     int32_t     floorpic;
        00C     int32_t     ceilingpic;
        010     int16_t     colorid;
        012     int16_t     lightlevel;
        014     int32_t     special;
        018     int32_t     tag;
        01C     int32_t     soundtraversed;
        020     mobj_t*     soundtarget;
        024     uint32_t    flags;
        028     int32_t     blockbox[4];

        // degenmobj_t
        struct {
            038     fixed_t         x;
            03C     fixed_t         y;
            040     fixed_t         z;
            044     subsector_t*    subsector;
        } soundorg;

        048     int32_t     validcount;
        04C     mobj_t*     thinglist;
        050     void*       specialdata;
        054     int32_t     linecount;
        058     line_t**    lines;
    };

subsector_t (16 bytes):
    struct subsector_t {
        000     sector_t*       sector;
        004     uint16_t        numsegs;
        006     uint16_t        firstseg;
        008     uint16_t        numLeafEdges;
        00A     uint16_t        firstLeafEdge;
        00C     ???             ???
    };

side_t (24 bytes):
    struct side_t {
        000     fixed_t     textureoffset;
        004     fixed_t     rowoffset;
        008     int32_t     toptexture;
        00C     int32_t     bottomtexture;
        010     int32_t     midtexture;
        014     sector_t*   sector;
    };

line_t (76 bytes):
    struct line_t {
        000     vertex_t*       v1;
        004     vertex_t*       v2;
        008     fixed_t         dx;             // Precomputed 'v2 - v1' in the x and y directions
        00C     fixed_t         dy;
        010     int32_t         flags;
        014     int32_t         special;
        018     int32_t         tag;
        01C     int32_t         sidenum[2];     // If sidenum[1] is '-1' then the line is one sided
        024     fixed_t         bbox[4];
        034     slopetype_t     slopetype;      // Used to simplify some collision detection
        038     sector_t*       frontsector;
        03C     sector_t*       backsector;
        040     int32_t         validcount;
        044     void*           specialdata;    // Used by thinkers doing special logic
        048     fixed_t         fineangle;      // So sine/cosine can be looked up quicker
    };

lumpinfo_t (16 bytes):
    struct lumpinfo_t {
        000     uint32_t    filepos;
        004     uint32_t    size;
        008     char        name[8];
    };

texture_t (32 bytes):
    struct texture_t {
        000     int16_t     offsetX;
        002     int16_t     offsetY;
        004     uint16_t    width;
        006     uint16_t    height;
        008     uint8_t     texPageCoordX;
        009     uint8_t     texPageCoordY;
        00A     uint16_t    texPageId;
        00C     uint16_t    width16;
        00E     uint16_t    height16;
        010     uint16_t    lumpNum;
        012     uint16_t    __padding ?
        014     texture_t** ppTexCacheEntries;
        018     uint32_t    unknown1;
        01C     uint32_t    uploadFrameNum;
    };

pspdef_t (16 bytes):
    struct pspdef_t {
        000     state_t*    state;
        004     int32_t     tics;
        008     fixed_t     sx;
        00C     fixed_t     sy;
    };

player_t (300 bytes):
    struct player_t {
        000     mobj_t*         mo;
        004     playerstate_t   playerstate;
        008     fixed_t         forwardmove;
        00C     fixed_t         sidemove;
        010     angle_t         angleturn;
        014     fixed_t         viewz;
        018     fixed_t         viewheight;
        01C     fixed_t         deltaviewheight;
        020     fixed_t         bob;
        024     uint32_t        health;
        028     uint32_t        armorpoints;
        02C     uint32_t        armortype;        
        030     int32_t         powers[NUMPOWERS = 6];
        048     bool32          cards[NUMCARDS = 6];
        060     bool32          backpack;
        064     uint32_t        frags;
        068     uint32_t        __padding;
        06C     weapontype_t    readyweapon;
        070     weapontype_t    pendingweapon;
        074     bool32          weaponowned[NUMWEAPONS = 9];
        098     int32_t         ammo[NUMAMMO = 4];
        0A8     int32_t         maxammo[NUMAMMO = 4];
        0B8     uint32_t        attackdown;
        0BC     uint32_t        usedown;
        0C0     uint32_t        cheats;
        0C4     uint32_t        refire;
        0C8     uint32_t        killcount;
        0CC     uint32_t        itemcount;
        0D0     uint32_t        secretcount;
        0D4     char*           message;
        0D8     uint32_t        damagecount;
        0DC     uint32_t        bonuscount;
        0E0     mobj_t*         attacker;
        0E4     uint32_t        extralight;
        0E8     uint32_t        fixedcolormap;
        0EC     uint32_t        colormap;
        0F0     pspdef_t        psprites[NUMPSPRITES = 2];
        110     bool32          didsecret;
        114     void*           lastsoundsector;
        118     int32_t         automapx;
        11C     int32_t         automapy;
        120     uint32_t        automapscale;
        124     uint32_t        automapflags;
        128     uint32_t        turnheld;
    };

memblock_t (24 bytes):
    struct memblock_t {
        000     int32_t         size;
        004     void*           user;
        008     int16_t         tag;
        00A     int16_t         id;
        00C     int32_t         lockframe;
        010     memblock_t*     next;
        014     memblock_t*     prev;
    };

memzone_t (32 bytes):
    struct memzone_t {
        000     int32_t         size;
        004     memblock_t*     rover;
        008     memblock_t      blocklist;
    };

node_t (56 bytes):
    struct node_t {
        000     fixed_t     x;                  // The partition line
        004     fixed_t     y;
        008     fixed_t     dx;
        00C     fixed_t     dy;
        010     fixed_t     bbox[2][4];         // Bounding box for both child nodes
        030     int32_t     children[2];        // When 'NF_SUBSECTOR' is set then it means it's a subsector number
    };

seg_t (40 bytes):
    struct seg_t {
        000     vertex_t*   vertex1;
        004     vertex_t*   vertex2;
        008     fixed_t     offset;
        00C     angle_t     angle;
        010     side_t*     sidedef;
        014     line_t*     linedef;
        018     sector_t*   frontsector;
        01C     sector_t*   backsector;
        020     uint16_t    flags;
        022     uint16_t    begScreenX;
        024     uint16_t    endScreenX;
        026     uint16_t    pad;
    };

vertex_t (28 bytes): 
    struct vertex_t {
        000     fixed_t     x;
        004     fixed_t     y;
        008     int32_t     scale;
        00C     int32_t     viewx;
        010     int32_t     viewy;
        014     int32_t     screenx;
        018     int32_t     frameUpdated;
    };
