[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

@ -86,7 +86,7 @@ bne checkScreenNames
lis r11, copySubPanelStringLen@ha lis r11, copySubPanelStringLen@ha
lwz r11, copySubPanelStringLen@l(r11) lwz r11, copySubPanelStringLen@l(r11)
lis r12, copySubPanelString@ha lis r12, copySubPanelString@ha
addi r12, r12, copySubPanelString@l addi r12, r12, copySubPanelString@l
copySubPanelLoop: copySubPanelLoop:
lbzx r10, r5, r11 lbzx r10, r5, r11
@ -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
@ -2172,7 +2172,7 @@ b exitScale
; Generic methods used to scale a specific pane type ; Generic methods used to scale a specific pane type
scaleRootToCenter: scaleRootToCenter:
addi r5, r31, 0x80 ; address to first character of the pane name that's getting loaded addi r5, r31, 0x80 ; address to first character of the pane name that's getting loaded
lis r10, str_RootPane@ha lis r10, str_RootPane@ha
addi r10, r10, str_RootPane@l addi r10, r10, str_RootPane@l
bla _compareString bla _compareString
@ -2261,13 +2261,13 @@ b exitScale
scalePaneAndSize: scalePaneAndSize:
lis r10, const_AspectRatio@ha lis r10, const_AspectRatio@ha
lfs f9, const_AspectRatio@l(r10) lfs f9, const_AspectRatio@l(r10)
lfs f0, 0x0(r27) lfs f0, 0x0(r27)
fmuls f0, f0, f9 fmuls f0, f0, f9
stfs f0, 0x0(r27) stfs f0, 0x0(r27)
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)
@ -2275,7 +2275,7 @@ b exitScale
scaleOnlySize: scaleOnlySize:
lis r10, const_AspectRatio@ha lis r10, const_AspectRatio@ha
lfs f9, const_AspectRatio@l(r10) lfs f9, const_AspectRatio@l(r10)
lfs f0, 0x0(r27) lfs f0, 0x0(r27)
fmuls f0, f0, f9 fmuls f0, f0, f9
stfs f0, 0x0(r27) stfs f0, 0x0(r27)
@ -2283,7 +2283,7 @@ b exitScale
scaleOnlySizeReverse: scaleOnlySizeReverse:
lis r10, const_ReverseAspectRatio@ha lis r10, const_ReverseAspectRatio@ha
lfs f9, const_ReverseAspectRatio@l(r10) lfs f9, const_ReverseAspectRatio@l(r10)
lfs f0, 0x0(r27) lfs f0, 0x0(r27)
fmuls f0, f0, f9 fmuls f0, f0, f9
stfs f0, 0x0(r27) stfs f0, 0x0(r27)
@ -2292,7 +2292,7 @@ b exitScale
; Scales pane to left side ; Scales pane to left side
scalePaneToLeftSide: scalePaneToLeftSide:
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)
@ -2329,7 +2329,7 @@ b exitScale
; Scales pane to right side ; Scales pane to right side
scalePaneToRightSide: scalePaneToRightSide:
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)
@ -2359,7 +2359,7 @@ b exitScale
scalePaneToRightSideAlt: scalePaneToRightSideAlt:
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)
@ -2373,7 +2373,7 @@ b exitScale
scalePaneReverseToLeft: scalePaneReverseToLeft:
lis r10, const_ReverseAspectRatio@ha lis r10, const_ReverseAspectRatio@ha
lfs f0, const_ReverseAspectRatio@l(r10) lfs f0, const_ReverseAspectRatio@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)
@ -2387,7 +2387,7 @@ b exitScale
scalePaneReverseToRight: scalePaneReverseToRight:
lis r10, const_ReverseAspectRatio@ha lis r10, const_ReverseAspectRatio@ha
lfs f0, const_ReverseAspectRatio@l(r10) lfs f0, const_ReverseAspectRatio@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)
@ -2402,7 +2402,7 @@ b exitScale
; Divides the width of this element with the change in aspect ratio ; Divides the width of this element with the change in aspect ratio
scalePaneNormal: scalePaneNormal:
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)
@ -2410,13 +2410,13 @@ b exitScale
scalePaneAndPos: scalePaneAndPos:
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)
lis r10, const_AspectRatio@ha lis r10, const_AspectRatio@ha
lfs f0, const_AspectRatio@l(r10) lfs f0, const_AspectRatio@l(r10)
lfs f9, 0x1C(r31) lfs f9, 0x1C(r31)
fmuls f0, f0, f9 fmuls f0, f0, f9
stfs f0, 0x1C(r31) stfs f0, 0x1C(r31)
@ -2424,7 +2424,7 @@ b exitScale
scaleOnlyPos: scaleOnlyPos:
lis r10, const_AspectRatio@ha lis r10, const_AspectRatio@ha
lfs f0, const_AspectRatio@l(r10) lfs f0, const_AspectRatio@l(r10)
lfs f9, 0x1C(r31) lfs f9, 0x1C(r31)
fmuls f0, f0, f9 fmuls f0, f0, f9
stfs f0, 0x1C(r31) stfs f0, 0x1C(r31)
@ -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,26 +2584,28 @@ 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
scalePaneHalf: scalePaneHalf:
lis r10, const_AspectRatioHalf@ha lis r10, const_AspectRatioHalf@ha
lfs f0, const_AspectRatioHalf@l(r10) lfs f0, const_AspectRatioHalf@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)
@ -2603,7 +2613,7 @@ b exitScale
scalePaneReverse: scalePaneReverse:
lis r10, const_ReverseAspectRatio@ha lis r10, const_ReverseAspectRatio@ha
lfs f0, const_ReverseAspectRatio@l(r10) lfs f0, const_ReverseAspectRatio@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)
@ -2611,13 +2621,13 @@ b exitScale
scalePaneAndPosReverse: scalePaneAndPosReverse:
lis r10, const_ReverseAspectRatio@ha lis r10, const_ReverseAspectRatio@ha
lfs f0, const_ReverseAspectRatio@l(r10) lfs f0, const_ReverseAspectRatio@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)
lis r10, const_ReverseAspectRatio@ha lis r10, const_ReverseAspectRatio@ha
lfs f0, const_ReverseAspectRatio@l(r10) lfs f0, const_ReverseAspectRatio@l(r10)
lfs f9, 0x1C(r31) lfs f9, 0x1C(r31)
fmuls f0, f0, f9 fmuls f0, f0, f9
stfs f0, 0x1C(r31) stfs f0, 0x1C(r31)
@ -2625,7 +2635,7 @@ b exitScale
scalePaneReverse2x: scalePaneReverse2x:
lis r10, const_ReverseAspectRatio2x@ha lis r10, const_ReverseAspectRatio2x@ha
lfs f0, const_ReverseAspectRatio2x@l(r10) lfs f0, const_ReverseAspectRatio2x@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)
@ -2633,7 +2643,7 @@ b exitScale
scalePaneOnYScale: scalePaneOnYScale:
lis r10, const_ReverseAspectRatio@ha lis r10, const_ReverseAspectRatio@ha
lfs f0, const_ReverseAspectRatio@l(r10) lfs f0, const_ReverseAspectRatio@l(r10)
lfs f9, 0x38(r31) lfs f9, 0x38(r31)
fmuls f0, f0, f9 fmuls f0, f0, f9
stfs f0, 0x38(r31) stfs f0, 0x38(r31)
@ -2641,7 +2651,7 @@ b exitScale
scalePaneOnYScaleReverse: scalePaneOnYScaleReverse:
lis r10, const_AspectRatio@ha lis r10, const_AspectRatio@ha
lfs f0, const_AspectRatio@l(r10) lfs f0, const_AspectRatio@l(r10)
lfs f9, 0x38(r31) lfs f9, 0x38(r31)
fmuls f0, f0, f9 fmuls f0, f0, f9
stfs f0, 0x38(r31) stfs f0, 0x38(r31)
@ -2649,7 +2659,7 @@ b exitScale
scaleReversePaneToRightSide: scaleReversePaneToRightSide:
lis r10, const_ReverseAspectRatio2x@ha lis r10, const_ReverseAspectRatio2x@ha
lfs f0, const_ReverseAspectRatio2x@l(r10) lfs f0, const_ReverseAspectRatio2x@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)
@ -2681,7 +2691,7 @@ mapXPositionAddr:
scaleMapAndStore: scaleMapAndStore:
; scale pane and move to right on initialization ; scale pane and move to right on initialization
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)
@ -2810,7 +2820,7 @@ _createNewScreenHook:
lis r11, copyScreenStringLen@ha lis r11, copyScreenStringLen@ha
lwz r11, copyScreenStringLen@l(r11) lwz r11, copyScreenStringLen@l(r11)
lis r12, copyScreenString@ha lis r12, copyScreenString@ha
addi r12, r12, copyScreenString@l addi r12, r12, copyScreenString@l
copyNameLoop: copyNameLoop:
lbzx r10, r24, r11 lbzx r10, r24, r11
@ -2823,7 +2833,7 @@ bne copyNameLoop
lis r11, copySubPanelStringLen@ha lis r11, copySubPanelStringLen@ha
lwz r11, copySubPanelStringLen@l(r11) lwz r11, copySubPanelStringLen@l(r11)
lis r12, copySubPanelString@ha lis r12, copySubPanelString@ha
addi r12, r12, copySubPanelString@l addi r12, r12, copySubPanelString@l
eraseSubPanelLoop: eraseSubPanelLoop:
li r10, 0 li r10, 0