Skip to content

Commit

Permalink
bfsoundlib: Moved some variables from ASM to C
Browse files Browse the repository at this point in the history
  • Loading branch information
mefistotelis committed Jun 30, 2024
1 parent 759f20e commit 24f5f87
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
19 changes: 14 additions & 5 deletions bfsoundlib/src/ailss.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@ enum SampleFileTypes {

static int32_t SS_use_locked;

extern uint8_t byte_15AA50[128];
static const uint8_t volume_pan_table[128] = {
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30,
32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62,
64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94,
96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
};

/******************************************************************************/

Expand Down Expand Up @@ -88,8 +97,8 @@ void SS_build_amplitude_tables(SNDSAMPLE *s)

vscale0 = s->vol_scale[0];
vscale1 = s->vol_scale[1];
vamp1 = byte_15AA50[s->pan];
vamp0 = byte_15AA50[127 - s->pan];
vamp1 = volume_pan_table[s->pan];
vamp0 = volume_pan_table[127 - s->pan];

vscale0[0] = final_volume * vamp0 / 127;
vscale1[0] = final_volume * vamp1 / 127;
Expand Down Expand Up @@ -145,8 +154,8 @@ void SS_build_amplitude_tables(SNDSAMPLE *s)

vscale0 = s->vol_scale[0];
vscale1 = s->vol_scale[1];
vamp1 = byte_15AA50[s->pan];
vamp0 = byte_15AA50[127 - s->pan];
vamp1 = volume_pan_table[s->pan];
vamp0 = volume_pan_table[127 - s->pan];
if (s->flags & DIG_PCM_SIGN)
{
nxval = 0;
Expand Down
14 changes: 7 additions & 7 deletions bfsoundlib/src/mssxmidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ int32_t MDI_sequence_done;

static uint32_t XMI_serve_entry = 0;

extern char GTL_prefix[128];
char GTL_prefix[128] = "SAMPLE";
extern char SoundDriverPath[144];

extern MDI_DRIVER *MDI_first;
extern uint32_t MDI_entry;
extern int32_t MDI_locked;
uint32_t MDI_entry = 0;
int32_t MDI_use_locked = 0;

/******************************************************************************/

Expand All @@ -61,7 +61,7 @@ void AILXMIDI_end(void);
*/
void AILXMIDI_start(void)
{
if (MDI_locked)
if (MDI_use_locked)
return;
AIL_VMM_lock_range(AILXMIDI_start, AILXMIDI_end);

Expand All @@ -81,7 +81,7 @@ void AILXMIDI_start(void)
AIL_vmm_lock(&MDI_ptr, sizeof(MDI_ptr));
AIL_vmm_lock(&MDI_event, sizeof(MDI_event));

MDI_locked = 1;
MDI_use_locked = 1;
}

/** Initialize state table entries.
Expand Down Expand Up @@ -2285,7 +2285,7 @@ void AIL2OAL_API_send_channel_voice_message(MDI_DRIVER *mdidrv, SNDSEQUENCE *seq
*/
void AILXMIDI_end(void)
{
if (!MDI_locked)
if (!MDI_use_locked)
return;
AIL_VMM_unlock_range(AILXMIDI_start, AILXMIDI_end);

Expand All @@ -2305,7 +2305,7 @@ void AILXMIDI_end(void)
AIL_vmm_unlock(&MDI_ptr, sizeof(MDI_ptr));
AIL_vmm_unlock(&MDI_event, sizeof(MDI_event));

MDI_locked = 0;
MDI_use_locked = 0;
}

/******************************************************************************/
1 change: 0 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ swars_SOURCES = \
bflib_render_gpoly_s.sx \
bflib_render_plin_s.sx \
bflib_render_drspr_s.sx \
bflib_sndlib_s.sx \
bflib_snd_mss_s.sx \
bflib_vidraw.c \
bflib_vidraw.h \
Expand Down
2 changes: 1 addition & 1 deletion src/bflib_sndlib_s.sx
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ AILXMIDI_end_:
.data


GLOBAL (byte_15AA50) /* 0x15AA50 */
GLOBAL (volume_pan_table) /* 0x15AA50 */
.ascii "\x00\x02\x04\x06\x08\x0a\x0c\x0e"
.ascii "\x10\x12\x14\x16\x18\x1a\x1c\x1e"
.ascii " \"$&(*,.02468:<>@BDFHJLNPRTVXZ\\^`bdfhjlnprtvxz|"
Expand Down

0 comments on commit 24f5f87

Please sign in to comment.