Skip to content

Commit

Permalink
Fix libxmp GDM fine effects continue bug
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceLR committed Apr 11, 2020
1 parent a5fba89 commit b279bd1
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 2 deletions.
45 changes: 43 additions & 2 deletions contrib/libxmp/src/loaders/gdm_load.c
Expand Up @@ -60,6 +60,7 @@ static int gdm_test(HIO_HANDLE *f, char *t, const int start)

void fix_effect(uint8 *fxt, uint8 *fxp)
{
int h, l;
switch (*fxt) {
case 0x00: /* no effect */
*fxp = 0;
Expand All @@ -80,9 +81,49 @@ void fix_effect(uint8 *fxt, uint8 *fxp)
case 0x0b:
case 0x0c:
case 0x0d:
case 0x0e:
case 0x0f: /* same as protracker */
break;
case 0x0e:
/* Convert some extended effects to their S3M equivalents. This is
* necessary because the continue effects were left as the original
* effect (e.g. FX_VOLSLIDE for the fine volume slides) by 2GDM!
* Otherwise, these should be the same as protracker.
*/
h = MSN(*fxp);
l = LSN(*fxp);
switch(h) {
case EX_F_PORTA_UP:
*fxt = FX_PORTA_UP;
*fxp = l | 0xF0;
break;
case EX_F_PORTA_DN:
*fxt = FX_PORTA_DN;
*fxp = l | 0xF0;
break;
case 0x8: /* extra fine portamento up */
*fxt = FX_PORTA_UP;
*fxp = l | 0xE0;
break;
case 0x9: /* extra fine portamento down */
*fxt = FX_PORTA_DN;
*fxp = l | 0xE0;
break;
case EX_F_VSLIDE_UP:
/* Don't convert 0 as it would turn into volume slide down... */
if (l) {
*fxt = FX_VOLSLIDE;
*fxp = (l << 4) | 0xF;
}
break;
case EX_F_VSLIDE_DN:
/* Don't convert 0 as it would turn into volume slide up... */
if (l) {
*fxt = FX_VOLSLIDE;
*fxp = l | 0xF0;
}
break;
}
break;
case 0x10: /* arpeggio */
*fxt = FX_S3M_ARPEGGIO;
break;
Expand Down Expand Up @@ -367,7 +408,7 @@ static int gdm_load(struct module_data *m, HIO_HANDLE *f, const int start)
return -1;
}

m->quirk |= QUIRK_ARPMEM;
m->quirk |= QUIRK_ARPMEM | QUIRK_FINEFX;

return 0;
}
72 changes: 72 additions & 0 deletions contrib/patches/libxmp/16-libxmp-4.4.1-fix-gdm-fine-effects.patch
@@ -0,0 +1,72 @@
diff --git a/src/loaders/gdm_load.c b/src/loaders/gdm_load.c
index a326c9fc..30907f63 100644
--- a/src/loaders/gdm_load.c
+++ b/src/loaders/gdm_load.c
@@ -60,6 +60,7 @@ static int gdm_test(HIO_HANDLE *f, char *t, const int start)

void fix_effect(uint8 *fxt, uint8 *fxp)
{
+ int h, l;
switch (*fxt) {
case 0x00: /* no effect */
*fxp = 0;
@@ -80,9 +81,49 @@ void fix_effect(uint8 *fxt, uint8 *fxp)
case 0x0b:
case 0x0c:
case 0x0d:
- case 0x0e:
case 0x0f: /* same as protracker */
break;
+ case 0x0e:
+ /* Convert some extended effects to their S3M equivalents. This is
+ * necessary because the continue effects were left as the original
+ * effect (e.g. FX_VOLSLIDE for the fine volume slides) by 2GDM!
+ * Otherwise, these should be the same as protracker.
+ */
+ h = MSN(*fxp);
+ l = LSN(*fxp);
+ switch(h) {
+ case EX_F_PORTA_UP:
+ *fxt = FX_PORTA_UP;
+ *fxp = l | 0xF0;
+ break;
+ case EX_F_PORTA_DN:
+ *fxt = FX_PORTA_DN;
+ *fxp = l | 0xF0;
+ break;
+ case 0x8: /* extra fine portamento up */
+ *fxt = FX_PORTA_UP;
+ *fxp = l | 0xE0;
+ break;
+ case 0x9: /* extra fine portamento down */
+ *fxt = FX_PORTA_DN;
+ *fxp = l | 0xE0;
+ break;
+ case EX_F_VSLIDE_UP:
+ /* Don't convert 0 as it would turn into volume slide down... */
+ if (l) {
+ *fxt = FX_VOLSLIDE;
+ *fxp = (l << 4) | 0xF;
+ }
+ break;
+ case EX_F_VSLIDE_DN:
+ /* Don't convert 0 as it would turn into volume slide up... */
+ if (l) {
+ *fxt = FX_VOLSLIDE;
+ *fxp = l | 0xF0;
+ }
+ break;
+ }
+ break;
case 0x10: /* arpeggio */
*fxt = FX_S3M_ARPEGGIO;
break;
@@ -367,7 +408,7 @@ static int gdm_load(struct module_data *m, HIO_HANDLE *f, const int start)
return -1;
}

- m->quirk |= QUIRK_ARPMEM;
+ m->quirk |= QUIRK_ARPMEM | QUIRK_FINEFX;

return 0;
}
3 changes: 3 additions & 0 deletions docs/changelog.txt
Expand Up @@ -34,6 +34,9 @@ USERS
decreased the size of the output HTML files somewhat.
+ Fixed libxmp playback for S3Ms containing ADPCM4 samples. This
fixes mm2flash.s3m in ZeuxDrop.
+ Fixed libxmp playback for GDMs where 100/200/A00 should
continue the fine portamento and fine volume slide commands.
This fixes LB2_7.GDM from Kikan.
+ Windows builds now attempt to load and call SetProcessDPIAware
on startup. This should fix undesirable DPI-related scaling
and fullscreen bugs.
Expand Down

0 comments on commit b279bd1

Please sign in to comment.