Пример #1
0
        public FormDLI(DLI dli = null, int forcedDliLineIndex = -1)
        {
            InitializeComponent();

            populateOrderCombo();

            if (dli != null)
            {
                ReturnAtariPFColors = new AtariPFColors(dli.AtariPFColors);
                ReturnIntLine       = forcedDliLineIndex != -1? forcedDliLineIndex:dli.IntLine;
                ReturnOrderValue    = dli.OrderValue;
            }
            else
            {
                ReturnAtariPFColors = new AtariPFColors();
                ReturnIntLine       = 1;
                ReturnOrderValue    = null;
            }

            UpdateColors();

            buttonColbk.Click  += (s, e) => { HandleButtonClick(PlayFieldColor.COLBK); };
            buttonColpf0.Click += (s, e) => { HandleButtonClick(PlayFieldColor.COLPF0); };
            buttonColpf1.Click += (s, e) => { HandleButtonClick(PlayFieldColor.COLPF1); };
            buttonColpf2.Click += (s, e) => { HandleButtonClick(PlayFieldColor.COLPF2); };
            buttonColpf3.Click += (s, e) => { HandleButtonClick(PlayFieldColor.COLPF3); };
        }
Пример #2
0
        public void RemoveDLI(DLI dli)
        {
            List <DLI> dlis = new List <DLI>(DLIS);

            dlis.Remove(dli);
            DLIS = dlis.ToArray();
            ((EventHandler)listEventDelegates[dliChangedEventKey])?.Invoke(this, null);
        }
Пример #3
0
        private Map()
        {
            Interlocked.Increment(ref counter);

            MapData = new byte[11 * 40];
            Name    = "New Map " + counter;
            DLIS    = new DLI[] { new DLI(this, new AtariPFColors(), 0) };

            IsDirty = true;
            IsNew   = true;
        }
Пример #4
0
        public bool ChangeDLI(DLI dliChanged, int intLine, AtariPFColors returnAtariPFColors, Object returnOrderValue)
        {
            foreach (DLI dli in DLIS)
            {
                if (dli.IntLine == intLine && !dli.Equals(dliChanged))
                {
                    MessageBox.Show("There already is a DLI at line " + intLine);
                    return(false);
                }
            }

            dliChanged.AtariPFColors = returnAtariPFColors;
            dliChanged.IntLine       = intLine;
            dliChanged.OrderValue    = returnOrderValue;

            CreateDLIMapIndex();

            ((EventHandler)listEventDelegates[dliChangedEventKey])?.Invoke(this, null);
            return(true);
        }
