mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
hey look, more crap
no MrRean this doesn't run NSMB yet
This commit is contained in:
parent
5b7ae6dab3
commit
3505ec993b
50
ARM.cpp
Normal file
50
ARM.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include "ARM.h"
|
||||
#include "NDS.h"
|
||||
|
||||
|
||||
ARM::ARM(u32 num)
|
||||
{
|
||||
// well uh
|
||||
Num = num;
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
R[i] = 0;
|
||||
|
||||
ExceptionBase = num ? 0x00000000 : 0xFFFF0000;
|
||||
|
||||
// zorp
|
||||
JumpTo(ExceptionBase);
|
||||
}
|
||||
|
||||
ARM::~ARM()
|
||||
{
|
||||
// dorp
|
||||
}
|
||||
|
||||
void ARM::JumpTo(u32 addr)
|
||||
{
|
||||
// pipeline shit
|
||||
|
||||
// TODO: THUMB!!
|
||||
|
||||
NextInstr = Read32(addr);
|
||||
R[15] = addr+4;
|
||||
}
|
||||
|
||||
s32 ARM::Execute(s32 cycles)
|
||||
{
|
||||
while (cycles > 0)
|
||||
{
|
||||
// TODO THUM SHIT ASGAFDGSUHAJISGFYAUISAGY
|
||||
|
||||
// prefetch
|
||||
CurInstr = NextInstr;
|
||||
NextInstr = Read32(R[15]);
|
||||
R[15] += 4;
|
||||
|
||||
// actually execute
|
||||
// er...
|
||||
}
|
||||
|
||||
return cycles;
|
||||
}
|
40
ARM.h
Normal file
40
ARM.h
Normal file
@ -0,0 +1,40 @@
|
||||
// ARM shit
|
||||
|
||||
#ifndef ARM_H
|
||||
#define ARM_H
|
||||
|
||||
#include "types.h"
|
||||
#include "NDS.h"
|
||||
|
||||
class ARM
|
||||
{
|
||||
public:
|
||||
ARM(u32 num);
|
||||
~ARM(); // destroy shit
|
||||
|
||||
void JumpTo(u32 addr);
|
||||
s32 Execute(s32 cycles);
|
||||
|
||||
u32 Read32(u32 addr)
|
||||
{
|
||||
if (Num) return NDS::ARM7Read32(addr);
|
||||
else return NDS::ARM9Read32(addr);
|
||||
}
|
||||
|
||||
|
||||
u32 Num;
|
||||
|
||||
u32 R[16]; // heh
|
||||
u32 CPSR;
|
||||
u32 R_FIQ[8]; // holding SPSR too
|
||||
u32 R_SVC[3];
|
||||
u32 R_ABT[3];
|
||||
u32 R_IRQ[3];
|
||||
u32 R_UND[3];
|
||||
u32 CurInstr;
|
||||
u32 NextInstr;
|
||||
|
||||
u32 ExceptionBase;
|
||||
};
|
||||
|
||||
#endif // ARM_H
|
50
NDS.cpp
50
NDS.cpp
@ -1,15 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include "NDS.h"
|
||||
#include "ARM.h"
|
||||
|
||||
|
||||
namespace NDS
|
||||
{
|
||||
|
||||
//
|
||||
ARM* ARM9;
|
||||
ARM* ARM7;
|
||||
|
||||
u8 ARM9BIOS[0x1000];
|
||||
u8 ARM7BIOS[0x4000];
|
||||
|
||||
|
||||
void Init()
|
||||
{
|
||||
ARM9 = new ARM(0);
|
||||
ARM7 = new ARM(1);
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
@ -22,13 +30,51 @@ void Reset()
|
||||
printf("ARM9 BIOS not found\n");
|
||||
else
|
||||
{
|
||||
// load BIOS here
|
||||
fseek(f, 0, SEEK_SET);
|
||||
fread(ARM9BIOS, 0x1000, 1, f);
|
||||
|
||||
printf("ARM9 BIOS loaded: %08X\n", ARM9Read32(0xFFFF0000));
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
f = fopen("bios7.bin", "rb");
|
||||
if (!f)
|
||||
printf("ARM7 BIOS not found\n");
|
||||
else
|
||||
{
|
||||
fseek(f, 0, SEEK_SET);
|
||||
fread(ARM7BIOS, 0x4000, 1, f);
|
||||
|
||||
printf("ARM7 BIOS loaded: %08X\n", ARM7Read32(0x00000000));
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
u32 ARM9Read32(u32 addr)
|
||||
{
|
||||
// implement ARM9y shit here, like memory protection
|
||||
|
||||
if ((addr & 0xFFFFF000) == 0xFFFF0000)
|
||||
{
|
||||
return *(u32*)&ARM9BIOS[addr & 0xFFF];
|
||||
}
|
||||
|
||||
printf("unknown arm9 read32 %08X\n", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 ARM7Read32(u32 addr)
|
||||
{
|
||||
if (addr < 0x00004000)
|
||||
{
|
||||
return *(u32*)&ARM7BIOS[addr];
|
||||
}
|
||||
|
||||
printf("unknown arm7 read32 %08X\n", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename T> T Read(u32 addr)
|
||||
{
|
||||
return (T)0;
|
||||
|
3
NDS.h
3
NDS.h
@ -10,6 +10,9 @@ namespace NDS
|
||||
void Init();
|
||||
void Reset();
|
||||
|
||||
u32 ARM9Read32(u32 addr);
|
||||
u32 ARM7Read32(u32 addr);
|
||||
|
||||
template<typename T> T Read(u32 addr);
|
||||
template<typename T> void Write(u32 addr, T val);
|
||||
|
||||
|
1
main.cpp
1
main.cpp
@ -5,6 +5,7 @@
|
||||
int main()
|
||||
{
|
||||
printf("melonDS version uh... 0.1??\n");
|
||||
printf("it's a DS emulator!!!\n");
|
||||
|
||||
NDS::Init();
|
||||
|
||||
|
@ -32,7 +32,10 @@
|
||||
<Add option="-Wall" />
|
||||
<Add option="-fexceptions" />
|
||||
</Compiler>
|
||||
<Unit filename="NDS.cpp" />
|
||||
<Unit filename="NDS.h" />
|
||||
<Unit filename="main.cpp" />
|
||||
<Unit filename="types.h" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
|
20
melonDS.depend
Normal file
20
melonDS.depend
Normal file
@ -0,0 +1,20 @@
|
||||
# depslib dependency file v1.0
|
||||
1478130209 source:c:\documents\sources\melonds\main.cpp
|
||||
<stdio.h>
|
||||
"NDS.h"
|
||||
|
||||
1478129148 c:\documents\sources\melonds\nds.h
|
||||
"types.h"
|
||||
|
||||
1463409689 c:\documents\sources\melonds\types.h
|
||||
|
||||
1463410049 source:c:\documents\sources\melonds\nds.cpp
|
||||
<stdio.h>
|
||||
"NDS.h"
|
||||
|
||||
1478128612 source:c:\documents\sources\melonds\arm.cpp
|
||||
"ARM.h"
|
||||
|
||||
1478130006 c:\documents\sources\melonds\arm.h
|
||||
"types.h"
|
||||
|
@ -2,4 +2,19 @@
|
||||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Debug" />
|
||||
<File name="NDS.cpp" open="1" top="1" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="253" topLine="14" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="NDS.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="0" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="main.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="0" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
Loading…
Reference in New Issue
Block a user