Although I'm still somewhat of a C novice, I believe the following should be functionally equivalent.
Code: Select all
// Struct assignment:
OAM[0] = shadowOAM[0];
Code: Select all
// Attribute by attribute assignment:
OAM[0].attr0 = shadowOAM[0].attr0;
OAM[0].attr1 = shadowOAM[0].attr1;
OAM[0].attr2 = shadowOAM[0].attr2;
Code: Select all
OAM[0].attr0 = shadowOAM[0].attr0;
OAM[0].attr1 = shadowOAM[0].attr1;
OAM[0].attr2 = shadowOAM[0].attr2;
OAM[0] = shadowOAM[0];
Code: Select all
// Struct for interfacing with sprite registers
typedef struct {
unsigned short attr0;
unsigned short attr1;
unsigned short attr2;
unsigned short fill;
}OBJ_ATTR;
// Start of sprite registers
#define OAM ((OBJ_ATTR*)(0x7000000))
// Sprite registers buffer
OBJ_ATTR shadowOAM[128];
Code: Select all
@ Struct assignment version
mov r3, #117440512
ldr r2, .L3+8
mov ip, #8
mov r0, r3
mov r1, r2
mov r2, ip
bl memcpy
@ Attribute by attribute assignment
mov r2, #117440512
ldr r3, .L3+8
ldrh r3, [r3, #0]
strh r3, [r2, #0] @ movhi
mov r2, #117440512
ldr r3, .L3+8
ldrh r3, [r3, #2]
strh r3, [r2, #2] @ movhi
mov r2, #117440512
ldr r3, .L3+8
ldrh r3, [r3, #4]
strh r3, [r2, #4] @ movhi
@ Reference
.L3:
.word Pikachu7Pal
.word Pikachu7Tiles
.word shadowOAM
.size main, .-main
.comm shadowOAM,1024,2
.ident "GCC: (devkitARM release 24) 4.3.2"
It's possible that there is something completely obvious that I'm missing, but I wanted to ask the forum to see if you had any insight into what's causing this problem. I've attached a stripped down example of the problem including my makefile. Uncomment line 61 in main.c to replicate the problem.
Thanks in advance to anyone willing to help!
Stripped down code:
http://www.etherealpanda.com/devkitarm-code.zip
Edit:
This is code for the GBA. I'm using the visualboyadvanced emulator.