32x: preliminary PWM implementation. 32x opts in menu

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@790 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2009-09-22 19:38:49 +00:00
parent 5e128c6d27
commit db1d3564e6
16 changed files with 256 additions and 46 deletions

View file

@ -135,12 +135,15 @@ static __inline void SekRunM68k(int cyc)
void PicoFrame32x(void) void PicoFrame32x(void)
{ {
pwm_frame_smp_cnt = 0;
Pico32x.vdp_regs[0x0a/2] &= ~P32XV_VBLK; // get out of vblank Pico32x.vdp_regs[0x0a/2] &= ~P32XV_VBLK; // get out of vblank
if ((Pico32x.vdp_regs[0] & 3 ) != 0) // no forced blanking if ((Pico32x.vdp_regs[0] & P32XV_Mx) != 0) // no forced blanking
Pico32x.vdp_regs[0x0a/2] &= ~P32XV_PEN; // no pal access Pico32x.vdp_regs[0x0a/2] &= ~P32XV_PEN; // no palette access
p32x_poll_event(1); p32x_poll_event(1);
PicoFrameStart(); PicoFrameStart();
PicoFrameHints(); PicoFrameHints();
} }

View file

@ -123,7 +123,6 @@ static void dma_68k2sh2_do(void)
Pico32x.regs[6 / 2] &= ~P32XS_68S; // transfer complete Pico32x.regs[6 / 2] &= ~P32XS_68S; // transfer complete
if (dmac0->tcr0 == 0) if (dmac0->tcr0 == 0)
dmac0->chcr0 |= 2; // DMA has ended normally dmac0->chcr0 |= 2; // DMA has ended normally
p32x_poll_undetect(&m68k_poll, 0);
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
@ -137,7 +136,7 @@ static u32 p32x_reg_read16(u32 a)
if ((a & 0x30) == 0x20) if ((a & 0x30) == 0x20)
return sh2_comm_faker(a); return sh2_comm_faker(a);
#else #else
if (p32x_poll_detect(&m68k_poll, a, SekPc, 0)) { if ((a & 0x30) == 0x20 && p32x_poll_detect(&m68k_poll, a, SekPc, 0)) {
SekEndRun(16); SekEndRun(16);
} }
#endif #endif
@ -146,6 +145,8 @@ static u32 p32x_reg_read16(u32 a)
if (a == 0x24 || a == 0x26) if (a == 0x24 || a == 0x26)
return sh2_comm_faker(a); return sh2_comm_faker(a);
#endif #endif
if ((a & 0x30) == 0x30)
return p32x_pwm_read16(a);
return Pico32x.regs[a / 2]; return Pico32x.regs[a / 2];
} }
@ -196,9 +197,6 @@ static void p32x_reg_write16(u32 a, u32 d)
u16 *r = Pico32x.regs; u16 *r = Pico32x.regs;
a &= 0x3e; a &= 0x3e;
// for write loops with FIFO checks..
m68k_poll.cnt = 0;
switch (a) { switch (a) {
case 0x00: // adapter ctl case 0x00: // adapter ctl
r[0] = (r[0] & 0x83) | (d & P32XS_FM); r[0] = (r[0] & 0x83) | (d & P32XS_FM);
@ -234,6 +232,11 @@ static void p32x_reg_write16(u32 a, u32 d)
SekEndRun(16); SekEndRun(16);
return; return;
} }
// PWM
else if ((a & 0x30) == 0x30) {
p32x_pwm_write16(a, d);
return;
}
p32x_reg_write8(a + 1, d); p32x_reg_write8(a + 1, d);
} }
@ -296,9 +299,19 @@ static u32 p32x_sh2reg_read16(u32 a, int cpuid)
return r[a / 2]; return r[a / 2];
} }
// DREQ src, dst; comm port // DREQ src, dst
if ((a & 0x38) == 0x08 || (a & 0x30) == 0x20) if ((a & 0x38) == 0x08)
return r[a / 2]; return r[a / 2];
// comm port
if ((a & 0x30) == 0x20) {
if (p32x_poll_detect(&sh2_poll[cpuid], a, sh2_pc(cpuid), 0))
ash2_end_run(8);
return r[a / 2];
}
if ((a & 0x30) == 0x30) {
sh2_poll[cpuid].cnt = 0;
return p32x_pwm_read16(a);
}
return 0; return 0;
} }
@ -316,12 +329,18 @@ static void p32x_sh2reg_write16(u32 a, u32 d, int cpuid)
{ {
a &= 0xfe; a &= 0xfe;
// comm
if ((a & 0x30) == 0x20 && Pico32x.regs[a/2] != d) { if ((a & 0x30) == 0x20 && Pico32x.regs[a/2] != d) {
Pico32x.regs[a / 2] = d; Pico32x.regs[a / 2] = d;
p32x_poll_undetect(&m68k_poll, 0); p32x_poll_undetect(&m68k_poll, 0);
p32x_poll_undetect(&sh2_poll[cpuid ^ 1], 0); p32x_poll_undetect(&sh2_poll[cpuid ^ 1], 0);
return; return;
} }
// PWM
else if ((a & 0x30) == 0x30) {
p32x_pwm_write16(a, d);
return;
}
switch (a) { switch (a) {
case 0x14: Pico32x.sh2irqs &= ~P32XI_VRES; goto irls; case 0x14: Pico32x.sh2irqs &= ~P32XI_VRES; goto irls;
@ -561,7 +580,6 @@ static void bank_switch(int b)
u32 p32x_sh2_read8(u32 a, int id) u32 p32x_sh2_read8(u32 a, int id)
{ {
int pd_vdp = 0;
u32 d = 0; u32 d = 0;
if (id == 0 && a < sizeof(Pico32xMem->sh2_rom_m)) if (id == 0 && a < sizeof(Pico32xMem->sh2_rom_m))
@ -581,13 +599,14 @@ u32 p32x_sh2_read8(u32 a, int id)
if ((a & 0x0fffff00) == 0x4000) { if ((a & 0x0fffff00) == 0x4000) {
d = p32x_sh2reg_read16(a, id); d = p32x_sh2reg_read16(a, id);
goto out_pd; goto out_16to8;
} }
if ((a & 0x0fffff00) == 0x4100) { if ((a & 0x0fffff00) == 0x4100) {
d = p32x_vdp_read16(a); d = p32x_vdp_read16(a);
pd_vdp = 1; if (p32x_poll_detect(&sh2_poll[id], a, sh2_pc(id), 1))
goto out_pd; ash2_end_run(8);
goto out_16to8;
} }
if ((a & 0x0fffff00) == 0x4200) { if ((a & 0x0fffff00) == 0x4200) {
@ -599,10 +618,6 @@ u32 p32x_sh2_read8(u32 a, int id)
id ? 's' : 'm', a, d, sh2_pc(id)); id ? 's' : 'm', a, d, sh2_pc(id));
return d; return d;
out_pd:
if (p32x_poll_detect(&sh2_poll[id], a, sh2_pc(id), pd_vdp))
ash2_end_run(8);
out_16to8: out_16to8:
if (a & 1) if (a & 1)
d &= 0xff; d &= 0xff;
@ -616,7 +631,6 @@ out_16to8:
u32 p32x_sh2_read16(u32 a, int id) u32 p32x_sh2_read16(u32 a, int id)
{ {
int pd_vdp = 0;
u32 d = 0; u32 d = 0;
if (id == 0 && a < sizeof(Pico32xMem->sh2_rom_m)) if (id == 0 && a < sizeof(Pico32xMem->sh2_rom_m))
@ -636,13 +650,14 @@ u32 p32x_sh2_read16(u32 a, int id)
if ((a & 0x0fffff00) == 0x4000) { if ((a & 0x0fffff00) == 0x4000) {
d = p32x_sh2reg_read16(a, id); d = p32x_sh2reg_read16(a, id);
goto out_pd; goto out;
} }
if ((a & 0x0fffff00) == 0x4100) { if ((a & 0x0fffff00) == 0x4100) {
d = p32x_vdp_read16(a); d = p32x_vdp_read16(a);
pd_vdp = 1; if (p32x_poll_detect(&sh2_poll[id], a, sh2_pc(id), 1))
goto out_pd; ash2_end_run(8);
goto out;
} }
if ((a & 0x0fffff00) == 0x4200) { if ((a & 0x0fffff00) == 0x4200) {
@ -654,10 +669,6 @@ u32 p32x_sh2_read16(u32 a, int id)
id ? 's' : 'm', a, d, sh2_pc(id)); id ? 's' : 'm', a, d, sh2_pc(id));
return d; return d;
out_pd:
if (p32x_poll_detect(&sh2_poll[id], a, sh2_pc(id), pd_vdp))
ash2_end_run(8);
out: out:
elprintf(EL_32X, "%csh2 r16 [%08x] %04x @%06x", elprintf(EL_32X, "%csh2 r16 [%08x] %04x @%06x",
id ? 's' : 'm', a, d, sh2_pc(id)); id ? 's' : 'm', a, d, sh2_pc(id));

144
pico/32x/pwm.c Normal file
View file

@ -0,0 +1,144 @@
#include "../pico_int.h"
static int pwm_line_samples;
static int pwm_cycles;
static int pwm_mult;
static int pwm_ptr;
int pwm_frame_smp_cnt;
void p32x_pwm_refresh(void)
{
int cycles = Pico32x.regs[0x32 / 2];
int frame_samples;
cycles = (cycles - 1) & 0x0fff;
if (cycles < 500) {
elprintf(EL_32X|EL_ANOMALY, "pwm: low cycle value: %d", cycles + 1);
cycles = 500;
}
pwm_cycles = cycles;
pwm_mult = 0x10000 / cycles;
if (Pico.m.pal)
frame_samples = OSC_PAL / 7 * 3 / 50 / cycles;
else
frame_samples = OSC_NTSC / 7 * 3 / 60 / cycles;
pwm_line_samples = (frame_samples << 16) / scanlines_total;
}
// irq for every sample??
// FIXME: we need to hit more than once per line :(
void p32x_pwm_irq_check(void)
{
int tm = (Pico32x.regs[0x30 / 2] & 0x0f00) >> 8;
if (tm == 0)
return; // TODO: verify
Pico32x.pwm_irq_sample_cnt += pwm_line_samples;
if (Pico32x.pwm_irq_sample_cnt >= (tm << 16)) {
Pico32x.pwm_irq_sample_cnt -= tm << 16;
Pico32x.sh2irqs |= P32XI_PWM;
p32x_update_irls();
}
}
unsigned int p32x_pwm_read16(unsigned int a)
{
unsigned int d = 0;
int predict;
a &= 0x0e;
switch (a) {
case 0: // control
case 2: // cycle
return Pico32x.regs[(0x30 + a) / 2];
case 4: // L ch
case 6: // R ch
case 8: // MONO
predict = (pwm_line_samples * Pico.m.scanline) >> 16;
elprintf(EL_32X, "pwm: read status: ptr %d/%d, predict %d",
pwm_frame_smp_cnt, (pwm_line_samples * scanlines_total) >> 16, predict);
if (pwm_frame_smp_cnt > predict + 3)
d |= P32XP_FULL;
else if (pwm_frame_smp_cnt == 0 || pwm_frame_smp_cnt < predict - 1)
d |= P32XP_EMPTY;
break;
}
return d;
}
void p32x_pwm_write16(unsigned int a, unsigned int d)
{
a &= 0x0e;
if (a == 0) // control
Pico32x.regs[0x30 / 2] = d;
else if (a == 2) { // cycle
Pico32x.regs[0x32 / 2] = d & 0x0fff;
p32x_pwm_refresh();
Pico32x.pwm_irq_sample_cnt = 0; // resets?
}
else if (a <= 8) {
d &= 0x0fff;
if (d > pwm_cycles)
d = pwm_cycles;
d = (d - pwm_cycles / 2) * pwm_mult;
if (a < 6) // L ch
Pico32xMem->pwm[pwm_ptr * 2] = d;
else if (a == 6) // R ch
Pico32xMem->pwm[pwm_ptr * 2 + 1] = d;
else // MONO
Pico32xMem->pwm[pwm_ptr * 2] = Pico32xMem->pwm[pwm_ptr * 2 + 1] = d;
if (a >= 6) { // R or MONO
pwm_frame_smp_cnt++;
pwm_ptr = (pwm_ptr + 1) & (PWM_BUFF_LEN - 1);
elprintf(EL_32X, "pwm: smp_cnt %d, ptr %d, smp %x", pwm_frame_smp_cnt, pwm_ptr, d);
}
}
}
void p32x_pwm_update(int *buf32, int length, int stereo)
{
extern int pwm_ptr;
short *pwmb;
int step;
int p = 0;
if (pwm_ptr <= 16) // at least some samples..
return;
step = (pwm_ptr << 16) / length; // FIXME: division..
pwmb = Pico32xMem->pwm;
if (stereo)
{
while (length-- > 0) {
*buf32++ += pwmb[0];
*buf32++ += pwmb[1];
p += step;
pwmb += (p >> 16) * 2;
p &= 0xffff;
}
}
else
{
while (length-- > 0) {
*buf32++ += pwmb[0];
p += step;
pwmb += (p >> 16) * 2;
p &= 0xffff;
}
}
elprintf(EL_STATUS, "pwm_update: pwm_ptr %d, len %d, step %04x, done %d",
pwm_ptr, length, step, (pwmb - Pico32xMem->pwm) / 2);
pwm_ptr = 0;
}

View file

@ -335,6 +335,8 @@ void PDebugDumpMem(void)
dump_ram(Pico32xMem->dram[0], "dumps/dram0.bin"); dump_ram(Pico32xMem->dram[0], "dumps/dram0.bin");
dump_ram(Pico32xMem->dram[1], "dumps/dram1.bin"); dump_ram(Pico32xMem->dram[1], "dumps/dram1.bin");
dump_ram(Pico32xMem->pal, "dumps/pal32x.bin"); dump_ram(Pico32xMem->pal, "dumps/pal32x.bin");
dump_ram(Pico32xMem->data_array[0], "dumps/data_array0.bin");
dump_ram(Pico32xMem->data_array[1], "dumps/data_array1.bin");
} }
} }

View file

@ -476,7 +476,7 @@ u32 PicoRead8_io(u32 a)
goto end; goto end;
} }
if (!(PicoOpt & POPT_DIS_32X)) { if (PicoOpt & POPT_EN_32X) {
d = PicoRead8_32x(a); d = PicoRead8_32x(a);
goto end; goto end;
} }
@ -511,7 +511,7 @@ u32 PicoRead16_io(u32 a)
goto end; goto end;
} }
if (!(PicoOpt & POPT_DIS_32X)) { if (PicoOpt & POPT_EN_32X) {
d = PicoRead16_32x(a); d = PicoRead16_32x(a);
goto end; goto end;
} }
@ -541,7 +541,7 @@ void PicoWrite8_io(u32 a, u32 d)
Pico.m.sram_reg |= (u8)(d & 3); Pico.m.sram_reg |= (u8)(d & 3);
return; return;
} }
if (!(PicoOpt & POPT_DIS_32X)) { if (PicoOpt & POPT_EN_32X) {
PicoWrite8_32x(a, d); PicoWrite8_32x(a, d);
return; return;
} }
@ -569,7 +569,7 @@ void PicoWrite16_io(u32 a, u32 d)
Pico.m.sram_reg |= (u8)(d & 3); Pico.m.sram_reg |= (u8)(d & 3);
return; return;
} }
if (!(PicoOpt & POPT_DIS_32X)) { if (PicoOpt & POPT_EN_32X) {
PicoWrite16_32x(a, d); PicoWrite16_32x(a, d);
return; return;
} }

