summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2019-07-13 09:15:20 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2019-07-13 09:15:20 -0400
commit19958a35c00e59d9d4f2471ffadcd36f7758b914 (patch)
tree92b6e4a2298671ae8f9c1af568584643882dc945 /src
parent7ec965bd24e363381d19139bd15f44093112815b (diff)
Port cable_car_util from Ruby
Diffstat (limited to 'src')
-rw-r--r--src/cable_car_util.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/cable_car_util.c b/src/cable_car_util.c
new file mode 100644
index 000000000..7bad79079
--- /dev/null
+++ b/src/cable_car_util.c
@@ -0,0 +1,38 @@
+#include "global.h"
+
+void CableCarUtil_FillWrapped(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height)
+{
+ u8 i;
+ u8 j;
+ u8 x;
+ u8 y;
+
+ for (i = 0, y = top; i < height; i++)
+ {
+ for (x = left, 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 left, u8 top, u8 width, u8 height)
+{
+ u8 i;
+ u8 j;
+ u8 x;
+ u8 y;
+ const u16 *_src;
+
+ for (i = 0, _src = src, y = top; i < height; i++)
+ {
+ for (x = left, j = 0; j < width; j++)
+ {
+ *(u16 *)&((u8 *)dest)[y * 64 + x * 2] = *_src++;
+ x = (x + 1) % 32;
+ }
+ y = (y + 1) % 32;
+ }
+}