Skip to content

Commit

Permalink
DeskTop: Remove seemingly unneeded safety check when adjusting ports
Browse files Browse the repository at this point in the history
When drawing window entries, the grafport needs to be adjusted to
account for the header. This is normally done in
`OffsetWindowGrafportAndSet` which updates the previously selected
`window_grafport`. Notably, while callers must be sensitive to
GetWinPort failing if the window is obscured, when the port is updated
and SetPort is called there is no subsequent check that the port is
not offscreen. MGTK seems okay with this.

When update events are being processed, a different grafport is
provided via `BeginUpdate`. This is clipped to just the necessary
update rect, e.g. what was revealed by a window move. There was
separate code to deal with updating the port to account for the header
here. And notably, because of issue #369, there was logic to ensure
the updated port was not offscreen. Why is it needed for updates, but
not for the normal drawing? Further testing reveals that the bug no
longer reproduces with this logic removed; likely it was only present
in old code that didn't use the grafport provided with the
`BeginUpdate`.

So... remove the check? Seems okay so far.
  • Loading branch information
inexorabletash committed Jan 27, 2025
1 parent 5c38a41 commit c169fbe
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions desktop/lc.s
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ params: .res 3
dey
bpl :-

;; Determine the update's maprect is already below the header; if
;; Determine if the update's maprect is already below the header; if
;; not, we need to offset the maprect below the header.
sub16 desktop_grafport+MGTK::GrafPort::viewloc+MGTK::Point::ycoord, window_grafport+MGTK::GrafPort::viewloc+MGTK::Point::ycoord, tmpw
scmp16 tmpw, #kWindowHeaderHeight
Expand All @@ -158,11 +158,6 @@ params: .res 3
add16 window_grafport+MGTK::GrafPort::viewloc+MGTK::Point::ycoord, #kWindowHeaderHeight, desktop_grafport+MGTK::GrafPort::viewloc+MGTK::Point::ycoord
add16 window_grafport+MGTK::GrafPort::maprect+MGTK::Rect::y1, #kWindowHeaderHeight, desktop_grafport+MGTK::GrafPort::maprect+MGTK::Rect::y1

;; MGTK doesn't like offscreen grafports, so if we end up with
;; nothing to draw, skip drawing!
;; https://github.com/a2stuff/a2d/issues/369
scmp16 desktop_grafport+MGTK::GrafPort::viewloc + MGTK::Point::ycoord, #kScreenHeight
bpl fail
MGTK_CALL MGTK::SetPort, desktop_grafport
bne fail

Expand Down

0 comments on commit c169fbe

Please sign in to comment.