[BotW] Fix centered HUD mode

Forgot how I made my original formula for the edge HUD, but now I finally understand MATH!
This commit is contained in:
Crementif 2022-01-21 18:58:42 +01:00
parent 4cdffcaef2
commit 84fb724c9e
No known key found for this signature in database
GPG Key ID: 12BB8BD3EA30651E

View File

@ -607,7 +607,7 @@ b exitScale
const_SensorsOffset: const_SensorsOffset:
.float 392.0 .float 392.0
scaleSensorMeterPanes: scaleSoundMeterPanes:
addi r5, r31, 0x80 addi r5, r31, 0x80
lis r10, const_SensorsOffset@ha lis r10, const_SensorsOffset@ha
lfs f12, const_SensorsOffset@l(r10) lfs f12, const_SensorsOffset@l(r10)
@ -616,7 +616,7 @@ addi r10, r10, str_N_InOut_00@l
bla _compareString bla _compareString
beq scalePaneAndKeepCustomPosIf beq scalePaneAndKeepCustomPosIf
b exitScale b exitScale
scaleSoundMeterPanes: scaleSensorMeterPanes:
addi r5, r31, 0x80 addi r5, r31, 0x80
lis r10, const_SensorsOffset@ha lis r10, const_SensorsOffset@ha
lfs f12, const_SensorsOffset@l(r10) lfs f12, const_SensorsOffset@l(r10)
@ -635,7 +635,7 @@ bla _compareString
beq scalePaneAndKeepCustomPosIf beq scalePaneAndKeepCustomPosIf
b exitScale b exitScale
const_TimeOffset: const_TimeOffset:
.float 342*0.85 .float (($ultrawideHUDMode == 1) * (342*0.85)) + (($ultrawideHUDMode == 2)*(342*(1/0.85)))
scaleMainScreenTimePanes: scaleMainScreenTimePanes:
addi r5, r31, 0x80 addi r5, r31, 0x80
lis r10, const_TimeOffset@ha lis r10, const_TimeOffset@ha
@ -2436,6 +2436,12 @@ const_640:
const_1: const_1:
.float 1.0 .float 1.0
scalePaneAndKeepPosIf:
li r10, $ultrawideHUDMode
cmpwi r10, 1
beq scalePaneAndKeepPos
bne scalePaneAndPos
scalePaneAndKeepPos: scalePaneAndKeepPos:
lis r10, const_AspectRatio@ha lis r10, const_AspectRatio@ha
lfs f0, const_AspectRatio@l(r10) lfs f0, const_AspectRatio@l(r10)
@ -2469,44 +2475,12 @@ fsubs f0, f11, f0
stfs f0, 0x1C(r31) stfs f0, 0x1C(r31)
b exitScale b exitScale
scalePaneAndKeepPosIf:
li r10, $ultrawideHUDMode
cmpwi r10, 1
beq scalePaneAndKeepPos
bne scalePaneAndPos
moveKeepPos:
lis r10, const_0@ha
lfs f11, const_0@l(r10)
lfs f9, 0x1C(r31)
fcmpu f9, f11
lis r10, const_640@ha
lfs f0, const_640@l(r10)
lfs f9, 0x1C(r31)
bge .+0x08
fsubs f9, f11, f9
fsubs f0, f0, f9
lis r10, const_1@ha
lfs f13, const_1@l(r10)
lis r10, const_AspectRatio@ha
lfs f9, const_AspectRatio@l(r10)
fsubs f13, f13, f9
fmuls f0, f0, f13
lfs f9, 0x1C(r31)
bge .+0x08
fsubs f9, f11, f9
fadds f0, f9, f0
bge .+0x08
fsubs f0, f11, f0
stfs f0, 0x1C(r31)
b exitScale
; Pass custom pos as f12 ; Pass custom pos as f12
scalePaneAndKeepCustomPosIf: scalePaneAndKeepCustomPosIf:
li r10, $ultrawideHUDMode li r10, $ultrawideHUDMode
cmpwi r10, 1 cmpwi r10, 1
beq scalePaneAndKeepCustomPos beq scalePaneAndKeepCustomPos
bne scalePaneAndCenterCustomPos bne scalePaneAndCustomPos
scalePaneAndKeepCustomPos: scalePaneAndKeepCustomPos:
lis r10, const_AspectRatio@ha lis r10, const_AspectRatio@ha
@ -2515,6 +2489,7 @@ lfs f9, 0x34(r31)
fmuls f0, f0, f9 fmuls f0, f0, f9
stfs f0, 0x34(r31) stfs f0, 0x34(r31)
; [XPositionOfPane] + ((1280/2 - [XPositionOfPane]) * (1-[AspectRatio])))
lis r10, const_0@ha lis r10, const_0@ha
lfs f11, const_0@l(r10) lfs f11, const_0@l(r10)
lfs f9, 0x1C(r31) lfs f9, 0x1C(r31)
@ -2544,15 +2519,48 @@ fsubs f0, f0, f12
stfs f0, 0x1C(r31) stfs f0, 0x1C(r31)
b exitScale b exitScale
; todo: currently broken for left-sided elements # ; [XPositionOfPane] + ((1280/2 - [XPositionOfPane]) * (1-[AspectRatio])))
scalePaneAndCenterCustomPos: # lis r10, const_640@ha
# lfs f0, const_640@l(r10) ; (1280/2)
# lfs f9, 0x1C(r31)
# fadds f9, f9, f12 ; Create XPositionOfPane (add position of current pane + custom position of parent pane)
# fsubs f0, f0, f9 ; (1280/2) - XPositionOfPane
# lis r10, const_1@ha
# lfs f13, const_1@l(r10)
# lis r10, const_AspectRatio@ha
# lfs f9, const_AspectRatio@l(r10)
# fsubs f13, f13, f9 ; (1-[AspectRatio])
# fmuls f0, f0, f13 ; ((1280/2) - XPositionOfPane) * (1-[AspectRatio])
# lfs f9, 0x1C(r31)
# fadds f9, f9, f12 ; [XPositionOfPane]
# fadds f0, f9, f0 ; [XPositionOfPane] + ((1280/2 - [XPositionOfPane]) * (1-[AspectRatio])))
# fsubs f0, f0, f12
; Explanation: The current position is 3x as big as it should be (let's take 3x at 48:9), so to correct that you scale it back by
; XPositionOfPane*(1-AspectRatio)
scalePaneAndCustomPos:
lis r10, const_AspectRatio@ha lis r10, const_AspectRatio@ha
lfs f0, const_AspectRatio@l(r10) lfs f0, const_AspectRatio@l(r10)
lfs f9, 0x34(r31) lfs f9, 0x34(r31)
fmuls f0, f0, f9 fmuls f0, f0, f9
stfs f0, 0x34(r31) stfs f0, 0x34(r31)
; [XPositionOfPane] + ((1280/2 - [XPositionOfPane]) * (1-[AspectRatio]))) lis r10, const_1@ha
lfs f9, const_1@l(r10)
lis r10, const_AspectRatio@ha
lfs f0, const_AspectRatio@l(r10)
fsubs f0, f9, f0
lfs f9, 0x1C(r31)
fsubs f9, f9, f12
fmuls f0, f9, f0
stfs f0, 0x1C(r31)
b exitScale
moveKeepPos:
lis r10, const_0@ha lis r10, const_0@ha
lfs f11, const_0@l(r10) lfs f11, const_0@l(r10)
lfs f9, 0x1C(r31) lfs f9, 0x1C(r31)
@ -2576,20 +2584,22 @@ fadds f0, f9, f0
bge .+0x08 bge .+0x08
fsubs f0, f11, f0 fsubs f0, f11, f0
stfs f0, 0x1C(r31) stfs f0, 0x1C(r31)
lis r10, const_640@ha
lfs f11, const_640@l(r10)
fsubs f0, f0, f11
stfs f0, 0x1C(r31)
b exitScale b exitScale
movePaneToCustomSize: ; Pass the scale in f0 and position in f12
lis r10, const_AspectRatio@ha scalePaneWithCustomPosAndScale:
lfs f0, const_AspectRatio@l(r10)
lfs f9, 0x34(r31) lfs f9, 0x34(r31)
fmuls f0, f0, f9 fmuls f0, f0, f9
stfs f0, 0x34(r31) stfs f0, 0x34(r31)
lfs f9, 0x1C(r31)
fsubs f0, f9, f12
stfs f12, 0x1C(r31)
b exitScale
movePaneToCustomPos:
lfs f9, 0x1C(r31)
fsubs f0, f9, f12
stfs f12, 0x1C(r31) stfs f12, 0x1C(r31)
b exitScale b exitScale