10 December 2014, 18:11 | #1 | |
Registered User
Join Date: May 2006
Location: Paris/France
Age: 52
Posts: 527
|
noise depakker.s help
hello,
The Noisepakker proggy (http://demozoo.org/productions/95863/) comes with a asm to depack, but my 68k is next to nonexistent. Could anyone translate the following lines to something readable (say, C-like description) ? with thanks Quote:
|
|
11 December 2014, 13:05 | #2 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,510
|
Something like this (untested):
Code:
struct Sample { char Name[22]; unsigned char WordLen[2]; unsigned char Volume[2]; char Rest[4]; }; struct Mod { char Header[20]; struct Sample Samples[31]; char SongLen; char Arrangement[128]; char MK[4]; char Patterns[1024]; }; #define PATTERNSIZE (2<<10) static char *sample_start,*sample_end; static char depack_lo[256],depack_hi[256]; static unsigned be_word(unsigned char *p) { return ((unsigned)p[0]<<8) | (unsigned)p[1]; } static void analyse_module(struct Mod *modptr) { char maxpat = 0; int i; /* find highest pattern number from song arrangement list */ for (i=0; i<128; i++) { if (modptr->Arrangement[i] > maxpat) maxpat = modptr->Arrangement[i]; } sample_start = &modptr->Patterns[(maxpat+1)*PATTERNSIZE]; /* sum up all sample lengths to find end of samples */ sample_end = sample_start; for (i=0; i<31; i++) sample_end += 2 * be_word(modptr->Samples[i].WordLen); } static void init_depack(void) { static const char power_bytes[] = { -128,-64,-32,-16,-8,-4,-2,-1,0,1,2,4,8,16,32,64 }; int i,j; for (i=0; i<16; i++) { for (j=0; j<16; j++) depack_lo[i*16+j] = power_bytes[j]; } for (i=i; i<16; i++) { for (j=0; j<16; j++) depack_hi[i*16+j] = power_bytes[i]; } } static void depack_sample(char *sample,unsigned unpacklen) { int remaining_bytes = (unpacklen + 1) & ~1; /* align to next word */ char *src = sample + remaining_bytes / 2; char *dst = sample + remaining_bytes; char s,d; for (s=0x80; remaining_bytes>0; remaining_bytes-=2) { d = *(--src); s += depack_hi[d]; *(--dst) = s; s += depack_lo[d]; *(--dst) = s; } } unsigned depack_module(struct Mod *modptr) { analyse_module(modptr); init_depack(); depack_sample(sample_start,sample_end-sample_start); return sample_end - sample_start; } |
11 December 2014, 14:36 | #3 |
Registered User
Join Date: May 2006
Location: Paris/France
Age: 52
Posts: 527
|
Hey, thanks for your help
So basically, we build a static table containing this: Code:
-128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, -128,-128,-128,-128,-128,-128,-128,-128,-128,-128,-128,-128,-128,-128,-128,-128, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, This production has examples : http://demozoo.org/productions/79312/ I took one, attached (as .7z since we can't attach .mod), and tried. Last byte is 0x08, so: d = *(--src); /* d = 0x08 */ s += depack_hi[d]; /* depack_hi[8] = -128 and s = 0 then */ *(--dst) = s; /* destination last byte is 0x00 */ s += depack_lo[d]; /* depack_lo[8] = 0 and s = 0 then */ *(--dst) = s; /* destination previous byte is 0x00 */ and we start over with the previous packed byte, being 0x88 (shouldn't d be declared as unsigned ?) d = *(--src); /* d = 0x88 */ s += depack_hi[d]; /* depack_hi[0x88] = 0 and s = 0 then since it's not reinitialized and was valued 0 */ *(--dst) = s; /* destination previous byte is 0x00 */ s += depack_lo[d]; /* depack_lo[88] = 0 and s = 0 then */ *(--dst) = s; /* destination prvious byte is 0x00 */ etc. Applying this logic results is pure garbage. Either signed or not signed (Atari ST replay are fond of signed samples data in MODs). I tried to force d as unsigned and the result IS BETTER So, it's all fine in the end. Last edited by Asle; 11 December 2014 at 15:52. Reason: update after another check of code |
11 December 2014, 18:02 | #4 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,510
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Power off death noise | john1979 | support.Hardware | 15 | 10 September 2012 12:27 |
TechnoSound 2 making noise | Amiga1992 | support.Hardware | 10 | 02 February 2012 18:49 |
Fatal Noise | viddi | Games images which need to be WHDified | 6 | 24 August 2008 23:29 |
Crappy Noise | Ebster | support.WinUAE | 2 | 13 February 2006 22:23 |
Awful Noise | Enverex | support.WinUAE | 8 | 11 February 2004 23:36 |
|
|