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

Diff for: src/ft2_about.c

+17-27
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;

Diff for: src/ft2_checkboxes.c

+5
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 },

Diff for: src/ft2_checkboxes.h

+3
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,

Diff for: src/ft2_edit.c

+1-1
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];

Diff for: src/ft2_header.h

+1-1
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

Diff for: src/ft2_main.c

+2
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();

Diff for: src/ft2_midi.c

+1-1
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;

Diff for: src/ft2_module_loader.c

+2
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

Diff for: src/ft2_pattern_draw.c

+3-3
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++;

Diff for: src/ft2_pattern_ed.c

+2
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;

Diff for: src/ft2_pushbuttons.c

+24-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "ft2_mouse.h"
2828
#include "ft2_edit.h"
2929
#include "ft2_sample_ed_features.h"
30+
#include "ft2_smpfx.h"
3031
#include "ft2_palette.h"
3132
#include "ft2_structs.h"
3233
#include "ft2_bmp.h"
@@ -218,7 +219,7 @@ pushButton_t pushButtons[NUM_PUSHBUTTONS] =
218219
{ 251, 382, 43, 16, 0, 0, "Paste", NULL, NULL, sampPaste },
219220
{ 300, 348, 50, 16, 0, 0, "Crop", NULL, NULL, sampCrop },
220221
{ 300, 365, 50, 16, 0, 0, "Volume", NULL, NULL, pbSampleVolume },
221-
{ 300, 382, 50, 16, 0, 0, "X-Fade", NULL, NULL, sampXFade },
222+
{ 300, 382, 50, 16, 0, 0, "Effects", NULL, NULL, pbEffects },
222223
{ 430, 348, 54, 16, 0, 0, "Exit", NULL, NULL, exitSampleEditor },
223224
{ 594, 348, 35, 13, 0, 0, "Clr S.", NULL, NULL, clearSample },
224225
{ 594, 360, 35, 13, 0, 0, "Min.", NULL, NULL, sampMinimize },
@@ -227,13 +228,34 @@ pushButton_t pushButtons[NUM_PUSHBUTTONS] =
227228
{ 594, 385, 18, 13, 2, 4, ARROW_UP_STRING, NULL, sampReplenUp, NULL },
228229
{ 611, 385, 18, 13, 2, 4, ARROW_DOWN_STRING, NULL, sampReplenDown, NULL },
229230

231+
// ------ SAMPLE EDITOR EFFECTS PUSHBUTTONS ------
232+
//x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp
233+
{ 78, 350, 18, 13, 2, 2, ARROW_UP_STRING, NULL, pbSfxCyclesUp, NULL },
234+
{ 95, 350, 18, 13, 2, 2, ARROW_DOWN_STRING, NULL, pbSfxCyclesDown, NULL },
235+
{ 3, 365, 54, 16, 0, 0, "Triangle", NULL, NULL, pbSfxTriangle },
236+
{ 59, 365, 54, 16, 0, 0, "Saw", NULL, NULL, pbSfxSaw },
237+
{ 3, 382, 54, 16, 0, 0, "Sine", NULL, NULL, pbSfxSine },
238+
{ 59, 382, 54, 16, 0, 0, "Square", NULL, NULL, pbSfxSquare },
239+
{ 192, 350, 18, 13, 1, 2, ARROW_UP_STRING, NULL, pbSfxResoUp, NULL },
240+
{ 209, 350, 18, 13, 1, 2, ARROW_DOWN_STRING, NULL, pbSfxResoDown, NULL },
241+
{ 119, 365, 53, 16, 0, 0, "lp filter", NULL, NULL, pbSfxLowPass },
242+
{ 174, 365, 53, 16, 0, 0, "hp filter", NULL, NULL, pbSfxHighPass },
243+
{ 269, 350, 13, 13, 0, 0, "-", NULL, NULL, pbSfxSubBass },
244+
{ 281, 350, 13, 13, 0, 0, "+", NULL, NULL, pbSfxAddBass },
245+
{ 269, 367, 13, 13, 0, 0, "-", NULL, NULL, pbSfxSubTreble },
246+
{ 281, 367, 13, 13, 0, 0, "+", NULL, NULL, pbSfxAddTreble },
247+
{ 233, 382, 61, 16, 0, 0, "Amplitude", NULL, NULL, pbSfxSetAmp },
248+
{ 300, 348, 50, 16, 0, 0, "Undo", NULL, NULL, pbSfxUndo },
249+
{ 300, 365, 50, 16, 0, 0, "X-Fade", NULL, NULL, sampXFade },
250+
{ 300, 382, 50, 16, 0, 0, "Back...", NULL, NULL, hideSampleEffectsScreen },
251+
230252
// ------ SAMPLE EDITOR EXTENSION PUSHBUTTONS ------
231253
//x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp
232254
{ 3, 138, 52, 16, 0, 0, "Clr. c.bf", NULL, NULL, clearCopyBuffer },
233255
{ 56, 138, 49, 16, 0, 0, "Sign", NULL, NULL, sampleChangeSign },
234256
{ 106, 138, 49, 16, 0, 0, "Echo", NULL, NULL, pbSampleEcho },
235257
{ 3, 155, 52, 16, 0, 0, "Backw.", NULL, NULL, sampleBackwards },
236-
{ 56, 155, 49, 16, 0, 0, "B. swap", NULL, NULL, sampleByteSwap },
258+
{ 56, 155, 49, 16, 0, 0, "B. swap", NULL, NULL, sampleByteSwap },
237259
{ 106, 155, 49, 16, 0, 0, "Fix DC", NULL, NULL, fixDC },
238260
{ 161, 121, 60, 16, 0, 0, "Copy ins.", NULL, NULL, copyInstr },
239261
{ 222, 121, 66, 16, 0, 0, "Copy smp.", NULL, NULL, copySmp },

