Skip to content

Commit 6f0d2c3

Browse files
committed
Pushed v1.08 code
- The mouse system has been rewritten so that we don't need to do mouse capturing while interacting with GUI widgets, which could be buggy sometimes. - Fixed a bug when exiting from Edit Op. screen #4 ("Sample chord editor") and reopening it. It could mess up the UI in worst case scenarios. - Some other small miscellaneous changes not worth of a mention - Small code cleanup (and also the opposite :-)
1 parent 0d1a2cf commit 6f0d2c3

28 files changed

+2095
-1871
lines changed

src/pt2_audio.c

Lines changed: 325 additions & 179 deletions
Large diffs are not rendered by default.

src/pt2_audio.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ void paulaSetLength(uint8_t ch, uint16_t len);
3737
void paulaSetData(uint8_t ch, const int8_t *src);
3838
void lockAudio(void);
3939
void unlockAudio(void);
40-
void clearPaulaAndScopes(void);
4140
void mixerUpdateLoops(void);
4241
void mixerKillVoice(uint8_t ch);
4342
void turnOffVoices(void);

src/pt2_config.c

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,26 @@ void loadConfig(void)
4141
FILE *f;
4242

4343
// set default config values first
44-
ptConfig.fullScreenStretch = false;
45-
ptConfig.pattDots = false;
46-
ptConfig.dottedCenterFlag = true;
47-
ptConfig.a500LowPassFilter = false;
48-
ptConfig.soundFrequency = 48000;
49-
ptConfig.rememberPlayMode = false;
50-
ptConfig.stereoSeparation = 20;
51-
ptConfig.videoScaleFactor = 2;
52-
ptConfig.realVuMeters = false;
53-
ptConfig.modDot = false;
54-
ptConfig.accidental = 0; // sharp
55-
ptConfig.quantizeValue = 1;
56-
ptConfig.transDel = false;
57-
ptConfig.blankZeroFlag = false;
58-
ptConfig.compoMode = false;
59-
ptConfig.soundBufferSize = 1024;
60-
ptConfig.autoCloseDiskOp = true;
61-
ptConfig.vsyncOff = false;
62-
ptConfig.hwMouse = false;
63-
ptConfig.sampleLowpass = true;
44+
config.fullScreenStretch = false;
45+
config.pattDots = false;
46+
config.dottedCenterFlag = true;
47+
config.a500LowPassFilter = false;
48+
config.soundFrequency = 48000;
49+
config.rememberPlayMode = false;
50+
config.stereoSeparation = 20;
51+
config.videoScaleFactor = 2;
52+
config.realVuMeters = false;
53+
config.modDot = false;
54+
config.accidental = 0; // sharp
55+
config.quantizeValue = 1;
56+
config.transDel = false;
57+
config.blankZeroFlag = false;
58+
config.compoMode = false;
59+
config.soundBufferSize = 1024;
60+
config.autoCloseDiskOp = true;
61+
config.vsyncOff = false;
62+
config.hwMouse = false;
63+
config.sampleLowpass = true;
6464

6565
#ifndef _WIN32
6666
getcwd(oldCwd, PATH_MAX);
@@ -191,127 +191,127 @@ static bool loadProTrackerDotIni(FILE *f)
191191
// HWMOUSE
192192
else if (!_strnicmp(configLine, "HWMOUSE=", 8))
193193
{
194-
if (!_strnicmp(&configLine[8], "TRUE", 4)) ptConfig.hwMouse = true;
195-
else if (!_strnicmp(&configLine[8], "FALSE", 5)) ptConfig.hwMouse = false;
194+
if (!_strnicmp(&configLine[8], "TRUE", 4)) config.hwMouse = true;
195+
else if (!_strnicmp(&configLine[8], "FALSE", 5)) config.hwMouse = false;
196196
}
197197

198198
// SAMPLELOWPASS
199199
else if (!_strnicmp(configLine, "SAMPLELOWPASS=", 14))
200200
{
201-
if (!_strnicmp(&configLine[14], "TRUE", 4)) ptConfig.sampleLowpass = true;
202-
else if (!_strnicmp(&configLine[14], "FALSE", 5)) ptConfig.sampleLowpass = false;
201+
if (!_strnicmp(&configLine[14], "TRUE", 4)) config.sampleLowpass = true;
202+
else if (!_strnicmp(&configLine[14], "FALSE", 5)) config.sampleLowpass = false;
203203
}
204204

