Exemplo n.º 1
0
void InitTracers(void)
{
  int i, p;
  long value, count;

  traceslistinit_t traces_init[NUMTRACES] = {
    {"-trace_thingshealth", "health ", TracerApply, NULL},
    {"-trace_thingspickup", "pickup ", TracerApply, NULL},
    {"-trace_linescross"  , "lcross ", TracerApply, NULL},
    {"-trace_givendamage" , "damage ", GivenDamageApply, GivenDamageReset},
  };

  traces_present = false;

  for (i = 0; i < NUMTRACES; i++)
  {
    strcpy(traces[i].cmd, traces_init[i].cmd);
    strcpy(traces[i].prefix, traces_init[i].prefix);
    traces[i].ApplyFunc = traces_init[i].ApplyFunc;
    traces[i].ResetFunc = traces_init[i].ResetFunc;

    count = 0;
    traces[i].count = 0;
    if ((p = M_CheckParm(traces[i].cmd)) && (p < myargc - 1))
    {
      while (count < 3 && p + count < myargc - 1 && M_StrToInt(myargv[p + 1 + count], &value))
      {
        sprintf(traces[i].items[count].value, "\x1b\x36%ld\x1b\x33 0", value);
        traces[i].items[count].index = value;

        if (traces[i].ApplyFunc)
          traces[i].ApplyFunc(i);

        traces_present = true;
        count++;
      }
      traces[i].count = count;
    }
  }
}
Exemplo n.º 2
0
boolean I_GetMemoryValue(uint32_t offset, void *value, int32_t size)
{
    static boolean    firsttime = true;

    if (firsttime)
    {
        uint32_t    p, i, val;

        firsttime = false;
        i = 0;

        //!
        // @category compat
        // @arg <version>
        //
        // Specify DOS version to emulate for NULL pointer dereference
        // emulation.  Supported versions are: dos622, dos71, dosbox.
        // The default is to emulate DOS 7.1 (Windows 98).
        //

        p = M_CheckParmWithArgs("-setmem", 1);

        if (p > 0)
        {
            if (!strcasecmp(myargv[p + 1], "dos622"))
            {
                dos_mem_dump = mem_dump_dos622;
            }
            if (!strcasecmp(myargv[p + 1], "dos71"))
            {
                dos_mem_dump = mem_dump_win98;
            }
            else if (!strcasecmp(myargv[p + 1], "dosbox"))
            {
                dos_mem_dump = mem_dump_dosbox;
            }
            else
            {
                for (i=0; i<DOS_MEM_DUMP_SIZE; ++i)
                {
                    ++p;

                    if (p >= myargc || myargv[p][0] == '-')
                    {
                        break;
                    }

                    M_StrToInt(myargv[p], &val);
                    mem_dump_custom[i++] = (unsigned char)val;
                }

                dos_mem_dump = mem_dump_custom;
            }
        }
    }

    switch (size)
    {
        case 1:
            *((unsigned char *)value) = dos_mem_dump[offset];
            return true;

        case 2:
            *((uint16_t *)value) = dos_mem_dump[offset]
                                 | (dos_mem_dump[offset + 1] << 8);
            return true;

        case 4:
            *((uint32_t *)value) = dos_mem_dump[offset]
                                 | (dos_mem_dump[offset + 1] << 8)
                                 | (dos_mem_dump[offset + 2] << 16)
                                 | (dos_mem_dump[offset + 3] << 24);
            return true;
    }

    return false;
}
Exemplo n.º 3
0
static void DonutOverrun(fixed_t *s3_floorheight, short *s3_floorpic,
                         line_t *line, sector_t *pillar_sector)
{
    static int first = 1;
    static int tmp_s3_floorheight;
    static int tmp_s3_floorpic;

    extern int numflats;

    if (first)
    {
        int p;

        // This is the first time we have had an overrun.
        first = 0;

        // Default values
        tmp_s3_floorheight = DONUT_FLOORHEIGHT_DEFAULT;
        tmp_s3_floorpic = DONUT_FLOORPIC_DEFAULT;

        //!
        // @category compat
        // @arg <x> <y>
        //
        // Use the specified magic values when emulating behavior caused
        // by memory overruns from improperly constructed donuts.
        // In Vanilla Doom this can differ depending on the operating
        // system.  The default (if this option is not specified) is to
        // emulate the behavior when running under Windows 98.

        p = M_CheckParmWithArgs("-donut", 2);

        if (p > 0)
        {
            // Dump of needed memory: (fixed_t)0000:0000 and (short)0000:0008
            //
            // C:\>debug
            // -d 0:0
            //
            // DOS 6.22:
            // 0000:0000    (57 92 19 00) F4 06 70 00-(16 00)
            // DOS 7.1:
            // 0000:0000    (9E 0F C9 00) 65 04 70 00-(16 00)
            // Win98:
            // 0000:0000    (00 00 00 00) 65 04 70 00-(16 00)
            // DOSBox under XP:
            // 0000:0000    (00 00 00 F1) ?? ?? ?? 00-(07 00)

            M_StrToInt(myargv[p + 1], &tmp_s3_floorheight);
            M_StrToInt(myargv[p + 2], &tmp_s3_floorpic);

            if (tmp_s3_floorpic >= numflats)
            {
                fprintf(stderr,
                        "DonutOverrun: The second parameter for \"-donut\" "
                        "switch should be greater than 0 and less than number "
                        "of flats (%d). Using default value (%d) instead. \n",
                        numflats, DONUT_FLOORPIC_DEFAULT);
                tmp_s3_floorpic = DONUT_FLOORPIC_DEFAULT;
            }
        }
    }

    /*
    fprintf(stderr,
            "Linedef: %d; Sector: %d; "
            "New floor height: %d; New floor pic: %d\n",
            line->iLineID, pillar_sector->iSectorID,
            tmp_s3_floorheight >> 16, tmp_s3_floorpic);
     */

    *s3_floorheight = (fixed_t) tmp_s3_floorheight;
    *s3_floorpic = (short) tmp_s3_floorpic;
}