dsda: fix reading OUT OF BOUNDS of mobj_t
This commit is contained in:
parent
f2ccc9af90
commit
8b43c98657
Binary file not shown.
|
@ -5,11 +5,9 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
{
|
||||
public partial class DSDA : IVideoProvider
|
||||
{
|
||||
private int[] _palBuffer = [ ];
|
||||
private int[] _vidBuff = [ ];
|
||||
public int VirtualWidth => BufferWidth;
|
||||
public int VirtualHeight { get; private set; }
|
||||
public int PaletteSize { get; private set; }
|
||||
public int BufferWidth { get; private set; }
|
||||
public int BufferHeight { get; private set; }
|
||||
public int BackgroundColor => unchecked((int)0xff000000);
|
||||
|
@ -23,16 +21,16 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
{
|
||||
_core.dsda_get_video(gamma, out var vi);
|
||||
|
||||
int[] _palBuffer = [ ];
|
||||
var videoBuffer = (byte*)vi.VideoBuffer.ToPointer();
|
||||
var paletteBuffer = (int*)vi.PaletteBuffer.ToPointer();
|
||||
PaletteSize = vi.PaletteSize;
|
||||
BufferWidth = vi.Width;
|
||||
BufferHeight = vi.Height;
|
||||
|
||||
// Handling pallette buffer
|
||||
if (_palBuffer.Length < PaletteSize)
|
||||
if (_palBuffer.Length < vi.PaletteSize)
|
||||
{
|
||||
_palBuffer = new int[PaletteSize];
|
||||
_palBuffer = new int[vi.PaletteSize];
|
||||
}
|
||||
for (var i = 0; i < _palBuffer.Length; i++)
|
||||
{
|
||||
|
|
|
@ -372,7 +372,6 @@ ECL_EXPORT int dsda_init(struct InitSettings *settings, int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
ECL_EXPORT int dsda_add_wad_file(const char *filename, const int size, ECL_ENTRY int (*feload_archive_cb)(const char *filename, uint8_t *buffer, int maxsize))
|
||||
{
|
||||
printf("Loading WAD '%s' of size %d...\n", filename, size);
|
||||
|
@ -457,19 +456,18 @@ ECL_EXPORT int dsda_add_wad_file(const char *filename, const int size, ECL_ENTRY
|
|||
// TODO: expose sectors and linedefs like xdre does (but better)
|
||||
ECL_EXPORT char dsda_read_memory_array(int type, uint32_t addr)
|
||||
{
|
||||
char out_of_bounts = 0xFF;
|
||||
char null_thing = 0x88;
|
||||
int padded_size = 512; // sizeof(mobj_t) is 464 but we pad for nice representation
|
||||
if (type != ARRAY_THINGS)
|
||||
return MEMORY_OUT_OF_BOUNDS;
|
||||
|
||||
if (addr >= numthings * padded_size)
|
||||
return out_of_bounts;
|
||||
if (addr >= numthings * MEMORY_PADDED_THING)
|
||||
return MEMORY_OUT_OF_BOUNDS;
|
||||
|
||||
int index = addr / padded_size;
|
||||
int offset = addr % padded_size;
|
||||
int index = addr / MEMORY_PADDED_THING;
|
||||
int offset = addr % MEMORY_PADDED_THING;
|
||||
mobj_t *mobj = mobj_ptrs[index];
|
||||
|
||||
if (mobj == NULL)
|
||||
return null_thing;
|
||||
if (mobj == NULL || offset >= sizeof(mobj_t))
|
||||
return MEMORY_NULL;
|
||||
|
||||
char *data = (char *)mobj + offset;
|
||||
return *data;
|
||||
|
|
|
@ -19,19 +19,27 @@
|
|||
#include "dsda/messenger.h"
|
||||
#include "dsda/settings.h"
|
||||
|
||||
#define SLOWTURNTICS 6
|
||||
#define MEMORY_PADDED_THING 0x200 // sizeof(mobj_t) is 464 but we pad for nice representation
|
||||
#define MEMORY_OUT_OF_BOUNDS 0xFF
|
||||
#define MEMORY_NULL 0x88
|
||||
|
||||
#ifdef PALETTE_SIZE
|
||||
#undef PALETTE_SIZE
|
||||
#endif
|
||||
#define PALETTE_SIZE 256
|
||||
|
||||
extern int headlessMain(int argc, char **argv);
|
||||
extern void headlessRunSingleTick();
|
||||
extern void headlessClearTickCommand();
|
||||
extern void headlessSetTickCommand(int playerId, int forwardSpeed, int strafingSpeed, int turningSpeed, int fire, int action, int weapon, int automap, int lookfly, int artifact, int jump, int endPlayer);
|
||||
extern void headlessGetMapName(char *outString);
|
||||
extern void headlessSetSaveStatePointer(void *savePtr, int saveStateSize);
|
||||
extern size_t headlessGetEffectiveSaveSize();
|
||||
extern unsigned int rngseed;
|
||||
|
||||
extern dboolean InventoryMoveLeft();
|
||||
extern dboolean InventoryMoveRight();
|
||||
extern int numthings;
|
||||
extern mobj_t **mobj_ptrs;
|
||||
extern dsda_arg_t arg_value[dsda_arg_count];
|
||||
//extern unsigned int rngseed;
|
||||
|
||||
// Video
|
||||
uint32_t _convertedPaletteBuffer[PALETTE_SIZE];
|
||||
extern void headlessUpdateVideo();
|
||||
extern void* headlessGetVideoBuffer();
|
||||
extern int headlessGetVideoPitch();
|
||||
|
@ -48,17 +56,16 @@ extern void headlessEnableAudioRendering();
|
|||
extern void headlessDisableAudioRendering();
|
||||
extern uint8_t *I_CaptureAudio (int *nsamples);
|
||||
|
||||
// Players information
|
||||
// Player information
|
||||
extern int enableOutput;
|
||||
extern int preventLevelExit;
|
||||
extern int preventGameEnd;
|
||||
extern int reachedLevelExit;
|
||||
extern int reachedGameEnd;
|
||||
extern int numthings;
|
||||
extern mobj_t **mobj_ptrs;
|
||||
extern dsda_arg_t arg_value[dsda_arg_count];
|
||||
extern int inv_ptr;
|
||||
extern dboolean inventory;
|
||||
extern dboolean InventoryMoveLeft();
|
||||
extern dboolean InventoryMoveRight();
|
||||
|
||||
// Automap
|
||||
extern void AM_addMark();
|
||||
|
@ -72,27 +79,18 @@ extern int automap_follow;
|
|||
extern int automap_grid;
|
||||
extern int markpointnum;
|
||||
extern int zoom_leveltime;
|
||||
extern int map_pan_speed;
|
||||
extern int map_scroll_speed;
|
||||
extern dboolean stop_zooming;
|
||||
extern mpoint_t m_paninc;
|
||||
extern fixed_t mtof_zoommul;
|
||||
extern fixed_t ftom_zoommul;
|
||||
extern fixed_t curr_mtof_zoommul;
|
||||
extern int map_pan_speed;
|
||||
extern int map_scroll_speed;
|
||||
extern fixed_t scale_mtof;
|
||||
extern fixed_t scale_ftom;
|
||||
#define FTOM(x) FixedMul(((x)<<16),scale_ftom)
|
||||
#define M_ZOOMIN ((int) ((float)FRACUNIT * (1.00f + map_scroll_speed / 200.0f)))
|
||||
#define M_ZOOMOUT ((int) ((float)FRACUNIT / (1.00f + map_scroll_speed / 200.0f)))
|
||||
|
||||
#ifdef PALETTE_SIZE
|
||||
#undef PALETTE_SIZE
|
||||
#endif
|
||||
#define PALETTE_SIZE 256
|
||||
uint32_t _convertedPaletteBuffer[PALETTE_SIZE];
|
||||
|
||||
#define SLOWTURNTICS 6
|
||||
|
||||
enum ExtraButtons
|
||||
{
|
||||
REGULAR_BUTTON_MASK = 0b0000000000000111,
|
||||
|
|
Loading…
Reference in New Issue