View file

@ -10,7 +10,7 @@
.equ SRR_READONLY, (1 << 1) .equ SRR_READONLY, (1 << 1)
.equ SRF_EEPROM, (1 << 1) .equ SRF_EEPROM, (1 << 1)
.equ POPT_6BTN_PAD, (1 << 5) .equ POPT_6BTN_PAD, (1 << 5)
.equ POPT_DIS_32X, (1 << 20) .equ POPT_EN_32X, (1 << 20)
.text .text
.align 4 .align 4
@ -114,8 +114,8 @@ m_read8_not_io:
m_read8_not_brq: m_read8_not_brq:
ldr r2, =PicoOpt ldr r2, =PicoOpt
ldr r2, [r2] ldr r2, [r2]
tst r2, #POPT_DIS_32X tst r2, #POPT_EN_32X
beq PicoRead8_32x bne PicoRead8_32x
mov r0, #0 mov r0, #0
bx lr bx lr
@ -190,8 +190,8 @@ m_read16_not_io:
m_read16_not_brq: m_read16_not_brq:
ldr r2, =PicoOpt ldr r2, =PicoOpt
ldr r2, [r2] ldr r2, [r2]
tst r2, #POPT_DIS_32X tst r2, #POPT_EN_32X
beq PicoRead16_32x bne PicoRead16_32x
mov r0, #0 mov r0, #0
bx lr bx lr
@ -261,8 +261,8 @@ m_write8_not_z80ctl:
m_write8_not_sreg: m_write8_not_sreg:
ldr r2, =PicoOpt ldr r2, =PicoOpt
ldr r2, [r2] ldr r2, [r2]
tst r2, #POPT_DIS_32X tst r2, #POPT_EN_32X
beq PicoWrite8_32x bne PicoWrite8_32x
bx lr bx lr
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ -298,8 +298,8 @@ m_write16_not_z80ctl:
m_write16_not_sreg: m_write16_not_sreg:
ldr r2, =PicoOpt ldr r2, =PicoOpt
ldr r2, [r2] ldr r2, [r2]
tst r2, #POPT_DIS_32X tst r2, #POPT_EN_32X
beq PicoWrite16_32x bne PicoWrite16_32x
bx lr bx lr
.pool .pool

