bug fixes in drc, audio, display

This commit is contained in:
kub 2020-01-14 22:49:03 +01:00
parent 8ac9ab7fcb
commit b9bc876c9c
14 changed files with 130 additions and 93 deletions

View file

@ -703,8 +703,8 @@ static void add_to_hashlist(struct block_entry *be, int tcache_id)
#if (DRC_DEBUG & 2) #if (DRC_DEBUG & 2)
if (be->next != NULL) { if (be->next != NULL) {
printf(" %08x: entry hash collision with %08x\n", printf(" %08x@%p: entry hash collision with %08x@%p\n",
be->pc, be->next->pc); be->pc, be->tcache_ptr, be->next->pc, be->next->tcache_ptr);
hash_collisions++; hash_collisions++;
} }
#endif #endif
@ -5323,7 +5323,7 @@ int sh2_execute_drc(SH2 *sh2c, int cycles)
// TODO: irq cycles // TODO: irq cycles
ret_cycles = (int32_t)sh2c->sr >> 12; ret_cycles = (int32_t)sh2c->sr >> 12;
if (ret_cycles > 0) if (ret_cycles > 0)
dbg(1, "warning: drc returned with cycles: %d", ret_cycles); dbg(1, "warning: drc returned with cycles: %d, pc %08x", ret_cycles, sh2c->pc);
sh2c->sr &= 0x3f3; sh2c->sr &= 0x3f3;
return ret_cycles; return ret_cycles;
@ -5506,10 +5506,6 @@ void sh2_drc_mem_setup(SH2 *sh2)
sh2->p_drcblk_ram = Pico32xMem->drcblk_ram; sh2->p_drcblk_ram = Pico32xMem->drcblk_ram;
} }
void sh2_drc_frame(void)
{
}
int sh2_drc_init(SH2 *sh2) int sh2_drc_init(SH2 *sh2)
{ {
int i; int i;
@ -5716,8 +5712,6 @@ u16 scan_block(u32 base_pc, int is_slave, u8 *op_flags, u32 *end_pc_out,
else if ((lowest_mova && lowest_mova <= pc) || else if ((lowest_mova && lowest_mova <= pc) ||
(lowest_literal && lowest_literal <= pc)) (lowest_literal && lowest_literal <= pc))
break; // text area collides with data area break; // text area collides with data area
else if ((op_flags[i] & OF_BTARGET) && dr_get_entry(pc, is_slave, &i_end))
break; // branch target already compiled
op = FETCH_OP(pc); op = FETCH_OP(pc);
switch ((op & 0xf000) >> 12) switch ((op & 0xf000) >> 12)
@ -6497,9 +6491,6 @@ end:
last_btarget = 0; last_btarget = 0;
op = 0; // delay/poll insns counter op = 0; // delay/poll insns counter
for (i = 0, pc = base_pc; i < i_end; i++, pc += 2) { for (i = 0, pc = base_pc; i < i_end; i++, pc += 2) {
int null;
if ((op_flags[i] & OF_BTARGET) && dr_get_entry(pc, is_slave, &null))
break; // branch target already compiled
opd = &ops[i]; opd = &ops[i];
crc += FETCH_OP(pc); crc += FETCH_OP(pc);

View file

@ -6,7 +6,6 @@ void sh2_drc_wcheck_da(uint32_t a, unsigned len, SH2 *sh2);
#ifdef DRC_SH2 #ifdef DRC_SH2
void sh2_drc_mem_setup(SH2 *sh2); void sh2_drc_mem_setup(SH2 *sh2);
void sh2_drc_flush_all(void); void sh2_drc_flush_all(void);
void sh2_drc_frame(void);
#else #else
#define sh2_drc_mem_setup(x) #define sh2_drc_mem_setup(x)
#define sh2_drc_flush_all() #define sh2_drc_flush_all()

View file

@ -580,7 +580,6 @@ void PicoFrame32x(void)
PicoFrameStart(); PicoFrameStart();
PicoFrameHints(); PicoFrameHints();
sh2_drc_frame();
elprintf(EL_32X, "poll: %02x %02x %02x", elprintf(EL_32X, "poll: %02x %02x %02x",
Pico32x.emu_flags & 3, msh2.state, ssh2.state); Pico32x.emu_flags & 3, msh2.state, ssh2.state);

View file

@ -137,11 +137,15 @@ static void dmac_memcpy(struct dma_chan *chan, SH2 *sh2)
if (!up || chan->tcr < 4) if (!up || chan->tcr < 4)
return; return;
// XXX Mars Check Program fills a 64K buffer, then copies 32K longwords from #if MARS_CHECK_HACK
// DRAM to SDRAM in 4-longword mode, which is 128K. This overwrites a comm // XXX Mars Check Program copies 32K longwords (128KB) from a 64KB buffer in
// area in SDRAM, which is why the check fails. // ROM or DRAM to SDRAM in 4-longword mode, overwriting an SDRAM comm area in
// Is this a buswidth mismatch problem? As a kludge, usw 16-bit width xfers // turn, which crashes the test on emulators without CPU cache emulation.
if (size == 3 && (chan->sar & 0xdf000000) == 0x04000000) size = 1; // This may be a bug in Mars Check. As a kludge limit the transfer to 64KB,
// which is what the check program test uses for checking the result.
// A better way would clearly be to have a mechanism to patch the ROM...
if (size == 3 && chan->tcr == 32768 && chan->dar == 0x06020000) size = 1;
#endif
if (size == 3) size = 2; // 4-word xfer mode still counts in words if (size == 3) size = 2; // 4-word xfer mode still counts in words
// XXX check TCR being a multiple of 4 in 4-word xfer mode? // XXX check TCR being a multiple of 4 in 4-word xfer mode?
// XXX check alignment of sar/dar, generating a bus error if unaligned? // XXX check alignment of sar/dar, generating a bus error if unaligned?

View file

@ -157,6 +157,8 @@ static void DrawWindowFull(int start, int end, int prio, struct PicoEState *est)
{ {
nametab=(pvid->reg[3]&0x3e)<<9; // 32-cell mode nametab=(pvid->reg[3]&0x3e)<<9; // 32-cell mode
nametab_step = 1<<5; nametab_step = 1<<5;
if (!(PicoIn.opt&POPT_DIS_32C_BORDER))
scrpos += 32;
} }
nametab += nametab_step*start; nametab += nametab_step*start;
@ -240,6 +242,8 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,
else nametab=(pvid->reg[4]&0x07)<<12; // B else nametab=(pvid->reg[4]&0x07)<<12; // B
scrpos = est->Draw2FB; scrpos = est->Draw2FB;
if (!(pvid->reg[12]&1) && !(PicoIn.opt&POPT_DIS_32C_BORDER))
scrpos += 32;
scrpos+=8*LINE_WIDTH*(planestart-START_ROW); scrpos+=8*LINE_WIDTH*(planestart-START_ROW);
// Get vertical scroll value: // Get vertical scroll value:
@ -315,6 +319,8 @@ static void DrawTilesFromCacheF(int *hc, struct PicoEState *est)
short blank=-1; // The tile we know is blank short blank=-1; // The tile we know is blank
unsigned char *scrpos = est->Draw2FB, *pd = 0; unsigned char *scrpos = est->Draw2FB, *pd = 0;
if (!(Pico.video.reg[12]&1) && !(PicoIn.opt&POPT_DIS_32C_BORDER))
scrpos += 32;
// *hcache++ = code|(dx<<16)|(trow<<27); // cache it // *hcache++ = code|(dx<<16)|(trow<<27); // cache it
scrpos+=(*hc++)*LINE_WIDTH - START_ROW*LINE_WIDTH*8; scrpos+=(*hc++)*LINE_WIDTH - START_ROW*LINE_WIDTH*8;
@ -377,6 +383,8 @@ static void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est)
while(sy <= START_ROW*8) { sy+=8; tile+=tdeltay; height--; } while(sy <= START_ROW*8) { sy+=8; tile+=tdeltay; height--; }
scrpos = est->Draw2FB; scrpos = est->Draw2FB;
if (!(Pico.video.reg[12]&1) && !(PicoIn.opt&POPT_DIS_32C_BORDER))
scrpos += 32;
scrpos+=(sy-START_ROW*8)*LINE_WIDTH; scrpos+=(sy-START_ROW*8)*LINE_WIDTH;
for (; height > 0; height--, sy+=8, tile+=tdeltay) for (; height > 0; height--, sy+=8, tile+=tdeltay)
@ -502,6 +510,11 @@ static void DrawDisplayFull(void)
maxw = 264; maxcolc = 32; maxw = 264; maxcolc = 32;
} }
// 32C border for centering? (for asm)
est->rendstatus &= ~PDRAW_BORDER_32;
if ((est->rendstatus&PDRAW_32_COLS) && !(PicoIn.opt&POPT_DIS_32C_BORDER))
est->rendstatus |= PDRAW_BORDER_32;
// horizontal window? // horizontal window?
if ((win=pvid->reg[0x12])) if ((win=pvid->reg[0x12]))
{ {

View file

@ -414,7 +414,10 @@ DrawLayerFull:
ldr r11,[sp, #9*4] @ est ldr r11,[sp, #9*4] @ est
sub r4, r9, #(START_ROW<<24) sub r4, r9, #(START_ROW<<24)
ldr r7, [r11, #OFS_EST_rendstatus]
ldr r11, [r11, #OFS_EST_Draw2FB] ldr r11, [r11, #OFS_EST_Draw2FB]
tst r7, #0x100 @ H32 border mode?
addne r11, r11, #32
mov r4, r4, asr #24 mov r4, r4, asr #24
mov r7, #328*8 mov r7, #328*8
mla r11, r4, r7, r11 @ scrpos+=8*328*(planestart-START_ROW); mla r11, r4, r7, r11 @ scrpos+=8*328*(planestart-START_ROW);
@ -590,8 +593,11 @@ DrawTilesFromCacheF:
mov r9, #0xff000000 @ r9=prevcode=-1 mov r9, #0xff000000 @ r9=prevcode=-1
mvn r6, #0 @ r6=prevy=-1 mvn r6, #0 @ r6=prevy=-1
ldr r7, [r1, #OFS_EST_rendstatus]
ldr r4, [r1, #OFS_EST_Draw2FB] ldr r4, [r1, #OFS_EST_Draw2FB]
ldr r2, [r0], #4 @ read y offset ldr r2, [r0], #4 @ read y offset
tst r7, #0x100 @ H32 border mode?
addne r4, r4, #32
mov r7, #328 mov r7, #328
mla r2, r7, r2, r4 mla r2, r7, r2, r4
sub r12, r2, #(328*8*START_ROW) @ r12=scrpos sub r12, r2, #(328*8*START_ROW) @ r12=scrpos
@ -688,13 +694,18 @@ DrawWindowFull:
ldr r4, [r11, #OFS_Pico_video_reg+12] ldr r4, [r11, #OFS_Pico_video_reg+12]
mov r5, #1 @ nametab_step mov r5, #1 @ nametab_step
ldr r11, [r3, #OFS_EST_Draw2FB]
tst r4, #1 @ 40 cell mode? tst r4, #1 @ 40 cell mode?
andne r12, r12, #0xf000 @ 0x3c<<10 andne r12, r12, #0xf000 @ 0x3c<<10
andeq r12, r12, #0xf800
movne r5, r5, lsl #7 movne r5, r5, lsl #7
moveq r5, r5, lsl #6 @ nametab_step bne 0f
ldr r7, [r3, #OFS_EST_rendstatus]
and r12, r12, #0xf800
mov r5, r5, lsl #6 @ nametab_step
tst r7, #0x100
addne r11, r11, #32 @ center screen in H32 mode
and r4, r0, #0xff 0: and r4, r0, #0xff
mla r12, r5, r4, r12 @ nametab += nametab_step*start; mla r12, r5, r4, r12 @ nametab += nametab_step*start;
ldr r10, [r3, #OFS_EST_PicoMem_vram] ldr r10, [r3, #OFS_EST_PicoMem_vram]
@ -715,7 +726,6 @@ DrawWindowFull:
mov r9, #0xff000000 @ r9=prevcode=-1 mov r9, #0xff000000 @ r9=prevcode=-1
ldr r11, [r3, #OFS_EST_Draw2FB]
and r4, r0, #0xff and r4, r0, #0xff
add r11, r11, #328*8 add r11, r11, #328*8
sub r4, r4, #START_ROW sub r4, r4, #START_ROW
@ -915,8 +925,11 @@ DrawSpriteFull:
and r3, lr, #0x6000 and r3, lr, #0x6000
mov r3, r3, lsr #9 @ r3=pal=((code>>9)&0x30); mov r3, r3, lsr #9 @ r3=pal=((code>>9)&0x30);
ldr r0, [r1, #OFS_EST_rendstatus]
ldr r11, [r1, #OFS_EST_Draw2FB] ldr r11, [r1, #OFS_EST_Draw2FB]
ldr r10, [r1, #OFS_EST_PicoMem_vram] ldr r10, [r1, #OFS_EST_PicoMem_vram]
tst r0, #0x100 @ H32 border mode?
addne r11, r11, #32
sub r1, r12, #(START_ROW*8) sub r1, r12, #(START_ROW*8)
mov r0, #328 mov r0, #328
mla r11, r1, r0, r11 @ scrpos+=(sy-START_ROW*8)*328; mla r11, r1, r0, r11 @ scrpos+=(sy-START_ROW*8)*328;

View file

@ -204,6 +204,7 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est);
#define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3) #define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3)
#define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed #define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed
#define PDRAW_32_COLS (1<<8) // 32 column mode #define PDRAW_32_COLS (1<<8) // 32 column mode
#define PDRAW_BORDER_32 (1<<9) // center H32 in buffer (32 px border)
extern int rendstatus_old; extern int rendstatus_old;
extern int rendlines; extern int rendlines;

View file

@ -176,10 +176,10 @@ m16_32_s2_no_unal2:
@ filter out DC offset @ filter out DC offset
@ in=int_sample (max 20 bit), y=filter memory, r3=tmp @ in=int_sample (max 20 bit), y=filter memory, r3=tmp
.macro DCfilt in y .macro DCfilt in y
rsb r3, \y, \in, asl #12 @ fixpoint 20.12 rsb r3, \y, \in, lsl #12 @ fixpoint 20.12
add \y, \y, r3, asr #13 add \y, \y, r3, asr #13
sub \in, \in, \y, asr #12 sub r3, r3, r3, asr #2 @ reduce audio lvl some
sub \in, \in, \in, asr #2 @ reduce audio lvl some asr \in, r3, #12
.endm .endm
@ mix 32bit audio (with 16bits really used, upper bits indicate overflow) with normal 16 bit audio with left channel only @ mix 32bit audio (with 16bits really used, upper bits indicate overflow) with normal 16 bit audio with left channel only

View file

@ -38,7 +38,7 @@ static void dac_recalculate(void)
for(i = 0; i <= lines; i++) for(i = 0; i <= lines; i++)
{ {
dac_info[i] = ((pos+(1<<15)) >> 16); // round to nearest dac_info[i] = ((pos+0x8000) >> 16); // round to nearest
pos += Pico.snd.fm_mult; pos += Pico.snd.fm_mult;
} }
for (i = lines+1; i < sizeof(dac_info) / sizeof(dac_info[0]); i++) for (i = lines+1; i < sizeof(dac_info) / sizeof(dac_info[0]); i++)
@ -85,10 +85,10 @@ void PsndRerate(int preserve_state)
// calculate Pico.snd.len // calculate Pico.snd.len
Pico.snd.len = PicoIn.sndRate / target_fps; Pico.snd.len = PicoIn.sndRate / target_fps;
Pico.snd.len_e_add = ((PicoIn.sndRate - Pico.snd.len * target_fps) << 16) / target_fps; Pico.snd.len_e_add = ((PicoIn.sndRate - Pico.snd.len * target_fps) << 16) / target_fps;
Pico.snd.len_e_cnt = 0; Pico.snd.len_e_cnt = 0; // Q16
// samples per line // samples per line (Q16)
Pico.snd.fm_mult = 65536.0 * PicoIn.sndRate / (target_fps*target_lines); Pico.snd.fm_mult = 65536LL * PicoIn.sndRate / (target_fps*target_lines);
// recalculate dac info // recalculate dac info
dac_recalculate(); dac_recalculate();
@ -176,7 +176,7 @@ PICO_INTERNAL void PsndDoFM(int line_to)
int pos, len; int pos, len;
int stereo = 0; int stereo = 0;
// Q16, number of samples to fill in buffer // Q16, number of samples since last call
len = ((line_to-1) * Pico.snd.fm_mult) - Pico.snd.fm_pos; len = ((line_to-1) * Pico.snd.fm_mult) - Pico.snd.fm_pos;
// don't do this too often (no more than 256 per sec) // don't do this too often (no more than 256 per sec)
@ -184,9 +184,9 @@ PICO_INTERNAL void PsndDoFM(int line_to)
return; return;
// update position and calculate buffer offset and length // update position and calculate buffer offset and length
pos = Pico.snd.fm_pos >> 16; pos = (Pico.snd.fm_pos+0x8000) >> 16;
Pico.snd.fm_pos += len; Pico.snd.fm_pos += len;
len = (Pico.snd.fm_pos >> 16) - pos; len = ((Pico.snd.fm_pos+0x8000) >> 16) - pos;
// fill buffer // fill buffer
if (PicoIn.opt & POPT_EN_STEREO) { if (PicoIn.opt & POPT_EN_STEREO) {
@ -195,8 +195,6 @@ PICO_INTERNAL void PsndDoFM(int line_to)
} }
if (PicoIn.opt & POPT_EN_FM) if (PicoIn.opt & POPT_EN_FM)
YM2612UpdateOne(PsndBuffer + pos, len, stereo, 1); YM2612UpdateOne(PsndBuffer + pos, len, stereo, 1);
else
memset32(PsndBuffer + pos, 0, len<<stereo);
} }
// cdda // cdda
@ -258,6 +256,8 @@ PICO_INTERNAL void PsndClear(void)
memset32((int *) out, 0, len/2); memset32((int *) out, 0, len/2);
if (len & 1) out[len-1] = 0; if (len & 1) out[len-1] = 0;
} }
if (!(PicoIn.opt & POPT_EN_FM))
memset32(PsndBuffer, 0, PicoIn.opt & POPT_EN_STEREO ? len*2 : len);
} }
@ -265,7 +265,7 @@ static int PsndRender(int offset, int length)
{ {
int *buf32; int *buf32;
int stereo = (PicoIn.opt & 8) >> 3; int stereo = (PicoIn.opt & 8) >> 3;
int fmlen = (Pico.snd.fm_pos >> 16) - offset; int fmlen = ((Pico.snd.fm_pos+0x8000) >> 16) - offset;
offset <<= stereo; offset <<= stereo;
buf32 = PsndBuffer+offset; buf32 = PsndBuffer+offset;
@ -282,15 +282,11 @@ static int PsndRender(int offset, int length)
int *fmbuf = buf32 + (fmlen << stereo); int *fmbuf = buf32 + (fmlen << stereo);
if (PicoIn.opt & POPT_EN_FM) if (PicoIn.opt & POPT_EN_FM)
YM2612UpdateOne(fmbuf, length-fmlen, stereo, 1); YM2612UpdateOne(fmbuf, length-fmlen, stereo, 1);
else
memset32(fmbuf, 0, (length-fmlen)<<stereo);
Pico.snd.fm_pos += (length-fmlen)<<16;
} }
// CD: PCM sound // CD: PCM sound
if (PicoIn.AHW & PAHW_MCD) { if (PicoIn.AHW & PAHW_MCD) {
pcd_pcm_update(buf32, length, stereo); pcd_pcm_update(buf32, length, stereo);
//buf32_updated = 1;
} }
// CD: CDDA audio // CD: CDDA audio

View file

@ -564,7 +564,7 @@ INLINE void FM_KEYON(int c , int s )
SLOT->ssg ^= SLOT->ssgn; SLOT->ssg ^= SLOT->ssgn;
SLOT->ssgn = 0; SLOT->ssgn = 0;
SLOT->state = (SLOT->sl == MIN_ATT_INDEX) ? EG_SUS : EG_DEC; SLOT->state = (SLOT->sl == MIN_ATT_INDEX) ? EG_SUS : EG_DEC;
if (SLOT->ar + SLOT->ksr < 32+62) { if (SLOT->ar_ksr < 32+62) {
if (SLOT->volume > MIN_ATT_INDEX) SLOT->state = EG_ATT; if (SLOT->volume > MIN_ATT_INDEX) SLOT->state = EG_ATT;
} else { } else {
SLOT->volume = MIN_ATT_INDEX; SLOT->volume = MIN_ATT_INDEX;
@ -619,6 +619,7 @@ INLINE void set_ar_ksr(FM_CH *CH, FM_SLOT *SLOT, int v)
int eg_sh_ar, eg_sel_ar; int eg_sh_ar, eg_sel_ar;
SLOT->ar = (v&0x1f) ? 32 + ((v&0x1f)<<1) : 0; SLOT->ar = (v&0x1f) ? 32 + ((v&0x1f)<<1) : 0;
SLOT->ar_ksr = SLOT->ar + SLOT->ksr;
SLOT->KSR = 3-(v>>6); SLOT->KSR = 3-(v>>6);
if (SLOT->KSR != old_KSR) if (SLOT->KSR != old_KSR)
@ -627,10 +628,10 @@ INLINE void set_ar_ksr(FM_CH *CH, FM_SLOT *SLOT, int v)
} }
/* refresh Attack rate */ /* refresh Attack rate */
if ((SLOT->ar + SLOT->ksr) < 32+62) if ((SLOT->ar_ksr) < 32+62)
{ {
eg_sh_ar = eg_rate_shift [SLOT->ar + SLOT->ksr ]; eg_sh_ar = eg_rate_shift [SLOT->ar_ksr];
eg_sel_ar = eg_rate_select[SLOT->ar + SLOT->ksr ]; eg_sel_ar = eg_rate_select[SLOT->ar_ksr];
} }
else else
{ {
@ -872,7 +873,7 @@ INLINE void update_ssg_eg_phase(FM_SLOT *SLOT)
if (SLOT->state != EG_ATT) { if (SLOT->state != EG_ATT) {
SLOT->state = (SLOT->sl == MIN_ATT_INDEX) ? EG_SUS : EG_DEC; SLOT->state = (SLOT->sl == MIN_ATT_INDEX) ? EG_SUS : EG_DEC;
if (SLOT->ar + SLOT->ksr < 32+62) { if (SLOT->ar_ksr < 32+62) {
if (SLOT->volume > MIN_ATT_INDEX) SLOT->state = EG_ATT; if (SLOT->volume > MIN_ATT_INDEX) SLOT->state = EG_ATT;
} else { } else {
SLOT->volume = MIN_ATT_INDEX; SLOT->volume = MIN_ATT_INDEX;
@ -972,7 +973,7 @@ static void chan_render_loop(chan_rend_context *ct, int *buffer, int length)
ct->vol_out3 = (SLOT->vol_ipol*ifrac1 + SLOT->vol_out*ifrac0) >> EG_SH; ct->vol_out3 = (SLOT->vol_ipol*ifrac1 + SLOT->vol_out*ifrac0) >> EG_SH;
SLOT = &ct->CH->SLOT[SLOT4]; SLOT = &ct->CH->SLOT[SLOT4];
ct->vol_out4 = (SLOT->vol_ipol*ifrac1 + SLOT->vol_out*ifrac0) >> EG_SH; ct->vol_out4 = (SLOT->vol_ipol*ifrac1 + SLOT->vol_out*ifrac0) >> EG_SH;
#else #elif 1
switch (ct->eg_timer >> EG_SH) switch (ct->eg_timer >> EG_SH)
{ {
case 0: case 0:
@ -997,6 +998,23 @@ static void chan_render_loop(chan_rend_context *ct, int *buffer, int length)
ct->vol_out4 = (ct->CH->SLOT[SLOT4].vol_ipol + ct->vol_out4 = (ct->CH->SLOT[SLOT4].vol_ipol +
ct->CH->SLOT[SLOT4].vol_out) >> 1; ct->CH->SLOT[SLOT4].vol_out) >> 1;
} }
#elif 0
if (ct->eg_timer >> (EG_SH-1) < EG_TIMER_OVERFLOW >> EG_SH) {
ct->vol_out1 = ct->CH->SLOT[SLOT1].vol_ipol;
ct->vol_out2 = ct->CH->SLOT[SLOT2].vol_ipol;
ct->vol_out3 = ct->CH->SLOT[SLOT3].vol_ipol;
ct->vol_out4 = ct->CH->SLOT[SLOT4].vol_ipol;
} else {
ct->vol_out1 = ct->CH->SLOT[SLOT1].vol_out;
ct->vol_out2 = ct->CH->SLOT[SLOT2].vol_out;
ct->vol_out3 = ct->CH->SLOT[SLOT3].vol_out;
ct->vol_out4 = ct->CH->SLOT[SLOT4].vol_out;
}
#else
ct->vol_out1 = ct->CH->SLOT[SLOT1].vol_out;
ct->vol_out2 = ct->CH->SLOT[SLOT2].vol_out;
ct->vol_out3 = ct->CH->SLOT[SLOT3].vol_out;
ct->vol_out4 = ct->CH->SLOT[SLOT4].vol_out;
#endif #endif
if (ct->pack & 4) continue; /* output disabled */ if (ct->pack & 4) continue; /* output disabled */
@ -1335,12 +1353,13 @@ INLINE void refresh_fc_eg_slot(FM_SLOT *SLOT, int fc, int kc)
{ {
int eg_sh, eg_sel; int eg_sh, eg_sel;
SLOT->ksr = ksr; SLOT->ksr = ksr;
SLOT->ar_ksr = SLOT->ar + ksr;
/* calculate envelope generator rates */ /* calculate envelope generator rates */
if ((SLOT->ar + ksr) < 32+62) if ((SLOT->ar_ksr) < 32+62)
{ {
eg_sh = eg_rate_shift [SLOT->ar + ksr ]; eg_sh = eg_rate_shift [SLOT->ar_ksr];
eg_sel = eg_rate_select[SLOT->ar + ksr ]; eg_sel = eg_rate_select[SLOT->ar_ksr];
} }
else else
{ {

View file

@ -56,8 +56,9 @@ typedef struct
UINT8 ssg; /* 0x30 SSG-EG waveform */ UINT8 ssg; /* 0x30 SSG-EG waveform */
UINT8 ssgn; UINT8 ssgn;
UINT16 vol_out; /* 0x32 current output from EG (without LFO) */ UINT16 ar_ksr; /* 0x32 ar+ksr */
UINT16 vol_ipol; /* 0x34 interpolator memory */ UINT16 vol_out; /* 0x34 current output from EG (without LFO) */
UINT16 vol_ipol; /* 0x36 interpolator memory */
} FM_SLOT; } FM_SLOT;

View file

@ -42,10 +42,10 @@
@ r5=slot, r1=eg_cnt, trashes: r0,r2,r3 @ r5=slot, r1=eg_cnt, trashes: r0,r2,r3
@ writes output to routp, but only if vol_out changes @ writes output to routp, but only if vol_out changes
.macro update_eg_phase_slot slot .macro update_eg_phase_slot slot
ldrh r0, [r5,#0x32] @ vol_out ldrh r0, [r5,#0x34] @ vol_out
ldrb r2, [r5,#0x17] @ state ldrb r2, [r5,#0x17] @ state
add r3, r5, #0x1c add r3, r5, #0x1c
strh r0, [r5,#0x34] @ vol_ipol strh r0, [r5,#0x36] @ vol_ipol
tst r2, r2 tst r2, r2
beq 0f @ EG_OFF beq 0f @ EG_OFF
@ -182,7 +182,7 @@
11: 11:
ldrh r3, [r5,#0x18] @ tl ldrh r3, [r5,#0x18] @ tl
add r0, r0, r3 @ volume += tl add r0, r0, r3 @ volume += tl
strh r0, [r5,#0x32] @ vol_out strh r0, [r5,#0x34] @ vol_out
.if \slot == SLOT1 .if \slot == SLOT1
mov r6, r6, lsr #16 mov r6, r6, lsr #16
orr r6, r0, r6, lsl #16 orr r6, r0, r6, lsl #16
@ -207,11 +207,9 @@
ldrh r0, [r5,#0x30] @ ssg+ssgn ldrh r0, [r5,#0x30] @ ssg+ssgn
ldrb r2, [r5,#0x17] @ state ldrb r2, [r5,#0x17] @ state
ldrh r3, [r5,#0x1a] @ volume ldrh r3, [r5,#0x1a] @ volume
tst r0, #0x08 @ ssg enabled? cmp r0, #0x08 @ ssg enabled &&
beq 9f cmpge r2, #EG_REL+1 @ state > EG_REL &&
cmp r2, #EG_REL @ state > EG_REL? cmpge r3, #0x200 @ volume >= 0x200?
ble 9f
cmp r3, #0x200 @ volume >= 0x200?
blt 9f blt 9f
tst r0, #0x01 tst r0, #0x01
@ -226,35 +224,33 @@
eor r0, r0, #0x4 @ if ( !(ssg&0x04 ) eor r0, r0, #0x4 @ if ( !(ssg&0x04 )
tst r0, #0x4 tst r0, #0x4
cmpne r2, #EG_ATT @ if ( state != EG_ATT ) cmpne r2, #EG_ATT @ if ( state != EG_ATT )
movne r0, #0x400 movne r3, #0x400
subne r0, r0, #1 subne r3, r3, #1
strneh r0, [r5,#0x1a] @ volume = MAX_ATT strneh r3, [r5,#0x1a] @ volume = MAX_ATT
b 9f b 9f
1: tst r0, #0x02 1: tst r0, #0x02
eorne r0, r0, #0x4 @ ssg ^= 4 eorne r0, r0, #0x4 @ ssg ^= 4
eorne r0, r0, #0x400 @ ssgn ^= 4 eorne r0, r0, #0x400 @ ssgn ^= 4
strneh r0, [r5,#0x30] strneh r0, [r5,#0x30]
moveq r3, #0 moveq r0, #0
streq r3, [r5,#0x0c] @ phase = 0 streq r0, [r5,#0x0c] @ phase = 0
cmp r2, #EG_ATT @ if ( state != EG_ATT ) cmp r2, #EG_ATT @ if ( state != EG_ATT )
beq 9f beq 9f
ldr r3, [r5,#0x1c] @ sl ldr r0, [r5,#0x1c] @ sl
mov r2, #EG_SUS @ state = sl==MIN_ATT ? EG_SUS:EG_DEC mov r2, #EG_SUS @ state = sl==MIN_ATT ? EG_SUS:EG_DEC
cmp r3, #0
ldr r0, [r5,#0x04] @ ar
ldr r3, [r5,#0x14] @ ksr
movne r2, #EG_DEC
add r0, r0, r3
cmp r0, #32+62 @ if ( ar+ksr >= 32+62 )
ldrlt r0, [r5,#0x1a]
movge r0, #0
strgeh r0, [r5,#0x1a] @ volume = MIN_ATT
cmp r0, #0 cmp r0, #0
ldrh r0, [r5,#0x32] @ ar+ksr
movne r2, #EG_DEC
cmp r0, #32+62 @ if ( ar+ksr >= 32+62 )
movge r3, #0
strgeh r3, [r5,#0x1a] @ volume = MIN_ATT
bge 9f
cmp r3, #0
movgt r2, #EG_ATT movgt r2, #EG_ATT
strb r2, [r5,#0x17] @ state strb r2, [r5,#0x17] @ state
9: 9:
@ -673,10 +669,10 @@ chan_render_loop:
ldr r10, [lr, #0x54] @ op1_out ldr r10, [lr, #0x54] @ op1_out
@ ldmia lr, {r6,r7} @ load volumes @ ldmia lr, {r6,r7} @ load volumes
ldr r5, [lr, #0x40] @ CH ldr r5, [lr, #0x40] @ CH
ldrh r6, [r5, #0x32] @ vol_out values for all slots ldrh r6, [r5, #0x34] @ vol_out values for all slots
ldrh r2, [r5, #0x32+SLOT_STRUCT_SIZE*2] ldrh r2, [r5, #0x34+SLOT_STRUCT_SIZE*2]
ldrh r7, [r5, #0x32+SLOT_STRUCT_SIZE] ldrh r7, [r5, #0x34+SLOT_STRUCT_SIZE]
ldrh r3, [r5, #0x32+SLOT_STRUCT_SIZE*3] ldrh r3, [r5, #0x34+SLOT_STRUCT_SIZE*3]
orr r6, r6, r2, lsl #16 orr r6, r6, r2, lsl #16
orr r7, r7, r3, lsl #16 orr r7, r7, r3, lsl #16
@ -756,28 +752,28 @@ eg_done:
cmp r3, #(EG_TIMER_OVERFLOW>>EG_SH)/2 cmp r3, #(EG_TIMER_OVERFLOW>>EG_SH)/2
bgt 0f @ mix is vol_out bgt 0f @ mix is vol_out
ldrh r0, [r5,#0x34] @ SLOT1 vol_ipol ldrh r0, [r5,#0x36] @ SLOT1 vol_ipol
lsleq r2, r6, #16 lsleq r2, r6, #16
addeq r0, r0, r2, lsr #16 addeq r0, r0, r2, lsr #16
lsreq r0, r0, #1 lsreq r0, r0, #1
mov r6, r6, lsr #16 mov r6, r6, lsr #16
orr r6, r0, r6, lsl #16 orr r6, r0, r6, lsl #16
ldrh r0, [r5,#0x34+SLOT_STRUCT_SIZE*2] @ SLOT2 vol_ipol ldrh r0, [r5,#0x36+SLOT_STRUCT_SIZE*2] @ SLOT2 vol_ipol
addeq r0, r0, r6, lsr #16 addeq r0, r0, r6, lsr #16
lsreq r0, r0, #1 lsreq r0, r0, #1
mov r6, r6, lsl #16 mov r6, r6, lsl #16
orr r6, r6, r0 orr r6, r6, r0
ror r6, r6, #16 ror r6, r6, #16
ldrh r0, [r5,#0x34+SLOT_STRUCT_SIZE] @ SLOT3 vol_ipol ldrh r0, [r5,#0x36+SLOT_STRUCT_SIZE] @ SLOT3 vol_ipol
lsleq r2, r7, #16 lsleq r2, r7, #16
addeq r0, r0, r2, lsr #16 addeq r0, r0, r2, lsr #16
lsreq r0, r0, #1 lsreq r0, r0, #1
mov r7, r7, lsr #16 mov r7, r7, lsr #16
orr r7, r0, r7, lsl #16 orr r7, r0, r7, lsl #16
ldrh r0, [r5,#0x34+SLOT_STRUCT_SIZE*3] @ SLOT4 vol_ipol ldrh r0, [r5,#0x36+SLOT_STRUCT_SIZE*3] @ SLOT4 vol_ipol
addeq r0, r0, r7, lsr #16 addeq r0, r0, r7, lsr #16
lsreq r0, r0, #1 lsreq r0, r0, #1
mov r7, r7, lsl #16 mov r7, r7, lsl #16
@ -787,22 +783,22 @@ eg_done:
@ super-basic... just take value closest to sample point @ super-basic... just take value closest to sample point
mov r3, r8, lsr #EG_SH-1 @ eg_timer, [0..3<<EG_SH) after loop mov r3, r8, lsr #EG_SH-1 @ eg_timer, [0..3<<EG_SH) after loop
cmp r3, #(EG_TIMER_OVERFLOW>>EG_SH) cmp r3, #(EG_TIMER_OVERFLOW>>EG_SH)
bgt 0f @ mix is vol_out bge 0f @ mix is vol_out
ldrh r0, [r5,#0x34] @ SLOT1 vol_ipol ldrh r0, [r5,#0x36] @ SLOT1 vol_ipol
mov r6, r6, lsr #16 mov r6, r6, lsr #16
orr r6, r0, r6, lsl #16 orr r6, r0, r6, lsl #16
ldrh r0, [r5,#0x34+SLOT_STRUCT_SIZE*2] @ SLOT2 vol_ipol ldrh r0, [r5,#0x36+SLOT_STRUCT_SIZE*2] @ SLOT2 vol_ipol
mov r6, r6, lsl #16 mov r6, r6, lsl #16
orr r6, r6, r0 orr r6, r6, r0
ror r6, r6, #16 ror r6, r6, #16
ldrh r0, [r5,#0x34+SLOT_STRUCT_SIZE] @ SLOT3 vol_ipol ldrh r0, [r5,#0x36+SLOT_STRUCT_SIZE] @ SLOT3 vol_ipol
mov r7, r7, lsr #16 mov r7, r7, lsr #16
orr r7, r0, r7, lsl #16 orr r7, r0, r7, lsl #16
ldrh r0, [r5,#0x34+SLOT_STRUCT_SIZE*3] @ SLOT4 vol_ipol ldrh r0, [r5,#0x36+SLOT_STRUCT_SIZE*3] @ SLOT4 vol_ipol
mov r7, r7, lsl #16 mov r7, r7, lsl #16
orr r7, r7, r0 orr r7, r7, r0
ror r7, r7, #16 ror r7, r7, #16

View file

@ -368,10 +368,12 @@ int dismips(uintptr_t pc, uint32_t insn, char *buf, size_t buflen, unsigned long
else else
snprintf(buf, buflen, "%s %s, %s, %d", pi->name, rd, rt, sa); snprintf(buf, buflen, "%s %s, %s, %d", pi->name, rd, rt, sa);
break; break;
//dext: pos,size-1 dextm: pos,size-33 dextu: pos-32,size-1
//dins: pos,pos+size-1 dinsm: pos,pos+size-33 dinsu: pos-32,pos+size-33
case F_IMM_TS: case F_IMM_TS:
if (insn & 0x01) sb+=32; if (insn & 0x01) sb+=32; // ...m
if (insn & 0x02) sa+=32; if (insn & 0x02) sa+=32; // ...u
if (insn & 0x04) sb-=sa; if (insn & 0x04) sb-=sa; // ins
snprintf(buf, buflen, "%s %s, %s, %d, %d", pi->name, rt, rs, sa, sb+1); snprintf(buf, buflen, "%s %s, %s, %d, %d", pi->name, rt, rs, sa, sb+1);
break; break;
case B_IMM_S: case B_IMM_S:

View file

@ -176,7 +176,10 @@ void plat_debug_cat(char *str)
void emu_video_mode_change(int start_line, int line_count, int is_32cols) void emu_video_mode_change(int start_line, int line_count, int is_32cols)
{ {
// clear whole screen in all buffers // clear whole screen in all buffers
memset32(g_screen_ptr, 0, g_screen_ppitch * g_screen_height * 2 / 4); if (currentConfig.renderer != RT_16BIT && !(PicoIn.AHW & PAHW_32X))
memset32(Pico.est.Draw2FB, 0, (320+8) * (8+240+8) / 4);
else
memset32(g_screen_ptr, 0, g_screen_ppitch * g_screen_height * 2 / 4);
} }
void pemu_loop_prep(void) void pemu_loop_prep(void)