From 03149e5536a831e2ea7a20175f04938343529c99 Mon Sep 17 00:00:00 2001 From: rodri Date: Wed, 7 Aug 2024 11:47:31 +0000 Subject: offset fb during drawing based on viewport config. move OBJ-related procedures to its own unit. --- fb.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'fb.c') diff --git a/fb.c b/fb.c index 6193a3c..88883fd 100644 --- a/fb.c +++ b/fb.c @@ -93,18 +93,18 @@ scale3x_filter(ulong *dst, Framebuf *fb, Point sp) //} static void -framebufctl_draw(Framebufctl *ctl, Image *dst) +framebufctl_draw(Framebufctl *ctl, Image *dst, Point off) { Framebuf *fb; qlock(ctl); fb = ctl->getfb(ctl); - loadimage(dst, rectaddpt(fb->r, dst->r.min), (uchar*)fb->cb, Dx(fb->r)*Dy(fb->r)*4); + loadimage(dst, rectaddpt(fb->r, addpt(dst->r.min, off)), (uchar*)fb->cb, Dx(fb->r)*Dy(fb->r)*4); qunlock(ctl); } static void -framebufctl_upscaledraw(Framebufctl *ctl, Image *dst, Point scale) +framebufctl_upscaledraw(Framebufctl *ctl, Image *dst, Point off, Point scale) { void (*filter)(ulong*, Framebuf*, Point); Framebuf *fb; @@ -130,8 +130,8 @@ framebufctl_upscaledraw(Framebufctl *ctl, Image *dst, Point scale) break; } - for(sp.y = fb->r.min.y, dp.y = dst->r.min.y; sp.y < fb->r.max.y; sp.y++, dp.y += scale.y) - for(sp.x = fb->r.min.x, dp.x = dst->r.min.x; sp.x < fb->r.max.x; sp.x++, dp.x += scale.x){ + for(sp.y = fb->r.min.y, dp.y = dst->r.min.y+off.y; sp.y < fb->r.max.y; sp.y++, dp.y += scale.y) + for(sp.x = fb->r.min.x, dp.x = dst->r.min.x+off.x; sp.x < fb->r.max.x; sp.x++, dp.x += scale.x){ if(filter != nil) filter(blk, fb, sp); else @@ -143,18 +143,18 @@ framebufctl_upscaledraw(Framebufctl *ctl, Image *dst, Point scale) } static void -framebufctl_memdraw(Framebufctl *ctl, Memimage *dst) +framebufctl_memdraw(Framebufctl *ctl, Memimage *dst, Point off) { Framebuf *fb; qlock(ctl); fb = ctl->getfb(ctl); - loadmemimage(dst, rectaddpt(fb->r, dst->r.min), (uchar*)fb->cb, Dx(fb->r)*Dy(fb->r)*4); + loadmemimage(dst, rectaddpt(fb->r, addpt(dst->r.min, off)), (uchar*)fb->cb, Dx(fb->r)*Dy(fb->r)*4); qunlock(ctl); } static void -framebufctl_upscalememdraw(Framebufctl *ctl, Memimage *dst, Point scale) +framebufctl_upscalememdraw(Framebufctl *ctl, Memimage *dst, Point off, Point scale) { void (*filter)(ulong*, Framebuf*, Point); Framebuf *fb; @@ -180,8 +180,8 @@ framebufctl_upscalememdraw(Framebufctl *ctl, Memimage *dst, Point scale) break; } - for(sp.y = fb->r.min.y, dp.y = dst->r.min.y; sp.y < fb->r.max.y; sp.y++, dp.y += scale.y) - for(sp.x = fb->r.min.x, dp.x = dst->r.min.x; sp.x < fb->r.max.x; sp.x++, dp.x += scale.x){ + for(sp.y = fb->r.min.y, dp.y = dst->r.min.y+off.y; sp.y < fb->r.max.y; sp.y++, dp.y += scale.y) + for(sp.x = fb->r.min.x, dp.x = dst->r.min.x+off.x; sp.x < fb->r.max.x; sp.x++, dp.x += scale.x){ if(filter != nil) filter(blk, fb, sp); else -- cgit v1.2.3