Commit 5ca57f5c authored by David Skywalker's avatar David Skywalker
Browse files

ui first tests

parent 155e0140
......@@ -360,7 +360,8 @@ INCDIRS := $(EXTRA_INCLUDES) $(INCFLAGS)
$(CXX) -c -o $@ $< $(CXXFLAGS) $(INCDIRS)
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS) $(INCDIRS)
@echo $@
@$(CC) -c -o $@ $< $(CFLAGS) $(INCDIRS)
%.o: %.S
$(CC_AS) -c -o $@ $< $(CFLAGS) $(INCDIRS)
......@@ -385,7 +386,7 @@ $(TARGET): $(HEADERS) $(OBJS)
ifeq ($(STATIC_LINKING), 1)
$(AR) rcs $@ $(OBJS)
else
$(CC) -o $@ $(SHARED) $(OBJS) $(LDFLAGS) $(LIBS)
@$(CC) -o $@ $(SHARED) $(OBJS) $(LDFLAGS) $(LIBS)
endif
clean-objs:
......
GUI = $(CORE_DIR)/libretro/nukleargui
DEPS = $(CORE_DIR)/utils
LIBRETRO_COMM_DIR := $(CORE_DIR)/libretro-common
......@@ -7,48 +6,44 @@ INCFLAGS := \
-I$(CORE_DIR)/cap32 \
-I$(CORE_DIR)/cap32/libcpccat \
-I$(CORE_DIR)/libretro \
-I$(LIBRETRO_COMM_DIR)/include \
-I$(GUI) \
-I$(GUI)/nuklear \
-I$(GUI)/retro \
-I$(DEPS)/zlib
-I$(CORE_DIR)/libretro/microui \
-I$(LIBRETRO_COMM_DIR)/include \
-I$(DEPS)/zlib
SOURCES_C := \
$(CORE_DIR)/libretro/libretro-core.c \
$(GUI)/retro/SDL_gfxPrimitives.c \
$(GUI)/retro/retro_surface.c \
$(GUI)/app.c
SOURCES_C += $(CORE_DIR)/cap32/cap32.c
SOURCES_C += $(CORE_DIR)/cap32/slots.c
SOURCES_C += $(CORE_DIR)/cap32/crtc.c
SOURCES_C += $(CORE_DIR)/cap32/fdc.c
SOURCES_C += $(CORE_DIR)/cap32/psg.c
SOURCES_C += $(CORE_DIR)/cap32/tape.c
SOURCES_C += $(CORE_DIR)/cap32/cart.c
SOURCES_C += $(CORE_DIR)/cap32/asic.c
SOURCES_C += $(CORE_DIR)/cap32/z80.c
SOURCES_C += $(CORE_DIR)/cap32/libcpccat/fs.c
SOURCES_C += $(CORE_DIR)/cap32/kbdauto.c
SOURCES_C += $(CORE_DIR)/libretro/retro_strings.c
SOURCES_C += $(CORE_DIR)/libretro/retro_utils.c
SOURCES_C += $(CORE_DIR)/libretro/retro_disk_control.c
SOURCES_C += $(CORE_DIR)/libretro/retro_events.c
SOURCES_C += $(CORE_DIR)/libretro/retro_snd.c
$(CORE_DIR)/libretro/libretro-core.c \
$(CORE_DIR)/cap32/cap32.c \
$(CORE_DIR)/cap32/slots.c \
$(CORE_DIR)/cap32/crtc.c \
$(CORE_DIR)/cap32/fdc.c \
$(CORE_DIR)/cap32/psg.c \
$(CORE_DIR)/cap32/tape.c \
$(CORE_DIR)/cap32/cart.c \
$(CORE_DIR)/cap32/asic.c \
$(CORE_DIR)/cap32/z80.c \
$(CORE_DIR)/cap32/libcpccat/fs.c \
$(CORE_DIR)/cap32/kbdauto.c \
$(CORE_DIR)/libretro/microui/microui.c \
$(CORE_DIR)/libretro/retro_strings.c \
$(CORE_DIR)/libretro/retro_utils.c \
$(CORE_DIR)/libretro/retro_disk_control.c \
$(CORE_DIR)/libretro/retro_events.c \
$(CORE_DIR)/libretro/retro_snd.c \
$(CORE_DIR)/libretro/retro_graph.c
SOURCES_C += \
$(DEPS)/zlib/adler32.c \
$(DEPS)/zlib/inflate.c \
$(DEPS)/zlib/inffast.c \
$(DEPS)/zlib/inftrees.c \
$(DEPS)/zlib/zutil.c \
$(DEPS)/zlib/gzread.c \
$(DEPS)/zlib/gzwrite.c \
$(DEPS)/zlib/gzclose.c \
$(DEPS)/zlib/gzlib.c \
$(DEPS)/zlib/trees.c \
$(DEPS)/zlib/crc32.c \
$(DEPS)/zlib/deflate.c
$(DEPS)/zlib/adler32.c \
$(DEPS)/zlib/inflate.c \
$(DEPS)/zlib/inffast.c \
$(DEPS)/zlib/inftrees.c \
$(DEPS)/zlib/zutil.c \
$(DEPS)/zlib/gzread.c \
$(DEPS)/zlib/gzwrite.c \
$(DEPS)/zlib/gzclose.c \
$(DEPS)/zlib/gzlib.c \
$(DEPS)/zlib/trees.c \
$(DEPS)/zlib/crc32.c \
$(DEPS)/zlib/deflate.c
ifneq ($(STATIC_LINKING), 1)
SOURCES_C += \
......
......@@ -162,12 +162,6 @@
May 29, 2004 - 18:09 reintroduced tape_eject, tape_insert and tape_insert_voc; added sound support via the native SDL audio routines
*/
#include <zlib.h>
#if defined (__CELLOS_LV2__) && !defined(__PSL1GHT__)
#define tmpnam(a)
#endif
#define AUTODELAY 50
/* forward declarations - some libretro port callbacks */
......@@ -1059,65 +1053,6 @@ int zip_dir (t_zip_info *zi)
return 0; // operation completed successfully
}
int zip_extract (char *pchZipFile, char *pchFileName, uint32_t dwOffset)
{
int iStatus, iCount;
uint32_t dwSize;
uint8_t *pbInputBuffer, *pbOutputBuffer;
FILE *pfileOut, *pfileIn;
z_stream z;
tmpnam(pchFileName); // generate a unique (temporary) file name for the decompression process
if (!(pfileOut = fopen(pchFileName, "wb")))
return ERR_FILE_UNZIP_FAILED; // couldn't create output file
pfileIn = fopen(pchZipFile, "rb"); // open ZIP file for reading
fseek(pfileIn, dwOffset, SEEK_SET); // move file pointer to beginning of data block
if(!fread(pbGPBuffer, 30, 1, pfileIn)) { // read local header
fclose(pfileIn);
fclose(pfileOut);
return ERR_FILE_UNZIP_FAILED;
}
dwSize = *(uint32_t *)(pbGPBuffer + 18); // length of compressed data
dwOffset += 30 + *(uint16_t *)(pbGPBuffer + 26) + *(uint16_t *)(pbGPBuffer + 28);
fseek(pfileIn, dwOffset, SEEK_SET); // move file pointer to start of compressed data
pbInputBuffer = pbGPBuffer; // space for compressed data chunck
pbOutputBuffer = pbInputBuffer + 16384; // space for uncompressed data chunck
z.zalloc = (alloc_func)0;
z.zfree = (free_func)0;
z.opaque = (voidpf)0;
iStatus = inflateInit2(&z, -MAX_WBITS); // init zlib stream (no header)
do {
z.next_in = pbInputBuffer;
if (dwSize > 16384) { // limit input size to max 16K or remaining bytes
z.avail_in = 16384;
} else {
z.avail_in = dwSize;
}
z.avail_in = fread(pbInputBuffer, 1, z.avail_in, pfileIn); // load compressed data chunck from ZIP file
while ((z.avail_in) && (iStatus == Z_OK)) { // loop until all data has been processed
z.next_out = pbOutputBuffer;
z.avail_out = 16384;
iStatus = inflate(&z, Z_NO_FLUSH); // decompress data
iCount = 16384 - z.avail_out;
if (iCount) { // save data to file if output buffer is full
fwrite(pbOutputBuffer, 1, iCount, pfileOut);
}
}
dwSize -= 16384; // advance to next chunck
} while ((dwSize > 0) && (iStatus == Z_OK)) ; // loop until done
if (iStatus != Z_STREAM_END) {
return ERR_FILE_UNZIP_FAILED; // abort on error
}
iStatus = inflateEnd(&z); // clean up
fclose(pfileIn);
fclose(pfileOut);
return 0; // data was successfully decompressed
}
int emulator_select_ROM (void)
{
uint8_t *pbPtr;
......
This diff is collapsed.
......@@ -288,6 +288,8 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(
libretro_vfs_implementation_file *stream = (libretro_vfs_implementation_file*)
calloc(1, sizeof(*stream));
(void) path_len;
#ifdef VFS_FRONTEND
const char *dumb_prefix = "vfsonly://";
size_t dumb_prefix_siz = strlen(dumb_prefix);
......
#include "microui.h"
#include "libretro.h"
#include "libretro-core.h"
#include "string/stdstring.h"
#include "file/file_path.h"
#include "retro_events.h"
#include "retro_utils.h"
#include "retro_snd.h"
#include "retro_graph.h"
//CORE VAR
#ifdef _WIN32
......@@ -40,8 +42,6 @@ retro_log_printf_t log_cb;
computer_cfg_t retro_computer_cfg;
extern int showkeyb;
extern int retro_disk_auto();
extern void change_model(int val);
extern int snapshot_load (char *pchFileName);
......@@ -71,33 +71,28 @@ extern void retro_key_up(int key);
extern void Screen_SetFullUpdate(int scr);
//VIDEO
PIXEL_TYPE *video_buffer;
PIXEL_TYPE video_buffer[WINDOW_MAX_SIZE];
PIXEL_TYPE bmp[WINDOW_MAX_SIZE];
uint32_t save_Screen[WINDOW_MAX_SIZE];
uint32_t bmp[WINDOW_MAX_SIZE];
mu_Context *ctx;
int32_t* audio_buffer = NULL;
int audio_buffer_size = 0;
//PATH
char RPATH[512];
int pauseg=0; //enter_gui
extern int app_init(void);
extern int app_free(void);
extern int app_render(int poll);
extern void app_screen_init(int width, int height);
extern void app_screen_free(void);
int retro_scr_style=0, retro_scr_w=0, retro_scr_h=0;
int gfx_buffer_size=0;
int pauseg = 0; //enter_gui
int showkeyb = 0;
int autorun = 0;
int SND=1;
int SHIFTON=-1;
#include "vkbd.i"
int retro_scr_style = 0;
int gfx_buffer_size = 0;
unsigned amstrad_devices[ 2 ];
int autorun=0;
int emu_status = COMPUTER_OFF;
int gui_status = GUI_DISABLED;
......@@ -154,8 +149,8 @@ int retro_getGfxBpp(){
}
int retro_getGfxBps(){
LOGI("getBPS: %u\n", retro_scr_w);
return retro_scr_w;
LOGI("getBPS: %u\n", EMULATION_SCREEN_WIDTH);
return EMULATION_SCREEN_WIDTH;
}
int retro_getAudioBuffer(){
......@@ -333,24 +328,6 @@ void enter_options(void) {}
#endif
void save_bkg()
{
memcpy(save_Screen,video_buffer,gfx_buffer_size);
}
void restore_bgk()
{
memcpy(video_buffer,save_Screen,gfx_buffer_size);
}
void Screen_SetFullUpdate(int scr)
{
if(scr==0 ||scr>1)
memset(&video_buffer, 0, gfx_buffer_size);
if(scr>0)
memset(&bmp,0, gfx_buffer_size);
}
void retro_message(const char *text) {
struct retro_message msg;
char msg_local[256];
......@@ -1053,6 +1030,15 @@ void computer_load_file() {
}
static int text_width(mu_Font font, const char *text, int len) {
if (len == -1) { len = strlen(text); }
return len * 16;
}
static int text_height(mu_Font font) {
return 16;
}
void retro_init(void)
{
struct retro_log_callback log;
......@@ -1116,7 +1102,6 @@ void retro_init(void)
// events initialize - joy and keyboard
ev_init();
app_init();
// Disk control interface
unsigned dci_version = 0;
......@@ -1135,19 +1120,22 @@ void retro_init(void)
update_variables();
#ifdef LOWRES
retro_scr_w = 384;
retro_scr_style = 3;
#else
retro_scr_w = 768;
retro_scr_style = 4;
#endif
retro_scr_h = 272;
gfx_buffer_size = retro_scr_w * retro_scr_h * PITCH;
gfx_buffer_size = EMULATION_SCREEN_WIDTH * EMULATION_SCREEN_HEIGHT * PITCH;
app_screen_init(retro_scr_w, retro_scr_h);
ctx = malloc(sizeof(mu_Context));
mu_init(ctx);
ctx->text_width = text_width;
ctx->text_height = text_height;
fprintf(stderr, "[libretro-cap32]: Got size: %u x %u (s%d rs%d bs%u).\n",
retro_scr_w, retro_scr_h, retro_scr_style, gfx_buffer_size, (unsigned int) sizeof(bmp));
EMULATION_SCREEN_WIDTH, EMULATION_SCREEN_HEIGHT, retro_scr_style, gfx_buffer_size, (unsigned int) sizeof(bmp));
memset(video_buffer, 0, gfx_buffer_size);
//memset(bmp, 0, WINDOW_MAX_SIZE); // buffer gui
Emu_init();
......@@ -1160,12 +1148,10 @@ extern void main_exit();
void retro_deinit(void)
{
free_retro_snd();
app_free();
app_screen_free();
Emu_uninit();
UnInitOSGLU();
mu_end(ctx);
// Clean the m3u storage
if(dc)
......@@ -1194,9 +1180,6 @@ void retro_get_system_info(struct retro_system_info *info)
{
memset(info, 0, sizeof(*info));
info->library_name = "cap32";
#ifdef LOWRES
#define SCREENMODE_STR " LO"
#endif
#ifndef GIT_VERSION
#define GIT_VERSION ""
#endif
......@@ -1241,6 +1224,19 @@ void retro_audio_mix()
audio_batch_cb((int16_t*) audio_buffer, audio_buffer_size);
}
void retro_PollEvent()
{
input_poll_cb(); // retroarch get keys
// --- Player 1/2 Joystick code
if(showkeyb < 0) {
ev_joysticks();
} else {
ev_events();
}
}
void retro_run(void)
{
bool updated = false;
......@@ -1248,18 +1244,13 @@ void retro_run(void)
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
update_variables();
if(pauseg==0)
{
retro_loop();
Core_PollEvent();
if(showkeyb==1)
app_render(0);
}
else if (pauseg==1)app_render(1);
video_cb(video_buffer, retro_scr_w, retro_scr_h, retro_scr_w << PIXEL_BYTES);
retro_loop();
retro_PollEvent();
// FIXME GRAPH TESTS
DrawLine(video_buffer, 10, 10, 80, 0);
DrawRect(video_buffer, 10, 10, EMULATION_SCREEN_WIDTH - 10, 50, 0xffffff00);
video_cb(video_buffer, EMULATION_SCREEN_WIDTH, EMULATION_SCREEN_HEIGHT, EMULATION_SCREEN_WIDTH << PIXEL_BYTES);
}
bool retro_load_game(const struct retro_game_info *game)
......@@ -1348,3 +1339,20 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code)
(void)enabled;
(void)code;
}
// unused funcs
void save_bkg()
{
memcpy(save_Screen,video_buffer,gfx_buffer_size);
}
void restore_bgk()
{
memcpy(video_buffer,save_Screen,gfx_buffer_size);
}
void Screen_SetFullUpdate(int scr)
{
if(scr==0 ||scr>1)
memset(&video_buffer, 0, gfx_buffer_size);
if(scr>0)
memset(&bmp,0, gfx_buffer_size);
}
......@@ -26,8 +26,6 @@ extern unsigned amstrad_devices[ PORTS_NUMBER ];
#define TEX_MAX_WIDTH 768
#define TEX_MAX_HEIGHT 272
//#define LOWRES 1
#define SCREENMODE_STR " HI"
//AUDIO
#define FRAME_PERIOD_MS 20.0 // check cap32.h
......@@ -58,8 +56,6 @@ extern unsigned amstrad_devices[ PORTS_NUMBER ];
#define PITCH 4
#endif
extern PIXEL_TYPE *video_buffer;
#ifdef M16B
#define RGB2COLOR(r, g, b) ((b>>3) | ((g>>2)<<5) | ((r>>3)<<11))
#define RGB2RED(colour) (((colour>>11)<<3) & 0xFF)
......@@ -74,6 +70,14 @@ extern PIXEL_TYPE *video_buffer;
#define WINDOW_MAX_SIZE (TEX_MAX_WIDTH * TEX_MAX_HEIGHT)
#define EMULATION_SCREEN_HEIGHT TEX_MAX_HEIGHT
#ifdef LOWRES
#define SCREENMODE_STR " LO"
#define EMULATION_SCREEN_WIDTH 384
#else
#define SCREENMODE_STR " HI"
#define EMULATION_SCREEN_WIDTH 768
#endif
// BIT OPERATIONS - MACROS
......
This diff is collapsed.
/*
** Copyright (c) 2020 rxi
**
** This library is free software; you can redistribute it and/or modify it
** under the terms of the MIT license. See `microui.c` for details.
*/
#ifndef MICROUI_H
#define MICROUI_H
#define MU_VERSION "2.01"
#define MU_COMMANDLIST_SIZE (256 * 1024)
#define MU_ROOTLIST_SIZE 32
#define MU_CONTAINERSTACK_SIZE 32
#define MU_CLIPSTACK_SIZE 32
#define MU_IDSTACK_SIZE 32
#define MU_LAYOUTSTACK_SIZE 16
#define MU_CONTAINERPOOL_SIZE 48
#define MU_TREENODEPOOL_SIZE 48
#define MU_MAX_WIDTHS 16
#define MU_REAL float
#define MU_REAL_FMT "%.3g"
#define MU_SLIDER_FMT "%.2f"
#define MU_MAX_FMT 127
#define mu_stack(T, n) struct { int idx; T items[n]; }
#define mu_min(a, b) ((a) < (b) ? (a) : (b))
#define mu_max(a, b) ((a) > (b) ? (a) : (b))
#define mu_clamp(x, a, b) mu_min(b, mu_max(a, x))
enum {
MU_CLIP_PART = 1,
MU_CLIP_ALL
};
enum {
MU_COMMAND_JUMP = 1,
MU_COMMAND_CLIP,
MU_COMMAND_RECT,
MU_COMMAND_TEXT,
MU_COMMAND_ICON,
MU_COMMAND_MAX
};
enum {
MU_COLOR_TEXT,
MU_COLOR_BORDER,
MU_COLOR_WINDOWBG,
MU_COLOR_TITLEBG,
MU_COLOR_TITLETEXT,
MU_COLOR_PANELBG,
MU_COLOR_BUTTON,
MU_COLOR_BUTTONHOVER,
MU_COLOR_BUTTONFOCUS,
MU_COLOR_BASE,
MU_COLOR_BASEHOVER,
MU_COLOR_BASEFOCUS,
MU_COLOR_SCROLLBASE,
MU_COLOR_SCROLLTHUMB,
MU_COLOR_MAX
};
enum {
MU_ICON_CLOSE = 1,
MU_ICON_CHECK,
MU_ICON_COLLAPSED,
MU_ICON_EXPANDED,
MU_ICON_MAX
};
enum {
MU_RES_ACTIVE = (1 << 0),
MU_RES_SUBMIT = (1 << 1),
MU_RES_CHANGE = (1 << 2)
};
enum {
MU_OPT_ALIGNCENTER = (1 << 0),
MU_OPT_ALIGNRIGHT = (1 << 1),
MU_OPT_NOINTERACT = (1 << 2),
MU_OPT_NOFRAME = (1 << 3),
MU_OPT_NORESIZE = (1 << 4),
MU_OPT_NOSCROLL = (1 << 5),
MU_OPT_NOCLOSE = (1 << 6),
MU_OPT_NOTITLE = (1 << 7),
MU_OPT_HOLDFOCUS = (1 << 8),
MU_OPT_AUTOSIZE = (1 << 9),
MU_OPT_POPUP = (1 << 10),
MU_OPT_CLOSED = (1 << 11),
MU_OPT_EXPANDED = (1 << 12)
};
enum {
MU_MOUSE_LEFT = (1 << 0),
MU_MOUSE_RIGHT = (1 << 1),
MU_MOUSE_MIDDLE = (1 << 2)
};
enum {
MU_KEY_SHIFT = (1 << 0),
MU_KEY_CTRL = (1 << 1),
MU_KEY_ALT = (1 << 2),
MU_KEY_BACKSPACE = (1 << 3),
MU_KEY_RETURN = (1 << 4)
};
typedef struct mu_Context mu_Context;
typedef unsigned mu_Id;
typedef MU_REAL mu_Real;
typedef void* mu_Font;
typedef struct { int x, y; } mu_Vec2;
typedef struct { int x, y, w, h; } mu_Rect;
typedef struct { unsigned char r, g, b, a; } mu_Color;
typedef struct { mu_Id id; int last_update; } mu_PoolItem;
typedef struct { int type, size; } mu_BaseCommand;
typedef struct { mu_BaseCommand base; void *dst; } mu_JumpCommand;
typedef struct { mu_BaseCommand base; mu_Rect rect; } mu_ClipCommand;
typedef struct { mu_BaseCommand base; mu_Rect rect; mu_Color color; } mu_RectCommand;
typedef struct { mu_BaseCommand base; mu_Font font; mu_Vec2 pos; mu_Color color; char str[1]; } mu_TextCommand;
typedef struct { mu_BaseCommand base; mu_Rect rect; int id; mu_Color color; } mu_IconCommand;
typedef union {
int type;
mu_BaseCommand base;
mu_JumpCommand jump;
mu_ClipCommand clip;
mu_RectCommand rect;
mu_TextCommand text;
mu_IconCommand icon;
} mu_Command;
typedef struct {
mu_Rect body;
mu_Rect next;
mu_Vec2 position;
mu_Vec2 size;
mu_Vec2 max;
int widths[MU_MAX_WIDTHS];
int items;
int item_index;
int next_row;
int next_type;
int indent;
} mu_Layout;
typedef struct {
mu_Command *head, *tail;
mu_Rect rect;
mu_Rect body;
mu_Vec2 content_size;
mu_Vec2 scroll;
int zindex;
int open;
} mu_Container;
typedef struct {