- separated slot1 handler to new files;
- fix boot games from firmware;
This commit is contained in:
mtabachenko 2010-08-06 09:39:36 +00:00
parent 8f090d0499
commit dbea6bfe75
13 changed files with 198 additions and 94 deletions

View File

@ -33,6 +33,7 @@ libdesmume_a_SOURCES = \
render3D.cpp render3D.h \
rtc.cpp rtc.h \
saves.cpp saves.h \
slot1.cpp slot1.h \
SPU.cpp SPU.h \
matrix.cpp matrix.h \
gfx3d.cpp gfx3d.h \

View File

@ -1,5 +1,4 @@
/* Copyright (C) 2009 CrazyMax
Copyright (C) 2009 DeSmuME team
/* Copyright (C) 2009-2010 DeSmuME team
This file is part of DeSmuME
@ -76,45 +75,3 @@ BOOL addonsChangePak(NDS_ADDON_TYPE type)
addon_type = type;
return addon.init();
}
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
extern ADDONINTERFACE slot1None;
extern ADDONINTERFACE slot1Retail;
extern ADDONINTERFACE slot1R4;
ADDONINTERFACE slot1List[NDS_SLOT1_COUNT] = {
slot1None,
slot1Retail,
slot1R4
};
ADDONINTERFACE slot1_device = slot1Retail; //default for frontends that dont even configure this
u8 slot1_device_type = NDS_SLOT1_RETAIL;
BOOL slot1Init()
{
return slot1_device.init();
}
void slot1Close()
{
slot1_device.close();
}
void slot1Reset()
{
slot1_device.reset();
}
BOOL slot1Change(NDS_SLOT1_TYPE changeToType)
{
printf("slot1Change to: %d\n", changeToType);
if (changeToType > NDS_SLOT1_COUNT || changeToType < 0) return FALSE;
slot1_device.close();
slot1_device_type = changeToType;
slot1_device = slot1List[slot1_device_type];
return slot1_device.init();
}

View File

@ -1,5 +1,4 @@
/* Copyright (C) 2009 CrazyMax
Copyright (C) 2009-2010 DeSmuME team
/* Copyright (C) 2009-2010 DeSmuME team
This file is part of DeSmuME
@ -93,20 +92,4 @@ extern BOOL addonsChangePak(NDS_ADDON_TYPE type); // change current adddon
extern void guitarGrip_setKey(bool green, bool red, bool yellow, bool blue); // Guitar grip keys
extern void piano_setKey(bool c, bool cs, bool d, bool ds, bool e, bool f, bool fs, bool g, bool gs, bool a, bool as, bool b, bool hic); //piano keys
extern ADDONINTERFACE slot1_device; // current slot1 device
enum NDS_SLOT1_TYPE
{
NDS_SLOT1_NONE,
NDS_SLOT1_RETAIL,
NDS_SLOT1_R4,
NDS_SLOT1_COUNT // use for counter addons - MUST TO BE LAST!!!
};
BOOL slot1Init();
void slot1Close();
void slot1Reset();
BOOL slot1Change(NDS_SLOT1_TYPE type); // change current adddon
#endif //__ADDONS_H__

View File

@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "../addons.h"
#include "../slot1.h"
static void slot1_info(char *info) { strcpy(info, "Slot1 no-card emulation (card ejected!)"); }
static void slot1_config(void) {}
@ -29,25 +29,25 @@ static void slot1_reset() {}
static void slot1_close() {}
static void slot1_write08(u32 adr, u8 val) {}
static void slot1_write16(u32 adr, u16 val) {}
static void slot1_write32(u32 adr, u32 val) {}
static void slot1_write08(u8 PROCNUM, u32 adr, u8 val) {}
static void slot1_write16(u8 PROCNUM, u32 adr, u16 val) {}
static void slot1_write32(u8 PROCNUM, u32 adr, u32 val) {}
static u8 slot1_read08(u32 adr)
static u8 slot1_read08(u8 PROCNUM, u32 adr)
{
return 0xFF;
}
static u16 slot1_read16(u32 adr)
static u16 slot1_read16(u8 PROCNUM, u32 adr)
{
return 0xFFFF;
}
static u32 slot1_read32(u32 adr)
static u32 slot1_read32(u8 PROCNUM, u32 adr)
{
return 0xFFFFFFFF;
}
ADDONINTERFACE slot1None = {
SLOT1INTERFACE slot1None = {
"Slot1None",
slot1_init,
slot1_reset,

View File

@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "../addons.h"
#include "../slot1.h"
#include "../registers.h"
#include "../MMU.h"
#include "../NDSSystem.h"
@ -53,8 +53,8 @@ static void reset() {}
static void close() {}
static void write08(u32 adr, u8 val) {}
static void write16(u32 adr, u16 val) {}
static void write08(u8 PROCNUM, u32 adr, u8 val) {}
static void write16(u8 PROCNUM, u32 adr, u16 val) {}
static void write32_GCROMCTRL(u32 val)
{
@ -137,7 +137,7 @@ static void write32_GCDATAIN(u32 val)
}*/
}
static void write32(u32 adr, u32 val)
static void write32(u8 PROCNUM, u32 adr, u32 val)
{
switch(adr)
{
@ -150,11 +150,11 @@ static void write32(u32 adr, u32 val)
}
}
static u8 read08(u32 adr)
static u8 read08(u8 PROCNUM, u32 adr)
{
return 0xFF;
}
static u16 read16(u32 adr)
static u16 read16(u8 PROCNUM, u32 adr)
{
return 0xFFFF;
}
@ -205,7 +205,7 @@ static u32 read32_GCDATAIN()
} //read32_GCDATAIN
static u32 read32(u32 adr)
static u32 read32(u8 PROCNUM, u32 adr)
{
switch(adr)
{
@ -216,7 +216,7 @@ static u32 read32(u32 adr)
}
}
ADDONINTERFACE slot1R4 = {
SLOT1INTERFACE slot1R4 = {
"Slot1R4",
init,
reset,

View File

@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "../addons.h"
#include "../slot1.h"
#include "../registers.h"
#include "../MMU.h"
#include "../NDSSystem.h"
@ -32,12 +32,12 @@ static void reset() {}
static void close() {}
static void write08(u32 adr, u8 val) {}
static void write16(u32 adr, u16 val) {}
static void write08(u8 PROCNUM, u32 adr, u8 val) {}
static void write16(u8 PROCNUM, u32 adr, u16 val) {}
static void write32_GCROMCTRL(u32 val)
static void write32_GCROMCTRL(u8 PROCNUM, u32 val)
{
nds_dscard& card = MMU.dscard[0];
nds_dscard& card = MMU.dscard[PROCNUM];
switch(card.command[0])
{
@ -46,34 +46,41 @@ static void write32_GCROMCTRL(u32 val)
card.address = (card.command[1] << 24) | (card.command[2] << 16) | (card.command[3] << 8) | card.command[4];
card.transfer_count = 0x80;
break;
case 0xB8: // Chip ID
card.address = 0;
card.transfer_count = 1;
break;
default:
card.address = 0;
card.transfer_count = 0;
break;
}
}
static void write32(u32 adr, u32 val)
static void write32(u8 PROCNUM, u32 adr, u32 val)
{
switch(adr)
{
case REG_GCROMCTRL:
write32_GCROMCTRL(val);
write32_GCROMCTRL(PROCNUM, val);
break;
}
}
static u8 read08(u32 adr)
static u8 read08(u8 PROCNUM, u32 adr)
{
return 0xFF;
}
static u16 read16(u32 adr)
static u16 read16(u8 PROCNUM, u32 adr)
{
return 0xFFFF;
}
static u32 read32_GCDATAIN()
static u32 read32_GCDATAIN(u8 PROCNUM)
{
nds_dscard& card = MMU.dscard[0];
nds_dscard& card = MMU.dscard[PROCNUM];
switch(card.command[0])
{
@ -118,10 +125,8 @@ static u32 read32_GCDATAIN()
DEBUG_Notify.ReadBeyondEndOfCart(card.address,gameInfo.romsize);
return 0xFFFFFFFF;
}
else
//but, this is actually handled by the cart rom buffer being oversized and full of 0xFF.
//is this a good idea? We think so.
return T1ReadLong(MMU.CART_ROM, card.address & MMU.CART_ROM_MASK);
}
break;
@ -130,19 +135,19 @@ static u32 read32_GCDATAIN()
} //switch(card.command[0])
} //read32_GCDATAIN
static u32 read32(u32 adr)
static u32 read32(u8 PROCNUM, u32 adr)
{
switch(adr)
{
case REG_GCDATAIN:
return read32_GCDATAIN();
return read32_GCDATAIN(PROCNUM);
default:
return 0;
}
}
ADDONINTERFACE slot1Retail = {
SLOT1INTERFACE slot1Retail = {
"Slot1Retail",
init,
reset,

View File

@ -28,6 +28,7 @@
#include "types.h"
#include "movie.h"
#include "addons.h"
#include "slot1.h"
#include "NDSSystem.h"
#include "utils/xstring.h"

59
desmume/src/slot1.cpp Normal file
View File

@ -0,0 +1,59 @@
/* Copyright (C) 2010 DeSmuME team
This file is part of DeSmuME
DeSmuME 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
(at your option) any later version.
DeSmuME 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
*/
#include "slot1.h"
#include <string>
extern SLOT1INTERFACE slot1None;
extern SLOT1INTERFACE slot1Retail;
extern SLOT1INTERFACE slot1R4;
SLOT1INTERFACE slot1List[NDS_SLOT1_COUNT] = {
slot1None,
slot1Retail,
slot1R4
};
SLOT1INTERFACE slot1_device = slot1Retail; //default for frontends that dont even configure this
u8 slot1_device_type = NDS_SLOT1_RETAIL;
BOOL slot1Init()
{
return slot1_device.init();
}
void slot1Close()
{
slot1_device.close();
}
void slot1Reset()
{
slot1_device.reset();
}
BOOL slot1Change(NDS_SLOT1_TYPE changeToType)
{
printf("slot1Change to: %d\n", changeToType);
if (changeToType > NDS_SLOT1_COUNT || changeToType < 0) return FALSE;
slot1_device.close();
slot1_device_type = changeToType;
slot1_device = slot1List[slot1_device_type];
return slot1_device.init();
}

74
desmume/src/slot1.h Normal file
View File

@ -0,0 +1,74 @@
/* Copyright (C) 2010 DeSmuME team
This file is part of DeSmuME
DeSmuME 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
(at your option) any later version.
DeSmuME 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
*/
#ifndef __SLOT1_H__
#define __SLOT1_H__
#include "common.h"
#include "types.h"
#include "debug.h"
struct SLOT1INTERFACE
{
// The name of the plugin, this name will appear in the plugins list
const char * name;
//called once when the plugin starts up
BOOL (*init)(void);
//called when the emulator resets
void (*reset)(void);
//called when the plugin shuts down
void (*close)(void);
//called when the user configurating plugin
void (*config)(void);
//called when the emulator write to addon
void (*write08)(u8 PROCNUM, u32 adr, u8 val);
void (*write16)(u8 PROCNUM, u32 adr, u16 val);
void (*write32)(u8 PROCNUM, u32 adr, u32 val);
//called when the emulator read from addon
u8 (*read08)(u8 PROCNUM, u32 adr);
u16 (*read16)(u8 PROCNUM, u32 adr);
u32 (*read32)(u8 PROCNUM, u32 adr);
//called when the user get info about addon pak (description)
void (*info)(char *info);
};
extern SLOT1INTERFACE slot1_device; // current slot1 device
enum NDS_SLOT1_TYPE
{
NDS_SLOT1_NONE,
NDS_SLOT1_RETAIL,
NDS_SLOT1_R4,
NDS_SLOT1_COUNT // use for counter addons - MUST TO BE LAST!!!
};
extern BOOL slot1Init();
extern void slot1Close();
extern void slot1Reset();
extern BOOL slot1Change(NDS_SLOT1_TYPE type); // change current adddon
#endif //__ADDONS_H__

View File

@ -2094,6 +2094,14 @@
RelativePath="..\shaders.h"
>
</File>
<File
RelativePath="..\slot1.cpp"
>
</File>
<File
RelativePath="..\slot1.h"
>
</File>
<File
RelativePath="..\SPU.cpp"
>

View File

@ -902,6 +902,14 @@
RelativePath="..\shaders.h"
>
</File>
<File
RelativePath="..\slot1.cpp"
>
</File>
<File
RelativePath="..\slot1.h"
>
</File>
<File
RelativePath="..\softrender.h"
>

View File

@ -465,6 +465,7 @@
<ClCompile Include="..\ROMReader.cpp" />
<ClCompile Include="..\rtc.cpp" />
<ClCompile Include="..\saves.cpp" />
<ClCompile Include="..\slot1.cpp" />
<ClCompile Include="..\SPU.cpp" />
<ClCompile Include="..\texcache.cpp" />
<ClCompile Include="..\thumb_instructions.cpp" />
@ -585,6 +586,7 @@
<ClInclude Include="..\rtc.h" />
<ClInclude Include="..\saves.h" />
<ClInclude Include="..\shaders.h" />
<ClInclude Include="..\slot1.h" />
<ClInclude Include="..\SPU.h" />
<ClInclude Include="..\texcache.h" />
<ClInclude Include="..\thumb_instructions.h" />

View File

@ -144,6 +144,9 @@
<ClCompile Include="..\saves.cpp">
<Filter>Core</Filter>
</ClCompile>
<ClCompile Include="..\slot1.cpp">
<Filter>Core</Filter>
</ClCompile>
<ClCompile Include="..\SPU.cpp">
<Filter>Core</Filter>
</ClCompile>
@ -512,6 +515,9 @@
<ClInclude Include="..\shaders.h">
<Filter>Core</Filter>
</ClInclude>
<ClInclude Include="..\slot1.h">
<Filter>Core</Filter>
</ClInclude>
<ClInclude Include="..\SPU.h">
<Filter>Core</Filter>
</ClInclude>