Skip to content

Commit

Permalink
Pushed v1.38 code
Browse files Browse the repository at this point in the history
  • Loading branch information
8bitbubsy committed Dec 30, 2021
1 parent 6c56bc9 commit 8950a75
Show file tree
Hide file tree
Showing 39 changed files with 961 additions and 637 deletions.
19 changes: 19 additions & 0 deletions release/macos/protracker.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@
; ENTRY=VALUE (only strings can have spaces!)
;

[SAMPLE LENGTH LIMIT]
; Limit samples to 64kB (65534/$FFFE), like intended in ProTracker
; Syntax: TRUE or FALSE
; Default value: TRUE
; Comment: Setting it to FALSE will remove the 64kB (65534/$FFFE) sample
; length limit and support 128kB samples (131070/$1FFFE).
; Keep in mind that >64kB samples are not officially supported in most
; ProTracker trackers and replayers, and will often result in bugs.
;
; CAUTION: The 9xx command (Set Sample Offset) doesn't work at all if
; the sample length is above 65534/$FFFE. This is a known bug
; in all ProTracker versions. I am not fixing this bug as I
; want to keep the ProTracker 2.3D replayer quirks.
;
; Please do not change this setting unless you're aware of the problems
; you might face when creating >64k-sample PT MODs!
;
64K_LIMIT=TRUE

[VIDEO SETTINGS]
; Video scaling factor
; Syntax: 1X, 2X, 3X ... 9X
Expand Down
19 changes: 19 additions & 0 deletions release/other/protracker.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@
; ENTRY=VALUE (only strings can have spaces!)
;

[SAMPLE LENGTH LIMIT]
; Limit samples to 64kB (65534/$FFFE), like intended in ProTracker
; Syntax: TRUE or FALSE
; Default value: TRUE
; Comment: Setting it to FALSE will remove the 64kB (65534/$FFFE) sample
; length limit and support 128kB samples (131070/$1FFFE).
; Keep in mind that >64kB samples are not officially supported in most
; ProTracker trackers and replayers, and will often result in bugs.
;
; CAUTION: The 9xx command (Set Sample Offset) doesn't work at all if
; the sample length is above 65534/$FFFE. This is a known bug
; in all ProTracker versions. I am not fixing this bug as I
; want to keep the ProTracker 2.3D replayer quirks.
;
; Please do not change this setting unless you're aware of the problems
; you might face when creating >64k-sample PT MODs!
;
64K_LIMIT=TRUE

[VIDEO SETTINGS]
; Video scaling factor
; Syntax: 1X, 2X, 3X ... 9X
Expand Down
19 changes: 19 additions & 0 deletions release/win32/protracker.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@
; ENTRY=VALUE (only strings can have spaces!)
;

[SAMPLE LENGTH LIMIT]
; Limit samples to 64kB (65534/$FFFE), like intended in ProTracker
; Syntax: TRUE or FALSE
; Default value: TRUE
; Comment: Setting it to FALSE will remove the 64kB (65534/$FFFE) sample
; length limit and support 128kB samples (131070/$1FFFE).
; Keep in mind that >64kB samples are not officially supported in most
; ProTracker trackers and replayers, and will often result in bugs.
;
; CAUTION: The 9xx command (Set Sample Offset) doesn't work at all if
; the sample length is above 65534/$FFFE. This is a known bug
; in all ProTracker versions. I am not fixing this bug as I
; want to keep the ProTracker 2.3D replayer quirks.
;
; Please do not change this setting unless you're aware of the problems
; you might face when creating >64k-sample PT MODs!
;
64K_LIMIT=TRUE

[VIDEO SETTINGS]
; Video scaling factor
; Syntax: 1X, 2X, 3X ... 9X
Expand Down
19 changes: 19 additions & 0 deletions release/win64/protracker.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@
; ENTRY=VALUE (only strings can have spaces!)
;

[SAMPLE LENGTH LIMIT]
; Limit samples to 64kB (65534/$FFFE), like intended in ProTracker
; Syntax: TRUE or FALSE
; Default value: TRUE
; Comment: Setting it to FALSE will remove the 64kB (65534/$FFFE) sample
; length limit and support 128kB samples (131070/$1FFFE).
; Keep in mind that >64kB samples are not officially supported in most
; ProTracker trackers and replayers, and will often result in bugs.
;
; CAUTION: The 9xx command (Set Sample Offset) doesn't work at all if
; the sample length is above 65534/$FFFE. This is a known bug
; in all ProTracker versions. I am not fixing this bug as I
; want to keep the ProTracker 2.3D replayer quirks.
;
; Please do not change this setting unless you're aware of the problems
; you might face when creating >64k-sample PT MODs!
;
64K_LIMIT=TRUE

