mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
improve input handling
This commit is contained in:
parent
be7867d875
commit
531a8f3883
12 changed files with 170 additions and 108 deletions
132
pico/memory.c
132
pico/memory.c
|
@ -186,62 +186,119 @@ void cyclone_crashed(u32 pc, struct Cyclone *context)
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
// memmap helpers
|
// memmap helpers
|
||||||
|
|
||||||
#ifndef _ASM_MEMORY_C
|
static u32 read_pad_3btn(int i, u32 out_bits)
|
||||||
static
|
|
||||||
#endif
|
|
||||||
int PadRead(int i)
|
|
||||||
{
|
{
|
||||||
int pad,value,data_reg;
|
u32 pad = ~PicoPadInt[i]; // Get inverse of pad MXYZ SACB RLDU
|
||||||
pad=~PicoPadInt[i]; // Get inverse of pad MXYZ SACB RLDU
|
u32 value;
|
||||||
data_reg=Pico.ioports[i+1];
|
|
||||||
|
|
||||||
// orr the bits, which are set as output
|
if (out_bits & 0x40) // TH
|
||||||
value = data_reg&(Pico.ioports[i+4]|0x80);
|
value = pad & 0x3f; // ?1CB RLDU
|
||||||
|
else
|
||||||
|
value = ((pad & 0xc0) >> 2) | (pad & 3); // ?0SA 00DU
|
||||||
|
|
||||||
if (PicoOpt & POPT_6BTN_PAD)
|
value |= out_bits & 0x40;
|
||||||
{
|
return value;
|
||||||
int phase = Pico.m.padTHPhase[i];
|
|
||||||
|
|
||||||
if(phase == 2 && !(data_reg&0x40)) { // TH
|
|
||||||
value|=(pad&0xc0)>>2; // ?0SA 0000
|
|
||||||
return value;
|
|
||||||
} else if(phase == 3) {
|
|
||||||
if(data_reg&0x40)
|
|
||||||
value|=(pad&0x30)|((pad>>8)&0xf); // ?1CB MXYZ
|
|
||||||
else
|
|
||||||
value|=((pad&0xc0)>>2)|0x0f; // ?0SA 1111
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(data_reg&0x40) // TH
|
|
||||||
value|=(pad&0x3f); // ?1CB RLDU
|
|
||||||
else value|=((pad&0xc0)>>2)|(pad&3); // ?0SA 00DU
|
|
||||||
|
|
||||||
return value; // will mirror later
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _ASM_MEMORY_C
|
static u32 read_pad_6btn(int i, u32 out_bits)
|
||||||
|
{
|
||||||
|
u32 pad = ~PicoPadInt[i]; // Get inverse of pad MXYZ SACB RLDU
|
||||||
|
int phase = Pico.m.padTHPhase[i];
|
||||||
|
u32 value;
|
||||||
|
|
||||||
static u32 io_ports_read(u32 a)
|
if (phase == 2 && !(out_bits & 0x40)) {
|
||||||
|
value = (pad & 0xc0) >> 2; // ?0SA 0000
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
else if(phase == 3) {
|
||||||
|
if (out_bits & 0x40)
|
||||||
|
return (pad & 0x30) | ((pad >> 8) & 0xf); // ?1CB MXYZ
|
||||||
|
else
|
||||||
|
return ((pad & 0xc0) >> 2) | 0x0f; // ?0SA 1111
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out_bits & 0x40) // TH
|
||||||
|
value = pad & 0x3f; // ?1CB RLDU
|
||||||
|
else
|
||||||
|
value = ((pad & 0xc0) >> 2) | (pad & 3); // ?0SA 00DU
|
||||||
|
|
||||||
|
out:
|
||||||
|
value |= out_bits & 0x40;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static u32 read_nothing(int i, u32 out_bits)
|
||||||
|
{
|
||||||
|
return 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef u32 (port_read_func)(int index, u32 out_bits);
|
||||||
|
|
||||||
|
static port_read_func *port_readers[3] = {
|
||||||
|
read_pad_3btn,
|
||||||
|
read_pad_3btn,
|
||||||
|
read_nothing
|
||||||
|
};
|
||||||
|
|
||||||
|
static NOINLINE u32 port_read(int i)
|
||||||
|
{
|
||||||
|
u32 data_reg = Pico.ioports[i + 1];
|
||||||
|
u32 ctrl_reg = Pico.ioports[i + 4] | 0x80;
|
||||||
|
u32 in, out;
|
||||||
|
|
||||||
|
out = data_reg & ctrl_reg;
|
||||||
|
out |= 0x7f & ~ctrl_reg; // pull-ups
|
||||||
|
|
||||||
|
in = port_readers[i](i, out);
|
||||||
|
|
||||||
|
return (in & ~ctrl_reg) | (data_reg & ctrl_reg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PicoSetInputDevice(int port, enum input_device device)
|
||||||
|
{
|
||||||
|
port_read_func *func;
|
||||||
|
|
||||||
|
if (port < 0 || port > 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (device) {
|
||||||
|
case PICO_INPUT_PAD_3BTN:
|
||||||
|
func = read_pad_3btn;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PICO_INPUT_PAD_6BTN:
|
||||||
|
func = read_pad_6btn;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
func = read_nothing;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
port_readers[port] = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
NOINLINE u32 io_ports_read(u32 a)
|
||||||
{
|
{
|
||||||
u32 d;
|
u32 d;
|
||||||
a = (a>>1) & 0xf;
|
a = (a>>1) & 0xf;
|
||||||
switch (a) {
|
switch (a) {
|
||||||
case 0: d = Pico.m.hardware; break; // Hardware value (Version register)
|
case 0: d = Pico.m.hardware; break; // Hardware value (Version register)
|
||||||
case 1: d = PadRead(0); break;
|
case 1: d = port_read(0); break;
|
||||||
case 2: d = PadRead(1); break;
|
case 2: d = port_read(1); break;
|
||||||
|
case 3: d = port_read(2); break;
|
||||||
default: d = Pico.ioports[a]; break; // IO ports can be used as RAM
|
default: d = Pico.ioports[a]; break; // IO ports can be used as RAM
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void NOINLINE io_ports_write(u32 a, u32 d)
|
NOINLINE void io_ports_write(u32 a, u32 d)
|
||||||
{
|
{
|
||||||
a = (a>>1) & 0xf;
|
a = (a>>1) & 0xf;
|
||||||
|
|
||||||
// 6 button gamepad: if TH went from 0 to 1, gamepad changes state
|
// 6 button gamepad: if TH went from 0 to 1, gamepad changes state
|
||||||
if (1 <= a && a <= 2 && (PicoOpt & POPT_6BTN_PAD))
|
if (1 <= a && a <= 2)
|
||||||
{
|
{
|
||||||
Pico.m.padDelay[a - 1] = 0;
|
Pico.m.padDelay[a - 1] = 0;
|
||||||
if (!(Pico.ioports[a] & 0x40) && (d & 0x40))
|
if (!(Pico.ioports[a] & 0x40) && (d & 0x40))
|
||||||
|
@ -252,8 +309,6 @@ static void NOINLINE io_ports_write(u32 a, u32 d)
|
||||||
Pico.ioports[a] = d;
|
Pico.ioports[a] = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _ASM_MEMORY_C
|
|
||||||
|
|
||||||
void NOINLINE ctl_write_z80busreq(u32 d)
|
void NOINLINE ctl_write_z80busreq(u32 d)
|
||||||
{
|
{
|
||||||
d&=1; d^=1;
|
d&=1; d^=1;
|
||||||
|
@ -1177,3 +1232,4 @@ static void z80_mem_setup(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// vim:shiftwidth=2:ts=2:expandtab
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
.equ SRR_MAPPED, (1 << 0)
|
.equ SRR_MAPPED, (1 << 0)
|
||||||
.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_EN_32X, (1 << 20)
|
.equ POPT_EN_32X, (1 << 20)
|
||||||
|
|
||||||
.text
|
.text
|
||||||
|
@ -67,24 +66,7 @@ m_read8_eeprom:
|
||||||
PicoRead8_io: @ u32 a, u32 d
|
PicoRead8_io: @ u32 a, u32 d
|
||||||
bic r2, r0, #0x001f @ most commonly we get i/o port read,
|
bic r2, r0, #0x001f @ most commonly we get i/o port read,
|
||||||
cmp r2, #0xa10000 @ so check for it first
|
cmp r2, #0xa10000 @ so check for it first
|
||||||
bne m_read8_not_io
|
beq io_ports_read
|
||||||
|
|
||||||
m_read8_misc_io:
|
|
||||||
ands r0, r0, #0x1e
|
|
||||||
beq m_read8_misc_hwreg
|
|
||||||
cmp r0, #4
|
|
||||||
movlt r0, #0
|
|
||||||
moveq r0, #1
|
|
||||||
ble PadRead
|
|
||||||
ldr r3, =(Pico+0x22000)
|
|
||||||
mov r0, r0, lsr #1 @ other IO ports (Pico.ioports[a])
|
|
||||||
ldrb r0, [r3, r0]
|
|
||||||
bx lr
|
|
||||||
|
|
||||||
m_read8_misc_hwreg:
|
|
||||||
ldr r3, =(Pico+0x22200)
|
|
||||||
ldrb r0, [r3, #0x0f] @ Pico.m.hardware
|
|
||||||
bx lr
|
|
||||||
|
|
||||||
m_read8_not_io:
|
m_read8_not_io:
|
||||||
and r2, r0, #0xfc00
|
and r2, r0, #0xfc00
|
||||||
|
@ -161,7 +143,7 @@ PicoRead16_io: @ u32 a, u32 d
|
||||||
cmp r2, #0xa10000 @ so check for it first
|
cmp r2, #0xa10000 @ so check for it first
|
||||||
bne m_read16_not_io
|
bne m_read16_not_io
|
||||||
stmfd sp!,{lr}
|
stmfd sp!,{lr}
|
||||||
bl m_read8_misc_io @ same as read8
|
bl io_ports_read @ same as read8
|
||||||
orr r0, r0, r0, lsl #8 @ only has bytes mirrored
|
orr r0, r0, r0, lsl #8 @ only has bytes mirrored
|
||||||
ldmfd sp!,{pc}
|
ldmfd sp!,{pc}
|
||||||
|
|
||||||
|
@ -201,37 +183,7 @@ PicoWrite8_io: @ u32 a, u32 d
|
||||||
bic r2, r0, #0x1e @ most commonly we get i/o port write,
|
bic r2, r0, #0x1e @ most commonly we get i/o port write,
|
||||||
eor r2, r2, #0xa10000 @ so check for it first
|
eor r2, r2, #0xa10000 @ so check for it first
|
||||||
eors r2, r2, #1
|
eors r2, r2, #1
|
||||||
bne m_write8_not_io
|
beq io_ports_write
|
||||||
|
|
||||||
m_write8_io:
|
|
||||||
ldr r2, =PicoOpt
|
|
||||||
and r0, r0, #0x1e
|
|
||||||
ldr r2, [r2]
|
|
||||||
ldr r3, =(Pico+0x22000) @ Pico.ioports
|
|
||||||
tst r2, #POPT_6BTN_PAD
|
|
||||||
beq m_write8_io_done
|
|
||||||
cmp r0, #2
|
|
||||||
cmpne r0, #4
|
|
||||||
bne m_write8_io_done @ not likely to happen
|
|
||||||
add r2, r3, #0x200 @ Pico+0x22200
|
|
||||||
mov r12,#0
|
|
||||||
cmp r0, #2
|
|
||||||
streqb r12,[r2,#0x18]
|
|
||||||
strneb r12,[r2,#0x19] @ Pico.m.padDelay[i] = 0
|
|
||||||
tst r1, #0x40 @ TH
|
|
||||||
beq m_write8_io_done
|
|
||||||
ldrb r12,[r3, r0, lsr #1]
|
|
||||||
tst r12,#0x40
|
|
||||||
bne m_write8_io_done
|
|
||||||
cmp r0, #2
|
|
||||||
ldreqb r12,[r2,#0x0a]
|
|
||||||
ldrneb r12,[r2,#0x0b] @ Pico.m.padTHPhase
|
|
||||||
add r12,r12,#1
|
|
||||||
streqb r12,[r2,#0x0a]
|
|
||||||
strneb r12,[r2,#0x0b] @ Pico.m.padTHPhase
|
|
||||||
m_write8_io_done:
|
|
||||||
strb r1, [r3, r0, lsr #1]
|
|
||||||
bx lr
|
|
||||||
|
|
||||||
m_write8_not_io:
|
m_write8_not_io:
|
||||||
tst r0, #1
|
tst r0, #1
|
||||||
|
@ -270,7 +222,7 @@ m_write8_not_sreg:
|
||||||
PicoWrite16_io: @ u32 a, u32 d
|
PicoWrite16_io: @ u32 a, u32 d
|
||||||
bic r2, r0, #0x1f @ most commonly we get i/o port write,
|
bic r2, r0, #0x1f @ most commonly we get i/o port write,
|
||||||
cmp r2, #0xa10000 @ so check for it first
|
cmp r2, #0xa10000 @ so check for it first
|
||||||
beq m_write8_io
|
beq io_ports_write
|
||||||
|
|
||||||
m_write16_not_io:
|
m_write16_not_io:
|
||||||
and r2, r0, #0xff00
|
and r2, r0, #0xff00
|
||||||
|
|
|
@ -70,6 +70,9 @@ void PicoPower(void)
|
||||||
Pico.video.pending_ints=0;
|
Pico.video.pending_ints=0;
|
||||||
z80_reset();
|
z80_reset();
|
||||||
|
|
||||||
|
// my MD1 VA6 console has this in IO
|
||||||
|
Pico.ioports[1] = Pico.ioports[2] = Pico.ioports[3] = 0xff;
|
||||||
|
|
||||||
// default VDP register values (based on Fusion)
|
// default VDP register values (based on Fusion)
|
||||||
Pico.video.reg[0] = Pico.video.reg[1] = 0x04;
|
Pico.video.reg[0] = Pico.video.reg[1] = 0x04;
|
||||||
Pico.video.reg[0xc] = 0x81;
|
Pico.video.reg[0xc] = 0x81;
|
||||||
|
|
10
pico/pico.h
10
pico/pico.h
|
@ -52,7 +52,7 @@ extern void *p32x_bios_g, *p32x_bios_m, *p32x_bios_s;
|
||||||
#define POPT_EN_Z80 (1<< 2)
|
#define POPT_EN_Z80 (1<< 2)
|
||||||
#define POPT_EN_STEREO (1<< 3)
|
#define POPT_EN_STEREO (1<< 3)
|
||||||
#define POPT_ALT_RENDERER (1<< 4) // 00 00x0
|
#define POPT_ALT_RENDERER (1<< 4) // 00 00x0
|
||||||
#define POPT_6BTN_PAD (1<< 5)
|
// unused (1<< 5)
|
||||||
// unused (1<< 6)
|
// unused (1<< 6)
|
||||||
#define POPT_ACC_SPRITES (1<< 7)
|
#define POPT_ACC_SPRITES (1<< 7)
|
||||||
#define POPT_DIS_32C_BORDER (1<< 8) // 00 0x00
|
#define POPT_DIS_32C_BORDER (1<< 8) // 00 0x00
|
||||||
|
@ -248,6 +248,14 @@ int PicoCdCheck(const char *fname_in, int *pregion);
|
||||||
|
|
||||||
extern unsigned char media_id_header[0x100];
|
extern unsigned char media_id_header[0x100];
|
||||||
|
|
||||||
|
// memory.c
|
||||||
|
enum input_device {
|
||||||
|
PICO_INPUT_NOTHING,
|
||||||
|
PICO_INPUT_PAD_3BTN,
|
||||||
|
PICO_INPUT_PAD_6BTN,
|
||||||
|
};
|
||||||
|
void PicoSetInputDevice(int port, enum input_device device);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // End of extern "C"
|
} // End of extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,11 +14,10 @@
|
||||||
#define CYCLES_S68K_ASD 241
|
#define CYCLES_S68K_ASD 241
|
||||||
|
|
||||||
// pad delay (for 6 button pads)
|
// pad delay (for 6 button pads)
|
||||||
#define PAD_DELAY \
|
#define PAD_DELAY() { \
|
||||||
if (PicoOpt&POPT_6BTN_PAD) { \
|
if(Pico.m.padDelay[0]++ > 25) Pico.m.padTHPhase[0]=0; \
|
||||||
if(Pico.m.padDelay[0]++ > 25) Pico.m.padTHPhase[0]=0; \
|
if(Pico.m.padDelay[1]++ > 25) Pico.m.padTHPhase[1]=0; \
|
||||||
if(Pico.m.padDelay[1]++ > 25) Pico.m.padTHPhase[1]=0; \
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// CPUS_RUN
|
// CPUS_RUN
|
||||||
#ifndef CPUS_RUN
|
#ifndef CPUS_RUN
|
||||||
|
@ -114,7 +113,7 @@ static int PicoFrameHints(void)
|
||||||
Pico.video.status|=0x200;
|
Pico.video.status|=0x200;
|
||||||
}
|
}
|
||||||
|
|
||||||
PAD_DELAY
|
PAD_DELAY();
|
||||||
#ifdef PICO_CD
|
#ifdef PICO_CD
|
||||||
check_cd_dma();
|
check_cd_dma();
|
||||||
#endif
|
#endif
|
||||||
|
@ -187,7 +186,7 @@ static int PicoFrameHints(void)
|
||||||
Pico.video.status|=0x200;
|
Pico.video.status|=0x200;
|
||||||
|
|
||||||
memcpy(PicoPadInt, PicoPad, sizeof(PicoPadInt));
|
memcpy(PicoPadInt, PicoPad, sizeof(PicoPadInt));
|
||||||
PAD_DELAY
|
PAD_DELAY();
|
||||||
#ifdef PICO_CD
|
#ifdef PICO_CD
|
||||||
check_cd_dma();
|
check_cd_dma();
|
||||||
#endif
|
#endif
|
||||||
|
@ -257,7 +256,7 @@ static int PicoFrameHints(void)
|
||||||
pv->v_counter = (pv->v_counter << 1) | 1;
|
pv->v_counter = (pv->v_counter << 1) | 1;
|
||||||
pv->v_counter &= 0xff;
|
pv->v_counter &= 0xff;
|
||||||
|
|
||||||
PAD_DELAY
|
PAD_DELAY();
|
||||||
#ifdef PICO_CD
|
#ifdef PICO_CD
|
||||||
check_cd_dma();
|
check_cd_dma();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -598,7 +598,6 @@ unsigned int PicoRead8_io(unsigned int a);
|
||||||
unsigned int PicoRead16_io(unsigned int a);
|
unsigned int PicoRead16_io(unsigned int a);
|
||||||
void PicoWrite8_io(unsigned int a, unsigned int d);
|
void PicoWrite8_io(unsigned int a, unsigned int d);
|
||||||
void PicoWrite16_io(unsigned int a, unsigned int d);
|
void PicoWrite16_io(unsigned int a, unsigned int d);
|
||||||
void p32x_dreq1_trigger(void);
|
|
||||||
|
|
||||||
// pico/memory.c
|
// pico/memory.c
|
||||||
PICO_INTERNAL void PicoMemSetupPico(void);
|
PICO_INTERNAL void PicoMemSetupPico(void);
|
||||||
|
|
|
@ -455,9 +455,11 @@ int emu_reload_rom(const char *rom_fname_in)
|
||||||
// additional movie stuff
|
// additional movie stuff
|
||||||
if (movie_data)
|
if (movie_data)
|
||||||
{
|
{
|
||||||
if (movie_data[0x14] == '6')
|
enum input_device indev = (movie_data[0x14] == '6') ?
|
||||||
PicoOpt |= POPT_6BTN_PAD; // 6 button pad
|
PICO_INPUT_PAD_6BTN : PICO_INPUT_PAD_3BTN;
|
||||||
else PicoOpt &= ~POPT_6BTN_PAD;
|
PicoSetInputDevice(0, indev);
|
||||||
|
PicoSetInputDevice(1, indev);
|
||||||
|
|
||||||
PicoOpt |= POPT_DIS_VDP_FIFO; // no VDP fifo timing
|
PicoOpt |= POPT_DIS_VDP_FIFO; // no VDP fifo timing
|
||||||
if (movie_data[0xF] >= 'A') {
|
if (movie_data[0xF] >= 'A') {
|
||||||
if (movie_data[0x16] & 0x80) {
|
if (movie_data[0x16] & 0x80) {
|
||||||
|
@ -550,6 +552,8 @@ void emu_prep_defconfig(void)
|
||||||
defaultConfig.s_PicoCDBuffers = 0;
|
defaultConfig.s_PicoCDBuffers = 0;
|
||||||
defaultConfig.confirm_save = EOPT_CONFIRM_SAVE;
|
defaultConfig.confirm_save = EOPT_CONFIRM_SAVE;
|
||||||
defaultConfig.Frameskip = -1; // auto
|
defaultConfig.Frameskip = -1; // auto
|
||||||
|
defaultConfig.input_dev0 = PICO_INPUT_PAD_3BTN;
|
||||||
|
defaultConfig.input_dev1 = PICO_INPUT_PAD_3BTN;
|
||||||
defaultConfig.volume = 50;
|
defaultConfig.volume = 50;
|
||||||
defaultConfig.gamma = 100;
|
defaultConfig.gamma = 100;
|
||||||
defaultConfig.scaling = 0;
|
defaultConfig.scaling = 0;
|
||||||
|
|
|
@ -57,6 +57,8 @@ typedef struct _currentConfig_t {
|
||||||
int s_PicoAutoRgnOrder;
|
int s_PicoAutoRgnOrder;
|
||||||
int s_PicoCDBuffers;
|
int s_PicoCDBuffers;
|
||||||
int Frameskip;
|
int Frameskip;
|
||||||
|
int input_dev0;
|
||||||
|
int input_dev1;
|
||||||
int confirm_save;
|
int confirm_save;
|
||||||
int CPUclock;
|
int CPUclock;
|
||||||
int volume;
|
int volume;
|
||||||
|
|
|
@ -355,12 +355,15 @@ static const char *mgn_dev_name(int id, int *offs)
|
||||||
static int mh_saveloadcfg(int id, int keys);
|
static int mh_saveloadcfg(int id, int keys);
|
||||||
static const char *mgn_saveloadcfg(int id, int *offs);
|
static const char *mgn_saveloadcfg(int id, int *offs);
|
||||||
|
|
||||||
|
const char *indev_names[] = { "none", "3 button pad", "6 button pad", NULL };
|
||||||
|
|
||||||
static menu_entry e_menu_keyconfig[] =
|
static menu_entry e_menu_keyconfig[] =
|
||||||
{
|
{
|
||||||
mee_handler_id("Player 1", MA_CTRL_PLAYER1, key_config_loop_wrap),
|
mee_handler_id("Player 1", MA_CTRL_PLAYER1, key_config_loop_wrap),
|
||||||
mee_handler_id("Player 2", MA_CTRL_PLAYER2, key_config_loop_wrap),
|
mee_handler_id("Player 2", MA_CTRL_PLAYER2, key_config_loop_wrap),
|
||||||
mee_handler_id("Emulator controls", MA_CTRL_EMU, key_config_loop_wrap),
|
mee_handler_id("Emulator controls", MA_CTRL_EMU, key_config_loop_wrap),
|
||||||
mee_onoff ("6 button pad", MA_OPT_6BUTTON_PAD, PicoOpt, POPT_6BTN_PAD),
|
mee_enum ("Input device 1", MA_OPT_INPUT_DEV0, currentConfig.input_dev0, indev_names),
|
||||||
|
mee_enum ("Input device 2", MA_OPT_INPUT_DEV1, currentConfig.input_dev1, indev_names),
|
||||||
mee_range ("Turbo rate", MA_CTRL_TURBO_RATE, currentConfig.turbo_rate, 1, 30),
|
mee_range ("Turbo rate", MA_CTRL_TURBO_RATE, currentConfig.turbo_rate, 1, 30),
|
||||||
mee_range ("Analog deadzone", MA_CTRL_DEADZONE, currentConfig.analog_deadzone, 1, 99),
|
mee_range ("Analog deadzone", MA_CTRL_DEADZONE, currentConfig.analog_deadzone, 1, 99),
|
||||||
mee_cust_nosave("Save global config", MA_OPT_SAVECFG, mh_saveloadcfg, mgn_saveloadcfg),
|
mee_cust_nosave("Save global config", MA_OPT_SAVECFG, mh_saveloadcfg, mgn_saveloadcfg),
|
||||||
|
@ -383,6 +386,10 @@ static int menu_loop_keyconfig(int id, int keys)
|
||||||
|
|
||||||
me_enable(e_menu_keyconfig, MA_OPT_SAVECFG_GAME, PicoGameLoaded);
|
me_enable(e_menu_keyconfig, MA_OPT_SAVECFG_GAME, PicoGameLoaded);
|
||||||
me_loop(e_menu_keyconfig, &sel);
|
me_loop(e_menu_keyconfig, &sel);
|
||||||
|
|
||||||
|
PicoSetInputDevice(0, currentConfig.input_dev0);
|
||||||
|
PicoSetInputDevice(1, currentConfig.input_dev1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,8 @@ typedef enum
|
||||||
MA_OPT_ENABLE_SOUND,
|
MA_OPT_ENABLE_SOUND,
|
||||||
MA_OPT_SOUND_QUALITY,
|
MA_OPT_SOUND_QUALITY,
|
||||||
MA_OPT_ARM940_SOUND,
|
MA_OPT_ARM940_SOUND,
|
||||||
MA_OPT_6BUTTON_PAD,
|
MA_OPT_INPUT_DEV0,
|
||||||
|
MA_OPT_INPUT_DEV1,
|
||||||
MA_OPT_REGION,
|
MA_OPT_REGION,
|
||||||
MA_OPT_SRAM_STATES,
|
MA_OPT_SRAM_STATES,
|
||||||
MA_OPT_CONFIRM_STATES,
|
MA_OPT_CONFIRM_STATES,
|
||||||
|
|
|
@ -183,6 +183,8 @@ void retro_set_environment(retro_environment_t cb)
|
||||||
{
|
{
|
||||||
static const struct retro_variable vars[] = {
|
static const struct retro_variable vars[] = {
|
||||||
//{ "region", "Region; Auto|NTSC|PAL" },
|
//{ "region", "Region; Auto|NTSC|PAL" },
|
||||||
|
{ "picodrive_input1", "Input device 1; 3 button pad|6 button pad|None" },
|
||||||
|
{ "picodrive_input2", "Input device 2; 3 button pad|6 button pad|None" },
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -545,7 +547,7 @@ bool retro_load_game(const struct retro_game_info *info)
|
||||||
|
|
||||||
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
|
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
|
||||||
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) {
|
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) {
|
||||||
lprintf("RGB565 suppot required, sorry\n");
|
lprintf("RGB565 support required, sorry\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,13 +662,41 @@ static void snd_write(int len)
|
||||||
audio_batch_cb(PsndOut, len / 4);
|
audio_batch_cb(PsndOut, len / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum input_device input_name_to_val(const char *name)
|
||||||
|
{
|
||||||
|
if (strcmp(name, "3 button pad") == 0)
|
||||||
|
return PICO_INPUT_PAD_3BTN;
|
||||||
|
if (strcmp(name, "6 button pad") == 0)
|
||||||
|
return PICO_INPUT_PAD_6BTN;
|
||||||
|
if (strcmp(name, "None") == 0)
|
||||||
|
return PICO_INPUT_NOTHING;
|
||||||
|
|
||||||
|
lprintf("invalid picodrive_input: '%s'\n", name);
|
||||||
|
return PICO_INPUT_PAD_3BTN;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void update_variables(void)
|
||||||
|
{
|
||||||
|
struct retro_variable var;
|
||||||
|
|
||||||
|
var.value = NULL;
|
||||||
|
var.key = "picodrive_input1";
|
||||||
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||||
|
PicoSetInputDevice(0, input_name_to_val(var.value));
|
||||||
|
|
||||||
|
var.value = NULL;
|
||||||
|
var.key = "picodrive_input2";
|
||||||
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||||
|
PicoSetInputDevice(1, input_name_to_val(var.value));
|
||||||
|
}
|
||||||
|
|
||||||
void retro_run(void)
|
void retro_run(void)
|
||||||
{
|
{
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
int pad, i;
|
int pad, i;
|
||||||
|
|
||||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
|
||||||
; //update_variables(true);
|
update_variables();
|
||||||
|
|
||||||
input_poll_cb();
|
input_poll_cb();
|
||||||
|
|
||||||
|
@ -720,6 +750,8 @@ void retro_init(void)
|
||||||
//PicoMessage = plat_status_msg_busy_next;
|
//PicoMessage = plat_status_msg_busy_next;
|
||||||
PicoMCDopenTray = disk_tray_open;
|
PicoMCDopenTray = disk_tray_open;
|
||||||
PicoMCDcloseTray = disk_tray_close;
|
PicoMCDcloseTray = disk_tray_close;
|
||||||
|
|
||||||
|
update_variables();
|
||||||
}
|
}
|
||||||
|
|
||||||
void retro_deinit(void)
|
void retro_deinit(void)
|
||||||
|
|
|
@ -64,7 +64,6 @@ int plat_wait_event(int *fds_hnds, int count, int timeout_ms)
|
||||||
void pemu_prep_defconfig(void)
|
void pemu_prep_defconfig(void)
|
||||||
{
|
{
|
||||||
memset(&defaultConfig, 0, sizeof(defaultConfig));
|
memset(&defaultConfig, 0, sizeof(defaultConfig));
|
||||||
defaultConfig.s_PicoOpt|= POPT_6BTN_PAD; // for xmen proto
|
|
||||||
defaultConfig.s_PicoCDBuffers = 0;
|
defaultConfig.s_PicoCDBuffers = 0;
|
||||||
defaultConfig.Frameskip = 0;
|
defaultConfig.Frameskip = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue