mirror of https://github.com/inolen/redream.git
windows build fixes
This commit is contained in:
parent
acd9e6c4a9
commit
55da995676
|
@ -303,6 +303,15 @@ gdb_server_t *gdb_server_create(gdb_target_t *target, int port) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if PLATFORM_WINDOWS
|
||||||
|
WSADATA wsadata;
|
||||||
|
int r = WSAStartup(MAKEWORD(2, 2), &wsadata);
|
||||||
|
if (r) {
|
||||||
|
GDB_SERVER_LOG("Failed to initialize WinSock");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
gdb_server_t *sv = (gdb_server_t *)GDB_SERVER_MALLOC(sizeof(gdb_server_t));
|
gdb_server_t *sv = (gdb_server_t *)GDB_SERVER_MALLOC(sizeof(gdb_server_t));
|
||||||
memset(sv, 0, sizeof(*sv));
|
memset(sv, 0, sizeof(*sv));
|
||||||
sv->target = *target;
|
sv->target = *target;
|
||||||
|
@ -310,8 +319,8 @@ gdb_server_t *gdb_server_create(gdb_target_t *target, int port) {
|
||||||
sv->client = INVALID_SOCKET;
|
sv->client = INVALID_SOCKET;
|
||||||
|
|
||||||
if (gdb_server_create_listen(sv, port) == -1) {
|
if (gdb_server_create_listen(sv, port) == -1) {
|
||||||
GDB_SERVER_FREE(sv);
|
gdb_server_destroy(sv);
|
||||||
sv = NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sv;
|
return sv;
|
||||||
|
@ -346,6 +355,11 @@ void gdb_server_destroy(gdb_server_t *sv) {
|
||||||
gdb_server_destroy_listen(sv);
|
gdb_server_destroy_listen(sv);
|
||||||
|
|
||||||
GDB_SERVER_FREE(sv);
|
GDB_SERVER_FREE(sv);
|
||||||
|
|
||||||
|
#if PLATFORM_WINDOWS
|
||||||
|
int r = WSACleanup();
|
||||||
|
GDB_SERVER_ASSERT(r == 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -414,6 +428,10 @@ static int gdb_server_create_listen(gdb_server_t *sv, int port) {
|
||||||
// destroy the listen server
|
// destroy the listen server
|
||||||
//
|
//
|
||||||
static void gdb_server_destroy_listen(gdb_server_t *sv) {
|
static void gdb_server_destroy_listen(gdb_server_t *sv) {
|
||||||
|
if (sv->listen == INVALID_SOCKET) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
gdb_server_destroy_client(sv);
|
gdb_server_destroy_client(sv);
|
||||||
|
|
||||||
shutdown(sv->listen, SHUT_RDWR);
|
shutdown(sv->listen, SHUT_RDWR);
|
||||||
|
|
|
@ -54,7 +54,7 @@ const char *format_check_error(const char *filename, int linenum,
|
||||||
do { \
|
do { \
|
||||||
if (!CHECK_EXPECT_TRUE(!strcmp(v1, v2))) { \
|
if (!CHECK_EXPECT_TRUE(!strcmp(v1, v2))) { \
|
||||||
const char *msg = FORMAT_CHECK_ERROR( \
|
const char *msg = FORMAT_CHECK_ERROR( \
|
||||||
__FILE__, __LINE__, "Expected '" #v1 "' to eq '" #v2 "'", 0, \
|
__FILE__, __LINE__, "expected '" #v1 "' to eq '" #v2 "'", 0, \
|
||||||
##__VA_ARGS__); \
|
##__VA_ARGS__); \
|
||||||
LOG_FATAL(msg); \
|
LOG_FATAL(msg); \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "core/sort.h"
|
#include "core/sort.h"
|
||||||
|
|
||||||
static void merge(void *in, void *out, size_t size, int l, int m, int r,
|
static void merge(uint8_t *in, uint8_t *out, size_t size, int l, int m, int r,
|
||||||
sort_cmp cmp) {
|
sort_cmp cmp) {
|
||||||
int i = l;
|
int i = l;
|
||||||
int j = m;
|
int j = m;
|
||||||
|
@ -21,7 +22,7 @@ static void merge(void *in, void *out, size_t size, int l, int m, int r,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void msort_r(void *in, void *out, size_t size, int l, int r,
|
static void msort_r(uint8_t *in, uint8_t *out, size_t size, int l, int r,
|
||||||
sort_cmp cmp) {
|
sort_cmp cmp) {
|
||||||
if ((r - l) < 2) {
|
if ((r - l) < 2) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -42,7 +42,7 @@ void cond_destroy(cond_t cond);
|
||||||
* sleeping
|
* sleeping
|
||||||
*/
|
*/
|
||||||
#if PLATFORM_WINDOWS
|
#if PLATFORM_WINDOWS
|
||||||
#include <Synchapi.h>
|
#include <windows.h>
|
||||||
#define sleep Sleep
|
#define sleep Sleep
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
|
@ -131,10 +131,12 @@ int dc_load(struct dreamcast *dc, const char *path) {
|
||||||
|
|
||||||
int dc_init(struct dreamcast *dc) {
|
int dc_init(struct dreamcast *dc) {
|
||||||
if (dc->debugger && !debugger_init(dc->debugger)) {
|
if (dc->debugger && !debugger_init(dc->debugger)) {
|
||||||
|
LOG_WARNING("failed to initialize debugger");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!memory_init(dc->memory)) {
|
if (!memory_init(dc->memory)) {
|
||||||
|
LOG_WARNING("failed to initialize shared memory");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,11 +161,13 @@ int dc_init(struct dreamcast *dc) {
|
||||||
/* initialize each device */
|
/* initialize each device */
|
||||||
list_for_each_entry(dev, &dc->devices, struct device, it) {
|
list_for_each_entry(dev, &dc->devices, struct device, it) {
|
||||||
if (!dev->init(dev)) {
|
if (!dev->init(dev)) {
|
||||||
|
LOG_WARNING("failed to initialize device '%s'", dev->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bios_init(dc->bios)) {
|
if (!bios_init(dc->bios)) {
|
||||||
|
LOG_WARNING("failed to initialize bios");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -362,7 +362,7 @@ static void *emu_video_thread(void *data) {
|
||||||
struct emu *emu = data;
|
struct emu *emu = data;
|
||||||
|
|
||||||
/* make secondary context active for this thread */
|
/* make secondary context active for this thread */
|
||||||
r_make_current(emu->r2);
|
r_bind_context(emu->r2);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
mutex_lock(emu->pending_mutex);
|
mutex_lock(emu->pending_mutex);
|
||||||
|
@ -399,6 +399,10 @@ static void *emu_video_thread(void *data) {
|
||||||
mutex_unlock(emu->pending_mutex);
|
mutex_unlock(emu->pending_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* unbind context from this thread before it dies, otherwise the main thread
|
||||||
|
may not be able to bind it in order to clean it up */
|
||||||
|
r_unbind_context(emu->r2);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,7 +623,7 @@ static void emu_host_context_destroyed(void *userdata) {
|
||||||
/* destroy the video thread */
|
/* destroy the video thread */
|
||||||
if (emu->multi_threaded) {
|
if (emu->multi_threaded) {
|
||||||
mutex_lock(emu->pending_mutex);
|
mutex_lock(emu->pending_mutex);
|
||||||
emu->pending_ctx = (struct tile_context *)0xdeadbeef;
|
emu->pending_ctx = (struct tile_context *)(intptr_t)0xdeadbeef;
|
||||||
cond_signal(emu->pending_cond);
|
cond_signal(emu->pending_cond);
|
||||||
mutex_unlock(emu->pending_mutex);
|
mutex_unlock(emu->pending_mutex);
|
||||||
|
|
||||||
|
@ -632,8 +636,7 @@ static void emu_host_context_destroyed(void *userdata) {
|
||||||
|
|
||||||
/* destroy video renderer */
|
/* destroy video renderer */
|
||||||
struct render_backend *r2 = emu_video_renderer(emu);
|
struct render_backend *r2 = emu_video_renderer(emu);
|
||||||
|
r_bind_context(r2);
|
||||||
r_make_current(r2);
|
|
||||||
|
|
||||||
r_destroy_framebuffer(r2, emu->video_fb);
|
r_destroy_framebuffer(r2, emu->video_fb);
|
||||||
if (emu->video_sync) {
|
if (emu->video_sync) {
|
||||||
|
@ -647,7 +650,7 @@ static void emu_host_context_destroyed(void *userdata) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* destroy primary renderer */
|
/* destroy primary renderer */
|
||||||
r_make_current(emu->r);
|
r_bind_context(emu->r);
|
||||||
|
|
||||||
mp_destroy(emu->mp);
|
mp_destroy(emu->mp);
|
||||||
imgui_destroy(emu->imgui);
|
imgui_destroy(emu->imgui);
|
||||||
|
@ -674,20 +677,19 @@ static void emu_host_context_reset(void *userdata) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct render_backend *r2 = emu_video_renderer(emu);
|
struct render_backend *r2 = emu_video_renderer(emu);
|
||||||
|
r_bind_context(r2);
|
||||||
r_make_current(r2);
|
|
||||||
|
|
||||||
emu->video_fb = r_create_framebuffer(r2, emu->video_width, emu->video_height,
|
emu->video_fb = r_create_framebuffer(r2, emu->video_width, emu->video_height,
|
||||||
&emu->video_tex);
|
&emu->video_tex);
|
||||||
|
|
||||||
|
/* make primary renderer active for the current thread */
|
||||||
|
r_bind_context(emu->r);
|
||||||
|
|
||||||
/* startup video thread */
|
/* startup video thread */
|
||||||
if (emu->multi_threaded) {
|
if (emu->multi_threaded) {
|
||||||
emu->video_thread = thread_create(&emu_video_thread, NULL, emu);
|
emu->video_thread = thread_create(&emu_video_thread, NULL, emu);
|
||||||
CHECK_NOTNULL(emu->video_thread);
|
CHECK_NOTNULL(emu->video_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make primary renderer active for the current thread */
|
|
||||||
r_make_current(emu->r);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void emu_host_resized(void *userdata) {
|
static void emu_host_resized(void *userdata) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ static int gdi_read_sector(struct disc *disc, int fad, enum gd_secfmt fmt,
|
||||||
CHECK(mask == MASK_DATA);
|
CHECK(mask == MASK_DATA);
|
||||||
|
|
||||||
/* open the file backing the track */
|
/* open the file backing the track */
|
||||||
int n = track - gdi->tracks;
|
int n = (int)(track - gdi->tracks);
|
||||||
FILE *fp = gdi->files[n];
|
FILE *fp = gdi->files[n];
|
||||||
|
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
|
|
|
@ -207,7 +207,7 @@ static void gdrom_spi_data(struct gdrom *gd, int arg) {
|
||||||
int offset = gd->pio_offset;
|
int offset = gd->pio_offset;
|
||||||
uint8_t *data = gd->pio_buffer;
|
uint8_t *data = gd->pio_buffer;
|
||||||
int size = gd->pio_size;
|
int size = gd->pio_size;
|
||||||
memcpy((void *)&gd->hw_info + offset, data, size);
|
memcpy((uint8_t *)&gd->hw_info + offset, data, size);
|
||||||
|
|
||||||
gdrom_spi_end(gd);
|
gdrom_spi_end(gd);
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ static void gdrom_spi_cmd(struct gdrom *gd, int arg) {
|
||||||
int offset = data[2];
|
int offset = data[2];
|
||||||
int size = data[4];
|
int size = data[4];
|
||||||
|
|
||||||
gdrom_spi_write(gd, (void *)&gd->hw_info + offset, size);
|
gdrom_spi_write(gd, (uint8_t *)&gd->hw_info + offset, size);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case SPI_REQ_ERROR: {
|
case SPI_REQ_ERROR: {
|
||||||
|
|
|
@ -64,7 +64,7 @@ static int boot_load_rom(struct boot *boot) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
if (!boot_validate(boot)) {
|
if (!boot_validate(boot)) {
|
||||||
LOG_WARNING("invalid BIOS file");
|
LOG_WARNING("failed to validate boot rom");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@ static void interp_backend_run_code(struct jit_backend *base, int cycles) {
|
||||||
struct interp_backend *backend = (struct interp_backend *)base;
|
struct interp_backend *backend = (struct interp_backend *)base;
|
||||||
struct jit *jit = backend->jit;
|
struct jit *jit = backend->jit;
|
||||||
struct jit_guest *guest = jit->guest;
|
struct jit_guest *guest = jit->guest;
|
||||||
void *ctx = guest->ctx;
|
uint8_t *ctx = guest->ctx;
|
||||||
uint32_t *pc = ctx + guest->offset_pc;
|
uint32_t *pc = (uint32_t *)(ctx + guest->offset_pc);
|
||||||
int32_t *run_cycles = ctx + guest->offset_cycles;
|
int32_t *run_cycles = (int32_t *)(ctx + guest->offset_cycles);
|
||||||
int32_t *ran_instrs = ctx + guest->offset_instrs;
|
int32_t *ran_instrs = (int32_t *)(ctx + guest->offset_instrs);
|
||||||
|
|
||||||
*run_cycles = cycles;
|
*run_cycles = cycles;
|
||||||
*ran_instrs = 0;
|
*ran_instrs = 0;
|
||||||
|
|
|
@ -829,7 +829,11 @@ void r_set_debug_flag(struct render_backend *r, int flag) {
|
||||||
r->debug_flags |= flag;
|
r->debug_flags |= flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void r_make_current(struct render_backend *r) {
|
void r_unbind_context(struct render_backend *r) {
|
||||||
|
video_gl_make_current(r->host, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void r_bind_context(struct render_backend *r) {
|
||||||
video_gl_make_current(r->host, r->ctx);
|
video_gl_make_current(r->host, r->ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,8 @@ struct render_backend *r_create(struct host *host);
|
||||||
struct render_backend *r_create_from(struct render_backend *other);
|
struct render_backend *r_create_from(struct render_backend *other);
|
||||||
void r_destroy(struct render_backend *rc);
|
void r_destroy(struct render_backend *rc);
|
||||||
|
|
||||||
void r_make_current(struct render_backend *r);
|
void r_bind_context(struct render_backend *r);
|
||||||
|
void r_unbind_context(struct render_backend *r);
|
||||||
|
|
||||||
void r_set_debug_flag(struct render_backend *r, int flag);
|
void r_set_debug_flag(struct render_backend *r, int flag);
|
||||||
int r_get_debug_flag(struct render_backend *r, int flag);
|
int r_get_debug_flag(struct render_backend *r, int flag);
|
||||||
|
|
|
@ -559,7 +559,7 @@ static void tracer_render_side_menu(struct tracer *tracer) {
|
||||||
igSetWindowPos(pos, ImGuiSetCond_Once);
|
igSetWindowPos(pos, ImGuiSetCond_Once);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int tex_per_row = MAX(igGetContentRegionAvailWidth() / 44, 1);
|
int tex_per_row = MAX((int)(igGetContentRegionAvailWidth() / 44.0f), 1);
|
||||||
|
|
||||||
rb_for_each_entry(tex, &tracer->live_textures, struct tracer_texture,
|
rb_for_each_entry(tex, &tracer->live_textures, struct tracer_texture,
|
||||||
live_it) {
|
live_it) {
|
||||||
|
|
Loading…
Reference in New Issue