View file

@ -77,7 +77,7 @@ void PicoPower(void)
if (PicoAHW & PAHW_MCD) if (PicoAHW & PAHW_MCD)
PicoPowerMCD(); PicoPowerMCD();
if (!(PicoOpt & POPT_DIS_32X)) if (PicoOpt & POPT_EN_32X)
PicoPower32x(); PicoPower32x();
PicoReset(); PicoReset();
@ -192,7 +192,7 @@ int PicoReset(void)
if (!(PicoOpt & POPT_DIS_IDLE_DET)) if (!(PicoOpt & POPT_DIS_IDLE_DET))
SekInitIdleDet(); SekInitIdleDet();
if (!(PicoOpt & POPT_DIS_32X)) { if (PicoOpt & POPT_EN_32X) {
PicoReset32x(); PicoReset32x();
return 0; return 0;
} }
@ -218,6 +218,9 @@ void PicoLoopPrepare(void)
// FIXME: PAL has 313 scanlines.. // FIXME: PAL has 313 scanlines..
scanlines_total = Pico.m.pal ? 312 : 262; scanlines_total = Pico.m.pal ? 312 : 262;
if (PicoAHW & PAHW_32X)
p32x_pwm_refresh();
} }

View file

@ -58,8 +58,8 @@ extern void emu_32x_startup(void);
#define POPT_EN_SVP_DRC (1<<17) #define POPT_EN_SVP_DRC (1<<17)
#define POPT_DIS_SPRITE_LIM (1<<18) #define POPT_DIS_SPRITE_LIM (1<<18)
#define POPT_DIS_IDLE_DET (1<<19) #define POPT_DIS_IDLE_DET (1<<19)
#define POPT_DIS_32X (1<<20) #define POPT_EN_32X (1<<20)
#define POPT_DIS_PWM (1<<21) #define POPT_EN_PWM (1<<21)
extern int PicoOpt; // bitfield extern int PicoOpt; // bitfield
#define PAHW_MCD (1<<0) #define PAHW_MCD (1<<0)

View file

@ -100,6 +100,9 @@ static int PicoFrameHints(void)
#ifdef PICO_CD #ifdef PICO_CD
check_cd_dma(); check_cd_dma();
#endif #endif
#ifdef PICO_32X
p32x_pwm_irq_check();
#endif
// H-Interrupts: // H-Interrupts:
if (--hint < 0) // y <= lines_vis: Comix Zone, Golden Axe if (--hint < 0) // y <= lines_vis: Comix Zone, Golden Axe
@ -169,6 +172,9 @@ static int PicoFrameHints(void)
#ifdef PICO_CD #ifdef PICO_CD
check_cd_dma(); check_cd_dma();
#endif #endif
#ifdef PICO_32X
p32x_pwm_irq_check();
#endif
// Last H-Int: // Last H-Int:
if (--hint < 0) if (--hint < 0)
@ -237,6 +243,9 @@ static int PicoFrameHints(void)
#ifdef PICO_CD #ifdef PICO_CD
check_cd_dma(); check_cd_dma();
#endif #endif
#ifdef PICO_32X
p32x_pwm_irq_check();
#endif
// Run scanline: // Run scanline:
if (Pico.m.dma_xfers) SekCyclesBurn(CheckDMA()); if (Pico.m.dma_xfers) SekCyclesBurn(CheckDMA());

View file

@ -1,7 +1,7 @@
// Pico Library - Internal Header File // Pico Library - Internal Header File
// (c) Copyright 2004 Dave, All rights reserved. // (c) Copyright 2004 Dave, All rights reserved.
// (c) Copyright 2006-2008 Grazvydas "notaz" Ignotas, all rights reserved. // (c) Copyright 2006-2009 Grazvydas "notaz" Ignotas, all rights reserved.
// Free for non-commercial use. // Free for non-commercial use.
// For commercial use, separate licencing terms must be obtained. // For commercial use, separate licencing terms must be obtained.
@ -418,6 +418,9 @@ typedef struct
#define P32XV_nFEN (1<< 1) #define P32XV_nFEN (1<< 1)
#define P32XV_FS (1<< 0) #define P32XV_FS (1<< 0)
#define P32XP_FULL (1<<15) // PWM
#define P32XP_EMPTY (1<<14)
#define P32XF_68KPOLL (1 << 0) #define P32XF_68KPOLL (1 << 0)
#define P32XF_MSH2POLL (1 << 1) #define P32XF_MSH2POLL (1 << 1)
#define P32XF_SSH2POLL (1 << 2) #define P32XF_SSH2POLL (1 << 2)
@ -433,6 +436,7 @@ typedef struct
// real one is 4*2, but we use more because we don't lockstep // real one is 4*2, but we use more because we don't lockstep
#define DMAC_FIFO_LEN (4*4) #define DMAC_FIFO_LEN (4*4)
#define PWM_BUFF_LEN 1024 // in one channel samples
struct Pico32x struct Pico32x
{ {
@ -447,6 +451,7 @@ struct Pico32x
unsigned int sh2irqs; // common irqs unsigned int sh2irqs; // common irqs
unsigned short dmac_fifo[DMAC_FIFO_LEN]; unsigned short dmac_fifo[DMAC_FIFO_LEN];
unsigned int dmac_ptr; unsigned int dmac_ptr;
unsigned int pwm_irq_sample_cnt;
}; };
struct Pico32xMem struct Pico32xMem
@ -460,6 +465,7 @@ struct Pico32xMem
unsigned short pal[0x100]; unsigned short pal[0x100];
unsigned short pal_native[0x100]; // converted to native (for renderer) unsigned short pal_native[0x100]; // converted to native (for renderer)
unsigned int sh2_peri_regs[2][0x200/4]; // periphereal regs of SH2s unsigned int sh2_peri_regs[2][0x200/4]; // periphereal regs of SH2s
signed short pwm[2*PWM_BUFF_LEN]; // PWM buffer for current frame
}; };
// area.c // area.c
@ -671,6 +677,14 @@ void p32x_poll_event(int is_vdp);
// 32x/draw.c // 32x/draw.c
void FinalizeLine32xRGB555(int sh, int line); void FinalizeLine32xRGB555(int sh, int line);
// 32x/pwm.c
unsigned int p32x_pwm_read16(unsigned int a);
void p32x_pwm_write16(unsigned int a, unsigned int d);
void p32x_pwm_refresh(void);
void p32x_pwm_irq_check(void);
void p32x_pwm_update(int *buf32, int length, int stereo);
extern int pwm_frame_smp_cnt;
/* avoid dependency on newer glibc */ /* avoid dependency on newer glibc */
static __inline int isspace_(int c) static __inline int isspace_(int c)
{ {

View file

@ -356,6 +356,9 @@ static int PsndRender(int offset, int length)
cdda_raw_update(buf32, length); cdda_raw_update(buf32, length);
} }
if ((PicoAHW & PAHW_32X) && (PicoOpt & POPT_EN_PWM))
p32x_pwm_update(buf32, length, stereo);
// convert + limit to normal 16bit output // convert + limit to normal 16bit output
PsndMix_32_to_16l(PsndOut+offset, buf32, length); PsndMix_32_to_16l(PsndOut+offset, buf32, length);

