summaryrefslogtreecommitdiff
path: root/include/gba
diff options
context:
space:
mode:
authorYamaArashi <shadow962@live.com>2016-05-20 11:45:24 -0700
committerYamaArashi <shadow962@live.com>2016-05-21 10:35:53 -0700
commitc0203de808a98d27446e01c6b7e9f9311a5ad3bf (patch)
treee538179372ce7cddc50b851e4c24a4c7e0a40c81 /include/gba
parent4af578c1865e4b620f4c64401e0a16ccbd9efc8d (diff)
sprite.c and updated preproc
Diffstat (limited to 'include/gba')
-rw-r--r--include/gba/defines.h49
-rw-r--r--include/gba/gba.h57
-rw-r--r--include/gba/syscall.h4
-rw-r--r--include/gba/types.h70
4 files changed, 124 insertions, 56 deletions
diff --git a/include/gba/defines.h b/include/gba/defines.h
new file mode 100644
index 000000000..005efb079
--- /dev/null
+++ b/include/gba/defines.h
@@ -0,0 +1,49 @@
+#ifndef GUARD_GBA_DEFINES
+#define GUARD_GBA_DEFINES
+
+#include <stddef.h>
+
+#define TRUE 1
+#define FALSE 0
+
+#define IWRAM_DATA __attribute__((section("iwram_data")))
+#define EWRAM_DATA __attribute__((section("ewram_data")))
+
+#define ALIGNED(n) __attribute__((aligned(n)))
+
+// The original build process placed COMMON data (i.e. uninitialized globals)
+// in IWRAM after the static variables.
+// When ld places COMMON variables in the output, it aligns the variable
+// according to the size of the variable, with a maximum alignment of 16. This
+// results in large alignment values.
+// Initialized variables are aligned according to the size of the largest
+// primitive type in the object, so their alignment will often be smaller.
+// However, we cannot use COMMON data in pokeruby because the order of COMMON
+// data in the output is not reliable. Instead, we need to initialize the
+// variables so that their order in the source file is preserved in the output.
+// But using initialized variables brings us into conflict with those large
+// alignment values.
+// These macros allow us to get around this by manually specifying what the
+// alignment would be if the variable were uninitialized.
+#define COMM(decl, n) IWRAM_DATA ALIGNED(1 << n) decl = {0};
+#define COMM_2(decl) COMM(decl, 2)
+#define COMM_4(decl) COMM(decl, 4)
+
+#define SOUND_INFO_PTR (*(struct SoundInfo **)0x3007FF0)
+#define INTR_CHECK (*(u16 *)0x3007FF8)
+#define INTR_VECTOR (*(void **)0x3007FFC)
+
+#define OBJ_VRAM0 0x6010000 // when BG is in tilemap mode
+#define OBJ_VRAM1 0x6014000 // when BG is in bitmap mode
+
+#define OAM 0x7000000
+
+#define DISPLAY_WIDTH 240
+#define DISPLAY_HEIGHT 160
+
+#define TILE_SIZE_4BPP 32
+#define TILE_SIZE_8BPP 64
+
+#define TOTAL_OBJ_TILE_COUNT 1024
+
+#endif // GUARD_GBA_DEFINES
diff --git a/include/gba/gba.h b/include/gba/gba.h
index 06067dacf..26342cf88 100644
--- a/include/gba/gba.h
+++ b/include/gba/gba.h
@@ -1,63 +1,10 @@
#ifndef GUARD_GBA_GBA_H
#define GUARD_GBA_GBA_H
-#include <stddef.h>
-
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned int u32;
-typedef signed char s8;
-typedef signed short s16;
-typedef signed int s32;
-
-typedef volatile u8 vu8;
-typedef volatile u16 vu16;
-typedef volatile u32 vu32;
-typedef volatile s8 vs8;
-typedef volatile s16 vs16;
-typedef volatile s32 vs32;
-
-typedef float f32;
-typedef double f64;
-
-typedef u8 bool8;
-typedef u16 bool16;
-typedef u32 bool32;
-
-#define TRUE 1
-#define FALSE 0
-
-#define IWRAM_DATA __attribute__((section("iwram_data")))
-#define EWRAM_DATA __attribute__((section("ewram_data")))
-
-#define ALIGNED(n) __attribute__((aligned(n)))
-
-// The original build process placed COMMON data (i.e. uninitialized globals)
-// in IWRAM after the static variables.
-// When ld places COMMON variables in the output, it aligns the variable
-// according to the size of the variable, with a maximum alignment of 16. This
-// results in large alignment values.
-// Initialized variables are aligned according to the size of the largest
-// primitive type in the object, so their alignment will often be smaller.
-// However, we cannot use COMMON data in pokeruby because the order of COMMON
-// data in the output is not reliable. Instead, we need to initialize the
-// variables so that their order in the source file is preserved in the output.
-// But using initialized variables brings us into conflict with those large
-// alignment values.
-// These macros allow us to get around this by manually specifying what the
-// alignment would be if the variable were uninitialized.
-#define COMM(decl, n) IWRAM_DATA ALIGNED(1 << n) decl = {0};
-#define COMM_0(decl) COMM(decl, 0)
-#define COMM_1(decl) COMM(decl, 1)
-#define COMM_2(decl) COMM(decl, 2)
-#define COMM_4(decl) COMM(decl, 4)
-
+#include "gba/defines.h"
#include "gba/io_reg.h"
+#include "gba/types.h"
#include "gba/syscall.h"
#include "gba/macro.h"
-#define SOUND_INFO_PTR (*(struct SoundInfo **)0x3007FF0)
-#define INTR_CHECK (*(u16 *)0x3007FF8)
-#define INTR_VECTOR (*(void **)0x3007FFC)
-
#endif // GUARD_GBA_GBA_H
diff --git a/include/gba/syscall.h b/include/gba/syscall.h
index 9b2b81311..8ef82c0e4 100644
--- a/include/gba/syscall.h
+++ b/include/gba/syscall.h
@@ -15,12 +15,14 @@ void SoftReset(u32 resetFlags);
void RegisterRamReset(u32 resetFlags);
+void VBlankIntrWait(void);
+
#define CPU_SET_SRC_FIXED 0x01000000
#define CPU_SET_16BIT 0x00000000
#define CPU_SET_32BIT 0x04000000
void CpuSet(void *src, void *dest, u32 control);
-void VBlankIntrWait(void);
+void ObjAffineSet(struct ObjAffineSrcData *src, void *dest, s32 count, s32 offset);
#endif // GUARD_GBA_SYSCALL_H
diff --git a/include/gba/types.h b/include/gba/types.h
new file mode 100644
index 000000000..4e1ab3003
--- /dev/null
+++ b/include/gba/types.h
@@ -0,0 +1,70 @@
+#ifndef GUARD_GBA_TYPES_H
+#define GUARD_GBA_TYPES_H
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned int u32;
+typedef signed char s8;
+typedef signed short s16;
+typedef signed int s32;
+
+typedef volatile u8 vu8;
+typedef volatile u16 vu16;
+typedef volatile u32 vu32;
+typedef volatile s8 vs8;
+typedef volatile s16 vs16;
+typedef volatile s32 vs32;
+
+typedef float f32;
+typedef double f64;
+
+typedef u8 bool8;
+typedef u16 bool16;
+typedef u32 bool32;
+
+struct OamData
+{
+ u32 y:8;
+ u32 affineMode:2;
+ u32 objMode:2;
+ u32 mosaic:1;
+ u32 bpp:1;
+ u32 shape:2;
+
+ u32 x:9;
+ u32 matrixNum:5; // bits 3/4 are h-flip/v-flip if not in affine mode
+ u32 size:2;
+
+ u16 tileNum:10;
+ u16 priority:2;
+ u16 paletteNum:4;
+ u16 affineParam;
+};
+
+#define ST_OAM_OBJ_NORMAL 0
+#define ST_OAM_OBJ_BLEND 1
+#define ST_OAM_OBJ_WINDOW 2
+
+#define ST_OAM_AFFINE_OFF 0
+#define ST_OAM_AFFINE_NORMAL 1
+#define ST_OAM_AFFINE_ERASE 2
+#define ST_OAM_AFFINE_DOUBLE 3
+
+#define ST_OAM_AFFINE_ON_MASK 1
+#define ST_OAM_AFFINE_DOUBLE_MASK 2
+
+#define ST_OAM_4BPP 0
+#define ST_OAM_8BPP 1
+
+#define ST_OAM_SQUARE 0
+#define ST_OAM_H_RECTANGLE 1
+#define ST_OAM_V_RECTANGLE 2
+
+struct ObjAffineSrcData
+{
+ s16 xScale;
+ s16 yScale;
+ u16 rotation;
+};
+
+#endif // GUARD_GBA_TYPES_H