Skip to content

Commit

Permalink
merge crap
Browse files Browse the repository at this point in the history
  • Loading branch information
Hydr8gon committed Jan 5, 2019
2 parents c9331a6 + 4b6ebd0 commit c0340a8
Show file tree
Hide file tree
Showing 44 changed files with 1,075 additions and 612 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ elseif (WIN32)
src/libui_sdl/libui/windows/drawtext.cpp
src/libui_sdl/libui/windows/dwrite.cpp
src/libui_sdl/libui/windows/editablecombo.cpp
#src/libui_sdl/libui/windows/entry.cpp
src/libui_sdl/libui/windows/entry.cpp
src/libui_sdl/libui/windows/events.cpp
src/libui_sdl/libui/windows/fontbutton.cpp
src/libui_sdl/libui/windows/fontdialog.cpp
Expand Down Expand Up @@ -168,10 +168,12 @@ elseif (WIN32)
LINK_LIBRARIES("dwrite")
LINK_LIBRARIES("usp10")
LINK_LIBRARIES("ws2_32")
LINK_LIBRARIES("uxtheme")
endif (UNIX)

find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
string(STRIP ${SDL2_LIBRARIES} SDL2_LIBRARIES)
link_libraries(${SDL2_LIBRARIES})

add_executable(${PROJECT_WX} ${SOURCES})
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h2 align="center"><b>melonDS</b></h2>
<p align="center">
<a href="http://melonds.kuribo64.net/" alt="melonDS website"><img src="https://img.shields.io/badge/website-melonds.kuribo64.net-%2331352e.svg"></a>
<a href="http://melonds.kuribo64.net/downloads.php" alt="Release: 0.7.1"><img src="https://img.shields.io/badge/release-0.7.1-%235c913b.svg"></a>
<a href="http://melonds.kuribo64.net/downloads.php" alt="Release: 0.7.2"><img src="https://img.shields.io/badge/release-0.7.2-%235c913b.svg"></a>
<a href="https://www.gnu.org/licenses/gpl-3.0" alt="License: GPLv3"><img src="https://img.shields.io/badge/License-GPL%20v3-%23ff554d.svg"></a>
<a href="https://kiwiirc.com/client/irc.badnik.net/?nick=IRC-Source_?#melonds" alt="IRC channel: #melonds"><img src="https://img.shields.io/badge/IRC%20chat-%23melonds-%23dd2e44.svg"></a>
</p>
Expand Down Expand Up @@ -35,13 +35,23 @@ As for the rest, the interface should be pretty straightforward. If you have a q

### Linux:

* Install dependencies:

```sh
sudo apt-get install libpcap0.8-dev libcurl4-gnutls-dev libsdl2-dev gtk+-3.0
```

* Compile:

```sh
mkdir -p build
cd build
cmake ..
make
```



### Windows:

* use CodeBlocks
Expand Down
8 changes: 4 additions & 4 deletions melon.rc
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@

//include version information in .exe, modify these values to match your needs
1 VERSIONINFO
FILEVERSION 0,7,2,0
PRODUCTVERSION 0,7,2,0
FILEVERSION 0,7,3,0
PRODUCTVERSION 0,7,3,0
FILETYPE VFT_APP
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "CompanyName", "Melon Factory of Kuribo64"
VALUE "FileVersion", "0.7.2"
VALUE "FileVersion", "0.7.3"
VALUE "FileDescription", "DS emulator, sorta. also 1st quality melon."
VALUE "InternalName", "SDnolem"
VALUE "LegalCopyright", "2016-2019 StapleButter & co."
VALUE "LegalTrademarks", ""
VALUE "OriginalFilename", "zafkflzdasd.exe"
VALUE "ProductName", "melonDS"
VALUE "ProductVersion", "0.7.2"
VALUE "ProductVersion", "0.7.3"
}
}
BLOCK "VarFileInfo"
Expand Down
8 changes: 7 additions & 1 deletion melonDS.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
<Add library="advapi32" />
<Add library="wsock32" />
<Add library="oleacc" />
<Add library="ole32" />
<Add library="usp10" />
<Add library="gdi32" />
<Add library="d2d1" />
<Add library="dwrite" />
<Add library="uxtheme" />
<Add library="ole32" />
<Add library="iphlpapi" />
<Add library="user32" />
</Linker>
</Target>
<Target title="Release Windows">
Expand Down Expand Up @@ -61,6 +63,8 @@
<Add library="d2d1" />
<Add library="dwrite" />
<Add library="uxtheme" />
<Add library="iphlpapi" />
<Add library="user32" />
</Linker>
</Target>
<Target title="DebugFast Windows">
Expand Down Expand Up @@ -89,6 +93,8 @@
<Add library="d2d1" />
<Add library="dwrite" />
<Add library="uxtheme" />
<Add library="iphlpapi" />
<Add library="user32" />
</Linker>
</Target>
</Build>
Expand Down
Binary file modified romlist.bin
Binary file not shown.
113 changes: 33 additions & 80 deletions src/ARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ ARM::ARM(u32 num)
{
// well uh
Num = num;

SetClockShift(0); // safe default
}

ARM::~ARM()
Expand Down Expand Up @@ -110,7 +108,7 @@ void ARM::DoSavestate(Savestate* file)
file->Section((char*)(Num ? "ARM7" : "ARM9"));

file->Var32((u32*)&Cycles);
file->Var32((u32*)&CyclesToRun);
//file->Var32((u32*)&CyclesToRun);
file->Var32(&Halted);

file->VarArray(R, 16*sizeof(u32));
Expand Down Expand Up @@ -176,14 +174,14 @@ void ARMv5::JumpTo(u32 addr, bool restorecpsr)
//if (addr == 0x0201764C) printf("capture test %d: R1=%08X\n", R[6], R[1]);
//if (addr == 0x020175D8) printf("capture test %d: res=%08X\n", R[6], R[0]);
// R0=DMA# R1=src R2=size
//if (addr==0x02019A88) printf("[%08X] [%03d] GX FIFO CMD %08X\n", R[15], NDS::ARM9Read16(0x04000006), R[0]);
//if (addr==0x02022A5C) printf("[%08X] [%03d|%04X] RENDE SHITO %08X\n", R[15], NDS::ARM9Read16(0x04000006), NDS::ARM9Read16(0x04000304), R[0]);

u32 oldregion = R[15] >> 24;
u32 newregion = addr >> 24;

RegionCodeCycles = MemTimings[addr >> 12][0];

s32 cycles;

if (addr & 0x1)
{
addr &= ~0x1;
Expand All @@ -195,15 +193,16 @@ void ARMv5::JumpTo(u32 addr, bool restorecpsr)
// doesn't matter if we put garbage in the MSbs there
if (addr & 0x2)
{
NextInstr[0] = CodeRead32(addr-2) >> 16;
NextInstr[1] = CodeRead32(addr+2);
cycles = CodeCycles * 2;
NextInstr[0] = CodeRead32(addr-2, true) >> 16;
Cycles += CodeCycles;
NextInstr[1] = CodeRead32(addr+2, false);
Cycles += CodeCycles;
}
else
{
NextInstr[0] = CodeRead32(addr);
NextInstr[0] = CodeRead32(addr, true);
NextInstr[1] = NextInstr[0] >> 16;
cycles = CodeCycles;
Cycles += CodeCycles;
}

CPSR |= 0x20;
Expand All @@ -215,9 +214,10 @@ void ARMv5::JumpTo(u32 addr, bool restorecpsr)

if (newregion != oldregion) SetupCodeMem(addr);

NextInstr[0] = CodeRead32(addr);
NextInstr[1] = CodeRead32(addr+4);
cycles = CodeCycles * 2;
NextInstr[0] = CodeRead32(addr, true);
Cycles += CodeCycles;
NextInstr[1] = CodeRead32(addr+4, false);
Cycles += CodeCycles;

CPSR &= ~0x20;
}
Expand All @@ -231,8 +231,6 @@ void ARMv5::JumpTo(u32 addr, bool restorecpsr)
PrefetchAbort();
return;
}*/

Cycles += cycles;
}

void ARMv4::JumpTo(u32 addr, bool restorecpsr)
Expand Down Expand Up @@ -450,7 +448,7 @@ void ARMv5::DataAbort()
JumpTo(ExceptionBase + 0x10);
}

s32 ARMv5::Execute()
void ARMv5::Execute()
{
if (Halted)
{
Expand All @@ -466,19 +464,12 @@ s32 ARMv5::Execute()
}
else
{
Cycles = CyclesToRun;
#ifdef DEBUG_CHECK_DESYNC
NDS::dbg_CyclesARM9 += (CyclesToRun >> ClockShift);
#endif // DEBUG_CHECK_DESYNC
//NDS::RunTightTimers(0, CyclesToRun >> ClockShift);
return Cycles;
NDS::ARM9Timestamp = NDS::ARM9Target;
return;
}
}

Cycles = 0;
s32 lastcycles = 0;

