Skip to content

[Feature Request] Handle negative Add Address offsets using Remember/Recall (or simply source modification for appropriate platforms), if available #617

@Souzooka

Description

@Souzooka

Problem:
When/if raintegration supports 64-bit values in achievement logic, achievements using negative offsets (which rely on integer overflow) will cease to work. This is because if someone uses a 0xFFFFFFC0 offset on a pointer to 0x1000, the resulting address becomes 0x9C0 with a 32-bit accumulator, but 0x1000009C0 with a 64-bit accumulator.

Solution:
While in 99.99% of scenarios a developer using a negative offset is using an incorrect pointer for their data, the 64-bit issue can still be mitigated for those doing so with RATools.

While currently RATools will output code such as:

Add Address mem 32-bit 0xCAFE     & value 0x1FFFFFF
            mem 32-bit 0xFFFFFFC0 = value 0xBAD

as an alternative when RATools sees that an offset >= 0x80000000 is being used, it can construct logic such as:

Remember    mem    32-bit 0xCAFE     & value 0x1FFFFFF
Add Address recall                   - value 0x40
            mem    32-bit 0x0        = value 0xBAD

For platforms which require no transformation of the pointer (via source modification) to comply with RA's custom virtual maps, simple source modification can be used:

Add Address mem    32-bit 0xCAFE     - value 0x40
            mem    32-bit 0x0        = value 0xBAD

While, to reiterate, developers should not be using negative offsets, this should reduce the technical debt created when this occurs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions