01 August 2019, 21:35 | #1 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,539
|
Protracker file format, number of samples
Starting with offset 20 a typical Protracker MOD file has a list of 31 entries with 30 bytes each for the samples. I wonder how to make sure whether such an entry is a valid sample or not.
Offset 22 of such an entry defines the sample length in words. I would expect that a zero length is written for unused samples. But I also saw MODs which have all fields zero, except a sample length of 1 word, a loop-offset of 1 word and a loop-length of 1 word. Still they seem to be unused, invalid samples, because there is no sample-data for them in the MOD file. Is this a common method to define unused entries? When loading this MOD into Milkytracker it lists the correct number of samples. With my ptplayer I had a memory corruption here, because I am assuming samples with a length of 1 word and clearing the first word of these samples to allow idle-looping. As these sample words are missing at the end of the MOD file I was destroying the following memory region. So the short question is: how can I safely identify unused sample entries in Protracker (and later tracker-) MODs? |
01 August 2019, 22:25 | #2 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,491
|
Quote:
As first word is cleared by any player to allow idle-looping it would make no sense to store this [*solo, 2 bytes] sample in the module. So if (sample_length<=1) no_sample; The '1' value I guess depends on (some) editors that, by default, set this value for unused samples. Cheers. EDIT: from the way I wrote the sentence it seemed that normally one less word is stored, which is not the case, so I added the[*] Last edited by ross; 01 August 2019 at 22:38. Reason: [] |
|
02 August 2019, 00:57 | #3 | |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,039
|
Quote:
|
|
02 August 2019, 09:00 | #4 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
|
For me a mod having empty samples with a size of 1 is to be considered as damaged. They come from some stupid pc editor that obviously did not understand the format.
Anyway, never assume the space exists for full samples that are indicated even if you take that into account. There are some truncated mods around. |
02 August 2019, 13:47 | #5 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,039
|
BTW. "Ode to Protracker" is very good test module for your Protracker replayer.
http://wt.exotica.org.uk/examples.html |
02 August 2019, 14:10 | #6 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,539
|
Ok, so the proposed solution would be to ignore all sample lengths <= 1?
This would have probably worked in my example, because there were 3 real samples, followed by 28 length 1 samples. Although I wonder what happens when such a length-1 sample appears between two real samples. Would I have to add the word to the sample pointer or not? Probably not, but I have to find some examples to be sure... What is WT's Protracker replay? Any URL? The original PT2.3 player doesn't even clear the sample starts, IIRC, as it expects Protracker to do it. Quote:
My example MOD, where I realized the problem, is the rg-jingle.mod, which is used in the hovering Retroguru intro before all games (Sqrzx, Trap Runner). It was certainly composed with a PC editor. Quote:
Quote:
And how could I ever support those? How do I recognize a missing sample when there is a sample length > 1 in the header? That would be an extremely corrupt MOD file for me. |
|||
02 August 2019, 14:13 | #7 |
Registered User
Join Date: Oct 2012
Location: Italy
Age: 49
Posts: 2,947
|
Out of curiosity phx, are you writing a MOD ripper ?
|
02 August 2019, 14:42 | #8 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,539
|
|
02 August 2019, 14:53 | #9 |
Registered User
Join Date: Oct 2012
Location: Italy
Age: 49
Posts: 2,947
|
Thanks
|
02 August 2019, 15:18 | #10 | ||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
|
Quote:
F.e. some old mods (again from non-Amiga software) use rep/replen in bytes rather than in words, leading to horrors if you're not prepared to this (DeliTracker supports them). For this length=1 problem, perhaps you could contact mod authors to know what exact software was used, then make tests with said software. Quote:
Note that mods bigger than computed size also exist. To support them, throw away anything larger than computed size, and fill missing data with zeroes. Maybe the latter can do the trick with length=1. If you want to be safe, be prepared to face just every possible garbage that can be done (by checking everything and bailing out with what you don't know how to handle). |
||
02 August 2019, 16:30 | #11 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,491
|
http://wt.exotica.org.uk/files/sourc...Protracker.lzx
Relevant part for your case: Code:
subq.l #1,D0 moveq #1,D1 lea 42(A0),A1 CheckInfos cmp.w (A1),D1 bne.b NoInit clr.w (A1) NoInit addq.l #6,A1 tst.w (A1) bne.b NoProtect move.w D1,(A1) NoProtect lea 24(A1),A1 dbf D0,CheckInfos As Don_Adan suggested, if you survive ode2ptk.mod you're more than okay. http://wt.exotica.org.uk/files/examp...Protracker.lzx |
02 August 2019, 16:48 | #12 |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
This might be off topic... apologies if it is...
The other day I had DJ Metune create an updated version of the Rygar music, some of the tunes when using PHX's replayer have a strange noise now... I tried the same mod through ProTracker on Windows and on Amiga and they're fine. I'm wondering if PHX would be willing to take a look to see if it's his player and if it is apply a fix? @Phx - Let me know and I can provide links via pm. Geezer |
02 August 2019, 20:03 | #13 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,539
|
Quote:
Quote:
But doing the length=1 check seems to be important. |
||
02 August 2019, 20:08 | #14 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,539
|
Quote:
So I added the check for length 1 and reset it to zero. This should fix support for these PC-MODs. The check for the repeat-length of 1 was already done for ptplayer V5.2 (as used in my last two games). Quote:
|
||
02 August 2019, 20:17 | #15 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,539
|
Quote:
Quote:
Please test the latest player version first. Last official release on Aminet is 5.1, but you can find 5.2 in the Celtic Heart and Trap Runner source archives (on EAB in Coders.Releases). I'm still waiting (since nearly 6 months) for a patch from Stingray, so I never released it. Quote:
EDIT: Attached you find the current ptplayer.asm (which may become 5.3), where I just fixed the length=1 case, as discussed above. Maybe you should try this. Last edited by phx; 07 December 2020 at 11:49. |
|||
02 August 2019, 20:19 | #16 | |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
Quote:
Incidentally DJ Metune sent another mod across which now works fine so I've asked him what he did. |
|
02 August 2019, 20:21 | #17 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
|
Then you can forget about altering the mod at all - as it's taking the risk of overwriting memory that does not belong to you - and instead setup another start address if you find an empty repeat (to play real nulls instead of the first two bytes of the sample).
|
02 August 2019, 20:28 | #18 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,539
|
|
02 August 2019, 20:31 | #19 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,539
|
Quote:
Quote:
|
||
02 August 2019, 21:08 | #20 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,039
|
I see some different solution too, you dont need to clear memory, you can alloc 4 bytes of chip ram and use this for your replay. Or even you can use clr.l 0 command and use 0 address as empty sample. I see this method in some Amiga replayers.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Protracker loads song but not the samples | Brick Nash | support.Other | 6 | 12 May 2019 16:20 |
Creating chiptune style samples in protracker | demether | request.Music | 22 | 26 September 2018 07:55 |
How to rip chiptune samples using ProTracker? | BSF-OF-BGP | request.Other | 2 | 12 November 2017 15:37 |
Getting protracker 2.2a samples from PC to floppy and working | W4LKR | New to Emulation or Amiga scene | 12 | 16 June 2013 17:45 |
Does anyone have any protracker samples adf's? | CaptainNow | Amiga scene | 7 | 26 June 2011 13:36 |
|
|