aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2017-04-04 15:32:50 +0200
committerStapleButter <thetotalworm@gmail.com>2017-04-04 15:32:50 +0200
commit28cddadfbcc547b8a7b015e219219088bbb2387d (patch)
treefff34452adabe2650ffc935de54c20230ae74c91
parent3a61ed0a917ee3e41a62733af7433c7bde82794c (diff)
* bump version number
* feed system time into RTC * start laying base for sound
-rw-r--r--melonDS.cbp2
-rw-r--r--src/RTC.cpp43
-rw-r--r--src/SPU.cpp62
-rw-r--r--src/SPU.h31
-rw-r--r--src/version.h2
5 files changed, 127 insertions, 13 deletions
diff --git a/melonDS.cbp b/melonDS.cbp
index 2e6bb77..c1c7f27 100644
--- a/melonDS.cbp
+++ b/melonDS.cbp
@@ -160,6 +160,8 @@
<Unit filename="src/RTC.h" />
<Unit filename="src/SPI.cpp" />
<Unit filename="src/SPI.h" />
+ <Unit filename="src/SPU.cpp" />
+ <Unit filename="src/SPU.h" />
<Unit filename="src/Wifi.cpp" />
<Unit filename="src/Wifi.h" />
<Unit filename="src/types.h" />
diff --git a/src/RTC.cpp b/src/RTC.cpp
index 842fdae..3d45bef 100644
--- a/src/RTC.cpp
+++ b/src/RTC.cpp
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <string.h>
+#include <time.h>
#include "RTC.h"
@@ -73,6 +74,12 @@ void Reset()
}
+u8 BCD(u8 val)
+{
+ return (val % 10) | ((val / 10) << 4);
+}
+
+
void ByteIn(u8 val)
{
//printf("RTC IN: %02X\n", val);
@@ -94,21 +101,33 @@ void ByteIn(u8 val)
case 0x40: Output[0] = StatusReg2; break;
case 0x20:
- // TODO: get actual system time
- Output[0] = 0x17;
- Output[1] = 0x01;
- Output[2] = 0x19;
- Output[3] = 0x04; // day of week. checkme. apparently 04=Thursday
- Output[4] = 0x06;
- Output[5] = 0x30;
- Output[6] = 0x30;
+ {
+ time_t timestamp;
+ struct tm* timedata;
+ time(&timestamp);
+ timedata = localtime(&timestamp);
+
+ Output[0] = BCD(timedata->tm_year - 100);
+ Output[1] = BCD(timedata->tm_mon + 1);
+ Output[2] = BCD(timedata->tm_mday);
+ Output[3] = BCD(timedata->tm_wday);
+ Output[4] = BCD(timedata->tm_hour);
+ Output[5] = BCD(timedata->tm_min);
+ Output[6] = BCD(timedata->tm_sec);
+ }
break;
case 0x60:
- // TODO: get actual system time
- Output[0] = 0x06;
- Output[1] = 0x30;
- Output[2] = 0x30;
+ {
+ time_t timestamp;
+ struct tm* timedata;
+ time(&timestamp);
+ timedata = localtime(&timestamp);
+
+ Output[0] = BCD(timedata->tm_hour);
+ Output[1] = BCD(timedata->tm_min);
+ Output[2] = BCD(timedata->tm_sec);
+ }
break;
case 0x10:
diff --git a/src/SPU.cpp b/src/SPU.cpp
new file mode 100644
index 0000000..c7a769e
--- /dev/null
+++ b/src/SPU.cpp
@@ -0,0 +1,62 @@
+/*
+ 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 <string.h>
+#include "NDS.h"
+#include "SPU.h"
+
+
+namespace SPU
+{
+
+//SDL_AudioDeviceID device;
+//
+
+
+bool Init()
+{
+ /*SDL_AudioSpec whatIwant, whatIget;
+
+ memset(&whatIwant, 0, sizeof(SDL_AudioSpec));
+ whatIwant.freq = 32824; // 32823.6328125
+ whatIwant.format = AUDIO_S16LSB;
+ whatIwant.channels = 2;
+ whatIwant.samples = 2048;
+ whatIwant.callback = zorp;
+ device = SDL_OpenAudioDevice(NULL, 0, &whatIwant, &whatIget, 0);
+ if (!device)
+ {
+ printf("Audio init failed: %s\n", SDL_GetError());
+ return false;
+ }*/
+
+ return true;
+}
+
+void DeInit()
+{
+ //if (device) SDL_CloseAudioDevice(device);
+}
+
+void Reset()
+{
+ //
+}
+
+}
diff --git a/src/SPU.h b/src/SPU.h
new file mode 100644
index 0000000..a66b98d
--- /dev/null
+++ b/src/SPU.h
@@ -0,0 +1,31 @@
+/*
+ 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 SPU_H
+#define SPU_H
+
+namespace SPU
+{
+
+bool Init();
+void DeInit();
+void Reset();
+
+}
+
+#endif // SPU_H
diff --git a/src/version.h b/src/version.h
index aa80b51..2657519 100644
--- a/src/version.h
+++ b/src/version.h
@@ -19,7 +19,7 @@
#ifndef VERSION_H
#define VERSION_H
-#define MELONDS_VERSION "0.1"
+#define MELONDS_VERSION "0.2"
#define MELONDS_URL "http://melonds.kuribo64.net/"