Beispiel #1
0
 public void CloseCowSystem()
 {
     _cowFile.Dispose();
     _cowFile        = null;
     _cowHeader      = null;
     _currentCowFile = 0;
 }
Beispiel #2
0
        public uint FnCheckForTextLine(uint textId)
        {
            byte retVal = 0;

            if (_textList[textId / ITM_PER_SEC, 0] == 0)
            {
                return(0); // section does not exist
            }
            byte lang     = (byte)SystemVars.Language;
            var  textData = new UIntAccess(_resMan.OpenFetchRes(_textList[textId / ITM_PER_SEC, lang]), Header.Size);

            if ((textId & ITM_ID) < _resMan.ReadUInt32(textData[0]))
            {
                textData.Offset += 4;
                if (textData[(int)(textId & ITM_ID)] != 0)
                {
                    retVal = 1;
                }
            }
            _resMan.ResClose(_textList[textId / ITM_PER_SEC, lang]);
            return(retVal);
        }
Beispiel #3
0
        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");
            }
        }