aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2023-10-22 09:08:40 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2023-10-22 09:08:40 +0530
commit9b6b14d2502abdd825975052c5619c4dbfaa9141 (patch)
tree96845f563f259672880e8f0f419d73276bc19f4c
parenteb6adb4b212cd55f8e6a553ecdcffa2f8a7cc63a (diff)
use constant
-rw-r--r--src/main.cpp4
-rw-r--r--src/platform.cpp3
2 files changed, 4 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 7e7d90a..b3e9dc0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -5,6 +5,8 @@
#include "chip8.hpp"
#include "platform.hpp"
+#define WINDOW_TITLE "chip8emu"
+
int main(int argc, char** argv) {
if (argc != 4) {
std::cerr << "Usage: " << argv[0] << " <Scale> <Delay> <ROM>\n";
@@ -16,7 +18,7 @@ int main(int argc, char** argv) {
char const* filename = argv[3];
Platform platform(
- "chip8emu",
+ WINDOW_TITLE,
VIDEO_WIDTH * videoScale,
VIDEO_HEIGHT * videoScale,
VIDEO_WIDTH, VIDEO_HEIGHT
diff --git a/src/platform.cpp b/src/platform.cpp
index f2d5984..93e574b 100644
--- a/src/platform.cpp
+++ b/src/platform.cpp
@@ -117,11 +117,10 @@ void Platform::AudioCallback(void* userdata, uint8_t* stream, int len) {
Platform* platform = static_cast<Platform*>(userdata);
if (platform->beepRequested) {
static double time = 0.0;
- double freq = 440.0;
int16_t* sample = reinterpret_cast<int16_t*>(stream);
for (int i = 0; i < len / 2; i++) {
- int16_t value = static_cast<int16_t>(32767.0 * sin(2.0 * PI * freq * time));
+ int16_t value = static_cast<int16_t>(32767.0 * sin(2.0 * PI * FREQUENCY * time));
sample[i] = value;
time += 1.0 / SAMPLE_RATE;
}