コード例 #1
0
        public void Load(uint address, uint mode, uint paletteCount)
        {
            // Format:
            // 00 16-bit BGR 5650
            // 01 16-bit ABGR 5551
            // 10 16-bit ABGR 4444
            // 11 32-bit ABGR 8888
            _format      = mode & 0x3;
            _shift       = ( int )((mode >> 2) & 0x1F);
            _mask        = (mode >> 8) & 0xFF;
            _start       = ((mode >> 16) & 0x1F) * 16;           // ??
            this.Pointer = address;

            if (address == 0x0)
            {
                return;
            }

            byte *tablePointer = _driver.MemorySystem.Translate(address);

            fixed(byte *p = &_table[0])
            {
                switch (_format)
                {
                case 0:
                    this.Checksum = ColorOperations.DecodeBGR5650(tablePointer, p, paletteCount * 16);
                    break;

                case 1:
                    this.Checksum = ColorOperations.DecodeABGR5551(tablePointer, p, paletteCount * 16);
                    break;

                case 2:
                    this.Checksum = ColorOperations.DecodeABGR4444(tablePointer, p, paletteCount * 16);
                    break;

                case 3:
                    this.Checksum = ColorOperations.DecodeABGR8888(tablePointer, p, paletteCount * 8);
                    break;
                }

                // Checksum so that we can tell if it changed
                //uint* cp = ( uint* )tablePointer;
                //uint checksum = 0;
                //for( int n = 0; n < ( entryCount * entryWidth ); n++ )
                //	checksum += *( cp++ );
                //if( this.Checksum != checksum )
                //{
                // Checksums don't match! Invalidate all CLUT textures!

                /*LLEntry<TextureEntry*>* e = context->TextureCache->GetEnumerator();
                 * while( e != NULL )
                 * {
                 *      LLEntry<TextureEntry*>* next = e->Next;
                 *      if( ( e->Value->PixelStorage & 0x4 ) == 0x4 )
                 *      {
                 *              // Check to see if it was from this clut
                 *              if( e->Value->ClutPointer == context->ClutPointer )
                 *              {
                 *                      // Kill it!
                 *                      GLuint freeIds[] = { e->Value->TextureID };
                 *                      glDeleteTextures( 1, freeIds );
                 *                      context->TextureCache->Remove( ( uint )e->Value->Address );
                 *              }
                 *      }
                 *      e = next;
                 * }*/
                //context->TextureCache->Clear();
                //}
                //this.Checksum = checksum;
            }
        }