205205
// VSYNCOFF
206206
else if (!_strnicmp(configLine, "VSYNCOFF=", 9))
207207
{
208-
if (!_strnicmp(&configLine[9], "TRUE", 4)) ptConfig.vsyncOff = true;
209-
else if (!_strnicmp(&configLine[9], "FALSE", 5)) ptConfig.vsyncOff = false;
208+
if (!_strnicmp(&configLine[9], "TRUE", 4)) config.vsyncOff = true;
209+
else if (!_strnicmp(&configLine[9], "FALSE", 5)) config.vsyncOff = false;
210210
}
211211

212212
// FULLSCREENSTRETCH
213213
else if (!_strnicmp(configLine, "FULLSCREENSTRETCH=", 18))
214214
{
215-
if (!_strnicmp(&configLine[18], "TRUE", 4)) ptConfig.fullScreenStretch = true;
216-
else if (!_strnicmp(&configLine[18], "FALSE", 5)) ptConfig.fullScreenStretch = false;
215+
if (!_strnicmp(&configLine[18], "TRUE", 4)) config.fullScreenStretch = true;
216+
else if (!_strnicmp(&configLine[18], "FALSE", 5)) config.fullScreenStretch = false;
217217
}
218218

219219
// HIDEDISKOPDATES
220220
else if (!_strnicmp(configLine, "HIDEDISKOPDATES=", 16))
221221
{
222-
if (!_strnicmp(&configLine[16], "TRUE", 4)) ptConfig.hideDiskOpDates = true;
223-
else if (!_strnicmp(&configLine[16], "FALSE", 5)) ptConfig.hideDiskOpDates = false;
222+
if (!_strnicmp(&configLine[16], "TRUE", 4)) config.hideDiskOpDates = true;
223+
else if (!_strnicmp(&configLine[16], "FALSE", 5)) config.hideDiskOpDates = false;
224224
}
225225

226226
// AUTOCLOSEDISKOP
227227
else if (!_strnicmp(configLine, "AUTOCLOSEDISKOP=", 16))
228228
{
229-
if (!_strnicmp(&configLine[16], "TRUE", 4)) ptConfig.autoCloseDiskOp = true;
230-
else if (!_strnicmp(&configLine[16], "FALSE", 5)) ptConfig.autoCloseDiskOp = false;
229+
if (!_strnicmp(&configLine[16], "TRUE", 4)) config.autoCloseDiskOp = true;
230+
else if (!_strnicmp(&configLine[16], "FALSE", 5)) config.autoCloseDiskOp = false;
231231
}
232232

233233
// COMPOMODE
234234
else if (!_strnicmp(configLine, "COMPOMODE=", 10))
235235
{
236-
if (!_strnicmp(&configLine[10], "TRUE", 4)) ptConfig.compoMode = true;
237-
else if (!_strnicmp(&configLine[10], "FALSE", 5)) ptConfig.compoMode = false;
236+
if (!_strnicmp(&configLine[10], "TRUE", 4)) config.compoMode = true;
237+
else if (!_strnicmp(&configLine[10], "FALSE", 5)) config.compoMode = false;
238238
}
239239

240240
// PATTDOTS
241241
else if (!_strnicmp(configLine, "PATTDOTS=", 9))
242242
{
243-
if (!_strnicmp(&configLine[9], "TRUE", 4)) ptConfig.pattDots = true;
244-
else if (!_strnicmp(&configLine[9], "FALSE", 5)) ptConfig.pattDots = false;
243+
if (!_strnicmp(&configLine[9], "TRUE", 4)) config.pattDots = true;
244+
else if (!_strnicmp(&configLine[9], "FALSE", 5)) config.pattDots = false;
245245
}
246246

