Skip to content

Commit

Permalink
Merge pull request #263 from sonninnos/master
Browse files Browse the repository at this point in the history
VKBD updates, CD turbo speed backport
  • Loading branch information
rsn8887 authored Mar 28, 2020
2 parents 1a45e70 + b0dda53 commit 16a5fd7
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 84 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ And of course for the RetroArch/Libretro team: "http://www.libretro.com/"
|A|Fire button 2 / Blue|
|L2|Left mouse button|
|R2|Right mouse button|
|SELECT|Toggle virtual keyboard|
|Select|Toggle virtual keyboard|

|Keyboard key|Action|
|---|---|
Expand All @@ -37,6 +37,7 @@ Right analog stick controls the mouse by default.
|---|---|
|B / Enter|Keypress|
|A|Toggle transparency|
|Y|Toggle CapsLock|
|X|Toggle position|
|Start|Press Return|

Expand Down
20 changes: 10 additions & 10 deletions libretro/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ unsigned char font_array[256*8]
0x00, 0x18, 0x24, 0x70, 0x20, 0x7C, 0x00, 0x00, // £
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // space 32
0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x00, // !
0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // "
0x00, 0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, // "
0x00, 0x28, 0x7C, 0x28, 0x7C, 0x28, 0x00, 0x00, // #
0x10, 0x3C, 0x50, 0x38, 0x14, 0x78, 0x10, 0x00, // $
0x10, 0x38, 0x30, 0x18, 0x38, 0x10, 0x00, 0x00, // $
0x00, 0x64, 0x68, 0x10, 0x2C, 0x4C, 0x00, 0x00, // %
0x00, 0x10, 0x28, 0x10, 0x2C, 0x38, 0x00, 0x00, // &
0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // '
0x18, 0x20, 0x20, 0x20, 0x20, 0x20, 0x18, 0x00, // (
0x18, 0x04, 0x04, 0x04, 0x04, 0x04, 0x18, 0x00, // )
0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // '
0x00, 0x10, 0x20, 0x20, 0x20, 0x10, 0x00, 0x00, // (
0x00, 0x08, 0x04, 0x04, 0x04, 0x08, 0x00, 0x00, // )
0x00, 0x10, 0x54, 0x38, 0x54, 0x10, 0x00, 0x00, // *
0x00, 0x10, 0x10, 0x7c, 0x10, 0x10, 0x00, 0x00, // +
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x00, // ,
Expand Down Expand Up @@ -221,9 +221,9 @@ unsigned char font_array[256*8]
0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x00, // X
0x00, 0x44, 0x28, 0x10, 0x10, 0x10, 0x00, 0x00, // Y
0x00, 0x7C, 0x08, 0x10, 0x20, 0x7C, 0x00, 0x00, // Z
0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x00, // [
0x00, 0x30, 0x20, 0x20, 0x20, 0x30, 0x00, 0x00, // [
0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00, // backslash
0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x00, // ]
0x00, 0x18, 0x08, 0x08, 0x08, 0x18, 0x00, 0x00, // ]
0x00, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, // ^
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, // _
0x00, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, // `
Expand Down Expand Up @@ -253,9 +253,9 @@ unsigned char font_array[256*8]
0x00, 0x00, 0x28, 0x10, 0x10, 0x28, 0x00, 0x00, // x
0x00, 0x00, 0x28, 0x28, 0x18, 0x08, 0x30, 0x00, // y
0x00, 0x00, 0x38, 0x10, 0x20, 0x38, 0x00, 0x00, // z
0x18, 0x20, 0x20, 0x40, 0x20, 0x20, 0x18, 0x00, // {
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, // |
0x30, 0x08, 0x08, 0x04, 0x08, 0x08, 0x30, 0x00, // }
0x00, 0x30, 0x20, 0x60, 0x20, 0x30, 0x00, 0x00, // {
0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, // |
0x00, 0x18, 0x08, 0x0C, 0x08, 0x18, 0x00, 0x00, // }
0x00, 0x34, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, // ~
0x00, 0x54, 0x28, 0x54, 0x28, 0x54, 0x00, 0x00,
};
Expand Down
12 changes: 7 additions & 5 deletions libretro/libretro-glue.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
#include "zfile.h"
#include "retro_disk_control.h"

extern int retrow;
extern int retroh;
extern int pix_bytes;
extern int zoomed_height;
extern int imagename_timer;
extern void reset_drawing(void);
extern void print_statusbar(void);
Expand Down Expand Up @@ -74,8 +70,9 @@ extern int vkbd_y_min;
extern int vkbd_y_max;

