Merge remote-tracking branch 'refs/remotes/origin/master'

This commit is contained in:
nretro
2019-05-25 20:04:43 +02:00
23 changed files with 1104 additions and 124 deletions

View File

@@ -5,7 +5,7 @@ SHELL = /bin/bash -o pipefail
BASE = arm-linux-gnueabihf
CC = $(BASE)-gcc
LD = $(CC)
LD = $(BASE)-ld
STRIP = $(BASE)-strip
ifeq ($(V),1)
@@ -22,6 +22,7 @@ INCLUDE += -I./lib/miniz
PRJ = MiSTer
SRC = $(wildcard *.c)
SRC2 = $(wildcard *.cpp)
IMG = $(wildcard *.png)
MINIMIG_SRC = $(wildcard ./support/minimig/*.cpp)
SHARPMZ_SRC = $(wildcard ./support/sharpmz/*.cpp)
ARCHIE_SRC = $(wildcard ./support/archie/*.cpp)
@@ -32,18 +33,20 @@ LIBCO_SRC = lib/libco/arm.c
LODEPNG_SRC = lib/lodepng/lodepng.cpp
MINIZ_SRC = $(wildcard ./lib/miniz/*.c)
IMLIB2_LIB = -Llib/imlib2 -lfreetype -lbz2 -lpng16 -lz -lImlib2
VPATH = ./:./support/minimig:./support/sharpmz:./support/archie:./support/st:./support/x86:./support/snes
OBJ = $(SRC:.c=.c.o) $(SRC2:.cpp=.cpp.o) $(MINIMIG_SRC:.cpp=.cpp.o) $(SHARPMZ_SRC:.cpp=.cpp.o) $(ARCHIE_SRC:.cpp=.cpp.o) $(ST_SRC:.cpp=.cpp.o) $(X86_SRC:.cpp=.cpp.o) $(SNES_SRC:.cpp=.cpp.o) $(LIBCO_SRC:.c=.c.o) $(MINIZ_SRC:.c=.c.o) $(LODEPNG_SRC:.cpp=.cpp.o)
OBJ = $(SRC:.c=.c.o) $(SRC2:.cpp=.cpp.o) $(IMG:.png=.png.o) $(MINIMIG_SRC:.cpp=.cpp.o) $(SHARPMZ_SRC:.cpp=.cpp.o) $(ARCHIE_SRC:.cpp=.cpp.o) $(ST_SRC:.cpp=.cpp.o) $(X86_SRC:.cpp=.cpp.o) $(SNES_SRC:.cpp=.cpp.o) $(LIBCO_SRC:.c=.c.o) $(MINIZ_SRC:.c=.c.o) $(LODEPNG_SRC:.cpp=.cpp.o)
DEP = $(SRC:.c=.cpp.d) $(SRC2:.cpp=.cpp.d) $(MINIMIG_SRC:.cpp=.cpp.d) $(SHARPMZ_SRC:.cpp=.cpp.d) $(ARCHIE_SRC:.cpp=.cpp.d) $(ST_SRC:.cpp=.cpp.d) $(X86_SRC:.cpp=.cpp.d) $(SNES_SRC:.cpp=.cpp.d) $(LIBCO_SRC:.c=.c.d) $(MINIZ_SRC:.c=.c.d) $(LODEPNG_SRC:.cpp=.cpp.d)
DFLAGS = $(INCLUDE) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DVDATE=\"`date +"%y%m%d"`\"
CFLAGS = $(DFLAGS) -Wall -Wextra -Wno-strict-aliasing -c -O3
LFLAGS = -lc -lstdc++ -lrt
LFLAGS = -lc -lstdc++ -lrt $(IMLIB2_LIB)
$(PRJ): $(OBJ)
$(Q)$(info $@)
$(Q)$(LD) -o $@ $+ $(LFLAGS)
$(Q)$(CC) -o $@ $+ $(LFLAGS)
$(Q)cp $@ $@.elf
$(Q)$(STRIP) $@
@@ -66,6 +69,10 @@ cleanall:
$(Q)$(info $<)
$(Q)$(CC) $(CFLAGS) -std=gnu++14 -o $@ -c $< 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):\([0-9]\+\):/\1(\2,\ \3):/g'
%.png.o: %.png
$(Q)$(info $<)
$(Q)$(LD) -r -b binary -o $@ $< 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):\([0-9]\+\):/\1(\2,\ \3):/g'
-include $(DEP)
%.c.d: %.c
$(Q)$(CC) $(DFLAGS) -MM $< -MT $@ -MT $*.c.o -MF $@ 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):\([0-9]\+\):/\1(\2,\ \3):/g'

View File

@@ -17,6 +17,7 @@ vscale_border=0 ; set vertical border for TVs cutting the upper/bottom pa
rbf_hide_datecode=0 ; 1 - hides datecodes from rbf file names. Press F2 for quick temporary toggle
menu_pal=0 ; 1 - PAL mode for menu core
hdmi_limited=0 ; 1 - use limited (16..235) color range over HDMI
fb_size=0 ; 0 - automatic, 1 - full size, 2 - 1/2 of resolution, 4 - 1/4 of resolution.
; lastcore - Autoboot the last loaded core (corename autosaved in CONFIG/lastcore.dat) first found on the SD/USB
; lastexactcore - Autoboot the last loaded exact core (corename_yyyymmdd.rbf autosaved in CONFIG/lastcore.dat) first found on the SD/USB

View File

@@ -107,6 +107,7 @@
<ClInclude Include="hardware.h" />
<ClInclude Include="ini_parser.h" />
<ClInclude Include="input.h" />
<ClInclude Include="lib\imlib2\Imlib2.h" />
<ClInclude Include="lib\libco\libco.h" />
<ClInclude Include="lib\libco\settings.h" />
<ClInclude Include="lib\lodepng\lodepng.h" />

View File

@@ -291,5 +291,8 @@
<ClInclude Include="video.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lib\imlib2\Imlib2.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@@ -50,6 +50,7 @@ const ini_var_t ini_vars[] = {
{ "BOOTCORE", (void*)(&(cfg.bootcore)), STRING, 0, sizeof(cfg.bootcore) - 1, 1 },
{ "BOOTCORE_TIMEOUT", (void*)(&(cfg.bootcore_timeout)), INT16, 10, 30, 1 },
{ "FONT", (void*)(&(cfg.font)), STRING, 0, sizeof(cfg.font) - 1, 1 },
{ "FB_SIZE", (void*)(&(cfg.fb_size)), UINT8, 1, 4, 1 },
};
// mist ini config

1
cfg.h
View File

@@ -34,6 +34,7 @@ typedef struct {
uint8_t rbf_hide_datecode;
uint8_t menu_pal;
int16_t bootcore_timeout;
uint8_t fb_size;
char bootcore[256];
char video_conf[1024];
char video_conf_pal[1024];

View File

@@ -508,9 +508,11 @@ int FileWriteSec(fileTYPE *file, void *pBuffer)
return FileWriteAdv(file, pBuffer, 512);
}
int FileSave(const char *name, void *pBuffer, int size)
int FileSave(const char *name, void *pBuffer, int size, int sys)
{
sprintf(full_path, "%s/%s", getRootDir(), name);
if(!sys) sprintf(full_path, "%s/%s", getRootDir(), name);
else strcpy(full_path, name);
int fd = open(full_path, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC, S_IRWXU | S_IRWXG | S_IRWXO);
if (fd < 0)
{
@@ -537,9 +539,11 @@ int FileSaveConfig(const char *name, void *pBuffer, int size)
return FileSave(path, pBuffer, size);
}
int FileLoad(const char *name, void *pBuffer, int size)
int FileLoad(const char *name, void *pBuffer, int size, int sys)
{
sprintf(full_path, "%s/%s", getRootDir(), name);
if (!sys) sprintf(full_path, "%s/%s", getRootDir(), name);
else strcpy(full_path, name);
int fd = open(full_path, O_RDONLY);
if (fd < 0)
{
@@ -581,6 +585,12 @@ int FileLoadConfig(const char *name, void *pBuffer, int size)
return FileLoad(path, pBuffer, size);
}
int FileExists(const char *name)
{
sprintf(full_path, "%s/%s", getRootDir(), name);
return !access(full_path, F_OK);
}
int FileCanWrite(const char *name)
{
sprintf(full_path, "%s/%s", getRootDir(), name);

View File

@@ -61,6 +61,7 @@ int FileReadSec(fileTYPE *file, void *pBuffer);
int FileWriteAdv(fileTYPE *file, void *pBuffer, int length);
int FileWriteSec(fileTYPE *file, void *pBuffer);
int FileExists(const char *name);
int FileCanWrite(const char *name);
#define SAVE_DIR "saves"
@@ -70,8 +71,8 @@ void FileGenerateSavePath(const char *name, char* out_name);
#define SCREENSHOT_DEFAULT "screen"
void FileGenerateScreenshotName(const char *name, char *out_name, int buflen);
int FileSave(const char *name, void *pBuffer, int size);
int FileLoad(const char *name, void *pBuffer, int size); // supply pBuffer = 0 to get the file size without loading
int FileSave(const char *name, void *pBuffer, int size, int sys = 0);
int FileLoad(const char *name, void *pBuffer, int size, int sys = 0); // supply pBuffer = 0 to get the file size without loading
//save/load from config dir
#define CONFIG_DIR "config"

View File

@@ -11,6 +11,7 @@
#include <sys/stat.h>
#include "fpga_io.h"
#include "file_io.h"
#include "input.h"
#include "fpga_base_addr_ac5.h"
#include "fpga_manager.h"
@@ -628,6 +629,8 @@ void app_restart(const char *path)
sync();
fpga_core_reset(1);
input_switch(0);
char *appname = getappname();
printf("restarting the %s\n", appname);
execl(appname, appname, path, NULL);

View File

@@ -1171,6 +1171,8 @@ static int mapping_set;
static uint32_t tmp_axis[4];
static int tmp_axis_n = 0;
static int grabbed = 1;
void start_map_setting(int cnt, int set)
{
mapping_button = 0;
@@ -1372,6 +1374,11 @@ static uint32_t mouse_timer = 0;
#define BTN_TGL 100
#define BTN_OSD 101
static void mouse_cb(unsigned char b, int16_t x, int16_t y)
{
if (grabbed) user_io_mouse(b, x, y);
}
static void joy_digital(int jnum, uint32_t mask, uint32_t code, char press, int bnum)
{
static char str[128];
@@ -1479,7 +1486,7 @@ static void joy_digital(int jnum, uint32_t mask, uint32_t code, char press, int
mouse_btn = 0;
mouse_emu_x = 0;
mouse_emu_y = 0;
user_io_mouse(mice_btn, 0, 0);
mouse_cb(mice_btn, 0, 0);
mouse_emu ^= 2;
if (hasAPI1_5()) Info((mouse_emu & 2) ? "Mouse mode ON" : "Mouse mode OFF");
@@ -1551,7 +1558,7 @@ static void joy_analog(int num, int axis, int offset)
{
static int pos[NUMPLAYERS][2] = {};
if (num > 0 && num < NUMPLAYERS+1)
if (grabbed && num > 0 && num < NUMPLAYERS+1)
{
num--;
pos[num][axis] = offset;
@@ -1985,7 +1992,7 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
default:
mouse_btn = ev->value ? mouse_btn | 1 << (i - 12) : mouse_btn & ~(1 << (i - 12));
user_io_mouse(mouse_btn | mice_btn, 0, 0);
mouse_cb(mouse_btn | mice_btn, 0, 0);
break;
}
return;
@@ -2025,7 +2032,7 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
mouse_btn = 0;
mouse_emu_x = 0;
mouse_emu_y = 0;
user_io_mouse(mice_btn, 0, 0);
mouse_cb(mice_btn, 0, 0);
}
}
}
@@ -2113,7 +2120,7 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
default:
mouse_btn = ev->value ? mouse_btn | 1 << (i - 12) : mouse_btn & ~(1 << (i - 12));
user_io_mouse(mouse_btn | mice_btn, 0, 0);
mouse_cb(mouse_btn | mice_btn, 0, 0);
break;
}
return;
@@ -2138,7 +2145,7 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
mouse_btn = 0;
mouse_emu_x = 0;
mouse_emu_y = 0;
user_io_mouse(mice_btn, 0, 0);
mouse_cb(mice_btn, 0, 0);
}
return;
}
@@ -2365,6 +2372,14 @@ int input_test(int getchar)
memset(input[n].uniq, 0, sizeof(input[n].uniq));
}
//Ultimarc lightgun
if (input[n].vid == 0xd209 && input[n].pid == 0x1601)
{
input[n].lightgun = 1;
}
ioctl(pool[n].fd, EVIOCGRAB, (grabbed | user_io_osd_is_visible()) ? 1 : 0);
n++;
if (n >= NUMDEV) break;
}
@@ -2410,7 +2425,11 @@ int input_test(int getchar)
if ((pool[NUMDEV].revents & POLLIN) && check_devs())
{
printf("Close all devices.\n");
for (int i = 0; i<NUMDEV; i++) if (pool[i].fd >= 0) close(pool[i].fd);
for (int i = 0; i < NUMDEV; i++) if (pool[i].fd >= 0)
{
ioctl(pool[i].fd, EVIOCGRAB, 0);
close(pool[i].fd);
}
state = 1;
return 0;
}
@@ -2737,7 +2756,7 @@ int input_test(int getchar)
mice_btn = data[0] & 7;
if (ds_mouse_emu) mice_btn = (mice_btn & 4) | ((mice_btn & 1)<<1);
user_io_mouse(mouse_btn | mice_btn, xval, yval);
mouse_cb(mouse_btn | mice_btn, xval, yval);
}
}
}
@@ -2797,7 +2816,7 @@ int input_poll(int getchar)
if (dy < -2) dy = -2;
}
user_io_mouse(mouse_btn | mice_btn, dx, dy);
mouse_cb(mouse_btn | mice_btn, dx, dy);
prev_dx = mouse_emu_x;
prev_dy = mouse_emu_y;
}
@@ -2832,7 +2851,7 @@ int input_poll(int getchar)
if (joy[i] & autofire[i]) send = 1;
}
if (send)
if (grabbed && send)
{
user_io_digital_joystick(i, af[i] ? joy[i] & ~autofire[i] : joy[i], newdir);
}
@@ -2878,5 +2897,21 @@ void input_notify_mode()
mouse_btn = 0;
mouse_emu_x = 0;
mouse_emu_y = 0;
user_io_mouse(mice_btn, 0, 0);
mouse_cb(mice_btn, 0, 0);
}
void input_switch(int grab)
{
if (grab >= 0) grabbed = grab;
printf("input_switch(%d), grabbed = %d\n", grab, grabbed);
for (int i = 0; i < NUMDEV; i++)
{
if (pool[i].fd >= 0) ioctl(pool[i].fd, EVIOCGRAB, (grabbed | user_io_osd_is_visible()) ? 1 : 0);
}
}
int input_state()
{
return grabbed;
}

View File

@@ -55,4 +55,7 @@ uint32_t get_archie_code(uint16_t key);
int input_has_lightgun();
void input_lightgun_cal(uint16_t *cal);
void input_switch(int grab);
int input_state();
#endif

596
lib/imlib2/Imlib2.h Normal file
View File

@@ -0,0 +1,596 @@
#ifndef __IMLIB_API_H
#define __IMLIB_API_H 1
#ifdef EAPI
#undef EAPI
#endif
#ifdef WIN32
#ifdef BUILDING_DLL
#define EAPI __declspec(dllexport)
#else
#define EAPI __declspec(dllimport)
#endif
#else
#ifdef __GNUC__
#if __GNUC__ >= 4
#define EAPI __attribute__ ((visibility("default")))
#else
#define EAPI
#endif
#else
#define EAPI
#endif
#endif
#define X_DISPLAY_MISSING
#ifndef X_DISPLAY_MISSING
#include <X11/Xlib.h>
#endif
/* Data types to use */
#ifndef DATA64
#define DATA64 unsigned long long
#define DATA32 unsigned int
#define DATA16 unsigned short
#define DATA8 unsigned char
#endif
/* opaque data types */
typedef void *Imlib_Context;
typedef void *Imlib_Image;
typedef void *Imlib_Color_Modifier;
typedef void *Imlib_Updates;
typedef void *Imlib_Font;
typedef void *Imlib_Color_Range;
typedef void *Imlib_Filter;
typedef struct _imlib_border Imlib_Border;
typedef struct _imlib_color Imlib_Color;
typedef void *ImlibPolygon;
/* blending operations */
enum _imlib_operation {
IMLIB_OP_COPY,
IMLIB_OP_ADD,
IMLIB_OP_SUBTRACT,
IMLIB_OP_RESHADE
};
enum _imlib_text_direction {
IMLIB_TEXT_TO_RIGHT = 0,
IMLIB_TEXT_TO_LEFT = 1,
IMLIB_TEXT_TO_DOWN = 2,
IMLIB_TEXT_TO_UP = 3,
IMLIB_TEXT_TO_ANGLE = 4
};
enum _imlib_load_error {
IMLIB_LOAD_ERROR_NONE,
IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST,
IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY,
IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ,
IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT,
IMLIB_LOAD_ERROR_PATH_TOO_LONG,
IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT,
IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY,
IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE,
IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS,
IMLIB_LOAD_ERROR_OUT_OF_MEMORY,
IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS,
IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE,
IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE,
IMLIB_LOAD_ERROR_UNKNOWN
};
/* Encodings known to Imlib2 (so far) */
enum _imlib_TTF_encoding {
IMLIB_TTF_ENCODING_ISO_8859_1,
IMLIB_TTF_ENCODING_ISO_8859_2,
IMLIB_TTF_ENCODING_ISO_8859_3,
IMLIB_TTF_ENCODING_ISO_8859_4,
IMLIB_TTF_ENCODING_ISO_8859_5
};
typedef enum _imlib_operation Imlib_Operation;
typedef enum _imlib_load_error Imlib_Load_Error;
typedef enum _imlib_text_direction Imlib_Text_Direction;
typedef enum _imlib_TTF_encoding Imlib_TTF_Encoding;
struct _imlib_border {
int left, right, top, bottom;
};
struct _imlib_color {
int alpha, red, green, blue;
};
/* Progressive loading callbacks */
typedef int (*Imlib_Progress_Function) (Imlib_Image im, char percent,
int update_x, int update_y,
int update_w, int update_h);
typedef void (*Imlib_Data_Destructor_Function) (Imlib_Image im,
void *data);
/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-ON* */
/* context handling */
EAPI Imlib_Context imlib_context_new(void);
EAPI void imlib_context_free(Imlib_Context context);
EAPI void imlib_context_push(Imlib_Context context);
EAPI void imlib_context_pop(void);
EAPI Imlib_Context imlib_context_get(void);
/* context setting */
#ifndef X_DISPLAY_MISSING
EAPI void imlib_context_set_display(Display * display);
EAPI void imlib_context_disconnect_display(void);
EAPI void imlib_context_set_visual(Visual * visual);
EAPI void imlib_context_set_colormap(Colormap colormap);
EAPI void imlib_context_set_drawable(Drawable drawable);
EAPI void imlib_context_set_mask(Pixmap mask);
#endif
EAPI void imlib_context_set_dither_mask(char dither_mask);
EAPI void imlib_context_set_mask_alpha_threshold(int
mask_alpha_threshold);
EAPI void imlib_context_set_anti_alias(char anti_alias);
EAPI void imlib_context_set_dither(char dither);
EAPI void imlib_context_set_blend(char blend);
EAPI void imlib_context_set_color_modifier(Imlib_Color_Modifier
color_modifier);
EAPI void imlib_context_set_operation(Imlib_Operation operation);
EAPI void imlib_context_set_font(Imlib_Font font);
EAPI void imlib_context_set_direction(Imlib_Text_Direction direction);
EAPI void imlib_context_set_angle(double angle);
EAPI void imlib_context_set_color(int red, int green, int blue,
int alpha);
EAPI void imlib_context_set_color_hsva(float hue, float saturation,
float value, int alpha);
EAPI void imlib_context_set_color_hlsa(float hue, float lightness,
float saturation, int alpha);
EAPI void imlib_context_set_color_cmya(int cyan, int magenta,
int yellow, int alpha);
EAPI void imlib_context_set_color_range(Imlib_Color_Range
color_range);
EAPI void imlib_context_set_progress_function(Imlib_Progress_Function
progress_function);
EAPI void imlib_context_set_progress_granularity(char
progress_granularity);
EAPI void imlib_context_set_image(Imlib_Image image);
EAPI void imlib_context_set_cliprect(int x, int y, int w, int h);
EAPI void imlib_context_set_TTF_encoding(Imlib_TTF_Encoding encoding);
/* context getting */
#ifndef X_DISPLAY_MISSING
EAPI Display *imlib_context_get_display(void);
EAPI Visual *imlib_context_get_visual(void);
EAPI Colormap imlib_context_get_colormap(void);
EAPI Drawable imlib_context_get_drawable(void);
EAPI Pixmap imlib_context_get_mask(void);
#endif
EAPI char imlib_context_get_dither_mask(void);
EAPI char imlib_context_get_anti_alias(void);
EAPI int imlib_context_get_mask_alpha_threshold(void);
EAPI char imlib_context_get_dither(void);
EAPI char imlib_context_get_blend(void);
EAPI Imlib_Color_Modifier imlib_context_get_color_modifier(void);
EAPI Imlib_Operation imlib_context_get_operation(void);
EAPI Imlib_Font imlib_context_get_font(void);
EAPI double imlib_context_get_angle(void);
EAPI Imlib_Text_Direction imlib_context_get_direction(void);
EAPI void imlib_context_get_color(int *red, int *green, int *blue,
int *alpha);
EAPI void imlib_context_get_color_hsva(float *hue, float *saturation,
float *value, int *alpha);
EAPI void imlib_context_get_color_hlsa(float *hue, float *lightness,
float *saturation, int *alpha);
EAPI void imlib_context_get_color_cmya(int *cyan, int *magenta,
int *yellow, int *alpha);
EAPI Imlib_Color *imlib_context_get_imlib_color(void);
EAPI Imlib_Color_Range imlib_context_get_color_range(void);
EAPI Imlib_Progress_Function imlib_context_get_progress_function(void);
EAPI char imlib_context_get_progress_granularity(void);
EAPI Imlib_Image imlib_context_get_image(void);
EAPI void imlib_context_get_cliprect(int *x, int *y, int *w, int *h);
EAPI Imlib_TTF_Encoding imlib_context_get_TTF_encoding(void);
EAPI int imlib_get_cache_size(void);
EAPI void imlib_set_cache_size(int bytes);
EAPI int imlib_get_color_usage(void);
EAPI void imlib_set_color_usage(int max);
EAPI void imlib_flush_loaders(void);
#ifndef X_DISPLAY_MISSING
EAPI int imlib_get_visual_depth(Display * display, Visual * visual);
EAPI Visual *imlib_get_best_visual(Display * display, int screen,
int *depth_return);
#endif
EAPI Imlib_Image imlib_load_image(const char *file);
EAPI Imlib_Image imlib_load_image_immediately(const char *file);
EAPI Imlib_Image imlib_load_image_without_cache(const char *file);
EAPI Imlib_Image imlib_load_image_immediately_without_cache(const char
*file);
EAPI Imlib_Image imlib_load_image_with_error_return(const char *file,
Imlib_Load_Error *
error_return);
EAPI void imlib_free_image(void);
EAPI void imlib_free_image_and_decache(void);
/* query/modify image parameters */
EAPI int imlib_image_get_width(void);
EAPI int imlib_image_get_height(void);
EAPI const char *imlib_image_get_filename(void);
EAPI DATA32 *imlib_image_get_data(void);
EAPI DATA32 *imlib_image_get_data_for_reading_only(void);
EAPI void imlib_image_put_back_data(DATA32 * data);
EAPI char imlib_image_has_alpha(void);
EAPI void imlib_image_set_changes_on_disk(void);
EAPI void imlib_image_get_border(Imlib_Border * border);
EAPI void imlib_image_set_border(Imlib_Border * border);
EAPI void imlib_image_set_format(const char *format);
EAPI void imlib_image_set_irrelevant_format(char irrelevant);
EAPI void imlib_image_set_irrelevant_border(char irrelevant);
EAPI void imlib_image_set_irrelevant_alpha(char irrelevant);
EAPI char *imlib_image_format(void);
EAPI void imlib_image_set_has_alpha(char has_alpha);
EAPI void imlib_image_query_pixel(int x, int y,
Imlib_Color * color_return);
EAPI void imlib_image_query_pixel_hsva(int x, int y, float *hue,
float *saturation,
float *value, int *alpha);
EAPI void imlib_image_query_pixel_hlsa(int x, int y, float *hue,
float *lightness,
float *saturation, int *alpha);
EAPI void imlib_image_query_pixel_cmya(int x, int y, int *cyan,
int *magenta, int *yellow,
int *alpha);
/* rendering functions */
#ifndef X_DISPLAY_MISSING
EAPI void imlib_render_pixmaps_for_whole_image(Pixmap * pixmap_return,
Pixmap * mask_return);
EAPI void imlib_render_pixmaps_for_whole_image_at_size(Pixmap *
pixmap_return,
Pixmap *
mask_return,
int width,
int height);
EAPI void imlib_free_pixmap_and_mask(Pixmap pixmap);
EAPI void imlib_render_image_on_drawable(int x, int y);
EAPI void imlib_render_image_on_drawable_at_size(int x, int y,
int width,
int height);
EAPI void imlib_render_image_part_on_drawable_at_size(int source_x,
int source_y,
int
source_width, int
source_height,
int x, int y,
int width,
int height);
EAPI DATA32 imlib_render_get_pixel_color(void);
#endif
EAPI void imlib_blend_image_onto_image(Imlib_Image source_image,
char merge_alpha,
int source_x, int source_y,
int source_width,
int source_height,
int destination_x,
int destination_y,
int destination_width,
int destination_height);
/* creation functions */
EAPI Imlib_Image imlib_create_image(int width, int height);
EAPI Imlib_Image imlib_create_image_using_data(int width, int height,
DATA32 * data);
EAPI Imlib_Image imlib_create_image_using_copied_data(int width,
int height,
DATA32 * data);
#ifndef X_DISPLAY_MISSING
EAPI Imlib_Image imlib_create_image_from_drawable(Pixmap mask,
int x, int y,
int width, int height,
char need_to_grab_x);
EAPI Imlib_Image imlib_create_image_from_ximage(XImage * image,
XImage * mask,
int x, int y,
int width, int height,
char need_to_grab_x);
EAPI Imlib_Image imlib_create_scaled_image_from_drawable(Pixmap mask,
int source_x,
int source_y,
int source_width,
int
source_height, int
destination_width, int
destination_height, char
need_to_grab_x, char
get_mask_from_shape);
EAPI char imlib_copy_drawable_to_image(Pixmap mask, int x, int y,
int width, int height,
int destination_x,
int destination_y,
char need_to_grab_x);
#endif
EAPI Imlib_Image imlib_clone_image(void);
EAPI Imlib_Image imlib_create_cropped_image(int x, int y, int width,
int height);
EAPI Imlib_Image imlib_create_cropped_scaled_image(int source_x,
int source_y,
int source_width,
int source_height,
int destination_width,
int destination_height);
/* imlib updates. lists of rectangles for storing required update draws */
EAPI Imlib_Updates imlib_updates_clone(Imlib_Updates updates);
EAPI Imlib_Updates imlib_update_append_rect(Imlib_Updates updates,
int x, int y, int w, int h);
EAPI Imlib_Updates imlib_updates_merge(Imlib_Updates updates, int w, int h);
EAPI Imlib_Updates imlib_updates_merge_for_rendering(Imlib_Updates updates,
int w, int h);
EAPI void imlib_updates_free(Imlib_Updates updates);
EAPI Imlib_Updates imlib_updates_get_next(Imlib_Updates updates);
EAPI void imlib_updates_get_coordinates(Imlib_Updates updates,
int *x_return,
int *y_return,
int *width_return,
int *height_return);
EAPI void imlib_updates_set_coordinates(Imlib_Updates updates,
int x, int y,
int width, int height);
EAPI void imlib_render_image_updates_on_drawable(Imlib_Updates
updates,
int x, int y);
EAPI Imlib_Updates imlib_updates_init(void);
EAPI Imlib_Updates imlib_updates_append_updates(Imlib_Updates updates,
Imlib_Updates
appended_updates);
/* image modification */
EAPI void imlib_image_flip_horizontal(void);
EAPI void imlib_image_flip_vertical(void);
EAPI void imlib_image_flip_diagonal(void);
EAPI void imlib_image_orientate(int orientation);
EAPI void imlib_image_blur(int radius);
EAPI void imlib_image_sharpen(int radius);
EAPI void imlib_image_tile_horizontal(void);
EAPI void imlib_image_tile_vertical(void);
EAPI void imlib_image_tile(void);
/* fonts and text */
EAPI Imlib_Font imlib_load_font(const char *font_name);
EAPI void imlib_free_font(void);
/* NB! The four functions below are deprecated. */
EAPI int imlib_insert_font_into_fallback_chain(Imlib_Font font,
Imlib_Font
fallback_font);
EAPI void imlib_remove_font_from_fallback_chain(Imlib_Font
fallback_font);
EAPI Imlib_Font imlib_get_prev_font_in_fallback_chain(Imlib_Font fn);
EAPI Imlib_Font imlib_get_next_font_in_fallback_chain(Imlib_Font fn);
/* NB! The four functions above are deprecated. */
EAPI void imlib_text_draw(int x, int y, const char *text);
EAPI void imlib_text_draw_with_return_metrics(int x, int y,
const char *text,
int *width_return,
int *height_return, int
*horizontal_advance_return, int
*vertical_advance_return);
EAPI void imlib_get_text_size(const char *text,
int *width_return, int *height_return);
EAPI void imlib_get_text_advance(const char *text,
int *horizontal_advance_return,
int *vertical_advance_return);
EAPI int imlib_get_text_inset(const char *text);
EAPI void imlib_add_path_to_font_path(const char *path);
EAPI void imlib_remove_path_from_font_path(const char *path);
EAPI char **imlib_list_font_path(int *number_return);
EAPI int imlib_text_get_index_and_location(const char *text,
int x, int y,
int *char_x_return,
int *char_y_return,
int *char_width_return,
int *char_height_return);
EAPI void imlib_text_get_location_at_index(const char *text,
int index,
int *char_x_return,
int *char_y_return,
int *char_width_return,
int *char_height_return);
EAPI char **imlib_list_fonts(int *number_return);
EAPI void imlib_free_font_list(char **font_list, int number);
EAPI int imlib_get_font_cache_size(void);
EAPI void imlib_set_font_cache_size(int bytes);
EAPI void imlib_flush_font_cache(void);
EAPI int imlib_get_font_ascent(void);
EAPI int imlib_get_font_descent(void);
EAPI int imlib_get_maximum_font_ascent(void);
EAPI int imlib_get_maximum_font_descent(void);
/* color modifiers */
EAPI Imlib_Color_Modifier imlib_create_color_modifier(void);
EAPI void imlib_free_color_modifier(void);
EAPI void imlib_modify_color_modifier_gamma(double gamma_value);
EAPI void imlib_modify_color_modifier_brightness(double
brightness_value);
EAPI void imlib_modify_color_modifier_contrast(double
contrast_value);
EAPI void imlib_set_color_modifier_tables(DATA8 * red_table,
DATA8 * green_table,
DATA8 * blue_table,
DATA8 * alpha_table);
EAPI void imlib_get_color_modifier_tables(DATA8 * red_table,
DATA8 * green_table,
DATA8 * blue_table,
DATA8 * alpha_table);
EAPI void imlib_reset_color_modifier(void);
EAPI void imlib_apply_color_modifier(void);
EAPI void imlib_apply_color_modifier_to_rectangle(int x, int y,
int width,
int height);
/* drawing on images */
EAPI Imlib_Updates imlib_image_draw_pixel(int x, int y, char make_updates);
EAPI Imlib_Updates imlib_image_draw_line(int x1, int y1, int x2, int y2,
char make_updates);
EAPI void imlib_image_draw_rectangle(int x, int y,
int width, int height);
EAPI void imlib_image_fill_rectangle(int x, int y,
int width, int height);
EAPI void imlib_image_copy_alpha_to_image(Imlib_Image image_source,
int x, int y);
EAPI void imlib_image_copy_alpha_rectangle_to_image(Imlib_Image
image_source,
int x, int y,
int width,
int height,
int destination_x,
int
destination_y);
EAPI void imlib_image_scroll_rect(int x, int y, int width, int height,
int delta_x, int delta_y);
EAPI void imlib_image_copy_rect(int x, int y, int width, int height,
int new_x, int new_y);
/* polygons */
EAPI ImlibPolygon imlib_polygon_new(void);
EAPI void imlib_polygon_free(ImlibPolygon poly);
EAPI void imlib_polygon_add_point(ImlibPolygon poly, int x, int y);
EAPI void imlib_image_draw_polygon(ImlibPolygon poly,
unsigned char closed);
EAPI void imlib_image_fill_polygon(ImlibPolygon poly);
EAPI void imlib_polygon_get_bounds(ImlibPolygon poly,
int *px1, int *py1,
int *px2, int *py2);
EAPI unsigned char imlib_polygon_contains_point(ImlibPolygon poly,
int x, int y);
/* ellipses */
EAPI void imlib_image_draw_ellipse(int xc, int yc, int a, int b);
EAPI void imlib_image_fill_ellipse(int xc, int yc, int a, int b);
/* color ranges */
EAPI Imlib_Color_Range imlib_create_color_range(void);
EAPI void imlib_free_color_range(void);
EAPI void imlib_add_color_to_color_range(int distance_away);
EAPI void imlib_image_fill_color_range_rectangle(int x, int y,
int width,
int height,
double angle);
EAPI void imlib_image_fill_hsva_color_range_rectangle(int x, int y,
int width,
int height,
double
angle);
/* image data */
EAPI void imlib_image_attach_data_value(const char *key,
void *data, int value,
Imlib_Data_Destructor_Function
destructor_function);
EAPI void *imlib_image_get_attached_data(const char *key);
EAPI int imlib_image_get_attached_value(const char *key);
EAPI void imlib_image_remove_attached_data_value(const char *key);
EAPI void imlib_image_remove_and_free_attached_data_value(const char
*key);
/* saving */
EAPI void imlib_save_image(const char *filename);
EAPI void imlib_save_image_with_error_return(const char *filename,
Imlib_Load_Error *
error_return);
/* FIXME: */
/* need to add arbitrary rotation routines */
/* rotation/skewing */
EAPI Imlib_Image imlib_create_rotated_image(double angle);
/* rotation from buffer to context (without copying)*/
EAPI void imlib_rotate_image_from_buffer(double angle,
Imlib_Image source_image);
EAPI void imlib_blend_image_onto_image_at_angle(Imlib_Image
source_image,
char merge_alpha,
int source_x,
int source_y,
int source_width,
int source_height,
int destination_x,
int destination_y,
int angle_x,
int angle_y);
EAPI void imlib_blend_image_onto_image_skewed(Imlib_Image
source_image,
char merge_alpha,
int source_x,
int source_y,
int source_width,
int source_height,
int destination_x,
int destination_y,
int h_angle_x,
int h_angle_y,
int v_angle_x,
int v_angle_y);
#ifndef X_DISPLAY_MISSING
EAPI void imlib_render_image_on_drawable_skewed(int source_x,
int source_y,
int source_width,
int source_height,
int destination_x,
int destination_y,
int h_angle_x,
int h_angle_y,
int v_angle_x,
int v_angle_y);
EAPI void imlib_render_image_on_drawable_at_angle(int source_x,
int source_y,
int source_width,
int source_height,
int destination_x,
int destination_y,
int angle_x,
int angle_y);
#endif
/* image filters */
EAPI void imlib_image_filter(void);
EAPI Imlib_Filter imlib_create_filter(int initsize);
EAPI void imlib_context_set_filter(Imlib_Filter filter);
EAPI Imlib_Filter imlib_context_get_filter(void);
EAPI void imlib_free_filter(void);
EAPI void imlib_filter_set(int xoff, int yoff,
int a, int r, int g, int b);
EAPI void imlib_filter_set_alpha(int xoff, int yoff,
int a, int r, int g, int b);
EAPI void imlib_filter_set_red(int xoff, int yoff,
int a, int r, int g, int b);
EAPI void imlib_filter_set_green(int xoff, int yoff,
int a, int r, int g, int b);
EAPI void imlib_filter_set_blue(int xoff, int yoff,
int a, int r, int g, int b);
EAPI void imlib_filter_constants(int a, int r, int g, int b);
EAPI void imlib_filter_divisors(int a, int r, int g, int b);
EAPI void imlib_apply_filter(char *script, ...);
EAPI void imlib_image_clear(void);
EAPI void imlib_image_clear_color(int r, int g, int b, int a);
/* *INDENT-OFF* */
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */
#endif

BIN
lib/imlib2/libImlib2.so Normal file

Binary file not shown.

BIN
lib/imlib2/libbz2.so Normal file

Binary file not shown.

BIN
lib/imlib2/libfreetype.so Normal file

Binary file not shown.

BIN
lib/imlib2/libpng16.so Normal file

Binary file not shown.

BIN
lib/imlib2/libz.so Normal file

Binary file not shown.

BIN
logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@@ -90,13 +90,13 @@ enum MENU
MENU_LOADCONFIG_2,
MENU_SAVECONFIG_1,
MENU_SAVECONFIG_2,
MENU_FIRMWARE1,
MENU_FIRMWARE_CORE_FILE_SELECTED1,
MENU_FIRMWARE_CORE_FILE_SELECTED2,
MENU_FIRMWARE_CORE_FILE_CANCELED,
MENU_SYSTEM1,
MENU_SYSTEM2,
MENU_CORE_FILE_SELECTED1,
MENU_CORE_FILE_SELECTED2,
MENU_CORE_FILE_CANCELED,
MENU_ERROR,
MENU_INFO,
MENU_STORAGE,
MENU_JOYDIGMAP,
MENU_JOYDIGMAP1,
MENU_JOYDIGMAP2,
@@ -463,7 +463,7 @@ static uint32_t menu_key_get(void)
c2 = c1;
// inject a fake "MENU_KEY" if no menu is visible and the menu key is loaded
if (!user_io_osd_is_visible() && is_menu_core()) c = KEY_F12;
if (!user_io_osd_is_visible() && !video_fb_state() && is_menu_core()) c = KEY_F12;
// generate repeat "key-pressed" events
if ((c1 & UPSTROKE) || (!c1))
@@ -804,6 +804,7 @@ void HandleUI(void)
case KEY_F12:
menu = true;
menu_key_set(KEY_F12 | UPSTROKE);
video_fb_enable(0);
break;
case KEY_F1:
if (is_menu_core())
@@ -812,6 +813,7 @@ void HandleUI(void)
status <<= 1;
user_io_8bit_set_status(status, 0xE);
FileSaveConfig(user_io_create_config_name(), &status, 4);
video_menu_bg((status >> 1) & 7);
}
break;
@@ -833,9 +835,9 @@ void HandleUI(void)
}
break;
//debug
case KEY_F9:
video_fb_enable(!video_fb_state());
if(video_fb_state() || !is_menu_core()) menustate = MENU_NONE1;
break;
// Within the menu the esc key acts as the menu key. problem:
@@ -966,7 +968,7 @@ void HandleUI(void)
OsdSetSize(16);
if(!is_menu_core() && (get_key_mod() & (LALT | RALT))) //Alt+Menu
{
SelectFile(0, SCANO_CORES, MENU_FIRMWARE_CORE_FILE_SELECTED1, MENU_NONE1);
SelectFile(0, SCANO_CORES, MENU_CORE_FILE_SELECTED1, MENU_NONE1);
}
else if (user_io_core_type() == CORE_TYPE_MINIMIG2) menustate = MENU_MAIN1;
else if (user_io_core_type() == CORE_TYPE_MIST) menustate = MENU_MIST_MAIN1;
@@ -975,7 +977,7 @@ void HandleUI(void)
if (is_menu_core())
{
OsdCoreNameSet("");
SelectFile(0, SCANO_CORES, MENU_FIRMWARE_CORE_FILE_SELECTED1, MENU_FIRMWARE1);
SelectFile(0, SCANO_CORES, MENU_CORE_FILE_SELECTED1, MENU_SYSTEM1);
}
else
{
@@ -1582,7 +1584,7 @@ void HandleUI(void)
switch (menusub)
{
case 0:
SelectFile(0, SCANO_CORES, MENU_FIRMWARE_CORE_FILE_SELECTED1, MENU_8BIT_SYSTEM1);
SelectFile(0, SCANO_CORES, MENU_CORE_FILE_SELECTED1, MENU_8BIT_SYSTEM1);
menusub = 0;
break;
@@ -2008,7 +2010,7 @@ void HandleUI(void)
finish_map_setting(menu);
if (is_menu_core())
{
menustate = MENU_FIRMWARE1;
menustate = MENU_SYSTEM1;
menusub = 2;
}
else
@@ -3679,7 +3681,13 @@ void HandleUI(void)
/******************************************************************/
/* firmware menu */
/******************************************************************/
case MENU_FIRMWARE1:
case MENU_SYSTEM1:
if (video_fb_state())
{
menustate = MENU_NONE1;
break;
}
helptext = helptexts[HELPTEXT_NONE];
parentstate = menustate;
@@ -3733,25 +3741,14 @@ void HandleUI(void)
OsdWrite(9, " Scripts \x16", menusub == 3, 0);
sysinfo_timer = 0;
menustate = MENU_STORAGE;
menustate = MENU_SYSTEM2;
case MENU_STORAGE:
case MENU_SYSTEM2:
if (menu)
{
switch (user_io_core_type()) {
case CORE_TYPE_MIST:
menusub = 5;
menustate = MENU_MIST_MAIN1;
break;
case CORE_TYPE_ARCHIE:
menusub = 3;
menustate = MENU_ARCHIE_MAIN1;
break;
default:
menusub = 0;
menustate = MENU_NONE1;
break;
}
OsdCoreNameSet("");
SelectFile(0, SCANO_CORES, MENU_CORE_FILE_SELECTED1, MENU_SYSTEM1);
break;
}
else if (select)
{
@@ -3801,7 +3798,7 @@ void HandleUI(void)
}
}
if(match) SelectFile("SH", SCANO_DIR, MENU_SCRIPTS, MENU_FIRMWARE1);
if(match) SelectFile("SH", SCANO_DIR, MENU_SCRIPTS, MENU_SYSTEM1);
else
{
menustate = MENU_SCRIPTS_PRE;
@@ -3905,13 +3902,13 @@ void HandleUI(void)
break;
case MENU_SCRIPTS_PRE1:
if (menu) menustate = MENU_FIRMWARE1;
if (menu) menustate = MENU_SYSTEM1;
else if (select)
{
switch (menusub)
{
case 0:
menustate = MENU_FIRMWARE1;
menustate = MENU_SYSTEM1;
break;
case 2:
@@ -3919,7 +3916,7 @@ void HandleUI(void)
// fall through
case 1:
SelectFile("SH", SCANO_DIR, MENU_SCRIPTS, MENU_FIRMWARE1);
SelectFile("SH", SCANO_DIR, MENU_SCRIPTS, MENU_SYSTEM1);
break;
}
}
@@ -4004,7 +4001,7 @@ void HandleUI(void)
}
else
{
menustate = MENU_FIRMWARE1;
menustate = MENU_SYSTEM1;
menusub = 3;
}
}
@@ -4045,12 +4042,12 @@ void HandleUI(void)
if (select || menu)
{
finish_map_setting(menu);
menustate = MENU_FIRMWARE1;
menustate = MENU_SYSTEM1;
menusub = 1;
}
break;
case MENU_FIRMWARE_CORE_FILE_SELECTED1:
case MENU_CORE_FILE_SELECTED1:
menustate = MENU_NONE1;
strcpy(SelectedRBF, SelectedPath);
if (!getStorage(0)) // multiboot is only on SD card.
@@ -4067,7 +4064,7 @@ void HandleUI(void)
strcat(SelectedPath, ".txt");
if (FileLoad(SelectedPath, 0, 0))
{
menustate = MENU_FIRMWARE_CORE_FILE_SELECTED2;
menustate = MENU_CORE_FILE_SELECTED2;
break;
}
}
@@ -4078,8 +4075,8 @@ void HandleUI(void)
strcpy(fs_pFileExt, "TXT");
fs_ExtLen = 3;
fs_Options = SCANO_CORES;
fs_MenuSelect = MENU_FIRMWARE_CORE_FILE_SELECTED2;
fs_MenuCancel = MENU_FIRMWARE_CORE_FILE_CANCELED;
fs_MenuSelect = MENU_CORE_FILE_SELECTED2;
fs_MenuCancel = MENU_CORE_FILE_CANCELED;
menustate = MENU_FILE_SELECT1;
break;
}
@@ -4090,14 +4087,14 @@ void HandleUI(void)
fpga_load_rbf(SelectedRBF);
break;
case MENU_FIRMWARE_CORE_FILE_SELECTED2:
case MENU_CORE_FILE_SELECTED2:
OsdDisable();
fpga_load_rbf(SelectedRBF, SelectedPath);
menustate = MENU_NONE1;
break;
case MENU_FIRMWARE_CORE_FILE_CANCELED:
SelectFile(0, SCANO_CORES, MENU_FIRMWARE_CORE_FILE_SELECTED1, cp_MenuCancel);
case MENU_CORE_FILE_CANCELED:
SelectFile(0, SCANO_CORES, MENU_CORE_FILE_SELECTED1, cp_MenuCancel);
break;
/******************************************************************/

BIN
releases/MiSTer_20190525 Normal file

Binary file not shown.

View File

@@ -593,6 +593,12 @@ void user_io_init(const char *path)
}
parse_config();
if (is_menu_core())
{
user_io_8bit_set_status((cfg.menu_pal) ? 0x10 : 0, 0x10);
video_menu_bg((status >> 1) & 7);
}
if (is_x86_core())
{
x86_config_load();
@@ -1533,6 +1539,7 @@ void user_io_send_buttons(char force)
if ((key_map & BUTTON2) && !(map & BUTTON2))
{
const char *name = get_rbf_name();
OsdDisable();
fpga_load_rbf(name[0] ? name : "Archie.rbf");
}
}
@@ -2162,6 +2169,7 @@ void user_io_poll()
if (!coldreset_req && prev_coldreset_req)
{
OsdDisable();
fpga_load_rbf("menu.rbf");
}
@@ -2468,6 +2476,7 @@ void user_io_osd_key_enable(char on)
{
printf("OSD is now %s\n", on ? "visible" : "invisible");
osd_is_visible = on;
input_switch(-1);
}
int get_volume()
@@ -2644,7 +2653,7 @@ void user_io_kbd(uint16_t key, int press)
else
{
if(key == KEY_MENU) key = KEY_F12;
send_keycode(key, press);
if(input_state()) send_keycode(key, press);
}
}
}

