Skip to content

Add 64-bit support#11

Open
jncronin wants to merge 10 commits intoerysdren:mainfrom
jncronin:64bitclean
Open

Add 64-bit support#11
jncronin wants to merge 10 commits intoerysdren:mainfrom
jncronin:64bitclean

Conversation

@jncronin
Copy link
Contributor

@jncronin jncronin commented Feb 1, 2026

This PR adds 64-bit support to quakegeneric. It has been tested on x86_64 (under WSL2) and aarch64 (custom OS on custom device). At least the first few levels are playable without errors and I suspect the rest is too.

The main change is around dynamically allocating several variables which were previously statically defined, to ensure that the pointer differences between them is small and consistently positive. The rationale is described in quakegeneric.c pasted below:

Quake uses eval_t members to point to the string table. For compatibility with loading
from disk these pointers are 4 bytes.

The string table is allocated on the heap.  The pointers can come from the
heap itself as well as the sv.world_view member, the mod_known array and
the pr_string_temp buffer.

For 32-bits the offset pointers will always be 32-bit, and can be positive or
negative as the address space will wraparound.

For 64-bits, however, we need the offsets to be within 2 GiB and positive else
they will point to an invalid address.

We therefore dynamically allocate sv, mod_known and pr_string_temp to ensure
that they are close together, and in the correct order

This leads to slightly unclean code in that we need to be able to access mod_known and pr_string_temp from quakegeneric.c to update them, but it seems to work for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant