minor code fixes for sprites

- saves several bytes for sketches using drawPlusMask()
This commit is contained in:
Josh Goebel 2017-04-18 21:26:32 -04:00 committed by Scott Allen
parent dac16d5e36
commit 3aa015b997
1 changed files with 5 additions and 9 deletions

View File

@ -252,8 +252,7 @@ void Sprites::drawBitmap(int16_t x, int16_t y,
asm volatile( asm volatile(
"push r28\n" // save Y "push r28\n" // save Y
"push r29\n" "push r29\n"
"mov r28, %A[buffer_page2_ofs]\n" // Y = buffer page 2 offset "movw r28, %[buffer_page2_ofs]\n" // Y = buffer page 2 offset
"mov r29, %B[buffer_page2_ofs]\n"
"loop_y:\n" "loop_y:\n"
"loop_x:\n" "loop_x:\n"
// load bitmap and mask data // load bitmap and mask data
@ -264,11 +263,9 @@ void Sprites::drawBitmap(int16_t x, int16_t y,
"tst %[yOffset]\n" "tst %[yOffset]\n"
"breq skip_shifting\n" "breq skip_shifting\n"
"mul %A[bitmap_data], %[mul_amt]\n" "mul %A[bitmap_data], %[mul_amt]\n"
"mov %A[bitmap_data], r0\n" "movw %[bitmap_data], r0\n"
"mov %B[bitmap_data], r1\n"
"mul %A[mask_data], %[mul_amt]\n" "mul %A[mask_data], %[mul_amt]\n"
"mov %A[mask_data], r0\n" "movw %[mask_data], r0\n"
// "mov %B[mask_data], r1\n"
// SECOND PAGE // SECOND PAGE
@ -277,8 +274,7 @@ void Sprites::drawBitmap(int16_t x, int16_t y,
"brge end_second_page\n" "brge end_second_page\n"
// then // then
"ld %[data], Y\n" "ld %[data], Y\n"
// "com %B[mask_data]\n" // invert high byte of mask "com %B[mask_data]\n" // invert high byte of mask
"com r1\n"
"and %[data], r1\n" // %B[mask_data] "and %[data], r1\n" // %B[mask_data]
"or %[data], %B[bitmap_data]\n" "or %[data], %B[bitmap_data]\n"
// update buffer, increment // update buffer, increment
@ -333,7 +329,7 @@ void Sprites::drawBitmap(int16_t x, int16_t y,
"clr __zero_reg__\n" // just in case "clr __zero_reg__\n" // just in case
: [xi] "+&r" (xi), : [xi] "+&r" (xi),
[yi] "+&r" (yi), [yi] "+&r" (yi),
[sRow] "+&a" (sRow), // CPI requires an upper register [sRow] "+&d" (sRow), // CPI requires an upper register
[data] "+&r" (data), [data] "+&r" (data),
[mask_data] "+&r" (mask_data), [mask_data] "+&r" (mask_data),
[bitmap_data] "+&r" (bitmap_data) [bitmap_data] "+&r" (bitmap_data)