// Colors
#define RGB565(r, g, b) (((r) << (5+6)) | ((g) << 6) | (b))
#define RGB565(r, g, b) ((((r>>3)<<11) | ((g>>2)<<5) | (b>>3)))
#define RGB888(r, g, b) (((r * 255 / 31) << (16)) | ((g * 255 / 31) << 8) | (b * 255 / 31))
#define ARGB888(a, r, g, b) ((a << 24) | (r << 16) | (g << 8) | b)

// Amiga models
// chipmem_size 1 = 0.5MB, 2 = 1MB, 4 = 2MB
Expand Down Expand Up @@ -224,5 +221,10 @@ fastmem_size=8\n\
#define EMULATOR_MAX_HEIGHT EMULATOR_DEF_HEIGHT

#define RETRO_BMP_SIZE (EMULATOR_DEF_WIDTH * EMULATOR_DEF_HEIGHT * 4) // 4x is big enough for 24-bit SuperHires double line
extern unsigned short int retro_bmp[RETRO_BMP_SIZE];
extern int pix_bytes;
extern int retrow;
extern int retroh;
extern int zoomed_height;

#endif /* LIBRETRO_GLUE_H */
26 changes: 19 additions & 7 deletions libretro/libretro-mapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int vkbd_x_max = 0;
int vkbd_y_min = 0;
int vkbd_y_max = 0;

int vkflag[8] = {0};
int vkflag[9] = {0};
static int jflag[4][16] = {0};
static int kjflag[2][16] = {0};
static int mflag[2][16] = {0};
Expand Down Expand Up @@ -1442,7 +1442,7 @@ void update_input(int disable_physical_cursor_keys)
}

/* Skip the VKBD buttons if VKBD is visible */
if (SHOWKEY==1 && (i==RETRO_DEVICE_ID_JOYPAD_B || i==RETRO_DEVICE_ID_JOYPAD_A || i==RETRO_DEVICE_ID_JOYPAD_X || i==RETRO_DEVICE_ID_JOYPAD_START))
if (SHOWKEY==1 && (i==RETRO_DEVICE_ID_JOYPAD_B || i==RETRO_DEVICE_ID_JOYPAD_A || i==RETRO_DEVICE_ID_JOYPAD_Y || i==RETRO_DEVICE_ID_JOYPAD_X || i==RETRO_DEVICE_ID_JOYPAD_START))
continue;

if (input_state_cb(j, RETRO_DEVICE_JOYPAD, 0, i) && jbt[j][i]==0 && i!=turbo_fire_button)
Expand Down Expand Up @@ -1676,10 +1676,10 @@ void update_input(int disable_physical_cursor_keys)
int p_x = input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X);
int p_y = input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y);

if (p_x !=0 && p_y != 0 && (p_x != last_pointer_x || p_y != last_pointer_y))
if (p_x != 0 && p_y != 0 && (p_x != last_pointer_x || p_y != last_pointer_y))
{
int px = (int)((p_x + 0x7fff) * retrow / 0xffff);
int py = (int)((p_y + 0x7fff) * zoomed_height / 0xffff);
int py = (int)((p_y + 0x7fff) * retroh / 0xffff);
last_pointer_x = p_x;
last_pointer_y = p_y;
#ifdef POINTER_DEBUG
Expand All @@ -1689,7 +1689,7 @@ void update_input(int disable_physical_cursor_keys)
if (px >= vkbd_x_min && px <= vkbd_x_max && py >= vkbd_y_min && py <= vkbd_y_max)
{
float vkey_width = (float)(vkbd_x_max - vkbd_x_min) / NPLGN;
vkey_pos_x = ((px - 2) / vkey_width);
vkey_pos_x = ((px - vkbd_x_min) / vkey_width);

float vkey_height = (float)(vkbd_y_max - vkbd_y_min) / NLIGN;
vkey_pos_y = ((py - vkbd_y_min) / vkey_height);
Expand All @@ -1707,15 +1707,27 @@ void update_input(int disable_physical_cursor_keys)

/* Press Return, RetroPad Start */
i=RETRO_DEVICE_ID_JOYPAD_START;
if (vkflag[8]==0 && (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) || input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i)))
{
vkflag[8]=1;
retro_key_down(AK_RET);
}
else if (vkflag[8]==1 && (!input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && !input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i)))
{
vkflag[8]=0;
retro_key_up(AK_RET);
}

/* CapsLock, RetroPad Y */
i=RETRO_DEVICE_ID_JOYPAD_Y;
if (vkflag[7]==0 && (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) || input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i)))
{
vkflag[7]=1;
retro_key_down(AK_RET);
SHIFTON=-SHIFTON;
}
else if (vkflag[7]==1 && (!input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && !input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i)))
{
vkflag[7]=0;
retro_key_up(AK_RET);
}

