Beispiel #1
0
        public void SetFont(SCIFont spr)
        {
            ushort cnt = (ushort)(spr.Frames.Count & 0xFFFF);

            ByteBuilder bb = new ByteBuilder();

            bb.AddByte(0);
            bb.AddShortLE(cnt);
            bb.AddShortLE(spr.FontHeight);
            bb.AddByte(0);

            for (int i = 0; i < cnt; i++)
            {
                bb.AddShortLE(0);
            }

            byte bit;
            byte bitMask;

            for (int i = 0; i < cnt; i++)
            {
                SpriteFrame frm    = spr[i];
                byte        w      = (byte)frm.Width;
                byte        h      = (byte)frm.Height;
                ushort      offset = (ushort)bb.Position;

                bb.SetShortBE(6 + i * 2, offset);

                bb.AddByte(w);
                bb.AddByte(h);
                for (int y = 0; y < frm.Height; y++)
                {
                    bit     = 0;
                    bitMask = 0;
                    for (int x = 0; x < frm.Width; x++)
                    {
                        if (frm[x, y] == 1)
                        {
                            bitMask |= (byte)(1 << (7 - bit));
                        }

                        bit++;
                        if (bit == 8)
                        {
                            bit = 0;
                            bb.AddByte(bitMask);
                            bitMask = 0;
                        }
                    }

                    if (bit != 0)
                    {
                        bb.AddByte(bitMask);
                    }
                }
            }

            SaveTranslate(bb.GetArray());
        }
Beispiel #2
0
        public override byte[] GetPatch()
        {
            ushort cnt = (ushort)(_font.Frames.Count & 0xFFFF);

            ByteBuilder bb = new ByteBuilder();

            bb.AddByte(0);
            bb.AddShortLE(cnt);
            bb.AddShortLE(_font.FontHeight);
            bb.AddByte(0);

            for (int i = 0; i < cnt; i++)
            {
                bb.AddShortLE(0);
            }

            byte bit;
            byte bitMask;

            for (int i = 0; i < cnt; i++)
            {
                SpriteFrame frm    = _font[i];
                byte        w      = (byte)frm.Width;
                byte        h      = (byte)frm.Height;
                ushort      offset = (ushort)bb.Position;

                bb.SetShortBE(6 + i * 2, offset);

                bb.AddByte(w);
                bb.AddByte(h);
                for (int y = 0; y < frm.Height; y++)
                {
                    bit     = 0;
                    bitMask = 0;
                    for (int x = 0; x < frm.Width; x++)
                    {
                        if (frm[x, y] == 1)
                        {
                            bitMask |= (byte)(1 << (7 - bit));
                        }

                        bit++;
                        if (bit == 8)
                        {
                            bit = 0;
                            bb.AddByte(bitMask);
                            bitMask = 0;
                        }
                    }

                    if (bit != 0)
                    {
                        bb.AddByte(bitMask);
                    }
                }
            }

            return(bb.GetArray());
        }