private void WriteHighScore(int levelOffset, int mission, MissionHighScore highScore) { int startOffset = levelOffset; // Grades and Plays is 16 bytes startOffset += 0x10; // 36 bytes per mission startOffset += mission * 0x24; // 12 bytes per score startOffset += highScore.Number * 0x0C; DebugWriteOffset("Writing rings " + highScore.Rings, levelOffset); // Write ring and score values // GC stores as big endian // PC stores as little endian if (ToSaveType == SaveType.GAMECUBE) { WriteUInt16BE(highScore.Rings, startOffset + 0x00); WriteUInt32BE(highScore.Score, startOffset + 0x04); } else { WriteUInt16LE(highScore.Rings, startOffset + 0x00); WriteUInt32LE(highScore.Score, startOffset + 0x04); } // Write time WriteTime(highScore.Time, startOffset + 0x08); }
private MissionHighScore ReadHighScore(int levelOffset, int mission, int highScore) { MissionHighScore score = new MissionHighScore(highScore); int startOffset = levelOffset; // Grades and Plays is 16 bytes startOffset += 0x10; // 36 bytes per mission startOffset += mission * 0x24; // 12 bytes per score startOffset += highScore * 0x0C; // Read ring and score values // GC stores as big endian // PC stores as little endian if (FromSaveType == SaveType.GAMECUBE) { score.Rings = ReadUInt16BE(startOffset); score.Score = ReadUInt32BE(startOffset + 0x04); } else { score.Rings = ReadUInt16LE(startOffset); score.Score = ReadUInt32LE(startOffset + 0x04); } if (score.Rings != 0 || score.Score != 0) { DebugWriteOffset("Reading highscore #" + highScore + " - rings " + score.Rings, startOffset); DebugWriteOffset("Reading highscore #" + highScore + " - score " + score.Score, startOffset + 0x04); } // Read mission time int minutes = saveFileBytes[startOffset + 0x08]; int seconds = saveFileBytes[startOffset + 0x09]; int milliseconds = saveFileBytes[startOffset + 0x0A] * 10; TimeSpan highScoreTime = new TimeSpan(0, 0, minutes, seconds, milliseconds); score.Time = highScoreTime; return(score); }