public FontBitmap(byte *Address, FontPixelFormat FontPixelFormat, int Width, int Height, int BytesPerLine)
            {
                this.Address         = Address;
                this.FontPixelFormat = FontPixelFormat;
                this.Width           = Width;
                this.Height          = Height;
                this.BytesPerLine    = BytesPerLine;
                switch (FontPixelFormat)
                {
                case sceLibFont.FontPixelFormat.PSP_FONT_PIXELFORMAT_4:
                    this.BitsPerPixel = 4;
                    break;

                case sceLibFont.FontPixelFormat.PSP_FONT_PIXELFORMAT_4_REV:
                    this.BitsPerPixel = 4;
                    break;

                case sceLibFont.FontPixelFormat.PSP_FONT_PIXELFORMAT_8:
                    this.BitsPerPixel = 8;
                    break;

                case sceLibFont.FontPixelFormat.PSP_FONT_PIXELFORMAT_24:
                    this.BitsPerPixel = 24;
                    break;

                case sceLibFont.FontPixelFormat.PSP_FONT_PIXELFORMAT_32:
                    this.BitsPerPixel = 32;
                    break;
                }
            }
Exemple #2
0
        private static readonly byte[] fontPixelSizeInBytes = { 0, 0, 1, 3, 4 }; // 0 means 2 pixels per byte
        //public void DoState(PointerWrap &p){}

        void SetFontPixel(uint @base, int bpl, int bufWidth, int bufHeight, int x, int y, int pixelColor, FontPixelFormat pixelformat)
        {
            if (x < 0 || x >= bufWidth || y < 0 || y >= bufHeight)
            {
                return;
            }

            int pixelBytes  = fontPixelSizeInBytes[(int)pixelformat];
            int bufMaxWidth = (pixelBytes == 0 ? bpl * 2 : bpl / pixelBytes);

            if (x >= bufMaxWidth)
            {
                return;
            }

            int framebufferAddr = (int)(@base + (y * bpl) + (pixelBytes == 0 ? x / 2 : x * pixelBytes));

            switch (pixelformat)
            {
            case FontPixelFormat.PSP_FONT_PIXELFORMAT_4:
            case FontPixelFormat.PSP_FONT_PIXELFORMAT_4_REV:
            {
                int oldColor = Read_U8(framebufferAddr);
                int newColor;
                if ((x & 1) != (int)pixelformat)
                {
                    newColor = (pixelColor << 4) | (oldColor & 0xF);
                }
                else
                {
                    newColor = (oldColor & 0xF0) | pixelColor;
                }
                Write_U8(newColor, framebufferAddr);
                break;
            }

            case FontPixelFormat.PSP_FONT_PIXELFORMAT_8:
            {
                Write_U8((byte)pixelColor, framebufferAddr);
                break;
            }

            case FontPixelFormat.PSP_FONT_PIXELFORMAT_24:
            {
                Write_U8(pixelColor & 0xFF, framebufferAddr + 0);
                Write_U8(pixelColor >> 8, framebufferAddr + 1);
                Write_U8(pixelColor >> 16, framebufferAddr + 2);
                break;
            }

            case FontPixelFormat.PSP_FONT_PIXELFORMAT_32:
            {
                Write_U32(pixelColor, framebufferAddr);
                break;
            }
            }
        }
Exemple #3
0
 public FontBitmap(byte* Address, FontPixelFormat FontPixelFormat, int Width, int Height, int BytesPerLine)
 {
     this.Address = Address;
     this.FontPixelFormat = FontPixelFormat;
     this.Width = Width;
     this.Height = Height;
     this.BytesPerLine = BytesPerLine;
     switch (FontPixelFormat)
     {
         case sceLibFont.FontPixelFormat.PSP_FONT_PIXELFORMAT_4: this.BitsPerPixel = 4; break;
         case sceLibFont.FontPixelFormat.PSP_FONT_PIXELFORMAT_4_REV: this.BitsPerPixel = 4; break;
         case sceLibFont.FontPixelFormat.PSP_FONT_PIXELFORMAT_8: this.BitsPerPixel = 8; break;
         case sceLibFont.FontPixelFormat.PSP_FONT_PIXELFORMAT_24: this.BitsPerPixel = 24; break;
         case sceLibFont.FontPixelFormat.PSP_FONT_PIXELFORMAT_32: this.BitsPerPixel = 32; break;
     }
 }