pc_decomp_ts2

pc_decomp_ts2 is an unofficial Android port of The Sims 2 Legacy Collection with touch controls and gamepad input.

README

The Sims 2 Legacy for Android

Development build: 0.3-dev.

An unofficial Android port of the PC version of The Sims 2 Legacy Collection. The original x86 executable is statically recompiled to C and built for ARM64 and ARMv7, with a Win32 compatibility runtime, native OpenGL ES and Vulkan renderers, touch controls, gamepad input and an Android launcher.

Project repository: phys-winner/pc_decomp_ts2.

Compatible game version

This project is compatible with The Sims 2 Legacy Collection, Steam build 18015495, released on 10 April 2025: The Sims 2 Legacy Patch Notes #8 on SteamDB. The APK bundles the matching original executable and DLL in assets/runtime.zip. Compatibility with other executable revisions, older disc releases, Ultimate Collection and mods has not been established.

Original PC file used by the buildSHA-256
EP9/TSBin/Sims2EP9.exe7b65c2e8cb3100368d3e10db422768d99ef07169a7cee3aa30e6908aefd0ea88
EP9/TSBin/ijl15.dll41d37bfb0a39017497e0aa373dc01f71ac9c5046c75f7cd269bee52112a5f3a1

Use your own installed copy of the game. The source repository excludes original EXE/DLL files, game packages, generated game code, saves and personal settings. The APK requires the data packages from your game installation. Port resource overlays are generated from the user's original files during the build and embedded in the APK.

Castaway Stories (work in progress)

The 0.4-dev release APK contains Legacy Collection only. Build it with both ABIs and the bundled launcher; --no-castaway excludes the optional native module, launcher entry, activity and runtime assets even in a Castaway checkout:

$env:PORT_LAUNCHER = 'android/launcher'
python tools/build_game_apk.py --abi both --no-castaway

The optional Castaway Stories module is under development. Earlier device builds loaded the main menu, N001 on ARM64, N002 on both ABIs, and Buy mode. An N001 purchase survived saving and a cold reload; N002 household funds saved on ARMv7 survived loading on ARM64. The current service-lifetime fixes have passed native Linux N002 save and normal game-menu exit; Android confirmation, full campaign and advanced touch controls still require acceptance. The published Legacy APK is separate from this work; see STATE.md for exact tested builds and remaining issues.

The supported analysis input is TSBin/SimsCS.exe, SHA-256 cf3a34df999fc50e73ca9b67ae1269702b903ab0cff3b5a9b64486c9adc10081. Keep an unchanged copy at original/SimsCS.exe when generating the optional module. Its original x86 resolver is compiled to static C from a retained, byte-verified observation graph; uncovered control-flow targets stop with a diagnostic. The graph has bounded coverage and requires further device testing.

Castaway uses a flat TSData directory under /sdcard/Sims2/castaway, and a separate profile under /sdcard/Sims2/castaway-userdata. Its texture converter supports this layout in both folders and ZIPs. Legacy Collection data archives do not contain the Castaway installation. Source builds use S2_GAME_DATA for the Legacy overlay inputs and S2_CASTAWAY_DATA for the Castaway installation (default C:\Games\The Sims 2\Castaway Stories). Both live-game and CAS configuration overlays enable native EVENT queries and disable camera drift and edge scrolling. Test/release APKs must still be built with --abi both.

The Android launcher shares neighborhood backup and restore with Legacy, using each edition's separate Documents path. Two backup generations and the clean-session guard keep a failed session from replacing the preceding backup.

Native builds can use separate output directories. Rebuild both engines before packaging their explicit paths; the APK builder checks the ELF architecture:

python tools/build_android.py --abi arm64 --shared --output build/castaway/native-arm64 --jobs 6
python tools/build_android.py --abi arm32 --shared --output build/castaway/native-arm32 --jobs 4
$env:PORT_LAUNCHER = 'android/launcher'
python tools/build_game_apk.py --abi both --skip-native --library-arm64 build/castaway/native-arm64/libsims2.so --library-arm32 build/castaway/native-arm32/libsims2.so
Running the development engine without a phone

Linux x86-64 (including WSL) can run the same statically recompiled functions and compatibility runtime with native OpenGL ES in a Mesa pbuffer. This is a diagnostic build with a silent audio sink. It needs the generated game sources, the original installed game data and a current APK's assets/runtime.zip. On Ubuntu, install clang, libegl1-mesa-dev, libgles2-mesa-dev, glslang-dev, zlib1g-dev, python3-capstone and python3-pefile, then run:

python3 tools/build_desktop.py --jobs 4
python3 tools/run_desktop.py --game '/mnt/c/Games/The Sims 2/Castaway Stories' --runtime path/to/runtime.zip --screen 2340x1080 --language russian --capture

The runner creates a separate build/desktop/userdata-qa-desktop-castaway profile. To reproduce a save, copy its Documents directory into that profile before starting. The engine prints the logical game resolution and a new live command file for each run. Append click x y 0 at logical game coordinates, key 1B to press Escape (key codes are hexadecimal), or quit to exit. With --capture, creating frame.request in the QA profile captures the next presented frame as frame.ppm. tools/check_desktop_capture.py checks the capture helper against a real EGL context. No ADB connection is required.

After a normal build, tools/build_desktop.py --host-only can reuse generated objects only when the source, common-function, compiler and object hashes still match. An uncovered guest target produces the same diagnostic used on Android; this mode does not add coverage or certify other chapters by itself.

The scheduler, real suspend counts, render waits and Castaway service lifetimes can also be checked without a device. These probes compile the production C implementations with controlled guest/GL boundaries and run real pthreads:

python3 tools/check_machine_yield.py --host
python3 tools/check_thread_suspend.py
python3 tools/check_render_sync_yield.py --host
python3 tools/check_render_wait.py --host
python3 tools/check_castaway_lifetime.py --host

The render-queue probe includes spurious wakeups, ring wrap, inline execution and negative controls that deliberately lose a wakeup. An old PGO host snapshot is optional and only provides a historical comparison binary.

Requirements

  • Android 10 / API 29 or later on ARM64 or an experimental ARMv7 device with Thumb-2, NEON and 4 KiB pages.
  • OpenGL ES 3.2. The app targets API 37 and includes arm64-v8a and armeabi-v7a libraries.
  • The data from a compatible Legacy Collection installation, including Base and the expansion and stuff-pack folders.
  • Enough storage for the original game, saves, optional converted textures and the app's native libraries. The APK carries both builds of the engine as XZ in assets/native. On first use it unpacks the selected engine into the app's files (about 191 MB for ARM64 or 154 MB for ARMv7). Texture conversion requires extra space.
  • Storage access granted through the launcher; Android 11+ uses All files access.

The APK is aligned for 16 KiB pages. ARM64 native libraries use 16 KiB alignment, and ARMv7 native libraries use 4 KiB alignment. Renderer requirements are additional to the minimum Android version.

Install and play

  1. Install the APK from pub on the Android device.
  2. Copy the installed PC game folder to the device, for example /sdcard/Sims2/game, preserving the Base, EP1 through EP9 and SP directory structure. The launcher can also import a ZIP of that folder.
  3. Open The Sims 2 and grant the requested storage access.
  4. Select the installed game folder or its ZIP in the launcher's Game files section. Select the folder containing Base and EP9, rather than either subfolder.
  5. For a ZIP stored without compression, choose Play from the archive in the import dialog. Keep the ZIP in its selected location. The launcher creates a small file index; the engine reads game files directly from the archive. A few compressed entries may be unpacked into a separate sidecar (up to 256 MiB); a fully compressed archive must be unpacked instead.
  6. Choose the language and renderer and press Play when the launcher reports that the files are ready. Texture conversion works with folders and mounted ZIP archives. The launcher checks only one texture package; full discovery runs only when conversion starts, in the background with progress and cancellation. For ZIP installations the converted cache stays in the separate sidecar; the original ZIP is never changed.

The launcher accepts game files on a mounted SD card. Select the installed folder or ZIP from the card in Game files. For FAT32 cards, copy the game folder because FAT32 cannot hold a single ZIP of 4 GiB or more.

The engine reads its bundled EXE and DLL from private app storage, where it also installs the port overlays. A game folder or ZIP containing the data packages is sufficient.

The ZIP is read-only. New or modified installation files are stored separately in the app's sidecar; original data is copied there only when actually written. User-profile templates are copied into the writable profile on first launch, just as for an unpacked installation. Reads, profile copies and their flushes release guest execution so that the audio decoder can refill its stream.

