add --dsi-mode=1 and dsi TSC emulation. this does not constitute "dsi support". you will probably think that it does anyway.
This commit is contained in:
parent
0a0d4fe509
commit
4a330878ae
|
@ -1,4 +1,5 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
/*
|
||||
Copyright (C) 2006 yopyop
|
||||
Copyright (C) 2007 shash
|
||||
Copyright (C) 2007-2011 DeSmuME team
|
||||
|
||||
|
@ -1072,6 +1073,114 @@ static void execdiv() {
|
|||
NDS_Reschedule();
|
||||
}
|
||||
|
||||
DSI_TSC::DSI_TSC()
|
||||
: state(0)
|
||||
, selection(0)
|
||||
{
|
||||
for(int i=0;i<ARRAY_SIZE(registers);i++)
|
||||
registers[i] = 0x00;
|
||||
}
|
||||
|
||||
void DSI_TSC::reset_command()
|
||||
{
|
||||
state = 0;
|
||||
readcount = 0;
|
||||
}
|
||||
|
||||
u16 DSI_TSC::write16(u16 val)
|
||||
{
|
||||
switch(state)
|
||||
{
|
||||
case 0:
|
||||
selection = val;
|
||||
state = 1;
|
||||
return read16();
|
||||
case 1:
|
||||
{
|
||||
u16 regsel = selection>>1;
|
||||
if(selection&1)
|
||||
{
|
||||
//read
|
||||
}
|
||||
else
|
||||
{
|
||||
//write
|
||||
registers[regsel] = val;
|
||||
}
|
||||
state = 2;
|
||||
return read16();
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
//continuing...
|
||||
readcount++;
|
||||
return read16();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
u16 DSI_TSC::read16()
|
||||
{
|
||||
u16 regsel = selection>>1;
|
||||
switch(regsel)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
u16 temp;
|
||||
if(registers[0] != 252) return 0xFF;
|
||||
if(readcount<10) temp = nds.touchX;
|
||||
else temp = nds.touchY;
|
||||
if(readcount&1) return temp&0xFF;
|
||||
else return (temp>>8)&0xFF;
|
||||
}
|
||||
case 9:
|
||||
if(registers[0] == 3)
|
||||
{
|
||||
if(nds.isTouch)
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
if(registers[0] == 3)
|
||||
{
|
||||
if(nds.isTouch)
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
bool DSI_TSC::save_state(EMUFILE* os)
|
||||
{
|
||||
u32 version = 0;
|
||||
write32le(version,os);
|
||||
|
||||
write16le(selection,os);
|
||||
write32le(state,os);
|
||||
write32le(readcount,os);
|
||||
for(int i=0;i<ARRAY_SIZE(registers);i++)
|
||||
write8le(registers[i],os);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DSI_TSC::load_state(EMUFILE* is)
|
||||
{
|
||||
u32 version;
|
||||
read32le(&version,is);
|
||||
|
||||
read16le(&selection,is);
|
||||
read32le(&state,is);
|
||||
read32le(&readcount,is);
|
||||
for(int i=0;i<ARRAY_SIZE(registers);i++)
|
||||
read8le(®isters[i],is);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// NAND flash support (used in Made in Ore/WarioWare D.I.Y.)
|
||||
template<int PROCNUM>
|
||||
|
@ -3397,6 +3506,13 @@ u32 FASTCALL _MMU_ARM9_read32(u32 adr)
|
|||
|
||||
switch(adr)
|
||||
{
|
||||
case REG_DSIMODE:
|
||||
if(!CommonSettings.DSI) break;
|
||||
return 1;
|
||||
case 0x04004008:
|
||||
if(!CommonSettings.DSI) break;
|
||||
return 0x8000;
|
||||
|
||||
case REG_DISPA_DISPSTAT:
|
||||
break;
|
||||
|
||||
|
@ -3730,6 +3846,10 @@ void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val)
|
|||
}
|
||||
MMU.SPI_CNT = val;
|
||||
|
||||
//new code:
|
||||
if(!BIT11(MMU.SPI_CNT))
|
||||
MMU_new.dsi_tsc.reset_command();
|
||||
|
||||
T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPICNT >> 20) & 0xff], REG_SPICNT & 0xfff, val);
|
||||
}
|
||||
return;
|
||||
|
@ -3801,6 +3921,12 @@ void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val)
|
|||
|
||||
case 2:
|
||||
{
|
||||
if(CommonSettings.DSI)
|
||||
{
|
||||
val = MMU_new.dsi_tsc.write16(val);
|
||||
break;
|
||||
}
|
||||
|
||||
int channel = (MMU.SPI_CMD&0x70)>>4;
|
||||
//printf("%08X\n",channel);
|
||||
switch(channel)
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
/*
|
||||
Copyright (C) 2006 yopyop
|
||||
Copyright (C) 2007 shash
|
||||
Copyright (C) 2007-2010 DeSmuME team
|
||||
Copyright (C) 2007-2011 DeSmuME team
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME is free software; you can redistribute it and/or modify
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DeSmuME is distributed in the hope that it will be useful,
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MMU_H
|
||||
|
@ -419,6 +417,26 @@ struct MMU_struct
|
|||
nds_dscard dscard[2];
|
||||
};
|
||||
|
||||
|
||||
//everything in here is derived from libnds behaviours. no hardware tests yet
|
||||
class DSI_TSC
|
||||
{
|
||||
public:
|
||||
DSI_TSC();
|
||||
void reset_command();
|
||||
u16 write16(u16 val);
|
||||
bool save_state(EMUFILE* os);
|
||||
bool load_state(EMUFILE* is);
|
||||
|
||||
private:
|
||||
u16 read16();
|
||||
u16 selection;
|
||||
s32 state;
|
||||
s32 readcount;
|
||||
u8 registers[0x80];
|
||||
};
|
||||
|
||||
|
||||
//this contains things which can't be memzeroed because they are smarter classes
|
||||
struct MMU_struct_new
|
||||
{
|
||||
|
@ -428,6 +446,7 @@ struct MMU_struct_new
|
|||
TGXSTAT gxstat;
|
||||
SqrtController sqrt;
|
||||
DivController div;
|
||||
DSI_TSC dsi_tsc;
|
||||
|
||||
void write_dma(const int proc, const int size, const u32 adr, const u32 val);
|
||||
u32 read_dma(const int proc, const int size, const u32 adr);
|
||||
|
|
|
@ -490,6 +490,7 @@ extern struct TCommonSettings {
|
|||
, spu_captureMuted(false)
|
||||
, spu_advanced(false)
|
||||
, StylusPressure(50)
|
||||
, DSI(false)
|
||||
{
|
||||
strcpy(ARM9BIOS, "biosnds9.bin");
|
||||
strcpy(ARM7BIOS, "biosnds7.bin");
|
||||
|
@ -524,6 +525,7 @@ extern struct TCommonSettings {
|
|||
bool BootFromFirmware;
|
||||
struct NDS_fw_config_data InternalFirmConf;
|
||||
|
||||
bool DSI;
|
||||
bool DebugConsole;
|
||||
bool EnsataEmulation;
|
||||
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
/* Copyright (C) 2009-2011 DeSmuME team
|
||||
/*
|
||||
Copyright (C) 2009-2011 DeSmuME team
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME is free software; you can redistribute it and/or modify
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DeSmuME is distributed in the hope that it will be useful,
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//windows note: make sure this file gets compiled with _cdecl
|
||||
|
@ -53,6 +51,7 @@ CommandLine::CommandLine()
|
|||
, _slot1_fat_dir(NULL)
|
||||
, depth_threshold(-1)
|
||||
, debug_console(-1)
|
||||
, dsi_mode(-1)
|
||||
, load_slot(-1)
|
||||
, arm9_gdb_port(0)
|
||||
, arm7_gdb_port(0)
|
||||
|
@ -97,6 +96,7 @@ void CommandLine::loadCommonOptions()
|
|||
{ "slot1-fat-dir", 0, 0, G_OPTION_ARG_STRING, &_slot1_fat_dir, "Directory to scan for slot 1", "SLOT1_DIR"},
|
||||
{ "depth-threshold", 0, 0, G_OPTION_ARG_INT, &depth_threshold, "Depth comparison threshold (default 0)", "DEPTHTHRESHOLD"},
|
||||
{ "debug-console", 0, 0, G_OPTION_ARG_INT, &debug_console, "Behave as 8MB debug console (default 0)", "DEBUGCONSOLE"},
|
||||
{ "dsi-mode", 0, 0, G_OPTION_ARG_INT, &dsi_mode, "Behave as a DSi", "DSIMODE"},
|
||||
#ifndef _MSC_VER
|
||||
{ "disable-sound", 0, 0, G_OPTION_ARG_NONE, &disable_sound, "Disables the sound emulation", NULL},
|
||||
{ "disable-limiter", 0, 0, G_OPTION_ARG_NONE, &disable_limiter, "Disables the 60fps limiter", NULL},
|
||||
|
@ -136,7 +136,9 @@ bool CommandLine::parse(int argc,char **argv)
|
|||
if(depth_threshold != -1)
|
||||
CommonSettings.GFX3D_Zelda_Shadow_Depth_Hack = depth_threshold;
|
||||
if(debug_console != -1)
|
||||
CommonSettings.DebugConsole = true;
|
||||
CommonSettings.DebugConsole = (debug_console==1);
|
||||
if(dsi_mode != -1)
|
||||
CommonSettings.DSI = (dsi_mode==1);
|
||||
|
||||
//TODO MAX PRIORITY! change ARM9BIOS etc to be a std::string
|
||||
if(_bios_arm9) { CommonSettings.UseExtBIOS = true; strcpy(CommonSettings.ARM9BIOS,_bios_arm9); }
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
/* Copyright (C) 2009-2011 DeSmuME team
|
||||
/*
|
||||
Copyright (C) 2009-2011 DeSmuME team
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME is free software; you can redistribute it and/or modify
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DeSmuME is distributed in the hope that it will be useful,
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _COMMANDLINE_H_
|
||||
|
@ -40,6 +38,7 @@ public:
|
|||
int load_slot;
|
||||
int depth_threshold;
|
||||
int debug_console;
|
||||
int dsi_mode;
|
||||
std::string nds_file;
|
||||
std::string play_movie_file;
|
||||
std::string record_movie_file;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* Copyright (C) 2006 Theo Berkau
|
||||
Copyright (C) 2006-2010 DeSmuME team
|
||||
/*
|
||||
Copyright (C) 2006 Theo Berkau
|
||||
Copyright (C) 2006-2011 DeSmuME team
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -347,6 +348,9 @@
|
|||
#define eng_3D_CLIPMTX_RESULT 0x04000640
|
||||
#define eng_3D_VECMTX_RESULT 0x04000680
|
||||
|
||||
//DSI
|
||||
#define REG_DSIMODE 0x04004000
|
||||
|
||||
#define IPCFIFOCNT_SENDEMPTY 0x0001
|
||||
#define IPCFIFOCNT_SENDFULL 0x0002
|
||||
#define IPCFIFOCNT_SENDIRQEN 0x0004
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
/* Copyright (C) 2006 Normmatt
|
||||
/*
|
||||
Copyright (C) 2006 Normmatt
|
||||
Copyright (C) 2006 Theo Berkau
|
||||
Copyright (C) 2007 Pascal Giard
|
||||
Copyright (C) 2008-2010 DeSmuME team
|
||||
Copyright (C) 2008-2011 DeSmuME team
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -264,7 +265,7 @@ SFORMAT SF_MOVIE[]={
|
|||
|
||||
static void mmu_savestate(EMUFILE* os)
|
||||
{
|
||||
u32 version = 5;
|
||||
u32 version = 6;
|
||||
write32le(version,os);
|
||||
|
||||
//version 2:
|
||||
|
@ -286,6 +287,9 @@ static void mmu_savestate(EMUFILE* os)
|
|||
//version 4:
|
||||
MMU_new.sqrt.savestate(os);
|
||||
MMU_new.div.savestate(os);
|
||||
|
||||
//version 6:
|
||||
MMU_new.dsi_tsc.save_state(os);
|
||||
}
|
||||
|
||||
SFORMAT SF_WIFI[]={
|
||||
|
@ -455,9 +459,14 @@ static bool mmu_loadstate(EMUFILE* is, int size)
|
|||
MMU_new.gxstat.fifo_low = gxFIFO.size <= 127;
|
||||
MMU_new.gxstat.fifo_empty = gxFIFO.size == 0;
|
||||
|
||||
if(version < 5)
|
||||
if(version < 4) return ok;
|
||||
|
||||
MMU.reg_DISP3DCNT_bits = T1ReadWord(MMU.ARM9_REG,0x60);
|
||||
|
||||
if(version < 6) return ok;
|
||||
|
||||
MMU_new.dsi_tsc.load_state(is);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue