From 8c8c78cf8347bde1e1853782f1c9b5316c7c339d Mon Sep 17 00:00:00 2001 From: StapleButter Date: Mon, 5 Dec 2016 18:02:29 +0100 Subject: 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. --- ARM.cpp | 18 +++++++++++++++++ ARM.h | 18 ++++++++++++++++- ARMInterpreter.cpp | 18 +++++++++++++++++ ARMInterpreter.h | 17 ++++++++++++++++ ARMInterpreter_ALU.cpp | 18 +++++++++++++++++ ARMInterpreter_ALU.h | 17 ++++++++++++++++ ARMInterpreter_Branch.cpp | 18 +++++++++++++++++ ARMInterpreter_Branch.h | 17 ++++++++++++++++ ARMInterpreter_LoadStore.cpp | 18 +++++++++++++++++ ARMInterpreter_LoadStore.h | 17 ++++++++++++++++ ARM_InstrTable.h | 17 ++++++++++++++++ CP15.cpp | 19 ++++++++++++++++++ CP15.h | 17 ++++++++++++++++ GPU2D.cpp | 28 ++++++++++++++++++++++++++ GPU2D.h | 29 ++++++++++++++++++++++++++ NDS.cpp | 38 +++++++++++++++++++++++++++++++++++ NDS.h | 17 ++++++++++++++++ SPI.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++ SPI.h | 17 ++++++++++++++++ main.cpp | 19 ++++++++++++++++++ melonDS.depend | 4 ++-- types.h | 18 ++++++++++++++++- 22 files changed, 443 insertions(+), 4 deletions(-) create mode 100644 GPU2D.cpp create mode 100644 GPU2D.h diff --git a/ARM.cpp b/ARM.cpp index 76ada16..fab4698 100644 --- a/ARM.cpp +++ b/ARM.cpp @@ -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 #include "NDS.h" #include "ARM.h" diff --git a/ARM.h b/ARM.h index fd7afb0..72ba088 100644 --- a/ARM.h +++ b/ARM.h @@ -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 #define ARM_H diff --git a/ARMInterpreter.cpp b/ARMInterpreter.cpp index 82ab3d5..c400fd7 100644 --- a/ARMInterpreter.cpp +++ b/ARMInterpreter.cpp @@ -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 #include "NDS.h" #include "CP15.h" diff --git a/ARMInterpreter.h b/ARMInterpreter.h index 00a3f20..12005f3 100644 --- a/ARMInterpreter.h +++ b/ARMInterpreter.h @@ -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 #define ARMINTERPRETER_H diff --git a/ARMInterpreter_ALU.cpp b/ARMInterpreter_ALU.cpp index 6555793..676ff5f 100644 --- a/ARMInterpreter_ALU.cpp +++ b/ARMInterpreter_ALU.cpp @@ -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" diff --git a/ARMInterpreter_ALU.h b/ARMInterpreter_ALU.h index d1195c3..1c6fe44 100644 --- a/ARMInterpreter_ALU.h +++ b/ARMInterpreter_ALU.h @@ -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 #define ARMINTERPRETER_ALU_H diff --git a/ARMInterpreter_Branch.cpp b/ARMInterpreter_Branch.cpp index 354dad3..efaddd3 100644 --- a/ARMInterpreter_Branch.cpp +++ b/ARMInterpreter_Branch.cpp @@ -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 #include "ARM.h" diff --git a/ARMInterpreter_Branch.h b/ARMInterpreter_Branch.h index 3419286..6b7989a 100644 --- a/ARMInterpreter_Branch.h +++ b/ARMInterpreter_Branch.h @@ -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 #define ARMINTERPRETER_BRANCH_H diff --git a/ARMInterpreter_LoadStore.cpp b/ARMInterpreter_LoadStore.cpp index c968920..165a2fe 100644 --- a/ARMInterpreter_LoadStore.cpp +++ b/ARMInterpreter_LoadStore.cpp @@ -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 #include "ARM.h" diff --git a/ARMInterpreter_LoadStore.h b/ARMInterpreter_LoadStore.h index 773d1ba..1c999a4 100644 --- a/ARMInterpreter_LoadStore.h +++ b/ARMInterpreter_LoadStore.h @@ -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 #define ARMINTERPRETER_LOADSTORE_H diff --git a/ARM_InstrTable.h b/ARM_InstrTable.h index 98d40fc..e39703c 100644 --- a/ARM_InstrTable.h +++ b/ARM_InstrTable.h @@ -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]) = { diff --git a/CP15.cpp b/CP15.cpp index ae73971..528f62e 100644 --- a/CP15.cpp +++ b/CP15.cpp @@ -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 #include "NDS.h" + namespace CP15 { diff --git a/CP15.h b/CP15.h index c633327..2bd888f 100644 --- a/CP15.h +++ b/CP15.h @@ -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 #define CP15_H diff --git a/GPU2D.cpp b/GPU2D.cpp new file mode 100644 index 0000000..8145101 --- /dev/null +++ b/GPU2D.cpp @@ -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 +{ + +// + +} diff --git a/GPU2D.h b/GPU2D.h new file mode 100644 index 0000000..4ff09e5 --- /dev/null +++ b/GPU2D.h @@ -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 diff --git a/NDS.cpp b/NDS.cpp index f5c8095..97fa850 100644 --- a/NDS.cpp +++ b/NDS.cpp @@ -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 #include #include "NDS.h" @@ -422,6 +440,8 @@ u8 ARM9Read8(u32 addr) case 0x04000000: switch (addr) { + case 0x04000208: return IME[0]; + case 0x04000247: return WRAMCnt; } @@ -468,6 +488,8 @@ u16 ARM9Read16(u32 addr) case 0x0400010E: return Timers[3].Control; case 0x04000180: return IPCSync9; + + case 0x04000208: return IME[0]; } } @@ -557,6 +579,8 @@ void ARM9Write8(u32 addr, u8 val) case 0x04000000: switch (addr) { + case 0x04000208: IME[0] = val; return; + case 0x04000247: WRAMCnt = val; MapSharedWRAM(); @@ -613,6 +637,8 @@ void ARM9Write16(u32 addr, u16 val) } CompensateARM7(); return; + + case 0x04000208: IME[0] = val; return; } } @@ -699,6 +725,8 @@ u8 ARM7Read8(u32 addr) case 0x040001C2: return SPI::ReadData(); + case 0x04000208: return IME[1]; + case 0x04000241: return WRAMCnt; } @@ -739,11 +767,15 @@ u16 ARM7Read16(u32 addr) case 0x0400010C: return Timers[7].Counter; case 0x0400010E: return Timers[7].Control; + case 0x04000138: return 0; // RTC shit + case 0x04000180: return IPCSync7; case 0x040001C0: return SPI::ReadCnt(); case 0x040001C2: return SPI::ReadData(); + case 0x04000208: return IME[1]; + case 0x04000504: return _soundbias; } } @@ -827,6 +859,8 @@ void ARM7Write8(u32 addr, u8 val) case 0x040001C2: SPI::WriteData(val); 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 0x0400010E: TimerStart(7, val); return; + case 0x04000138: return; // RTC shit + case 0x04000180: IPCSync9 &= 0xFFF0; IPCSync9 |= ((val & 0x0F00) >> 8); @@ -894,6 +930,8 @@ void ARM7Write16(u32 addr, u16 val) SPI::WriteData(val & 0xFF); return; + case 0x04000208: IME[1] = val; return; + case 0x04000504: _soundbias = val & 0x3FF; return; diff --git a/NDS.h b/NDS.h index 9a0e5bf..fc6ca32 100644 --- a/NDS.h +++ b/NDS.h @@ -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 #define NDS_H diff --git a/SPI.cpp b/SPI.cpp index 40bbf11..562cf09 100644 --- a/SPI.cpp +++ b/SPI.cpp @@ -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 #include "NDS.h" #include "SPI.h" @@ -14,6 +32,7 @@ u8 CurCmd; u32 DataPos; u8 Data; +u8 StatusReg; u32 Addr; void Init() @@ -38,6 +57,7 @@ void Reset() Hold = 0; CurCmd = 0; Data = 0; + StatusReg = 0x00; } u8 Read() @@ -56,6 +76,7 @@ void Write(u8 val, u32 hold) { CurCmd = val; Hold = 1; + Data = 0; DataPos = 1; Addr = 0; printf("firmware SPI command %02X\n", CurCmd); @@ -88,6 +109,33 @@ void Write(u8 val, u32 hold) } 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: printf("unknown firmware SPI command %02X\n", CurCmd); break; diff --git a/SPI.h b/SPI.h index d16e14f..b778f2b 100644 --- a/SPI.h +++ b/SPI.h @@ -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 #define SPI_H diff --git a/main.cpp b/main.cpp index 376dea1..725ad65 100644 --- a/main.cpp +++ b/main.cpp @@ -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 #include "NDS.h" @@ -6,6 +24,7 @@ int main() { printf("melonDS version uh... 0.1??\n"); printf("it's a DS emulator!!!\n"); + printf("http://melonds.kuribo64.net/\n"); NDS::Init(); diff --git a/melonDS.depend b/melonDS.depend index c5e5ee3..a8a280b 100644 --- a/melonDS.depend +++ b/melonDS.depend @@ -55,7 +55,7 @@ 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 "ARM.h" @@ -67,7 +67,7 @@ 1480814622 c:\documents\sources\melonds\spi.h -1480816963 source:c:\documents\sources\melonds\spi.cpp +1480954747 source:c:\documents\sources\melonds\spi.cpp "NDS.h" "SPI.h" diff --git a/types.h b/types.h index 4b4a408..ad69d9c 100644 --- a/types.h +++ b/types.h @@ -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 #define TYPES_H -- cgit v1.2.3