Beispiel #1
0
void GBOamView::save()
{
  CString captureBuffer;

  if(theApp.captureFormat == 0)
    captureBuffer = _T("oam.png");
  else
    captureBuffer = _T("oam.bmp");

  LPCTSTR exts[] = {_T(".png"), _T(".bmp") };

  CString filter = theApp.winLoadFilter(IDS_FILTER_PNG);
  CString title = winResLoadString(IDS_SELECT_CAPTURE_NAME);

  FileDlg dlg(this,
              captureBuffer,
              filter,
              theApp.captureFormat ? 2 : 1,
              theApp.captureFormat ? _T("BMP") : _T("PNG"),
              exts,
              _T(""),
              title,
              true);

  if(dlg.DoModal() == IDCANCEL) {
    return;
  }
  captureBuffer = dlg.GetPathName();

  if(dlg.getFilterIndex() == 2)
    saveBMP(captureBuffer);
  else
    savePNG(captureBuffer);
}
void GBTileView::OnSave() 
{
  CString captureBuffer;

  if(theApp.captureFormat == 0)
    captureBuffer = "tiles.png";
  else
    captureBuffer = "tiles.bmp";

  LPCTSTR exts[] = {".png", ".bmp" };

  CString filter = theApp.winLoadFilter(IDS_FILTER_PNG);
  CString title = winResLoadString(IDS_SELECT_CAPTURE_NAME);

  FileDlg dlg(this,
              captureBuffer,
              filter,
              theApp.captureFormat ? 2 : 1,
              theApp.captureFormat ? "BMP" : "PNG",
              exts,
              "",
              title,
              true);

  if(dlg.DoModal() == IDCANCEL) {
    return;
  }

  captureBuffer = dlg.GetPathName();

  if(theApp.captureFormat)
    saveBMP(captureBuffer);
  else
    savePNG(captureBuffer);  
}
Beispiel #3
0
void MainWnd::OnCheatsSavecheatlist()
{
  CString buffer;
  CString filename;

  int index = theApp.filename.ReverseFind('\\');

  if(index != -1)
    buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1);
  else
    buffer = theApp.filename;

  CString saveDir = regQueryStringValue(_T("saveDir"), NULL);

  if(saveDir.IsEmpty())
    saveDir = getDirFromFile(theApp.filename);

  if(isDriveRoot(saveDir))
    filename.Format(_T("%s%s.clt"), saveDir, buffer);
  else
    filename.Format(_T("%s\\%s.clt"), saveDir, buffer);

  LPCTSTR exts[] = { _T(".clt") };
  CString filter = winLoadFilter(IDS_FILTER_CHEAT_LIST);
  CString title = winResLoadString(IDS_SELECT_CHEAT_LIST_NAME);

  FileDlg dlg(this, filename, filter, 0, _T("CLT"), exts, saveDir, title, true);

  if(dlg.DoModal() == IDOK) {
    winSaveCheatList(dlg.GetPathName());
  }
}
void Directories::OnSaveDir() 
{
  m_savePath.GetWindowText(initialFolderDir);
  CString p = browseForDir(winResLoadString(IDS_SELECT_SAVE_DIR));
  if(!p.IsEmpty())
    m_savePath.SetWindowText(p);
}
void TileViewer::save()
{
    char captureBuffer[2048];

    if(captureFormat == 0)
        strcpy(captureBuffer, "tiles.png");
    else
        strcpy(captureBuffer, "tiles.bmp");

    char *exts[] = {".png", ".bmp" };

    FileDlg dlg(getHandle(),
                (char *)captureBuffer,
                (int)sizeof(captureBuffer),
                (char *)winLoadFilter(IDS_FILTER_PNG),
                captureFormat ? 2 : 1,
                captureFormat ? "BMP" : "PNG",
                exts,
                (char *)NULL,
                (char *)winResLoadString(IDS_SELECT_CAPTURE_NAME),
                TRUE);

    BOOL res = dlg.DoModal();
    if(res == FALSE) {
        DWORD res = CommDlgExtendedError();
        return;
    }

    if(captureFormat)
        saveBMP(captureBuffer);
    else
        savePNG(captureBuffer);
}
void Directories::OnGbromDir() 
{
  m_gbromPath.GetWindowText(initialFolderDir);
  CString p = browseForDir(winResLoadString(IDS_SELECT_ROM_DIR));
  if(!p.IsEmpty())
    m_gbromPath.SetWindowText(p);
}
bool MainWnd::fileOpenSelect()
{
  theApp.dir = "";
  CString initialDir = regQueryStringValue("romdir",".");
  if(!initialDir.IsEmpty())
    theApp.dir = initialDir;

  int selectedFilter = regQueryDwordValue("selectedFilter", 0);
  if(selectedFilter < 0 || selectedFilter > 2)
    selectedFilter = 0;

  theApp.szFile = "";

  LPCTSTR exts[] = { "" };
  CString filter = winLoadFilter(IDS_FILTER_ROM);
  CString title = winResLoadString(IDS_SELECT_ROM);

  FileDlg dlg(this, "", filter, selectedFilter, "", exts, theApp.dir, title, false);

  if(dlg.DoModal() == IDOK) {
    regSetDwordValue("selectedFilter", dlg.m_ofn.nFilterIndex);
    theApp.szFile = dlg.GetPathName();
    theApp.dir = theApp.szFile.Left(dlg.m_ofn.nFileOffset);
    if(theApp.dir.GetLength() > 3 && theApp.dir[theApp.dir.GetLength()-1] == '\\')
      theApp.dir = theApp.dir.Left(theApp.dir.GetLength()-1);
    regSetStringValue("romdir", theApp.dir);
    return true;
  }
  return false;
}
void Directories::OnBatteryDir() 
{
  m_batteryPath.GetWindowText(initialFolderDir);
  CString p = browseForDir(winResLoadString(IDS_SELECT_BATTERY_DIR));
  if(!p.IsEmpty())
    m_batteryPath.SetWindowText(p);
}
void MainWnd::OnOptionsSoundStartrecording()
{
  CString captureBuffer;

  CString capdir = regQueryStringValue("soundRecordDir", NULL);

  if(capdir.IsEmpty())
    capdir = getDirFromFile(theApp.filename);

  CString filter = theApp.winLoadFilter(IDS_FILTER_WAV);
  CString title = winResLoadString(IDS_SELECT_WAV_NAME);

  LPCTSTR exts[] = { ".WAV" };

  FileDlg dlg(this, "", filter, 1, "WAV", exts, capdir, title, true);

  if(dlg.DoModal() == IDCANCEL) {
    return;
  }

  captureBuffer = theApp.soundRecordName =  dlg.GetPathName();
  soundRecording = true;

  if(dlg.m_ofn.nFileOffset > 0) {
    captureBuffer = captureBuffer.Left(dlg.m_ofn.nFileOffset);
  }

  int len = captureBuffer.GetLength();

  if(len > 3 && captureBuffer[len-1] == '\\')
    captureBuffer = captureBuffer.Left(len-1);
  regSetStringValue("soundRecordDir", captureBuffer);
}
void MainWnd::readBatteryFile()
{
  CString buffer;
  CString filename;

  int index = theApp.filename.ReverseFind('\\');

  if(index != -1)
    buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1);
  else
    buffer = theApp.filename;

  CString saveDir = regQueryStringValue("batteryDir", NULL);

  if(saveDir.IsEmpty())
    saveDir = getDirFromFile(theApp.filename);

  if(isDriveRoot(saveDir))
    filename.Format("%s%s.sav", saveDir, buffer);
  else
    filename.Format("%s\\%s.sav", saveDir, buffer);

  bool res = false;

  if(theApp.emuReadBattery)
    res = theApp.emuReadBattery(filename);

  if(res)
    systemScreenMessage(winResLoadString(IDS_LOADED_BATTERY));
}
void GBMapView::OnSave()
{
  CString filename;

  if(theApp.captureFormat == 0)
    filename = "map.png";
  else
    filename = "map.bmp";

  LPCTSTR exts[] = {".png", ".bmp" };
  CString title = winResLoadString(IDS_SELECT_CAPTURE_NAME);
  CString filter = theApp.winLoadFilter(IDS_FILTER_PNG);

  FileDlg dlg(this,
              filename,
              filter,
              theApp.captureFormat ? 2 : 1,
              theApp.captureFormat ? "BMP" : "PNG",
              exts,
              "",
              title,
              true);

  if(dlg.DoModal() == IDCANCEL) {
    return;
  }

  if(dlg.getFilterIndex() == 2)
    saveBMP(dlg.GetPathName());
  else
    savePNG(dlg.GetPathName());
}
CString MainWnd::winLoadFilter(UINT id)
{
  CString res = winResLoadString(id);
  res.Replace('_','|');
  
  return res;
}
Beispiel #13
0
void Directories::OnCaptureDir() 
{
  m_capturePath.GetWindowText(initialFolderDir);
  CString p = browseForDir(winResLoadString(IDS_SELECT_CAPTURE_DIR));
  if(!p.IsEmpty())
    m_capturePath.SetWindowText(p);
}
Beispiel #14
0
void MainWnd::screenCapture(int captureNumber)
{
  CString buffer;

  CString captureDir = regQueryStringValue("captureDir", "");
  if( captureDir[0] == '.' ) {
	  // handle as relative path
	  char baseDir[MAX_PATH+1];
	  GetModuleFileName( NULL, baseDir, MAX_PATH );
	  baseDir[MAX_PATH] = '\0'; // for security reasons
	  PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
	  strcat( baseDir, "\\" );
	  strcat( baseDir, captureDir );
	  captureDir = baseDir;
	}

  int index = theApp.filename.ReverseFind('\\');

  CString name;
  if(index != -1)
    name = theApp.filename.Right(theApp.filename.GetLength()-index-1);
  else
    name = theApp.filename;

  if(captureDir.IsEmpty())
    captureDir = getDirFromFile(theApp.filename);

  LPCTSTR ext = "png";
  if(theApp.captureFormat != 0)
    ext = "bmp";

  if(isDriveRoot(captureDir))
    buffer.Format("%s%s_%02d.%s",
                  captureDir,
                  name,
                  captureNumber,
                  ext);
  else
    buffer.Format("%s\\%s_%02d.%s",
                  captureDir,
                  name,
                  captureNumber,
                  ext);

  if( fileExists( buffer ) ) {
	  // screenshot file already exists
	  screenCapture(++captureNumber);
	  // this will recursively use the first non-existent screenshot number
	  return;
  }

  if(theApp.captureFormat == 0)
    theApp.emulator.emuWritePNG(buffer);
  else
    theApp.emulator.emuWriteBMP(buffer);

  CString msg = winResLoadString(IDS_SCREEN_CAPTURE);
  systemScreenMessage(msg);
}
Beispiel #15
0
void systemMessage(int number, const char *defaultMsg, ...)
{
	CString buffer;
	va_list valist;
	CString msg = defaultMsg;
	if (number)
		msg = winResLoadString(number);

	va_start(valist, defaultMsg);
	buffer.FormatV(msg, valist);

	theApp.winCheckFullscreen();
	systemSoundClearBuffer();
	AfxGetApp()->m_pMainWnd->MessageBox(buffer, winResLoadString(IDS_ERROR), MB_OK | MB_ICONERROR);

	va_end(valist);
}
void MemoryViewerDlg::OnLoad() 
{
  if(rom != NULL)
  {
  CString buffer;
  LPCTSTR exts[] = { ".dmp" };

  CString filter = theApp.winLoadFilter(IDS_FILTER_DUMP);
  CString title = winResLoadString(IDS_SELECT_DUMP_FILE);

  FileDlg file(this,
               buffer,
               filter,
               0,
               "DMP",
               exts,
               "",
               title,
               false);
  
  if(file.DoModal() == IDOK) {
    buffer = file.GetPathName();
    FILE *f = fopen(buffer, "rb");
    if(f == NULL) {
      systemMessage(IDS_CANNOT_OPEN_FILE,
                    "Cannot open file %s",
                    buffer);
      return;
    }
    
    MemoryViewerAddressSize dlg;    

    fseek(f, 0, SEEK_END);
    int size = ftell(f);

    fseek(f, 0, SEEK_SET);
    
    dlg.setAddress(m_viewer.getCurrentAddress());
    dlg.setSize(size);
    
    if(dlg.DoModal() == IDOK) {
      int size = dlg.getSize();
      u32 addr = dlg.getAddress();

      for(int i = 0; i < size; i++) {
        int c = fgetc(f);
        if(c == -1)
          break;
        CPUWriteByteQuick(addr, c);
        addr++;
      }
      OnRefresh();
    }
    fclose(f);    
  }  
}
}
void MainWnd::OnToolsRecordStartmovierecording()
{
  CString captureBuffer;
  CString capdir = regQueryStringValue("movieRecordDir", "");

  if(capdir.IsEmpty())
    capdir = getDirFromFile(theApp.filename);

  CString filter = theApp.winLoadFilter(IDS_FILTER_VMV);
  CString title = winResLoadString(IDS_SELECT_MOVIE_NAME);

  LPCTSTR exts[] = { ".VMV" };

  FileDlg dlg(this, "", filter, 1, "VMV", exts, capdir, title, true);

  if(dlg.DoModal() == IDCANCEL) {
    return;
  }

  CString movieName = dlg.GetPathName();
  captureBuffer = movieName;

  if(dlg.m_ofn.nFileOffset > 0) {
    captureBuffer = captureBuffer.Left(dlg.m_ofn.nFileOffset);
  }

  int len = captureBuffer.GetLength();

  if(len > 3 && captureBuffer[len-1] == '\\')
    captureBuffer = captureBuffer.Left(len-1);

  regSetStringValue("movieRecordDir", captureBuffer);

  theApp.movieFile = fopen(movieName, "wb");

  if(!theApp.movieFile) {
    systemMessage(IDS_CANNOT_OPEN_FILE, "Cannot open file %s",
                  (const char *)movieName);
    return;
  }

  int version = 1;

  fwrite(&version, 1, sizeof(int), theApp.movieFile);

  movieName = movieName.Left(movieName.GetLength()-3) + "VM0";

  if(writeSaveGame(movieName)) {
    movieFrame = 0;
    movieLastJoypad = 0;
    movieRecording = true;
    moviePlaying = false;
  } else {
    systemMessage(IDS_CANNOT_OPEN_FILE, "Cannot open file %s",
                  (const char *)movieName);
  }
}
Beispiel #18
0
static LPCTSTR winGBARomInfoFindMakerCode(LPCTSTR code)
{
  int i = 0;
  while(winGBARomInfoCompanies[i].code) {
    if(!_tcscmp(winGBARomInfoCompanies[i].code, code))
      return winGBARomInfoCompanies[i].name;
    i++;
  }
  return (LPCTSTR)winResLoadString(IDS_UNKNOWN);
}
void MainWnd::winLoadCheatList(const char *name)
{
  bool res = false;

  if(theApp.cartridgeType == 0)
    res = cheatsLoadCheatList(name);
  else
    res = gbCheatsLoadCheatList(name);

  if(res)
    systemScreenMessage(winResLoadString(IDS_LOADED_CHEATS));
}
Beispiel #20
0
void GBPaletteView::save(int which)
{
  CString captureBuffer;

  if(which == 0)
    captureBuffer = "bg.pal";
  else
    captureBuffer = "obj.pal";

  LPCTSTR exts[] = {".pal", ".pal", ".act" };

  CString filter = theApp.winLoadFilter(IDS_FILTER_PAL);
  CString title = winResLoadString(IDS_SELECT_PALETTE_NAME);
  FileDlg dlg(this,
              captureBuffer,
              filter,
              1,
              "PAL",
              exts,
              "",
              title,
              true);

  if(dlg.DoModal() == IDCANCEL) {
    return;
  }

  captureBuffer = dlg.GetPathName();

  PaletteViewControl *p = NULL;

  if(which == 0)
    p = &paletteView;
  else
    p = &paletteViewOBJ;

  switch(dlg.getFilterIndex()) {
  case 0:
  case 1:
    p->saveMSPAL(captureBuffer);
    break;
  case 2:
    p->saveJASCPAL(captureBuffer);
    break;
  case 3:
    p->saveAdobe(captureBuffer);
    break;
  }
}
void MemoryViewerDlg::OnSave() 
{
  if(rom != NULL)
  {
  MemoryViewerAddressSize dlg;
  CString buffer;

  dlg.setAddress(m_viewer.getCurrentAddress());

  LPCTSTR exts[] = { ".dmp" };
  
  if(dlg.DoModal() == IDOK) {
    CString filter = theApp.winLoadFilter(IDS_FILTER_DUMP);
    CString title = winResLoadString(IDS_SELECT_DUMP_FILE);

    FileDlg file(this,
                 buffer,
                 filter,
                 0,
                 "DMP",
                 exts,
                 "",
                 title, 
                 true);
    if(file.DoModal() == IDOK) {
      buffer = file.GetPathName();

      FILE *f = fopen(buffer, "wb");
      
      if(f == NULL) {
        systemMessage(IDS_ERROR_CREATING_FILE, buffer);
        return;
      }

      int size = dlg.getSize();
      u32 addr = dlg.getAddress();

      for(int i = 0; i < size; i++) {
        fputc(CPUReadByteQuick(addr), f);
        addr++;
      }

      fclose(f);
    }
  }
}
}
void MainWnd::OnCheatsSavecheatlist()
{
	theApp.winCheckFullscreen();

	LPCTSTR exts[] = { ".clt", NULL };
	CString filter = winResLoadFilter(IDS_FILTER_CHEAT_LIST);
	CString title  = winResLoadString(IDS_SELECT_CHEAT_LIST_NAME);

	CString cheatName = winGetDestFilename(theApp.gameFilename, IDS_CHEAT_DIR, exts[0]);
	CString cheatDir = winGetDestDir(IDS_CHEAT_DIR);

	FileDlg dlg(this, cheatName, filter, 0, "CLT", exts, cheatDir, title, true);

	if (dlg.DoModal() == IDOK)
	{
		winSaveCheatList(dlg.GetPathName());
	}
}
void MainWnd::screenCapture(int captureNumber)
{
  CString buffer;
  
  CString captureDir = regQueryStringValue("captureDir", "");
  int index = theApp.filename.ReverseFind('\\');
  
  CString name;
  if(index != -1)
    name = theApp.filename.Right(theApp.filename.GetLength()-index-1);
  else
    name = theApp.filename;
  
  if(captureDir.IsEmpty())
    captureDir = getDirFromFile(theApp.filename);

  LPCTSTR ext = "png";
  if(theApp.captureFormat != 0)
    ext = "bmp";
  
  if(isDriveRoot(captureDir))
    buffer.Format("%s%s_%02d.%s",
                  captureDir,
                  name,
                  captureNumber,
                  ext);
  else
    buffer.Format("%s\\%s_%02d.%s",
                  captureDir,
                  name,
                  captureNumber,
                  ext);

  if(theApp.captureFormat == 0)
    theApp.emuWritePNG(buffer);
  else
    theApp.emuWriteBMP(buffer);

  CString msg = winResLoadString(IDS_SCREEN_CAPTURE);
  systemScreenMessage(msg);
}
Beispiel #24
0
void MainWnd::readBatteryFile()
{
  CString buffer;
  CString filename;

  int index = theApp.filename.ReverseFind('\\');

  if(index != -1)
    buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1);
  else
    buffer = theApp.filename;

  CString saveDir = regQueryStringValue("batteryDir", NULL);
  if( saveDir[0] == '.' ) {
	  // handle as relative path
	  char baseDir[MAX_PATH+1];
	  GetModuleFileName( NULL, baseDir, MAX_PATH );
	  baseDir[MAX_PATH] = '\0'; // for security reasons
	  PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
	  strcat( baseDir, "\\" );
	  strcat( baseDir, saveDir );
	  saveDir = baseDir;
	}

  if(saveDir.IsEmpty())
    saveDir = getDirFromFile(theApp.filename);

  if(isDriveRoot(saveDir))
    filename.Format("%s%s.sav", saveDir, buffer);
  else
    filename.Format("%s\\%s.sav", saveDir, buffer);

  bool res = false;

  if(theApp.emulator.emuReadBattery)
    res = theApp.emulator.emuReadBattery(MakeInstanceFilename(filename));

  if(res)
    systemScreenMessage(winResLoadString(IDS_LOADED_BATTERY));
}
INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	RECT r;
	RECT r2;
	int dx1, dy1, dx2, dy2;

	switch (msg) {

	case WM_INITDIALOG:
	{
		// remove the 30000 character limit from the console control
		SendMessage(GetDlgItem(hDlg, IDC_LUACONSOLE),EM_LIMITTEXT,0,0);

		GetWindowRect(AfxGetMainWnd()->GetSafeHwnd(), &r);
		dx1 = (r.right - r.left) / 2;
		dy1 = (r.bottom - r.top) / 2;

		GetWindowRect(hDlg, &r2);
		dx2 = (r2.right - r2.left) / 2;
		dy2 = (r2.bottom - r2.top) / 2;

		int windowIndex = 0;//std::find(LuaScriptHWnds.begin(), LuaScriptHWnds.end(), hDlg) - LuaScriptHWnds.begin();
		int staggerOffset = windowIndex * 24;
		r.left += staggerOffset;
		r.right += staggerOffset;
		r.top += staggerOffset;
		r.bottom += staggerOffset;

		// push it away from the main window if we can
		const int width = (r.right-r.left); 
		const int width2 = (r2.right-r2.left); 
		if(r.left+width2 + width < GetSystemMetrics(SM_CXSCREEN))
		{
			r.right += width;
			r.left += width;
		}
		else if((int)r.left - (int)width2 > 0)
		{
			r.right -= width2;
			r.left -= width2;
		}

		SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);

		RECT r3;
		GetClientRect(hDlg, &r3);
		windowInfo.width = r3.right - r3.left;
		windowInfo.height = r3.bottom - r3.top;
		for(int i = 0; i < numControlLayoutInfos; i++) {
			ControlLayoutState& layoutState = windowInfo.layoutState[i];
			layoutState.valid = false;
		}

		DragAcceptFiles(hDlg, true);
		SetDlgItemText(hDlg, IDC_EDIT_LUAPATH, VBAGetLuaScriptName());

		SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &LuaConsoleLogFont, 0); // reset with an acceptable font
		return true;
	}	break;

	case WM_SIZE:
	{
		// resize or move controls in the window as necessary when the window is resized

		//LuaPerWindowInfo& windowInfo = LuaWindowInfo[hDlg];
		int prevDlgWidth = windowInfo.width;
		int prevDlgHeight = windowInfo.height;

		int dlgWidth = LOWORD(lParam);
		int dlgHeight = HIWORD(lParam);

		int deltaWidth = dlgWidth - prevDlgWidth;
		int deltaHeight = dlgHeight - prevDlgHeight;

		for(int i = 0; i < numControlLayoutInfos; i++)
		{
			ControlLayoutInfo layoutInfo = controlLayoutInfos[i];
			ControlLayoutState& layoutState = windowInfo.layoutState[i];

			HWND hCtrl = GetDlgItem(hDlg,layoutInfo.controlID);

			int x,y,width,height;
			if(layoutState.valid)
			{
				x = layoutState.x;
				y = layoutState.y;
				width = layoutState.width;
				height = layoutState.height;
			}
			else
			{
				RECT r;
				GetWindowRect(hCtrl, &r);
				POINT p = {r.left, r.top};
				ScreenToClient(hDlg, &p);
				x = p.x;
				y = p.y;
				width = r.right - r.left;
				height = r.bottom - r.top;
			}

			switch(layoutInfo.horizontalLayout)
			{
				case ControlLayoutInfo::RESIZE_END: width += deltaWidth; break;
				case ControlLayoutInfo::MOVE_START: x += deltaWidth; break;
				default: break;
			}
			switch(layoutInfo.verticalLayout)
			{
				case ControlLayoutInfo::RESIZE_END: height += deltaHeight; break;
				case ControlLayoutInfo::MOVE_START: y += deltaHeight; break;
				default: break;
			}

			SetWindowPos(hCtrl, 0, x,y, width,height, 0);

			layoutState.x = x;
			layoutState.y = y;
			layoutState.width = width;
			layoutState.height = height;
			layoutState.valid = true;
		}

		windowInfo.width = dlgWidth;
		windowInfo.height = dlgHeight;

		RedrawWindow(hDlg, NULL, NULL, RDW_INVALIDATE);
	}	break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
			case IDOK:
			case IDCANCEL: {
				EndDialog(hDlg, true); // goto case WM_CLOSE;
			}	break;

			case IDC_BUTTON_LUARUN:
			{
				if (systemIsEmulating())
				{
					char filename[MAX_PATH];
					GetDlgItemText(hDlg, IDC_EDIT_LUAPATH, filename, MAX_PATH);
					VBALoadLuaCode(filename);
				}
			}	break;

			case IDC_BUTTON_LUASTOP:
			{
				VBALuaStop();
			}	break;

			case IDC_BUTTON_LUAEDIT:
			{
				char Str_Tmp [1024];
				SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_GETTEXT,(WPARAM)512,(LPARAM)Str_Tmp);
				// tell the OS to open the file with its associated editor,
				// without blocking on it or leaving a command window open.
				if((int)ShellExecute(NULL, "edit", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC)
					if((int)ShellExecute(NULL, "open", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC)
						ShellExecute(NULL, NULL, "notepad", Str_Tmp, NULL, SW_SHOWNORMAL);
			}	break;

			case IDC_BUTTON_LUABROWSE:
			{
				systemSoundClearBuffer();

				CString filter = winResLoadFilter(IDS_FILTER_LUA);
				CString title  = winResLoadString(IDS_SELECT_LUA_NAME);

				CString luaName = winGetDestFilename(theApp.gameFilename, IDS_LUA_DIR, ".lua");
				CString luaDir = winGetDestDir(IDS_LUA_DIR);

				filter.Replace('|', '\000');
//				char *p = filter.GetBuffer(0);
//				while ((p = strchr(p, '|')) != NULL)
//					*p++ = 0;

				OPENFILENAME  ofn;
				ZeroMemory( (LPVOID)&ofn, sizeof(OPENFILENAME) );
				ofn.lpstrFile       = luaName.GetBuffer(MAX_PATH);
				ofn.nMaxFile        = MAX_PATH;
				ofn.lStructSize     = sizeof(OPENFILENAME);
				ofn.hwndOwner       = hDlg;
				ofn.lpstrFilter     = filter;
				ofn.nFilterIndex    = 0;
				ofn.lpstrInitialDir = luaDir;
				ofn.lpstrTitle      = title;
				ofn.lpstrDefExt     = "lua";
				ofn.Flags           = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_ENABLESIZING | OFN_EXPLORER; // hide previously-ignored read-only checkbox (the real read-only box is in the open-movie dialog itself)
				if(GetOpenFileName( &ofn ))
				{
					SetWindowText(GetDlgItem(hDlg, IDC_EDIT_LUAPATH), luaName);
				}
				return true;
			}	break;

			case IDC_EDIT_LUAPATH:
			{
				char filename[MAX_PATH];
				GetDlgItemText(hDlg, IDC_EDIT_LUAPATH, filename, MAX_PATH);
				FILE* file = fopen(filename, "rb");
				EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_LUAEDIT), file != NULL);
				if(file)
					fclose(file);
			}	break;

			case IDC_LUACONSOLE_CHOOSEFONT:
			{
				CHOOSEFONT cf;

				ZeroMemory(&cf, sizeof(cf));
				cf.lStructSize = sizeof(CHOOSEFONT);
				cf.hwndOwner = hDlg;
				cf.lpLogFont = &LuaConsoleLogFont;
				cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
				if (ChooseFont(&cf)) {
					if (hFont) {
						DeleteObject(hFont);
						hFont = NULL;
					}
					hFont = CreateFontIndirect(&LuaConsoleLogFont);
					if (hFont)
						SendDlgItemMessage(hDlg, IDC_LUACONSOLE, WM_SETFONT, (WPARAM)hFont, 0);
				}
			}	break;

			case IDC_LUACONSOLE_CLEAR:
			{
				SetWindowText(GetDlgItem(hDlg, IDC_LUACONSOLE), "");
			}	break;
		}
		break;

	case WM_CLOSE: {
		SendMessage(hDlg, WM_DESTROY, 0, 0);
	}	break;

	case WM_DESTROY: {
		//VBALuaStop();
		DragAcceptFiles(hDlg, FALSE);
		if (hFont) {
			DeleteObject(hFont);
			hFont = NULL;
		}
		LuaConsoleHWnd = NULL;
	}	break;

	case WM_DROPFILES: {
		HDROP hDrop;
		//UINT fileNo;
		UINT fileCount;
		char filename[_MAX_PATH];

		hDrop = (HDROP)wParam;
		fileCount = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
		if (fileCount > 0) {
			DragQueryFile(hDrop, 0, filename, sizeof(filename));
			SetWindowText(GetDlgItem(hDlg, IDC_EDIT_LUAPATH), filename);
		}
		DragFinish(hDrop);
		return true;
	}	break;

	}

	return false;

}
Beispiel #26
0
void MainWnd::OnCheatsDisablecheats()
{
  cheatsEnabled = !cheatsEnabled;
  systemScreenMessage(CStringA(winResLoadString(cheatsEnabled ? IDS_CHEATS_ENABLED : IDS_CHEATS_DISABLED)));
}
Beispiel #27
0
BOOL RomInfoGB::OnInitDialog()
{
  CDialog::OnInitDialog();

  TCHAR buffer[128];

  CStringA bufferA((const char *)&rom[0x134], 15);
  GetDlgItem(IDC_ROM_TITLE)->SetWindowText(CString(bufferA));

  _stprintf(buffer, _T("%02x"), rom[0x143]);
  GetDlgItem(IDC_ROM_COLOR)->SetWindowText(buffer);

  bufferA = CStringA((const char *)&rom[0x144], 2);
  GetDlgItem(IDC_ROM_MAKER_CODE)->SetWindowText(CString(bufferA));

  if(rom[0x14b] != 0x33) {
    _stprintf(buffer, _T("%02X"), rom[0x14b]);
    GetDlgItem(IDC_ROM_MAKER_CODE)->SetWindowText(buffer);
  }
  GetDlgItem(IDC_ROM_MAKER_NAME2)->SetWindowText(winGBARomInfoFindMakerCode(buffer));

  _stprintf(buffer, _T("%02x"), rom[0x146]);
  GetDlgItem(IDC_ROM_UNIT_CODE)->SetWindowText(buffer);

  CString type = winResLoadString(IDS_UNKNOWN);
  switch(rom[0x147]) {
  case 0x00:
    type = _T("ROM");
    break;
  case 0x01:
    type = _T("ROM+MBC1");
    break;
  case 0x02:
    type = _T("ROM+MBC1+RAM");
    break;
  case 0x03:
    type = _T("ROM+MBC1+RAM+BATT");
    break;
  case 0x05:
    type = _T("ROM+MBC2");
    break;
  case 0x06:
    type = _T("ROM+MBC2+BATT");
    break;
  case 0x0b:
    type = _T("ROM+MMM01");
    break;
  case 0x0c:
    type = _T("ROM+MMM01+RAM");
    break;
  case 0x0d:
    type = _T("ROM+MMM01+RAM+BATT");
    break;
  case 0x0f:
    type = _T("ROM+MBC3+TIMER+BATT");
    break;
  case 0x10:
    type = _T("ROM+MBC3+TIMER+RAM+BATT");
    break;
  case 0x11:
    type = _T("ROM+MBC3");
    break;
  case 0x12:
    type = _T("ROM+MBC3+RAM");
    break;
  case 0x13:
    type = _T("ROM+MBC3+RAM+BATT");
    break;
  case 0x19:
    type = _T("ROM+MBC5");
    break;
  case 0x1a:
    type = _T("ROM+MBC5+RAM");
    break;
  case 0x1b:
    type = _T("ROM+MBC5+RAM+BATT");
    break;
  case 0x1c:
    type = _T("ROM+MBC5+RUMBLE");
    break;
  case 0x1d:
    type = _T("ROM+MBC5+RUMBLE+RAM");
    break;
  case 0x1e:
    type = _T("ROM+MBC5+RUMBLE+RAM+BATT");
    break;
  case 0x22:
    type = _T("ROM+MBC7+BATT");
    break;
  case 0x55:
    type = _T("GameGenie");
    break;
  case 0x56:
    type = _T("GameShark V3.0");
    break;
  case 0xfc:
    type = _T("ROM+POCKET CAMERA");
    break;
  case 0xfd:
    type = _T("ROM+BANDAI TAMA5");
    break;
  case 0xfe:
    type = _T("ROM+HuC-3");
    break;
  case 0xff:
    type = _T("ROM+HuC-1");
    break;
  }
  _stprintf(buffer, _T("%02x (%s)"), rom[0x147], type);
  GetDlgItem(IDC_ROM_DEVICE_TYPE)->SetWindowText(buffer);

  type = winResLoadString(IDS_UNKNOWN);
  switch(rom[0x148]) {
  case 0:
    type = _T("32K");
    break;
  case 1:
    type = _T("64K");
    break;
  case 2:
    type = _T("128K");
    break;
  case 3:
    type = _T("256K");
    break;
  case 4:
    type = _T("512K");
    break;
  case 5:
    type = _T("1M");
    break;
  case 6:
    type = _T("2M");
    break;
  case 7:
    type = _T("4M");
    break;
  }

  _stprintf(buffer, _T("%02x (%s)"), rom[0x148], type);
  GetDlgItem(IDC_ROM_SIZE)->SetWindowText(buffer);

  type = winResLoadString(IDS_UNKNOWN);
  switch(rom[0x149]) {
  case 0:
    type = winResLoadString(IDS_NONE);
    break;
  case 1:
    type = _T("2K");
    break;
  case 2:
    type = _T("8K");
    break;
  case 3:
    type = _T("32K");
    break;
  case 4:
    type = _T("128K");
    break;
  case 5:
    type = _T("64K");
    break;
  }

  _stprintf(buffer, _T("%02x (%s)"), rom[0x149], type);
  GetDlgItem(IDC_ROM_RAM_SIZE)->SetWindowText(buffer);

  _stprintf(buffer, _T("%02x"), rom[0x14a]);
  GetDlgItem(IDC_ROM_DEST_CODE)->SetWindowText(buffer);

  _stprintf(buffer, _T("%02x"), rom[0x14b]);
  GetDlgItem(IDC_ROM_LIC_CODE)->SetWindowText(buffer);

  _stprintf(buffer, _T("%02x"), rom[0x14c]);
  GetDlgItem(IDC_ROM_VERSION)->SetWindowText(buffer);

  u8 crc = 25;
  int i;
  for(i = 0x134; i < 0x14d; i++) {
    crc += rom[i];
  }

  crc = 256 - crc;

  _stprintf(buffer, _T("%02x (%02x)"), crc, rom[0x14d]);
  GetDlgItem(IDC_ROM_CRC)->SetWindowText(buffer);

  u16 crc16 = 0;
  for(i = 0; i < gbRomSize; i++) {
    crc16 += rom[i];
  }

  crc16 -= rom[0x14e];
  crc16 -= rom[0x14f];
  _stprintf(buffer, _T("%04x (%04x)"), crc16, (rom[0x14e]<<8)|rom[0x14f]);
  GetDlgItem(IDC_ROM_CHECKSUM)->SetWindowText(buffer);

  CenterWindow();

  return TRUE;  // return TRUE unless you set the focus to a control
                // EXCEPTION: OCX Property Pages should return FALSE
}
Beispiel #28
0
bool MainWnd::fileOpenSelect( int system )
{
	theApp.dir = _T("");
	CString initialDir;
	int selectedFilter = 0;
	LPCTSTR exts[] = { _T(""), _T(""), _T(""), _T("") };
	CString filter;
	CString title;

	switch( system )
	{
	case 0:
		// GBA
		initialDir = regQueryStringValue( _T("romdir"), _T(".") );
		selectedFilter = regQueryDwordValue( _T("selectedFilter"), 0);
		if( (selectedFilter < 0) || (selectedFilter > 2) ) {
			selectedFilter = 0;
		}
		filter = winLoadFilter( IDS_FILTER_GBAROM );
		break;
	case 1:
		// GBC
		initialDir = regQueryStringValue( _T("gbcromdir"), _T(".") );
		// TODO: memorize selected filter for GBC as well
		filter = winLoadFilter( IDS_FILTER_GBCROM );
		break;
	case 2:
		// GB
		initialDir = regQueryStringValue( _T("gbromdir"), _T(".") );
		// TODO: memorize selected filter for GB as well
		filter = winLoadFilter( IDS_FILTER_GBROM );
		break;
	}

	title = winResLoadString( IDS_SELECT_ROM );

	if( !initialDir.IsEmpty() ) {
		theApp.dir = initialDir;
	}

	if( initialDir[0] == '.' ) {
		// handle as relative path
		char baseDir[MAX_PATH+1];
		GetModuleFileName( NULL, baseDir, MAX_PATH );
		baseDir[MAX_PATH] = '\0'; // for security reasons
		PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
		strcat( baseDir, "\\" );
		strcat( baseDir, initialDir );
		initialDir = baseDir;
	}

	theApp.szFile = _T("");


	FileDlg dlg( this, _T(""), filter, selectedFilter, _T(""), exts, theApp.dir, title, false);

	if( dlg.DoModal() == IDOK ) {
		if( system == 0 ) {
			regSetDwordValue( _T("selectedFilter"), dlg.m_ofn.nFilterIndex );
		}
		theApp.szFile = dlg.GetPathName();
		theApp.dir = theApp.szFile.Left( dlg.m_ofn.nFileOffset );
		if( (theApp.dir.GetLength() > 3) && (theApp.dir[theApp.dir.GetLength()-1] == _T('\\')) ) {
			theApp.dir = theApp.dir.Left( theApp.dir.GetLength() - 1 );
		}
		SetCurrentDirectory( theApp.dir );
		regSetStringValue( _T("lastDir"), theApp.dir );
		return true;
	}
	return false;
}
void MainWnd::OnToolsRecordStartavirecording()
{
	CString captureBuffer;
	CString capdir = regQueryStringValue( "aviRecordDir", NULL );

	if( capdir.IsEmpty() ) {
		capdir = getDirFromFile( theApp.filename );
	}

	CString filter = theApp.winLoadFilter( IDS_FILTER_AVI );
	CString title = winResLoadString( IDS_SELECT_AVI_NAME );

	LPCTSTR exts[] = { ".AVI" };

	FileDlg dlg( this, "", filter, 1, "AVI", exts, capdir, title, true );

	if( dlg.DoModal() == IDCANCEL ) {
		return;
	}

	captureBuffer = theApp.soundRecordName =  dlg.GetPathName();
	theApp.aviRecordName = captureBuffer;
	aviRecording = true;

	if( dlg.m_ofn.nFileOffset > 0 ) {
		captureBuffer = captureBuffer.Left( dlg.m_ofn.nFileOffset );
	}

	int len = captureBuffer.GetLength();

	if( ( len > 3 ) && captureBuffer[ len - 1 ] == '\\' ) {
		captureBuffer = captureBuffer.Left( len - 1 );
	}

	regSetStringValue( "aviRecordDir", captureBuffer );


	// create AVI file
	bool ret;

	if( theApp.aviRecorder ) {
		delete theApp.aviRecorder;
		theApp.aviRecorder = NULL;
	}
	theApp.aviRecorder = new AVIWrite();

	// create AVI file
	ret = theApp.aviRecorder->CreateAVIFile( theApp.aviRecordName );
	if( !ret ) {
		systemMessage( IDS_AVI_CANNOT_CREATE_AVI, "Cannot create AVI file." );
		delete theApp.aviRecorder;
		theApp.aviRecorder = NULL;
		aviRecording = false;
		return;
	}

	// add video stream
	ret = theApp.aviRecorder->CreateVideoStream(
		sizeX,
		sizeY,
		( systemColorDepth == 32 ) ? 24 : 16,
		60,
		this->GetSafeHwnd()
		);
	if( !ret ) {
		systemMessage( IDS_AVI_CANNOT_CREATE_VIDEO, "Cannot create video stream in AVI file. Make sure the selected codec supports input in RGB24 color space!" );
		delete theApp.aviRecorder;
		theApp.aviRecorder = NULL;
		aviRecording = false;
		return;
	}

	// add audio stream
	ret = theApp.aviRecorder->CreateAudioStream(
		2,
		soundGetSampleRate(),
		16,
		this->GetSafeHwnd()
		);
	if( !ret ) {
		systemMessage( IDS_AVI_CANNOT_CREATE_AUDIO, "Cannot create audio stream in AVI file." );
		delete theApp.aviRecorder;
		theApp.aviRecorder = NULL;
		aviRecording = false;
		return;
	}
}
void MainWnd::OnToolsPlayStartmovieplaying()
{
  static bool moviePlayMessage = false;

  if(!moviePlayMessage) {
    moviePlayMessage = true;
    CString msg = winResLoadString(IDS_MOVIE_PLAY);
    CString title = winResLoadString(IDS_CONFIRM_ACTION);
    if(MessageBox(msg,
                  title,
                  MB_OKCANCEL) == IDCANCEL)
      return;
  }

  CString captureBuffer;
  CString capdir = regQueryStringValue("movieRecordDir", "");

  if(capdir.IsEmpty())
    capdir = getDirFromFile(theApp.filename);

  CString filter = theApp.winLoadFilter(IDS_FILTER_VMV);
  CString title = winResLoadString(IDS_SELECT_MOVIE_NAME);

  LPCTSTR exts[] = { ".VMV" };

  FileDlg dlg(this, "", filter, 1, "VMV", exts, capdir, title, false);

  if(dlg.DoModal() == IDCANCEL) {
    return;
  }

  CString movieName = dlg.GetPathName();
  captureBuffer = movieName;

  theApp.movieFile = fopen(movieName, "rb");

  if(!theApp.movieFile) {
    systemMessage(IDS_CANNOT_OPEN_FILE, "Cannot open file %s",
                  (const char *)movieName);
    return;
  }
  int version = 0;
  fread(&version, 1, sizeof(int), theApp.movieFile);
  if(version != 1) {
    systemMessage(IDS_UNSUPPORTED_MOVIE_VERSION,
                  "Unsupported movie version %d.",
                  version);
    fclose(theApp.movieFile);
    theApp.movieFile = NULL;
    return;
  }
  movieName = movieName.Left(movieName.GetLength()-3)+"VM0";
  if(loadSaveGame(movieName)) {
    moviePlaying = true;
    movieFrame = 0;
    moviePlayFrame = 0;
    movieLastJoypad = 0;
    theApp.movieReadNext();
  } else {
    systemMessage(IDS_CANNOT_OPEN_FILE, "Cannot open file %s",
                  (const char *)movieName);
  }
}