247247
// BLANKZERO
248248
else if (!_strnicmp(configLine, "BLANKZERO=", 10))
249249
{
250-
if (!_strnicmp(&configLine[10], "TRUE", 4)) ptConfig.blankZeroFlag = true;
251-
else if (!_strnicmp(&configLine[10], "FALSE", 5)) ptConfig.blankZeroFlag = false;
250+
if (!_strnicmp(&configLine[10], "TRUE", 4)) config.blankZeroFlag = true;
251+
else if (!_strnicmp(&configLine[10], "FALSE", 5)) config.blankZeroFlag = false;
252252
}
253253

254254
// REALVUMETERS
255255
else if (!_strnicmp(configLine, "REALVUMETERS=", 13))
256256
{
257-
if (!_strnicmp(&configLine[13], "TRUE", 4)) ptConfig.realVuMeters = true;
258-
else if (!_strnicmp(&configLine[13], "FALSE", 5)) ptConfig.realVuMeters = false;
257+
if (!_strnicmp(&configLine[13], "TRUE", 4)) config.realVuMeters = true;
258+
else if (!_strnicmp(&configLine[13], "FALSE", 5)) config.realVuMeters = false;
259259
}
260260

261261
// ACCIDENTAL
262262
else if (!_strnicmp(configLine, "ACCIDENTAL=", 11))
263263
{
264-
if (!_strnicmp(&configLine[11], "SHARP", 4)) ptConfig.accidental = 0;
265-
else if (!_strnicmp(&configLine[11], "FLAT", 5)) ptConfig.accidental = 1;
264+
if (!_strnicmp(&configLine[11], "SHARP", 4)) config.accidental = 0;
265+
else if (!_strnicmp(&configLine[11], "FLAT", 5)) config.accidental = 1;
266266
}
267267

268268
// QUANTIZE
269269
else if (!_strnicmp(configLine, "QUANTIZE=", 9))
270270
{
271271
if (configLine[9] != '\0')
272-
ptConfig.quantizeValue = (int16_t)(CLAMP(atoi(&configLine[9]), 0, 63));
272+
config.quantizeValue = (int16_t)(CLAMP(atoi(&configLine[9]), 0, 63));
273273
}
274274

275275
// TRANSDEL
276276
else if (!_strnicmp(configLine, "TRANSDEL=", 9))
277277
{
278-
if (!_strnicmp(&configLine[9], "TRUE", 4)) ptConfig.transDel = true;
279-
else if (!_strnicmp(&configLine[9], "FALSE", 5)) ptConfig.transDel = false;
278+
if (!_strnicmp(&configLine[9], "TRUE", 4)) config.transDel = true;
279+
else if (!_strnicmp(&configLine[9], "FALSE", 5)) config.transDel = false;
280280
}
281281

282282
// DOTTEDCENTER
283283
else if (!_strnicmp(configLine, "DOTTEDCENTER=", 13))
284284
{
285-
if (!_strnicmp(&configLine[13], "TRUE", 4)) ptConfig.dottedCenterFlag = true;
286-
else if (!_strnicmp(&configLine[13], "FALSE", 5)) ptConfig.dottedCenterFlag = false;
285+
if (!_strnicmp(&configLine[13], "TRUE", 4)) config.dottedCenterFlag = true;
286+
else if (!_strnicmp(&configLine[13], "FALSE", 5)) config.dottedCenterFlag = false;
287287
}
288288

289289
// MODDOT
290290
else if (!_strnicmp(configLine, "MODDOT=", 7))
291291
{
292-
if (!_strnicmp(&configLine[7], "TRUE", 4)) ptConfig.modDot = true;
293-
else if (!_strnicmp(&configLine[7], "FALSE", 5)) ptConfig.modDot = false;
292+
if (!_strnicmp(&configLine[7], "TRUE", 4)) config.modDot = true;
293+
else if (!_strnicmp(&configLine[7], "FALSE", 5)) config.modDot = false;
294294
}
295295

