From fb8c227ff018e21a0abd9a15852a060f4b84ba1b Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 25 Apr 2021 20:30:05 +0100 Subject: RISC OS: Plotters: On RISC OS y1 is top and y0 is bottom. When storing RISC OS coordinates, use y0 and y1 consistently. --- frontends/riscos/plotters.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'frontends') diff --git a/frontends/riscos/plotters.c b/frontends/riscos/plotters.c index 2b306827d..25c953f97 100644 --- a/frontends/riscos/plotters.c +++ b/frontends/riscos/plotters.c @@ -110,12 +110,17 @@ ro_plot_clip(const struct redraw_context *ctx, const struct rect *clip) os_error *error; char buf[12]; - int clip_x0 = ro_plot_origin_x + clip->x0 * 2; - int clip_y0 = ro_plot_origin_y - clip->y0 * 2 - 1; - int clip_x1 = ro_plot_origin_x + clip->x1 * 2 - 1; - int clip_y1 = ro_plot_origin_y - clip->y1 * 2; + int clip_x0 = clip->x0 * 2; + int clip_y0 = clip->y1 * 2; + int clip_x1 = clip->x1 * 2; + int clip_y1 = clip->y0 * 2; - if (clip_x1 < clip_x0 || clip_y0 < clip_y1) { + clip_x0 = ro_plot_origin_x + clip_x0; + clip_y0 = ro_plot_origin_y - clip_y0; + clip_x1 = ro_plot_origin_x + clip_x1 - 1; + clip_y1 = ro_plot_origin_y - clip_y1 - 1; + + if (clip_x1 < clip_x0 || clip_y1 < clip_y0) { NSLOG(netsurf, INFO, "bad clip rectangle %i %i %i %i", clip_x0, clip_y0, clip_x1, clip_y1); return NSERROR_BAD_SIZE; @@ -124,12 +129,12 @@ ro_plot_clip(const struct redraw_context *ctx, const struct rect *clip) buf[0] = os_VDU_SET_GRAPHICS_WINDOW; buf[1] = clip_x0; buf[2] = clip_x0 >> 8; - buf[3] = clip_y1; - buf[4] = clip_y1 >> 8; + buf[3] = clip_y0; + buf[4] = clip_y0 >> 8; buf[5] = clip_x1; buf[6] = clip_x1 >> 8; - buf[7] = clip_y0; - buf[8] = clip_y0 >> 8; + buf[7] = clip_y1; + buf[8] = clip_y1 >> 8; error = xos_writen(buf, 9); if (error) { @@ -365,7 +370,7 @@ ro_plot_rectangle(const struct redraw_context *ctx, error = xos_plot(os_MOVE_TO, ro_plot_origin_x + rect->x0 * 2, - ro_plot_origin_y - rect->y0 * 2 - 1); + ro_plot_origin_y - rect->y1 * 2); if (error) { NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", error->errnum, error->errmess); @@ -374,7 +379,7 @@ ro_plot_rectangle(const struct redraw_context *ctx, error = xos_plot(os_PLOT_RECTANGLE | os_PLOT_TO, ro_plot_origin_x + rect->x1 * 2 - 1, - ro_plot_origin_y - rect->y1 * 2); + ro_plot_origin_y - rect->y0 * 2 - 1); if (error) { NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", error->errnum, error->errmess); -- cgit v1.2.3