<!--
  ~ Copyright 2018 The app Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <PreferenceCategory app:title="General" app:iconSpaceReserved="false">
        <SwitchPreferenceCompat
            app:key="Main/SpeedLimiterEnabled"
            app:title="@string/settings_behavior_enable_speed_limiter"
            app:defaultValue="true"
            app:summary="Throttles the emulation speed to the chosen speed above. If unchecked, the emulator will run as fast as possible, which may not be playable."
            app:iconSpaceReserved="false" />
        <SwitchPreferenceCompat
            app:key="Main/SaveStateOnExit"
            app:title="Save State On Exit"
            app:defaultValue="true"
            app:summary="Automatically saves the emulator state when powering down or exiting. You can then resume directly from where you left off next time."
            app:iconSpaceReserved="false" />
        <SwitchPreferenceCompat
            app:key="Main/AutoLoadCheats"
            app:title="Load Cheats"
            app:defaultValue="false"
            app:summary="Loads cheats from cheats/&lt;game name&gt;.cht in PCSXR format. Cheats can be toggled while ingame."
            app:iconSpaceReserved="false" />
        <SwitchPreferenceCompat
            app:key="Display/VSync"
            app:title="Video Sync"
            app:defaultValue="true"
            app:summary="Enable this option to match DuckStation's refresh rate with your current monitor or screen. VSync is automatically disabled when it is not possible (e.g. running at non-100% speed)."
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            app:key="Audio/Sync"
            app:title="Audio Sync"
            app:defaultValue="true"
            app:summary="Throttles the emulation speed based on the audio backend pulling audio frames. This helps to remove noises or crackling if emulation is too fast. Sync will automatically be disabled if not running at 100% speed."
            app:iconSpaceReserved="false" />

        <ListPreference
            app:key="CPU/ExecutionMode"
            app:title="@string/settings_cpu_execution_mode"
            app:entries="@array/settings_cpu_execution_mode_entries"
            app:entryValues="@array/settings_cpu_execution_mode_values"
            app:defaultValue="Recompiler"
            app:useSimpleSummaryProvider="true"
            app:iconSpaceReserved="false" />

        <ListPreference
            app:key="GPU/Renderer"
            app:title="@string/settings_gpu_renderer"
            app:entries="@array/gpu_renderer_entries"
            app:entryValues="@array/gpu_renderer_values"
            app:defaultValue="OpenGL"
            app:useSimpleSummaryProvider="true"
            app:iconSpaceReserved="false" />
    </PreferenceCategory>

    <PreferenceCategory app:title="@string/settings_osd_header" app:iconSpaceReserved="false">
        <SwitchPreferenceCompat
            app:key="Display/ShowOSDMessages"
            app:title="@string/settings_osd_show_messages"
            app:defaultValue="true"
            app:summary="Shows on-screen-display messages when events occur such as save states being created/loaded, screenshots being taken, etc."
            app:iconSpaceReserved="false" />
        <SwitchPreferenceCompat
            app:key="Display/ShowSpeed"
            app:title="@string/settings_osd_show_speed"
            app:defaultValue="false"
            app:summary="Sets the target emulation speed. It is not guaranteed that this speed will be reached, and if not, the emulator will run as fast as it can manage."
            app:iconSpaceReserved="false" />
        <SwitchPreferenceCompat
            app:key="Display/ShowFPS"
            app:title="@string/settings_osd_show_show_fps"
            app:defaultValue="false"
            app:summary="Shows the internal frame rate of the game in the top-right corner of the display."
            app:iconSpaceReserved="false" />
        <SwitchPreferenceCompat
            app:key="Display/ShowVPS"
            app:title="@string/settings_osd_show_show_vps"
            app:defaultValue="false"
            app:summary="Shows the number of frames (or v-syncs) displayed per second by the system in the top-right corner of the display."
            app:iconSpaceReserved="false" />
    </PreferenceCategory>

    <PreferenceCategory app:title="@string/settings_console_header" app:iconSpaceReserved="false">

        <ListPreference
            app:key="Console/Region"
            app:title="@string/settings_console_region"
            app:entries="@array/settings_console_region_entries"
            app:entryValues="@array/settings_console_region_values"
            app:defaultValue="@string/settings_console_region_default"
            app:useSimpleSummaryProvider="true"
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            app:key="CDROM/RegionCheck"
            app:title="CD-ROM Region Check"
            app:defaultValue="false"
            app:summary="Prevents discs from incorrect regions being read by the emulator. Usually safe to disable."
            app:iconSpaceReserved="false" />

        <ListPreference
            app:key="CDROM/ReadSpeedup"
            app:title="CD-ROM Read Speedup"
            app:entries="@array/settings_cdrom_read_speedup_entries"
            app:entryValues="@array/settings_cdrom_read_speedup_values"
            app:defaultValue="1"
            app:summary="Speeds up CD-ROM reads by the specified factor. Only applies to double-speed reads, and is ignored when audio is playing. May improve loading speeds in some games, at the cost of breaking others."
            app:useSimpleSummaryProvider="true"
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            app:key="CDROM/MuteCDAudio"
            app:title="Mute CD Audio"
            app:defaultValue="false"
            app:summary="Forcibly mutes both CD-DA and XA audio from the CD-ROM. Can be used to disable background music in some games."
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            app:key="BIOS/PatchFastBoot"
            app:title="@string/settings_console_fast_boot"
            app:defaultValue="false"
            app:summary="Skips the BIOS shell/intro, booting directly into the game. Usually safe to enable, but some games break."
            app:iconSpaceReserved="false" />

    </PreferenceCategory>

    <PreferenceCategory app:title="Enhancements" app:iconSpaceReserved="false">
        <ListPreference
            app:key="GPU/ResolutionScale"
            app:title="@string/settings_gpu_resolution_scale"
            app:entries="@array/settings_gpu_resolution_scale_entries"
            app:entryValues="@array/settings_gpu_resolution_scale_values"
            app:defaultValue="1"
            app:useSimpleSummaryProvider="true"
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            app:key="GPU/TrueColor"
            app:title="True Color Rendering (24-bit, disables dithering)"
            app:summary="Forces the precision of colours output to the console's framebuffer to use the full 8 bits of precision per channel. This produces nicer looking gradients at the cost of making some colours look slightly different. Disabling the option also enables dithering, which makes the transition between colours less sharp by applying a pattern around those pixels. Most games are compatible with this option, but there is a number which aren't and will have broken effects with it enabled. Only applies to the hardware renderers."
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            app:key="GPU/ScaledDithering"
            app:title="Scaled Dithering (scale dither pattern to resolution)"
            app:defaultValue="true"
            app:summary="Scales the dither pattern to the resolution scale of the emulated GPU. This makes the dither pattern much less obvious at higher resolutions. Usually safe to enable, and only supported by the hardware renderers."
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            app:key="GPU/DisableInterlacing"
            app:title="Disable Interlacing (force progressive render/scan)"
            app:defaultValue="true"
            app:summary="Forces the rendering and display of frames to progressive mode. This removes the &quot;combing&quot; effect seen in 480i games by rendering them in 480p. Usually safe to enable."
            app:iconSpaceReserved="false" />

        <ListPreference
            app:key="GPU/TextureFilter"
            app:title="Texture Filtering"
            app:entries="@array/settings_gpu_texture_filter_names"
            app:entryValues="@array/settings_gpu_texture_filter_values"
            app:defaultValue="Nearest"
            app:useSimpleSummaryProvider="true"
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            app:key="GPU/ForceNTSCTimings"
            app:title="Force NTSC Timings (60hz-on-PAL)"
            app:defaultValue="false"
            app:summary="Uses NTSC frame timings when the console is in PAL mode, forcing PAL games to run at 60hz. For most games which have a speed tied to the framerate, this will result in the game running approximately 17% faster. For variable frame rate games, it may not affect the speed."
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            app:key="GPU/WidescreenHack"
            app:title="Widescreen Hack"
            app:defaultValue="false"
            app:summary="Scales vertex positions in screen-space to a widescreen aspect ratio, essentially increasing the field of view from 4:3 to 16:9 in 3D games. For 2D games, or games which use pre-rendered backgrounds, this enhancement will not work as expected. May not be compatible with all games."
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            app:key="Display/Force4_3For24Bit"
            app:title="Force 4:3 For 24-Bit Display"
            app:defaultValue="false"
            app:summary="Switches back to 4:3 display aspect ratio when displaying 24-bit content, usually FMVs."
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            app:key="GPU/PGXPEnable"
            app:title="PGXP Geometry Correction"
            app:defaultValue="false"
            app:summary="Reduces &quot;wobbly&quot; polygons and &quot;warping&quot; textures that are common in PS1 games. >Only works with the hardware renderers. May not be compatible with all games."
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            app:key="GPU/PGXPCulling"
            app:title="PGXP Culling Correction"
            app:defaultValue="true"
            app:summary="Increases the precision of polygon culling, reducing the number of holes in geometry. Requires geometry correction enabled."
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            app:key="GPU/PGXPTextureCorrection"
            app:title="PGXP Texture Correction"
            app:summary="Uses perspective-correct interpolation for texture coordinates and colors, straightening out warped textures. Requires geometry correction enabled."
            app:iconSpaceReserved="false" />

    </PreferenceCategory>

    <PreferenceCategory app:title="Display" app:iconSpaceReserved="false">
        <ListPreference
            app:key="Display/CropMode"
            app:title="Crop Mode"
            app:entries="@array/settings_display_crop_mode_entries"
            app:entryValues="@array/settings_display_crop_mode_values"
            app:defaultValue="Overscan"
            app:useSimpleSummaryProvider="true"
            app:iconSpaceReserved="false" />

        <ListPreference
            app:key="Display/AspectRatio"
            app:title="Aspect Ratio"
            app:entries="@array/settings_display_aspect_ratio_names"
            app:entryValues="@array/settings_display_aspect_ratio_values"
            app:defaultValue="4:3"
            app:useSimpleSummaryProvider="true"
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            app:key="Display/LinearFiltering"
            app:title="Linear Upscaling"
            app:defaultValue="true"
            app:summary="Uses bilinear texture filtering when displaying the console's framebuffer to the screen. Disabling filtering will producer a sharper, blockier/pixelated image. Enabling will smooth out the image. The option will be less noticable the higher the resolution scale."
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            app:key="Display/IntegerScaling"
            app:title="Integer Upscaling"
            app:defaultValue="false"
            app:summary="Adds padding to the display area to ensure that the ratio between pixels on the host to pixels in the console is an integer number. May result in a sharper image in some 2D games."
            app:iconSpaceReserved="false" />

    </PreferenceCategory>

    <PreferenceCategory app:title="Controller" app:iconSpaceReserved="false">
        <ListPreference
            app:key="Controller1/Type"
            app:title="Controller Type"
            app:entries="@array/settings_controller_type_entries"
            app:entryValues="@array/settings_controller_type_values"
            app:defaultValue="DigitalController"
            app:useSimpleSummaryProvider="true"
            app:iconSpaceReserved="false" />
        <SwitchPreferenceCompat
            app:key="Controller1/AutoEnableAnalog"
            app:title="Enable Analog Mode On Reset"
            app:defaultValue="false"
            app:iconSpaceReserved="false" />
        <SwitchPreferenceCompat
            app:key="Controller1/EnableTouchscreenController"
            app:title="Display Touchscreen Controller"
            app:defaultValue="true"
            app:iconSpaceReserved="false" />
    </PreferenceCategory>

    <PreferenceCategory app:title="Memory Cards" app:iconSpaceReserved="false">
    <ListPreference
            app:key="MemoryCards/Card1Type"
            app:title="Memory Card 1 Type"
            app:entries="@array/settings_memory_card_mode_entries"
            app:entryValues="@array/settings_memory_card_mode_values"
            app:defaultValue="PerGameTitle"
            app:useSimpleSummaryProvider="true"
            app:iconSpaceReserved="false" />
        <ListPreference
            app:key="MemoryCards/Card2Type"
            app:title="Memory Card 2 Type"
            app:entries="@array/settings_memory_card_mode_entries"
            app:entryValues="@array/settings_memory_card_mode_values"
            app:defaultValue="None"
            app:useSimpleSummaryProvider="true"
            app:iconSpaceReserved="false" />
    </PreferenceCategory>

    <PreferenceCategory app:title="Advanced Settings" app:iconSpaceReserved="false">
        <SwitchPreferenceCompat
            app:key="GPU/PGXPVertexCache"
            app:title="PGXP Vertex Cache"
            app:defaultValue="false"
            app:summary="Uses screen coordinates as a fallback when tracking vertices through memory fails. May improve PGXP compatibility."
            app:iconSpaceReserved="false" />
        <SwitchPreferenceCompat
            app:key="GPU/PGXPCPU"
            app:title="PGXP CPU Mode"
            app:defaultValue="false"
            app:summary="Tries to track vertex manipulation through the CPU. Some games require this option for PGXP to be effective. Very slow, and incompatible with the recompiler."
            app:iconSpaceReserved="false" />
        <SwitchPreferenceCompat
            app:key="CPU/RecompilerICache"
            app:title="CPU Recompiler ICache"
            app:defaultValue="false"
            app:summary="Determines whether the CPU's instruction cache is simulated in the recompiler. Improves accuracy at a small cost to performance. If games are running too fast, try enabling this option."
            app:iconSpaceReserved="false" />
        <SwitchPreferenceCompat
            app:key="BIOS/PatchTTYEnable"
            app:title="@string/settings_console_tty_output"
            app:defaultValue="false"
            app:iconSpaceReserved="false" />
    </PreferenceCategory>

</PreferenceScreen>
