From 8d035c81528d172570338ec82c07770e7ebcfe50 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 5 Jan 2018 22:15:05 -0700 Subject: cable car util --- src/engine/cable_car_util.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/engine/cable_car_util.c (limited to 'src/engine') diff --git a/src/engine/cable_car_util.c b/src/engine/cable_car_util.c new file mode 100644 index 000000000..27f703b42 --- /dev/null +++ b/src/engine/cable_car_util.c @@ -0,0 +1,46 @@ +#include "global.h" +#include "cable_car_util.h" + +// static types + +// static declarations + +// rodata + +// text + +void CableCarUtil_FillWrapped(void *dest, u16 value, u8 x, u8 y, u8 width, u8 height) +{ + u8 i; + u8 j; + u8 _x; + u8 _y; + + for (i = 0, _y = y; i < height; i++) + { + for (_x = x, j = 0; j < width; j++) + { + *(u16 *)&((u8 *)dest)[_y * 64 + _x * 2] = value; + _x = (_x + 1) % 32; + } + _y = (_y + 1) % 32; + } +} +void CableCarUtil_CopyWrapped(void *dest, const u16 *src, u8 x, u8 y, u8 width, u8 height) +{ + u8 i; + u8 j; + u8 _x; + u8 _y; + const u16 *_src; + + for (i = 0, _src = src, _y = y; i < height; i++) + { + for (_x = x, j = 0; j < width; j++) + { + *(u16 *)&((u8 *)dest)[_y * 64 + _x * 2] = *_src++; + _x = (_x + 1) % 32; + } + _y = (_y + 1) % 32; + } +} -- cgit v1.2.3