Skip to content

Commit c46a3f1

Browse files
committed
prepare for win release
1 parent 01ef6d4 commit c46a3f1

File tree

7 files changed

+27
-19
lines changed

7 files changed

+27
-19
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.7)
33
project(sid-monitor)
44

55
add_compile_options(-std=c++17 -Wall -Ofast)
6+
#add_compile_options(-std=c++17 -Wall -Og -g)
67

78
find_package(SDL2 REQUIRED)
89
include_directories(${SDL2_INCLUDE_DIRS})

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SID monitor
1+
SID Monitor
22
===========
33

44
A SID player with piano-roll-like visualization.

src/fx.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
#include <SDL2/SDL.h>
21
#include <vector>
2+
#include <cstdio>
3+
#include <SDL2/SDL.h>
34
#include "fx.hpp"
45

6+
57
namespace fx {
68
namespace {
79

src/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include <cstdio>
22
#include <chrono>
3+
#include <cmath>
4+
#define SDL_MAIN_HANDLED
35
#include <SDL2/SDL.h>
46
#include "record.hpp"
57
#include "fx.hpp"
@@ -8,7 +10,7 @@
810

911
enum {
1012
MIXRATE = 44100,
11-
BUFFER_SIZE = MIXRATE / 50,
13+
BUFFER_SIZE = 1024,
1214
CHANNEL_COUT = 3,
1315
};
1416

@@ -292,7 +294,7 @@ struct App : fx::App {
292294
fx::printf(8, 8 + 24, "%s", record.song_author.c_str());
293295
fx::printf(8, 8 + 48, "%s", record.song_released.c_str());
294296

295-
fx::printf(fx::screen_width() - 8 - 16 * 14, 8 + 24 * 0, " speed: %dX", record.speed);
297+
fx::printf(fx::screen_width() - 8 - 16 * 14, 8 + 24 * 0, " speed: %4.gX", record.speed);
296298
fx::printf(fx::screen_width() - 8 - 16 * 14, 8 + 24 * 1, " time: %02d:%02d", frame / framerate / 60, frame / framerate % 60);
297299
fx::printf(fx::screen_width() - 8 - 16 * 14, 8 + 24 * 2, " pos: %6d", f);
298300
fx::printf(fx::screen_width() - 8 - 16 * 14, 8 + 24 * 3, " bar: %6d", bar);

src/record.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <fstream>
22
#include <cstring>
3+
#include <cmath>
34
#include "record.hpp"
45
#include "cpu.hpp"
56

@@ -143,7 +144,9 @@ bool Record::load(const char* filename, int nr) {
143144
// check timer
144145
if (song_nr < 32 && ((h->speed >> (song_nr - 1)) & 1)) {
145146
int timer = (cpu.ram[0xdc05] << 8) | cpu.ram[0xdc04];
146-
speed = (19656 + timer / 2) / timer;
147+
// speed = (19656 + timer / 2) / timer;
148+
// speed = 19656.0f / timer;
149+
speed = round(19656 * 2.0f / timer) / 2;
147150
}
148151
else {
149152
speed = 1;

src/record.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct Record {
1919
std::string song_released;
2020
int song_count;
2121
int song_nr;
22-
int speed;
22+
float speed;
2323

2424
bool load(const char* filename, int song_nr = 0);
2525
};

src/sidengine.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@ class TinySidEngine : public SidEngine {
4242

4343
private:
4444

45-
constexpr static std::array<int, 16> attack_speeds = {
46-
168867, 47495, 24124, 15998, 10200, 6908, 5692, 4855,
47-
3877, 1555, 777, 486, 389, 129, 77, 48,
48-
};
49-
50-
constexpr static std::array<int, 16> release_speeds = {
51-
42660, 15468, 7857, 5210, 3322, 2250, 1853, 1581,
52-
1262, 506, 253, 158, 126, 42, 25, 15,
53-
};
54-
5545
enum {
5646
CHANNEL_COUNT = 3
5747
};
@@ -108,13 +98,23 @@ void TinySidEngine::update_registers(uint8_t const* regs) {
10898
Channel& chan = m_channels[i];
10999
uint8_t const* r = regs + (i * 7);
110100

101+
static const std::array<int, 16> ATTACK_SPEEDS = {
102+
168867, 47495, 24124, 15998, 10200, 6908, 5692, 4855,
103+
3877, 1555, 777, 486, 389, 129, 77, 48,
104+
};
105+
106+
static const std::array<int, 16> RELEASE_SPEEDS = {
107+
42660, 15468, 7857, 5210, 3322, 2250, 1853, 1581,
108+
1262, 506, 253, 158, 126, 42, 25, 15,
109+
};
110+
111111
chan.freq = (r[0] | (r[1] << 8)) * (15872000 / MIXRATE);
112112
chan.next_pulsewidth = (r[2] | ((r[3] & 15) << 8)) << 16;
113113
chan.flags = r[4];
114-
chan.adsr[0] = attack_speeds[r[5] >> 4];
115-
chan.adsr[1] = release_speeds[r[5] & 15];
114+
chan.adsr[0] = ATTACK_SPEEDS[r[5] >> 4];
115+
chan.adsr[1] = RELEASE_SPEEDS[r[5] & 15];
116116
chan.adsr[2] = (r[6] >> 4) * 0x111111;
117-
chan.adsr[3] = release_speeds[r[6] & 15];
117+
chan.adsr[3] = RELEASE_SPEEDS[r[6] & 15];
118118
chan.filter = (regs[23] >> i) & 1;
119119
}
120120

0 commit comments

Comments
 (0)