diff --git display/simgraph16.cc display/simgraph16.cc index 4c58c9d63e..1c3d711b01 100644 --- display/simgraph16.cc +++ display/simgraph16.cc @@ -3926,9 +3926,13 @@ void display_base_img_alpha(const image_id n, const image_id alpha_n, const unsi // scrolls horizontally, will ignore clipping etc. -void display_scroll_band(const KOORD_VAL start_y, const KOORD_VAL x_offset, const KOORD_VAL h) +void display_scroll_band(KOORD_VAL start_y, KOORD_VAL x_offset, KOORD_VAL h) { - const PIXVAL*const src = textur + start_y * disp_width + x_offset; + start_y = std::max(start_y, 0); + x_offset = std::min(x_offset, disp_width); + h = std::min(h, disp_height); + + const PIXVAL *const src = textur + start_y * disp_width + x_offset; PIXVAL *const dst = textur + start_y * disp_width; const size_t amount = sizeof(PIXVAL) * (h * disp_width - x_offset);