dali small sfx bugged
Closed this issue · 2 comments
Hi, I just checked dali sources and I noticed the sfx generates different binary for default/fast, hence it would be better to increase the version number in this case, 0.3.3 for example;
Good idea to implement relocated sfx, the default version works really well;
then there is a bug when using relocated small sfx, the offset for the source address is wrong. Using --relocate-sfx 0x080d you can see yourself the wrong calulated address.
I'll add a diff to correct it:
--- dali032\dali.c 2023-09-04 14:40:48 +0000
+++ dali033\dali.c 2023-09-04 14:38:47 +0000
@@ -377,6 +377,6 @@
printf("packed: $%04x-$%04x ($%04x) %3.2f%%\n", ctx->cbm_relocate_sfx_addr, ctx->cbm_relocate_sfx_addr + (int)ctx->sfx_size + (int)ctx->packed_index, (int)ctx->sfx_size + (int)ctx->packed_index, ((float)(ctx->packed_index + (int)ctx->sfx_size) / (float)(ctx->unpacked_size) * 100.0));
if (ctx->sfx_small) {
- ctx->sfx_code[DALI_SMALL_SFX_SRC + 0] = (ctx->cbm_relocate_sfx_addr + 0x13) & 255;
- ctx->sfx_code[DALI_SMALL_SFX_SRC + 1] = (ctx->cbm_relocate_sfx_addr + 0x13) >> 8;
+ ctx->sfx_code[DALI_SMALL_SFX_SRC + 0] = (ctx->cbm_relocate_sfx_addr + 0x0d ) & 255; // wrong: + 0x13
+ ctx->sfx_code[DALI_SMALL_SFX_SRC + 1] = (ctx->cbm_relocate_sfx_addr + 0x0d ) >> 8; // correct: 13 dec =)
ctx->sfx_code[DALI_SMALL_DATA_END + 0] = (ctx->cbm_relocate_sfx_addr + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100 - 0x0c) & 0xff;
ctx->sfx_code[DALI_SMALL_DATA_END + 1] = ((ctx->cbm_relocate_sfx_addr + ctx->sfx_size - 2 + ctx->reencoded_index - 0x100 - 0x0c) >> 8) & 0xff;
@@ -732,5 +732,5 @@
}
- printf("dali v0.3.2 - a zx0-reencoder for bitfire by Tobias Bindhammer\n");
+ printf("dali v0.3.3 - a zx0-reencoder for bitfire by Tobias Bindhammer\n"); // please update version when sfx changes
printf("underlying zx0-packer salvador by Emmanuel Marty\n");
I've also made a windows executable but I'll wait for an official patched source, then I can add it to CSDb
Added your fix, thanks a lot for pointing that out, seems like copy & paste or simply mixing up hex/dez :-D Also version is bumped. Building windows binaries might work with make win=1 or make win32=1 those build executables using mingw
ok cool, cheers