From e09a23f0a4f342aa83854ce8cc11aacc09e350fd Mon Sep 17 00:00:00 2001 From: Logan Hunt Date: Mon, 10 Aug 2020 14:04:44 -0600 Subject: Added rotation --- source/toolbox.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 source/toolbox.c (limited to 'source/toolbox.c') diff --git a/source/toolbox.c b/source/toolbox.c new file mode 100644 index 0000000..32042a0 --- /dev/null +++ b/source/toolbox.c @@ -0,0 +1,82 @@ +// +// toolbox.c +// +// Tools source for obj_demo +// +// (20060922-20060924, cearn) +// +// === NOTES === +// * This is a _small_ set of typedefs, #defines and inlines that can +// be found in tonclib, and might not represent the +// final forms. + +#include "../include/toolbox.h" + +// === (tonc_core.c) ================================================== + +u16 __key_curr= 0, __key_prev= 0; + +// === (tonc_oam.c) =================================================== + +void oam_init(OBJ_ATTR *obj, u32 count) +{ + u32 nn= count; + u32 *dst= (u32*)obj; + + // Hide each object + while(nn--) + { + *dst++= ATTR0_HIDE; + *dst++= 0; + } + // init oam + oam_copy(oam_mem, obj, count); +} + +void oam_copy(OBJ_ATTR *dst, const OBJ_ATTR *src, u32 count) +{ + +// NOTE: while struct-copying is the Right Thing to do here, +// there's a strange bug in DKP that sometimes makes it not work +// If you see problems, just use the word-copy version. +#if 1 + while(count--) + *dst++ = *src++; +#else + u32 *dstw= (u32*)dst, *srcw= (u32*)src; + while(count--) + { + *dstw++ = *srcw++; + *dstw++ = *srcw++; + } +#endif + +} + +void obj_copy(OBJ_ATTR *dst, const OBJ_ATTR *src, u32 count) +{ + int ii; + for(ii=0; iipa = src->pa; dst->pb = src->pb; + dst->pc = src->pc; dst->pd = src->pd; + + dst++; + src++; + } +} + +void obj_affine_identity(OBJ_AFFINE *aff) { + // Make a pointer point to a identity affine matrix + aff->pa = 1 << 8; aff->pb = 0; + aff->pc = 0 ; aff->pd = 1 << 8; +} -- cgit v1.2.3-70-g09d2