[ Home ]

adlib.c File Reference

Interface to adlib hardware. More...

#include <stdlib.h>
#include <stdio.h>
#include "adlib.h"
#include "fmopl.h"
#include "../../common/platform.h"
#include "../../common/common_utils.h"
#include "../../memory/memory.h"
#include "../../console/console.h"

Include dependency graph for adlib.c:


Data Structures

struct  musicGroup_t

Defines

#define OPL_INTERNAL_FREQ   3600000
#define OPL_NUM_CHIPS   1
#define ADLIB_FREQ   22050
#define alFMStatus   0x388
#define alFMAddr   0x388
#define alFMData   0x389
#define alChar   0x20
#define alScale   0x40
#define alAttack   0x60
#define alSus   0x80
#define alWave   0xe0
#define alFreqL   0xa0
#define alFreqH   0xb0
#define alFeedCon   0xc0
#define alEffects   0xbd
#define ADLIB_MUSIC_SPEED   44100
#define ADLIB_MUSIC_BYPS   (ADLIB_MUSIC_SPEED*2)

Functions

PUBLIC wtBoolean ADLIB_Init (W32 freq)
 Start adlib hardware.
PUBLIC void ADLIB_Shutdown (void)
 Shutdown adlib hardware.
PRIVATE void ADLIB_SetFXInst (Instrument *inst)
 Set Adlib FX instruction.
PUBLIC void * ADLIB_DecodeSound (AdLibSound *sound, W32 *length)
 Decode adlib sound.
PUBLIC void ADLIB_LoadMusic (void *musbuffer)
 Setup music decoder.
PUBLIC W32 ADLIB_UpdateMusic (W32 size, void *buffer)
 Decode adlib music sound.
PUBLIC W32 ADLIB_getLength (void *musbuffer)
 Get music length in milliseconds.

Variables

PRIVATE W8 carriers [9] = { 3, 4, 5, 11, 12,13, 19, 20, 21 }
PRIVATE W8 modifiers [9] = { 0, 1, 2, 8, 9, 10, 16, 17, 18 }
PRIVATE FM_OPL * hAdLib = NULL
PRIVATE W16 * sqHackPtr
PRIVATE W32 sqHackLen
PRIVATE W32 sqHackTime
PRIVATE W32 alTimeCount
musicGroup_t * music

Detailed Description

Interface to adlib hardware.

Author:
Michael Liebscher
Date:
2004-2005
Note:
Portion of this code was derived from Wolfenstein 3-D, and was originally written by Id Software, Inc.

Function Documentation

PUBLIC void* ADLIB_DecodeSound ( AdLibSound *  sound,
W32 *  length 
)

Decode adlib sound.

Parameters:
[in] inst Valid pointer to Instrument structure.
[out] length Length of decoded sound data in bytes.
Returns:
On success true, otherwise false.

Here is the call graph for this function:

Here is the caller graph for this function:

PUBLIC W32 ADLIB_getLength ( void *  musbuffer  ) 

Get music length in milliseconds.

Parameters:
[in] musbuffer musicGroup_t data structure.
[in,out] buffer Hold decoded sound data.
Returns:
On success length in milliseconds.

Here is the caller graph for this function:

PUBLIC wtBoolean ADLIB_Init ( W32  freq  ) 

Start adlib hardware.

Returns:
1 on success, otherwise 0.
Note:
Must call ADLIB_Shutdown() when done.

Here is the caller graph for this function:

PUBLIC void ADLIB_LoadMusic ( void *  musbuffer  ) 

Setup music decoder.

Parameters:
[in] musbuffer musicGroup_t data structure.
Returns:
Nothing.

Here is the caller graph for this function:

PRIVATE void ADLIB_SetFXInst ( Instrument *  inst  ) 

Set Adlib FX instruction.

Parameters:
[in] inst Valid pointer to Instrument structure.
Returns:
Nothing.

Here is the caller graph for this function:

PUBLIC W32 ADLIB_UpdateMusic ( W32  size,
void *  buffer 
)

Decode adlib music sound.

Parameters:
[in] size Number of bytes to write to buffer.
[in,out] buffer Hold decoded sound data.
Returns:
1 on success, otherwise 0.
Note:
Data written to buffer is 44100/16/mono

Here is the caller graph for this function: