Skip to content

Commit

Permalink
Merged develop
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-jonsson committed Sep 4, 2024
2 parents 5a69fd7 + b926905 commit 9559d29
Show file tree
Hide file tree
Showing 49 changed files with 1,084 additions and 1,254 deletions.
1,196 changes: 513 additions & 683 deletions bios/glabios.h

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions front/common/frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@
#endif

struct frontend_video_adapter {
struct vxt_pirepheral *device;
vxt_dword (*border_color)(struct vxt_pirepheral *p);
bool (*snapshot)(struct vxt_pirepheral *p);
int (*render)(struct vxt_pirepheral *p, int (*f)(int,int,const vxt_byte*,void*), void *userdata);
struct vxt_peripheral *device;
vxt_dword (*border_color)(struct vxt_peripheral *p);
bool (*snapshot)(struct vxt_peripheral *p);
int (*render)(struct vxt_peripheral *p, int (*f)(int,int,const vxt_byte*,void*), void *userdata);
};

struct frontend_audio_adapter {
struct vxt_pirepheral *device;
vxt_int16 (*generate_sample)(struct vxt_pirepheral *p, int freq);
struct vxt_peripheral *device;
vxt_int16 (*generate_sample)(struct vxt_peripheral *p, int freq);
};

enum frontend_mouse_button {
Expand All @@ -68,15 +68,15 @@ struct frontend_mouse_event {
};

struct frontend_mouse_adapter {
struct vxt_pirepheral *device;
bool (*push_event)(struct vxt_pirepheral *p, const struct frontend_mouse_event *ev);
struct vxt_peripheral *device;
bool (*push_event)(struct vxt_peripheral *p, const struct frontend_mouse_event *ev);
};

struct frontend_disk_controller {
struct vxt_pirepheral *device;
vxt_error (*mount)(struct vxt_pirepheral *p, int num, void *fp);
bool (*unmount)(struct vxt_pirepheral *p, int num);
void (*set_boot)(struct vxt_pirepheral *p, int num);
struct vxt_peripheral *device;
vxt_error (*mount)(struct vxt_peripheral *p, int num, void *fp);
bool (*unmount)(struct vxt_peripheral *p, int num);
void (*set_boot)(struct vxt_peripheral *p, int num);
};

enum frontend_path_type {
Expand Down Expand Up @@ -104,13 +104,13 @@ struct frontend_joystick_event {
};

struct frontend_joystick_controller {
struct vxt_pirepheral *device;
bool (*push_event)(struct vxt_pirepheral *p, const struct frontend_joystick_event *ev);
struct vxt_peripheral *device;
bool (*push_event)(struct vxt_peripheral *p, const struct frontend_joystick_event *ev);
};

struct frontend_keyboard_controller {
struct vxt_pirepheral *device;
bool (*push_event)(struct vxt_pirepheral *p, enum vxtu_scancode key, bool force);
struct vxt_peripheral *device;
bool (*push_event)(struct vxt_peripheral *p, enum vxtu_scancode key, bool force);
};

enum frontend_ctrl_command {
Expand Down
32 changes: 16 additions & 16 deletions front/libretro/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ struct retro_vfs_file_handle *hd_image = NULL;
int cpu_frequency = VXT_DEFAULT_FREQUENCY;

vxt_system *sys = NULL;
struct vxt_pirepheral *disk = NULL;
struct vxt_pirepheral *ppi = NULL;
struct vxt_pirepheral *cga = NULL;
struct vxt_pirepheral *mouse = NULL;
struct vxt_pirepheral *joystick = NULL;
struct vxt_peripheral *disk = NULL;
struct vxt_peripheral *ppi = NULL;
struct vxt_peripheral *cga = NULL;
struct vxt_peripheral *mouse = NULL;
struct vxt_peripheral *joystick = NULL;

// From joystick.c
bool joystick_push_event(struct vxt_pirepheral *p, const struct frontend_joystick_event *ev);
struct vxt_pirepheral *joystick_create(vxt_allocator *alloc, void *frontend, const char *args);
bool joystick_push_event(struct vxt_peripheral *p, const struct frontend_joystick_event *ev);
struct vxt_peripheral *joystick_create(vxt_allocator *alloc, void *frontend, const char *args);

// From mouse.c
struct vxt_pirepheral *mouse_create(vxt_allocator *alloc, void *frontend, const char *args);
bool mouse_push_event(struct vxt_pirepheral *p, const struct frontend_mouse_event *ev);
struct vxt_peripheral *mouse_create(vxt_allocator *alloc, void *frontend, const char *args);
bool mouse_push_event(struct vxt_peripheral *p, const struct frontend_mouse_event *ev);

static void no_log(enum retro_log_level level, const char *fmt, ...) {
(void)level; (void)fmt;
Expand Down Expand Up @@ -321,8 +321,8 @@ static void check_variables(void) {
}
}

static struct vxt_pirepheral *load_bios(const vxt_byte *data, int size, vxt_pointer base) {
struct vxt_pirepheral *rom = vxtu_memory_create(&realloc, base, size, true);
static struct vxt_peripheral *load_bios(const vxt_byte *data, int size, vxt_pointer base) {
struct vxt_peripheral *rom = vxtu_memory_create(&realloc, base, size, true);
if (!vxtu_memory_device_fill(rom, data, size)) {
log_cb(RETRO_LOG_ERROR, "vxtu_memory_device_fill() failed!\n");
return NULL;
Expand All @@ -347,7 +347,7 @@ void retro_init(void) {
mouse = mouse_create(&realloc, NULL, "0x3F8"); // COM1
joystick = joystick_create(&realloc, NULL, "0x201");

struct vxt_pirepheral *devices[] = {
struct vxt_peripheral *devices[] = {
vxtu_memory_create(&realloc, 0x0, 0x100000, false),
load_bios(glabios_bin, (int)glabios_bin_len, 0xFE000),
load_bios(vxtx_bin, (int)vxtx_bin_len, 0xE0000),
Expand All @@ -369,11 +369,11 @@ void retro_init(void) {
vxt_system_initialize(sys);

LOG("CPU Frequency: %.2fMHz\n", (double)cpu_frequency / 1000000.0);
LOG("Installed pirepherals:\n");
for (int i = 1; i < VXT_MAX_PIREPHERALS; i++) {
struct vxt_pirepheral *device = vxt_system_pirepheral(sys, (vxt_byte)i);
LOG("Installed peripherals:\n");
for (int i = 1; i < VXT_MAX_PERIPHERALS; i++) {
struct vxt_peripheral *device = vxt_system_peripheral(sys, (vxt_byte)i);
if (device)
LOG("%d - %s\n", i, vxt_pirepheral_name(device));
LOG("%d - %s\n", i, vxt_peripheral_name(device));
}
vxt_system_reset(sys);
)
Expand Down
4 changes: 2 additions & 2 deletions front/libretro/joystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@

#include "../../modules/joystick/joystick.c"

bool joystick_push_event(struct vxt_pirepheral *p, const struct frontend_joystick_event *ev) {
bool joystick_push_event(struct vxt_peripheral *p, const struct frontend_joystick_event *ev) {
return push_event(p, ev);
}

struct vxt_pirepheral *joystick_create(vxt_allocator *alloc, void *frontend, const char *args) {
struct vxt_peripheral *joystick_create(vxt_allocator *alloc, void *frontend, const char *args) {
return create(alloc, frontend, args);
}
4 changes: 2 additions & 2 deletions front/libretro/mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@

#include "../../modules/mouse/mouse.c"

struct vxt_pirepheral *mouse_create(vxt_allocator *alloc, void *frontend, const char *args) {
struct vxt_peripheral *mouse_create(vxt_allocator *alloc, void *frontend, const char *args) {
return create(alloc, frontend, args);
}

bool mouse_push_event(struct vxt_pirepheral *p, const struct frontend_mouse_event *ev) {
bool mouse_push_event(struct vxt_peripheral *p, const struct frontend_mouse_event *ev) {
return push_event(p, ev);
}
52 changes: 26 additions & 26 deletions front/sdl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ double cpu_frequency = (double)VXT_DEFAULT_FREQUENCY / 1000000.0;
bool cpu_paused = false;

int num_devices = 0;
struct vxt_pirepheral *devices[VXT_MAX_PIREPHERALS] = { NULL };
struct vxt_peripheral *devices[VXT_MAX_PERIPHERALS] = { NULL };
#define APPEND_DEVICE(d) { devices[num_devices++] = (d); }

// Needed for detecting turbo mode.
struct vxt_pirepheral *ppi_device = NULL;
struct vxt_peripheral *ppi_device = NULL;

SDL_atomic_t running = {1};
SDL_mutex *emu_mutex = NULL;
Expand Down Expand Up @@ -203,7 +203,7 @@ static int emu_loop(void *ptr) {
}
num_cycles += res.cycles;
}

frequency = vxtu_ppi_turbo_enabled(ppi_device) ? cpu_frequency : ((double)VXT_DEFAULT_FREQUENCY / 1000000.0);
frequency_hz = (int)(frequency * 1000000.0);
vxt_system_set_frequency(vxt, frequency_hz);
Expand Down Expand Up @@ -236,7 +236,7 @@ void monitors_window(mu_Context *ctx, vxt_system *s) {
mu_layout_row(ctx, 2, (int[]){ 120, -1 }, 0);
if (mu_button_ex(ctx, cpu_paused ? "Resume" : "Pause", 0, MU_OPT_ALIGNCENTER))
cpu_paused = !cpu_paused;

mu_label(ctx, cpu_paused ? "Halted!" : "Running...");

for (vxt_byte i = 0; i < VXT_MAX_MONITORS;) {
Expand All @@ -252,7 +252,7 @@ void monitors_window(mu_Context *ctx, vxt_system *s) {
} else if (!open) {
continue;
}

mu_layout_row(ctx, 2, (int[]){ mr_get_text_width(m->name, (int)strlen(m->name)) + 10, -1 }, 0);
mu_label(ctx, m->name);

Expand Down Expand Up @@ -312,7 +312,7 @@ static int render_callback(int width, int height, const vxt_byte *rgba, void *us
static void audio_callback(void *udata, uint8_t *stream, int len) {
(void)udata;
len /= 2;

SYNC(
for (int i = 0; i < len; i++) {
vxt_word sample = 0;
Expand Down Expand Up @@ -383,7 +383,7 @@ static const char *resolve_path(enum frontend_path_type type, const char *path)

if (file_exist(buffer))
return buffer;

const char *bp = SDL_GetBasePath();
bp = bp ? bp : ".";

Expand All @@ -410,7 +410,7 @@ static const char *resolve_path(enum frontend_path_type type, const char *path)
case FRONTEND_MODULE_PATH: sprintf(buffer, "%s/modules/%s", sp, path); break;
default: break;
};

if (file_exist(buffer))
return buffer;
}
Expand Down Expand Up @@ -467,7 +467,7 @@ static vxt_byte emu_control(enum frontend_ctrl_command cmd, vxt_byte data, void
emuctrl_buffer[emuctrl_buffer_len++] = data;
break;
case FRONTEND_CTRL_POPEN:
if (!(emuctrl_file_handle =
if (!(emuctrl_file_handle =
#ifdef _WIN32
_popen
#else
Expand Down Expand Up @@ -626,7 +626,7 @@ static int load_modules(void *user, const char *section, const char *name, const
}

for (vxtu_module_entry_func *f = const_func; *f; f++) {
struct vxt_pirepheral *p = (*f)(VXTU_CAST(user, void*, vxt_allocator*), (void*)&front_interface, value);
struct vxt_peripheral *p = (*f)(VXTU_CAST(user, void*, vxt_allocator*), (void*)&front_interface, value);
if (!p)
continue; // Assume the module chose not to be loaded.
APPEND_DEVICE(p);
Expand All @@ -645,7 +645,7 @@ static int load_modules(void *user, const char *section, const char *name, const
return 1;
}

static int configure_pirepherals(void *user, const char *section, const char *name, const char *value) {
static int configure_peripherals(void *user, const char *section, const char *name, const char *value) {
return (vxt_system_configure(user, section, name, value) == VXT_NO_ERROR) ? 1 : 0;
}

Expand All @@ -659,9 +659,9 @@ static void print_memory_map(vxt_system *s) {
if (idx && (idx != prev_idx)) {
printf("[0x%.4X-", i);
while (map[++i] == idx);
printf("0x%.4X] %s\n", i - 1, vxt_pirepheral_name(vxt_system_pirepheral(s, idx)));
printf("0x%.4X] %s\n", i - 1, vxt_peripheral_name(vxt_system_peripheral(s, idx)));
prev_idx = idx;
}
}
}

prev_idx = 0;
Expand All @@ -673,10 +673,10 @@ static void print_memory_map(vxt_system *s) {
if (idx != prev_idx) {
printf("[0x%.5X-", i << 4);
while (map[++i] == idx);
printf("0x%.5X] %s\n", (i << 4) - 1, vxt_pirepheral_name(vxt_system_pirepheral(s, idx)));
printf("0x%.5X] %s\n", (i << 4) - 1, vxt_peripheral_name(vxt_system_peripheral(s, idx)));
prev_idx = idx;
i--;
}
}
}
}

Expand Down Expand Up @@ -853,7 +853,7 @@ int main(int argc, char *argv[]) {

int num_sticks = 0;
SDL_Joystick *sticks[2] = {NULL};

printf("Initialize joysticks:\n");
if (!(num_sticks = SDL_NumJoysticks())) {
printf("No joystick found!\n");
Expand Down Expand Up @@ -888,7 +888,7 @@ int main(int argc, char *argv[]) {
front_interface.resolve_path = &resolve_path;
front_interface.ctrl.callback = &emu_control;
front_interface.disk.di = disk_interface;

SDL_atomic_t icon_fade = {0};
if (!args.no_activity) {
front_interface.disk.activity_callback = &disk_activity_cb;
Expand All @@ -914,8 +914,8 @@ int main(int argc, char *argv[]) {
// Initializing this here is a bit late. But it works.
front_interface.ctrl.userdata = vxt;

if (ini_parse(sprint("%s/" CONFIG_FILE_NAME, args.config), &configure_pirepherals, vxt)) {
printf("ERROR: Could not configure all pirepherals!\n");
if (ini_parse(sprint("%s/" CONFIG_FILE_NAME, args.config), &configure_peripherals, vxt)) {
printf("ERROR: Could not configure all peripherals!\n");
return -1;
}

Expand Down Expand Up @@ -955,13 +955,13 @@ int main(int argc, char *argv[]) {
return -1;
}

printf("Installed pirepherals:\n");
for (int i = 1; i < VXT_MAX_PIREPHERALS; i++) {
struct vxt_pirepheral *device = vxt_system_pirepheral(vxt, (vxt_byte)i);
printf("Installed peripherals:\n");
for (int i = 1; i < VXT_MAX_PERIPHERALS; i++) {
struct vxt_peripheral *device = vxt_system_peripheral(vxt, (vxt_byte)i);
if (device) {
printf("%d - %s\n", i, vxt_pirepheral_name(device));
printf("%d - %s\n", i, vxt_peripheral_name(device));

if (vxt_pirepheral_class(device) == VXT_PCLASS_PPI)
if (vxt_peripheral_class(device) == VXT_PCLASS_PPI)
ppi_device = device;
}
}
Expand Down Expand Up @@ -1152,7 +1152,7 @@ int main(int argc, char *argv[]) {
num_cycles = 0;
turbo = vxtu_ppi_turbo_enabled(ppi_device);
);

if (ticks > 10000) {
snprintf(buffer, sizeof(buffer), "VirtualXT - %.2f MHz%s", mhz, turbo ? " (Turbo)" : "");
} else {
Expand Down Expand Up @@ -1267,7 +1267,7 @@ int main(int argc, char *argv[]) {
mr_destroy(mr);
SDL_free(ctx);

SDL_DestroyTexture(disk_icon_texture);
SDL_DestroyTexture(disk_icon_texture);
SDL_DestroyTexture(framebuffer);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
Expand Down
Loading

0 comments on commit 9559d29

Please sign in to comment.