431
video.cpp
View File

@@ -3,6 +3,8 @@
#include <string.h>
#include <inttypes.h>
#include <sys/mman.h>
#include <linux/fb.h>
#include <errno.h>
#include "hardware.h"
#include "user_io.h"
@@ -11,13 +13,15 @@
#include "file_io.h"
#include "menu.h"
#include "video.h"
#include "input.h"
#include "support.h"
#include "lib/imlib2/Imlib2.h"
#define FB_SIZE (1024*1024*8) // 8MB x 3
#define FB_SIZE (1024*1024*8/4) // 8MB
#define FB_ADDR (0x20000000 + (32*1024*1024)) // 512mb + 32mb(Core's fb)
#define FB_FMT 2 // 0 - 16bit, 1 - 24bit(not supported), 2 - 32bit
#define FB_HDRSZ (256/(FB_FMT+2))
#define FB_RxB 1
#if(FB_FMT == 2)
static volatile uint32_t *fb_base = 0;
@@ -27,8 +31,13 @@
static int fb_enabled = 0;
static int fb_width = 0;
static int fb_width_full = 0;
static int fb_height = 0;
static int fb_stride = 0;
static int fb_num = 0;
static int menu_bg = 0;
static int menu_bgn = 0;
struct vmode_t
{
@@ -264,6 +273,8 @@ static void loadScalerCfg()
}
}
static char fb_reset_cmd[128] = {};
static void set_video(vmode_custom_t *v, double Fpix)
{
loadScalerCfg();
@@ -288,7 +299,7 @@ static void set_video(vmode_custom_t *v, double Fpix)
for (int i = 9; i < 21; i++)
{
printf("0x%X, ", v_cur.item[i]);
if (i & 1) spi_w(v_cur.item[i] | ((i == 9 && (is_menu_core() ? cfg.menu_pal : (Fpix && cfg.vsync_adjust == 2))) ? 0x8000 : 0));
if (i & 1) spi_w(v_cur.item[i] | ((i == 9 && Fpix && cfg.vsync_adjust == 2 && !is_menu_core()) ? 0x8000 : 0));
else
{
spi_w(v_cur.item[i]);
@@ -298,6 +309,20 @@ static void set_video(vmode_custom_t *v, double Fpix)
printf("Fpix=%f\n", v_cur.Fpix);
DisableIO();
if (cfg.fb_size < 1) cfg.fb_size = (v_cur.item[1] < 1000) ? 1 : 2;
else if (cfg.fb_size == 3) cfg.fb_size = 2;
else if (cfg.fb_size > 4) cfg.fb_size = 4;
fb_width = v_cur.item[1] / cfg.fb_size;
fb_height = v_cur.item[5] / cfg.fb_size;
fb_stride = ((fb_width * (FB_FMT ? 4 : 2)) + 255) & ~255;
fb_width_full = fb_stride / (FB_FMT + 2);
if (fb_enabled) video_fb_enable(1, fb_num);
sprintf(fb_reset_cmd, "taskset 1 echo %d %d %d %d %d >/sys/module/MiSTer_fb/parameters/mode", FB_FMT ? 8888 : 1555, FB_RxB, fb_width, fb_height, fb_stride);
system(fb_reset_cmd);
}
static int parse_custom_video_mode(char* vcfg, vmode_custom_t *v)
@@ -377,23 +402,18 @@ static void fb_init()
{
if (!fb_base)
{
static int fd;
fb_base = 0;
int fd = open("/dev/mem", O_RDWR | O_SYNC);
if (fd == -1) return;
if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) return;
#if(FB_FMT == 2)
fb_base = (volatile uint32_t*)mmap(0, FB_SIZE * 3, PROT_READ | PROT_WRITE, MAP_SHARED, fd, FB_ADDR);
#else
fb_base = (volatile uint16_t*)mmap(0, FB_SIZE * 3, PROT_READ | PROT_WRITE, MAP_SHARED, fd, FB_ADDR);
#endif
fb_base = (volatile uint32_t*)mmap(0, FB_SIZE * 4 * 3, PROT_READ | PROT_WRITE, MAP_SHARED, fd, FB_ADDR);
if (fb_base == (void *)-1)
{
printf("Unable to mmap FB!\n");
fb_base = 0;
close(fd);
}
close(fd);
}
spi_uio_cmd16(UIO_SET_FBUF, 0);
}
void video_mode_load()
@@ -408,7 +428,7 @@ void video_mode_load()
static int api1_5 = 0;
int hasAPI1_5()
{
return api1_5;
return api1_5 || is_menu_core();
}
static uint32_t show_video_info(int force)
@@ -555,81 +575,372 @@ void video_mode_adjust()
}
}
static void fill_fb()
{
int pos = 0;
for (int y = 0; y < fb_height; y++)
{
pos = y * fb_stride + FB_HDRSZ;
int base_color = (y / 32) & 7;
for (int x = 0; x < fb_width; x++)
{
#if(FB_FMT == 2)
int gray = (256 * x) / fb_width;
uint32_t color = 0;
if (base_color & 1) color |= gray;
if (base_color & 2) color |= gray << 8;
if (base_color & 4) color |= gray << 16;
#else
int gray = (32 * x) / fb_width;
uint16_t color = 0;
if (base_color & 1) color |= gray;
if (base_color & 2) color |= gray << 5;
if (base_color & 4) color |= gray << 10;
#endif
fb_base[pos++] = color;
}
}
}
void video_fb_enable(int enable)
void video_fb_enable(int enable, int n)
{
if (fb_base)
{
int res = spi_uio_cmd_cont(UIO_SET_FBUF);
if (res)
{
if (is_menu_core() && !enable && menu_bg)
{
enable = 1;
n = menu_bgn;
}
if (enable)
{
fb_width = (v_cur.item[1] >= 1440) ? v_cur.item[1] / 2 : v_cur.item[1];
fb_height = (v_cur.item[5] >= 1080) ? v_cur.item[5] / 2 : v_cur.item[5];
uint32_t fb_addr = FB_ADDR + (FB_SIZE * 4 * n);
fb_num = n;
printf("Switch to HPS frame buffer\n");
spi_w(0x8000 | (FB_FMT & 3) << 12); // enable flag, format, fixed height
spi_w((uint16_t)FB_ADDR); // base address low word
spi_w(FB_ADDR >> 16); // base address high word
spi_w(fb_width-1); // frame width
spi_w(fb_height-1); // frame height
spi_w(0); // Aspect ratio X/Y (0 - full screen)
spi_w((FB_FMT << 1) | (FB_RxB << 3) | 1); // format, enable flag
spi_w((uint16_t)fb_addr); // base address low word
spi_w(fb_addr >> 16); // base address high word
spi_w(fb_width); // frame width
spi_w(fb_height); // frame height
spi_w(0); // scaled left
spi_w(v_cur.item[1] - 1); // scaled right
spi_w(0); // scaled top
spi_w(v_cur.item[5] - 1); // scaled bottom
#if(FB_FMT == 2)
fb_stride = (((fb_width * 4 + 255) / 256) * 256)/4;
#else
fb_stride = (((fb_width * 2 + 255) / 256) * 256)/2;
#endif
printf("HPS frame buffer: %dx%d, stride = %d items\n", fb_width, fb_height, fb_stride);
fill_fb();
printf("HPS frame buffer: %dx%d, stride = %d bytes\n", fb_width, fb_height, fb_stride);
if (!fb_num)
{
system(fb_reset_cmd);
input_switch(0);
}
else
{
input_switch(1);
}
}
else
{
printf("Switch to core frame buffer\n");
spi_w(0); // enable flag
input_switch(1);
}
fb_enabled = enable;
}
else
{
printf("Core doesn't support HPS frame buffer\n");
input_switch(1);
}
DisableIO();
}
}
int video_fb_state()
{
if (is_menu_core())
{
return fb_enabled && !fb_num;
}
return fb_enabled;
}
static void draw_checkers()
{
volatile uint32_t* buf = fb_base + (FB_SIZE*menu_bgn);
int stride = fb_stride / (FB_FMT + 2);
uint32_t col1 = 0x888888;
uint32_t col2 = 0x666666;
int sz = fb_width/128;
int pos = 0;
for (int y = 0; y < fb_height; y++)
{
int c1 = (y / sz) & 1;
pos = y * stride;
for (int x = 0; x < fb_width; x++)
{
int c2 = c1 ^ ((x / sz) & 1);
buf[pos++] = c2 ? col2 : col1;
}
}
}
static void draw_hbars1()
{
volatile uint32_t* buf = fb_base + (FB_SIZE*menu_bgn);
int stride = fb_stride / (FB_FMT + 2);
int old_base = 0;
int gray = 255;
int sz = fb_height/7;
int stp = 0;
for (int y = 0; y < fb_height; y++)
{
int pos = y * stride;
int base_color = ((7 * y) / fb_height)+1;
if (old_base != base_color)
{
stp = sz;
old_base = base_color;
}
gray = 255 * stp / sz;
for (int x = 0; x < fb_width; x++)
{
uint32_t color = 0;
if (base_color & 4) color |= gray;
if (base_color & 2) color |= gray << 8;
if (base_color & 1) color |= gray << 16;
buf[pos++] = color;
}
stp--;
if (stp < 0) stp = 0;
}
}
static void draw_hbars2()
{
volatile uint32_t* buf = fb_base + (FB_SIZE*menu_bgn);
int stride = fb_stride / (FB_FMT + 2);
for (int y = 0; y < fb_height; y++)
{
int pos = y * stride;
int base_color = ((14 * y) / fb_height);
int inv = base_color & 1;
base_color >>= 1;
base_color = (inv ? base_color : 6 - base_color) + 1;
for (int x = 0; x < fb_width; x++)
{
int gray = (256 * x) / fb_width;
if (inv) gray = 255 - gray;
uint32_t color = 0;
if (base_color & 4) color |= gray;
if (base_color & 2) color |= gray << 8;
if (base_color & 1) color |= gray << 16;
buf[pos++] = color;
}
}
}
static void draw_vbars1()
{
volatile uint32_t* buf = fb_base + (FB_SIZE*menu_bgn);
int stride = fb_stride / (FB_FMT + 2);
int sz = fb_width / 7;
int stp = 0;
for (int y = 0; y < fb_height; y++)
{
int pos = y * stride;
int old_base = 0;
int gray = 255;
for (int x = 0; x < fb_width; x++)
{
int base_color = ((7 * x) / fb_width)+1;
if (old_base != base_color)
{
stp = sz;
old_base = base_color;
}
gray = 255 * stp / sz;
uint32_t color = 0;
if (base_color & 4) color |= gray;
if (base_color & 2) color |= gray << 8;
if (base_color & 1) color |= gray << 16;
buf[pos++] = color;
stp--;
if (stp < 0) stp = 0;
}
}
}
static void draw_vbars2()
{
volatile uint32_t* buf = fb_base + (FB_SIZE*menu_bgn);
int stride = fb_stride / (FB_FMT + 2);
for (int y = 0; y < fb_height; y++)
{
int pos = y * stride;
for (int x = 0; x < fb_width; x++)
{
int gray = ((256 * y) / fb_height);
int base_color = ((14 * x) / fb_width);
int inv = base_color & 1;
base_color >>= 1;
base_color = (inv ? base_color : 6 - base_color) + 1;
if (inv) gray = 255 - gray;
uint32_t color = 0;
if (base_color & 4) color |= gray;
if (base_color & 2) color |= gray << 8;
if (base_color & 1) color |= gray << 16;
buf[pos++] = color;
}
}
}
static void draw_spectrum()
{
volatile uint32_t* buf = fb_base + (FB_SIZE*menu_bgn);
int stride = fb_stride / (FB_FMT + 2);
for (int y = 0; y < fb_height; y++)
{
int pos = y * stride;
int blue = ((256 * y) / fb_height);
for (int x = 0; x < fb_width; x++)
{
int green = ((256 * x) / fb_width) - blue / 2;
int red = 255 - green - blue / 2;
if (red < 0) red = 0;
if (green < 0) green = 0;
buf[pos++] = (red<<16) | (green<<8) | blue;
}
}
}
static void draw_black()
{
volatile uint32_t* buf = fb_base + (FB_SIZE*menu_bgn);
int stride = fb_stride / (FB_FMT + 2);
for (int y = 0; y < fb_height; y++)
{
int pos = y * stride;
for (int x = 0; x < fb_width; x++) buf[pos++] = 0;
}
}
static uint64_t getus()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec * 10000000) + tv.tv_usec;
}
static void vs_wait()
{
int fb = open("/dev/fb0", O_RDWR);
int zero = 0;
uint64_t t1, t2;
if (ioctl(fb, FBIO_WAITFORVSYNC, &zero) == -1)
{
printf("fb ioctl failed: %s\n", strerror(errno));
close(fb);
return;
}
t1 = getus();
ioctl(fb, FBIO_WAITFORVSYNC, &zero);
t2 = getus();
close(fb);
printf("vs_wait(us): %llu\n", t2 - t1);
}
extern uint8_t _binary_logo_png_start[], _binary_logo_png_end[];
void video_menu_bg(int n)
{
menu_bg = n;
if (n)
{
menu_bgn = (menu_bgn == 1) ? 2 : 1;
static Imlib_Image menubg = 0;
static Imlib_Image bg1 = 0, bg2 = 0;
if (!bg1) bg1 = imlib_create_image_using_data(fb_width_full, fb_height, (uint32_t*)(fb_base + (FB_SIZE * 1)));
if (!bg2) bg2 = imlib_create_image_using_data(fb_width_full, fb_height, (uint32_t*)(fb_base + (FB_SIZE * 2)));
Imlib_Image *bg = (menu_bgn == 1) ? &bg1 : &bg2;
switch (n)
{
case 1:
if (menubg || FileExists("menu.png") || FileExists("menu.jpg"))
{
if (!menubg) menubg = imlib_load_image_immediately(getFullPath("menu.png"));
if (!menubg) menubg = imlib_load_image_immediately(getFullPath("menu.jpg"));
if (menubg)
{
imlib_context_set_image(menubg);
int src_w = imlib_image_get_width();
int src_h = imlib_image_get_height();
if (*bg)
{
imlib_context_set_image(*bg);
imlib_blend_image_onto_image(menubg, 255,
0, 0, //int source_x, int source_y,
src_w, src_h, //int source_width, int source_height,
0, 0, //int destination_x, int destination_y,
fb_width, fb_height //int destination_width, int destination_height
);
break;
}
}
}
draw_checkers();
break;
case 2:
draw_hbars1();
break;
case 3:
draw_hbars2();
break;
case 4:
draw_vbars1();
break;
case 5:
draw_vbars2();
break;
case 6:
draw_spectrum();
break;
case 7:
draw_black();
break;
}
static Imlib_Image logo = 0;
if (!logo)
{
unlink("/tmp/logo.png");
if (FileSave("/tmp/logo.png", _binary_logo_png_start, _binary_logo_png_end - _binary_logo_png_start, 1))
{
logo = imlib_load_image_immediately("/tmp/logo.png");
unlink("/tmp/logo.png");
}
}
if (logo)
{
imlib_context_set_image(logo);
int src_w = imlib_image_get_width();
int src_h = imlib_image_get_height();
if (*bg)
{
imlib_context_set_image(*bg);
imlib_blend_image_onto_image(logo, 255,
0, 0, //int source_x, int source_y,
src_w, src_h, //int source_width, int source_height,
0, 0, //int destination_x, int destination_y,
fb_width*2 / 7, src_h*fb_width*2 / (src_w * 7) //int destination_width, int destination_height
);
}
}
//test the fb driver
vs_wait();
}
video_fb_enable(0);
}

View File

@@ -11,7 +11,8 @@ void video_mode_adjust();
int hasAPI1_5();
void video_fb_enable(int enable);
void video_fb_enable(int enable, int n = 0);
int video_fb_state();
void video_menu_bg(int n);
#endif // VIDEO_H