Example #1
0
        //public static bool flushToFile()
        //{
        //    if (OpenFile.DumpName != "")
        //    {
        //        try
        //        {
        //            using (FileStream f = File.OpenWrite(OpenFile.DumpName))
        //            {
        //                f.Write(Globals.dumpdata, 0, Globals.dumpdata.Length);
        //                f.Seek(0, SeekOrigin.Begin);
        //            }
        //        }

        //        catch (Exception ex)
        //        {
        //            MessageBox.Show(ex.Message);
        //            return false;
        //        }
        //    }
        //    try
        //    {
        //        using (FileStream f = File.OpenWrite(OpenFile.FileName))
        //        {
        //            f.Write(Globals.romdata, 0, Globals.romdata.Length);
        //            f.Seek(0, SeekOrigin.Begin);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(ex.Message);
        //        return false;
        //    }
        //    return true;
        //}

        public static int readBlockIndexFromMap(byte[] arrayWithData, int romAddr, int index)
        {
            int  wordLen      = ConfigScript.getWordLen();
            bool littleEndian = ConfigScript.isLittleEndian();
            int  dataStride   = ConfigScript.getScreenDataStride();

            if (wordLen == 1)
            {
                return(ConfigScript.convertScreenTile(arrayWithData[romAddr + index * dataStride]));
            }
            else if (wordLen == 2)
            {
                if (littleEndian)
                {
                    return(ConfigScript.convertScreenTile(Utils.readWordLE(arrayWithData, romAddr + index * (dataStride * wordLen))));
                }
                else
                {
                    return(ConfigScript.convertScreenTile(Utils.readWord(arrayWithData, romAddr + index * (dataStride * wordLen))));
                }
            }
            return(-1);
        }