Esempio n. 1
0
static u32  GBAgame_read32(u32 adr)
{ 
	//INFO("Read32 at 0x%08X value 0x%08X\n", adr, (u32)T1ReadLong(GBArom, (adr - 0x08000000)));
	if ( (adr >= 0x08000004) && (adr < 0x080000A0) )
		return T1ReadLong(MMU.MMU_MEM[0][0xFF], (adr +0x1C) & MMU.MMU_MASK[0][0xFF]);
	return (u32)T1ReadLong(GBArom, (adr - 0x08000000));
}
Esempio n. 2
0
static u32  GBAgame_read32(u32 adr)
{ 
	//INFO("GBAgame: read32 at 0x%08X value 0x%08X\n", adr, (u32)T1ReadLong(GBArom, (adr - 0x08000000)));

	if (adr < 0x0A000000)
		return (u32)T1ReadLong(GBArom, (adr - 0x08000000));

	if (adr < 0x0A010000)
	{
		//INFO("GBAgame: flash read32 at 0x%08X\n", adr);
		return (u32)T1ReadLong(saveData, (adr - 0x0A000000));
	}
	return 0xFFFFFFFF;
}
Esempio n. 3
0
static u32 ExpMemory_read32(u32 procnum, u32 adr)
{
	if(adr>=0x080000B0 && adr<0x080000C0)
		return T1ReadLong(header_0x00B0,adr-0x080000B0);

	if (adr >= 0x09000000)
	{
		u32 offs = (adr - 0x09000000);
		if (offs >= expMemSize) return 0xFFFFFFFF;
		return T1ReadLong(expMemory, offs);
	}

	EXPINFO("ExpMemory: read 32 at 0x%08X\n", adr);
	return 0xFFFFFFFF;
}
Esempio n. 4
0
	virtual void connect()
	{
		protocol.reset(this);
		protocol.chipId = gameInfo.chipID;
		protocol.gameCode = T1ReadLong((u8*)gameInfo.header.gameCode,0);
		g_Slot1Comp_MC.connect();
	}
Esempio n. 5
0
u32 FASTCALL Vdp1FrameBufferReadLong(u32 addr) {
   addr &= 0x3FFFF;
   if (VIDCore->Vdp1ReadFrameBuffer){
     u32 val;
     VIDCore->Vdp1ReadFrameBuffer(2, addr, &val);
     return val;
   }
   return T1ReadLong(Vdp1FrameBuffer, addr);
}
Esempio n. 6
0
u32 SPU_ReadLong(u32 addr)
{
	addr &= 0xFFF;

	if (addr < 0x500)
	{
		switch (addr & 0xF)
		{
		case 0x0:
			//            LOG("Sound Channel %d Control Register long read\n", (addr >> 4) & 0xF);
			return T1ReadLong(MMU.ARM7_REG, addr);
		case 0x4:
			//            LOG("Sound Channel %d Data Source Register long read\n");
			return T1ReadLong(MMU.ARM7_REG, addr);
		case 0x8:
			//            LOG("Sound Channel %d Timer/Loop Start Register long read\n", (addr >> 4) & 0xF);
			return T1ReadLong(MMU.ARM7_REG, addr);
		case 0xC:
			//            LOG("Sound Channel %d Length Register long read\n", (addr >> 4) & 0xF);
			return T1ReadLong(MMU.ARM7_REG, addr);
		default:
			return T1ReadLong(MMU.ARM7_REG, addr);
		}
	}
	else
	{
		switch (addr & 0x1F)
		{
		case 0x000:
			//            LOG("Sound Control Register long read\n");
			return T1ReadLong(MMU.ARM7_REG, addr);
		case 0x004:
			//            LOG("Sound Bias Register long read\n");
			return T1ReadLong(MMU.ARM7_REG, addr);
		case 0x008:
			//            LOG("Sound Capture 0/1 Control Register long read: %08X\n");
			return T1ReadLong(MMU.ARM7_REG, addr);
		default:
			return T1ReadLong(MMU.ARM7_REG, addr);
		}
	}

	return T1ReadLong(MMU.ARM7_REG, addr);
}
	virtual void connect()
	{
		protocol.reset(this);
		protocol.chipId = gameInfo.chipID;
		protocol.gameCode = T1ReadLong((u8*)gameInfo.header.gameCode,0);

      save_adr = 0;
		handle_save = 0;
		mode = 0;
		subAdr = T1ReadWord(gameInfo.header.reserved2, 0x6) << 17;
	}
Esempio n. 8
0
void GFX_FIFOclear()
{
	u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600);

	memset(&gxFIFO, 0, sizeof(GFX_FIFO));

	// TODO: irq handle
	gxstat &= 0x0000FF00;
	gxstat |= 0x00000002;			// this is hack
	gxstat |= 0x86000000;
	T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat);
}
Esempio n. 9
0
static u32  ExpMemory_read32(u32 adr)
{
	if (adr == 0x080000AC) return(0x027FFC30);

	if (adr >= 0x09000000)
	{
		u32 offs = (adr - 0x09000000);
		if (offs >= expMemSize) return (0);
		return (T1ReadLong(expMemory, offs));
	}

	EXPINFO("ExpMemory: read 32 at 0x%08X\n", adr);
	return (0);
}
Esempio n. 10
0
static u8 getSaveTypeGBA(const u8 *data, const u32 size)
{
// 	u8	type = 0;
	u8	*dat = (u8 *)data;
	
	for (u32 i = 0; i < (size / 4); i++)
	{
		u32	tmp = T1ReadLong(dat, i);

		if (tmp == 0x52504545)
		{
			if(memcmp(dat, "EEPROM_", 7) == 0)
			{
				return 1;
			}
		}

		if (tmp == 0x4D415253)
		{
			if(memcmp(dat, "SRAM_", 5) == 0)
			{
				return 2;
			}
		}

		if (tmp == 0x53414C46)
		{
			if(memcmp(dat, "FLASH1M_", 8) == 0)
			{
				return 3;
			}
		}

		if (tmp == 0x52494953)
		{
			if(memcmp(dat, "SIIRTC_V", 8) == 0)
			{
				return 4;
			}
		}

		if(memcmp(dat, "FLASH", 5) == 0)
		{
			return 5;
		}
		dat += 4;
	}

	return 0xFF;		// NONE
}
Esempio n. 11
0
void GFX_FIFOcnt(u32 val)
{
	u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600);
	//INFO("GFX FIFO: write context 0x%08X (prev 0x%08X)\n", val, gxstat);
	if (val & (1<<29))		// clear? (homebrew)
	{
		// need to flush before???
		GFX_FIFOclear();
		return;
	}
	T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat);
	
	if (gxstat & 0xC0000000)
	{
		setIF(0, (1<<21));
	}
}
Esempio n. 12
0
	virtual void connect()
	{
		protocol.reset(this);
		protocol.chipId = gameInfo.chipID;
		protocol.gameCode = T1ReadLong((u8*)gameInfo.header.gameCode,0);

		curr_file_id = 0xFFFF;
		fpROM = NULL;
		fs = NULL;

		if (!CommonSettings.loadToMemory) 
		{
			printf("NitroFS: change load type to \"Load to RAM\"\n");
			return;
		}
		pathData = path.getpath(path.SLOT1D) + path.GetRomNameWithoutExtension();
		printf("Path to Slot1 data: %s\n", pathData.c_str());
		
		fs = new FS_NITRO(gameInfo.romdata);
		fs->rebuildFAT(pathData);
	}
