News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Porting the FCPlay lib to MASM32

Started by r0ger, March 28, 2021, 06:26:49 AM

Previous topic - Next topic

r0ger

hi there guys ,
i was trying to convert the FutureComposer library from C++ to MASM32. when i tried to initiate the fcplay library , play the FC tune and to compile it, i get following errors:
bones.obj : error LNK2001: unresolved external symbol _fc14play_PlaySong@16
bones.obj : error LNK2001: unresolved external symbol _fc14play_Close@0


does this have to do with a newer SDK ? the lib is actually for VS2015. here is the attachemnt where i tried to convert it to MASM32.
r0ger // PRF

r0ger

and here is the original source code Rbz made for C++ , sorry for double post , got an attachment error saying the files were too large.
r0ger // PRF

jj2007

According to this post, fc14play_PlaySong has three arguments, not four. Adjust your header accordingly, and the error will disappear. However, this does not apply to fc14play_Close :sad:

r0ger

tried that , still got this error tho but different error :
bones.obj : error LNK2001: unresolved external symbol _fc14play_PlaySong@12
bones.obj : error LNK2001: unresolved external symbol _fc14play_Close@0
r0ger // PRF

jj2007

Looks like the usual C++ mess :sad:

With
fc14play_PlaySong PROTO C :DWORD,:DWORD,:DWORD
; void __cdecl fc14play_Close(void);
fc14play_Close PROTO C


and the Micros*t linker, I end up with fatal error LNK1171: unable to load c2.dll

So, where is c2.dll?

r0ger

Quote from: jj2007 on March 28, 2021, 07:45:54 AM
Looks like the usual C++ mess :sad:

With
fc14play_PlaySong PROTO C :DWORD,:DWORD,:DWORD
; void __cdecl fc14play_Close(void);
fc14play_Close PROTO C


and the Micros*t linker, I end up with fatal error LNK1171: unable to load c2.dll

So, where is c2.dll?

well, mine says this:
LINK : fatal error LNK1196: invalid or corrupt import object: unknown version
r0ger // PRF

jj2007

Quote from: r0ger on March 28, 2021, 07:48:42 AMwell, mine says this:
LINK : fatal error LNK1196: invalid or corrupt import object: unknown version

Yes, that's the message with older linkers. A recent M$ link.exe understands the object format but will complain about the missing c2.dll. You seem to have VS2015, find its linker and put it into \Masm32\bin, with the dlls it needs.

TimoVJL

Compiled with Pelles C v8 and stdcall

source: https://pastebin.com/VHxZ58UC
May the source be with you

Biterider

Hi
Maybe I can help a bit. I was able to compile it using the right prototypes. I translated fc14play_v1.27.h from your upload to fc14play_v1.27.inc. This solved the naming decoration issues.  :biggrin:

Additionally I needed to add a lot of C/C++ stuff required for the fc14play_v1.27.lib
includelib C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\libcmt.lib
includelib C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\oldnames.lib
includelib C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\libvcruntime.lib

includelib C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\ucrt\x86\libucrt.lib
includelib C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x86\Uuid.Lib


and then
includelib fc14play_v1.27.lib
include fc14play_v1.27.inc
include classic.inc


and finally
...
invoke fc14play_PlaySong, addr fctune, sizeof fctune, 44100
...


Unfortunately I got a GPF when the fc14play_v1.27.lib called a malloc. At that point I stopped because I have no knowledge of the library and how to properly set it up.   :rolleyes:

Regards, Biterider


TimoVJL

#9
With msvc 2019
This works in Windows 7

missing function round in WDDK 7.10int round(double number)
{
    return (number >= 0) ? (int)(number + 0.5) : (int)(number - 0.5);
}
Windows Driver Kit Version 7.1.0
May the source be with you

jj2007

Quote from: TimoVJL on March 28, 2021, 06:40:03 PM
Compiled with Pelles C v8 and stdcall

source: https://pastebin.com/VHxZ58UC

I got it compiled adding PROTO C somewhere, but it looked wrong. Pastebin plays foul on me, it freezes my browser...

Biterider

Hi
I finally got it working. What was missing was the CRT initialization.  :icon_idea:

Attached the complete app and the binary using the ObjAsm framework.
It can be easily converted into plain MASM.

Biterider

r0ger

hi biterider,

thanks for making this fc replayer to work on assembly :)
but where do i get these Visual Studio 14.0 libs that you've inserted ?
can you give me a link to the installer of the MS Visual studio 14 please ? and the "Windows Kits"?
r0ger // PRF

Biterider

Hi r0ger
I got the SDK files from the VS installer, but you can also get it from the internet. Just google for them.
It is not necessary to use the versions that I used. Just find where they are on your system and make sure they are from the same version/distribution.

Just for fun, I added the horizon data and recompiled the app. I suspect the data is .fc files imported into the .const section.

Biterider

Biterider

Hi
I found some .fc files here http://xmms-fc.sourceforge.net/.
Importing the binary content into the .const section does the trick.

Bin2inc.exe is the right tool, but incbin can also be used with less effort:
.const
fctune label BYTE
incbin <.\modules\Arcane-Theme.fc>
fctunesize = $ - fctune


Unfortunately, not that many .fc files are currently available.

Biterider