[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-110612":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":16,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":12,"compositeScore":18,"rankGlobal":9,"rankLanguage":9,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":9,"pushedAt":32,"updatedAt":33,"readmeContent":34,"aiSummary":35,"trendingCount":15,"starSnapshotCount":15,"syncStatus":13,"lastSyncTime":36,"discoverSource":37},110612,"METAL-GEAR-SOLID-2-Sons-of-Liberty-for-Android","luisxl15\u002FMETAL-GEAR-SOLID-2-Sons-of-Liberty-for-Android","luisxl15","Metal Gear Solid 2 HD (NVIDIA SHIELD) para Android ARM64 — recompilação estática ARM32→ARM64, Adreno e Mali, LSFG, menus em 7 idiomas. Traga sua própria cópia do jogo. \u002F Static recompilation port, bring your own game files.",null,"C",57,3,2,22,0,1,6,44.53,"GNU General Public License v3.0",false,"main",true,[24,25,26,27,28,29,30,31],"android","arm64","frame-generation","gles","metal-gear-solid","nvidia-shield","static-recompilation","vulkan","2026-10-24 04:41:47","2026-11-23 10:16:32","\u003Cp align=\"center\">\n  \u003Cimg src=\"docs\u002Fbanner.svg\" alt=\"Metal Gear Solid 2: Sons of Liberty HD — Android ARM64\" width=\"100%\">\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Cimg alt=\"Android 8+\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FAndroid-8.0%2B-3ddc84?logo=android&logoColor=white\">\n  \u003Cimg alt=\"arm64-v8a\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FABI-arm64--v8a-0b1712\">\n  \u003Cimg alt=\"GPU\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FGPU-Adreno%20%7C%20Mali-7fd6a0\">\n  \u003Cimg alt=\"Idiomas\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fmenus-PT%20%7C%20EN%20%7C%20ES%20%7C%20FR%20%7C%20IT%20%7C%20DE%20%7C%20JA-95a59d\">\n  \u003Cimg alt=\"Licença GPL-3.0\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicen%C3%A7a-GPL--3.0-blue\">\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Cb>\u003Ca href=\"#-português\">🇧🇷 Português\u003C\u002Fa>\u003C\u002Fb> · \u003Cb>\u003Ca href=\"#-english\">🇺🇸 English\u003C\u002Fa>\u003C\u002Fb>\n\u003C\u002Fp>\n\n---\n\n# 🇧🇷 Português\n\n**Metal Gear Solid 2: Sons of Liberty HD** da NVIDIA SHIELD TV rodando em celulares Android de **64 bits** atuais (Snapdragon e MediaTek).\n\nA versão do SHIELD é um jogo nativo para ARM de **32 bits**. Os processadores novos (como o Snapdragon 8 Elite) **não executam mais código de 32 bits**, então o APK original nem instala. Este projeto faz uma **recompilação estática**: lê o binário ARM32 do jogo, traduz cada função para C e compila de novo para **ARM64**, com um runtime próprio que substitui o sistema do SHIELD (memória, libc, OpenGL, áudio, JNI).\n\n## 📸 Capturas\n\n| Tela inicial | Título com controles na tela |\n|:---:|:---:|\n| \u003Cimg src=\"docs\u002Fcapturas\u002F01-menu.jpg\" width=\"420\"> | \u003Cimg src=\"docs\u002Fcapturas\u002F02-titulo.jpg\" width=\"420\"> |\n| **Abertura** | **Abertura (código)** |\n| \u003Cimg src=\"docs\u002Fcapturas\u002F04-abertura.jpg\" width=\"420\"> | \u003Cimg src=\"docs\u002Fcapturas\u002F05-abertura-codigo.jpg\" width=\"420\"> |\n\n\u003Cp align=\"center\">\u003Cimg src=\"docs\u002Fcapturas\u002F03-controles.jpg\" width=\"600\">\u003Cbr>\u003Csub>Galaxy S25+ (Snapdragon 8 Elite), 60 FPS, controles na tela.\u003C\u002Fsub>\u003C\u002Fp>\n\n## ✨ Recursos\n\n- **ARM64 nativo:** o jogo inteiro (≈22 mil funções do jogo + ≈3 mil da biblioteca C++) recompilado para 64 bits, sem emulador.\n- **Duas versões do APK:**\n  - `MGS2-ARM64.apk` para **Snapdragon \u002F Adreno**;\n  - `MGS2-ARM64-Mali.apk` para **MediaTek \u002F Mali** (com ajustes para GPU de ladrilhos).\n- **OpenGL de desktop → GLES 3.2:** a camada D3D9→GL da versão SHIELD pede OpenGL de PC; o runtime traduz shaders, formatos de textura e funções.\n- **Texturas DXT na CPU** para GPUs que não têm S3TC\u002FRGTC (Mali, PowerVR), decididas automaticamente.\n- **Extração automática das OBBs:** na primeira vez, o próprio app tira os ≈7 GB de arquivos de dentro das OBBs, com CRC conferido em cada arquivo e retomada se for interrompido.\n- **Controles na tela** com editor de posição, tamanho e opacidade. Controles Bluetooth e USB funcionam direto, e os botões da tela somem sozinhos quando há um controle ligado.\n- **Medidor de FPS** com os quadros do jogo e os quadros na tela.\n- **Geração de quadros LSFG** (60 → 120), no mesmo esquema do emulador Eden, usando os shaders do *Lossless Scaling* do usuário (veja as limitações).\n- **Menus em 7 idiomas**, seguindo o idioma do celular: português, inglês, espanhol, francês, italiano, alemão e japonês.\n\n## 📱 Requisitos\n\n| | |\n|---|---|\n| **Celular** | Android **8.0+**, processador **64 bits** (arm64-v8a) |\n| **GPU** | Adreno (Snapdragon) ou Mali (MediaTek\u002FExynos antigos); precisa de **OpenGL ES 3.2** |\n| **Espaço livre** | **≈12 GB**: 3,7 GB das OBBs + 6,9 GB extraídos + o APK |\n| **Arquivos do jogo** | `base.apk` + `main.14.jp.konami.mgs2hd.shield.obb` + `patch.14.jp.konami.mgs2hd.shield.obb`, da SHIELD TV, versão **21.21.1219.GM** |\n\nTestado em: **Galaxy S25+** (Snapdragon 8 Elite, Adreno 830) e **Redmi 13C** (Helio G85, Mali-G52).\n\n## 📖 Tutorial de instalação\n\n### Passo 1: copiar os arquivos do jogo da sua SHIELD TV\n\nVocê precisa de três arquivos da **sua** SHIELD com o jogo instalado:\n\n| Arquivo | Tamanho | Onde fica na SHIELD |\n|---|---|---|\n| `base.apk` | ≈13 MB | pasta do app (o comando abaixo mostra) |\n| `main.14.jp.konami.mgs2hd.shield.obb` | ≈2,1 GB | `\u002Fsdcard\u002FAndroid\u002Fobb\u002Fjp.konami.mgs2hd.shield\u002F` |\n| `patch.14.jp.konami.mgs2hd.shield.obb` | ≈1,6 GB | `\u002Fsdcard\u002FAndroid\u002Fobb\u002Fjp.konami.mgs2hd.shield\u002F` |\n\n1. Na SHIELD: **Configurações → Preferências do dispositivo → Sobre** e toque 7 vezes em **Build** para liberar as opções de desenvolvedor.\n2. Em **Opções do desenvolvedor**, ligue a **Depuração de rede** (ou a USB).\n3. No PC, com o [Android Platform Tools](https:\u002F\u002Fdeveloper.android.com\u002Ftools\u002Freleases\u002Fplatform-tools) instalado:\n\n```bash\nadb connect IP_DA_SHIELD:5555\nadb shell pm path jp.konami.mgs2hd.shield\n```\n\n4. O comando acima mostra algo como `package:\u002Fdata\u002Fapp\u002F...\u002Fbase.apk`. Copie esse arquivo e as OBBs para uma pasta **`jogo\u002F`** dentro deste repositório:\n\n```bash\nmkdir jogo\nadb pull \u002Fdata\u002Fapp\u002FCAMINHO_QUE_APARECEU\u002Fbase.apk jogo\u002F\nadb pull \u002Fsdcard\u002FAndroid\u002Fobb\u002Fjp.konami.mgs2hd.shield\u002Fmain.14.jp.konami.mgs2hd.shield.obb jogo\u002F\nadb pull \u002Fsdcard\u002FAndroid\u002Fobb\u002Fjp.konami.mgs2hd.shield\u002Fpatch.14.jp.konami.mgs2hd.shield.obb jogo\u002F\n```\n\n### Passo 2: montar o APK\n\nComo o APK contém o código do jogo, ele **não é distribuído**: cada pessoa monta o seu a partir dos próprios arquivos. As instruções completas estão em [**Como compilar**](#-como-compilar). O resultado fica em `recomp\u002Fbuild\u002F`:\n\n- **Snapdragon \u002F Adreno:** `MGS2-ARM64.apk`\n- **MediaTek \u002F Mali:** `MGS2-ARM64-Mali.apk`\n\n> Não sabe qual é a sua GPU? Instale o app *CPU-Z* e veja em **SoC → GPU**. Adreno = Snapdragon; Mali = MediaTek\u002FExynos.\n\n### Passo 3: instalar o APK no celular\n\nEscolha uma das formas:\n\n- **Pelo cabo (adb):** `adb install MGS2-ARM64.apk`\n- **Pelo celular:** copie o APK para o celular, abra pelo gerenciador de arquivos e permita **\"Instalar apps desconhecidos\"** quando o Android pedir.\n\n> **Xiaomi \u002F Redmi \u002F POCO:** para instalar pelo cabo, ative em **Configurações → Configurações adicionais → Opções do desenvolvedor** a opção **\"Instalar via USB\"**. Sem ela aparece `INSTALL_FAILED_USER_RESTRICTED`.\n\n### Passo 4: colocar as OBBs no lugar certo ⚠️\n\nAs duas OBBs vão **exatamente** nesta pasta do celular, com estes nomes:\n\n```\nArmazenamento interno\u002F\n└── Android\u002F\n    └── obb\u002F\n        └── jp.konami.mgs2hd.shield\u002F            ← crie esta pasta se não existir\n            ├── main.14.jp.konami.mgs2hd.shield.obb\n            └── patch.14.jp.konami.mgs2hd.shield.obb\n```\n\n**Instale o APK antes** (passo 3) e depois copie as OBBs, de uma destas formas:\n\n**A) Pelo PC com cabo USB (recomendado)**\n1. Conecte o celular e escolha **\"Transferência de arquivos\"** na notificação USB.\n2. No Explorador de Arquivos do Windows, abra **Armazenamento interno → Android → obb**.\n3. Crie a pasta `jp.konami.mgs2hd.shield` (se ainda não existir).\n4. Copie as duas OBBs para dentro dela e espere terminar (são ≈3,7 GB).\n\n**B) Pelo adb**\n```bash\nadb shell mkdir -p \u002Fsdcard\u002FAndroid\u002Fobb\u002Fjp.konami.mgs2hd.shield\nadb push jogo\u002Fmain.14.jp.konami.mgs2hd.shield.obb \u002Fsdcard\u002FAndroid\u002Fobb\u002Fjp.konami.mgs2hd.shield\u002F\nadb push jogo\u002Fpatch.14.jp.konami.mgs2hd.shield.obb \u002Fsdcard\u002FAndroid\u002Fobb\u002Fjp.konami.mgs2hd.shield\u002F\n```\nOu, de uma vez (instala o APK, envia as OBBs e **não** abre o jogo):\n```bash\nbash instalar.sh recomp\u002Fbuild\u002FMGS2-ARM64.apk\n```\n\n**C) Só pelo celular**\nA partir do Android 11, os gerenciadores de arquivos comuns não conseguem mais entrar em `Android\u002Fobb`. Use um gerenciador com acesso via **Shizuku** (por exemplo, MiXplorer ou ZArchiver com Shizuku) ou prefira as formas A ou B.\n\n> [!WARNING]\n> **Não copie os arquivos já extraídos** (pastas `assets`, `us`, `textures`…) para `Android\u002Fdata` pelo PC ou pelo adb. Em alguns aparelhos, como os da Xiaomi, eles ficam com o dono errado, o jogo não consegue ler e fecha logo na abertura. Copie **só as OBBs** e deixe o app extrair.\n\n### Passo 5: primeira abertura\n\n1. Abra **MGS2 HD** e toque em **Jogar**.\n2. Aparece a tela **\"Preparando os dados do jogo\"**: o app tira os ≈32 mil arquivos de dentro das OBBs, com barra de progresso e tempo restante.\n   - Leva de 1 a 5 minutos, dependendo do celular. Deixe o app aberto; a tela fica acesa sozinha.\n   - Se for interrompido, ao tocar em Jogar de novo ele **continua de onde parou**.\n3. No fim, o jogo abre sozinho. Nas próximas vezes, vai direto para o jogo.\n\n> Depois da extração as OBBs não são mais lidas pelo jogo. Mesmo assim, mantenha-as: se os dados forem apagados (ao limpar os dados do app, por exemplo), o app extrai de novo a partir delas.\n\n### Passo 6: ajustes\n\nNa tela inicial, toque em **Ajustes**:\n\n| Ajuste | Opções | O que faz |\n|---|---|---|\n| **Limite de quadros** | 30 · **60** · Sem limite | O MGS2 foi feito para 60. \"Sem limite\" pode **acelerar** o jogo |\n| **Imagem** | **16:9** · Esticar | 16:9 mantém a proporção (faixas pretas nas laterais); Esticar ocupa a tela toda |\n| **Medidor de FPS** | ligado\u002Fdesligado | Mostra no canto os FPS do jogo e, com o LSFG, os FPS da tela |\n| **Geração de quadros (LSFG)** | **Desligada** · 2x (120) | Cria um quadro intermediário: 60 → 120 sem acelerar o jogo |\n| **Precisão do movimento** | **100%** · 75% · 50% | Menor = GPU mais livre, mais erro nas bordas de objetos rápidos |\n| **Lossless.dll** | Importar | Escolhe o `Lossless.dll` do seu Lossless Scaling |\n| **Mostrar controles na tela** | **Automático** · Sempre · Nunca | Automático esconde os botões quando há controle físico ligado |\n| **Opacidade dos botões** | 10–100% | Transparência dos botões por cima do jogo |\n| **Vibrar ao tocar** | ligado\u002Fdesligado | Vibração curta em cada botão |\n\n### Passo 7: controles\n\n- **Controle Bluetooth\u002FUSB** (padrão Xbox, como os 8BitDo, ou DualSense): conecte e jogue. Os botões da tela somem sozinhos.\n- **Controles na tela:** em **Controles na tela** (tela inicial), arraste cada botão para mover, use pinça para mudar o tamanho e ajuste o tamanho geral e a opacidade. Depois toque em **Salvar**.\n\n### Geração de quadros (LSFG): limitações\n\nO LSFG usa os shaders do programa **Lossless Scaling** (pago, na Steam), lidos do **seu** `Lossless.dll`; o arquivo é só lido, nunca executado. Para importar: no PC, abra **Steam → Lossless Scaling → Gerenciar → Ver arquivos locais**, copie o `Lossless.dll` para o celular e use **Ajustes → Lossless.dll → Importar**.\n\n> [!NOTE]\n> Esta versão aceita o `Lossless.dll` que traz os shaders já em **SPIR-V**. A versão atual do Lossless Scaling (**3.2.1**) traz **só DXBC** e ainda **não é suportada**: com ela o jogo roda normalmente, sem a geração de quadros. A geração também precisa de Vulkan 1.2 com `nullDescriptor`, `vulkanMemoryModel` e `shaderFloat16`.\n\n## 🛠️ Solução de problemas\n\n| Problema | Solução |\n|---|---|\n| `INSTALL_FAILED_USER_RESTRICTED` ao instalar | Xiaomi: ative **\"Instalar via USB\"** nas opções do desenvolvedor |\n| \"Faltam as OBBs do jogo\" | Confira a pasta e os **nomes exatos** do passo 4 |\n| \"Espaço insuficiente\" | Libere ≈7 GB e toque em **Tentar de novo** |\n| O jogo fecha logo ao abrir | Você copiou arquivos extraídos pelo PC\u002Fadb? Apague as pastas de `Android\u002Fdata\u002Fjp.konami.mgs2hd.shield\u002Ffiles\u002F` (menos `saveData`) e deixe o app extrair |\n| Os botões da tela não aparecem | **Ajustes → Mostrar controles na tela → Sempre** |\n| Jogo acelerado | **Ajustes → Limite de quadros → 60** |\n| Mandar o log de um problema | O jogo grava o log em `Android\u002Fdata\u002Fjp.konami.mgs2hd.shield\u002Ffiles\u002Fmgs2_log.txt`. Se o jogo fechou, abra de novo e mande o `mgs2_log_anterior.txt` (é o da vez que fechou) |\n| Ver o log técnico pelo PC | `adb logcat -s MGS2-RT MGS2-stdout DEBUG` |\n\n## ⚙️ Como funciona\n\n```mermaid\nflowchart LR\n    A[\"base.apk da SHIELD\u003Cbr\u002F>libMGS2HD.so (ARM32)\"] --> B[\"recompilar.py\u003Cbr\u002F>análise + tradução\"]\n    B --> C[\"≈25 mil funções em C\u003Cbr\u002F>recomp\u002Fsaida\u002F\"]\n    C --> D[\"clang (NDK)\u003Cbr\u002F>ARM64\"]\n    R[\"runtime\u002F\u003Cbr\u002F>memória · libc · GL · EGL\u003Cbr\u002F>JNI · OpenSL · LSFG\"] --> D\n    D --> E[\"libMGS2HD.so\u003Cbr\u002F>ARM64\"]\n    J[\"casca Java\u003Cbr\u002F>menus · ajustes · controles\u003Cbr\u002F>extrator de OBB\"] --> F\n    E --> F[\"empacotar.py\u003Cbr\u002F>APK ARM64 assinado\"]\n```\n\n- **Recompilador** (`recomp\u002Frecompilar.py`, `gerar*.py`, `ual.py`): acha as funções (tabelas de exceção, alvos de `bl`, ponteiros, tabelas de salto ARM e Thumb), lê o texto do Capstone e emite C. Os registradores viram variáveis locais, que o clang põe nos registradores do ARM64.\n- **Testes:**\n  - `diferencial.py` compara instrução por instrução com o Unicorn;\n  - `fuzz_funcoes.py` compara funções inteiras com estados aleatórios;\n  - `medir_abi.py` e `medir_bandeiras.py` validam as otimizações de chamada.\n- **Runtime** (`recomp\u002Fruntime\u002F`): memória de 4 GB do jogo, pontes para a libc do Android, `pthread`, OpenGL de desktop sobre GLES 3.2 (`gl_desktop.c`, `gl_shader.c`, `gl_formato.c`), DXT\u002FRGTC na CPU (`s3tc.c`), áudio OpenSL, JNI falso para o Java da NVIDIA Forge, e LSFG em Vulkan (`lsfg_vk.cpp`, `lsfg_gl.c`).\n- **Casca Java** (`recomp\u002Fjava_tela\u002F`): menu, ajustes, editor de controles, controles na tela, medidor de FPS, extrator de OBB e traduções (`Textos.java`).\n\n## 🧱 Como compilar\n\n**Ambiente testado:** Windows 11 com Git Bash. Os scripts também devem funcionar em Linux e macOS.\n\n1. **Instale:**\n   - [Python 3.11+](https:\u002F\u002Fwww.python.org\u002F) e depois:\n     ```bash\n     pip install capstone unicorn pillow\n     ```\n   - [Android SDK](https:\u002F\u002Fdeveloper.android.com\u002Fstudio) com **NDK r27+**, **Build-Tools** e uma **Platform** (pelo SDK Manager do Android Studio);\n   - **JDK 17+**.\n2. **Confira** se as ferramentas foram encontradas:\n   ```bash\n   python recomp\u002Fcaminhos.py\n   ```\n   Se algo aparecer como `NAO ENCONTRADO`, defina `ANDROID_HOME`, `ANDROID_NDK_HOME` ou `JAVA_HOME`.\n3. **Coloque os arquivos do seu jogo** em `jogo\u002F` (passo 1 do tutorial) e extraia as bibliotecas ARM32:\n   ```bash\n   python recomp\u002Fpreparar.py\n   ```\n   Sem o `base.apk`, mas com um APK ARM64 já montado por este projeto, dá para reconstruir as mesmas bibliotecas a partir das imagens que vão dentro dele (o script confere byte a byte):\n   ```bash\n   python recomp\u002Freconstruir_libs.py caminho\u002Fdo\u002FMGS2-ARM64.apk\n   python recomp\u002Freconstruir_base.py caminho\u002Fdo\u002FMGS2-ARM64.apk\n   ```\n4. **Recompile** o jogo. A primeira vez leva uns 10 minutos e gera `recomp\u002Fsaida\u002F`:\n   ```bash\n   python recomp\u002Frecompilar.py\n   ```\n5. **Compile a casca Java:**\n   ```bash\n   bash recomp\u002Fjava_tela\u002Fcompilar.sh\n   ```\n6. **Compile para ARM64 e monte o APK:**\n   ```bash\n   python recomp\u002Fconstruir_android.py && python recomp\u002Fempacotar.py\n   MGS2_SABOR=mali python recomp\u002Fconstruir_android.py && MGS2_SABOR=mali python recomp\u002Fempacotar.py\n   ```\n   A primeira linha gera o APK **Adreno**; a segunda, o **Mali**.\n7. Os APKs ficam em `recomp\u002Fbuild\u002F`. Na primeira vez, o `empacotar.py` cria uma chave de assinatura própria (`recomp\u002Fassinatura.jks`). **Guarde essa chave**: sem ela, as próximas versões não instalam por cima da anterior.\n\n> [!NOTE]\n> A versão SHIELD tem uma camada de licença exclusiva do aparelho (NVSI). O componente que faz o papel dela **não faz parte deste repositório**.\n\n## 📂 Estrutura\n\n```\n├── extrair_obb.py          extrai as OBBs no PC (opcional; o app já faz isso)\n├── instalar.sh             instala APK + OBBs pelo adb, sem abrir o jogo\n├── docs\u002F                   banner e capturas\n└── recomp\u002F\n    ├── caminhos.py         onde estão SDK\u002FNDK\u002FJDK e os arquivos do jogo\n    ├── preparar.py         tira as bibliotecas ARM32 do base.apk\n    ├── recompilar.py       análise + emissão de C (gerar.py, gerar_vfp.py, ual.py…)\n    ├── construir_android.py \u002F empacotar.py   compila e monta o APK\n    ├── runtime\u002F            o \"sistema\" do jogo em ARM64\n    ├── java_tela\u002F          menus, ajustes, controles, extrator, traduções\n    └── lsfg_teste\u002F         testes da geração de quadros (PC, Vulkan com validação)\n```\n\n## 🙏 Créditos\n\n- **Geração de quadros:** implementação portada do [emulador Eden](https:\u002F\u002Fgit.eden-emu.dev\u002Feden-emu\u002Feden) (PR #4263), baseada no **lsfg-vk** de PancakeTAS. Os shaders são do **Lossless Scaling** (THS), lidos da cópia do usuário.\n- [Capstone](https:\u002F\u002Fwww.capstone-engine.org\u002F) (desmontagem) e [Unicorn](https:\u002F\u002Fwww.unicorn-engine.org\u002F) (testes).\n- *Metal Gear Solid* é marca da Konami Digital Entertainment. *SHIELD* é marca da NVIDIA. Este projeto não tem ligação com nenhuma das duas.\n\n## 📜 Licença\n\nO código deste repositório está sob a [GPL-3.0](LICENSE), por incluir código derivado do Eden e do lsfg-vk (GPL-3.0).\n\n---\n\n# 🇺🇸 English\n\n**Metal Gear Solid 2: Sons of Liberty HD** from the NVIDIA SHIELD TV running on modern **64-bit** Android phones (Snapdragon and MediaTek).\n\nThe SHIELD release is a native **32-bit** ARM game. New chips (such as the Snapdragon 8 Elite) **can no longer run 32-bit code**, so the original APK won't even install. This project does a **static recompilation**: it reads the game's ARM32 binary, translates every function to C and compiles it again for **ARM64**, with its own runtime replacing the SHIELD system (memory, libc, OpenGL, audio, JNI).\n\n## 📸 Screenshots\n\n| Start screen | Title screen with on-screen controls |\n|:---:|:---:|\n| \u003Cimg src=\"docs\u002Fcapturas\u002F01-menu.jpg\" width=\"420\"> | \u003Cimg src=\"docs\u002Fcapturas\u002F02-titulo.jpg\" width=\"420\"> |\n| **Intro** | **Intro (code)** |\n| \u003Cimg src=\"docs\u002Fcapturas\u002F04-abertura.jpg\" width=\"420\"> | \u003Cimg src=\"docs\u002Fcapturas\u002F05-abertura-codigo.jpg\" width=\"420\"> |\n\n## ✨ Features\n\n- **Native ARM64:** the whole game (≈22k game functions + ≈3k C++ library functions) recompiled to 64-bit, no emulator.\n- **Two APK flavors:**\n  - `MGS2-ARM64.apk` for **Snapdragon \u002F Adreno**;\n  - `MGS2-ARM64-Mali.apk` for **MediaTek \u002F Mali** (tuned for tile-based GPUs).\n- **Desktop OpenGL → GLES 3.2:** the SHIELD build's D3D9→GL layer asks for PC OpenGL; the runtime translates shaders, texture formats and functions.\n- **CPU-side DXT textures** for GPUs without S3TC\u002FRGTC (Mali, PowerVR), picked automatically.\n- **Automatic OBB extraction:** on first launch the app itself unpacks the ≈7 GB of files from the OBBs, with a CRC check on every file and resume if interrupted.\n- **On-screen controls** with an editor for position, size and opacity. Bluetooth and USB controllers work out of the box, and the on-screen buttons hide themselves when a controller is connected.\n- **FPS counter** showing game frames and frames on screen.\n- **LSFG frame generation** (60 → 120), the same scheme as the Eden emulator, using the user's own *Lossless Scaling* shaders (see the limitations).\n- **Menus in 7 languages**, following the phone's language: Portuguese, English, Spanish, French, Italian, German and Japanese.\n\n## 📱 Requirements\n\n| | |\n|---|---|\n| **Phone** | Android **8.0+**, **64-bit** CPU (arm64-v8a) |\n| **GPU** | Adreno (Snapdragon) or Mali (MediaTek\u002Folder Exynos); needs **OpenGL ES 3.2** |\n| **Free space** | **≈12 GB**: 3.7 GB of OBBs + 6.9 GB extracted + the APK |\n| **Game files** | `base.apk` + `main.14.jp.konami.mgs2hd.shield.obb` + `patch.14.jp.konami.mgs2hd.shield.obb`, from the SHIELD TV, version **21.21.1219.GM** |\n\nTested on: **Galaxy S25+** (Snapdragon 8 Elite, Adreno 830) and **Redmi 13C** (Helio G85, Mali-G52).\n\n## 📖 Installation guide\n\n### Step 1: copy the game files from your SHIELD TV\n\nYou need three files from **your** SHIELD with the game installed:\n\n| File | Size | Location on the SHIELD |\n|---|---|---|\n| `base.apk` | ≈13 MB | the app folder (the command below shows it) |\n| `main.14.jp.konami.mgs2hd.shield.obb` | ≈2.1 GB | `\u002Fsdcard\u002FAndroid\u002Fobb\u002Fjp.konami.mgs2hd.shield\u002F` |\n| `patch.14.jp.konami.mgs2hd.shield.obb` | ≈1.6 GB | `\u002Fsdcard\u002FAndroid\u002Fobb\u002Fjp.konami.mgs2hd.shield\u002F` |\n\n1. On the SHIELD: **Settings → Device Preferences → About**, tap **Build** 7 times to unlock developer options.\n2. In **Developer options**, enable **Network debugging** (or USB debugging).\n3. On the PC, with [Android Platform Tools](https:\u002F\u002Fdeveloper.android.com\u002Ftools\u002Freleases\u002Fplatform-tools) installed:\n\n```bash\nadb connect SHIELD_IP:5555\nadb shell pm path jp.konami.mgs2hd.shield\n```\n\n4. The command above prints something like `package:\u002Fdata\u002Fapp\u002F...\u002Fbase.apk`. Copy that file and the OBBs into a **`jogo\u002F`** folder inside this repository:\n\n```bash\nmkdir jogo\nadb pull \u002Fdata\u002Fapp\u002FTHE_PATH_IT_PRINTED\u002Fbase.apk jogo\u002F\nadb pull \u002Fsdcard\u002FAndroid\u002Fobb\u002Fjp.konami.mgs2hd.shield\u002Fmain.14.jp.konami.mgs2hd.shield.obb jogo\u002F\nadb pull \u002Fsdcard\u002FAndroid\u002Fobb\u002Fjp.konami.mgs2hd.shield\u002Fpatch.14.jp.konami.mgs2hd.shield.obb jogo\u002F\n```\n\n### Step 2: build the APK\n\nSince the APK contains the game's code, it is **not distributed**: everyone builds their own from their own files. Full instructions are in [**Building**](#-building). The result lands in `recomp\u002Fbuild\u002F`:\n\n- **Snapdragon \u002F Adreno:** `MGS2-ARM64.apk`\n- **MediaTek \u002F Mali:** `MGS2-ARM64-Mali.apk`\n\n> Not sure which GPU you have? Install *CPU-Z* and check **SoC → GPU**. Adreno = Snapdragon; Mali = MediaTek\u002FExynos.\n\n### Step 3: install the APK on the phone\n\nPick one:\n\n- **Over USB (adb):** `adb install MGS2-ARM64.apk`\n- **On the phone:** copy the APK over, open it with the file manager and allow **\"Install unknown apps\"** when Android asks.\n\n> **Xiaomi \u002F Redmi \u002F POCO:** to install over USB, enable **\"Install via USB\"** in **Settings → Additional settings → Developer options**. Without it you get `INSTALL_FAILED_USER_RESTRICTED`.\n\n### Step 4: put the OBBs in the right place ⚠️\n\nBoth OBBs go **exactly** into this folder on the phone, with these names:\n\n```\nInternal storage\u002F\n└── Android\u002F\n    └── obb\u002F\n        └── jp.konami.mgs2hd.shield\u002F            ← create this folder if it doesn't exist\n            ├── main.14.jp.konami.mgs2hd.shield.obb\n            └── patch.14.jp.konami.mgs2hd.shield.obb\n```\n\n**Install the APK first** (step 3), then copy the OBBs in one of these ways:\n\n**A) From the PC over USB (recommended)**\n1. Plug the phone in and choose **\"File transfer\"** in the USB notification.\n2. In Windows File Explorer, open **Internal storage → Android → obb**.\n3. Create the folder `jp.konami.mgs2hd.shield` (if it isn't there yet).\n4. Copy both OBBs into it and wait for it to finish (≈3.7 GB).\n\n**B) With adb**\n```bash\nadb shell mkdir -p \u002Fsdcard\u002FAndroid\u002Fobb\u002Fjp.konami.mgs2hd.shield\nadb push jogo\u002Fmain.14.jp.konami.mgs2hd.shield.obb \u002Fsdcard\u002FAndroid\u002Fobb\u002Fjp.konami.mgs2hd.shield\u002F\nadb push jogo\u002Fpatch.14.jp.konami.mgs2hd.shield.obb \u002Fsdcard\u002FAndroid\u002Fobb\u002Fjp.konami.mgs2hd.shield\u002F\n```\nOr all at once (installs the APK, pushes the OBBs and does **not** launch the game):\n```bash\nbash instalar.sh recomp\u002Fbuild\u002FMGS2-ARM64.apk\n```\n\n**C) On the phone only**\nSince Android 11, regular file managers can't open `Android\u002Fobb`. Use one with **Shizuku** access (e.g. MiXplorer or ZArchiver with Shizuku), or go with A or B.\n\n> [!WARNING]\n> **Do not copy already-extracted files** (the `assets`, `us`, `textures`… folders) into `Android\u002Fdata` from the PC or with adb. On some phones, such as Xiaomi's, they end up with the wrong owner, the game can't read them and closes right at startup. Copy **only the OBBs** and let the app extract them.\n\n### Step 5: first launch\n\n1. Open **MGS2 HD** and tap **Play**.\n2. The **\"Preparing game data\"** screen appears: the app unpacks the ≈32k files from the OBBs, with a progress bar and time remaining.\n   - It takes 1 to 5 minutes depending on the phone. Keep the app open; the screen stays on by itself.\n   - If it gets interrupted, tapping Play again **resumes where it stopped**.\n3. When it's done, the game starts by itself. From then on, it goes straight to the game.\n\n> After extraction the game no longer reads the OBBs. Keep them anyway: if the data gets wiped (by clearing the app's data, for example), the app extracts again from them.\n\n### Step 6: settings\n\nOn the start screen, tap **Settings**:\n\n| Setting | Options | What it does |\n|---|---|---|\n| **Frame limit** | 30 · **60** · Unlimited | MGS2 was made for 60. \"Unlimited\" can **speed the game up** |\n| **Image** | **16:9** · Stretch | 16:9 keeps the aspect ratio (black bars on the sides); Stretch fills the whole screen |\n| **FPS counter** | on\u002Foff | Shows game FPS in the corner and, with LSFG, screen FPS |\n| **Frame generation (LSFG)** | **Off** · 2x (120) | Creates an in-between frame: 60 → 120 without speeding the game up |\n| **Motion accuracy** | **100%** · 75% · 50% | Lower = lighter on the GPU, more errors around fast-moving objects |\n| **Lossless.dll** | Import | Picks the `Lossless.dll` from your Lossless Scaling |\n| **Show on-screen controls** | **Automatic** · Always · Never | Automatic hides the buttons when a physical controller is connected |\n| **Button opacity** | 10–100% | How see-through the buttons are over the game |\n| **Vibrate on touch** | on\u002Foff | Short vibration on every button |\n\n### Step 7: controls\n\n- **Bluetooth\u002FUSB controller** (Xbox layout, such as 8BitDo pads, or DualSense): connect it and play. The on-screen buttons hide themselves.\n- **On-screen controls:** in **On-screen controls** (start screen), drag each button to move it, pinch to resize, and adjust the overall size and opacity. Then tap **Save**.\n\n### Frame generation (LSFG): limitations\n\nLSFG uses the shaders from **Lossless Scaling** (paid, on Steam), read from **your** `Lossless.dll`; the file is only read, never executed. To import it: on the PC, open **Steam → Lossless Scaling → Manage → Browse local files**, copy `Lossless.dll` to the phone and use **Settings → Lossless.dll → Import**.\n\n> [!NOTE]\n> This version accepts a `Lossless.dll` that ships the shaders already in **SPIR-V**. The current Lossless Scaling (**3.2.1**) ships **DXBC only** and is **not supported yet**: with it the game runs normally, without frame generation. Frame generation also needs Vulkan 1.2 with `nullDescriptor`, `vulkanMemoryModel` and `shaderFloat16`.\n\n## 🛠️ Troubleshooting\n\n| Problem | Fix |\n|---|---|\n| `INSTALL_FAILED_USER_RESTRICTED` when installing | Xiaomi: enable **\"Install via USB\"** in developer options |\n| \"The game OBBs are missing\" | Check the folder and the **exact names** from step 4 |\n| \"Not enough space\" | Free ≈7 GB and tap **Try again** |\n| The game closes right after opening | Did you copy extracted files from the PC\u002Fadb? Delete the folders in `Android\u002Fdata\u002Fjp.konami.mgs2hd.shield\u002Ffiles\u002F` (except `saveData`) and let the app extract |\n| On-screen buttons don't show up | **Settings → Show on-screen controls → Always** |\n| Game runs too fast | **Settings → Frame limit → 60** |\n| Sending a log for a problem | The game writes its log to `Android\u002Fdata\u002Fjp.konami.mgs2hd.shield\u002Ffiles\u002Fmgs2_log.txt`. If the game closed, open it again and send `mgs2_log_anterior.txt` (the log from the run that closed) |\n| Technical log from a PC | `adb logcat -s MGS2-RT MGS2-stdout DEBUG` |\n\n## ⚙️ How it works\n\n```mermaid\nflowchart LR\n    A[\"SHIELD base.apk\u003Cbr\u002F>libMGS2HD.so (ARM32)\"] --> B[\"recompilar.py\u003Cbr\u002F>analysis + translation\"]\n    B --> C[\"≈25k functions in C\u003Cbr\u002F>recomp\u002Fsaida\u002F\"]\n    C --> D[\"clang (NDK)\u003Cbr\u002F>ARM64\"]\n    R[\"runtime\u002F\u003Cbr\u002F>memory · libc · GL · EGL\u003Cbr\u002F>JNI · OpenSL · LSFG\"] --> D\n    D --> E[\"libMGS2HD.so\u003Cbr\u002F>ARM64\"]\n    J[\"Java shell\u003Cbr\u002F>menus · settings · controls\u003Cbr\u002F>OBB extractor\"] --> F\n    E --> F[\"empacotar.py\u003Cbr\u002F>signed ARM64 APK\"]\n```\n\n- **Recompiler** (`recomp\u002Frecompilar.py`, `gerar*.py`, `ual.py`): finds functions (exception tables, `bl` targets, pointers, ARM and Thumb jump tables), reads Capstone's text output and emits C. Registers become local variables, which clang maps onto ARM64 registers.\n- **Tests:**\n  - `diferencial.py` compares instruction by instruction against Unicorn;\n  - `fuzz_funcoes.py` compares whole functions with random states;\n  - `medir_abi.py` and `medir_bandeiras.py` validate the call optimizations.\n- **Runtime** (`recomp\u002Fruntime\u002F`): the game's 4 GB memory, bridges to Android's libc, `pthread`, desktop OpenGL on top of GLES 3.2 (`gl_desktop.c`, `gl_shader.c`, `gl_formato.c`), CPU DXT\u002FRGTC (`s3tc.c`), OpenSL audio, a fake JNI for the NVIDIA Forge Java code, and Vulkan LSFG (`lsfg_vk.cpp`, `lsfg_gl.c`).\n- **Java shell** (`recomp\u002Fjava_tela\u002F`): menu, settings, controls editor, on-screen controls, FPS counter, OBB extractor and translations (`Textos.java`).\n\n## 🧱 Building\n\n**Tested environment:** Windows 11 with Git Bash. The scripts should also work on Linux and macOS.\n\n1. **Install:**\n   - [Python 3.11+](https:\u002F\u002Fwww.python.org\u002F), then:\n     ```bash\n     pip install capstone unicorn pillow\n     ```\n   - the [Android SDK](https:\u002F\u002Fdeveloper.android.com\u002Fstudio) with **NDK r27+**, **Build-Tools** and a **Platform** (from Android Studio's SDK Manager);\n   - **JDK 17+**.\n2. **Check** that the tools were found:\n   ```bash\n   python recomp\u002Fcaminhos.py\n   ```\n   If anything shows `NAO ENCONTRADO` (not found), set `ANDROID_HOME`, `ANDROID_NDK_HOME` or `JAVA_HOME`.\n3. **Put your game files** in `jogo\u002F` (step 1 of the guide) and extract the ARM32 libraries:\n   ```bash\n   python recomp\u002Fpreparar.py\n   ```\n   Without the `base.apk`, but with an ARM64 APK already built by this project, the same libraries can be rebuilt from the images inside it (the script checks them byte by byte):\n   ```bash\n   python recomp\u002Freconstruir_libs.py path\u002Fto\u002FMGS2-ARM64.apk\n   python recomp\u002Freconstruir_base.py path\u002Fto\u002FMGS2-ARM64.apk\n   ```\n4. **Recompile** the game. The first run takes about 10 minutes and creates `recomp\u002Fsaida\u002F`:\n   ```bash\n   python recomp\u002Frecompilar.py\n   ```\n5. **Build the Java shell:**\n   ```bash\n   bash recomp\u002Fjava_tela\u002Fcompilar.sh\n   ```\n6. **Compile for ARM64 and package the APK:**\n   ```bash\n   python recomp\u002Fconstruir_android.py && python recomp\u002Fempacotar.py\n   MGS2_SABOR=mali python recomp\u002Fconstruir_android.py && MGS2_SABOR=mali python recomp\u002Fempacotar.py\n   ```\n   The first line builds the **Adreno** APK; the second, the **Mali** one.\n7. The APKs end up in `recomp\u002Fbuild\u002F`. On the first run, `empacotar.py` creates your own signing key (`recomp\u002Fassinatura.jks`). **Keep that key**: without it, later builds won't install over the previous one.\n\n> [!NOTE]\n> The SHIELD build has a device-exclusive licensing layer (NVSI). The component that stands in for it is **not part of this repository**.\n\n## 🙏 Credits\n\n- **Frame generation:** implementation ported from the [Eden emulator](https:\u002F\u002Fgit.eden-emu.dev\u002Feden-emu\u002Feden) (PR #4263), based on **lsfg-vk** by PancakeTAS. The shaders are from **Lossless Scaling** (THS), read from the user's own copy.\n- [Capstone](https:\u002F\u002Fwww.capstone-engine.org\u002F) (disassembly) and [Unicorn](https:\u002F\u002Fwww.unicorn-engine.org\u002F) (testing).\n- *Metal Gear Solid* is a trademark of Konami Digital Entertainment. *SHIELD* is a trademark of NVIDIA. This project is not affiliated with either.\n\n## 📜 License\n\nThe code in this repository is licensed under the [GPL-3.0](LICENSE), as it includes code derived from Eden and lsfg-vk (GPL-3.0).\n","这是一个将《合金装备2：自由之子》NVIDIA SHIELD TV版（ARM32原生）静态重编译为Android ARM64平台运行的开源项目。核心功能包括：完整函数级ARM32→ARM64静态翻译、自研轻量级运行时（替代SHIELD系统层，支持GLES 3.2、音频、JNI及内存管理）、Adreno与Mali双GPU适配、自动OBB解包、多语言菜单（7种）及可配置触控映射。不依赖模拟器，无动态翻译开销。适用于搭载高通骁龙或联发科芯片的现代Android 8.0+ ARM64设备，尤其适合因CPU架构升级（如Snapdragon 8 Elite）而无法运行原版32位游戏的用户。","2026-11-24 04:39:28","CREATED_QUERY"]