From 16365d54f351c056785d474c6997b3574d55288b Mon Sep 17 00:00:00 2001
From: Michael <goldtextwitch@outlook.com>
Date: Tue, 17 Oct 2017 15:50:26 -0700
Subject: [PATCH] [Sploot] Add build script

---
 Source/Splatoon/patches.txt | 60 ++++++++++++++++++++++++
 Source/Splatoon/rules.txt   | 93 +++++++++++++++++++++++++++++++++++++
 build.sh                    | 17 ++++++-
 3 files changed, 168 insertions(+), 2 deletions(-)
 create mode 100644 Source/Splatoon/patches.txt
 create mode 100644 Source/Splatoon/rules.txt

diff --git a/Source/Splatoon/patches.txt b/Source/Splatoon/patches.txt
new file mode 100644
index 00000000..6b4570da
--- /dev/null
+++ b/Source/Splatoon/patches.txt
@@ -0,0 +1,60 @@
+<?php
+$width = $argv[1];
+$height = $argv[2];
+
+$aspect = $width / (float)$height;
+
+if (round($aspect*100.0) == 178)
+	exit(1);
+
+$aspect = number_format((float)$aspect, 3, '.', '');
+?>
+[SplatoonV272uw]
+moduleMatches = 0xF7A78809
+
+#rodata constants
+
+0x1004364C = .float <?=$aspect?> 
+0x10124BE0 = .float <?=$aspect?> 
+0x10158FE0 = .float <?=$aspect?> 
+0x10160454 = .float <?=$aspect?> 
+
+_aspectAddr = 0x1004364C
+
+#patches
+
+0x028B1910 = lis r29, _aspectAddr@ha ;hud
+0x028B1914 = lfs f13, _aspectAddr@l(r29) ;hud
+
+0x02014864 = lis r4, _aspectAddr@ha ;master ar
+0x0201486C = lfs f9, _aspectAddr@l(r4) ;master ar
+
+0x02014570 = lis r4, _aspectAddr@ha ;transition frames
+0x02014578 = lfs f9, _aspectAddr@l(r4)
+0x0201434C = lis r4, _aspectAddr@ha
+0x02014354 = lfs f9, _aspectAddr@l(r4)
+
+[SplatoonV0uw]
+moduleMatches = 0x08ED6677
+
+#rodata constants
+0x1003C670 = .float <?=$aspect?> 
+0x101092B0 = .float <?=$aspect?> 
+0x10144564 = .float <?=$aspect?> 
+0x1014A514 = .float <?=$aspect?> 
+
+_aspectAddr = 0x1003C670
+
+#patches
+
+0x027E6400 = lis r29, _aspectAddr@ha ;hud
+0x027E6404 = lfs f13, _aspectAddr@l(r29) ;hud
+
+0x02015690 = lis r4, _aspectAddr@ha ;master AR
+0x02015698 = lfs f9, _aspectAddr@l(r4)
+
+0x0201539C = lis r4, _aspectAddr@ha ;Transition frames
+0x020153A4 = lfs f9, _aspectAddr@l(r4)
+
+0x02015178 = lis r4, _aspectAddr@ha ;Transition frames
+0x02015180 = lfs f9, _aspectAddr@l(r4) 
\ No newline at end of file
diff --git a/Source/Splatoon/rules.txt b/Source/Splatoon/rules.txt
new file mode 100644
index 00000000..144c0a41
--- /dev/null
+++ b/Source/Splatoon/rules.txt
@@ -0,0 +1,93 @@
+<?php
+$fullWidth = $argv[1];
+$fullHeight = $argv[2];
+$scaleFactorX = $fullWidth / 1280.0;
+$scaleFactorY = $fullHeight / 720.0;
+
+$title = $fullWidth . "x" . $fullHeight;
+
+$aspect = $fullWidth / (float)$fullHeight;
+if (round($aspect*10) == 23 || round($aspect*10) == 24)
+	$title = $title . " (21:9)";
+?>
+[Definition]
+titleIds = 0005000010176900,0005000010176A00,0005000010162B00
+name = "Splatoon - <?=$title?>"
+version = 2
+
+[TextureRedefine] # tv
+width = 1280
+height = 720
+overwriteWidth = <?=round($scaleFactorX*1280)?> 
+overwriteHeight = <?=round($scaleFactorY*720)?> 
+
+[TextureRedefine] # half-res alpha
+width = 640
+height = 360
+formatsExcluded = 0x41A,0x431 # exclude obvious textures
+overwriteWidth = <?=round($scaleFactorX*640)?> 
+overwriteHeight = <?=round($scaleFactorY*360)?> 
+
+[TextureRedefine] # quarter-res alpha
+width = 320
+height = 180
+formatsExcluded = 0x41A,0x431 # exclude obvious textures
+overwriteWidth = <?=round($scaleFactorX*320)?> 
+overwriteHeight = <?=round($scaleFactorY*180)?> 
+
+[TextureRedefine] # squid sisters
+width = 1024
+height = 576
+overwriteWidth = <?=round($scaleFactorX*1024)?> 
+overwriteHeight = <?=round($scaleFactorY*576)?> 
+
+[TextureRedefine] # gamepad
+width = 854
+height = 480
+overwriteWidth = <?=round($scaleFactorX*1280)?> 
+overwriteHeight = <?=round($scaleFactorY*720)?> 
+
+[TextureRedefine] # zoom blur
+width = 512
+height = 288
+overwriteWidth = <?=round($scaleFactorX*512)?> 
+overwriteHeight = <?=round($scaleFactorY*288)?> 
+
+[TextureRedefine] # sub zoom blur
+width = 448
+height = 252
+overwriteWidth = <?=round($scaleFactorX*448)?> 
+overwriteHeight = <?=round($scaleFactorY*252)?> 
+
+[TextureRedefine] # player icon - GL_SRGB8_ALPHA8
+width = 128
+height = 128
+formats = 0x41A
+#overwriteWidth = 384
+#overwriteHeight = 384 #Need to confirm on next Cemu version
+
+[TextureRedefine] # player icon - GL_RGBA8
+width = 256
+height = 256
+formats = 0x01a
+#overwriteWidth = 768
+#overwriteHeight = 768 #Need to confirm on next Cemu version
+
+[TextureRedefine] # multiplayer
+width = 848
+height = 480
+overwriteWidth = <?=round($scaleFactorX*1280)?> 
+overwriteHeight = <?=round($scaleFactorY*720)?> 
+
+[TextureRedefine] # half-res alpha (multiplayer)
+width = 424
+height = 240
+overwriteWidth = <?=round($scaleFactorX*640)?> 
+overwriteHeight = <?=round($scaleFactorY*360)?> 
+
+[TextureRedefine] # a bloom mip
+width = 160
+height = 90
+formats = 0x816
+overwriteWidth = <?=round($scaleFactorX*160)?> 
+overwriteHeight = <?=round($scaleFactorY*90)?> 
\ No newline at end of file
diff --git a/build.sh b/build.sh
index aa27a8b0..5711a74a 100644
--- a/build.sh
+++ b/build.sh
@@ -48,9 +48,22 @@ build_dir "Source/BreathOfTheWild" "Quality/BreathOfTheWild_1440pUW" 3440 1440
 build_dir "Source/BreathOfTheWild" "Quality/BreathOfTheWild_1800p" 3200 1800
 build_dir "Source/BreathOfTheWild" "Quality/BreathOfTheWild_2160p" 3840 2160
 build_dir "Source/BreathOfTheWild" "Quality/BreathOfTheWild_2160pUW" 5120 2160
-build_dir "Source/BreathOfTheWild" "Quality/BreathOfTheWild_Switch" 1600 900
+build_dir "Source/BreathOfTheWild" "Quality/BreathOfTheWild_900p" 1600 900
 build_dir "Source/BreathOfTheWild" "Enthusiast/BreathOfTheWild_2880p" 5120 2880
 build_dir "Source/BreathOfTheWild" "Enthusiast/BreathOfTheWild_4320p" 7680 4320
 build_dir "Source/BreathOfTheWild" "Enthusiast/BreathOfTheWild_5760p" 10240 5760
 build_dir "Source/BreathOfTheWild" "Performance/BreathOfTheWild_360p" 640 360
-build_dir "Source/BreathOfTheWild" "Performance/BreathOfTheWild_540p" 960 540
\ No newline at end of file
+build_dir "Source/BreathOfTheWild" "Performance/BreathOfTheWild_540p" 960 540
+build_dir "Source/Splatoon" "Quality/Splatoon_1080p" 1920 1080
+build_dir "Source/Splatoon" "Quality/Splatoon_1080pUW" 2560 1080
+build_dir "Source/Splatoon" "Quality/Splatoon_1440p" 2560 1440
+build_dir "Source/Splatoon" "Quality/Splatoon_1440pUW" 3440 1440
+build_dir "Source/Splatoon" "Quality/Splatoon_1800p" 3200 1800
+build_dir "Source/Splatoon" "Quality/Splatoon_2160p" 3840 2160
+build_dir "Source/Splatoon" "Quality/Splatoon_2160pUW" 5120 2160
+build_dir "Source/Splatoon" "Quality/Splatoon_900p" 1600 900
+build_dir "Source/Splatoon" "Enthusiast/Splatoon_2880p" 5120 2880
+build_dir "Source/Splatoon" "Enthusiast/Splatoon_4320p" 7680 4320
+build_dir "Source/Splatoon" "Enthusiast/Splatoon_5760p" 10240 5760
+build_dir "Source/Splatoon" "Performance/Splatoon_360p" 640 360
+build_dir "Source/Splatoon" "Performance/Splatoon_540p" 960 540
\ No newline at end of file