Skip to content

Commit

Permalink
Revert the mixer patching code
Browse files Browse the repository at this point in the history
  • Loading branch information
viciious committed Aug 7, 2023
1 parent 8a20ada commit f0801ea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 61 deletions.
5 changes: 0 additions & 5 deletions marshw.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ int Mars_GetWDTCount(void);

#endif

#define Mars_PatchRAMCode(loc,inst) do {\
__asm volatile("mov.w %0, %1\n\t" : : "r"(inst), "m"(loc) : "memory"); \
Mars_ClearCacheLine(loc); \
} while(0)

uint16_t *Mars_FrameBufferLines(void);

#define Mars_IsPAL() ((MARS_VDP_DISPMODE & MARS_NTSC_FORMAT) == 0)
Expand Down
53 changes: 6 additions & 47 deletions marssound.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ static marsrb_t soundcmds = { 0 };

VINT sfxdriver = 0, mcd_avail = 0; // 0 - auto, 2 - megacd, 2 - 32x

extern uintptr_t paintchan_movr5r1;
extern uintptr_t paintchan_movr5r1_ima;
extern uintptr_t paintchan_movr5r1_ima2x_1, paintchan_movr5r1_ima2x_2;

static sfxchannel_t *S_AllocateChannel(mobj_t* mobj, unsigned sound_id, int vol, getsoundpos_t getpos);
static void S_SetChannelData(sfxchannel_t* channel);
int S_PaintChannel4IMA(void* mixer, int16_t* buffer, int32_t cnt, int32_t scale) ATTR_DATA_CACHE_ALIGN;
Expand Down Expand Up @@ -727,24 +723,9 @@ static void S_UpdatePCM(void)

static int S_PaintChannel(sfxchannel_t *ch, int16_t* buffer, int painted)
{
boolean patch;
const int mov0r1 = 0xE100;
const int movpr5r1 = 0x6152;
const int movp4r5r1 = 0x5151;

if (!ch->data)
return 0;

patch = painted == 0;
if (patch)
{
/* PATCH */
Mars_PatchRAMCode(paintchan_movr5r1, mov0r1); /* mov #0,r1 */
Mars_PatchRAMCode(paintchan_movr5r1_ima, mov0r1); /* mov #0,r1 */
Mars_PatchRAMCode(paintchan_movr5r1_ima2x_1, mov0r1); /* mov #0,r1 */
Mars_PatchRAMCode(paintchan_movr5r1_ima2x_2, mov0r1); /* mov #0,r1 */
}

if (ch->width == 4)
{
int i = MAX_SAMPLES;
Expand Down Expand Up @@ -807,25 +788,6 @@ static int S_PaintChannel(sfxchannel_t *ch, int16_t* buffer, int painted)
painted = MAX_SAMPLES;
}

if (patch)
{
int j;
int32_t *b2;

/* PATCH BACK */
Mars_PatchRAMCode(paintchan_movr5r1, movpr5r1); /* mov @r5,r1 */
Mars_PatchRAMCode(paintchan_movr5r1_ima, movpr5r1); /* mov @r5,r1 */
Mars_PatchRAMCode(paintchan_movr5r1_ima2x_1, movpr5r1); /* mov @r5,r1 */
Mars_PatchRAMCode(paintchan_movr5r1_ima2x_2, movp4r5r1); /* mov @(4,r5),r1 */

/* clear the remaining buffer */
b2 = (int32_t *)buffer + painted;
for (j = painted; j < MAX_SAMPLES; j++)
{
*b2++ = 0;
}
}

return painted;
}

Expand Down Expand Up @@ -875,6 +837,12 @@ static void S_Update(int16_t* buffer)
return;
}

b2 = (int32_t *)buffer;
for (i = 0; i < MAX_SAMPLES; i++)
{
*b2++ = 0;
}

/* keep updating the channel until done */
painted += S_PaintChannel(&pcmchannel, buffer, painted);

Expand Down Expand Up @@ -912,15 +880,6 @@ static void S_Update(int16_t* buffer)
}
}

// clear the buffer if we painted nothing
if (!painted)
{
b2 = (int32_t *)buffer;
for (i = 0; i < MAX_SAMPLES; i++)
{
*b2++ = 0;
}
}
if (samplecount >= SPATIALIZATION_SRATE)
samplecount -= SPATIALIZATION_SRATE;
samplecount += MAX_SAMPLES;
Expand Down
9 changes: 0 additions & 9 deletions sh2_mixer.s
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ mix_loop:
/* scale sample for left output */
muls.w r3,r13
add r10,r9 /* position += increment */
.global _paintchan_movr5r1
_paintchan_movr5r1:
mov.l @r5,r1
sts macl,r0

/* scale sample for right output */
Expand Down Expand Up @@ -261,8 +258,6 @@ mix4_gets:

/* scale sample for left output */
muls.w r12,r13
.global _paintchan_movr5r1_ima
_paintchan_movr5r1_ima:
mov.l @r5,r1
add r10,r9 /* position += increment */
sts macl,r0
Expand Down Expand Up @@ -444,8 +439,6 @@ mix4_gets2x:

/* scale sample for left output */
muls.w r12,r13
.global _paintchan_movr5r1_ima2x_1
_paintchan_movr5r1_ima2x_1:
mov.l @r5,r1
dt r6
add r10,r9 /* position += increment */
Expand All @@ -468,8 +461,6 @@ _paintchan_movr5r1_ima2x_1:
add r3,r1
mov.l r1,@r5

.global _paintchan_movr5r1_ima2x_2
_paintchan_movr5r1_ima2x_2:
mov.l @(4,r5),r1
cmp/hs r11,r9
add r3,r1
Expand Down

0 comments on commit f0801ea

Please sign in to comment.