Created
July 31, 2015 19:35
-
-
Save fl4shk/cf6d0b3ab8412ad0fc23 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void sprite::copy_the_oam_entry_to_oam_mirror ( u32 slot_for_oam_mirror ) | |
{ | |
//oam_mirror [slot_for_oam_mirror].attr0 = the_oam_entry.attr0; | |
//oam_mirror [slot_for_oam_mirror].attr1 = the_oam_entry.attr1; | |
//oam_mirror [slot_for_oam_mirror].attr2 = the_oam_entry.attr2; | |
//u32 output; | |
//asm __volatile__ | |
//( | |
// "mov r0, %1\n\t" | |
// "mov %0, r0\n\t" | |
// : "=r" (output) | |
// : "r" (slot_for_oam_mirror) | |
// : "r0" | |
//); | |
asm __volatile__ | |
( | |
// Get the address of this->the_oam_entry | |
"add r0, #36\n\t" | |
// Load the address of the oam_mirror into r2 | |
"ldr r2, =oam_mirror\n\t" | |
// The size of an oam_entry is 8 bytes, so multiply | |
// slot_for_oam_mirror by 8 | |
"lsl r1, #0x3\n\t" | |
// Get the address of the particular oam_entry | |
"add r2, r1\n\t" | |
// At this point, r0 contains &(this->the_oam_entry) and r2 | |
// contains &( oam_mirror [slot_for_oam_mirror] ) | |
// attr0 and attr1 | |
"ldr r1, [r0]\n\t" | |
"str r1, [r2]\n\t" | |
// attr2 | |
"ldrh r1, [r0, #0x4]\n\t" | |
"strh r1, [r2, #0x4]\n\t" | |
: | |
: //"r" (&the_oam_entry) // inputs | |
: "r0", "r1", "r2" // clobbers | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment