ref: b7102dd20d6aecd272068ee3b7a5fd2efa9c43a8
parent: 111a06b02ac20c539326e1d4182e4c7b3b78d771
author: Olav Sørensen <[email protected]>
date: Sun Mar 14 09:39:52 EDT 2021
Allow hex chars in Mix text input in Edit Op. #3 (fixes issue #15)
--- a/src/pt2_keyboard.c
+++ b/src/pt2_keyboard.c
@@ -4010,7 +4010,7 @@
textMarkerMoveRight();
}
- else if ((textChar >= '0' && textChar <= '9') || (textChar >= 'A' && textChar <= 'F'))
+ else if ((textChar >= '0' && textChar <= '9') || (textChar >= 'a' && textChar <= 'f'))
{
if (ui.dstPos == 14) // hack for sample mix text
{
--- a/src/pt2_sampler.c
+++ b/src/pt2_sampler.c
@@ -1028,33 +1028,30 @@
updateWindowTitle(MOD_IS_MODIFIED);
}
+// reads two hex chars from pointer and converts them to one byte
static uint8_t hexToInteger2(char *ptr)
{
- char lo, hi;
+ char hi = ptr[0];
+ char lo = ptr[1];
- /* This routine must ONLY be used on an address
- ** where two bytes can be read. It will mess up
- ** if the ASCII values are not '0 .. 'F' */
+ if (hi >= '0' && hi <= '9')
+ hi -= '0';
+ else if (hi >= 'A' && hi <= 'F')
+ hi -= 'A'-10;
+ else if (hi >= 'a' && hi <= 'f')
+ hi -= 'a'-10;
+ else
+ hi = 0;
- hi = ptr[0];
- lo = ptr[1];
+ if (lo >= '0' && lo <= '9')
+ lo -= '0';
+ else if (lo >= 'A' && lo <= 'F')
+ lo -= 'A'-10;
+ else if (lo >= 'a' && lo <= 'f')
+ lo -= 'a'-10;
+ else
+ lo = 0;
- // high nybble
- if (hi >= 'a')
- hi -= ' ';
-
- hi -= '0';
- if (hi > 9)
- hi -= 7;
-
- // low nybble
- if (lo >= 'a')
- lo -= ' ';
-
- lo -= '0';
- if (lo > 9)
- lo -= 7;
-
return (hi << 4) | lo;
}
@@ -1076,9 +1073,13 @@
return;
}
- s1 = &song->samples[--smpFrom1];
- s2 = &song->samples[--smpFrom2];
- s3 = &song->samples[--smpTo];
+ smpFrom1--;
+ smpFrom2--;
+ smpTo--;
+
+ s1 = &song->samples[smpFrom1];
+ s2 = &song->samples[smpFrom2];
+ s3 = &song->samples[smpTo];
if (s1->length == 0 || s2->length == 0)
{