Skip to content

Commit 108c333

Browse files
committed
Pushed v1.15 code
- More improvements to S3M loader. Fixes "satellite one.s3m" and other S3Ms. - Up/down pushbutton delay has been increased even more, to prevent accidentally skipping too much. - Some other small miscellaneous changes not worth of a mention
1 parent aaa773b commit 108c333

25 files changed

+435
-644
lines changed

src/ft2_about.c

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
// ported from original FT2 code
1111

12-
#define NUM_STARS 512
12+
#define NUM_STARS 1000
1313
#define ABOUT_SCREEN_W 626
1414
#define ABOUT_SCREEN_H 167
1515
#define ABOUT_LOGO_W 449
@@ -53,7 +53,7 @@ static inline int32_t random32(int32_t l) // Turbo Pascal Random() implementatio
5353
randSeed *= 134775813;
5454
randSeed += 1;
5555

56-
r = (int32_t)(((int64_t)randSeed * l) >> 32);
56+
r = ((int64_t)randSeed * l) >> 32;
5757
return r;
5858
}
5959

@@ -68,13 +68,13 @@ static void fixaMatris(rotate_t a, matrix_t *mat)
6868
sc = sin32767[a.z >> 6];
6969
cc = cos32767[a.z >> 6];
7070

71-
mat->x.x = ((ca * cc) >> 16) + (((sc * ((sa * sb) >> 16)) >> 16) << 1);
71+
mat->x.x = ((ca * cc) >> 16) + ((sc * ((sa * sb) >> 16)) >> (16-1));
7272
mat->y.x = (sa * cb) >> 16;
73-
mat->z.x = (((cc * ((sa * sb) >> 16)) >> 16) << 1) - ((ca * sc) >> 16);
73+
mat->z.x = ((cc * ((sa * sb) >> 16)) >> (16-1)) - ((ca * sc) >> 16);
7474

75-
mat->x.y = (((sc * ((ca * sb) >> 16)) >> 16) << 1) - ((sa * cc) >> 16);
75+
mat->x.y = ((sc * ((ca * sb) >> 16)) >> (16-1)) - ((sa * cc) >> 16);
7676
mat->y.y = (ca * cb) >> 16;
77-
mat->z.y = ((sa * sc) >> 16) + (((cc * ((ca * sb) >> 16)) >> 16) << 1);
77+
mat->z.y = ((sa * sc) >> 16) + ((cc * ((ca * sb) >> 16)) >> (16-1));
7878

7979
mat->x.z = (cb * sc) >> 16;
8080
mat->y.z = 0 - (sb >> 1);
@@ -167,8 +167,8 @@ static void aboutInit(void)
167167
static void realStars(void)
168168
{
169169
uint8_t col;
170-
int16_t x, y, z, xx, xy, xz, yx, yy, yz, zx, zy, zz;
171-
int32_t screenBufferPos;
170+
int16_t z, xx, xy, xz, yx, yy, yz, zx, zy, zz;
171+
int32_t x, y, zMul, screenBufferPos;
172172
vector_t *star;
173173

174174
xx = starmat.x.x; xy = starmat.x.y; xz = starmat.x.z;
@@ -190,26 +190,27 @@ static void realStars(void)
190190
star = &starcrd[i];
191191
star->z += hastighet;
192192

193-
z = ((xz * star->x) >> 16) + ((yz * star->y) >> 16) + ((zz * star->z) >> 16);
193+
z = ((xz * star->x) + (yz * star->y) + (zz * star->z)) >> 16;
194194
z += 9000;
195-
if (z <= 100)
196-
continue;
197-
198-
y = ((xy * star->x) >> 16) + ((yy * star->y) >> 16) + ((zy * star->z) >> 16);
199-
y = (int16_t)((y << 7) / z) + 84;
200-
if ((uint16_t)y >= 173-6)
201-
continue;
202-
203-
x = ((xx * star->x) >> 16) + ((yx * star->y) >> 16) + ((zx * star->z) >> 16);
204-
x = (int16_t)((((x >> 2) + x) << 7) / z) + (320-8);
205-
if ((uint16_t)x >= 640-16)
206-
continue;
195+
if (z <= 100) continue;
196+
zMul = 0xFFFFFFFF / z; // 8bitbubsy: optimization
197+
198+
y = ((xy * star->x) + (yy * star->y) + (zy * star->z)) >> (16-7);
199+
y = ((int64_t)y * zMul) >> 32;
200+
y += (2+ABOUT_SCREEN_H)/2;
201+
if ((uint32_t)y > 2+ABOUT_SCREEN_H) continue;
202+
203+
x = ((xx * star->x) + (yx * star->y) + (zx * star->z)) >> (16-7);
204+
x += x >> 2; // x *= 1.25
205+
x = ((int64_t)x * zMul) >> 32;
206+
x += (2+ABOUT_SCREEN_W)/2;
207+
if ((uint32_t)x > 2+ABOUT_SCREEN_W) continue;
207208

208209
// render star pixel if the pixel under it is the background
209-
screenBufferPos = ((y + 4) * SCREEN_W) + (x + 4);
210+
screenBufferPos = ((uint32_t)y * SCREEN_W) + (uint32_t)x;
210211
if ((video.frameBuffer[screenBufferPos] >> 24) == PAL_BCKGRND)
211212
{
212-
col = ((uint8_t)~(z >> 8) >> 3) - (22 - 8);
213+
col = ((uint8_t)~(z >> 8) >> 3) - 14;
213214
if (col < 24)
214215
{
215216
video.frameBuffer[screenBufferPos] = video.palette[starColConv[col]] & 0x00FFFFFF;

src/ft2_audio.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
static int8_t pmpCountDiv, pmpChannels = 2;
2121
static uint16_t smpBuffSize;
2222
static int32_t masterVol, oldAudioFreq, speedVal, pmpLeft, randSeed = INITIAL_DITHER_SEED;
23-
static int32_t prngStateL, prngStateR;
24-
static uint32_t tickTimeLen, tickTimeLenFrac, oldSFrq, oldSFrqRev = 0xFFFFFFFF;
23+
static int32_t prngStateL, prngStateR, oldPeriod, oldSFrq, oldSFrqRev;
24+
static uint32_t tickTimeLen, tickTimeLenFrac;
2525
static float fAudioAmpMul;
2626
static voice_t voice[MAX_VOICES * 2];
2727
static void (*sendAudSamplesFunc)(uint8_t *, uint32_t, uint8_t); // "send mixed samples" routines
@@ -31,8 +31,9 @@ chSyncData_t *chSyncEntry;
3131

3232
volatile bool pattQueueReading, pattQueueClearing, chQueueReading, chQueueClearing;
3333

34-
void resetOldRevFreqs(void)
34+
void resetCachedMixerVars(void)
3535
{
36+
oldPeriod = -1;
3637
oldSFrq = 0;
3738
oldSFrqRev = 0xFFFFFFFF;
3839
}
@@ -369,17 +370,16 @@ void mix_UpdateChannelVolPanFrq(void)
369370
// frequency change
370371
if (status & IS_Period)
371372
{
372-
v->SFrq = getFrequenceValue(ch->finalPeriod);
373-
374-
if (v->SFrq != oldSFrq) // this value will very often be the same as before
373+
if (ch->finalPeriod != oldPeriod) // this value will very often be the same as before
375374
{
376-
oldSFrq = v->SFrq;
375+
oldSFrq = getFrequenceValue(ch->finalPeriod);
377376

378377
oldSFrqRev = 0xFFFFFFFF;
379378
if (oldSFrq != 0)
380379
oldSFrqRev /= oldSFrq;
381380
}
382381

382+
v->SFrq = oldSFrq;
383383
v->SFrqRev = oldSFrqRev;
384384
}
385385

src/ft2_audio.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ typedef struct
4545
bool backwards, isFadeOutVoice;
4646
uint8_t SPan;
4747
uint16_t SVol;
48-
int32_t SLVol1, SRVol1, SLVol2, SRVol2, SLVolIP, SRVolIP, SVolIPLen, SPos, SLen, SRepS, SRepL;
49-
uint32_t SPosDec, SFrq, SFrqRev;
48+
int32_t SLVol1, SRVol1, SLVol2, SRVol2, SLVolIP, SRVolIP, SVolIPLen;
49+
int32_t SPos, SLen, SRepS, SRepL, SFrq, SFrqRev;
50+
uint32_t SPosDec;
51+
5052
void (*mixRoutine)(void *, int32_t); // function pointer to mix routine
5153
} voice_t;
5254

@@ -79,7 +81,7 @@ extern chSyncData_t *chSyncEntry;
7981

8082
extern volatile bool pattQueueReading, pattQueueClearing, chQueueReading, chQueueClearing;
8183

82-
void resetOldRevFreqs(void);
84+
void resetCachedMixerVars(void);
8385
int32_t pattQueueReadSize(void);
8486
int32_t pattQueueWriteSize(void);
8587
bool pattQueuePush(pattSyncData_t t);

src/ft2_checkboxes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ checkBox_t checkBoxes[NUM_CHECKBOXES] =
7979

8080
// ------ CONFIG CHECKBOXES ------
8181
//x, y, w, h, funcOnUp
82-
{ 3, 91, 76, 12, cbToggleAutoSaveConfig },
82+
{ 3, 91, 77, 12, cbToggleAutoSaveConfig },
8383
{ 389, 132, 90, 12, cbConfigInterpolation },
8484
{ 389, 145, 107, 12, cbConfigVolRamp },
8585
{ 389, 158 , 84, 12, cbConfigDither },

src/ft2_config.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,14 +1106,14 @@ void showConfigScreen(void)
11061106
showPushButton(PB_CONFIG_SAVE);
11071107
showPushButton(PB_CONFIG_EXIT);
11081108

1109-
textOutShadow(5, 4, PAL_FORGRND, PAL_DSKTOP2, "Configuration:");
1110-
textOutShadow(22, 20, PAL_FORGRND, PAL_DSKTOP2, "I/O devices");
1111-
textOutShadow(22, 36, PAL_FORGRND, PAL_DSKTOP2, "Layout");
1112-
textOutShadow(22, 52, PAL_FORGRND, PAL_DSKTOP2, "Miscellaneous");
1109+
textOutShadow(4, 4, PAL_FORGRND, PAL_DSKTOP2, "Configuration:");
1110+
textOutShadow(21, 19, PAL_FORGRND, PAL_DSKTOP2, "I/O devices");
1111+
textOutShadow(21, 35, PAL_FORGRND, PAL_DSKTOP2, "Layout");
1112+
textOutShadow(21, 51, PAL_FORGRND, PAL_DSKTOP2, "Miscellaneous");
11131113
#ifdef HAS_MIDI
1114-
textOutShadow(22, 68, PAL_FORGRND, PAL_DSKTOP2, "MIDI input");
1114+
textOutShadow(21, 67, PAL_FORGRND, PAL_DSKTOP2, "MIDI input");
11151115
#endif
1116-
textOutShadow(19, 92, PAL_FORGRND, PAL_DSKTOP2, "Auto save");
1116+
textOutShadow(20, 93, PAL_FORGRND, PAL_DSKTOP2, "Auto save");
11171117

11181118
switch (editor.currConfigScreen)
11191119
{

src/ft2_diskop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ int32_t getFileSize(UNICHAR *fileNameU) // returning -1 = filesize over 2GB
104104
if (stat(fileNameU, &st) != 0)
105105
return 0;
106106

107-
fSize = (int64_t)(st.st_size);
107+
fSize = (int64_t)st.st_size;
108108
#endif
109109
if (fSize < 0)
110110
fSize = 0;

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.14"
15+
#define PROG_VER_STR "1.15"
1616

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

src/ft2_help.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,13 @@ void showHelpScreen(void)
417417

418418
showScrollBar(SB_HELP_SCROLL);
419419

420-
textOutShadow(4, 3, PAL_FORGRND, PAL_DSKTOP2, "Subjects:");
421-
textOutShadow(20, 17, PAL_FORGRND, PAL_DSKTOP2, "Features");
422-
textOutShadow(20, 32, PAL_FORGRND, PAL_DSKTOP2, "Effects");
423-
textOutShadow(20, 47, PAL_FORGRND, PAL_DSKTOP2, "Keyboard");
424-
textOutShadow(20, 62, PAL_FORGRND, PAL_DSKTOP2, "How to use FT2");
425-
textOutShadow(20, 77, PAL_FORGRND, PAL_DSKTOP2, "Problems/FAQ");
426-
textOutShadow(20, 92, PAL_FORGRND, PAL_DSKTOP2, "Known bugs");
420+
textOutShadow(4, 4, PAL_FORGRND, PAL_DSKTOP2, "Subjects:");
421+
textOutShadow(21, 19, PAL_FORGRND, PAL_DSKTOP2, "Features");
422+
textOutShadow(21, 35, PAL_FORGRND, PAL_DSKTOP2, "Effects");
423+
textOutShadow(21, 51, PAL_FORGRND, PAL_DSKTOP2, "Keyboard");
424+
textOutShadow(21, 67, PAL_FORGRND, PAL_DSKTOP2, "How to use FT2");
425+
textOutShadow(21, 83, PAL_FORGRND, PAL_DSKTOP2, "Problems/FAQ");
426+
textOutShadow(21, 99, PAL_FORGRND, PAL_DSKTOP2, "Known bugs");
427427

428428
writeHelp();
429429
}

src/ft2_inst_ed.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ static void drawVolEnvRepS(void)
397397
instrTyp *ins = getCurDispInstr();
398398

399399
sprintf(str, "%02d", ins->envVRepS);
400-
textOutFixed(382, 234, PAL_FORGRND, PAL_DESKTOP, str);
400+
textOutFixed(382, 233, PAL_FORGRND, PAL_DESKTOP, str);
401401
}
402402

403403
static void drawVolEnvRepE(void)
@@ -415,7 +415,7 @@ static void drawPanEnvSus(void)
415415
instrTyp *ins = getCurDispInstr();
416416

417417
sprintf(str, "%02d", ins->envPSust);
418-
textOutFixed(382, 294, PAL_FORGRND, PAL_DESKTOP, str);
418+
textOutFixed(382, 293, PAL_FORGRND, PAL_DESKTOP, str);
419419
}
420420

421421
static void drawPanEnvRepS(void)
@@ -424,7 +424,7 @@ static void drawPanEnvRepS(void)
424424
instrTyp *ins = getCurDispInstr();
425425

426426
sprintf(str, "%02d", ins->envPRepS);
427-
textOutFixed(382, 321, PAL_FORGRND, PAL_DESKTOP, str);
427+
textOutFixed(382, 320, PAL_FORGRND, PAL_DESKTOP, str);
428428
}
429429

430430
static void drawPanEnvRepE(void)
@@ -433,7 +433,7 @@ static void drawPanEnvRepE(void)
433433
instrTyp *ins = getCurDispInstr();
434434

435435
sprintf(str, "%02d", ins->envPRepE);
436-
textOutFixed(382, 335, PAL_FORGRND, PAL_DESKTOP, str);
436+
textOutFixed(382, 334, PAL_FORGRND, PAL_DESKTOP, str);
437437
}
438438

439439
static void drawVolume(void)
@@ -445,7 +445,7 @@ static void drawVolume(void)
445445
else
446446
s = &instr[editor.curInstr]->samp[editor.curSmp];
447447

448-
hexOutBg(505, 178, PAL_FORGRND, PAL_DESKTOP, s->vol, 2);
448+
hexOutBg(505, 177, PAL_FORGRND, PAL_DESKTOP, s->vol, 2);
449449
}
450450

