예제 #1
0
        private void btSave_Click(object sender, EventArgs e)
        {
            int FRAME_COUNT = AnimConfig.FRAME_COUNT;
            int frameAddr1Hi = AnimConfig.frameAddrHi;
            int frameAddr1Lo = AnimConfig.frameAddrLo;

            for (int frame = 0; frame < FRAME_COUNT; frame++)
            {
                byte frameAddrHi = Globals.romdata[frameAddr1Hi + frame];
                byte frameAddrLo = Globals.romdata[frameAddr1Lo + frame];
                int frameAddr = Utils.makeAddrPtr(frameAddrHi, frameAddrLo);
                int frameAddrRom = Utils.getRomAddr(AnimConfig.animBankNo, frameAddr);
                int tileCount = Globals.romdata[frameAddrRom] + 1;
                int coordsIndex = Globals.romdata[frameAddrRom + 1];
                var tiles = frameList[frame].tiles;
                for (int tile = 0; tile < tileCount; tile++)
                {
                    Globals.romdata[frameAddrRom + 2 + tile * 2] = (byte)tiles[tile].index;
                    Globals.romdata[frameAddrRom + 2 + tile * 2 + 1] = (byte)tiles[tile].property;
                }
                FrameData frameData = new FrameData(frame, frameAddr, tileCount, coordsIndex, tiles);
                frameList[frame] = frameData;
            }

            flushToFile();
        }
예제 #2
0
 private void tvAnims_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     var node = e.Node;
     if (node.Tag != null)
     {
         activeFrame = (FrameData)node.Tag;
         drawFrame(activeFrame);
         setTiles(activeFrame);
     }
 }
예제 #3
0
 private void setTiles(FrameData f)
 {
     lvTiles.Items.Clear();
     TileInfo[] tiles = f.tiles;
     int coordsAddr = coordList[f.coordsIndex].addr;
     int coordsRomAddr = Utils.getRomAddr(AnimConfig.animBankNo, coordsAddr);
     for (int i = 0; i < tiles.Length; i++)
     {
         byte xcByte = Globals.romdata[coordsRomAddr + i * 2 + 1];
         byte ycByte = Globals.romdata[coordsRomAddr + i * 2 + 0];
         lvTiles.Items.Add(String.Format("T:{0,2:X2} P[{1,2:X2}] X:{2,2:X2} Y:{3,2:X2}", tiles[i].index, tiles[i].property, xcByte, ycByte));
     }
 }
