Beispiel #1
0
void CClctrl::exitError(const string error)
{
  cerr << error << endl << endl;
  waitForSpace();
  helpInfo();
  exit(1);
}
Beispiel #2
0
void CClctrl::exitNormal()
{
#ifdef _DEBUG
#ifdef _MSC_VER
  // For debugging under visual studio, to prevent window disappearing.
  waitForSpace();
#endif
#endif
  exit(0);
}
jint 
shmemBase_sendByte(SharedMemoryConnection *connection, jbyte data)
{
    Stream *stream = &connection->outgoing;
    SharedStream *shared = stream->shared;
    int offset;

    CHECK_ERROR(enterMutex(stream, connection->shutdown));
    CHECK_ERROR(waitForSpace(connection, stream));
    SHMEM_ASSERT(!FULL(stream));
    offset = shared->writeOffset;
    shared->buffer[offset] = data;
    shared->writeOffset = ADD_OFFSET(offset, 1);
    shared->isFull = (shared->readOffset == shared->writeOffset);

    STREAM_INVARIANT(stream);
    CHECK_ERROR(leaveMutex(stream));

    CHECK_ERROR(signalData(stream));

    return SYS_OK;
}
static jint
sendBytes(SharedMemoryConnection *connection, const void *bytes, jint length)
{
    Stream *stream = &connection->outgoing;
    SharedStream *shared = stream->shared;
    jint fragmentStart;
    jint fragmentLength;
    jint index = 0;
    jint maxLength;

    clearLastError();

    CHECK_ERROR(enterMutex(stream, connection->shutdown));
    while (index < length) {
        CHECK_ERROR(waitForSpace(connection, stream));
        SHMEM_ASSERT(!FULL(stream));

        fragmentStart = shared->writeOffset;

        if (fragmentStart < shared->readOffset) {
            maxLength = shared->readOffset - fragmentStart;
        } else {
            maxLength = SHARED_BUFFER_SIZE - fragmentStart;
        }
        fragmentLength = MIN(maxLength, length - index);
        memcpy(shared->buffer + fragmentStart, (jbyte *)bytes + index, fragmentLength);
        shared->writeOffset = ADD_OFFSET(fragmentStart, fragmentLength);
        index += fragmentLength;

        shared->isFull = (shared->readOffset == shared->writeOffset);

        STREAM_INVARIANT(stream);
        CHECK_ERROR(signalData(stream));

    }
    CHECK_ERROR(leaveMutex(stream));

    return SYS_OK;
}
Beispiel #5
0
int WasapiEngine::write(void *buffer, std::size_t frames, UINT32 numFramesPadding) {
	if (posFrames) {
		UINT64 pos = 0;
		UINT64 qpcpos = 0;
		if (started && numFramesPadding) {
			if (SUCCEEDED(pAudioClock->GetPosition(&pos, &qpcpos)) && pos_) {
				est.feed((static_cast<UINT32>(pos) - pos_) / posFrames,
				         qpcpos / 10);
			} else
				est.resetLastFeedTimeStamp();
		}

		pos_ = pos;
	}

	std::size_t const maxSpaceWait = bufferFrameCount / 8;

	while (frames) {
		int const fof = waitForSpace(numFramesPadding,
		                             std::min(frames, maxSpaceWait));
		if (fof <= 0)
			return fof;

		std::size_t const n = std::min(std::size_t(fof), frames);
		if (::write(pRenderClient, buffer, n, nchannels_) < 0) {
			std::cerr << "::write fail" << std::endl;
			return -1;
		}

		buffer = static_cast<char *>(buffer) + n * 4;
		frames -= n;
		numFramesPadding += n;
	}

	return 0;
}
Beispiel #6
0
void AGOSEngine_FeebleDemo::mainMenu() {
    for (int i = 1; i <= 6; i++)
        enableBox(i);

    for (int i = 11; i <= 19; i++)
        disableBox(i);

    playVideo("mmfadein.smk", true);

    startInteractiveVideo("mainmenu.smk");

    HitArea *ha = 0;
    do {
        _lastHitArea = NULL;
        _lastHitArea3 = NULL;

        while (_lastHitArea3 == 0) {
            if (shouldQuit())
                return;
            handleText();
            delay(1);
        }

        ha = _lastHitArea;
    } while (ha == NULL || !(ha->id >= 1 && ha->id <= 6));

    if (shouldQuit())
        return;

    stopInteractiveVideo();

    if (ha->id == 1) {
        // Feeble Files Data
        playVideo("ffade5.smk");
        playVideo("ftext0.smk");
        playVideo("ftext1.smk", true);
        waitForSpace();
        playVideo("ftext2.smk", true);
        waitForSpace();
        playVideo("ftext3.smk", true);
        waitForSpace();
        playVideo("ftext4.smk", true);
        waitForSpace();
        playVideo("ftext5.smk", true);
        waitForSpace();
    } else if (ha->id == 2) {
        // Opening Sequence
        playVideo("ffade1.smk");
        playVideo("musosp1.smk");
        playVideo("newcred.smk");
        playVideo("fasall.smk");
        playVideo("mus5p2.smk");
        playVideo("coach.smk");
        playVideo("outmin.smk");
    } else if (ha->id == 3) {
        // Technical Information
        playVideo("ffade3.smk");
        playVideo("idfx4a.smk");
        playVideo("idfx4b.smk");
        playVideo("idfx4c.smk");
        playVideo("idfx4d.smk");
        playVideo("idfx4e.smk");
        playVideo("idfx4f.smk");
        playVideo("idfx4g.smk");
    } else if (ha->id == 4) {
        // About AdventureSoft
        playVideo("ffade2.smk");
        playVideo("fscene3b.smk");
        playVideo("fscene3a.smk");
        playVideo("fscene3c.smk");
        playVideo("fscene3g.smk");
    } else if (ha->id == 5) {
        // Video Clips
        playVideo("ffade4.smk");
        filmMenu();
    } else if (ha->id == 6) {
        // Exit InfoDisk
        playVideo("ffade6.smk");
        exitMenu();
    }
}
Beispiel #7
0
void ExploreImages(uint8_t* data, size_t size, int numTabs){
    
    PrintTabs(numTabs);
    //printf("Exploring 0X%X\n",data);
    
    if (size == 0){
        printf("Size == 0 !\n");
        return;
    }
        
        
    //SHP files are PAKs containing direct images.
    PakArchive font;
    font.InitFromRAM("XXXX",data,size);
    if (font.IsReady()){
        font.List(stdout);
        PrintTabs(numTabs);
        printf("Pak Found\n");
        for(size_t i =0 ; i  < font.GetNumEntries() ; i++){
            PakEntry* e = font.GetEntry(i);
            PrintTabs(numTabs);
            printf("Pak entry %lu\n",i);
            ExploreImages(e->data,e->size,numTabs+1);
            
        }
        return;
    }
    
    
    //Myabe it is a direct image ?
    RLEShape shape;
    shape.Init(data, size);
    
    bool errorFound;
    VGA.Clear();
    errorFound = VGA.DrawShape(&shape);
    if (!errorFound){
        VGA.VSync();
        Screen.Refresh();
        waitForSpace();
        PrintTabs(numTabs);
        printf("Image Found \n");
        return;
    }
    
    
    //TODO there is palette at the end of the sequence of images. It should be retrieved.
    //Maybe it is a sequence of images ?
    uint8_t* end = data + size;
    ByteStream s(data);
    uint32_t nextImage = s.ReadUInt32LE();
    nextImage = nextImage & 0x00FFFFFF;
    
    if (data + nextImage >= end)
        return;
    
    uint32_t numImages = nextImage/4 ;
    for(size_t i = 0 ; i < numImages && (data+nextImage < end) ; i++){
        
        RLEShape shape;
        shape.Init(data+nextImage, size);
        
        bool errorFound;
        VGA.Clear();
        errorFound = VGA.DrawShape(&shape);
        if (!errorFound){
            VGA.VSync();
            Screen.Refresh();
            waitForSpace();
            PrintTabs(numTabs);
            printf("Image Found\n");
            
        }
        //else
          //  return;
        
        nextImage = s.ReadUInt32LE();
        nextImage = nextImage & 0x00FFFFFF;
    }
    
}