451451
static void drawPanning(void)
@@ -457,7 +457,7 @@ static void drawPanning(void)
457457
else
458458
s = &instr[editor.curInstr]->samp[editor.curSmp];
459459

460-
hexOutBg(505, 192, PAL_FORGRND, PAL_DESKTOP, s->pan, 2);
460+
hexOutBg(505, 191, PAL_FORGRND, PAL_DESKTOP, s->pan, 2);
461461
}
462462

463463
static void drawFineTune(void)
@@ -2262,17 +2262,17 @@ void showInstEditor(void)
22622262

22632263
textOutShadow(20, 176, PAL_FORGRND, PAL_DSKTOP2, "Volume envelope:");
22642264
textOutShadow(153, 176, PAL_FORGRND, PAL_DSKTOP2, "Predef.");
2265-
textOutShadow(358, 193, PAL_FORGRND, PAL_DSKTOP2, "Sustain:");
2265+
textOutShadow(358, 194, PAL_FORGRND, PAL_DSKTOP2, "Sustain:");
22662266
textOutShadow(342, 206, PAL_FORGRND, PAL_DSKTOP2, "Point");
22672267
textOutShadow(358, 219, PAL_FORGRND, PAL_DSKTOP2, "Env.loop:");
2268-
textOutShadow(342, 234, PAL_FORGRND, PAL_DSKTOP2, "Start");
2268+
textOutShadow(342, 233, PAL_FORGRND, PAL_DSKTOP2, "Start");
22692269
textOutShadow(342, 247, PAL_FORGRND, PAL_DSKTOP2, "End");
22702270
textOutShadow(20, 263, PAL_FORGRND, PAL_DSKTOP2, "Panning envelope:");
22712271
textOutShadow(152, 263, PAL_FORGRND, PAL_DSKTOP2, "Predef.");
2272-
textOutShadow(358, 280, PAL_FORGRND, PAL_DSKTOP2, "Sustain:");
2272+
textOutShadow(358, 281, PAL_FORGRND, PAL_DSKTOP2, "Sustain:");
22732273
textOutShadow(342, 293, PAL_FORGRND, PAL_DSKTOP2, "Point");
22742274
textOutShadow(358, 306, PAL_FORGRND, PAL_DSKTOP2, "Env.loop:");
2275-
textOutShadow(342, 321, PAL_FORGRND, PAL_DSKTOP2, "Start");
2275+
textOutShadow(342, 320, PAL_FORGRND, PAL_DSKTOP2, "Start");
22762276
textOutShadow(342, 334, PAL_FORGRND, PAL_DSKTOP2, "End");
22772277
textOutShadow(443, 177, PAL_FORGRND, PAL_DSKTOP2, "Volume");
22782278
textOutShadow(443, 191, PAL_FORGRND, PAL_DSKTOP2, "Panning");
@@ -2609,8 +2609,8 @@ void drawInstEditorExt(void)
26092609
textOutShadow(4, 96, PAL_FORGRND, PAL_DSKTOP2, "Instrument Editor Extension:");
26102610
textOutShadow(20, 114, PAL_FORGRND, PAL_DSKTOP2, "Instrument MIDI enable");
26112611
textOutShadow(189, 114, PAL_FORGRND, PAL_DSKTOP2, "Mute computer");
2612-
textOutShadow(4, 133, PAL_FORGRND, PAL_DSKTOP2, "MIDI transmit channel");
2613-
textOutShadow(4, 147, PAL_FORGRND, PAL_DSKTOP2, "MIDI program");
2612+
textOutShadow(4, 132, PAL_FORGRND, PAL_DSKTOP2, "MIDI transmit channel");
2613+
textOutShadow(4, 146, PAL_FORGRND, PAL_DSKTOP2, "MIDI program");
26142614
textOutShadow(4, 160, PAL_FORGRND, PAL_DSKTOP2, "Bender range (halftones)");
26152615