View file

@ -1424,6 +1424,21 @@ static int menu_loop_cd_options(menu_id id, int keys)
return 0; return 0;
} }
// ------------ 32X options menu ------------
static menu_entry e_menu_32x_options[] =
{
mee_onoff("32X enabled", MA_32XOPT_ENABLE_32X, PicoOpt, POPT_EN_32X),
mee_onoff("PWM sound", MA_32XOPT_PWM, PicoOpt, POPT_EN_PWM),
};
static int menu_loop_32x_options(menu_id id, int keys)
{
static int sel = 0;
me_loop(e_menu_32x_options, &sel, NULL);
return 0;
}
// ------------ adv options menu ------------ // ------------ adv options menu ------------
static menu_entry e_menu_adv_options[] = static menu_entry e_menu_adv_options[] =
@ -1672,6 +1687,7 @@ static menu_entry e_menu_options[] =
mee_range (cpu_clk_name, MA_OPT_CPU_CLOCKS, currentConfig.CPUclock, 20, 900), mee_range (cpu_clk_name, MA_OPT_CPU_CLOCKS, currentConfig.CPUclock, 20, 900),
mee_handler ("[Display options]", menu_loop_gfx_options), mee_handler ("[Display options]", menu_loop_gfx_options),
mee_handler ("[Sega/Mega CD options]", menu_loop_cd_options), mee_handler ("[Sega/Mega CD options]", menu_loop_cd_options),
mee_handler ("[32X options]", menu_loop_32x_options),
mee_handler ("[Advanced options]", menu_loop_adv_options), mee_handler ("[Advanced options]", menu_loop_adv_options),
mee_handler_mkname_id(MA_OPT_SAVECFG, mh_saveloadcfg, mgn_savecfg), mee_handler_mkname_id(MA_OPT_SAVECFG, mh_saveloadcfg, mgn_savecfg),
mee_handler_id("Save cfg for current game only", MA_OPT_SAVECFG_GAME, mh_saveloadcfg), mee_handler_id("Save cfg for current game only", MA_OPT_SAVECFG_GAME, mh_saveloadcfg),
@ -2079,6 +2095,7 @@ static menu_entry *e_menu_table[] =
e_menu_gfx_options, e_menu_gfx_options,
e_menu_adv_options, e_menu_adv_options,
e_menu_cd_options, e_menu_cd_options,
e_menu_32x_options,
e_menu_keyconfig, e_menu_keyconfig,
e_menu_hidden, e_menu_hidden,
}; };

