Beispiel #1
0
VBA::~VBA()
{
  char winBuffer[2048];

  GetModuleFileName(NULL, winBuffer, 2048);
  char *p = strrchr(winBuffer, '\\');
  if(p)
    *p = 0;

  regInit(winBuffer);

  saveSettings();

  soundPause();
  soundShutdown();

  if(rom != NULL) {
    ((MainWnd *)m_pMainWnd)->writeBatteryFile();
    emulator.emuCleanUp();
  }

  if(input)
    delete input;

  shutdownDisplay();

  CoUninitialize();
}
Beispiel #2
0
void* regLoop(void* userData) {
  int l = 0;
  int status;
  int numParamsChanged;
  int numRecvdCmds;
  int recvdCmds[REG_MAX_NUM_STR_CMDS];
  char** changedParamLabels;
  char** recvdCmdParams;
  bool done;
  bool needRefresh = false;

  // params to be registered...
  int mVis;
  int bVis;
  double isoValue[PVS_MAX_ISOS];
  int isoVis[PVS_MAX_ISOS];
  int orthoslice;
  int cutplane;

  // thread data...
  threadData* td = (threadData*) ((ThreadInfoStruct*) userData)->UserData;

  // allocate memory...
  changedParamLabels = Alloc_string_array(REG_MAX_STRING_LENGTH,
					  REG_MAX_NUM_STR_PARAMS);
  recvdCmdParams = Alloc_string_array(REG_MAX_STRING_LENGTH,
				      REG_MAX_NUM_STR_CMDS);

  // initialise steering library...
  regInit();

  // register params...
  if(td->xyzPipeline) {
    ((PlatoXYZPipeline*) td->xyzPipeline)->isMoleculeVisible() ? mVis = 1 : mVis = 0;
    status = Register_param("Molecule visible?", REG_TRUE, (void*) &mVis,
			    REG_INT, "0", "1");
    ((PlatoXYZPipeline*) td->xyzPipeline)->isBondsVisible() ? bVis = 1 : bVis = 0;
    status = Register_param("Bonds visible?", REG_TRUE, (void*) &bVis,
			    REG_INT, "0", "1");
  }

  double* isoRange = ((PlatoDataReader*) td->dataReader)->getDataRange();
  char isoMin[10];
  char isoMax[10];
  char isoLabel[20];
  snprintf(isoMin, 10, "%f", isoRange[0]);
  snprintf(isoMax, 10, "%f", isoRange[1]);
  for(int i = 0; i < PVS_MAX_ISOS; i++) {
    snprintf(isoLabel, 20, "Iso %d visible?", i);
    ((PlatoIsoPipeline*) td->isoPipeline)->isIsoVisible(i) ? isoVis[i] = 1 : isoVis[i] = 0;
    status = Register_param(isoLabel, REG_TRUE, (void*) &isoVis[i],
			    REG_INT, "0", "1");
    snprintf(isoLabel, 20, "Iso %d value", i);
    isoValue[i] = ((PlatoIsoPipeline*) td->isoPipeline)->getIsoValue(i);
    status = Register_param(isoLabel, REG_TRUE, (void*) &isoValue[i],
			    REG_DBL, isoMin, isoMax);
  }

  ((PlatoOrthoPipeline*) td->orthoPipeline)->isOrthosliceOn() ? orthoslice = 1
    : orthoslice = 0;
  status = Register_param("Orthoslice?", REG_TRUE, (void*) &orthoslice,
			  REG_INT, "0", "1");

  ((PlatoIsoPipeline*) td->isoPipeline)->isIsoCutterOn() ? cutplane = 1 :
    cutplane = 0;
  status = Register_param("Cut-plane?", REG_TRUE, (void*) &cutplane,
			  REG_INT, "0", "1");

  loopLock->Lock();
  done = regLoopDone;
  loopLock->Unlock();

  // go into loop until told to finish...
  while(!done) {
    // sleep for 0.2 seconds...
    usleep(200000);

    status = Steering_control(l, &numParamsChanged, changedParamLabels,
			      &numRecvdCmds, recvdCmds, recvdCmdParams);

    if(status != REG_SUCCESS) {
      std::cerr << "Call to Steering_control failed...\n";
      continue;
    }

    // deal with commands from steering library...
    for(int i = 0; i < numRecvdCmds; i++) {
      switch(recvdCmds[i]) {
      case REG_STR_STOP:
	//td->window->getInteractor()->InvokeEvent(vtkCommand::ExitEvent);
	td->window->exit();
	break;
      }
    }

    // deal with changed parameters...
    for(int i = 0; i < numParamsChanged; i++) {
      if(strstr(changedParamLabels[i], "Molecule") || 
	 strstr(changedParamLabels[i], "Bonds")) {
	moleculeVisibility((PlatoXYZPipeline*) td->xyzPipeline, mVis, bVis);
	needRefresh = true;
	continue;
      }

      if(!strncmp(changedParamLabels[i], "Iso", 3)) {
	isoChanged((PlatoIsoPipeline*) td->isoPipeline,
		   changedParamLabels[i], isoValue, isoVis);
	needRefresh = true;
	continue;
      }

      if(!strcmp(changedParamLabels[i], "Orthoslice?")) {
	toggleOrthoslice((PlatoOrthoPipeline*) td->orthoPipeline, orthoslice);
	needRefresh = true;
	continue;
      }

      if(!strcmp(changedParamLabels[i], "Cut-plane?")) {
	toggleCutplane((PlatoIsoPipeline*) td->isoPipeline, cutplane);
	needRefresh = true;
	continue;
      }
    }

    // tell the interactor to render if needs be...
    if(needRefresh) {
      renderLock->Lock();
      reRender = true;
      renderLock->Unlock();
      needRefresh = false;
    }

    // see if we're done yet...
    loopLock->Lock();
    done = regLoopDone;
    loopLock->Unlock();

    // update loop count for steering library...
    l++;
  }

  // clean up steering library...
  regFinalise();

  // tell main thread that this one is done...
  sem_post(&regDone);
}
Beispiel #3
0
int main(int argc, char *argv[])
{
    char buffer[256];
    char *p;
    BOOLEAN multipleFiles = FALSE;
    int rv;
    char realOutFile[260];
    char oldOutFile[260];
    srand(time(0));

        /*   signal(SIGSEGV,internalError) ;*/
        /*   signal(SIGFPE, internalError) ;*/

    /* initialize back end */
    if (!init_backend(&argc,argv))
        fatal("Could not initialize back end");

    if (chosenAssembler->Args)
    {
        CMDLIST *newArgs = calloc(sizeof(Args) + sizeof(Args[0]) * chosenAssembler->ArgCount, 1);
        if (newArgs)
        {
            memcpy(&newArgs[0], chosenAssembler->Args, 
                   chosenAssembler->ArgCount *sizeof(Args[0]));
            memcpy(&newArgs[chosenAssembler->ArgCount], &Args[0], sizeof(Args));
            ArgList = newArgs;
        }
    }		
    /* parse environment variables, command lines, and config files  */
    ccinit(argc, argv);
    
    /* loop through and preprocess all the files on the file list */
    if (clist && clist->next)
        multipleFiles = TRUE;
#ifdef PARSER_ONLY
    strcpy(buffer, clist->data);
    strcpy(realOutFile, outfile);
    outputfile(realOutFile, buffer, ".ods");
    if (!ccDBOpen(realOutFile))
        fatal("Cannot open database file %s", realOutFile);
#else
    BitInit();
    regInit();
#endif
    while (clist)
    {
        cparams.prm_cplusplus = FALSE;
        strcpy(buffer, clist->data);
#ifndef PARSER_ONLY
        strcpy(realOutFile, outfile);
        if (cparams.prm_asmfile)
            outputfile(realOutFile, buffer, chosenAssembler->asmext);
        else
            outputfile(realOutFile, buffer, chosenAssembler->objext);
        strcpy(oldOutFile, realOutFile);
        StripExt(oldOutFile);
        AddExt(oldOutFile, ".tmp");
#else
        ccNewFile(buffer, TRUE);
#endif
        AddExt(buffer, ".C");
        p = strrchr(buffer, '.');
        if (*(p - 1) != '.')
        {
            if (p[1] == 'h' || p[1] == 'H') // compile H files as C++ for the IDE
                cparams.prm_cplusplus = TRUE;
            if (p[1] == 'c' || p[1] == 'C')
            if (p[2] == 'p' || p[2] == 'P')
            {
                if (p[3] == 'p' || p[3] == 'P')
                    cparams.prm_cplusplus = TRUE;
            }
            else
            {
                if (p[2] == 'x' || p[2] == 'X')
                {
                    if (p[3] == 'x' || p[3] == 'X')
                        cparams.prm_cplusplus = TRUE;
                }
            }
            else if ((p[2] == 'c' ||p[2] == 'C' ) && !p[3])
            {
                        cparams.prm_cplusplus = TRUE;
            }
            else
            {
                if (p[2] == '+')
                {
                    if (p[3] == '+')
                        cparams.prm_cplusplus = TRUE;
                }
            }
        }
        inputFile = SrchPth2(buffer, "", "r");
        if (!inputFile)
            fatal("Cannot open input file %s", buffer);
        strcpy(infile, buffer);
        if (cparams.prm_makestubs)
        {
            MakeStubs();
        }
        else
        {
#ifndef PARSER_ONLY
            unlink(oldOutFile);
            rename(realOutFile, oldOutFile);
            outputFile = fopen(realOutFile, cparams.prm_asmfile ? "w" : "wb");
            if (!outputFile)
            {
                fclose(inputFile);
                fatal("Cannot open output file %s", realOutFile);
            }
            setvbuf(outputFile,0,_IOFBF,32768);
#endif
             if (cparams.prm_cppfile)
            {
                StripExt(buffer);
                AddExt(buffer, ".i");
                strcpy(cppfile, buffer);
                cppFile = fopen(buffer, "w");
                if (!cppFile)
                {
                    fclose(inputFile);
                    fclose(outputFile);
                    fatal("Cannot open preprocessor output file %s", buffer);
                }
            }
            if (cparams.prm_listfile)
            {
                StripExt(buffer);
                AddExt(buffer, ".lst");
                listFile = fopen(buffer, "w");
                if (!listFile)
                {
                    fclose(inputFile);
                    fclose(cppFile);
                    fclose(outputFile);
                    fatal("Cannot open list file %s", buffer);
                }
            }
            if (cparams.prm_errfile)
            {
                StripExt(buffer);
                AddExt(buffer, ".err");
                errFile = fopen(buffer, "w");
                if (!errFile)
                {
                    fclose(inputFile);
                    fclose(cppFile);
                    fclose(listFile);
                    fclose(outputFile);
                    fatal("Cannot open error file %s", buffer);
                }
            }
            if (cparams.prm_browse)
            {
                char name[260];
                strcpy(name, outfile);
                StripExt(name);
                AddExt(name, ".cbr");
                browseFile = fopen(name, "wb");
                if (!browseFile)
                {   
                    fclose(errFile);
                    fclose(inputFile);
                    fclose(cppFile);
                    fclose(listFile);
                    fclose(outputFile);
                    fatal("Cannot open browse file %s", buffer);
                }
                setvbuf(browseFile,0,_IOFBF,32768);
            }
            if (cparams.prm_icdfile)
            {
                StripExt(buffer);
                AddExt(buffer, ".icd");
                icdFile = fopen(buffer, "w");
                if (!icdFile)
                {   
                    fclose(browseFile);
                    fclose(errFile);
                    fclose(inputFile);
                    fclose(cppFile);
                    fclose(listFile);
                    fclose(outputFile);
                    fatal("Cannot open error file %s", buffer);
                }
                setvbuf(icdFile,0,_IOFBF,32768);
            }
    
            if (multipleFiles && !cparams.prm_quiet)
                printf("%s\n", clist->data);
    
    
            compile();
        }
#ifdef PARSER_ONLY
        localFree();
#endif
        globalFree();
        if (cparams.prm_diag)
        {
            mem_summary();
            printf("Intermediate stats:\n");
               printf("  Block peak:          %d\n", maxBlocks);
               printf("  Temp peak:           %d\n", maxTemps);
               printf("  Allocation Spills:   %d\n", maxAllocationSpills);		
               printf("  Allocation Passes:   %d\n", maxAllocationPasses);		
               printf("  Allocation Accesses: %d\n", maxAllocationAccesses);
        }
        maxBlocks = maxTemps = maxAllocationSpills = maxAllocationPasses = maxAllocationAccesses = 0;
#ifdef PARSER_ONLY
        ccCloseFile(inputFile);
#else
        fclose(inputFile);
#endif
        if (outputFile)
            fclose(outputFile);
        if (cppFile)
            fclose(cppFile);
        if (listFile)
            fclose(listFile);
        if (errFile)
            fclose(errFile);
        if (browseFile)
            fclose(browseFile);
        if (icdFile)
            fclose(icdFile);
        
        if (total_errors)
        {
            unlink(realOutFile);
            rename(oldOutFile, realOutFile);
        }
        else
        {
            unlink (oldOutFile);
        }

        /* Flag to stop if there are any errors */
        stoponerr |= total_errors;

        clist = clist->next;
    }
    rv = !!stoponerr ;
    if (!cparams.prm_makestubs)
    {
        if (!cparams.prm_compileonly && !stoponerr) {
            rv = 0 ;
            if (chosenAssembler->compiler_postprocess)
            {
                char buf[260];
#ifdef MICROSOFT
                GetModuleFileNameA(NULL, buffer, sizeof(buffer));    
#else
                strcpy(buffer, argv[0]);
#endif
                rv = chosenAssembler->compiler_postprocess(buffer);
            }
        }
        if (chosenAssembler->rundown)
            chosenAssembler->rundown();
    }
    return rv;
}
Beispiel #4
0
BOOL VBA::InitInstance()
{
  SetRegistryKey(_T("VBA"));

  wndClass = AfxRegisterWndClass(0, LoadCursor(IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), LoadIcon(IDI_MAINICON));

  char winBuffer[2048];

  GetModuleFileName(NULL, winBuffer, 2048);
  char *p = strrchr(winBuffer, '\\');
  if(p)
    *p = 0;

  bool force = false;

  if (m_lpCmdLine[0])
  {
    if(__argc > 0) {
      if( 0 == strcmp( __argv[1], "--configpath" ) ) {
        if( __argc > 2 ) {
          strcpy( winBuffer, __argv[2] );
          force = true;
          if( __argc > 3 ) {
            filename = __argv[3];
          }
        }
      } else {
        filename = __argv[1];
      }
    }
  }

  regInit(winBuffer, force);

  loadSettings();

    if(!initDisplay()) {
    if(videoOption >= VIDEO_320x240) {
      regSetDwordValue("video", VIDEO_2X);
    }
    return FALSE;
  }

  
  if(!initInput())
    return FALSE;

  hAccel = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR));

  winAccelMgr.Connect((MainWnd *)m_pMainWnd);

  winAccelMgr.SetRegKey(HKEY_CURRENT_USER, "Software\\Emulators\\VisualBoyAdvance");

  extern void winAccelAddCommands(CAcceleratorManager&);

  winAccelAddCommands(winAccelMgr);

  winAccelMgr.CreateDefaultTable();

  winAccelMgr.Load();

  winAccelMgr.UpdateWndTable();

  winAccelMgr.UpdateMenu(menu);

  if( !filename.IsEmpty() ) {
    if(((MainWnd*)m_pMainWnd)->FileRun())
      emulating = true;
    else
      emulating = false;
  }

  return TRUE;
}