26162616
if (ins == NULL)
@@ -3268,9 +3268,9 @@ static int32_t SDLCALL loadInstrThread(void *ptr)
32683268
{
32693269
s->typ &= ~32;
32703270

3271-
s->len /= 2;
3272-
s->repL /= 2;
3273-
s->repS /= 2;
3271+
s->len >>= 1;
3272+
s->repL >>= 1;
3273+
s->repS >>= 1;
32743274

32753275
newPtr = (int8_t *)realloc(s->origPek, s->len + LOOP_FIX_LEN);
32763276
if (newPtr != NULL)
@@ -3348,11 +3348,11 @@ static int32_t SDLCALL loadInstrThread(void *ptr)
33483348
{
33493349
ins->vibSweep = ih_PATWave.vibSweep;
33503350

3351-
ins->vibRate = (ih_PATWave.vibRate + 2) / 4;
3351+
ins->vibRate = (ih_PATWave.vibRate + 2) >> 2;
33523352
if (ins->vibRate > 0x3F)
33533353
ins->vibRate = 0x3F;
33543354

3355-
ins->vibDepth = (ih_PATWave.vibDepth + 1) / 2;
3355+
ins->vibDepth = (ih_PATWave.vibDepth + 1) >> 1;
33563356
if (ins->vibDepth > 0x0F)
33573357
ins->vibDepth = 0x0F;
33583358
}

0 commit comments

Comments
 (0)