Commit 0c14da02 authored by Erik Faye-Lund's avatar Erik Faye-Lund
Browse files

removed MOST c++-comments, fixed 16khz rendering (works, but clicks)

git-svn-id: https://pimpmobile.svn.sourceforge.net/svnroot/pimpmobile/trunk@156 3d5ecaf0-f903-0410-b953-c2c1a4d75763
parent 12773987
...@@ -46,8 +46,9 @@ else ...@@ -46,8 +46,9 @@ else
CPPFLAGS += -DRELEASE -DNDEBUG CPPFLAGS += -DRELEASE -DNDEBUG
CXXFLAGS += -O3 -fomit-frame-pointer CXXFLAGS += -O3 -fomit-frame-pointer
CFLAGS += -O3 -fomit-frame-pointer CFLAGS += -O3 -fomit-frame-pointer
# OBJS += src/pimp_mixer_portable.o
OBJS += src/pimp_mixer_arm.o OBJS += src/pimp_mixer_arm.o
# OBJS += src/pimp_mixer_clip_arm.o OBJS += src/pimp_mixer_clip_arm.o
endif endif
......
...@@ -115,7 +115,7 @@ int main(int argc, char *argv[]) ...@@ -115,7 +115,7 @@ int main(int argc, char *argv[])
for (unsigned period = 1; period < 32767; period += 17) for (unsigned period = 1; period < 32767; period += 17)
{ {
float frequency1 = (8363 * 1712) / float(period); float frequency1 = (8363 * 1712) / float(period);
float delta1 = frequency1 / SAMPLERATE; float delta1 = frequency1 / (SAMPLERATE);
delta1 = unsigned(delta1 * (1 << 12) + 0.5) * (1.0 / (1 << 12)); delta1 = unsigned(delta1 * (1 << 12) + 0.5) * (1.0 / (1 << 12));
float delta2 = get_amiga_delta(period) * (1.0 / (1 << 12)); float delta2 = get_amiga_delta(period) * (1.0 / (1 << 12));
...@@ -136,7 +136,7 @@ int main(int argc, char *argv[]) ...@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
int period = (10 * 12 * 16 * 4) - i * (16 * 4) - fine_tune / 2; int period = (10 * 12 * 16 * 4) - i * (16 * 4) - fine_tune / 2;
float frequency1 = 8363 * pow(2.0, float(6 * 12 * 16 * 4 - period) / (12 * 16 * 4)); float frequency1 = 8363 * pow(2.0, float(6 * 12 * 16 * 4 - period) / (12 * 16 * 4));
float delta1 = frequency1 / SAMPLERATE; float delta1 = frequency1 / (SAMPLERATE);
delta1 = unsigned(delta1 * (1 << 12) + 0.5) * (1.0 / (1 << 12)); delta1 = unsigned(delta1 * (1 << 12) + 0.5) * (1.0 / (1 << 12));
float delta2 = get_linear_delta(period) * (1.0 / (1 << 12)); float delta2 = get_linear_delta(period) * (1.0 / (1 << 12));
......
...@@ -6,30 +6,26 @@ ...@@ -6,30 +6,26 @@
#ifndef PIMP_CONFIG_H #ifndef PIMP_CONFIG_H
#define PIMP_CONFIG_H #define PIMP_CONFIG_H
#define CYCLES_PR_FRAME 280896
/* 32 is the maximum amount of channels in fasttracker2. a nice default. */ /* 32 is the maximum amount of channels in fasttracker2. a nice default. */
#define CHANNELS 8 #define CHANNELS 32
/* check the sample-rate calculator at http://www.pineight.com/gba/samplerates/ for more glitch-free samplerates */ /* check the sample-rate calculator at http://www.pineight.com/gba/samplerates/ for more glitch-free samplerates */
/* 0x4000100 = 0xFFFF, 0x4000102 = 0x0083 */ /* 0x4000100 = 0xFFFF, 0x4000102 = 0x0083 */
#define SAMPLERATE (18157.16) /* #define SAMPLERATE (18157.16) */
/* #define SAMPLERATE (16384) */
#define SAMPLERATE 15768.06
/* only 130 bytes big, quite damn pleasing results */ /* only 130 bytes big, quite damn pleasing results */
#define AMIGA_DELTA_LUT_LOG_SIZE 7 #define AMIGA_DELTA_LUT_LOG_SIZE 7
/* derivated settings. don't touch. */ /* derivated settings. don't touch. */
#define SOUND_BUFFER_SIZE (CYCLES_PR_FRAME / ((int)((1 << 24) / SAMPLERATE)))
#define AMIGA_DELTA_LUT_SIZE (1 << AMIGA_DELTA_LUT_LOG_SIZE) #define AMIGA_DELTA_LUT_SIZE (1 << AMIGA_DELTA_LUT_LOG_SIZE)
#define AMIGA_DELTA_LUT_FRAC_BITS (15 - AMIGA_DELTA_LUT_LOG_SIZE) #define AMIGA_DELTA_LUT_FRAC_BITS (15 - AMIGA_DELTA_LUT_LOG_SIZE)
/* enable / disable assert */ /* enable / disable assert */
/* /*
#define DEBUG_PRINTF_ENABLED #define DEBUG_PRINT_ENABLE
#define ASSERT_ENABLED #define ASSERT_ENABLE
*/ */
#define DEBUG_PRINTF_ENABLED
// #define ASSERT_ENABLED
#endif /* PIMP_CONFIG_H */ #endif /* PIMP_CONFIG_H */
...@@ -6,17 +6,25 @@ ...@@ -6,17 +6,25 @@
#ifndef PIMP_DEBUG_H #ifndef PIMP_DEBUG_H
#define PIMP_DEBUG_H #define PIMP_DEBUG_H
#ifdef DEBUG_PRINTF_ENABLED /* current debug level */
#define DEBUG_PRINT(X) iprintf X #define DEBUG_LEVEL 100
/* some standard debug levels */
#define DEBUG_LEVEL_INFO 10
#define DEBUG_LEVEL_WARNING 50
#define DEBUG_LEVEL_ERROR 100
#ifdef DEBUG_PRINT_ENABLE
#define DEBUG_PRINT(debug_level, X) do { if (DEBUG_LEVEL <= debug_level) iprintf X } while(0)
#else #else
#define DEBUG_PRINT(X) #define DEBUG_PRINT(debug_level, X)
#endif #endif
#ifdef ASSERT_ENABLED #ifdef ASSERT_ENABLE
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#define ASSERT(expr) \ #define ASSERT(expr) \
do { \ do { \
if (!(expr)) iprintf("*** ASSERT FAILED %s AT (%s:%i)\n", #expr, __FILE__, __LINE__); \ if (!(expr)) iprintf("*** ASSERT FAILED %s AT (%s:%i)\n", #expr, __FILE__, __LINE__); \
} while(0) } while(0)
#else #else
......
...@@ -19,7 +19,7 @@ typedef struct ...@@ -19,7 +19,7 @@ typedef struct
s16 node_delta[25]; s16 node_delta[25];
u8 node_count; u8 node_count;
u8 flags; // bit 0: loop enable, bit 1: sustain loop enable u8 flags; /* bit 0: loop enable, bit 1: sustain loop enable */
u8 loop_start, loop_end; u8 loop_start, loop_end;
u8 sustain_loop_start, sustain_loop_end; u8 sustain_loop_start, sustain_loop_end;
} pimp_envelope; } pimp_envelope;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#define PIMP_TYPES_H /* prevent pimp_types.h from being included */ #define PIMP_TYPES_H /* prevent pimp_types.h from being included */
#include "pimp_render.h" #include "pimp_render.h"
#include "pimp_debug.h"
#include <gba_dma.h> #include <gba_dma.h>
#include <gba_sound.h> #include <gba_sound.h>
...@@ -18,8 +19,14 @@ ...@@ -18,8 +19,14 @@
pimp_mod_context __pimp_ctx; pimp_mod_context __pimp_ctx;
pimp_mixer __pimp_mixer; pimp_mixer __pimp_mixer;
/* setup some constants */
#define CYCLES_PR_FRAME 280896
#define SAMPLES_PER_FRAME ((int)((1 << 24) / ((float)SAMPLERATE)))
#define SOUND_BUFFER_SIZE ((int)((float)CYCLES_PR_FRAME / SAMPLES_PER_FRAME))
STATIC s8 __pimp_sound_buffers[2][SOUND_BUFFER_SIZE] IWRAM_DATA; STATIC s8 __pimp_sound_buffers[2][SOUND_BUFFER_SIZE] IWRAM_DATA;
STATIC u32 __pimp_sound_buffer_index = 0; STATIC u32 __pimp_sound_buffer_index = 0;
s32 __pimp_mix_buffer[SOUND_BUFFER_SIZE] IWRAM_DATA;
void pimp_init(const void *module, const void *sample_bank) void pimp_init(const void *module, const void *sample_bank)
{ {
...@@ -30,8 +37,10 @@ void pimp_init(const void *module, const void *sample_bank) ...@@ -30,8 +37,10 @@ void pimp_init(const void *module, const void *sample_bank)
REG_SOUNDCNT_H = SNDA_VOL_100 | SNDA_L_ENABLE | SNDA_R_ENABLE | SNDA_RESET_FIFO; REG_SOUNDCNT_H = SNDA_VOL_100 | SNDA_L_ENABLE | SNDA_R_ENABLE | SNDA_RESET_FIFO;
REG_SOUNDCNT_X = (1 << 7); REG_SOUNDCNT_X = (1 << 7);
/* setup timer-shit */ DEBUG_PRINT(DEBUG_LEVEL_INFO, ("samples pr frame: 0x%x\nsound buffer size: %d\n", SAMPLES_PER_FRAME, SOUND_BUFFER_SIZE));
REG_TM0CNT_L = (1 << 16) - (int)((1 << 24) / SAMPLERATE);
/* setup timer */
REG_TM0CNT_L = (1 << 16) - SAMPLES_PER_FRAME;
REG_TM0CNT_H = TIMER_START; REG_TM0CNT_H = TIMER_START;
} }
...@@ -77,7 +86,7 @@ void pimp_frame() ...@@ -77,7 +86,7 @@ void pimp_frame()
static volatile BOOL locked = FALSE; static volatile BOOL locked = FALSE;
if (TRUE == locked) return; /* whops, we're in the middle of filling. sorry. you did something wrong! */ if (TRUE == locked) return; /* whops, we're in the middle of filling. sorry. you did something wrong! */
locked = TRUE; locked = TRUE;
__pimp_render(&__pimp_ctx, __pimp_sound_buffers[__pimp_sound_buffer_index], SOUND_BUFFER_SIZE); __pimp_render(&__pimp_ctx, __pimp_sound_buffers[__pimp_sound_buffer_index], SOUND_BUFFER_SIZE);
locked = FALSE; locked = FALSE;
...@@ -85,6 +94,14 @@ void pimp_frame() ...@@ -85,6 +94,14 @@ void pimp_frame()
void __pimp_mixer_clear(void *target, int samples) void __pimp_mixer_clear(void *target, int samples)
{ {
u32 zero = 0; int i;
CpuFastSet(&zero, target, DMA_SRC_FIXED | (samples)); const u32 zero = 0;
u32 *dst = (u32*)target;
for (i = samples &7; i; --i)
{
*dst++ = 0;
}
CpuFastSet(&zero, dst, DMA_SRC_FIXED | (samples & ~7));
} }
...@@ -36,10 +36,10 @@ unsigned __pimp_get_linear_period(int note, int fine_tune) ...@@ -36,10 +36,10 @@ unsigned __pimp_get_linear_period(int note, int fine_tune)
ASSERT(fine_tune >= -8); ASSERT(fine_tune >= -8);
ASSERT(fine_tune < 8); ASSERT(fine_tune < 8);
int xm_note = note - (12 * 1) - 1; // we extended our note-range with one octave. int xm_note = note - (12 * 1) - 1; /* we extended our note-range with one octave. */
return (10 * 12 * 16 * 4 - xm_note * 16 * 4 - fine_tune / 2); return (10 * 12 * 16 * 4 - xm_note * 16 * 4 - fine_tune / 2);
// return 10 * 12 * 16 * 4 - note * 16 * 4 - fine_tune / 2; /* return 10 * 12 * 16 * 4 - note * 16 * 4 - fine_tune / 2; */
} }
#include "linear_delta_lut.h" #include "linear_delta_lut.h"
...@@ -51,7 +51,7 @@ unsigned __pimp_get_linear_delta(unsigned period) ...@@ -51,7 +51,7 @@ unsigned __pimp_get_linear_delta(unsigned period)
unsigned delta = linear_delta_lut[octave_period] << octave; unsigned delta = linear_delta_lut[octave_period] << octave;
/* BEHOLD: the expression of the devil (this compiles to one arm-instruction) */ /* BEHOLD: the expression of the devil (this compiles to one arm-instruction) */
const unsigned int scale = (unsigned int)((1.0 / SAMPLERATE) * (1 << 3) * (1ULL << 32)); const unsigned int scale = (unsigned int)((1.0 / (SAMPLERATE)) * (1 << 3) * (1ULL << 32));
delta = ((long long)delta * scale + (1ULL << 31)) >> 32; delta = ((long long)delta * scale + (1ULL << 31)) >> 32;
return delta; return delta;
} }
...@@ -61,7 +61,7 @@ unsigned __pimp_get_linear_delta(unsigned period) ...@@ -61,7 +61,7 @@ unsigned __pimp_get_linear_delta(unsigned period)
#include "amiga_period_lut.h" #include "amiga_period_lut.h"
unsigned __pimp_get_amiga_period(int note, int fine_tune) unsigned __pimp_get_amiga_period(int note, int fine_tune)
{ {
fine_tune /= 8; // todo: interpolate instead? fine_tune /= 8; /* todo: interpolate instead? */
ASSERT(fine_tune >= -8); ASSERT(fine_tune >= -8);
ASSERT(fine_tune <= 8); ASSERT(fine_tune <= 8);
...@@ -94,16 +94,16 @@ unsigned __pimp_get_amiga_delta(unsigned period) ...@@ -94,16 +94,16 @@ unsigned __pimp_get_amiga_delta(unsigned period)
unsigned p_frac = p & ((1 << AMIGA_DELTA_LUT_FRAC_BITS) - 1); unsigned p_frac = p & ((1 << AMIGA_DELTA_LUT_FRAC_BITS) - 1);
p >>= AMIGA_DELTA_LUT_FRAC_BITS; p >>= AMIGA_DELTA_LUT_FRAC_BITS;
// interpolate table-entries for better result /* interpolate table-entries for better result */
int d1 = amiga_delta_lut[p - (AMIGA_DELTA_LUT_SIZE / 2)]; // (8363 * 1712) / float(p); int d1 = amiga_delta_lut[p - (AMIGA_DELTA_LUT_SIZE / 2)]; /* (8363 * 1712) / float(p) */
int d2 = amiga_delta_lut[p + 1 - (AMIGA_DELTA_LUT_SIZE / 2)]; // (8363 * 1712) / float(p + 1); int d2 = amiga_delta_lut[p + 1 - (AMIGA_DELTA_LUT_SIZE / 2)]; /* (8363 * 1712) / float(p + 1) */
unsigned delta = (d1 << AMIGA_DELTA_LUT_FRAC_BITS) + (d2 - d1) * p_frac; unsigned delta = (d1 << AMIGA_DELTA_LUT_FRAC_BITS) + (d2 - d1) * p_frac;
if (shamt > AMIGA_DELTA_LUT_FRAC_BITS) delta <<= shamt - AMIGA_DELTA_LUT_FRAC_BITS; if (shamt > AMIGA_DELTA_LUT_FRAC_BITS) delta <<= shamt - AMIGA_DELTA_LUT_FRAC_BITS;
else delta >>= AMIGA_DELTA_LUT_FRAC_BITS - shamt; else delta >>= AMIGA_DELTA_LUT_FRAC_BITS - shamt;
/* BEHOLD: the expression of the devil 2.0 (this compiles to one arm-instruction) */ /* BEHOLD: the expression of the devil 2.0 (this compiles to one arm-instruction) */
const unsigned int scale = (unsigned int)(((1.0 / SAMPLERATE) * (1 << 6)) * (1LL << 32)); const unsigned int scale = (unsigned int)(((1.0 / (SAMPLERATE)) * (1 << 6)) * (1LL << 32));
delta = ((long long)delta * scale + (1ULL << 31)) >> 32; delta = ((long long)delta * scale + (1ULL << 31)) >> 32;
return delta; return delta;
......
...@@ -35,12 +35,12 @@ STATIC BOOL detect_loop_event(pimp_mixer_channel_state *chan, int samples) ...@@ -35,12 +35,12 @@ STATIC BOOL detect_loop_event(pimp_mixer_channel_state *chan, int samples)
case LOOP_TYPE_PINGPONG: case LOOP_TYPE_PINGPONG:
if (chan->sample_cursor_delta >= 0) if (chan->sample_cursor_delta >= 0)
{ {
// moving forwards through the sample /* moving forwards through the sample */
check_point = chan->loop_end; check_point = chan->loop_end;
} }
else else
{ {
// moving backwards through the sample /* moving backwards through the sample */
check_point = chan->loop_start; check_point = chan->loop_start;
if (end_sample < (check_point << 12)) if (end_sample < (check_point << 12))
{ {
...@@ -63,7 +63,7 @@ STATIC BOOL detect_loop_event(pimp_mixer_channel_state *chan, int samples) ...@@ -63,7 +63,7 @@ STATIC BOOL detect_loop_event(pimp_mixer_channel_state *chan, int samples)
return FALSE; return FALSE;
} }
// returns false if we hit sample-end /* returns false if we hit sample-end */
BOOL process_loop_event(pimp_mixer_channel_state *chan) BOOL process_loop_event(pimp_mixer_channel_state *chan)
{ {
switch (chan->loop_type) switch (chan->loop_type)
...@@ -115,7 +115,7 @@ void __pimp_mixer_mix_channel(pimp_mixer_channel_state *chan, s32 *target, u32 s ...@@ -115,7 +115,7 @@ void __pimp_mixer_mix_channel(pimp_mixer_channel_state *chan, s32 *target, u32 s
while (samples > 0 && detect_loop_event(chan, samples) == TRUE) while (samples > 0 && detect_loop_event(chan, samples) == TRUE)
{ {
// TODO: iterative binary search here instead /* TODO: iterative binary search here instead */
do do
{ {
ASSERT((chan->sample_cursor >> 12) < chan->sample_length); ASSERT((chan->sample_cursor >> 12) < chan->sample_length);
...@@ -134,12 +134,12 @@ void __pimp_mixer_mix_channel(pimp_mixer_channel_state *chan, s32 *target, u32 s ...@@ -134,12 +134,12 @@ void __pimp_mixer_mix_channel(pimp_mixer_channel_state *chan, s32 *target, u32 s
if (process_loop_event(chan) == FALSE) if (process_loop_event(chan) == FALSE)
{ {
// the sample has stopped, we need to fill the rest of the buffer with the dc-offset, so it doesn't ruin our unsigned mixing-thing /* the sample has stopped, we need to fill the rest of the buffer with the dc-offset, so it doesn't ruin our unsigned mixing-thing */
while (samples--) while (samples--)
{ {
*target++ += chan->volume * 128; *target++ += chan->volume * 128;
} }
// terminate sample /* terminate sample */
chan->sample_data = 0; chan->sample_data = 0;
return; return;
} }
...@@ -162,23 +162,23 @@ void __pimp_mixer_reset(pimp_mixer *mixer) ...@@ -162,23 +162,23 @@ void __pimp_mixer_reset(pimp_mixer *mixer)
} }
} }
STATIC s32 sound_mix_buffer[SOUND_BUFFER_SIZE] __attribute__((section(".iwram"))); extern s32 __pimp_mix_buffer[];
void __pimp_mixer_mix(pimp_mixer *mixer, s8 *target, int samples) void __pimp_mixer_mix(pimp_mixer *mixer, s8 *target, int samples)
{ {
u32 c; u32 c;
ASSERT(samples > 0); ASSERT(samples > 0);
__pimp_mixer_clear(sound_mix_buffer, samples); __pimp_mixer_clear(__pimp_mix_buffer, samples);
dc_offs = 0; dc_offs = 0;
for (c = 0; c < CHANNELS; ++c) for (c = 0; c < CHANNELS; ++c)
{ {
pimp_mixer_channel_state *chan = &mixer->channels[c]; pimp_mixer_channel_state *chan = &mixer->channels[c];
if (NULL != chan->sample_data) __pimp_mixer_mix_channel(chan, sound_mix_buffer, samples); if (NULL != chan->sample_data) __pimp_mixer_mix_channel(chan, __pimp_mix_buffer, samples);
} }
dc_offs >>= 8; dc_offs >>= 8;
__pimp_mixer_clip_samples(target, sound_mix_buffer, samples, dc_offs); __pimp_mixer_clip_samples(target, __pimp_mix_buffer, samples, dc_offs);
} }
...@@ -61,6 +61,6 @@ void __pimp_mod_context_set_bpm(pimp_mod_context *ctx, int bpm) ...@@ -61,6 +61,6 @@ void __pimp_mod_context_set_bpm(pimp_mod_context *ctx, int bpm)
ASSERT(bpm > 0); ASSERT(bpm > 0);
/* we're using 8 fractional-bits for the tick-length */ /* we're using 8 fractional-bits for the tick-length */
const int temp = (int)((SAMPLERATE * 5) * (1 << 8)); const int temp = (int)(((SAMPLERATE) * 5) * (1 << 8));
ctx->tick_len = temp / (bpm * 2); ctx->tick_len = temp / (bpm * 2);
} }
...@@ -29,8 +29,7 @@ typedef struct ...@@ -29,8 +29,7 @@ typedef struct
u32 flags; u32 flags;
u32 reserved; /* for future flags */ u32 reserved; /* for future flags */
// these are offsets relative to the begining of the pimp_module_t-structure /* these are offsets relative to the begining of the pimp_module_t-structure */
/* TODO: make these relative to their storage, and make a generic getter for those kinds of pointers */
u32 order_ptr; u32 order_ptr;
u32 pattern_ptr; u32 pattern_ptr;
u32 channel_ptr; u32 channel_ptr;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "pimp_mixer.h" #include "pimp_mixer.h"
#include "pimp_math.h" #include "pimp_math.h"
// #define PRINT_PATTERNS /* #define PRINT_PATTERNS */
/* need to move these to a separate channel state header (?) */ /* need to move these to a separate channel state header (?) */
STATIC void porta_up(pimp_channel_state *chan, s32 period_low_clamp) STATIC void porta_up(pimp_channel_state *chan, s32 period_low_clamp)
...@@ -64,7 +64,7 @@ STATIC int __pimp_channel_get_volume(pimp_channel_state *chan) ...@@ -64,7 +64,7 @@ STATIC int __pimp_channel_get_volume(pimp_channel_state *chan)
chan->fadeout -= chan->instrument->volume_fadeout; chan->fadeout -= chan->instrument->volume_fadeout;
if (chan->fadeout <= 0) if (chan->fadeout <= 0)
{ {
// TODO: kill sample /* TODO: kill sample */
chan->fadeout = 0; chan->fadeout = 0;
} }
} }
...@@ -105,7 +105,7 @@ STATIC void __pimp_mod_context_update_row(pimp_mod_context *ctx) ...@@ -105,7 +105,7 @@ STATIC void __pimp_mod_context_update_row(pimp_mod_context *ctx)
if (note->note == KEY_OFF) if (note->note == KEY_OFF)
{ {
chan->sustain = FALSE; chan->sustain = FALSE;
volume_dirty = TRUE; // we need to update volume if note off killed note volume_dirty = TRUE; /* we need to update volume if note off killed note */
} }
else else
{ {
...@@ -136,7 +136,7 @@ STATIC void __pimp_mod_context_update_row(pimp_mod_context *ctx) ...@@ -136,7 +136,7 @@ STATIC void __pimp_mod_context_update_row(pimp_mod_context *ctx)
{ {
/* TODO: this should be handeled in the converter, and as an assert. */ /* TODO: this should be handeled in the converter, and as an assert. */
// stupid musician, tried to play an empty instrument... /* stupid musician, tried to play an empty instrument... */
mc->sample_data = NULL; mc->sample_data = NULL;
mc->sample_cursor = 0; mc->sample_cursor = 0;
mc->sample_cursor_delta = 0; mc->sample_cursor_delta = 0;
...@@ -172,7 +172,7 @@ STATIC void __pimp_mod_context_update_row(pimp_mod_context *ctx) ...@@ -172,7 +172,7 @@ STATIC void __pimp_mod_context_update_row(pimp_mod_context *ctx)
if (mc->sample_cursor > (mc->sample_length << 12)) if (mc->sample_cursor > (mc->sample_length << 12))
{ {
if (ctx->mod->flags & FLAG_SAMPLE_OFFSET_CLAMP) mc->sample_cursor = mc->sample_length << 12; if (ctx->mod->flags & FLAG_SAMPLE_OFFSET_CLAMP) mc->sample_cursor = mc->sample_length << 12;
else mc->sample_data = NULL; // kill sample else mc->sample_data = NULL; /* kill sample */
} }
} }
...@@ -213,12 +213,12 @@ $f0-$ff Tone porta ...@@ -213,12 +213,12 @@ $f0-$ff Tone porta
if (note->volume_command > 0x50) if (note->volume_command > 0x50)
{ {
/* something else */ /* something else */
DEBUG_PRINT(("unsupported volume-command %02X\n", note->volume_command)); DEBUG_PRINT(DEBUG_LEVEL_ERROR, ("unsupported volume-command %02X\n", note->volume_command));
} }
else else
{ {
chan->volume = note->volume_command - 0x10; chan->volume = note->volume_command - 0x10;
// DEBUG_PRINT(("setting volume to: %02X\n", chan->volume)); DEBUG_PRINT(DEBUG_LEVEL_INFO, ("setting volume to: %02X\n", chan->volume));
volume_dirty = TRUE; volume_dirty = TRUE;
} }
break; break;
...@@ -239,7 +239,7 @@ $f0-$ff Tone porta ...@@ -239,7 +239,7 @@ $f0-$ff Tone porta
default: default:
DEBUG_PRINT(("unsupported volume-command %02X\n", note->volume_command)); DEBUG_PRINT(DEBUG_LEVEL_ERROR, ("unsupported volume-command %02X\n", note->volume_command));
} }
switch (chan->effect) switch (chan->effect)
...@@ -257,7 +257,7 @@ $f0-$ff Tone porta ...@@ -257,7 +257,7 @@ $f0-$ff Tone porta
case EFF_PORTA_NOTE: case EFF_PORTA_NOTE:
if (note->note > 0) if (note->note > 0)
{ {
// no fine tune or relative note here, boooy /* no fine tune or relative note here, boooy */
if (ctx->mod->flags & FLAG_LINEAR_PERIODS) chan->porta_target = __pimp_get_linear_period(note->note + chan->sample->rel_note, 0); if (ctx->mod->flags & FLAG_LINEAR_PERIODS) chan->porta_target = __pimp_get_linear_period(note->note + chan->sample->rel_note, 0);
else chan->porta_target = __pimp_get_amiga_period(note->note, 0); else chan->porta_target = __pimp_get_amiga_period(note->note, 0);
...@@ -274,7 +274,7 @@ $f0-$ff Tone porta ...@@ -274,7 +274,7 @@ $f0-$ff Tone porta
/* TODO: move to a separate function ? */ /* TODO: move to a separate function ? */
if (note->note > 0) if (note->note > 0)
{ {
// no fine tune or relative note here, boooy /* no fine tune or relative note here, boooy */
if (ctx->mod->flags & FLAG_LINEAR_PERIODS) chan->porta_target = __pimp_get_linear_period(note->note + chan->sample->rel_note, 0); if (ctx->mod->flags & FLAG_LINEAR_PERIODS) chan->porta_target = __pimp_get_linear_period(note->note + chan->sample->rel_note, 0);
else chan->porta_target = __pimp_get_amiga_period(note->note, 0); else chan->porta_target = __pimp_get_amiga_period(note->note, 0);
...@@ -321,8 +321,8 @@ $f0-$ff Tone porta ...@@ -321,8 +321,8 @@ $f0-$ff Tone porta
case EFF_BREAK_ROW: case EFF_BREAK_ROW:
__pimp_mod_context_set_pos( __pimp_mod_context_set_pos(
ctx, ctx,
(chan->effect_param >> 4) * 10 + (chan->effect_param & 0xF) - 1, // row (chan->effect_param >> 4) * 10 + (chan->effect_param & 0xF) - 1, /* row */
ctx->curr_order + 1 // order ctx->curr_order + 1 /* order */
); );
break; break;
...@@ -363,7 +363,7 @@ $f0-$ff Tone porta ...@@ -363,7 +363,7 @@ $f0-$ff Tone porta
break; break;
default: default:
DEBUG_PRINT(("unsupported effect E%X\n", chan->effect_param >> 4)); DEBUG_PRINT(DEBUG_LEVEL_ERROR, ("unsupported effect E%X\n", chan->effect_param >> 4));
} }
break; break;
...@@ -380,7 +380,7 @@ $f0-$ff Tone porta ...@@ -380,7 +380,7 @@ $f0-$ff Tone porta
case EFF_PAN_SLIDE: break; case EFF_PAN_SLIDE: break;
*/ */
case EFF_MULTI_RETRIG: case EFF_MULTI_RETRIG:
if ((note->effect_parameter & 0xF0) != 0) DEBUG_PRINT(("multi retrig x-parameter != 0 not supported\n")); if ((note->effect_parameter & 0xF0) != 0) DEBUG_PRINT(DEBUG_LEVEL_ERROR, ("multi retrig x-parameter != 0 not supported\n"));
if ((note->effect_parameter & 0xF) != 0) chan->note_retrig = note->effect_parameter & 0xF; if ((note->effect_parameter & 0xF) != 0) chan->note_retrig = note->effect_parameter & 0xF;
break; break;
...@@ -397,7 +397,7 @@ $f0-$ff Tone porta ...@@ -397,7 +397,7 @@ $f0-$ff Tone porta
*/ */
default: default:
DEBUG_PRINT(("unsupported effect %02X\n", chan->effect));