Skip to content

Commit daee88a

Browse files
committed
SMS correct controls
Signed-off-by: Vincent-FK <[email protected]>
1 parent 83ece47 commit daee88a

File tree

4 files changed

+76
-4
lines changed

4 files changed

+76
-4
lines changed

pico/sms.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ static unsigned char z80_sms_in(unsigned short a)
100100
unsigned char d = 0;
101101

102102
elprintf(EL_IO, "z80 port %04x read", a);
103+
//printf("z80 port %04x read\n", a);
104+
103105
a &= 0xc1;
104106
switch (a)
105107
{
@@ -137,6 +139,7 @@ static unsigned char z80_sms_in(unsigned short a)
137139
}
138140

139141
elprintf(EL_IO, "ret = %02x", d);
142+
//printf( "ret = %02x\n", d);
140143
return d;
141144
}
142145

platform/common/emu.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,15 @@ int emu_reload_rom(const char *rom_fname_in)
494494
PicoIn.opt &= ~POPT_DIS_VDP_FIFO;
495495
}
496496

497+
/* Set input map */
498+
if (PicoIn.AHW & PAHW_SMS) {
499+
printf("plat set sms input\n");
500+
plat_set_sms_input();
501+
}
502+
else{
503+
plat_set_genesis_input();
504+
}
505+
497506
strncpy(rom_fname_loaded, rom_fname, sizeof(rom_fname_loaded)-1);
498507
rom_fname_loaded[sizeof(rom_fname_loaded)-1] = 0;
499508

@@ -1338,6 +1347,7 @@ void emu_update_input(void)
13381347

13391348
if (events)
13401349
run_events_ui(events);
1350+
13411351
if (movie_data)
13421352
update_movie();
13431353

platform/common/emu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ void pemu_sound_start(void);
165165
void plat_early_init(void);
166166
void plat_init(void);
167167
void plat_finish(void);
168+
void plat_set_sms_input(void);
169+
void plat_set_genesis_input(void);
168170

169171
/* used before things blocking for a while (these funcs redraw on return) */
170172
void plat_status_msg_busy_first(const char *msg);