The default writable profile is /sdcard/Sims2/userdata. Back up this directory before replacing the app or experimenting with game modifications. Preserve the APK signing key when building updates; a different certificate cannot update an existing installation in place.

Controls and settings

  • Tap to interact. In Live Mode a tap checks a small area for nearby targets. A single object opens its actions immediately. With several objects, choose one from the list, which also includes the ground if the tap area hits it. A tap on the ground alone opens its actions directly.

  • Drag one finger to pan the town or lot camera. Pinch to zoom, twist to rotate, and move two fingers vertically to tilt.

  • Drag a Buy/Build catalog object onto the lot to preview it. The on-screen rotate, confirm and cancel buttons control placement; releasing a drag does not purchase the object. A brief two-finger world tap cancels selection.

  • Hold an ordinary interface element for a right click. Hold a catalog thumbnail to show its description. Swipe lists, text, catalogs and category strips.

  • Hold the ... control to open grouped cheats and the editable command console.

  • The ? control in the original Options screen opens interface settings and gesture help. Interface scale is available in the game's Graphics Options.

  • Android gamepad support includes a left-stick cursor, right-stick camera, trigger zoom, shoulder rotation and selection/placement buttons.

  • The launcher selects game language, resolution, frame limit and supported renderer options. The game supports 21 language choices; the launcher UI supports English, Russian, German and Polish.

  • Loading does not wait for the loading screens' animations: on PC the town and lot screens hold every loading step until their progress animation ends (about 320 ms a step). The animations still play; on the Redmi Note 8 Pro Veronaville loads in 6.4-6.9 s instead of 10.2-10.6 s and a lot in 28.9 s instead of 31.0-31.4 s. The startup screen is bound by its real work and is unchanged.

  • The launcher's Mods folder card shows where The Sims 2 reads .package mods: Sims2/userdata/Documents/EA Games/The Sims 2 Legacy/Downloads in shared storage (subfolders work too); the launcher creates it.

Adaptive interface is on by default. Its checkbox in the launcher and in-game port settings saves the choice for the next launch. Regular UI layouts for mods selects the layouts targeted by most UI mods on the next launch, including when the current UI scale would otherwise choose the compact layouts.

Family and lot thumbnails appear as their slots are filled between frames. An individual uncached family portrait can still stall a frame.

TS2 Extender

Enable TS2 Extender in the launcher's options to use the ARM64 adaptation of TS2 Extender 1.0.0 for Legacy Collection. The switch defaults to off. The game reads the switch and the INI at startup.

  • TS2Extender.ini opens the editor. It saves to Sims2/userdata/TS2Extender.ini in shared storage. The editor starts with the imported INI, or with the upstream field names and defaults. A saved profile INI takes precedence over the copy in the ZIP.
  • Import LC ZIP accepts the original Legacy Collection archive and stores it as Sims2/userdata/TS2Extender.zip. While enabled, the game reads the date, timing and wall cutaway packages from it. The OFB uniforms fix uses its companion package when FixOFBUniform is enabled and the game loads custom content. Choose Enable Custom Content in the game's startup dialog and restart if the game reports that custom content is disabled. The port uses a file of the same name in the ordinary Downloads folder if the player has installed their own copy.
  • On Android, Console enables verbose logging in sims2.log. UIScaleResolution sets the reference height for the port's UI scale when UIScale is enabled. The two Sims 3 Camera sensitivity values apply to the rotation and tilt gestures. Splash uses the image from the imported archive while the game starts.
  • ExtendedLua enables additional libraries in the game's existing Lua VM. Mods that require the extender's additional Lua functions and script loader still require the Windows version. The port uses its own graphics settings interface and its statically compiled game code.

QA profiles keep their own INI and ZIP. The launcher switch also applies to QA runs unless the test specifies --es qa_ts2_extender 0 or --es qa_ts2_extender 1. QA launches always skip both intro movies.

Renderers

ModeRequirements and behavior
OpenGL ESThe port's native OpenGL ES renderer; the default.
VulkanThe port's native Vulkan renderer with the system driver, offered when the launcher's probe succeeds.
Vulkan (Turnip / PanVK)The same native Vulkan renderer with a compatible app-local Mesa driver; availability is checked by the launcher.

Both renderers (android/render) draw the game's Direct3D 9 calls directly: the fixed-function pipeline runs as two port shaders driven by constants. The game's shaders come from a shader library built with the APK (tools/build_shaderlib.py, from shader bytecode captured on a device); a shader the library lacks, such as a mod's, is translated on the device when first used (Vulkan keeps the compiled SPIR-V in the app's cache, OpenGL ES the linked program binaries). DXVK is not used. Turnip and PanVK are optional drivers for the port's native Vulkan backend. The original game's Direct3D 9 interface remains the compatibility boundary; GPU operations run through the selected native OpenGL ES or Vulkan backend.

The launcher's render options apply to both renderers: game resolution (the render scale), render upscaling (bilinear or FSR 1), FXAA, scene MSAA (2x or 4x) and FSR 1 for interface textures. FSR 3.1 was removed because it was too slow on phones; a profile that chose it now uses FSR 1. ProcessVertices and multiple render targets work in both renderers.

Where the GPU cannot sample the game's DXT textures (Mali, and OpenGL ES on Adreno), both renderers decode them to RGBA8 while loading unless the launcher's Textures card has converted them to ETC2 or ASTC 4x4: the converted levels then go to the GPU as they are, 4-8 times smaller. On a Redmi Note 8 Pro lot the textures took 121 MB (ETC2) or 127 MB (ASTC) instead of 201 MB, and the process 85-88 MB (OpenGL ES) or 126-167 MB (Vulkan) less memory. ASTC keeps more detail; ETC2 converts faster and takes less storage. Where the GPU samples DXT (BC), the textures stay DXT and the card offers no conversion. Both Legacy and Castaway use the native renderer selection. The retired legacy selection now means native OpenGL ES, and debug.s2.renderer=legacy leaves the selected native backend in place. A native renderer initialization failure stops the session and lets the launcher offer another choice.

Audio

The game's own mixer, EA SND inside the original executable, renders straight into an AAudio stream in the low-latency performance mode. DirectSound is not emulated: SND's PC output driver is replaced natively (android/host/sims2_audio.c), and the stream's data callback drains a FIFO that SND fills on demand (android/host/audio.c). SND mixes at the device's output rate when it lies in SND's 11025–48000 Hz range (normally 48 kHz), so the port does not resample. The FIFO's reserve adapts: an underrun widens it at once by how late the mixer was, and quiet periods narrow it again. A 10 Hz high-pass at the FIFO removes the constant offset SND leaves while the game is paused (it holds paused voices at their last sample), so stopping or starting the stream does not click.

SND's service thread is urgent for the guest machine: the holder hands over at its next loop back-edge, and the owner of SND's lock is served first while the mixer waits for it. A D3D call waiting for the render thread (a GetRenderTargetData screen grab, ProcessVertices) lends the machine to the mixer, wherever the mixer waits in the queue, or to the owner of the lock the mixer waits for until that owner releases it; the borrower parks its ticket, runs, hands the machine back, and the other threads keep waiting for the lender. A waiter sleeps on its own condition, and a release wakes only the owner of the next ticket. Slow host work does not keep the machine: cache write-back and truncation in SetEndOfFile/FlushFileBuffers, the unlink in DeleteFile, registry writes (a writer thread, flushed before a pause or an exit), and the memory report's mincore; the native QFS decoder and window search offer the machine like the loops they replace. An urgent wait over 20 ms logs a [machine] line with the holder's function, its last import or method, the threads ahead of the mixer, the loans so far and the holder's host program counter and return addresses (sampled with a signal); a [machine] last 10 s line counts slow handoffs.

The stream closes in the background and reopens on return; the game's sounds stay paused meanwhile. A changed output route (headphones, Bluetooth, an output capture) reopens the stream, and a failed open is retried after 20 ms, doubling up to 2 s. A new stream's first 200 ms (its prefill) do not count as underruns and do not grow the device buffer. A low-latency stream whose callback stops twice is reopened in Android's normal mode until the route changes. Each session log has a 10-second [audio] summary with the latency, underruns, the offset per channel and the mixer's response time, and a [latency] line with the age of the mix when it is heard (from SND's commit to the stream's presentation timestamp); sims2.audio.log in the profile records stream events.

Development status

Representative development checks cover startup, town and household loading, CAS, Buy/Build/Live navigation, saving/loading, touch input, audio and app resume on selected Mali, Adreno and PowerVR devices. These checks do not establish whole-game completion or compatibili