Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match Chain 100% #320

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions src/Chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ ChainElem::ChainElem()
deletedCallback = NULL;
priority = 0;

// MISMATCH: An extra XOR is present for no apparent reason (TODO figure this out)
// xor eax, eax
// mov ax, word ptr [edx + 2]
// and al, 0xfe
// mov ecx, dword ptr [ebp - 4]
flags &= CHAIN_ELEM_FLAG_MASK;
isHeapAllocated = false;
}

ChainElem::~ChainElem()
Expand All @@ -49,12 +44,7 @@ ChainElem *Chain::CreateElem(ChainCallback callback)
elem->addedCallback = NULL;
elem->deletedCallback = NULL;

// MISMATCH: An extra XOR is present for no apparent reason and ecx is used instead of cl (TODO figure this out)
// xor ecx, ecx
// mov cx, word ptr [eax + 2]
// or ecx, 1
// mov edx, dword ptr [ebp - 0x10]
elem->flags |= CHAIN_ELEM_FLAG_HEAP_ALLOCATED;
elem->isHeapAllocated = true;

return elem;
}
Expand Down Expand Up @@ -170,13 +160,7 @@ void Chain::Cut(ChainElem *to_remove)
to_remove->prev = NULL;
to_remove->next = NULL;

// MISMATCH: An extra XOR is present for no apparent reason and edx is used instead of dx (TODO figure this out)
// xor edx, edx
// mov dx, word ptr [ecx + 2]
// and edx, 1
// and edx, 0xffff
// test edx, edx
if ((to_remove->flags & CHAIN_ELEM_FLAG_HEAP_ALLOCATED & 0xffff) != 0)
if (to_remove->isHeapAllocated)
{
delete to_remove;
to_remove = NULL;
Expand Down
8 changes: 2 additions & 6 deletions src/Chain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@

#include "ZunResult.hpp"
#include "diffbuild.hpp"
#include "inttypes.hpp"

#include <Windows.h>

namespace th06
{
enum ChainElemFlag
{
CHAIN_ELEM_FLAG_HEAP_ALLOCATED = (unsigned char)1,
CHAIN_ELEM_FLAG_MASK = ~(unsigned char)CHAIN_ELEM_FLAG_HEAP_ALLOCATED,
};

enum ChainCallbackResult
{
Expand All @@ -33,7 +29,7 @@ class ChainElem
{
public:
short priority;
unsigned short flags;
u16 isHeapAllocated : 1;
ChainCallback callback;
ChainAddedCallback addedCallback;
ChainDeletedCallback deletedCallback;
Expand Down
Loading