*** DISCLAIMER: The information on these pages is not an official instruction or documentation. No responsibility will be taken. Use at your own risk. ***
Showing posts with label vbcc. Show all posts
Showing posts with label vbcc. Show all posts

Monday, February 16, 2026

How to use medplayer.library / octaplayer.library / octamix.library with programs compiled with vbcc?

When you want to play OctaMED music in your program, you'll probably want to take a look at the player routines provided by author Teijo Kinnunen, the package can be found here:

https://aminet.net/package/dev/src/OcSS_src

It contains everything required for the developer, including runtime libraries, but to be able to use these a little preparation is required.

vbcc includes a tool named "fd2pragma" that creates the required C include files in a format that's suitable for vbcc. The source file for operations with "fd2pragma" is an "fd" ("file descriptor") file that describes the library in question to the compiler. The result is one or more new C include files that contains the library's function prototypes, and the actual function addresses of the library.

Here's one way to provide the required information to vbcc:

1. The basic command line to create a prototype include file for "medplayer.library" is:

fd2pragma medplayer_lib.fd 70 clib libproto.h

"medplayer_lib.fd" is the fundamental library file descriptor, provided by OcSS_src package.

"libproto.h" is the "template" prototype file, provided by OcSS_src package.

"70" is fd2pragma's SPECIAL value for "vbcc inline prototype" generation - see fd2pragma docs (click "VBCC").

The result of the above commandline is a new file named "medplayer_protos.h" in your current directory.

(Note that there's a deprecated function named "DimOffPlayer()" for which no function prototype will be created, "fd2pragma" gives a warning that can be ignored.)

2. In your program's C code, include "proplayer.h", as suggested by the example code in OcSS_src package. Do not include "libproto.h", but use your newly created "medplayer_protos.h". (Probably after "proplayer.h".)

3. Put a "struct Library *MEDPlayerBase;" somewhere in your program's code.


Now your program should compile with vbcc, and you can use "medplayer.library" like any other AmigaOS runtime library. There are more options to "fd2pragma" and different ways to make it work - see fd2pragma's docs for more information (e.g. in your vbcc package at doc/fd2pragma.guide).

The procedure is the same with "octaplayer.library" and "octamix.library", only the "fd" file to use is "octaplayer_lib.fd" or "octamix_lib.fd", respectively, and the resulting names ("octaplayer_protos.h", "OctaPlayerBase", etc.) are different.

Note that if you want to play different types of OctaMED music (4-channel, 5-8 channel, multichannel-mixing) you can use function "RequiredPlayRoutine()" (medplayer.library) to find out if your program needs to also open octaplayer.library or octamix.library and use different playback functions ("PlayModule8()", "PlayModuleM()").

Tuesday, August 15, 2017

why does vbcc's printf()/snprintf()... not respect %f in format strings?

Problem:
using printf("%f", 1.2);
prints
   %f
instead of
   1.20000

Possible reasons:
no math lib included

Possible solutions:
- add -lmieee or -lmsoft (or other math library -> see vbcc manual) to list of compiler options
- put -lmieee (or whatever math lib you're using) before -lvc in list of compiler libs options

Friday, July 28, 2017

how to create a linker library with vbcc for vbcc

1. compile individual .c source code files for your desired linker library into .o object files, for example:

> path/to/linkerlib
> vc -c libfunc1.c 
> vc -c libfunc2.c

will create "libfunc1.o" and "libfunc2.o"


2. use .o files as required when compiling your code, for example:

> path/to/my_program
> vc path/to/linkerlib/libfunc1.o path/to/linkerlib/libfunc2.o -o my_program my_program.c

or join .o files into one file, which is your new linker library, and use accordingly, for example:

> path/to/linkerlib
> join libfunc1.o libfunc2.o to my.lib
> path/to/my_program
> vc -Lpath/to/linkerlib -lmy -o my_program my_program.c