Пример #5
0
        private void ExportColorsDeltaDLI(StreamWriter file, int mapIndex, int dliIndex, DLI dli, DLI previousDli, bool lastDLI)
        {
            Dictionary <RbgPFColors.PlayFieldColor, byte> colorsDelta = dli.AtariPFColors.Delta(previousDli?.AtariPFColors);

            colorsDelta.Remove(RbgPFColors.PlayFieldColor.COLPF3);  // Always Black;

            colorsDelta = SortColors(colorsDelta, dli.OrderValue);

            String currentLabel = $"Map{mapIndex}Dli{dliIndex}";

            AddLabel(file, currentLabel);

            file.WriteLine($"{BOL}pha");

            switch (colorsDelta.Count)
            {
            case 1:
                file.WriteLine($"{BOL}lda #{colorsDelta.Values.ElementAt(0)}");
                file.WriteLine($"{BOL}sta WSYNC");
                file.WriteLine($"{BOL}sta {colorsDelta.Keys.ElementAt(0)}");
                break;

            case 2:
                file.WriteLine($"{BOL}stx {currentLabel}X");
                file.WriteLine($"{BOL}lda #{colorsDelta.Values.ElementAt(0)}");
                file.WriteLine($"{BOL}ldx #{colorsDelta.Values.ElementAt(1)}");
                file.WriteLine($"{BOL}sta WSYNC");
                file.WriteLine($"{BOL}sta {colorsDelta.Keys.ElementAt(0)}");
                file.WriteLine($"{BOL}stx {colorsDelta.Keys.ElementAt(1)}");
                file.WriteLine($"{BOL}{currentLabel}X equ *+1");
                file.WriteLine($"{BOL}ldx #$FF");
                break;

            case 3:
                file.WriteLine($"{BOL}stx {currentLabel}X");
                file.WriteLine($"{BOL}lda #{colorsDelta.Values.ElementAt(0)}");
                file.WriteLine($"{BOL}ldx #{colorsDelta.Values.ElementAt(1)}");
                file.WriteLine($"{BOL}sta WSYNC");
                file.WriteLine($"{BOL}sta {colorsDelta.Keys.ElementAt(0)}");
                file.WriteLine($"{BOL}stx {colorsDelta.Keys.ElementAt(1)}");
                file.WriteLine($"{BOL}lda #{colorsDelta.Values.ElementAt(2)}");
                file.WriteLine($"{BOL}sta {colorsDelta.Keys.ElementAt(2)}");
                file.WriteLine($"{BOL}{currentLabel}X equ *+1");
                file.WriteLine($"{BOL}ldx #$FF");
                break;

            case 4:
                file.WriteLine($"{BOL}stx {currentLabel}X");
                file.WriteLine($"{BOL}lda #{colorsDelta.Values.ElementAt(0)}");
                file.WriteLine($"{BOL}ldx #{colorsDelta.Values.ElementAt(1)}");
                file.WriteLine($"{BOL}sta WSYNC");
                file.WriteLine($"{BOL}sta {colorsDelta.Keys.ElementAt(0)}");
                file.WriteLine($"{BOL}stx {colorsDelta.Keys.ElementAt(1)}");
                file.WriteLine($"{BOL}lda #{colorsDelta.Values.ElementAt(2)}");
                file.WriteLine($"{BOL}sta {colorsDelta.Keys.ElementAt(2)}");
                file.WriteLine($"{BOL}lda #{colorsDelta.Values.ElementAt(3)}");
                file.WriteLine($"{BOL}sta {colorsDelta.Keys.ElementAt(3)}");
                file.WriteLine($"{BOL}{currentLabel}X equ *+1");
                file.WriteLine($"{BOL}ldx #$FF");
                break;
            }

            String nextLabel = lastDLI?"LastDLI":$"Map{mapIndex}Dli{dliIndex+1}";


            file.WriteLine($"{BOL}lda #<{nextLabel}");
            file.WriteLine($"{BOL}sta VDSLST");
            file.WriteLine($"{BOL}lda #>{nextLabel}");
            file.WriteLine($"{BOL}sta VDSLST+1");
            file.WriteLine($"{BOL}pla");
            file.WriteLine($"{BOL}rti");
        }
Пример #6
0
        public static Map Load(MapSet mapSet, XElement mapElemept)
        {
            Map map = CreateNewMap(mapSet, mapSet.GetFont(GuidHelper.parse(mapElemept.Attribute("font")?.Value)), mapElemept.Attribute("uid")?.Value);

            map.Name    = mapElemept.Attribute("name").Value;
            map.Path    = PathHelper.GetExactPath(mapSet.Path, mapElemept.Attribute("path").Value);
            map.MapData = map.UseRleCompression() ? DecodeRLE(File.ReadAllBytes(map.Path)) : DecodeLZ4(map.Path);

            XElement   dlis    = mapElemept.Element("dlis");
            List <DLI> DLIList = new List <DLI>();

            foreach (XElement xdli in dlis.Elements("dli"))
            {
                DLI dli = DLI.Load(map, xdli);
                DLIList.Add(dli);
            }
            map.DLIS = DLIList.ToArray();

            ImportTextFile(mapElemept, "InitRoutinePath", mapSet.Path, (Path, Content) => { map.InitRoutinePath = Path; map.InitRoutine = Content; });
            ImportTextFile(mapElemept, "ExecRoutinePath", mapSet.Path, (Path, Content) => { map.ExecRoutinePath = Path; map.ExecRoutine = Content; });
            ImportTextFile(mapElemept, "TileCollisionRoutinePath", mapSet.Path, (Path, Content) => { map.TileCollisionRoutinePath = Path; map.TileCollisionRoutine = Content; });
            ImportBoolean(mapElemept, "foe", value => map.Foe = value);
            ImportByte(mapElemept, "YamoSpawnPosition", value => map.YamoSpawnPosition   = value);
            ImportByte(mapElemept, "NinjaSpawnPosition", value => map.NinjaSpawnPosition = value);
            ImportByte(mapElemept, "NinjaEnterCount1", value => map.NinjaEnterCount1     = value);
            ImportByte(mapElemept, "NinjaEnterCount2", value => map.NinjaEnterCount2     = value);
            ImportByte(mapElemept, "YamoEnterCount1", value => map.YamoEnterCount1       = value);
            ImportByte(mapElemept, "YamoEnterCount2", value => map.YamoEnterCount2       = value);
            ImportColorDetection(mapElemept, "Colpf0Dectection", ref map.Colpf0Detection, ref map.Colpf0DetectionRects, ref map.Colpf0DetectionFlags);
            ImportColorDetection(mapElemept, "Colpf2Dectection", ref map.Colpf2Detection, ref map.Colpf2DetectionRects, ref map.Colpf2DetectionFlags);
            ImportColorDetection(mapElemept, "Colpf3Dectection", ref map.Colpf3Detection, ref map.Colpf3DetectionRects, ref map.Colpf3DetectionFlags);

            if (mapElemept.Elements("brucestart").Any())
            {
                XElement brucestart = mapElemept.Element("brucestart");
                map.BruceStartX1 = Convert.ToByte(brucestart.Element("x1").Value);
                map.BruceStartY1 = Convert.ToByte(brucestart.Element("y1").Value);
                map.BruceStartX2 = Convert.ToByte(brucestart.Element("x2").Value);
                map.BruceStartY2 = Convert.ToByte(brucestart.Element("y2").Value);
            }

            if (mapElemept.Elements("exit1").Any())
            {
                XElement exit = mapElemept.Element("exit1");
                map.Exit1MapID = GuidHelper.parse(exit.Element("map").Value);
                map.Exit1X     = Convert.ToByte(exit.Element("x").Value);
                map.Exit1Y     = Convert.ToByte(exit.Element("y").Value);
            }

            if (mapElemept.Elements("exit2").Any())
            {
                XElement exit = mapElemept.Element("exit2");
                map.Exit2MapID = GuidHelper.parse(exit.Element("map").Value);
                map.Exit2X     = Convert.ToByte(exit.Element("x").Value);
                map.Exit2Y     = Convert.ToByte(exit.Element("y").Value);
            }

            if (mapElemept.Elements("exit3").Any())
            {
                XElement exit = mapElemept.Element("exit3");
                map.Exit3MapID = GuidHelper.parse(exit.Element("map").Value);
                map.Exit3X     = Convert.ToByte(exit.Element("x").Value);
                map.Exit3Y     = Convert.ToByte(exit.Element("y").Value);
            }

            if (mapElemept.Elements("exit4").Any())
            {
                XElement exit = mapElemept.Element("exit4");
                map.Exit4MapID = GuidHelper.parse(exit.Element("map").Value);
                map.Exit4X     = Convert.ToByte(exit.Element("x").Value);
                map.Exit4Y     = Convert.ToByte(exit.Element("y").Value);
            }

            map.SetLoaded();

            return(map);
        }
Пример #7
0
 public DLISelectedEventArgs(DLI DLI)
     : base()
 {
     this.DLI = DLI;
 }