296296
// SCALE3X (deprecated)
297297
else if (!_strnicmp(configLine, "SCALE3X=", 8))
298298
{
299-
if (!_strnicmp(&configLine[8], "TRUE", 4)) ptConfig.videoScaleFactor = 3;
300-
else if (!_strnicmp(&configLine[8], "FALSE", 5)) ptConfig.videoScaleFactor = 2;
299+
if (!_strnicmp(&configLine[8], "TRUE", 4)) config.videoScaleFactor = 3;
300+
else if (!_strnicmp(&configLine[8], "FALSE", 5)) config.videoScaleFactor = 2;
301301
}
302302

303303
// VIDEOSCALE
304304
else if (!_strnicmp(configLine, "VIDEOSCALE=", 11))
305305
{
306306
if (lineLen >= 13 && configLine[12] == 'X' && isdigit(configLine[11]))
307-
ptConfig.videoScaleFactor = configLine[11] - '0';
307+
config.videoScaleFactor = configLine[11] - '0';
308308
}
309309

310310
// REMEMBERPLAYMODE
311311
else if (!_strnicmp(configLine, "REMEMBERPLAYMODE=", 17))
312312
{
313-
if (!_strnicmp(&configLine[17], "TRUE", 4)) ptConfig.rememberPlayMode = true;
314-
else if (!_strnicmp(&configLine[17], "FALSE", 5)) ptConfig.rememberPlayMode = false;
313+
if (!_strnicmp(&configLine[17], "TRUE", 4)) config.rememberPlayMode = true;
314+
else if (!_strnicmp(&configLine[17], "FALSE", 5)) config.rememberPlayMode = false;
315315
}
316316

317317
// DEFAULTDIR
@@ -325,7 +325,7 @@ static bool loadProTrackerDotIni(FILE *f)
325325

326326
lineLen -= i;
327327
if (lineLen > 0)
328-
strncpy(ptConfig.defModulesDir, &configLine[i], (lineLen > PATH_MAX) ? PATH_MAX : lineLen);
328+
strncpy(config.defModulesDir, &configLine[i], (lineLen > PATH_MAX) ? PATH_MAX : lineLen);
329329
}
330330
}
331331

@@ -340,43 +340,43 @@ static bool loadProTrackerDotIni(FILE *f)
340340

341341
lineLen -= i;
342342
if (lineLen > 0)
343-
strncpy(ptConfig.defSamplesDir, &configLine[i], (lineLen > PATH_MAX) ? PATH_MAX : lineLen);
343+
strncpy(config.defSamplesDir, &configLine[i], (lineLen > PATH_MAX) ? PATH_MAX : lineLen);
344344
}
345345
}
346346

347347
// A500LOWPASSFILTER
348348
else if (!_strnicmp(configLine, "A500LOWPASSFILTER=", 18))
349349
{
350-
if (!_strnicmp(&configLine[18], "TRUE", 4)) ptConfig.a500LowPassFilter = true;
351-
else if (!_strnicmp(&configLine[18], "FALSE", 5)) ptConfig.a500LowPassFilter = false;
350+
if (!_strnicmp(&configLine[18], "TRUE", 4)) config.a500LowPassFilter = true;
351+
else if (!_strnicmp(&configLine[18], "FALSE", 5)) config.a500LowPassFilter = false;
352352
}
353353

354354
// A4000LOWPASSFILTER (deprecated, same as A500LOWPASSFILTER)
355355
else if (!_strnicmp(configLine, "A4000LOWPASSFILTER=", 19))
356356
{
357-
if (!_strnicmp(&configLine[19], "TRUE", 4)) ptConfig.a500LowPassFilter = true;
358-
else if (!_strnicmp(&configLine[19], "FALSE", 5)) ptConfig.a500LowPassFilter = false;
357+
if (!_strnicmp(&configLine[19], "TRUE", 4)) config.a500LowPassFilter = true;
358+
else if (!_strnicmp(&configLine[19], "FALSE", 5)) config.a500LowPassFilter = false;
359359
}
360360

361361
// FREQUENCY
362362
else if (!_strnicmp(configLine, "FREQUENCY=", 10))
363363
{
364364
if (configLine[10] != '\0')
365-
ptConfig.soundFrequency = (uint32_t)(CLAMP(atoi(&configLine[10]), 32000, 96000));
365+
config.soundFrequency = (uint32_t)(CLAMP(atoi(&configLine[10]), 32000, 96000));
366366
}
367367

