# PlatPC
Pokemon Platinum PC Port

## System Requirements
* Windows or Linux
* GPU with OpenGL 4.2 support (you can try running with llvmpipe but it might be slow!)

## Supported Features
* Graphics
  * Internal resolution of the 3D graphics can be increased throught the config file. By default this is 10x.
  * A 60fps patch is enabled by default with some speed fixes, though some things will still be double speed
  * There may be some graphical issues with the 3D
  * Screen layout can be adjusted through the config file or IMGUI
* Audio
* Touchscreen (simulated with mouse)
* Both the PC port and the NDS ROM can be built and debugged from the same source tree
* Playing the game from start to finish
* Poketch
* Battle frontier
* Contests
* Debug features (this build by deafault has PM_DEBUG turned on)
* IMGUI (press TAB)
* Saving
  * The save file is just the raw data that would be written through SDK backup APIs, and is currently not compatible with emulators.
* Local multiplayer over LAN or internet (press tab and select NET in the IMGUI)
  * Union Room
  * Underground
  * Local multiplayer is over port 2009. You can port forward or use a VPN like hamachi to play over the internet
* Some WiFi features (WiFi plaza, WiFi club, GTS is only partially supported and has bugs)
  * Voice chat (libVCT) is NOT supported
  * By deafault, the Poke Classic DNS is used. You can go to the wifi settings from the main menu of the game to change to whatever DNS you want.
  * In my testing, I was able to trade and battle with a real DS using the WiFi club but it is very finnicky and can be difficult to get both devices to connect to each other

### Note
Portions of this software, specifically the SIM library in NitroSDK use snippets of code from melonDS, licensed under GPLv3
  
## Building on Windows
You need some 32 bit version of MS Office (2003 is recommended, but newer versions have also worked) in order for ExcelSeetConverter to work.

* Run Install_MSys2.ps1 through PowerShell. This will set up MSYS2 and all required packages to build the SDK and PlatPC.
* To enter the environment, run either LaunchEnv_ARM.ps1 or LaunchEnv_Win64.ps1 depending on which target you want to build.
* Once in the build environment, go inside the "main" directory and run these commands:
* "make allsdk" to build NitroSDK, NitroSystem, NitroWiFi, and NitroDWC.
* "make" to build the project. Note that by default, the SDKs are not built on an incremental build to cut down on build times.
* You can run the SDK and project build in a sequence with the "build_all.sh" script inside of the "main" directory.

## Building on Linux
The linux build uses a Debian 13 docker container with the following packages installed:
* g++
* gcc
* libenet-dev
* libsdl2-dev
* libsdl2-mixer-dev
* make
* perl
* ruby
* wine (10.0~repack-6)

By default, the environment will set the WINEPREFIX to $(repoRoot)/wine

For ExcelSeetConverter to work, you will need to install Office 2003 into this wine prefix. 
Go to the root of the repo and run ./scripts/setup_wineprefix.sh
* This will download office 2003 iso from archive.org, mount it (you will need to enter sudo password), and run the setup exe. TODO: Make this setup unattended and use a userspace mount that does not need root privileges

Use ./drun.sh to interact with the docker build environment. The first time this is run, the container image will be built.

drun.sh usage:
* ./drun.sh {command}"
* or ./drun.sh --arm {command} to use the ARM build environment variables. This will build a NDS rom.
* use --interactive instead of {command} for an interactive shell.

To build NitroSDK: ./drun.sh make nitrosdk
To build all SDKs: ./drun.sh make allsdk
To build the project: ./drun.sh make

### Debugging
To run this project, you will need SDL2 and enet libraries installed on your system.
Use the following block in a vscode launch.json to run with lldb:
```
        {
            "name": "Debug (LLDB)",
            "type": "lldb",
            "request": "launch",
            "program": "${workspaceFolder}/bin/eng/X86-TS/Release/main",
            "cwd": "${workspaceFolder}/bin/eng/X86-TS/Release",
            "initCommands": [
                "settings set target.source-map /main ${workspaceRoot}"
            ]
        }
```
