Exemplo n.º 1
0
        //save screensData from firstScreenIndex to ConfigScript.screensOffset[currentOffset]
        public static void saveScreensToOffset(OffsetRec screensRec, Screen[] screensData, int firstScreenIndex, int currentOffsetIndex, int layerNo)
        {
            var  arrayToSave  = Globals.dumpdata != null ? Globals.dumpdata : Globals.romdata;
            int  wordLen      = ConfigScript.getWordLen();
            bool littleEndian = ConfigScript.isLittleEndian();
            //write back tiles
            int dataStride = ConfigScript.getScreenDataStride();

            for (int i = 0; i < screensRec.recCount; i++)
            {
                var curScrNo    = firstScreenIndex + i;
                var curScreen   = screensData[curScrNo];
                var dataToWrite = curScreen.layers[layerNo].data;
                if (ConfigScript.getScreenVertical())
                {
                    dataToWrite = Utils.transpose(dataToWrite, screensRec.width, screensRec.height);
                }
                int addr = screensRec.beginAddr + i * screensRec.recSize * (dataStride * wordLen);
                if (wordLen == 1)
                {
                    for (int x = 0; x < screensRec.recSize; x++)
                    {
                        arrayToSave[addr + x * dataStride] = (byte)ConfigScript.backConvertScreenTile(dataToWrite[x]);
                    }
                }
                else if (wordLen == 2)
                {
                    if (littleEndian)
                    {
                        for (int x = 0; x < screensRec.recSize; x++)
                        {
                            Utils.writeWordLE(arrayToSave, addr + x * (dataStride * wordLen), ConfigScript.backConvertScreenTile(dataToWrite[x]));
                        }
                    }
                    else
                    {
                        for (int x = 0; x < screensRec.recSize; x++)
                        {
                            Utils.writeWord(arrayToSave, addr + x * (dataStride * wordLen), ConfigScript.backConvertScreenTile(dataToWrite[x]));
                        }
                    }
                }

                //write physics info, if it present
                if (curScreen.physicsLayer != null)
                {
                    ConfigScript.savePhysicsLayerFunc?.Invoke(curScrNo, curScreen.physicsLayer.data);
                }
            }
        }
Exemplo n.º 2
0
        private void saveScreens(OffsetRec screensRec, int[][] screensData)
        {
            var  arrayToSave  = Globals.dumpdata != null ? Globals.dumpdata : Globals.romdata;
            int  wordLen      = ConfigScript.getWordLen();
            bool littleEndian = ConfigScript.isLittleEndian();
            //write back tiles
            int dataStride = ConfigScript.getScreenDataStride();

            for (int i = 0; i < screensRec.recCount; i++)
            {
                int addr = screensRec.beginAddr + i * screensRec.recSize * (dataStride * wordLen);
                if (wordLen == 1)
                {
                    for (int x = 0; x < screensRec.recSize; x++)
                    {
                        arrayToSave[addr + x * dataStride] = (byte)ConfigScript.backConvertScreenTile(screensData[i][x]);
                    }
                }
                else if (wordLen == 2)
                {
                    if (littleEndian)
                    {
                        for (int x = 0; x < screensRec.recSize; x++)
                        {
                            Utils.writeWordLE(arrayToSave, addr + x * (dataStride * wordLen), ConfigScript.backConvertScreenTile(screensData[i][x]));
                        }
                    }
                    else
                    {
                        for (int x = 0; x < screensRec.recSize; x++)
                        {
                            Utils.writeWord(arrayToSave, addr + x * (dataStride * wordLen), ConfigScript.backConvertScreenTile(screensData[i][x]));
                        }
                    }
                }
            }
        }