368368
// BUFFERSIZE
369369
else if (!_strnicmp(configLine, "BUFFERSIZE=", 11))
370370
{
371371
if (configLine[11] != '\0')
372-
ptConfig.soundBufferSize = (uint32_t)(CLAMP(atoi(&configLine[11]), 128, 8192));
372+
config.soundBufferSize = (uint32_t)(CLAMP(atoi(&configLine[11]), 128, 8192));
373373
}
374374

375375
// STEREOSEPARATION
376376
else if (!_strnicmp(configLine, "STEREOSEPARATION=", 17))
377377
{
378378
if (configLine[17] != '\0')
379-
ptConfig.stereoSeparation = (int8_t)(CLAMP(atoi(&configLine[17]), 0, 100));
379+
config.stereoSeparation = (int8_t)(CLAMP(atoi(&configLine[17]), 0, 100));
380380
}
381381

382382
configLine = strtok(NULL, "\n");
@@ -450,20 +450,20 @@ static bool loadPTDotConfig(FILE *f)
450450
{
451451
fread(&tmp16, 2, 1, f); // stored as Big-Endian
452452
tmp16 = SWAP16(tmp16);
453-
palette[i] = RGB12_to_RGB24(tmp16);
453+
video.palette[i] = RGB12_to_RGB24(tmp16);
454454
}
455455

456456
// Transpose Delete (delete out of range notes on transposing)
457457
fseek(f, 174, SEEK_SET);
458458
fread(&tmp8, 1, 1, f);
459-
ptConfig.transDel = tmp8 ? true : false;
460-
ptConfig.transDel = ptConfig.transDel;
459+
config.transDel = tmp8 ? true : false;
460+
config.transDel = config.transDel;
461461

462462
// Note style (sharps/flats)
463463
fseek(f, 200, SEEK_SET);
464464
fread(&tmp8, 1, 1, f);
465-
ptConfig.accidental = tmp8 ? 1 : 0;
466-
ptConfig.accidental = ptConfig.accidental;
465+
config.accidental = tmp8 ? 1 : 0;
466+
config.accidental = config.accidental;
467467

468468
// Multi Mode Next
469469
fseek(f, 462, SEEK_SET);
@@ -489,8 +489,8 @@ static bool loadPTDotConfig(FILE *f)
489489
// Blank Zeroes
490490
fseek(f, 490, SEEK_SET);
491491
fread(&tmp8, 1, 1, f);
492-
ptConfig.blankZeroFlag = tmp8 ? true : false;
493-
ptConfig.blankZeroFlag = ptConfig.blankZeroFlag;
492+
config.blankZeroFlag = tmp8 ? true : false;
493+
config.blankZeroFlag = config.blankZeroFlag;
494494

495495
// Initial Tempo (don't load if timing is set to VBLANK)
496496
if (editor.timingMode == TEMPO_MODE_CIA)
@@ -603,7 +603,7 @@ static bool loadColorsDotIni(void)
603603
{
604604
color = (hex2int(configLine[0]) << 8) | (hex2int(configLine[1]) << 4) | hex2int(configLine[2]);
605605
color &= 0xFFF;
606-
palette[line] = RGB12_to_RGB24(color);
606+
video.palette[line] = RGB12_to_RGB24(color);
607607

608608
configLine = strtok(NULL, "\n");
609609
line++;

src/pt2_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <stdint.h>
44
#include <stdbool.h>
55

6-
struct ptConfig_t
6+
struct config_t
77
{
88
char *defModulesDir, *defSamplesDir;
99
bool dottedCenterFlag, pattDots, a500LowPassFilter, compoMode, autoCloseDiskOp, hideDiskOpDates, hwMouse;
@@ -12,6 +12,6 @@ struct ptConfig_t
1212
int8_t stereoSeparation, videoScaleFactor, accidental;
1313
uint16_t quantizeValue;
1414
uint32_t soundFrequency, soundBufferSize;
15-
} ptConfig;
15+
} config;
1616

1717
void loadConfig(void);

0 commit comments

Comments
 (0)