Diff for: src/ft2_pushbuttons.h

+21-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ enum // PUSHBUTTONS
168168
PB_SAMP_PASTE,
169169
PB_SAMP_CROP,
170170
PB_SAMP_VOLUME,
171-
PB_SAMP_XFADE,
171+
PB_SAMP_EFFECTS,
172172
PB_SAMP_EXIT,
173173
PB_SAMP_CLEAR,
174174
PB_SAMP_MIN,
@@ -177,6 +177,26 @@ enum // PUSHBUTTONS
177177
PB_SAMP_REPLEN_UP,
178178
PB_SAMP_REPLEN_DOWN,
179179

180+
// SAMPLE EDITOR EFFECTS SCREEN
181+
PB_SAMPFX_CYCLES_UP,
182+
PB_SAMPFX_CYCLES_DOWN,
183+
PB_SAMPFX_TRIANGLE,
184+
PB_SAMPFX_SAW,
185+
PB_SAMPFX_SINE,
186+
PB_SAMPFX_SQUARE,
187+
PB_SAMPFX_RESO_UP,
188+
PB_SAMPFX_RESO_DOWN,
189+
PB_SAMPFX_LOWPASS,
190+
PB_SAMPFX_HIGHPASS,
191+
PB_SAMPFX_SUB_BASS,
192+
PB_SAMPFX_SUB_TREBLE,
193+
PB_SAMPFX_ADD_BASS,
194+
PB_SAMPFX_ADD_TREBLE,
195+
PB_SAMPFX_SET_AMP,
196+
PB_SAMPFX_UNDO,
197+
PB_SAMPFX_XFADE,
198+
PB_SAMPFX_BACK,
199+
180200
// SAMPLE EDITOR EXTENSION
181201
PB_SAMP_EXT_CLEAR_COPYBUF,
182202
PB_SAMP_EXT_CONV,

Diff for: src/ft2_random.c

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <SDL2/SDL.h>
2+
#include <stdint.h>
3+
#include <stdbool.h>
4+
5+
static uint32_t randSeed;
6+
7+
void randomize(void)
8+
{
9+
randSeed = (uint32_t)SDL_GetTicks();
10+
}
11+
12+
int32_t randoml(int32_t limit)
13+
{
14+
randSeed *= 134775813;
15+
randSeed++;
16+
return ((int64_t)randSeed * (int32_t)limit) >> 32;
17+
}
18+
19+
int32_t random32(void)
20+
{
21+
randSeed *= 134775813;
22+
randSeed++;
23+
24+
return randSeed;
25+
}

Diff for: src/ft2_random.h

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
#include <stdint.h>
4+
5+
void randomize(void);
6+
int32_t randoml(int32_t limit);
7+
int32_t random32(void);

0 commit comments

Comments
 (0)