[VIDEO SETTINGS]
; Video scaling factor
; Syntax: 1X, 2X, 3X ... 9X
Expand Down
23 changes: 23 additions & 0 deletions src/gfx/pt2_gfx_editop.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
#include <stdint.h>

// Final unpack length: 352
// Decoded length: 88 (first four bytes of buffer)
const uint8_t fix128KPosPackedBMP[81] =
{
0x00,0x00,0x00,0x58,0xCC,0x05,0x55,0x95,0x55,0x6A,0xCC,0x04,0xAA,0xDA,0xAA,0x6A,0xCC,0x04,0xAA,0xDA,
0xAA,0x65,0x56,0xA5,0x5A,0x95,0x5A,0xDA,0xAA,0x65,0xF5,0x97,0xD6,0x5F,0xFE,0xDA,0xAA,0x65,0x57,0xD7,
0x97,0x95,0x6A,0xDA,0xAA,0x65,0xFF,0x97,0x97,0xAF,0x5A,0xDA,0xAA,0x65,0xEA,0xA5,0x5F,0x55,0x7E,0xDA,
0xAA,0x6B,0xEA,0xAB,0xFE,0xBF,0xFA,0xDA,0xAA,0x6A,0xCC,0x04,0xAA,0xDA,0xAA,0xBF,0xCC,0x04,0xFF,0xEF,
0xFF
};

// Final unpack length: 528
// Decoded length: 132 (first four bytes of buffer)
const uint8_t fix128KChordPackedBMP[110] =
{
0x00,0x00,0x00,0x84,0xCC,0x08,0x55,0x65,0x55,0x55,0x6A,0xCC,0x07,0xAA,0xB6,0xAA,0xAA,0x6A,0xCC,0x07,
0xAA,0xB6,0xAA,0xAA,0x6A,0xA9,0x6A,0xA5,0x55,0x96,0x96,0xAA,0xAA,0xB6,0xAA,0xAA,0x6A,0xA9,0x7A,0xA5,
0xFF,0xD5,0x97,0xAA,0xAA,0xB6,0xAA,0xAA,0x6A,0xA9,0x7A,0xA5,0x5A,0x95,0x57,0xAA,0xAA,0xB6,0xAA,0xAA,
0x6A,0xA9,0x7A,0xA5,0xFE,0x97,0x57,0x5A,0xAA,0xB6,0xAA,0xAA,0x6A,0xA9,0x55,0x65,0x55,0x97,0x97,0x5E,
0xAA,0xB6,0xAA,0xAA,0x6A,0xAA,0xFF,0xFB,0xFF,0xEF,0xAF,0xBE,0xAA,0xB6,0xAA,0xAA,0x6A,0xCC,0x07,0xAA,
0xB6,0xAA,0xAA,0xBF,0xCC,0x07,0xFF,0xFB,0xFF,0xFF
};

// Final unpack length: 336
// Decoded length: 84 (first four bytes of buffer)
const uint8_t editOpModeCharsPackedBMP[88] =
Expand Down
25 changes: 25 additions & 0 deletions src/gfx/pt2_gfx_tracker.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
#include <stdint.h>

