title_name = "Gears of War 2"
title_id = "4D53082D" # MS-2093
hash = "BDB97753374D520A" # default.xex
#media_id = "33FCE762" # Disc (Europe): http://redump.org/disc/19951

[[patch]]
    name = "Unlock FPS"
    desc = "See note about framerate patches in the README."
    author = "illusion, boma"
    is_enabled = false

    [[patch.be32]]
        address = 0x824a2e94
        value = 0x60000000
    [[patch.be8]]
        address = 0x8298cfb3
        value = 0x01

[[patch]]
    name = "Black Shading Fix"
    desc = "Effectively turns off MSAA, solving the dynamic lighting artifacts caused by MSAA resolve imperfections. Use in tandem with either Ambient Occlusion or Upscaling Fix patches to prevent nearly all other artifacts."
    author = "illusion, boma"
    is_enabled = false

    [[patch.be32]] # GUseTilingMode = FALSE
        address = 0x82806a44
        value = 0x39600000 # li r11, 0

[[patch]]
    name = "Ambient Occlusion - Option A: Upscaling Fix"
    desc = "Mitigates most post-processing ghosting, shimmer, and checkerboard artifacts caused by resolution upscaling. With this patch, Disable Ambient Occlusion and Disable Depth of Field are no longer required when upscaling. For best results, do not use 3×3 scaling."
    author = "boma"
    is_enabled = false

    [[patch.be16]]
        address = 0x82806b12 # Force screen height to 0x2c0 (704)
        value = 0x02c0
    [[patch.be32]]
        address = 0x8272e00c
        value = 0x39400001
    [[patch.be32]]
        address = 0x8272ff54
        value = 0x39600001
    [[patch.be32]]
        address = 0x82807594
        value = 0x38600001
    [[patch.be32]]
        address = 0x8280759c
        value = 0x4e800020
    [[patch.be32]]
        address = 0x8272b1f8
        value = 0x4e800020
    [[patch.be16]]
        address = 0x8252d608 # Constrain Aspect Ratio
        value = 0x4800

[[patch]]
    name = "Ambient Occlusion - Option B: Disable"
    desc = "Fixes various artifacts when using upscaling."
    author = "illusion"
    is_enabled = false

    [[patch.be32]]
        address = 0x826f9d18
        value = 0x39600000

[[patch]]
    name = "Performance Patch: Optimized Settings (Smart Shadow Cuts)"
    desc = "Recommended for most people who want a moderate FPS boost without major visual loss. Some cutscenes and specific situations may be missing shadows, but the change is generally mild. The largest performance gains are typically with NVIDIA GPUs. Use in tandem with the Ambient Occlusion Upscaling Fix for best results."
    author = "boma"
    is_enabled = false

    [[patch.be32]]
        address = 0x827360c0
        value = 0x480a5efc # b 0x827dbfbc
    [[patch.be32]]
        address = 0x827dbfbc
        value = 0x7edfb378 # mr r31, r22
    [[patch.be32]]
        address = 0x827dbfc0
        value = 0x2f16000c # cmpwi r22, 12
    [[patch.be32]]
        address = 0x827dbfc4
        value = 0x41980010 # blt 0x827dbfd4
    [[patch.be32]]
        address = 0x827dbfc8
        value = 0x3be0000b # li r31, 11
    [[patch.be32]]
        address = 0x827dbfcc
        value = 0x3ac0000b # li r22, 11
    [[patch.be32]]
        address = 0x827dbfd0
        value = 0x4bf5a0f4 # b 0x827360c4
    [[patch.be32]]
        address = 0x827dbfd4
        value = 0x4bf5a0f0 # b 0x827360c4
    [[patch.be32]]
        address = 0x82741300 # Force MaxShadowResolution=400, BCPF shader choose state
        value = 0x39600190
    [[patch.be32]]
        address = 0x82741884 # Force MaxShadowResolution=400, init projected shadow depths
        value = 0x39600190

[[patch]]
    name = "Disable Motion Blur"
    desc = "Solves most ghosting and artifacting caused by quickly panning cameras."
    author = "illusion"
    is_enabled = false

    [[patch.be32]]
        address = 0x8236004c
        value = 0x39600000

[[patch]]
    name = "Texture Streaming Fix"
    desc = "Minimizes the texture pop-in common in heavy scenes, especially when using custom resolution scaling, allowing textures to stream in sooner and maintain higher visual detail during gameplay."
    author = "boma"
    is_enabled = false

    [[patch.be32]]
        address = 0x8280d534 # Set PoolSize=196
        value = 0x388000c4
    [[patch.be32]]
        address = 0x8280ddc8 # RHIGetTextureMemoryStats=FALSE, effectively locking FudgeFactor=1.0
        value = 0x38600000
    [[patch.be32]]
        address = 0x8280ddcc
        value = 0x4e800020

[[patch]]
    name = "16x Anisotropic Filtering"
    author = "boma"
    is_enabled = false

    [[patch.be32]]
        address = 0x8280e7fc
        value = 0x38a00010

[[patch]]
    name = "Disable Lens Flares"
    desc = "Fixes unoccluded bright lights on-screen."
    author = "boma"
    is_enabled = false

    [[patch.be32]]
        address = 0x827b817c
        value = 0x39400000

[[patch]]
    name = "Depth of Field, Option A - Disable Gaussian Blur (Upscaling Fix)"
    desc = "Recommended when using upscaling. Disables gaussian blur which reduces ghosting caused by blur sampling/resolves at higher internal resolutions."
    author = "boma"
    is_enabled = false

    [[patch.be32]]
        address = 0x827296bc
        value = 0xec210828
    [[patch.be32]]
        address = 0x82729700
        value = 0xec210828

[[patch]]
    name = "Depth of Field, Option B - Disable Entire DoF Pipeline"
    desc = "Disables the Uber postprocess shader pipeline. Produces a completely sharp image at all distances but also removes most post-processing effects, including tonemapping and color grading. Use Option A if you do not like the results of this patch."
    author = "boma"
    is_enabled = false

    [[patch.be32]]
        address = 0x823e1720
        value = 0x39600000
    [[patch.be32]]
        address = 0x824eceec
        value = 0x39200000
    [[patch.be32]]
        address = 0x824ed06c
        value = 0x39600000
    [[patch.be32]]
        address = 0x824ed0b0
        value = 0x39600000

[[patch]]
    name = "Disable Bloom"
    author = "boma"
    is_enabled = false

    [[patch.be32]]
        address = 0x824ecef8
        value = 0x39400000
    [[patch.be32]]
        address = 0x824ed078
        value = 0x39600000
    [[patch.be32]]
        address = 0x824ed0a4
        value = 0x39400000

[[patch]]
    name = "Disable Coalesced Hash Check"
    desc = "Allows for editing the Coalesced engine files without triggering the dirty disc error at launch."
    author = "Sowa_95, boma"
    is_enabled = false

    [[patch.be8]]
        address = 0x82aa8907
        value = 0x00
    [[patch.be32]]
        address = 0x827f9148
        value = 0x4e800020

[[patch]]
    name = "Show FPS"
    author = "Sowa_95"
    is_enabled = false

    [[patch.be8]]
        address = 0x83123468
        value = 0x01
    [[patch.be8]]
        address = 0x83123470 # Frametime
        value = 0x01

[[patch]]
    name = "21:9 Ultrawide Aspect Ratio Support"
    desc = "Must set present_letterbox = FALSE in the xenia canary config. Expands gameplay and cutscene rendering to true 21:9 ultrawide, updates the FOV axis constraint for proper framing, and adds pillarboxing for pre-rendered videos. Because the game now renders at 1280x550, certain elements may appear more aliased."
    author = "boma, TudorHorse"
    is_enabled = false

    [[patch.f32]] # GAMEPLAY & CUTSCENE FOV CAN BE ADJUSTED BY INCREASING/DECREASING THIS FIRST FLOAT IN INCREMENTS OF 0.0005
        address = 0x8263f7d4
        value = 0.0106355 # (pi / 360) * 1.295, change this value to adjust FOV
    [[patch.be32]]
        address = 0x8252d73c
        value = 0x48112088 # b 0x8263f7c4 code cave
    [[patch.be32]]
        address = 0x8263f7c4
        value = 0x3d808263 # lis r12, 0x8263
    [[patch.be32]]
        address = 0x8263f7c8
        value = 0x618cf7d4 # lwz r12, 0xf7d4, r12 = 0x8263f7d4 literal
    [[patch.be32]]
        address = 0x8263f7cc
        value = 0xc00c0000 # lfs f0, 0(r12)
    [[patch.be32]]
        address = 0x8263f7d0 # Return to calculate scene view
        value = 0x4beedf70 # b 0x8252d740
    [[patch.be16]]
        address = 0x82806b12 # Define scene color buffer height
        value = 0x0226 # 550 (1280x550)
    [[patch.be16]]
        address = 0x8252d608 # ConstrainAspectRatio = FALSE, prevents pillarboxed cutscenes
        value = 0x4800
    [[patch.f32]]
        address = 0x821d0b28 # .rdata float, controls split-screen FOV adjustments
        value = 2.33333333
    [[patch.be32]]
        address = 0x826e3720 # Set UIScene viewport height with additional height for overscan
        value = 0x38600234  # li r3, 0x234 (564)
    [[patch.be32]]
        address = 0x826e3724 # Skip if null then get from world
        value = 0x48000008

[[patch]]
    name = "Steam Deck / 16:10 Aspect Ratio Support"
    desc = "Must set present_letterbox = FALSE in the xenia canary config. Designed for Steam Deck and modern gaming laptop displays. Expands gameplay and cutscene rendering to true 16:10, updates the FOV axis constraint for proper framing, and adds letterboxing for pre-rendered videos."
    author = "boma, TudorHorse"
    is_enabled = false

    [[patch.be32]]
        address = 0x82888508 # Different FOV adj approach than the ultrawide patch.
        value = 0x4801c888 # b 0x828a4d90
    [[patch.be32]]
        address = 0x828a4d90
        value = 0x3d603f66 # lis r11, 0x3f66
    [[patch.be32]]
        address = 0x828a4d94
        value = 0x616b6666 # lwz r11, 0x6666
    [[patch.be32]]
        address = 0x828a4d98
        value = 0x91610020 # stw r11, 0x20(r1)
    [[patch.be32]]
        address = 0x828a4d9c
        value = 0xc0010020 # lfs f0, 0x20(r1)
    [[patch.be32]]
        address = 0x828a4da0
        value = 0xec210032 # fmuls f1, f1, f0
    [[patch.be32]]
        address = 0x828a4da4 # Recreate original 0x82888508 instruction
        value = 0x38210090 # addi r1, r1, 0x90
    [[patch.be32]]
        address = 0x828a4da8
        value = 0x4bfe3764 # b 0x8288850c
    [[patch.be16]]
        address = 0x82806e6a # Define scene color buffer width
        value = 0x0480 # 1152 (1152x720)
    [[patch.be16]]
        address = 0x8252d608 # ConstrainAspectRatio = FALSE, prevents letterboxed cutscenes
        value = 0x4800
    [[patch.f32]]
        address = 0x821d0b28 # .rdata float, controls split-screen FOV adjustments
        value = 1.6
