ref: 4188e80007f412afb1eaa79901189675073db0ef
parent: bc53178ef2eec6e25e5780cf3a6d41a976ca4395
author: Olav Sørensen <olav.sorensen@live.no>
date: Sat Aug 12 16:11:33 EDT 2023
Pushed v1.62 code - Bugfix: It was possible to scroll out of bounds in Disk Op. by using shift+key - Bugfix: Don't set "song unsaved" flag if text editing didn't make a change - Bugfix: Editing the Disk Op. path text would set the "song unsaved" flag (lol) - Bugfix: Using the "CLEAR" button while Edit. Op. or the about screen was open could lead to a screen redrawing issue - Disk Op. file entry jumping (left shift + key) now works a bit differently. If the last pressed jump key didn't change, cycle through pages if there are more matches to be found. This allows for quicker module finding. Thanks to Fireb0y for this suggestion! - Re-implemented the Pos Ed. pattern naming feature. Be aware that this data is not saved to the module, and is only used to temporarily keep track of the patterns while making the module. Yes, it's a quite crippled feature, but some people asked me to implement it again! - Code refactoring, a small portion of the code should be easier to understand now (still a long way to go...) - Windows/macOS: Updated SDL to v2.28.2
--- a/release/macos/pt2-clone-macos.app/Contents/Frameworks/SDL2.framework/Versions/A/Headers/SDL_atomic.h
+++ b/release/macos/pt2-clone-macos.app/Contents/Frameworks/SDL2.framework/Versions/A/Headers/SDL_atomic.h
@@ -240,7 +240,7 @@
/* "REP NOP" is PAUSE, coded for tools that don't know it by that name. */
#if (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))
#define SDL_CPUPauseInstruction() __asm__ __volatile__("pause\n") /* Some assemblers can't do REP NOP, so go with PAUSE. */
-#elif (defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__)
+#elif (defined(__arm__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7) || defined(__aarch64__)
#define SDL_CPUPauseInstruction() __asm__ __volatile__("yield" ::: "memory")
#elif (defined(__powerpc__) || defined(__powerpc64__))
#define SDL_CPUPauseInstruction() __asm__ __volatile__("or 27,27,27");
--- a/release/macos/pt2-clone-macos.app/Contents/Frameworks/SDL2.framework/Versions/A/Headers/SDL_hints.h
+++ b/release/macos/pt2-clone-macos.app/Contents/Frameworks/SDL2.framework/Versions/A/Headers/SDL_hints.h
@@ -1008,6 +1008,15 @@
#define SDL_HINT_JOYSTICK_THREAD "SDL_JOYSTICK_THREAD"
/**
+ * \brief A variable controlling whether Windows.Gaming.Input should be used for controller handling.
+ *
+ * This variable can be set to the following values:
+ * "0" - WGI is not used
+ * "1" - WGI is used (the default)
+ */
+#define SDL_HINT_JOYSTICK_WGI "SDL_JOYSTICK_WGI"
+
+/**
* \brief Determines whether SDL enforces that DRM master is required in order
* to initialize the KMSDRM video backend.
*
--- a/release/macos/pt2-clone-macos.app/Contents/Frameworks/SDL2.framework/Versions/A/Headers/SDL_revision.h
+++ b/release/macos/pt2-clone-macos.app/Contents/Frameworks/SDL2.framework/Versions/A/Headers/SDL_revision.h
@@ -1,7 +1,7 @@
/* Generated by updaterev.sh, do not edit */
#ifdef SDL_VENDOR_INFO
-#define SDL_REVISION "SDL-release-2.28.0-0-gffa78e6be (" SDL_VENDOR_INFO ")"
+#define SDL_REVISION "SDL-release-2.28.2-0-g031912c4b (" SDL_VENDOR_INFO ")"
#else
-#define SDL_REVISION "SDL-release-2.28.0-0-gffa78e6be"
+#define SDL_REVISION "SDL-release-2.28.2-0-g031912c4b"
#endif
#define SDL_REVISION_NUMBER 0
--- a/release/macos/pt2-clone-macos.app/Contents/Frameworks/SDL2.framework/Versions/A/Headers/SDL_version.h
+++ b/release/macos/pt2-clone-macos.app/Contents/Frameworks/SDL2.framework/Versions/A/Headers/SDL_version.h
@@ -59,7 +59,7 @@
*/
#define SDL_MAJOR_VERSION 2
#define SDL_MINOR_VERSION 28
-#define SDL_PATCHLEVEL 0
+#define SDL_PATCHLEVEL 2
/**
* Macro to determine SDL version program was compiled against.
--- a/release/macos/pt2-clone-macos.app/Contents/Frameworks/SDL2.framework/Versions/A/Resources/Info.plist
+++ b/release/macos/pt2-clone-macos.app/Contents/Frameworks/SDL2.framework/Versions/A/Resources/Info.plist
@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
- <string>22F66</string>
+ <string>22F82</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
@@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
- <string>2.28.0</string>
+ <string>2.28.2</string>
<key>CFBundleSignature</key>
<string>SDLX</string>
<key>CFBundleSupportedPlatforms</key>
@@ -27,7 +27,7 @@
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
- <string>2.28.0</string>
+ <string>2.28.2</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
binary files a/release/macos/pt2-clone-macos.app/Contents/Frameworks/SDL2.framework/Versions/A/SDL2 b/release/macos/pt2-clone-macos.app/Contents/Frameworks/SDL2.framework/Versions/A/SDL2 differ
--- a/release/macos/pt2-clone-macos.app/Contents/Frameworks/SDL2.framework/Versions/A/_CodeSignature/CodeResources
+++ b/release/macos/pt2-clone-macos.app/Contents/Frameworks/SDL2.framework/Versions/A/_CodeSignature/CodeResources
@@ -14,7 +14,7 @@
</data>
<key>Resources/Info.plist</key>
<data>
- MP8SsWNX9fsyVRo11YwxKezmPug=
+ W12gMTmaD7mAaqt5KDExNr0RKgM=
</data>
<key>Resources/License.txt</key>
<data>
@@ -57,11 +57,11 @@
<dict>
<key>hash</key>
<data>
- FTCyRgMQ1IzdGYV2XbCDSQ7JNec=
+ yrv6uC/CjYpeCteZDUbBFr2nwiU=
</data>
<key>hash2</key>
<data>
- 4iFngSAorzMM520V+2V1sriu9mL12sLlPrhNfgT12Ck=
+ Mrfc980NeBAvQ5I040V8xusL6cHBcFfPaA9B2prA4dw=
</data>
</dict>
<key>Headers/SDL_audio.h</key>
@@ -255,11 +255,11 @@
<dict>
<key>hash</key>
<data>
- M/nqf8jyrXJ9IrgLrVffOZG4Jlo=
+ ddWp0+3xCgtIDS6440MPWGe9/04=
</data>
<key>hash2</key>
<data>
- nCUBVEvtWTQ2Ab/H1a9n4I68tT572DhjMnne+N52bwY=
+ AhMB8T7Wo/c4Ix80R5g/zjWalP7OnCAvnIVEdw8SsLU=
</data>
</dict>
<key>Headers/SDL_joystick.h</key>
@@ -563,11 +563,11 @@
<dict>
<key>hash</key>
<data>
- sRLTPAglYSZ19Pdm+afA2j47taM=
+ 2zFl2NItuevlztjQRT+teL9UtjY=
</data>
<key>hash2</key>
<data>
- Fo7p72CdM/uZzX9nxLeCot/MrKYwSKmo0ESISIMTIOI=
+ 1tOTMLCAdQRkl90qB0NtmJIvpr0E4EFoXWZ+4NhffJE=
</data>
</dict>
<key>Headers/SDL_rwops.h</key>
@@ -706,11 +706,11 @@
<dict>
<key>hash</key>
<data>
- BrMh/0kZeBHu8Xr+/5hS8IHcMfU=
+ gBiHBn/GcLooPsMb3m+jTv+T1Is=
</data>
<key>hash2</key>
<data>
- tIqaCIDNMsT9rQ9arELIo8WVF04pSMBtxaavylyyrK4=
+ Mgpkfe47yvQhBrQOqP9Xij7/ILlB/q7anYqKeYoRMDw=
</data>
</dict>
<key>Headers/SDL_video.h</key>
@@ -783,11 +783,11 @@
<dict>
<key>hash</key>
<data>
- MP8SsWNX9fsyVRo11YwxKezmPug=
+ W12gMTmaD7mAaqt5KDExNr0RKgM=
</data>
<key>hash2</key>
<data>
- JS+9bRfZuLgojqjIgCYRqSXUyJ5L/MJO+Cyss5R17Rs=
+ ct5khvInzhQJNnmPb2gTqlooYCRrHKg1NnWxtf/AwC8=
</data>
</dict>
<key>Resources/License.txt</key>
binary files a/release/win32/SDL2.dll b/release/win32/SDL2.dll differ
binary files a/release/win64/SDL2.dll b/release/win64/SDL2.dll differ
--- a/src/modloaders/pt2_load_mod15.c
+++ b/src/modloaders/pt2_load_mod15.c
@@ -57,9 +57,9 @@
s->loopLength = ((p[0] << 8) | p[1]) * 2; p += 2;
}
- m->header.numOrders = *p++;
+ m->header.songLength = *p++;
- if (m->header.numOrders == 0 || m->header.numOrders > 128)
+ if (m->header.songLength == 0 || m->header.songLength > 128)
{
displayErrorMsg("NOT A MOD FILE !");
goto loadError;
@@ -96,11 +96,11 @@
// read orders and count number of patterns
int32_t numPatterns = 0;
- for (int32_t i = 0; i < MOD_ORDERS; i++)
+ for (int32_t i = 0; i < 128; i++)
{
- m->header.order[i] = *p++;
- if (m->header.order[i] > numPatterns)
- numPatterns = m->header.order[i];
+ m->header.patternTable[i] = *p++;
+ if (m->header.patternTable[i] > numPatterns)
+ numPatterns = m->header.patternTable[i];
}
numPatterns++;
--- a/src/modloaders/pt2_load_mod31.c
+++ b/src/modloaders/pt2_load_mod31.c
@@ -78,13 +78,13 @@
}
}
- m->header.numOrders = *p++;
+ m->header.songLength = *p++;
p++; // skip uninteresting field (127 in PT MOds, "restart pos" in PC MODs)
- if (modFormat == FORMAT_PT && m->header.numOrders == 129)
- m->header.numOrders = 127; // fixes a specific copy of beatwave.mod (XXX: hackish...)
+ if (modFormat == FORMAT_PT && m->header.songLength == 129)
+ m->header.songLength = 127; // fixes a specific copy of beatwave.mod (XXX: hackish...)
- if (m->header.numOrders == 0 || m->header.numOrders > 129)
+ if (m->header.songLength == 0 || m->header.songLength > 129)
{
displayErrorMsg("NOT A MOD FILE !");
goto loadError;
@@ -92,11 +92,11 @@
// read orders and count number of patterns
int32_t numPatterns = 0;
- for (int32_t i = 0; i < MOD_ORDERS; i++)
+ for (int32_t i = 0; i < 128; i++)
{
- m->header.order[i] = *p++;
- if (m->header.order[i] > numPatterns)
- numPatterns = m->header.order[i];
+ m->header.patternTable[i] = *p++;
+ if (m->header.patternTable[i] > numPatterns)
+ numPatterns = m->header.patternTable[i];
}
numPatterns++;
--- a/src/pt2_askbox.c
+++ b/src/pt2_askbox.c
@@ -10,6 +10,7 @@
#include "pt2_mod2wav.h"
#include "pt2_pat2smp.h"
#include "pt2_askbox.h"
+#include "pt2_posed.h"
#define INIT_BUTTONS(num, abortRetVal, defRetVal) \
d.numButtons = num; \
--- a/src/pt2_diskop.c
+++ b/src/pt2_diskop.c
@@ -290,22 +290,55 @@
{
if (diskOpEntry != NULL)
{
- for (int32_t i = 0; i < diskop.numEntries; i++)
+ fileEntry_t *f;
+
+ // if last jump key was the same, go to next page of matching character
+ if (diskop.numEntries > DISKOP_LINES && diskop.lastEntryJumpKey == jumpToChar)
{
- if (jumpToChar == diskOpEntry[i].firstAnsiChar)
+ for (int32_t i = 0; i < DISKOP_LINES; i++)
{
- // fix visual overrun
- if (diskop.numEntries > DISKOP_LINES && i > diskop.numEntries-DISKOP_LINES)
- i = diskop.numEntries - DISKOP_LINES;
+ int32_t offset = diskop.scrollOffset+DISKOP_LINES;
+ if (offset > diskop.numEntries-DISKOP_LINES)
+ offset = diskop.numEntries-DISKOP_LINES;
- diskop.scrollOffset = i;
- ui.updateDiskOpFileList = true;
+ f = &diskOpEntry[offset];
+
+ if (!f->isDir && f->firstAnsiChar == jumpToChar)
+ {
+ diskop.scrollOffset += DISKOP_LINES;
+ if (diskop.scrollOffset > diskop.numEntries-DISKOP_LINES)
+ diskop.scrollOffset = diskop.numEntries-DISKOP_LINES;
+
+ ui.updateDiskOpFileList = true;
+ return;
+ }
+ }
+ }
+
+ diskop.lastEntryJumpKey = jumpToChar;
+
+ // jump to first match from the beginning of file list
+
+ f = diskOpEntry;
+ for (int32_t i = 0; i < diskop.numEntries; i++, f++)
+ {
+ if (!f->isDir && f->firstAnsiChar == jumpToChar)
+ {
+ if (diskop.numEntries > DISKOP_LINES)
+ {
+ diskop.scrollOffset = i;
+ if (diskop.scrollOffset > diskop.numEntries-DISKOP_LINES)
+ diskop.scrollOffset = diskop.numEntries-DISKOP_LINES;
+
+ ui.updateDiskOpFileList = true;
+ }
+
return;
}
}
}
- // character not found in file list, show red mouse pointer (error)!
+ // character not found in file list, show red mouse pointer (error)
editor.errorMsgActive = true;
editor.errorMsgBlock = true;
editor.errorMsgCounter = 0;
@@ -423,6 +456,8 @@
ui.updateDiskOpFileList = true;
diskop.scrollOffset = 0;
+ diskop.lastEntryJumpKey = SDLK_UNKNOWN;
+
return true;
}
else
@@ -562,6 +597,7 @@
fileEntry_t tmpBuffer;
diskop.scrollOffset = 0;
+ diskop.lastEntryJumpKey = SDLK_UNKNOWN;
// do we have a path set?
if (editor.currPathU[0] == '\0')
@@ -917,11 +953,17 @@
// print disk op. path
for (int32_t i = 0; i < 26; i++)
{
- char tmpChar = editor.currPath[ui.diskOpPathTextOffset+i];
- if (tmpChar == '\0')
- tmpChar = '_';
+ char ch;
+
+ if (ui.editTextFlag)
+ ch = editor.currPath[textEdit.scrollOffset + i];
+ else
+ ch = editor.currPath[i];
- charOutBg(24 + (i * FONT_CHAR_W), 25, tmpChar, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
+ if (ch == '\0')
+ ch = '_';
+
+ charOutBg(24 + (i * FONT_CHAR_W), 25, ch, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
}
}
}
--- a/src/pt2_edit.c
+++ b/src/pt2_edit.c
@@ -49,617 +49,6 @@
-1, 24, 26, 28
};
-// used for re-rendering text object while editing it
-void updateTextObject(int16_t editObject)
-{
- switch (editObject)
- {
- default: break;
- case PTB_SONGNAME: ui.updateSongName = true; break;
- case PTB_SAMPLENAME: ui.updateCurrSampleName = true; break;
- case PTB_PE_PATT: ui.updatePosEd = true; break;
- case PTB_EO_QUANTIZE: ui.updateQuantizeText = true; break;
- case PTB_EO_METRO_1: ui.updateMetro1Text = true; break;
- case PTB_EO_METRO_2: ui.updateMetro2Text = true; break;
- case PTB_EO_FROM_NUM: ui.updateFromText = true; break;
- case PTB_EO_TO_NUM: ui.updateToText = true; break;
- case PTB_EO_MIX: ui.updateMixText = true; break;
- case PTB_EO_POS_NUM: ui.updatePosText = true; break;
- case PTB_EO_MOD_NUM: ui.updateModText = true; break;
- case PTB_EO_VOL_NUM: ui.updateVolText = true; break;
- case PTB_DO_DATAPATH: ui.updateDiskOpPathText = true; break;
- case PTB_POSS: ui.updateSongPos = true; break;
- case PTB_PATTERNS: ui.updateSongPattern = true; break;
- case PTB_LENGTHS: ui.updateSongLength = true; break;
- case PTB_SAMPLES: ui.updateCurrSampleNum = true; break;
- case PTB_SVOLUMES: ui.updateCurrSampleVolume = true; break;
- case PTB_SLENGTHS: ui.updateCurrSampleLength = true; break;
- case PTB_SREPEATS: ui.updateCurrSampleRepeat = true; break;
- case PTB_SREPLENS: ui.updateCurrSampleReplen = true; break;
- case PTB_PATTDATA: ui.updateCurrPattText = true; break;
- case PTB_SA_VOL_FROM_NUM: ui.updateVolFromText = true; break;
- case PTB_SA_VOL_TO_NUM: ui.updateVolToText = true; break;
- case PTB_SA_FIL_LP_CUTOFF: ui.updateLPText = true; break;
- case PTB_SA_FIL_HP_CUTOFF: ui.updateHPText = true; break;
- }
-}
-
-void exitGetTextLine(bool updateValue)
-{
- int8_t tmp8;
- int16_t tmp16;
- int32_t tmp32;
-
- SDL_StopTextInput();
-
- // if user updated the disk op path text
- if (ui.diskOpScreenShown && ui.editObject == PTB_DO_DATAPATH)
- {
- UNICHAR *pathU = (UNICHAR *)calloc(PATH_MAX + 2, sizeof (UNICHAR));
- if (pathU != NULL)
- {
-#ifdef _WIN32
- MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, editor.currPath, -1, pathU, PATH_MAX);
-#else
- strcpy(pathU, editor.currPath);
-#endif
- diskOpSetPath(pathU, DISKOP_CACHE);
- free(pathU);
- }
- }
-
- if (ui.editTextType != TEXT_EDIT_STRING)
- {
- if (ui.dstPos != ui.numLen)
- removeTextEditMarker();
-
- updateTextObject(ui.editObject);
- }
- else
- {
- removeTextEditMarker();
-
- // yet another kludge...
- if (ui.editObject == PTB_PE_PATT)
- ui.updatePosEd = true;
- }
-
- ui.editTextFlag = false;
-
- ui.lineCurX = 0;
- ui.lineCurY = 0;
- ui.editPos = NULL;
- ui.dstPos = 0;
-
- if (ui.editTextType == TEXT_EDIT_STRING)
- {
- if (ui.dstOffset != NULL)
- *ui.dstOffset = '\0';
-
- pointerSetPreviousMode();
-
- if (!editor.mixFlag)
- updateWindowTitle(MOD_IS_MODIFIED);
- }
- else
- {
- // set back GUI text pointers and update values (if requested)
-
- moduleSample_t *s = &song->samples[editor.currSample];
- switch (ui.editObject)
- {
- case PTB_SA_FIL_LP_CUTOFF:
- {
- editor.lpCutOffDisp = &editor.lpCutOff;
-
- if (updateValue)
- {
- editor.lpCutOff = ui.tmpDisp16;
- if (editor.lpCutOff > (uint16_t)(FILTERS_BASE_FREQ/2))
- editor.lpCutOff = (uint16_t)(FILTERS_BASE_FREQ/2);
-
- ui.updateLPText = true;
- }
- }
- break;
-
- case PTB_SA_FIL_HP_CUTOFF:
- {
- editor.hpCutOffDisp = &editor.hpCutOff;
-
- if (updateValue)
- {
- editor.hpCutOff = ui.tmpDisp16;
- if (editor.hpCutOff > (uint16_t)(FILTERS_BASE_FREQ/2))
- editor.hpCutOff = (uint16_t)(FILTERS_BASE_FREQ/2);
-
- ui.updateHPText = true;
- }
- }
- break;
-
- case PTB_SA_VOL_FROM_NUM:
- {
- editor.vol1Disp = &editor.vol1;
-
- if (updateValue)
- {
- editor.vol1 = ui.tmpDisp16;
- if (editor.vol1 > 200)
- editor.vol1 = 200;
-
- ui.updateVolFromText = true;
- showVolFromSlider();
- }
- }
- break;
-
- case PTB_SA_VOL_TO_NUM:
- {
- editor.vol2Disp = &editor.vol2;
-
- if (updateValue)
- {
- editor.vol2 = ui.tmpDisp16;
- if (editor.vol2 > 200)
- editor.vol2 = 200;
-
- ui.updateVolToText = true;
- showVolToSlider();
- }
- }
- break;
-
- case PTB_EO_VOL_NUM:
- {
- editor.sampleVolDisp = &editor.sampleVol;
-
- if (updateValue)
- {
- editor.sampleVol = ui.tmpDisp16;
- ui.updateVolText = true;
- }
- }
- break;
-
- case PTB_EO_POS_NUM:
- {
- editor.samplePosDisp = &editor.samplePos;
-
- if (updateValue)
- {
- editor.samplePos = ui.tmpDisp32;
- if (editor.samplePos > config.maxSampleLength)
- editor.samplePos = config.maxSampleLength;
-
- if (editor.samplePos > song->samples[editor.currSample].length)
- editor.samplePos = song->samples[editor.currSample].length;
-
- ui.updatePosText = true;
- }
- }
- break;
-
- case PTB_EO_QUANTIZE:
- {
- editor.quantizeValueDisp = &config.quantizeValue;
-
- if (updateValue)
- {
- if (ui.tmpDisp16 > 63)
- ui.tmpDisp16 = 63;
-
- config.quantizeValue = ui.tmpDisp16;
- ui.updateQuantizeText = true;
- }
- }
- break;
-
- case PTB_EO_METRO_1: // metronome speed
- {
- editor.metroSpeedDisp = &editor.metroSpeed;
-
- if (updateValue)
- {
- if (ui.tmpDisp16 > 64)
- ui.tmpDisp16 = 64;
-
- editor.metroSpeed = ui.tmpDisp16;
- ui.updateMetro1Text = true;
- }
- }
- break;
-
- case PTB_EO_METRO_2: // metronome channel
- {
- editor.metroChannelDisp = &editor.metroChannel;
-
- if (updateValue)
- {
- if (ui.tmpDisp16 > 4)
- ui.tmpDisp16 = 4;
-
- editor.metroChannel = ui.tmpDisp16;
- ui.updateMetro2Text = true;
- }
- }
- break;
-
- case PTB_EO_FROM_NUM:
- {
- editor.sampleFromDisp = &editor.sampleFrom;
-
- if (updateValue)
- {
- editor.sampleFrom = ui.tmpDisp8;
-
- // signed check + normal check
- if (editor.sampleFrom < 0x00 || editor.sampleFrom > 0x1F)
- editor.sampleFrom = 0x1F;
-
- ui.updateFromText = true;
- }
- }
- break;
-
- case PTB_EO_TO_NUM:
- {
- editor.sampleToDisp = &editor.sampleTo;
-
- if (updateValue)
- {
- editor.sampleTo = ui.tmpDisp8;
-
- // signed check + normal check
- if (editor.sampleTo < 0x00 || editor.sampleTo > 0x1F)
- editor.sampleTo = 0x1F;
-
- ui.updateToText = true;
- }
- }
- break;
-
- case PTB_PE_PATT:
- {
- int16_t posEdPos = song->currOrder;
- if (posEdPos > song->header.numOrders-1)
- posEdPos = song->header.numOrders-1;
-
- editor.currPosEdPattDisp = &song->header.order[posEdPos];
-
- if (updateValue)
- {
- if (ui.tmpDisp16 > MAX_PATTERNS-1)
- ui.tmpDisp16 = MAX_PATTERNS-1;
-
- song->header.order[posEdPos] = ui.tmpDisp16;
-
- updateWindowTitle(MOD_IS_MODIFIED);
-
- if (ui.posEdScreenShown)
- ui.updatePosEd = true;
-
- ui.updateSongPattern = true;
- ui.updateSongSize = true;
- }
- }
- break;
-
- case PTB_POSS:
- {
- editor.currPosDisp = &song->currOrder;
-
- if (updateValue)
- {
- tmp16 = ui.tmpDisp16;
- if (tmp16 > 126)
- tmp16 = 126;
-
- if (song->currOrder != tmp16)
- {
- song->currOrder = tmp16;
- editor.currPatternDisp = &song->header.order[song->currOrder];
-
- if (ui.posEdScreenShown)
- ui.updatePosEd = true;
-
- ui.updateSongPos = true;
- ui.updatePatternData = true;
- }
- }
- }
- break;
-
- case PTB_PATTERNS:
- {
- editor.currPatternDisp = &song->header.order[song->currOrder];
-
- if (updateValue)
- {
- tmp16 = ui.tmpDisp16;
- if (tmp16 > MAX_PATTERNS-1)
- tmp16 = MAX_PATTERNS-1;
-
- if (song->header.order[song->currOrder] != tmp16)
- {
- song->header.order[song->currOrder] = tmp16;
-
- updateWindowTitle(MOD_IS_MODIFIED);
-
- if (ui.posEdScreenShown)
- ui.updatePosEd = true;
-
- ui.updateSongPattern = true;
- ui.updateSongSize = true;
- }
- }
- }
- break;
-
- case PTB_LENGTHS:
- {
- editor.currLengthDisp = &song->header.numOrders;
-
- if (updateValue)
- {
- tmp16 = CLAMP(ui.tmpDisp16, 1, 127);
-
- if (song->header.numOrders != tmp16)
- {
- song->header.numOrders = tmp16;
-
- int16_t posEdPos = song->currOrder;
- if (posEdPos > song->header.numOrders-1)
- posEdPos = song->header.numOrders-1;
-
- editor.currPosEdPattDisp = &song->header.order[posEdPos];
-
- if (ui.posEdScreenShown)
- ui.updatePosEd = true;
-
- ui.updateSongLength = true;
- ui.updateSongSize = true;
- updateWindowTitle(MOD_IS_MODIFIED);
- }
- }
- }
- break;
-
- case PTB_PATTDATA:
- {
- editor.currEditPatternDisp = &song->currPattern;
-
- if (updateValue)
- {
- if (song->currPattern != ui.tmpDisp16)
- {
- setPattern(ui.tmpDisp16);
- ui.updatePatternData = true;
- ui.updateCurrPattText = true;
- }
- }
- }
- break;
-
- case PTB_SAMPLES:
- {
- editor.currSampleDisp = &editor.currSample;
-
- if (updateValue)
- {
- tmp8 = ui.tmpDisp8;
- if (tmp8 < 0x00) // (signed) if >0x7F was entered, clamp to 0x1F
- tmp8 = 0x1F;
-
- tmp8 = CLAMP(tmp8, 0x01, 0x1F) - 1;
-
- if (tmp8 != editor.currSample)
- {
- editor.currSample = tmp8;
- updateCurrSample();
- }
- }
- }
- break;
-
- case PTB_SVOLUMES:
- {
- s->volumeDisp = &s->volume;
-
- if (updateValue)
- {
- tmp8 = ui.tmpDisp8;
-
- // signed check + normal check
- if (tmp8 < 0x00 || tmp8 > 0x40)
- tmp8 = 0x40;
-
- if (s->volume != tmp8)
- {
- s->volume = tmp8;
- ui.updateCurrSampleVolume = true;
- updateWindowTitle(MOD_IS_MODIFIED);
- }
- }
- }
- break;
-
- case PTB_SLENGTHS:
- {
- s->lengthDisp = &s->length;
-
- if (updateValue)
- {
- tmp32 = ui.tmpDisp32 & ~1; // even'ify
- if (tmp32 > config.maxSampleLength)
- tmp32 = config.maxSampleLength;
-
- if (s->loopStart+s->loopLength > 2)
- {
- if (tmp32 < s->loopStart+s->loopLength)
- tmp32 = s->loopStart+s->loopLength;
- }
-
- tmp32 &= ~1;
-
- if (s->length != tmp32)
- {
- turnOffVoices();
- s->length = tmp32;
-
- ui.updateCurrSampleLength = true;
- ui.updateSongSize = true;
- updateSamplePos();
-
- if (ui.samplerScreenShown)
- redrawSample();
-
- recalcChordLength();
- updateWindowTitle(MOD_IS_MODIFIED);
- }
- }
- }
- break;
-
- case PTB_SREPEATS:
- {
- s->loopStartDisp = &s->loopStart;
-
- if (updateValue)
- {
- tmp32 = ui.tmpDisp32 & ~1; // even'ify
- if (tmp32 > config.maxSampleLength)
- tmp32 = config.maxSampleLength;
-
- if (s->length >= s->loopLength)
- {
- if (tmp32+s->loopLength > s->length)
- tmp32 = s->length - s->loopLength;
- }
- else
- {
- tmp32 = 0;
- }
-
- tmp32 &= ~1;
-
- if (s->loopStart != tmp32)
- {
- turnOffVoices();
- s->loopStart = tmp32;
- updatePaulaLoops();
-
- ui.updateCurrSampleRepeat = true;
-
- if (ui.editOpScreenShown && ui.editOpScreen == 3)
- ui.updateChordLengthText = true;
-
- if (ui.samplerScreenShown)
- setLoopSprites();
-
- updateWindowTitle(MOD_IS_MODIFIED);
- }
- }
- }
- break;
-
- case PTB_SREPLENS:
- {
- s->loopLengthDisp = &s->loopLength;
-
- if (updateValue)
- {
- tmp32 = ui.tmpDisp32 & ~1; // even'ify
- if (tmp32 > config.maxSampleLength)
- tmp32 = config.maxSampleLength;
-
- if (s->length >= s->loopStart)
- {
- if (s->loopStart+tmp32 > s->length)
- tmp32 = s->length - s->loopStart;
- }
- else
- {
- tmp32 = 2;
- }
-
- tmp32 &= ~1;
-
- if (tmp32 < 2)
- tmp32 = 2;
-
- if (s->loopLength != tmp32)
- {
- turnOffVoices();
- s->loopLength = tmp32;
- updatePaulaLoops();
-
- ui.updateCurrSampleReplen = true;
- if (ui.editOpScreenShown && ui.editOpScreen == 3)
- ui.updateChordLengthText = true;
-
- if (ui.samplerScreenShown)
- setLoopSprites();
-
- updateWindowTitle(MOD_IS_MODIFIED);
- }
- }
- }
- break;
-
- default: break;
- }
-
- pointerSetPreviousMode();
- }
-
- ui.editTextType = 0;
-}
-
-void getTextLine(int16_t editObject)
-{
- pointerSetMode(POINTER_MODE_MSG1, NO_CARRY);
-
- ui.lineCurY = (ui.editTextPos / 40) + 5;
- ui.lineCurX = ((ui.editTextPos % 40) * FONT_CHAR_W) + 4;
- ui.dstPtr = ui.showTextPtr;
- ui.editPos = ui.showTextPtr;
- ui.dstPos = 0;
- ui.editTextFlag = true;
- ui.editTextType = TEXT_EDIT_STRING;
- ui.editObject = editObject;
-
- if (ui.dstOffset != NULL)
- ui.dstOffset[0] = '\0';
-
- // kludge
- if (editor.mixFlag)
- {
- textCharNext();
- textCharNext();
- textCharNext();
- textCharNext();
- }
-
- renderTextEditMarker();
- SDL_StartTextInput();
-}
-
-void getNumLine(uint8_t type, int16_t editObject)
-{
- pointerSetMode(POINTER_MODE_MSG1, NO_CARRY);
-
- ui.lineCurY = (ui.editTextPos / 40) + 5;
- ui.lineCurX = ((ui.editTextPos % 40) * FONT_CHAR_W) + 4;
- ui.dstPos = 0;
- ui.editTextFlag = true;
- ui.editTextType = type;
- ui.editObject = editObject;
-
- renderTextEditMarker();
- SDL_StartTextInput();
-}
-
static uint8_t quantizeCheck(uint8_t row)
{
assert(song != NULL);
--- a/src/pt2_edit.h
+++ b/src/pt2_edit.h
@@ -17,11 +17,7 @@
void pattNoteDown(bool sampleAllFlag);
void pattOctaUp(bool sampleAllFlag);
void pattOctaDown(bool sampleAllFlag);
-void exitGetTextLine(bool updateValue);
-void getTextLine(int16_t editObject);
-void getNumLine(uint8_t type, int16_t editObject);
void handleEditKeys(SDL_Scancode scancode, bool normalMode);
bool handleSpecialKeys(SDL_Scancode scancode);
int8_t keyToNote(SDL_Scancode scancode);
-void updateTextObject(int16_t editObject);
void handleSampleJamming(SDL_Scancode scancode);
--- a/src/pt2_header.h
+++ b/src/pt2_header.h
@@ -14,7 +14,7 @@
#include "pt2_unicode.h"
#include "pt2_palette.h"
-#define PROG_VER_STR "1.61"
+#define PROG_VER_STR "1.62"
#ifdef _WIN32
#define DIR_DELIMITER '\\'
@@ -55,7 +55,6 @@
#define MOD_ROWS 64
#define MOD_SAMPLES 31
-#define MOD_ORDERS 128
#define MAX_PATTERNS 100
#define SCOPE_WIDTH 40
@@ -63,8 +62,6 @@
#define SPECTRUM_BAR_NUM 23
#define SPECTRUM_BAR_HEIGHT 36
#define SPECTRUM_BAR_WIDTH 6
-
-#define POSED_LIST_SIZE 12
// Amount of video frames. 14 (PT on Amiga) -> 17 (converted from 49.92Hz to 60Hz)
#define KEYB_REPEAT_DELAY 17
--- a/src/pt2_keyboard.c
+++ b/src/pt2_keyboard.c
@@ -27,6 +27,8 @@
#include "pt2_chordmaker.h"
#include "pt2_askbox.h"
#include "pt2_replayer.h"
+#include "pt2_posed.h"
+#include "pt2_textedit.h"
#if defined _WIN32 && !defined _DEBUG
extern bool windowsKeyIsDown;
@@ -41,13 +43,6 @@
bool handleTextEditMode(SDL_Scancode scancode);
-void gotoNextMulti(void)
-{
- cursor.channel = (editor.multiModeNext[cursor.channel] - 1) & 3;
- cursor.pos = cursor.channel * 6;
- updateCursorPos();
-}
-
void readKeyModifiers(void)
{
const SDL_Keymod modState = SDL_GetModState();
@@ -107,169 +102,6 @@
}
#endif
-// these four functions are for the text edit cursor
-void textMarkerMoveLeft(void)
-{
- if (ui.dstPos > 0)
- {
- removeTextEditMarker();
- ui.dstPos--;
- ui.lineCurX -= FONT_CHAR_W;
- renderTextEditMarker();
- }
- else
- {
- if (ui.dstOffset != NULL)
- {
- (*ui.dstOffset)--;
- if (ui.editObject == PTB_DO_DATAPATH)
- ui.updateDiskOpPathText = true;
- }
- }
-}
-
-void textMarkerMoveRight(void)
-{
- if (ui.editTextType == TEXT_EDIT_STRING)
- {
- if (ui.dstPos < ui.textLength-1)
- {
- removeTextEditMarker();
- ui.dstPos++;
- ui.lineCurX += FONT_CHAR_W;
- renderTextEditMarker();
- }
- else
- {
- if (ui.dstOffset != NULL)
- {
- (*ui.dstOffset)++;
- if (ui.editObject == PTB_DO_DATAPATH)
- ui.updateDiskOpPathText = true;
- }
- }
- }
- else
- {
- // we end up here when entering a number/hex digit
-
- if (ui.dstPos < ui.numLen)
- removeTextEditMarker();
-
- ui.dstPos++;
- ui.lineCurX += FONT_CHAR_W;
-
- if (ui.dstPos < ui.numLen)
- renderTextEditMarker();
-
- // don't clamp, dstPos is tested elsewhere to check if done editing a number
- }
-}
-
-void textCharPrevious(void)
-{
- if (ui.editTextType != TEXT_EDIT_STRING)
- {
- if (ui.dstPos > 0)
- {
- removeTextEditMarker();
- ui.dstPos--;
- ui.lineCurX -= FONT_CHAR_W;
- renderTextEditMarker();
- }
-
- return;
- }
-
- if (editor.mixFlag && ui.dstPos <= 4)
- return;
-
- if (ui.editPos > ui.showTextPtr)
- {
- removeTextEditMarker();
-
- ui.editPos--;
- textMarkerMoveLeft();
-
- if (editor.mixFlag) // special case for "Mix" input field in Edit. Op.
- {
- if (ui.dstPos == 12)
- {
- ui.editPos--; textMarkerMoveLeft();
- ui.editPos--; textMarkerMoveLeft();
- ui.editPos--; textMarkerMoveLeft();
- ui.editPos--; textMarkerMoveLeft();
- }
- else if (ui.dstPos == 6)
- {
- ui.editPos--;
- textMarkerMoveLeft();
- }
- }
-
- renderTextEditMarker();
- }
-
- ui.dstOffsetEnd = false;
-}
-
-void textCharNext(void)
-{
- if (ui.editTextType != TEXT_EDIT_STRING)
- {
- if (ui.dstPos < ui.numLen-1)
- {
- removeTextEditMarker();
- ui.dstPos++;
- ui.lineCurX += FONT_CHAR_W;
- renderTextEditMarker();
- }
-
- return;
- }
-
- if (editor.mixFlag && ui.dstPos >= 14)
- return;
-
- if (ui.editPos < ui.textEndPtr)
- {
- if (*ui.editPos != '\0')
- {
- removeTextEditMarker();
-
- ui.editPos++;
- textMarkerMoveRight();
-
- if (editor.mixFlag) // special case for "Mix" input field in Edit. Op.
- {
- if (ui.dstPos == 9)
- {
- ui.editPos++; textMarkerMoveRight();
- ui.editPos++; textMarkerMoveRight();
- ui.editPos++; textMarkerMoveRight();
- ui.editPos++; textMarkerMoveRight();
- }
- else if (ui.dstPos == 6)
- {
- ui.editPos++;
- textMarkerMoveRight();
- }
- }
-
- renderTextEditMarker();
- }
- else
- {
- ui.dstOffsetEnd = true;
- }
- }
- else
- {
- ui.dstOffsetEnd = true;
- }
-}
-// --------------------------------
-
void keyUpHandler(SDL_Scancode scancode)
{
if (scancode == SDL_SCANCODE_KP_PLUS)
@@ -473,7 +305,7 @@
if (!ui.askBoxShown)
{
editor.playMode = PLAY_MODE_NORMAL;
- modPlay(DONT_SET_PATTERN, song->currOrder, DONT_SET_ROW);
+ modPlay(DONT_SET_PATTERN, song->currPos, DONT_SET_ROW);
editor.currMode = MODE_PLAY;
pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
statusAllRight();
@@ -562,10 +394,10 @@
{
if (ui.posEdScreenShown)
{
- if (song->currOrder > 0)
+ if (song->currPos > 0)
{
- if (song->currOrder-(POSED_LIST_SIZE-1) > 0)
- modSetPos(song->currOrder-(POSED_LIST_SIZE-1), DONT_SET_ROW);
+ if (song->currPos-(POSED_LIST_SIZE-1) > 0)
+ modSetPos(song->currPos-(POSED_LIST_SIZE-1), DONT_SET_ROW);
else
modSetPos(0, DONT_SET_ROW);
}
@@ -603,12 +435,12 @@
{
if (ui.posEdScreenShown)
{
- if (song->currOrder != song->header.numOrders-1)
+ if (song->currPos != song->header.songLength-1)
{
- if (song->currOrder+(POSED_LIST_SIZE-1) <= song->header.numOrders-1)
- modSetPos(song->currOrder+(POSED_LIST_SIZE-1), DONT_SET_ROW);
+ if (song->currPos+(POSED_LIST_SIZE-1) <= song->header.songLength-1)
+ modSetPos(song->currPos+(POSED_LIST_SIZE-1), DONT_SET_ROW);
else
- modSetPos(song->header.numOrders - 1, DONT_SET_ROW);
+ modSetPos(song->header.songLength - 1, DONT_SET_ROW);
}
}
else if (ui.diskOpScreenShown)
@@ -640,7 +472,7 @@
{
if (ui.posEdScreenShown)
{
- if (song->currOrder > 0)
+ if (song->currPos > 0)
modSetPos(0, DONT_SET_ROW);
}
else if (ui.diskOpScreenShown)
@@ -663,7 +495,7 @@
{
if (ui.posEdScreenShown)
{
- modSetPos(song->header.numOrders - 1, DONT_SET_ROW);
+ modSetPos(song->header.songLength - 1, DONT_SET_ROW);
}
else if (ui.diskOpScreenShown)
{
@@ -1049,7 +881,7 @@
else if (keyb.leftAmigaPressed)
{
editor.playMode = PLAY_MODE_NORMAL;
- modPlay(DONT_SET_PATTERN, song->currOrder, editor.f6Pos);
+ modPlay(DONT_SET_PATTERN, song->currPos, editor.f6Pos);
editor.currMode = MODE_PLAY;
pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
@@ -1096,7 +928,7 @@
else if (keyb.leftAmigaPressed)
{
editor.playMode = PLAY_MODE_NORMAL;
- modPlay(DONT_SET_PATTERN, song->currOrder, editor.f7Pos);
+ modPlay(DONT_SET_PATTERN, song->currPos, editor.f7Pos);
editor.currMode = MODE_PLAY;
pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
@@ -1143,7 +975,7 @@
else if (keyb.leftAmigaPressed)
{
editor.playMode = PLAY_MODE_NORMAL;
- modPlay(DONT_SET_PATTERN, song->currOrder, editor.f8Pos);
+ modPlay(DONT_SET_PATTERN, song->currPos, editor.f8Pos);
editor.currMode = MODE_PLAY;
pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
@@ -1190,7 +1022,7 @@
else if (keyb.leftAmigaPressed)
{
editor.playMode = PLAY_MODE_NORMAL;
- modPlay(DONT_SET_PATTERN, song->currOrder, editor.f9Pos);
+ modPlay(DONT_SET_PATTERN, song->currPos, editor.f9Pos);
editor.currMode = MODE_PLAY;
pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
@@ -1237,7 +1069,7 @@
else if (keyb.leftAmigaPressed)
{
editor.playMode = PLAY_MODE_NORMAL;
- modPlay(DONT_SET_PATTERN, song->currOrder, editor.f10Pos);
+ modPlay(DONT_SET_PATTERN, song->currPos, editor.f10Pos);
editor.currMode = MODE_PLAY;
pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
@@ -1864,12 +1696,12 @@
}
else if (ui.posEdScreenShown)
{
- if (song->currOrder != song->header.numOrders-1)
+ if (song->currPos != song->header.songLength-1)
{
- if (++song->currOrder > song->header.numOrders-1)
- song->currOrder = song->header.numOrders-1;
+ if (++song->currPos > song->header.songLength-1)
+ song->currPos = song->header.songLength-1;
- modSetPos(song->currOrder, DONT_SET_ROW);
+ modSetPos(song->currPos, DONT_SET_ROW);
ui.updatePosEd = true;
}
@@ -1913,9 +1745,9 @@
}
else if (ui.posEdScreenShown)
{
- if (song->currOrder > 0)
+ if (song->currPos > 0)
{
- modSetPos(song->currOrder - 1, DONT_SET_ROW);
+ modSetPos(song->currPos - 1, DONT_SET_ROW);
ui.updatePosEd = true;
}
@@ -1951,9 +1783,9 @@
}
else if (keyb.shiftPressed)
{
- if (song->currOrder > 0)
+ if (song->currPos > 0)
{
- modSetPos(song->currOrder - 1, DONT_SET_ROW);
+ modSetPos(song->currPos - 1, DONT_SET_ROW);
if (editor.repeatKeyFlag)
{
keyb.delayKey = true;
@@ -1994,9 +1826,9 @@
}
else if (keyb.shiftPressed)
{
- if (song->currOrder < 126)
+ if (song->currPos < 126)
{
- modSetPos(song->currOrder + 1, DONT_SET_ROW);
+ modSetPos(song->currPos + 1, DONT_SET_ROW);
if (editor.repeatKeyFlag)
{
keyb.delayKey = true;
@@ -2650,18 +2482,7 @@
else if (keyb.leftAltPressed)
{
if (!ui.diskOpScreenShown)
- {
- ui.posEdScreenShown ^= 1;
- if (ui.posEdScreenShown)
- {
- renderPosEdScreen();
- ui.updatePosEd = true;
- }
- else
- {
- displayMainScreen();
- }
- }
+ posEdToggle();
}
else
{
@@ -3148,8 +2969,8 @@
if (ui.posEdScreenShown)
{
- if (song->currOrder-(POSED_LIST_SIZE-1) > 0)
- modSetPos(song->currOrder-(POSED_LIST_SIZE-1), DONT_SET_ROW);
+ if (song->currPos-(POSED_LIST_SIZE-1) > 0)
+ modSetPos(song->currPos-(POSED_LIST_SIZE-1), DONT_SET_ROW);
else
modSetPos(0, DONT_SET_ROW);
}
@@ -3185,10 +3006,10 @@
if (ui.posEdScreenShown)
{
- if (song->currOrder+(POSED_LIST_SIZE-1) <= song->header.numOrders-1)
- modSetPos(song->currOrder+(POSED_LIST_SIZE-1), DONT_SET_ROW);
+ if (song->currPos+(POSED_LIST_SIZE-1) <= song->header.songLength-1)
+ modSetPos(song->currPos+(POSED_LIST_SIZE-1), DONT_SET_ROW);
else
- modSetPos(song->header.numOrders - 1, DONT_SET_ROW);
+ modSetPos(song->header.songLength - 1, DONT_SET_ROW);
}
else if (ui.diskOpScreenShown)
{
@@ -3218,7 +3039,7 @@
if (keyb.repeatCounter >= 3)
{
keyb.repeatCounter = 0;
- textCharPrevious();
+ editTextPrevChar();
}
}
else
@@ -3241,8 +3062,8 @@
if (keyb.repeatCounter >= 6)
{
keyb.repeatCounter = 0;
- if (song->currOrder > 0)
- modSetPos(song->currOrder - 1, DONT_SET_ROW);
+ if (song->currPos > 0)
+ modSetPos(song->currPos - 1, DONT_SET_ROW);
}
}
else if (keyb.leftAltPressed)
@@ -3275,7 +3096,7 @@
if (keyb.repeatCounter >= 3)
{
keyb.repeatCounter = 0;
- textCharNext();
+ editTextNextChar();
}
}
else
@@ -3298,8 +3119,8 @@
if (keyb.repeatCounter >= 6)
{
keyb.repeatCounter = 0;
- if (song->currOrder < 126)
- modSetPos(song->currOrder + 1, DONT_SET_ROW);
+ if (song->currPos < 126)
+ modSetPos(song->currPos + 1, DONT_SET_ROW);
}
}
else if (keyb.leftAltPressed)
@@ -3346,9 +3167,9 @@
if (keyb.repeatCounter >= 3)
{
keyb.repeatCounter = 0;
- if (song->currOrder > 0)
+ if (song->currPos > 0)
{
- modSetPos(song->currOrder - 1, DONT_SET_ROW);
+ modSetPos(song->currPos - 1, DONT_SET_ROW);
ui.updatePosEd = true;
}
}
@@ -3400,12 +3221,12 @@
{
keyb.repeatCounter = 0;
- if (song->currOrder != song->header.numOrders-1)
+ if (song->currPos != song->header.songLength-1)
{
- if (++song->currOrder > song->header.numOrders-1)
- song->currOrder = song->header.numOrders-1;
+ if (++song->currPos > song->header.songLength-1)
+ song->currPos = song->header.songLength-1;
- modSetPos(song->currOrder, DONT_SET_ROW);
+ modSetPos(song->currPos, DONT_SET_ROW);
ui.updatePosEd = true;
}
}
@@ -3586,7 +3407,7 @@
// EDIT OP. SCREEN #3
if (editor.mixFlag && scancode == SDL_SCANCODE_ESCAPE)
{
- exitGetTextLine(EDIT_TEXT_UPDATE);
+ leaveTextEditMode(EDIT_TEXT_UPDATE);
editor.mixFlag = false;
ui.updateMixText = true;
return false;
@@ -3760,417 +3581,4 @@
}
return true;
-}
-
-void handleTextEditInputChar(char textChar)
-{
- // we only want certain keys
- if (textChar < ' ' || textChar > '~')
- return;
-
- // A..Z -> a..z
- if (textChar >= 'A' && textChar <= 'Z')
- textChar = (char)tolower(textChar);
-
- if (ui.editTextType == TEXT_EDIT_STRING)
- {
- if (ui.editPos < ui.textEndPtr)
- {
- if (!editor.mixFlag)
- {
- char *readTmp = ui.textEndPtr;
- while (readTmp > ui.editPos)
- {
- int8_t readTmpPrev = *--readTmp;
- *(readTmp + 1) = readTmpPrev;
- }
-
- *ui.textEndPtr = '\0';
- *ui.editPos++ = textChar;
-
- textMarkerMoveRight();
- }
- else if ((textChar >= '0' && textChar <= '9') || (textChar >= 'a' && textChar <= 'f'))
- {
- if (ui.dstPos == 14) // hack for sample mix text
- {
- *ui.editPos = textChar;
- }
- else
- {
- *ui.editPos++ = textChar;
- textMarkerMoveRight();
-
- if (ui.dstPos == 9) // hack for sample mix text
- {
- for (int32_t i = 0; i < 4; i++)
- {
- ui.editPos++;
- textMarkerMoveRight();
- }
- }
- else if (ui.dstPos == 6) // hack for sample mix text
- {
- ui.editPos++;
- textMarkerMoveRight();
- }
- }
- }
- }
- }
- else
- {
- if (ui.editTextType == TEXT_EDIT_DECIMAL)
- {
- if (textChar >= '0' && textChar <= '9')
- {
- uint8_t digit1, digit2, digit3, digit4;
- uint32_t number;
-
- textChar -= '0';
-
- if (ui.numLen == 4)
- {
- number = *ui.numPtr16;
- digit4 = number % 10; number /= 10;
- digit3 = number % 10; number /= 10;
- digit2 = number % 10; number /= 10;
- digit1 = (uint8_t)number;
-
- if (ui.dstPos == 0) *ui.numPtr16 = (textChar * 1000) + (digit2 * 100) + (digit3 * 10) + digit4;
- else if (ui.dstPos == 1) *ui.numPtr16 = (digit1 * 1000) + (textChar * 100) + (digit3 * 10) + digit4;
- else if (ui.dstPos == 2) *ui.numPtr16 = (digit1 * 1000) + (digit2 * 100) + (textChar * 10) + digit4;
- else if (ui.dstPos == 3) *ui.numPtr16 = (digit1 * 1000) + (digit2 * 100) + (digit3 * 10) + textChar;
- }
- else if (ui.numLen == 3)
- {
- number = *ui.numPtr16;
- digit3 = number % 10; number /= 10;
- digit2 = number % 10; number /= 10;
- digit1 = (uint8_t)number;
-
- if (ui.dstPos == 0) *ui.numPtr16 = (textChar * 100) + (digit2 * 10) + digit3;
- else if (ui.dstPos == 1) *ui.numPtr16 = (digit1 * 100) + (textChar * 10) + digit3;
- else if (ui.dstPos == 2) *ui.numPtr16 = (digit1 * 100) + (digit2 * 10) + textChar;
- }
- else if (ui.numLen == 2)
- {
- number = *ui.numPtr16;
- digit2 = number % 10; number /= 10;
- digit1 = (uint8_t)number;
-
- if (ui.dstPos == 0) *ui.numPtr16 = (textChar * 10) + digit2;
- else if (ui.dstPos == 1) *ui.numPtr16 = (digit1 * 10) + textChar;
- }
-
- textMarkerMoveRight();
- if (ui.dstPos >= ui.numLen)
- exitGetTextLine(EDIT_TEXT_UPDATE);
- }
- }
- else
- {
- if ((textChar >= '0' && textChar <= '9') || (textChar >= 'a' && textChar <= 'f'))
- {
- if (textChar <= '9')
- textChar -= '0';
- else if (textChar <= 'f')
- textChar -= 'a'-10;
-
- if (ui.numBits == 17)
- {
- *ui.numPtr32 &= ~(0xF0000 >> (ui.dstPos << 2));
- *ui.numPtr32 |= textChar << (16 - (ui.dstPos << 2));
- }
- else if (ui.numBits == 16)
- {
- if (ui.force32BitNumPtr)
- {
- *ui.numPtr32 &= ~(0xF000 >> (ui.dstPos << 2));
- *ui.numPtr32 |= textChar << (12 - (ui.dstPos << 2));
- }
- else
- {
- *ui.numPtr16 &= ~(0xF000 >> (ui.dstPos << 2));
- *ui.numPtr16 |= textChar << (12 - (ui.dstPos << 2));
- }
- }
- else if (ui.numBits == 8)
- {
- *ui.numPtr8 &= ~(0xF0 >> (ui.dstPos << 2));
- *ui.numPtr8 |= textChar << (4 - (ui.dstPos << 2));
- }
-
- textMarkerMoveRight();
- if (ui.dstPos >= ui.numLen)
- exitGetTextLine(EDIT_TEXT_UPDATE);
- }
- }
- }
-
- updateTextObject(ui.editObject);
-
- if (!keyb.repeatKey)
- keyb.delayCounter = 0;
-
- keyb.repeatKey = true;
- keyb.delayKey = true;
-}
-
-bool handleTextEditMode(SDL_Scancode scancode)
-{
- switch (scancode)
- {
- case SDL_SCANCODE_ESCAPE:
- {
- editor.blockMarkFlag = false;
- if (ui.editTextFlag)
- {
- exitGetTextLine(EDIT_TEXT_NO_UPDATE);
- return false;
- }
- }
- break;
-
- case SDL_SCANCODE_HOME:
- {
- if (ui.editTextFlag && !editor.mixFlag)
- {
- while (ui.editPos > ui.showTextPtr)
- textCharPrevious();
- }
- }
- break;
-
- case SDL_SCANCODE_END:
- {
- if (ui.editTextFlag && !editor.mixFlag)
- {
- if (ui.editTextType != TEXT_EDIT_STRING)
- break;
-
- while (!ui.dstOffsetEnd)
- textCharNext();
- }
- }
- break;
-
- case SDL_SCANCODE_LEFT:
- {
- if (ui.editTextFlag)
- {
- textCharPrevious();
- if (!keyb.repeatKey)
- keyb.delayCounter = 0;
-
- keyb.repeatKey = true;
- keyb.delayKey = false;
- }
- else
- {
- keyb.delayKey = false;
- keyb.repeatKey = true;
- }
- }
- break;
-
- case SDL_SCANCODE_RIGHT:
- {
- if (ui.editTextFlag)
- {
- textCharNext();
- if (!keyb.repeatKey)
- keyb.delayCounter = 0;
-
- keyb.repeatKey = true;
- keyb.delayKey = false;
- }
- else
- {
- keyb.delayKey = false;
- keyb.repeatKey = true;
- }
- }
- break;
-
- case SDL_SCANCODE_DELETE:
- {
- if (ui.editTextFlag)
- {
- if (editor.mixFlag || ui.editTextType != TEXT_EDIT_STRING)
- break;
-
- char *readTmp = ui.editPos;
- while (readTmp < ui.textEndPtr)
- {
- int8_t readTmpNext = *(readTmp + 1);
- *readTmp++ = readTmpNext;
- }
-
- // kludge to prevent cloning last character if the song/sample name has one character too much
- if (ui.editObject == PTB_SONGNAME || ui.editObject == PTB_SAMPLENAME)
- *ui.textEndPtr = '\0';
-
- if (!keyb.repeatKey)
- keyb.delayCounter = 0;
-
- keyb.repeatKey = true;
- keyb.delayKey = true;
-
- updateTextObject(ui.editObject);
- }
- }
- break;
-
- case SDL_SCANCODE_BACKSPACE:
- {
- if (ui.editTextFlag)
- {
- if (editor.mixFlag || ui.editTextType != TEXT_EDIT_STRING)
- break;
-
- if (ui.editPos > ui.dstPtr)
- {
- ui.editPos--;
-
- char *readTmp = ui.editPos;
- while (readTmp < ui.textEndPtr)
- {
- int8_t readTmpNext = *(readTmp + 1);
- *readTmp++ = readTmpNext;
- }
-
- // kludge to prevent cloning last character if the song/sample name has one character too much
- if (ui.editObject == PTB_SONGNAME || ui.editObject == PTB_SAMPLENAME)
- *ui.textEndPtr = '\0';
-
- textMarkerMoveLeft();
- updateTextObject(ui.editObject);
- }
-
- if (!keyb.repeatKey)
- keyb.delayCounter = 0;
-
- keyb.repeatKey = true;
- keyb.delayKey = false;
- }
- else
- {
- if (ui.diskOpScreenShown)
- {
-#ifdef _WIN32
- diskOpSetPath(L"..", DISKOP_CACHE);
-#else
- diskOpSetPath("..", DISKOP_CACHE);
-#endif
- }
- else if (keyb.shiftPressed || keyb.leftAltPressed || keyb.leftCtrlPressed)
- {
- saveUndo();
- if (keyb.leftAltPressed && !keyb.leftCtrlPressed)
- {
- if (song->currRow > 0)
- {
- for (int32_t i = 0; i < PAULA_VOICES; i++)
- {
- for (int32_t j = (song->currRow - 1); j < MOD_ROWS; j++)
- {
- note_t *noteSrc = &song->patterns[song->currPattern][((j + 1) * PAULA_VOICES) + i];
- song->patterns[song->currPattern][(j * PAULA_VOICES) + i] = *noteSrc;
- }
-
- // clear newly made row on very bottom
- note_t *noteDst = &song->patterns[song->currPattern][(63 * PAULA_VOICES) + i];
- noteDst->period = 0;
- noteDst->sample = 0;
- noteDst->command = 0;
- noteDst->param = 0;
- }
-
- song->currRow--;
- ui.updatePatternData = true;
- }
- }
- else
- {
- if (song->currRow > 0)
- {
- for (int32_t i = song->currRow-1; i < MOD_ROWS-1; i++)
- {
- note_t *noteSrc = &song->patterns[song->currPattern][((i + 1) * PAULA_VOICES) + cursor.channel];
- note_t *noteDst = &song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel];
-
- if (keyb.leftCtrlPressed)
- {
- noteDst->command = noteSrc->command;
- noteDst->param = noteSrc->param;
- }
- else
- {
- *noteDst = *noteSrc;
- }
- }
-
- // clear newly made row on very bottom
- note_t *noteDst = &song->patterns[song->currPattern][(63 * PAULA_VOICES) + cursor.channel];
- noteDst->period = 0;
- noteDst->sample = 0;
- noteDst->command = 0;
- noteDst->param = 0;
-
- song->currRow--;
- ui.updatePatternData = true;
- }
- }
- }
- else
- {
- editor.stepPlayEnabled = true;
- editor.stepPlayBackwards = true;
-
- editor.stepPlayLastMode = editor.currMode;
-
- if (config.keepEditModeAfterStepPlay && editor.stepPlayLastMode == MODE_EDIT)
- doStopIt(false);
- else
- doStopIt(true);
-
- playPattern((song->currRow - 1) & 63);
-
- if (config.keepEditModeAfterStepPlay && editor.stepPlayLastMode == MODE_EDIT)
- {
- pointerSetMode(POINTER_MODE_EDIT, DO_CARRY);
- editor.playMode = PLAY_MODE_NORMAL;
- editor.currMode = MODE_EDIT;
- }
- }
- }
- }
- break;
-
- default: break;
- }
-
- if (ui.editTextFlag)
- {
- if (scancode == SDL_SCANCODE_RETURN || scancode == SDL_SCANCODE_KP_ENTER)
- {
- // dirty hack
- if (ui.editObject == PTB_SAMPLES)
- ui.tmpDisp8++;
-
- exitGetTextLine(EDIT_TEXT_UPDATE);
-
- if (editor.mixFlag)
- {
- editor.mixFlag = false;
- ui.updateMixText = true;
- doMix();
- }
- }
-
- return false; // don't continue further key handling
- }
-
- return true; // continue further key handling (we're not editing text)
}
--- a/src/pt2_keyboard.h
+++ b/src/pt2_keyboard.h
@@ -6,16 +6,10 @@
#endif
#include <stdint.h>
-void gotoNextMulti(void);
-void textMarkerMoveLeft(void);
-void textMarkerMoveRight(void);
-void textCharPrevious(void);
-void textCharNext(void);
void readKeyModifiers(void);
void handleKeyRepeat(SDL_Scancode scancode);
void keyUpHandler(SDL_Scancode scancode);
void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode);
-void handleTextEditInputChar(char textChar);
#if defined _WIN32 && !defined _DEBUG
LRESULT CALLBACK lowLevelKeyboardProc(int32_t nCode, WPARAM wParam, LPARAM lParam);
--- a/src/pt2_main.c
+++ b/src/pt2_main.c
@@ -35,6 +35,7 @@
#include "pt2_sampling.h"
#include "pt2_askbox.h"
#include "pt2_replayer.h"
+#include "pt2_textedit.h"
#define CRASH_TEXT "Oh no! The ProTracker 2 clone has crashed...\nA backup .mod was hopefully " \
"saved to the current module directory.\n\nPlease report this bug if you can.\n" \
@@ -89,15 +90,16 @@
static void clearStructs(void)
{
- memset(&keyb, 0, sizeof (keyb));
- memset(&mouse, 0, sizeof (mouse));
- memset(&video, 0, sizeof (video));
+ memset(&keyb, 0, sizeof (keyb));
+ memset(&mouse, 0, sizeof (mouse));
+ memset(&video, 0, sizeof (video));
memset(&editor, 0, sizeof (editor));
memset(&diskop, 0, sizeof (diskop));
memset(&cursor, 0, sizeof (cursor));
- memset(&ui, 0, sizeof (ui));
+ memset(&ui, 0, sizeof (ui));
memset(&config, 0, sizeof (config));
- memset(&audio, 0, sizeof (audio));
+ memset(&audio, 0, sizeof (audio));
+ memset(&textEdit, 0, sizeof (textEdit));
audio.rescanAudioDevicesSupported = true;
}
@@ -289,10 +291,10 @@
// setup GUI text pointers (for recently allocated song structure)
editor.currEditPatternDisp = &song->currPattern;
- editor.currPosDisp = &song->currOrder;
- editor.currPatternDisp = &song->header.order[0];
- editor.currPosEdPattDisp = &song->header.order[0];
- editor.currLengthDisp = &song->header.numOrders;
+ editor.currPosDisp = &song->currPos;
+ editor.currPatternDisp = &song->header.patternTable[0];
+ editor.currPosEdPattDisp = &song->header.patternTable[0];
+ editor.currLengthDisp = &song->header.songLength;
if (!initScopes())
{
--- a/src/pt2_mod2wav.c
+++ b/src/pt2_mod2wav.c
@@ -225,7 +225,7 @@
else
{
// clear the "last visisted rows" table and let the song continue playing (loop)
- memset(editor.rowVisitTable, 0, MOD_ORDERS * MOD_ROWS);
+ memset(editor.rowVisitTable, 0, 128 * MOD_ROWS);
}
}
@@ -408,7 +408,7 @@
} \
else \
{ \
- memset(editor.rowVisitTable, 0, MOD_ORDERS * MOD_ROWS); \
+ memset(editor.rowVisitTable, 0, 128 * MOD_ROWS); \
}
// ONLY used for a visual percentage counter, so accuracy is not very important
@@ -423,13 +423,13 @@
song->rowsCounter = song->rowsInTotal = 0;
uint8_t modRow = 0;
- int16_t modOrder = 0;
- uint16_t modPattern = song->header.order[0];
+ int16_t modPos = 0;
+ uint16_t modPattern = song->header.patternTable[0];
uint8_t pBreakPosition = 0;
bool posJumpAssert = false;
bool pBreakFlag = false;
- memset(editor.rowVisitTable, 0, MOD_ORDERS * MOD_ROWS);
+ memset(editor.rowVisitTable, 0, 128 * MOD_ROWS);
int8_t numLoops = editor.mod2WavNumLoops; // make a copy
@@ -436,7 +436,7 @@
bool calcingRows = true;
while (calcingRows)
{
- editor.rowVisitTable[(modOrder * MOD_ROWS) + modRow] = true;
+ editor.rowVisitTable[(modPos * MOD_ROWS) + modRow] = true;
for (int32_t ch = 0; ch < PAULA_VOICES; ch++)
{
@@ -443,7 +443,7 @@
note_t *note = &song->patterns[modPattern][(modRow * PAULA_VOICES) + ch];
if (note->command == 0x0B) // Bxx - Position Jump
{
- modOrder = note->param - 1;
+ modPos = note->param - 1;
pBreakPosition = 0;
posJumpAssert = true;
}
@@ -474,7 +474,7 @@
pBreakFlag = true;
for (pos = pBreakPosition; pos <= modRow; pos++)
- editor.rowVisitTable[(modOrder * MOD_ROWS) + pos] = false;
+ editor.rowVisitTable[(modPos * MOD_ROWS) + pos] = false;
}
else if (--n_loopcount[ch])
{
@@ -482,7 +482,7 @@
pBreakFlag = true;
for (pos = pBreakPosition; pos <= modRow; pos++)
- editor.rowVisitTable[(modOrder * MOD_ROWS) + pos] = false;
+ editor.rowVisitTable[(modPos * MOD_ROWS) + pos] = false;
}
}
}
@@ -503,19 +503,19 @@
pBreakPosition = 0;
posJumpAssert = false;
- modOrder = (modOrder + 1) & 127;
- if (modOrder >= song->header.numOrders)
+ modPos = (modPos + 1) & 127;
+ if (modPos >= song->header.songLength)
{
- modOrder = 0;
+ modPos = 0;
CALC__END_OF_SONG
}
- modPattern = song->header.order[modOrder];
+ modPattern = song->header.patternTable[modPos];
if (modPattern > MAX_PATTERNS-1)
modPattern = MAX_PATTERNS-1;
}
- if (calcingRows && editor.rowVisitTable[(modOrder * MOD_ROWS) + modRow])
+ if (calcingRows && editor.rowVisitTable[(modPos * MOD_ROWS) + modRow])
{
// row has been visited before, we're now done!
CALC__END_OF_SONG
--- a/src/pt2_module_loader.c
+++ b/src/pt2_module_loader.c
@@ -29,6 +29,7 @@
#include "modloaders/pt2_xpk_unpack.h"
#include "modloaders/pt2_pp_unpack.h"
#include "pt2_askbox.h"
+#include "pt2_posed.h"
static void fixZeroesInString(char *str, uint32_t maxLength); // converts zeroes to spaces in a string, up until the last zero found
@@ -228,12 +229,14 @@
modSetPos(0, 0);
modSetPattern(0); // set pattern to 00 instead of first order's pattern
+ posEdClearNames();
+
// setup GUI text pointers
editor.currEditPatternDisp = &song->currPattern;
- editor.currPosDisp = &song->currOrder;
- editor.currPatternDisp = &song->header.order[0];
- editor.currPosEdPattDisp = &song->header.order[0];
- editor.currLengthDisp = &song->header.numOrders;
+ editor.currPosDisp = &song->currPos;
+ editor.currPatternDisp = &song->header.patternTable[0];
+ editor.currPosEdPattDisp = &song->header.patternTable[0];
+ editor.currLengthDisp = &song->header.songLength;
// calculate MOD size
ui.updateSongSize = true;
--- a/src/pt2_module_saver.c
+++ b/src/pt2_module_saver.c
@@ -52,17 +52,17 @@
fwrite(&loopLength16, sizeof (int16_t), 1, f);
}
- fputc((uint8_t)song->header.numOrders, f);
+ fputc((uint8_t)song->header.songLength, f);
fputc(0x7F, f); // ProTracker puts 0x7F at this place (restartPos/tempo in other trackers)
- for (int32_t i = 0; i < MOD_ORDERS; i++)
- fputc((uint8_t)song->header.order[i], f);
+ for (int32_t i = 0; i < 128; i++)
+ fputc((uint8_t)song->header.patternTable[i], f);
int32_t numPatterns = 0;
- for (int32_t i = 0; i < MOD_ORDERS; i++)
+ for (int32_t i = 0; i < 128; i++)
{
- if (song->header.order[i] > numPatterns)
- numPatterns = song->header.order[i];
+ if (song->header.patternTable[i] > numPatterns)
+ numPatterns = song->header.patternTable[i];
}
numPatterns++;
--- a/src/pt2_mouse.c
+++ b/src/pt2_mouse.c
@@ -28,11 +28,12 @@
#include "pt2_mod2wav.h"
#include "pt2_askbox.h"
#include "pt2_replayer.h"
+#include "pt2_posed.h"
+#include "pt2_textedit.h"
SDL_Cursor *cursors[NUM_CURSORS]; // globalized
static int32_t checkGUIButtons(void);
-static void handleTextEditing(uint8_t mouseButton);
static bool handleRightMouseButton(void);
static bool handleLeftMouseButton(void);
static bool handleGUIButtons(int32_t button);
@@ -1050,7 +1051,7 @@
static void songLengthUpButton(void)
{
- int16_t val = song->header.numOrders;
+ int16_t val = song->header.songLength;
if (mouse.rightButtonPressed)
val += 10;
else
@@ -1059,19 +1060,19 @@
if (val > 128)
val = 128;
- song->header.numOrders = (uint8_t)val;
+ song->header.songLength = (uint8_t)val;
- val = song->currOrder;
- if (val > song->header.numOrders-1)
- val = song->header.numOrders-1;
+ val = song->currPos;
+ if (val > song->header.songLength-1)
+ val = song->header.songLength-1;
- editor.currPosEdPattDisp = &song->header.order[val];
+ editor.currPosEdPattDisp = &song->header.patternTable[val];
ui.updateSongLength = true;
}
static void songLengthDownButton(void)
{
- int16_t val = song->header.numOrders;
+ int16_t val = song->header.songLength;
if (mouse.rightButtonPressed)
val -= 10;
@@ -1081,19 +1082,19 @@
if (val < 1)
val = 1;
- song->header.numOrders = (uint8_t)val;
+ song->header.songLength = (uint8_t)val;
- val = song->currOrder;
- if (val > song->header.numOrders-1)
- val = song->header.numOrders-1;
+ val = song->currPos;
+ if (val > song->header.songLength-1)
+ val = song->header.songLength-1;
- editor.currPosEdPattDisp = &song->header.order[val];
+ editor.currPosEdPattDisp = &song->header.patternTable[val];
ui.updateSongLength = true;
}
static void patternUpButton(void)
{
- int16_t val = song->header.order[song->currOrder];
+ int16_t val = song->header.patternTable[song->currPos];
if (mouse.rightButtonPressed)
val += 10;
@@ -1103,7 +1104,7 @@
if (val > MAX_PATTERNS-1)
val = MAX_PATTERNS-1;
- song->header.order[song->currOrder] = (uint8_t)val;
+ song->header.patternTable[song->currPos] = (uint8_t)val;
if (ui.posEdScreenShown)
ui.updatePosEd = true;
@@ -1113,7 +1114,7 @@
static void patternDownButton(void)
{
- int16_t val = song->header.order[song->currOrder];
+ int16_t val = song->header.patternTable[song->currPos];
if (mouse.rightButtonPressed)
val -= 10;
@@ -1123,7 +1124,7 @@
if (val < 0)
val = 0;
- song->header.order[song->currOrder] = (uint8_t)val;
+ song->header.patternTable[song->currPos] = (uint8_t)val;
if (ui.posEdScreenShown)
ui.updatePosEd = true;
@@ -1133,7 +1134,7 @@
static void positionUpButton(void)
{
- int16_t val = song->currOrder;
+ int16_t val = song->currPos;
if (mouse.rightButtonPressed)
val += 10;
@@ -1148,7 +1149,7 @@
static void positionDownButton(void)
{
- int16_t val = song->currOrder;
+ int16_t val = song->currPos;
if (mouse.rightButtonPressed)
val -= 10;
@@ -1167,7 +1168,7 @@
{
if (ui.editTextFlag)
{
- exitGetTextLine(EDIT_TEXT_NO_UPDATE);
+ leaveTextEditMode(EDIT_TEXT_NO_UPDATE);
}
else
{
@@ -1245,12 +1246,13 @@
// FROM NUM
if (mouse.y >= 154 && mouse.y <= 164)
{
- ui.tmpDisp16 = editor.vol1;
- editor.vol1Disp = &ui.tmpDisp16;
- ui.numPtr16 = &ui.tmpDisp16;
- ui.numLen = 3;
- ui.editTextPos = 6342; // (y * 40) + x
- getNumLine(TEXT_EDIT_DECIMAL, PTB_SA_VOL_FROM_NUM);
+ textEdit.tmpDisp16 = editor.vol1;
+ editor.vol1Disp = &textEdit.tmpDisp16;
+ textEdit.numPtr16 = &textEdit.tmpDisp16;
+ textEdit.numDigits = 3;
+ textEdit.cursorStartX = 176;
+ textEdit.cursorStartY = 162;
+ enterNumberEditMode(TEXT_EDIT_DECIMAL, PTB_SA_VOL_FROM_NUM);
return;
}
@@ -1257,12 +1259,13 @@
// TO NUM
else if (mouse.y >= 165 && mouse.y <= 175)
{
- ui.tmpDisp16 = editor.vol2;
- editor.vol2Disp = &ui.tmpDisp16;
- ui.numPtr16 = &ui.tmpDisp16;
- ui.numLen = 3;
- ui.editTextPos = 6782; // (y * 40) + x
- getNumLine(TEXT_EDIT_DECIMAL, PTB_SA_VOL_TO_NUM);
+ textEdit.tmpDisp16 = editor.vol2;
+ editor.vol2Disp = &textEdit.tmpDisp16;
+ textEdit.numPtr16 = &textEdit.tmpDisp16;
+ textEdit.numDigits = 3;
+ textEdit.cursorStartX = 176;
+ textEdit.cursorStartY = 173;
+ enterNumberEditMode(TEXT_EDIT_DECIMAL, PTB_SA_VOL_TO_NUM);
return;
}
}
@@ -1559,7 +1562,7 @@
{
if (mouse.rightButtonPressed && ui.editTextFlag)
{
- exitGetTextLine(EDIT_TEXT_NO_UPDATE);
+ leaveTextEditMode(EDIT_TEXT_NO_UPDATE);
return;
}
@@ -1660,12 +1663,13 @@
}
else
{
- ui.tmpDisp16 = editor.lpCutOff;
- editor.lpCutOffDisp = &ui.tmpDisp16;
- ui.numPtr16 = &ui.tmpDisp16;
- ui.numLen = 4;
- ui.editTextPos = 6341; // (y * 40) + x
- getNumLine(TEXT_EDIT_DECIMAL, PTB_SA_FIL_LP_CUTOFF);
+ textEdit.tmpDisp16 = editor.lpCutOff;
+ editor.lpCutOffDisp = &textEdit.tmpDisp16;
+ textEdit.numPtr16 = &textEdit.tmpDisp16;
+ textEdit.numDigits = 4;
+ textEdit.cursorStartX = 168;
+ textEdit.cursorStartY = 162;
+ enterNumberEditMode(TEXT_EDIT_DECIMAL, PTB_SA_FIL_LP_CUTOFF);
}
return;
@@ -1741,12 +1745,13 @@
}
else
{
- ui.tmpDisp16 = editor.hpCutOff;
- editor.hpCutOffDisp = &ui.tmpDisp16;
- ui.numPtr16 = &ui.tmpDisp16;
- ui.numLen = 4;
- ui.editTextPos = 6781; // (y * 40) + x
- getNumLine(TEXT_EDIT_DECIMAL, PTB_SA_FIL_HP_CUTOFF);
+ textEdit.tmpDisp16 = editor.hpCutOff;
+ editor.hpCutOffDisp = &textEdit.tmpDisp16;
+ textEdit.numPtr16 = &textEdit.tmpDisp16;
+ textEdit.numDigits = 4;
+ textEdit.cursorStartX = 168;
+ textEdit.cursorStartY = 173;
+ enterNumberEditMode(TEXT_EDIT_DECIMAL, PTB_SA_FIL_HP_CUTOFF);
}
return;
@@ -1879,92 +1884,6 @@
return -1;
}
-static void handleTextEditing(uint8_t mouseButton)
-{
- // handle mouse while editing text/numbers
-
- if (!ui.editTextFlag)
- return;
-
- if (ui.editTextType != TEXT_EDIT_STRING)
- {
- if (mouseButton == SDL_BUTTON_RIGHT)
- exitGetTextLine(EDIT_TEXT_NO_UPDATE);
- }
- else if (mouseButton == SDL_BUTTON_LEFT && !editor.mixFlag)
- {
- int32_t tmp32 = mouse.y - ui.lineCurY;
- if (tmp32 <= 2 && tmp32 >= -9)
- {
- tmp32 = (int32_t)((mouse.x - ui.lineCurX) + 4) >> 3;
- while (tmp32 != 0) // 0 = pos we want
- {
- if (tmp32 > 0)
- {
- if (ui.editPos < ui.textEndPtr && *ui.editPos != '\0')
- {
- ui.editPos++;
- textMarkerMoveRight();
- }
- tmp32--;
- }
- else if (tmp32 < 0)
- {
- if (ui.editPos > ui.dstPtr)
- {
- ui.editPos--;
- textMarkerMoveLeft();
- }
- tmp32++;
- }
- }
- }
- else
- {
- exitGetTextLine(EDIT_TEXT_UPDATE);
- }
- }
- else if (mouseButton == SDL_BUTTON_RIGHT)
- {
- if (editor.mixFlag)
- {
- exitGetTextLine(EDIT_TEXT_UPDATE);
- editor.mixFlag = false;
- ui.updateMixText = true;
- }
- else
- {
- char *tmpRead = ui.dstPtr;
- while (tmpRead < ui.textEndPtr)
- *tmpRead++ = '\0';
-
- *ui.textEndPtr = '\0';
-
- // don't exit text edit mode if the disk op. path was about to be deleted
- if (ui.editObject == PTB_DO_DATAPATH)
- {
- // move text cursor to pos 0
- while (ui.editPos > ui.dstPtr)
- {
- ui.editPos--;
- textMarkerMoveLeft();
- }
-
- ui.updateDiskOpPathText = true;
- }
- else
- {
- if (ui.editObject == PTB_SONGNAME)
- ui.updateSongName = true;
- else if (ui.editObject == PTB_SAMPLENAME)
- ui.updateCurrSampleName = true;
-
- exitGetTextLine(EDIT_TEXT_UPDATE);
- }
- }
- }
-}
-
void mouseWheelUpHandler(void)
{
if (ui.editTextFlag || ui.askBoxShown || editor.swapChannelFlag ||
@@ -1982,9 +1901,9 @@
ui.updateDiskOpFileList = true;
}
}
- else if (ui.posEdScreenShown && song->currOrder > 0)
+ else if (ui.posEdScreenShown && song->currPos > 0)
{
- modSetPos(song->currOrder - 1, DONT_SET_ROW);
+ modSetPos(song->currPos - 1, DONT_SET_ROW);
}
}
else if (ui.samplerScreenShown) // lower part of screen
@@ -2014,9 +1933,9 @@
ui.updateDiskOpFileList = true;
}
}
- else if (ui.posEdScreenShown && song->currOrder < song->header.numOrders-1)
+ else if (ui.posEdScreenShown && song->currPos < song->header.songLength-1)
{
- modSetPos(song->currOrder + 1, DONT_SET_ROW);
+ modSetPos(song->currPos + 1, DONT_SET_ROW);
}
}
else if (ui.samplerScreenShown) // lower part of screen
@@ -2182,7 +2101,7 @@
static bool handleGUIButtons(int32_t button) // are you prepared to enter the jungle?
{
- ui.force32BitNumPtr = false;
+ textEdit.force32BitNumPtr = false;
switch (button)
{
@@ -2283,58 +2202,63 @@
case PTB_EO_QUANTIZE:
{
- ui.tmpDisp16 = config.quantizeValue;
- editor.quantizeValueDisp = &ui.tmpDisp16;
- ui.numPtr16 = &ui.tmpDisp16;
- ui.numLen = 2;
- ui.editTextPos = 2824; // (y * 40) + x
- getNumLine(TEXT_EDIT_DECIMAL, PTB_EO_QUANTIZE);
+ textEdit.tmpDisp16 = config.quantizeValue;
+ editor.quantizeValueDisp = &textEdit.tmpDisp16;
+ textEdit.numPtr16 = &textEdit.tmpDisp16;
+ textEdit.numDigits = 2;
+ textEdit.cursorStartX = 192;
+ textEdit.cursorStartY = 74;
+ enterNumberEditMode(TEXT_EDIT_DECIMAL, PTB_EO_QUANTIZE);
}
break;
case PTB_EO_METRO_1: // metronome speed
{
- ui.tmpDisp16 = editor.metroSpeed;
- editor.metroSpeedDisp = &ui.tmpDisp16;
- ui.numPtr16 = &ui.tmpDisp16;
- ui.numLen = 2;
- ui.editTextPos = 3261; // (y * 40) + x
- getNumLine(TEXT_EDIT_DECIMAL, PTB_EO_METRO_1);
+ textEdit.tmpDisp16 = editor.metroSpeed;
+ editor.metroSpeedDisp = &textEdit.tmpDisp16;
+ textEdit.numPtr16 = &textEdit.tmpDisp16;
+ textEdit.numDigits = 2;
+ textEdit.cursorStartX = 168;
+ textEdit.cursorStartY = 85;
+ enterNumberEditMode(TEXT_EDIT_DECIMAL, PTB_EO_METRO_1);
}
break;
case PTB_EO_METRO_2: // metronome channel
{
- ui.tmpDisp16 = editor.metroChannel;
- editor.metroChannelDisp = &ui.tmpDisp16;
- ui.numPtr16 = &ui.tmpDisp16;
- ui.numLen = 2;
- ui.editTextPos = 3264; // (y * 40) + x
- getNumLine(TEXT_EDIT_DECIMAL, PTB_EO_METRO_2);
+ textEdit.tmpDisp16 = editor.metroChannel;
+ editor.metroChannelDisp = &textEdit.tmpDisp16;
+ textEdit.numPtr16 = &textEdit.tmpDisp16;
+ textEdit.numDigits = 2;
+ textEdit.cursorStartX = 192;
+ textEdit.cursorStartY = 85;
+ enterNumberEditMode(TEXT_EDIT_DECIMAL, PTB_EO_METRO_2);
}
break;
case PTB_EO_FROM_NUM:
{
- ui.tmpDisp8 = editor.sampleFrom;
- editor.sampleFromDisp = &ui.tmpDisp8;
- ui.numPtr8 = &ui.tmpDisp8;
- ui.numLen = 2;
- ui.numBits = 8;
- ui.editTextPos = 3273; // (y * 40) + x
- getNumLine(TEXT_EDIT_HEX, PTB_EO_FROM_NUM);
+ textEdit.tmpDisp8 = editor.sampleFrom;
+ editor.sampleFromDisp = &textEdit.tmpDisp8;
+ textEdit.numPtr8 = &textEdit.tmpDisp8;
+ textEdit.numDigits = 2;
+ textEdit.numBits = 8;
+ textEdit.cursorStartX = 264;
+ textEdit.cursorStartY = 85;
+ enterNumberEditMode(TEXT_EDIT_HEX, PTB_EO_FROM_NUM);
}
break;
case PTB_EO_TO_NUM:
{
- ui.tmpDisp8 = editor.sampleTo;
- editor.sampleToDisp = &ui.tmpDisp8;
- ui.numPtr8 = &ui.tmpDisp8;
- ui.numLen = 2;
- ui.numBits = 8;
- ui.editTextPos = 3713; // (y * 40) + x
- getNumLine(TEXT_EDIT_HEX, PTB_EO_TO_NUM);
+ textEdit.tmpDisp8 = editor.sampleTo;
+ editor.sampleToDisp = &textEdit.tmpDisp8;
+ textEdit.numPtr8 = &textEdit.tmpDisp8;
+ textEdit.numDigits = 2;
+ textEdit.numBits = 8;
+ textEdit.cursorStartX = 264;
+ textEdit.cursorStartY = 96;
+ enterNumberEditMode(TEXT_EDIT_HEX, PTB_EO_TO_NUM);
}
break;
@@ -2394,14 +2318,15 @@
if (!mouse.rightButtonPressed)
{
editor.mixFlag = true;
- ui.showTextPtr = editor.mixText;
- ui.textEndPtr = editor.mixText + 15;
- ui.textLength = 16;
- ui.editTextPos = 1936; // (y * 40) + x
- ui.dstOffset = NULL;
- ui.dstOffsetEnd = false;
ui.updateMixText = true;
- getTextLine(PTB_EO_MIX);
+
+ textEdit.textStartPtr = editor.mixText;
+ textEdit.textEndPtr = editor.mixText + 15;
+ textEdit.numBlocks = 16;
+ textEdit.cursorStartX = 128;
+ textEdit.cursorStartY = 52;
+ textEdit.scrollable = false;
+ enterTextEditMode(PTB_EO_MIX);
}
else
{
@@ -2569,26 +2494,28 @@
}
else
{
- ui.force32BitNumPtr = true;
+ textEdit.force32BitNumPtr = true;
- ui.tmpDisp32 = editor.samplePos;
- editor.samplePosDisp = &ui.tmpDisp32;
- ui.numPtr32 = &ui.tmpDisp32;
+ textEdit.tmpDisp32 = editor.samplePos;
+ editor.samplePosDisp = &textEdit.tmpDisp32;
+ textEdit.numPtr32 = &textEdit.tmpDisp32;
if (config.maxSampleLength == 65534)
{
- ui.numLen = 4;
- ui.numBits = 16;
- ui.editTextPos = 2391; // (y * 40) + x
+ textEdit.numDigits = 4;
+ textEdit.numBits = 16;
+ textEdit.cursorStartX = 248;
+ textEdit.cursorStartY = 63;
}
else
{
- ui.numLen = 5;
- ui.numBits = 17;
- ui.editTextPos = 2390; // (y * 40) + x
+ textEdit.numDigits = 5;
+ textEdit.numBits = 17;
+ textEdit.cursorStartX = 240;
+ textEdit.cursorStartY = 63;
}
- getNumLine(TEXT_EDIT_HEX, PTB_EO_POS_NUM);
+ enterNumberEditMode(TEXT_EDIT_HEX, PTB_EO_POS_NUM);
}
}
break;
@@ -2990,12 +2917,13 @@
}
else
{
- ui.tmpDisp16 = editor.sampleVol;
- editor.sampleVolDisp = &ui.tmpDisp16;
- ui.numPtr16 = &ui.tmpDisp16;
- ui.numLen = 3;
- ui.editTextPos = 3711; // (y * 40) + x
- getNumLine(TEXT_EDIT_DECIMAL, PTB_EO_VOL_NUM);
+ textEdit.tmpDisp16 = editor.sampleVol;
+ editor.sampleVolDisp = &textEdit.tmpDisp16;
+ textEdit.numPtr16 = &textEdit.tmpDisp16;
+ textEdit.numDigits = 3;
+ textEdit.cursorStartX = 248;
+ textEdit.cursorStartY = 96;
+ enterNumberEditMode(TEXT_EDIT_DECIMAL, PTB_EO_VOL_NUM);
}
}
break;
@@ -3099,23 +3027,26 @@
{
if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT)
{
- ui.tmpDisp16 = song->currOrder;
- if (ui.tmpDisp16 > song->header.numOrders-1)
- ui.tmpDisp16 = song->header.numOrders-1;
+ textEdit.tmpDisp16 = song->currPos;
+ if (textEdit.tmpDisp16 > song->header.songLength-1)
+ textEdit.tmpDisp16 = song->header.songLength-1;
- ui.tmpDisp16 = song->header.order[ui.tmpDisp16];
- editor.currPosEdPattDisp = &ui.tmpDisp16;
- ui.numPtr16 = &ui.tmpDisp16;
- ui.numLen = 2;
- ui.editTextPos = 2180; // (y * 40) + x
- getNumLine(TEXT_EDIT_DECIMAL, PTB_PE_PATT);
+ textEdit.tmpDisp16 = song->header.patternTable[textEdit.tmpDisp16];
+ editor.currPosEdPattDisp = &textEdit.tmpDisp16;
+ textEdit.numPtr16 = &textEdit.tmpDisp16;
+ textEdit.numDigits = 2;
+ textEdit.cursorStartX = 160;
+ textEdit.cursorStartY = 58;
+ enterNumberEditMode(TEXT_EDIT_DECIMAL, PTB_PE_PATT);
}
}
break;
+ case PTB_PE_PATTNAME: posEdEditName(); break;
+
case PTB_PE_SCROLLTOP:
{
- if (song->currOrder != 0)
+ if (song->currPos != 0)
modSetPos(0, DONT_SET_ROW);
}
break;
@@ -3122,22 +3053,22 @@
case PTB_PE_SCROLLUP:
{
- if (song->currOrder > 0)
- modSetPos(song->currOrder - 1, DONT_SET_ROW);
+ if (song->currPos > 0)
+ modSetPos(song->currPos - 1, DONT_SET_ROW);
}
break;
case PTB_PE_SCROLLDOWN:
{
- if (song->currOrder < song->header.numOrders-1)
- modSetPos(song->currOrder + 1, DONT_SET_ROW);
+ if (song->currPos < song->header.songLength-1)
+ modSetPos(song->currPos + 1, DONT_SET_ROW);
}
break;
case PTB_PE_SCROLLBOT:
{
- if (song->currOrder != song->header.numOrders-1)
- modSetPos(song->header.numOrders - 1, DONT_SET_ROW);
+ if (song->currPos != song->header.songLength-1)
+ modSetPos(song->header.songLength - 1, DONT_SET_ROW);
}
break;
@@ -3151,18 +3082,7 @@
case PTB_POS:
case PTB_POSED:
- {
- ui.posEdScreenShown ^= 1;
- if (ui.posEdScreenShown)
- {
- renderPosEdScreen();
- ui.updatePosEd = true;
- }
- else
- {
- displayMainScreen();
- }
- }
+ posEdToggle();
break;
case PTB_POSS:
@@ -3171,8 +3091,8 @@
{
if (mouse.rightButtonPressed)
{
- song->currOrder = 0;
- editor.currPatternDisp = &song->header.order[song->currOrder];
+ song->currPos = 0;
+ editor.currPatternDisp = &song->header.patternTable[song->currPos];
if (ui.posEdScreenShown)
ui.updatePosEd = true;
@@ -3179,12 +3099,13 @@
}
else
{
- ui.tmpDisp16 = song->currOrder;
- editor.currPosDisp = &ui.tmpDisp16;
- ui.numPtr16 = &ui.tmpDisp16;
- ui.numLen = 3;
- ui.editTextPos = 169; // (y * 40) + x
- getNumLine(TEXT_EDIT_DECIMAL, PTB_POSS);
+ textEdit.tmpDisp16 = song->currPos;
+ editor.currPosDisp = &textEdit.tmpDisp16;
+ textEdit.numPtr16 = &textEdit.tmpDisp16;
+ textEdit.numDigits = 3;
+ textEdit.cursorStartX = 72;
+ textEdit.cursorStartY = 8;
+ enterNumberEditMode(TEXT_EDIT_DECIMAL, PTB_POSS);
}
}
}
@@ -3196,7 +3117,7 @@
{
if (mouse.rightButtonPressed)
{
- song->header.order[song->currOrder] = 0;
+ song->header.patternTable[song->currPos] = 0;
ui.updateSongSize = true;
updateWindowTitle(MOD_IS_MODIFIED);
@@ -3206,12 +3127,13 @@
}
else
{
- ui.tmpDisp16 = song->header.order[song->currOrder];
- editor.currPatternDisp = &ui.tmpDisp16;
- ui.numPtr16 = &ui.tmpDisp16;
- ui.numLen = 2;
- ui.editTextPos = 610; // (y * 40) + x
- getNumLine(TEXT_EDIT_DECIMAL, PTB_PATTERNS);
+ textEdit.tmpDisp16 = song->header.patternTable[song->currPos];
+ editor.currPatternDisp = &textEdit.tmpDisp16;
+ textEdit.numPtr16 = &textEdit.tmpDisp16;
+ textEdit.numDigits = 2;
+ textEdit.cursorStartX = 80;
+ textEdit.cursorStartY = 19;
+ enterNumberEditMode(TEXT_EDIT_DECIMAL, PTB_PATTERNS);
}
}
}
@@ -3223,13 +3145,13 @@
{
if (mouse.rightButtonPressed)
{
- song->header.numOrders = 1;
+ song->header.songLength = 1;
- int16_t tmp16 = song->currOrder;
- if (tmp16 > song->header.numOrders-1)
- tmp16 = song->header.numOrders-1;
+ int16_t tmp16 = song->currPos;
+ if (tmp16 > song->header.songLength-1)
+ tmp16 = song->header.songLength-1;
- editor.currPosEdPattDisp = &song->header.order[tmp16];
+ editor.currPosEdPattDisp = &song->header.patternTable[tmp16];
ui.updateSongSize = true;
updateWindowTitle(MOD_IS_MODIFIED);
@@ -3239,12 +3161,13 @@
}
else
{
- ui.tmpDisp16 = song->header.numOrders;
- editor.currLengthDisp = &ui.tmpDisp16;
- ui.numPtr16 = &ui.tmpDisp16;
- ui.numLen = 3;
- ui.editTextPos = 1049; // (y * 40) + x
- getNumLine(TEXT_EDIT_DECIMAL, PTB_LENGTHS);
+ textEdit.tmpDisp16 = song->header.songLength;
+ editor.currLengthDisp = &textEdit.tmpDisp16;
+ textEdit.numPtr16 = &textEdit.tmpDisp16;
+ textEdit.numDigits = 3;
+ textEdit.cursorStartX = 72;
+ textEdit.cursorStartY = 30;
+ enterNumberEditMode(TEXT_EDIT_DECIMAL, PTB_LENGTHS);
}
}
}
@@ -3255,12 +3178,13 @@
{
if (!ui.introTextShown && (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT || editor.playMode != PLAY_MODE_NORMAL))
{
- ui.tmpDisp16 = song->currPattern;
- editor.currEditPatternDisp = &ui.tmpDisp16;
- ui.numPtr16 = &ui.tmpDisp16;
- ui.numLen = 2;
- ui.editTextPos = 5121; // (y * 40) + x
- getNumLine(TEXT_EDIT_DECIMAL, PTB_PATTDATA);
+ textEdit.tmpDisp16 = song->currPattern;
+ editor.currEditPatternDisp = &textEdit.tmpDisp16;
+ textEdit.numPtr16 = &textEdit.tmpDisp16;
+ textEdit.numDigits = 2;
+ textEdit.cursorStartX = 8;
+ textEdit.cursorStartY = 132;
+ enterNumberEditMode(TEXT_EDIT_DECIMAL, PTB_PATTDATA);
}
}
break;
@@ -3273,13 +3197,14 @@
ui.updateCurrSampleNum = true;
}
- ui.tmpDisp8 = editor.currSample;
- editor.currSampleDisp = &ui.tmpDisp8;
- ui.numPtr8 = &ui.tmpDisp8;
- ui.numLen = 2;
- ui.numBits = 8;
- ui.editTextPos = 1930; // (y * 40) + x
- getNumLine(TEXT_EDIT_HEX, PTB_SAMPLES);
+ textEdit.tmpDisp8 = editor.currSample;
+ editor.currSampleDisp = &textEdit.tmpDisp8;
+ textEdit.numPtr8 = &textEdit.tmpDisp8;
+ textEdit.numDigits = 2;
+ textEdit.numBits = 8;
+ textEdit.cursorStartX = 80;
+ textEdit.cursorStartY = 52;
+ enterNumberEditMode(TEXT_EDIT_HEX, PTB_SAMPLES);
}
break;
@@ -3297,13 +3222,14 @@
}
else
{
- ui.tmpDisp8 = song->samples[editor.currSample].volume;
- song->samples[editor.currSample].volumeDisp = &ui.tmpDisp8;
- ui.numPtr8 = &ui.tmpDisp8;
- ui.numLen = 2;
- ui.numBits = 8;
- ui.editTextPos = 2370; // (y * 40) + x
- getNumLine(TEXT_EDIT_HEX, PTB_SVOLUMES);
+ textEdit.tmpDisp8 = song->samples[editor.currSample].volume;
+ song->samples[editor.currSample].volumeDisp = &textEdit.tmpDisp8;
+ textEdit.numPtr8 = &textEdit.tmpDisp8;
+ textEdit.numDigits = 2;
+ textEdit.numBits = 8;
+ textEdit.cursorStartX = 80;
+ textEdit.cursorStartY = 63;
+ enterNumberEditMode(TEXT_EDIT_HEX, PTB_SVOLUMES);
}
}
break;
@@ -3343,26 +3269,28 @@
}
else
{
- ui.force32BitNumPtr = true;
+ textEdit.force32BitNumPtr = true;
- ui.tmpDisp32 = song->samples[editor.currSample].length;
- song->samples[editor.currSample].lengthDisp = &ui.tmpDisp32;
- ui.numPtr32 = &ui.tmpDisp32;
+ textEdit.tmpDisp32 = song->samples[editor.currSample].length;
+ song->samples[editor.currSample].lengthDisp = &textEdit.tmpDisp32;
+ textEdit.numPtr32 = &textEdit.tmpDisp32;
if (config.maxSampleLength == 65534)
{
- ui.numLen = 4;
- ui.numBits = 16;
- ui.editTextPos = 2808; // (y * 40) + x
+ textEdit.numDigits = 4;
+ textEdit.numBits = 16;
+ textEdit.cursorStartX = 64;
+ textEdit.cursorStartY = 74;
}
else
{
- ui.numLen = 5;
- ui.numBits = 17;
- ui.editTextPos = 2807; // (y * 40) + x
+ textEdit.numDigits = 5;
+ textEdit.numBits = 17;
+ textEdit.cursorStartX = 56;
+ textEdit.cursorStartY = 74;
}
- getNumLine(TEXT_EDIT_HEX, PTB_SLENGTHS);
+ enterNumberEditMode(TEXT_EDIT_HEX, PTB_SLENGTHS);
}
}
break;
@@ -3405,26 +3333,28 @@
}
else
{
- ui.force32BitNumPtr = true;
+ textEdit.force32BitNumPtr = true;
- ui.tmpDisp32 = song->samples[editor.currSample].loopStart;
- song->samples[editor.currSample].loopStartDisp = &ui.tmpDisp32;
- ui.numPtr32 = &ui.tmpDisp32;
+ textEdit.tmpDisp32 = song->samples[editor.currSample].loopStart;
+ song->samples[editor.currSample].loopStartDisp = &textEdit.tmpDisp32;
+ textEdit.numPtr32 = &textEdit.tmpDisp32;
if (config.maxSampleLength == 65534)
{
- ui.numLen = 4;
- ui.numBits = 16;
- ui.editTextPos = 3248; // (y * 40) + x
+ textEdit.numDigits = 4;
+ textEdit.numBits = 16;
+ textEdit.cursorStartX = 64;
+ textEdit.cursorStartY = 85;
}
else
{
- ui.numLen = 5;
- ui.numBits = 17;
- ui.editTextPos = 3247; // (y * 40) + x
+ textEdit.numDigits = 5;
+ textEdit.numBits = 17;
+ textEdit.cursorStartX = 56;
+ textEdit.cursorStartY = 85;
}
- getNumLine(TEXT_EDIT_HEX, PTB_SREPEATS);
+ enterNumberEditMode(TEXT_EDIT_HEX, PTB_SREPEATS);
}
}
break;
@@ -3470,26 +3400,28 @@
}
else
{
- ui.force32BitNumPtr = true;
+ textEdit.force32BitNumPtr = true;
- ui.tmpDisp32 = song->samples[editor.currSample].loopLength;
- song->samples[editor.currSample].loopLengthDisp = &ui.tmpDisp32;
- ui.numPtr32 = &ui.tmpDisp32;
+ textEdit.tmpDisp32 = song->samples[editor.currSample].loopLength;
+ song->samples[editor.currSample].loopLengthDisp = &textEdit.tmpDisp32;
+ textEdit.numPtr32 = &textEdit.tmpDisp32;
if (config.maxSampleLength == 0xFFFE)
{
- ui.numLen = 4;
- ui.numBits = 16;
- ui.editTextPos = 3688; // (y * 40) + x
+ textEdit.numDigits = 4;
+ textEdit.numBits = 16;
+ textEdit.cursorStartX = 64;
+ textEdit.cursorStartY = 96;
}
else
{
- ui.numLen = 5;
- ui.numBits = 17;
- ui.editTextPos = 3687; // (y * 40) + x
+ textEdit.numDigits = 5;
+ textEdit.numBits = 17;
+ textEdit.cursorStartX = 56;
+ textEdit.cursorStartY = 96;
}
- getNumLine(TEXT_EDIT_HEX, PTB_SREPLENS);
+ enterNumberEditMode(TEXT_EDIT_HEX, PTB_SREPLENS);
}
}
break;
@@ -3726,54 +3658,9 @@
case PTB_SA_TUNETONE: toggleTuningTone(); break;
- case PTB_POSINS:
- {
- if ((editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT) && song->header.numOrders < 128)
- {
- for (int32_t i = 0; i < 127-song->currOrder; i++)
- song->header.order[127-i] = song->header.order[(127-i)-1];
- song->header.order[song->currOrder] = 0;
+ case PTB_POSINS: posEdInsert(); break;
+ case PTB_POSDEL: posEdDelete(); break;
- song->header.numOrders++;
- if (song->currOrder > song->header.numOrders-1)
- editor.currPosEdPattDisp = &song->header.order[song->header.numOrders-1];
-
- updateWindowTitle(MOD_IS_MODIFIED);
-
- ui.updateSongSize = true;
- ui.updateSongLength = true;
- ui.updateSongPattern = true;
-
- if (ui.posEdScreenShown)
- ui.updatePosEd = true;
- }
- }
- break;
-
- case PTB_POSDEL:
- {
- if ((editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT) && song->header.numOrders > 1)
- {
- for (int32_t i = 0; i < 128-song->currOrder; i++)
- song->header.order[song->currOrder+i] = song->header.order[song->currOrder+i+1];
- song->header.order[127] = 0;
-
- song->header.numOrders--;
- if (song->currOrder > song->header.numOrders-1)
- editor.currPosEdPattDisp = &song->header.order[song->header.numOrders-1];
-
- updateWindowTitle(MOD_IS_MODIFIED);
-
- ui.updateSongSize = true;
- ui.updateSongLength = true;
- ui.updateSongPattern = true;
-
- if (ui.posEdScreenShown)
- ui.updatePosEd = true;
- }
- }
- break;
-
case PTB_DO_SAVEMODULE:
{
bool changeLoadMode = (diskop.mode != DISKOP_MODE_MOD);
@@ -3807,13 +3694,13 @@
ui.updateDiskOpPathText = true;
}
- ui.showTextPtr = editor.currPath;
- ui.textEndPtr = &editor.currPath[PATH_MAX - 1];
- ui.textLength = 26;
- ui.editTextPos = 1043; // (y * 40) + x
- ui.dstOffset = &ui.diskOpPathTextOffset;
- ui.dstOffsetEnd = false;
- getTextLine(PTB_DO_DATAPATH);
+ textEdit.textStartPtr = editor.currPath;
+ textEdit.textEndPtr = &editor.currPath[PATH_MAX - 1];
+ textEdit.numBlocks = 26;
+ textEdit.cursorStartX = 24;
+ textEdit.cursorStartY = 30;
+ textEdit.scrollable = true;
+ enterTextEditMode(PTB_DO_DATAPATH);
}
break;
@@ -3827,13 +3714,13 @@
}
else
{
- ui.showTextPtr = song->header.name;
- ui.textEndPtr = song->header.name + 19;
- ui.textLength = 20;
- ui.editTextPos = 4133; // (y * 40) + x
- ui.dstOffset = NULL;
- ui.dstOffsetEnd = false;
- getTextLine(PTB_SONGNAME);
+ textEdit.textStartPtr = song->header.name;
+ textEdit.textEndPtr = song->header.name + 19;
+ textEdit.numBlocks = 20;
+ textEdit.cursorStartX = 104;
+ textEdit.cursorStartY = 107;
+ textEdit.scrollable = false;
+ enterTextEditMode(PTB_SONGNAME);
}
}
break;
@@ -3848,13 +3735,13 @@
}
else
{
- ui.showTextPtr = song->samples[editor.currSample].text;
- ui.textEndPtr = song->samples[editor.currSample].text + 21;
- ui.textLength = 22;
- ui.editTextPos = 4573; // (y * 40) + x
- ui.dstOffset = NULL;
- ui.dstOffsetEnd = false;
- getTextLine(PTB_SAMPLENAME);
+ textEdit.textStartPtr = song->samples[editor.currSample].text;
+ textEdit.textEndPtr = song->samples[editor.currSample].text + 21;
+ textEdit.numBlocks = 22;
+ textEdit.cursorStartX = 104;
+ textEdit.cursorStartY = 118;
+ textEdit.scrollable = false;
+ enterTextEditMode(PTB_SAMPLENAME);
}
}
break;
@@ -4043,9 +3930,9 @@
editor.playMode = PLAY_MODE_NORMAL;
if (mouse.rightButtonPressed)
- modPlay(DONT_SET_PATTERN, song->currOrder, song->currRow);
+ modPlay(DONT_SET_PATTERN, song->currPos, song->currRow);
else
- modPlay(DONT_SET_PATTERN, song->currOrder, DONT_SET_ROW);
+ modPlay(DONT_SET_PATTERN, song->currPos, DONT_SET_ROW);
editor.currMode = MODE_PLAY;
pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
@@ -4126,6 +4013,14 @@
pointerSetMode(POINTER_MODE_IDLE, DO_CARRY);
statusAllRight();
+ // hide edit op. and about screen, and redraw visualizer
+
+ ui.editOpScreenShown = false;
+ ui.aboutScreenShown = false;
+
+ if (ui.visualizerMode == VISUAL_QUADRASCOPE) renderQuadrascopeBg();
+ else if (ui.visualizerMode == VISUAL_SPECTRUM) renderSpectrumAnalyzerBg();
+
updateWindowTitle(MOD_IS_MODIFIED);
}
break;
@@ -4271,7 +4166,7 @@
case PTB_LENGTHU:
{
- if (song->header.numOrders < 128)
+ if (song->header.songLength < 128)
{
songLengthUpButton();
updateWindowTitle(MOD_IS_MODIFIED);
@@ -4281,7 +4176,7 @@
case PTB_LENGTHD:
{
- if (song->header.numOrders > 1)
+ if (song->header.songLength > 1)
{
songLengthDownButton();
updateWindowTitle(MOD_IS_MODIFIED);
@@ -4291,7 +4186,7 @@
case PTB_PATTERNU:
{
- if (song->header.order[song->currOrder] < 99)
+ if (song->header.patternTable[song->currPos] < 99)
{
patternUpButton();
updateWindowTitle(MOD_IS_MODIFIED);
@@ -4301,7 +4196,7 @@
case PTB_PATTERND:
{
- if (song->header.order[song->currOrder] > 0)
+ if (song->header.patternTable[song->currPos] > 0)
{
patternDownButton();
updateWindowTitle(MOD_IS_MODIFIED);
@@ -4731,8 +4626,8 @@
if (mouse.repeatCounter >= 2)
{
mouse.repeatCounter = 0;
- if (song->currOrder > 0)
- modSetPos(song->currOrder - 1, DONT_SET_ROW);
+ if (song->currPos > 0)
+ modSetPos(song->currPos - 1, DONT_SET_ROW);
}
}
break;
@@ -4742,8 +4637,8 @@
if (mouse.repeatCounter >= 2)
{
mouse.repeatCounter = 0;
- if (song->currOrder < song->header.numOrders-1)
- modSetPos(song->currOrder + 1, DONT_SET_ROW);
+ if (song->currPos < song->header.songLength-1)
+ modSetPos(song->currPos + 1, DONT_SET_ROW);
}
}
break;
--- a/src/pt2_mouse.h
+++ b/src/pt2_mouse.h
@@ -17,6 +17,7 @@
// POS ED. SCREEN
PTB_PE_BADGE,
PTB_PE_PATT,
+ PTB_PE_PATTNAME,
PTB_PE_SCROLLTOP,
PTB_PE_SCROLLUP,
PTB_PE_EXIT,
--- /dev/null
+++ b/src/pt2_posed.c
@@ -1,0 +1,160 @@
+#include <stdint.h>
+#include <stdbool.h>
+#include "pt2_textout.h"
+#include "pt2_visuals.h"
+#include "pt2_helpers.h"
+#include "pt2_replayer.h"
+#include "pt2_bmp.h"
+#include "pt2_mouse.h"
+#include "pt2_edit.h"
+#include "pt2_textedit.h"
+#include "pt2_posed.h"
+
+static char posEdNames[MAX_PATTERNS][16];
+
+void posEdClearNames(void)
+{
+ memset(posEdNames, 0, sizeof (posEdNames));
+
+ if (ui.posEdScreenShown)
+ ui.updatePosEd = true;
+}
+
+void posEdEditName(void)
+{
+ if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT)
+ {
+ const uint8_t pattern = (uint8_t)song->header.patternTable[song->currPos & 0x7F];
+
+ textEdit.textStartPtr = posEdNames[pattern];
+ textEdit.textEndPtr = posEdNames[pattern] + 15;
+ textEdit.numBlocks = 15;
+ textEdit.cursorStartX = 184;
+ textEdit.cursorStartY = 58;
+ textEdit.scrollable = true;
+ enterTextEditMode(PTB_PE_PATTNAME);
+ }
+}
+
+void posEdInsert(void)
+{
+ if ((editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT) && song->header.songLength < 128)
+ {
+ for (int32_t i = 0; i < 127-song->currPos; i++)
+ song->header.patternTable[127-i] = song->header.patternTable[(127-i)-1];
+ song->header.patternTable[song->currPos] = 0;
+
+ song->header.songLength++;
+ if (song->currPos > song->header.songLength-1)
+ editor.currPosEdPattDisp = &song->header.patternTable[song->header.songLength-1];
+
+ updateWindowTitle(MOD_IS_MODIFIED);
+
+ ui.updateSongSize = true;
+ ui.updateSongLength = true;
+ ui.updateSongPattern = true;
+
+ if (ui.posEdScreenShown)
+ ui.updatePosEd = true;
+ }
+}
+
+void posEdDelete(void)
+{
+ if ((editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT) && song->header.songLength > 1)
+ {
+ for (int32_t i = 0; i < 128-song->currPos; i++)
+ song->header.patternTable[song->currPos+i] = song->header.patternTable[song->currPos+i+1];
+ song->header.patternTable[127] = 0;
+
+ song->header.songLength--;
+ if (song->currPos > song->header.songLength-1)
+ editor.currPosEdPattDisp = &song->header.patternTable[song->header.songLength-1];
+
+ updateWindowTitle(MOD_IS_MODIFIED);
+
+ ui.updateSongSize = true;
+ ui.updateSongLength = true;
+ ui.updateSongPattern = true;
+
+ if (ui.posEdScreenShown)
+ ui.updatePosEd = true;
+ }
+}
+
+void posEdToggle(void)
+{
+ ui.posEdScreenShown ^= 1;
+ if (ui.posEdScreenShown)
+ {
+ renderPosEdScreen();
+ ui.updatePosEd = true;
+ }
+ else
+ {
+ displayMainScreen();
+ }
+}
+
+void renderPosEdScreen(void)
+{
+ blit32(120, 0, 200, 99, posEdBMP);
+ ui.updatePosEd = true;
+}
+
+static void drawPosEdName(int32_t entry, int32_t y, bool selected)
+{
+ const uint8_t pattern = (uint8_t)song->header.patternTable[entry & 0x7F];
+ for (int32_t i = 0; i < 15; i++)
+ {
+ const int32_t x = 184 + (i * FONT_CHAR_W);
+
+ char ch;
+
+ if (ui.editTextFlag)
+ ch = posEdNames[pattern][textEdit.scrollOffset + i];
+ else
+ ch = posEdNames[pattern][i];
+
+ if (ch == '\0')
+ break;
+
+ if (selected)
+ charOut(x, y, ch, video.palette[PAL_GENTXT]);
+ else
+ charOut(x, y, ch, video.palette[PAL_QADSCP]);
+ }
+}
+
+void updatePosEd(void)
+{
+ if (!ui.updatePosEd || !ui.posEdScreenShown || ui.askBoxShown)
+ return;
+
+ ui.updatePosEd = false;
+
+ // clear entries first
+ fillRect(128, 23, (22*FONT_CHAR_W)-1, ((FONT_CHAR_H+1)*5)-1, video.palette[PAL_BACKGRD]);
+ fillRect(128, 53, (22*FONT_CHAR_W)-1, FONT_CHAR_H, video.palette[PAL_GENBKG]);
+ fillRect(128, 59, (22*FONT_CHAR_W)-1, ((FONT_CHAR_H+1)*6)-1, video.palette[PAL_BACKGRD]);
+
+ for (int32_t i = 0; i < POSED_LIST_SIZE; i++)
+ {
+ const int32_t entry = song->currPos - (5 - i);
+ if (entry < 0 || entry >= song->header.songLength)
+ continue;
+
+ const int32_t pattern = song->header.patternTable[entry];
+ const int32_t yPos = 23 + (i * (FONT_CHAR_H+1));
+ const bool selected = (i == 5);
+ const uint32_t textColor = selected ? video.palette[PAL_GENTXT] : video.palette[PAL_QADSCP];
+
+ printThreeDecimals(128, yPos, entry, textColor);
+ printTwoDecimals(160, yPos, selected ? *editor.currPosEdPattDisp : pattern, textColor);
+ drawPosEdName(entry, yPos, selected);
+ }
+
+ // kludge to fix bottom part of text edit marker
+ if (ui.editTextFlag && (textEdit.object == PTB_PE_PATT || textEdit.object == PTB_PE_PATTNAME))
+ renderTextEditCursor();
+}
--- /dev/null
+++ b/src/pt2_posed.h
@@ -1,0 +1,11 @@
+#pragma once
+
+#define POSED_LIST_SIZE 12
+
+void posEdClearNames(void);
+void posEdEditName(void);
+void posEdInsert(void);
+void posEdDelete(void);
+void posEdToggle(void);
+void renderPosEdScreen(void);
+void updatePosEd(void);
--- a/src/pt2_replayer.c
+++ b/src/pt2_replayer.c
@@ -15,12 +15,13 @@
#include "pt2_scopes.h"
#include "pt2_paula.h"
#include "pt2_visuals_sync.h"
+#include "pt2_posed.h"
static bool posJumpAssert, pBreakFlag, modRenderDone;
static bool doStopSong; // from F00 (Set Speed)
static int8_t pBreakPosition, oldRow, modPattern;
static uint8_t pattDelTime, lowMask = 0xFF, pattDelTime2;
-static int16_t modOrder, oldPattern, oldOrder;
+static int16_t modPos, oldPattern, oldPos;
static uint16_t DMACONtemp;
static int32_t modBPM, oldBPM, oldSpeed, ciaSetBPM;
@@ -30,6 +31,13 @@
0x10, 0x13, 0x16, 0x1A, 0x20, 0x2B, 0x40, 0x80
};
+void gotoNextMulti(void)
+{
+ cursor.channel = (editor.multiModeNext[cursor.channel] - 1) & 3;
+ cursor.pos = cursor.channel * 6;
+ updateCursorPos();
+}
+
double ciaBpm2Hz(int32_t bpm)
{
if (bpm == 0)
@@ -112,7 +120,7 @@
return;
modPattern = (int8_t)song->currPattern;
- modOrder = song->currOrder;
+ modPos = song->currPos;
song->row = song->currRow;
song->tick = 0;
}
@@ -137,7 +145,7 @@
goto error;
}
- m->header.numOrders = 1;
+ m->header.songLength = 1;
moduleSample_t *s = m->samples;
for (int32_t i = 0; i < MOD_SAMPLES; i++, s++)
@@ -222,7 +230,7 @@
{
oldBPM = song->currBPM;
oldRow = song->currRow;
- oldOrder = song->currOrder;
+ oldPos = song->currPos;
oldSpeed = song->currSpeed;
oldPattern = song->currPattern;
}
@@ -309,7 +317,7 @@
if (editor.mod2WavOngoing)
{
for (int32_t tempParam = pBreakPosition; tempParam <= song->row; tempParam++)
- editor.rowVisitTable[(modOrder * MOD_ROWS) + tempParam] = false;
+ editor.rowVisitTable[(modPos * MOD_ROWS) + tempParam] = false;
}
}
}
@@ -464,7 +472,7 @@
{
// original PT doesn't do this check, but we have to
if (editor.playMode != PLAY_MODE_PATTERN || (editor.currMode == MODE_RECORD && editor.recordMode != RECORD_PATT))
- modOrder = (ch->n_cmd & 0xFF) - 1; // B00 results in -1, but it safely jumps to order 0
+ modPos = (ch->n_cmd & 0xFF) - 1; // B00 results in -1, but it safely jumps to order 0
pBreakPosition = 0;
posJumpAssert = true;
@@ -1099,10 +1107,10 @@
return; // don't update UI under MOD2WAV/PAT2SMP rendering
song->currRow = song->row;
- song->currOrder = modOrder;
+ song->currPos = modPos;
song->currPattern = modPattern;
- uint16_t *currPatPtr = &song->header.order[modOrder];
+ uint16_t *currPatPtr = &song->header.patternTable[modPos];
editor.currPatternDisp = currPatPtr;
editor.currPosEdPattDisp = currPatPtr;
editor.currPatternDisp = currPatPtr;
@@ -1162,10 +1170,10 @@
return;
}
- modOrder = (modOrder + 1) & 127;
- if (modOrder >= song->header.numOrders)
+ modPos = (modPos + 1) & 127;
+ if (modPos >= song->header.songLength)
{
- modOrder = 0;
+ modPos = 0;
if (config.compoMode) // stop song for music competitions playing
{
@@ -1172,8 +1180,8 @@
doStopIt(true);
turnOffVoices();
- modOrder = 0;
- modPattern = (int8_t)song->header.order[modOrder];
+ modPos = 0;
+ modPattern = (int8_t)song->header.patternTable[modPos];
song->row = 0;
updateUIPositions();
@@ -1183,7 +1191,7 @@
modRenderDone = true;
}
- modPattern = (int8_t)song->header.order[modOrder];
+ modPattern = (int8_t)song->header.patternTable[modPos];
if (modPattern > MAX_PATTERNS-1)
modPattern = MAX_PATTERNS-1;
}
@@ -1210,7 +1218,7 @@
static void setCurrRowToVisited(void) // for MOD2WAV
{
if (editor.mod2WavOngoing)
- editor.rowVisitTable[(modOrder * MOD_ROWS) + song->row] = true;
+ editor.rowVisitTable[(modPos * MOD_ROWS) + song->row] = true;
}
static bool renderEndCheck(void) // for MOD2WAV/PAT2SMP
@@ -1229,7 +1237,7 @@
if (editor.mod2WavOngoing && song->tick == song->speed-1)
{
- bool rowVisited = editor.rowVisitTable[(modOrder * MOD_ROWS) + song->row];
+ bool rowVisited = editor.rowVisitTable[(modPos * MOD_ROWS) + song->row];
if (rowVisited || modRenderDone)
{
modRenderDone = false;
@@ -1454,7 +1462,7 @@
ui.updateCurrPattText = true;
}
-void modSetPos(int16_t order, int16_t row)
+void modSetPos(int16_t pos, int16_t row)
{
if (row != -1)
{
@@ -1465,17 +1473,16 @@
song->currRow = (int8_t)row;
}
- if (order != -1)
+ if (pos != -1)
{
- if (order >= 0)
+ if (pos >= 0)
{
- modOrder = order;
- song->currOrder = order;
+ song->currPos = modPos = pos;
ui.updateSongPos = true;
if (editor.currMode == MODE_PLAY && editor.playMode == PLAY_MODE_NORMAL)
{
- modPattern = (int8_t)song->header.order[order];
+ modPattern = (int8_t)song->header.patternTable[pos];
if (modPattern > MAX_PATTERNS-1)
modPattern = MAX_PATTERNS-1;
@@ -1484,13 +1491,13 @@
}
ui.updateSongPattern = true;
- editor.currPatternDisp = &song->header.order[modOrder];
+ editor.currPatternDisp = &song->header.patternTable[modPos];
- int16_t posEdPos = song->currOrder;
- if (posEdPos > song->header.numOrders-1)
- posEdPos = song->header.numOrders-1;
+ int16_t posEdPos = song->currPos;
+ if (posEdPos > song->header.songLength-1)
+ posEdPos = song->header.songLength-1;
- editor.currPosEdPattDisp = &song->header.order[posEdPos];
+ editor.currPosEdPattDisp = &song->header.patternTable[posEdPos];
if (ui.posEdScreenShown)
ui.updatePosEd = true;
@@ -1584,7 +1591,7 @@
ui.updateCurrPattText = true;
}
-void modPlay(int16_t patt, int16_t order, int8_t row)
+void modPlay(int16_t patt, int16_t pos, int8_t row)
{
const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
@@ -1609,32 +1616,23 @@
if (editor.playMode != PLAY_MODE_PATTERN)
{
- if (modOrder >= song->header.numOrders)
- {
- modOrder = 0;
- song->currOrder = 0;
- }
+ if (modPos >= song->header.songLength)
+ song->currPos = modPos = 0;
- if (order >= 0 && order < song->header.numOrders)
- {
- modOrder = order;
- song->currOrder = order;
- }
+ if (pos >= 0 && pos < song->header.songLength)
+ song->currPos = modPos = pos;
- if (order >= song->header.numOrders)
- {
- modOrder = 0;
- song->currOrder = 0;
- }
+ if (pos >= song->header.songLength)
+ song->currPos = modPos = 0;
}
if (patt >= 0 && patt <= MAX_PATTERNS-1)
song->currPattern = modPattern = (int8_t)patt;
else
- song->currPattern = modPattern = (int8_t)song->header.order[modOrder];
+ song->currPattern = modPattern = (int8_t)song->header.patternTable[modPos];
- editor.currPatternDisp = &song->header.order[modOrder];
- editor.currPosEdPattDisp = &song->header.order[modOrder];
+ editor.currPatternDisp = &song->header.patternTable[modPos];
+ editor.currPosEdPattDisp = &song->header.patternTable[modPos];
song->tick = song->speed-1;
ciaSetBPM = -1; // fix possibly stuck "set BPM" flag
@@ -1671,9 +1669,11 @@
if (song == NULL)
return;
- memset(song->header.order, 0, sizeof (song->header.order));
+ memset(song->header.patternTable, 0, sizeof (song->header.patternTable));
memset(song->header.name, 0, sizeof (song->header.name));
+ posEdClearNames();
+
editor.muted[0] = false;
editor.muted[1] = false;
editor.muted[2] = false;
@@ -1694,7 +1694,7 @@
editor.blockMarkFlag = false;
editor.swapChannelFlag = false;
- song->header.numOrders = 1;
+ song->header.songLength = 1;
for (int32_t i = 0; i < MAX_PATTERNS; i++)
memset(song->patterns[i], 0, (MOD_ROWS * PAULA_VOICES) * sizeof (note_t));
@@ -1710,10 +1710,10 @@
modSetPos(0, 0); // this also refreshes pattern data
- song->currOrder = 0;
+ song->currPos = 0;
song->currPattern = 0;
- editor.currPatternDisp = &song->header.order[0];
- editor.currPosEdPattDisp = &song->header.order[0];
+ editor.currPatternDisp = &song->header.patternTable[0];
+ editor.currPosEdPattDisp = &song->header.patternTable[0];
modSetTempo(editor.initialTempo, true);
modSetSpeed(editor.initialSpeed);
@@ -1752,11 +1752,9 @@
editor.currSample = 0;
editor.hiLowInstr = 0;
editor.sampleZero = false;
- ui.editOpScreenShown = false;
- ui.aboutScreenShown = false;
editor.blockMarkFlag = false;
-
editor.samplePos = 0;
+
updateCurrSample();
}
@@ -1799,7 +1797,7 @@
song->currRow = 0;
song->rowsCounter = 0;
- memset(editor.rowVisitTable, 0, MOD_ORDERS * MOD_ROWS); // for MOD2WAV
+ memset(editor.rowVisitTable, 0, 128 * MOD_ROWS); // for MOD2WAV
if (editor.pat2SmpOngoing)
{
@@ -1835,19 +1833,19 @@
initializeModuleChannels(song);
- modOrder = oldOrder;
+ modPos = oldPos;
modPattern = (int8_t)oldPattern;
song->row = oldRow;
song->currRow = oldRow;
song->currBPM = oldBPM;
- song->currOrder = oldOrder;
+ song->currPos = oldPos;
song->currPattern = oldPattern;
- editor.currPosDisp = &song->currOrder;
+ editor.currPosDisp = &song->currPos;
editor.currEditPatternDisp = &song->currPattern;
- editor.currPatternDisp = &song->header.order[song->currOrder];
- editor.currPosEdPattDisp = &song->header.order[song->currOrder];
+ editor.currPatternDisp = &song->header.patternTable[song->currPos];
+ editor.currPosEdPattDisp = &song->header.patternTable[song->currPos];
modSetSpeed(oldSpeed);
modSetTempo(oldBPM, true);
--- a/src/pt2_replayer.h
+++ b/src/pt2_replayer.h
@@ -7,6 +7,7 @@
#define MIN_BPM 32
#define MAX_BPM 255
+void gotoNextMulti(void);
double ciaBpm2Hz(int32_t bpm);
void updatePaulaLoops(void); // used after manipulating Paula sample loop points while playing
void turnOffVoices(void);
@@ -20,11 +21,11 @@
void resetSong(void);
void incPatt(void);
void decPatt(void);
-void modSetPos(int16_t order, int16_t row);
+void modSetPos(int16_t pos, int16_t row);
void modStop(void);
void doStopIt(bool resetPlayMode);
void playPattern(int8_t startRow);
-void modPlay(int16_t patt, int16_t order, int8_t row);
+void modPlay(int16_t patt, int16_t pos, int8_t row);
void modSetSpeed(int32_t speed);
void modSetTempo(int32_t bpm, bool doLockAudio);
void modFree(void);
--- a/src/pt2_structs.c
+++ b/src/pt2_structs.c
@@ -7,3 +7,4 @@
diskop_t diskop;
cursor_t cursor;
ui_t ui;
+textEdit_t textEdit;
--- a/src/pt2_structs.h
+++ b/src/pt2_structs.h
@@ -52,7 +52,7 @@
typedef struct moduleHeader_t
{
char name[20 + 1];
- uint16_t order[MOD_ORDERS], numOrders;
+ uint16_t patternTable[128], songLength;
uint16_t initialTempo; // used for STK/UST modules after module is loaded
} moduleHeader_t;
@@ -100,7 +100,7 @@
// for pattern viewer
int8_t currRow;
int32_t currSpeed, currBPM;
- uint16_t currOrder, currPattern;
+ uint16_t currPos, currPattern;
// for MOD2WAV progress bar
uint32_t rowsCounter, rowsInTotal;
@@ -158,7 +158,7 @@
volatile uint16_t *currPosEdPattDisp, *currLengthDisp, *lpCutOffDisp, *hpCutOffDisp;
volatile int32_t *samplePosDisp, *chordLengthDisp;
- char mixText[16];
+ char mixText[16+1];
char *entryNameTmp, *currPath, *dropTempFileName;
UNICHAR *fileNameTmpU, *currPathU, *modulesPathU, *samplesPathU;
@@ -166,7 +166,7 @@
bool sampleAllFlag, halfClipFlag, newOldFlag, pat2SmpHQ, mixFlag;
bool modLoaded, autoInsFlag, repeatKeyFlag, sampleZero, tuningToneFlag;
bool stepPlayEnabled, stepPlayBackwards, blockBufferFlag, blockMarkFlag, didQuantize;
- bool swapChannelFlag, configFound, chordLengthMin, rowVisitTable[MOD_ORDERS * MOD_ROWS];
+ bool swapChannelFlag, configFound, chordLengthMin, rowVisitTable[128 * MOD_ROWS];
bool muted[PAULA_VOICES];
int8_t smpRedoFinetunes[MOD_SAMPLES], smpRedoVolumes[MOD_SAMPLES], multiModeNext[4], trackPattFlag;
@@ -201,6 +201,7 @@
bool modPackFlg;
int8_t mode, smpSaveType;
int32_t numEntries, scrollOffset;
+ SDL_Keycode lastEntryJumpKey;
SDL_Thread *fillThread;
} diskop_t;
@@ -213,20 +214,18 @@
typedef struct ui_t
{
char statusMessage[18], prevStatusMessage[18];
- char *dstPtr, *editPos, *textEndPtr, *showTextPtr;
-
volatile bool askBoxShown, throwExit;
-
bool editTextFlag, samplerScreenShown;
bool leftLoopPinMoving, rightLoopPinMoving, changingSmpResample, changingDrumPadNote;
bool forceSampleDrag, forceSampleEdit, introTextShown;
bool aboutScreenShown, posEdScreenShown, diskOpScreenShown;
bool samplerVolBoxShown, samplerFiltersBoxShown, samplingBoxShown, editOpScreenShown;
- bool changingSamplingNote, force32BitNumPtr;
-
- int8_t *numPtr8, tmpDisp8, pointerMode, editOpScreen, editTextType;
+ bool changingSamplingNote;
+ bool disableVisualizer; // ask boxes (f.ex. MOD2WAV)
+ int8_t pointerMode, editOpScreen;
int8_t visualizerMode, previousPointerMode, forceVolDrag, changingChordNote;
- uint8_t numLen, numBits;
+ int16_t sampleMarkingPos;
+ uint16_t lastSampleOffset;
// render/update flags
bool updateStatusText, updatePatternData;
@@ -259,15 +258,19 @@
// pos ed.
bool updatePosEd, updateDiskOpFileList;
-
- bool disableVisualizer; // ask boxes (f.ex. MOD2WAV)
-
- int16_t lineCurX, lineCurY, editObject, sampleMarkingPos;
- uint16_t *numPtr16, tmpDisp16, *dstOffset, dstPos, textLength, editTextPos;
- uint16_t dstOffsetEnd, lastSampleOffset, diskOpPathTextOffset;
- int32_t *numPtr32, tmpDisp32;
} ui_t;
+typedef struct textEdit_t
+{
+ bool endReached, scrollable, force32BitNumPtr;
+ char *textPtr, *textEndPtr, *textStartPtr;
+ int8_t *numPtr8, tmpDisp8, type;
+ uint8_t numDigits, numBits;
+ int16_t cursorStartX, cursorStartY, object;
+ uint16_t *numPtr16, tmpDisp16, cursorBlock, numBlocks;
+ int32_t scrollOffset, *numPtr32, tmpDisp32;
+} textEdit_t;
+
extern keyb_t keyb;
extern mouse_t mouse;
extern video_t video;
@@ -275,5 +278,5 @@
extern diskop_t diskop;
extern cursor_t cursor;
extern ui_t ui;
-
+extern textEdit_t textEdit;
extern module_t *song; // pt2_main.c
--- a/src/pt2_tables.c
+++ b/src/pt2_tables.c
@@ -360,7 +360,7 @@
{268, 0,319, 10, PTB_PLAY},
{120, 11,171, 21, PTB_POSDEL},
- {178, 22,307, 98, PTB_DUMMY},
+ {178, 22,307, 98, PTB_PE_PATTNAME},
{268, 11,319, 21, PTB_PATTERN},
{120, 22,177, 98, PTB_PE_PATT},
--- /dev/null
+++ b/src/pt2_textedit.c
@@ -1,0 +1,1329 @@
+// for finding memory leaks in debug mode with Visual Studio
+#if defined _DEBUG && defined _MSC_VER
+#include <crtdbg.h>
+#endif
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <ctype.h>
+#include "pt2_textout.h"
+#include "pt2_visuals.h"
+#include "pt2_helpers.h"
+#include "pt2_replayer.h"
+#include "pt2_bmp.h"
+#include "pt2_mouse.h"
+#include "pt2_edit.h"
+#include "pt2_config.h"
+#include "pt2_diskop.h"
+#include "pt2_sampler.h"
+#include "pt2_audio.h"
+#include "pt2_chordmaker.h"
+#include "pt2_textedit.h"
+
+// PATH_MAX is the absolute longest editable string possible
+static char oldText[PATH_MAX+2];
+static uint32_t oldTextLength;
+
+void renderTextEditCursor(void)
+{
+ if (!ui.editTextFlag)
+ return;
+
+ const int32_t x = textEdit.cursorStartX + (textEdit.cursorBlock * FONT_CHAR_W);
+ const int32_t y = textEdit.cursorStartY;
+ const int32_t w = 7;
+ const int32_t h = 2;
+
+ if (x < 0 || x+w >= SCREEN_W || y < 0 || y+h >= SCREEN_H)
+ return;
+
+ fillRect(x, y, w, h, video.palette[PAL_TEXTMARK]);
+}
+
+void removeTextEditCursor(void)
+{
+ if (!ui.editTextFlag)
+ return;
+
+ const int32_t x = textEdit.cursorStartX + (textEdit.cursorBlock * FONT_CHAR_W);
+ const int32_t y = textEdit.cursorStartY;
+ const int32_t w = 7;
+ const int32_t h = 2;
+
+ if (x < 0 || x+w >= SCREEN_W || y < 0 || y+h >= SCREEN_H)
+ return;
+
+ if (textEdit.object == PTB_PE_PATT || textEdit.object == PTB_PE_PATTNAME)
+ {
+ // position editor text editing needs different handling
+
+ // rewrite border pixels (below second row of text edit cursor)
+ hLine(x, y, w, video.palette[PAL_GENBKG2]);
+
+ ui.updatePosEd = true; // this also erases the first row of the text edit cursor
+ }
+ else
+ {
+ // all others
+ fillRect(x, y, w, h, video.palette[PAL_GENBKG]);
+ }
+}
+
+static void moveTextCursorLeft(void)
+{
+ if (textEdit.cursorBlock > 0)
+ {
+ removeTextEditCursor();
+ textEdit.cursorBlock--;
+ renderTextEditCursor();
+ }
+ else if (textEdit.scrollable)
+ {
+ if (textEdit.scrollOffset > 0)
+ {
+ textEdit.scrollOffset--;
+
+ if (textEdit.object == PTB_DO_DATAPATH)
+ ui.updateDiskOpPathText = true;
+ else if (textEdit.object == PTB_PE_PATTNAME)
+ ui.updatePosEd = true;
+ }
+ }
+}
+
+static void moveTextCursorRight(void)
+{
+ if (textEdit.type == TEXT_EDIT_STRING)
+ {
+ if (textEdit.cursorBlock < textEdit.numBlocks-1)
+ {
+ removeTextEditCursor();
+ textEdit.cursorBlock++;
+ renderTextEditCursor();
+ }
+ else if (textEdit.scrollable)
+ {
+ if (textEdit.textPtr <= textEdit.textEndPtr)
+ {
+ textEdit.scrollOffset++;
+
+ if (textEdit.object == PTB_DO_DATAPATH)
+ ui.updateDiskOpPathText = true;
+ else if (textEdit.object == PTB_PE_PATTNAME)
+ ui.updatePosEd = true;
+ }
+ }
+ }
+ else
+ {
+ // we end up here when entering a number/hex digit
+
+ if (textEdit.cursorBlock < textEdit.numDigits)
+ removeTextEditCursor();
+
+ textEdit.cursorBlock++;
+
+ if (textEdit.cursorBlock < textEdit.numDigits)
+ renderTextEditCursor();
+
+ // don't clamp now, textEdit.cursorBlock is tested elsewhere
+ }
+}
+
+void editTextPrevChar(void)
+{
+ if (textEdit.type != TEXT_EDIT_STRING)
+ {
+ if (textEdit.cursorBlock > 0)
+ {
+ removeTextEditCursor();
+ textEdit.cursorBlock--;
+ renderTextEditCursor();
+ }
+
+ return;
+ }
+
+ if (editor.mixFlag && textEdit.cursorBlock <= 4) // kludge...
+ return;
+
+ if (textEdit.textPtr > textEdit.textStartPtr)
+ {
+ removeTextEditCursor();
+
+ textEdit.textPtr--;
+ moveTextCursorLeft();
+
+ if (editor.mixFlag) // special case for "Mix" input field in Edit. Op.
+ {
+ if (textEdit.cursorBlock == 12)
+ {
+ textEdit.textPtr--; moveTextCursorLeft();
+ textEdit.textPtr--; moveTextCursorLeft();
+ textEdit.textPtr--; moveTextCursorLeft();
+ textEdit.textPtr--; moveTextCursorLeft();
+ }
+ else if (textEdit.cursorBlock == 6)
+ {
+ textEdit.textPtr--;
+ moveTextCursorLeft();
+ }
+ }
+
+ renderTextEditCursor();
+ }
+
+ textEdit.endReached = false;
+}
+
+void editTextNextChar(void)
+{
+ if (textEdit.type != TEXT_EDIT_STRING)
+ {
+ if (textEdit.cursorBlock < textEdit.numDigits-1)
+ {
+ removeTextEditCursor();
+ textEdit.cursorBlock++;
+ renderTextEditCursor();
+ }
+
+ return;
+ }
+
+ if (editor.mixFlag && textEdit.cursorBlock >= 14) // kludge
+ return;
+
+ if (textEdit.textPtr < textEdit.textEndPtr)
+ {
+ if (*textEdit.textPtr != '\0')
+ {
+ removeTextEditCursor();
+
+ textEdit.textPtr++;
+ moveTextCursorRight();
+
+ if (editor.mixFlag) // special case for "Mix" input field in Edit. Op.
+ {
+ if (textEdit.cursorBlock == 9)
+ {
+ textEdit.textPtr++; moveTextCursorRight();
+ textEdit.textPtr++; moveTextCursorRight();
+ textEdit.textPtr++; moveTextCursorRight();
+ textEdit.textPtr++; moveTextCursorRight();
+ }
+ else if (textEdit.cursorBlock == 6)
+ {
+ textEdit.textPtr++;
+ moveTextCursorRight();
+ }
+ }
+
+ renderTextEditCursor();
+ }
+ else
+ {
+ textEdit.endReached = true;
+ }
+ }
+ else
+ {
+ textEdit.endReached = true;
+ }
+}
+
+void handleTextEditing(uint8_t mouseButton) // handle mouse while editing text/numbers
+{
+ if (!ui.editTextFlag)
+ return;
+
+ if (textEdit.type != TEXT_EDIT_STRING)
+ {
+ if (mouseButton == SDL_BUTTON_RIGHT)
+ leaveTextEditMode(EDIT_TEXT_NO_UPDATE);
+ }
+ else if (mouseButton == SDL_BUTTON_LEFT && !editor.mixFlag) // string type
+ {
+ // jump to edit character under the mouse pointer
+
+ int32_t tmp32 = mouse.y - textEdit.cursorStartY;
+ if (tmp32 <= 2 && tmp32 >= -9)
+ {
+ assert(textEdit.textStartPtr != NULL);
+ const int32_t textLength = (int32_t)strlen(textEdit.textStartPtr);
+ int32_t cursorBlock = (mouse.x - textEdit.cursorStartX) / FONT_CHAR_W;
+ const int32_t textPos = CLAMP(textEdit.scrollOffset + cursorBlock, 0, textLength);
+
+ cursorBlock = CLAMP(cursorBlock, 0, textEdit.numBlocks-1);
+ if (cursorBlock > textLength)
+ cursorBlock = textLength;
+
+ removeTextEditCursor();
+ textEdit.cursorBlock = (uint16_t)cursorBlock;
+ textEdit.textPtr = textEdit.textStartPtr + textPos;
+ renderTextEditCursor();
+ }
+ else
+ {
+ // if we clicked outside of the vertical edit area, stop edit mode
+
+ if (textEdit.object != PTB_PE_PATTNAME) // special case...
+ leaveTextEditMode(EDIT_TEXT_UPDATE);
+ }
+ }
+ else if (mouseButton == SDL_BUTTON_RIGHT)
+ {
+ if (editor.mixFlag)
+ {
+ leaveTextEditMode(EDIT_TEXT_UPDATE);
+ editor.mixFlag = false;
+ ui.updateMixText = true;
+ }
+ else
+ {
+ // delete text
+ const uint32_t charsToZero = (uint32_t)(textEdit.textEndPtr - textEdit.textStartPtr);
+ memset(textEdit.textStartPtr, '\0', charsToZero);
+
+ if (textEdit.object == PTB_DO_DATAPATH)
+ {
+ /* Don't exit text edit mode if the Disk Op. path was about to
+ ** be deleted with the right mouse button.
+ ** Set text cursor to beginning instead.
+ */
+ removeTextEditCursor();
+ textEdit.cursorBlock = 0;
+ textEdit.textPtr = textEdit.textStartPtr;
+ textEdit.scrollOffset = 0;
+ renderTextEditCursor();
+
+ ui.updateDiskOpPathText = true;
+ }
+ else
+ {
+ if (textEdit.object == PTB_SONGNAME)
+ ui.updateSongName = true;
+ else if (textEdit.object == PTB_SAMPLENAME)
+ ui.updateCurrSampleName = true;
+
+ leaveTextEditMode(EDIT_TEXT_UPDATE);
+ }
+ }
+ }
+}
+
+void enterTextEditMode(int16_t editObject)
+{
+ pointerSetMode(POINTER_MODE_MSG1, NO_CARRY);
+
+ textEdit.textPtr = textEdit.textStartPtr;
+ textEdit.cursorBlock = 0;
+ textEdit.scrollOffset = 0;
+ textEdit.type = TEXT_EDIT_STRING;
+ textEdit.object = editObject;
+ textEdit.endReached = false;
+ ui.editTextFlag = true;
+
+ // make backup of old text (for handling 'song modified' flag later)
+ oldTextLength = (uint32_t)strlen(textEdit.textPtr);
+ memset(oldText, '\0', sizeof (oldText));
+ memcpy(oldText, textEdit.textPtr, oldTextLength);
+
+ if (editor.mixFlag) // skip to editable text section
+ {
+ editTextNextChar();
+ editTextNextChar();
+ editTextNextChar();
+ editTextNextChar();
+ }
+
+ renderTextEditCursor();
+ SDL_StartTextInput();
+}
+
+void enterNumberEditMode(uint8_t type, int16_t editObject)
+{
+ pointerSetMode(POINTER_MODE_MSG1, NO_CARRY);
+
+ textEdit.cursorBlock = 0;
+ textEdit.type = type;
+ textEdit.object = editObject;
+ textEdit.endReached = false;
+ ui.editTextFlag = true;
+
+ renderTextEditCursor();
+ SDL_StartTextInput();
+}
+
+static void redrawTextEditObject(void)
+{
+ switch (textEdit.object)
+ {
+ default: break;
+ case PTB_SONGNAME: ui.updateSongName = true; break;
+ case PTB_SAMPLENAME: ui.updateCurrSampleName = true; break;
+ case PTB_PE_PATT: ui.updatePosEd = true; break;
+ case PTB_PE_PATTNAME: ui.updatePosEd = true; break;
+ case PTB_EO_QUANTIZE: ui.updateQuantizeText = true; break;
+ case PTB_EO_METRO_1: ui.updateMetro1Text = true; break;
+ case PTB_EO_METRO_2: ui.updateMetro2Text = true; break;
+ case PTB_EO_FROM_NUM: ui.updateFromText = true; break;
+ case PTB_EO_TO_NUM: ui.updateToText = true; break;
+ case PTB_EO_MIX: ui.updateMixText = true; break;
+ case PTB_EO_POS_NUM: ui.updatePosText = true; break;
+ case PTB_EO_MOD_NUM: ui.updateModText = true; break;
+ case PTB_EO_VOL_NUM: ui.updateVolText = true; break;
+ case PTB_DO_DATAPATH: ui.updateDiskOpPathText = true; break;
+ case PTB_POSS: ui.updateSongPos = true; break;
+ case PTB_PATTERNS: ui.updateSongPattern = true; break;
+ case PTB_LENGTHS: ui.updateSongLength = true; break;
+ case PTB_SAMPLES: ui.updateCurrSampleNum = true; break;
+ case PTB_SVOLUMES: ui.updateCurrSampleVolume = true; break;
+ case PTB_SLENGTHS: ui.updateCurrSampleLength = true; break;
+ case PTB_SREPEATS: ui.updateCurrSampleRepeat = true; break;
+ case PTB_SREPLENS: ui.updateCurrSampleReplen = true; break;
+ case PTB_PATTDATA: ui.updateCurrPattText = true; break;
+ case PTB_SA_VOL_FROM_NUM: ui.updateVolFromText = true; break;
+ case PTB_SA_VOL_TO_NUM: ui.updateVolToText = true; break;
+ case PTB_SA_FIL_LP_CUTOFF: ui.updateLPText = true; break;
+ case PTB_SA_FIL_HP_CUTOFF: ui.updateHPText = true; break;
+ }
+}
+
+void leaveTextEditMode(bool updateValue)
+{
+ int8_t tmp8;
+ int16_t tmp16;
+ int32_t tmp32;
+
+ SDL_StopTextInput();
+
+ // if user updated the disk op path text
+ if (ui.diskOpScreenShown && textEdit.object == PTB_DO_DATAPATH)
+ {
+ UNICHAR *pathU = (UNICHAR *)calloc(PATH_MAX + 2, sizeof (UNICHAR));
+ if (pathU != NULL)
+ {
+#ifdef _WIN32
+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, editor.currPath, -1, pathU, PATH_MAX);
+#else
+ strcpy(pathU, editor.currPath);
+#endif
+ diskOpSetPath(pathU, DISKOP_CACHE);
+ free(pathU);
+ }
+ }
+
+ if (textEdit.type != TEXT_EDIT_STRING)
+ {
+ if (textEdit.cursorBlock != textEdit.numDigits)
+ removeTextEditCursor();
+
+ redrawTextEditObject();
+ }
+ else
+ {
+ removeTextEditCursor();
+
+ // yet another kludge...
+ if (textEdit.object == PTB_PE_PATT || textEdit.object == PTB_PE_PATTNAME)
+ ui.updatePosEd = true;
+ }
+
+ ui.editTextFlag = false;
+
+ if (textEdit.type == TEXT_EDIT_STRING)
+ {
+ pointerSetPreviousMode();
+
+ // handle song modified state (only for some text edit objects)
+ if (textEdit.object != PTB_EO_MIX && textEdit.object != PTB_PE_PATTNAME && textEdit.object != PTB_DO_DATAPATH)
+ {
+ if (strcmp(textEdit.textStartPtr, oldText) != 0)
+ updateWindowTitle(MOD_IS_MODIFIED);
+ }
+ }
+ else
+ {
+ // set back GUI text pointers and update values (if requested)
+
+ moduleSample_t *s = &song->samples[editor.currSample];
+ switch (textEdit.object)
+ {
+ case PTB_SA_FIL_LP_CUTOFF:
+ {
+ editor.lpCutOffDisp = &editor.lpCutOff;
+
+ if (updateValue)
+ {
+ editor.lpCutOff = textEdit.tmpDisp16;
+ if (editor.lpCutOff > (uint16_t)(FILTERS_BASE_FREQ/2))
+ editor.lpCutOff = (uint16_t)(FILTERS_BASE_FREQ/2);
+
+ ui.updateLPText = true;
+ }
+ }
+ break;
+
+ case PTB_SA_FIL_HP_CUTOFF:
+ {
+ editor.hpCutOffDisp = &editor.hpCutOff;
+
+ if (updateValue)
+ {
+ editor.hpCutOff = textEdit.tmpDisp16;
+ if (editor.hpCutOff > (uint16_t)(FILTERS_BASE_FREQ/2))
+ editor.hpCutOff = (uint16_t)(FILTERS_BASE_FREQ/2);
+
+ ui.updateHPText = true;
+ }
+ }
+ break;
+
+ case PTB_SA_VOL_FROM_NUM:
+ {
+ editor.vol1Disp = &editor.vol1;
+
+ if (updateValue)
+ {
+ editor.vol1 = textEdit.tmpDisp16;
+ if (editor.vol1 > 200)
+ editor.vol1 = 200;
+
+ ui.updateVolFromText = true;
+ showVolFromSlider();
+ }
+ }
+ break;
+
+ case PTB_SA_VOL_TO_NUM:
+ {
+ editor.vol2Disp = &editor.vol2;
+
+ if (updateValue)
+ {
+ editor.vol2 = textEdit.tmpDisp16;
+ if (editor.vol2 > 200)
+ editor.vol2 = 200;
+
+ ui.updateVolToText = true;
+ showVolToSlider();
+ }
+ }
+ break;
+
+ case PTB_EO_VOL_NUM:
+ {
+ editor.sampleVolDisp = &editor.sampleVol;
+
+ if (updateValue)
+ {
+ editor.sampleVol = textEdit.tmpDisp16;
+ ui.updateVolText = true;
+ }
+ }
+ break;
+
+ case PTB_EO_POS_NUM:
+ {
+ editor.samplePosDisp = &editor.samplePos;
+
+ if (updateValue)
+ {
+ editor.samplePos = textEdit.tmpDisp32;
+ if (editor.samplePos > config.maxSampleLength)
+ editor.samplePos = config.maxSampleLength;
+
+ if (editor.samplePos > song->samples[editor.currSample].length)
+ editor.samplePos = song->samples[editor.currSample].length;
+
+ ui.updatePosText = true;
+ }
+ }
+ break;
+
+ case PTB_EO_QUANTIZE:
+ {
+ editor.quantizeValueDisp = &config.quantizeValue;
+
+ if (updateValue)
+ {
+ if (textEdit.tmpDisp16 > 63)
+ textEdit.tmpDisp16 = 63;
+
+ config.quantizeValue = textEdit.tmpDisp16;
+ ui.updateQuantizeText = true;
+ }
+ }
+ break;
+
+ case PTB_EO_METRO_1: // metronome speed
+ {
+ editor.metroSpeedDisp = &editor.metroSpeed;
+
+ if (updateValue)
+ {
+ if (textEdit.tmpDisp16 > 64)
+ textEdit.tmpDisp16 = 64;
+
+ editor.metroSpeed = textEdit.tmpDisp16;
+ ui.updateMetro1Text = true;
+ }
+ }
+ break;
+
+ case PTB_EO_METRO_2: // metronome channel
+ {
+ editor.metroChannelDisp = &editor.metroChannel;
+
+ if (updateValue)
+ {
+ if (textEdit.tmpDisp16 > 4)
+ textEdit.tmpDisp16 = 4;
+
+ editor.metroChannel = textEdit.tmpDisp16;
+ ui.updateMetro2Text = true;
+ }
+ }
+ break;
+
+ case PTB_EO_FROM_NUM:
+ {
+ editor.sampleFromDisp = &editor.sampleFrom;
+
+ if (updateValue)
+ {
+ editor.sampleFrom = textEdit.tmpDisp8;
+
+ // signed check + normal check
+ if (editor.sampleFrom < 0x00 || editor.sampleFrom > 0x1F)
+ editor.sampleFrom = 0x1F;
+
+ ui.updateFromText = true;
+ }
+ }
+ break;
+
+ case PTB_EO_TO_NUM:
+ {
+ editor.sampleToDisp = &editor.sampleTo;
+
+ if (updateValue)
+ {
+ editor.sampleTo = textEdit.tmpDisp8;
+
+ // signed check + normal check
+ if (editor.sampleTo < 0x00 || editor.sampleTo > 0x1F)
+ editor.sampleTo = 0x1F;
+
+ ui.updateToText = true;
+ }
+ }
+ break;
+
+ case PTB_PE_PATT:
+ {
+ int16_t posEdPos = song->currPos;
+ if (posEdPos > song->header.songLength-1)
+ posEdPos = song->header.songLength-1;
+
+ editor.currPosEdPattDisp = &song->header.patternTable[posEdPos];
+
+ if (updateValue)
+ {
+ if (textEdit.tmpDisp16 > MAX_PATTERNS-1)
+ textEdit.tmpDisp16 = MAX_PATTERNS-1;
+
+ song->header.patternTable[posEdPos] = textEdit.tmpDisp16;
+
+ updateWindowTitle(MOD_IS_MODIFIED);
+
+ if (ui.posEdScreenShown)
+ ui.updatePosEd = true;
+
+ ui.updateSongPattern = true;
+ ui.updateSongSize = true;
+ }
+ }
+ break;
+
+ case PTB_POSS:
+ {
+ editor.currPosDisp = &song->currPos;
+
+ if (updateValue)
+ {
+ tmp16 = textEdit.tmpDisp16;
+ if (tmp16 > 126)
+ tmp16 = 126;
+
+ if (song->currPos != tmp16)
+ {
+ song->currPos = tmp16;
+ editor.currPatternDisp = &song->header.patternTable[song->currPos];
+
+ if (ui.posEdScreenShown)
+ ui.updatePosEd = true;
+
+ ui.updateSongPos = true;
+ ui.updatePatternData = true;
+ }
+ }
+ }
+ break;
+
+ case PTB_PATTERNS:
+ {
+ editor.currPatternDisp = &song->header.patternTable[song->currPos];
+
+ if (updateValue)
+ {
+ tmp16 = textEdit.tmpDisp16;
+ if (tmp16 > MAX_PATTERNS-1)
+ tmp16 = MAX_PATTERNS-1;
+
+ if (song->header.patternTable[song->currPos] != tmp16)
+ {
+ song->header.patternTable[song->currPos] = tmp16;
+
+ updateWindowTitle(MOD_IS_MODIFIED);
+
+ if (ui.posEdScreenShown)
+ ui.updatePosEd = true;
+
+ ui.updateSongPattern = true;
+ ui.updateSongSize = true;
+ }
+ }
+ }
+ break;
+
+ case PTB_LENGTHS:
+ {
+ editor.currLengthDisp = &song->header.songLength;
+
+ if (updateValue)
+ {
+ tmp16 = CLAMP(textEdit.tmpDisp16, 1, 127);
+
+ if (song->header.songLength != tmp16)
+ {
+ song->header.songLength = tmp16;
+
+ int16_t posEdPos = song->currPos;
+ if (posEdPos > song->header.songLength-1)
+ posEdPos = song->header.songLength-1;
+
+ editor.currPosEdPattDisp = &song->header.patternTable[posEdPos];
+
+ if (ui.posEdScreenShown)
+ ui.updatePosEd = true;
+
+ ui.updateSongLength = true;
+ ui.updateSongSize = true;
+ updateWindowTitle(MOD_IS_MODIFIED);
+ }
+ }
+ }
+ break;
+
+ case PTB_PATTDATA:
+ {
+ editor.currEditPatternDisp = &song->currPattern;
+
+ if (updateValue)
+ {
+ if (song->currPattern != textEdit.tmpDisp16)
+ {
+ setPattern(textEdit.tmpDisp16);
+ ui.updatePatternData = true;
+ ui.updateCurrPattText = true;
+ }
+ }
+ }
+ break;
+
+ case PTB_SAMPLES:
+ {
+ editor.currSampleDisp = &editor.currSample;
+
+ if (updateValue)
+ {
+ tmp8 = textEdit.tmpDisp8;
+ if (tmp8 < 0x00) // (signed) if >0x7F was entered, clamp to 0x1F
+ tmp8 = 0x1F;
+
+ tmp8 = CLAMP(tmp8, 0x01, 0x1F) - 1;
+
+ if (tmp8 != editor.currSample)
+ {
+ editor.currSample = tmp8;
+ updateCurrSample();
+ }
+ }
+ }
+ break;
+
+ case PTB_SVOLUMES:
+ {
+ s->volumeDisp = &s->volume;
+
+ if (updateValue)
+ {
+ tmp8 = textEdit.tmpDisp8;
+
+ // signed check + normal check
+ if (tmp8 < 0x00 || tmp8 > 0x40)
+ tmp8 = 0x40;
+
+ if (s->volume != tmp8)
+ {
+ s->volume = tmp8;
+ ui.updateCurrSampleVolume = true;
+ updateWindowTitle(MOD_IS_MODIFIED);
+ }
+ }
+ }
+ break;
+
+ case PTB_SLENGTHS:
+ {
+ s->lengthDisp = &s->length;
+
+ if (updateValue)
+ {
+ tmp32 = textEdit.tmpDisp32 & ~1; // even'ify
+ if (tmp32 > config.maxSampleLength)
+ tmp32 = config.maxSampleLength;
+
+ if (s->loopStart+s->loopLength > 2)
+ {
+ if (tmp32 < s->loopStart+s->loopLength)
+ tmp32 = s->loopStart+s->loopLength;
+ }
+
+ tmp32 &= ~1;
+
+ if (s->length != tmp32)
+ {
+ turnOffVoices();
+ s->length = tmp32;
+
+ ui.updateCurrSampleLength = true;
+ ui.updateSongSize = true;
+ updateSamplePos();
+
+ if (ui.samplerScreenShown)
+ redrawSample();
+
+ recalcChordLength();
+ updateWindowTitle(MOD_IS_MODIFIED);
+ }
+ }
+ }
+ break;
+
+ case PTB_SREPEATS:
+ {
+ s->loopStartDisp = &s->loopStart;
+
+ if (updateValue)
+ {
+ tmp32 = textEdit.tmpDisp32 & ~1; // even'ify
+ if (tmp32 > config.maxSampleLength)
+ tmp32 = config.maxSampleLength;
+
+ if (s->length >= s->loopLength)
+ {
+ if (tmp32+s->loopLength > s->length)
+ tmp32 = s->length - s->loopLength;
+ }
+ else
+ {
+ tmp32 = 0;
+ }
+
+ tmp32 &= ~1;
+
+ if (s->loopStart != tmp32)
+ {
+ turnOffVoices();
+ s->loopStart = tmp32;
+ updatePaulaLoops();
+
+ ui.updateCurrSampleRepeat = true;
+
+ if (ui.editOpScreenShown && ui.editOpScreen == 3)
+ ui.updateChordLengthText = true;
+
+ if (ui.samplerScreenShown)
+ setLoopSprites();
+
+ updateWindowTitle(MOD_IS_MODIFIED);
+ }
+ }
+ }
+ break;
+
+ case PTB_SREPLENS:
+ {
+ s->loopLengthDisp = &s->loopLength;
+
+ if (updateValue)
+ {
+ tmp32 = textEdit.tmpDisp32 & ~1; // even'ify
+ if (tmp32 > config.maxSampleLength)
+ tmp32 = config.maxSampleLength;
+
+ if (s->length >= s->loopStart)
+ {
+ if (s->loopStart+tmp32 > s->length)
+ tmp32 = s->length - s->loopStart;
+ }
+ else
+ {
+ tmp32 = 2;
+ }
+
+ tmp32 &= ~1;
+
+ if (tmp32 < 2)
+ tmp32 = 2;
+
+ if (s->loopLength != tmp32)
+ {
+ turnOffVoices();
+ s->loopLength = tmp32;
+ updatePaulaLoops();
+
+ ui.updateCurrSampleReplen = true;
+ if (ui.editOpScreenShown && ui.editOpScreen == 3)
+ ui.updateChordLengthText = true;
+
+ if (ui.samplerScreenShown)
+ setLoopSprites();
+
+ updateWindowTitle(MOD_IS_MODIFIED);
+ }
+ }
+ }
+ break;
+
+ default: break;
+ }
+
+ pointerSetPreviousMode();
+ }
+
+ textEdit.type = 0;
+}
+
+void handleTextEditInputChar(char textChar)
+{
+ // we only want certain keys
+ if (textChar < ' ' || textChar > '~')
+ return;
+
+ // A..Z -> a..z
+ if (textChar >= 'A' && textChar <= 'Z')
+ textChar = (char)tolower(textChar);
+
+ if (textEdit.type == TEXT_EDIT_STRING)
+ {
+ if (textEdit.textPtr < textEdit.textEndPtr)
+ {
+ if (!editor.mixFlag)
+ {
+ char *readTmp = textEdit.textEndPtr;
+ while (readTmp > textEdit.textPtr)
+ {
+ int8_t readTmpPrev = *--readTmp;
+ *(readTmp + 1) = readTmpPrev;
+ }
+
+ *textEdit.textEndPtr = '\0';
+ *textEdit.textPtr++ = textChar;
+
+ moveTextCursorRight();
+ }
+ else if ((textChar >= '0' && textChar <= '9') || (textChar >= 'a' && textChar <= 'f'))
+ {
+ if (textEdit.cursorBlock == 14) // hack for sample mix text
+ {
+ *textEdit.textPtr = textChar;
+ }
+ else
+ {
+ *textEdit.textPtr++ = textChar;
+ moveTextCursorRight();
+
+ // hack for sample mix text
+ if (textEdit.cursorBlock == 9)
+ {
+ for (int32_t i = 0; i < 4; i++)
+ {
+ textEdit.textPtr++;
+ moveTextCursorRight();
+ }
+ }
+ else if (textEdit.cursorBlock == 6)
+ {
+ textEdit.textPtr++;
+ moveTextCursorRight();
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ if (textEdit.type == TEXT_EDIT_DECIMAL)
+ {
+ if (textChar >= '0' && textChar <= '9')
+ {
+ uint8_t digit1, digit2, digit3, digit4;
+ uint32_t number;
+
+ textChar -= '0';
+
+ if (textEdit.numDigits == 4)
+ {
+ number = *textEdit.numPtr16;
+ digit4 = number % 10; number /= 10;
+ digit3 = number % 10; number /= 10;
+ digit2 = number % 10; number /= 10;
+ digit1 = (uint8_t)number;
+
+ if (textEdit.cursorBlock == 0) *textEdit.numPtr16 = (textChar * 1000) + (digit2 * 100) + (digit3 * 10) + digit4;
+ else if (textEdit.cursorBlock == 1) *textEdit.numPtr16 = (digit1 * 1000) + (textChar * 100) + (digit3 * 10) + digit4;
+ else if (textEdit.cursorBlock == 2) *textEdit.numPtr16 = (digit1 * 1000) + (digit2 * 100) + (textChar * 10) + digit4;
+ else if (textEdit.cursorBlock == 3) *textEdit.numPtr16 = (digit1 * 1000) + (digit2 * 100) + (digit3 * 10) + textChar;
+ }
+ else if (textEdit.numDigits == 3)
+ {
+ number = *textEdit.numPtr16;
+ digit3 = number % 10; number /= 10;
+ digit2 = number % 10; number /= 10;
+ digit1 = (uint8_t)number;
+
+ if (textEdit.cursorBlock == 0) *textEdit.numPtr16 = (textChar * 100) + (digit2 * 10) + digit3;
+ else if (textEdit.cursorBlock == 1) *textEdit.numPtr16 = (digit1 * 100) + (textChar * 10) + digit3;
+ else if (textEdit.cursorBlock == 2) *textEdit.numPtr16 = (digit1 * 100) + (digit2 * 10) + textChar;
+ }
+ else if (textEdit.numDigits == 2)
+ {
+ number = *textEdit.numPtr16;
+ digit2 = number % 10; number /= 10;
+ digit1 = (uint8_t)number;
+
+ if (textEdit.cursorBlock == 0) *textEdit.numPtr16 = (textChar * 10) + digit2;
+ else if (textEdit.cursorBlock == 1) *textEdit.numPtr16 = (digit1 * 10) + textChar;
+ }
+
+ moveTextCursorRight();
+ if (textEdit.cursorBlock >= textEdit.numDigits)
+ leaveTextEditMode(EDIT_TEXT_UPDATE);
+ }
+ }
+ else
+ {
+ if ((textChar >= '0' && textChar <= '9') || (textChar >= 'a' && textChar <= 'f'))
+ {
+ if (textChar <= '9')
+ textChar -= '0';
+ else if (textChar <= 'f')
+ textChar -= 'a'-10;
+
+ if (textEdit.numBits == 17)
+ {
+ *textEdit.numPtr32 &= ~(0xF0000 >> (textEdit.cursorBlock << 2));
+ *textEdit.numPtr32 |= textChar << (16 - (textEdit.cursorBlock << 2));
+ }
+ else if (textEdit.numBits == 16)
+ {
+ if (textEdit.force32BitNumPtr)
+ {
+ *textEdit.numPtr32 &= ~(0xF000 >> (textEdit.cursorBlock << 2));
+ *textEdit.numPtr32 |= textChar << (12 - (textEdit.cursorBlock << 2));
+ }
+ else
+ {
+ *textEdit.numPtr16 &= ~(0xF000 >> (textEdit.cursorBlock << 2));
+ *textEdit.numPtr16 |= textChar << (12 - (textEdit.cursorBlock << 2));
+ }
+ }
+ else if (textEdit.numBits == 8)
+ {
+ *textEdit.numPtr8 &= ~(0xF0 >> (textEdit.cursorBlock << 2));
+ *textEdit.numPtr8 |= textChar << (4 - (textEdit.cursorBlock << 2));
+ }
+
+ moveTextCursorRight();
+ if (textEdit.cursorBlock >= textEdit.numDigits)
+ leaveTextEditMode(EDIT_TEXT_UPDATE);
+ }
+ }
+ }
+
+ redrawTextEditObject();
+
+ if (!keyb.repeatKey)
+ keyb.delayCounter = 0;
+
+ keyb.repeatKey = true;
+ keyb.delayKey = true;
+}
+
+bool handleTextEditMode(SDL_Scancode scancode)
+{
+ switch (scancode)
+ {
+ case SDL_SCANCODE_ESCAPE:
+ {
+ editor.blockMarkFlag = false;
+ if (ui.editTextFlag)
+ {
+ leaveTextEditMode(EDIT_TEXT_NO_UPDATE);
+ return false;
+ }
+ }
+ break;
+
+ case SDL_SCANCODE_HOME:
+ {
+ if (ui.editTextFlag && !editor.mixFlag && textEdit.type == TEXT_EDIT_STRING)
+ {
+ while (textEdit.textPtr > textEdit.textStartPtr)
+ editTextPrevChar();
+ }
+ }
+ break;
+
+ case SDL_SCANCODE_END:
+ {
+ if (ui.editTextFlag && !editor.mixFlag && textEdit.type == TEXT_EDIT_STRING)
+ {
+ while (!textEdit.endReached)
+ editTextNextChar();
+ }
+ }
+ break;
+
+ case SDL_SCANCODE_LEFT:
+ {
+ if (ui.editTextFlag)
+ {
+ editTextPrevChar();
+ if (!keyb.repeatKey)
+ keyb.delayCounter = 0;
+
+ keyb.repeatKey = true;
+ keyb.delayKey = false;
+ }
+ else
+ {
+ keyb.delayKey = false;
+ keyb.repeatKey = true;
+ }
+ }
+ break;
+
+ case SDL_SCANCODE_RIGHT:
+ {
+ if (ui.editTextFlag)
+ {
+ editTextNextChar();
+ if (!keyb.repeatKey)
+ keyb.delayCounter = 0;
+
+ keyb.repeatKey = true;
+ keyb.delayKey = false;
+ }
+ else
+ {
+ keyb.delayKey = false;
+ keyb.repeatKey = true;
+ }
+ }
+ break;
+
+ case SDL_SCANCODE_DELETE:
+ {
+ if (ui.editTextFlag)
+ {
+ if (editor.mixFlag || textEdit.type != TEXT_EDIT_STRING)
+ break;
+
+ char *readTmp = textEdit.textPtr;
+ while (readTmp < textEdit.textEndPtr)
+ {
+ int8_t readTmpNext = *(readTmp + 1);
+ *readTmp++ = readTmpNext;
+ }
+
+ // kludge to prevent cloning last character if the song/sample name has one character too much
+ if (textEdit.object == PTB_SONGNAME || textEdit.object == PTB_SAMPLENAME || textEdit.object == PTB_PE_PATTNAME)
+ *textEdit.textEndPtr = '\0';
+
+ if (!keyb.repeatKey)
+ keyb.delayCounter = 0;
+
+ keyb.repeatKey = true;
+ keyb.delayKey = true;
+
+ redrawTextEditObject();
+ }
+ }
+ break;
+
+ case SDL_SCANCODE_BACKSPACE:
+ {
+ if (ui.editTextFlag)
+ {
+ if (editor.mixFlag || textEdit.type != TEXT_EDIT_STRING)
+ break;
+
+ if (textEdit.textPtr > textEdit.textStartPtr)
+ {
+ textEdit.textPtr--;
+
+ char *readTmp = textEdit.textPtr;
+ while (readTmp < textEdit.textEndPtr)
+ {
+ int8_t readTmpNext = *(readTmp + 1);
+ *readTmp++ = readTmpNext;
+ }
+
+ // kludge to prevent cloning last character if the song/sample name has one character too much
+ if (textEdit.object == PTB_SONGNAME || textEdit.object == PTB_SAMPLENAME || textEdit.object == PTB_PE_PATTNAME)
+ *textEdit.textEndPtr = '\0';
+
+ moveTextCursorLeft();
+ redrawTextEditObject();
+ }
+
+ if (!keyb.repeatKey)
+ keyb.delayCounter = 0;
+
+ keyb.repeatKey = true;
+ keyb.delayKey = false;
+ }
+ else
+ {
+ if (ui.diskOpScreenShown)
+ {
+#ifdef _WIN32
+ diskOpSetPath(L"..", DISKOP_CACHE);
+#else
+ diskOpSetPath("..", DISKOP_CACHE);
+#endif
+ }
+ else if (keyb.shiftPressed || keyb.leftAltPressed || keyb.leftCtrlPressed)
+ {
+ saveUndo();
+ if (keyb.leftAltPressed && !keyb.leftCtrlPressed)
+ {
+ if (song->currRow > 0)
+ {
+ for (int32_t i = 0; i < PAULA_VOICES; i++)
+ {
+ for (int32_t j = (song->currRow - 1); j < MOD_ROWS; j++)
+ {
+ note_t *noteSrc = &song->patterns[song->currPattern][((j + 1) * PAULA_VOICES) + i];
+ song->patterns[song->currPattern][(j * PAULA_VOICES) + i] = *noteSrc;
+ }
+
+ // clear newly made row on very bottom
+ note_t *noteDst = &song->patterns[song->currPattern][(63 * PAULA_VOICES) + i];
+ noteDst->period = 0;
+ noteDst->sample = 0;
+ noteDst->command = 0;
+ noteDst->param = 0;
+ }
+
+ song->currRow--;
+ ui.updatePatternData = true;
+ }
+ }
+ else
+ {
+ if (song->currRow > 0)
+ {
+ for (int32_t i = song->currRow-1; i < MOD_ROWS-1; i++)
+ {
+ note_t *noteSrc = &song->patterns[song->currPattern][((i + 1) * PAULA_VOICES) + cursor.channel];
+ note_t *noteDst = &song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel];
+
+ if (keyb.leftCtrlPressed)
+ {
+ noteDst->command = noteSrc->command;
+ noteDst->param = noteSrc->param;
+ }
+ else
+ {
+ *noteDst = *noteSrc;
+ }
+ }
+
+ // clear newly made row on very bottom
+ note_t *noteDst = &song->patterns[song->currPattern][(63 * PAULA_VOICES) + cursor.channel];
+ noteDst->period = 0;
+ noteDst->sample = 0;
+ noteDst->command = 0;
+ noteDst->param = 0;
+
+ song->currRow--;
+ ui.updatePatternData = true;
+ }
+ }
+ }
+ else
+ {
+ editor.stepPlayEnabled = true;
+ editor.stepPlayBackwards = true;
+
+ editor.stepPlayLastMode = editor.currMode;
+
+ if (config.keepEditModeAfterStepPlay && editor.stepPlayLastMode == MODE_EDIT)
+ doStopIt(false);
+ else
+ doStopIt(true);
+
+ playPattern((song->currRow - 1) & 63);
+
+ if (config.keepEditModeAfterStepPlay && editor.stepPlayLastMode == MODE_EDIT)
+ {
+ pointerSetMode(POINTER_MODE_EDIT, DO_CARRY);
+ editor.playMode = PLAY_MODE_NORMAL;
+ editor.currMode = MODE_EDIT;
+ }
+ }
+ }
+ }
+ break;
+
+ default: break;
+ }
+
+ if (ui.editTextFlag)
+ {
+ if (scancode == SDL_SCANCODE_RETURN || scancode == SDL_SCANCODE_KP_ENTER)
+ {
+ // dirty hack
+ if (textEdit.object == PTB_SAMPLES)
+ textEdit.tmpDisp8++;
+
+ leaveTextEditMode(EDIT_TEXT_UPDATE);
+
+ if (editor.mixFlag)
+ {
+ editor.mixFlag = false;
+ ui.updateMixText = true;
+ doMix();
+ }
+ }
+
+ return false; // don't continue further key handling
+ }
+
+ return true; // continue further key handling (we're not editing text)
+}
--- /dev/null
+++ b/src/pt2_textedit.h
@@ -1,0 +1,16 @@
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <SDL2/SDL.h>
+
+void renderTextEditCursor(void);
+void removeTextEditCursor(void);
+void editTextPrevChar(void);
+void editTextNextChar(void);
+void handleTextEditing(uint8_t mouseButton);
+void enterTextEditMode(int16_t editObject);
+void enterNumberEditMode(uint8_t type, int16_t editObject);
+void leaveTextEditMode(bool updateValue);
+void handleTextEditInputChar(char textChar);
+bool handleTextEditMode(SDL_Scancode scancode);
--- a/src/pt2_visuals.c
+++ b/src/pt2_visuals.c
@@ -34,6 +34,8 @@
#include "pt2_chordmaker.h"
#include "pt2_mod2wav.h"
#include "pt2_audio.h"
+#include "pt2_posed.h"
+#include "pt2_textedit.h"
typedef struct sprite_t
{
@@ -288,7 +290,7 @@
}
if (ui.editTextFlag)
- exitGetTextLine(EDIT_TEXT_NO_UPDATE);
+ leaveTextEditMode(EDIT_TEXT_NO_UPDATE);
}
static void fillFromVuMetersBgBuffer(void)
@@ -603,10 +605,10 @@
totalSampleDataSize += song->samples[i].length;
uint32_t totalPatterns = 0;
- for (int32_t i = 0; i < MOD_ORDERS; i++)
+ for (int32_t i = 0; i < 128; i++)
{
- if (song->header.order[i] > totalPatterns)
- totalPatterns = song->header.order[i];
+ if (song->header.patternTable[i] > totalPatterns)
+ totalPatterns = song->header.patternTable[i];
}
uint32_t moduleSize = 2108 + (totalPatterns * 1024) + totalSampleDataSize;
@@ -808,60 +810,6 @@
displaySample();
}
-void updatePosEd(void)
-{
- if (!ui.posEdScreenShown || ui.askBoxShown || !ui.updatePosEd)
- return;
-
- ui.updatePosEd = false;
-
- int32_t posEdPosition = song->currOrder;
- if (posEdPosition > song->header.numOrders-1)
- posEdPosition = song->header.numOrders-1;
-
- // top five
- for (int32_t y = 0; y < 5; y++)
- {
- if (posEdPosition-(5-y) >= 0)
- {
- printThreeDecimalsBg(128, 23+(y*6), posEdPosition-(5-y), video.palette[PAL_QADSCP], video.palette[PAL_BACKGRD]);
- printTwoDecimalsBg(160, 23+(y*6), song->header.order[posEdPosition-(5-y)], video.palette[PAL_QADSCP], video.palette[PAL_BACKGRD]);
- }
- else
- {
- fillRect(128, 23+(y*6), 22*FONT_CHAR_W, FONT_CHAR_H, video.palette[PAL_BACKGRD]);
- }
- }
-
- // middle
- printThreeDecimalsBg(128, 53, posEdPosition, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
- printTwoDecimalsBg(160, 53, *editor.currPosEdPattDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
-
- // bottom six
- for (int32_t y = 0; y < 6; y++)
- {
- if (posEdPosition+y < song->header.numOrders-1)
- {
- printThreeDecimalsBg(128, 59+(y*6), posEdPosition+(y+1), video.palette[PAL_QADSCP], video.palette[PAL_BACKGRD]);
- printTwoDecimalsBg(160, 59+(y*6), song->header.order[posEdPosition+(y+1)], video.palette[PAL_QADSCP], video.palette[PAL_BACKGRD]);
- }
- else
- {
- fillRect(128, 59+(y*6), 22*FONT_CHAR_W, FONT_CHAR_H, video.palette[PAL_BACKGRD]);
- }
- }
-
- // kludge to fix bottom part of text edit marker in pos ed
- if (ui.editTextFlag && ui.editObject == PTB_PE_PATT)
- renderTextEditMarker();
-}
-
-void renderPosEdScreen(void)
-{
- blit32(120, 0, 200, 99, posEdBMP);
- ui.updatePosEd = true;
-}
-
void renderMuteButtons(void)
{
if (ui.diskOpScreenShown || ui.posEdScreenShown)
@@ -930,35 +878,6 @@
if (!ui.samplerScreenShown)
redrawPattern();
}
-}
-
-void removeTextEditMarker(void)
-{
- if (!ui.editTextFlag)
- return;
-
- if (ui.editObject == PTB_PE_PATT)
- {
- // position editor text editing
- hLine(ui.lineCurX - 4, ui.lineCurY - 1, 7, video.palette[PAL_GENBKG2]);
-
- // no need to clear the second row of pixels
-
- ui.updatePosEd = true;
- }
- else
- {
- // all others
- fillRect(ui.lineCurX - 4, ui.lineCurY - 1, 7, 2, video.palette[PAL_GENBKG]);
- }
-}
-
-void renderTextEditMarker(void)
-{
- if (!ui.editTextFlag)
- return;
-
- fillRect(ui.lineCurX - 4, ui.lineCurY - 1, 7, 2, video.palette[PAL_TEXTMARK]);
}
static void sendMouseButtonUpEvent(uint8_t button)
--- a/src/pt2_visuals.h
+++ b/src/pt2_visuals.h
@@ -53,17 +53,14 @@
void toggleFullscreen(void);
void videoClose(void);
void displayMainScreen(void);
-void renderPosEdScreen(void);
void renderMuteButtons(void);
void renderAboutScreen(void);
void renderQuadrascopeBg(void);
void renderSpectrumAnalyzerBg(void);
void renderEditOpMode(void);
-void renderTextEditMarker(void);
void renderEditOpScreen(void);
void renderSamplerVolBox(void);
void renderSamplerFiltersBox(void);
-void removeTextEditMarker(void);
void removeSamplerVolBox(void);
void removeSamplerFiltersBox(void);
void fillToVuMetersBgBuffer(void);
binary files a/vs2019_project/pt2-clone/SDL2.dll b/vs2019_project/pt2-clone/SDL2.dll differ
--- a/vs2019_project/pt2-clone/pt2-clone.vcxproj
+++ b/vs2019_project/pt2-clone/pt2-clone.vcxproj
@@ -269,6 +269,7 @@
<ClInclude Include="..\..\src\pt2_pat2smp.h" />
<ClInclude Include="..\..\src\pt2_pattern_viewer.h" />
<ClInclude Include="..\..\src\pt2_paula.h" />
+ <ClInclude Include="..\..\src\pt2_posed.h" />
<ClInclude Include="..\..\src\pt2_rcfilters.h" />
<ClInclude Include="..\..\src\pt2_downsample2x.h" />
<ClInclude Include="..\..\src\pt2_replayer.h" />
@@ -278,6 +279,7 @@
<ClInclude Include="..\..\src\pt2_sampling.h" />
<ClInclude Include="..\..\src\pt2_scopes.h" />
<ClInclude Include="..\..\src\pt2_structs.h" />
+ <ClInclude Include="..\..\src\pt2_textedit.h" />
<ClInclude Include="..\..\src\pt2_visuals_sync.h" />
<ClInclude Include="..\..\src\pt2_tables.h" />
<ClInclude Include="..\..\src\pt2_textout.h" />
@@ -332,6 +334,7 @@
<ClCompile Include="..\..\src\pt2_mod2wav.c" />
<ClCompile Include="..\..\src\pt2_module_loader.c" />
<ClCompile Include="..\..\src\pt2_paula.c" />
+ <ClCompile Include="..\..\src\pt2_posed.c" />
<ClCompile Include="..\..\src\pt2_rcfilters.c" />
<ClCompile Include="..\..\src\pt2_replayer.c" />
<ClCompile Include="..\..\src\pt2_module_saver.c" />
@@ -346,6 +349,7 @@
<ClCompile Include="..\..\src\pt2_sampling.c" />
<ClCompile Include="..\..\src\pt2_scopes.c" />
<ClCompile Include="..\..\src\pt2_structs.c" />
+ <ClCompile Include="..\..\src\pt2_textedit.c" />
<ClCompile Include="..\..\src\pt2_visuals_sync.c" />
<ClCompile Include="..\..\src\pt2_tables.c" />
<ClCompile Include="..\..\src\pt2_textout.c" />
--- a/vs2019_project/pt2-clone/pt2-clone.vcxproj.filters
+++ b/vs2019_project/pt2-clone/pt2-clone.vcxproj.filters
@@ -135,6 +135,12 @@
<ClInclude Include="..\..\src\modloaders\pt2_load_mod15.h">
<Filter>modloaders</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\pt2_posed.h">
+ <Filter>headers</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\pt2_textedit.h">
+ <Filter>headers</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\pt2_audio.c" />
@@ -280,6 +286,8 @@
<ClCompile Include="..\..\src\libflac\windows_unicode_filenames.c">
<Filter>libflac</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\pt2_posed.c" />
+ <ClCompile Include="..\..\src\pt2_textedit.c" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\src\pt2-clone.rc" />
--- a/vs2019_project/pt2-clone/sdl/include/SDL2/SDL_atomic.h
+++ b/vs2019_project/pt2-clone/sdl/include/SDL2/SDL_atomic.h
@@ -240,7 +240,7 @@
/* "REP NOP" is PAUSE, coded for tools that don't know it by that name. */
#if (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))
#define SDL_CPUPauseInstruction() __asm__ __volatile__("pause\n") /* Some assemblers can't do REP NOP, so go with PAUSE. */
-#elif (defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__)
+#elif (defined(__arm__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7) || defined(__aarch64__)
#define SDL_CPUPauseInstruction() __asm__ __volatile__("yield" ::: "memory")
#elif (defined(__powerpc__) || defined(__powerpc64__))
#define SDL_CPUPauseInstruction() __asm__ __volatile__("or 27,27,27");
--- a/vs2019_project/pt2-clone/sdl/include/SDL2/SDL_hints.h
+++ b/vs2019_project/pt2-clone/sdl/include/SDL2/SDL_hints.h
@@ -1008,6 +1008,15 @@
#define SDL_HINT_JOYSTICK_THREAD "SDL_JOYSTICK_THREAD"
/**
+ * \brief A variable controlling whether Windows.Gaming.Input should be used for controller handling.
+ *
+ * This variable can be set to the following values:
+ * "0" - WGI is not used
+ * "1" - WGI is used (the default)
+ */
+#define SDL_HINT_JOYSTICK_WGI "SDL_JOYSTICK_WGI"
+
+/**
* \brief Determines whether SDL enforces that DRM master is required in order
* to initialize the KMSDRM video backend.
*
--- a/vs2019_project/pt2-clone/sdl/include/SDL2/SDL_revision.h
+++ b/vs2019_project/pt2-clone/sdl/include/SDL2/SDL_revision.h
@@ -1,7 +1,7 @@
/* Generated by updaterev.sh, do not edit */
#ifdef SDL_VENDOR_INFO
-#define SDL_REVISION "SDL-release-2.28.0-0-gffa78e6be (" SDL_VENDOR_INFO ")"
+#define SDL_REVISION "SDL-release-2.28.2-0-g031912c4b (" SDL_VENDOR_INFO ")"
#else
-#define SDL_REVISION "SDL-release-2.28.0-0-gffa78e6be"
+#define SDL_REVISION "SDL-release-2.28.2-0-g031912c4b"
#endif
#define SDL_REVISION_NUMBER 0
--- a/vs2019_project/pt2-clone/sdl/include/SDL2/SDL_version.h
+++ b/vs2019_project/pt2-clone/sdl/include/SDL2/SDL_version.h
@@ -59,7 +59,7 @@
*/
#define SDL_MAJOR_VERSION 2
#define SDL_MINOR_VERSION 28
-#define SDL_PATCHLEVEL 0
+#define SDL_PATCHLEVEL 2
/**
* Macro to determine SDL version program was compiled against.
binary files a/vs2019_project/x64/Debug/SDL2.dll b/vs2019_project/x64/Debug/SDL2.dll differ