Skip to content

Commit 8cb9da6

Browse files
authored
Merge pull request #3567 from SuperFromND/gamewidth-fix
fix: Use float versions of gameWidth/gameHeight for w/hScale & render origin
2 parents cc5c58c + 4b2777c commit 8cb9da6

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/stage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ func (bg backGround) draw(pos [2]float32, drawscl, bgscl, stglscl float32,
703703
// Choose render origin: top-left for screenpack/storyboard videos, center for everything else
704704
var rcx float32
705705
if bg._type != BG_Video || isStage {
706-
rcx = float32(sys.gameWidth) / 2
706+
rcx = sys.gameWidthFloat / 2
707707
}
708708

709709
bg.anim.Draw(&rect, x-xsoffset, y, sclx, scly,

src/system.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ type SystemStateVars struct {
6565

6666
scrrect [4]int32
6767
gameWidth, gameHeight int32
68+
gameWidthFloat float32 // Float forms used for precise screenpack math
69+
gameHeightFloat float32 // TODO: rework gameWidth/gameHeight as floats instead
6870
widthScale, heightScale float32
6971
gameEnd, frameSkip bool
7072
paused, frameStepFlag bool
@@ -617,17 +619,21 @@ func (s *System) setGameSize(w, h int32) {
617619

618620
if screenAspect > targetAspect {
619621
// Screen is wider than 4:3 - scale based on height
620-
s.gameWidth = int32(float32(baseHeight) * screenAspect)
622+
s.gameWidthFloat = float32(baseHeight) * screenAspect
623+
s.gameWidth = int32(s.gameWidthFloat)
621624
s.gameHeight = baseHeight
625+
s.gameHeightFloat = float32(s.gameHeight)
622626
} else {
623627
// Screen is taller than 4:3 - scale based on width
624628
s.gameWidth = baseWidth
625-
s.gameHeight = int32(float32(baseWidth) / screenAspect)
629+
s.gameWidthFloat = float32(baseWidth)
630+
s.gameHeightFloat = float32(baseWidth) / screenAspect
631+
s.gameHeight = int32(s.gameHeightFloat)
626632
}
627633

628634
// Update scale
629-
s.widthScale = float32(s.scrrect[2]) / float32(s.gameWidth)
630-
s.heightScale = float32(s.scrrect[3]) / float32(s.gameHeight)
635+
s.widthScale = float32(s.scrrect[2]) / s.gameWidthFloat
636+
s.heightScale = float32(s.scrrect[3]) / s.gameHeightFloat
631637
}
632638

633639
// Change aspect ratio at match start

0 commit comments

Comments
 (0)