Beispiel #1
0
BOOL	UploadGAR (void)
{
	FILE *GAR;
	char filename[MAX_PATH];
	int i;
	
	if (!PromptFile(topHWnd,"Game Action Replay RAM file (gar.bin)\0gar.bin\0\0",filename,NULL,Path_PLUG,"Please select a valid Game Action Replay data file...","gar.bin",FALSE))
		return FALSE;
	
	if ((GAR = fopen(filename,"rb")) == NULL)
	{
		MessageBox(topHWnd,"Unable to open GAR data file!",MSGBOX_TITLE,MB_OK | MB_ICONERROR);
		return FALSE;
	}
	OpenStatus(topHWnd);
	InitPort();
	StatusText("Resetting CopyNES...");
	ResetNES(RESET_COPYMODE);
	StatusText("Loading initialization plugin...");
	if (!LoadPlugin("garset.bin"))
	{
		fclose(GAR);
		CloseStatus();
		return FALSE;
	}
	StatusText("Running initialization plugin...");
	RunCode();
	Sleep(SLEEP_LONG);
	StatusText("Loading upload plugin...");
	if (!LoadPlugin("garup.bin"))
	{
		fclose(GAR);
		CloseStatus();
		return FALSE;
	}
	StatusText("Running upload plugin...");
	RunCode();
	StatusText("Uploading from data file...");
	BYTE a[256];
	for (i = 0; i < 8; i++)
	{
		fread(&a,256,1,GAR);
		if (!WriteBlock(a, 256))
		{
			fclose(GAR);
			CloseStatus();
			return FALSE;
		}
		StatusPercent((i*100)/8);
	}
	StatusPercent(100);
	StatusText("...done!");
	fclose(GAR);
	StatusText("Upload complete!");
	StatusOK();
	ResetNES(RESET_COPYMODE);
	return TRUE;
}
Beispiel #2
0
BOOL	WriteByteEx (BYTE data, int timeout, BOOL warn)
{
	if (ParPort == -1)
	{
		DWORD BytesWritten = 0;
		FT_SetTimeouts(ftHandleA,10000,0);
		TxBuffer[0] = data;
		ftStatus = FT_Write(ftHandleA,TxBuffer,1,&BytesWritten);
		if (ftStatus == FT_OK)
		{
			if (BytesWritten == 1)
			{
				// FT_Read OK
				return TRUE;
			}
			else
			{
				// FT_Write Timeout
				if (warn)
					MessageBox(topHWnd, "USB Error: Write Timeout", "WriteByteEx", MB_OK | MB_ICONERROR);
				return FALSE;
			}
		}
		else
		{
			// FT_Write Failed
			StatusText("FT STATUS = %i", ftStatus);
			MessageBox(topHWnd, "USB Error: Write Failed", "WriteByteEx", MB_OK | MB_ICONERROR);
			return FALSE;
		}
	}
	else
	{
		time_t starttime = time(NULL);
		BYTE b;
		shadow &= 0xDF;
		pwControl(shadow);	// set port to output mode
		pwData(data);		// output data
		shadow ^= 0x01;
		pwControl(shadow);	// signal byte sent
		b = prStatus();		// wait for ACK
		while (!((b ^ c) & 0x10))
		{
			b = prStatus();
			if (time(NULL) > starttime + (time_t)timeout)
			{
				if (warn)
					MessageBox(topHWnd, "Timeout on data transfer!", "WriteByte", MB_OK | MB_ICONERROR);
				return FALSE;
			}
		}
		c = b;
		return TRUE;
	}
}
Beispiel #3
0
BOOL	DownloadGAR (void)
{
	FILE *GAR;
	char filename[MAX_PATH];
	int i;

	if (!PromptFile(topHWnd,"Game Action Replay RAM file (gar_d.bin)\0gar_d.bin\0\0",filename,NULL,Path_PLUG,"Please specify where to save Game Action Replay RAM data...","gar_d.bin",TRUE))
		return FALSE;

	if ((GAR = fopen(filename,"wb")) == NULL)
	{
		MessageBox(topHWnd,"Unable to open file for output!",MSGBOX_TITLE,MB_OK | MB_ICONERROR);
		return FALSE;
	}
	OpenStatus(topHWnd);
	InitPort();
	StatusText("Resetting CopyNES...");
	ResetNES(RESET_COPYMODE);
	StatusText("Loading initialization plugin...");
	if (!LoadPlugin("garset.bin"))
	{
		fclose(GAR);
		CloseStatus();
		return FALSE;
	}
	StatusText("Running initialization plugin...");
	RunCode();
	Sleep(SLEEP_LONG);
	StatusText("Loading download plugin...");
	if (!LoadPlugin("gardn.bin"))
	{
		fclose(GAR);
		CloseStatus();
		return FALSE;
	}
	StatusText("Running download plugin...");
	RunCode();
	StatusText("Saving to file...");
	for (i = 0; i < 0x800; i++)
	{
		BYTE n;
		if (!ReadByte(n))
		{
			fclose(GAR);
			CloseStatus();
			return FALSE;
		}
		fwrite(&n,1,1,GAR);
		if (!(i & 0x7))
			StatusPercent((i*100)/2048);
	}
	fclose(GAR);
	StatusText("Download complete!");
	StatusOK();
	ResetNES(RESET_COPYMODE);
	return TRUE;
}
Beispiel #4
0
bool wxExFrame::UpdateStatusBar(const wxListView* lv)
{
    if (lv->IsShown())
    {
        const wxString text = (lv->GetSelectedItemCount() == 0 ?
                               wxString::Format("%d", lv->GetItemCount()):
                               wxString::Format("%d,%d", lv->GetItemCount(), lv->GetSelectedItemCount()));

        return StatusText(text, "PaneInfo");
    }

    return false;
}
		virtual void
			OnTaskUpdate(tTaskHandle handle, cStringRef status, float progress)
		{
				
			if(mTaskHandle != handle)
			{
				Log::Debug("Not My task! %d", handle.id.operator uint32_t());
				return;
			}
			Log::Debug("Is My task! %d", handle.id.operator uint32_t());
			cCoord2 bottom_right = mBarMoving.BottomRight();
			bottom_right.x = mFullBarLength*progress + mXOrigin;
			//TODO: set text
			mBarMoving.BottomRight(bottom_right);
			StatusText().ChangeText(status);
		}
Beispiel #6
0
//! Constructor.
GUI::GUI()
{
	// Load all textures
	mOpacity		=	gGraphics->loadTexture("imgs\\opacity.bmp");
	mGreyBkgd		=	gGraphics->loadTexture("imgs\\grey_bkgd.bmp");
	mOpponentLogo	=	gGraphics->loadTexture("imgs\\opponent_logo.bmp");

	// Create the status text
	mStatusText		=	StatusText("Invalid position!", 675, 380, 0.0f);

	// Create components.
	mPiecesCaptured =	new PiecesCaptured(700, 80);
	mChat			=	new Chat();

	// Build the upper panel.
	buildUpperPanel();
}
Beispiel #7
0
extern "C" BOOL WriteBlock (BYTE* blockdata, int size)
{
	int i;
	if (ParPort == -1)
	{
		DWORD BytesWritten = 0;
  		if(usb_timeout_error) return FALSE;
		FT_SetTimeouts(ftHandleA,10000,0);
		ftStatus = FT_Write(ftHandleA, (LPVOID)blockdata, size, &BytesWritten);
		if (ftStatus == FT_OK)
		{ 
			if (BytesWritten == size) 
			{ 
				// FT_Read OK
				return TRUE;
			} 
			else 
			{ 
				// FT_Write Timeout 
				MessageBox(topHWnd, "USB Error: Write Timeout", "WriteBlock", MB_OK | MB_ICONERROR);
				return FALSE;  
			} 
		} 
		else 
		{ 
			// FT_Write Failed 
			StatusText("FT STATUS = %i", ftStatus);
			MessageBox(topHWnd, "USB Error: Write Failed", "WriteBlock", MB_OK | MB_ICONERROR);
			return FALSE;  
		}
	}
	else
	{
		BOOL success;
		for (i = 0; i < size; i++)
		{
			success = WriteByteEx(blockdata[i], 10, TRUE);
			if (!success)
				return FALSE;
		}
		return TRUE;
	}
}
Beispiel #8
0
void LocalState::init(Game* game)
{
	// important!
	setGame(game);

	mBkgd			= gGraphics->loadTexture("imgs\\bkgd.bmp");
	mGreyBkgd		= gGraphics->loadTexture("imgs\\grey_bkgd.bmp");

	mBoard			= new Board(80);
	mActivePlayer	= new LocalPlayer(WHITE);
	mPlayer2		= new LocalPlayer(BLACK);
	mPiecesCaptured = new PiecesCaptured(700, 40);

	// Both players uses the same board
	mActivePlayer->setBoard(mBoard);
	mPlayer2->setBoard(mBoard);
	mSelectedPiece	= NULL;

	// Create the status text
	mStatusText		=	StatusText("Invalid position!", 675, 220, 0.0f);
	gSound->playEffect(NEW_GAME_SOUND);
}
Beispiel #9
0
BOOL	CMD_NESINFO (void)
{
	char Version[256];
	int i;
	OpenStatus(topHWnd);
	InitPort();
	if (HWVer == 1)
	{
		if (ParPort == -1)
		{
			StatusText("CopyNES did not return a version reply!");
			StatusOK();
			return FALSE;
		}
		else
		{
			StatusText("CopyNES did not return a version reply, assuming version 1");
			StatusOK();
			return TRUE;
		}
	}
	StatusText("Retrieving internal version string...");
	if (!WriteByteEx(0xA1,3,FALSE))
	{
		StatusText("Failed to request version string!");
		StatusOK();
		return FALSE;
	}

	for (i = 0; i < 256; i++)
	{
		if (!ReadByteEx(&Version[i],1,FALSE))
		{
			StatusText("Error reading version string!");
			StatusOK();
			return FALSE;
		}
		if (!Version[i])
			break;
	}
	StatusText(Version);

	StatusOK();
	return TRUE;
}
Beispiel #10
0
void ReadASEHeader(LPCSTR psFilename, int &iStartFrame, int &iFrameCount, int &iFrameSpeed, bool bReadingGLA, bool bCanSkipXSIRead /* = false */)
{
	StatusText(va("Reading Header: \"%s\"",psFilename));
	ReadASEHeader_Actual(psFilename, iStartFrame, iFrameCount, iFrameSpeed, bReadingGLA, bCanSkipXSIRead);
	StatusText(NULL);
}
Beispiel #11
0
BOOL	CMD_DUMPCART (void)
{
	int dtype = 2;
	int rbyte = 0, rcount = 0;
	PPlugin plugin;
	char *path, *ext;
	char filename[MAX_PATH];
	char fnamebuf[MAX_PATH];
	int cmode, battery, bytes, numk;
	int mapper,submapper=0;
	int nes2=0, wram=0, vram=0;
	BYTE ctype;
	WORD nblks;
	char Status[256];
	FILE *CRC, *DATA;

	// select board name
	plugin = PromptPlugin(PLUG_STD);
	if (plugin == NULL)
		return FALSE;

	mapper = plugin->num;

	PromptTitle = "Choose a ROM filename (omit extension)";
	if (!Prompt(topHWnd))
		return FALSE;
	strcpy(filename,PromptResult);

	OpenStatus(topHWnd);
	StatusText("Resetting USB CopyNES...");
	ResetNES(RESET_COPYMODE);

	StatusText("Unloading any existing plugin...");
	if (!LoadPlugin("clear.bin"))
	{
		CloseStatus();
		return FALSE;
	}
	RunCode();
	Sleep(SLEEP_SHORT);
  
	StatusText("Resetting USB CopyNES...");
	ResetNES(RESET_COPYMODE);
	StatusText("Loading plugin...");
	if (!LoadPlugin(plugin->file))
	{
		CloseStatus();
		return FALSE;
	}
	StatusText("Running plugin...");
	RunCode();
	Sleep(SLEEP_LONG);

	if (SaveCRC)
		CRC = fopen(strjoin3(fnamebuf,Path_CRC,filename,".txt"),"wb");
	
	cmode = 0;
	if (!ReadByte((BYTE *)&cmode))		// mirroring
	{
		CloseStatus();
		return FALSE;
	}
	battery = 0;
	while (1)
	{	// for the first 'header' byte, wait longer than usual
		// since the plugin might be busy doing size detection, which can take a while
		int s;
		if (!ReadByteEx((BYTE *)&nblks,10,TRUE) || !ReadByte((BYTE *)&nblks+1))
		{
			CloseStatus();
			return FALSE;
		}
		bytes = nblks << 8;
		numk = bytes / 1024;
		if (!ReadByte(&ctype))
		{
			CloseStatus();
			return FALSE;
		}
		if (ctype == 0)
			break;
		switch (ctype)
		{
		case 1:	ext = ".prg";
			if(numk >= 4096) nes2 = 1;
			path = Path_PRG;
			sprintf(Status,"Dumping %iK PRG ROM...",numk);	break;
		case 2:	ext = ".chr";
			if(numk >= 2048) nes2 = 1;
			path = Path_CHR;
			sprintf(Status,"Dumping %iK CHR ROM...",numk);	break;
		case 3:	ext = ".sav";
			path = Path_WRAM;
			sprintf(Status,"Dumping %iK WRAM/VRAM...",numk);
			battery = 1;					break;
		case 4:	rbyte = nblks / 4;
			continue;
		case 5:	nes2 = 1;
			wram = nblks & 0xFF;
			vram = nblks >> 8;
			if(wram & 0xF0) battery = 1;
			if(vram & 0xF0) battery = 1;
			sprintf(Status,"Non battery WRAM size: %i Bytes...", ((wram & 0x0f)?64 << (wram & 0x0F):0));
			StatusText(Status);
			sprintf(Status,"battery WRAM size: %i Bytes...", ((wram >> 4)?64 << (wram & 0x0F):0));
			StatusText(Status);
			sprintf(Status,"Non battery VRAM size: %i Bytes...", ((vram & 0x0f)?64 << (vram & 0x0F):0));
			StatusText(Status);
			sprintf(Status,"battery VRAM size: %i Bytes...", ((vram >> 4)?64 << (vram & 0x0F):0));
			StatusText(Status);
			continue;
		case 6:	//Mapper number override by plugin.
			mapper = nblks & 0xFFF;
			submapper = (nblks & 0xF000) >> 12;
			sprintf(Status,"Mapper number: %i, submapper: %i...",mapper,submapper);
			StatusText(Status);
			if((mapper > 255) || (submapper > 0))
				nes2 = 1;					continue;
		case 255:
			sprintf(Status,".");
			continue;	//Prevent timeout.
		default:StatusText("Unknown block type %i! Aborting...",ctype);
			StatusOK();
			return FALSE;					break;
		}
		StatusText(Status);
		DATA = fopen(strjoin3(fnamebuf,path,filename,ext),"w+b");
		if (DATA == NULL)
		{
			StatusText("Unable to open output file!");
			StatusOK();
			return FALSE;
		}
		for (s = 0; s < numk; s++)
		{
			int a;
			BYTE n;
			for (a = 0; a < 1024; a++)
			{
				if (!ReadByte(&n))
				{
					CloseStatus();
					return FALSE;
				}
				fwrite(&n,1,1,DATA);
			}
			if (rbyte)
			{
				rcount++;
				if (rbyte <= rcount)
				{
					rcount = 0;
					StatusText("Resetting USB CopyNES as requested by plugin...");
					ResetNES(RESET_COPYMODE);
					StatusText("Reloading plugin...");
					LoadPlugin(plugin->file);
					StatusText("Rerunning plugin...");
					RunCode();
					rbyte = 0;
					if (!ReadByte((BYTE *)&rbyte) || !ReadByte((BYTE *)&rbyte+1))
					{
						CloseStatus();
						return FALSE;
					}
					rbyte /= 4;
				}
			}
			StatusPercent((s*100)/numk);
			DoEvents();
		}
		StatusPercent(100);
		StatusText("...done!");
		if (SaveCRC)
			fprintf(CRC,"%s%s %08X\n",filename,ext,GetCRC(DATA));
		fclose(DATA);
	}

	if (SaveCRC)
		fclose(CRC);
	StatusText("Dump complete!");
	StatusOK();
	ResetNES(RESET_COPYMODE);
	{
		int scrn4 = (cmode & 0x2) >> 1;
		int mirror = (~cmode & 0x1);
		int mcon = (cmode & 0x4) >> 2;
		if (plugin->num == 9999)
			return TRUE;
		WriteNES(filename,mapper,battery,mirror,scrn4,nes2,wram,vram,submapper,0);
		if (MakeUnif == 1)
		  WriteUNIF(filename,plugin->name,battery,mirror,scrn4,mcon);
		if (SaveFiles == 0)
		{
			unlink(strjoin3(fnamebuf,Path_CHR,filename,".chr"));
			unlink(strjoin3(fnamebuf,Path_PRG,filename,".prg"));
		}
	}
	return TRUE;
}
Beispiel #12
0
// Do not make it const, too many const_casts needed,
// I thought that might cause crash in rect selection, but it didn't.
bool wxExFrame::UpdateStatusBar(wxExSTC* stc, const wxString& pane)
{
    if (stc == NULL)
    {
        return false;
    }

    wxString text;

    if (pane == "PaneInfo")
    {
        if (stc->GetCurrentPos() == 0)
        {
            text = wxString::Format("%d", stc->GetLineCount());
        }
        else
        {
            int start;
            int end;
            stc->GetSelection(&start, &end);

            const int len  = end - start;
            const int line = stc->GetCurrentLine() + 1;
            const int pos = stc->GetCurrentPos() + 1 - stc->PositionFromLine(line - 1);

            if (len == 0)
            {
                text = wxString::Format("%d,%d", line, pos);
            }
            else
            {
                if (stc->SelectionIsRectangle())
                {
                    text = wxString::Format("%d,%d,%d", line, pos, stc->GetSelectedText().length());
                }
                else
                {
                    // There might be NULL's inside selection.
                    // So use the GetSelectedTextRaw variant.
                    const int number_of_lines =
                        wxExGetNumberOfLines(stc->GetSelectedTextRaw());

                    if (number_of_lines <= 1)
                        text = wxString::Format("%d,%d,%d", line, pos, len);
                    else
                        text = wxString::Format("%d,%d,%d", line, number_of_lines, len);
                }
            }
        }
    }
    else if (pane == "PaneLexer")
    {
        text = stc->GetLexer().GetDisplayLexer();
    }
    else if (pane == "PaneFileType")
    {
        switch (stc->GetEOLMode())
        {
        case wxSTC_EOL_CRLF:
            text = "DOS";
            break;
        case wxSTC_EOL_CR:
            text = "MAC";
            break;
        case wxSTC_EOL_LF:
            text = "UNIX";
            break;
        default:
            text = "UNKNOWN";
        }
    }
    else
    {
        return false;
    }

    return StatusText(text, pane);
}