/* Position toggle, RetroPad X */
Expand Down
69 changes: 54 additions & 15 deletions libretro/libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ bool opt_statusbar_minimal = false;
int opt_statusbar_position = 0;
int opt_statusbar_position_old = 0;
int opt_statusbar_position_offset = 0;
unsigned int opt_vkbd_theme = 0;
unsigned int opt_vkbd_alpha = 204;
bool opt_keyrahkeypad = false;
bool opt_keyboard_pass_through = false;
Expand All @@ -88,7 +89,6 @@ static char *uae_argv[] = { "puae", RPATH };
static int restart_pending = 0;

unsigned short int retro_bmp[RETRO_BMP_SIZE];
extern int SHIFTON;
extern int STATUSON;
extern int prefs_changed;

Expand Down Expand Up @@ -547,6 +547,19 @@ void retro_set_environment(retro_environment_t cb)
},
"bottom"
},
{
"puae_vkbd_theme",
"Virtual Keyboard Theme",
"By default, the keyboard comes up with SELECT button or F11 key.",
{
{ "0", "Classic" },
{ "1", "CD32" },
{ "2", "Dark" },
{ "3", "Light" },
{ NULL, NULL },
},
"0"
},
{
"puae_vkbd_alpha",
"Virtual Keyboard Transparency",
Expand Down Expand Up @@ -744,6 +757,17 @@ void retro_set_environment(retro_environment_t cb)
},
"100"
},
{
"puae_cd_speed",
"CD Speed",
"",
{
{ "100", "1x" },
{ "0", "Turbo" },
{ NULL, NULL },
},
"100"
},
{
"puae_shared_nvram",
"Shared CD32 NVRAM",
Expand Down Expand Up @@ -1165,10 +1189,10 @@ void retro_set_environment(retro_environment_t cb)
"RetroPad Face Button Options",
"Rotate face buttons clockwise and/or make 2nd fire press up.",
{
{ "disabled", NULL },
{ "rotate", "Rotate" },
{ "jump", "2nd fire = Up" },
{ "rotate_jump", "Rotate + 2nd fire = Up" },
{ "disabled", "B = Fire, A = 2nd fire" },
{ "jump", "B = Fire, A = Up" },
{ "rotate", "Y = Fire, B = 2nd fire" },
{ "rotate_jump", "Y = Fire, B = Up" },
{ NULL, NULL },
},
"disabled"
Expand All @@ -1178,10 +1202,10 @@ void retro_set_environment(retro_environment_t cb)
"CD32 Pad Face Button Options",
"Rotate face buttons clockwise and/or make blue button press up.",
{
{ "disabled", NULL },
{ "rotate", "Rotate" },
{ "jump", "Blue = Up" },
{ "rotate_jump", "Rotate + Blue = Up" },
{ "disabled", "B = Red, A = Blue" },
{ "jump", "B = Red, A = Up" },
{ "rotate", "Y = Red, B = Blue" },
{ "rotate_jump", "Y = Red, B = Up" },
{ NULL, NULL },
},
"disabled"
Expand Down Expand Up @@ -1463,6 +1487,13 @@ static void update_variables(void)
opt_statusbar_position_old = opt_statusbar_position;
}

var.key = "puae_vkbd_theme";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
opt_vkbd_theme = atoi(var.value);
}

var.key = "puae_vkbd_alpha";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
Expand Down Expand Up @@ -1644,6 +1675,18 @@ static void update_variables(void)
changed_prefs.sound_volume_cd=val;
}

var.key = "puae_cd_speed";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
strcat(uae_config, "cd_speed=");
strcat(uae_config, var.value);
strcat(uae_config, "\n");

if (libretro_runloop_active)
changed_prefs.cd_speed=atoi(var.value);
}

var.key = "puae_floppy_speed";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
Expand Down Expand Up @@ -2353,6 +2396,8 @@ static void update_variables(void)
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display);
option_display.key = "puae_statusbar";
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display);
option_display.key = "puae_vkbd_theme";
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display);
option_display.key = "puae_vkbd_alpha";
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display);

Expand Down Expand Up @@ -4686,12 +4731,6 @@ void retro_run(void)
// Virtual keyboard requires a graceful redraw, blunt reset_drawing() interferes with zoom
frame_redraw_necessary = 2;
print_virtual_kbd(retro_bmp);
#ifdef POINTER_DEBUG
if (pix_bytes == 4)
DrawHlineBmp32((uint32_t *)retro_bmp, pointer_x, pointer_y, 2, 2, RGB888(30, 0, 30));
else
DrawHlineBmp(retro_bmp, pointer_x, pointer_y, 2, 2, RGB565(30, 0, 30));
#endif
}
// Maximum 288p/576p PAL shenanigans:
// Mask the last line(s), since UAE does not refresh the last line, and even its own OSD will leave trails
Expand Down
Loading

0 comments on commit 16a5fd7

Please sign in to comment.