View file

@ -85,6 +85,8 @@ typedef enum
MA_CDOPT_SCALEROT_CHIP, MA_CDOPT_SCALEROT_CHIP,
MA_CDOPT_BETTER_SYNC, MA_CDOPT_BETTER_SYNC,
MA_CDOPT_DONE, MA_CDOPT_DONE,
MA_32XOPT_ENABLE_32X,
MA_32XOPT_PWM,
MA_CTRL_PLAYER1, MA_CTRL_PLAYER1,
MA_CTRL_PLAYER2, MA_CTRL_PLAYER2,
MA_CTRL_EMU, MA_CTRL_EMU,

View file

@ -73,7 +73,7 @@ OBJS += pico/cd/pico.o pico/cd/memory.o pico/cd/sek.o pico/cd/LC89510.o \
pico/cd/area.o pico/cd/misc.o pico/cd/pcm.o pico/cd/buffering.o pico/cd/area.o pico/cd/misc.o pico/cd/pcm.o pico/cd/buffering.o
endif endif
# Pico - 32X # Pico - 32X
OBJS += pico/32x/32x.o pico/32x/memory.o pico/32x/draw.o OBJS += pico/32x/32x.o pico/32x/memory.o pico/32x/draw.o pico/32x/pwm.o
# Pico - Pico # Pico - Pico
OBJS += pico/pico/pico.o pico/pico/memory.o pico/pico/xpcm.o OBJS += pico/pico/pico.o pico/pico/memory.o pico/pico/xpcm.o
# Pico - carthw # Pico - carthw

View file

@ -78,7 +78,9 @@ void pemu_prep_defconfig(void)
memset(&defaultConfig, 0, sizeof(defaultConfig)); memset(&defaultConfig, 0, sizeof(defaultConfig));
defaultConfig.EmuOpt = 0x9d | EOPT_RAM_TIMINGS|EOPT_CONFIRM_SAVE|EOPT_EN_CD_LEDS; defaultConfig.EmuOpt = 0x9d | EOPT_RAM_TIMINGS|EOPT_CONFIRM_SAVE|EOPT_EN_CD_LEDS;
defaultConfig.s_PicoOpt = 0x0f | POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC|POPT_ACC_SPRITES; defaultConfig.s_PicoOpt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 |
POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC|POPT_ACC_SPRITES |
POPT_EN_32X|POPT_EN_PWM;
defaultConfig.s_PsndRate = 44100; defaultConfig.s_PsndRate = 44100;
defaultConfig.s_PicoRegion = 0; // auto defaultConfig.s_PicoRegion = 0; // auto
defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP

View file

@ -40,7 +40,7 @@ OBJS += pico/cd/pico.o pico/cd/memory.o pico/cd/sek.o pico/cd/LC89510.o \
pico/cd/cd_sys.o pico/cd/cd_file.o pico/cd/cue.o pico/cd/gfx_cd.o \ pico/cd/cd_sys.o pico/cd/cd_file.o pico/cd/cue.o pico/cd/gfx_cd.o \
pico/cd/area.o pico/cd/misc.o pico/cd/pcm.o pico/cd/buffering.o pico/cd/area.o pico/cd/misc.o pico/cd/pcm.o pico/cd/buffering.o
# Pico - 32X # Pico - 32X
OBJS += pico/32x/32x.o pico/32x/memory.o pico/32x/draw.o OBJS += pico/32x/32x.o pico/32x/memory.o pico/32x/draw.o pico/32x/pwm.o
# Pico - Pico # Pico - Pico
OBJS += pico/pico/pico.o pico/pico/memory.o pico/pico/xpcm.o OBJS += pico/pico/pico.o pico/pico/memory.o pico/pico/xpcm.o
# Pico - sound # Pico - sound