platform/common/plat_sdl.c

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ const struct in_default_bind in_sdl_defbinds[] __attribute__((weak)) = {
4343
{ SDLK_x, IN_BINDTYPE_PLAYER12, GBTN_Y },
4444
{ SDLK_m, IN_BINDTYPE_PLAYER12, GBTN_X },
4545
{ SDLK_n, IN_BINDTYPE_PLAYER12, GBTN_Z },
46-
{ SDLK_s, IN_BINDTYPE_PLAYER12, GBTN_START },
46+
{ SDLK_s, IN_BINDTYPE_PLAYER12, GBTN_START },
4747
{ SDLK_k, IN_BINDTYPE_PLAYER12, GBTN_MODE },
48-
{ SDLK_q, IN_BINDTYPE_EMU, PEVB_MENU },
48+
{ SDLK_q, IN_BINDTYPE_EMU, PEVB_MENU },
4949
{ SDLK_TAB, IN_BINDTYPE_EMU, PEVB_RESET },
5050
//{ SDLK_p, IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
5151
{ SDLK_F1, IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
@@ -69,6 +69,43 @@ const struct in_default_bind in_sdl_defbinds[] __attribute__((weak)) = {
6969
{ 0, 0, 0 }
7070
};
7171

72+
const struct in_default_bind in_sdl_defbinds_SMS[] __attribute__((weak)) = {
73+
{ SDLK_u, IN_BINDTYPE_PLAYER12, GBTN_UP },
74+
{ SDLK_d, IN_BINDTYPE_PLAYER12, GBTN_DOWN },
75+
{ SDLK_l, IN_BINDTYPE_PLAYER12, GBTN_LEFT },
76+
{ SDLK_r, IN_BINDTYPE_PLAYER12, GBTN_RIGHT },
77+
{ SDLK_y, IN_BINDTYPE_PLAYER12, GBTN_C },
78+
{ SDLK_a, IN_BINDTYPE_PLAYER12, GBTN_C },
79+
{ SDLK_b, IN_BINDTYPE_PLAYER12, GBTN_B },
80+
{ SDLK_x, IN_BINDTYPE_PLAYER12, GBTN_B },
81+
{ SDLK_m, IN_BINDTYPE_PLAYER12, GBTN_X },
82+
{ SDLK_n, IN_BINDTYPE_PLAYER12, GBTN_Z },
83+
{ SDLK_s, IN_BINDTYPE_PLAYER12, GBTN_START },
84+
{ SDLK_k, IN_BINDTYPE_PLAYER12, GBTN_MODE },
85+
{ SDLK_q, IN_BINDTYPE_EMU, PEVB_MENU },
86+
{ SDLK_TAB, IN_BINDTYPE_EMU, PEVB_RESET },
87+
//{ SDLK_p, IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
88+
{ SDLK_F1, IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
89+
{ SDLK_F2, IN_BINDTYPE_EMU, PEVB_STATE_LOAD },
90+
91+
{ SDLK_e, IN_BINDTYPE_EMU, PEVB_VOL_DOWN },
92+
{ SDLK_c, IN_BINDTYPE_EMU, PEVB_VOL_UP },
93+
{ SDLK_w, IN_BINDTYPE_EMU, PEVB_BRIGHT_DOWN },
94+
{ SDLK_g, IN_BINDTYPE_EMU, PEVB_BRIGHT_UP },
95+
{ SDLK_j, IN_BINDTYPE_EMU, PEVB_AR_FACT_DOWN },
96+
{ SDLK_i, IN_BINDTYPE_EMU, PEVB_AR_FACT_UP },
97+
{ SDLK_h, IN_BINDTYPE_EMU, PEVB_DISPMODE },
98+
99+
{ SDLK_F3, IN_BINDTYPE_EMU, PEVB_SSLOT_PREV },
100+
{ SDLK_F4, IN_BINDTYPE_EMU, PEVB_SSLOT_NEXT },
101+
{ SDLK_F5, IN_BINDTYPE_EMU, PEVB_SWITCH_RND },
102+
{ SDLK_F6, IN_BINDTYPE_EMU, PEVB_PICO_PPREV },
103+
{ SDLK_F7, IN_BINDTYPE_EMU, PEVB_PICO_PNEXT },
104+
{ SDLK_F8, IN_BINDTYPE_EMU, PEVB_PICO_SWINP },
105+
{ SDLK_BACKSPACE, IN_BINDTYPE_EMU, PEVB_FF },
106+
{ 0, 0, 0 }
107+
};
108+
72109
const struct menu_keymap in_sdl_key_map[] __attribute__((weak)) =
73110
{
74111
{ SDLK_u, PBTN_UP },
@@ -107,6 +144,15 @@ static const struct in_pdata in_sdl_platform_data = {
107144
.key_names = in_sdl_key_names,
108145
};
109146

147+
static const struct in_pdata in_sdl_platform_data_SMS = {
148+
.defbinds = in_sdl_defbinds_SMS,
149+
.key_map = in_sdl_key_map,
150+
.kmap_size = sizeof(in_sdl_key_map) / sizeof(in_sdl_key_map[0]),
151+
.joy_map = in_sdl_joy_map,
152+
.jmap_size = sizeof(in_sdl_joy_map) / sizeof(in_sdl_joy_map[0]),
153+
.key_names = in_sdl_key_names,
154+
};
155+
110156
/* YUV stuff */
111157
static int yuv_ry[32], yuv_gy[32], yuv_by[32];
112158
static unsigned char yuv_u[32 * 2], yuv_v[32 * 2];
@@ -1564,8 +1610,8 @@ void plat_init(void)
15641610
g_screen_ppitch = 320;
15651611
g_screen_ptr = shadow_fb;
15661612

1567-
in_sdl_init(&in_sdl_platform_data, plat_sdl_event_handler);
1568-
in_probe();
1613+
/*in_sdl_init(&in_sdl_platform_data, plat_sdl_event_handler);
1614+
in_probe();*/
15691615

15701616

15711617
init_menu_SDL();
@@ -1574,9 +1620,20 @@ void plat_init(void)
15741620
bgr_to_uyvy_init();
15751621
}
15761622

1623+
void plat_set_sms_input(void){
1624+
in_sdl_init(&in_sdl_platform_data_SMS, plat_sdl_event_handler);
1625+
in_probe();
1626+
}
1627+
1628+
void plat_set_genesis_input(void){
1629+
in_sdl_init(&in_sdl_platform_data, plat_sdl_event_handler);
1630+
in_probe();
1631+
}
1632+
15771633
void plat_finish(void)
15781634
{
15791635
SDL_FreeSurface(virtual_hw_screen);
1636+
SDL_FreeSurface(sms_game_screen);
15801637
deinit_menu_SDL();
15811638
free(shadow_fb);
15821639
shadow_fb = NULL;

0 commit comments

Comments
 (0)