- add Expansion Memory Pak (need for NDS Browser (Opera) and other games);
- fix init GBAgame buffer;

bios:
- fix SWI 10h (BitUnPack - DSlinux dont freeze emu now);
This commit is contained in:
mtabachenko 2009-09-01 09:35:33 +00:00
parent 9c4a2dc20c
commit e1d70a6f76
11 changed files with 211 additions and 12 deletions

View File

@ -41,6 +41,7 @@ extern ADDONINTERFACE addonCFlash;
extern ADDONINTERFACE addonRumblePak; extern ADDONINTERFACE addonRumblePak;
extern ADDONINTERFACE addonGBAgame; extern ADDONINTERFACE addonGBAgame;
extern ADDONINTERFACE addonGuitarGrip; extern ADDONINTERFACE addonGuitarGrip;
extern ADDONINTERFACE addonExpMemory;
//extern ADDONINTERFACE addonExternalMic; //extern ADDONINTERFACE addonExternalMic;
ADDONINTERFACE addonList[NDS_ADDON_COUNT] = { ADDONINTERFACE addonList[NDS_ADDON_COUNT] = {
@ -48,7 +49,8 @@ ADDONINTERFACE addonList[NDS_ADDON_COUNT] = {
addonCFlash, addonCFlash,
addonRumblePak, addonRumblePak,
addonGBAgame, addonGBAgame,
addonGuitarGrip addonGuitarGrip,
addonExpMemory
}; };
ADDONINTERFACE addon = addonCFlash; // default none pak ADDONINTERFACE addon = addonCFlash; // default none pak

View File

@ -66,6 +66,7 @@ enum {
NDS_ADDON_RUMBLEPAK, // rumble pack NDS_ADDON_RUMBLEPAK, // rumble pack
NDS_ADDON_GBAGAME, // gba game in slot NDS_ADDON_GBAGAME, // gba game in slot
NDS_ADDON_GUITARGRIP, // Guitar Grip NDS_ADDON_GUITARGRIP, // Guitar Grip
NDS_ADDON_EXPMEMORY, // Memory Expansion
//NDS_ADDON_EXTERNALMIC, //NDS_ADDON_EXTERNALMIC,
NDS_ADDON_COUNT // use for counter addons - MUST TO BE LAST!!! NDS_ADDON_COUNT // use for counter addons - MUST TO BE LAST!!!
}; };

View File

@ -0,0 +1,151 @@
/* Copyright (C) 2006 yopyop
yopyop156@ifrance.com
yopyop156.ifrance.com
Copyright (C) 2009 CrazyMax
Copyright (C) 2009 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 "../addons.h"
#include "../mem.h"
#include <string.h>
#include "../MMU.h"
u8 *expMemory = NULL;
u32 expMemSize = 8 * 1024 * 1024; // 8Mb
#if 0
#define EXPINFO(...) INFO(__VA_ARGS__)
#else
#define EXPINFO(...)
#endif
static BOOL ExpMemory_init(void) { return (TRUE); }
static void ExpMemory_reset(void)
{
if (expMemory)
{
delete [] expMemory;
expMemory = NULL;
}
expMemory = new u8 [expMemSize];
memset(expMemory, 0xFF, expMemSize);
}
static void ExpMemory_close(void)
{
if (expMemory)
{
delete [] expMemory;
expMemory = NULL;
}
}
static void ExpMemory_config(void) {}
static void ExpMemory_write08(u32 adr, u8 val)
{
if (adr >= 0x09000000)
{
u32 offs = (adr - 0x09000000);
if (offs >= expMemSize) return;
T1WriteByte(expMemory, offs, val);
}
EXPINFO("ExpMemory: write 08 at 0x%08X = 0x%02X\n", adr, val);
}
static void ExpMemory_write16(u32 adr, u16 val)
{
if (adr >= 0x09000000)
{
u32 offs = (adr - 0x09000000);
if (offs >= expMemSize) return;
T1WriteWord(expMemory, offs, val);
}
EXPINFO("ExpMemory: write 16 at 0x%08X = 0x%04X\n", adr, val);
}
static void ExpMemory_write32(u32 adr, u32 val)
{
if (adr >= 0x09000000)
{
u32 offs = (adr - 0x09000000);
if (offs >= expMemSize) return;
T1WriteLong(expMemory, offs, val);
}
EXPINFO("ExpMemory: write 32 at 0x%08X = 0x%08X\n", adr, val);
}
static u8 ExpMemory_read08(u32 adr)
{
if (adr == 0x080000B2) return(0x96);
if (adr >= 0x09000000)
{
u32 offs = (adr - 0x09000000);
if (offs >= expMemSize) return (0);
return (T1ReadByte(expMemory, offs));
}
EXPINFO("ExpMemory: read 08 at 0x%08X\n", adr);
return (0);
}
static u16 ExpMemory_read16(u32 adr)
{
if (adr == 0x080000B6) return(0x2424);
if (adr == 0x080000BC) return(0x7FFF);
if (adr == 0x080000BE) return(0x0096);
if (adr == 0x0801FFFC) return(0x7FFF);
if (adr >= 0x09000000)
{
u32 offs = (adr - 0x09000000);
if (offs >= expMemSize) return (0);
return (T1ReadWord(expMemory, offs));
}
EXPINFO("ExpMemory: read 16 at 0x%08X\n", adr);
return (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);
}
static void ExpMemory_info(char *info) { strcpy(info, "Memory Expansion Pak"); }
ADDONINTERFACE addonExpMemory = {
"Memory Expansion Pak",
ExpMemory_init,
ExpMemory_reset,
ExpMemory_close,
ExpMemory_config,
ExpMemory_write08,
ExpMemory_write16,
ExpMemory_write32,
ExpMemory_read08,
ExpMemory_read16,
ExpMemory_read32,
ExpMemory_info};

View File

@ -38,12 +38,17 @@ static u8 *GBArom = NULL;
static BOOL GBAgame_init(void) static BOOL GBAgame_init(void)
{ {
GBArom = new u8 [GBA_SIZE];
return (TRUE); return (TRUE);
} }
static void GBAgame_reset(void) static void GBAgame_reset(void)
{ {
if (GBArom)
{
delete [] GBArom;
GBArom = NULL;
}
GBArom = new u8 [GBA_SIZE];
memset(GBArom, 0, GBA_SIZE); memset(GBArom, 0, GBA_SIZE);
if (!strlen(GBAgameName)) return; if (!strlen(GBAgameName)) return;
@ -80,8 +85,11 @@ static void GBAgame_reset(void)
static void GBAgame_close(void) static void GBAgame_close(void)
{ {
delete[] GBArom; if (GBArom)
GBArom = NULL; {
delete [] GBArom;
GBArom = NULL;
}
} }
static void GBAgame_config(void) {} static void GBAgame_config(void) {}

View File

@ -328,7 +328,7 @@ TEMPLATE static u32 divide()
cpu->R[0] = (u32)(num / dnum); cpu->R[0] = (u32)(num / dnum);
cpu->R[1] = (u32)(num % dnum); cpu->R[1] = (u32)(num % dnum);
cpu->R[3] = (u32) (((s32)cpu->R[0])<0 ? -(s32)cpu->R[0] : cpu->R[0]); cpu->R[3] = (u32) (((s32)cpu->R[0])<0 ? -(s32)cpu->R[0] : cpu->R[0]);
return 6; return 6;
} }
@ -857,17 +857,37 @@ TEMPLATE static u32 BitUnPack()
dest = cpu->R[1]; dest = cpu->R[1];
header = cpu->R[2]; header = cpu->R[2];
//INFO("swi bitunpack\n");
len = _MMU_read16<PROCNUM>(header); len = _MMU_read16<PROCNUM>(header);
// check address
bits = _MMU_read08<PROCNUM>(header+2); bits = _MMU_read08<PROCNUM>(header+2);
switch (bits)
{
case 1:
case 2:
case 4:
case 8:
break;
default: return (0); // error
}
dataSize = _MMU_read08<PROCNUM>(header+3);
switch (dataSize)
{
case 1:
case 2:
case 4:
case 8:
case 16:
case 32:
break;
default: return (0); // error
}
revbits = 8 - bits; revbits = 8 - bits;
// u32 value = 0; // u32 value = 0;
base = _MMU_read08<PROCNUM>(header+4); base = _MMU_read08<PROCNUM>(header+4);
addBase = (base & 0x80000000) ? 1 : 0; addBase = (base & 0x80000000) ? 1 : 0;
base &= 0x7fffffff; base &= 0x7fffffff;
dataSize = _MMU_read08<PROCNUM>(header+3);
//INFO("SWI10: bitunpack src 0x%08X dst 0x%08X hdr 0x%08X (src len %05i src bits %02i dst bits %02i)\n\n", source, dest, header, len, bits, dataSize);
data = 0; data = 0;
bitwritecount = 0; bitwritecount = 0;

View File

@ -132,7 +132,7 @@ public:
virtual size_t _fread(const void *ptr, size_t bytes){ virtual size_t _fread(const void *ptr, size_t bytes){
u32 remain = len-pos; u32 remain = len-pos;
u32 todo = std::min(remain,bytes); u32 todo = std::min<u32>(remain,bytes);
memcpy((void*)ptr,buf()+pos,todo); memcpy((void*)ptr,buf()+pos,todo);
pos += todo; pos += todo;
if(todo<bytes) if(todo<bytes)

View File

@ -1057,6 +1057,10 @@
RelativePath="..\addons\compactFlash.cpp" RelativePath="..\addons\compactFlash.cpp"
> >
</File> </File>
<File
RelativePath="..\addons\expMemory.cpp"
>
</File>
<File <File
RelativePath="..\addons\gbagame.cpp" RelativePath="..\addons\gbagame.cpp"
> >

View File

@ -832,6 +832,10 @@
RelativePath="..\addons\compactFlash.cpp" RelativePath="..\addons\compactFlash.cpp"
> >
</File> </File>
<File
RelativePath="..\addons\expMemory.cpp"
>
</File>
<File <File
RelativePath="..\addons\gbagame.cpp" RelativePath="..\addons\gbagame.cpp"
> >

View File

@ -183,6 +183,7 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="..\addons.cpp" /> <ClCompile Include="..\addons.cpp" />
<ClCompile Include="..\addons\compactFlash.cpp" /> <ClCompile Include="..\addons\compactFlash.cpp" />
<ClCompile Include="..\addons\expMemory.cpp" />
<ClCompile Include="..\addons\gbagame.cpp" /> <ClCompile Include="..\addons\gbagame.cpp" />
<ClCompile Include="..\addons\guitarGrip.cpp" /> <ClCompile Include="..\addons\guitarGrip.cpp" />
<ClCompile Include="..\addons\none.cpp" /> <ClCompile Include="..\addons\none.cpp" />

View File

@ -355,7 +355,9 @@ u32 GBAslot_IDDs[NDS_ADDON_COUNT] = {
IDD_GBASLOT_CFLASH, IDD_GBASLOT_CFLASH,
IDD_GBASLOT_RUMBLEPAK, IDD_GBASLOT_RUMBLEPAK,
IDD_GBASLOT_GBAGAME, IDD_GBASLOT_GBAGAME,
IDD_GBASLOT_GUITARGRIP IDD_GBASLOT_GUITARGRIP,
// todo
IDD_GBASLOT_NONE
}; };
DLGPROC GBAslot_Procs[NDS_ADDON_COUNT] = { DLGPROC GBAslot_Procs[NDS_ADDON_COUNT] = {
@ -363,7 +365,9 @@ DLGPROC GBAslot_Procs[NDS_ADDON_COUNT] = {
GbaSlotCFlash, GbaSlotCFlash,
GbaSlotRumblePak, GbaSlotRumblePak,
GbaSlotGBAgame, GbaSlotGBAgame,
GbaSlotGuitarGrip //todo
GbaSlotGuitarGrip,
GbaSlotNone
}; };
@ -504,6 +508,8 @@ void GBAslotDialog(HWND hwnd)
else else
needReset = false; needReset = false;
break; break;
case NDS_ADDON_EXPMEMORY:
break;
default: default:
return; return;
} }

View File

@ -1979,6 +1979,8 @@ int _main()
break; break;
case NDS_ADDON_GUITARGRIP: case NDS_ADDON_GUITARGRIP:
break; break;
case NDS_ADDON_EXPMEMORY:
break;
default: default:
addon_type = NDS_ADDON_NONE; addon_type = NDS_ADDON_NONE;
break; break;