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:
commit
51d085e865
89 files changed
+7999
No files matched your search
@@ -0,0 +1,37 @@
|
||||
#include "save_layout.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct {
|
||||
const uint8_t *bytes;
|
||||
size_t length,cursor;
|
||||
uint64_t version[2];
|
||||
unsigned reads;
|
||||
} NativeReader;
|
||||
extern void *factorio_map_header_original(void *,NativeReader *);
|
||||
void native_map_header_read(NativeReader *r,void *out,size_t size) {
|
||||
assert(size==8 && r->reads<3 && r->cursor+size<=r->length);
|
||||
memcpy(out,r->bytes+r->cursor,size);r->cursor+=size;++r->reads;
|
||||
}
|
||||
int main(int argc,char **argv) {
|
||||
if(argc!=2) return 2;
|
||||
FactorioSaveLayout layout;
|
||||
assert(factorio_save_map_header(argv[1],&layout)==0);
|
||||
uint8_t *prefix=malloc(layout.next_offset);assert(prefix);
|
||||
assert(factorio_save_prefix(argv[1],prefix,layout.next_offset)==0);
|
||||
FactorioMapVersion v=layout.header.version;
|
||||
NativeReader reader={.bytes=prefix,.length=layout.next_offset,.cursor=layout.header_offset,
|
||||
.version={(uint64_t)v.major<<48|(uint64_t)v.minor<<32|(uint64_t)v.patch<<16|v.build,v.flag}};
|
||||
uint8_t native[48];memset(native,0xa5,sizeof(native));
|
||||
assert(factorio_map_header_original(native,&reader)==native);
|
||||
assert(reader.reads==3 && reader.cursor==layout.next_offset);
|
||||
assert(memcmp(native+16,layout.header.tick_fields,24)==0);
|
||||
for(unsigned i=40;i<48;++i) assert(native[i]==0xa5);
|
||||
free(prefix);
|
||||
printf("{\"status\":\"pass\",\"header_offset\":%zu,\"native_reads\":%u,"
|
||||
"\"constructor_values_match\":true,\"offset_authority\":\"recovered metadata layout; not full-engine execution\"}\n",
|
||||
layout.header_offset,reader.reads);
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user