Skip to content

Add player for A2M (versions 1-14) and A2T (versions 1-14)#207

Merged
binarymaster merged 33 commits into
adplug:masterfrom
dmitrysmagin:a2m-v2-sq
May 31, 2024
Merged

Add player for A2M (versions 1-14) and A2T (versions 1-14)#207
binarymaster merged 33 commits into
adplug:masterfrom
dmitrysmagin:a2m-v2-sq

Conversation

@dmitrysmagin

@dmitrysmagin dmitrysmagin commented Feb 26, 2024

Copy link
Copy Markdown
Contributor

Hi.
After years of converting FreePascal to C I was able to commit this code to adplug...

This is a direct translation of the player routine from the sources of the Adlib Tracker 2 (http://adlibtracker.net/). A2M and tiny modules A2T are supported (versions 1 - 14).

However, this player doesn't replace the original a2m.cpp, but picks up all modules that a2m.cpp can't handle.
Ideally, I'd like to remove old a2m.cpp in future since it doesn't support some effects and panning even for versions 1-8.

Now about packers:

depack.c
https://ibsensoftware.com/products_aPLib.html
https://ibsensoftware.com/files/aPLib-1.1.1.zip

sixpack.c
https://www.sac.sk/download/pack/ddjcompr.zip
https://github.com/70MM13/Step5Archive/blob/main/resources/sixpack/sixpack.c

unlzh.c
http://fileformats.archiveteam.org/wiki/Ar_(Haruhiko_Okumura)
http://cd.textfiles.com/sourcecode/msdos/arc_lbr/ar002.zip

unlzw.c and unlzss.c
Those unpackers were written in hand-optimized assembly in Adlib Tracker 2, so I did
a backward conversion to C.
It seems that they are customized and don't correspond to any existing C implementation.

I've left the names 'depack.c' and 'sixpack.c' because those are original names used by their authors. Note that the old 0.26 algo for aPlib is used which is incompatible with the recent aPlib.
As for 'unlzh.c', it's a combination of multiple original files with some custom tweaking which might make the algo incompatible with the original lzh.
All original copyrights and license details are kept intact along with some notes from the authors.

Yes, the author of Adlib Tracker 2 is notoriously known for using a new pack/unpack routine for every new a2m version...

UPDATE 2024-03-06: Added unlzw.c and unlzwss.c unpackers.

@dmitrysmagin dmitrysmagin changed the title Add player for A2M (versions 9-14) and A2T (versions 1-14) Add player for A2M (versions 1-14) and A2T (versions 1-14) Mar 6, 2024
@dmitrysmagin

Copy link
Copy Markdown
Contributor Author

@mywave82, @Malvineous ?

1 similar comment
@dmitrysmagin

Copy link
Copy Markdown
Contributor Author

@mywave82, @Malvineous ?

@mywave82

mywave82 commented Apr 3, 2024

Copy link
Copy Markdown
Contributor

Sorry for slow response, been extra busy last months.

CI currently does not compile, so that needs to be resolved.

depack.c: from readme.txt:

aPLib is freeware. If you use aPLib in a product, an acknowledgement would be
appreciated, e.g. by adding something like the following to the documentation:

    This product uses the aPLib compression library,
    Copyright (c) 1998-2014 Joergen Ibsen, All Rights Reserved.
    For more information, please visit: http://www.ibsensoftware.com/

You may not redistribute aPLib without all of the files.

Probably nice to reach out to the author, since we only use one of the files.

sixpack.c: no special copyright requirement present, published as entry in a magazine competition.

unlzh.c: no special copyright requirement present,

@dmitrysmagin

Copy link
Copy Markdown
Contributor Author

I've sent a message to contact@ibsensoftware.com asking for permission to use depack.c as-is.
Let's hope the author is checking his mail regularly.

@jibsen

jibsen commented Apr 10, 2024

Copy link
Copy Markdown

Thanks for taking the time to reach out, you are welcome to use the aPLib decompression code here.

@dmitrysmagin

dmitrysmagin commented Apr 15, 2024

Copy link
Copy Markdown
Contributor Author

Thanks!
@mywave82 are we ok now?
sixpack.c seems to be written 35 years ago and is already used in older player a2p.cpp without much modifications,
unlzh.c is public domain too and ~35 years as well, so
I don't see problems with merging new a2m-v2.cpp.

@mywave82

Copy link
Copy Markdown
Contributor

Thanks! @mywave82 are we ok now? sixpack.c seems to be written 35 years ago and is already used in older player a2p.cpp without much modifications, unlzh.c is public domain too and ~35 years as well, so I don't see problems with merging new a2m-v2.cpp.

Still need to fix the CI that fails.

@Enet4 Enet4 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured I'd leave some comments on this PR, as I am interested in this A2M loader and I'm seeing that it might get further traction in the near future. Can't speak much about the errors in CI, as I'm not very familiar with the full project.

Comment thread src/a2m-v2.h Outdated
Comment thread src/a2m-v2.h Outdated
Enet4 added a commit to Enet4/adlib2vgm that referenced this pull request Apr 26, 2024
- add a2m-v2 impl
- replace A2M loader in main application
- add the necessary C dependencies
- tweak CMakeLists to include dependencies and compile C code

Code adapted from adplug/adplug#207
@dmitrysmagin

dmitrysmagin commented May 2, 2024

Copy link
Copy Markdown
Contributor Author

Now using static_assert() everywhere, and dropped redundant one.
Extra benefit -- static_assert() is parsed by code editors and might be highlighted in case of assert failing.

mywave82 added 5 commits May 3, 2024 09:13
.ref files are stored in testref directory, not testmus
…flow in playertest, most of them had problem in stresstest.
@dmitrysmagin

Copy link
Copy Markdown
Contributor Author

@mywave82 , thanks for you patch, I was about to make smth very similar. I'll see if it can be improved to look more elegant...

@mywave82

mywave82 commented May 5, 2024

Copy link
Copy Markdown
Contributor

https://ci.appveyor.com/project/AdPlug/adplug/builds/49753291

Appears that MSVC does not like the ... in the switch case blocks
(and a forrest of unsigned/signed comparisons)

@dmitrysmagin

Copy link
Copy Markdown
Contributor Author

It's a shame for MSVC, it seems that gcc and clang support '...' in case clauses...
Okay, this might be replaced with multiple case statements in certain places and chained if-else in others.

@mywave82

Copy link
Copy Markdown
Contributor

Looking through the code, and the few parts that probably would be endian sensitive is not in "danger" at the moment, since the memcpy() are commented out.

We are probably ready to merge :-)

@dmitrysmagin

Copy link
Copy Markdown
Contributor Author

Let's go for it! Better squash commits or leave as is?

@binarymaster binarymaster merged commit 855e091 into adplug:master May 31, 2024
Enet4 added a commit to Enet4/adlib2vgm that referenced this pull request Jun 1, 2024
- add the required C bitpacking libraries into `deps/`
- add a2m-v2 impl
- replace A2M loader in main application
- add the necessary C dependencies
- tweak CMakeLists to include dependencies and compile C code

Code adapted from adplug/adplug#207
ReimuNotMoe pushed a commit to SudoMaker/adlib2vgm that referenced this pull request Jun 1, 2024
- add the required C bitpacking libraries into `deps/`
- add a2m-v2 impl
- replace A2M loader in main application
- add the necessary C dependencies
- tweak CMakeLists to include dependencies and compile C code

Code adapted from adplug/adplug#207
@dmitrysmagin dmitrysmagin deleted the a2m-v2-sq branch August 29, 2024 17:00
@barracuda156

Copy link
Copy Markdown

@dmitrysmagin Could you please take a look at these errors? #247
Quite a number of static asserts in a2m-v2.h fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants