Commit 9bfe374d authored by David Skywalker's avatar David Skywalker
Browse files

KoS: wip multilanguage, lots clean!

parent 05c25125
......@@ -25,7 +25,8 @@ SOURCES_C := \
$(CORE_DIR)/cap32/kbdauto.c \
$(CORE_DIR)/libretro/microui/microui.c \
$(CORE_DIR)/libretro/gfx/software.c \
$(CORE_DIR)/libretro/assets/ui_keyboard.c \
$(CORE_DIR)/libretro/assets/ui_keyboard_bg.c \
$(CORE_DIR)/libretro/assets/ui_keyboard_en.c \
$(CORE_DIR)/libretro/assets/font.c \
$(CORE_DIR)/libretro/retro_strings.c \
$(CORE_DIR)/libretro/retro_utils.c \
......
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
/* Copyright (C) 2021
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//---------------------------------------------------------------------------------
#ifndef _ui_h_
#define _ui_h_
#ifndef _assets_h_
#define _assets_h_
//---------------------------------------------------------------------------------
#define IMG_KEYBOARD_WIDTH 384
#define IMG_KEYBOARD_HEIGHT 108
extern const unsigned char ui_keyboard_data[];
extern const int ui_keyboard_size;
extern const unsigned char ui_keyboard_bg[];
extern const int ui_keyboard_bg_size;
extern const unsigned char ui_keyboard_en[];
extern const int ui_keyboard_en_size;
//--------------------------------------------------------------------
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -23,7 +23,7 @@
#include <libretro.h>
#include <libretro-core.h>
#include "assets/ui.h"
#include "assets/assets.h"
#include "software.h"
// FIXME PIXEL_BYTES
......@@ -179,3 +179,23 @@ void draw_image_linear(PIXEL_TYPE * buffer, PIXEL_TYPE * img, int x, int y, unsi
*(buffer_ptr++) = *(img_ptr++);
}
}
void draw_image_transparent(PIXEL_TYPE * buffer, PIXEL_TYPE * img, int x, int y, unsigned int size)
{
PIXEL_TYPE * buffer_ptr = (
(PIXEL_TYPE *) (buffer + x) + (y * EMULATION_SCREEN_WIDTH)
);
PIXEL_TYPE * img_ptr = img;
unsigned int loop_counter = (EMULATION_SCALE * size);
while (loop_counter--)
{
uint32_t value = *(img_ptr++);
if (value != PIXEL_TRANSPARENT)
{
*(buffer_ptr) = value;
}
buffer_ptr++;
}
}
......@@ -31,6 +31,7 @@ void draw_text(PIXEL_TYPE * buffer, int x, int y, const char * text, PIXEL_TYPE
void draw_char(PIXEL_TYPE * buffer, int x, int y, char chr_idx, PIXEL_TYPE color);
void draw_image(PIXEL_TYPE * buffer, PIXEL_TYPE * img, int x, int y, int width, int height);
void draw_image_linear(PIXEL_TYPE * buffer, PIXEL_TYPE * img, int x, int y, unsigned int size);
void draw_image_transparent(PIXEL_TYPE * buffer, PIXEL_TYPE * img, int x, int y, unsigned int size);
void convert_image(PIXEL_TYPE * buffer, const unsigned int * img, unsigned int size);
PIXEL_TYPE convert_color (unsigned int color);
#endif
......@@ -11,7 +11,7 @@
#include "retro_ui.h"
#include "gfx/software.h"
#include "assets/ui.h"
#include "assets/assets.h"
char DISKA_NAME[512]="\0";
char DISKB_NAME[512]="\0";
......
......@@ -30,19 +30,22 @@ extern unsigned amstrad_devices[ PORTS_NUMBER ];
#define TEX_MAX_HEIGHT CPC_SCREEN_HEIGHT
// compile flags
#define NO_FLOPPY_SND
#define LOWRES
#define M16B // SCREEN 16BITS
//#define NO_FLOPPY_SND
//#define NO_BORDER
//#define LOWRES
//#define M16B // SCREEN 16BITS
#ifdef M16B
#define PIXEL_RAW_DENSITY 2
#define PIXEL_BYTES 1
#define PIXEL_TYPE unsigned short
#define PIXEL_TRANSPARENT 0x0000
#define PITCH 2
#else
#define PIXEL_RAW_DENSITY 1
#define PIXEL_BYTES 2
#define PIXEL_TYPE unsigned int
#define PIXEL_TRANSPARENT 0x000000
#define PITCH 4
#endif
......
......@@ -25,7 +25,7 @@
#include "retro_events.h"
#include "retro_keyboard.h"
#include "assets/ui.h"
#include "assets/assets.h"
#include "gfx/software.h"
extern PIXEL_TYPE video_buffer[WINDOW_MAX_SIZE];
......@@ -37,8 +37,8 @@ extern PIXEL_TYPE * keyboard_surface;
#define COMPOSE_YELLOW_COLOR RGB2COLOR(0xe7, 0xea, 0)
#define COMPOSE_PRESS_COLOR RGB2COLOR(0xea, 0, 0x22)
#define BASE_X 3
#define BASE_Y 12 + ( EMULATION_SCREEN_HEIGHT - IMG_KEYBOARD_HEIGHT )
#define BASE_X 2
#define BASE_Y (12 + ( EMULATION_SCREEN_HEIGHT - IMG_KEYBOARD_HEIGHT ))
#define KEY_HEIGHT 16
#define KEY_WIDTH 18
#define KEY_GAP 3
......@@ -48,7 +48,7 @@ extern PIXEL_TYPE * keyboard_surface;
typedef struct {
// calc keyboard position on screen
unsigned short x, y;
unsigned short top, left, bottom, right;
unsigned short w, h;
// keyboard internal value
unsigned char value;
......@@ -61,7 +61,7 @@ typedef struct {
static retro_keyboard kbd_data [KEYBOARD_MAX_KEYS];
static base_keyboard_t keyboard_positions [KEYBOARD_MAX_KEYS] = {
{ CPC_KEY_ESC , 20 },
{ CPC_KEY_ESC , 21 },
{ CPC_KEY_1 , KEY_WIDTH },
{ CPC_KEY_2 , KEY_WIDTH },
{ CPC_KEY_3 , KEY_WIDTH },
......@@ -81,7 +81,7 @@ static base_keyboard_t keyboard_positions [KEYBOARD_MAX_KEYS] = {
{ CPC_KEY_F9 , KEY_WIDTH },
{ CPC_KEY_NULL , 0 }, // next line
{ CPC_KEY_TAB , 31},
{ CPC_KEY_TAB , 32},
{ CPC_KEY_Q , KEY_WIDTH },
{ CPC_KEY_W , KEY_WIDTH },
{ CPC_KEY_E , KEY_WIDTH },
......@@ -100,7 +100,7 @@ static base_keyboard_t keyboard_positions [KEYBOARD_MAX_KEYS] = {
{ CPC_KEY_F6 , KEY_WIDTH },
{ CPC_KEY_NULL , 0 }, // next line
{ CPC_KEY_CAPS_LOCK, 37 },
{ CPC_KEY_CAPS_LOCK, 38 },
{ CPC_KEY_A , KEY_WIDTH },
{ CPC_KEY_S , KEY_WIDTH },
{ CPC_KEY_D , KEY_WIDTH },
......@@ -137,7 +137,7 @@ static base_keyboard_t keyboard_positions [KEYBOARD_MAX_KEYS] = {
{ CPC_KEY_FDOT , KEY_WIDTH },
{ CPC_KEY_NULL , 0 }, // next line
{ CPC_KEY_CONTROL, 37 },
{ CPC_KEY_CONTROL, 38 },
{ CPC_KEY_COPY, 36 },
{ CPC_KEY_SPACE, 168 },
{ CPC_KEY_INTRO, 65 },
......@@ -159,24 +159,44 @@ void keyboard_init()
}
kbd_data[key].value = keyboard_positions[key].value;
kbd_data[key].x = x;
kbd_data[key].y = y;
kbd_data[key].w = x + (keyboard_positions[key].width * EMULATION_SCALE);
kbd_data[key].h = y + KEY_HEIGHT;
kbd_data[key].w = keyboard_positions[key].width * EMULATION_SCALE;
kbd_data[key].h = KEY_HEIGHT;
x = kbd_data[key].w + (KEY_GAP * EMULATION_SCALE);
kbd_data[key].top = y;
kbd_data[key].left = x;
kbd_data[key].right = x + kbd_data[key].w;
kbd_data[key].bottom = y + kbd_data[key].h;
x = kbd_data[key].right + (KEY_GAP * EMULATION_SCALE);
}
}
static unsigned char _get_key()
{
for (int key = 0; key < KEYBOARD_MAX_KEYS; key++)
{
if (
mouse.x > kbd_data[key].x && mouse.x < kbd_data[key].w &&
mouse.y > kbd_data[key].y && mouse.y < kbd_data[key].h)
mouse.x > kbd_data[key].left && mouse.x < kbd_data[key].right &&
mouse.y > kbd_data[key].top && mouse.y < kbd_data[key].bottom)
{
//printf("mouse: (%u,%u) (%i=%u)\n", mouse.x, mouse.y, key, kbd_data[key].value);
#ifdef DEBUG_KOS
int y = ((kbd_data[key].top) - BASE_Y) + 14;
printf("mouse: (%u,%u %u,%u) [%i=%u]\n",
kbd_data[key].left, y, kbd_data[key].w, kbd_data[key].h,
key, kbd_data[key].value
);
draw_rect(
keyboard_surface,
kbd_data[key].left + 4,
y,
kbd_data[key].w,
kbd_data[key].h,
0xaaaaaa
);
#endif
return kbd_data[key].value;
}
}
......@@ -194,8 +214,8 @@ static void _draw_compose_led (unsigned char key, bool clicked)
draw_rect(
keyboard_surface,
kbd_data[keys].x + (2 * EMULATION_SCALE),
kbd_data[keys].y - ( EMULATION_SCREEN_HEIGHT - IMG_KEYBOARD_HEIGHT ) + 3,
kbd_data[keys].left + (2 * EMULATION_SCALE),
kbd_data[keys].top - ( EMULATION_SCREEN_HEIGHT - IMG_KEYBOARD_HEIGHT ) + 3,
KEYBOARD_LED_SIZE * EMULATION_SCALE,
KEYBOARD_LED_SIZE,
clicked ? COMPOSE_PRESS_COLOR : COMPOSE_CLEAN_COLOR
......
......@@ -25,7 +25,7 @@
#include "gfx/software.h"
#include "retro_render.h"
#include "assets/ui.h"
#include "assets/assets.h"
//unsigned int number = 0;
......
......@@ -29,7 +29,7 @@
#include "retro_events.h"
#include "retro_render.h"
#include "retro_keyboard.h"
#include "assets/ui.h"
#include "assets/assets.h"
extern PIXEL_TYPE video_buffer[WINDOW_MAX_SIZE];
extern PIXEL_TYPE bmp[WINDOW_MAX_SIZE];
......@@ -37,6 +37,7 @@ extern retro_mouse_t mouse;
extern computer_cfg_t retro_computer_cfg;
PIXEL_TYPE * keyboard_surface = NULL;
PIXEL_TYPE * keyboard_lang = NULL;
PIXEL_TYPE * ui_surface = NULL;
static unsigned char ui_status = 0;
......@@ -213,15 +214,25 @@ void retro_ui_init(void)
{
// prepare pointer to surface data
keyboard_surface = bmp;
ui_surface = bmp + ui_keyboard_size;
keyboard_lang = bmp + ((IMG_KEYBOARD_HEIGHT * IMG_KEYBOARD_WIDTH) * EMULATION_SCALE);
ui_surface = bmp + ((IMG_KEYBOARD_HEIGHT * IMG_KEYBOARD_WIDTH) * EMULATION_SCALE * 2);
// convert KeyboardOnScreen to current video/color-depth
convert_image(
keyboard_surface,
(const unsigned int *) ui_keyboard_data,
(const unsigned int *) ui_keyboard_bg,
IMG_KEYBOARD_HEIGHT * IMG_KEYBOARD_WIDTH
);
// convert raw keyboard to current video/color-depth
// and blit to keyboard_surface to optimize draw KoS
convert_image(
keyboard_lang,
(const unsigned int *) ui_keyboard_en,
IMG_KEYBOARD_HEIGHT * IMG_KEYBOARD_WIDTH
);
draw_image_transparent(keyboard_surface, keyboard_lang, 0, 0, IMG_KEYBOARD_HEIGHT * IMG_KEYBOARD_WIDTH);
// init KoS
keyboard_init();
retro_ui_update_text();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment