diff --git a/include/vm_screen.h b/include/vm_screen.h index 4a9bcba..e7b014c 100644 --- a/include/vm_screen.h +++ b/include/vm_screen.h @@ -45,13 +45,8 @@ typedef struct { SDL_Rect name; \ SET_SDL_RECT(name, a) -#define vm_area_set(a, x, y, w, h) \ - (a)->xoff = x; \ - (a)->yoff = y; \ - (a)->width = w; \ - (a)->height = h - extern bool vm_screen_active(vm_screen *); +extern void vm_area_set(vm_area *, int, int, int, int); extern int vm_screen_add_window(vm_screen *, int, int); extern int vm_screen_init(); extern int vm_screen_xcoords(vm_screen *); diff --git a/src/vm_screen.c b/src/vm_screen.c index e8ba829..26f569e 100644 --- a/src/vm_screen.c +++ b/src/vm_screen.c @@ -211,3 +211,12 @@ vm_screen_draw_rect(vm_screen *screen, vm_area *area) SDL_RenderFillRect(screen->render, &rect); } + +inline void +vm_area_set(vm_area *area, int xoff, int yoff, int width, int height) +{ + area->xoff = xoff; + area->yoff = yoff; + area->width = width; + area->height = height; +} diff --git a/tests/vm_screen.c b/tests/vm_screen.c index fc14d7b..484cda9 100644 --- a/tests/vm_screen.c +++ b/tests/vm_screen.c @@ -52,3 +52,14 @@ Test(vm_screen, ycoords) screen->ycoords = 234; cr_assert_eq(screen->ycoords, 234); } + +Test(vm_screen, area_set) +{ + vm_area area; + + vm_area_set(&area, 1, 2, 3, 4); + cr_assert_eq(area.xoff, 1); + cr_assert_eq(area.yoff, 2); + cr_assert_eq(area.width, 3); + cr_assert_eq(area.height, 4); +}