From: Bill Lash Date: Wed, 2 Oct 2019 01:25:08 +0000 (-0500) Subject: Use independent width and height scaling X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=fd91f7033d8e569f70b0cb77de10e78311535e6d;p=liskon_frotz.git Use independent width and height scaling Calculate independent width and height scaling by a floating point value based on the -W and -H options in sdl interface --- diff --git a/src/sdl/sf_frotz.h b/src/sdl/sf_frotz.h index b2c7305..0ebea9d 100644 --- a/src/sdl/sf_frotz.h +++ b/src/sdl/sf_frotz.h @@ -54,7 +54,8 @@ int colour_in_use(zword colour); /* various data */ extern bool m_tandy; extern int m_v6scale; -extern int m_gfxScale; +extern double m_gfxScale_w; +extern double m_gfxScale_h; extern ulong m_defaultFore; extern ulong m_defaultBack; extern ulong m_colours[11]; diff --git a/src/sdl/sf_resource.c b/src/sdl/sf_resource.c index 9b50b5b..235db34 100644 --- a/src/sdl/sf_resource.c +++ b/src/sdl/sf_resource.c @@ -23,7 +23,8 @@ z_header_t z_header; /* various data */ bool m_tandy = 0; int m_v6scale; -int m_gfxScale = 1; +double m_gfxScale_w = 1.0; +double m_gfxScale_h = 1.0; ulong m_defaultFore; ulong m_defaultBack; ulong m_colours[11]; @@ -289,8 +290,8 @@ int os_picture_data(int picture, int *height, int *width) } else { sf_picture *res = sf_getpic(picture); if (res) { - *height = m_gfxScale * res->height; - *width = m_gfxScale * res->width; + *height = m_gfxScale_h * res->height; + *width = m_gfxScale_w * res->width; return 1; } } @@ -489,7 +490,8 @@ void sf_readsettings(void) m_frequency = sf_GetProfileInt("Audio", "Frequency", m_frequency); m_v6scale = sf_GetProfileInt("Display", "Infocom V6 Scaling", 2); - m_gfxScale = 1; + m_gfxScale_w = 1.0; + m_gfxScale_h = 1.0; m_defaultFore = (sf_GetProfileInt("Display", "Foreground", 0xffffff)); m_defaultBack = (sf_GetProfileInt("Display", "Background", 0x800000)); m_morePrompts = @@ -669,10 +671,15 @@ void os_init_screen(void) sf_initvideo(AcWidth, AcHeight, (m_fullscreen != -1)); /* Set the graphics scaling */ - if (sf_IsInfocomV6() || (story_id == BEYOND_ZORK)) - m_gfxScale = m_v6scale; - else - m_gfxScale = 1; + if (sf_IsInfocomV6() || (story_id == BEYOND_ZORK)) { + m_gfxScale_w = (double)m_v6scale; + m_gfxScale_h = (double)m_v6scale; + } else { + m_gfxScale_w = 1.0; + m_gfxScale_h = 1.0; + } + m_gfxScale_w *= (double) AcWidth /640.0; + m_gfxScale_h *= (double) AcHeight /400.0; /* Set the configuration */ if (z_header.version == V3) { diff --git a/src/sdl/sf_video.c b/src/sdl/sf_video.c index f1509e8..2d47520 100644 --- a/src/sdl/sf_video.c +++ b/src/sdl/sf_video.c @@ -549,8 +549,8 @@ void os_draw_picture(int picture, int y, int x) x--; y--; - ew = m_gfxScale * pic->width; - eh = m_gfxScale * pic->height; + ew = m_gfxScale_w * pic->width; + eh = m_gfxScale_h * pic->height; /* this takes care of the fact that x, y are really 16 bit values */ if (x & 0x8000) @@ -574,7 +574,7 @@ void os_draw_picture(int picture, int y, int x) } if (x + ew > xmax) ew = xmax - x; - ew /= m_gfxScale; + ew /= m_gfxScale_w; if (y < ymin) { d = ymin - y; @@ -584,7 +584,7 @@ void os_draw_picture(int picture, int y, int x) } if (y + eh > ymax) eh = ymax - y; - eh /= m_gfxScale; + eh /= m_gfxScale_h; sf_setclip(ox, oy, ow, oh); @@ -599,10 +599,10 @@ void os_draw_picture(int picture, int y, int x) if (!pic->adaptive && ApplyPalette(pic)) sf_flushdisplay(); - for (yy = 0; yy < eh * m_gfxScale; yy++) { - int ys = yy / m_gfxScale; - for (xx = 0; xx < ew * m_gfxScale; xx++) { - int xs = xx / m_gfxScale; + for (yy = 0; yy < eh * m_gfxScale_h; yy++) { + int ys = yy / m_gfxScale_h; + for (xx = 0; xx < ew * m_gfxScale_w; xx++) { + int xs = xx / m_gfxScale_w; int index = pic->pixels[ys * pic->width + xs]; if (index != pic->transparentcolor) sf_wpixel(x + xx, y + yy, @@ -616,8 +616,8 @@ void os_draw_picture(int picture, int y, int x) for (yy = 0; yy < eh; yy++) { for (xx = 0; xx < ew; xx++) { dst = - sbuffer + x + xx * m_gfxScale + - sbpitch * (y + yy * m_gfxScale); + sbuffer + x + (uint32_t)(xx * m_gfxScale_w) + + sbpitch * (y + (uint32_t)(yy * m_gfxScale_h)); sval = src[xx]; alpha = (sval >> 24); if (alpha == 255) @@ -627,8 +627,8 @@ void os_draw_picture(int picture, int y, int x) sf_blend((int) (alpha + (alpha >> 7)), sval, dst[0]); - for (iy = 0; iy < m_gfxScale; iy++) { - for (ix = 0; ix < m_gfxScale; ix++) + for (iy = 0; iy < m_gfxScale_h; iy++) { + for (ix = 0; ix < m_gfxScale_w; ix++) dst[ix] = dval; dst += sbpitch; }