Ejemplo n.º 1
0
void EMISound::restoreState(SaveGame *savedState) {
	// Clear any current music
	flushStack();
	setMusicState(0);
	freeAllChannels();
	// Actually load:
	savedState->beginSection('SOUN');
	_musicPrefix = savedState->readString();
	// Stack:
	uint32 stackSize = savedState->readLEUint32();
	for (uint32 i = 0; i < stackSize; i++) {
		SoundTrack *track = nullptr;
		Common::String soundName = savedState->readString();
		if (!soundName.empty()) {
			track = createEmptyMusicTrack();
			if (initTrack(soundName, track)) {
				track->play();
				track->pause();
			} else {
				error("Couldn't reopen %s", soundName.c_str());
			}
		}
		_stateStack.push(track);
	}
	// Currently playing music:
	uint32 hasActiveTrack = savedState->readLEUint32();
	if (hasActiveTrack) {
		_music = createEmptyMusicTrack();
		Common::String soundName = savedState->readString();
		if (initTrack(soundName, _music)) {
			_music->play();
		} else {
			error("Couldn't reopen %s", soundName.c_str());
		}
	}
	// Channels:
	uint32 numChannels = savedState->readLEUint32();
	if (numChannels > NUM_CHANNELS) {
		error("Save game made with more channels than we have now: %d > %d", numChannels, NUM_CHANNELS);
	}
	for (uint32 i = 0; i < numChannels; i++) {
		uint32 channelIsActive = savedState->readLEUint32();
		if (channelIsActive) {
			Common::String soundName = savedState->readString();
			uint32 volume = savedState->readLEUint32();
			uint32 pan = savedState->readLEUint32();
			/*uint32 pos = */savedState->readLEUint32();
			/*bool isPlaying = */savedState->readByte();
			startVoice(soundName.c_str(), volume, pan);
		}
	}
	savedState->endSection();
}
Ejemplo n.º 2
0
static void doRunUntilShift( traceback **h, a_sym *sym, traceback **ht, unsigned count )
{
    index_t             sidx;
    a_sym               *chk_sym;
    a_state             *state;
    a_state             *top;
    a_reduce_action     *raction;

    for( ;; ) {
        if( *h == NULL ) break;
        top = (*h)->state;
        if( top == NULL ) {
            flushStack( h );
            break;
        }
        state = findNewShiftState( top, sym );
        if( state != NULL ) {
            pushTrace( h, state, sym );
            pushTrace( ht, NULL, sym );
            if( sym == eofsym ) {
                break;
            }
            for( ;; ) {
                if( *h == NULL ) break;
                top = (*h)->state;
                if( top->redun->pro == NULL ) break;
                performReduce( h, top->redun->pro );
            }
            break;
        }
        sidx = sym->idx;
        for( raction = top->redun; raction->pro != NULL; ++raction ) {
            if( IsBitSet( raction->follow, sidx ) ) {
                performReduce( h, raction->pro );
                break;
            }
        }
        if( raction->pro == NULL ) {
            if( sym != eofsym ) {
                /* a syntax error will result */
                flushStack( h );
                break;
            }
            if( top->redun->pro != NULL ) {
                performReduce( h, top->redun->pro );
            } else {
                if( count ) {
                    --count;
                    chk_sym = findNewShiftSym( top, ht );
                } else {
                    chk_sym = NULL;
                }
                if( chk_sym != NULL ) {
                    doRunUntilShift( h, chk_sym, ht, count );
                } else {
                    /* a syntax error will result */
                    flushStack( h );
                    break;
                }
            }
        }
    }
}