Skip to content

Commit 62f65a6

Browse files
authored
Merge pull request #2558 from SuperFromND/xy-trunc
feat: X/Y Truncate setting
2 parents 34aaa59 + 53efc1b commit 62f65a6

6 files changed

Lines changed: 31 additions & 1 deletion

File tree

data/system.base.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,7 @@
16521652
menu.itemname.menuvideo.resolution.back = "Back"
16531653
menu.itemname.menuvideo.fullscreen = "Fullscreen"
16541654
menu.itemname.menuvideo.keepaspect = "Keep Aspect Ratio"
1655+
menu.itemname.menuvideo.xytruncate = "X/Y Rounding"
16551656
menu.itemname.menuvideo.windowscalemode = "Bilinear Filtering"
16561657
menu.itemname.menuvideo.vsync = "VSync"
16571658
menu.itemname.menuvideo.msaa = "MSAA"

external/script/motif.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,6 +2041,7 @@ function motif.setBaseOptionInfo()
20412041
motif.option_info.menu_itemname_menuvideo_fullscreen = "Fullscreen"
20422042
motif.option_info.menu_itemname_menuvideo_vsync = "VSync"
20432043
motif.option_info.menu_itemname_menuvideo_keepaspect = "Keep Aspect Ratio"
2044+
motif.option_info.menu_itemname_menuvideo_xytruncate = "X/Y Rounding"
20442045
motif.option_info.menu_itemname_menuvideo_windowscalemode = "Bilinear Filtering"
20452046
motif.option_info.menu_itemname_menuvideo_msaa = "MSAA"
20462047
motif.option_info.menu_itemname_menuvideo_shaders = "Shaders" --reserved submenu
@@ -2175,6 +2176,7 @@ function motif.setBaseOptionInfo()
21752176
"menuvideo_fullscreen",
21762177
"menuvideo_vsync",
21772178
"menuvideo_keepaspect",
2179+
"menuvideo_xytruncate",
21782180
"menuvideo_windowscalemode",
21792181
"menuvideo_msaa",
21802182
"menuvideo_shaders",

external/script/options.lua

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ options.t_itemname = {
213213
--modifyGameOption('Video.WindowCentered', true)
214214
modifyGameOption('Video.ExternalShaders', {})
215215
modifyGameOption('Video.WindowScaleMode', true)
216-
modifyGameOption('Video.KeepAspect', true)
216+
modifyGameOption('Video.KeepAspect', true)
217+
modifyGameOption('Video.XyTruncate', true)
217218
modifyGameOption('Video.EnableModel', true)
218219
modifyGameOption('Video.EnableModelShadow', true)
219220
--modifyGameOption('Sound.SampleRate', 44100)
@@ -939,6 +940,20 @@ options.t_itemname = {
939940
end
940941
return true
941942
end,
943+
--X/Y Trunccate
944+
['xytruncate'] = function(t, item, cursorPosY, moveTxt)
945+
if main.f_input(main.t_players, {'$F', '$B', 'pal', 's'}) then
946+
sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
947+
if gameOption('Video.XyTruncate') then
948+
modifyGameOption('Video.XyTruncate', false)
949+
else
950+
modifyGameOption('Video.XyTruncate', true)
951+
end
952+
t.items[item].vardisplay = options.f_boolDisplay(gameOption('Video.XyTruncate'), motif.option_info.menu_valuename_enabled, motif.option_info.menu_valuename_disabled)
953+
options.modified = true
954+
end
955+
return true
956+
end,
942957
--Shaders (submenu)
943958
['shaders'] = function(t, item, cursorPosY, moveTxt)
944959
if main.f_input(main.t_players, {'$F', '$B', 'pal', 's'}) then
@@ -1552,6 +1567,9 @@ options.t_vardisplay = {
15521567
['windowscalemode'] = function()
15531568
return options.f_boolDisplay(gameOption('Video.WindowScaleMode'), motif.option_info.menu_valuename_enabled, motif.option_info.menu_valuename_disabled)
15541569
end,
1570+
['xytruncate'] = function()
1571+
return options.f_boolDisplay(gameOption('Video.XyTruncate'), motif.option_info.menu_valuename_enabled, motif.option_info.menu_valuename_disabled)
1572+
end,
15551573
}
15561574

15571575
-- Returns setting value rendered alongside menu item name (calls appropriate

src/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ type Config struct {
165165
ExternalShaders []string `ini:"ExternalShaders"`
166166
WindowScaleMode bool `ini:"WindowScaleMode"`
167167
KeepAspect bool `ini:"KeepAspect"`
168+
XyTruncate bool `ini:"XyTruncate"`
168169
EnableModel bool `ini:"EnableModel"`
169170
EnableModelShadow bool `ini:"EnableModelShadow"`
170171
} `ini:"Video"`

src/render.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,11 @@ func rmInitSub(rp *RenderParams) {
407407
rp.y *= -1
408408
}
409409
rp.y += rp.rcy
410+
411+
if sys.cfg.Video.XyTruncate {
412+
rp.x = float32(int(rp.x))
413+
rp.y = float32(int(rp.y))
414+
}
410415
}
411416

412417
func BlendReset() {

src/resources/defaultConfig.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ ExternalShaders =
214214
WindowScaleMode = 1
215215
; Toggles Keep Aspect mode.
216216
KeepAspect = 1
217+
; Toggles whether or not to truncate X/Y coordinates to whole numbers when rendering.
218+
; Helps to solve "blurring" artifacts, particularly on lower resolution characters.
219+
XyTruncate = 1
217220
; Toggles 3D Model support.
218221
EnableModel = 1
219222
; Toggles 3D Model Shadow support.

0 commit comments

Comments
 (0)