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.
36 lines
2.2 KiB
Objective-C
36 lines
2.2 KiB
Objective-C
// Builds the 1024x1024 iOS app icon from the game's own 128 px icon (read from the local install).
|
|
// The gear is scaled with high-quality interpolation onto an opaque dark background
|
|
// (iOS app icons must be opaque).
|
|
// Usage: make_icon SOURCE_PNG OUTPUT_PNG
|
|
#import <Foundation/Foundation.h>
|
|
#import <CoreGraphics/CoreGraphics.h>
|
|
#import <ImageIO/ImageIO.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
@autoreleasepool {
|
|
if (argc != 3) { fprintf(stderr, "usage: make_icon SOURCE_PNG OUTPUT_PNG\n"); return 2; }
|
|
CGImageSourceRef src = CGImageSourceCreateWithURL((__bridge CFURLRef)[NSURL fileURLWithPath:@(argv[1])], NULL);
|
|
CGImageRef gear = src ? CGImageSourceCreateImageAtIndex(src, 0, NULL) : NULL;
|
|
if (!gear) { fprintf(stderr, "cannot read %s\n", argv[1]); return 1; }
|
|
const size_t size = 1024;
|
|
CGColorSpaceRef rgb = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
|
|
CGContextRef ctx = CGBitmapContextCreate(NULL, size, size, 8, 0, rgb, (CGBitmapInfo)kCGImageAlphaNoneSkipLast);
|
|
// Dark warm gradient, close to Factorio's menu backdrop.
|
|
CGFloat stops[] = {0.20, 0.17, 0.14, 1, 0.07, 0.06, 0.05, 1};
|
|
CGGradientRef gradient = CGGradientCreateWithColorComponents(rgb, stops, NULL, 2);
|
|
CGContextDrawRadialGradient(ctx, gradient, CGPointMake(size / 2.0, size * 0.55), 0,
|
|
CGPointMake(size / 2.0, size / 2.0), size * 0.75, kCGGradientDrawsAfterEndLocation);
|
|
CGContextSetInterpolationQuality(ctx, kCGInterpolationHigh);
|
|
CGFloat inset = size * 0.12;
|
|
CGContextDrawImage(ctx, CGRectMake(inset, inset, size - 2 * inset, size - 2 * inset), gear);
|
|
CGImageRef icon = CGBitmapContextCreateImage(ctx);
|
|
CGImageDestinationRef dst = CGImageDestinationCreateWithURL((__bridge CFURLRef)[NSURL fileURLWithPath:@(argv[2])],
|
|
CFSTR("public.png"), 1, NULL);
|
|
CGImageDestinationAddImage(dst, icon, NULL);
|
|
BOOL ok = CGImageDestinationFinalize(dst);
|
|
CFRelease(dst); CGImageRelease(icon); CGGradientRelease(gradient); CGContextRelease(ctx);
|
|
CGColorSpaceRelease(rgb); CGImageRelease(gear); CFRelease(src);
|
|
return ok ? 0 : 1;
|
|
}
|
|
}
|