Skip to content

Commit 380d39a

Browse files
committed
New smp. ed. "effects" screen, code cleanup + more
1 parent 4dd5fb9 commit 380d39a

28 files changed

+1656
-127
lines changed

src/ft2_about.c

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "ft2_gfxdata.h"
99
#include "ft2_pattern_ed.h" // exitPatternEditorExtended()
1010
#include "ft2_config.h"
11+
#include "ft2_random.h"
1112

1213
#define OLD_NUM_STARS 1000
1314
#define NUM_STARS 1500
@@ -64,17 +65,6 @@ static oldMatrix_t oldStarMatrix;
6465
static vector_t starPoints[NUM_STARS], starRotation;
6566
static matrix_t starMatrix;
6667

67-
// exact Turbo Pascal Random() implementation
68-
static int32_t Random(int32_t limit)
69-
{
70-
static uint32_t randSeed; // seed is 0 in Turbo Pascal unless Randomize() is called
71-
72-
randSeed *= 134775813;
73-
randSeed++;
74-
75-
return ((int64_t)randSeed * limit) >> 32;
76-
}
77-
7868
static uint32_t blendPixels(uint32_t pixelA, uint32_t pixelB, uint16_t alpha)
7969
{
8070
const uint16_t invAlpha = alpha ^ 0xFFFF;
@@ -333,7 +323,7 @@ void showAboutScreen(void) // called once when about screen is opened
333323
{
334324
oldVector_t *s = oldStarPoints;
335325

336-
const int32_t type = Random(4);
326+
const int32_t type = randoml(4);
337327
switch (type)
338328
{
339329
// classic "space stars"
@@ -342,9 +332,9 @@ void showAboutScreen(void) // called once when about screen is opened
342332
zSpeed = 309;
343333
for (int32_t i = 0; i < OLD_NUM_STARS; i++, s++)
344334
{
345-
s->z = (int16_t)Random(0xFFFF) - 0x8000;
346-
s->y = (int16_t)Random(0xFFFF) - 0x8000;
347-
s->x = (int16_t)Random(0xFFFF) - 0x8000;
335+
s->z = (int16_t)randoml(0xFFFF) - 0x8000;
336+
s->y = (int16_t)randoml(0xFFFF) - 0x8000;
337+
s->x = (int16_t)randoml(0xFFFF) - 0x8000;
348338
}
349339
}
350340
break;
@@ -357,17 +347,17 @@ void showAboutScreen(void) // called once when about screen is opened
357347
{
358348
if (i < OLD_NUM_STARS/4)
359349
{
360-
s->z = (int16_t)Random(0xFFFF) - 0x8000;
361-
s->y = (int16_t)Random(0xFFFF) - 0x8000;
362-
s->x = (int16_t)Random(0xFFFF) - 0x8000;
350+
s->z = (int16_t)randoml(0xFFFF) - 0x8000;
351+
s->y = (int16_t)randoml(0xFFFF) - 0x8000;
352+
s->x = (int16_t)randoml(0xFFFF) - 0x8000;
363353
}
364354
else
365355
{
366-
int32_t r = Random(30000);
367-
int32_t n = Random(5);
368-
int32_t w = ((2 * Random(2)) - 1) * Sqr(Random(1000));
356+
int32_t r = randoml(30000);
357+
int32_t n = randoml(5);
358+
int32_t w = ((2 * randoml(2)) - 1) * Sqr(randoml(1000));
369359
double ww = (((PI * 2.0) / 5.0) * n) + (r * (1.0 / 12000.0)) + (w * (1.0 / 3000000.0));
370-
int32_t h = ((Sqr(r) / 30000) * (Random(10000) - 5000)) / 12000;
360+
int32_t h = ((Sqr(r) / 30000) * (randoml(10000) - 5000)) / 12000;
371361

372362
s->x = (int16_t)(r * cos(ww));
373363
s->y = (int16_t)(r * sin(ww));
@@ -384,8 +374,8 @@ void showAboutScreen(void) // called once when about screen is opened
384374
zSpeed = 0;
385375
for (int32_t i = 0; i < OLD_NUM_STARS; i++, s++)
386376
{
387-
int32_t r = (int32_t)round(sqrt(Random(500) * 500));
388-
int32_t w = Random(3000);
377+
int32_t r = (int32_t)round(sqrt(randoml(500) * 500));
378+
int32_t w = randoml(3000);
389379
double ww = ((w * 8) + r) * (1.0 / 16.0);
390380

391381
const int16_t z = (int16_t)round(32767.0 * cos(w * (2.0 * PI / 1024.0)));
@@ -421,9 +411,9 @@ void initAboutScreen(void)
421411
vector_t *s = starPoints;
422412
for (int32_t i = 0; i < NUM_STARS; i++, s++)
423413
{
424-
s->x = (float)((Random(INT32_MAX) - (INT32_MAX/2)) * (1.0 / INT32_MAX));
425-
s->y = (float)((Random(INT32_MAX) - (INT32_MAX/2)) * (1.0 / INT32_MAX));
426-
s->z = (float)((Random(INT32_MAX) - (INT32_MAX/2)) * (1.0 / INT32_MAX));
414+
s->x = (float)((randoml(INT32_MAX) - (INT32_MAX/2)) * (1.0 / INT32_MAX));
415+
s->y = (float)((randoml(INT32_MAX) - (INT32_MAX/2)) * (1.0 / INT32_MAX));
416+
s->z = (float)((randoml(INT32_MAX) - (INT32_MAX/2)) * (1.0 / INT32_MAX));
427417
}
428418

429419
sinp1 = 0;

src/ft2_checkboxes.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "ft2_edit.h"
1616
#include "ft2_bmp.h"
1717
#include "ft2_wav_renderer.h"
18+
#include "ft2_smpfx.h"
1819
#include "ft2_structs.h"
1920

2021
checkBox_t checkBoxes[NUM_CHECKBOXES] =
@@ -70,6 +71,10 @@ checkBox_t checkBoxes[NUM_CHECKBOXES] =
7071
{ 3, 112, 148, 12, cbInstMidiEnable },
7172
{ 172, 112, 103, 12, cbInstMuteComputer },
7273

74+
// ------ SAMPLE EDITOR EFFECTS CHECKBOXES ------
75+
//x, y, w, h, funcOnUp
76+
{ 119, 384, 95, 12, cbSfxNormalization },
77+
7378
// ------ TRIM SCREEN CHECKBOXES ------
7479
//x, y, w, h, funcOnUp
7580
{ 3, 107, 113, 12, cbTrimUnusedPatt },

src/ft2_checkboxes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ enum // CHECKBOXES
4242
CB_INST_EXT_MIDI,
4343
CB_INST_EXT_MUTE,
4444

45+
// SAMPLE EDITOR EFFECTS
46+
CB_SAMPFX_NORMALIZATION,
47+
4548
// TRIM
4649
CB_TRIM_PATT,
4750
CB_TRIM_INST,

src/ft2_edit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ void recordNote(uint8_t noteNum, int8_t vol) // directly ported from the origina
369369
time = INT32_MAX;
370370
for (i = 0; i < song.numChannels; i++)
371371
{
372-
if (editor.chnMode[i] && config.multiRecChn[i] && editor.keyOffTime[i] < time && editor.keyOnTab[i] == 0)
372+
if (!editor.channelMuted[i] && config.multiRecChn[i] && editor.keyOffTime[i] < time && editor.keyOnTab[i] == 0)
373373
{
374374
c = i;
375375
time = editor.keyOffTime[i];

src/ft2_header.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#endif
1313
#include "ft2_replayer.h"
1414

15-
#define PROG_VER_STR "1.94"
15+
#define PROG_VER_STR "1.95"
1616

1717
// do NOT change these! It will only mess things up...
1818

src/ft2_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "ft2_bmp.h"
3636
#include "ft2_structs.h"
3737
#include "ft2_hpc.h"
38+
#include "ft2_smpfx.h"
3839

3940
static void initializeVars(void);
4041
static void cleanUpAndExit(void); // never call this inside the main loop
@@ -362,6 +363,7 @@ static void cleanUpAndExit(void) // never call this inside the main loop!
362363
freeSprites();
363364
freeDiskOp();
364365
clearCopyBuffer();
366+
clearSampleUndo();
365367
freeAudioDeviceSelectorBuffers();
366368
windUpFTHelp();
367369
freeTextBoxes();

src/ft2_midi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ void recordMIDIEffect(uint8_t efx, uint8_t efxData)
220220
note_t *p = &pattern[editor.editPattern][editor.row * MAX_CHANNELS];
221221
for (int32_t i = 0; i < song.numChannels; i++, p++)
222222
{
223-
if (config.multiRecChn[i] && editor.chnMode[i])
223+
if (config.multiRecChn[i] && !editor.channelMuted[i])
224224
{
225225
if (!allocatePattern(editor.editPattern))
226226
return;

src/ft2_module_loader.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "ft2_gui.h"
2020
#include "ft2_diskop.h"
2121
#include "ft2_sample_loader.h"
22+
#include "ft2_smpfx.h"
2223
#include "ft2_mouse.h"
2324
#include "ft2_midi.h"
2425
#include "ft2_events.h"
@@ -498,6 +499,7 @@ static void setupLoadedModule(void)
498499
updateChanNums();
499500
resetWavRenderer();
500501
clearPattMark();
502+
clearSampleUndo();
501503
resetTrimSizes();
502504
resetPlaybackTime();
503505

src/ft2_pattern_draw.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ static void writePatternBlockMark(int32_t currRow, uint32_t rowHeight, const pat
300300
static void drawChannelNumbering(uint16_t yPos)
301301
{
302302
uint16_t xPos = 30;
303-
int32_t ch = ui.channelOffset + 1;
303+
uint8_t ch = ui.channelOffset + 1;
304304

305305
for (uint8_t i = 0; i < ui.numChannelsShown; i++)
306306
{
@@ -310,8 +310,8 @@ static void drawChannelNumbering(uint16_t yPos)
310310
}
311311
else
312312
{
313-
charOutOutlined(xPos, yPos, PAL_MOUSEPT, chDecTab1[ch]);
314-
charOutOutlined(xPos + (FONT1_CHAR_W + 1), yPos, PAL_MOUSEPT, chDecTab2[ch]);
313+
charOutOutlined(xPos, yPos, PAL_MOUSEPT, '0' + (ch / 10));
314+
charOutOutlined(xPos + (FONT1_CHAR_W + 1), yPos, PAL_MOUSEPT, '0' + (ch % 10));
315315
}
316316

317317
ch++;

src/ft2_pattern_ed.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ void patternEditorExtended(void)
613613
ui._instEditorShown = ui.instEditorShown;
614614
ui._instEditorExtShown = ui.instEditorExtShown;
615615
ui._sampleEditorExtShown = ui.sampleEditorExtShown;
616+
ui._sampleEditorEffectsShown = ui.sampleEditorEffectsShown;
616617
ui._patternEditorShown = ui.patternEditorShown;
617618
ui._sampleEditorShown = ui.sampleEditorShown;
618619
ui._advEditShown= ui.advEditShown;
@@ -703,6 +704,7 @@ void exitPatternEditorExtended(void)
703704
ui.instEditorShown = ui._instEditorShown;
704705
ui.instEditorExtShown = ui._instEditorExtShown;
705706
ui.sampleEditorExtShown = ui._sampleEditorExtShown;
707+
ui.sampleEditorEffectsShown = ui._sampleEditorEffectsShown;
706708
ui.patternEditorShown = ui._patternEditorShown;
707709
ui.sampleEditorShown = ui._sampleEditorShown;
708710
ui.advEditShown = ui._advEditShown;

0 commit comments

Comments
 (0)