Skip to content

Commit

Permalink
Merge pull request #325 from Atari2/asar_19
Browse files Browse the repository at this point in the history
Fix resolvedefines not being loaded in the DLL and fix getwrittenblocks not working correctly when building statically
  • Loading branch information
randomdude999 authored Jul 31, 2024
2 parents 5edd93c + 3d48a4e commit 5e0cdba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/asar-dll-bindings/c/asardll.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ static bool asar_init_shared(void)
load(getlabelval);
load(getdefine);
load(getalldefines);
load(resolvedefines);
load(math);
load(getwrittenblocks);
load(getmapper);
Expand Down
5 changes: 4 additions & 1 deletion src/asar/interface-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,11 +493,14 @@ EXPORT const char * asar_getdefine(const char * name)
EXPORT const char * asar_resolvedefines(const char * data)
{
static string out;
out = "";
try
{
resolvedefines(out, data);
}
catch(errfatal&){}
catch(errfatal&){
out = "";
}
return out;
}

Expand Down
9 changes: 5 additions & 4 deletions src/asar/libsmw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ asar_error_id openromerror;
autoarray<writtenblockdata> writtenblocks;

// RPG Hacker: Uses binary search to find the insert position of our ROM write
#ifdef ASAR_SHARED
#if defined(ASAR_SHARED) || defined(ASAR_STATIC)
static int findromwritepos(int snesoffset, int searchstartpos, int searchendpos)
{
if (searchendpos == searchstartpos)
Expand All @@ -40,6 +40,7 @@ static int findromwritepos(int snesoffset, int searchstartpos, int searchendpos)

static void addromwriteforbank(int snesoffset, int numbytes)
{
if (numbytes == 0) return;
int currentbank = (snesoffset & 0xFF0000);

int insertpos = findromwritepos(snesoffset, 0, writtenblocks.count);
Expand Down Expand Up @@ -110,23 +111,23 @@ static void addromwrite(int pcoffset, int numbytes)
void writeromdata(int pcoffset, const void * indata, int numbytes)
{
memcpy(const_cast<unsigned char*>(romdata) + pcoffset, indata, (size_t)numbytes);
#ifdef ASAR_SHARED
#if defined(ASAR_SHARED) || defined(ASAR_STATIC)
addromwrite(pcoffset, numbytes);
#endif
}

void writeromdata_byte(int pcoffset, unsigned char indata)
{
memcpy(const_cast<unsigned char*>(romdata) + pcoffset, &indata, 1);
#ifdef ASAR_SHARED
#if defined(ASAR_SHARED) || defined(ASAR_STATIC)
addromwrite(pcoffset, 1);
#endif
}

void writeromdata_bytes(int pcoffset, unsigned char indata, int numbytes, bool add_write)
{
memset(const_cast<unsigned char*>(romdata) + pcoffset, indata, (size_t)numbytes);
#ifdef ASAR_SHARED
#if defined(ASAR_SHARED) || defined(ASAR_STATIC)
if(add_write)
addromwrite(pcoffset, numbytes);
#endif
Expand Down

0 comments on commit 5e0cdba

Please sign in to comment.