Advertisement
Guest User

NX20

a guest
Oct 22nd, 2014
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.57 KB | None | 0 0
  1. using Microsoft.Xna.Framework;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7. namespace OMG
  8. {
  9.     public static class StepData
  10.     {
  11.         //LOS DATOS
  12.         public static string dType;
  13.         public static int dTracks;
  14.         public static int dMetaData;
  15.         public static List<int> dData;
  16.         //EL SPLIT
  17.         public static List<int> sBlocks;
  18.         public static List<float> sStepTime;
  19.         public static List<float> sBpm;
  20.         public static List<float> sMystery; //ni idea porque está en float
  21.         public static List<float> sDelay;
  22.         public static List<bool> sFreeze;
  23.         public static List<float> sSpeed;
  24.         public static List<float> sBeatSplit;
  25.         public static List<int> sMeasure;
  26.         public static List<int> sSmooth;
  27.         public static List<float> sRows;
  28.         //LAS NOTAS
  29.         public static List<float[]> sNotes;      
  30.  
  31.         public static void _CLEAN()
  32.         {
  33.             dType = "";
  34.             dTracks = 5;
  35.             dMetaData = 2;
  36.             dData = new List<int>();
  37.             sBlocks = new List<int>();            
  38.             sStepTime = new List<float>();
  39.             sBpm = new List<float>();
  40.             sMystery = new List<float>();
  41.             sDelay = new List<float>();
  42.             sFreeze = new List<bool>();
  43.             sSpeed = new List<float>();
  44.             sBeatSplit = new List<float>();
  45.             sMeasure = new List<int>();
  46.             sSmooth = new List<int>();
  47.             sRows = new List<float>();
  48.             sNotes = new List<float[]>();
  49.         }
  50.         public static void _PARSE()
  51.         {
  52.             int total = 0;//en que espacio voy
  53.             dTracks = Convert.ToInt32(Reader.FILEDATA[2].Substring(0, 2), 16);
  54.             dMetaData = Convert.ToInt32(Reader.FILEDATA[4].Substring(0, 2), 16);
  55.  
  56.             total = 6; //independiente del step, siempre el metadata empieza en 6
  57.             for (int i = 0; i < dMetaData; i++)            
  58.                 dData.Add(Convert.ToInt32(Reader.FILEDATA[total + i * 2].Substring(0, 2), 16));
  59.             total += (dMetaData * 2);   //cada metadata va acompañado de 1 bloque
  60.             total += 2; //espaciado entre splits
  61.  
  62.  
  63.             _MAKEDEC();   //PENDIENTE
  64.             bool DATA = true;
  65.             float temp = 0;
  66.             float space = 60f;
  67.             for (int i = total; i < Reader.FILEDATA.Count; i++)
  68.             {
  69.                 if (DATA)
  70.                 {
  71.                     sBlocks.Add(Convert.ToInt32(Reader.FILEDATA[i].Substring(0, 2), 16));
  72.                     sStepTime.Add(_GETFLOAT(Reader.FILEDATA[i + 1]));
  73.                     sBpm.Add(_GETFLOAT(Reader.FILEDATA[i + 2]));
  74.                     sMystery.Add(_GETFLOAT(Reader.FILEDATA[i + 3]));
  75.                     if (sMystery[sMystery.Count - 1].ToString() == "NaN")
  76.                         sMystery[sMystery.Count - 1] = 0;
  77.                     sDelay.Add(_GETFLOAT(Reader.FILEDATA[i + 4]));
  78.                     if (sDelay[sDelay.Count - 1].ToString() == "NaN" || sDelay[sDelay.Count - 1].ToString() == "NeuN")
  79.                         sDelay[sDelay.Count - 1] = 0;
  80.                     sFreeze.Add(_GETFLOAT(Reader.FILEDATA[i + 5]) < 0 ? true : false);
  81.                     sSpeed.Add(_GETFLOAT(Reader.FILEDATA[i + 5]));
  82.                     sBeatSplit.Add(Convert.ToInt32(Reader.FILEDATA[i + 6].Substring(0, 2), 16));
  83.                     sMeasure.Add(Convert.ToInt32(Reader.FILEDATA[i + 6].Substring(2, 2), 16));
  84.                     sSmooth.Add(Convert.ToInt32(Reader.FILEDATA[i + 6].Substring(4, 2), 16));
  85.                     sRows.Add(_ROWS(Reader.FILEDATA[i + 8]));
  86.                     i += 8;
  87.                     DATA = false;
  88.                 }
  89.                 else
  90.                 {
  91.                     for (int r = 0; r < sRows[sRows.Count-1]; r++)
  92.                     {
  93.                         temp = ((space / (sBpm[sBpm.Count - 1] / space) / sBeatSplit[sBeatSplit.Count - 1]) * (float)r) + (sStepTime[sStepTime.Count - 1] / 16.66666667f);
  94.                         if (Reader.FILEDATA[i + r].Substring(0, 2) != "80")
  95.                         {
  96.                             for (int t = 0; t < dTracks; t++)
  97.                             {
  98.                                 if (Convert.ToInt32(Reader.FILEDATA[i + r + t].Substring(0, 2), 16) == 0)
  99.                                     continue;   //empty
  100.                                 //COMO ES LA WEÁ
  101.                                 //TAPNOTE, MÁSCARA, PLAYER, UNKNOW, SPLIT, TRACK, Y, asd
  102.                                 sNotes.Add(new float[] {   Convert.ToInt32(Reader.FILEDATA[i + r + t].Substring(0, 2), 16)
  103.                                                     , Convert.ToInt32(Reader.FILEDATA[i + r + t].Substring(2, 2), 16)
  104.                                                     , Convert.ToInt32(Reader.FILEDATA[i + r + t].Substring(4, 2), 16)
  105.                                                     , Convert.ToInt32(Reader.FILEDATA[i + r + t].Substring(6, 2), 16)
  106.                                                     , sBlocks.Count - 1
  107.                                                     , t
  108.                                                     , temp
  109.                                                     , 0
  110.                                 });
  111.                             }
  112.                             i += dTracks - 1;
  113.                         }
  114.                     }
  115.                     i += (int)sRows[sRows.Count - 1] + 1;    //1 de espaciado
  116.                     DATA = true;
  117.  
  118.                 }              
  119.             }
  120.  
  121.             for (int i = 0; i < sNotes.Count; i++)
  122.             {
  123.                 switch (sNotes[i][0].ToString())
  124.                 {
  125.                     case "35":  //fake tap
  126.                     case "55":  //fake head
  127.                     case "59":  //fake body
  128.                     case "63":  //fake tail
  129.                         sNotes.RemoveAt(i);
  130.                         i--;
  131.                         break;
  132.                 }
  133.                
  134.                 //if (sNotes[i][1] != 3)
  135.                 //{
  136.                 //    sNotes.RemoveAt(i);
  137.                 //    i--;
  138.                 //}
  139.             }
  140.  
  141.         }
  142.  
  143.         static int _ROWS(string hex)
  144.         {
  145.             int num1,num2, rows=0;
  146.             num1 = Convert.ToInt32(hex.Substring(0, 2), 16);
  147.             num2 = Convert.ToInt32(hex.Substring(2, 2), 16);
  148.             rows = num1 + num2 * 256;
  149.             return rows;
  150.         }
  151.        
  152.  
  153.  
  154.         static int[] decim = new int[20];
  155.         static float[] bases = new float[20];
  156.         static float[] mult0 = new float[20];
  157.         static float[] mult1 = new float[20];
  158.         static float[] mult2 =
  159.             new float[20];
  160.  
  161.         static void _MAKEDEC()
  162.         {
  163.             decim[0] = 58;
  164.             bases[0] = 0.00048828125f;
  165.             mult0[0] = 16777216;
  166.             mult1[0] = 65536;
  167.             mult2[0] = 262144f;
  168.  
  169.             for (int i = 1; i < decim.Length; i++)
  170.             {
  171.                 decim[i] = decim[i - 1] + 1;
  172.                 bases[i] = bases[i - 1] * 4;
  173.                 mult0[i] = mult0[i - 1] / 4;
  174.                 mult1[i] = mult1[i - 1] / 4;
  175.                 mult2[i] = mult2[i - 1] / 4;
  176.             }
  177.         }
  178.  
  179.  
  180.         static float _GETFLOAT(String hex)
  181.         {
  182.             float convert = 0;
  183.             float based = 0;
  184.             float[] mult = new float[3];
  185.             List<int> dec = new List<int>();
  186.             for (int i = 0; i < hex.Length; i += 2)
  187.                 dec.Add(Convert.ToInt32(hex.Substring(i, 2), 16));            
  188.  
  189.             int fix = 1;
  190.             for (int i = 0; i < decim.Length; i++)            
  191.                 if ((dec[3] == decim[i]) || (dec[3] == (decim[i] + 128)))
  192.                 {
  193.                     based = bases[i];
  194.                     mult[0] = mult0[i];
  195.                     mult[1] = mult1[i];
  196.                     mult[2] = mult2[i];
  197.                 }
  198.            
  199.  
  200.             int divisor0 = 1024;
  201.             int divisor1 = 1024;
  202.             int divisor2 = 1;
  203.  
  204.             if (dec[2] >= 128)
  205.             {
  206.                 based = 0;
  207.                 divisor0 = 512;
  208.                 divisor1 = 512;
  209.                 divisor2 = 2;
  210.             }
  211.  
  212.             if (dec[3] >= 186)
  213.                 fix = -1;
  214.  
  215.             convert =
  216.             based +
  217.             (dec[0] / (mult[0] * divisor0)) +
  218.             (dec[1] / (mult[1] * divisor1)) +
  219.             (dec[2] / (mult[2] / divisor2));
  220.             convert = (float)(Math.Round((convert * fix), 3));
  221.             return convert;
  222.         }
  223.     }
  224. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement