diff --git a/Makefile.common b/Makefile.common index 0e760f71a1..b658fae21b 100644 --- a/Makefile.common +++ b/Makefile.common @@ -2073,12 +2073,6 @@ OBJ += $(LIBRETRO_COMM_DIR)/formats/bmp/rbmp_encode.o \ $(LIBRETRO_COMM_DIR)/formats/image_transfer.o \ $(LIBRETRO_COMM_DIR)/formats/m3u/m3u_file.o -# Gong embedded core -ifeq ($(HAVE_GONG),1) - DEFINES += -DHAVE_GONG - OBJ += cores/libretro-gong/gong.o -endif - # Video4Linux 2 ifeq ($(HAVE_V4L2),1) diff --git a/cores/internal_cores.h b/cores/internal_cores.h index 250e33832f..08e916d63e 100644 --- a/cores/internal_cores.h +++ b/cores/internal_cores.h @@ -360,62 +360,6 @@ size_t libretro_videoprocessor_retro_get_memory_size(unsigned id); #endif -#ifdef HAVE_GONG -/* Internal gong core. */ - -void libretro_gong_retro_init(void); - -void libretro_gong_retro_deinit(void); - -unsigned libretro_gong_retro_api_version(void); - -void libretro_gong_retro_get_system_info(struct retro_system_info *info); - -void libretro_gong_retro_get_system_av_info(struct retro_system_av_info *info); - -void libretro_gong_retro_set_environment(retro_environment_t cb); - -void libretro_gong_retro_set_video_refresh(retro_video_refresh_t cb); - -void libretro_gong_retro_set_audio_sample(retro_audio_sample_t cb); - -void libretro_gong_retro_set_audio_sample_batch(retro_audio_sample_batch_t cb); - -void libretro_gong_retro_set_input_poll(retro_input_poll_t cb); - -void libretro_gong_retro_set_input_state(retro_input_state_t cb); - -void libretro_gong_retro_set_controller_port_device(unsigned port, unsigned device); - -void libretro_gong_retro_reset(void); - -void libretro_gong_retro_run(void); - -size_t libretro_gong_retro_serialize_size(void); - -bool libretro_gong_retro_serialize(void *data, size_t size); - -bool libretro_gong_retro_unserialize(const void *data, size_t size); - -void libretro_gong_retro_cheat_reset(void); - -void libretro_gong_retro_cheat_set(unsigned index, bool enabled, const char *code); - -bool libretro_gong_retro_load_game(const struct retro_game_info *game); - -bool libretro_gong_retro_load_game_special(unsigned game_type, - const struct retro_game_info *info, size_t num_info); - -void libretro_gong_retro_unload_game(void); - -unsigned libretro_gong_retro_get_region(void); - -void *libretro_gong_retro_get_memory_data(unsigned id); - -size_t libretro_gong_retro_get_memory_size(unsigned id); - -#endif - RETRO_END_DECLS #endif diff --git a/cores/libretro-gong/Makefile b/cores/libretro-gong/Makefile deleted file mode 100644 index 45b38098bf..0000000000 --- a/cores/libretro-gong/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -gong.so: gong.c - gcc \ - -std=c89 \ - -pedantic \ - -Wall \ - -Wno-unused-variable \ - -g \ - gong.c \ - -I../../libretro-common/include/ \ - -shared \ - -fPIC \ - -Wl,--no-undefined \ - -lm \ - -o gong.so - -clean: - rm -f gong.so diff --git a/cores/libretro-gong/gong.c b/cores/libretro-gong/gong.c deleted file mode 100644 index 56e74f5208..0000000000 --- a/cores/libretro-gong/gong.c +++ /dev/null @@ -1,939 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2017 - Daniel De Matteis - * Copyright (C) 2016-2019 - Brad Parker - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -/* Libretro port by Brad Parker, - Original source code by Dan Zaidan: https://danzaidan.itch.io/ - Original license: - "You can do whatever you want with the code, but I am providing it as is without any warranty whatsoever." - */ - -#include -#include -#include -#include -#include -#include - -#ifdef RARCH_INTERNAL -#include "internal_cores.h" -#define GONG_CORE_PREFIX(s) libretro_gong_##s -#else -#define GONG_CORE_PREFIX(s) s -#endif - -#define WIDTH 356 -#define HEIGHT 200 -#define MAX_PLAYERS 2 -#define STATE_SIZE 4096 /* can be anything as long as it's large enough to hold everything */ - -static retro_log_printf_t GONG_CORE_PREFIX(log_cb); -static retro_video_refresh_t GONG_CORE_PREFIX(video_cb); -static retro_input_poll_t GONG_CORE_PREFIX(input_poll_cb); -static retro_input_state_t GONG_CORE_PREFIX(input_state_cb); -static retro_audio_sample_t GONG_CORE_PREFIX(audio_cb); -static retro_audio_sample_batch_t GONG_CORE_PREFIX(audio_batch_cb); -static retro_environment_t GONG_CORE_PREFIX(environ_cb); - -static const char *GONG_CORE_PREFIX(valid_extensions) = "gong"; - -static unsigned char *video_buf = NULL; - -enum -{ - B_MOVE_UP, - B_MOVE_DOWN, - B_SPEED_UP, - B_COUNT /* This should always be in the bottom */ -}; - -/* any changes here must be handled in serialization code too */ -typedef struct -{ - union { float f; unsigned u; } py; - union { float f; unsigned u; } dpy; -} Player; - -/* any changes here must be handled in serialization code too */ -typedef struct -{ - int half_transition_count; - bool ended_down; -} Game_Button_State; - -/* any changes here must be handled in serialization code too */ -typedef struct -{ - Game_Button_State buttons[B_COUNT]; - float last_dt; /* not in savestate */ -} Game_Input; - -typedef struct -{ - uint16_t input; - uint16_t not_input; - uint16_t realinput; - int16_t analogYLeft; - int16_t analogYRight; -} retro_inputs; - -/* any changes here must be handled in serialization code too */ -typedef struct -{ - unsigned version; - unsigned player1_score; - unsigned player2_score; - union { float f; unsigned u; } player2_speed; - union { float f; unsigned u; } ball_px; - union { float f; unsigned u; } ball_py; - union { float f; unsigned u; } ball_dpx; - union { float f; unsigned u; } ball_dpy; - union { float f; unsigned u; } ball_speed; - union { float f; unsigned u; } current_play_points; - float refresh; /* not in savestate */ - bool is_initialized; - bool player2_human; - uint16_t previnput[MAX_PLAYERS]; - Game_Input g_input[MAX_PLAYERS]; - Player player[MAX_PLAYERS]; -} State; - -typedef struct -{ - /* Pixels are always 32-bit wide, memory order XX BB GG RR */ - int width; - int height; - int pitch; - void *memory; -} Game_Offscreen_Buffer; - -static State *g_state = NULL; -static Game_Offscreen_Buffer game_buffer = {0}; -static void game_update_and_render(Game_Input *input, Game_Offscreen_Buffer *draw_buffer); - -static const struct retro_controller_description pads1[] = { - { "Joypad", RETRO_DEVICE_JOYPAD }, - { NULL, 0 }, -}; - -static const struct retro_controller_description pads2[] = { - { "Joypad", RETRO_DEVICE_JOYPAD }, - { NULL, 0 }, -}; - -static const struct retro_controller_info ports[] = { - { pads1, 1 }, - { pads2, 1 }, - { 0 }, -}; - -struct retro_input_descriptor desc[] = { - { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, - { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, - { 0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" }, - { 0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y, "Right Analog Y" }, - - { 0 }, -}; - -static void check_variables(void) -{ - struct retro_variable var = {0}; - - var.key = "gong_refresh"; - if (GONG_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - int i; - g_state->refresh = atoi(var.value); - - for (i = 0; i < (int)(sizeof(g_state->g_input) / sizeof(g_state->g_input[0])); i++) - g_state->g_input[i].last_dt = 1.0f / g_state->refresh; - } - - var.key = "gong_player2"; - if (GONG_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - if (!strncmp(var.value, "CPU", 3)) - g_state->player2_human = false; - else if (!strncmp(var.value, "Human", 5)) - g_state->player2_human = true; - } -} - -static void save_state(void *data, size_t size) -{ - int i = 0; - int j = 0; - unsigned char *buf = (unsigned char*)data; - unsigned version = swap_if_little32(g_state->version); - unsigned player1_score = swap_if_little32(g_state->player1_score); - unsigned player2_score = swap_if_little32(g_state->player2_score); - unsigned player2_speed = swap_if_little32(g_state->player2_speed.u); - unsigned ball_px = swap_if_little32(g_state->ball_px.u); - unsigned ball_py = swap_if_little32(g_state->ball_py.u); - unsigned ball_dpx = swap_if_little32(g_state->ball_dpx.u); - unsigned ball_dpy = swap_if_little32(g_state->ball_dpy.u); - unsigned ball_speed = swap_if_little32(g_state->ball_speed.u); - unsigned current_play_points = swap_if_little32(g_state->current_play_points.u); - unsigned is_initialized = g_state->is_initialized; - unsigned player2_human = g_state->player2_human; - - (void)size; - - memcpy(buf, &version, sizeof(unsigned)); - buf += sizeof(unsigned); - - memcpy(buf, &player1_score, sizeof(unsigned)); - buf += sizeof(unsigned); - - memcpy(buf, &player2_score, sizeof(unsigned)); - buf += sizeof(unsigned); - - memcpy(buf, &player2_speed, sizeof(unsigned)); - buf += sizeof(unsigned); - - memcpy(buf, &ball_px, sizeof(unsigned)); - buf += sizeof(unsigned); - - memcpy(buf, &ball_py, sizeof(unsigned)); - buf += sizeof(unsigned); - - memcpy(buf, &ball_dpx, sizeof(unsigned)); - buf += sizeof(unsigned); - - memcpy(buf, &ball_dpy, sizeof(unsigned)); - buf += sizeof(unsigned); - - memcpy(buf, &ball_speed, sizeof(unsigned)); - buf += sizeof(unsigned); - - memcpy(buf, ¤t_play_points, sizeof(unsigned)); - buf += sizeof(unsigned); - - memcpy(buf, &is_initialized, sizeof(unsigned)); - buf += sizeof(unsigned); - - memcpy(buf, &player2_human, sizeof(unsigned)); - buf += sizeof(unsigned); - - /* previnput */ - for (i = 0; i < MAX_PLAYERS; i++) - { - uint16_t previnput = swap_if_little16(g_state->previnput[i]); - memcpy(buf, &previnput, sizeof(uint16_t)); - buf += sizeof(uint16_t); - } - - /* g_input */ - for (i = 0; i < MAX_PLAYERS; i++) - { - for (j = 0; j < B_COUNT; j++) - { - int half_transition_count = swap_if_little32(g_state->g_input[i].buttons[j].half_transition_count); - unsigned ended_down = g_state->g_input[i].buttons[j].ended_down; - - memcpy(buf, &half_transition_count, sizeof(int)); - buf += sizeof(int); - - memcpy(buf, &ended_down, sizeof(unsigned)); - buf += sizeof(unsigned); - } - } - - /* player */ - for (i = 0; i < MAX_PLAYERS; i++) - { - unsigned py = swap_if_little32((unsigned)g_state->player[i].py.u); - - memcpy(buf, &py, sizeof(unsigned)); - buf += sizeof(uint16_t); - } -} - -static void load_state(const void *data, size_t size) -{ - int i = 0; - int j = 0; - const unsigned char *buf = (const unsigned char*)data; - - (void)size; - - memset(g_state, 0, sizeof(*g_state)); - - g_state->version = swap_if_little32(*(unsigned*)buf); - buf += sizeof(unsigned); - - g_state->player1_score = swap_if_little32(*(unsigned*)buf); - buf += sizeof(unsigned); - - g_state->player2_score = swap_if_little32(*(unsigned*)buf); - buf += sizeof(unsigned); - - g_state->player2_speed.u = swap_if_little32(*(unsigned*)buf); - buf += sizeof(unsigned); - - g_state->ball_px.u = swap_if_little32(*(unsigned*)buf); - buf += sizeof(unsigned); - - g_state->ball_py.u = swap_if_little32(*(unsigned*)buf); - buf += sizeof(unsigned); - - g_state->ball_dpx.u = swap_if_little32(*(unsigned*)buf); - buf += sizeof(unsigned); - - g_state->ball_dpy.u = swap_if_little32(*(unsigned*)buf); - buf += sizeof(unsigned); - - g_state->ball_speed.u = swap_if_little32(*(unsigned*)buf); - buf += sizeof(unsigned); - - g_state->current_play_points.u = swap_if_little32(*(unsigned*)buf); - buf += sizeof(unsigned); - - g_state->is_initialized = (bool)swap_if_little32(*(unsigned*)buf); - buf += sizeof(unsigned); - - g_state->player2_human = (bool)swap_if_little32(*(unsigned*)buf); - buf += sizeof(unsigned); - - /* previnput */ - for (i = 0; i < MAX_PLAYERS; i++) - { - uint16_t previnput = swap_if_little16(*(uint16_t*)buf); - g_state->previnput[i] = previnput; - buf += sizeof(uint16_t); - } - - /* g_input */ - for (i = 0; i < MAX_PLAYERS; i++) - { - for (j = 0; j < B_COUNT; j++) - { - int half_transition_count; - bool ended_down; - - half_transition_count = (int)swap_if_little32(*(unsigned*)buf); - - g_state->g_input[i].buttons[j].half_transition_count = half_transition_count; - buf += sizeof(int); - - ended_down = (bool)swap_if_little32(*(unsigned*)buf); - - g_state->g_input[i].buttons[j].ended_down = ended_down; - buf += sizeof(unsigned); - } - } - - /* player */ - for (i = 0; i < MAX_PLAYERS; i++) - { - g_state->player[i].py.u = swap_if_little32(*(unsigned*)buf); - buf += sizeof(unsigned); - - g_state->player[i].dpy.u = swap_if_little32(*(unsigned*)buf); - buf += sizeof(unsigned); - } - - check_variables(); -} - -static INLINE bool is_down(Game_Button_State state) -{ - return state.ended_down; -} - -void GONG_CORE_PREFIX(retro_get_system_info)(struct retro_system_info *info) -{ - info->library_name = "gong"; - info->library_version = "v1.0"; - info->need_fullpath = false; - info->block_extract = false; - info->valid_extensions = GONG_CORE_PREFIX(valid_extensions); -} - -void GONG_CORE_PREFIX(retro_get_system_av_info)(struct retro_system_av_info *info) -{ - info->geometry.base_width = WIDTH; - info->geometry.base_height = HEIGHT; - info->geometry.max_width = WIDTH; - info->geometry.max_height = HEIGHT; - info->geometry.aspect_ratio = 16.0f / 9.0f; - info->timing.fps = g_state->refresh; - info->timing.sample_rate = 44100.0; -} - -void GONG_CORE_PREFIX(retro_init)(void) -{ - struct retro_log_callback log; - - g_state = (State*)calloc(1, sizeof(*g_state)); - - if (GONG_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log)) - GONG_CORE_PREFIX(log_cb) = log.log; - else - GONG_CORE_PREFIX(log_cb) = NULL; - - video_buf = (unsigned char*)calloc(1, WIDTH * HEIGHT * sizeof(unsigned)); - - game_buffer.width = WIDTH; - game_buffer.height = HEIGHT; - game_buffer.pitch = WIDTH * sizeof(unsigned); - game_buffer.memory = video_buf; -} - -void GONG_CORE_PREFIX(retro_deinit)(void) -{ - if (video_buf) - free(video_buf); - - video_buf = NULL; - game_buffer.memory = NULL; - - if (g_state) - free(g_state); -} - -void GONG_CORE_PREFIX(retro_set_environment)(retro_environment_t cb) -{ - bool no_content = true; - - static const struct retro_variable vars[] = { - { "gong_player2", "Player 2; CPU|Human" }, - { "gong_refresh", "Video Refresh Rate (restart); 60|70|72|75|100|119|120|140|144" }, - { NULL, NULL }, - }; - - GONG_CORE_PREFIX(environ_cb) = cb; - - cb(RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME, &no_content); - cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars); - cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports); -} - -void GONG_CORE_PREFIX(retro_set_video_refresh)(retro_video_refresh_t cb) -{ - GONG_CORE_PREFIX(video_cb) = cb; -} - -void GONG_CORE_PREFIX(retro_set_audio_sample)(retro_audio_sample_t cb) -{ - GONG_CORE_PREFIX(audio_cb) = cb; -} - -void GONG_CORE_PREFIX(retro_set_audio_sample_batch)(retro_audio_sample_batch_t cb) -{ - GONG_CORE_PREFIX(audio_batch_cb) = cb; -} - -void GONG_CORE_PREFIX(retro_set_input_poll)(retro_input_poll_t cb) -{ - GONG_CORE_PREFIX(input_poll_cb) = cb; -} - -void GONG_CORE_PREFIX(retro_set_input_state)(retro_input_state_t cb) -{ - GONG_CORE_PREFIX(input_state_cb) = cb; -} - -void GONG_CORE_PREFIX(retro_set_controller_port_device)(unsigned a, unsigned b) -{ -} - -void GONG_CORE_PREFIX(retro_reset)(void) -{ - memset(g_state, 0, sizeof(*g_state)); - check_variables(); -} - -size_t GONG_CORE_PREFIX(retro_serialize_size)(void) -{ - return STATE_SIZE; -} - -bool GONG_CORE_PREFIX(retro_serialize)(void *data, size_t size) -{ - if (size != STATE_SIZE) - return false; - - save_state(data, size); - return true; -} - -bool GONG_CORE_PREFIX(retro_unserialize)(const void *data, size_t size) -{ - if (size != STATE_SIZE) - return false; - - load_state(data, size); - return true; -} - -void GONG_CORE_PREFIX(retro_cheat_reset)(void) -{ -} - -void GONG_CORE_PREFIX(retro_cheat_set)(unsigned a, bool b, const char * c) -{ -} - -bool GONG_CORE_PREFIX(retro_load_game)(const struct retro_game_info *info) -{ - enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888; - - check_variables(); - - if (!GONG_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) - { - if (GONG_CORE_PREFIX(log_cb)) - GONG_CORE_PREFIX(log_cb)(RETRO_LOG_INFO, "XRGB8888 is not supported.\n"); - return false; - } - - return true; -} - -bool GONG_CORE_PREFIX(retro_load_game_special)(unsigned a, const struct retro_game_info *b, size_t c) -{ - return false; -} - -void GONG_CORE_PREFIX(retro_unload_game)(void) -{ -} - -unsigned GONG_CORE_PREFIX(retro_get_region)(void) -{ - return RETRO_REGION_NTSC; -} - -void* GONG_CORE_PREFIX(retro_get_memory_data)(unsigned id) -{ - return NULL; -} - -size_t GONG_CORE_PREFIX(retro_get_memory_size)(unsigned id) -{ - return 0; -} - -static void process_joypad(Game_Button_State *new_state, bool is_down) -{ - if (new_state->ended_down != is_down) - { - new_state->ended_down = is_down; - new_state->half_transition_count += 1; - } -} - -static bool is_key_up_or_down(int16_t input, int16_t not_input, int key) -{ - if (input & (1 << key) || not_input & (1 << key)) - return true; - - return false; -} - -void GONG_CORE_PREFIX(retro_run)(void) -{ - int i = 0; - int port = 0; - bool updated = false; - retro_inputs inputs[MAX_PLAYERS] = {{0}}; - - if (GONG_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) - check_variables(); - - GONG_CORE_PREFIX(input_poll_cb)(); - - for (port = 0; port < MAX_PLAYERS; port++) - { - for (i = 0; i < 16; i++) - { - if (GONG_CORE_PREFIX(input_state_cb)(port, RETRO_DEVICE_JOYPAD, 0, i)) - { - inputs[port].realinput |= 1 << i; - } - } - - inputs[port].analogYLeft = GONG_CORE_PREFIX(input_state_cb)(port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 5000.0f; - inputs[port].analogYRight = GONG_CORE_PREFIX(input_state_cb)(port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 5000.0f; - - if (inputs[port].analogYLeft > 0) - inputs[port].realinput |= (1 << RETRO_DEVICE_ID_JOYPAD_DOWN); - else if (inputs[port].analogYRight > 0) - inputs[port].realinput |= (1 << RETRO_DEVICE_ID_JOYPAD_DOWN); - - if (inputs[port].analogYLeft < 0) - inputs[port].realinput |= (1 << RETRO_DEVICE_ID_JOYPAD_UP); - else if (inputs[port].analogYRight < 0) - inputs[port].realinput |= (1 << RETRO_DEVICE_ID_JOYPAD_UP); - - inputs[port].input = inputs[port].realinput & ~g_state->previnput[port]; - inputs[port].not_input = g_state->previnput[port] & ~inputs[port].realinput; - - if (is_key_up_or_down(inputs[port].input, inputs[port].not_input, RETRO_DEVICE_ID_JOYPAD_UP)) - process_joypad(&g_state->g_input[port].buttons[B_MOVE_UP], inputs[port].realinput & (1 << RETRO_DEVICE_ID_JOYPAD_UP)); - else if (is_key_up_or_down(inputs[port].input, inputs[port].not_input, RETRO_DEVICE_ID_JOYPAD_DOWN)) - process_joypad(&g_state->g_input[port].buttons[B_MOVE_DOWN], inputs[port].realinput & (1 << RETRO_DEVICE_ID_JOYPAD_DOWN)); - else if (is_key_up_or_down(inputs[port].input, inputs[port].not_input, RETRO_DEVICE_ID_JOYPAD_DOWN)) - process_joypad(&g_state->g_input[port].buttons[B_MOVE_DOWN], inputs[port].realinput & (1 << RETRO_DEVICE_ID_JOYPAD_DOWN)); - - if (is_key_up_or_down(inputs[port].input, inputs[port].not_input, RETRO_DEVICE_ID_JOYPAD_A)) - process_joypad(&g_state->g_input[port].buttons[B_SPEED_UP], inputs[port].realinput & (1 << RETRO_DEVICE_ID_JOYPAD_A)); - else if (is_key_up_or_down(inputs[port].input, inputs[port].not_input, RETRO_DEVICE_ID_JOYPAD_B)) - process_joypad(&g_state->g_input[port].buttons[B_SPEED_UP], inputs[port].realinput & (1 << RETRO_DEVICE_ID_JOYPAD_B)); - else if (is_key_up_or_down(inputs[port].input, inputs[port].not_input, RETRO_DEVICE_ID_JOYPAD_X)) - process_joypad(&g_state->g_input[port].buttons[B_SPEED_UP], inputs[port].realinput & (1 << RETRO_DEVICE_ID_JOYPAD_X)); - else if (is_key_up_or_down(inputs[port].input, inputs[port].not_input, RETRO_DEVICE_ID_JOYPAD_Y)) - process_joypad(&g_state->g_input[port].buttons[B_SPEED_UP], inputs[port].realinput & (1 << RETRO_DEVICE_ID_JOYPAD_Y)); - - g_state->previnput[port] = inputs[port].realinput; - } - - game_update_and_render(g_state->g_input, &game_buffer); - - GONG_CORE_PREFIX(video_cb)(video_buf, WIDTH, HEIGHT, WIDTH * sizeof(uint32_t)); -} - -unsigned GONG_CORE_PREFIX(retro_api_version)(void) -{ - return RETRO_API_VERSION; -} - -static void draw_rect_in_pixels(Game_Offscreen_Buffer *buffer, unsigned color, int min_x, int min_y, int max_x, int max_y) -{ - int y; - - min_x = MAX(min_x, 0); - min_y = MAX(min_y, 0); - max_x = MIN(max_x, buffer->width); - max_y = MIN(max_y, buffer->height); - - for (y = min_y; y < max_y; y++) - { - int x; - - for (x = min_x; x < max_x; x++) - { - unsigned *pixel = (unsigned*)((unsigned char*)buffer->memory + ((buffer->width * (buffer->height - y - 1) + x) * sizeof(unsigned))); - - *pixel++ = color; - } - } -} - -static void clear(Game_Offscreen_Buffer *buffer, unsigned color) -{ - draw_rect_in_pixels(buffer, color, 0, 0, buffer->width, buffer->height); -} - -static void draw_rect(Game_Offscreen_Buffer *buffer, unsigned color, float x, float y, float half_size_x, float half_size_y) -{ - /* @Hardcoded to always keep the playing field area on screen, no matter the aspect ratio */ - float scale = .01f; - float relative_axis = (float)buffer->height; - int min_x, min_y, max_x, max_y; - - if ((float)buffer->width / (float)buffer->height < 1.77f) - { - relative_axis = (float)buffer->width; - scale = .0056f; - } - - half_size_x *= relative_axis * scale; - half_size_y *= relative_axis * scale; - x *= relative_axis * scale; - y *= relative_axis * scale; - - x = x + buffer->width / 2; - y = y + buffer->height / 2; - - min_x = (unsigned)(x - half_size_x); - min_y = (unsigned)(y - half_size_y); - max_x = (unsigned)(x + half_size_x); - max_y = (unsigned)(y + half_size_y); - - draw_rect_in_pixels(buffer, color, min_x, min_y, max_x, max_y); -} - -static void draw_number(Game_Offscreen_Buffer *buffer, unsigned number, unsigned color, float x, float y) -{ - float at_x = x; - - do { - unsigned alg = number % 10; - - number /= 10; - - switch (alg) - { - case 0: - { - draw_rect(buffer, color, at_x - 2.f, y, .5f, 4.f); - draw_rect(buffer, color, at_x + 2.f, y, .5f, 4.f); - draw_rect(buffer, color, at_x, y + 4.f, 2.5f, .5f); - draw_rect(buffer, color, at_x, y - 4.f, 2.5f, .5f); - break; - } - - case 1: - { - draw_rect(buffer, color, at_x + 2.f, y, .5f, 4.5f); - break; - } - - case 2: - { - draw_rect(buffer, color, at_x - 2.f, y - 2.f, .5f, 2.f); - draw_rect(buffer, color, at_x + 2.f, y + 2.f, .5f, 2.f); - draw_rect(buffer, color, at_x, y + 4.f, 2.5f, .5f); - draw_rect(buffer, color, at_x, y, 2.5f, .5f); - draw_rect(buffer, color, at_x, y - 4.f, 2.5f, .5f); - break; - } - - case 3: - { - draw_rect(buffer, color, at_x + 2.f, y, .5f, 4.f); - draw_rect(buffer, color, at_x, y + 4.f, 2.5f, .5f); - draw_rect(buffer, color, at_x, y, 2.5f, .5f); - draw_rect(buffer, color, at_x, y - 4.f, 2.5f, .5f); - break; - }; - - case 4: - { - draw_rect(buffer, color, at_x, y, 2.5f, .5f); - draw_rect(buffer, color, at_x + 2.f, y, .5f, 4.5f); - draw_rect(buffer, color, at_x - 2.f, y+2.5f, .5f, 2.f); - break; - }; - - case 5: - { - draw_rect(buffer, color, at_x + 2.f, y-2.f, .5f, 2.f); - draw_rect(buffer, color, at_x - 2.f, y+2.f, .5f, 2.f); - draw_rect(buffer, color, at_x, y + 4.f, 2.5f, .5f); - draw_rect(buffer, color, at_x, y, 2.5f, .5f); - draw_rect(buffer, color, at_x, y - 4.f, 2.5f, .5f); - break; - }; - - case 6: - { - draw_rect(buffer, color, at_x + 2.f, y-2.f, .5f, 2.f); - draw_rect(buffer, color, at_x - 2.f, y, .5f, 4.f); - draw_rect(buffer, color, at_x, y + 4.f, 2.5f, .5f); - draw_rect(buffer, color, at_x, y, 2.5f, .5f); - draw_rect(buffer, color, at_x, y - 4.f, 2.5f, .5f); - break; - }; - - case 7: - { - draw_rect(buffer, color, at_x + 2.f, y, .5f, 4.5f); - draw_rect(buffer, color, at_x, y + 4.f, 2.5f, .5f); - break; - }; - - case 8: - { - draw_rect(buffer, color, at_x - 2.f, y, .5f, 4.f); - draw_rect(buffer, color, at_x + 2.f, y, .5f, 4.f); - draw_rect(buffer, color, at_x, y + 4.f, 2.5f, .5f); - draw_rect(buffer, color, at_x, y - 4.f, 2.5f, .5f); - draw_rect(buffer, color, at_x, y, 2.5f, .5f); - break; - }; - - case 9: - { - draw_rect(buffer, color, at_x - 2.f, y + 2.f, .5f, 2.f); - draw_rect(buffer, color, at_x + 2.f, y, .5f, 4.f); - draw_rect(buffer, color, at_x, y + 4.f, 2.5f, .5f); - draw_rect(buffer, color, at_x, y, 2.5f, .5f); - draw_rect(buffer, color, at_x, y - 4.f, 2.5f, .5f); - break; - }; - - default: - break; - } - - at_x -= 7.f; - } while(number > 0); -} - -static void game_update_and_render(Game_Input *input, Game_Offscreen_Buffer *draw_buffer) -{ - const float initial_ball_speed = 80.f; - float playing_field_x = 85.f; - float playing_field_y = 48.f; - float player_size_x = 2.5f; - float player_size_y = 10.f; - int i; - - if (!g_state->is_initialized) - { - g_state->is_initialized = 1; - g_state->ball_px.f = 0; - g_state->ball_py.f = 0; - g_state->ball_dpx.f = initial_ball_speed; - g_state->ball_dpy.f = 0; - g_state->current_play_points.f = 10.f; - g_state->player2_speed.f = 80.f; - } - - for (i = 0; i < MAX_PLAYERS; i++) - { - float speed = 80.f; - - if (i == 1 && !g_state->player2_human) - break; - - g_state->player[i].dpy.f = 0.f; - - if (is_down(input[i].buttons[B_SPEED_UP])) - speed = 150.f; - - if (is_down(input[i].buttons[B_MOVE_UP])) - { - if (g_state->player[i].py.f < playing_field_y - player_size_y) - { - g_state->player[i].dpy.f = speed; - } - - if (g_state->player[i].py.f < -playing_field_y + player_size_y) - { - g_state->player[i].py.f = -playing_field_y + player_size_y; - g_state->player[i].dpy.f = 0.f; - } - } - if (is_down(input[i].buttons[B_MOVE_DOWN])) - { - if (g_state->player[i].py.f > -playing_field_y + player_size_y) - { - g_state->player[i].dpy.f = -speed; - } - - if (g_state->player[i].py.f < -playing_field_y + player_size_y) - { - g_state->player[i].py.f = -playing_field_y + player_size_y; - g_state->player[i].dpy.f = 0.f; - } - } - - g_state->player[i].py.f += g_state->player[i].dpy.f * input->last_dt; - } - - if (!g_state->player2_human) - { - g_state->player[1].dpy.f = (g_state->ball_py.f - g_state->player[1].py.f) * 100.f; - g_state->player[1].dpy.f = MIN(g_state->player[1].dpy.f, g_state->player2_speed.f); - g_state->player[1].dpy.f = MAX(g_state->player[1].dpy.f, -g_state->player2_speed.f); - g_state->player[1].py.f += g_state->player[1].dpy.f * input->last_dt; - - if (g_state->player[1].py.f < -playing_field_y + player_size_y) - { - g_state->player[1].py.f = -playing_field_y + player_size_y; - g_state->player[1].dpy.f = 0.f; - } - - if (g_state->player[1].py.f > playing_field_y - player_size_y) - { - g_state->player[1].py.f = playing_field_y - player_size_y; - g_state->player[1].dpy.f = 0.f; - } - } - - g_state->ball_px.f += g_state->ball_dpx.f * input->last_dt; - - if (g_state->ball_dpx.f > 0) - { - g_state->ball_dpx.f += 10.f * input->last_dt; - } - else - { - g_state->ball_dpx.f -= 10.f * input->last_dt; - } - - g_state->ball_py.f += g_state->ball_dpy.f * input->last_dt; - - if (g_state->ball_py.f > playing_field_y - 1.f) - { - g_state->ball_py.f = playing_field_y - 1.f; - g_state->ball_dpy.f *= -1.f; - } - else if (g_state->ball_py.f < -playing_field_y + 1) - { - g_state->ball_py.f = -playing_field_y + 1.f; - g_state->ball_dpy.f *= -1; - } - - if (g_state->ball_px.f > 80.f - 2.5f - 1.f) /* @Hardcoded */ - { - if ((g_state->ball_py.f >= (g_state->player[1].py.f - 10.f)) && (g_state->ball_py.f <= (g_state->player[1].py.f + 10.f))) - { - g_state->ball_dpx.f *= -1.f; - g_state->ball_px.f = 80.f - 2.5f - 1.f; /* @Hardcoded */ - g_state->ball_dpy.f = (g_state->ball_py.f - g_state->player[1].py.f) + g_state->player[1].dpy.f; - ++g_state->current_play_points.f; - } - else if (g_state->ball_px.f >= playing_field_x - 1) - { - g_state->ball_px.f = 0; - g_state->ball_py.f = 0; - g_state->ball_dpy.f = 0; - g_state->ball_dpx.f = -initial_ball_speed; - g_state->player2_score += (unsigned)g_state->current_play_points.f; - g_state->current_play_points.f = 10.f; - } - } - else if (g_state->ball_px.f < -80 + 2.5f + 1.f) /* @Hardcoded */ - { - if ((g_state->ball_py.f >= (g_state->player[0].py.f - 10.f)) && (g_state->ball_py.f <= (g_state->player[0].py.f + 10.f))) - { - g_state->ball_dpx.f *= -1.f; - g_state->ball_px.f = -80 + 2.5f + 1.f; /* @Hardcoded */ - g_state->ball_dpy.f = (g_state->ball_py.f - g_state->player[0].py.f) + g_state->player[0].dpy.f; - ++g_state->current_play_points.f; - } - else if (g_state->ball_px.f <= -playing_field_x + 1) - { - g_state->ball_px.f = 0; - g_state->ball_py.f = 0; - g_state->ball_dpy.f = 0; - g_state->ball_dpx.f = initial_ball_speed; - g_state->player1_score += (unsigned)g_state->current_play_points.f; - g_state->current_play_points.f = 10.f; - - if (!g_state->player2_human) - g_state->player2_speed.f += g_state->current_play_points.f * 0.01f; - } - } - - clear(draw_buffer, 0x021077); - draw_rect(draw_buffer, 0x000530, 0.f, 0.f, playing_field_x, playing_field_y); - - draw_rect(draw_buffer, 0x00ffff, -80.f, g_state->player[0].py.f, player_size_x, player_size_y); - draw_rect(draw_buffer, 0x00ffff, 80.f, g_state->player[1].py.f, player_size_x, player_size_y); - - draw_rect(draw_buffer, 0xffff00, g_state->ball_px.f, g_state->ball_py.f, 1.f, 1.f); - - draw_number(draw_buffer, (unsigned)g_state->current_play_points.f, 0xaaaaaa, 0.f, 38.f); - draw_number(draw_buffer, g_state->player1_score, 0xff6611, 20.f, 38.f); - draw_number(draw_buffer, g_state->player2_score, 0xff6611, -20.f, 38.f); -} diff --git a/cores/libretro-gong/internal_cores.h b/cores/libretro-gong/internal_cores.h deleted file mode 100644 index 7e1a2aab98..0000000000 --- a/cores/libretro-gong/internal_cores.h +++ /dev/null @@ -1 +0,0 @@ -#include "../internal_cores.h" diff --git a/cores/libretro-gong/link.T b/cores/libretro-gong/link.T deleted file mode 100644 index 9e82b5dd3f..0000000000 --- a/cores/libretro-gong/link.T +++ /dev/null @@ -1,4 +0,0 @@ -{ - global: retro_*; - local: *; -}; diff --git a/griffin/griffin.c b/griffin/griffin.c index e9fe20ed48..2c7490d577 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -1664,10 +1664,6 @@ SSL #endif #endif -#ifdef HAVE_GONG -#include "../cores/libretro-gong/gong.c" -#endif - /*============================================================ PLAYLIST NAME SANITIZATION ============================================================ */ diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index 5f0f0d5e5a..65467fd97b 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -9702,10 +9702,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NETPLAY_COMPAT_CONTENT_FOUND, "Conteúdo compatível encontrado" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_START_GONG, - "Iniciar gong" - ) /* Unused (Only Exist in Translation Files) */ diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 53f19456b6..3c36d20933 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3761,7 +3761,6 @@ static int action_ok_load_core_deferred(const char *path, } DEFAULT_ACTION_OK_START_BUILTIN_CORE(action_ok_start_net_retropad_core, CORE_TYPE_NETRETROPAD) -DEFAULT_ACTION_OK_START_BUILTIN_CORE(action_ok_start_gong_core, CORE_TYPE_GONG) DEFAULT_ACTION_OK_START_BUILTIN_CORE(action_ok_start_video_processor_core, CORE_TYPE_VIDEO_PROCESSOR) #if defined(HAVE_FFMPEG) || defined(HAVE_MPV) @@ -7789,7 +7788,6 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, {MENU_ENUM_LABEL_FILE_BROWSER_CORE_SELECT_FROM_COLLECTION_CURRENT_CORE,action_ok_core_deferred_set}, {MENU_ENUM_LABEL_START_CORE, action_ok_start_core}, {MENU_ENUM_LABEL_START_NET_RETROPAD, action_ok_start_net_retropad_core}, - {MENU_ENUM_LABEL_START_GONG, action_ok_start_gong_core}, {MENU_ENUM_LABEL_START_VIDEO_PROCESSOR, action_ok_start_video_processor_core}, {MENU_ENUM_LABEL_OPEN_ARCHIVE_DETECT_CORE, action_ok_open_archive_detect_core}, {MENU_ENUM_LABEL_OPEN_ARCHIVE, action_ok_open_archive}, diff --git a/runloop.c b/runloop.c index d9f8c42b86..8c7ae6afc3 100644 --- a/runloop.c +++ b/runloop.c @@ -279,10 +279,6 @@ #define SYMBOL_VIDEOPROCESSOR(x) current_core->x = libretro_videoprocessor_##x #endif -#ifdef HAVE_GONG -#define SYMBOL_GONG(x) current_core->x = libretro_gong_##x -#endif - #define CORE_SYMBOLS(x) \ x(retro_init); \ x(retro_deinit); \ @@ -3463,11 +3459,6 @@ static bool init_libretro_symbols_custom( case CORE_TYPE_VIDEO_PROCESSOR: #if defined(HAVE_VIDEOPROCESSOR) CORE_SYMBOLS(SYMBOL_VIDEOPROCESSOR); -#endif - break; - case CORE_TYPE_GONG: -#ifdef HAVE_GONG - CORE_SYMBOLS(SYMBOL_GONG); #endif break; }