Native iPhone port of Factorio 2.0.77

Run the original macOS ARM64 game code on iOS:
- tools/retarget.py: header-only Mach-O retargeting to an iOS dylib
- platform/native: UIKit host and macOS API shims (AppKit for SDL's
  Cocoa backend, CoreGraphics displays, CoreAudio device, Metal device
  properties, Wuffs PNG decoding, Steam and peripheral stubs)
- touch, overlay, iOS keyboard and hardware keyboard input
- tools/build_native.py: build, sign, install, data copy, launch
- docs: build guide, controls, architecture

Also includes the earlier static-translation research (ARM64 -> WASM ->
native) under docs/research, runtime/, tests/ and tools/.

No game files are included; the build reads them from a local install.
This commit is contained in:
SashaGoncharov19 committed 2026-10-23 15:27:58 +04:00
commit 51d085e865
89 files changed
+7999

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
#include "guest_heap.h"
#include <limits.h>
int factorio_guest_heap_init(FactorioGuestHeap *heap, uint8_t *memory,
uint64_t memory_size, uint64_t begin, uint64_t end) {
if (!heap || !memory || !begin || begin > end || end > memory_size ||
memory_size > SIZE_MAX || begin % 16) return 2;
*heap = (FactorioGuestHeap){memory, memory_size, begin, begin, end, 0};
return 0;
}
int factorio_guest_heap_allocate(FactorioGuestHeap *heap, uint64_t size, uint64_t *out) {
if (!heap || !out || !heap->memory || !heap->begin || heap->begin % 16 ||
heap->cursor < heap->begin || heap->cursor > heap->end ||
heap->end > heap->memory_size || heap->memory_size > SIZE_MAX ||
heap->allocations == UINT_MAX) return 2;
uint64_t padding = (16 - heap->cursor % 16) % 16;
if (padding > heap->end - heap->cursor) return 1;
uint64_t address = heap->cursor + padding;
if (!size) size = 1; /* operator new(0) still returns a distinct allocation. */
if (size > heap->end - address) return 1;
heap->cursor = address + size;
++heap->allocations;
*out = address;
return 0;
}