using Inu.Language;

namespace Inu.Linker
{
    class P6File : BinaryTargetFile
    {
        private static byte[] Basic =
        {
            0xd3,0xd3,0xd3,0xd3,0xd3,0xd3,0xd3,0xd3,0xd3,0xd3,0x4c,0x4f,0x41,0x44,0x45,0x52,
            0xff,0xff,0x0a,0x00,0x41,0xd2,0xe3,0x28,0x26,0x48,0x46,0x46,0x35,0x41,0x29,0xca,
            0xe3,0x28,0x26,0x48,0x46,0x46,0x35,0x42,0x29,0xcc,0x32,0x35,0x36,0xca,0x31,0x36,
            0x00,0xff,0xff,0x14,0x00,0x81,0x20,0x49,0xd2,0x41,0x20,0xc3,0x20,0x41,0xca,0x34,
            0x35,0x00,0xff,0xff,0x1e,0x00,0x86,0x20,0x41,0x24,0x3a,0x20,0x94,0x20,0x49,0x2c,
            0xe7,0x28,0x22,0x26,0x48,0x22,0xca,0x41,0x24,0x29,0x00,0xff,0xff,0x28,0x00,0x82,
            0x00,0xff,0xff,0x32,0x00,0xa5,0x20,0x41,0x00,0xff,0xff,0x3c,0x00,0x83,0x20,0x43,
            0x44,0x2c,0x36,0x31,0x2c,0x31,0x41,0x2c,0x43,0x44,0x2c,0x37,0x30,0x2c,0x31,0x41,
            0x2c,0x46,0x45,0x2c,0x43,0x39,0x2c,0x32,0x30,0x2c,0x46,0x39,0x2c,0x43,0x44,0x2c,
            0x37,0x30,0x2c,0x31,0x41,0x2c,0x46,0x45,0x2c,0x43,0x39,0x2c,0x32,0x38,0x2c,0x46,
            0x39,0x2c,0x36,0x46,0x2c,0x43,0x44,0x2c,0x37,0x30,0x2c,0x31,0x41,0x2c,0x36,0x37,
            0x2c,0x45,0x35,0x2c,0x43,0x44,0x2c,0x37,0x30,0x2c,0x31,0x41,0x2c,0x34,0x46,0x2c,
            0x43,0x44,0x2c,0x37,0x30,0x2c,0x31,0x41,0x2c,0x34,0x37,0x2c,0x43,0x44,0x2c,0x37,
            0x30,0x2c,0x31,0x41,0x2c,0x37,0x37,0x2c,0x32,0x33,0x2c,0x30,0x42,0x2c,0x37,0x38,
            0x2c,0x42,0x31,0x2c,0x32,0x30,0x2c,0x46,0x36,0x2c,0x43,0x44,0x2c,0x41,0x41,0x2c,
            0x31,0x41,0x2c,0x45,0x31,0x2c,0x45,0x39,0x2c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00
        };

        public P6File(string fileName) : base(fileName) { }

        public override void Write(int address, byte[] bytes)
        {
            Stream.Write(Basic, 0, Basic.Length);
            for (int i = 0; i < 10; ++i) {
                Stream.WriteByte(0xc9);
            }
            Stream.WriteWord(address);
            Stream.WriteWord(bytes.Length);
            Stream.Write(bytes, 0, bytes.Length);
        }

        protected override void WriteRecord(int address, byte[] bytes, int offset, int recordSize) { }
    }
}
