lay base for SD shit
This commit is contained in:
parent
566a8df6cd
commit
d4dd97638d
|
@ -106,6 +106,8 @@
|
|||
<Unit filename="src/DSiCrypto.h" />
|
||||
<Unit filename="src/DSi_I2C.cpp" />
|
||||
<Unit filename="src/DSi_I2C.h" />
|
||||
<Unit filename="src/DSi_SD.cpp" />
|
||||
<Unit filename="src/DSi_SD.h" />
|
||||
<Unit filename="src/FIFO.h" />
|
||||
<Unit filename="src/GPU.cpp" />
|
||||
<Unit filename="src/GPU.h" />
|
||||
|
|
67
src/DSi.cpp
67
src/DSi.cpp
|
@ -26,6 +26,7 @@
|
|||
#include "Platform.h"
|
||||
|
||||
#include "DSi_I2C.h"
|
||||
#include "DSi_SD.h"
|
||||
|
||||
|
||||
namespace NDS
|
||||
|
@ -56,6 +57,27 @@ u32 NWRAMStart[2][3];
|
|||
u32 NWRAMEnd[2][3];
|
||||
u32 NWRAMMask[2][3];
|
||||
|
||||
DSi_SD* SDMMC;
|
||||
DSi_SD* SDIO;
|
||||
|
||||
|
||||
bool Init()
|
||||
{
|
||||
if (!DSi_I2C::Init()) return false;
|
||||
|
||||
SDMMC = new DSi_SD(0);
|
||||
SDIO = new DSi_SD(1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeInit()
|
||||
{
|
||||
DSi_I2C::DeInit();
|
||||
|
||||
delete SDMMC;
|
||||
delete SDIO;
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
|
@ -67,6 +89,9 @@ void Reset()
|
|||
NDS::ARM7->JumpTo(BootAddr[1]);
|
||||
|
||||
DSi_I2C::Reset();
|
||||
|
||||
SDMMC->Reset();
|
||||
SDIO->Reset();
|
||||
}
|
||||
|
||||
bool LoadBIOS()
|
||||
|
@ -904,6 +929,15 @@ u16 ARM7IORead16(u32 addr)
|
|||
case 0x04004006: return 0; // JTAG register
|
||||
}
|
||||
|
||||
if (addr >= 0x04004800 && addr < 0x04004A00)
|
||||
{
|
||||
return SDMMC->Read(addr);
|
||||
}
|
||||
if (addr >= 0x04004A00 && addr < 0x04004C00)
|
||||
{
|
||||
return SDIO->Read(addr);
|
||||
}
|
||||
|
||||
return NDS::ARM7IORead16(addr);
|
||||
}
|
||||
|
||||
|
@ -917,6 +951,15 @@ u32 ARM7IORead32(u32 addr)
|
|||
case 0x04004008: return 0x80000000; // HAX
|
||||
}
|
||||
|
||||
if (addr >= 0x04004800 && addr < 0x04004A00)
|
||||
{
|
||||
return SDMMC->Read(addr) | (SDMMC->Read(addr+2) << 16);
|
||||
}
|
||||
if (addr >= 0x04004A00 && addr < 0x04004C00)
|
||||
{
|
||||
return SDIO->Read(addr) | (SDIO->Read(addr+2) << 16);
|
||||
}
|
||||
|
||||
return NDS::ARM7IORead32(addr);
|
||||
}
|
||||
|
||||
|
@ -939,6 +982,17 @@ void ARM7IOWrite16(u32 addr, u16 val)
|
|||
case 0x0400021C: NDS::IF2 &= ~(val & 0x7FF7); NDS::UpdateIRQ(1); return;
|
||||
}
|
||||
|
||||
if (addr >= 0x04004800 && addr < 0x04004A00)
|
||||
{
|
||||
SDMMC->Write(addr, val);
|
||||
return;
|
||||
}
|
||||
if (addr >= 0x04004A00 && addr < 0x04004C00)
|
||||
{
|
||||
SDIO->Write(addr, val);
|
||||
return;
|
||||
}
|
||||
|
||||
return NDS::ARM7IOWrite16(addr, val);
|
||||
}
|
||||
|
||||
|
@ -950,6 +1004,19 @@ void ARM7IOWrite32(u32 addr, u32 val)
|
|||
case 0x0400021C: NDS::IF2 &= ~(val & 0x7FF7); NDS::UpdateIRQ(1); return;
|
||||
}
|
||||
|
||||
if (addr >= 0x04004800 && addr < 0x04004A00)
|
||||
{
|
||||
SDMMC->Write(addr, val & 0xFFFF);
|
||||
SDMMC->Write(addr+2, val >> 16);
|
||||
return;
|
||||
}
|
||||
if (addr >= 0x04004A00 && addr < 0x04004C00)
|
||||
{
|
||||
SDIO->Write(addr, val & 0xFFFF);
|
||||
SDIO->Write(addr+2, val >> 16);
|
||||
return;
|
||||
}
|
||||
|
||||
return NDS::ARM7IOWrite32(addr, val);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
namespace DSi
|
||||
{
|
||||
|
||||
bool Init();
|
||||
void DeInit();
|
||||
void Reset();
|
||||
|
||||
bool LoadBIOS();
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
Copyright 2016-2019 Arisotura
|
||||
|
||||
This file is part of melonDS.
|
||||
|
||||
melonDS 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 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
melonDS 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 melonDS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "DSi.h"
|
||||
#include "DSi_SD.h"
|
||||
|
||||
|
||||
DSi_SD::DSi_SD(u32 num)
|
||||
{
|
||||
Num = num;
|
||||
}
|
||||
|
||||
DSi_SD::~DSi_SD()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
void DSi_SD::Reset()
|
||||
{
|
||||
if (Num == 0)
|
||||
{
|
||||
PortSelect = 0x0200; // CHECKME
|
||||
}
|
||||
else
|
||||
{
|
||||
PortSelect = 0x0100; // CHECKME
|
||||
}
|
||||
}
|
||||
|
||||
void DSi_SD::DoSavestate(Savestate* file)
|
||||
{
|
||||
// TODO!
|
||||
}
|
||||
|
||||
|
||||
u16 DSi_SD::Read(u32 addr)
|
||||
{
|
||||
switch (addr & 0x1FF)
|
||||
{
|
||||
case 0x002: return PortSelect & 0x030F;
|
||||
}
|
||||
|
||||
printf("unknown %s read %08X\n", Num?"SDIO":"SD/MMC", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DSi_SD::Write(u32 addr, u16 val)
|
||||
{
|
||||
switch (addr & 0x1FF)
|
||||
{
|
||||
case 0x002: PortSelect = val; return;
|
||||
}
|
||||
|
||||
printf("unknown %s write %08X %04X\n", Num?"SDIO":"SD/MMC", addr, val);
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
Copyright 2016-2019 Arisotura
|
||||
|
||||
This file is part of melonDS.
|
||||
|
||||
melonDS 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 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
melonDS 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 melonDS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#ifndef DSI_SD_H
|
||||
#define DSI_SD_H
|
||||
|
||||
class DSi_SD
|
||||
{
|
||||
public:
|
||||
DSi_SD(u32 num);
|
||||
~DSi_SD();
|
||||
|
||||
void Reset();
|
||||
|
||||
void DoSavestate(Savestate* file);
|
||||
|
||||
u16 Read(u32 addr);
|
||||
void Write(u32 addr, u16 val);
|
||||
|
||||
private:
|
||||
u32 Num;
|
||||
|
||||
u16 PortSelect;
|
||||
};
|
||||
|
||||
#endif // DSI_SD_H
|
|
@ -178,6 +178,8 @@ bool Init()
|
|||
if (!RTC::Init()) return false;
|
||||
if (!Wifi::Init()) return false;
|
||||
|
||||
if (!DSi::Init()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -198,6 +200,8 @@ void DeInit()
|
|||
SPI::DeInit();
|
||||
RTC::DeInit();
|
||||
Wifi::DeInit();
|
||||
|
||||
DSi::DeInit();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
#define MELONDS_VERSION "0.8.1"
|
||||
#define MELONDS_VERSION "0.8.1-DSi"
|
||||
|
||||
#define MELONDS_URL "http://melonds.kuribo64.net/"
|
||||
|
||||
|
|
Loading…
Reference in New Issue