Esempio n. 13
0
void GFX_FIFOsend(u32 cmd, u32 param)
{
	u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600);
	gxstat &= 0x0000FF00;
	gxstat |= 0x00000002;		// this is hack

	if (gxFIFO.tail < 260)
	{
		gxFIFO.cmd[gxFIFO.tail] = cmd & 0xFF;
		gxFIFO.param[gxFIFO.tail] = param;
		gxFIFO.tail++;
		// TODO: irq handle
		if (gxFIFO.tail < 130)
			gxstat |= 0x72000000;
		if (gxFIFO.tail == 16)
			gxstat |= 0x01000000;
	}
	else
		gxstat |= 0x01000000;

	T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat);
}
Esempio n. 14
0
u32 FASTCALL Vdp1RamReadLong(u32 addr) {
   addr &= 0x7FFFF;
   return T1ReadLong(Vdp1Ram, addr);
}
Esempio n. 15
0
static u32 read32_GCDATAIN(u8 PROCNUM)
{
	nds_dscard& card = MMU.dscard[PROCNUM];

	switch(card.command[0])
	{
		//Get ROM chip ID
		case 0x90:
		case 0xB8:
			{
				// Note: the BIOS stores the chip ID in main memory
				// Most games continuously compare the chip ID with
				// the value in memory, probably to know if the card
				// was removed.
				// As DeSmuME boots directly from the game, the chip
				// ID in main mem is zero and this value needs to be
				// zero too.

				//note that even if desmume was booting from firmware, and reading this chip ID to store in main memory,
				//this still works, since it will have read 00 originally and then read 00 to validate.

				//staff of kings verifies this (it also uses the arm7 IRQ 20)
				if(nds.cardEjected) //TODO - handle this with ejected card slot1 device (and verify using this case)
					return 0xFFFFFFFF;
				else return 0;
			}
			break;


		// Data read
		case 0x00:
		case 0xB7:
			{
				// Make sure any reads below 0x8000 redirect to 0x8000+(adr&0x1FF) as on real cart
				if((card.command[0] == 0xB7) && (card.address < 0x8000))
				{
					//TODO - refactor this to include the PROCNUM, for debugging purposes if nothing else
					//(can refactor gbaslot also)

					//INFO("Read below 0x8000 (0x%04X) from: ARM%s %08X\n",
					//	card.address, (PROCNUM ? "7":"9"), (PROCNUM ? NDS_ARM7:NDS_ARM9).instruct_adr);

					card.address = (0x8000 + (card.address&0x1FF));
				}

				//it seems that etrian odyssey 3 doesnt work unless we mask this to cart size.
				//but, a thought: does the internal rom address counter register wrap around? we may be making a mistake by keeping the extra precision
				//but there is no test case yet
				u32 address = card.address & (gameInfo.mask);

				//as a sanity measure for funny-sized roms (homebrew and perhaps truncated retail roms)
				//we need to protect ourselves by returning 0xFF for things still out of range
				if(address >= gameInfo.romsize)
				{
					DEBUG_Notify.ReadBeyondEndOfCart(address,gameInfo.romsize);
					return 0xFFFFFFFF;
				}

				return T1ReadLong(MMU.CART_ROM, address);
			}
			break;

		// Nand Init?
		case 0x94:
			return 0; //Unsure what to return here so return 0 for now

		// Nand Status?
		case 0xD6:
			//0x80 == busy
			// Made in Ore/WariWare D.I.Y. need set value to 0x80
			return 0x80; //0x20 == ready

		default:
			return 0;
	} //switch(card.command[0])
} //read32_GCDATAIN
Esempio n. 16
0
u32 SPU_ReadLong(u32 addr)
{
	addr &= 0xFFF;

	return T1ReadLong(MMU.ARM7_REG, addr);
}
Esempio n. 17
0
NDS_header * NDS_getROMHeader(void)
{
	NDS_header * header = new NDS_header;

	memcpy(header->gameTile, MMU.CART_ROM, 12);
	memcpy(header->gameCode, MMU.CART_ROM + 12, 4);
	header->makerCode = T1ReadWord(MMU.CART_ROM, 16);
	header->unitCode = MMU.CART_ROM[18];
	header->deviceCode = MMU.CART_ROM[19];
	header->cardSize = MMU.CART_ROM[20];
	memcpy(header->cardInfo, MMU.CART_ROM + 21, 8);
	header->flags = MMU.CART_ROM[29];
	header->ARM9src = T1ReadLong(MMU.CART_ROM, 32);
	header->ARM9exe = T1ReadLong(MMU.CART_ROM, 36);
	header->ARM9cpy = T1ReadLong(MMU.CART_ROM, 40);
	header->ARM9binSize = T1ReadLong(MMU.CART_ROM, 44);
	header->ARM7src = T1ReadLong(MMU.CART_ROM, 48);
	header->ARM7exe = T1ReadLong(MMU.CART_ROM, 52);
	header->ARM7cpy = T1ReadLong(MMU.CART_ROM, 56);
	header->ARM7binSize = T1ReadLong(MMU.CART_ROM, 60);
	header->FNameTblOff = T1ReadLong(MMU.CART_ROM, 64);
	header->FNameTblSize = T1ReadLong(MMU.CART_ROM, 68);
	header->FATOff = T1ReadLong(MMU.CART_ROM, 72);
	header->FATSize = T1ReadLong(MMU.CART_ROM, 76);
	header->ARM9OverlayOff = T1ReadLong(MMU.CART_ROM, 80);
	header->ARM9OverlaySize = T1ReadLong(MMU.CART_ROM, 84);
	header->ARM7OverlayOff = T1ReadLong(MMU.CART_ROM, 88);
	header->ARM7OverlaySize = T1ReadLong(MMU.CART_ROM, 92);
	header->unknown2a = T1ReadLong(MMU.CART_ROM, 96);
	header->unknown2b = T1ReadLong(MMU.CART_ROM, 100);
	header->IconOff = T1ReadLong(MMU.CART_ROM, 104);
	header->CRC16 = T1ReadWord(MMU.CART_ROM, 108);
	header->ROMtimeout = T1ReadWord(MMU.CART_ROM, 110);
	header->ARM9unk = T1ReadLong(MMU.CART_ROM, 112);
	header->ARM7unk = T1ReadLong(MMU.CART_ROM, 116);
	memcpy(header->unknown3c, MMU.CART_ROM + 120, 8);
	header->ROMSize = T1ReadLong(MMU.CART_ROM, 128);
	header->HeaderSize = T1ReadLong(MMU.CART_ROM, 132);
	memcpy(header->unknown5, MMU.CART_ROM + 136, 56);
	memcpy(header->logo, MMU.CART_ROM + 192, 156);
	header->logoCRC16 = T1ReadWord(MMU.CART_ROM, 348);
	header->headerCRC16 = T1ReadWord(MMU.CART_ROM, 350);
	memcpy(header->reserved, MMU.CART_ROM + 352, 160);

	return header;
} 
Esempio n. 18
0
LRESULT GInfo_Paint(HWND hDlg, WPARAM wParam, LPARAM lParam)
{
	HDC				hdc;
	PAINTSTRUCT		ps;
	char			text[80];
	u32				icontitleOffset;
	wchar_t			*utf16text;
	u32				val;
        
	hdc = BeginPaint(hDlg, &ps);

	icontitleOffset = T1ReadLong(MMU.CART_ROM, 0x68);

	if(icontitleOffset >= 0x8000)
	{
		utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x240 + (0x100 * win_fw_config.language));
		sprintf(text, "%ws", utf16text);
		SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLE), text);

		utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x240);
		sprintf(text, "%ws", utf16text);
		SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEJP), text);

		utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x340);
		sprintf(text, "%ws", utf16text);
		SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEEN), text);

		utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x440);
		sprintf(text, "%ws", utf16text);
		SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEFR), text);

		utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x540);
		sprintf(text, "%ws", utf16text);
		SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEGE), text);

		utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x640);
		sprintf(text, "%ws", utf16text);
		SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEIT), text);

		utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x740);
		sprintf(text, "%ws", utf16text);
		SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLESP), text);
	}
	else
	{
		SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLE), "\nNo title\n");

		SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEJP), "None");
		SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEEN), "None");
		SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEFR), "None");
		SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEGE), "None");
		SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEIT), "None");
		SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLESP), "None");
	}


	memcpy(text, MMU.CART_ROM, 12);
	text[12] = '\0';
	SetWindowText(GetDlgItem(hDlg, IDC_GI_GAMETITLE), text);

	memcpy(text, (MMU.CART_ROM+0xC), 4);
	text[4] = '\0';
	SetWindowText(GetDlgItem(hDlg, IDC_GI_GAMECODE), text);

	memcpy(text, (MMU.CART_ROM+0x10), 2);
	text[2] = '\0';
	SetWindowText(GetDlgItem(hDlg, IDC_GI_MAKERCODE), text);

	val = T1ReadByte(MMU.CART_ROM, 0x14);
	sprintf(text, "%i kilobytes", (0x80 << val));
	SetWindowText(GetDlgItem(hDlg, IDC_GI_CHIPSIZE), text);


	val = T1ReadLong(MMU.CART_ROM, 0x20);
	sprintf(text, "0x%08X", val);
	SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9ROM), text);

	val = T1ReadLong(MMU.CART_ROM, 0x24);
	sprintf(text, "0x%08X", val);
	SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9ENTRY), text);

	val = T1ReadLong(MMU.CART_ROM, 0x28);
	sprintf(text, "0x%08X", val);
	SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9START), text);

	val = T1ReadLong(MMU.CART_ROM, 0x2C);
	sprintf(text, "%i bytes", val);
	SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9SIZE), text);

	val = T1ReadLong(MMU.CART_ROM, 0x30);
	sprintf(text, "0x%08X", val);
	SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7ROM), text);

	val = T1ReadLong(MMU.CART_ROM, 0x34);
	sprintf(text, "0x%08X", val);
	SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7ENTRY), text);

	val = T1ReadLong(MMU.CART_ROM, 0x38);
	sprintf(text, "0x%08X", val);
	SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7START), text);

	val = T1ReadLong(MMU.CART_ROM, 0x3C);
	sprintf(text, "%i bytes", val);
	SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7SIZE), text);


	val = T1ReadLong(MMU.CART_ROM, 0x40);
	sprintf(text, "0x%08X", val);
	SetWindowText(GetDlgItem(hDlg, IDC_GI_FNTOFS), text);

	val = T1ReadLong(MMU.CART_ROM, 0x44);
	sprintf(text, "%i bytes", val);
	SetWindowText(GetDlgItem(hDlg, IDC_GI_FNTSIZE), text);

	val = T1ReadLong(MMU.CART_ROM, 0x48);
	sprintf(text, "0x%08X", val);
	SetWindowText(GetDlgItem(hDlg, IDC_GI_FATOFS), text);

	val = T1ReadLong(MMU.CART_ROM, 0x4C);
	sprintf(text, "%i bytes", val);
	SetWindowText(GetDlgItem(hDlg, IDC_GI_FATSIZE), text);


	sprintf(text, "0x%08X", icontitleOffset);
	SetWindowText(GetDlgItem(hDlg, IDC_GI_ICONTITLEOFS), text);

	val = T1ReadLong(MMU.CART_ROM, 0x80);
	sprintf(text, "0x%08X", val);
	SetWindowText(GetDlgItem(hDlg, IDC_GI_USEDROMSIZE), text);


	EndPaint(hDlg, &ps);

	return 0;
}
Esempio n. 19
0
LRESULT GInfo_IconBoxPaint(HWND hCtl, WPARAM wParam, LPARAM lParam)
{
	HDC				hdc;
	PAINTSTRUCT		ps;
	RECT			rc;
	int				w, h;
	SIZE			fontsize;
	HDC				mem_hdc;
	HBITMAP			mem_bmp;
	BITMAPV4HEADER	bmph;
	u32				icontitleOffset;
	u16				icon[32 * 32];
	int				x, y;

	GetClientRect(hCtl, &rc);
	w = (rc.right - rc.left);
	h = (rc.bottom - rc.top);

	hdc = BeginPaint(hCtl, &ps);

	mem_hdc = CreateCompatibleDC(hdc);
	mem_bmp = CreateCompatibleBitmap(hdc, w, h);
	SelectObject(mem_hdc, mem_bmp);
		
	FillRect(mem_hdc, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH));

	ZeroMemory(&bmph, sizeof(bmph));
	bmph.bV4Size			 = sizeof(bmph);
	bmph.bV4Planes			 = 1;
	bmph.bV4BitCount		 = 16;
	bmph.bV4V4Compression	 = BI_BITFIELDS;
	bmph.bV4RedMask			 = 0x001F;
	bmph.bV4GreenMask		 = 0x03E0;
	bmph.bV4BlueMask		 = 0x7C00;
	bmph.bV4Width			 = 32;
	bmph.bV4Height			 = -32;

	icontitleOffset = T1ReadLong(MMU.CART_ROM, 0x68);

	if(icontitleOffset >= 0x8000)
	{
		for(y = 0; y < 32; y++)
		{
			for(x = 0; x < 32; x++)
			{
				int tilenum = (((y / 8) * 4) + (x / 8));
				int tilex = (x % 8);
				int tiley = (y % 8);
				int mapoffset = ((tilenum * 64) + (tiley * 8) + tilex);

				u8 val = T1ReadByte(MMU.CART_ROM, (icontitleOffset + 0x20 + (mapoffset>>1)));

				if(mapoffset & 1)
					val = ((val >> 4) & 0xF);
				else
					val = (val & 0xF);

				icon[(y * 32) + x] = T1ReadWord(MMU.CART_ROM, (icontitleOffset + 0x220 + (val<<1)));
			}
		}

		SetDIBitsToDevice(mem_hdc, ((w/2) - 16), ((h/2) - 16), 32, 32, 0, 0, 0, 32, icon, (BITMAPINFO*)&bmph, DIB_RGB_COLORS);
	}