while (Cycles < CyclesToRun)
while (NDS::ARM9Timestamp < NDS::ARM9Target)
{
if (CPSR & 0x20) // THUMB
{
Expand All @@ -487,7 +478,7 @@ s32 ARMv5::Execute()
CurInstr = NextInstr[0];
NextInstr[0] = NextInstr[1];
if (R[15] & 0x2) { NextInstr[1] >>= 16; CodeCycles = 0; }
else NextInstr[1] = CodeRead32(R[15]);
else NextInstr[1] = CodeRead32(R[15], false);

// actually execute
u32 icode = (CurInstr >> 6) & 0x3FF;
Expand All @@ -499,7 +490,7 @@ s32 ARMv5::Execute()
R[15] += 4;
CurInstr = NextInstr[0];
NextInstr[0] = NextInstr[1];
NextInstr[1] = CodeRead32(R[15]);
NextInstr[1] = CodeRead32(R[15], false);

// actually execute
if (CheckCondition(CurInstr >> 28))
Expand All @@ -515,19 +506,12 @@ s32 ARMv5::Execute()
AddCycles_C();
}

//s32 diff = Cycles - lastcycles;arm9timer+=(diff>>1);
//NDS::RunTightTimers(0, diff >> ClockShift);
//lastcycles = Cycles - (diff & ClockDiffMask);

// TODO optimize this shit!!!
if (Halted)
{
if (Halted == 1 && Cycles < CyclesToRun)
if (Halted == 1 && NDS::ARM9Timestamp < NDS::ARM9Target)
{
//s32 diff = CyclesToRun - Cycles;
Cycles = CyclesToRun;
//NDS::RunTightTimers(0, diff >> ClockShift);
//arm9timer += (diff>>1);
NDS::ARM9Timestamp = NDS::ARM9Target;
}
break;
}
Expand All @@ -536,24 +520,16 @@ s32 ARMv5::Execute()
if (NDS::IME[0] & 0x1)
TriggerIRQ();
}

NDS::ARM9Timestamp += Cycles;
Cycles = 0;
}

if (Halted == 2)
Halted = 0;

/*if (Cycles > lastcycles)
{
//s32 diff = Cycles - lastcycles;arm9timer+=(diff>>1);
//NDS::RunTightTimers(0, diff >> ClockShift);
}*/
#ifdef DEBUG_CHECK_DESYNC
NDS::dbg_CyclesARM9 += (Cycles >> ClockShift);
#endif // DEBUG_CHECK_DESYNC

return Cycles;
}

s32 ARMv4::Execute()
void ARMv4::Execute()
{
if (Halted)
{
Expand All @@ -569,19 +545,12 @@ s32 ARMv4::Execute()
}
else
{
Cycles = CyclesToRun;
#ifdef DEBUG_CHECK_DESYNC
NDS::dbg_CyclesARM7 += CyclesToRun;
#endif // DEBUG_CHECK_DESYNC
//NDS::RunTightTimers(1, CyclesToRun);
return Cycles;
NDS::ARM7Timestamp = NDS::ARM7Target;
return;
}
}

Cycles = 0;
s32 lastcycles = 0;

while (Cycles < CyclesToRun)
while (NDS::ARM7Timestamp < NDS::ARM7Target)
{
if (CPSR & 0x20) // THUMB
{
Expand Down Expand Up @@ -613,19 +582,12 @@ s32 ARMv4::Execute()
AddCycles_C();
}

//s32 diff = Cycles - lastcycles;arm7timer+=diff;
//NDS::RunTightTimers(1, diff);
//lastcycles = Cycles;

// TODO optimize this shit!!!
if (Halted)
{
if (Halted == 1 && Cycles < CyclesToRun)
if (Halted == 1 && NDS::ARM7Timestamp < NDS::ARM7Target)
{
//s32 diff = CyclesToRun - Cycles;
Cycles = CyclesToRun;
//NDS::RunTightTimers(1, diff);
//arm7timer += diff;
NDS::ARM7Timestamp = NDS::ARM7Target;
}
break;
}
Expand All @@ -634,20 +596,11 @@ s32 ARMv4::Execute()
if (NDS::IME[1] & 0x1)
TriggerIRQ();
}

NDS::ARM7Timestamp += Cycles;
Cycles = 0;
}

if (Halted == 2)
Halted = 0;

/*if (Cycles > lastcycles)
{
//s32 diff = Cycles - lastcycles;arm7timer+=(diff);
//NDS::RunTightTimers(1, diff);
}*/

#ifdef DEBUG_CHECK_DESYNC
NDS::dbg_CyclesARM7 += Cycles;
#endif // DEBUG_CHECK_DESYNC

return Cycles;
}
Loading

0 comments on commit c0340a8

Please sign in to comment.