####################################################
# Alex Builds His Farm Widescreen Fix V1.0 by lk19 #
####################################################

################
# 0 - Features #
################

There are two versions of the patch.

Version A:
	- Removes the CD check
	- Reads ubi.ini DIRECTLY from the game's directory rather than <WinDir>\Ubisoft
	- Fixes the placement of the "green bar" (HUD element) on resolutions other than 640x480
	- Corrects the FOV so that the vertical FOV matches the one in the original 4:3 aspect ratio
	
Version B:
	- Everything that version A does
	- Un-stretches menu backgrounds and loading screens (they are centered with black bars on the sides)
	- Un-stretches 2D HUD elements
	- Un-stretches text (e.g. in the game's credits)

#############
# 1 - Notes #
#############

- This is for the original version of the game only, not for the Pentium III version.

- The patch was developed for the European English/French/German release, but should work with other versions as well (tested with the Dutch and Brazilian Portuguese version)

- The Python source code (in the "src" folder) is mainly for documentation. It does not need to be run.


##################
# 2 Instructions #
##################

1) Replace Alex_D3D.exe in the game folder with the desired version (A or B)
2) Copy (or move) ubi.ini from <WinDir>\Ubisoft to the game folder
3) Open ubi.ini. Under [Alex Builds His Farm], add the line ScreenSize=1920x1080 (or any other desired resolution)
4) IMPORTANT (the game will crash if you skip this step):
	i) Open <path-to-game>\GameData\Gamemem.bin with a hex editor such as HxD.
    ii) In HxD, if the Data Inspector is not visible on the right hand side, press Ctrl+Alt+D (or click View -> Data inspector). The Byte order in the Data Inspector needs to be set to Little Endian.
    iii) Press Ctrl+G (or click Search -> Go to...). Make sure that "hex" and "Offset relative to: begin" are selected. Type in the offset "3C" and press return. The cursor should jump to the relevant offset. From there, select the following four bytes (they may vary between different versions of the game, but should be 00 12 7A 00 in the English/French/German release). This is the TMPFixMemory.
    iv) In the Data Inspector under Int32, increase the memory amount to the desired value. 25000000 should be enough to run the game at 1920x1080.
    v) Repeat steps iii and iv, but this time with the offset "88" instead of "3C". This is the TMPLevelMemory. Again, 25000000 should be enough to run the game 1920x1080.
    vi) Click the save icon to save the changes made to Gamemem.bin.
5) Configure a DirectX wrapper to run the game. Instructions can be found here:
	https://www.pcgamingwiki.com/wiki/Alex_Builds_His_Farm#Direct3D_wrapper
	
(Notes): 
- The amount of memory that needs to be set in Gamemem.bin depends on the resolution set in ubi.ini (not the actual screen resolution). 
- If the game crashes, whenever entering a certain map, this might be an indication that the TMPLevelMemory was set too low.
- There is no need to set the resolution in ubi.ini very high, only the aspect ratio needs to be correct. For example, a resolution of 1280x720 is more than enough for a 16:9 aspect ratio. The DirectX wrapper can be configured to scale it up to, for example, 1920x1080 or 3840x2160 (4k).
- If the resolution set in ubi.ini is set too low, then the 2D background images will be downsampled, so do not set the resolution VERY low. Anything with a y-resolution that is at least the original of 480, should be fine.
- The resolution in ubi.ini needs to be a native resolution of the monitor, because the game does not accept non-native resolutions. A non-native resolution can still be set, if the DirectX wrapper is configured to report it to the game as "native" (see the link under 5).
