<!--
 Copyright (c) 2019 Emilian Roman
 
 This software is provided 'as-is', without any express or implied
 warranty. In no event will the authors be held liable for any damages
 arising from the use of this software.
 
 Permission is granted to anyone to use this software for any purpose,
 including commercial applications, and to alter it and redistribute it
 freely, subject to the following restrictions:
 
 1. The origin of this software must not be misrepresented; you must not
    claim that you wrote the original software. If you use this software
    in a product, an acknowledgment in the product documentation would be
    appreciated but is not required.
 2. Altered source versions must be plainly marked as such, and must not be
    misrepresented as being the original software.
 3. This notice may not be removed or altered from any source distribution.
-->

LOADER KERNEL
=============

The kernel is the core component of HXE, which is responsible for:

1.  determining the player's campaign progress for resuming; and
2.  inferring the post-processing settings and encoding them; and
3.  applying video/audio/input enhancements and initiation tweaks; and
4.  patching the HCE executable with Large Address Aware; and
5.  loading SPV3 with user start-up parameters for HCE.

The sections below elaborate upon the aforementioned steps.

ROUTINES
--------

The kernel routines are executed in the following order:

-   INIT ........ initiation routines
    -   RESUME .. spv3 campaign resuming
    -   TWEAKS .. spv3/hce launch tweaks
    -   SHADER .. spv3.2 post-processing
    -   UNLOCK .. spv3.2 campaign unlock
-   BLAM ........ profile tweaks routines
    -   VIDEO ... video tweaks & custom resolution
    -   AUDIO ... audio enhancements & eax/hw
    -   INPUT ... controller input overriding
-   EXEC ........ hce execution routines
    -   RESET ... kill running hce processes
    -   PATCH ... apply conditional laa patching
    -   START ... start the hce executable
    -   BLESS ... post-launch border-less patch

All of the routines above can be reviewed in their respective
documentation.

CONFIGURATION
-------------

Kernel and post-processing settings are by default at the following
path:

    %APPDATA%\HXE\kernel.bin

The configuration can be changed from the CLI using:

    .\hxe.exe -config

Currently, the binary stores the following categories:

  Offset   Property
  -------- -------------------
  0x00     Vanity Signature
  0x10     HXE Kernel Mode
  0x20     Main Execution
  0x30     Video Patches
  0x40     Audio Patches
  0x50     Input Patches
  0x60     Initiation Tweaks
  0xA0     SPV3.2 Shaders

KERNEL MODE

The routines the kernel carries out depend on its selected mode:

  Mode     Summary
  -------- --------------------------------------------------------------
  HCE      Video, audio, input enhancements and initiation tweaks
  SPV3.2   HCE mode, but with post-processing & SPV3.2 compatibility
  SPV3.1   HCE mode, no SPV3.2 mode, but with SPV3.1 campaing unlocking

AVAILABLE OPTIONS

The following table outlines the available options:

  Section             Property              Type     Offset
  ------------------- --------------------- -------- --------
  Main Execution      Reset                 bool     0x20
                      Patch                 bool     0x21
                      Start                 bool     0x22
                      Resume                bool     0x23
                      Elevated              bool     0x24
  Video Patches       Resolution            bool     0x30
                      Uncap                 bool     0x31
                      Quality               bool     0x32
                      Gamma                 byte     0x33
                      Borderless            bool     0x34
  Audio Patches       Quality               bool     0x40
                      Enhancements          bool     0x41
  Input Patches       Override              bool     0x50
  Initiation Tweaks   Cinematic             bool     0x60
                      Sensor                bool     0x60
                      Magnetism             bool     0x60
                      Auto Aim              bool     0x60
                      Acceleration          bool     0x60
                      Unload                bool     0x60
                      Speed                 double   0x60
  SPV3.2 Shaders      Internal              bool     0xA0
                      External              bool     0xA1
                      G-Buffer              bool     0xA2
                      Depth Fade            bool     0xA3
                      Bloom                 bool     0xA4
                      LensDirt              bool     0xA5
                      Dynamic Lens Flares   bool     0xA6
                      Volumetric Lighting   bool     0xA7
                      Anti Aliasing         bool     0xA8
                      HUD Visor             bool     0xA9
                      Film Grain            bool     0xAA
                      Motion Blur           byte     0xAB
                      MXAO                  byte     0xAC
                      DOF                   byte     0xAD
                      SSR                   byte     0xAE

Implicitly speaking, the aforementioned properties are:

-   representative of what the kernel does;
-   configurable by the end-user;
-   stored in the kernel configuration.
