Skip to content

Commit ec3b840

Browse files
committed
television resizing
TV cropping was misaligned by one pixel vertically (gui)
1 parent 7679d96 commit ec3b840

File tree

3 files changed

+5
-28
lines changed

3 files changed

+5
-28
lines changed

gui/sdlimgui/gl32_dbgscr.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ func (attr *dbgScrHelper) set(img *SdlImgui) {
9494

9595
// screen geometry
9696
gl.Uniform1f(attr.hblank, (specification.ClksHBlank)*xscaling)
97-
gl.Uniform1f(attr.visibleTop, float32(img.screen.crit.frameInfo.VisibleTop)*yscaling)
98-
gl.Uniform1f(attr.visibleBottom, float32(img.screen.crit.frameInfo.VisibleBottom)*yscaling)
97+
gl.Uniform1f(attr.visibleTop, float32(img.screen.crit.frameInfo.VisibleTop+1)*yscaling)
98+
gl.Uniform1f(attr.visibleBottom, float32(img.screen.crit.frameInfo.VisibleBottom+1)*yscaling)
9999
gl.Uniform1f(attr.lastNewFrameAtScanline, float32(img.screen.crit.frameInfo.TotalScanlines)*yscaling)
100100

101101
// window magnification

gui/sdlimgui/screen.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,10 @@ func (scr *screen) resize() {
402402

403403
scr.crit.resize = false
404404

405-
// create a cropped image from the main
405+
// create cropped image(s)
406406
crop := image.Rect(
407-
specification.ClksHBlank, scr.crit.frameInfo.VisibleTop,
408-
specification.ClksHBlank+specification.ClksVisible, scr.crit.frameInfo.VisibleBottom,
407+
specification.ClksHBlank, scr.crit.frameInfo.VisibleTop+1,
408+
specification.ClksHBlank+specification.ClksVisible, scr.crit.frameInfo.VisibleBottom+1,
409409
)
410410
scr.crit.cropPixels = scr.crit.presentationPixels.SubImage(crop).(*image.RGBA)
411411
scr.crit.cropElementPixels = scr.crit.elementPixels.SubImage(crop).(*image.RGBA)

hardware/television/resizer.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,6 @@ const framesUntilResize = 2
158158

159159
// commit resizing possibility found through examine() function.
160160
func (sr *resizer) commit(tv *Television) error {
161-
// only commit on even frames. the only reason we do this is to catch
162-
// flicker kernels where pixels are different every frame. this is a bit of
163-
// a pathological situation but it does happen so we should handle it
164-
//
165-
// an example of this is the CDFJ QBert demo ROM
166-
//
167-
// note that this means the framesUntilResize value is effectively double
168-
// that value stated
169-
if tv.state.frameNum%2 == 0 {
170-
return nil
171-
}
172-
173161
// make sure candidate top and bottom value are equal to stable top/bottom
174162
// at beginning of a frame
175163
defer func() {
@@ -232,17 +220,6 @@ func (sr *resizer) commit(tv *Television) error {
232220

233221
// sanity check before we do anything drastic
234222
if tv.state.frameInfo.VisibleTop < tv.state.frameInfo.VisibleBottom {
235-
// add one to the bottom value before committing. Ladybug and Hack'Em
236-
// Pacman are good examples of ROMs that are "wrong" if we don't do
237-
// this
238-
sr.pendingBottom++
239-
240-
// add another one. Man Down is an example of ROM which is "wrong"
241-
// without an additional (two) scanlines after the VBLANK
242-
sr.pendingBottom++
243-
244-
// !!TODO: more elegant way of handling the additional scanline problem
245-
246223
// clamp bottom scanline to safe bottom
247224
if sr.pendingBottom > tv.state.frameInfo.Spec.NewSafeVisibleBottom {
248225
sr.pendingBottom = tv.state.frameInfo.Spec.NewSafeVisibleBottom

0 commit comments

Comments
 (0)