this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

sprite flags works only in 4bpp mode

Nesbox 8b885881 babe9a10

+22 -37
+22 -37
src/sprite.c
··· 644 644 static s32 indexes[TIC_SPRITESIZE*TIC_SPRITESIZE+1]; 645 645 memset(indexes, -1, sizeof indexes); 646 646 647 - u16 sheet_cols = SHEET_COLS*sprite->nbPages; 647 + u16 sheet_cols = SHEET_COLS * sprite->nbPages; 648 648 649 649 { 650 650 tic_rect r = {sprite->index % sheet_cols, sprite->index / sheet_cols ··· 653 653 s32 c = 0; 654 654 for(s32 j = r.y; j < r.h + r.y; j++) 655 655 for(s32 i = r.x; i < r.w + r.x; i++) 656 - indexes[c++] = i + j * sheet_cols; 657 - 656 + indexes[c++] = (i + j * sheet_cols) + sprite->bank * TIC_BANK_SPRITES; 658 657 } 659 658 660 659 return indexes; ··· 667 666 if(hasCanvasSelection(sprite)) return; 668 667 669 668 enum {Size = 5}; 670 - u8 nbFlags = 2*sprite->bpp; 671 - u8 flagMask = (1 << nbFlags) - 1; 672 - 673 - y+= (Size+1)*(8-nbFlags)/2; 674 669 675 670 u8* flags = getBankFlags()->data; 676 671 u8 or = 0; 677 - u8 and = flagMask; 672 + u8 and = 0xff; 678 673 679 - u8 indicesPerNibble = 4/sprite->bpp; 680 - s32* indexes = getSpriteIndexes(sprite); 674 + const s32* indexes = getSpriteIndexes(sprite); 681 675 682 676 { 683 - s32* i = indexes; 677 + const s32* i = indexes; 684 678 while(*i >= 0) 685 679 { 686 - s32 ii=*i/indicesPerNibble, ir=*i%indicesPerNibble; 687 - u8 iiflags = flags[ii]; 688 - iiflags >>= ir*nbFlags; 689 - iiflags &= flagMask; 690 - 691 - or |= iiflags; 692 - and &= iiflags; 693 - i++; 680 + u8 mask = flags[*i++]; 681 + or |= mask; 682 + and &= mask; 694 683 } 695 684 } 696 685 697 - for(s32 i = 0; i < nbFlags; i++) 686 + for(s32 i = 0; i < BITS_IN_BYTE; i++) 698 687 { 699 688 const u8 mask = 1 << i; 700 689 tic_rect rect = {x, y + (Size+1)*i, Size, Size}; ··· 709 698 710 699 if(checkMouseClick(&rect, tic_mouse_left)) 711 700 { 712 - s32* i = indexes; 701 + const s32* i = indexes; 713 702 714 703 if(or & mask) 715 - while(*i >= 0){ 716 - s32 ii=*i/indicesPerNibble, ir=*i%indicesPerNibble; 717 - flags[ii] &= ~(mask << (ir * nbFlags)); 718 - i++; 719 - } 704 + while(*i >= 0) 705 + flags[*i++] &= ~mask; 720 706 else 721 - while(*i >= 0) { 722 - s32 ii=*i/indicesPerNibble, ir=*i%indicesPerNibble; 723 - flags[ii] |= mask << (ir * nbFlags); 724 - i++; 725 - } 707 + while(*i >= 0) 708 + flags[*i++] |= mask; 726 709 } 727 710 } 728 711 ··· 731 714 u8 flagColor = i + 2; 732 715 733 716 if(or & mask) 734 - tic_api_pix(tic, rect.x+2, rect.y+2, flagColor, false); 717 + tic_api_pix(tic, rect.x + 2, rect.y + 2, flagColor, false); 735 718 else if(over) 736 - tic_api_rect(tic, rect.x+1, rect.y+1, Size-2, Size-2, flagColor); 719 + tic_api_rect(tic, rect.x + 1, rect.y + 1, Size - 2, Size - 2, flagColor); 737 720 738 721 if(and & mask) 739 722 { 740 - tic_api_rect(tic, rect.x+1, rect.y+1, Size-2, Size-2, flagColor); 741 - tic_api_pix(tic, rect.x+3, rect.y+1, tic_color_12, false); 723 + tic_api_rect(tic, rect.x + 1, rect.y + 1, Size - 2, Size - 2, flagColor); 724 + tic_api_pix(tic, rect.x + 3, rect.y + 1, tic_color_12, false); 742 725 } 743 726 744 727 tic_api_print(tic, (char[]){'0' + i, '\0'}, rect.x + (Size+2), rect.y, tic_color_13, false, 1, true); ··· 1728 1711 1729 1712 static void switchBanks(Sprite* sprite) 1730 1713 { 1731 - sprite->bank=!sprite->bank; 1714 + sprite->bank = !sprite->bank; 1732 1715 1733 1716 updateIndex(sprite); 1734 1717 initTileSheet(sprite); ··· 2037 2020 2038 2021 if(sprite->advanced) 2039 2022 { 2040 - drawFlags(sprite, 24+64+7, 20+8); 2023 + if(sprite->bpp == 4) 2024 + drawFlags(sprite, 24+64+7, 20+8); 2025 + 2041 2026 drawBitMode(sprite, PaletteX, PaletteY + PaletteH + 2, PaletteW, 8); 2042 2027 } 2043 2028