private void InitCowSystem() { if (SystemVars.CurrentCd == 0) return; if (_cowFile == null) { var cowName = $"SPEECH{SystemVars.CurrentCd}.CLF"; _cowFile = TryToOpen(cowName); //if (_cowFile.isOpen()) //{ // debug(1, "Using FLAC compressed Speech Cluster"); //} _cowMode = CowMode.CowFLAC; } if (_cowFile == null) { var cowName = $"SPEECH{SystemVars.CurrentCd}.CLU"; _cowFile = TryToOpen(cowName); //if (!_cowFile.isOpen()) //{ // _cowFile.open("speech.clu"); //} // TODO: debug(1, "Using uncompressed Speech Cluster"); _cowMode = CowMode.CowWave; } if (SystemVars.Platform == Platform.PSX) { // There's only one file on the PSX, so set it to the current disc. _currentCowFile = (byte)SystemVars.CurrentCd; if (_cowFile == null) { _cowFile = TryToOpen("speech.dat"); _cowMode = CowMode.CowPSX; } } if (_cowFile == null) _cowFile = TryToOpen("speech.clu"); if (_cowFile == null) { _cowFile = TryToOpen("cows.mad"); _cowMode = CowMode.CowDemo; } if (_cowFile != null) { if (SystemVars.Platform == Platform.PSX) { // Get data from the external table file using (var tableFile = TryToOpen("speech.tab")) { _cowHeaderSize = (uint)tableFile.BaseStream.Length; _cowHeader = new UIntAccess(new byte[_cowHeaderSize], 0); if ((_cowHeaderSize & 3) != 0) throw new InvalidOperationException($"Unexpected cow header size {_cowHeaderSize}"); for (var cnt = 0; cnt < _cowHeaderSize / 4; cnt++) _cowHeader[cnt] = tableFile.ReadUInt32(); } } else { _cowHeaderSize = _cowFile.ReadUInt32(); _cowHeader = new UIntAccess(new byte[_cowHeaderSize], 0); if ((_cowHeaderSize & 3) != 0) throw new InvalidOperationException("Unexpected cow header size {_cowHeaderSize}"); for (var cnt = 0; cnt < (_cowHeaderSize / 4) - 1; cnt++) _cowHeader[cnt] = _cowFile.ReadUInt32(); _currentCowFile = (byte)SystemVars.CurrentCd; } } else { // TODO: warning($"Sound::initCowSystem: Can't open SPEECH{SystemVars.CurrentCd}.CLU"); } }
private void InitCowSystem() { if (SystemVars.CurrentCd == 0) { return; } if (_cowFile == null) { var cowName = $"SPEECH{SystemVars.CurrentCd}.CLF"; _cowFile = TryToOpen(cowName); //if (_cowFile.isOpen()) //{ // debug(1, "Using FLAC compressed Speech Cluster"); //} _cowMode = CowMode.CowFLAC; } if (_cowFile == null) { var cowName = $"SPEECH{SystemVars.CurrentCd}.CLU"; _cowFile = TryToOpen(cowName); //if (!_cowFile.isOpen()) //{ // _cowFile.open("speech.clu"); //} // TODO: debug(1, "Using uncompressed Speech Cluster"); _cowMode = CowMode.CowWave; } if (SystemVars.Platform == Platform.PSX) { // There's only one file on the PSX, so set it to the current disc. _currentCowFile = (byte)SystemVars.CurrentCd; if (_cowFile == null) { _cowFile = TryToOpen("speech.dat"); _cowMode = CowMode.CowPSX; } } if (_cowFile == null) { _cowFile = TryToOpen("speech.clu"); } if (_cowFile == null) { _cowFile = TryToOpen("cows.mad"); _cowMode = CowMode.CowDemo; } if (_cowFile != null) { if (SystemVars.Platform == Platform.PSX) { // Get data from the external table file using (var tableFile = TryToOpen("speech.tab")) { _cowHeaderSize = (uint)tableFile.BaseStream.Length; _cowHeader = new UIntAccess(new byte[_cowHeaderSize], 0); if ((_cowHeaderSize & 3) != 0) { throw new InvalidOperationException($"Unexpected cow header size {_cowHeaderSize}"); } for (var cnt = 0; cnt < _cowHeaderSize / 4; cnt++) { _cowHeader[cnt] = tableFile.ReadUInt32(); } } } else { _cowHeaderSize = _cowFile.ReadUInt32(); _cowHeader = new UIntAccess(new byte[_cowHeaderSize], 0); if ((_cowHeaderSize & 3) != 0) { throw new InvalidOperationException("Unexpected cow header size {_cowHeaderSize}"); } for (var cnt = 0; cnt < (_cowHeaderSize / 4) - 1; cnt++) { _cowHeader[cnt] = _cowFile.ReadUInt32(); } _currentCowFile = (byte)SystemVars.CurrentCd; } } else { // TODO: warning($"Sound::initCowSystem: Can't open SPEECH{SystemVars.CurrentCd}.CLU"); } }