#include <psx.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <adpcm.h>
#include "modplay.h"
#include "modplay_int.h"
Macros | |
#define | ADPCM_BUFFER_SIZE 0x4000 |
Functions | |
ModMusic * | MODLoad (void *d) |
Just like MODLoadEx() but with the flags parameters set to zero, i.e. | |
ModMusic * | MODLoadEx (void *d, unsigned int flags) |
Allocate a ModMusic structure and copy data to it from data in memory containing a music module file. | |
void | MODUnload (ModMusic *m) |
Free memory allocated for music module. | |
void | MODPlay_func (ModMusic *m, int c, int s, int p, int vl, int vr) |
MODPlay: internal prototypes. | |
void | MODPlay (ModMusic *m, int *t) |
Play a tick of a music. | |
void | MODStop (ModMusic *m) |
Stop a music. | |
int | MODUploadSamples (ModMusic *m, int base_addr) |
Upload the samples of the module music to Sound RAM. | |
int | MOD4PSX_Upload (void *d, int base_addr) |
Upload preconverted ADPCM samples, as generated by the mod4psx tool. | |
void | MODSetBaseVoice (int base_voice) |
Sets the SPU voice to use as the first channel when playing music. | |
void | MODSetMaxVolume (unsigned short max_volume) |
Set maximum volume for MODPlay. | |
void | MODRewind (ModMusic *m) |
Rewind music, that is, make it restart from the beginning. | |
void | MODSetTranspose (ModMusic *m, short transpose) |
Sets transpose for music. | |
void | MODSetMono (int value) |
Set mono mode. | |
Variables | |
int | modplay_base_voice = 0 |
int | modplay_max_vol = 0x3fff |
int | modplay_chan_vols [8] |
int | modplay_int_cnt = 0 |
int | modplay_samples_off [32] |
int | modplay_chan_mask = 0 |
int | modplay_is_mono = 0 |
unsigned char | modplay_adpcm_buffer [ADPCM_BUFFER_SIZE] |
unsigned int | modload_flags = 0 |
#define ADPCM_BUFFER_SIZE 0x4000 |
int MOD4PSX_Upload | ( | void * | d, |
int | base_addr | ||
) |
Upload preconverted ADPCM samples, as generated by the mod4psx tool.
d | Pointer to buffer containing the ADPCM samples archive |
base_addr | Base address at which the samples will start to be uploaded. |
ModMusic* MODLoad | ( | void * | d | ) |
Just like MODLoadEx() but with the flags parameters set to zero, i.e.
default behaviour.
d | Pointer to a buffer containing a music module file |
ModMusic* MODLoadEx | ( | void * | d, |
unsigned int | flags | ||
) |
Allocate a ModMusic structure and copy data to it from data in memory containing a music module file.
Almost all data from the music module file is copied into another location in memory for the ModMusic structure.
This means your free memory should be roughly the double of the size of the MOD you're loading.
You can avoid loading the samples in the module file's native format, thus saving useful memory, by passing the MODLOAD_NOSAMPLES flag. This is especially the case when you use MOD4PSX_Upload().
d | Pointer to a buffer containing a music module file |
flags | Flag bitmask. |
void MODPlay | ( | ModMusic * | m, |
int * | t | ||
) |
Play a tick of a music.
This has to be called 60 / 50 times per second.
MODPlay decreases the value referenced by t every time the music finishes.
Set the variable pointed by t when you want to set the number of times again!
m | Pointer to ModMusic structure |
t | Pointer to an int which contains how many times the music module has to be played. i.e. if *t == 1, play once, if *t == 2, play twice, ..., if *t == -1, loop endlessly |
void MODPlay_func | ( | ModMusic * | m, |
int | c, | ||
int | s, | ||
int | p, | ||
int | vl, | ||
int | vr | ||
) |
MODPlay: internal prototypes.
void MODRewind | ( | ModMusic * | m | ) |
Rewind music, that is, make it restart from the beginning.
m | Pointer to ModMusic structure for the music. |
void MODSetBaseVoice | ( | int | base_voice | ) |
Sets the SPU voice to use as the first channel when playing music.
The voice for the second channel will then be this (value+1), and so on...
Usually the base voice is 0; a MOD file can have up to eight channels, so take care of that.
A 669 file can always have 8 channels.
base_voice | Desired base voice (0-23) |
void MODSetMaxVolume | ( | unsigned short | max_volume | ) |
Set maximum volume for MODPlay.
max_volume | Maximum volume desired (0-0x3FFF) |
void MODSetMono | ( | int | value | ) |
Set mono mode.
value | If 0 set stereo mode, if 1 set mono mode |
void MODSetTranspose | ( | ModMusic * | m, |
short | transpose | ||
) |
Sets transpose for music.
Changing the transpose value for a music shifts the frequency its samples are played at, but the music's tempo is unchanged.
m | Pointer to ModMusic structure |
transpose | Transpose value |
void MODUnload | ( | ModMusic * | m | ) |
Free memory allocated for music module.
m | Pointer to ModMusic structure |
int MODUploadSamples | ( | ModMusic * | m, |
int | base_addr | ||
) |
Upload the samples of the module music to Sound RAM.
m | Pointer to ModMusic structure for the music. |
base_addr | Sound RAM address to start from when uploading to Sound RAM If -1 it is interpreted to be the same as the start of the section for sound data in Sound RAM (SPU_DATA_BASE_ADDR). base_addr must be a multiply of 8. |
unsigned int modload_flags = 0 |
unsigned char modplay_adpcm_buffer[ADPCM_BUFFER_SIZE] |
int modplay_base_voice = 0 |
int modplay_chan_mask = 0 |
int modplay_chan_vols[8] |
int modplay_int_cnt = 0 |
int modplay_is_mono = 0 |
int modplay_max_vol = 0x3fff |
int modplay_samples_off[32] |