예제 #4
0
        private void loadAnimData()
        {
            int ANIM_COUNT = AnimConfig.ANIM_COUNT;
            int animAddrHi = AnimConfig.animAddrHi;
            int animAddrLo = AnimConfig.animAddrLo;

            int FRAME_COUNT = AnimConfig.FRAME_COUNT;
            int frameAddr1Hi = AnimConfig.frameAddrHi;
            int frameAddr1Lo = AnimConfig.frameAddrLo;

            int COORD_COUNT = AnimConfig.COORD_COUNT;
            int coordAddrHi = AnimConfig.coordAddrHi;
            int coordAddrLo = AnimConfig.coordAddrLo;

            animList = new AnimData[ANIM_COUNT];
            frameList = new FrameData[FRAME_COUNT];
            coordList = new CoordData[COORD_COUNT];

            for (int i = 0; i < ANIM_COUNT; i++)
            {
                byte hiAddrByte = Globals.romdata[animAddrHi + i];
                byte loAddrByte = Globals.romdata[animAddrLo + i];
                int addr = Utils.makeAddrPtr(hiAddrByte, loAddrByte);
                int addrRom = Utils.getRomAddr(AnimConfig.animBankNo, addr);
                int frameCountAndShift = Globals.romdata[addrRom] + 1;
                int framesCount = frameCountAndShift % 128;
                int frameShift = frameCountAndShift < 128 ? 0 : 256;
                int timer = Globals.romdata[addrRom+1];
                int[] frameIndexes = null;
                {
                    frameIndexes = new int[framesCount];
                    for (int frame = 0; frame < framesCount; frame++)
                    {
                        int frameNo = Globals.romdata[addrRom + 2 + frame];
                        frameIndexes[frame] = frameNo + frameShift;
                    }
                }
                animList[i] = new AnimData(i, addr, framesCount, timer, frameIndexes, frameShift);
            }

            for (int frame = 0; frame < FRAME_COUNT; frame++)
            {
                byte frameAddrHi = Globals.romdata[frameAddr1Hi + frame];
                byte frameAddrLo = Globals.romdata[frameAddr1Lo + frame];
                int frameAddr = Utils.makeAddrPtr(frameAddrHi, frameAddrLo);
                int frameAddrRom = Utils.getRomAddr(AnimConfig.animBankNo, frameAddr);
                int tileCount = Globals.romdata[frameAddrRom]+1;
                int coordsIndex = Globals.romdata[frameAddrRom+1];
                var tiles = new TileInfo[tileCount];
                for (int tile = 0; tile < tileCount; tile++)
                {
                    tiles[tile].index    = Globals.romdata[frameAddrRom + 2 + tile*2];
                    tiles[tile].property = Globals.romdata[frameAddrRom + 2 + tile*2+1];
                }
                FrameData frameData = new FrameData(frame, frameAddr, tileCount, coordsIndex, tiles);
                frameList[frame] = frameData;
            }

            for (int coord = 0; coord < COORD_COUNT; coord++)
            {
                byte coordAddrHiByte = Globals.romdata[coordAddrHi + coord];
                byte coordAddrLoByte = Globals.romdata[coordAddrLo + coord];
                int coordAddr = Utils.makeAddrPtr(coordAddrHiByte, coordAddrLoByte);
                CoordData coordData = new CoordData(coordAddr);
                coordList[coord] = coordData;
            }

            mapAnimToTreeView();
        }
예제 #5
0
        private void drawFrame(FrameData f, bool drawWithSelectedTiles = false)
        {
            if (f == null)
                return;
            int scale = 4;
            Bitmap frame = new Bitmap(128 * scale, 128 * scale);

            int count = f.tileCount;
            TileInfo[] tiles = f.tiles;
            int coordsAddr = coordList[f.coordsIndex].addr;
            int coordsRomAddr = Utils.getRomAddr(AnimConfig.animBankNo, coordsAddr);
            int addPart = (128 / 2 * scale);

            ImageList[] imageLists = { imageList1, imageList2, imageList3, imageList4 };

            using (Graphics g = Graphics.FromImage(frame))
            {
                g.FillRectangle(Brushes.Black, new Rectangle(0,0,128*scale, 128*scale));
                for (int i = 0; i < count; i++)
                {
                    byte xcByte = Globals.romdata[coordsRomAddr + i * 2 + 1];
                    byte ycByte = Globals.romdata[coordsRomAddr + i * 2 + 0];
                    int xOrig = Utils.getSignedFromByte(xcByte);
                    int yOrig = Utils.getSignedFromByte(ycByte);
                    int x = addPart + xOrig * scale;
                    int y = addPart + yOrig * scale;
                    int index = tiles[i].index;
                    int property = tiles[i].property;
                    int xh = x + 8 * scale;
                    int yh = y + 8 * scale;
                    int subPalIndex = property & 0x3;

                    Point[] destPoints = new Point[3];
                    bool xReverted = (property & 0x40) == 0x40;
                    bool yReverted = (property & 0x80) == 0x80;
                    destPoints[0] = new Point(xReverted ? xh : x, yReverted ? yh : y);
                    destPoints[1] = new Point(xReverted ? x : xh, yReverted ? yh : y);
                    destPoints[2] = new Point(xReverted ? xh : x, yReverted ? y : yh);
                    g.DrawImage(imageLists[subPalIndex].Images[index], destPoints/*, new Rectangle(addPart + xs[i]*scale, addPart + ys[i]*scale, 8 * scale, 8 * scale)*/);
                    if (drawWithSelectedTiles)
                    {
                        if (lvTiles.SelectedIndices.Contains(i))
                          g.DrawRectangle(new Pen(Brushes.Red, 2.0f), new Rectangle(destPoints[0].X, destPoints[0].Y, 8 * scale, 8 * scale));
                    }
                }
            }
            pbFrame.Image = frame;
        }
예제 #6
0
        private void loadAnimData()
        {
            int ANIM_COUNT = AnimConfig.ANIM_COUNT;
            int animAddrHi = AnimConfig.animAddrHi;
            int animAddrLo = AnimConfig.animAddrLo;

            int FRAME_COUNT  = AnimConfig.FRAME_COUNT;
            int frameAddr1Hi = AnimConfig.frameAddrHi;
            int frameAddr1Lo = AnimConfig.frameAddrLo;

            int COORD_COUNT = AnimConfig.COORD_COUNT;
            int coordAddrHi = AnimConfig.coordAddrHi;
            int coordAddrLo = AnimConfig.coordAddrLo;

            animList  = new AnimData[ANIM_COUNT];
            frameList = new FrameData[FRAME_COUNT];
            coordList = new CoordData[COORD_COUNT];

            for (int i = 0; i < ANIM_COUNT; i++)
            {
                byte  hiAddrByte         = Globals.romdata[animAddrHi + i];
                byte  loAddrByte         = Globals.romdata[animAddrLo + i];
                int   addr               = Utils.makeAddrPtr(hiAddrByte, loAddrByte);
                int   addrRom            = Utils.getRomAddr(AnimConfig.animBankNo, addr);
                int   frameCountAndShift = Globals.romdata[addrRom] + 1;
                int   framesCount        = frameCountAndShift % 128;
                int   frameShift         = frameCountAndShift < 128 ? 0 : 256;
                int   timer              = Globals.romdata[addrRom + 1];
                int[] frameIndexes       = null;
                {
                    frameIndexes = new int[framesCount];
                    for (int frame = 0; frame < framesCount; frame++)
                    {
                        int frameNo = Globals.romdata[addrRom + 2 + frame];
                        frameIndexes[frame] = frameNo + frameShift;
                    }
                }
                animList[i] = new AnimData(i, addr, framesCount, timer, frameIndexes, frameShift);
            }

            for (int frame = 0; frame < FRAME_COUNT; frame++)
            {
                byte frameAddrHi  = Globals.romdata[frameAddr1Hi + frame];
                byte frameAddrLo  = Globals.romdata[frameAddr1Lo + frame];
                int  frameAddr    = Utils.makeAddrPtr(frameAddrHi, frameAddrLo);
                int  frameAddrRom = Utils.getRomAddr(AnimConfig.animBankNo, frameAddr);
                int  tileCount    = Globals.romdata[frameAddrRom] + 1;
                int  coordsIndex  = Globals.romdata[frameAddrRom + 1];
                var  tiles        = new TileInfo[tileCount];
                for (int tile = 0; tile < tileCount; tile++)
                {
                    tiles[tile].index    = Globals.romdata[frameAddrRom + 2 + tile * 2];
                    tiles[tile].property = Globals.romdata[frameAddrRom + 2 + tile * 2 + 1];
                }
                FrameData frameData = new FrameData(frame, frameAddr, tileCount, coordsIndex, tiles);
                frameList[frame] = frameData;
            }

            for (int coord = 0; coord < COORD_COUNT; coord++)
            {
                byte      coordAddrHiByte = Globals.romdata[coordAddrHi + coord];
                byte      coordAddrLoByte = Globals.romdata[coordAddrLo + coord];
                int       coordAddr       = Utils.makeAddrPtr(coordAddrHiByte, coordAddrLoByte);
                CoordData coordData       = new CoordData(coordAddr);
                coordList[coord] = coordData;
            }

            mapAnimToTreeView();
        }