mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
some Pico input support
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@441 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
6cab49fd07
commit
406c96c547
7 changed files with 125 additions and 23 deletions
|
@ -67,7 +67,7 @@ static __inline int PicoMemBase(u32 pc)
|
|||
#endif
|
||||
|
||||
|
||||
static u32 PicoCheckPc(u32 pc)
|
||||
PICO_INTERNAL u32 PicoCheckPc(u32 pc)
|
||||
{
|
||||
u32 ret=0;
|
||||
#if defined(EMU_C68K)
|
||||
|
|
|
@ -70,6 +70,10 @@ extern void (*PicoMCDopenTray)(void);
|
|||
extern int (*PicoMCDcloseTray)(void);
|
||||
extern int PicoCDBuffers;
|
||||
|
||||
// Pico/Pico.c
|
||||
extern int PicoPicoPenPos[2]; // x: 0x03c-0x17d, y: 0x200-0x2d8
|
||||
extern int PicoPicoPage;
|
||||
|
||||
// Area.c
|
||||
typedef size_t (arearw)(void *p, size_t _size, size_t _n, void *file);
|
||||
typedef size_t (areaeof)(void *file);
|
||||
|
|
|
@ -25,7 +25,30 @@ static u32 PicoReadPico8(u32 a)
|
|||
goto end;
|
||||
}
|
||||
|
||||
elprintf(EL_UIO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
|
||||
if ((a&0xffffe0)==0x800000) // Pico I/O
|
||||
{
|
||||
switch (a & 0x1f)
|
||||
{
|
||||
case 0x03:
|
||||
d = PicoPad[0]&0x0f; // d-pad
|
||||
d |= (PicoPad[0]&0x20) >> 1; // red button -> C
|
||||
d |= (PicoPad[0]&0x40) << 1; // pen tap -> A
|
||||
d = ~d;
|
||||
break;
|
||||
|
||||
case 0x05: d = (PicoPicoPenPos[0] >> 8) & 3; break; // what is MS bit for? Games read it..
|
||||
case 0x07: d = PicoPicoPenPos[0] & 0xff; break;
|
||||
case 0x09: d = (PicoPicoPenPos[1] >> 8) & 3; break;
|
||||
case 0x0b: d = PicoPicoPenPos[1] & 0xff; break;
|
||||
case 0x0d: d = (1 << (PicoPicoPage & 7)) - 1;break;
|
||||
case 0x12: d = 0x80; break;
|
||||
default:
|
||||
elprintf(EL_UIO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// elprintf(EL_UIO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
|
||||
|
||||
end:
|
||||
elprintf(EL_IO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
|
||||
|
@ -47,10 +70,12 @@ static u32 PicoReadPico16(u32 a)
|
|||
goto end;
|
||||
}
|
||||
|
||||
elprintf(EL_UIO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
|
||||
if (a == 0x800010) d = 0x0f;
|
||||
|
||||
elprintf(EL_UIO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
|
||||
|
||||
end:
|
||||
elprintf(EL_IO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
|
||||
elprintf(EL_IO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
|
||||
return d;
|
||||
}
|
||||
|
||||
|
@ -79,6 +104,14 @@ end:
|
|||
// -----------------------------------------------------------------
|
||||
// Write Ram
|
||||
|
||||
void dump(u16 w)
|
||||
{
|
||||
FILE *f = fopen("dump.bin", "a");
|
||||
fwrite(&w, 1, 2, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
|
||||
static void PicoWritePico8(u32 a,u8 d)
|
||||
{
|
||||
elprintf(EL_IO, "w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);
|
||||
|
@ -104,6 +137,8 @@ static void PicoWritePico16(u32 a,u16 d)
|
|||
a&=0xfffffe;
|
||||
if ((a&0xffffe0)==0xc00000) { PicoVideoWrite(a,(u16)d); return; } // VDP
|
||||
|
||||
// if (a == 0x800010) dump(d);
|
||||
|
||||
elprintf(EL_UIO, "w16: %06x, %04x", a&0xffffff, d);
|
||||
}
|
||||
|
||||
|
@ -164,6 +199,15 @@ static unsigned int m68k_read_memory_pcrp_32(unsigned int a)
|
|||
|
||||
PICO_INTERNAL void PicoMemSetupPico(void)
|
||||
{
|
||||
#ifdef EMU_C68K
|
||||
PicoCpuCM68k.checkpc=PicoCheckPc;
|
||||
PicoCpuCM68k.fetch8 =PicoCpuCM68k.read8 =PicoReadPico8;
|
||||
PicoCpuCM68k.fetch16=PicoCpuCM68k.read16=PicoReadPico16;
|
||||
PicoCpuCM68k.fetch32=PicoCpuCM68k.read32=PicoReadPico32;
|
||||
PicoCpuCM68k.write8 =PicoWritePico8;
|
||||
PicoCpuCM68k.write16=PicoWritePico16;
|
||||
PicoCpuCM68k.write32=PicoWritePico32;
|
||||
#endif
|
||||
#ifdef EMU_M68K
|
||||
pm68k_read_memory_8 = PicoReadPico8;
|
||||
pm68k_read_memory_16 = PicoReadPico16;
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
#include "../PicoInt.h"
|
||||
|
||||
// x: 0x03c - 0x19d
|
||||
// y: 0x1fc - 0x2f7
|
||||
// 0x2f8 - 0x3f3
|
||||
int PicoPicoPenPos[2] = { 0x3c, 0x200 };
|
||||
int PicoPicoPage = 0; // 0-6
|
||||
|
||||
PICO_INTERNAL int PicoInitPico(void)
|
||||
{
|
||||
elprintf(EL_STATUS, "Pico detected");
|
||||
PicoAHW = PAHW_PICO;
|
||||
PicoPicoPage = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -397,6 +397,7 @@ PICO_INTERNAL void PicoFrameFull();
|
|||
|
||||
// Memory.c
|
||||
PICO_INTERNAL int PicoInitPc(unsigned int pc);
|
||||
PICO_INTERNAL unsigned int PicoCheckPc(unsigned int pc);
|
||||
PICO_INTERNAL_ASM unsigned int PicoRead32(unsigned int a);
|
||||
PICO_INTERNAL void PicoMemSetup(void);
|
||||
PICO_INTERNAL_ASM void PicoMemReset(void);
|
||||
|
|
|
@ -53,6 +53,8 @@ char noticeMsg[64]; // notice msg to draw
|
|||
unsigned char *PicoDraw2FB = NULL; // temporary buffer for alt renderer
|
||||
int reset_timing = 0;
|
||||
|
||||
static int pico_pen_x = 0, pico_pen_y = 0, pico_inp_mode = 0;
|
||||
|
||||
static void emu_msg_cb(const char *msg);
|
||||
static void emu_msg_tray_open(void);
|
||||
|
||||
|
@ -396,6 +398,41 @@ static void emu_msg_tray_open(void)
|
|||
gettimeofday(¬iceMsgTime, 0);
|
||||
}
|
||||
|
||||
static void RunEventsPico(unsigned int events, unsigned int gp2x_keys)
|
||||
{
|
||||
if (events & (1 << 3)) {
|
||||
pico_inp_mode++;
|
||||
if (pico_inp_mode > 2) pico_inp_mode = 0;
|
||||
switch (pico_inp_mode) {
|
||||
case 0: strcpy(noticeMsg, "Input: Joytick "); break;
|
||||
case 1: strcpy(noticeMsg, "Input: Pen on Storyware"); break;
|
||||
case 2: strcpy(noticeMsg, "Input: Pen on Pad "); break;
|
||||
}
|
||||
gettimeofday(¬iceMsgTime, 0);
|
||||
}
|
||||
if (events & (1 << 4)) {
|
||||
PicoPicoPage--;
|
||||
if (PicoPicoPage < 0) PicoPicoPage = 0;
|
||||
sprintf(noticeMsg, "Page %i ", PicoPicoPage);
|
||||
gettimeofday(¬iceMsgTime, 0);
|
||||
}
|
||||
if (events & (1 << 5)) {
|
||||
PicoPicoPage++;
|
||||
if (PicoPicoPage > 6) PicoPicoPage = 6;
|
||||
sprintf(noticeMsg, "Page %i ", PicoPicoPage);
|
||||
gettimeofday(¬iceMsgTime, 0);
|
||||
}
|
||||
if (pico_inp_mode != 0) {
|
||||
PicoPad[0] &= ~0x0f; // release UDLR
|
||||
if (gp2x_keys & GP2X_UP) { pico_pen_y--; if (pico_pen_y < 0) pico_pen_y = 0; }
|
||||
if (gp2x_keys & GP2X_DOWN) { pico_pen_y++; if (pico_pen_y > 251) pico_pen_y = 251; }
|
||||
if (gp2x_keys & GP2X_LEFT) { pico_pen_x--; if (pico_pen_x < 0) pico_pen_x = 0; }
|
||||
if (gp2x_keys & GP2X_RIGHT){ pico_pen_x++; if (pico_pen_x > 353) pico_pen_x = 353; }
|
||||
PicoPicoPenPos[0] = 0x03c + pico_pen_x;
|
||||
PicoPicoPenPos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y);
|
||||
}
|
||||
}
|
||||
|
||||
static void update_volume(int has_changed, int is_up)
|
||||
{
|
||||
static int prev_frame = 0, wait_frames = 0;
|
||||
|
@ -520,8 +557,8 @@ static void RunEvents(unsigned int which)
|
|||
|
||||
static void updateKeys(void)
|
||||
{
|
||||
unsigned long keys, allActions[2] = { 0, 0 }, events;
|
||||
static unsigned long prevEvents = 0;
|
||||
unsigned int keys, keys2, allActions[2] = { 0, 0 }, events;
|
||||
static unsigned int prevEvents = 0;
|
||||
int joy, i;
|
||||
|
||||
keys = gp2x_joystick_read(0);
|
||||
|
@ -532,10 +569,11 @@ static void updateKeys(void)
|
|||
}
|
||||
|
||||
keys &= CONFIGURABLE_KEYS;
|
||||
keys2 = keys;
|
||||
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
if (keys & (1 << i))
|
||||
if (keys2 & (1 << i))
|
||||
{
|
||||
int pl, acts = currentConfig.KeyBinds[i];
|
||||
if (!acts) continue;
|
||||
|
@ -546,9 +584,9 @@ static void updateKeys(void)
|
|||
// let's try to find the other one
|
||||
if (acts_c) {
|
||||
for (; u < 32; u++)
|
||||
if ( (keys & (1 << u)) && (currentConfig.KeyBinds[u] & acts_c) ) {
|
||||
if ( (keys2 & (1 << u)) && (currentConfig.KeyBinds[u] & acts_c) ) {
|
||||
allActions[pl] |= acts_c & currentConfig.KeyBinds[u];
|
||||
keys &= ~((1 << i) | (1 << u));
|
||||
keys2 &= ~((1 << i) | (1 << u));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -566,9 +604,9 @@ static void updateKeys(void)
|
|||
{
|
||||
gp2x_usbjoy_update();
|
||||
for (joy = 0; joy < num_of_joys; joy++) {
|
||||
int keys = gp2x_usbjoy_check2(joy);
|
||||
int btns = gp2x_usbjoy_check2(joy);
|
||||
for (i = 0; i < 32; i++) {
|
||||
if (keys & (1 << i)) {
|
||||
if (btns & (1 << i)) {
|
||||
int acts = currentConfig.JoyBinds[joy][i];
|
||||
int pl = (acts >> 16) & 1;
|
||||
allActions[pl] |= acts;
|
||||
|
@ -590,6 +628,10 @@ static void updateKeys(void)
|
|||
change_fast_forward(events & 0x40);
|
||||
|
||||
events &= ~prevEvents;
|
||||
|
||||
if (PicoAHW == PAHW_PICO)
|
||||
RunEventsPico(events, keys);
|
||||
|
||||
if (events) RunEvents(events);
|
||||
if (movie_data) emu_updateMovie();
|
||||
|
||||
|
|
|
@ -751,7 +751,7 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_
|
|||
x = 40;
|
||||
}
|
||||
|
||||
menu_draw_selection(x - 16, tl_y + sel*10, (player_idx >= 0) ? 66 : 130);
|
||||
menu_draw_selection(x - 16, tl_y + sel*10, (player_idx >= 0) ? 66 : 140);
|
||||
|
||||
y = tl_y;
|
||||
for (i = 0; i < opt_cnt; i++, y+=10)
|
||||
|
@ -857,21 +857,25 @@ static void draw_kc_sel(int menu_sel)
|
|||
}
|
||||
|
||||
|
||||
// player2_flag, ?, ?, ?, ?, ?, ?, menu
|
||||
// player2_flag, reserved, ?, ?,
|
||||
// ?, ?, fast forward, menu
|
||||
// "NEXT SAVE SLOT", "PREV SAVE SLOT", "SWITCH RENDERER", "SAVE STATE",
|
||||
// "LOAD STATE", "VOLUME UP", "VOLUME DOWN", "DONE"
|
||||
me_bind_action emuctrl_actions[] =
|
||||
{
|
||||
{ "Load State ", 1<<28 },
|
||||
{ "Save State ", 1<<27 },
|
||||
{ "Prev Save Slot ", 1<<25 },
|
||||
{ "Next Save Slot ", 1<<24 },
|
||||
{ "Switch Renderer", 1<<26 },
|
||||
{ "Volume Down ", 1<<30 },
|
||||
{ "Volume Up ", 1<<29 },
|
||||
{ "Fast forward ", 1<<22 },
|
||||
{ "Enter Menu ", 1<<23 },
|
||||
{ NULL, 0 }
|
||||
{ "Load State ", 1<<28 },
|
||||
{ "Save State ", 1<<27 },
|
||||
{ "Prev Save Slot ", 1<<25 },
|
||||
{ "Next Save Slot ", 1<<24 },
|
||||
{ "Switch Renderer ", 1<<26 },
|
||||
{ "Volume Down ", 1<<30 },
|
||||
{ "Volume Up ", 1<<29 },
|
||||
{ "Fast forward ", 1<<22 },
|
||||
{ "Enter Menu ", 1<<23 },
|
||||
{ "Pico Next page ", 1<<21 },
|
||||
{ "Pico Prev page ", 1<<20 },
|
||||
{ "Pico Switch input", 1<<19 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static void kc_sel_loop(void)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue