misc fixes.

shit in place to start implementing GPU shit.
GPL headers added before it's too late. (TODO: put actual GPL license in the repo)
also added URL that doesn't exist yet but is reserved.
This commit is contained in:
StapleButter 2016-12-05 18:02:29 +01:00
parent 343797f47d
commit 8c8c78cf83
22 changed files with 443 additions and 4 deletions

18
ARM.cpp
View File

@ -1,3 +1,21 @@
/*
Copyright 2016-2017 StapleButter
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 <stdio.h>
#include "NDS.h" #include "NDS.h"
#include "ARM.h" #include "ARM.h"

18
ARM.h
View File

@ -1,4 +1,20 @@
// ARM shit /*
Copyright 2016-2017 StapleButter
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 ARM_H #ifndef ARM_H
#define ARM_H #define ARM_H

View File

@ -1,3 +1,21 @@
/*
Copyright 2016-2017 StapleButter
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 <stdio.h>
#include "NDS.h" #include "NDS.h"
#include "CP15.h" #include "CP15.h"

View File

@ -1,3 +1,20 @@
/*
Copyright 2016-2017 StapleButter
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 ARMINTERPRETER_H #ifndef ARMINTERPRETER_H
#define ARMINTERPRETER_H #define ARMINTERPRETER_H

View File

@ -1,3 +1,21 @@
/*
Copyright 2016-2017 StapleButter
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 "ARM.h" #include "ARM.h"

View File

@ -1,3 +1,20 @@
/*
Copyright 2016-2017 StapleButter
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 ARMINTERPRETER_ALU_H #ifndef ARMINTERPRETER_ALU_H
#define ARMINTERPRETER_ALU_H #define ARMINTERPRETER_ALU_H

View File

@ -1,3 +1,21 @@
/*
Copyright 2016-2017 StapleButter
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 <stdio.h>
#include "ARM.h" #include "ARM.h"

View File

@ -1,3 +1,20 @@
/*
Copyright 2016-2017 StapleButter
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 ARMINTERPRETER_BRANCH_H #ifndef ARMINTERPRETER_BRANCH_H
#define ARMINTERPRETER_BRANCH_H #define ARMINTERPRETER_BRANCH_H

View File

@ -1,3 +1,21 @@
/*
Copyright 2016-2017 StapleButter
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 <stdio.h>
#include "ARM.h" #include "ARM.h"

View File

@ -1,3 +1,20 @@
/*
Copyright 2016-2017 StapleButter
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 ARMINTERPRETER_LOADSTORE_H #ifndef ARMINTERPRETER_LOADSTORE_H
#define ARMINTERPRETER_LOADSTORE_H #define ARMINTERPRETER_LOADSTORE_H

View File

@ -1,3 +1,20 @@
/*
Copyright 2016-2017 StapleButter
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/.
*/
INSTRFUNC_PROTO(ARMInstrTable[4096]) = INSTRFUNC_PROTO(ARMInstrTable[4096]) =
{ {

View File

@ -1,6 +1,25 @@
/*
Copyright 2016-2017 StapleButter
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 <stdio.h>
#include "NDS.h" #include "NDS.h"
namespace CP15 namespace CP15
{ {

17
CP15.h
View File

@ -1,3 +1,20 @@
/*
Copyright 2016-2017 StapleButter
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 CP15_H #ifndef CP15_H
#define CP15_H #define CP15_H

28
GPU2D.cpp Normal file
View File

@ -0,0 +1,28 @@
/*
Copyright 2016-2017 StapleButter
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 "NDS.h"
#include "GPU2D.h"
namespace GPU2D
{
//
}

29
GPU2D.h Normal file
View File

@ -0,0 +1,29 @@
/*
Copyright 2016-2017 StapleButter
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 GPU2D_H
#define GPU2D_H
namespace GPU2D
{
// shit here
}
#endif

38
NDS.cpp
View File

@ -1,3 +1,21 @@
/*
Copyright 2016-2017 StapleButter
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 <stdio.h>
#include <string.h> #include <string.h>
#include "NDS.h" #include "NDS.h"
@ -422,6 +440,8 @@ u8 ARM9Read8(u32 addr)
case 0x04000000: case 0x04000000:
switch (addr) switch (addr)
{ {
case 0x04000208: return IME[0];
case 0x04000247: case 0x04000247:
return WRAMCnt; return WRAMCnt;
} }
@ -468,6 +488,8 @@ u16 ARM9Read16(u32 addr)
case 0x0400010E: return Timers[3].Control; case 0x0400010E: return Timers[3].Control;
case 0x04000180: return IPCSync9; case 0x04000180: return IPCSync9;
case 0x04000208: return IME[0];
} }
} }
@ -557,6 +579,8 @@ void ARM9Write8(u32 addr, u8 val)
case 0x04000000: case 0x04000000:
switch (addr) switch (addr)
{ {
case 0x04000208: IME[0] = val; return;
case 0x04000247: case 0x04000247:
WRAMCnt = val; WRAMCnt = val;
MapSharedWRAM(); MapSharedWRAM();
@ -613,6 +637,8 @@ void ARM9Write16(u32 addr, u16 val)
} }
CompensateARM7(); CompensateARM7();
return; return;
case 0x04000208: IME[0] = val; return;
} }
} }
@ -699,6 +725,8 @@ u8 ARM7Read8(u32 addr)
case 0x040001C2: return SPI::ReadData(); case 0x040001C2: return SPI::ReadData();
case 0x04000208: return IME[1];
case 0x04000241: case 0x04000241:
return WRAMCnt; return WRAMCnt;
} }
@ -739,11 +767,15 @@ u16 ARM7Read16(u32 addr)
case 0x0400010C: return Timers[7].Counter; case 0x0400010C: return Timers[7].Counter;
case 0x0400010E: return Timers[7].Control; case 0x0400010E: return Timers[7].Control;
case 0x04000138: return 0; // RTC shit
case 0x04000180: return IPCSync7; case 0x04000180: return IPCSync7;
case 0x040001C0: return SPI::ReadCnt(); case 0x040001C0: return SPI::ReadCnt();
case 0x040001C2: return SPI::ReadData(); case 0x040001C2: return SPI::ReadData();
case 0x04000208: return IME[1];
case 0x04000504: return _soundbias; case 0x04000504: return _soundbias;
} }
} }
@ -827,6 +859,8 @@ void ARM7Write8(u32 addr, u8 val)
case 0x040001C2: case 0x040001C2:
SPI::WriteData(val); SPI::WriteData(val);
return; return;
case 0x04000208: IME[1] = val; return;
} }
} }
@ -875,6 +909,8 @@ void ARM7Write16(u32 addr, u16 val)
case 0x0400010C: Timers[7].Reload = val; return; case 0x0400010C: Timers[7].Reload = val; return;
case 0x0400010E: TimerStart(7, val); return; case 0x0400010E: TimerStart(7, val); return;
case 0x04000138: return; // RTC shit
case 0x04000180: case 0x04000180:
IPCSync9 &= 0xFFF0; IPCSync9 &= 0xFFF0;
IPCSync9 |= ((val & 0x0F00) >> 8); IPCSync9 |= ((val & 0x0F00) >> 8);
@ -894,6 +930,8 @@ void ARM7Write16(u32 addr, u16 val)
SPI::WriteData(val & 0xFF); SPI::WriteData(val & 0xFF);
return; return;
case 0x04000208: IME[1] = val; return;
case 0x04000504: case 0x04000504:
_soundbias = val & 0x3FF; _soundbias = val & 0x3FF;
return; return;

17
NDS.h
View File

@ -1,3 +1,20 @@
/*
Copyright 2016-2017 StapleButter
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 NDS_H #ifndef NDS_H
#define NDS_H #define NDS_H

48
SPI.cpp
View File

@ -1,3 +1,21 @@
/*
Copyright 2016-2017 StapleButter
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 <stdio.h>
#include "NDS.h" #include "NDS.h"
#include "SPI.h" #include "SPI.h"
@ -14,6 +32,7 @@ u8 CurCmd;
u32 DataPos; u32 DataPos;
u8 Data; u8 Data;
u8 StatusReg;
u32 Addr; u32 Addr;
void Init() void Init()
@ -38,6 +57,7 @@ void Reset()
Hold = 0; Hold = 0;
CurCmd = 0; CurCmd = 0;
Data = 0; Data = 0;
StatusReg = 0x00;
} }
u8 Read() u8 Read()
@ -56,6 +76,7 @@ void Write(u8 val, u32 hold)
{ {
CurCmd = val; CurCmd = val;
Hold = 1; Hold = 1;
Data = 0;
DataPos = 1; DataPos = 1;
Addr = 0; Addr = 0;
printf("firmware SPI command %02X\n", CurCmd); printf("firmware SPI command %02X\n", CurCmd);
@ -88,6 +109,33 @@ void Write(u8 val, u32 hold)
} }
break; break;
case 0x04: // write disable
StatusReg &= ~(1<<1);
Data = 0;
break;
case 0x05: // read status reg
Data = StatusReg;
break;
case 0x06: // write enable
StatusReg |= (1<<1);
Data = 0;
break;
case 0x9F: // read JEDEC ID
{
switch (DataPos)
{
case 1: Data = 0x20; break;
case 2: Data = 0x40; break;
case 3: Data = 0x12; break;
default: Data = 0; break;
}
DataPos++;
}
break;
default: default:
printf("unknown firmware SPI command %02X\n", CurCmd); printf("unknown firmware SPI command %02X\n", CurCmd);
break; break;

17
SPI.h
View File

@ -1,3 +1,20 @@
/*
Copyright 2016-2017 StapleButter
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 SPI_H #ifndef SPI_H
#define SPI_H #define SPI_H

View File

@ -1,3 +1,21 @@
/*
Copyright 2016-2017 StapleButter
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 <stdio.h>
#include "NDS.h" #include "NDS.h"
@ -6,6 +24,7 @@ int main()
{ {
printf("melonDS version uh... 0.1??\n"); printf("melonDS version uh... 0.1??\n");
printf("it's a DS emulator!!!\n"); printf("it's a DS emulator!!!\n");
printf("http://melonds.kuribo64.net/\n");
NDS::Init(); NDS::Init();

View File

@ -55,7 +55,7 @@
1480953933 c:\documents\sources\melonds\arminterpreter_loadstore.h 1480953933 c:\documents\sources\melonds\arminterpreter_loadstore.h
1480951014 source:c:\documents\sources\melonds\arminterpreter_loadstore.cpp 1480953916 source:c:\documents\sources\melonds\arminterpreter_loadstore.cpp
<stdio.h> <stdio.h>
"ARM.h" "ARM.h"
@ -67,7 +67,7 @@
1480814622 c:\documents\sources\melonds\spi.h 1480814622 c:\documents\sources\melonds\spi.h
1480816963 source:c:\documents\sources\melonds\spi.cpp 1480954747 source:c:\documents\sources\melonds\spi.cpp
<stdio.h> <stdio.h>
"NDS.h" "NDS.h"
"SPI.h" "SPI.h"

18
types.h
View File

@ -1,4 +1,20 @@
// types, common crap /*
Copyright 2016-2017 StapleButter
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 TYPES_H #ifndef TYPES_H
#define TYPES_H #define TYPES_H