// Final unpack length: 2108
// Decoded length: 527 (first four bytes of buffer)
const uint8_t tracker128KFixPackedBMP[363] =
{
0x00,0x00,0x02,0x0F,0xCC,0x0C,0xAA,0xFF,0xFF,0xEA,0xCC,0x0B,0xAA,0xAD,0x55,0x55,0xCC,0x0C,0xAA,0xDA,
0xAA,0xAA,0xA9,0x6A,0xA5,0x55,0x96,0x96,0x95,0x59,0x55,0x65,0xA5,0xAA,0xAD,0xAA,0xAA,0xAA,0x97,0xAA,
0x5F,0xFD,0x59,0x75,0xFF,0xED,0x7F,0x5E,0x5E,0xAA,0xDA,0xAA,0xAA,0xA9,0x7A,0xA5,0x56,0x95,0x57,0x5D,
0x5A,0x97,0xA5,0x55,0xEA,0xAD,0xAA,0xAA,0xAA,0x97,0xAA,0x5F,0xF9,0x75,0x75,0xE5,0xE9,0x7A,0x5F,0x5E,
0xAA,0xDA,0xAA,0xAA,0xA9,0x55,0x65,0x55,0x97,0x97,0x95,0x5E,0x97,0xA5,0xE5,0xEA,0xAD,0xAA,0xAA,0xAA,
0xAF,0xFF,0xBF,0xFE,0xFA,0xFA,0xFF,0xEA,0xFA,0xBE,0xBE,0xAA,0xDA,0xCC,0x0D,0xAA,0xAD,0xCC,0x0E,0xAA,
0xDA,0xCC,0x0D,0xAA,0xAE,0xFF,0xFF,0xCC,0x0C,0xAA,0xD5,0x55,0x5A,0xCC,0x0B,0xAA,0xAD,0xAA,0xAA,0xAA,
0x95,0x5A,0x55,0x59,0x55,0xA5,0x55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0B,0xFF,
0xFE,0xFF,0xFF
};

// Final unpack length: 81600
// Decoded length: 20400 (first four bytes of buffer)
const uint8_t trackerFramePackedBMP[8486] =
Expand Down
24 changes: 12 additions & 12 deletions src/pt2_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "pt2_rcfilter.h"
#include "pt2_ledfilter.h"
#include "pt2_downsample2x.h"
#include "pt2_hpc.h"

#define STEREO_NORM_FACTOR 0.5 /* cumulative mid/side normalization factor (1/sqrt(2))*(1/sqrt(2)) */

Expand Down Expand Up @@ -129,14 +130,13 @@ static void calcAudioLatencyVars(int32_t audioBufferSize, int32_t audioFreq)

const double dAudioLatencySecs = audioBufferSize / (double)audioFreq;

dFrac = modf(dAudioLatencySecs * editor.dPerfFreq, &dInt);
dFrac = modf(dAudioLatencySecs * hpcFreq.dFreq, &dInt);

// integer part
audLatencyPerfValInt = (int32_t)dInt;
audLatencyPerfValInt = (uint32_t)dInt;

// fractional part (scaled to 0..2^32-1)
dFrac *= UINT32_MAX+1.0;
audLatencyPerfValFrac = (uint32_t)dFrac;
audLatencyPerfValFrac = (uint32_t)((dFrac * (UINT32_MAX+1.0)) + 0.5); // rounded
}

void setSyncTickTimeLen(uint32_t timeLen, uint32_t timeLenFrac)
Expand Down Expand Up @@ -181,7 +181,7 @@ void mixerUpdateLoops(void) // updates Paula loop (+ scopes)
const moduleSample_t *s = &song->samples[editor.currSample];

paulaSetData(i, ch->n_start + s->loopStart);
paulaSetLength(i, s->loopLength >> 1);
paulaSetLength(i, (uint16_t)(s->loopLength >> 1));
}
}

Expand Down Expand Up @@ -335,7 +335,7 @@ void paulaSetData(int32_t ch, const int8_t *src)
paulaVoice_t *v = &paula[ch];

if (src == NULL)
src = &song->sampleData[RESERVED_SAMPLE_OFFSET]; // 128K reserved sample
src = &song->sampleData[config.reservedSampleOffset]; // 128K reserved sample

v->AUD_LC = src;

Expand All @@ -362,7 +362,7 @@ void paulaStartDMA(int32_t ch)
paulaVoice_t *v = &paula[ch];

if (v->AUD_LC == NULL)
v->AUD_LC = &song->sampleData[RESERVED_SAMPLE_OFFSET]; // 128K reserved sample
v->AUD_LC = &song->sampleData[config.reservedSampleOffset]; // 128K reserved sample

/* This is not really accurate to what happens on Paula
** during DMA start, but it's good enough.
Expand Down Expand Up @@ -801,8 +801,8 @@ void outputAudio(int16_t *target, int32_t numSamples)
// render to sample (PAT2SMP)

int32_t samplesTodo = numSamples;
if (editor.pat2SmpPos+samplesTodo > MAX_SAMPLE_LEN)
samplesTodo = MAX_SAMPLE_LEN-editor.pat2SmpPos;
if (editor.pat2SmpPos+samplesTodo > config.maxSampleLength)
samplesTodo = config.maxSampleLength-editor.pat2SmpPos;

// mix channels (with 2x oversampling, PAT2SMP needs it)
mixChannels(samplesTodo*2);
Expand All @@ -821,7 +821,7 @@ void outputAudio(int16_t *target, int32_t numSamples)
}

editor.pat2SmpPos += samplesTodo;
if (editor.pat2SmpPos >= MAX_SAMPLE_LEN)
if (editor.pat2SmpPos >= config.maxSampleLength)
{
editor.smpRenderingDone = true;
updateWindowTitle(MOD_IS_MODIFIED);
Expand Down Expand Up @@ -1127,10 +1127,10 @@ static void generateTickLengthTable(bool vblankTimingFlag)

// BPM -> Hz -> tick length for performance counter (syncing visuals to audio)
double dTimeInt;
double dTimeFrac = modf(editor.dPerfFreq / dHz, &dTimeInt);
double dTimeFrac = modf(hpcFreq.dFreq / dHz, &dTimeInt);
const int32_t timeInt = (int32_t)dTimeInt;

dTimeFrac = floor((UINT32_MAX+1.0) * dTimeFrac); // fractional part (scaled to 0..2^32-1)
dTimeFrac = floor((dTimeFrac * (UINT32_MAX+1.0)) + 0.5); // fractional part (scaled to 0..2^32-1)

audio.tickLengthTable[bpm-32] = ((uint64_t)timeInt << 32) | (uint32_t)dTimeFrac;
}
Expand Down
38 changes: 26 additions & 12 deletions src/pt2_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ uint32_t *samplerScreenBMP = NULL, *pat2SmpDialogBMP = NULL, *trackerFrameBMP
uint32_t *yesNoDialogBMP = NULL, *bigYesNoDialogBMP = NULL, *sampleMonitorBMP = NULL;
uint32_t *samplingBoxBMP = NULL;

// fix-bitmaps for 128K sample mode
uint32_t *fix128KTrackerBMP = NULL;
uint32_t *fix128KPosBMP = NULL;
uint32_t *fix128KChordBMP = NULL;

void createBitmaps(void)
{
uint8_t r8, g8, b8, r8_2, g8_2, b8_2;
Expand Down Expand Up @@ -161,6 +166,9 @@ void createBitmaps(void)

void freeBMPs(void)
{
if (fix128KChordBMP != NULL) free(fix128KChordBMP);
if (fix128KPosBMP != NULL) free(fix128KPosBMP);
if (fix128KTrackerBMP != NULL) free(fix128KTrackerBMP);
if (trackerFrameBMP != NULL) free(trackerFrameBMP);
if (samplerScreenBMP != NULL) free(samplerScreenBMP);
if (samplerVolumeBMP != NULL) free(samplerVolumeBMP);
Expand Down Expand Up @@ -189,27 +197,29 @@ uint32_t *unpackBMP(const uint8_t *src, uint32_t packedLen)
const uint8_t *packSrc;
uint8_t *tmpBuffer, *packDst, byteIn;
int16_t count;
uint32_t *dst, decodedLength, i;
uint32_t *dst;

int32_t decodedLength, i;

// RLE decode
decodedLength = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3];

// 2-bit to 8-bit conversion
dst = (uint32_t *)malloc((decodedLength * 4) * sizeof (int32_t));
dst = (uint32_t *)malloc(((decodedLength * 4) * sizeof (int32_t)) + 8);
if (dst == NULL)
return NULL;

tmpBuffer = (uint8_t *)malloc(decodedLength + 512); // some margin is needed, the packer is buggy
tmpBuffer = (uint8_t *)malloc(decodedLength + 128); // some margin is needed, the packer is buggy
if (tmpBuffer == NULL)
{
free(dst);
return NULL;
}

packSrc = src + 4;
packSrc = src + 4; // skip "length" field
packDst = tmpBuffer;

i = packedLen - 4;
i = packedLen - 4; // subtract "length" field
while (i > 0)
{
byteIn = *packSrc++;
Expand Down Expand Up @@ -256,6 +266,9 @@ uint32_t *unpackBMP(const uint8_t *src, uint32_t packedLen)

bool unpackBMPs(void)
{
fix128KChordBMP = unpackBMP(fix128KChordPackedBMP, sizeof (fix128KChordPackedBMP));
fix128KPosBMP = unpackBMP(fix128KPosPackedBMP, sizeof (fix128KPosPackedBMP));
fix128KTrackerBMP = unpackBMP(tracker128KFixPackedBMP, sizeof (tracker128KFixPackedBMP));
trackerFrameBMP = unpackBMP(trackerFramePackedBMP, sizeof (trackerFramePackedBMP));
samplerScreenBMP = unpackBMP(samplerScreenPackedBMP, sizeof (samplerScreenPackedBMP));
samplerVolumeBMP = unpackBMP(samplerVolumePackedBMP, sizeof (samplerVolumePackedBMP));
Expand All @@ -278,13 +291,14 @@ bool unpackBMPs(void)
sampleMonitorBMP = unpackBMP(sampleMonitorPackedBMP, sizeof (sampleMonitorPackedBMP));
samplingBoxBMP = unpackBMP(samplingBoxPackedBMP, sizeof (samplingBoxPackedBMP));

if (trackerFrameBMP == NULL || samplerScreenBMP == NULL || samplerVolumeBMP == NULL ||
clearDialogBMP == NULL || diskOpScreenBMP == NULL || mod2wavBMP == NULL ||
posEdBMP == NULL || spectrumVisualsBMP == NULL || yesNoDialogBMP == NULL ||
editOpScreen1BMP == NULL || editOpScreen2BMP == NULL || editOpScreen3BMP == NULL ||
editOpScreen4BMP == NULL || aboutScreenBMP == NULL || muteButtonsBMP == NULL ||
editOpModeCharsBMP == NULL || samplerFiltersBMP == NULL || yesNoDialogBMP == NULL ||
bigYesNoDialogBMP == NULL || sampleMonitorBMP == NULL || samplingBoxBMP == NULL)
if (fix128KTrackerBMP == NULL || fix128KPosBMP == NULL || fix128KChordBMP == NULL ||
trackerFrameBMP == NULL || samplerScreenBMP == NULL || samplerVolumeBMP == NULL ||
clearDialogBMP == NULL || diskOpScreenBMP == NULL || mod2wavBMP == NULL ||
posEdBMP == NULL || spectrumVisualsBMP == NULL || yesNoDialogBMP == NULL ||
editOpScreen1BMP == NULL || editOpScreen2BMP == NULL || editOpScreen3BMP == NULL ||
editOpScreen4BMP == NULL || aboutScreenBMP == NULL || muteButtonsBMP == NULL ||
editOpModeCharsBMP == NULL || samplerFiltersBMP == NULL || yesNoDialogBMP == NULL ||
bigYesNoDialogBMP == NULL || sampleMonitorBMP == NULL || samplingBoxBMP == NULL)
{
showErrorMsgBox("Out of memory!");
return false; // BMPs are free'd in cleanUp()
Expand Down
8 changes: 8 additions & 0 deletions src/pt2_bmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ extern const uint8_t fontBMP[6096];
extern const uint8_t aboutScreenPackedBMP[1408];
extern const uint8_t clearDialogPackedBMP[525];
extern const uint8_t diskOpScreenPackedBMP[1898];
extern const uint8_t fix128KChordPackedBMP[110];
extern const uint8_t fix128KPosPackedBMP[81];
extern const uint8_t editOpModeCharsPackedBMP[88];
extern const uint8_t editOpScreen1PackedBMP[1481];
extern const uint8_t editOpScreen2PackedBMP[1502];
Expand All @@ -34,6 +36,7 @@ extern const uint8_t samplerVolumePackedBMP[706];
extern const uint8_t samplerFiltersPackedBMP[933];
extern const uint8_t samplerScreenPackedBMP[3076];
extern const uint8_t spectrumVisualsPackedBMP[2217];
extern const uint8_t tracker128KFixPackedBMP[363];
extern const uint8_t trackerFramePackedBMP[8486];
extern const uint8_t yesNoDialogPackedBMP[476];
extern const uint8_t bigYesNoDialogPackedBMP[472];
Expand Down Expand Up @@ -68,6 +71,11 @@ extern uint32_t *pat2SmpDialogBMP;
extern uint32_t *sampleMonitorBMP;
extern uint32_t *samplingBoxBMP;

// fix-bitmaps for 128K sample mode
extern uint32_t *fix128KTrackerBMP;
extern uint32_t *fix128KPosBMP;
extern uint32_t *fix128KChordBMP;

bool unpackBMPs(void);
void createBitmaps(void);
void freeBMPs(void);
Loading

0 comments on commit 8950a75

Please sign in to comment.