mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 01:25:33 -07:00
A bit more clang-format
This commit is contained in:
@@ -769,7 +769,7 @@ usage:
|
||||
|
||||
for (i = 0; i < FDD_NUM; i++) {
|
||||
if (fn[i] != NULL) {
|
||||
if (strlen(fn[i]) <= 511)
|
||||
if (strlen(fn[i]) <= 511)
|
||||
strncpy(floppyfns[i], fn[i], 511);
|
||||
free(fn[i]);
|
||||
fn[i] = NULL;
|
||||
|
||||
@@ -135,7 +135,7 @@ static track_file_t *
|
||||
bin_init(const char *filename, int *error)
|
||||
{
|
||||
track_file_t *tf = (track_file_t *) malloc(sizeof(track_file_t));
|
||||
struct stat stats;
|
||||
struct stat stats;
|
||||
|
||||
if (tf == NULL) {
|
||||
*error = 1;
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
* Copyright 2022 RichardG.
|
||||
*/
|
||||
#ifndef _LARGEFILE_SOURCE
|
||||
#define _LARGEFILE_SOURCE
|
||||
# define _LARGEFILE_SOURCE
|
||||
#endif
|
||||
#ifndef _LARGEFILE64_SOURCE
|
||||
#define _LARGEFILE64_SOURCE
|
||||
# define _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
typedef struct
|
||||
{
|
||||
uint8_t idx, is_pci,
|
||||
regs[16];
|
||||
regs[16];
|
||||
} opti5x7_t;
|
||||
|
||||
#ifdef ENABLE_OPTI5X7_LOG
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t irq_convert,
|
||||
pci_regs[256];
|
||||
uint8_t irq_convert,
|
||||
pci_regs[256];
|
||||
} opti822_t;
|
||||
|
||||
// #define ENABLE_OPTI822_LOG 1
|
||||
@@ -56,13 +56,13 @@ opti822_log(const char *fmt, ...)
|
||||
va_list ap;
|
||||
|
||||
if (opti822_do_log) {
|
||||
va_start(ap, fmt);
|
||||
pclog_ex(fmt, ap);
|
||||
va_end(ap);
|
||||
va_start(ap, fmt);
|
||||
pclog_ex(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define opti822_log(fmt, ...)
|
||||
# define opti822_log(fmt, ...)
|
||||
#endif
|
||||
|
||||
/* NOTE: We currently cheat and pass all PCI shadow RAM accesses to ISA as well.
|
||||
@@ -71,13 +71,13 @@ opti822_log(const char *fmt, ...)
|
||||
static void
|
||||
opti822_recalc(opti822_t *dev)
|
||||
{
|
||||
int i, reg, bit_r, bit_w;
|
||||
int state;
|
||||
int i, reg, bit_r, bit_w;
|
||||
int state;
|
||||
uint32_t base;
|
||||
|
||||
for (i = 0; i < 12; i++) {
|
||||
base = 0x000c0000 + (i << 14);
|
||||
reg = 0x44 + ((i >> 2) ^ 3);
|
||||
base = 0x000c0000 + (i << 14);
|
||||
reg = 0x44 + ((i >> 2) ^ 3);
|
||||
bit_w = (i & 3);
|
||||
bit_r = bit_w + 4;
|
||||
bit_w = 1 << bit_w;
|
||||
@@ -99,19 +99,19 @@ static void
|
||||
opti822_update_irqs(opti822_t *dev, int set)
|
||||
{
|
||||
uint8_t val;
|
||||
int i, reg;
|
||||
int shift, irq;
|
||||
int irq_map[8] = { -1, 5, 9, 10, 11, 12, 14, 15 };
|
||||
pic_t *temp_pic;
|
||||
int i, reg;
|
||||
int shift, irq;
|
||||
int irq_map[8] = { -1, 5, 9, 10, 11, 12, 14, 15 };
|
||||
pic_t *temp_pic;
|
||||
|
||||
// dev->irq_convert = (dev->pci_regs[0x53] & 0x08);
|
||||
dev->irq_convert = 1;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
reg = 0x88 + (i >> 1);
|
||||
reg = 0x88 + (i >> 1);
|
||||
shift = (i & 1) << 2;
|
||||
val = (dev->pci_regs[reg] >> shift) & 0x0f;
|
||||
irq = irq_map[val & 0x07];
|
||||
val = (dev->pci_regs[reg] >> shift) & 0x0f;
|
||||
irq = irq_map[val & 0x07];
|
||||
if (irq == -1)
|
||||
continue;
|
||||
temp_pic = (irq >= 8) ? &pic2 : &pic;
|
||||
@@ -127,8 +127,8 @@ static void
|
||||
opti822_pci_write(int func, int addr, uint8_t val, void *priv)
|
||||
{
|
||||
opti822_t *dev = (opti822_t *) priv;
|
||||
int irq, irq_map[8] = { -1, 5, 9, 10, 11, 12, 14, 15 };
|
||||
int pin, slot;
|
||||
int irq, irq_map[8] = { -1, 5, 9, 10, 11, 12, 14, 15 };
|
||||
int pin, slot;
|
||||
|
||||
opti822_log("opti822_write(%02X, %02X, %02X)\n", func, addr, val);
|
||||
|
||||
@@ -144,7 +144,7 @@ opti822_pci_write(int func, int addr, uint8_t val, void *priv)
|
||||
/* Status Register */
|
||||
case 0x06:
|
||||
if (!(dev->pci_regs[0x52] & 0x04))
|
||||
dev->pci_regs[addr] = (val & 0x80);
|
||||
dev->pci_regs[addr] = (val & 0x80);
|
||||
break;
|
||||
case 0x07:
|
||||
dev->pci_regs[addr] &= ~(val & 0xf9);
|
||||
@@ -293,33 +293,33 @@ opti822_pci_write(int func, int addr, uint8_t val, void *priv)
|
||||
dev->pci_regs[addr] = val;
|
||||
break;
|
||||
|
||||
case 0x88 ... 0x8f:
|
||||
dev->pci_regs[addr] = val;
|
||||
opti822_update_irqs(dev, 0);
|
||||
irq = irq_map[val & 0x07];
|
||||
pin = 4 - ((addr & 0x01) << 1);
|
||||
slot = ((addr & 0x06) >> 1);
|
||||
if (irq >= 0) {
|
||||
opti822_log("Set IRQ routing: INT %c%c -> %02X\n", pin + 0x40, slot + 0x31, irq);
|
||||
pci_set_irq_routing(pin + (slot << 2), irq);
|
||||
pci_set_irq_level(pin + (slot << 2), !!(val & 0x07));
|
||||
} else {
|
||||
opti822_log("Set IRQ routing: INT %c%c -> FF\n", pin + 0x40, slot + 0x31);
|
||||
pci_set_irq_routing(pin + (slot << 2), PCI_IRQ_DISABLED);
|
||||
}
|
||||
irq = irq_map[(val >> 4) & 0x07];
|
||||
pin = 3 - ((addr & 0x01) << 1);
|
||||
slot = ((addr & 0x06) >> 1);
|
||||
if (irq >= 0) {
|
||||
opti822_log("Set IRQ routing: INT %c%c -> %02X\n", pin + 0x40, slot + 0x31, irq);
|
||||
pci_set_irq_routing(pin + (slot << 2), irq);
|
||||
pci_set_irq_level(pin + (slot << 2), !!((val >> 4) & 0x07));
|
||||
} else {
|
||||
opti822_log("Set IRQ routing: INT %c%c -> FF\n", pin + 0x40, slot + 0x31);
|
||||
pci_set_irq_routing(pin + (slot << 2), PCI_IRQ_DISABLED);
|
||||
}
|
||||
opti822_update_irqs(dev, 1);
|
||||
break;
|
||||
case 0x88 ... 0x8f:
|
||||
dev->pci_regs[addr] = val;
|
||||
opti822_update_irqs(dev, 0);
|
||||
irq = irq_map[val & 0x07];
|
||||
pin = 4 - ((addr & 0x01) << 1);
|
||||
slot = ((addr & 0x06) >> 1);
|
||||
if (irq >= 0) {
|
||||
opti822_log("Set IRQ routing: INT %c%c -> %02X\n", pin + 0x40, slot + 0x31, irq);
|
||||
pci_set_irq_routing(pin + (slot << 2), irq);
|
||||
pci_set_irq_level(pin + (slot << 2), !!(val & 0x07));
|
||||
} else {
|
||||
opti822_log("Set IRQ routing: INT %c%c -> FF\n", pin + 0x40, slot + 0x31);
|
||||
pci_set_irq_routing(pin + (slot << 2), PCI_IRQ_DISABLED);
|
||||
}
|
||||
irq = irq_map[(val >> 4) & 0x07];
|
||||
pin = 3 - ((addr & 0x01) << 1);
|
||||
slot = ((addr & 0x06) >> 1);
|
||||
if (irq >= 0) {
|
||||
opti822_log("Set IRQ routing: INT %c%c -> %02X\n", pin + 0x40, slot + 0x31, irq);
|
||||
pci_set_irq_routing(pin + (slot << 2), irq);
|
||||
pci_set_irq_level(pin + (slot << 2), !!((val >> 4) & 0x07));
|
||||
} else {
|
||||
opti822_log("Set IRQ routing: INT %c%c -> FF\n", pin + 0x40, slot + 0x31);
|
||||
pci_set_irq_routing(pin + (slot << 2), PCI_IRQ_DISABLED);
|
||||
}
|
||||
opti822_update_irqs(dev, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ static uint8_t
|
||||
opti822_pci_read(int func, int addr, void *priv)
|
||||
{
|
||||
opti822_t *dev = (opti822_t *) priv;
|
||||
uint8_t ret;
|
||||
uint8_t ret;
|
||||
|
||||
ret = 0xff;
|
||||
|
||||
@@ -343,12 +343,14 @@ static void
|
||||
opti822_reset(void *priv)
|
||||
{
|
||||
opti822_t *dev = (opti822_t *) priv;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
memset(dev->pci_regs, 0, 256);
|
||||
|
||||
dev->pci_regs[0x00] = 0x45; dev->pci_regs[0x01] = 0x10; /*OPTi*/
|
||||
dev->pci_regs[0x02] = 0x22; dev->pci_regs[0x03] = 0xc8; /*82C822 PCIB*/
|
||||
dev->pci_regs[0x00] = 0x45;
|
||||
dev->pci_regs[0x01] = 0x10; /*OPTi*/
|
||||
dev->pci_regs[0x02] = 0x22;
|
||||
dev->pci_regs[0x03] = 0xc8; /*82C822 PCIB*/
|
||||
dev->pci_regs[0x04] = 0x07;
|
||||
dev->pci_regs[0x06] = 0x80;
|
||||
dev->pci_regs[0x07] = 0x02;
|
||||
@@ -356,7 +358,8 @@ opti822_reset(void *priv)
|
||||
dev->pci_regs[0x0b] = 0x06;
|
||||
dev->pci_regs[0x0d] = 0x20;
|
||||
|
||||
dev->pci_regs[0x40] = 0x01; dev->pci_regs[0x41] = 0x0c;
|
||||
dev->pci_regs[0x40] = 0x01;
|
||||
dev->pci_regs[0x41] = 0x0c;
|
||||
dev->pci_regs[0x43] = 0x02;
|
||||
dev->pci_regs[0x52] = 0x06;
|
||||
dev->pci_regs[0x53] = 0x90;
|
||||
@@ -370,7 +373,7 @@ opti822_reset(void *priv)
|
||||
static void
|
||||
opti822_close(void *p)
|
||||
{
|
||||
opti822_t *dev = (opti822_t *)p;
|
||||
opti822_t *dev = (opti822_t *) p;
|
||||
|
||||
free(dev);
|
||||
}
|
||||
|
||||
@@ -279,8 +279,8 @@ gl518sm_init(const device_t *info)
|
||||
},
|
||||
{
|
||||
/* voltages */
|
||||
hwm_get_vcore(), /* Vcore */
|
||||
RESISTOR_DIVIDER(12000, 150, 47), /* +12V (15K/4.7K divider suggested in the datasheet) */
|
||||
hwm_get_vcore(), /* Vcore */
|
||||
RESISTOR_DIVIDER(12000, 150, 47), /* +12V (15K/4.7K divider suggested in the datasheet) */
|
||||
3300, /* +3.3V */
|
||||
5000 /* +5V */
|
||||
}
|
||||
|
||||
@@ -757,25 +757,25 @@ lm78_init(const device_t *info)
|
||||
hwm_values_t defaults = {
|
||||
{
|
||||
/* fan speeds */
|
||||
3000, /* usually Chassis, sometimes CPU */
|
||||
3000, /* usually Chassis, sometimes CPU */
|
||||
3000, /* usually CPU, sometimes Chassis */
|
||||
3000 /* usually PSU, sometimes Chassis */
|
||||
},
|
||||
{
|
||||
/* temperatures */
|
||||
30, /* usually Board, sometimes Chassis */
|
||||
30, /* Winbond only: usually CPU, sometimes Probe */
|
||||
30, /* usually Board, sometimes Chassis */
|
||||
30, /* Winbond only: usually CPU, sometimes Probe */
|
||||
30 /* Winbond only: usually CPU when not the one above */
|
||||
},
|
||||
{
|
||||
/* voltages */
|
||||
hwm_get_vcore(), /* Vcore */
|
||||
0, /* sometimes Vtt, Vio or second CPU */
|
||||
3300, /* +3.3V */
|
||||
RESISTOR_DIVIDER(5000, 11, 16), /* +5V (divider values bruteforced) */
|
||||
hwm_get_vcore(), /* Vcore */
|
||||
0, /* sometimes Vtt, Vio or second CPU */
|
||||
3300, /* +3.3V */
|
||||
RESISTOR_DIVIDER(5000, 11, 16), /* +5V (divider values bruteforced) */
|
||||
RESISTOR_DIVIDER(12000, 28, 10), /* +12V (28K/10K divider suggested in the W83781D datasheet) */
|
||||
LM78_NEG_VOLTAGE(12000, 2100), /* -12V */
|
||||
LM78_NEG_VOLTAGE(5000, 909), /* -5V */
|
||||
LM78_NEG_VOLTAGE(12000, 2100), /* -12V */
|
||||
LM78_NEG_VOLTAGE(5000, 909), /* -5V */
|
||||
RESISTOR_DIVIDER(5000, 51, 75), /* W83782D/AS99127F only: +5VSB (5.1K/7.5K divider suggested in the datasheet) */
|
||||
3000, /* W83782D/AS99127F only: Vbat */
|
||||
2500, /* AS99127F only: +2.5V */
|
||||
|
||||
@@ -182,7 +182,7 @@ vt82c686_init(const device_t *info)
|
||||
/* Set default values. Since this hardware monitor has a complex voltage factor system,
|
||||
the values struct contains voltage values *before* applying their respective factors. */
|
||||
hwm_values_t defaults = {
|
||||
// clang-format on
|
||||
// clang-format off
|
||||
{ /* fan speeds */
|
||||
3000, /* usually CPU */
|
||||
3000 /* usually Chassis */
|
||||
@@ -197,7 +197,7 @@ vt82c686_init(const device_t *info)
|
||||
5000, /* +5V */
|
||||
12000 /* +12V */
|
||||
}
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
hwm_values = defaults;
|
||||
dev->values = &hwm_values;
|
||||
|
||||
@@ -1614,6 +1614,6 @@ isamem_get_from_internal_name(const char *s)
|
||||
const device_t *
|
||||
isamem_get_device(int board)
|
||||
{
|
||||
/* Add the instance to the system. */
|
||||
/* Add the instance to the system. */
|
||||
return boards[board].dev;
|
||||
}
|
||||
|
||||
@@ -763,7 +763,7 @@ isartc_get_from_internal_name(char *s)
|
||||
c++;
|
||||
}
|
||||
|
||||
/* Not found. */
|
||||
/* Not found. */
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
@@ -430,7 +430,7 @@ kbd_adddata(uint16_t val)
|
||||
/* Test for T1000 'Fn' key (Right Alt / Right Ctrl) */
|
||||
if (is_t1x00) {
|
||||
if (keyboard_recv(0x138) || keyboard_recv(0x11d)) { /* 'Fn' pressed */
|
||||
t1000_syskey(0x00, 0x04, 0x00); /* Set 'Fn' indicator */
|
||||
t1000_syskey(0x00, 0x04, 0x00); /* Set 'Fn' indicator */
|
||||
switch (val) {
|
||||
case 0x45: /* Num Lock => toggle numpad */
|
||||
t1000_syskey(0x00, 0x00, 0x10);
|
||||
@@ -515,8 +515,7 @@ static void
|
||||
kbd_write(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
xtkbd_t *kbd = (xtkbd_t *) priv;
|
||||
uint8_t bit, set, new_clock;
|
||||
|
||||
uint8_t bit, set, new_clock;
|
||||
|
||||
switch (port) {
|
||||
case 0x61: /* Keyboard Control Register (aka Port B) */
|
||||
@@ -532,7 +531,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv)
|
||||
kbd->pb = val;
|
||||
if (!(kbd->pb & 0x80))
|
||||
kbd->clock = !!(kbd->pb & 0x40);
|
||||
ppi.pb = val;
|
||||
ppi.pb = val;
|
||||
|
||||
timer_process();
|
||||
|
||||
@@ -570,8 +569,8 @@ kbd_write(uint16_t port, uint8_t val, void *priv)
|
||||
case 0xc0 ... 0xcf: /* Pravetz Flags */
|
||||
kbd_log("XTkbd: Port %02X out: %02X\n", port, val);
|
||||
if (kbd->type == KBD_TYPE_PRAVETZ) {
|
||||
bit = (port >> 1) & 0x07;
|
||||
set = (port & 0x01) << bit;
|
||||
bit = (port >> 1) & 0x07;
|
||||
set = (port & 0x01) << bit;
|
||||
kbd->pravetz_flags = (kbd->pravetz_flags & ~(1 << bit)) | set;
|
||||
}
|
||||
break;
|
||||
@@ -693,10 +692,10 @@ kbd_reset(void *priv)
|
||||
{
|
||||
xtkbd_t *kbd = (xtkbd_t *) priv;
|
||||
|
||||
kbd->want_irq = 0;
|
||||
kbd->blocked = 0;
|
||||
kbd->pa = 0x00;
|
||||
kbd->pb = 0x00;
|
||||
kbd->want_irq = 0;
|
||||
kbd->blocked = 0;
|
||||
kbd->pa = 0x00;
|
||||
kbd->pb = 0x00;
|
||||
kbd->pravetz_flags = 0x00;
|
||||
|
||||
keyboard_scan = 1;
|
||||
|
||||
@@ -800,7 +800,7 @@ static const device_config_t ms_config[] = {
|
||||
}
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const device_t mouse_logibus_device = {
|
||||
|
||||
@@ -37,8 +37,8 @@ typedef struct {
|
||||
int mode;
|
||||
|
||||
uint16_t flags;
|
||||
uint8_t resolution;
|
||||
uint8_t sample_rate;
|
||||
uint8_t resolution;
|
||||
uint8_t sample_rate;
|
||||
|
||||
uint8_t command;
|
||||
|
||||
@@ -84,7 +84,7 @@ mouse_clear_data(void *priv)
|
||||
static void
|
||||
ps2_report_coordinates(mouse_t *dev)
|
||||
{
|
||||
uint8_t buff[3] = {0x08, 0x00, 0x00};
|
||||
uint8_t buff[3] = { 0x08, 0x00, 0x00 };
|
||||
|
||||
if (dev->x > 255)
|
||||
dev->x = 255;
|
||||
@@ -248,14 +248,13 @@ mouse_reset:
|
||||
dev->last_data[5] = val;
|
||||
|
||||
if (dev->last_data[0] == 0xf3 && dev->last_data[1] == 0xc8
|
||||
&& dev->last_data[2] == 0xf3 && dev->last_data[3] == 0xc8
|
||||
&& dev->last_data[4] == 0xf3 && dev->last_data[5] == 0x50
|
||||
&& mouse_get_buttons() == 5) {
|
||||
&& dev->last_data[2] == 0xf3 && dev->last_data[3] == 0xc8
|
||||
&& dev->last_data[4] == 0xf3 && dev->last_data[5] == 0x50
|
||||
&& mouse_get_buttons() == 5) {
|
||||
dev->flags |= FLAG_INTMODE | FLAG_5BTN;
|
||||
}
|
||||
else if (dev->last_data[0] == 0xf3 && dev->last_data[1] == 0xc8
|
||||
&& dev->last_data[2] == 0xf3 && dev->last_data[3] == 0x64
|
||||
&& dev->last_data[4] == 0xf3 && dev->last_data[5] == 0x50) {
|
||||
} else if (dev->last_data[0] == 0xf3 && dev->last_data[1] == 0xc8
|
||||
&& dev->last_data[2] == 0xf3 && dev->last_data[3] == 0x64
|
||||
&& dev->last_data[4] == 0xf3 && dev->last_data[5] == 0x50) {
|
||||
dev->flags |= FLAG_INTMODE;
|
||||
}
|
||||
}
|
||||
@@ -264,7 +263,7 @@ mouse_reset:
|
||||
static int
|
||||
ps2_poll(int x, int y, int z, int b, void *priv)
|
||||
{
|
||||
mouse_t *dev = (mouse_t *) priv;
|
||||
mouse_t *dev = (mouse_t *) priv;
|
||||
|
||||
if (!x && !y && !z && (b == dev->b))
|
||||
return (0xff);
|
||||
@@ -310,7 +309,8 @@ mouse_ps2_init(const device_t *info)
|
||||
if (i > 2)
|
||||
dev->flags |= FLAG_INTELLI;
|
||||
|
||||
if (i == 4) i = 3;
|
||||
if (i == 4)
|
||||
i = 3;
|
||||
|
||||
/* Hook into the general AT Keyboard driver. */
|
||||
keyboard_at_set_mouse(ps2_write, dev);
|
||||
@@ -356,7 +356,7 @@ static const device_config_t ps2_config[] = {
|
||||
{
|
||||
.name = "", .description = "", .type = CONFIG_END
|
||||
}
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const device_t mouse_ps2_device = {
|
||||
|
||||
@@ -878,7 +878,7 @@ static const device_config_t ltsermouse_config[] = {
|
||||
}
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const device_t mouse_mssystems_device = {
|
||||
|
||||
@@ -51,7 +51,7 @@ enum {
|
||||
static int next_inst = 0;
|
||||
static serial_device_t serial_devices[SERIAL_MAX];
|
||||
|
||||
//#define ENABLE_SERIAL_CONSOLE 1
|
||||
// #define ENABLE_SERIAL_CONSOLE 1
|
||||
|
||||
#ifdef ENABLE_SERIAL_LOG
|
||||
int serial_do_log = ENABLE_SERIAL_LOG;
|
||||
|
||||
@@ -1632,14 +1632,14 @@ ide_writeb(uint16_t addr, uint8_t val, void *priv)
|
||||
double xfer_time = ide_get_xfer_time(ide, 512 * sec_count);
|
||||
wait_time = seek_time > xfer_time ? seek_time : xfer_time;
|
||||
} else if ((val == WIN_READ_MULTIPLE) && (ide->blocksize > 0)) {
|
||||
sec_count = ide->secount ? ide->secount : 256;
|
||||
sec_count = ide->secount ? ide->secount : 256;
|
||||
if (sec_count > ide->blocksize)
|
||||
sec_count = ide->blocksize;
|
||||
double seek_time = hdd_timing_read(&hdd[ide->hdd_num], ide_get_sector(ide), sec_count);
|
||||
double xfer_time = ide_get_xfer_time(ide, 512 * sec_count);
|
||||
wait_time = seek_time + xfer_time;
|
||||
} else if ((val == WIN_READ_MULTIPLE) && (ide->blocksize == 0))
|
||||
wait_time = 200.0;
|
||||
wait_time = 200.0;
|
||||
else {
|
||||
sec_count = 1;
|
||||
double seek_time = hdd_timing_read(&hdd[ide->hdd_num], ide_get_sector(ide), sec_count);
|
||||
@@ -1692,7 +1692,7 @@ ide_writeb(uint16_t addr, uint8_t val, void *priv)
|
||||
ide_set_callback(ide, wait_time);
|
||||
} else if ((ide->type == IDE_HDD) && ((val == WIN_VERIFY) || (val == WIN_VERIFY_ONCE))) {
|
||||
uint32_t sec_count = ide->secount ? ide->secount : 256;
|
||||
double seek_time = hdd_timing_read(&hdd[ide->hdd_num], ide_get_sector(ide), sec_count);
|
||||
double seek_time = hdd_timing_read(&hdd[ide->hdd_num], ide_get_sector(ide), sec_count);
|
||||
ide_set_callback(ide, seek_time + ide_get_xfer_time(ide, 2));
|
||||
} else if ((val == WIN_IDENTIFY) || (val == WIN_SET_FEATURES))
|
||||
ide_callback(ide);
|
||||
@@ -1865,8 +1865,8 @@ ide_read_data(ide_t *ide, int length)
|
||||
uint32_t sec_count = ide->secount ? ide->secount : 256;
|
||||
if (sec_count > ide->blocksize)
|
||||
sec_count = ide->blocksize;
|
||||
double seek_time = hdd_timing_read(&hdd[ide->hdd_num], ide_get_sector(ide), sec_count);
|
||||
double xfer_time = ide_get_xfer_time(ide, 512 * sec_count);
|
||||
double seek_time = hdd_timing_read(&hdd[ide->hdd_num], ide_get_sector(ide), sec_count);
|
||||
double xfer_time = ide_get_xfer_time(ide, 512 * sec_count);
|
||||
ide_set_callback(ide, seek_time + xfer_time);
|
||||
} else {
|
||||
ide_callback(ide);
|
||||
@@ -2166,7 +2166,7 @@ ide_callback(void *priv)
|
||||
ide_set_signature(ide);
|
||||
|
||||
if (ide->type == IDE_ATAPI) {
|
||||
ide->sc->error = 1;
|
||||
ide->sc->error = 1;
|
||||
if (ide->device_reset)
|
||||
ide->device_reset(ide->sc);
|
||||
if (ide->sc->pad0) /* pad0 = early */
|
||||
|
||||
@@ -100,12 +100,12 @@
|
||||
#define ST506_XT_TYPE_VICTOR_V86P 27
|
||||
#define ST506_XT_TYPE_TOSHIBA_T1200 28
|
||||
|
||||
#define XEBEC_BIOS_FILE "roms/hdd/st506/ibm_xebec_62x0822_1985.bin"
|
||||
#define DTC_BIOS_FILE "roms/hdd/st506/dtc_cxd21a.bin"
|
||||
#define ST11_BIOS_FILE_OLD "roms/hdd/st506/st11_bios_vers_1.7.bin"
|
||||
#define ST11_BIOS_FILE_NEW "roms/hdd/st506/st11_bios_vers_2.0.bin"
|
||||
#define WD1002A_WX1_BIOS_FILE "roms/hdd/st506/wd1002a_wx1-62-000094-032.bin"
|
||||
#define WD1004A_WX1_BIOS_FILE "roms/hdd/st506/wd1002a_wx1-62-000094-032.bin"
|
||||
#define XEBEC_BIOS_FILE "roms/hdd/st506/ibm_xebec_62x0822_1985.bin"
|
||||
#define DTC_BIOS_FILE "roms/hdd/st506/dtc_cxd21a.bin"
|
||||
#define ST11_BIOS_FILE_OLD "roms/hdd/st506/st11_bios_vers_1.7.bin"
|
||||
#define ST11_BIOS_FILE_NEW "roms/hdd/st506/st11_bios_vers_2.0.bin"
|
||||
#define WD1002A_WX1_BIOS_FILE "roms/hdd/st506/wd1002a_wx1-62-000094-032.bin"
|
||||
#define WD1004A_WX1_BIOS_FILE "roms/hdd/st506/wd1002a_wx1-62-000094-032.bin"
|
||||
/* SuperBIOS was for both the WX1 and 27X, users jumpers readout to determine
|
||||
if to use 26 sectors per track, 26 -> 17 sectors per track translation, or
|
||||
17 sectors per track. */
|
||||
@@ -292,13 +292,16 @@ typedef struct {
|
||||
} hd_type_t;
|
||||
|
||||
hd_type_t hd_types[4] = {
|
||||
// clang-format off
|
||||
{ 306, 4, MFM_SECTORS}, /* type 0 */
|
||||
{ 612, 4, MFM_SECTORS}, /* type 16 */
|
||||
{ 615, 4, MFM_SECTORS}, /* type 2 */
|
||||
{ 306, 8, MFM_SECTORS} /* type 13 */
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
hd_type_t hd_types_olivetti[16] = {
|
||||
// clang-format off
|
||||
{ 697, 5, MFM_SECTORS},
|
||||
{ 612, 4, MFM_SECTORS}, /* type 16 */
|
||||
{ 612, 4, MFM_SECTORS}, /* type 16 */
|
||||
@@ -315,6 +318,7 @@ hd_type_t hd_types_olivetti[16] = {
|
||||
{ 612, 4, MFM_SECTORS}, /* type 16 */
|
||||
{ 612, 4, MFM_SECTORS}, /* type 16 */
|
||||
{ 306, 4, MFM_SECTORS} /* "not present" with the second hard disk */
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
#ifdef ENABLE_ST506_XT_LOG
|
||||
@@ -1291,9 +1295,9 @@ mem_write(uint32_t addr, uint8_t val, void *priv)
|
||||
addr -= dev->bios_addr;
|
||||
|
||||
switch (dev->type) {
|
||||
case ST506_XT_TYPE_ST11M: /* ST-11M */
|
||||
case ST506_XT_TYPE_ST11R: /* ST-11R */
|
||||
mask = 0x1fff; /* ST-11 decodes RAM on each 8K block */
|
||||
case ST506_XT_TYPE_ST11M: /* ST-11M */
|
||||
case ST506_XT_TYPE_ST11R: /* ST-11R */
|
||||
mask = 0x1fff; /* ST-11 decodes RAM on each 8K block */
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1341,9 +1345,9 @@ mem_read(uint32_t addr, void *priv)
|
||||
}
|
||||
break;
|
||||
|
||||
case ST506_XT_TYPE_ST11M: /* ST-11M */
|
||||
case ST506_XT_TYPE_ST11R: /* ST-11R */
|
||||
mask = 0x1fff; /* ST-11 decodes RAM on each 8K block */
|
||||
case ST506_XT_TYPE_ST11M: /* ST-11M */
|
||||
case ST506_XT_TYPE_ST11R: /* ST-11R */
|
||||
mask = 0x1fff; /* ST-11 decodes RAM on each 8K block */
|
||||
break;
|
||||
|
||||
/* default:
|
||||
@@ -1636,7 +1640,7 @@ st506_init(const device_t *info)
|
||||
break;
|
||||
|
||||
case ST506_XT_TYPE_TOSHIBA_T1200: /* Toshiba T1200 */
|
||||
fn = NULL;
|
||||
fn = NULL;
|
||||
dev->base = 0x01f0;
|
||||
dev->switches = 0x0c;
|
||||
break;
|
||||
|
||||
@@ -419,21 +419,16 @@ hdd_zones_init(hard_disk_t *hdd)
|
||||
}
|
||||
|
||||
static hdd_preset_t hdd_speed_presets[] = {
|
||||
{.name = "RAM Disk (max. speed)", .internal_name = "ramdisk", .rcache_num_seg = 16, .rcache_seg_size = 128, .max_multiple = 32},
|
||||
|
||||
{ .name = "[1989] 3500 RPM", .internal_name = "1989_3500rpm", .zones = 1, .avg_spt = 35, .heads = 2, .rpm = 3500, .full_stroke_ms = 40, .track_seek_ms = 8, .rcache_num_seg = 1, .rcache_seg_size = 16, .max_multiple = 8 },
|
||||
|
||||
{ .name = "[1992] 3600 RPM", .internal_name = "1992_3600rpm", .zones = 1, .avg_spt = 45, .heads = 2, .rpm = 3600, .full_stroke_ms = 30, .track_seek_ms = 6, .rcache_num_seg = 4, .rcache_seg_size = 16, .max_multiple = 8 },
|
||||
|
||||
{ .name = "[1994] 4500 RPM", .internal_name = "1994_4500rpm", .zones = 8, .avg_spt = 80, .heads = 4, .rpm = 4500, .full_stroke_ms = 26, .track_seek_ms = 5, .rcache_num_seg = 4, .rcache_seg_size = 32, .max_multiple = 16 },
|
||||
|
||||
{ .name = "[1996] 5400 RPM", .internal_name = "1996_5400rpm", .zones = 16, .avg_spt = 135, .heads = 4, .rpm = 5400, .full_stroke_ms = 24, .track_seek_ms = 3, .rcache_num_seg = 4, .rcache_seg_size = 64, .max_multiple = 16 },
|
||||
|
||||
{ .name = "[1997] 5400 RPM", .internal_name = "1997_5400rpm", .zones = 16, .avg_spt = 185, .heads = 6, .rpm = 5400, .full_stroke_ms = 20, .track_seek_ms = 2.5, .rcache_num_seg = 8, .rcache_seg_size = 64, .max_multiple = 32 },
|
||||
|
||||
{ .name = "[1998] 5400 RPM", .internal_name = "1998_5400rpm", .zones = 16, .avg_spt = 300, .heads = 8, .rpm = 5400, .full_stroke_ms = 20, .track_seek_ms = 2, .rcache_num_seg = 8, .rcache_seg_size = 128, .max_multiple = 32 },
|
||||
|
||||
{ .name = "[2000] 7200 RPM", .internal_name = "2000_7200rpm", .zones = 16, .avg_spt = 350, .heads = 6, .rpm = 7200, .full_stroke_ms = 15, .track_seek_ms = 2, .rcache_num_seg = 16, .rcache_seg_size = 128, .max_multiple = 32 },
|
||||
// clang-format off
|
||||
{ .name = "RAM Disk (max. speed)", .internal_name = "ramdisk", .rcache_num_seg = 16, .rcache_seg_size = 128, .max_multiple = 32 },
|
||||
{ .name = "[1989] 3500 RPM", .internal_name = "1989_3500rpm", .zones = 1, .avg_spt = 35, .heads = 2, .rpm = 3500, .full_stroke_ms = 40, .track_seek_ms = 8, .rcache_num_seg = 1, .rcache_seg_size = 16, .max_multiple = 8 },
|
||||
{ .name = "[1992] 3600 RPM", .internal_name = "1992_3600rpm", .zones = 1, .avg_spt = 45, .heads = 2, .rpm = 3600, .full_stroke_ms = 30, .track_seek_ms = 6, .rcache_num_seg = 4, .rcache_seg_size = 16, .max_multiple = 8 },
|
||||
{ .name = "[1994] 4500 RPM", .internal_name = "1994_4500rpm", .zones = 8, .avg_spt = 80, .heads = 4, .rpm = 4500, .full_stroke_ms = 26, .track_seek_ms = 5, .rcache_num_seg = 4, .rcache_seg_size = 32, .max_multiple = 16 },
|
||||
{ .name = "[1996] 5400 RPM", .internal_name = "1996_5400rpm", .zones = 16, .avg_spt = 135, .heads = 4, .rpm = 5400, .full_stroke_ms = 24, .track_seek_ms = 3, .rcache_num_seg = 4, .rcache_seg_size = 64, .max_multiple = 16 },
|
||||
{ .name = "[1997] 5400 RPM", .internal_name = "1997_5400rpm", .zones = 16, .avg_spt = 185, .heads = 6, .rpm = 5400, .full_stroke_ms = 20, .track_seek_ms = 2.5, .rcache_num_seg = 8, .rcache_seg_size = 64, .max_multiple = 32 },
|
||||
{ .name = "[1998] 5400 RPM", .internal_name = "1998_5400rpm", .zones = 16, .avg_spt = 300, .heads = 8, .rpm = 5400, .full_stroke_ms = 20, .track_seek_ms = 2, .rcache_num_seg = 8, .rcache_seg_size = 128, .max_multiple = 32 },
|
||||
{ .name = "[2000] 7200 RPM", .internal_name = "2000_7200rpm", .zones = 16, .avg_spt = 350, .heads = 6, .rpm = 7200, .full_stroke_ms = 15, .track_seek_ms = 2, .rcache_num_seg = 16, .rcache_seg_size = 128, .max_multiple = 32 },
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
int
|
||||
|
||||
@@ -170,5 +170,5 @@ unsigned int hdd_table[128][3] = {
|
||||
{ 1120, 16, 59 },
|
||||
{ 1054, 16, 63 },
|
||||
{ 0, 0, 0 }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
@@ -2373,17 +2373,17 @@ const device_t fdc_xt_device = {
|
||||
};
|
||||
|
||||
const device_t fdc_xt_sec_device = {
|
||||
.name = "PC/XT Floppy Drive Controller (Secondary)",
|
||||
.name = "PC/XT Floppy Drive Controller (Secondary)",
|
||||
.internal_name = "fdc_xt",
|
||||
.flags = FDC_FLAG_SEC,
|
||||
.local = 0,
|
||||
.init = fdc_init,
|
||||
.close = fdc_close,
|
||||
.reset = fdc_reset,
|
||||
.flags = FDC_FLAG_SEC,
|
||||
.local = 0,
|
||||
.init = fdc_init,
|
||||
.close = fdc_close,
|
||||
.reset = fdc_reset,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t fdc_xt_t1x00_device = {
|
||||
@@ -2457,17 +2457,17 @@ const device_t fdc_at_device = {
|
||||
};
|
||||
|
||||
const device_t fdc_at_sec_device = {
|
||||
.name = "PC/AT Floppy Drive Controller (Secondary)",
|
||||
.name = "PC/AT Floppy Drive Controller (Secondary)",
|
||||
.internal_name = "fdc_at_sec",
|
||||
.flags = 0,
|
||||
.local = FDC_FLAG_AT | FDC_FLAG_SEC,
|
||||
.init = fdc_init,
|
||||
.close = fdc_close,
|
||||
.reset = fdc_reset,
|
||||
.flags = 0,
|
||||
.local = FDC_FLAG_AT | FDC_FLAG_SEC,
|
||||
.init = fdc_init,
|
||||
.close = fdc_close,
|
||||
.reset = fdc_reset,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t fdc_at_actlow_device = {
|
||||
|
||||
@@ -124,7 +124,7 @@ static const device_config_t b215_config[] = {
|
||||
}
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const device_t fdc_b215_device = {
|
||||
|
||||
@@ -140,7 +140,7 @@ static const device_config_t pii_config[] = {
|
||||
}
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const device_t fdc_pii151b_device = {
|
||||
|
||||
@@ -75,7 +75,7 @@ typedef struct {
|
||||
|
||||
fdd_t fdd[FDD_NUM];
|
||||
|
||||
char floppyfns[FDD_NUM][512];
|
||||
char floppyfns[FDD_NUM][512];
|
||||
char *fdd_image_history[FDD_NUM][FLOPPY_IMAGE_HISTORY];
|
||||
|
||||
pc_timer_t fdd_poll_time[FDD_NUM];
|
||||
|
||||
1312
src/floppy/fdd_img.c
1312
src/floppy/fdd_img.c
File diff suppressed because it is too large
Load Diff
1258
src/floppy/fdd_td0.c
1258
src/floppy/fdd_td0.c
File diff suppressed because it is too large
Load Diff
@@ -116,7 +116,7 @@ static uint8_t gameport_pnp_rom[] = {
|
||||
static const isapnp_device_config_t gameport_pnp_defaults[] = {
|
||||
{.activate = 1,
|
||||
.io = {
|
||||
{ .base = 0x200 },
|
||||
{ .base = 0x200 },
|
||||
}}
|
||||
};
|
||||
|
||||
@@ -642,7 +642,7 @@ static const device_config_t tmacm_config[] = {
|
||||
}
|
||||
},
|
||||
{ "", "", -1 }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const device_t gameport_tm_acm_device = {
|
||||
|
||||
@@ -128,7 +128,7 @@ const joystick_if_t joystick_ch_flightstick_pro = {
|
||||
.button_count = 4,
|
||||
.pov_count = 1,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = {"X axis", "Y axis", "Throttle" },
|
||||
.axis_names = { "X axis", "Y axis", "Throttle" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { "POV"}
|
||||
.pov_names = { "POV" }
|
||||
};
|
||||
|
||||
@@ -251,9 +251,9 @@ const joystick_if_t joystick_2axis_2button = {
|
||||
.button_count = 2,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 2,
|
||||
.axis_names = {"X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2" },
|
||||
.pov_names = { NULL}
|
||||
.axis_names = { "X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2" },
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_2axis_4button = {
|
||||
@@ -269,9 +269,9 @@ const joystick_if_t joystick_2axis_4button = {
|
||||
.button_count = 4,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = {"X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { NULL}
|
||||
.axis_names = { "X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_3axis_2button = {
|
||||
@@ -287,9 +287,9 @@ const joystick_if_t joystick_3axis_2button = {
|
||||
.button_count = 2,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = {"X axis", "Y axis", "Z axis" },
|
||||
.button_names = { "Button 1", "Button 2" },
|
||||
.pov_names = { NULL}
|
||||
.axis_names = { "X axis", "Y axis", "Z axis" },
|
||||
.button_names = { "Button 1", "Button 2" },
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_3axis_4button = {
|
||||
@@ -305,9 +305,9 @@ const joystick_if_t joystick_3axis_4button = {
|
||||
.button_count = 4,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = {"X axis", "Y axis", "Z axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { NULL}
|
||||
.axis_names = { "X axis", "Y axis", "Z axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_4axis_4button = {
|
||||
@@ -323,9 +323,9 @@ const joystick_if_t joystick_4axis_4button = {
|
||||
.button_count = 4,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = {"X axis", "Y axis", "Z axis", "zX axis" },
|
||||
.axis_names = { "X axis", "Y axis", "Z axis", "zX axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { NULL }
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_2axis_6button = {
|
||||
@@ -341,9 +341,9 @@ const joystick_if_t joystick_2axis_6button = {
|
||||
.button_count = 6,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = {"X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6" },
|
||||
.pov_names = { NULL}
|
||||
.axis_names = { "X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6" },
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_2axis_8button = {
|
||||
@@ -359,7 +359,7 @@ const joystick_if_t joystick_2axis_8button = {
|
||||
.button_count = 8,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = {"X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6", "Button 7", "Button 8" },
|
||||
.pov_names = { NULL}
|
||||
.axis_names = { "X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6", "Button 7", "Button 8" },
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
@@ -266,7 +266,7 @@ const joystick_if_t joystick_sw_pad = {
|
||||
.button_count = 10,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 4,
|
||||
.axis_names = {"X axis", "Y axis" },
|
||||
.button_names = { "A", "B", "C", "X", "Y", "Z", "L", "R", "Start", "M" },
|
||||
.pov_names = { NULL}
|
||||
.axis_names = { "X axis", "Y axis" },
|
||||
.button_names = { "A", "B", "C", "X", "Y", "Z", "L", "R", "Start", "M" },
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
@@ -128,7 +128,7 @@ const joystick_if_t joystick_tm_fcs = {
|
||||
.button_count = 4,
|
||||
.pov_count = 1,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = {"X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { "POV"}
|
||||
.axis_names = { "X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { "POV" }
|
||||
};
|
||||
|
||||
@@ -36,12 +36,12 @@
|
||||
*/
|
||||
|
||||
#ifndef BSWAP_H
|
||||
# define BSWAP_H
|
||||
#define BSWAP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef HAVE_BYTESWAP_H
|
||||
#include <byteswap.h>
|
||||
# include <byteswap.h>
|
||||
#else
|
||||
# define bswap_16(x) \
|
||||
( \
|
||||
@@ -81,103 +81,111 @@ static __inline uint16_t bswap16(uint16_t x)
|
||||
{
|
||||
return bswap_16(x);
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
#else
|
||||
static __inline uint16_t bswap16(uint16_t x)
|
||||
static __inline uint16_t
|
||||
bswap16(uint16_t x)
|
||||
{
|
||||
return bswap_16(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __GNUC__ >= 10
|
||||
#if defined __has_builtin && __has_builtin(__builtin_bswap32)
|
||||
#define bswap32(x) __builtin_bswap32(x)
|
||||
#else
|
||||
static __inline uint32_t bswap32(uint32_t x)
|
||||
#if __GNUC__ >= 10
|
||||
# if defined __has_builtin && __has_builtin(__builtin_bswap32)
|
||||
# define bswap32(x) __builtin_bswap32(x)
|
||||
# else
|
||||
static __inline uint32_t
|
||||
bswap32(uint32_t x)
|
||||
{
|
||||
return bswap_32(x);
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
#else
|
||||
static __inline uint32_t bswap32(uint32_t x)
|
||||
static __inline uint32_t
|
||||
bswap32(uint32_t x)
|
||||
{
|
||||
return bswap_32(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __GNUC__ >= 10
|
||||
#if defined __has_builtin && __has_builtin(__builtin_bswap64)
|
||||
#define bswap64(x) __builtin_bswap64(x)
|
||||
#else
|
||||
static __inline uint64_t bswap64(uint64_t x)
|
||||
#if __GNUC__ >= 10
|
||||
# if defined __has_builtin && __has_builtin(__builtin_bswap64)
|
||||
# define bswap64(x) __builtin_bswap64(x)
|
||||
# else
|
||||
static __inline uint64_t
|
||||
bswap64(uint64_t x)
|
||||
{
|
||||
return bswap_64(x);
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
#else
|
||||
static __inline uint64_t bswap64(uint64_t x)
|
||||
static __inline uint64_t
|
||||
bswap64(uint64_t x)
|
||||
{
|
||||
return bswap_64(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
static __inline void bswap16s(uint16_t *s)
|
||||
static __inline void
|
||||
bswap16s(uint16_t *s)
|
||||
{
|
||||
*s = bswap16(*s);
|
||||
}
|
||||
|
||||
static __inline void bswap32s(uint32_t *s)
|
||||
static __inline void
|
||||
bswap32s(uint32_t *s)
|
||||
{
|
||||
*s = bswap32(*s);
|
||||
}
|
||||
|
||||
static __inline void bswap64s(uint64_t *s)
|
||||
static __inline void
|
||||
bswap64s(uint64_t *s)
|
||||
{
|
||||
*s = bswap64(*s);
|
||||
}
|
||||
|
||||
#if defined(WORDS_BIGENDIAN)
|
||||
# define be_bswap(v, size) (v)
|
||||
# define le_bswap(v, size) bswap ## size(v)
|
||||
# define be_bswaps(v, size)
|
||||
# define le_bswaps(p, size) *p = bswap ## size(*p);
|
||||
# define be_bswap(v, size) (v)
|
||||
# define le_bswap(v, size) bswap##size(v)
|
||||
# define be_bswaps(v, size)
|
||||
# define le_bswaps(p, size) *p = bswap##size(*p);
|
||||
#else
|
||||
# define le_bswap(v, size) (v)
|
||||
# define be_bswap(v, size) bswap ## size(v)
|
||||
# define le_bswaps(v, size)
|
||||
# define be_bswaps(p, size) *p = bswap ## size(*p);
|
||||
# define le_bswap(v, size) (v)
|
||||
# define be_bswap(v, size) bswap##size(v)
|
||||
# define le_bswaps(v, size)
|
||||
# define be_bswaps(p, size) *p = bswap##size(*p);
|
||||
#endif
|
||||
|
||||
#define CPU_CONVERT(endian, size, type)\
|
||||
static __inline type endian ## size ## _to_cpu(type v)\
|
||||
{\
|
||||
return endian ## _bswap(v, size);\
|
||||
}\
|
||||
\
|
||||
static __inline type cpu_to_ ## endian ## size(type v)\
|
||||
{\
|
||||
return endian ## _bswap(v, size);\
|
||||
}\
|
||||
\
|
||||
static __inline void endian ## size ## _to_cpus(type *p)\
|
||||
{\
|
||||
endian ## _bswaps(p, size)\
|
||||
}\
|
||||
\
|
||||
static __inline void cpu_to_ ## endian ## size ## s(type *p)\
|
||||
{\
|
||||
endian ## _bswaps(p, size)\
|
||||
}\
|
||||
\
|
||||
static __inline type endian ## size ## _to_cpup(const type *p)\
|
||||
{\
|
||||
return endian ## size ## _to_cpu(*p);\
|
||||
}\
|
||||
\
|
||||
static __inline void cpu_to_ ## endian ## size ## w(type *p, type v)\
|
||||
{\
|
||||
*p = cpu_to_ ## endian ## size(v);\
|
||||
}
|
||||
#define CPU_CONVERT(endian, size, type) \
|
||||
static __inline type endian##size##_to_cpu(type v) \
|
||||
{ \
|
||||
return endian##_bswap(v, size); \
|
||||
} \
|
||||
\
|
||||
static __inline type cpu_to_##endian##size(type v) \
|
||||
{ \
|
||||
return endian##_bswap(v, size); \
|
||||
} \
|
||||
\
|
||||
static __inline void endian##size##_to_cpus(type *p) \
|
||||
{ \
|
||||
endian##_bswaps(p, size) \
|
||||
} \
|
||||
\
|
||||
static __inline void cpu_to_##endian##size##s(type *p) \
|
||||
{ \
|
||||
endian##_bswaps(p, size) \
|
||||
} \
|
||||
\
|
||||
static __inline type endian##size##_to_cpup(const type *p) \
|
||||
{ \
|
||||
return endian##size##_to_cpu(*p); \
|
||||
} \
|
||||
\
|
||||
static __inline void cpu_to_##endian##size##w(type *p, type v) \
|
||||
{ \
|
||||
*p = cpu_to_##endian##size(v); \
|
||||
}
|
||||
|
||||
CPU_CONVERT(be, 16, uint16_t)
|
||||
CPU_CONVERT(be, 32, uint32_t)
|
||||
@@ -191,27 +199,29 @@ CPU_CONVERT(le, 64, uint64_t)
|
||||
|
||||
#if defined(__i386__) || defined(__powerpc__)
|
||||
|
||||
#define cpu_to_le16wu(p, v) cpu_to_le16w(p, v)
|
||||
#define cpu_to_le32wu(p, v) cpu_to_le32w(p, v)
|
||||
#define le16_to_cpupu(p) le16_to_cpup(p)
|
||||
#define le32_to_cpupu(p) le32_to_cpup(p)
|
||||
# define cpu_to_le16wu(p, v) cpu_to_le16w(p, v)
|
||||
# define cpu_to_le32wu(p, v) cpu_to_le32w(p, v)
|
||||
# define le16_to_cpupu(p) le16_to_cpup(p)
|
||||
# define le32_to_cpupu(p) le32_to_cpup(p)
|
||||
|
||||
#define cpu_to_be16wu(p, v) cpu_to_be16w(p, v)
|
||||
#define cpu_to_be32wu(p, v) cpu_to_be32w(p, v)
|
||||
# define cpu_to_be16wu(p, v) cpu_to_be16w(p, v)
|
||||
# define cpu_to_be32wu(p, v) cpu_to_be32w(p, v)
|
||||
|
||||
#else
|
||||
|
||||
static __inline void cpu_to_le16wu(uint16_t *p, uint16_t v)
|
||||
static __inline void
|
||||
cpu_to_le16wu(uint16_t *p, uint16_t v)
|
||||
{
|
||||
uint8_t *p1 = (uint8_t *)p;
|
||||
uint8_t *p1 = (uint8_t *) p;
|
||||
|
||||
p1[0] = v & 0xff;
|
||||
p1[1] = v >> 8;
|
||||
}
|
||||
|
||||
static __inline void cpu_to_le32wu(uint32_t *p, uint32_t v)
|
||||
static __inline void
|
||||
cpu_to_le32wu(uint32_t *p, uint32_t v)
|
||||
{
|
||||
uint8_t *p1 = (uint8_t *)p;
|
||||
uint8_t *p1 = (uint8_t *) p;
|
||||
|
||||
p1[0] = v;
|
||||
p1[1] = v >> 8;
|
||||
@@ -219,29 +229,33 @@ static __inline void cpu_to_le32wu(uint32_t *p, uint32_t v)
|
||||
p1[3] = v >> 24;
|
||||
}
|
||||
|
||||
static __inline uint16_t le16_to_cpupu(const uint16_t *p)
|
||||
static __inline uint16_t
|
||||
le16_to_cpupu(const uint16_t *p)
|
||||
{
|
||||
const uint8_t *p1 = (const uint8_t *)p;
|
||||
const uint8_t *p1 = (const uint8_t *) p;
|
||||
return p1[0] | (p1[1] << 8);
|
||||
}
|
||||
|
||||
static __inline uint32_t le32_to_cpupu(const uint32_t *p)
|
||||
static __inline uint32_t
|
||||
le32_to_cpupu(const uint32_t *p)
|
||||
{
|
||||
const uint8_t *p1 = (const uint8_t *)p;
|
||||
const uint8_t *p1 = (const uint8_t *) p;
|
||||
return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24);
|
||||
}
|
||||
|
||||
static __inline void cpu_to_be16wu(uint16_t *p, uint16_t v)
|
||||
static __inline void
|
||||
cpu_to_be16wu(uint16_t *p, uint16_t v)
|
||||
{
|
||||
uint8_t *p1 = (uint8_t *)p;
|
||||
uint8_t *p1 = (uint8_t *) p;
|
||||
|
||||
p1[0] = v >> 8;
|
||||
p1[1] = v & 0xff;
|
||||
}
|
||||
|
||||
static __inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
|
||||
static __inline void
|
||||
cpu_to_be32wu(uint32_t *p, uint32_t v)
|
||||
{
|
||||
uint8_t *p1 = (uint8_t *)p;
|
||||
uint8_t *p1 = (uint8_t *) p;
|
||||
|
||||
p1[0] = v >> 24;
|
||||
p1[1] = v >> 16;
|
||||
@@ -252,9 +266,9 @@ static __inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
|
||||
#endif
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define cpu_to_32wu cpu_to_be32wu
|
||||
# define cpu_to_32wu cpu_to_be32wu
|
||||
#else
|
||||
#define cpu_to_32wu cpu_to_le32wu
|
||||
# define cpu_to_32wu cpu_to_le32wu
|
||||
#endif
|
||||
|
||||
#undef le_bswap
|
||||
|
||||
@@ -40,18 +40,18 @@ extern int fdc_type;
|
||||
#define FDC_QUATERNARY_IRQ 6
|
||||
#define FDC_QUATERNARY_DMA 2
|
||||
|
||||
#define FDC_FLAG_PCJR 0x01 /* PCjr */
|
||||
#define FDC_FLAG_DISKCHG_ACTLOW 0x02 /* Amstrad, PS/1, PS/2 ISA */
|
||||
#define FDC_FLAG_AT 0x04 /* AT+, PS/x */
|
||||
#define FDC_FLAG_PS1 0x08 /* PS/1, PS/2 ISA */
|
||||
#define FDC_FLAG_SUPERIO 0x10 /* Super I/O chips */
|
||||
#define FDC_FLAG_START_RWC_1 0x20 /* W83877F, W83977F */
|
||||
#define FDC_FLAG_MORE_TRACKS 0x40 /* W83877F, W83977F, PC87306, PC87309 */
|
||||
#define FDC_FLAG_NSC 0x80 /* PC87306, PC87309 */
|
||||
#define FDC_FLAG_TOSHIBA 0x100 /* T1000, T1200 */
|
||||
#define FDC_FLAG_AMSTRAD 0x200 /* Non-AT Amstrad machines */
|
||||
#define FDC_FLAG_UMC 0x400 /* UMC UM8398 */
|
||||
#define FDC_FLAG_ALI 0x800 /* ALi M512x / M1543C */
|
||||
#define FDC_FLAG_PCJR 0x01 /* PCjr */
|
||||
#define FDC_FLAG_DISKCHG_ACTLOW 0x02 /* Amstrad, PS/1, PS/2 ISA */
|
||||
#define FDC_FLAG_AT 0x04 /* AT+, PS/x */
|
||||
#define FDC_FLAG_PS1 0x08 /* PS/1, PS/2 ISA */
|
||||
#define FDC_FLAG_SUPERIO 0x10 /* Super I/O chips */
|
||||
#define FDC_FLAG_START_RWC_1 0x20 /* W83877F, W83977F */
|
||||
#define FDC_FLAG_MORE_TRACKS 0x40 /* W83877F, W83977F, PC87306, PC87309 */
|
||||
#define FDC_FLAG_NSC 0x80 /* PC87306, PC87309 */
|
||||
#define FDC_FLAG_TOSHIBA 0x100 /* T1000, T1200 */
|
||||
#define FDC_FLAG_AMSTRAD 0x200 /* Non-AT Amstrad machines */
|
||||
#define FDC_FLAG_UMC 0x400 /* UMC UM8398 */
|
||||
#define FDC_FLAG_ALI 0x800 /* ALi M512x / M1543C */
|
||||
#define FDC_FLAG_SEC 0x1000 /* Is Secondary */
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
#ifndef EMU_FDD_H
|
||||
#define EMU_FDD_H
|
||||
|
||||
#define FDD_NUM 4
|
||||
#define FLOPPY_IMAGE_HISTORY 4
|
||||
#define SEEK_RECALIBRATE -999
|
||||
#define FDD_NUM 4
|
||||
#define FLOPPY_IMAGE_HISTORY 4
|
||||
#define SEEK_RECALIBRATE -999
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -85,7 +85,7 @@ typedef struct {
|
||||
|
||||
extern DRIVE drives[FDD_NUM];
|
||||
extern char floppyfns[FDD_NUM][512];
|
||||
extern char *fdd_image_history[FDD_NUM][FLOPPY_IMAGE_HISTORY];
|
||||
extern char *fdd_image_history[FDD_NUM][FLOPPY_IMAGE_HISTORY];
|
||||
extern pc_timer_t fdd_poll_time[FDD_NUM];
|
||||
extern int ui_writeprot[FDD_NUM];
|
||||
|
||||
|
||||
@@ -33,19 +33,19 @@
|
||||
|
||||
extern int hdc_current;
|
||||
|
||||
extern const device_t st506_xt_xebec_device; /* st506_xt_xebec */
|
||||
extern const device_t st506_xt_dtc5150x_device; /* st506_xt_dtc */
|
||||
extern const device_t st506_xt_st11_m_device; /* st506_xt_st11_m */
|
||||
extern const device_t st506_xt_st11_r_device; /* st506_xt_st11_m */
|
||||
extern const device_t st506_xt_wd1002a_wx1_device; /* st506_xt_wd1002a_wx1 */
|
||||
extern const device_t st506_xt_wd1002a_wx1_nobios_device; /* st506_xt_wd1002a_wx1 */
|
||||
extern const device_t st506_xt_wd1002a_27x_device; /* st506_xt_wd1002a_27x */
|
||||
extern const device_t st506_at_wd1003_device; /* st506_at_wd1003 */
|
||||
extern const device_t st506_xt_wd1004a_wx1_device; /* st506_xt_wd1004a_wx1 */
|
||||
extern const device_t st506_xt_wd1004_27x_device; /* st506_xt_wd1004_27x */
|
||||
extern const device_t st506_xt_wd1004a_27x_device; /* st506_xt_wd1004a_27x */
|
||||
extern const device_t st506_xt_victor_v86p_device; /* st506_xt_victor_v86p */
|
||||
extern const device_t st506_xt_toshiba_t1200_device; /* st506_xt_toshiba_t1200 */
|
||||
extern const device_t st506_xt_xebec_device; /* st506_xt_xebec */
|
||||
extern const device_t st506_xt_dtc5150x_device; /* st506_xt_dtc */
|
||||
extern const device_t st506_xt_st11_m_device; /* st506_xt_st11_m */
|
||||
extern const device_t st506_xt_st11_r_device; /* st506_xt_st11_m */
|
||||
extern const device_t st506_xt_wd1002a_wx1_device; /* st506_xt_wd1002a_wx1 */
|
||||
extern const device_t st506_xt_wd1002a_wx1_nobios_device; /* st506_xt_wd1002a_wx1 */
|
||||
extern const device_t st506_xt_wd1002a_27x_device; /* st506_xt_wd1002a_27x */
|
||||
extern const device_t st506_at_wd1003_device; /* st506_at_wd1003 */
|
||||
extern const device_t st506_xt_wd1004a_wx1_device; /* st506_xt_wd1004a_wx1 */
|
||||
extern const device_t st506_xt_wd1004_27x_device; /* st506_xt_wd1004_27x */
|
||||
extern const device_t st506_xt_wd1004a_27x_device; /* st506_xt_wd1004a_27x */
|
||||
extern const device_t st506_xt_victor_v86p_device; /* st506_xt_victor_v86p */
|
||||
extern const device_t st506_xt_toshiba_t1200_device; /* st506_xt_toshiba_t1200 */
|
||||
|
||||
extern const device_t esdi_at_wd1007vse1_device; /* esdi_at */
|
||||
extern const device_t esdi_ps2_device; /* esdi_mca */
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
#ifndef EMU_HDD_H
|
||||
#define EMU_HDD_H
|
||||
|
||||
#define IMG_FMT_RAW 0
|
||||
#define IMG_FMT_HDI 1
|
||||
#define IMG_FMT_HDX 2
|
||||
#define IMG_FMT_VHD_FIXED 3
|
||||
#define IMG_FMT_RAW 0
|
||||
#define IMG_FMT_HDI 1
|
||||
#define IMG_FMT_HDX 2
|
||||
#define IMG_FMT_VHD_FIXED 3
|
||||
#define IMG_FMT_VHD_DYNAMIC 4
|
||||
#define IMG_FMT_VHD_DIFF 5
|
||||
#define IMG_FMT_VHD_DIFF 5
|
||||
|
||||
#define HDD_NUM 88 /* total of 88 images supported */
|
||||
#define HDD_NUM 88 /* total of 88 images supported */
|
||||
|
||||
/* Hard Disk bus types. */
|
||||
#if 0
|
||||
|
||||
@@ -15,32 +15,36 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct i8080
|
||||
{
|
||||
union {
|
||||
typedef struct i8080 {
|
||||
union {
|
||||
uint16_t af; /* Intended in case we also go for μPD9002 emulation, which also has a Z80 emulation mode. */
|
||||
struct { uint8_t a, flags; };
|
||||
struct {
|
||||
uint8_t a, flags;
|
||||
};
|
||||
};
|
||||
union
|
||||
{
|
||||
union {
|
||||
uint16_t bc;
|
||||
struct { uint8_t b, c; };
|
||||
struct {
|
||||
uint8_t b, c;
|
||||
};
|
||||
};
|
||||
union
|
||||
{
|
||||
union {
|
||||
uint16_t de;
|
||||
struct { uint8_t d, e; };
|
||||
struct {
|
||||
uint8_t d, e;
|
||||
};
|
||||
};
|
||||
union
|
||||
{
|
||||
union {
|
||||
uint16_t hl;
|
||||
struct { uint8_t h, l; };
|
||||
struct {
|
||||
uint8_t h, l;
|
||||
};
|
||||
};
|
||||
uint16_t pc, sp;
|
||||
uint16_t oldpc, ei;
|
||||
uint32_t pmembase, dmembase; /* Base from where i8080 starts. */
|
||||
uint8_t emulated; /* 0 = not emulated, use separate registers, 1 = emulated, use x86 registers. */
|
||||
uint16_t* cpu_flags;
|
||||
uint16_t pc, sp;
|
||||
uint16_t oldpc, ei;
|
||||
uint32_t pmembase, dmembase; /* Base from where i8080 starts. */
|
||||
uint8_t emulated; /* 0 = not emulated, use separate registers, 1 = emulated, use x86 registers. */
|
||||
uint16_t *cpu_flags;
|
||||
void (*writemembyte)(uint32_t, uint8_t);
|
||||
uint8_t (*readmembyte)(uint32_t);
|
||||
void (*startclock)(void);
|
||||
@@ -49,8 +53,8 @@ typedef struct i8080
|
||||
uint8_t (*fetchinstruction)(void *);
|
||||
} i8080;
|
||||
|
||||
#define C_FLAG_I8080 (1 << 0)
|
||||
#define P_FLAG_I8080 (1 << 2)
|
||||
#define C_FLAG_I8080 (1 << 0)
|
||||
#define P_FLAG_I8080 (1 << 2)
|
||||
#define AC_FLAG_I8080 (1 << 4)
|
||||
#define Z_FLAG_I8080 (1 << 6)
|
||||
#define S_FLAG_I8080 (1 << 7)
|
||||
#define Z_FLAG_I8080 (1 << 6)
|
||||
#define S_FLAG_I8080 (1 << 7)
|
||||
|
||||
@@ -22,65 +22,65 @@
|
||||
#define LANG_UAGE_H
|
||||
|
||||
/* String IDs. */
|
||||
#define IDS_STRINGS 2048 // "86Box"
|
||||
#define IDS_2049 2049 // "Error"
|
||||
#define IDS_2050 2050 // "Fatal error"
|
||||
#define IDS_2051 2051 // " - PAUSED"
|
||||
#define IDS_2052 2052 // "Press Ctrl+Alt+PgDn..."
|
||||
#define IDS_2053 2053 // "Speed"
|
||||
#define IDS_2054 2054 // "ZIP %i (%03i): %ls"
|
||||
#define IDS_2055 2055 // "ZIP images (*.IM?)\0*.IM..."
|
||||
#define IDS_2056 2056 // "No usable ROM images found!"
|
||||
#define IDS_2057 2057 // "(empty)"
|
||||
#define IDS_2058 2058 // "ZIP images (*.IM?)\0*.IM..."
|
||||
#define IDS_2059 2059 // "(Turbo)"
|
||||
#define IDS_2060 2060 // "On"
|
||||
#define IDS_2061 2061 // "Off"
|
||||
#define IDS_2062 2062 // "All floppy images (*.DSK..."
|
||||
#define IDS_2063 2063 // "Machine ""%hs"" is not..."
|
||||
#define IDS_2064 2064 // "Video card ""%hs"" is not..."
|
||||
#define IDS_2065 2065 // "Machine"
|
||||
#define IDS_2066 2066 // "Display"
|
||||
#define IDS_2067 2067 // "Input devices"
|
||||
#define IDS_2068 2068 // "Sound"
|
||||
#define IDS_2069 2069 // "Network"
|
||||
#define IDS_2070 2070 // "Ports (COM & LPT)"
|
||||
#define IDS_2071 2071 // "Storage controllers"
|
||||
#define IDS_2072 2072 // "Hard disks"
|
||||
#define IDS_2073 2073 // "Floppy and CD-ROM drives"
|
||||
#define IDS_2074 2074 // "Other removable devices"
|
||||
#define IDS_2075 2075 // "Other peripherals"
|
||||
#define IDS_2076 2076 // "Surface-based images (*.8.."
|
||||
#define IDS_2077 2077 // "Click to capture mouse"
|
||||
#define IDS_2078 2078 // "Press F12-F8 to release mouse"
|
||||
#define IDS_2079 2079 // "Press F12-F8 or middle button.."
|
||||
#define IDS_2080 2080 // "Unable to initialize Flui.."
|
||||
#define IDS_2081 2081 // "Bus"
|
||||
#define IDS_BUS IDS_2081 // "Bus"
|
||||
#define IDS_2082 2082 // "File"
|
||||
#define IDS_2083 2083 // "C"
|
||||
#define IDS_2084 2084 // "H"
|
||||
#define IDS_2085 2085 // "S"
|
||||
#define IDS_2086 2086 // "MB"
|
||||
#define IDS_MB IDS_2086 // "MB"
|
||||
#define IDS_2087 2087 // "Speed"
|
||||
#define IDS_STRINGS 2048 // "86Box"
|
||||
#define IDS_2049 2049 // "Error"
|
||||
#define IDS_2050 2050 // "Fatal error"
|
||||
#define IDS_2051 2051 // " - PAUSED"
|
||||
#define IDS_2052 2052 // "Press Ctrl+Alt+PgDn..."
|
||||
#define IDS_2053 2053 // "Speed"
|
||||
#define IDS_2054 2054 // "ZIP %i (%03i): %ls"
|
||||
#define IDS_2055 2055 // "ZIP images (*.IM?)\0*.IM..."
|
||||
#define IDS_2056 2056 // "No usable ROM images found!"
|
||||
#define IDS_2057 2057 // "(empty)"
|
||||
#define IDS_2058 2058 // "ZIP images (*.IM?)\0*.IM..."
|
||||
#define IDS_2059 2059 // "(Turbo)"
|
||||
#define IDS_2060 2060 // "On"
|
||||
#define IDS_2061 2061 // "Off"
|
||||
#define IDS_2062 2062 // "All floppy images (*.DSK..."
|
||||
#define IDS_2063 2063 // "Machine ""%hs"" is not..."
|
||||
#define IDS_2064 2064 // "Video card ""%hs"" is not..."
|
||||
#define IDS_2065 2065 // "Machine"
|
||||
#define IDS_2066 2066 // "Display"
|
||||
#define IDS_2067 2067 // "Input devices"
|
||||
#define IDS_2068 2068 // "Sound"
|
||||
#define IDS_2069 2069 // "Network"
|
||||
#define IDS_2070 2070 // "Ports (COM & LPT)"
|
||||
#define IDS_2071 2071 // "Storage controllers"
|
||||
#define IDS_2072 2072 // "Hard disks"
|
||||
#define IDS_2073 2073 // "Floppy and CD-ROM drives"
|
||||
#define IDS_2074 2074 // "Other removable devices"
|
||||
#define IDS_2075 2075 // "Other peripherals"
|
||||
#define IDS_2076 2076 // "Surface-based images (*.8.."
|
||||
#define IDS_2077 2077 // "Click to capture mouse"
|
||||
#define IDS_2078 2078 // "Press F12-F8 to release mouse"
|
||||
#define IDS_2079 2079 // "Press F12-F8 or middle button.."
|
||||
#define IDS_2080 2080 // "Unable to initialize Flui.."
|
||||
#define IDS_2081 2081 // "Bus"
|
||||
#define IDS_BUS IDS_2081 // "Bus"
|
||||
#define IDS_2082 2082 // "File"
|
||||
#define IDS_2083 2083 // "C"
|
||||
#define IDS_2084 2084 // "H"
|
||||
#define IDS_2085 2085 // "S"
|
||||
#define IDS_2086 2086 // "MB"
|
||||
#define IDS_MB IDS_2086 // "MB"
|
||||
#define IDS_2087 2087 // "Speed"
|
||||
|
||||
#define IDS_2088 2088 // "Check BPB"
|
||||
#define IDS_BPB IDS_2088 // "Check BPB"
|
||||
#define IDS_2088 2088 // "Check BPB"
|
||||
#define IDS_BPB IDS_2088 // "Check BPB"
|
||||
|
||||
#define IDS_2089 2089 // "KB"
|
||||
#define IDS_KB IDS_2089 // "KB"
|
||||
#define IDS_2089 2089 // "KB"
|
||||
#define IDS_KB IDS_2089 // "KB"
|
||||
|
||||
#define IDS_2090 2090 // "Could not initialize the video..."
|
||||
#define IDS_2090 2090 // "Could not initialize the video..."
|
||||
|
||||
#define IDS_2091 2091 // "Default"
|
||||
#define IDS_DEFAULT IDS_2091 // "Default"
|
||||
#define IDS_2091 2091 // "Default"
|
||||
#define IDS_DEFAULT IDS_2091 // "Default"
|
||||
|
||||
#define IDS_2092 2092 // "%i Wait state(s)"
|
||||
#define IDS_WS IDS_2092 // "%i Wait state(s)"
|
||||
#define IDS_2092 2092 // "%i Wait state(s)"
|
||||
#define IDS_WS IDS_2092 // "%i Wait state(s)"
|
||||
|
||||
#define IDS_2093 2093 // "Type"
|
||||
#define IDS_TYPE IDS_2093 // "Type"
|
||||
#define IDS_2093 2093 // "Type"
|
||||
#define IDS_TYPE IDS_2093 // "Type"
|
||||
|
||||
/* TODO */
|
||||
#define IDS_2094 2094 // "PCap failed to set up.."
|
||||
@@ -262,14 +262,14 @@
|
||||
|
||||
#define STR_NUM_2048 115
|
||||
// UNUSED: #define STR_NUM_3072 11
|
||||
#define STR_NUM_4096 40
|
||||
#define STR_NUM_4352 6
|
||||
#define STR_NUM_4608 6
|
||||
#define STR_NUM_5120 1
|
||||
#define STR_NUM_5376 7
|
||||
#define STR_NUM_5632 7
|
||||
#define STR_NUM_5888 24
|
||||
#define STR_NUM_6144 4
|
||||
#define STR_NUM_7168 1
|
||||
#define STR_NUM_4096 40
|
||||
#define STR_NUM_4352 6
|
||||
#define STR_NUM_4608 6
|
||||
#define STR_NUM_5120 1
|
||||
#define STR_NUM_5376 7
|
||||
#define STR_NUM_5632 7
|
||||
#define STR_NUM_5888 24
|
||||
#define STR_NUM_6144 4
|
||||
#define STR_NUM_7168 1
|
||||
|
||||
#endif /*LANG_UAGE_H*/
|
||||
|
||||
@@ -127,7 +127,10 @@
|
||||
#define IS_AT(m) (((machines[m].bus_flags & (MACHINE_BUS_ISA16 | MACHINE_BUS_EISA | MACHINE_BUS_VLB | MACHINE_BUS_MCA | MACHINE_BUS_PCI | MACHINE_BUS_PCMCIA | MACHINE_BUS_AGP | MACHINE_BUS_AC97)) && !(machines[m].bus_flags & MACHINE_PC98)) ? 1 : 0)
|
||||
|
||||
#define CPU_BLOCK(...) \
|
||||
(const uint8_t[]) { __VA_ARGS__, 0 }
|
||||
(const uint8_t[]) \
|
||||
{ \
|
||||
__VA_ARGS__, 0 \
|
||||
}
|
||||
#define MACHINE_MULTIPLIER_FIXED -1
|
||||
|
||||
#define CPU_BLOCK_NONE 0
|
||||
|
||||
@@ -22,38 +22,38 @@
|
||||
#ifndef EMU_PCI_H
|
||||
#define EMU_PCI_H
|
||||
|
||||
#define PCI_REG_COMMAND 0x04
|
||||
#define PCI_REG_COMMAND 0x04
|
||||
|
||||
#define PCI_COMMAND_IO 0x01
|
||||
#define PCI_COMMAND_MEM 0x02
|
||||
#define PCI_COMMAND_IO 0x01
|
||||
#define PCI_COMMAND_MEM 0x02
|
||||
|
||||
#define PCI_NO_IRQ_STEERING 0x8000
|
||||
#define PCI_CAN_SWITCH_TYPE 0x10000
|
||||
#define PCI_NO_BRIDGES 0x20000
|
||||
#define PCI_ALWAYS_EXPOSE_DEV0 0x40000
|
||||
#define PCI_NO_IRQ_STEERING 0x8000
|
||||
#define PCI_CAN_SWITCH_TYPE 0x10000
|
||||
#define PCI_NO_BRIDGES 0x20000
|
||||
#define PCI_ALWAYS_EXPOSE_DEV0 0x40000
|
||||
|
||||
#define PCI_CONFIG_TYPE_1 1
|
||||
#define PCI_CONFIG_TYPE_2 2
|
||||
#define PCI_CONFIG_TYPE_1 1
|
||||
#define PCI_CONFIG_TYPE_2 2
|
||||
|
||||
#define PCI_CONFIG_TYPE_MASK 0x7fff
|
||||
#define PCI_CONFIG_TYPE_MASK 0x7fff
|
||||
|
||||
#define PCI_INTA 1
|
||||
#define PCI_INTB 2
|
||||
#define PCI_INTC 3
|
||||
#define PCI_INTD 4
|
||||
#define PCI_INTA 1
|
||||
#define PCI_INTB 2
|
||||
#define PCI_INTC 3
|
||||
#define PCI_INTD 4
|
||||
|
||||
#define PCI_MIRQ0 0
|
||||
#define PCI_MIRQ1 1
|
||||
#define PCI_MIRQ2 2
|
||||
#define PCI_MIRQ3 3
|
||||
#define PCI_MIRQ4 4
|
||||
#define PCI_MIRQ5 5
|
||||
#define PCI_MIRQ6 6
|
||||
#define PCI_MIRQ7 7
|
||||
#define PCI_MIRQ0 0
|
||||
#define PCI_MIRQ1 1
|
||||
#define PCI_MIRQ2 2
|
||||
#define PCI_MIRQ3 3
|
||||
#define PCI_MIRQ4 4
|
||||
#define PCI_MIRQ5 5
|
||||
#define PCI_MIRQ6 6
|
||||
#define PCI_MIRQ7 7
|
||||
|
||||
#define PCI_IRQ_DISABLED -1
|
||||
#define PCI_IRQ_DISABLED -1
|
||||
|
||||
#define PCI_ADD_STRICT 0x80
|
||||
#define PCI_ADD_STRICT 0x80
|
||||
|
||||
enum {
|
||||
PCI_CARD_NORTHBRIDGE = 0,
|
||||
|
||||
@@ -49,7 +49,7 @@ extern int strnicmp(const char *s1, const char *s2, size_t n);
|
||||
# define ftello64 ftello
|
||||
# define off64_t off_t
|
||||
#elif defined(_MSC_VER)
|
||||
//# define fopen64 fopen
|
||||
// # define fopen64 fopen
|
||||
# define fseeko64 _fseeki64
|
||||
# define ftello64 _ftelli64
|
||||
# define off64_t off_t
|
||||
|
||||
@@ -19,24 +19,24 @@
|
||||
|
||||
/* Windows needs the POSIX re-implementations */
|
||||
#if defined(_WIN32)
|
||||
#ifdef _MAX_FNAME
|
||||
# define MAXNAMLEN _MAX_FNAME
|
||||
#else
|
||||
# define MAXNAMLEN 15
|
||||
#endif
|
||||
#define MAXDIRLEN 127
|
||||
# ifdef _MAX_FNAME
|
||||
# define MAXNAMLEN _MAX_FNAME
|
||||
# else
|
||||
# define MAXNAMLEN 15
|
||||
# endif
|
||||
# define MAXDIRLEN 127
|
||||
|
||||
struct dirent {
|
||||
long d_ino;
|
||||
unsigned short d_reclen;
|
||||
unsigned short d_off;
|
||||
#ifdef UNICODE
|
||||
# ifdef UNICODE
|
||||
wchar_t d_name[MAXNAMLEN + 1];
|
||||
#else
|
||||
# else
|
||||
char d_name[MAXNAMLEN + 1];
|
||||
#endif
|
||||
# endif
|
||||
};
|
||||
#define d_namlen d_reclen
|
||||
# define d_namlen d_reclen
|
||||
|
||||
typedef struct {
|
||||
short flags; /* internal flags */
|
||||
@@ -44,18 +44,18 @@ typedef struct {
|
||||
long handle; /* open handle to Win32 system */
|
||||
short sts; /* last known status code */
|
||||
char *dta; /* internal work data */
|
||||
#ifdef UNICODE
|
||||
# ifdef UNICODE
|
||||
wchar_t dir[MAXDIRLEN + 1]; /* open dir */
|
||||
#else
|
||||
# else
|
||||
char dir[MAXDIRLEN + 1]; /* open dir */
|
||||
#endif
|
||||
# endif
|
||||
struct dirent dent; /* actual directory entry */
|
||||
} DIR;
|
||||
|
||||
/* Directory routine flags. */
|
||||
#define DIR_F_LOWER 0x0001 /* force to lowercase */
|
||||
#define DIR_F_SANE 0x0002 /* force this to sane path */
|
||||
#define DIR_F_ISROOT 0x0010 /* this is the root directory */
|
||||
# define DIR_F_LOWER 0x0001 /* force to lowercase */
|
||||
# define DIR_F_SANE 0x0002 /* force this to sane path */
|
||||
# define DIR_F_ISROOT 0x0010 /* this is the root directory */
|
||||
|
||||
/* Function prototypes. */
|
||||
extern DIR *opendir(const char *);
|
||||
@@ -64,11 +64,10 @@ extern long telldir(DIR *);
|
||||
extern void seekdir(DIR *, long);
|
||||
extern int closedir(DIR *);
|
||||
|
||||
#define rewinddir(dirp) seekdir(dirp, 0L)
|
||||
# define rewinddir(dirp) seekdir(dirp, 0L)
|
||||
#else
|
||||
/* On linux and macOS, use the standard functions and types */
|
||||
#include <sys/dir.h>
|
||||
# include <sys/dir.h>
|
||||
#endif
|
||||
|
||||
|
||||
#endif /*PLAT_DIR_H*/
|
||||
|
||||
@@ -137,11 +137,11 @@
|
||||
#define IDT_CD_SPEED 1761 /* Speed: */
|
||||
|
||||
/* DLG_CFG_OTHER_REMOVABLE_DEVICES */
|
||||
#define IDT_MO_DRIVES 1762 /* MO drives: */
|
||||
#define IDT_MO_BUS 1763 /* Bus: */
|
||||
#define IDT_MO_ID 1764 /* ID: */
|
||||
#define IDT_MO_CHANNEL 1765 /* Channel */
|
||||
#define IDT_MO_TYPE 1766 /* Type: */
|
||||
#define IDT_MO_DRIVES 1762 /* MO drives: */
|
||||
#define IDT_MO_BUS 1763 /* Bus: */
|
||||
#define IDT_MO_ID 1764 /* ID: */
|
||||
#define IDT_MO_CHANNEL 1765 /* Channel */
|
||||
#define IDT_MO_TYPE 1766 /* Type: */
|
||||
|
||||
#define IDT_ZIP_DRIVES 1767 /* ZIP drives: */
|
||||
#define IDT_ZIP_BUS 1768 /* Bus: */
|
||||
|
||||
@@ -68,8 +68,8 @@ void cga_poll(void *p);
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern const device_config_t cga_config[];
|
||||
|
||||
extern const device_t cga_device;
|
||||
extern const device_t cga_pravetz_device;
|
||||
extern const device_t cga_device;
|
||||
extern const device_t cga_pravetz_device;
|
||||
#endif
|
||||
|
||||
#endif /*VIDEO_CGA_H*/
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#define Bit8u uint8_t
|
||||
#define Bit32u uint32_t
|
||||
#define Bitu unsigned int
|
||||
#define bool uint8_t
|
||||
#define bool uint8_t
|
||||
|
||||
void update_cga16_color(uint8_t cgamode);
|
||||
void cga_comp_init(int revision);
|
||||
|
||||
@@ -2075,12 +2075,12 @@ voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo_params_t *params,
|
||||
addbyte(0x05);
|
||||
addlong((uint32_t) &xmm_ff_b);
|
||||
}
|
||||
//#if 0
|
||||
// addbyte(0x66); /*MOVD state->out[EDI], XMM0*/
|
||||
// addbyte(0x0f);
|
||||
// addbyte(0x7e);
|
||||
// addbyte(0x87);
|
||||
// addlong(offsetof(voodoo_state_t, out));
|
||||
// #if 0
|
||||
// addbyte(0x66); /*MOVD state->out[EDI], XMM0*/
|
||||
// addbyte(0x0f);
|
||||
// addbyte(0x7e);
|
||||
// addbyte(0x87);
|
||||
// addlong(offsetof(voodoo_state_t, out));
|
||||
if (params->fogMode & FOG_ENABLE) {
|
||||
if (params->fogMode & FOG_CONSTANT) {
|
||||
addbyte(0x66); /*MOVD XMM3, params->fogColor[ESI]*/
|
||||
@@ -2695,7 +2695,7 @@ voodoo_generate(uint8_t *code_block, voodoo_t *voodoo, voodoo_params_t *params,
|
||||
addbyte(0x67);
|
||||
addbyte(0xc0);
|
||||
}
|
||||
//#endif
|
||||
// #endif
|
||||
|
||||
// addbyte(0x8b); /*MOV EDX, x (ESP+12)*/
|
||||
// addbyte(0x54);
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
#define TEX_CACHE_MAX 64
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <atomic>
|
||||
# include <atomic>
|
||||
using atomic_int = std::atomic<int>;
|
||||
#else
|
||||
#include <stdatomic.h>
|
||||
# include <stdatomic.h>
|
||||
#endif
|
||||
|
||||
enum {
|
||||
@@ -320,7 +320,7 @@ typedef struct voodoo_t {
|
||||
uint32_t cmdfifo_amin, cmdfifo_amax;
|
||||
int cmdfifo_holecount;
|
||||
|
||||
atomic_uint cmd_status;
|
||||
atomic_uint cmd_status;
|
||||
|
||||
uint32_t sSetupMode;
|
||||
vert_t verts[4];
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#ifndef VIDEO_VOODOO_DITHER_H
|
||||
# define VIDEO_VOODOO_DITHER_H
|
||||
#define VIDEO_VOODOO_DITHER_H
|
||||
|
||||
static const uint8_t dither_rb[256][4][4] =
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifndef __FDI2RAW_H
|
||||
#define __FDI2RAW_H
|
||||
|
||||
#define uae_u8 uint8_t
|
||||
#define uae_u8 uint8_t
|
||||
#define uae_u16 uint16_t
|
||||
#define uae_u32 uint32_t
|
||||
|
||||
@@ -32,20 +32,20 @@ typedef struct fdi FDI;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int fdi2raw_loadtrack (FDI*, uae_u16 *mfmbuf, uae_u16 *tracktiming, int track, int *tracklength, int *indexoffset, int *multirev, int mfm);
|
||||
extern int fdi2raw_loadtrack(FDI *, uae_u16 *mfmbuf, uae_u16 *tracktiming, int track, int *tracklength, int *indexoffset, int *multirev, int mfm);
|
||||
|
||||
extern int fdi2raw_loadrevolution (FDI*, uae_u16 *mfmbuf, uae_u16 *tracktiming, int track, int *tracklength, int mfm);
|
||||
extern int fdi2raw_loadrevolution(FDI *, uae_u16 *mfmbuf, uae_u16 *tracktiming, int track, int *tracklength, int mfm);
|
||||
|
||||
extern FDI *fdi2raw_header(FILE *f);
|
||||
extern void fdi2raw_header_free (FDI *);
|
||||
extern int fdi2raw_get_last_track(FDI *);
|
||||
extern int fdi2raw_get_num_sector (FDI *);
|
||||
extern int fdi2raw_get_last_head(FDI *);
|
||||
extern int fdi2raw_get_type (FDI *);
|
||||
extern int fdi2raw_get_bit_rate (FDI *);
|
||||
extern int fdi2raw_get_rotation (FDI *);
|
||||
extern int fdi2raw_get_write_protect (FDI *);
|
||||
extern int fdi2raw_get_tpi (FDI *);
|
||||
extern void fdi2raw_header_free(FDI *);
|
||||
extern int fdi2raw_get_last_track(FDI *);
|
||||
extern int fdi2raw_get_num_sector(FDI *);
|
||||
extern int fdi2raw_get_last_head(FDI *);
|
||||
extern int fdi2raw_get_type(FDI *);
|
||||
extern int fdi2raw_get_bit_rate(FDI *);
|
||||
extern int fdi2raw_get_rotation(FDI *);
|
||||
extern int fdi2raw_get_write_protect(FDI *);
|
||||
extern int fdi2raw_get_tpi(FDI *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -15,101 +15,99 @@
|
||||
* Copyright 2020 RichardG.
|
||||
*/
|
||||
#ifndef TINYGLIB_H
|
||||
# define TINYGLIB_H
|
||||
#define TINYGLIB_H
|
||||
|
||||
/* Define this to bypass TinyGLib and use full GLib instead. */
|
||||
#ifdef TINYGLIB_USE_GLIB
|
||||
#include <glib.h>
|
||||
# include <glib.h>
|
||||
#else
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
|
||||
# include <stdarg.h>
|
||||
# include <stdint.h>
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# define HAVE_STDARG_H
|
||||
# include <86box/86box.h>
|
||||
|
||||
/* Definitions */
|
||||
|
||||
#define G_LITTLE_ENDIAN 1234
|
||||
#define G_BIG_ENDIAN 4321
|
||||
#define G_PDP_ENDIAN 3412
|
||||
#ifdef __BYTE_ORDER__
|
||||
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define G_BYTE_ORDER G_LITTLE_ENDIAN
|
||||
# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
# define G_BYTE_ORDER G_BIG_ENDIAN
|
||||
# elif __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__
|
||||
# define G_BYTE_ORDER G_PDP_ENDIAN
|
||||
# endif
|
||||
#endif
|
||||
#ifndef G_BYTE_ORDER
|
||||
# define G_LITTLE_ENDIAN 1234
|
||||
# define G_BIG_ENDIAN 4321
|
||||
# define G_PDP_ENDIAN 3412
|
||||
# ifdef __BYTE_ORDER__
|
||||
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define G_BYTE_ORDER G_LITTLE_ENDIAN
|
||||
# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
# define G_BYTE_ORDER G_BIG_ENDIAN
|
||||
# elif __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__
|
||||
# define G_BYTE_ORDER G_PDP_ENDIAN
|
||||
# endif
|
||||
# endif
|
||||
# ifndef G_BYTE_ORDER
|
||||
/* Safe to assume LE for MSVC, as Windows is LE on all architectures. */
|
||||
# define G_BYTE_ORDER G_LITTLE_ENDIAN
|
||||
#endif
|
||||
# define G_BYTE_ORDER G_LITTLE_ENDIAN
|
||||
# endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# define G_OS_WIN32 1
|
||||
#else
|
||||
# define G_OS_UNIX 1
|
||||
#endif
|
||||
# ifdef _WIN32
|
||||
# define G_OS_WIN32 1
|
||||
# else
|
||||
# define G_OS_UNIX 1
|
||||
# endif
|
||||
|
||||
#define G_SPAWN_SEARCH_PATH 0
|
||||
|
||||
#if defined(__LP64__) || defined(__LLP64__) || defined(_WIN64)
|
||||
# define GLIB_SIZEOF_VOID_P 8
|
||||
# if defined(__LLP64__) || defined(_WIN64)
|
||||
# define GLIB_SIZEOF_LONG 4
|
||||
# else
|
||||
# define GLIB_SIZEOF_LONG 8
|
||||
# endif
|
||||
# define GLIB_SIZEOF_SIZE_T 8
|
||||
# define GLIB_SIZEOF_SSIZE_T 8
|
||||
#else
|
||||
# define GLIB_SIZEOF_VOID_P 4
|
||||
# define GLIB_SIZEOF_LONG 4
|
||||
# define GLIB_SIZEOF_SIZE_T 4
|
||||
# define GLIB_SIZEOF_SSIZE_T 4
|
||||
#endif
|
||||
# define G_SPAWN_SEARCH_PATH 0
|
||||
|
||||
# if defined(__LP64__) || defined(__LLP64__) || defined(_WIN64)
|
||||
# define GLIB_SIZEOF_VOID_P 8
|
||||
# if defined(__LLP64__) || defined(_WIN64)
|
||||
# define GLIB_SIZEOF_LONG 4
|
||||
# else
|
||||
# define GLIB_SIZEOF_LONG 8
|
||||
# endif
|
||||
# define GLIB_SIZEOF_SIZE_T 8
|
||||
# define GLIB_SIZEOF_SSIZE_T 8
|
||||
# else
|
||||
# define GLIB_SIZEOF_VOID_P 4
|
||||
# define GLIB_SIZEOF_LONG 4
|
||||
# define GLIB_SIZEOF_SIZE_T 4
|
||||
# define GLIB_SIZEOF_SSIZE_T 4
|
||||
# endif
|
||||
|
||||
/* Types */
|
||||
|
||||
/* Windows does not define ssize_t, so we need to define it here. */
|
||||
#ifndef _SSIZE_T_DEFINED
|
||||
# define _SSIZE_T_DEFINED
|
||||
# undef ssize_t
|
||||
# ifdef _WIN64
|
||||
# define ssize_t int64_t
|
||||
# else
|
||||
# define ssize_t int32_t
|
||||
# endif
|
||||
#endif
|
||||
# ifndef _SSIZE_T_DEFINED
|
||||
# define _SSIZE_T_DEFINED
|
||||
# undef ssize_t
|
||||
# ifdef _WIN64
|
||||
# define ssize_t int64_t
|
||||
# else
|
||||
# define ssize_t int32_t
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#define gboolean int
|
||||
#define gchar char
|
||||
#define gint int
|
||||
#define gint16 int16_t
|
||||
#define gint32 int32_t
|
||||
#define gint64 int64_t
|
||||
#define glong long
|
||||
#define GPid void *
|
||||
#define gpointer void *
|
||||
#define gsize size_t
|
||||
#define GSpawnFlags void *
|
||||
#define GSpawnChildSetupFunc void *
|
||||
#define gssize ssize_t
|
||||
#define GString char
|
||||
#define GStrv char **
|
||||
#define guint unsigned int
|
||||
#define guint16 uint16_t
|
||||
#define guint32 uint32_t
|
||||
#define guint64 uint64_t
|
||||
# define gboolean int
|
||||
# define gchar char
|
||||
# define gint int
|
||||
# define gint16 int16_t
|
||||
# define gint32 int32_t
|
||||
# define gint64 int64_t
|
||||
# define glong long
|
||||
# define GPid void *
|
||||
# define gpointer void *
|
||||
# define gsize size_t
|
||||
# define GSpawnFlags void *
|
||||
# define GSpawnChildSetupFunc void *
|
||||
# define gssize ssize_t
|
||||
# define GString char
|
||||
# define GStrv char **
|
||||
# define guint unsigned int
|
||||
# define guint16 uint16_t
|
||||
# define guint32 uint32_t
|
||||
# define guint64 uint64_t
|
||||
|
||||
typedef struct _GDebugKey {
|
||||
char key[32];
|
||||
int val;
|
||||
int val;
|
||||
} GDebugKey;
|
||||
|
||||
typedef struct _GError {
|
||||
@@ -120,80 +118,86 @@ typedef struct _GRand {
|
||||
uint8_t dummy;
|
||||
} GRand;
|
||||
|
||||
|
||||
/* Functions */
|
||||
extern gboolean g_spawn_async_with_fds(const gchar *working_directory, gchar **argv,
|
||||
extern gboolean g_spawn_async_with_fds(const gchar *working_directory, gchar **argv,
|
||||
gchar **envp, GSpawnFlags flags,
|
||||
GSpawnChildSetupFunc child_setup,
|
||||
gpointer user_data, GPid *child_pid, gint stdin_fd,
|
||||
gint stdout_fd, gint stderr_fd, GError **error);
|
||||
extern GString *g_string_new(gchar *base);
|
||||
extern gchar *g_string_free(GString *string, gboolean free_segment);
|
||||
extern gchar *g_strstr_len(const gchar *haystack, gssize haystack_len, const gchar *needle);
|
||||
extern guint g_strv_length(gchar **str_array);
|
||||
|
||||
extern GString *g_string_new(gchar *base);
|
||||
extern gchar *g_string_free(GString *string, gboolean free_segment);
|
||||
extern gchar *g_strstr_len(const gchar *haystack, gssize haystack_len, const gchar *needle);
|
||||
extern guint g_strv_length(gchar **str_array);
|
||||
|
||||
/* Macros */
|
||||
#define tinyglib_pclog(f, s, ...) pclog("TinyGLib " f "(): " s "\n", ##__VA_ARGS__)
|
||||
# define tinyglib_pclog(f, s, ...) pclog("TinyGLib " f "(): " s "\n", ##__VA_ARGS__)
|
||||
|
||||
#define GLIB_CHECK_VERSION(a, b, c) 1
|
||||
#ifdef __GNUC__
|
||||
# define G_GNUC_PRINTF(format_idx, arg_idx) __attribute__((__format__ (__printf__, format_idx, arg_idx)))
|
||||
#else
|
||||
# define G_GNUC_PRINTF(format_idx, arg_idx)
|
||||
#endif
|
||||
#define G_N_ELEMENTS(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
#define G_STATIC_ASSERT(e) /* this should probably do something */
|
||||
#define G_UNLIKELY(e) (e)
|
||||
|
||||
#define g_assert(e) do { if (!(e)) fatal("TinyGLib g_assert(" #e ")\n"); } while (0)
|
||||
#ifdef __GNUC__
|
||||
# define g_assert_not_reached __builtin_unreachable
|
||||
#else
|
||||
# ifdef _MSC_VER
|
||||
# define g_assert_not_reached() __assume(0)
|
||||
# else
|
||||
# define g_assert_not_reached()
|
||||
# endif
|
||||
#endif
|
||||
#define g_critical(s, ...) fatal("TinyGLib g_critical(): " s "\n", ##__VA_ARGS__)
|
||||
#ifdef TINYGLIB_DEBUG
|
||||
# define g_debug(s, ...) tinyglib_pclog("g_debug", s, ##__VA_ARGS__)
|
||||
#else
|
||||
# define g_debug(s, ...)
|
||||
#endif
|
||||
#define g_error(s, ...) tinyglib_pclog("g_error", s, ##__VA_ARGS__)
|
||||
#define g_error_free(err)
|
||||
#define g_malloc0(s) calloc(1, s)
|
||||
#define g_new(t, n) (t *) malloc(sizeof(t) * n)
|
||||
#define g_new0(t, n) (t *) calloc(n, sizeof(t))
|
||||
#ifdef TINYGLIB_DEBUG
|
||||
# define g_parse_debug_string(s, k, n) ((!!sizeof(k)) * -1) /* unimplemented; always enables all debug flags */
|
||||
#else
|
||||
# define g_parse_debug_string(s, k, n) (!sizeof(k))
|
||||
#endif
|
||||
#define g_rand_int_range(r, min, max) (rand() % (max + 1 - min) + min)
|
||||
#define g_rand_new() calloc(1, sizeof(GRand))
|
||||
#define g_return_val_if_fail(e, v) if (!(e)) return (v)
|
||||
#define g_shell_parse_argv(a, b, c, d) !!(sizeof(b)) /* unimplemented */
|
||||
#define g_strdup(str) ((str) ? strdup(str) : NULL)
|
||||
#define g_warn_if_fail(e) do { if (!(e)) pclog("TinyGLib g_warn_if_fail(" #e ")\n"); } while (0)
|
||||
#define g_warn_if_reached() pclog("TinyGLib g_warn_if_reached()\n")
|
||||
#define g_warning(s, ...) tinyglib_pclog("g_warning", s, ##__VA_ARGS__)
|
||||
# define GLIB_CHECK_VERSION(a, b, c) 1
|
||||
# ifdef __GNUC__
|
||||
# define G_GNUC_PRINTF(format_idx, arg_idx) __attribute__((__format__(__printf__, format_idx, arg_idx)))
|
||||
# else
|
||||
# define G_GNUC_PRINTF(format_idx, arg_idx)
|
||||
# endif
|
||||
# define G_N_ELEMENTS(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
# define G_STATIC_ASSERT(e) /* this should probably do something */
|
||||
# define G_UNLIKELY(e) (e)
|
||||
|
||||
# define g_assert(e) \
|
||||
do { \
|
||||
if (!(e)) \
|
||||
fatal("TinyGLib g_assert(" #e ")\n"); \
|
||||
} while (0)
|
||||
# ifdef __GNUC__
|
||||
# define g_assert_not_reached __builtin_unreachable
|
||||
# else
|
||||
# ifdef _MSC_VER
|
||||
# define g_assert_not_reached() __assume(0)
|
||||
# else
|
||||
# define g_assert_not_reached()
|
||||
# endif
|
||||
# endif
|
||||
# define g_critical(s, ...) fatal("TinyGLib g_critical(): " s "\n", ##__VA_ARGS__)
|
||||
# ifdef TINYGLIB_DEBUG
|
||||
# define g_debug(s, ...) tinyglib_pclog("g_debug", s, ##__VA_ARGS__)
|
||||
# else
|
||||
# define g_debug(s, ...)
|
||||
# endif
|
||||
# define g_error(s, ...) tinyglib_pclog("g_error", s, ##__VA_ARGS__)
|
||||
# define g_error_free(err)
|
||||
# define g_malloc0(s) calloc(1, s)
|
||||
# define g_new(t, n) (t *) malloc(sizeof(t) * n)
|
||||
# define g_new0(t, n) (t *) calloc(n, sizeof(t))
|
||||
# ifdef TINYGLIB_DEBUG
|
||||
# define g_parse_debug_string(s, k, n) ((!!sizeof(k)) * -1) /* unimplemented; always enables all debug flags */
|
||||
# else
|
||||
# define g_parse_debug_string(s, k, n) (!sizeof(k))
|
||||
# endif
|
||||
# define g_rand_int_range(r, min, max) (rand() % (max + 1 - min) + min)
|
||||
# define g_rand_new() calloc(1, sizeof(GRand))
|
||||
# define g_return_val_if_fail(e, v) \
|
||||
if (!(e)) \
|
||||
return (v)
|
||||
# define g_shell_parse_argv(a, b, c, d) !!(sizeof(b)) /* unimplemented */
|
||||
# define g_strdup(str) ((str) ? strdup(str) : NULL)
|
||||
# define g_warn_if_fail(e) \
|
||||
do { \
|
||||
if (!(e)) \
|
||||
pclog("TinyGLib g_warn_if_fail(" #e ")\n"); \
|
||||
} while (0)
|
||||
# define g_warn_if_reached() pclog("TinyGLib g_warn_if_reached()\n")
|
||||
# define g_warning(s, ...) tinyglib_pclog("g_warning", s, ##__VA_ARGS__)
|
||||
|
||||
/* Remapped functions */
|
||||
#define g_free free
|
||||
#define g_getenv getenv
|
||||
#define g_malloc malloc
|
||||
#define g_rand_free free
|
||||
#define g_realloc realloc
|
||||
#define g_snprintf snprintf
|
||||
#define g_strerror strerror
|
||||
#define g_strfreev free
|
||||
#define g_string_append_printf sprintf /* unimplemented */
|
||||
#define g_vsnprintf vsnprintf
|
||||
|
||||
# define g_free free
|
||||
# define g_getenv getenv
|
||||
# define g_malloc malloc
|
||||
# define g_rand_free free
|
||||
# define g_realloc realloc
|
||||
# define g_snprintf snprintf
|
||||
# define g_strerror strerror
|
||||
# define g_strfreev free
|
||||
# define g_string_append_printf sprintf /* unimplemented */
|
||||
# define g_vsnprintf vsnprintf
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ static const struct {
|
||||
{"plip", &lpt_plip_device },
|
||||
{"dongle_savquest", &lpt_hasp_savquest_device },
|
||||
{"", NULL }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
char *
|
||||
|
||||
@@ -162,10 +162,10 @@ static uint8_t key_queue[16];
|
||||
static int key_queue_start = 0,
|
||||
key_queue_end = 0;
|
||||
static uint8_t crtc_mask[32] = {
|
||||
0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f,
|
||||
0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff,
|
||||
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f,
|
||||
0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff,
|
||||
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
static video_timings_t timing_pc1512 = { VIDEO_BUS, 0, 0, 0, 0, 0, 0 }; /*PC1512 video code handles waitstates itself*/
|
||||
@@ -2551,7 +2551,7 @@ machine_amstrad_init(const machine_t *model, int type)
|
||||
ms_read, NULL, NULL, ms_write, NULL, NULL, ams);
|
||||
|
||||
if (mouse_type == MOUSE_TYPE_INTERNAL) {
|
||||
/* Tell mouse driver about our internal mouse. */
|
||||
/* Tell mouse driver about our internal mouse. */
|
||||
mouse_reset();
|
||||
mouse_set_buttons(2);
|
||||
mouse_set_poll(ms_poll, ams);
|
||||
|
||||
@@ -702,7 +702,7 @@ const device_config_t compaq_plasma_config[] = {
|
||||
}
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const device_t compaq_plasma_device = {
|
||||
|
||||
@@ -336,26 +336,25 @@ machine_xt_pravetz16_imko4_init(const machine_t *model)
|
||||
|
||||
ret = bios_load_linear("roms/machines/pravetz16/BIOS_IMKO4_FE00.BIN",
|
||||
0x000fe000, 65536, 0);
|
||||
if (ret)
|
||||
{
|
||||
if (ret) {
|
||||
bios_load_aux_linear("roms/machines/pravetz16/BIOS_IMKO4_F400.BIN",
|
||||
0x000f4000, 8192, 0);
|
||||
0x000f4000, 8192, 0);
|
||||
|
||||
bios_load_aux_linear("roms/machines/pravetz16/BIOS_IMKO4_F600.BIN",
|
||||
0x000f6000, 8192, 0);
|
||||
0x000f6000, 8192, 0);
|
||||
|
||||
bios_load_aux_linear("roms/machines/pravetz16/BIOS_IMKO4_FA00.BIN",
|
||||
0x000fa000, 8192, 0);
|
||||
0x000fa000, 8192, 0);
|
||||
|
||||
bios_load_aux_linear("roms/machines/pravetz16/BIOS_IMKO4_F800.BIN",
|
||||
0x000f8000, 8192, 0);
|
||||
0x000f8000, 8192, 0);
|
||||
|
||||
bios_load_aux_linear("roms/machines/pravetz16/BIOS_IMKO4_FC00.BIN",
|
||||
0x000fc000, 8192, 0);
|
||||
0x000fc000, 8192, 0);
|
||||
}
|
||||
|
||||
if (bios_only || !ret)
|
||||
return ret;
|
||||
return ret;
|
||||
|
||||
device_add(&keyboard_pravetz_device);
|
||||
|
||||
@@ -367,13 +366,13 @@ machine_xt_pravetz16_imko4_init(const machine_t *model)
|
||||
int
|
||||
machine_xt_micoms_xl7turbo_init(const machine_t *model)
|
||||
{
|
||||
int ret;
|
||||
|
||||
int ret;
|
||||
|
||||
ret = bios_load_linear("roms/machines/mxl7t/XL7_TURBO.BIN",
|
||||
0x000fe000, 8192, 0);
|
||||
0x000fe000, 8192, 0);
|
||||
|
||||
if (bios_only || !ret)
|
||||
return ret;
|
||||
return ret;
|
||||
|
||||
machine_xt_init_ex(model);
|
||||
return ret;
|
||||
@@ -602,14 +601,14 @@ machine_xt_v20xt_init(const machine_t *model)
|
||||
int ret;
|
||||
|
||||
ret = bios_load_linear("roms/machines/v20xt/V20XTBios.bin",
|
||||
0x000fe000, 8192, 0);
|
||||
0x000fe000, 8192, 0);
|
||||
|
||||
if (bios_only || !ret)
|
||||
return ret;
|
||||
return ret;
|
||||
|
||||
machine_xt_clone_init(model);
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -74,43 +74,43 @@
|
||||
#define CGA_COMPOSITE 1
|
||||
|
||||
enum MM58174_ADDR {
|
||||
/* Registers */
|
||||
MM58174_TEST, /* TEST register, write only */
|
||||
MM58174_TENTHS, /* Tenths of second, read only */
|
||||
MM58174_SECOND1, /* Units of seconds, read only */
|
||||
MM58174_SECOND10, /* Tens of seconds, read only */
|
||||
MM58174_MINUTE1,
|
||||
MM58174_MINUTE10,
|
||||
MM58174_HOUR1,
|
||||
MM58174_HOUR10,
|
||||
MM58174_DAY1,
|
||||
MM58174_DAY10,
|
||||
MM58174_WEEKDAY,
|
||||
MM58174_MONTH1,
|
||||
MM58174_MONTH10,
|
||||
MM58174_LEAPYEAR, /* Leap year status, write only */
|
||||
MM58174_RESET, /* RESET register, write only */
|
||||
MM58174_IRQ /* Interrupt register, read / write */
|
||||
/* Registers */
|
||||
MM58174_TEST, /* TEST register, write only */
|
||||
MM58174_TENTHS, /* Tenths of second, read only */
|
||||
MM58174_SECOND1, /* Units of seconds, read only */
|
||||
MM58174_SECOND10, /* Tens of seconds, read only */
|
||||
MM58174_MINUTE1,
|
||||
MM58174_MINUTE10,
|
||||
MM58174_HOUR1,
|
||||
MM58174_HOUR10,
|
||||
MM58174_DAY1,
|
||||
MM58174_DAY10,
|
||||
MM58174_WEEKDAY,
|
||||
MM58174_MONTH1,
|
||||
MM58174_MONTH10,
|
||||
MM58174_LEAPYEAR, /* Leap year status, write only */
|
||||
MM58174_RESET, /* RESET register, write only */
|
||||
MM58174_IRQ /* Interrupt register, read / write */
|
||||
};
|
||||
|
||||
enum MM58274_ADDR {
|
||||
/* Registers */
|
||||
MM58274_CONTROL, /* Control register */
|
||||
MM58274_TENTHS, /* Tenths of second, read only */
|
||||
MM58274_SECOND1,
|
||||
MM58274_SECOND10,
|
||||
MM58274_MINUTE1,
|
||||
MM58274_MINUTE10,
|
||||
MM58274_HOUR1,
|
||||
MM58274_HOUR10,
|
||||
MM58274_DAY1,
|
||||
MM58274_DAY10,
|
||||
MM58274_MONTH1,
|
||||
MM58274_MONTH10,
|
||||
MM58274_YEAR1,
|
||||
MM58274_YEAR10,
|
||||
MM58274_WEEKDAY,
|
||||
MM58274_SETTINGS /* Settings register */
|
||||
/* Registers */
|
||||
MM58274_CONTROL, /* Control register */
|
||||
MM58274_TENTHS, /* Tenths of second, read only */
|
||||
MM58274_SECOND1,
|
||||
MM58274_SECOND10,
|
||||
MM58274_MINUTE1,
|
||||
MM58274_MINUTE10,
|
||||
MM58274_HOUR1,
|
||||
MM58274_HOUR10,
|
||||
MM58274_DAY1,
|
||||
MM58274_DAY10,
|
||||
MM58274_MONTH1,
|
||||
MM58274_MONTH10,
|
||||
MM58274_YEAR1,
|
||||
MM58274_YEAR10,
|
||||
MM58274_WEEKDAY,
|
||||
MM58274_SETTINGS /* Settings register */
|
||||
};
|
||||
|
||||
static struct tm intclk;
|
||||
@@ -124,7 +124,7 @@ typedef struct {
|
||||
uint8_t output_port;
|
||||
uint8_t id;
|
||||
int param,
|
||||
param_total;
|
||||
param_total;
|
||||
uint8_t params[16];
|
||||
uint8_t scan[7];
|
||||
|
||||
@@ -254,14 +254,14 @@ mm58174_start(nvr_t *nvr)
|
||||
static void
|
||||
mm58174_write(uint16_t addr, uint8_t val, void *priv)
|
||||
{
|
||||
nvr_t *nvr = (nvr_t *) priv;
|
||||
nvr_t *nvr = (nvr_t *) priv;
|
||||
|
||||
addr &= 0x0f;
|
||||
val &= 0x0f;
|
||||
|
||||
/* Update non-read-only changed values if not synchronizing time to host */
|
||||
if ((addr != MM58174_TENTHS) && (addr != MM58174_SECOND1) && (addr != MM58174_SECOND10))
|
||||
if ((nvr->regs[addr] != val) && !(time_sync & TIME_SYNC_ENABLED))
|
||||
if ((addr != MM58174_TENTHS) && (addr != MM58174_SECOND1) && (addr != MM58174_SECOND10))
|
||||
if ((nvr->regs[addr] != val) && !(time_sync & TIME_SYNC_ENABLED))
|
||||
nvr_dosave = 1;
|
||||
|
||||
if ((addr == MM58174_RESET) && (val & 0x01)) {
|
||||
@@ -269,7 +269,7 @@ mm58174_write(uint16_t addr, uint8_t val, void *priv)
|
||||
nvr->regs[MM58174_TENTHS] = 0;
|
||||
if (!(time_sync & TIME_SYNC_ENABLED)) {
|
||||
/* Only set seconds to 0 if not synchronizing time to host clock */
|
||||
nvr->regs[MM58174_SECOND1] = 0;
|
||||
nvr->regs[MM58174_SECOND1] = 0;
|
||||
nvr->regs[MM58174_SECOND10] = 0;
|
||||
}
|
||||
}
|
||||
@@ -285,7 +285,7 @@ mm58174_write(uint16_t addr, uint8_t val, void *priv)
|
||||
static uint8_t
|
||||
mm58174_read(uint16_t addr, void *priv)
|
||||
{
|
||||
nvr_t *nvr = (nvr_t *) priv;
|
||||
nvr_t *nvr = (nvr_t *) priv;
|
||||
|
||||
addr &= 0x0f;
|
||||
|
||||
@@ -334,12 +334,12 @@ mm58174_init(nvr_t *nvr, int size)
|
||||
static void
|
||||
mm58274_time_set(uint8_t *regs, struct tm *tm)
|
||||
{
|
||||
regs[MM58274_SECOND1] = (tm->tm_sec % 10);
|
||||
regs[MM58274_SECOND10] = (tm->tm_sec / 10);
|
||||
regs[MM58274_MINUTE1] = (tm->tm_min % 10);
|
||||
regs[MM58274_MINUTE10] = (tm->tm_min / 10);
|
||||
regs[MM58274_HOUR1] = (tm->tm_hour % 10);
|
||||
regs[MM58274_HOUR10] = (tm->tm_hour / 10);
|
||||
regs[MM58274_SECOND1] = (tm->tm_sec % 10);
|
||||
regs[MM58274_SECOND10] = (tm->tm_sec / 10);
|
||||
regs[MM58274_MINUTE1] = (tm->tm_min % 10);
|
||||
regs[MM58274_MINUTE10] = (tm->tm_min / 10);
|
||||
regs[MM58274_HOUR1] = (tm->tm_hour % 10);
|
||||
regs[MM58274_HOUR10] = (tm->tm_hour / 10);
|
||||
/* Store hour in 24-hour or 12-hour mode */
|
||||
if (regs[MM58274_SETTINGS] & 0x01) {
|
||||
regs[MM58274_HOUR1] = (tm->tm_hour % 10);
|
||||
@@ -352,35 +352,35 @@ mm58274_time_set(uint8_t *regs, struct tm *tm)
|
||||
else
|
||||
regs[MM58274_SETTINGS] &= 0x0B;
|
||||
}
|
||||
regs[MM58274_WEEKDAY] = (tm->tm_wday + 1);
|
||||
regs[MM58274_DAY1] = (tm->tm_mday % 10);
|
||||
regs[MM58274_DAY10] = (tm->tm_mday / 10);
|
||||
regs[MM58274_MONTH1] = ((tm->tm_mon + 1) % 10);
|
||||
regs[MM58274_MONTH10] = ((tm->tm_mon + 1) / 10);
|
||||
regs[MM58274_WEEKDAY] = (tm->tm_wday + 1);
|
||||
regs[MM58274_DAY1] = (tm->tm_mday % 10);
|
||||
regs[MM58274_DAY10] = (tm->tm_mday / 10);
|
||||
regs[MM58274_MONTH1] = ((tm->tm_mon + 1) % 10);
|
||||
regs[MM58274_MONTH10] = ((tm->tm_mon + 1) / 10);
|
||||
/* MM58274 can store 00 to 99 years but M240 uses the YEAR1 register to count 8 years from leap year */
|
||||
regs[MM58274_YEAR1] = ((tm->tm_year + 1900) % 8);
|
||||
regs[MM58274_YEAR1] = ((tm->tm_year + 1900) % 8);
|
||||
/* Keep bit 0 and 1 12-hour / 24-hour and AM / PM */
|
||||
regs[MM58274_SETTINGS] &= 0x03;
|
||||
regs[MM58274_SETTINGS] &= 0x03;
|
||||
/* Set leap counter bits 2 and 3 */
|
||||
regs[MM58274_SETTINGS] += (4* (regs[MM58274_YEAR1] & 0x03));
|
||||
regs[MM58274_SETTINGS] += (4 * (regs[MM58274_YEAR1] & 0x03));
|
||||
}
|
||||
|
||||
/* Get the chip time. */
|
||||
static void
|
||||
mm58274_time_get(uint8_t *regs, struct tm *tm)
|
||||
{
|
||||
tm->tm_sec = nibbles(MM58274_SECOND);
|
||||
tm->tm_min = nibbles(MM58274_MINUTE);
|
||||
tm->tm_sec = nibbles(MM58274_SECOND);
|
||||
tm->tm_min = nibbles(MM58274_MINUTE);
|
||||
/* Read hour in 24-hour or 12-hour mode */
|
||||
if (regs[MM58274_SETTINGS] & 0x01)
|
||||
tm->tm_hour = nibbles(MM58274_HOUR);
|
||||
else
|
||||
tm->tm_hour = ((nibbles(MM58274_HOUR) % 12) + (regs[MM58274_SETTINGS] & 0x04) ? 12 : 0);
|
||||
tm->tm_wday = (regs[MM58274_WEEKDAY] - 1);
|
||||
tm->tm_mday = nibbles(MM58274_DAY);
|
||||
tm->tm_mon = (nibbles(MM58274_MONTH) - 1);
|
||||
tm->tm_wday = (regs[MM58274_WEEKDAY] - 1);
|
||||
tm->tm_mday = nibbles(MM58274_DAY);
|
||||
tm->tm_mon = (nibbles(MM58274_MONTH) - 1);
|
||||
/* MM58274 can store 00 to 99 years but M240 uses the YEAR1 register to count 8 years from leap year */
|
||||
tm->tm_year = (1984 + regs[MM58274_YEAR1] - 1900);
|
||||
tm->tm_year = (1984 + regs[MM58274_YEAR1] - 1900);
|
||||
}
|
||||
|
||||
/* This is called every second through the NVR/RTC hook. */
|
||||
@@ -413,14 +413,14 @@ mm58274_start(nvr_t *nvr)
|
||||
static void
|
||||
mm58274_write(uint16_t addr, uint8_t val, void *priv)
|
||||
{
|
||||
nvr_t *nvr = (nvr_t *) priv;
|
||||
nvr_t *nvr = (nvr_t *) priv;
|
||||
|
||||
addr &= 0x0f;
|
||||
val &= 0x0f;
|
||||
|
||||
/* Update non-read-only changed values if not synchronizing time to host */
|
||||
if ((addr != MM58274_TENTHS))
|
||||
if ((nvr->regs[addr] != val) && !(time_sync & TIME_SYNC_ENABLED))
|
||||
if ((nvr->regs[addr] != val) && !(time_sync & TIME_SYNC_ENABLED))
|
||||
nvr_dosave = 1;
|
||||
|
||||
if ((addr == MM58274_CONTROL) && (val & 0x04)) {
|
||||
@@ -439,7 +439,7 @@ mm58274_write(uint16_t addr, uint8_t val, void *priv)
|
||||
static uint8_t
|
||||
mm58274_read(uint16_t addr, void *priv)
|
||||
{
|
||||
nvr_t *nvr = (nvr_t *) priv;
|
||||
nvr_t *nvr = (nvr_t *) priv;
|
||||
|
||||
addr &= 0x0f;
|
||||
|
||||
@@ -517,7 +517,7 @@ m24_kbd_adddata_ex(uint16_t val)
|
||||
kbd_adddata_process(val, m24_kbd_adddata);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
From the Olivetti M21/M24 Theory of Operation:
|
||||
|
||||
Port Function
|
||||
@@ -535,7 +535,7 @@ static void
|
||||
m24_kbd_write(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
m24_kbd_t *m24_kbd = (m24_kbd_t *) priv;
|
||||
uint8_t ret;
|
||||
uint8_t ret;
|
||||
|
||||
xt_olivetti_log("M24: write %04X %02X\n", port, val);
|
||||
|
||||
@@ -1831,7 +1831,7 @@ machine_xt_m24_init(const machine_t *model)
|
||||
int
|
||||
machine_xt_m240_init(const machine_t *model)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
m24_kbd_t *m24_kbd;
|
||||
nvr_t *nvr;
|
||||
|
||||
|
||||
@@ -723,7 +723,7 @@ static const device_config_t t1000_config[] = {
|
||||
.default_int = 0
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const device_t t1000_video_device = {
|
||||
|
||||
@@ -156,7 +156,7 @@ static const device_config_t xi8088_config[] = {
|
||||
.default_int = 0
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const device_t xi8088_device = {
|
||||
|
||||
@@ -11969,8 +11969,8 @@ const machine_t machines[] = {
|
||||
|
||||
/* Saved copies - jumpers get applied to these.
|
||||
We use also machine_gpio to store IBM PC/XT jumpers as they need more than one byte. */
|
||||
static uint16_t machine_p1;
|
||||
static uint32_t machine_gpio;
|
||||
static uint16_t machine_p1;
|
||||
static uint32_t machine_gpio;
|
||||
|
||||
uint8_t
|
||||
machine_get_p1(void)
|
||||
@@ -12005,97 +12005,97 @@ machine_set_gpio(uint32_t gpio)
|
||||
int
|
||||
machine_count(void)
|
||||
{
|
||||
return((sizeof(machines) / sizeof(machine_t)) - 1);
|
||||
return ((sizeof(machines) / sizeof(machine_t)) - 1);
|
||||
}
|
||||
|
||||
char *
|
||||
machine_getname(void)
|
||||
{
|
||||
return((char *)machines[machine].name);
|
||||
return ((char *) machines[machine].name);
|
||||
}
|
||||
|
||||
char *
|
||||
machine_getname_ex(int m)
|
||||
{
|
||||
return((char *)machines[m].name);
|
||||
return ((char *) machines[m].name);
|
||||
}
|
||||
|
||||
const device_t *
|
||||
machine_getdevice(int m)
|
||||
{
|
||||
if (machines[m].device)
|
||||
return(machines[m].device);
|
||||
return (machines[m].device);
|
||||
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const device_t *
|
||||
machine_getviddevice(int m)
|
||||
{
|
||||
if (machines[m].vid_device)
|
||||
return(machines[m].vid_device);
|
||||
return (machines[m].vid_device);
|
||||
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const device_t *
|
||||
machine_getsnddevice(int m)
|
||||
{
|
||||
if (machines[m].snd_device)
|
||||
return(machines[m].snd_device);
|
||||
return (machines[m].snd_device);
|
||||
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const device_t *
|
||||
machine_getnetdevice(int m)
|
||||
{
|
||||
if (machines[m].net_device)
|
||||
return(machines[m].net_device);
|
||||
return (machines[m].net_device);
|
||||
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
machine_get_internal_name(void)
|
||||
{
|
||||
return((char *)machines[machine].internal_name);
|
||||
return ((char *) machines[machine].internal_name);
|
||||
}
|
||||
|
||||
char *
|
||||
machine_get_internal_name_ex(int m)
|
||||
{
|
||||
return((char *)machines[m].internal_name);
|
||||
return ((char *) machines[m].internal_name);
|
||||
}
|
||||
|
||||
int
|
||||
machine_get_nvrmask(int m)
|
||||
{
|
||||
return(machines[m].nvrmask);
|
||||
return (machines[m].nvrmask);
|
||||
}
|
||||
|
||||
int
|
||||
machine_has_flags(int m, int flags)
|
||||
{
|
||||
return(machines[m].flags & flags);
|
||||
return (machines[m].flags & flags);
|
||||
}
|
||||
|
||||
int
|
||||
machine_has_bus(int m, int bus_flags)
|
||||
{
|
||||
return(machines[m].bus_flags & bus_flags);
|
||||
return (machines[m].bus_flags & bus_flags);
|
||||
}
|
||||
|
||||
int
|
||||
machine_has_cartridge(int m)
|
||||
{
|
||||
return(machine_has_bus(m, MACHINE_CARTRIDGE) ? 1 : 0);
|
||||
return (machine_has_bus(m, MACHINE_CARTRIDGE) ? 1 : 0);
|
||||
}
|
||||
|
||||
int
|
||||
machine_get_min_ram(int m)
|
||||
{
|
||||
return(machines[m].ram.min);
|
||||
return (machines[m].ram.min);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -12111,13 +12111,13 @@ machine_get_max_ram(int m)
|
||||
int
|
||||
machine_get_ram_granularity(int m)
|
||||
{
|
||||
return(machines[m].ram.step);
|
||||
return (machines[m].ram.step);
|
||||
}
|
||||
|
||||
int
|
||||
machine_get_type(int m)
|
||||
{
|
||||
return(machines[m].type);
|
||||
return (machines[m].type);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -12126,16 +12126,16 @@ machine_get_machine_from_internal_name(char *s)
|
||||
int c = 0;
|
||||
|
||||
while (machines[c].init != NULL) {
|
||||
if (!strcmp(machines[c].internal_name, (const char *)s))
|
||||
return(c);
|
||||
if (!strcmp(machines[c].internal_name, (const char *) s))
|
||||
return (c);
|
||||
c++;
|
||||
}
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
machine_has_mouse(void)
|
||||
{
|
||||
return(machines[machine].flags & MACHINE_MOUSE);
|
||||
return (machines[machine].flags & MACHINE_MOUSE);
|
||||
}
|
||||
|
||||
@@ -55,12 +55,12 @@
|
||||
#endif
|
||||
|
||||
mem_mapping_t ram_low_mapping, /* 0..640K mapping */
|
||||
ram_mid_mapping, /* 640..1024K mapping */
|
||||
ram_mid_mapping2, /* 640..1024K mapping, second part, for SiS 471 in relocate mode */
|
||||
ram_remapped_mapping, /* 640..1024K mapping */
|
||||
ram_remapped_mapping2,/* 640..1024K second mapping, for SiS 471 mode */
|
||||
ram_high_mapping, /* 1024K+ mapping */
|
||||
ram_2gb_mapping, /* 1024M+ mapping */
|
||||
ram_mid_mapping, /* 640..1024K mapping */
|
||||
ram_mid_mapping2, /* 640..1024K mapping, second part, for SiS 471 in relocate mode */
|
||||
ram_remapped_mapping, /* 640..1024K mapping */
|
||||
ram_remapped_mapping2, /* 640..1024K second mapping, for SiS 471 mode */
|
||||
ram_high_mapping, /* 1024K+ mapping */
|
||||
ram_2gb_mapping, /* 1024M+ mapping */
|
||||
ram_split_mapping,
|
||||
bios_mapping,
|
||||
bios_high_mapping;
|
||||
@@ -2806,9 +2806,9 @@ mem_remap_top(int kb)
|
||||
uint32_t c;
|
||||
uint32_t start = (mem_size >= 1024) ? mem_size : 1024;
|
||||
int offset, size = mem_size - 640;
|
||||
int set = 1;
|
||||
static int old_kb = 0;
|
||||
int sis_mode = 0;
|
||||
int set = 1;
|
||||
static int old_kb = 0;
|
||||
int sis_mode = 0;
|
||||
uint32_t start_addr = 0, addr = 0;
|
||||
|
||||
mem_log("MEM: remapping top %iKB (mem=%i)\n", kb, mem_size);
|
||||
@@ -2817,7 +2817,7 @@ mem_remap_top(int kb)
|
||||
|
||||
/* SiS 471 special mode. */
|
||||
if (kb == -256) {
|
||||
kb = 256;
|
||||
kb = 256;
|
||||
sis_mode = 1;
|
||||
}
|
||||
|
||||
@@ -2830,11 +2830,11 @@ mem_remap_top(int kb)
|
||||
if (size > kb)
|
||||
size = kb;
|
||||
|
||||
remap_start_addr = start << 10;
|
||||
remap_start_addr = start << 10;
|
||||
remap_start_addr2 = (start << 10) + 0x00020000;
|
||||
|
||||
for (c = ((start * 1024) >> 12); c < (((start + size) * 1024) >> 12); c++) {
|
||||
offset = c - ((start * 1024) >> 12);
|
||||
offset = c - ((start * 1024) >> 12);
|
||||
/* Use A0000-BFFFF, D0000-EFFFF instead of C0000-DFFFF, E0000-FFFFF. */
|
||||
addr = 0xa0000 + (offset << 12);
|
||||
if (sis_mode) {
|
||||
@@ -2858,8 +2858,8 @@ mem_remap_top(int kb)
|
||||
mem_set_mem_state_both(start * 1024, size * 1024, set ? (MEM_READ_INTERNAL | MEM_WRITE_INTERNAL) : (MEM_READ_EXTERNAL | MEM_WRITE_EXTERNAL));
|
||||
|
||||
for (c = 0xa0; c < 0xf0; c++) {
|
||||
if ((c >= 0xc0) && (c <= 0xcf))
|
||||
continue;
|
||||
if ((c >= 0xc0) && (c <= 0xcf))
|
||||
continue;
|
||||
|
||||
if (sis_mode || ((c << 12) >= (mem_size << 10)))
|
||||
pages[c].mem = page_ff;
|
||||
|
||||
@@ -756,11 +756,11 @@ padr_match(nic_t *dev, const uint8_t *buf, int size)
|
||||
result = !CSR_DRCVPA(dev) && !memcmp(hdr->ether_dhost, padr, 6);
|
||||
|
||||
pcnet_log(3, "%s: packet dhost=%02x:%02x:%02x:%02x:%02x:%02x, "
|
||||
"padr=%02x:%02x:%02x:%02x:%02x:%02x => %d\n",
|
||||
dev->name,
|
||||
hdr->ether_dhost[0], hdr->ether_dhost[1], hdr->ether_dhost[2],
|
||||
hdr->ether_dhost[3], hdr->ether_dhost[4], hdr->ether_dhost[5],
|
||||
padr[0], padr[1], padr[2], padr[3], padr[4], padr[5], result);
|
||||
"padr=%02x:%02x:%02x:%02x:%02x:%02x => %d\n",
|
||||
dev->name,
|
||||
hdr->ether_dhost[0], hdr->ether_dhost[1], hdr->ether_dhost[2],
|
||||
hdr->ether_dhost[3], hdr->ether_dhost[4], hdr->ether_dhost[5],
|
||||
padr[0], padr[1], padr[2], padr[3], padr[4], padr[5], result);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -944,13 +944,13 @@ pcnetInit(nic_t *dev)
|
||||
dev->GCUpperPhys = 0;
|
||||
PCNET_INIT();
|
||||
pcnet_log(3, "%s: initblk.rlen=%#04x, initblk.tlen=%#04x\n",
|
||||
dev->name, initblk.rlen, initblk.tlen);
|
||||
dev->name, initblk.rlen, initblk.tlen);
|
||||
} else {
|
||||
struct INITBLK16 initblk;
|
||||
dev->GCUpperPhys = (0xff00 & (uint32_t) dev->aCSR[2]) << 16;
|
||||
PCNET_INIT();
|
||||
pcnet_log(3, "%s: initblk.rlen=%#04x, initblk.tlen=%#04x\n",
|
||||
dev->name, initblk.rlen, initblk.tlen);
|
||||
dev->name, initblk.rlen, initblk.tlen);
|
||||
}
|
||||
|
||||
#undef PCNET_INIT
|
||||
@@ -985,9 +985,9 @@ pcnetInit(nic_t *dev)
|
||||
CSR_CXST(dev) = CSR_CXBC(dev) = CSR_NXST(dev) = CSR_NXBC(dev) = 0;
|
||||
|
||||
pcnet_log(1, "%s: Init: SWSTYLE=%d GCRDRA=%#010x[%d] GCTDRA=%#010x[%d]%s\n",
|
||||
dev->name, BCR_SWSTYLE(dev),
|
||||
dev->GCRDRA, CSR_RCVRL(dev), dev->GCTDRA, CSR_XMTRL(dev),
|
||||
!dev->fSignalRxMiss ? " (CSR0_MISS disabled)" : "");
|
||||
dev->name, BCR_SWSTYLE(dev),
|
||||
dev->GCRDRA, CSR_RCVRL(dev), dev->GCTDRA, CSR_XMTRL(dev),
|
||||
!dev->fSignalRxMiss ? " (CSR0_MISS disabled)" : "");
|
||||
|
||||
if (dev->GCRDRA & (dev->iLog2DescSize - 1))
|
||||
pcnet_log(1, "%s: Warning: Misaligned RDRA\n", dev->name);
|
||||
@@ -1072,7 +1072,7 @@ pcnetRdtePoll(nic_t *dev)
|
||||
*/
|
||||
if (++dev->uCntBadRMD < 50)
|
||||
pcnet_log(1, "%s: BAD RMD ENTRIES AT %#010x (i=%d)\n",
|
||||
dev->name, addr, i);
|
||||
dev->name, addr, i);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1098,7 +1098,7 @@ pcnetRdtePoll(nic_t *dev)
|
||||
*/
|
||||
if (++dev->uCntBadRMD < 50)
|
||||
pcnet_log(1, "%s: BAD RMD ENTRIES + AT %#010x (i=%d)\n",
|
||||
dev->name, addr, i);
|
||||
dev->name, addr, i);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1126,7 +1126,7 @@ pcnetTdtePoll(nic_t *dev, TMD *tmd)
|
||||
|
||||
if (tmd->tmd1.ones != 15) {
|
||||
pcnet_log(1, "%s: BAD TMD XDA=%#010x\n",
|
||||
dev->name, PHYSADDR(dev, cxda));
|
||||
dev->name, PHYSADDR(dev, cxda));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1182,7 +1182,7 @@ pcnetCalcPacketLen(nic_t *dev, int cb)
|
||||
}
|
||||
if (tmd.tmd1.ones != 15) {
|
||||
pcnet_log(1, "%s: BAD TMD XDA=%#010x\n",
|
||||
dev->name, PHYSADDR(dev, addrDesc));
|
||||
dev->name, PHYSADDR(dev, addrDesc));
|
||||
pcnet_log(3, "%s: pcnetCalcPacketLen: bad TMD, return %u\n", dev->name, cbPacket);
|
||||
return cbPacket;
|
||||
}
|
||||
@@ -1228,9 +1228,9 @@ pcnetReceiveNoSync(void *priv, uint8_t *buf, int size)
|
||||
return 0;
|
||||
|
||||
pcnet_log(1, "%s: pcnetReceiveNoSync: RX %x:%x:%x:%x:%x:%x > %x:%x:%x:%x:%x:%x len %d\n", dev->name,
|
||||
buf[6], buf[7], buf[8], buf[9], buf[10], buf[11],
|
||||
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
|
||||
size);
|
||||
buf[6], buf[7], buf[8], buf[9], buf[10], buf[11],
|
||||
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
|
||||
size);
|
||||
|
||||
/*
|
||||
* Perform address matching.
|
||||
@@ -1411,7 +1411,7 @@ pcnetReceiveNoSync(void *priv, uint8_t *buf, int size)
|
||||
|
||||
dev->aCSR[0] |= 0x0400;
|
||||
pcnet_log(1, "%s: RINT set, RCVRC=%d CRDA=%#010x\n", dev->name,
|
||||
CSR_RCVRC(dev), PHYSADDR(dev, CSR_CRDA(dev)));
|
||||
CSR_RCVRC(dev), PHYSADDR(dev, CSR_CRDA(dev)));
|
||||
|
||||
/* guest driver is owner: force repoll of current and next RDTEs */
|
||||
CSR_CRST(dev) = 0;
|
||||
@@ -1574,7 +1574,7 @@ pcnetAsyncTransmit(nic_t *dev)
|
||||
CSR_XMTRC(dev) = CSR_XMTRL(dev);
|
||||
else
|
||||
CSR_XMTRC(dev)
|
||||
--;
|
||||
--;
|
||||
|
||||
TMD dummy;
|
||||
if (!pcnetTdtePoll(dev, &dummy)) {
|
||||
@@ -1629,7 +1629,7 @@ pcnetAsyncTransmit(nic_t *dev)
|
||||
CSR_XMTRC(dev) = CSR_XMTRL(dev);
|
||||
else
|
||||
CSR_XMTRC(dev)
|
||||
--;
|
||||
--;
|
||||
break;
|
||||
}
|
||||
} /* the loop */
|
||||
@@ -1897,7 +1897,7 @@ pcnet_csr_writew(nic_t *dev, uint16_t rap, uint16_t val)
|
||||
return;
|
||||
}
|
||||
pcnet_log(3, "%s: WRITE CSR%d, %#06x (hacked %#06x) (alt init)\n", dev->name,
|
||||
rap, val, 1 + ~val);
|
||||
rap, val, 1 + ~val);
|
||||
val = 1 + ~val;
|
||||
|
||||
/*
|
||||
@@ -2984,12 +2984,12 @@ pcnet_init(const device_t *info)
|
||||
}
|
||||
|
||||
pcnet_log(2, "%s: I/O=%04x, IRQ=%d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
dev->name, dev->base_address, dev->base_irq,
|
||||
dev->aPROM[0], dev->aPROM[1], dev->aPROM[2],
|
||||
dev->aPROM[3], dev->aPROM[4], dev->aPROM[5]);
|
||||
dev->name, dev->base_address, dev->base_irq,
|
||||
dev->aPROM[0], dev->aPROM[1], dev->aPROM[2],
|
||||
dev->aPROM[3], dev->aPROM[4], dev->aPROM[5]);
|
||||
|
||||
pcnet_log(1, "%s: %s attached IO=0x%X IRQ=%d\n", dev->name,
|
||||
dev->is_pci ? "PCI" : "VLB/ISA", dev->base_address, dev->base_irq);
|
||||
dev->is_pci ? "PCI" : "VLB/ISA", dev->base_address, dev->base_irq);
|
||||
|
||||
/* Reset the board. */
|
||||
pcnetHardReset(dev);
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <86box/config.h>
|
||||
#include <86box/video.h>
|
||||
|
||||
# define _SSIZE_T_DEFINED
|
||||
#define _SSIZE_T_DEFINED
|
||||
#include <slirp/libslirp.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
#include <wchar.h>
|
||||
#include <time.h>
|
||||
#ifndef _WIN32
|
||||
#include <sys/time.h>
|
||||
# include <sys/time.h>
|
||||
#endif /* _WIN32 */
|
||||
#include <stdbool.h>
|
||||
#define HAVE_STDARG_H
|
||||
@@ -126,7 +126,7 @@ netdev_t network_devs[NET_HOST_INTF_MAX];
|
||||
|
||||
/* Local variables. */
|
||||
|
||||
#if defined ENABLE_NETWORK_LOG && !defined(_WIN32)
|
||||
#if defined ENABLE_NETWORK_LOG && !defined(_WIN32)
|
||||
int network_do_log = ENABLE_NETWORK_LOG;
|
||||
static FILE *network_dump = NULL;
|
||||
static mutex_t *network_dump_mutex;
|
||||
|
||||
@@ -288,7 +288,7 @@ main(int argc, char **argv)
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Looks good, go and listen.. */
|
||||
/* Looks good, go and listen.. */
|
||||
i = start_cap(interfaces[i - 1].device);
|
||||
|
||||
dynld_close(pcap_handle);
|
||||
|
||||
@@ -28,18 +28,16 @@ g_spawn_async_with_fds(const gchar *working_directory, gchar **argv,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Needs bounds checking, but not really used by libslirp. */
|
||||
GString *
|
||||
g_string_new(gchar *base)
|
||||
{
|
||||
char *ret = malloc(4096);
|
||||
if (base)
|
||||
strcpy(ret, base);
|
||||
strcpy(ret, base);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* Unimplemented, as with anything related to GString. */
|
||||
gchar *
|
||||
g_string_free(GString *string, gboolean free_segment)
|
||||
@@ -47,87 +45,84 @@ g_string_free(GString *string, gboolean free_segment)
|
||||
return (free_segment ? NULL : string);
|
||||
}
|
||||
|
||||
|
||||
/* Implementation borrowed from GLib itself. */
|
||||
gchar *
|
||||
g_strstr_len(const gchar *haystack, gssize haystack_len, const gchar *needle)
|
||||
{
|
||||
if (haystack_len < 0)
|
||||
return strstr(haystack, needle);
|
||||
return strstr(haystack, needle);
|
||||
else {
|
||||
const gchar *p = haystack;
|
||||
gsize needle_len = strlen(needle);
|
||||
gsize haystack_len_unsigned = haystack_len;
|
||||
const gchar *end;
|
||||
gsize i;
|
||||
const gchar *p = haystack;
|
||||
gsize needle_len = strlen(needle);
|
||||
gsize haystack_len_unsigned = haystack_len;
|
||||
const gchar *end;
|
||||
gsize i;
|
||||
|
||||
if (needle_len == 0)
|
||||
return (gchar *) haystack;
|
||||
if (needle_len == 0)
|
||||
return (gchar *) haystack;
|
||||
|
||||
if (haystack_len_unsigned < needle_len)
|
||||
return NULL;
|
||||
if (haystack_len_unsigned < needle_len)
|
||||
return NULL;
|
||||
|
||||
end = haystack + haystack_len - needle_len;
|
||||
end = haystack + haystack_len - needle_len;
|
||||
|
||||
while (p <= end && *p) {
|
||||
for (i = 0; i < needle_len; i++)
|
||||
if (p[i] != needle[i])
|
||||
goto next;
|
||||
while (p <= end && *p) {
|
||||
for (i = 0; i < needle_len; i++)
|
||||
if (p[i] != needle[i])
|
||||
goto next;
|
||||
|
||||
return (gchar *)p;
|
||||
return (gchar *) p;
|
||||
|
||||
next:
|
||||
p++;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Implementation borrowed from GLib itself. */
|
||||
guint
|
||||
g_strv_length(gchar **str_array)
|
||||
{
|
||||
guint i = 0;
|
||||
while (str_array[i] != NULL)
|
||||
++i;
|
||||
++i;
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Implementation borrowed from GLib itself. */
|
||||
gsize
|
||||
g_strlcpy (gchar *dest,
|
||||
const gchar *src,
|
||||
gsize dest_size)
|
||||
g_strlcpy(gchar *dest,
|
||||
const gchar *src,
|
||||
gsize dest_size)
|
||||
{
|
||||
gchar *d = dest;
|
||||
const gchar *s = src;
|
||||
gsize n = dest_size;
|
||||
gchar *d = dest;
|
||||
const gchar *s = src;
|
||||
gsize n = dest_size;
|
||||
|
||||
if (dest == NULL) return 0;
|
||||
if (src == NULL) return 0;
|
||||
if (dest == NULL)
|
||||
return 0;
|
||||
if (src == NULL)
|
||||
return 0;
|
||||
|
||||
/* Copy as many bytes as will fit */
|
||||
if (n != 0 && --n != 0)
|
||||
do
|
||||
{
|
||||
gchar c = *s++;
|
||||
/* Copy as many bytes as will fit */
|
||||
if (n != 0 && --n != 0)
|
||||
do {
|
||||
gchar c = *s++;
|
||||
|
||||
*d++ = c;
|
||||
if (c == 0)
|
||||
break;
|
||||
}
|
||||
while (--n != 0);
|
||||
*d++ = c;
|
||||
if (c == 0)
|
||||
break;
|
||||
} while (--n != 0);
|
||||
|
||||
/* If not enough room in dest, add NUL and traverse rest of src */
|
||||
if (n == 0)
|
||||
{
|
||||
if (dest_size != 0)
|
||||
*d = 0;
|
||||
while (*s++)
|
||||
;
|
||||
/* If not enough room in dest, add NUL and traverse rest of src */
|
||||
if (n == 0) {
|
||||
if (dest_size != 0)
|
||||
*d = 0;
|
||||
while (*s++)
|
||||
;
|
||||
}
|
||||
|
||||
return s - src - 1; /* count does not include NUL */
|
||||
return s - src - 1; /* count does not include NUL */
|
||||
}
|
||||
|
||||
16
src/pci.c
16
src/pci.c
@@ -404,9 +404,9 @@ pci_set_pmc(uint8_t pmc)
|
||||
io_sethandler(0x0cf8, 1,
|
||||
NULL, NULL, pci_cf8_read, NULL, NULL, pci_cf8_write, NULL);
|
||||
io_sethandler(0x0cfa, 1,
|
||||
pci_type2_read,NULL,NULL, pci_type2_write,NULL,NULL, NULL);
|
||||
pci_type2_read, NULL, NULL, pci_type2_write, NULL, NULL, NULL);
|
||||
io_sethandler(0x0cfc, 4,
|
||||
pci_read,pci_readw,pci_readl, pci_write,pci_writew,pci_writel, NULL);
|
||||
pci_read, pci_readw, pci_readl, pci_write, pci_writew, pci_writel, NULL);
|
||||
} else if (pci_pmc && !(pmc & 0x01)) {
|
||||
io_removehandler(pci_base, pci_size,
|
||||
pci_type2_read, NULL, NULL,
|
||||
@@ -420,9 +420,9 @@ pci_set_pmc(uint8_t pmc)
|
||||
io_removehandler(0x0cf8, 1,
|
||||
NULL, NULL, pci_cf8_read, NULL, NULL, pci_cf8_write, NULL);
|
||||
io_removehandler(0x0cfa, 1,
|
||||
pci_type2_read,NULL,NULL, pci_type2_write,NULL,NULL, NULL);
|
||||
pci_type2_read, NULL, NULL, pci_type2_write, NULL, NULL, NULL);
|
||||
io_removehandler(0x0cfc, 4,
|
||||
pci_read,pci_readw,pci_readl, pci_write,pci_writew,pci_writel, NULL);
|
||||
pci_read, pci_readw, pci_readl, pci_write, pci_writew, pci_writel, NULL);
|
||||
io_sethandler(0x0cf8, 1,
|
||||
pci_type2_read, NULL, NULL, pci_type2_write, NULL, NULL, NULL);
|
||||
io_sethandler(0x0cfa, 1,
|
||||
@@ -509,7 +509,7 @@ static uint8_t
|
||||
pci_type2_read(uint16_t port, void *priv)
|
||||
{
|
||||
uint8_t slot = 0;
|
||||
uint8_t ret = 0xff;
|
||||
uint8_t ret = 0xff;
|
||||
|
||||
if (port == 0xcf8)
|
||||
ret = pci_key | (pci_func << 1);
|
||||
@@ -862,11 +862,11 @@ pci_reset(void)
|
||||
io_removehandler(0x0cf8, 1,
|
||||
NULL, NULL, pci_cf8_read, NULL, NULL, pci_cf8_write, NULL);
|
||||
io_removehandler(0x0cfc, 4,
|
||||
pci_read,pci_readw,pci_readl, pci_write,pci_writew,pci_writel, NULL);
|
||||
pci_read, pci_readw, pci_readl, pci_write, pci_writew, pci_writel, NULL);
|
||||
io_removehandler(0x0cf8, 1,
|
||||
pci_type2_read,NULL,NULL, pci_type2_write,NULL,NULL, NULL);
|
||||
pci_type2_read, NULL, NULL, pci_type2_write, NULL, NULL, NULL);
|
||||
io_removehandler(0x0cfa, 1,
|
||||
pci_type2_read,NULL,NULL, pci_type2_write,NULL,NULL, NULL);
|
||||
pci_type2_read, NULL, NULL, pci_type2_write, NULL, NULL, NULL);
|
||||
io_sethandler(0x0cf8, 1,
|
||||
pci_type2_read, NULL, NULL, pci_type2_write, NULL, NULL, NULL);
|
||||
io_sethandler(0x0cfa, 1,
|
||||
|
||||
@@ -124,7 +124,7 @@ error:
|
||||
png_log("PNG: fatal error, bailing out, error = %i\n", errno);
|
||||
if (png != NULL)
|
||||
PNGFUNC(destroy_write_struct)
|
||||
(&png, &info);
|
||||
(&png, &info);
|
||||
if (fp != NULL)
|
||||
(void) fclose(fp);
|
||||
return (0);
|
||||
@@ -206,7 +206,7 @@ png_write_rgb(char *fn, uint8_t *pix, int16_t w, int16_t h, uint16_t pitch, PALE
|
||||
error:
|
||||
if (png != NULL)
|
||||
PNGFUNC(destroy_write_struct)
|
||||
(&png, &info);
|
||||
(&png, &info);
|
||||
if (fp != NULL)
|
||||
(void) fclose(fp);
|
||||
return;
|
||||
|
||||
@@ -350,7 +350,7 @@ ps_init(void *lpt)
|
||||
}
|
||||
}
|
||||
|
||||
/* Cache print folder path. */
|
||||
/* Cache print folder path. */
|
||||
memset(dev->printer_path, 0x00, sizeof(dev->printer_path));
|
||||
path_append_filename(dev->printer_path, usr_path, "printer");
|
||||
if (!plat_dir_check(dev->printer_path))
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
#include <QByteArray>
|
||||
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
#define result_t qintptr
|
||||
# define result_t qintptr
|
||||
#else
|
||||
#define result_t long
|
||||
# define result_t long
|
||||
#endif
|
||||
|
||||
class CocoaEventFilter : public QAbstractNativeEventFilter
|
||||
{
|
||||
class CocoaEventFilter : public QAbstractNativeEventFilter {
|
||||
public:
|
||||
CocoaEventFilter() {};
|
||||
~CocoaEventFilter();
|
||||
|
||||
@@ -26,63 +26,59 @@
|
||||
|
||||
#include <QThread>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/mouse.h>
|
||||
#include <poll.h>
|
||||
}
|
||||
|
||||
static std::vector<std::pair<int, libevdev*>> evdev_mice;
|
||||
static std::atomic<bool> stopped = false;
|
||||
static QThread* evdev_thread;
|
||||
static std::vector<std::pair<int, libevdev *>> evdev_mice;
|
||||
static std::atomic<bool> stopped = false;
|
||||
static QThread *evdev_thread;
|
||||
|
||||
static std::atomic<int> evdev_mouse_rel_x = 0, evdev_mouse_rel_y = 0;
|
||||
|
||||
void evdev_mouse_poll()
|
||||
void
|
||||
evdev_mouse_poll()
|
||||
{
|
||||
if (!evdev_mice.size() || !mouse_capture)
|
||||
{
|
||||
if (!evdev_mice.size() || !mouse_capture) {
|
||||
evdev_mouse_rel_x = 0;
|
||||
evdev_mouse_rel_y = 0;
|
||||
return;
|
||||
}
|
||||
mouse_x = evdev_mouse_rel_x;
|
||||
mouse_y = evdev_mouse_rel_y;
|
||||
mouse_x = evdev_mouse_rel_x;
|
||||
mouse_y = evdev_mouse_rel_y;
|
||||
evdev_mouse_rel_x = evdev_mouse_rel_y = 0;
|
||||
}
|
||||
|
||||
void evdev_thread_func()
|
||||
void
|
||||
evdev_thread_func()
|
||||
{
|
||||
struct pollfd *pfds = (struct pollfd*)calloc(evdev_mice.size(), sizeof(struct pollfd));
|
||||
for (unsigned int i = 0; i < evdev_mice.size(); i++)
|
||||
{
|
||||
pfds[i].fd = libevdev_get_fd(evdev_mice[i].second);
|
||||
struct pollfd *pfds = (struct pollfd *) calloc(evdev_mice.size(), sizeof(struct pollfd));
|
||||
for (unsigned int i = 0; i < evdev_mice.size(); i++) {
|
||||
pfds[i].fd = libevdev_get_fd(evdev_mice[i].second);
|
||||
pfds[i].events = POLLIN;
|
||||
}
|
||||
|
||||
while (!stopped)
|
||||
{
|
||||
while (!stopped) {
|
||||
poll(pfds, evdev_mice.size(), 500);
|
||||
for (unsigned int i = 0; i < evdev_mice.size(); i++)
|
||||
{
|
||||
for (unsigned int i = 0; i < evdev_mice.size(); i++) {
|
||||
struct input_event ev;
|
||||
if (pfds[i].revents & POLLIN) {
|
||||
while (libevdev_next_event(evdev_mice[i].second, LIBEVDEV_READ_FLAG_NORMAL, &ev) == 0)
|
||||
{
|
||||
if (ev.type == EV_REL && mouse_capture)
|
||||
{
|
||||
if (ev.code == REL_X) evdev_mouse_rel_x += ev.value;
|
||||
if (ev.code == REL_Y) evdev_mouse_rel_y += ev.value;
|
||||
while (libevdev_next_event(evdev_mice[i].second, LIBEVDEV_READ_FLAG_NORMAL, &ev) == 0) {
|
||||
if (ev.type == EV_REL && mouse_capture) {
|
||||
if (ev.code == REL_X)
|
||||
evdev_mouse_rel_x += ev.value;
|
||||
if (ev.code == REL_Y)
|
||||
evdev_mouse_rel_y += ev.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < evdev_mice.size(); i++)
|
||||
{
|
||||
for (unsigned int i = 0; i < evdev_mice.size(); i++) {
|
||||
libevdev_free(evdev_mice[i].second);
|
||||
evdev_mice[i].second = nullptr;
|
||||
close(evdev_mice[i].first);
|
||||
@@ -91,7 +87,8 @@ void evdev_thread_func()
|
||||
evdev_mice.clear();
|
||||
}
|
||||
|
||||
void evdev_stop()
|
||||
void
|
||||
evdev_stop()
|
||||
{
|
||||
if (evdev_thread) {
|
||||
stopped = true;
|
||||
@@ -100,37 +97,32 @@ void evdev_stop()
|
||||
}
|
||||
}
|
||||
|
||||
void evdev_init()
|
||||
void
|
||||
evdev_init()
|
||||
{
|
||||
if (evdev_thread) return;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
if (evdev_thread)
|
||||
return;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
std::string evdev_device_path = "/dev/input/event" + std::to_string(i);
|
||||
int fd = open(evdev_device_path.c_str(), O_NONBLOCK | O_RDONLY);
|
||||
if (fd != -1)
|
||||
{
|
||||
libevdev* input_struct = nullptr;
|
||||
int rc = libevdev_new_from_fd(fd, &input_struct);
|
||||
if (rc <= -1)
|
||||
{
|
||||
int fd = open(evdev_device_path.c_str(), O_NONBLOCK | O_RDONLY);
|
||||
if (fd != -1) {
|
||||
libevdev *input_struct = nullptr;
|
||||
int rc = libevdev_new_from_fd(fd, &input_struct);
|
||||
if (rc <= -1) {
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!libevdev_has_event_type(input_struct, EV_REL) || !libevdev_has_event_code(input_struct, EV_KEY, BTN_LEFT))
|
||||
{
|
||||
} else {
|
||||
if (!libevdev_has_event_type(input_struct, EV_REL) || !libevdev_has_event_code(input_struct, EV_KEY, BTN_LEFT)) {
|
||||
libevdev_free(input_struct);
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
evdev_mice.push_back(std::make_pair(fd, input_struct));
|
||||
}
|
||||
}
|
||||
else if (errno == ENOENT) break;
|
||||
} else if (errno == ENOENT)
|
||||
break;
|
||||
}
|
||||
if (evdev_mice.size() != 0)
|
||||
{
|
||||
if (evdev_mice.size() != 0) {
|
||||
evdev_thread = QThread::create(evdev_thread_func);
|
||||
evdev_thread->start();
|
||||
atexit(evdev_stop);
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
#include <SDL.h>
|
||||
//#include "86box/plat.h"
|
||||
// #include "86box/plat.h"
|
||||
#include "cocoa_mouse.hpp"
|
||||
#import <AppKit/AppKit.h>
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/mouse.h>
|
||||
#include <86box/config.h>
|
||||
//#include <86box/plat.h>
|
||||
// #include <86box/plat.h>
|
||||
#include <86box/plat_dynld.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/ui.h>
|
||||
#include <86box/video.h>
|
||||
extern int mouse_capture;
|
||||
extern int mouse_capture;
|
||||
extern void plat_mouse_capture(int);
|
||||
}
|
||||
|
||||
typedef struct mouseinputdata
|
||||
{
|
||||
typedef struct mouseinputdata {
|
||||
int deltax, deltay, deltaz;
|
||||
int mousebuttons;
|
||||
} mouseinputdata;
|
||||
@@ -28,64 +26,63 @@ static mouseinputdata mousedata;
|
||||
|
||||
CocoaEventFilter::~CocoaEventFilter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CocoaEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, result_t *result)
|
||||
bool
|
||||
CocoaEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, result_t *result)
|
||||
{
|
||||
if (mouse_capture)
|
||||
{
|
||||
if (eventType == "mac_generic_NSEvent")
|
||||
{
|
||||
NSEvent* event = (NSEvent*)message;
|
||||
if (mouse_capture) {
|
||||
if (eventType == "mac_generic_NSEvent") {
|
||||
NSEvent *event = (NSEvent *) message;
|
||||
if ([event type] == NSEventTypeMouseMoved
|
||||
|| [event type] == NSEventTypeLeftMouseDragged
|
||||
|| [event type] == NSEventTypeRightMouseDragged
|
||||
|| [event type] == NSEventTypeOtherMouseDragged)
|
||||
{
|
||||
|| [event type] == NSEventTypeOtherMouseDragged) {
|
||||
mousedata.deltax += [event deltaX];
|
||||
mousedata.deltay += [event deltaY];
|
||||
return true;
|
||||
}
|
||||
if ([event type] == NSEventTypeScrollWheel)
|
||||
{
|
||||
if ([event type] == NSEventTypeScrollWheel) {
|
||||
mousedata.deltaz += [event deltaY];
|
||||
return true;
|
||||
}
|
||||
switch ([event type])
|
||||
{
|
||||
default: return false;
|
||||
switch ([event type]) {
|
||||
default:
|
||||
return false;
|
||||
case NSEventTypeLeftMouseDown:
|
||||
{
|
||||
mousedata.mousebuttons |= 1;
|
||||
break;
|
||||
}
|
||||
{
|
||||
mousedata.mousebuttons |= 1;
|
||||
break;
|
||||
}
|
||||
case NSEventTypeLeftMouseUp:
|
||||
{
|
||||
mousedata.mousebuttons &= ~1;
|
||||
break;
|
||||
}
|
||||
{
|
||||
mousedata.mousebuttons &= ~1;
|
||||
break;
|
||||
}
|
||||
case NSEventTypeRightMouseDown:
|
||||
{
|
||||
mousedata.mousebuttons |= 2;
|
||||
break;
|
||||
}
|
||||
{
|
||||
mousedata.mousebuttons |= 2;
|
||||
break;
|
||||
}
|
||||
case NSEventTypeRightMouseUp:
|
||||
{
|
||||
mousedata.mousebuttons &= ~2;
|
||||
break;
|
||||
}
|
||||
{
|
||||
mousedata.mousebuttons &= ~2;
|
||||
break;
|
||||
}
|
||||
case NSEventTypeOtherMouseDown:
|
||||
{
|
||||
mousedata.mousebuttons |= 4;
|
||||
break;
|
||||
}
|
||||
{
|
||||
mousedata.mousebuttons |= 4;
|
||||
break;
|
||||
}
|
||||
case NSEventTypeOtherMouseUp:
|
||||
{
|
||||
if (mouse_get_buttons() < 3) { plat_mouse_capture(0); return true; }
|
||||
mousedata.mousebuttons &= ~4;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (mouse_get_buttons() < 3) {
|
||||
plat_mouse_capture(0);
|
||||
return true;
|
||||
}
|
||||
mousedata.mousebuttons &= ~4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -93,11 +90,12 @@ bool CocoaEventFilter::nativeEventFilter(const QByteArray &eventType, void *mess
|
||||
return false;
|
||||
}
|
||||
|
||||
extern "C" void macos_poll_mouse()
|
||||
extern "C" void
|
||||
macos_poll_mouse()
|
||||
{
|
||||
mouse_x = mousedata.deltax;
|
||||
mouse_y = mousedata.deltay;
|
||||
mouse_z = mousedata.deltaz;
|
||||
mouse_x = mousedata.deltax;
|
||||
mouse_y = mousedata.deltay;
|
||||
mouse_z = mousedata.deltaz;
|
||||
mousedata.deltax = mousedata.deltay = mousedata.deltaz = 0;
|
||||
mouse_buttons = mousedata.mousebuttons;
|
||||
mouse_buttons = mousedata.mousebuttons;
|
||||
}
|
||||
|
||||
65
src/qt/qt.c
65
src/qt/qt.c
@@ -17,7 +17,7 @@
|
||||
* implemented in Qt
|
||||
*/
|
||||
#if !defined(_WIN32) || !defined(__clang__)
|
||||
#include <strings.h>
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
@@ -29,14 +29,17 @@
|
||||
#include <86box/timer.h>
|
||||
#include <86box/nvr.h>
|
||||
|
||||
int qt_nvr_save(void) {
|
||||
int
|
||||
qt_nvr_save(void)
|
||||
{
|
||||
return nvr_save();
|
||||
}
|
||||
|
||||
char icon_set[256] = ""; /* name of the iconset to be used */
|
||||
char icon_set[256] = ""; /* name of the iconset to be used */
|
||||
|
||||
int
|
||||
plat_vidapi(char* api) {
|
||||
plat_vidapi(char *api)
|
||||
{
|
||||
if (!strcasecmp(api, "default") || !strcasecmp(api, "system")) {
|
||||
return 0;
|
||||
} else if (!strcasecmp(api, "qt_software")) {
|
||||
@@ -58,34 +61,36 @@ plat_vidapi(char* api) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* plat_vidapi_name(int api) {
|
||||
char* name = "default";
|
||||
char *
|
||||
plat_vidapi_name(int api)
|
||||
{
|
||||
char *name = "default";
|
||||
|
||||
switch (api) {
|
||||
case 0:
|
||||
name = "qt_software";
|
||||
break;
|
||||
case 1:
|
||||
name = "qt_opengl";
|
||||
break;
|
||||
case 2:
|
||||
name = "qt_opengles";
|
||||
break;
|
||||
case 3:
|
||||
name = "qt_opengl3";
|
||||
break;
|
||||
case 4:
|
||||
name = "qt_vulkan";
|
||||
break;
|
||||
case 5:
|
||||
name = "qt_d3d9";
|
||||
break;
|
||||
case 6:
|
||||
name = "vnc";
|
||||
break;
|
||||
default:
|
||||
fatal("Unknown renderer: %i\n", api);
|
||||
break;
|
||||
case 0:
|
||||
name = "qt_software";
|
||||
break;
|
||||
case 1:
|
||||
name = "qt_opengl";
|
||||
break;
|
||||
case 2:
|
||||
name = "qt_opengles";
|
||||
break;
|
||||
case 3:
|
||||
name = "qt_opengl3";
|
||||
break;
|
||||
case 4:
|
||||
name = "qt_vulkan";
|
||||
break;
|
||||
case 5:
|
||||
name = "qt_d3d9";
|
||||
break;
|
||||
case 6:
|
||||
name = "vnc";
|
||||
break;
|
||||
default:
|
||||
fatal("Unknown renderer: %i\n", api);
|
||||
break;
|
||||
}
|
||||
|
||||
return name;
|
||||
|
||||
@@ -45,11 +45,11 @@ plat_cdrom_ui_update(uint8_t id, uint8_t reload)
|
||||
cdrom_t *drv = &cdrom[id];
|
||||
|
||||
if (drv->host_drive == 0) {
|
||||
ui_sb_update_icon_state(SB_CDROM|id, 1);
|
||||
ui_sb_update_icon_state(SB_CDROM | id, 1);
|
||||
} else {
|
||||
ui_sb_update_icon_state(SB_CDROM|id, 0);
|
||||
ui_sb_update_icon_state(SB_CDROM | id, 0);
|
||||
}
|
||||
|
||||
//media_menu_update_cdrom(id);
|
||||
ui_sb_update_tip(SB_CDROM|id);
|
||||
// media_menu_update_cdrom(id);
|
||||
ui_sb_update_tip(SB_CDROM | id);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
#include <QResizeEvent>
|
||||
#include <QTimer>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
#include <86box/video.h>
|
||||
}
|
||||
|
||||
D3D9Renderer::D3D9Renderer(QWidget *parent, int monitor_index)
|
||||
: QWidget{parent}, RendererCommon()
|
||||
: QWidget { parent }
|
||||
, RendererCommon()
|
||||
{
|
||||
QPalette pal = palette();
|
||||
pal.setColor(QPalette::Window, Qt::black);
|
||||
@@ -22,7 +22,7 @@ D3D9Renderer::D3D9Renderer(QWidget *parent, int monitor_index)
|
||||
setAttribute(Qt::WA_NoSystemBackground);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
|
||||
windowHandle = (HWND)winId();
|
||||
windowHandle = (HWND) winId();
|
||||
surfaceInUse = true;
|
||||
|
||||
RendererCommon::parentWidget = parent;
|
||||
@@ -36,24 +36,36 @@ D3D9Renderer::~D3D9Renderer()
|
||||
finalize();
|
||||
}
|
||||
|
||||
void D3D9Renderer::finalize()
|
||||
void
|
||||
D3D9Renderer::finalize()
|
||||
{
|
||||
if (!finalized) {
|
||||
while (surfaceInUse) {}
|
||||
while (surfaceInUse) { }
|
||||
finalized = true;
|
||||
}
|
||||
surfaceInUse = true;
|
||||
if (d3d9surface) { d3d9surface->Release(); d3d9surface = nullptr;}
|
||||
if (d3d9dev) { d3d9dev->Release(); d3d9dev = nullptr; }
|
||||
if (d3d9) { d3d9->Release(); d3d9 = nullptr; };
|
||||
if (d3d9surface) {
|
||||
d3d9surface->Release();
|
||||
d3d9surface = nullptr;
|
||||
}
|
||||
if (d3d9dev) {
|
||||
d3d9dev->Release();
|
||||
d3d9dev = nullptr;
|
||||
}
|
||||
if (d3d9) {
|
||||
d3d9->Release();
|
||||
d3d9 = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
void D3D9Renderer::hideEvent(QHideEvent *event)
|
||||
void
|
||||
D3D9Renderer::hideEvent(QHideEvent *event)
|
||||
{
|
||||
finalize();
|
||||
}
|
||||
|
||||
void D3D9Renderer::showEvent(QShowEvent *event)
|
||||
void
|
||||
D3D9Renderer::showEvent(QShowEvent *event)
|
||||
{
|
||||
params = {};
|
||||
|
||||
@@ -71,13 +83,15 @@ void D3D9Renderer::showEvent(QShowEvent *event)
|
||||
params.hDeviceWindow = windowHandle;
|
||||
|
||||
HRESULT result = d3d9->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, windowHandle, D3DCREATE_MULTITHREADED | D3DCREATE_HARDWARE_VERTEXPROCESSING, ¶ms, nullptr, &d3d9dev);
|
||||
if (FAILED(result)) result = d3d9->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, windowHandle, D3DCREATE_MULTITHREADED | D3DCREATE_SOFTWARE_VERTEXPROCESSING, ¶ms, nullptr, &d3d9dev);
|
||||
if (FAILED(result))
|
||||
result = d3d9->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, windowHandle, D3DCREATE_MULTITHREADED | D3DCREATE_SOFTWARE_VERTEXPROCESSING, ¶ms, nullptr, &d3d9dev);
|
||||
if (FAILED(result)) {
|
||||
return error("Failed to create Direct3D 9 device");
|
||||
}
|
||||
|
||||
result = d3d9dev->CreateOffscreenPlainSurface(2048, 2048, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d9surface, nullptr);
|
||||
if (FAILED(result)) result = d3d9dev->CreateOffscreenPlainSurface(1024, 1024, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d9surface, nullptr);
|
||||
if (FAILED(result))
|
||||
result = d3d9dev->CreateOffscreenPlainSurface(1024, 1024, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d9surface, nullptr);
|
||||
if (FAILED(result)) {
|
||||
return error("Failed to create Direct3D 9 surface");
|
||||
}
|
||||
@@ -86,33 +100,34 @@ void D3D9Renderer::showEvent(QShowEvent *event)
|
||||
alreadyInitialized = true;
|
||||
}
|
||||
surfaceInUse = false;
|
||||
finalized = false;
|
||||
finalized = false;
|
||||
}
|
||||
|
||||
void D3D9Renderer::paintEvent(QPaintEvent *event)
|
||||
void
|
||||
D3D9Renderer::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
IDirect3DSurface9* backbuffer = nullptr;
|
||||
RECT srcRect, dstRect;
|
||||
HRESULT result = d3d9dev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
|
||||
IDirect3DSurface9 *backbuffer = nullptr;
|
||||
RECT srcRect, dstRect;
|
||||
HRESULT result = d3d9dev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
|
||||
|
||||
if (FAILED(result)) {
|
||||
return;
|
||||
}
|
||||
|
||||
srcRect.top = source.top();
|
||||
srcRect.top = source.top();
|
||||
srcRect.bottom = source.bottom();
|
||||
srcRect.left = source.left();
|
||||
srcRect.right = source.right();
|
||||
dstRect.top = destination.top();
|
||||
srcRect.left = source.left();
|
||||
srcRect.right = source.right();
|
||||
dstRect.top = destination.top();
|
||||
dstRect.bottom = destination.bottom();
|
||||
dstRect.left = destination.left();
|
||||
dstRect.right = destination.right();
|
||||
dstRect.left = destination.left();
|
||||
dstRect.right = destination.right();
|
||||
d3d9dev->BeginScene();
|
||||
d3d9dev->Clear(0, nullptr, D3DCLEAR_TARGET, 0xFF000000, 0, 0);
|
||||
while (surfaceInUse) {}
|
||||
while (surfaceInUse) { }
|
||||
surfaceInUse = true;
|
||||
d3d9dev->StretchRect(d3d9surface, &srcRect, backbuffer, &dstRect, video_filter_method == 0 ? D3DTEXF_POINT : D3DTEXF_LINEAR);
|
||||
result = d3d9dev->EndScene();
|
||||
result = d3d9dev->EndScene();
|
||||
surfaceInUse = false;
|
||||
if (SUCCEEDED(result)) {
|
||||
if (FAILED(d3d9dev->PresentEx(nullptr, nullptr, 0, nullptr, 0))) {
|
||||
@@ -122,51 +137,57 @@ void D3D9Renderer::paintEvent(QPaintEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
bool D3D9Renderer::event(QEvent *event)
|
||||
bool
|
||||
D3D9Renderer::event(QEvent *event)
|
||||
{
|
||||
bool res = false;
|
||||
if (!eventDelegate(event, res)) return QWidget::event(event);
|
||||
if (!eventDelegate(event, res))
|
||||
return QWidget::event(event);
|
||||
return res;
|
||||
}
|
||||
|
||||
void D3D9Renderer::resizeEvent(QResizeEvent *event)
|
||||
void
|
||||
D3D9Renderer::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
onResize(event->size().width() * devicePixelRatioF(), event->size().height() * devicePixelRatioF());
|
||||
|
||||
params.BackBufferWidth = event->size().width() * devicePixelRatioF();
|
||||
params.BackBufferWidth = event->size().width() * devicePixelRatioF();
|
||||
params.BackBufferHeight = event->size().height() * devicePixelRatioF();
|
||||
if (d3d9dev) d3d9dev->Reset(¶ms);
|
||||
if (d3d9dev)
|
||||
d3d9dev->Reset(¶ms);
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void D3D9Renderer::blit(int x, int y, int w, int h)
|
||||
void
|
||||
D3D9Renderer::blit(int x, int y, int w, int h)
|
||||
{
|
||||
if (blitDummied || (x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (monitors[m_monitor_index].target_buffer == NULL) || surfaceInUse) {
|
||||
video_blit_complete_monitor(m_monitor_index);
|
||||
return;
|
||||
}
|
||||
surfaceInUse = true;
|
||||
surfaceInUse = true;
|
||||
auto origSource = source;
|
||||
source.setRect(x, y, w, h);
|
||||
RECT srcRect;
|
||||
RECT srcRect;
|
||||
D3DLOCKED_RECT lockRect;
|
||||
srcRect.top = source.top();
|
||||
srcRect.top = source.top();
|
||||
srcRect.bottom = source.bottom();
|
||||
srcRect.left = source.left();
|
||||
srcRect.right = source.right();
|
||||
srcRect.left = source.left();
|
||||
srcRect.right = source.right();
|
||||
|
||||
if (monitors[m_monitor_index].mon_screenshots) {
|
||||
video_screenshot_monitor((uint32_t *) &(monitors[m_monitor_index].target_buffer->line[y][x]), 0, 0, 2048, m_monitor_index);
|
||||
}
|
||||
if (SUCCEEDED(d3d9surface->LockRect(&lockRect, &srcRect, 0))) {
|
||||
for (int y1 = 0; y1 < h; y1++) {
|
||||
video_copy(((uint8_t*)lockRect.pBits) + (y1 * lockRect.Pitch), &(monitors[m_monitor_index].target_buffer->line[y + y1][x]), w * 4);
|
||||
video_copy(((uint8_t *) lockRect.pBits) + (y1 * lockRect.Pitch), &(monitors[m_monitor_index].target_buffer->line[y + y1][x]), w * 4);
|
||||
}
|
||||
video_blit_complete_monitor(m_monitor_index);
|
||||
d3d9surface->UnlockRect();
|
||||
}
|
||||
else video_blit_complete_monitor(m_monitor_index);
|
||||
if (origSource != source) onResize(this->width() * devicePixelRatioF(), this->height() * devicePixelRatioF());
|
||||
} else
|
||||
video_blit_complete_monitor(m_monitor_index);
|
||||
if (origSource != source)
|
||||
onResize(this->width() * devicePixelRatioF(), this->height() * devicePixelRatioF());
|
||||
surfaceInUse = false;
|
||||
QTimer::singleShot(0, this, [this] { this->update(); });
|
||||
}
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
#include <d3d9.h>
|
||||
#include <atomic>
|
||||
|
||||
class D3D9Renderer : public QWidget, public RendererCommon
|
||||
{
|
||||
class D3D9Renderer : public QWidget, public RendererCommon {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit D3D9Renderer(QWidget *parent = nullptr, int monitor_index = 0);
|
||||
@@ -19,27 +18,27 @@ public:
|
||||
void finalize() override;
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* event) override;
|
||||
void hideEvent(QHideEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
bool event(QEvent* event) override;
|
||||
QPaintEngine* paintEngine() const override { return nullptr; }
|
||||
void showEvent(QShowEvent *event) override;
|
||||
void hideEvent(QHideEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
bool event(QEvent *event) override;
|
||||
QPaintEngine *paintEngine() const override { return nullptr; }
|
||||
|
||||
signals:
|
||||
void initialized();
|
||||
void error(QString);
|
||||
|
||||
private:
|
||||
HWND windowHandle = 0;
|
||||
D3DPRESENT_PARAMETERS params{};
|
||||
IDirect3D9Ex* d3d9 = nullptr;
|
||||
IDirect3DDevice9Ex* d3d9dev = nullptr;
|
||||
IDirect3DSurface9* d3d9surface = nullptr;
|
||||
HWND windowHandle = 0;
|
||||
D3DPRESENT_PARAMETERS params {};
|
||||
IDirect3D9Ex *d3d9 = nullptr;
|
||||
IDirect3DDevice9Ex *d3d9dev = nullptr;
|
||||
IDirect3DSurface9 *d3d9surface = nullptr;
|
||||
|
||||
std::atomic<bool> surfaceInUse{false}, finalized{false};
|
||||
bool alreadyInitialized = false;
|
||||
int m_monitor_index = 0;
|
||||
std::atomic<bool> surfaceInUse { false }, finalized { false };
|
||||
bool alreadyInitialized = false;
|
||||
int m_monitor_index = 0;
|
||||
};
|
||||
|
||||
#endif // D3D9RENDERER_HPP
|
||||
|
||||
@@ -39,9 +39,9 @@ extern "C" {
|
||||
#include "qt_filefield.hpp"
|
||||
#include "qt_models_common.hpp"
|
||||
|
||||
DeviceConfig::DeviceConfig(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DeviceConfig)
|
||||
DeviceConfig::DeviceConfig(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::DeviceConfig)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
@@ -51,7 +51,9 @@ DeviceConfig::~DeviceConfig()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DeviceConfig::ConfigureDevice(const _device_* device, int instance, Settings* settings) {
|
||||
void
|
||||
DeviceConfig::ConfigureDevice(const _device_ *device, int instance, Settings *settings)
|
||||
{
|
||||
DeviceConfig dc(settings);
|
||||
dc.setWindowTitle(QString("%1 Device Configuration").arg(device->name));
|
||||
int c, d, p, q;
|
||||
@@ -59,142 +61,142 @@ void DeviceConfig::ConfigureDevice(const _device_* device, int instance, Setting
|
||||
device_context_t device_context;
|
||||
device_set_context(&device_context, device, instance);
|
||||
|
||||
const auto* config = device->config;
|
||||
const auto *config = device->config;
|
||||
while (config->type != -1) {
|
||||
switch (config->type) {
|
||||
case CONFIG_BINARY:
|
||||
{
|
||||
auto value = config_get_int(device_context.name, const_cast<char*>(config->name), config->default_int);
|
||||
auto* cbox = new QCheckBox();
|
||||
cbox->setObjectName(config->name);
|
||||
cbox->setChecked(value > 0);
|
||||
dc.ui->formLayout->addRow(config->description, cbox);
|
||||
break;
|
||||
}
|
||||
case CONFIG_BINARY:
|
||||
{
|
||||
auto value = config_get_int(device_context.name, const_cast<char *>(config->name), config->default_int);
|
||||
auto *cbox = new QCheckBox();
|
||||
cbox->setObjectName(config->name);
|
||||
cbox->setChecked(value > 0);
|
||||
dc.ui->formLayout->addRow(config->description, cbox);
|
||||
break;
|
||||
}
|
||||
#ifdef USE_RTMIDI
|
||||
case CONFIG_MIDI_OUT:
|
||||
{
|
||||
auto* cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
auto* model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
int selected = config_get_int(device_context.name, const_cast<char*>(config->name), config->default_int);
|
||||
for (int i = 0; i < rtmidi_out_get_num_devs(); i++) {
|
||||
char midiName[512] = { 0 };
|
||||
rtmidi_out_get_dev_name(i, midiName);
|
||||
case CONFIG_MIDI_OUT:
|
||||
{
|
||||
auto *cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
auto *model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
int selected = config_get_int(device_context.name, const_cast<char *>(config->name), config->default_int);
|
||||
for (int i = 0; i < rtmidi_out_get_num_devs(); i++) {
|
||||
char midiName[512] = { 0 };
|
||||
rtmidi_out_get_dev_name(i, midiName);
|
||||
|
||||
Models::AddEntry(model, midiName, i);
|
||||
if (selected == i) {
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
dc.ui->formLayout->addRow(config->description, cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
case CONFIG_MIDI_IN:
|
||||
{
|
||||
auto* cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
auto* model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
int selected = config_get_int(device_context.name, const_cast<char*>(config->name), config->default_int);
|
||||
for (int i = 0; i < rtmidi_in_get_num_devs(); i++) {
|
||||
char midiName[512] = { 0 };
|
||||
rtmidi_in_get_dev_name(i, midiName);
|
||||
|
||||
Models::AddEntry(model, midiName, i);
|
||||
if (selected == i) {
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
dc.ui->formLayout->addRow(config->description, cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case CONFIG_SELECTION:
|
||||
case CONFIG_HEX16:
|
||||
case CONFIG_HEX20:
|
||||
{
|
||||
auto* cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
auto* model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
int selected = 0;
|
||||
switch (config->type) {
|
||||
case CONFIG_SELECTION:
|
||||
selected = config_get_int(device_context.name, const_cast<char*>(config->name), config->default_int);
|
||||
break;
|
||||
case CONFIG_HEX16:
|
||||
selected = config_get_hex16(device_context.name, const_cast<char*>(config->name), config->default_int);
|
||||
break;
|
||||
case CONFIG_HEX20:
|
||||
selected = config_get_hex20(device_context.name, const_cast<char*>(config->name), config->default_int);
|
||||
break;
|
||||
}
|
||||
|
||||
for (auto* sel = config->selection; (sel != nullptr) && (sel->description != nullptr) && (strlen(sel->description) > 0); ++sel) {
|
||||
int row = Models::AddEntry(model, sel->description, sel->value);
|
||||
if (selected == sel->value) {
|
||||
currentIndex = row;
|
||||
}
|
||||
}
|
||||
dc.ui->formLayout->addRow(config->description, cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
case CONFIG_BIOS:
|
||||
{
|
||||
auto* cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
auto* model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
char *selected;
|
||||
selected = config_get_string(device_context.name, const_cast<char*>(config->name), const_cast<char*>(config->default_string));
|
||||
|
||||
c = q = 0;
|
||||
for (auto* bios = config->bios; (bios != nullptr) && (bios->name != nullptr) && (strlen(bios->name) > 0); ++bios) {
|
||||
p = 0;
|
||||
for (d = 0; d < bios->files_no; d++)
|
||||
p += !!rom_present(const_cast<char*>(bios->files[d]));
|
||||
if (p == bios->files_no) {
|
||||
int row = Models::AddEntry(model, bios->name, q);
|
||||
if (!strcmp(selected, bios->internal_name)) {
|
||||
currentIndex = row;
|
||||
Models::AddEntry(model, midiName, i);
|
||||
if (selected == i) {
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
c++;
|
||||
}
|
||||
q++;
|
||||
}
|
||||
dc.ui->formLayout->addRow(config->description, cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
case CONFIG_SPINNER:
|
||||
{
|
||||
int value = config_get_int(device_context.name, const_cast<char*>(config->name), config->default_int);
|
||||
auto* spinBox = new QSpinBox();
|
||||
spinBox->setObjectName(config->name);
|
||||
spinBox->setMaximum(config->spinner.max);
|
||||
spinBox->setMinimum(config->spinner.min);
|
||||
if (config->spinner.step > 0) {
|
||||
spinBox->setSingleStep(config->spinner.step);
|
||||
}
|
||||
spinBox->setValue(value);
|
||||
dc.ui->formLayout->addRow(config->description, spinBox);
|
||||
break;
|
||||
}
|
||||
case CONFIG_FNAME:
|
||||
{
|
||||
auto* fileName = config_get_string(device_context.name, const_cast<char*>(config->name), const_cast<char*>(config->default_string));
|
||||
auto* fileField = new FileField();
|
||||
fileField->setObjectName(config->name);
|
||||
fileField->setFileName(fileName);
|
||||
fileField->setFilter(QString(config->file_filter).left(strcspn(config->file_filter, "|")));
|
||||
dc.ui->formLayout->addRow(config->description, fileField);
|
||||
break;
|
||||
}
|
||||
dc.ui->formLayout->addRow(config->description, cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
case CONFIG_MIDI_IN:
|
||||
{
|
||||
auto *cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
auto *model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
int selected = config_get_int(device_context.name, const_cast<char *>(config->name), config->default_int);
|
||||
for (int i = 0; i < rtmidi_in_get_num_devs(); i++) {
|
||||
char midiName[512] = { 0 };
|
||||
rtmidi_in_get_dev_name(i, midiName);
|
||||
|
||||
Models::AddEntry(model, midiName, i);
|
||||
if (selected == i) {
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
dc.ui->formLayout->addRow(config->description, cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case CONFIG_SELECTION:
|
||||
case CONFIG_HEX16:
|
||||
case CONFIG_HEX20:
|
||||
{
|
||||
auto *cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
auto *model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
int selected = 0;
|
||||
switch (config->type) {
|
||||
case CONFIG_SELECTION:
|
||||
selected = config_get_int(device_context.name, const_cast<char *>(config->name), config->default_int);
|
||||
break;
|
||||
case CONFIG_HEX16:
|
||||
selected = config_get_hex16(device_context.name, const_cast<char *>(config->name), config->default_int);
|
||||
break;
|
||||
case CONFIG_HEX20:
|
||||
selected = config_get_hex20(device_context.name, const_cast<char *>(config->name), config->default_int);
|
||||
break;
|
||||
}
|
||||
|
||||
for (auto *sel = config->selection; (sel != nullptr) && (sel->description != nullptr) && (strlen(sel->description) > 0); ++sel) {
|
||||
int row = Models::AddEntry(model, sel->description, sel->value);
|
||||
if (selected == sel->value) {
|
||||
currentIndex = row;
|
||||
}
|
||||
}
|
||||
dc.ui->formLayout->addRow(config->description, cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
case CONFIG_BIOS:
|
||||
{
|
||||
auto *cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
auto *model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
char *selected;
|
||||
selected = config_get_string(device_context.name, const_cast<char *>(config->name), const_cast<char *>(config->default_string));
|
||||
|
||||
c = q = 0;
|
||||
for (auto *bios = config->bios; (bios != nullptr) && (bios->name != nullptr) && (strlen(bios->name) > 0); ++bios) {
|
||||
p = 0;
|
||||
for (d = 0; d < bios->files_no; d++)
|
||||
p += !!rom_present(const_cast<char *>(bios->files[d]));
|
||||
if (p == bios->files_no) {
|
||||
int row = Models::AddEntry(model, bios->name, q);
|
||||
if (!strcmp(selected, bios->internal_name)) {
|
||||
currentIndex = row;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
q++;
|
||||
}
|
||||
dc.ui->formLayout->addRow(config->description, cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
case CONFIG_SPINNER:
|
||||
{
|
||||
int value = config_get_int(device_context.name, const_cast<char *>(config->name), config->default_int);
|
||||
auto *spinBox = new QSpinBox();
|
||||
spinBox->setObjectName(config->name);
|
||||
spinBox->setMaximum(config->spinner.max);
|
||||
spinBox->setMinimum(config->spinner.min);
|
||||
if (config->spinner.step > 0) {
|
||||
spinBox->setSingleStep(config->spinner.step);
|
||||
}
|
||||
spinBox->setValue(value);
|
||||
dc.ui->formLayout->addRow(config->description, spinBox);
|
||||
break;
|
||||
}
|
||||
case CONFIG_FNAME:
|
||||
{
|
||||
auto *fileName = config_get_string(device_context.name, const_cast<char *>(config->name), const_cast<char *>(config->default_string));
|
||||
auto *fileField = new FileField();
|
||||
fileField->setObjectName(config->name);
|
||||
fileField->setFileName(fileName);
|
||||
fileField->setFilter(QString(config->file_filter).left(strcspn(config->file_filter, "|")));
|
||||
dc.ui->formLayout->addRow(config->description, fileField);
|
||||
break;
|
||||
}
|
||||
}
|
||||
++config;
|
||||
}
|
||||
@@ -205,59 +207,61 @@ void DeviceConfig::ConfigureDevice(const _device_* device, int instance, Setting
|
||||
config = device->config;
|
||||
while (config->type != -1) {
|
||||
switch (config->type) {
|
||||
case CONFIG_BINARY:
|
||||
{
|
||||
auto* cbox = dc.findChild<QCheckBox*>(config->name);
|
||||
config_set_int(device_context.name, const_cast<char*>(config->name), cbox->isChecked() ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
case CONFIG_MIDI_OUT:
|
||||
case CONFIG_MIDI_IN:
|
||||
case CONFIG_SELECTION:
|
||||
{
|
||||
auto* cbox = dc.findChild<QComboBox*>(config->name);
|
||||
config_set_int(device_context.name, const_cast<char*>(config->name), cbox->currentData().toInt());
|
||||
break;
|
||||
}
|
||||
case CONFIG_BIOS:
|
||||
{
|
||||
auto* cbox = dc.findChild<QComboBox*>(config->name);
|
||||
int idx = cbox->currentData().toInt();
|
||||
config_set_string(device_context.name, const_cast<char*>(config->name), const_cast<char*>(config->bios[idx].internal_name));
|
||||
break;
|
||||
}
|
||||
case CONFIG_HEX16:
|
||||
{
|
||||
auto* cbox = dc.findChild<QComboBox*>(config->name);
|
||||
config_set_hex16(device_context.name, const_cast<char*>(config->name), cbox->currentData().toInt());
|
||||
break;
|
||||
}
|
||||
case CONFIG_HEX20:
|
||||
{
|
||||
auto* cbox = dc.findChild<QComboBox*>(config->name);
|
||||
config_set_hex20(device_context.name, const_cast<char*>(config->name), cbox->currentData().toInt());
|
||||
break;
|
||||
}
|
||||
case CONFIG_FNAME:
|
||||
{
|
||||
auto* fbox = dc.findChild<FileField*>(config->name);
|
||||
auto fileName = fbox->fileName().toUtf8();
|
||||
config_set_string(device_context.name, const_cast<char*>(config->name), fileName.data());
|
||||
break;
|
||||
}
|
||||
case CONFIG_SPINNER:
|
||||
{
|
||||
auto* spinBox = dc.findChild<QSpinBox*>(config->name);
|
||||
config_set_int(device_context.name, const_cast<char*>(config->name), spinBox->value());
|
||||
break;
|
||||
}
|
||||
case CONFIG_BINARY:
|
||||
{
|
||||
auto *cbox = dc.findChild<QCheckBox *>(config->name);
|
||||
config_set_int(device_context.name, const_cast<char *>(config->name), cbox->isChecked() ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
case CONFIG_MIDI_OUT:
|
||||
case CONFIG_MIDI_IN:
|
||||
case CONFIG_SELECTION:
|
||||
{
|
||||
auto *cbox = dc.findChild<QComboBox *>(config->name);
|
||||
config_set_int(device_context.name, const_cast<char *>(config->name), cbox->currentData().toInt());
|
||||
break;
|
||||
}
|
||||
case CONFIG_BIOS:
|
||||
{
|
||||
auto *cbox = dc.findChild<QComboBox *>(config->name);
|
||||
int idx = cbox->currentData().toInt();
|
||||
config_set_string(device_context.name, const_cast<char *>(config->name), const_cast<char *>(config->bios[idx].internal_name));
|
||||
break;
|
||||
}
|
||||
case CONFIG_HEX16:
|
||||
{
|
||||
auto *cbox = dc.findChild<QComboBox *>(config->name);
|
||||
config_set_hex16(device_context.name, const_cast<char *>(config->name), cbox->currentData().toInt());
|
||||
break;
|
||||
}
|
||||
case CONFIG_HEX20:
|
||||
{
|
||||
auto *cbox = dc.findChild<QComboBox *>(config->name);
|
||||
config_set_hex20(device_context.name, const_cast<char *>(config->name), cbox->currentData().toInt());
|
||||
break;
|
||||
}
|
||||
case CONFIG_FNAME:
|
||||
{
|
||||
auto *fbox = dc.findChild<FileField *>(config->name);
|
||||
auto fileName = fbox->fileName().toUtf8();
|
||||
config_set_string(device_context.name, const_cast<char *>(config->name), fileName.data());
|
||||
break;
|
||||
}
|
||||
case CONFIG_SPINNER:
|
||||
{
|
||||
auto *spinBox = dc.findChild<QSpinBox *>(config->name);
|
||||
config_set_int(device_context.name, const_cast<char *>(config->name), spinBox->value());
|
||||
break;
|
||||
}
|
||||
}
|
||||
config++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString DeviceConfig::DeviceName(const _device_* device, const char *internalName, int bus) {
|
||||
QString
|
||||
DeviceConfig::DeviceName(const _device_ *device, const char *internalName, int bus)
|
||||
{
|
||||
if (QStringLiteral("none") == internalName) {
|
||||
return tr("None");
|
||||
} else if (QStringLiteral("internal") == internalName) {
|
||||
|
||||
@@ -15,16 +15,16 @@ class DeviceConfig;
|
||||
|
||||
class Settings;
|
||||
|
||||
class DeviceConfig : public QDialog
|
||||
{
|
||||
class DeviceConfig : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DeviceConfig(QWidget *parent = nullptr);
|
||||
~DeviceConfig();
|
||||
|
||||
static void ConfigureDevice(const _device_* device, int instance = 0, Settings* settings = nullptr);
|
||||
static QString DeviceName(const _device_* device, const char* internalName, int bus);
|
||||
static void ConfigureDevice(const _device_ *device, int instance = 0, Settings *settings = nullptr);
|
||||
static QString DeviceName(const _device_ *device, const char *internalName, int bus);
|
||||
|
||||
private:
|
||||
Ui::DeviceConfig *ui;
|
||||
};
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
FileField::FileField(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::FileField)
|
||||
FileField::FileField(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::FileField)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->label, &QLineEdit::editingFinished, this, [this] () {
|
||||
connect(ui->label, &QLineEdit::editingFinished, this, [this]() {
|
||||
fileName_ = ui->label->text();
|
||||
emit fileSelected(ui->label->text());
|
||||
});
|
||||
@@ -39,12 +39,16 @@ FileField::~FileField()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FileField::setFileName(const QString &fileName) {
|
||||
void
|
||||
FileField::setFileName(const QString &fileName)
|
||||
{
|
||||
fileName_ = fileName;
|
||||
ui->label->setText(fileName);
|
||||
}
|
||||
|
||||
void FileField::on_pushButton_clicked() {
|
||||
void
|
||||
FileField::on_pushButton_clicked()
|
||||
{
|
||||
QString fileName;
|
||||
if (createFile_) {
|
||||
fileName = QFileDialog::getSaveFileName(this, QString(), QString(), filter_, &selectedFilter_);
|
||||
|
||||
@@ -7,8 +7,7 @@ namespace Ui {
|
||||
class FileField;
|
||||
}
|
||||
|
||||
class FileField : public QWidget
|
||||
{
|
||||
class FileField : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@@ -16,26 +15,26 @@ public:
|
||||
~FileField();
|
||||
|
||||
QString fileName() const { return fileName_; }
|
||||
void setFileName(const QString& fileName);
|
||||
void setFileName(const QString &fileName);
|
||||
|
||||
void setFilter(const QString& filter) { filter_ = filter; }
|
||||
void setFilter(const QString &filter) { filter_ = filter; }
|
||||
QString selectedFilter() const { return selectedFilter_; }
|
||||
|
||||
void setCreateFile(bool createFile) { createFile_ = createFile; }
|
||||
bool createFile() { return createFile_; }
|
||||
|
||||
signals:
|
||||
void fileSelected(const QString& fileName);
|
||||
void fileSelected(const QString &fileName);
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::FileField *ui;
|
||||
QString fileName_;
|
||||
QString selectedFilter_;
|
||||
QString filter_;
|
||||
bool createFile_ = false;
|
||||
QString fileName_;
|
||||
QString selectedFilter_;
|
||||
QString filter_;
|
||||
bool createFile_ = false;
|
||||
};
|
||||
|
||||
#endif // QT_FILEFIELD_HPP
|
||||
|
||||
@@ -45,9 +45,9 @@ extern "C" {
|
||||
#include "qt_models_common.hpp"
|
||||
#include "qt_util.hpp"
|
||||
|
||||
HarddiskDialog::HarddiskDialog(bool existing, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::HarddiskDialog)
|
||||
HarddiskDialog::HarddiskDialog(bool existing, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::HarddiskDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -86,7 +86,7 @@ HarddiskDialog::HarddiskDialog(bool existing, QWidget *parent) :
|
||||
});
|
||||
}
|
||||
|
||||
auto* model = ui->comboBoxFormat->model();
|
||||
auto *model = ui->comboBoxFormat->model();
|
||||
model->insertRows(0, 6);
|
||||
model->setData(model->index(0, 0), tr("Raw image (.img)"));
|
||||
model->setData(model->index(1, 0), tr("HDI image (.hdi)"));
|
||||
@@ -108,9 +108,9 @@ HarddiskDialog::HarddiskDialog(bool existing, QWidget *parent) :
|
||||
|
||||
model = ui->comboBoxType->model();
|
||||
for (int i = 0; i < 127; i++) {
|
||||
uint64_t size = ((uint64_t) hdd_table[i][0]) * hdd_table[i][1] * hdd_table[i][2];
|
||||
uint64_t size = ((uint64_t) hdd_table[i][0]) * hdd_table[i][1] * hdd_table[i][2];
|
||||
uint32_t size_mb = size >> 11LL;
|
||||
//QString text = QString("%1 MiB (CHS: %2, %3, %4)").arg(size_mb).arg(hdd_table[i][0]).arg(hdd_table[i][1]).arg(hdd_table[i][2]);
|
||||
// QString text = QString("%1 MiB (CHS: %2, %3, %4)").arg(size_mb).arg(hdd_table[i][0]).arg(hdd_table[i][1]).arg(hdd_table[i][2]);
|
||||
QString text = QString::asprintf(tr("%u MB (CHS: %i, %i, %i)").toUtf8().constData(), (size_mb), (hdd_table[i][0]), (hdd_table[i][1]), (hdd_table[i][2]));
|
||||
Models::AddEntry(model, text, i);
|
||||
}
|
||||
@@ -126,23 +126,33 @@ HarddiskDialog::~HarddiskDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
uint8_t HarddiskDialog::bus() const {
|
||||
uint8_t
|
||||
HarddiskDialog::bus() const
|
||||
{
|
||||
return static_cast<uint8_t>(ui->comboBoxBus->currentData().toUInt());
|
||||
}
|
||||
|
||||
uint8_t HarddiskDialog::channel() const {
|
||||
uint8_t
|
||||
HarddiskDialog::channel() const
|
||||
{
|
||||
return static_cast<uint8_t>(ui->comboBoxChannel->currentData().toUInt());
|
||||
}
|
||||
|
||||
QString HarddiskDialog::fileName() const {
|
||||
QString
|
||||
HarddiskDialog::fileName() const
|
||||
{
|
||||
return ui->fileField->fileName();
|
||||
}
|
||||
|
||||
uint32_t HarddiskDialog::speed() const {
|
||||
uint32_t
|
||||
HarddiskDialog::speed() const
|
||||
{
|
||||
return static_cast<uint32_t>(ui->comboBoxSpeed->currentData().toUInt());
|
||||
}
|
||||
|
||||
void HarddiskDialog::on_comboBoxFormat_currentIndexChanged(int index) {
|
||||
void
|
||||
HarddiskDialog::on_comboBoxFormat_currentIndexChanged(int index)
|
||||
{
|
||||
bool enabled;
|
||||
if (index == 5) { /* They switched to a diff VHD; disable the geometry fields. */
|
||||
enabled = false;
|
||||
@@ -177,12 +187,13 @@ void HarddiskDialog::on_comboBoxFormat_currentIndexChanged(int index) {
|
||||
* of about 21 MB, and should only be necessary for VHDs larger than 31.5 GB, so should never be more
|
||||
* than a tenth of a percent change in size.
|
||||
*/
|
||||
static void adjust_86box_geometry_for_vhd(MVHDGeom *_86box_geometry, MVHDGeom *vhd_geometry)
|
||||
static void
|
||||
adjust_86box_geometry_for_vhd(MVHDGeom *_86box_geometry, MVHDGeom *vhd_geometry)
|
||||
{
|
||||
if (_86box_geometry->cyl <= 65535) {
|
||||
vhd_geometry->cyl = _86box_geometry->cyl;
|
||||
vhd_geometry->cyl = _86box_geometry->cyl;
|
||||
vhd_geometry->heads = _86box_geometry->heads;
|
||||
vhd_geometry->spt = _86box_geometry->spt;
|
||||
vhd_geometry->spt = _86box_geometry->spt;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -194,33 +205,35 @@ static void adjust_86box_geometry_for_vhd(MVHDGeom *_86box_geometry, MVHDGeom *v
|
||||
if (remainder > 0)
|
||||
desired_sectors += (85680 - remainder);
|
||||
|
||||
_86box_geometry->cyl = desired_sectors / (16 * 63);
|
||||
_86box_geometry->cyl = desired_sectors / (16 * 63);
|
||||
_86box_geometry->heads = 16;
|
||||
_86box_geometry->spt = 63;
|
||||
_86box_geometry->spt = 63;
|
||||
|
||||
vhd_geometry->cyl = desired_sectors / (16 * 255);
|
||||
vhd_geometry->cyl = desired_sectors / (16 * 255);
|
||||
vhd_geometry->heads = 16;
|
||||
vhd_geometry->spt = 255;
|
||||
vhd_geometry->spt = 255;
|
||||
}
|
||||
|
||||
static HarddiskDialog* callbackPtr = nullptr;
|
||||
static MVHDGeom create_drive_vhd_fixed(const QString& fileName, HarddiskDialog* p, uint16_t cyl, uint8_t heads, uint8_t spt) {
|
||||
static HarddiskDialog *callbackPtr = nullptr;
|
||||
static MVHDGeom
|
||||
create_drive_vhd_fixed(const QString &fileName, HarddiskDialog *p, uint16_t cyl, uint8_t heads, uint8_t spt)
|
||||
{
|
||||
MVHDGeom _86box_geometry = { .cyl = cyl, .heads = heads, .spt = spt };
|
||||
MVHDGeom vhd_geometry;
|
||||
adjust_86box_geometry_for_vhd(&_86box_geometry, &vhd_geometry);
|
||||
|
||||
int vhd_error = 0;
|
||||
int vhd_error = 0;
|
||||
QByteArray filenameBytes = fileName.toUtf8();
|
||||
callbackPtr = p;
|
||||
MVHDMeta *vhd = mvhd_create_fixed(filenameBytes.data(), vhd_geometry, &vhd_error, [](uint32_t current_sector, uint32_t total_sectors) {
|
||||
callbackPtr = p;
|
||||
MVHDMeta *vhd = mvhd_create_fixed(filenameBytes.data(), vhd_geometry, &vhd_error, [](uint32_t current_sector, uint32_t total_sectors) {
|
||||
callbackPtr->fileProgress((current_sector * 100) / total_sectors);
|
||||
});
|
||||
callbackPtr = nullptr;
|
||||
callbackPtr = nullptr;
|
||||
|
||||
if (vhd == NULL) {
|
||||
_86box_geometry.cyl = 0;
|
||||
_86box_geometry.cyl = 0;
|
||||
_86box_geometry.heads = 0;
|
||||
_86box_geometry.spt = 0;
|
||||
_86box_geometry.spt = 0;
|
||||
} else {
|
||||
mvhd_close(vhd);
|
||||
}
|
||||
@@ -228,24 +241,26 @@ static MVHDGeom create_drive_vhd_fixed(const QString& fileName, HarddiskDialog*
|
||||
return _86box_geometry;
|
||||
}
|
||||
|
||||
static MVHDGeom create_drive_vhd_dynamic(const QString& fileName, uint16_t cyl, uint8_t heads, uint8_t spt, int blocksize) {
|
||||
static MVHDGeom
|
||||
create_drive_vhd_dynamic(const QString &fileName, uint16_t cyl, uint8_t heads, uint8_t spt, int blocksize)
|
||||
{
|
||||
MVHDGeom _86box_geometry = { .cyl = cyl, .heads = heads, .spt = spt };
|
||||
MVHDGeom vhd_geometry;
|
||||
adjust_86box_geometry_for_vhd(&_86box_geometry, &vhd_geometry);
|
||||
int vhd_error = 0;
|
||||
QByteArray filenameBytes = fileName.toUtf8();
|
||||
int vhd_error = 0;
|
||||
QByteArray filenameBytes = fileName.toUtf8();
|
||||
MVHDCreationOptions options;
|
||||
options.block_size_in_sectors = blocksize;
|
||||
options.path = filenameBytes.data();
|
||||
options.size_in_bytes = 0;
|
||||
options.geometry = vhd_geometry;
|
||||
options.type = MVHD_TYPE_DYNAMIC;
|
||||
options.path = filenameBytes.data();
|
||||
options.size_in_bytes = 0;
|
||||
options.geometry = vhd_geometry;
|
||||
options.type = MVHD_TYPE_DYNAMIC;
|
||||
|
||||
MVHDMeta *vhd = mvhd_create_ex(options, &vhd_error);
|
||||
if (vhd == NULL) {
|
||||
_86box_geometry.cyl = 0;
|
||||
_86box_geometry.cyl = 0;
|
||||
_86box_geometry.heads = 0;
|
||||
_86box_geometry.spt = 0;
|
||||
_86box_geometry.spt = 0;
|
||||
} else {
|
||||
mvhd_close(vhd);
|
||||
}
|
||||
@@ -253,29 +268,31 @@ static MVHDGeom create_drive_vhd_dynamic(const QString& fileName, uint16_t cyl,
|
||||
return _86box_geometry;
|
||||
}
|
||||
|
||||
static MVHDGeom create_drive_vhd_diff(const QString& fileName, const QString& parentFileName, int blocksize) {
|
||||
int vhd_error = 0;
|
||||
QByteArray filenameBytes = fileName.toUtf8();
|
||||
QByteArray parentFilenameBytes = parentFileName.toUtf8();
|
||||
static MVHDGeom
|
||||
create_drive_vhd_diff(const QString &fileName, const QString &parentFileName, int blocksize)
|
||||
{
|
||||
int vhd_error = 0;
|
||||
QByteArray filenameBytes = fileName.toUtf8();
|
||||
QByteArray parentFilenameBytes = parentFileName.toUtf8();
|
||||
MVHDCreationOptions options;
|
||||
options.block_size_in_sectors = blocksize;
|
||||
options.path = filenameBytes.data();
|
||||
options.parent_path = parentFilenameBytes.data();
|
||||
options.type = MVHD_TYPE_DIFF;
|
||||
options.path = filenameBytes.data();
|
||||
options.parent_path = parentFilenameBytes.data();
|
||||
options.type = MVHD_TYPE_DIFF;
|
||||
|
||||
MVHDMeta *vhd = mvhd_create_ex(options, &vhd_error);
|
||||
MVHDGeom vhd_geometry;
|
||||
MVHDGeom vhd_geometry;
|
||||
if (vhd == NULL) {
|
||||
vhd_geometry.cyl = 0;
|
||||
vhd_geometry.cyl = 0;
|
||||
vhd_geometry.heads = 0;
|
||||
vhd_geometry.spt = 0;
|
||||
vhd_geometry.spt = 0;
|
||||
} else {
|
||||
vhd_geometry = mvhd_get_geometry(vhd);
|
||||
|
||||
if (vhd_geometry.spt > 63) {
|
||||
vhd_geometry.cyl = mvhd_calc_size_sectors(&vhd_geometry) / (16 * 63);
|
||||
vhd_geometry.cyl = mvhd_calc_size_sectors(&vhd_geometry) / (16 * 63);
|
||||
vhd_geometry.heads = 16;
|
||||
vhd_geometry.spt = 63;
|
||||
vhd_geometry.spt = 63;
|
||||
}
|
||||
|
||||
mvhd_close(vhd);
|
||||
@@ -284,11 +301,13 @@ static MVHDGeom create_drive_vhd_diff(const QString& fileName, const QString& pa
|
||||
return vhd_geometry;
|
||||
}
|
||||
|
||||
void HarddiskDialog::onCreateNewFile() {
|
||||
void
|
||||
HarddiskDialog::onCreateNewFile()
|
||||
{
|
||||
|
||||
for (auto& curObject : children())
|
||||
{
|
||||
if (qobject_cast<QWidget*>(curObject)) qobject_cast<QWidget*>(curObject)->setDisabled(true);
|
||||
for (auto &curObject : children()) {
|
||||
if (qobject_cast<QWidget *>(curObject))
|
||||
qobject_cast<QWidget *>(curObject)->setDisabled(true);
|
||||
}
|
||||
|
||||
ui->progressBar->setEnabled(true);
|
||||
@@ -299,27 +318,27 @@ void HarddiskDialog::onCreateNewFile() {
|
||||
return;
|
||||
}
|
||||
|
||||
int img_format = ui->comboBoxFormat->currentIndex();
|
||||
uint32_t zero = 0;
|
||||
uint32_t base = 0x1000;
|
||||
int img_format = ui->comboBoxFormat->currentIndex();
|
||||
uint32_t zero = 0;
|
||||
uint32_t base = 0x1000;
|
||||
uint32_t sector_size = 512;
|
||||
|
||||
auto fileName = ui->fileField->fileName();
|
||||
auto fileName = ui->fileField->fileName();
|
||||
QString expectedSuffix;
|
||||
switch (img_format) {
|
||||
case IMG_FMT_HDI:
|
||||
expectedSuffix = "hdi";
|
||||
break;
|
||||
case IMG_FMT_HDX:
|
||||
expectedSuffix = "hdx";
|
||||
break;
|
||||
case IMG_FMT_VHD_FIXED:
|
||||
case IMG_FMT_VHD_DYNAMIC:
|
||||
case IMG_FMT_VHD_DIFF:
|
||||
expectedSuffix = "vhd";
|
||||
break;
|
||||
case IMG_FMT_HDI:
|
||||
expectedSuffix = "hdi";
|
||||
break;
|
||||
case IMG_FMT_HDX:
|
||||
expectedSuffix = "hdx";
|
||||
break;
|
||||
case IMG_FMT_VHD_FIXED:
|
||||
case IMG_FMT_VHD_DYNAMIC:
|
||||
case IMG_FMT_VHD_DIFF:
|
||||
expectedSuffix = "vhd";
|
||||
break;
|
||||
}
|
||||
if (! expectedSuffix.isEmpty()) {
|
||||
if (!expectedSuffix.isEmpty()) {
|
||||
QFileInfo fileInfo(fileName);
|
||||
if (fileInfo.suffix().compare(expectedSuffix, Qt::CaseInsensitive) != 0) {
|
||||
fileName = QString("%1.%2").arg(fileName, expectedSuffix);
|
||||
@@ -331,7 +350,7 @@ void HarddiskDialog::onCreateNewFile() {
|
||||
ui->fileField->setFileName(fileName);
|
||||
|
||||
QFile file(fileName);
|
||||
if (! file.open(QIODevice::WriteOnly)) {
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
QMessageBox::critical(this, tr("Unable to write file"), tr("Make sure the file is being saved to a writable directory."));
|
||||
return;
|
||||
}
|
||||
@@ -344,14 +363,14 @@ void HarddiskDialog::onCreateNewFile() {
|
||||
return;
|
||||
}
|
||||
uint32_t s = static_cast<uint32_t>(size);
|
||||
stream << zero; /* 00000000: Zero/unknown */
|
||||
stream << zero; /* 00000004: Zero/unknown */
|
||||
stream << base; /* 00000008: Offset at which data starts */
|
||||
stream << s; /* 0000000C: Full size of the data (32-bit) */
|
||||
stream << sector_size; /* 00000010: Sector size in bytes */
|
||||
stream << sectors_; /* 00000014: Sectors per cylinder */
|
||||
stream << heads_; /* 00000018: Heads per cylinder */
|
||||
stream << cylinders_; /* 0000001C: Cylinders */
|
||||
stream << zero; /* 00000000: Zero/unknown */
|
||||
stream << zero; /* 00000004: Zero/unknown */
|
||||
stream << base; /* 00000008: Offset at which data starts */
|
||||
stream << s; /* 0000000C: Full size of the data (32-bit) */
|
||||
stream << sector_size; /* 00000010: Sector size in bytes */
|
||||
stream << sectors_; /* 00000014: Sectors per cylinder */
|
||||
stream << heads_; /* 00000018: Heads per cylinder */
|
||||
stream << cylinders_; /* 0000001C: Cylinders */
|
||||
|
||||
for (int i = 0; i < 0x3f8; i++) {
|
||||
stream << zero;
|
||||
@@ -360,57 +379,50 @@ void HarddiskDialog::onCreateNewFile() {
|
||||
QDataStream stream(&file);
|
||||
stream.setByteOrder(QDataStream::LittleEndian);
|
||||
quint64 signature = 0xD778A82044445459;
|
||||
stream << signature; /* 00000000: Signature */
|
||||
stream << size; /* 00000008: Full size of the data (64-bit) */
|
||||
stream << sector_size; /* 00000010: Sector size in bytes */
|
||||
stream << sectors_; /* 00000014: Sectors per cylinder */
|
||||
stream << heads_; /* 00000018: Heads per cylinder */
|
||||
stream << cylinders_; /* 0000001C: Cylinders */
|
||||
stream << zero; /* 00000020: [Translation] Sectors per cylinder */
|
||||
stream << zero; /* 00000004: [Translation] Heads per cylinder */
|
||||
stream << signature; /* 00000000: Signature */
|
||||
stream << size; /* 00000008: Full size of the data (64-bit) */
|
||||
stream << sector_size; /* 00000010: Sector size in bytes */
|
||||
stream << sectors_; /* 00000014: Sectors per cylinder */
|
||||
stream << heads_; /* 00000018: Heads per cylinder */
|
||||
stream << cylinders_; /* 0000001C: Cylinders */
|
||||
stream << zero; /* 00000020: [Translation] Sectors per cylinder */
|
||||
stream << zero; /* 00000004: [Translation] Heads per cylinder */
|
||||
} else if (img_format >= IMG_FMT_VHD_FIXED) { /* VHD file */
|
||||
file.close();
|
||||
|
||||
MVHDGeom _86box_geometry{};
|
||||
int block_size = ui->comboBoxBlockSize->currentIndex() == 0 ? MVHD_BLOCK_LARGE : MVHD_BLOCK_SMALL;
|
||||
MVHDGeom _86box_geometry {};
|
||||
int block_size = ui->comboBoxBlockSize->currentIndex() == 0 ? MVHD_BLOCK_LARGE : MVHD_BLOCK_SMALL;
|
||||
switch (img_format) {
|
||||
case IMG_FMT_VHD_FIXED:
|
||||
{
|
||||
connect(this, &HarddiskDialog::fileProgress, this, [this] (int value) { ui->progressBar->setValue(value); QApplication::processEvents(); } );
|
||||
ui->progressBar->setVisible(true);
|
||||
[&_86box_geometry, fileName, this] {
|
||||
_86box_geometry = create_drive_vhd_fixed(fileName, this, cylinders_, heads_, sectors_);
|
||||
}();
|
||||
}
|
||||
break;
|
||||
case IMG_FMT_VHD_DYNAMIC:
|
||||
_86box_geometry = create_drive_vhd_dynamic(fileName, cylinders_, heads_, sectors_, block_size);
|
||||
break;
|
||||
case IMG_FMT_VHD_DIFF:
|
||||
QString vhdParent = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr("Select the parent VHD"),
|
||||
QString(),
|
||||
tr("VHD files") %
|
||||
util::DlgFilter({ "vhd" }) %
|
||||
tr("All files") %
|
||||
util::DlgFilter({ "*" }, true));
|
||||
case IMG_FMT_VHD_FIXED:
|
||||
{
|
||||
connect(this, &HarddiskDialog::fileProgress, this, [this](int value) { ui->progressBar->setValue(value); QApplication::processEvents(); });
|
||||
ui->progressBar->setVisible(true);
|
||||
[&_86box_geometry, fileName, this] {
|
||||
_86box_geometry = create_drive_vhd_fixed(fileName, this, cylinders_, heads_, sectors_);
|
||||
}();
|
||||
}
|
||||
break;
|
||||
case IMG_FMT_VHD_DYNAMIC:
|
||||
_86box_geometry = create_drive_vhd_dynamic(fileName, cylinders_, heads_, sectors_, block_size);
|
||||
break;
|
||||
case IMG_FMT_VHD_DIFF:
|
||||
QString vhdParent = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr("Select the parent VHD"),
|
||||
QString(),
|
||||
tr("VHD files") % util::DlgFilter({ "vhd" }) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
|
||||
if (vhdParent.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
_86box_geometry = create_drive_vhd_diff(fileName, vhdParent, block_size);
|
||||
break;
|
||||
if (vhdParent.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
_86box_geometry = create_drive_vhd_diff(fileName, vhdParent, block_size);
|
||||
break;
|
||||
}
|
||||
|
||||
if (_86box_geometry.cyl == 0 &&
|
||||
_86box_geometry.heads == 0 &&
|
||||
_86box_geometry.spt == 0)
|
||||
{
|
||||
if (_86box_geometry.cyl == 0 && _86box_geometry.heads == 0 && _86box_geometry.spt == 0) {
|
||||
QMessageBox::critical(this, tr("Unable to write file"), tr("Make sure the file is being saved to a writable directory."));
|
||||
return;
|
||||
}
|
||||
else if (img_format != IMG_FMT_VHD_DIFF) {
|
||||
} else if (img_format != IMG_FMT_VHD_DIFF) {
|
||||
QMessageBox::information(this, tr("Disk image created"), tr("Remember to partition and format the newly-created drive."));
|
||||
}
|
||||
|
||||
@@ -418,23 +430,23 @@ void HarddiskDialog::onCreateNewFile() {
|
||||
ui->lineEditHeads->setText(QString::number(_86box_geometry.heads));
|
||||
ui->lineEditSectors->setText(QString::number(_86box_geometry.spt));
|
||||
cylinders_ = _86box_geometry.cyl;
|
||||
heads_ = _86box_geometry.heads;
|
||||
sectors_ = _86box_geometry.spt;
|
||||
heads_ = _86box_geometry.heads;
|
||||
sectors_ = _86box_geometry.spt;
|
||||
setResult(QDialog::Accepted);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// formats 0, 1 and 2
|
||||
connect(this, &HarddiskDialog::fileProgress, this, [this] (int value) { ui->progressBar->setValue(value); QApplication::processEvents(); } );
|
||||
connect(this, &HarddiskDialog::fileProgress, this, [this](int value) { ui->progressBar->setValue(value); QApplication::processEvents(); });
|
||||
ui->progressBar->setVisible(true);
|
||||
[size, &file, this] {
|
||||
QDataStream stream(&file);
|
||||
stream.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
QByteArray buf(1048576, 0);
|
||||
uint64_t mibBlocks = size >> 20;
|
||||
uint64_t restBlock = size & 0xfffff;
|
||||
uint64_t mibBlocks = size >> 20;
|
||||
uint64_t restBlock = size & 0xfffff;
|
||||
|
||||
if (restBlock) {
|
||||
stream.writeRawData(buf.data(), restBlock);
|
||||
@@ -453,7 +465,9 @@ void HarddiskDialog::onCreateNewFile() {
|
||||
setResult(QDialog::Accepted);
|
||||
}
|
||||
|
||||
static void adjust_vhd_geometry_for_86box(MVHDGeom *vhd_geometry) {
|
||||
static void
|
||||
adjust_vhd_geometry_for_86box(MVHDGeom *vhd_geometry)
|
||||
{
|
||||
if (vhd_geometry->spt <= 63)
|
||||
return;
|
||||
|
||||
@@ -465,17 +479,17 @@ static void adjust_vhd_geometry_for_86box(MVHDGeom *vhd_geometry) {
|
||||
if (remainder > 0)
|
||||
desired_sectors -= remainder;
|
||||
|
||||
vhd_geometry->cyl = desired_sectors / (16 * 63);
|
||||
vhd_geometry->cyl = desired_sectors / (16 * 63);
|
||||
vhd_geometry->heads = 16;
|
||||
vhd_geometry->spt = 63;
|
||||
vhd_geometry->spt = 63;
|
||||
}
|
||||
|
||||
void HarddiskDialog::recalcSelection() {
|
||||
void
|
||||
HarddiskDialog::recalcSelection()
|
||||
{
|
||||
int selection = 127;
|
||||
for (int i = 0; i < 127; i++) {
|
||||
if ((cylinders_ == hdd_table[i][0]) &&
|
||||
(heads_ == hdd_table[i][1]) &&
|
||||
(sectors_ == hdd_table[i][2]))
|
||||
if ((cylinders_ == hdd_table[i][0]) && (heads_ == hdd_table[i][1]) && (sectors_ == hdd_table[i][2]))
|
||||
selection = i;
|
||||
}
|
||||
if ((selection == 127) && (heads_ == 16) && (sectors_ == 63)) {
|
||||
@@ -484,7 +498,9 @@ void HarddiskDialog::recalcSelection() {
|
||||
ui->comboBoxType->setCurrentIndex(selection);
|
||||
}
|
||||
|
||||
void HarddiskDialog::onExistingFileSelected(const QString &fileName) {
|
||||
void
|
||||
HarddiskDialog::onExistingFileSelected(const QString &fileName)
|
||||
{
|
||||
// TODO : Over to non-existing file selected
|
||||
/*
|
||||
if (!(existing & 1)) {
|
||||
@@ -505,16 +521,16 @@ void HarddiskDialog::onExistingFileSelected(const QString &fileName) {
|
||||
}
|
||||
*/
|
||||
|
||||
uint64_t size = 0;
|
||||
uint64_t size = 0;
|
||||
uint32_t sector_size = 0;
|
||||
uint32_t sectors = 0;
|
||||
uint32_t heads = 0;
|
||||
uint32_t cylinders = 0;
|
||||
int vhd_error = 0;
|
||||
uint32_t sectors = 0;
|
||||
uint32_t heads = 0;
|
||||
uint32_t cylinders = 0;
|
||||
int vhd_error = 0;
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
QFile file(fileName);
|
||||
if (! file.open(QIODevice::ReadOnly)) {
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
QMessageBox::critical(this, tr("Unable to read file"), tr("Make sure the file exists and is readable."));
|
||||
return;
|
||||
}
|
||||
@@ -536,7 +552,7 @@ void HarddiskDialog::onExistingFileSelected(const QString &fileName) {
|
||||
stream >> heads;
|
||||
stream >> cylinders;
|
||||
} else if (image_is_vhd(fileNameUtf8.data(), 1)) {
|
||||
MVHDMeta* vhd = mvhd_open(fileNameUtf8.data(), 0, &vhd_error);
|
||||
MVHDMeta *vhd = mvhd_open(fileNameUtf8.data(), 0, &vhd_error);
|
||||
if (vhd == nullptr) {
|
||||
QMessageBox::critical(this, tr("Unable to read file"), tr("Make sure the file exists and is readable"));
|
||||
return;
|
||||
@@ -558,9 +574,9 @@ void HarddiskDialog::onExistingFileSelected(const QString &fileName) {
|
||||
MVHDGeom vhd_geom = mvhd_get_geometry(vhd);
|
||||
adjust_vhd_geometry_for_86box(&vhd_geom);
|
||||
cylinders = vhd_geom.cyl;
|
||||
heads = vhd_geom.heads;
|
||||
sectors = vhd_geom.spt;
|
||||
size = static_cast<uint64_t>(cylinders * heads * sectors * 512);
|
||||
heads = vhd_geom.heads;
|
||||
sectors = vhd_geom.spt;
|
||||
size = static_cast<uint64_t>(cylinders * heads * sectors * 512);
|
||||
mvhd_close(vhd);
|
||||
} else {
|
||||
size = file.size();
|
||||
@@ -582,7 +598,7 @@ void HarddiskDialog::onExistingFileSelected(const QString &fileName) {
|
||||
}
|
||||
} else {
|
||||
sectors = 63;
|
||||
heads = 16;
|
||||
heads = 16;
|
||||
}
|
||||
|
||||
cylinders = ((size >> 9) / heads) / sectors;
|
||||
@@ -593,8 +609,8 @@ void HarddiskDialog::onExistingFileSelected(const QString &fileName) {
|
||||
return;
|
||||
}
|
||||
|
||||
heads_ = heads;
|
||||
sectors_ = sectors;
|
||||
heads_ = heads;
|
||||
sectors_ = sectors;
|
||||
cylinders_ = cylinders;
|
||||
ui->lineEditCylinders->setText(QString::number(cylinders));
|
||||
ui->lineEditHeads->setText(QString::number(heads));
|
||||
@@ -610,13 +626,18 @@ void HarddiskDialog::onExistingFileSelected(const QString &fileName) {
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
}
|
||||
|
||||
void HarddiskDialog::recalcSize() {
|
||||
if (disallowSizeModifications) return;
|
||||
void
|
||||
HarddiskDialog::recalcSize()
|
||||
{
|
||||
if (disallowSizeModifications)
|
||||
return;
|
||||
uint64_t size = (static_cast<uint64_t>(cylinders_) * static_cast<uint64_t>(heads_) * static_cast<uint64_t>(sectors_)) << 9;
|
||||
ui->lineEditSize->setText(QString::number(size >> 20));
|
||||
}
|
||||
|
||||
bool HarddiskDialog::checkAndAdjustSectors() {
|
||||
bool
|
||||
HarddiskDialog::checkAndAdjustSectors()
|
||||
{
|
||||
if (sectors_ > max_sectors) {
|
||||
sectors_ = max_sectors;
|
||||
ui->lineEditSectors->setText(QString::number(max_sectors));
|
||||
@@ -627,7 +648,9 @@ bool HarddiskDialog::checkAndAdjustSectors() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HarddiskDialog::checkAndAdjustHeads() {
|
||||
bool
|
||||
HarddiskDialog::checkAndAdjustHeads()
|
||||
{
|
||||
if (heads_ > max_heads) {
|
||||
heads_ = max_heads;
|
||||
ui->lineEditHeads->setText(QString::number(max_heads));
|
||||
@@ -638,7 +661,9 @@ bool HarddiskDialog::checkAndAdjustHeads() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HarddiskDialog::checkAndAdjustCylinders() {
|
||||
bool
|
||||
HarddiskDialog::checkAndAdjustCylinders()
|
||||
{
|
||||
if (cylinders_ > max_cylinders) {
|
||||
cylinders_ = max_cylinders;
|
||||
ui->lineEditCylinders->setText(QString::number(max_cylinders));
|
||||
@@ -649,44 +674,45 @@ bool HarddiskDialog::checkAndAdjustCylinders() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void HarddiskDialog::on_comboBoxBus_currentIndexChanged(int index) {
|
||||
void
|
||||
HarddiskDialog::on_comboBoxBus_currentIndexChanged(int index)
|
||||
{
|
||||
int chanIdx = 0;
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (ui->comboBoxBus->currentData().toInt()) {
|
||||
case HDD_BUS_DISABLED:
|
||||
default:
|
||||
max_sectors = max_heads = max_cylinders = 0;
|
||||
break;
|
||||
case HDD_BUS_MFM:
|
||||
max_sectors = 26; /* 17 for MFM, 26 for RLL. */
|
||||
max_heads = 15;
|
||||
max_cylinders = 2047;
|
||||
break;
|
||||
case HDD_BUS_XTA:
|
||||
max_sectors = 63;
|
||||
max_heads = 16;
|
||||
max_cylinders = 1023;
|
||||
break;
|
||||
case HDD_BUS_ESDI:
|
||||
max_sectors = 99; /* ESDI drives usually had 32 to 43 sectors per track. */
|
||||
max_heads = 16;
|
||||
max_cylinders = 266305;
|
||||
break;
|
||||
case HDD_BUS_IDE:
|
||||
max_sectors = 63;
|
||||
max_heads = 255;
|
||||
max_cylinders = 266305;
|
||||
break;
|
||||
case HDD_BUS_ATAPI:
|
||||
case HDD_BUS_SCSI:
|
||||
max_sectors = 99;
|
||||
max_heads = 255;
|
||||
max_cylinders = 266305;
|
||||
break;
|
||||
case HDD_BUS_DISABLED:
|
||||
default:
|
||||
max_sectors = max_heads = max_cylinders = 0;
|
||||
break;
|
||||
case HDD_BUS_MFM:
|
||||
max_sectors = 26; /* 17 for MFM, 26 for RLL. */
|
||||
max_heads = 15;
|
||||
max_cylinders = 2047;
|
||||
break;
|
||||
case HDD_BUS_XTA:
|
||||
max_sectors = 63;
|
||||
max_heads = 16;
|
||||
max_cylinders = 1023;
|
||||
break;
|
||||
case HDD_BUS_ESDI:
|
||||
max_sectors = 99; /* ESDI drives usually had 32 to 43 sectors per track. */
|
||||
max_heads = 16;
|
||||
max_cylinders = 266305;
|
||||
break;
|
||||
case HDD_BUS_IDE:
|
||||
max_sectors = 63;
|
||||
max_heads = 255;
|
||||
max_cylinders = 266305;
|
||||
break;
|
||||
case HDD_BUS_ATAPI:
|
||||
case HDD_BUS_SCSI:
|
||||
max_sectors = 99;
|
||||
max_heads = 255;
|
||||
max_cylinders = 266305;
|
||||
break;
|
||||
}
|
||||
|
||||
checkAndAdjustCylinders();
|
||||
@@ -710,8 +736,7 @@ void HarddiskDialog::on_comboBoxBus_currentIndexChanged(int index) {
|
||||
Harddrives::populateBusChannels(ui->comboBoxChannel->model(), ui->comboBoxBus->currentData().toInt());
|
||||
Harddrives::populateSpeeds(ui->comboBoxSpeed->model(), ui->comboBoxBus->currentData().toInt());
|
||||
|
||||
switch (ui->comboBoxBus->currentData().toInt())
|
||||
{
|
||||
switch (ui->comboBoxBus->currentData().toInt()) {
|
||||
case HDD_BUS_MFM:
|
||||
chanIdx = (Harddrives::busTrackClass->next_free_mfm_channel());
|
||||
break;
|
||||
@@ -730,13 +755,16 @@ void HarddiskDialog::on_comboBoxBus_currentIndexChanged(int index) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (chanIdx == 0xFF) chanIdx = 0;
|
||||
if (chanIdx == 0xFF)
|
||||
chanIdx = 0;
|
||||
ui->comboBoxChannel->setCurrentIndex(chanIdx);
|
||||
}
|
||||
|
||||
void HarddiskDialog::on_lineEditSize_textEdited(const QString &text) {
|
||||
void
|
||||
HarddiskDialog::on_lineEditSize_textEdited(const QString &text)
|
||||
{
|
||||
disallowSizeModifications = true;
|
||||
uint32_t size = text.toUInt();
|
||||
uint32_t size = text.toUInt();
|
||||
/* This is needed to ensure VHD standard compliance. */
|
||||
hdd_image_calc_chs(&cylinders_, &heads_, §ors_, size);
|
||||
ui->lineEditCylinders->setText(QString::number(cylinders_));
|
||||
@@ -751,7 +779,9 @@ void HarddiskDialog::on_lineEditSize_textEdited(const QString &text) {
|
||||
disallowSizeModifications = false;
|
||||
}
|
||||
|
||||
void HarddiskDialog::on_lineEditCylinders_textEdited(const QString &text) {
|
||||
void
|
||||
HarddiskDialog::on_lineEditCylinders_textEdited(const QString &text)
|
||||
{
|
||||
cylinders_ = text.toUInt();
|
||||
if (checkAndAdjustCylinders()) {
|
||||
recalcSize();
|
||||
@@ -759,7 +789,9 @@ void HarddiskDialog::on_lineEditCylinders_textEdited(const QString &text) {
|
||||
}
|
||||
}
|
||||
|
||||
void HarddiskDialog::on_lineEditHeads_textEdited(const QString &text) {
|
||||
void
|
||||
HarddiskDialog::on_lineEditHeads_textEdited(const QString &text)
|
||||
{
|
||||
heads_ = text.toUInt();
|
||||
if (checkAndAdjustHeads()) {
|
||||
recalcSize();
|
||||
@@ -767,7 +799,9 @@ void HarddiskDialog::on_lineEditHeads_textEdited(const QString &text) {
|
||||
}
|
||||
}
|
||||
|
||||
void HarddiskDialog::on_lineEditSectors_textEdited(const QString &text) {
|
||||
void
|
||||
HarddiskDialog::on_lineEditSectors_textEdited(const QString &text)
|
||||
{
|
||||
sectors_ = text.toUInt();
|
||||
if (checkAndAdjustSectors()) {
|
||||
recalcSize();
|
||||
@@ -775,21 +809,23 @@ void HarddiskDialog::on_lineEditSectors_textEdited(const QString &text) {
|
||||
}
|
||||
}
|
||||
|
||||
void HarddiskDialog::on_comboBoxType_currentIndexChanged(int index) {
|
||||
void
|
||||
HarddiskDialog::on_comboBoxType_currentIndexChanged(int index)
|
||||
{
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((index != 127) && (index != 128)) {
|
||||
cylinders_ = hdd_table[index][0];
|
||||
heads_ = hdd_table[index][1];
|
||||
sectors_ = hdd_table[index][2];
|
||||
heads_ = hdd_table[index][1];
|
||||
sectors_ = hdd_table[index][2];
|
||||
ui->lineEditCylinders->setText(QString::number(cylinders_));
|
||||
ui->lineEditHeads->setText(QString::number(heads_));
|
||||
ui->lineEditSectors->setText(QString::number(sectors_));
|
||||
recalcSize();
|
||||
} else if (index == 128) {
|
||||
heads_ = 16;
|
||||
heads_ = 16;
|
||||
sectors_ = 63;
|
||||
ui->lineEditHeads->setText(QString::number(heads_));
|
||||
ui->lineEditSectors->setText(QString::number(sectors_));
|
||||
@@ -801,9 +837,12 @@ void HarddiskDialog::on_comboBoxType_currentIndexChanged(int index) {
|
||||
checkAndAdjustSectors();
|
||||
}
|
||||
|
||||
void HarddiskDialog::accept()
|
||||
void
|
||||
HarddiskDialog::accept()
|
||||
{
|
||||
if (ui->fileField->createFile()) onCreateNewFile();
|
||||
else setResult(QDialog::Accepted);
|
||||
if (ui->fileField->createFile())
|
||||
onCreateNewFile();
|
||||
else
|
||||
setResult(QDialog::Accepted);
|
||||
QDialog::done(result());
|
||||
}
|
||||
|
||||
@@ -7,17 +7,16 @@ namespace Ui {
|
||||
class HarddiskDialog;
|
||||
}
|
||||
|
||||
class HarddiskDialog : public QDialog
|
||||
{
|
||||
class HarddiskDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HarddiskDialog(bool existing, QWidget *parent = nullptr);
|
||||
~HarddiskDialog();
|
||||
|
||||
uint8_t bus() const;
|
||||
uint8_t channel() const;
|
||||
QString fileName() const;
|
||||
uint8_t bus() const;
|
||||
uint8_t channel() const;
|
||||
QString fileName() const;
|
||||
uint32_t cylinders() const { return cylinders_; }
|
||||
uint32_t heads() const { return heads_; }
|
||||
uint32_t sectors() const { return sectors_; }
|
||||
@@ -38,7 +37,8 @@ private slots:
|
||||
void on_comboBoxBus_currentIndexChanged(int index);
|
||||
void on_comboBoxFormat_currentIndexChanged(int index);
|
||||
void onCreateNewFile();
|
||||
void onExistingFileSelected(const QString& fileName);
|
||||
void onExistingFileSelected(const QString &fileName);
|
||||
|
||||
private:
|
||||
Ui::HarddiskDialog *ui;
|
||||
|
||||
@@ -46,10 +46,10 @@ private:
|
||||
uint32_t heads_;
|
||||
uint32_t sectors_;
|
||||
|
||||
uint32_t max_sectors = 0;
|
||||
uint32_t max_heads = 0;
|
||||
uint32_t max_sectors = 0;
|
||||
uint32_t max_heads = 0;
|
||||
uint32_t max_cylinders = 0;
|
||||
|
||||
|
||||
bool disallowSizeModifications = false;
|
||||
|
||||
bool checkAndAdjustCylinders();
|
||||
|
||||
@@ -24,7 +24,9 @@ extern "C" {
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
void Harddrives::populateBuses(QAbstractItemModel *model) {
|
||||
void
|
||||
Harddrives::populateBuses(QAbstractItemModel *model)
|
||||
{
|
||||
model->removeRows(0, model->rowCount());
|
||||
model->insertRows(0, 6);
|
||||
model->setData(model->index(0, 0), "MFM/RLL");
|
||||
@@ -42,7 +44,9 @@ void Harddrives::populateBuses(QAbstractItemModel *model) {
|
||||
model->setData(model->index(5, 0), HDD_BUS_SCSI, Qt::UserRole);
|
||||
}
|
||||
|
||||
void Harddrives::populateRemovableBuses(QAbstractItemModel *model) {
|
||||
void
|
||||
Harddrives::populateRemovableBuses(QAbstractItemModel *model)
|
||||
{
|
||||
model->removeRows(0, model->rowCount());
|
||||
model->insertRows(0, 3);
|
||||
model->setData(model->index(0, 0), QObject::tr("Disabled"));
|
||||
@@ -54,7 +58,9 @@ void Harddrives::populateRemovableBuses(QAbstractItemModel *model) {
|
||||
model->setData(model->index(2, 0), HDD_BUS_SCSI, Qt::UserRole);
|
||||
}
|
||||
|
||||
void Harddrives::populateSpeeds(QAbstractItemModel *model, int bus) {
|
||||
void
|
||||
Harddrives::populateSpeeds(QAbstractItemModel *model, int bus)
|
||||
{
|
||||
int num_preset;
|
||||
|
||||
switch (bus) {
|
||||
@@ -76,29 +82,31 @@ void Harddrives::populateSpeeds(QAbstractItemModel *model, int bus) {
|
||||
}
|
||||
}
|
||||
|
||||
void Harddrives::populateBusChannels(QAbstractItemModel *model, int bus) {
|
||||
void
|
||||
Harddrives::populateBusChannels(QAbstractItemModel *model, int bus)
|
||||
{
|
||||
model->removeRows(0, model->rowCount());
|
||||
|
||||
int busRows = 0;
|
||||
int shifter = 1;
|
||||
int orer = 1;
|
||||
int busRows = 0;
|
||||
int shifter = 1;
|
||||
int orer = 1;
|
||||
int subChannelWidth = 1;
|
||||
switch (bus) {
|
||||
case HDD_BUS_MFM:
|
||||
case HDD_BUS_XTA:
|
||||
case HDD_BUS_ESDI:
|
||||
busRows = 2;
|
||||
break;
|
||||
case HDD_BUS_IDE:
|
||||
case HDD_BUS_ATAPI:
|
||||
busRows = 8;
|
||||
break;
|
||||
case HDD_BUS_SCSI:
|
||||
shifter = 4;
|
||||
orer = 15;
|
||||
busRows = 64;
|
||||
subChannelWidth = 2;
|
||||
break;
|
||||
case HDD_BUS_MFM:
|
||||
case HDD_BUS_XTA:
|
||||
case HDD_BUS_ESDI:
|
||||
busRows = 2;
|
||||
break;
|
||||
case HDD_BUS_IDE:
|
||||
case HDD_BUS_ATAPI:
|
||||
busRows = 8;
|
||||
break;
|
||||
case HDD_BUS_SCSI:
|
||||
shifter = 4;
|
||||
orer = 15;
|
||||
busRows = 64;
|
||||
subChannelWidth = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
model->insertRows(0, busRows);
|
||||
@@ -109,30 +117,32 @@ void Harddrives::populateBusChannels(QAbstractItemModel *model, int bus) {
|
||||
}
|
||||
}
|
||||
|
||||
QString Harddrives::BusChannelName(uint8_t bus, uint8_t channel) {
|
||||
QString
|
||||
Harddrives::BusChannelName(uint8_t bus, uint8_t channel)
|
||||
{
|
||||
QString busName;
|
||||
switch(bus) {
|
||||
case HDD_BUS_DISABLED:
|
||||
busName = QString(QObject::tr("Disabled"));
|
||||
break;
|
||||
case HDD_BUS_MFM:
|
||||
busName = QString("MFM/RLL (%1:%2)").arg(channel >> 1).arg(channel & 1);
|
||||
break;
|
||||
case HDD_BUS_XTA:
|
||||
busName = QString("XTA (%1:%2)").arg(channel >> 1).arg(channel & 1);
|
||||
break;
|
||||
case HDD_BUS_ESDI:
|
||||
busName = QString("ESDI (%1:%2)").arg(channel >> 1).arg(channel & 1);
|
||||
break;
|
||||
case HDD_BUS_IDE:
|
||||
busName = QString("IDE (%1:%2)").arg(channel >> 1).arg(channel & 1);
|
||||
break;
|
||||
case HDD_BUS_ATAPI:
|
||||
busName = QString("ATAPI (%1:%2)").arg(channel >> 1).arg(channel & 1);
|
||||
break;
|
||||
case HDD_BUS_SCSI:
|
||||
busName = QString("SCSI (%1:%2)").arg(channel >> 4).arg(channel & 15, 2, 10, QChar('0'));
|
||||
break;
|
||||
switch (bus) {
|
||||
case HDD_BUS_DISABLED:
|
||||
busName = QString(QObject::tr("Disabled"));
|
||||
break;
|
||||
case HDD_BUS_MFM:
|
||||
busName = QString("MFM/RLL (%1:%2)").arg(channel >> 1).arg(channel & 1);
|
||||
break;
|
||||
case HDD_BUS_XTA:
|
||||
busName = QString("XTA (%1:%2)").arg(channel >> 1).arg(channel & 1);
|
||||
break;
|
||||
case HDD_BUS_ESDI:
|
||||
busName = QString("ESDI (%1:%2)").arg(channel >> 1).arg(channel & 1);
|
||||
break;
|
||||
case HDD_BUS_IDE:
|
||||
busName = QString("IDE (%1:%2)").arg(channel >> 1).arg(channel & 1);
|
||||
break;
|
||||
case HDD_BUS_ATAPI:
|
||||
busName = QString("ATAPI (%1:%2)").arg(channel >> 1).arg(channel & 1);
|
||||
break;
|
||||
case HDD_BUS_SCSI:
|
||||
busName = QString("SCSI (%1:%2)").arg(channel >> 4).arg(channel & 15, 2, 10, QChar('0'));
|
||||
break;
|
||||
}
|
||||
|
||||
return busName;
|
||||
|
||||
@@ -7,10 +7,10 @@ class QAbstractItemModel;
|
||||
class SettingsBusTracking;
|
||||
|
||||
namespace Harddrives {
|
||||
void populateBuses(QAbstractItemModel* model);
|
||||
void populateRemovableBuses(QAbstractItemModel* model);
|
||||
void populateBusChannels(QAbstractItemModel* model, int bus);
|
||||
void populateSpeeds(QAbstractItemModel* model, int bus);
|
||||
QString BusChannelName(uint8_t bus, uint8_t channel);
|
||||
inline SettingsBusTracking* busTrackClass = nullptr;
|
||||
void populateBuses(QAbstractItemModel *model);
|
||||
void populateRemovableBuses(QAbstractItemModel *model);
|
||||
void populateBusChannels(QAbstractItemModel *model, int bus);
|
||||
void populateSpeeds(QAbstractItemModel *model, int bus);
|
||||
QString BusChannelName(uint8_t bus, uint8_t channel);
|
||||
inline SettingsBusTracking *busTrackClass = nullptr;
|
||||
};
|
||||
|
||||
@@ -33,85 +33,77 @@ extern "C" {
|
||||
#include <86box/video.h>
|
||||
}
|
||||
|
||||
void HardwareRenderer::resizeGL(int w, int h)
|
||||
void
|
||||
HardwareRenderer::resizeGL(int w, int h)
|
||||
{
|
||||
m_context->makeCurrent(this);
|
||||
glViewport(0, 0, qRound(w * devicePixelRatio()), qRound(h * devicePixelRatio()));
|
||||
}
|
||||
|
||||
#define PROGRAM_VERTEX_ATTRIBUTE 0
|
||||
#define PROGRAM_VERTEX_ATTRIBUTE 0
|
||||
#define PROGRAM_TEXCOORD_ATTRIBUTE 1
|
||||
|
||||
void HardwareRenderer::initializeGL()
|
||||
void
|
||||
HardwareRenderer::initializeGL()
|
||||
{
|
||||
m_context->makeCurrent(this);
|
||||
initializeOpenGLFunctions();
|
||||
auto image = QImage(2048, 2048, QImage::Format_RGB32);
|
||||
image.fill(0xff000000);
|
||||
m_texture = new QOpenGLTexture(image);
|
||||
m_blt = new QOpenGLTextureBlitter;
|
||||
m_blt = new QOpenGLTextureBlitter;
|
||||
m_blt->setRedBlueSwizzle(true);
|
||||
m_blt->create();
|
||||
QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, this);
|
||||
const char *vsrc =
|
||||
"attribute highp vec4 VertexCoord;\n"
|
||||
"attribute mediump vec4 TexCoord;\n"
|
||||
"varying mediump vec4 texc;\n"
|
||||
"uniform mediump mat4 MVPMatrix;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" gl_Position = MVPMatrix * VertexCoord;\n"
|
||||
" texc = TexCoord;\n"
|
||||
"}\n";
|
||||
QString vsrccore =
|
||||
"in highp vec4 VertexCoord;\n"
|
||||
"in mediump vec4 TexCoord;\n"
|
||||
"out mediump vec4 texc;\n"
|
||||
"uniform mediump mat4 MVPMatrix;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" gl_Position = MVPMatrix * VertexCoord;\n"
|
||||
" texc = TexCoord;\n"
|
||||
"}\n";
|
||||
if (m_context->isOpenGLES() && m_context->format().version() >= qMakePair(3, 0))
|
||||
{
|
||||
QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, this);
|
||||
const char *vsrc = "attribute highp vec4 VertexCoord;\n"
|
||||
"attribute mediump vec4 TexCoord;\n"
|
||||
"varying mediump vec4 texc;\n"
|
||||
"uniform mediump mat4 MVPMatrix;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" gl_Position = MVPMatrix * VertexCoord;\n"
|
||||
" texc = TexCoord;\n"
|
||||
"}\n";
|
||||
QString vsrccore = "in highp vec4 VertexCoord;\n"
|
||||
"in mediump vec4 TexCoord;\n"
|
||||
"out mediump vec4 texc;\n"
|
||||
"uniform mediump mat4 MVPMatrix;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" gl_Position = MVPMatrix * VertexCoord;\n"
|
||||
" texc = TexCoord;\n"
|
||||
"}\n";
|
||||
if (m_context->isOpenGLES() && m_context->format().version() >= qMakePair(3, 0)) {
|
||||
vsrccore.prepend("#version 300 es\n");
|
||||
vshader->compileSourceCode(vsrccore);
|
||||
}
|
||||
else if (m_context->format().version() >= qMakePair(3, 0) && m_context->format().profile() == QSurfaceFormat::CoreProfile)
|
||||
{
|
||||
} else if (m_context->format().version() >= qMakePair(3, 0) && m_context->format().profile() == QSurfaceFormat::CoreProfile) {
|
||||
vsrccore.prepend("#version 130\n");
|
||||
vshader->compileSourceCode(vsrccore);
|
||||
}
|
||||
else vshader->compileSourceCode(vsrc);
|
||||
} else
|
||||
vshader->compileSourceCode(vsrc);
|
||||
|
||||
QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, this);
|
||||
const char *fsrc =
|
||||
"uniform sampler2D texture;\n"
|
||||
"varying mediump vec4 texc;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" gl_FragColor = texture2D(texture, texc.st).bgra;\n"
|
||||
"}\n";
|
||||
QString fsrccore =
|
||||
"uniform sampler2D texture;\n"
|
||||
"in mediump vec4 texc;\n"
|
||||
"out highp vec4 FragColor;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" FragColor = texture2D(texture, texc.st).bgra;\n"
|
||||
"}\n";
|
||||
if (m_context->isOpenGLES() && m_context->format().version() >= qMakePair(3, 0))
|
||||
{
|
||||
QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, this);
|
||||
const char *fsrc = "uniform sampler2D texture;\n"
|
||||
"varying mediump vec4 texc;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" gl_FragColor = texture2D(texture, texc.st).bgra;\n"
|
||||
"}\n";
|
||||
QString fsrccore = "uniform sampler2D texture;\n"
|
||||
"in mediump vec4 texc;\n"
|
||||
"out highp vec4 FragColor;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" FragColor = texture2D(texture, texc.st).bgra;\n"
|
||||
"}\n";
|
||||
if (m_context->isOpenGLES() && m_context->format().version() >= qMakePair(3, 0)) {
|
||||
fsrccore.prepend("#version 300 es\n");
|
||||
fshader->compileSourceCode(fsrccore);
|
||||
}
|
||||
else if (m_context->format().version() >= qMakePair(3, 0) && m_context->format().profile() == QSurfaceFormat::CoreProfile)
|
||||
{
|
||||
} else if (m_context->format().version() >= qMakePair(3, 0) && m_context->format().profile() == QSurfaceFormat::CoreProfile) {
|
||||
fsrccore.prepend("#version 130\n");
|
||||
fshader->compileSourceCode(fsrccore);
|
||||
}
|
||||
else fshader->compileSourceCode(fsrc);
|
||||
} else
|
||||
fshader->compileSourceCode(fsrc);
|
||||
|
||||
m_prog = new QOpenGLShaderProgram;
|
||||
m_prog->addShader(vshader);
|
||||
@@ -144,95 +136,115 @@ void HardwareRenderer::initializeGL()
|
||||
m_context->swapBuffers(this);
|
||||
}
|
||||
|
||||
void HardwareRenderer::paintGL() {
|
||||
void
|
||||
HardwareRenderer::paintGL()
|
||||
{
|
||||
m_context->makeCurrent(this);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
QVector<QVector2D> verts, texcoords;
|
||||
QMatrix4x4 mat;
|
||||
QMatrix4x4 mat;
|
||||
mat.setToIdentity();
|
||||
mat.ortho(QRectF(0, 0, (qreal)width(), (qreal)height()));
|
||||
verts.push_back(QVector2D((float)destination.x(), (float)destination.y()));
|
||||
verts.push_back(QVector2D((float)destination.x(), (float)destination.y() + (float)destination.height()));
|
||||
verts.push_back(QVector2D((float)destination.x() + (float)destination.width(), (float)destination.y() + (float)destination.height()));
|
||||
verts.push_back(QVector2D((float)destination.x() + (float)destination.width(), (float)destination.y()));
|
||||
texcoords.push_back(QVector2D((float)source.x() / 2048.f, (float)(source.y()) / 2048.f));
|
||||
texcoords.push_back(QVector2D((float)source.x() / 2048.f, (float)(source.y() + source.height()) / 2048.f));
|
||||
texcoords.push_back(QVector2D((float)(source.x() + source.width()) / 2048.f, (float)(source.y() + source.height()) / 2048.f));
|
||||
texcoords.push_back(QVector2D((float)(source.x() + source.width()) / 2048.f, (float)(source.y()) / 2048.f));
|
||||
mat.ortho(QRectF(0, 0, (qreal) width(), (qreal) height()));
|
||||
verts.push_back(QVector2D((float) destination.x(), (float) destination.y()));
|
||||
verts.push_back(QVector2D((float) destination.x(), (float) destination.y() + (float) destination.height()));
|
||||
verts.push_back(QVector2D((float) destination.x() + (float) destination.width(), (float) destination.y() + (float) destination.height()));
|
||||
verts.push_back(QVector2D((float) destination.x() + (float) destination.width(), (float) destination.y()));
|
||||
texcoords.push_back(QVector2D((float) source.x() / 2048.f, (float) (source.y()) / 2048.f));
|
||||
texcoords.push_back(QVector2D((float) source.x() / 2048.f, (float) (source.y() + source.height()) / 2048.f));
|
||||
texcoords.push_back(QVector2D((float) (source.x() + source.width()) / 2048.f, (float) (source.y() + source.height()) / 2048.f));
|
||||
texcoords.push_back(QVector2D((float) (source.x() + source.width()) / 2048.f, (float) (source.y()) / 2048.f));
|
||||
|
||||
m_vbo[PROGRAM_VERTEX_ATTRIBUTE].bind(); m_vbo[PROGRAM_VERTEX_ATTRIBUTE].write(0, verts.data(), sizeof(QVector2D) * 4); m_vbo[PROGRAM_VERTEX_ATTRIBUTE].release();
|
||||
m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].bind(); m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].write(0, texcoords.data(), sizeof(QVector2D) * 4); m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].release();
|
||||
m_vbo[PROGRAM_VERTEX_ATTRIBUTE].bind();
|
||||
m_vbo[PROGRAM_VERTEX_ATTRIBUTE].write(0, verts.data(), sizeof(QVector2D) * 4);
|
||||
m_vbo[PROGRAM_VERTEX_ATTRIBUTE].release();
|
||||
m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].bind();
|
||||
m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].write(0, texcoords.data(), sizeof(QVector2D) * 4);
|
||||
m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].release();
|
||||
|
||||
m_prog->setUniformValue("MVPMatrix", mat);
|
||||
m_prog->enableAttributeArray(PROGRAM_VERTEX_ATTRIBUTE);
|
||||
m_prog->enableAttributeArray(PROGRAM_TEXCOORD_ATTRIBUTE);
|
||||
|
||||
m_vbo[PROGRAM_VERTEX_ATTRIBUTE].bind(); m_prog->setAttributeBuffer(PROGRAM_VERTEX_ATTRIBUTE, GL_FLOAT, 0, 2, 0); m_vbo[PROGRAM_VERTEX_ATTRIBUTE].release();
|
||||
m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].bind(); m_prog->setAttributeBuffer(PROGRAM_TEXCOORD_ATTRIBUTE, GL_FLOAT, 0, 2, 0); m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].release();
|
||||
m_vbo[PROGRAM_VERTEX_ATTRIBUTE].bind();
|
||||
m_prog->setAttributeBuffer(PROGRAM_VERTEX_ATTRIBUTE, GL_FLOAT, 0, 2, 0);
|
||||
m_vbo[PROGRAM_VERTEX_ATTRIBUTE].release();
|
||||
m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].bind();
|
||||
m_prog->setAttributeBuffer(PROGRAM_TEXCOORD_ATTRIBUTE, GL_FLOAT, 0, 2, 0);
|
||||
m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].release();
|
||||
m_texture->bind();
|
||||
m_texture->setMinMagFilters(video_filter_method ? QOpenGLTexture::Linear : QOpenGLTexture::Nearest, video_filter_method ? QOpenGLTexture::Linear : QOpenGLTexture::Nearest);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
}
|
||||
|
||||
void HardwareRenderer::setRenderType(RenderType type) {
|
||||
void
|
||||
HardwareRenderer::setRenderType(RenderType type)
|
||||
{
|
||||
QSurfaceFormat format;
|
||||
switch (type) {
|
||||
case RenderType::OpenGL3:
|
||||
format.setVersion(3, 0);
|
||||
format.setProfile(QSurfaceFormat::CoreProfile);
|
||||
case RenderType::OpenGL:
|
||||
format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||
break;
|
||||
case RenderType::OpenGLES:
|
||||
format.setRenderableType(QSurfaceFormat::OpenGLES);
|
||||
break;
|
||||
case RenderType::OpenGL3:
|
||||
format.setVersion(3, 0);
|
||||
format.setProfile(QSurfaceFormat::CoreProfile);
|
||||
case RenderType::OpenGL:
|
||||
format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||
break;
|
||||
case RenderType::OpenGLES:
|
||||
format.setRenderableType(QSurfaceFormat::OpenGLES);
|
||||
break;
|
||||
}
|
||||
format.setSwapInterval(0);
|
||||
setFormat(format);
|
||||
}
|
||||
|
||||
void HardwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h) {
|
||||
auto tval = this;
|
||||
void* nuldata = 0;
|
||||
if (memcmp(&tval, &nuldata, sizeof(void*)) == 0) return;
|
||||
void
|
||||
HardwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h)
|
||||
{
|
||||
auto tval = this;
|
||||
void *nuldata = 0;
|
||||
if (memcmp(&tval, &nuldata, sizeof(void *)) == 0)
|
||||
return;
|
||||
auto origSource = source;
|
||||
if (!m_texture || !m_texture->isCreated())
|
||||
{
|
||||
if (!m_texture || !m_texture->isCreated()) {
|
||||
buf_usage[buf_idx].clear();
|
||||
source.setRect(x, y, w, h);
|
||||
return;
|
||||
}
|
||||
m_context->makeCurrent(this);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
m_texture->setData(x, y, 0, w, h, 0, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void*)((uintptr_t)imagebufs[buf_idx].get() + (uintptr_t)(2048 * 4 * y + x * 4)), &m_transferOptions);
|
||||
m_texture->setData(x, y, 0, w, h, 0, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void *) ((uintptr_t) imagebufs[buf_idx].get() + (uintptr_t) (2048 * 4 * y + x * 4)), &m_transferOptions);
|
||||
#else
|
||||
m_texture->bind();
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 2048);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void*)((uintptr_t)imagebufs[buf_idx].get() + (uintptr_t)(2048 * 4 * y + x * 4)));
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void *) ((uintptr_t) imagebufs[buf_idx].get() + (uintptr_t) (2048 * 4 * y + x * 4)));
|
||||
m_texture->release();
|
||||
#endif
|
||||
buf_usage[buf_idx].clear();
|
||||
source.setRect(x, y, w, h);
|
||||
if (origSource != source) onResize(this->width(), this->height());
|
||||
if (origSource != source)
|
||||
onResize(this->width(), this->height());
|
||||
update();
|
||||
}
|
||||
|
||||
void HardwareRenderer::resizeEvent(QResizeEvent *event) {
|
||||
void
|
||||
HardwareRenderer::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
onResize(width(), height());
|
||||
|
||||
QOpenGLWindow::resizeEvent(event);
|
||||
}
|
||||
|
||||
bool HardwareRenderer::event(QEvent *event)
|
||||
bool
|
||||
HardwareRenderer::event(QEvent *event)
|
||||
{
|
||||
bool res = false;
|
||||
if (!eventDelegate(event, res)) return QOpenGLWindow::event(event);
|
||||
if (!eventDelegate(event, res))
|
||||
return QOpenGLWindow::event(event);
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<std::tuple<uint8_t*, std::atomic_flag*>> HardwareRenderer::getBuffers()
|
||||
std::vector<std::tuple<uint8_t *, std::atomic_flag *>>
|
||||
HardwareRenderer::getBuffers()
|
||||
{
|
||||
std::vector<std::tuple<uint8_t*, std::atomic_flag*>> buffers;
|
||||
std::vector<std::tuple<uint8_t *, std::atomic_flag *>> buffers;
|
||||
|
||||
buffers.push_back(std::make_tuple(imagebufs[0].get(), &buf_usage[0]));
|
||||
buffers.push_back(std::make_tuple(imagebufs[1].get(), &buf_usage[1]));
|
||||
|
||||
@@ -24,21 +24,20 @@
|
||||
#include "qt_renderercommon.hpp"
|
||||
|
||||
#ifdef WAYLAND
|
||||
#include "wl_mouse.hpp"
|
||||
# include "wl_mouse.hpp"
|
||||
#endif
|
||||
|
||||
class HardwareRenderer : public QOpenGLWindow, protected QOpenGLFunctions, public RendererCommon
|
||||
{
|
||||
Q_OBJECT
|
||||
class HardwareRenderer : public QOpenGLWindow, protected QOpenGLFunctions, public RendererCommon {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
bool wayland = false;
|
||||
QOpenGLContext* m_context;
|
||||
QOpenGLTexture* m_texture{nullptr};
|
||||
QOpenGLShaderProgram* m_prog{nullptr};
|
||||
QOpenGLTextureBlitter* m_blt{nullptr};
|
||||
QOpenGLBuffer m_vbo[2];
|
||||
QOpenGLVertexArrayObject m_vao;
|
||||
bool wayland = false;
|
||||
QOpenGLContext *m_context;
|
||||
QOpenGLTexture *m_texture { nullptr };
|
||||
QOpenGLShaderProgram *m_prog { nullptr };
|
||||
QOpenGLTextureBlitter *m_blt { nullptr };
|
||||
QOpenGLBuffer m_vbo[2];
|
||||
QOpenGLVertexArrayObject m_vao;
|
||||
QOpenGLPixelTransferOptions m_transferOptions;
|
||||
|
||||
public:
|
||||
@@ -50,13 +49,14 @@ public:
|
||||
void resizeGL(int w, int h) override;
|
||||
void initializeGL() override;
|
||||
void paintGL() override;
|
||||
void exposeEvent(QExposeEvent* event) override
|
||||
void exposeEvent(QExposeEvent *event) override
|
||||
{
|
||||
onResize(size().width(), size().height());
|
||||
}
|
||||
std::vector<std::tuple<uint8_t*, std::atomic_flag*>> getBuffers() override;
|
||||
HardwareRenderer(QWidget* parent = nullptr, RenderType rtype = RenderType::OpenGL)
|
||||
: QOpenGLWindow(QOpenGLWindow::NoPartialUpdate, parent->windowHandle()), QOpenGLFunctions()
|
||||
std::vector<std::tuple<uint8_t *, std::atomic_flag *>> getBuffers() override;
|
||||
HardwareRenderer(QWidget *parent = nullptr, RenderType rtype = RenderType::OpenGL)
|
||||
: QOpenGLWindow(QOpenGLWindow::NoPartialUpdate, parent->windowHandle())
|
||||
, QOpenGLFunctions()
|
||||
{
|
||||
imagebufs[0] = std::unique_ptr<uint8_t>(new uint8_t[2048 * 2048 * 4]);
|
||||
imagebufs[1] = std::unique_ptr<uint8_t>(new uint8_t[2048 * 2048 * 4]);
|
||||
@@ -80,7 +80,8 @@ public:
|
||||
~HardwareRenderer()
|
||||
{
|
||||
m_context->makeCurrent(this);
|
||||
if (m_blt) m_blt->destroy();
|
||||
if (m_blt)
|
||||
m_blt->destroy();
|
||||
m_prog->release();
|
||||
delete m_prog;
|
||||
m_prog = nullptr;
|
||||
@@ -88,7 +89,6 @@ public:
|
||||
delete m_context;
|
||||
}
|
||||
|
||||
|
||||
void setRenderType(RenderType type);
|
||||
|
||||
public slots:
|
||||
@@ -98,5 +98,5 @@ protected:
|
||||
std::array<std::unique_ptr<uint8_t>, 2> imagebufs;
|
||||
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
bool event(QEvent* event) override;
|
||||
bool event(QEvent *event) override;
|
||||
};
|
||||
|
||||
@@ -22,24 +22,23 @@ extern "C" {
|
||||
#include <86box/gameport.h>
|
||||
}
|
||||
|
||||
|
||||
#include <QLabel>
|
||||
#include <QComboBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include "qt_models_common.hpp"
|
||||
|
||||
JoystickConfiguration::JoystickConfiguration(int type, int joystick_nr, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::JoystickConfiguration),
|
||||
type(type),
|
||||
joystick_nr(joystick_nr)
|
||||
JoystickConfiguration::JoystickConfiguration(int type, int joystick_nr, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::JoystickConfiguration)
|
||||
, type(type)
|
||||
, joystick_nr(joystick_nr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
auto model = ui->comboBoxDevice->model();
|
||||
Models::AddEntry(model, "None", 0);
|
||||
for (int c = 0; c < joysticks_present; c++) {
|
||||
Models::AddEntry(model, plat_joystick_state[c].name, c+1);
|
||||
Models::AddEntry(model, plat_joystick_state[c].name, c + 1);
|
||||
}
|
||||
|
||||
ui->comboBoxDevice->setCurrentIndex(joystick_state[joystick_nr].plat_joystick_nr);
|
||||
@@ -51,35 +50,45 @@ JoystickConfiguration::~JoystickConfiguration()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
int JoystickConfiguration::selectedDevice() {
|
||||
int
|
||||
JoystickConfiguration::selectedDevice()
|
||||
{
|
||||
return ui->comboBoxDevice->currentIndex();
|
||||
}
|
||||
|
||||
int JoystickConfiguration::selectedAxis(int axis) {
|
||||
auto* cbox = findChild<QComboBox*>(QString("cboxAxis%1").arg(QString::number(axis)));
|
||||
int
|
||||
JoystickConfiguration::selectedAxis(int axis)
|
||||
{
|
||||
auto *cbox = findChild<QComboBox *>(QString("cboxAxis%1").arg(QString::number(axis)));
|
||||
if (cbox == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return cbox->currentIndex();
|
||||
}
|
||||
|
||||
int JoystickConfiguration::selectedButton(int button) {
|
||||
auto* cbox = findChild<QComboBox*>(QString("cboxButton%1").arg(QString::number(button)));
|
||||
int
|
||||
JoystickConfiguration::selectedButton(int button)
|
||||
{
|
||||
auto *cbox = findChild<QComboBox *>(QString("cboxButton%1").arg(QString::number(button)));
|
||||
if (cbox == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return cbox->currentIndex();
|
||||
}
|
||||
|
||||
int JoystickConfiguration::selectedPov(int pov) {
|
||||
auto* cbox = findChild<QComboBox*>(QString("cboxPov%1").arg(QString::number(pov)));
|
||||
int
|
||||
JoystickConfiguration::selectedPov(int pov)
|
||||
{
|
||||
auto *cbox = findChild<QComboBox *>(QString("cboxPov%1").arg(QString::number(pov)));
|
||||
if (cbox == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return cbox->currentIndex();
|
||||
}
|
||||
|
||||
void JoystickConfiguration::on_comboBoxDevice_currentIndexChanged(int index) {
|
||||
void
|
||||
JoystickConfiguration::on_comboBoxDevice_currentIndexChanged(int index)
|
||||
{
|
||||
for (auto w : widgets) {
|
||||
ui->ct->removeWidget(w);
|
||||
w->deleteLater();
|
||||
@@ -91,11 +100,11 @@ void JoystickConfiguration::on_comboBoxDevice_currentIndexChanged(int index) {
|
||||
}
|
||||
|
||||
int joystick = index - 1;
|
||||
int row = 0;
|
||||
int row = 0;
|
||||
for (int c = 0; c < joystick_get_axis_count(type); c++) {
|
||||
/*Combo box*/
|
||||
auto label = new QLabel(joystick_get_axis_name(type, c), this);
|
||||
auto cbox = new QComboBox(this);
|
||||
auto cbox = new QComboBox(this);
|
||||
cbox->setObjectName(QString("cboxAxis%1").arg(QString::number(c)));
|
||||
auto model = cbox->model();
|
||||
|
||||
@@ -135,7 +144,7 @@ void JoystickConfiguration::on_comboBoxDevice_currentIndexChanged(int index) {
|
||||
|
||||
for (int c = 0; c < joystick_get_button_count(type); c++) {
|
||||
auto label = new QLabel(joystick_get_button_name(type, c), this);
|
||||
auto cbox = new QComboBox(this);
|
||||
auto cbox = new QComboBox(this);
|
||||
cbox->setObjectName(QString("cboxButton%1").arg(QString::number(c)));
|
||||
auto model = cbox->model();
|
||||
|
||||
@@ -155,11 +164,11 @@ void JoystickConfiguration::on_comboBoxDevice_currentIndexChanged(int index) {
|
||||
}
|
||||
|
||||
for (int c = 0; c < joystick_get_pov_count(type) * 2; c++) {
|
||||
QLabel* label;
|
||||
QLabel *label;
|
||||
if (c & 1) {
|
||||
label = new QLabel(QString("%1 (Y axis)").arg(joystick_get_pov_name(type, c/2)), this);
|
||||
label = new QLabel(QString("%1 (Y axis)").arg(joystick_get_pov_name(type, c / 2)), this);
|
||||
} else {
|
||||
label = new QLabel(QString("%1 (X axis)").arg(joystick_get_pov_name(type, c/2)), this);
|
||||
label = new QLabel(QString("%1 (X axis)").arg(joystick_get_pov_name(type, c / 2)), this);
|
||||
}
|
||||
auto cbox = new QComboBox(this);
|
||||
cbox->setObjectName(QString("cboxPov%1").arg(QString::number(c)));
|
||||
@@ -179,17 +188,17 @@ void JoystickConfiguration::on_comboBoxDevice_currentIndexChanged(int index) {
|
||||
if (mapping & POV_X)
|
||||
cbox->setCurrentIndex((mapping & 3) * 2);
|
||||
else if (mapping & POV_Y)
|
||||
cbox->setCurrentIndex((mapping & 3)*2 + 1);
|
||||
cbox->setCurrentIndex((mapping & 3) * 2 + 1);
|
||||
else
|
||||
cbox->setCurrentIndex(mapping + nr_povs * 2);
|
||||
|
||||
mapping = joystick_state[joystick_nr].pov_mapping[c][1];
|
||||
if (mapping & POV_X)
|
||||
cbox->setCurrentIndex((mapping & 3)*2);
|
||||
cbox->setCurrentIndex((mapping & 3) * 2);
|
||||
else if (mapping & POV_Y)
|
||||
cbox->setCurrentIndex((mapping & 3)*2 + 1);
|
||||
cbox->setCurrentIndex((mapping & 3) * 2 + 1);
|
||||
else
|
||||
cbox->setCurrentIndex(mapping + nr_povs*2);
|
||||
cbox->setCurrentIndex(mapping + nr_povs * 2);
|
||||
|
||||
ui->ct->addWidget(label, row, 0);
|
||||
ui->ct->addWidget(cbox, row, 1);
|
||||
|
||||
@@ -7,8 +7,7 @@ namespace Ui {
|
||||
class JoystickConfiguration;
|
||||
}
|
||||
|
||||
class JoystickConfiguration : public QDialog
|
||||
{
|
||||
class JoystickConfiguration : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@@ -24,9 +23,9 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::JoystickConfiguration *ui;
|
||||
QList<QWidget*> widgets;
|
||||
int type;
|
||||
int joystick_nr;
|
||||
QList<QWidget *> widgets;
|
||||
int type;
|
||||
int joystick_nr;
|
||||
};
|
||||
|
||||
#endif // QT_JOYSTICKCONFIGURATION_HPP
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
extern "C" {
|
||||
#define EMU_CPU_H // superhack - don't want timer.h to include cpu.h here, and some combo is preventing a compile
|
||||
extern uint64_t tsc;
|
||||
extern uint64_t tsc;
|
||||
|
||||
#include <86box/hdd.h>
|
||||
#include <86box/timer.h>
|
||||
@@ -58,140 +58,154 @@ extern uint64_t tsc;
|
||||
|
||||
#include <array>
|
||||
|
||||
extern MainWindow* main_window;
|
||||
extern MainWindow *main_window;
|
||||
|
||||
namespace {
|
||||
struct PixmapSetActive {
|
||||
QPixmap normal;
|
||||
QPixmap active;
|
||||
void load(const QString& basePath);
|
||||
};
|
||||
struct PixmapSetEmpty {
|
||||
QPixmap normal;
|
||||
QPixmap empty;
|
||||
void load(const QString& basePath);
|
||||
};
|
||||
struct PixmapSetEmptyActive {
|
||||
QPixmap normal;
|
||||
QPixmap active;
|
||||
QPixmap empty;
|
||||
QPixmap empty_active;
|
||||
void load(QString basePath);
|
||||
};
|
||||
struct Pixmaps {
|
||||
PixmapSetEmpty cartridge;
|
||||
PixmapSetEmptyActive cassette;
|
||||
PixmapSetEmptyActive floppy_disabled;
|
||||
PixmapSetEmptyActive floppy_525;
|
||||
PixmapSetEmptyActive floppy_35;
|
||||
PixmapSetEmptyActive cdrom;
|
||||
PixmapSetEmptyActive zip;
|
||||
PixmapSetEmptyActive mo;
|
||||
PixmapSetActive hd;
|
||||
PixmapSetEmptyActive net;
|
||||
QPixmap sound;
|
||||
};
|
||||
struct PixmapSetActive {
|
||||
QPixmap normal;
|
||||
QPixmap active;
|
||||
void load(const QString &basePath);
|
||||
};
|
||||
struct PixmapSetEmpty {
|
||||
QPixmap normal;
|
||||
QPixmap empty;
|
||||
void load(const QString &basePath);
|
||||
};
|
||||
struct PixmapSetEmptyActive {
|
||||
QPixmap normal;
|
||||
QPixmap active;
|
||||
QPixmap empty;
|
||||
QPixmap empty_active;
|
||||
void load(QString basePath);
|
||||
};
|
||||
struct Pixmaps {
|
||||
PixmapSetEmpty cartridge;
|
||||
PixmapSetEmptyActive cassette;
|
||||
PixmapSetEmptyActive floppy_disabled;
|
||||
PixmapSetEmptyActive floppy_525;
|
||||
PixmapSetEmptyActive floppy_35;
|
||||
PixmapSetEmptyActive cdrom;
|
||||
PixmapSetEmptyActive zip;
|
||||
PixmapSetEmptyActive mo;
|
||||
PixmapSetActive hd;
|
||||
PixmapSetEmptyActive net;
|
||||
QPixmap sound;
|
||||
};
|
||||
|
||||
struct StateActive {
|
||||
std::unique_ptr<QLabel> label;
|
||||
PixmapSetActive* pixmaps = nullptr;
|
||||
bool active = false;
|
||||
struct StateActive {
|
||||
std::unique_ptr<QLabel> label;
|
||||
PixmapSetActive *pixmaps = nullptr;
|
||||
bool active = false;
|
||||
|
||||
void setActive(bool b) {
|
||||
if (!label || b == active)
|
||||
return;
|
||||
active = b;
|
||||
void setActive(bool b)
|
||||
{
|
||||
if (!label || b == active)
|
||||
return;
|
||||
active = b;
|
||||
|
||||
refresh();
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
if (!label)
|
||||
return;
|
||||
void refresh()
|
||||
{
|
||||
if (!label)
|
||||
return;
|
||||
label->setPixmap(active ? pixmaps->active : pixmaps->normal);
|
||||
}
|
||||
};
|
||||
struct StateEmpty {
|
||||
std::unique_ptr<QLabel> label;
|
||||
PixmapSetEmpty *pixmaps = nullptr;
|
||||
bool empty = false;
|
||||
|
||||
void setEmpty(bool e)
|
||||
{
|
||||
if (!label || e == empty)
|
||||
return;
|
||||
empty = e;
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
void refresh()
|
||||
{
|
||||
if (!label)
|
||||
return;
|
||||
label->setPixmap(empty ? pixmaps->empty : pixmaps->normal);
|
||||
}
|
||||
};
|
||||
struct StateEmptyActive {
|
||||
std::unique_ptr<QLabel> label;
|
||||
PixmapSetEmptyActive *pixmaps = nullptr;
|
||||
bool empty = false;
|
||||
bool active = false;
|
||||
|
||||
void setActive(bool b)
|
||||
{
|
||||
if (!label || b == active)
|
||||
return;
|
||||
|
||||
active = b;
|
||||
refresh();
|
||||
}
|
||||
void setEmpty(bool b)
|
||||
{
|
||||
if (!label || b == empty)
|
||||
return;
|
||||
|
||||
empty = b;
|
||||
refresh();
|
||||
}
|
||||
void refresh()
|
||||
{
|
||||
if (!label)
|
||||
return;
|
||||
if (empty) {
|
||||
label->setPixmap(active ? pixmaps->empty_active : pixmaps->empty);
|
||||
} else {
|
||||
label->setPixmap(active ? pixmaps->active : pixmaps->normal);
|
||||
}
|
||||
};
|
||||
struct StateEmpty {
|
||||
std::unique_ptr<QLabel> label;
|
||||
PixmapSetEmpty* pixmaps = nullptr;
|
||||
bool empty = false;
|
||||
|
||||
void setEmpty(bool e) {
|
||||
if (!label || e == empty)
|
||||
return;
|
||||
empty = e;
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
if (!label)
|
||||
return;
|
||||
label->setPixmap(empty ? pixmaps->empty : pixmaps->normal);
|
||||
}
|
||||
};
|
||||
struct StateEmptyActive {
|
||||
std::unique_ptr<QLabel> label;
|
||||
PixmapSetEmptyActive* pixmaps = nullptr;
|
||||
bool empty = false;
|
||||
bool active = false;
|
||||
|
||||
void setActive(bool b) {
|
||||
if (!label || b == active)
|
||||
return;
|
||||
|
||||
active = b;
|
||||
refresh();
|
||||
}
|
||||
void setEmpty(bool b) {
|
||||
if (!label || b == empty)
|
||||
return;
|
||||
|
||||
empty = b;
|
||||
refresh();
|
||||
}
|
||||
void refresh() {
|
||||
if (!label)
|
||||
return;
|
||||
if (empty) {
|
||||
label->setPixmap(active ? pixmaps->empty_active : pixmaps->empty);
|
||||
} else {
|
||||
label->setPixmap(active ? pixmaps->active : pixmaps->normal);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static QSize pixmap_size(16, 16);
|
||||
static const QString pixmap_empty = QStringLiteral("_empty");
|
||||
static const QString pixmap_active = QStringLiteral("_active");
|
||||
static const QString pixmap_empty_active = QStringLiteral("_empty_active");
|
||||
void PixmapSetEmpty::load(const QString &basePath) {
|
||||
normal = ProgSettings::loadIcon(basePath.arg(QStringLiteral(""))).pixmap(pixmap_size);
|
||||
empty = ProgSettings::loadIcon(basePath.arg(pixmap_empty)).pixmap(pixmap_size);
|
||||
}
|
||||
};
|
||||
|
||||
void PixmapSetActive::load(const QString &basePath) {
|
||||
normal = ProgSettings::loadIcon(basePath.arg(QStringLiteral(""))).pixmap(pixmap_size);
|
||||
active = ProgSettings::loadIcon(basePath.arg(pixmap_active)).pixmap(pixmap_size);
|
||||
}
|
||||
static QSize pixmap_size(16, 16);
|
||||
static const QString pixmap_empty = QStringLiteral("_empty");
|
||||
static const QString pixmap_active = QStringLiteral("_active");
|
||||
static const QString pixmap_empty_active = QStringLiteral("_empty_active");
|
||||
void
|
||||
PixmapSetEmpty::load(const QString &basePath)
|
||||
{
|
||||
normal = ProgSettings::loadIcon(basePath.arg(QStringLiteral(""))).pixmap(pixmap_size);
|
||||
empty = ProgSettings::loadIcon(basePath.arg(pixmap_empty)).pixmap(pixmap_size);
|
||||
}
|
||||
|
||||
void PixmapSetEmptyActive::load(QString basePath) {
|
||||
normal = ProgSettings::loadIcon(basePath.arg(QStringLiteral(""))).pixmap(pixmap_size);
|
||||
active = ProgSettings::loadIcon(basePath.arg(pixmap_active)).pixmap(pixmap_size);
|
||||
empty = ProgSettings::loadIcon(basePath.arg(pixmap_empty)).pixmap(pixmap_size);
|
||||
empty_active = ProgSettings::loadIcon(basePath.arg(pixmap_empty_active)).pixmap(pixmap_size);
|
||||
}
|
||||
void
|
||||
PixmapSetActive::load(const QString &basePath)
|
||||
{
|
||||
normal = ProgSettings::loadIcon(basePath.arg(QStringLiteral(""))).pixmap(pixmap_size);
|
||||
active = ProgSettings::loadIcon(basePath.arg(pixmap_active)).pixmap(pixmap_size);
|
||||
}
|
||||
|
||||
void
|
||||
PixmapSetEmptyActive::load(QString basePath)
|
||||
{
|
||||
normal = ProgSettings::loadIcon(basePath.arg(QStringLiteral(""))).pixmap(pixmap_size);
|
||||
active = ProgSettings::loadIcon(basePath.arg(pixmap_active)).pixmap(pixmap_size);
|
||||
empty = ProgSettings::loadIcon(basePath.arg(pixmap_empty)).pixmap(pixmap_size);
|
||||
empty_active = ProgSettings::loadIcon(basePath.arg(pixmap_empty_active)).pixmap(pixmap_size);
|
||||
}
|
||||
}
|
||||
|
||||
struct MachineStatus::States {
|
||||
Pixmaps pixmaps;
|
||||
|
||||
States(QObject* parent) {
|
||||
States(QObject *parent)
|
||||
{
|
||||
pixmaps.cartridge.load("/cartridge%1.ico");
|
||||
pixmaps.cassette.load("/cassette%1.ico");
|
||||
pixmaps.floppy_disabled.normal = ProgSettings::loadIcon(QStringLiteral("/floppy_disabled.ico")).pixmap(pixmap_size);
|
||||
pixmaps.floppy_disabled.active = pixmaps.floppy_disabled.normal;
|
||||
pixmaps.floppy_disabled.empty = pixmaps.floppy_disabled.normal;
|
||||
pixmaps.floppy_disabled.normal = ProgSettings::loadIcon(QStringLiteral("/floppy_disabled.ico")).pixmap(pixmap_size);
|
||||
pixmaps.floppy_disabled.active = pixmaps.floppy_disabled.normal;
|
||||
pixmaps.floppy_disabled.empty = pixmaps.floppy_disabled.normal;
|
||||
pixmaps.floppy_disabled.empty_active = pixmaps.floppy_disabled.normal;
|
||||
pixmaps.floppy_525.load("/floppy_525%1.ico");
|
||||
pixmaps.floppy_35.load("/floppy_35%1.ico");
|
||||
@@ -204,42 +218,42 @@ struct MachineStatus::States {
|
||||
|
||||
cartridge[0].pixmaps = &pixmaps.cartridge;
|
||||
cartridge[1].pixmaps = &pixmaps.cartridge;
|
||||
cassette.pixmaps = &pixmaps.cassette;
|
||||
for (auto& f : fdd) {
|
||||
cassette.pixmaps = &pixmaps.cassette;
|
||||
for (auto &f : fdd) {
|
||||
f.pixmaps = &pixmaps.floppy_disabled;
|
||||
}
|
||||
for (auto& c : cdrom) {
|
||||
for (auto &c : cdrom) {
|
||||
c.pixmaps = &pixmaps.cdrom;
|
||||
}
|
||||
for (auto& z : zip) {
|
||||
for (auto &z : zip) {
|
||||
z.pixmaps = &pixmaps.zip;
|
||||
}
|
||||
for (auto& m : mo) {
|
||||
for (auto &m : mo) {
|
||||
m.pixmaps = &pixmaps.mo;
|
||||
}
|
||||
for (auto& h : hdds) {
|
||||
for (auto &h : hdds) {
|
||||
h.pixmaps = &pixmaps.hd;
|
||||
}
|
||||
for (auto& n : net) {
|
||||
for (auto &n : net) {
|
||||
n.pixmaps = &pixmaps.net;
|
||||
}
|
||||
}
|
||||
|
||||
std::array<StateEmpty, 2> cartridge;
|
||||
StateEmptyActive cassette;
|
||||
std::array<StateEmptyActive, FDD_NUM> fdd;
|
||||
std::array<StateEmptyActive, CDROM_NUM> cdrom;
|
||||
std::array<StateEmptyActive, ZIP_NUM> zip;
|
||||
std::array<StateEmptyActive, MO_NUM> mo;
|
||||
std::array<StateActive, HDD_BUS_USB> hdds;
|
||||
std::array<StateEmpty, 2> cartridge;
|
||||
StateEmptyActive cassette;
|
||||
std::array<StateEmptyActive, FDD_NUM> fdd;
|
||||
std::array<StateEmptyActive, CDROM_NUM> cdrom;
|
||||
std::array<StateEmptyActive, ZIP_NUM> zip;
|
||||
std::array<StateEmptyActive, MO_NUM> mo;
|
||||
std::array<StateActive, HDD_BUS_USB> hdds;
|
||||
std::array<StateEmptyActive, NET_CARD_MAX> net;
|
||||
std::unique_ptr<ClickableLabel> sound;
|
||||
std::unique_ptr<QLabel> text;
|
||||
std::unique_ptr<ClickableLabel> sound;
|
||||
std::unique_ptr<QLabel> text;
|
||||
};
|
||||
|
||||
MachineStatus::MachineStatus(QObject *parent) :
|
||||
QObject(parent),
|
||||
refreshTimer(new QTimer(this))
|
||||
MachineStatus::MachineStatus(QObject *parent)
|
||||
: QObject(parent)
|
||||
, refreshTimer(new QTimer(this))
|
||||
{
|
||||
d = std::make_unique<MachineStatus::States>(this);
|
||||
connect(refreshTimer, &QTimer::timeout, this, &MachineStatus::refreshIcons);
|
||||
@@ -248,19 +262,27 @@ MachineStatus::MachineStatus(QObject *parent) :
|
||||
|
||||
MachineStatus::~MachineStatus() = default;
|
||||
|
||||
bool MachineStatus::hasCassette() {
|
||||
bool
|
||||
MachineStatus::hasCassette()
|
||||
{
|
||||
return cassette_enable > 0 ? true : false;
|
||||
}
|
||||
|
||||
bool MachineStatus::hasIDE() {
|
||||
bool
|
||||
MachineStatus::hasIDE()
|
||||
{
|
||||
return machine_has_flags(machine, MACHINE_IDE_QUAD) > 0;
|
||||
}
|
||||
|
||||
bool MachineStatus::hasSCSI() {
|
||||
bool
|
||||
MachineStatus::hasSCSI()
|
||||
{
|
||||
return machine_has_flags(machine, MACHINE_SCSI_DUAL) > 0;
|
||||
}
|
||||
|
||||
void MachineStatus::iterateFDD(const std::function<void (int)> &cb) {
|
||||
void
|
||||
MachineStatus::iterateFDD(const std::function<void(int)> &cb)
|
||||
{
|
||||
for (int i = 0; i < FDD_NUM; ++i) {
|
||||
if (fdd_get_type(i) != 0) {
|
||||
cb(i);
|
||||
@@ -268,17 +290,15 @@ void MachineStatus::iterateFDD(const std::function<void (int)> &cb) {
|
||||
}
|
||||
}
|
||||
|
||||
void MachineStatus::iterateCDROM(const std::function<void (int)> &cb) {
|
||||
void
|
||||
MachineStatus::iterateCDROM(const std::function<void(int)> &cb)
|
||||
{
|
||||
auto hdc_name = QString(hdc_get_internal_name(hdc_current));
|
||||
for (size_t i = 0; i < CDROM_NUM; i++) {
|
||||
/* Could be Internal or External IDE.. */
|
||||
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) &&
|
||||
!hasIDE() && hdc_name.left(3) != QStringLiteral("ide") &&
|
||||
hdc_name.left(5) != QStringLiteral("xtide"))
|
||||
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && !hasIDE() && hdc_name.left(3) != QStringLiteral("ide") && hdc_name.left(5) != QStringLiteral("xtide"))
|
||||
continue;
|
||||
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && !hasSCSI() &&
|
||||
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
|
||||
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
|
||||
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && !hasSCSI() && (scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) && (scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
|
||||
continue;
|
||||
if (cdrom[i].bus_type != 0) {
|
||||
cb(i);
|
||||
@@ -286,17 +306,15 @@ void MachineStatus::iterateCDROM(const std::function<void (int)> &cb) {
|
||||
}
|
||||
}
|
||||
|
||||
void MachineStatus::iterateZIP(const std::function<void (int)> &cb) {
|
||||
void
|
||||
MachineStatus::iterateZIP(const std::function<void(int)> &cb)
|
||||
{
|
||||
auto hdc_name = QString(hdc_get_internal_name(hdc_current));
|
||||
for (size_t i = 0; i < ZIP_NUM; i++) {
|
||||
/* Could be Internal or External IDE.. */
|
||||
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) &&
|
||||
!hasIDE() && hdc_name.left(3) != QStringLiteral("ide") &&
|
||||
hdc_name.left(5) != QStringLiteral("xtide"))
|
||||
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && !hasIDE() && hdc_name.left(3) != QStringLiteral("ide") && hdc_name.left(5) != QStringLiteral("xtide"))
|
||||
continue;
|
||||
if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) && !hasSCSI() &&
|
||||
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
|
||||
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
|
||||
if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) && !hasSCSI() && (scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) && (scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
|
||||
continue;
|
||||
if (zip_drives[i].bus_type != 0) {
|
||||
cb(i);
|
||||
@@ -304,17 +322,15 @@ void MachineStatus::iterateZIP(const std::function<void (int)> &cb) {
|
||||
}
|
||||
}
|
||||
|
||||
void MachineStatus::iterateMO(const std::function<void (int)> &cb) {
|
||||
void
|
||||
MachineStatus::iterateMO(const std::function<void(int)> &cb)
|
||||
{
|
||||
auto hdc_name = QString(hdc_get_internal_name(hdc_current));
|
||||
for (size_t i = 0; i < MO_NUM; i++) {
|
||||
/* Could be Internal or External IDE.. */
|
||||
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) &&
|
||||
!hasIDE() && hdc_name.left(3) != QStringLiteral("ide") &&
|
||||
hdc_name.left(5) != QStringLiteral("xtide"))
|
||||
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && !hasIDE() && hdc_name.left(3) != QStringLiteral("ide") && hdc_name.left(5) != QStringLiteral("xtide"))
|
||||
continue;
|
||||
if ((mo_drives[i].bus_type == MO_BUS_SCSI) && !hasSCSI() &&
|
||||
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
|
||||
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
|
||||
if ((mo_drives[i].bus_type == MO_BUS_SCSI) && !hasSCSI() && (scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) && (scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
|
||||
continue;
|
||||
if (mo_drives[i].bus_type != 0) {
|
||||
cb(i);
|
||||
@@ -322,7 +338,9 @@ void MachineStatus::iterateMO(const std::function<void (int)> &cb) {
|
||||
}
|
||||
}
|
||||
|
||||
void MachineStatus::iterateNIC(const std::function<void (int)> &cb) {
|
||||
void
|
||||
MachineStatus::iterateNIC(const std::function<void(int)> &cb)
|
||||
{
|
||||
for (int i = 0; i < NET_CARD_MAX; i++) {
|
||||
if (network_dev_available(i)) {
|
||||
cb(i);
|
||||
@@ -330,7 +348,9 @@ void MachineStatus::iterateNIC(const std::function<void (int)> &cb) {
|
||||
}
|
||||
}
|
||||
|
||||
static int hdd_count(int bus) {
|
||||
static int
|
||||
hdd_count(int bus)
|
||||
{
|
||||
int c = 0;
|
||||
int i;
|
||||
|
||||
@@ -340,10 +360,12 @@ static int hdd_count(int bus) {
|
||||
}
|
||||
}
|
||||
|
||||
return(c);
|
||||
return (c);
|
||||
}
|
||||
|
||||
void MachineStatus::refreshIcons() {
|
||||
void
|
||||
MachineStatus::refreshIcons()
|
||||
{
|
||||
for (size_t i = 0; i < FDD_NUM; ++i) {
|
||||
d->fdd[i].setActive(machine_status.fdd[i].active);
|
||||
d->fdd[i].setEmpty(machine_status.fdd[i].empty);
|
||||
@@ -375,18 +397,19 @@ void MachineStatus::refreshIcons() {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
d->cartridge[i].setEmpty(machine_status.cartridge[i].empty);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
bool has_mfm = machine_has_flags(machine, MACHINE_MFM) > 0;
|
||||
bool has_xta = machine_has_flags(machine, MACHINE_XTA) > 0;
|
||||
void
|
||||
MachineStatus::refresh(QStatusBar *sbar)
|
||||
{
|
||||
bool has_mfm = machine_has_flags(machine, MACHINE_MFM) > 0;
|
||||
bool has_xta = machine_has_flags(machine, MACHINE_XTA) > 0;
|
||||
bool has_esdi = machine_has_flags(machine, MACHINE_ESDI) > 0;
|
||||
|
||||
int c_mfm = hdd_count(HDD_BUS_MFM);
|
||||
int c_mfm = hdd_count(HDD_BUS_MFM);
|
||||
int c_esdi = hdd_count(HDD_BUS_ESDI);
|
||||
int c_xta = hdd_count(HDD_BUS_XTA);
|
||||
int c_ide = hdd_count(HDD_BUS_IDE);
|
||||
int c_xta = hdd_count(HDD_BUS_XTA);
|
||||
int c_ide = hdd_count(HDD_BUS_IDE);
|
||||
int c_scsi = hdd_count(HDD_BUS_SCSI);
|
||||
|
||||
sbar->removeWidget(d->cassette.label.get());
|
||||
@@ -417,10 +440,10 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
d->cassette.label = std::make_unique<ClickableLabel>();
|
||||
d->cassette.setEmpty(QString(cassette_fname).isEmpty());
|
||||
d->cassette.refresh();
|
||||
connect((ClickableLabel*)d->cassette.label.get(), &ClickableLabel::clicked, [](QPoint pos) {
|
||||
connect((ClickableLabel *) d->cassette.label.get(), &ClickableLabel::clicked, [](QPoint pos) {
|
||||
MediaMenu::ptr->cassetteMenu->popup(pos - QPoint(0, MediaMenu::ptr->cassetteMenu->sizeHint().height()));
|
||||
});
|
||||
connect((ClickableLabel*)d->cassette.label.get(), &ClickableLabel::dropped, [](QString str) {
|
||||
connect((ClickableLabel *) d->cassette.label.get(), &ClickableLabel::dropped, [](QString str) {
|
||||
MediaMenu::ptr->cassetteMount(str, false);
|
||||
});
|
||||
d->cassette.label->setToolTip(MediaMenu::ptr->cassetteMenu->title());
|
||||
@@ -433,10 +456,10 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
d->cartridge[i].label = std::make_unique<ClickableLabel>();
|
||||
d->cartridge[i].setEmpty(QString(cart_fns[i]).isEmpty());
|
||||
d->cartridge[i].refresh();
|
||||
connect((ClickableLabel*)d->cartridge[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
connect((ClickableLabel *) d->cartridge[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
MediaMenu::ptr->cartridgeMenus[i]->popup(pos - QPoint(0, MediaMenu::ptr->cartridgeMenus[i]->sizeHint().height()));
|
||||
});
|
||||
connect((ClickableLabel*)d->cartridge[i].label.get(), &ClickableLabel::dropped, [i](QString str) {
|
||||
connect((ClickableLabel *) d->cartridge[i].label.get(), &ClickableLabel::dropped, [i](QString str) {
|
||||
MediaMenu::ptr->cartridgeMount(i, str);
|
||||
});
|
||||
d->cartridge[i].label->setToolTip(MediaMenu::ptr->cartridgeMenus[i]->title());
|
||||
@@ -458,10 +481,10 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
d->fdd[i].setEmpty(QString(floppyfns[i]).isEmpty());
|
||||
d->fdd[i].setActive(false);
|
||||
d->fdd[i].refresh();
|
||||
connect((ClickableLabel*)d->fdd[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
connect((ClickableLabel *) d->fdd[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
MediaMenu::ptr->floppyMenus[i]->popup(pos - QPoint(0, MediaMenu::ptr->floppyMenus[i]->sizeHint().height()));
|
||||
});
|
||||
connect((ClickableLabel*)d->fdd[i].label.get(), &ClickableLabel::dropped, [i](QString str) {
|
||||
connect((ClickableLabel *) d->fdd[i].label.get(), &ClickableLabel::dropped, [i](QString str) {
|
||||
MediaMenu::ptr->floppyMount(i, str, false);
|
||||
});
|
||||
d->fdd[i].label->setToolTip(MediaMenu::ptr->floppyMenus[i]->title());
|
||||
@@ -474,10 +497,10 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
d->cdrom[i].setEmpty(cdrom[i].host_drive != 200 || QString(cdrom[i].image_path).isEmpty());
|
||||
d->cdrom[i].setActive(false);
|
||||
d->cdrom[i].refresh();
|
||||
connect((ClickableLabel*)d->cdrom[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
connect((ClickableLabel *) d->cdrom[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
MediaMenu::ptr->cdromMenus[i]->popup(pos - QPoint(0, MediaMenu::ptr->cdromMenus[i]->sizeHint().height()));
|
||||
});
|
||||
connect((ClickableLabel*)d->cdrom[i].label.get(), &ClickableLabel::dropped, [i](QString str) {
|
||||
connect((ClickableLabel *) d->cdrom[i].label.get(), &ClickableLabel::dropped, [i](QString str) {
|
||||
MediaMenu::ptr->cdromMount(i, str);
|
||||
});
|
||||
d->cdrom[i].label->setToolTip(MediaMenu::ptr->cdromMenus[i]->title());
|
||||
@@ -490,10 +513,10 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
d->zip[i].setEmpty(QString(zip_drives[i].image_path).isEmpty());
|
||||
d->zip[i].setActive(false);
|
||||
d->zip[i].refresh();
|
||||
connect((ClickableLabel*)d->zip[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
connect((ClickableLabel *) d->zip[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
MediaMenu::ptr->zipMenus[i]->popup(pos - QPoint(0, MediaMenu::ptr->zipMenus[i]->sizeHint().height()));
|
||||
});
|
||||
connect((ClickableLabel*)d->zip[i].label.get(), &ClickableLabel::dropped, [i](QString str) {
|
||||
connect((ClickableLabel *) d->zip[i].label.get(), &ClickableLabel::dropped, [i](QString str) {
|
||||
MediaMenu::ptr->zipMount(i, str, false);
|
||||
});
|
||||
d->zip[i].label->setToolTip(MediaMenu::ptr->zipMenus[i]->title());
|
||||
@@ -506,10 +529,10 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
d->mo[i].setEmpty(QString(mo_drives[i].image_path).isEmpty());
|
||||
d->mo[i].setActive(false);
|
||||
d->mo[i].refresh();
|
||||
connect((ClickableLabel*)d->mo[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
connect((ClickableLabel *) d->mo[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
MediaMenu::ptr->moMenus[i]->popup(pos - QPoint(0, MediaMenu::ptr->moMenus[i]->sizeHint().height()));
|
||||
});
|
||||
connect((ClickableLabel*)d->mo[i].label.get(), &ClickableLabel::dropped, [i](QString str) {
|
||||
connect((ClickableLabel *) d->mo[i].label.get(), &ClickableLabel::dropped, [i](QString str) {
|
||||
MediaMenu::ptr->moMount(i, str, false);
|
||||
});
|
||||
d->mo[i].label->setToolTip(MediaMenu::ptr->moMenus[i]->title());
|
||||
@@ -523,7 +546,7 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
d->net[i].setActive(false);
|
||||
d->net[i].refresh();
|
||||
d->net[i].label->setToolTip(MediaMenu::ptr->netMenus[i]->title());
|
||||
connect((ClickableLabel*)d->net[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
connect((ClickableLabel *) d->net[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||
MediaMenu::ptr->netMenus[i]->popup(pos - QPoint(0, MediaMenu::ptr->netMenus[i]->sizeHint().height()));
|
||||
});
|
||||
sbar->addWidget(d->net[i].label.get());
|
||||
@@ -558,8 +581,7 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
d->hdds[HDD_BUS_IDE].label->setToolTip(tr("Hard disk (%s)").replace("%s", "IDE"));
|
||||
sbar->addWidget(d->hdds[HDD_BUS_IDE].label.get());
|
||||
}
|
||||
if ((hasSCSI() || (scsi_card_current[0] != 0) || (scsi_card_current[1] != 0) ||
|
||||
(scsi_card_current[2] != 0) || (scsi_card_current[3] != 0)) && c_scsi > 0) {
|
||||
if ((hasSCSI() || (scsi_card_current[0] != 0) || (scsi_card_current[1] != 0) || (scsi_card_current[2] != 0) || (scsi_card_current[3] != 0)) && c_scsi > 0) {
|
||||
d->hdds[HDD_BUS_SCSI].label = std::make_unique<QLabel>();
|
||||
d->hdds[HDD_BUS_SCSI].setActive(false);
|
||||
d->hdds[HDD_BUS_SCSI].refresh();
|
||||
@@ -580,45 +602,57 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
||||
sbar->addWidget(d->text.get());
|
||||
}
|
||||
|
||||
void MachineStatus::message(const QString &msg) {
|
||||
void
|
||||
MachineStatus::message(const QString &msg)
|
||||
{
|
||||
d->text->setText(msg);
|
||||
}
|
||||
|
||||
QString MachineStatus::getMessage() {
|
||||
QString
|
||||
MachineStatus::getMessage()
|
||||
{
|
||||
return d->text->text();
|
||||
}
|
||||
|
||||
void MachineStatus::updateTip(int tag)
|
||||
void
|
||||
MachineStatus::updateTip(int tag)
|
||||
{
|
||||
int category = tag & 0xfffffff0;
|
||||
int item = tag & 0xf;
|
||||
if (!MediaMenu::ptr) return;
|
||||
int item = tag & 0xf;
|
||||
if (!MediaMenu::ptr)
|
||||
return;
|
||||
switch (category) {
|
||||
case SB_CASSETTE:
|
||||
if (d->cassette.label && MediaMenu::ptr->cassetteMenu) d->cassette.label->setToolTip(MediaMenu::ptr->cassetteMenu->title());
|
||||
break;
|
||||
case SB_CARTRIDGE:
|
||||
if (d->cartridge[item].label && MediaMenu::ptr->cartridgeMenus[item]) d->cartridge[item].label->setToolTip(MediaMenu::ptr->cartridgeMenus[item]->title());
|
||||
break;
|
||||
case SB_FLOPPY:
|
||||
if (d->fdd[item].label && MediaMenu::ptr->floppyMenus[item]) d->fdd[item].label->setToolTip(MediaMenu::ptr->floppyMenus[item]->title());
|
||||
break;
|
||||
case SB_CDROM:
|
||||
if (d->cdrom[item].label && MediaMenu::ptr->cdromMenus[item]) d->cdrom[item].label->setToolTip(MediaMenu::ptr->cdromMenus[item]->title());
|
||||
break;
|
||||
case SB_ZIP:
|
||||
if (d->zip[item].label && MediaMenu::ptr->zipMenus[item]) d->zip[item].label->setToolTip(MediaMenu::ptr->zipMenus[item]->title());
|
||||
break;
|
||||
case SB_MO:
|
||||
if (d->mo[item].label && MediaMenu::ptr->moMenus[item]) d->mo[item].label->setToolTip(MediaMenu::ptr->moMenus[item]->title());
|
||||
break;
|
||||
case SB_HDD:
|
||||
break;
|
||||
case SB_NETWORK:
|
||||
break;
|
||||
case SB_SOUND:
|
||||
break;
|
||||
case SB_TEXT:
|
||||
break;
|
||||
case SB_CASSETTE:
|
||||
if (d->cassette.label && MediaMenu::ptr->cassetteMenu)
|
||||
d->cassette.label->setToolTip(MediaMenu::ptr->cassetteMenu->title());
|
||||
break;
|
||||
case SB_CARTRIDGE:
|
||||
if (d->cartridge[item].label && MediaMenu::ptr->cartridgeMenus[item])
|
||||
d->cartridge[item].label->setToolTip(MediaMenu::ptr->cartridgeMenus[item]->title());
|
||||
break;
|
||||
case SB_FLOPPY:
|
||||
if (d->fdd[item].label && MediaMenu::ptr->floppyMenus[item])
|
||||
d->fdd[item].label->setToolTip(MediaMenu::ptr->floppyMenus[item]->title());
|
||||
break;
|
||||
case SB_CDROM:
|
||||
if (d->cdrom[item].label && MediaMenu::ptr->cdromMenus[item])
|
||||
d->cdrom[item].label->setToolTip(MediaMenu::ptr->cdromMenus[item]->title());
|
||||
break;
|
||||
case SB_ZIP:
|
||||
if (d->zip[item].label && MediaMenu::ptr->zipMenus[item])
|
||||
d->zip[item].label->setToolTip(MediaMenu::ptr->zipMenus[item]->title());
|
||||
break;
|
||||
case SB_MO:
|
||||
if (d->mo[item].label && MediaMenu::ptr->moMenus[item])
|
||||
d->mo[item].label->setToolTip(MediaMenu::ptr->moMenus[item]->title());
|
||||
break;
|
||||
case SB_HDD:
|
||||
break;
|
||||
case SB_NETWORK:
|
||||
break;
|
||||
case SB_SOUND:
|
||||
break;
|
||||
case SB_TEXT:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,47 +12,48 @@ class QStatusBar;
|
||||
|
||||
class ClickableLabel : public QLabel {
|
||||
Q_OBJECT;
|
||||
public:
|
||||
explicit ClickableLabel(QWidget* parent = nullptr)
|
||||
: QLabel(parent) {}
|
||||
~ClickableLabel() {};
|
||||
|
||||
signals:
|
||||
void clicked(QPoint);
|
||||
void doubleClicked(QPoint);
|
||||
void dropped(QString);
|
||||
public:
|
||||
explicit ClickableLabel(QWidget *parent = nullptr)
|
||||
: QLabel(parent)
|
||||
{
|
||||
}
|
||||
~ClickableLabel() {};
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* event) override { emit clicked(event->globalPos()); }
|
||||
void mouseDoubleClickEvent(QMouseEvent* event) override { emit doubleClicked(event->globalPos()); }
|
||||
void dragEnterEvent(QDragEnterEvent* event) override
|
||||
{
|
||||
if (event->mimeData()->hasUrls() && event->mimeData()->urls().size() == 1) {
|
||||
event->setDropAction(Qt::CopyAction);
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
else event->ignore();
|
||||
}
|
||||
void dragMoveEvent(QDragMoveEvent* event) override
|
||||
{
|
||||
if (event->mimeData()->hasUrls() && event->mimeData()->urls().size() == 1) {
|
||||
event->setDropAction(Qt::CopyAction);
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
else event->ignore();
|
||||
}
|
||||
void dropEvent(QDropEvent* event) override
|
||||
{
|
||||
if (event->dropAction() == Qt::CopyAction)
|
||||
{
|
||||
emit dropped(event->mimeData()->urls()[0].toLocalFile());
|
||||
}
|
||||
else event->ignore();
|
||||
}
|
||||
signals:
|
||||
void clicked(QPoint);
|
||||
void doubleClicked(QPoint);
|
||||
void dropped(QString);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event) override { emit clicked(event->globalPos()); }
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) override { emit doubleClicked(event->globalPos()); }
|
||||
void dragEnterEvent(QDragEnterEvent *event) override
|
||||
{
|
||||
if (event->mimeData()->hasUrls() && event->mimeData()->urls().size() == 1) {
|
||||
event->setDropAction(Qt::CopyAction);
|
||||
event->acceptProposedAction();
|
||||
} else
|
||||
event->ignore();
|
||||
}
|
||||
void dragMoveEvent(QDragMoveEvent *event) override
|
||||
{
|
||||
if (event->mimeData()->hasUrls() && event->mimeData()->urls().size() == 1) {
|
||||
event->setDropAction(Qt::CopyAction);
|
||||
event->acceptProposedAction();
|
||||
} else
|
||||
event->ignore();
|
||||
}
|
||||
void dropEvent(QDropEvent *event) override
|
||||
{
|
||||
if (event->dropAction() == Qt::CopyAction) {
|
||||
emit dropped(event->mimeData()->urls()[0].toLocalFile());
|
||||
} else
|
||||
event->ignore();
|
||||
}
|
||||
};
|
||||
|
||||
class MachineStatus : public QObject
|
||||
{
|
||||
class MachineStatus : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@@ -62,23 +63,23 @@ public:
|
||||
static bool hasCassette();
|
||||
static bool hasIDE();
|
||||
static bool hasSCSI();
|
||||
static void iterateFDD(const std::function<void(int i)>& cb);
|
||||
static void iterateCDROM(const std::function<void(int i)>& cb);
|
||||
static void iterateZIP(const std::function<void(int i)>& cb);
|
||||
static void iterateMO(const std::function<void(int i)>& cb);
|
||||
static void iterateNIC(const std::function<void(int i)>& cb);
|
||||
static void iterateFDD(const std::function<void(int i)> &cb);
|
||||
static void iterateCDROM(const std::function<void(int i)> &cb);
|
||||
static void iterateZIP(const std::function<void(int i)> &cb);
|
||||
static void iterateMO(const std::function<void(int i)> &cb);
|
||||
static void iterateNIC(const std::function<void(int i)> &cb);
|
||||
|
||||
QString getMessage();
|
||||
public slots:
|
||||
void refresh(QStatusBar* sbar);
|
||||
void message(const QString& msg);
|
||||
void refresh(QStatusBar *sbar);
|
||||
void message(const QString &msg);
|
||||
void updateTip(int tag);
|
||||
void refreshIcons();
|
||||
|
||||
private:
|
||||
struct States;
|
||||
std::unique_ptr<States> d;
|
||||
QTimer *refreshTimer;
|
||||
QTimer *refreshTimer;
|
||||
};
|
||||
|
||||
#endif // QT_MACHINESTATUS_HPP
|
||||
|
||||
@@ -31,23 +31,22 @@
|
||||
|
||||
#ifdef QT_STATIC
|
||||
/* Static builds need plugin imports */
|
||||
#include <QtPlugin>
|
||||
# include <QtPlugin>
|
||||
Q_IMPORT_PLUGIN(QICOPlugin)
|
||||
#ifdef Q_OS_WINDOWS
|
||||
# ifdef Q_OS_WINDOWS
|
||||
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
|
||||
Q_IMPORT_PLUGIN(QWindowsVistaStylePlugin)
|
||||
#endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
#include "qt_winrawinputfilter.hpp"
|
||||
#include "qt_winmanagerfilter.hpp"
|
||||
#include <86box/win.h>
|
||||
#include <Shobjidl.h>
|
||||
# include "qt_winrawinputfilter.hpp"
|
||||
# include "qt_winmanagerfilter.hpp"
|
||||
# include <86box/win.h>
|
||||
# include <Shobjidl.h>
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
#include <86box/config.h>
|
||||
#include <86box/plat.h>
|
||||
@@ -69,15 +68,15 @@ extern "C"
|
||||
#include "qt_unixmanagerfilter.hpp"
|
||||
|
||||
// Void Cast
|
||||
#define VC(x) const_cast<wchar_t*>(x)
|
||||
#define VC(x) const_cast<wchar_t *>(x)
|
||||
|
||||
extern QElapsedTimer elapsed_timer;
|
||||
extern MainWindow* main_window;
|
||||
extern MainWindow *main_window;
|
||||
|
||||
extern "C" {
|
||||
#include <86box/timer.h>
|
||||
#include <86box/nvr.h>
|
||||
extern int qt_nvr_save(void);
|
||||
extern int qt_nvr_save(void);
|
||||
}
|
||||
|
||||
void qt_set_sequence_auto_mnemonic(bool b);
|
||||
@@ -86,11 +85,11 @@ void
|
||||
main_thread_fn()
|
||||
{
|
||||
uint64_t old_time, new_time;
|
||||
int drawits, frames;
|
||||
int drawits, frames;
|
||||
|
||||
QThread::currentThread()->setPriority(QThread::HighestPriority);
|
||||
framecountx = 0;
|
||||
//title_update = 1;
|
||||
// title_update = 1;
|
||||
old_time = elapsed_timer.elapsed();
|
||||
drawits = frames = 0;
|
||||
while (!is_quit && cpu_thread_run) {
|
||||
@@ -98,10 +97,10 @@ main_thread_fn()
|
||||
new_time = elapsed_timer.elapsed();
|
||||
#ifdef USE_GDBSTUB
|
||||
if (gdbstub_next_asap && (drawits <= 0))
|
||||
drawits = 10;
|
||||
drawits = 10;
|
||||
else
|
||||
#endif
|
||||
drawits += (new_time - old_time);
|
||||
drawits += (new_time - old_time);
|
||||
old_time = new_time;
|
||||
if (drawits > 0 && !dopause) {
|
||||
/* Yes, so do one frame now. */
|
||||
@@ -117,8 +116,8 @@ main_thread_fn()
|
||||
|
||||
#ifdef USE_INSTRUMENT
|
||||
if (instru_enabled) {
|
||||
uint64_t elapsed_us = (elapsed_timer.nsecsElapsed() - start_time) / 1000;
|
||||
uint64_t total_elapsed_ms = (uint64_t)((double)tsc / cpu_s->rspeed * 1000);
|
||||
uint64_t elapsed_us = (elapsed_timer.nsecsElapsed() - start_time) / 1000;
|
||||
uint64_t total_elapsed_ms = (uint64_t) ((double) tsc / cpu_s->rspeed * 1000);
|
||||
printf("[instrument] %llu, %llu\n", total_elapsed_ms, elapsed_us);
|
||||
if (instru_run_ms && total_elapsed_ms >= instru_run_ms)
|
||||
break;
|
||||
@@ -128,7 +127,7 @@ main_thread_fn()
|
||||
if (++frames >= 200 && nvr_dosave) {
|
||||
qt_nvr_save();
|
||||
nvr_dosave = 0;
|
||||
frames = 0;
|
||||
frames = 0;
|
||||
}
|
||||
} else {
|
||||
/* Just so we dont overload the host OS. */
|
||||
@@ -137,12 +136,14 @@ main_thread_fn()
|
||||
}
|
||||
|
||||
is_quit = 1;
|
||||
QTimer::singleShot(0, QApplication::instance(), [] () { QApplication::instance()->quit(); });
|
||||
QTimer::singleShot(0, QApplication::instance(), []() { QApplication::instance()->quit(); });
|
||||
}
|
||||
|
||||
static std::thread* main_thread;
|
||||
static std::thread *main_thread;
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, false);
|
||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
@@ -168,8 +169,7 @@ int main(int argc, char* argv[]) {
|
||||
#endif
|
||||
elapsed_timer.start();
|
||||
|
||||
if (!pc_init(argc, argv))
|
||||
{
|
||||
if (!pc_init(argc, argv)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -182,16 +182,14 @@ int main(int argc, char* argv[]) {
|
||||
QApplication::setFont(QFont(font_name, font_size.toInt()));
|
||||
SetCurrentProcessExplicitAppUserModelID(L"86Box.86Box");
|
||||
#endif
|
||||
if (! pc_init_modules()) {
|
||||
ui_msgbox_header(MBX_FATAL, (void*)IDS_2121, (void*)IDS_2056);
|
||||
if (!pc_init_modules()) {
|
||||
ui_msgbox_header(MBX_FATAL, (void *) IDS_2121, (void *) IDS_2056);
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (settings_only)
|
||||
{
|
||||
if (settings_only) {
|
||||
Settings settings;
|
||||
if (settings.exec() == QDialog::Accepted)
|
||||
{
|
||||
if (settings.exec() == QDialog::Accepted) {
|
||||
settings.save();
|
||||
config_save();
|
||||
}
|
||||
@@ -212,22 +210,21 @@ int main(int argc, char* argv[]) {
|
||||
#ifdef Q_OS_WINDOWS
|
||||
/* Setup VM-manager messages */
|
||||
std::unique_ptr<WindowsManagerFilter> wmfilter;
|
||||
if (source_hwnd)
|
||||
{
|
||||
HWND main_hwnd = (HWND)main_window->winId();
|
||||
if (source_hwnd) {
|
||||
HWND main_hwnd = (HWND) main_window->winId();
|
||||
|
||||
wmfilter.reset(new WindowsManagerFilter());
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::showsettings, main_window, &MainWindow::showSettings);
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::pause, main_window, &MainWindow::togglePause);
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::reset, main_window, &MainWindow::hardReset);
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::request_shutdown, main_window, &MainWindow::close);
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::force_shutdown, [](){
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::force_shutdown, []() {
|
||||
do_stop();
|
||||
emit main_window->close();
|
||||
});
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::ctrlaltdel, [](){ pc_send_cad(); });
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::dialogstatus, [main_hwnd](bool open){
|
||||
PostMessage((HWND)(uintptr_t)source_hwnd, WM_SENDDLGSTATUS, (WPARAM)(open ? 1 : 0), (LPARAM)main_hwnd);
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::ctrlaltdel, []() { pc_send_cad(); });
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::dialogstatus, [main_hwnd](bool open) {
|
||||
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDDLGSTATUS, (WPARAM) (open ? 1 : 0), (LPARAM) main_hwnd);
|
||||
});
|
||||
|
||||
/* Native filter to catch VM-managers commands */
|
||||
@@ -237,41 +234,39 @@ int main(int argc, char* argv[]) {
|
||||
main_window->installEventFilter(wmfilter.get());
|
||||
|
||||
/* Send main window HWND to manager */
|
||||
PostMessage((HWND)(uintptr_t)source_hwnd, WM_SENDHWND, (WPARAM)unique_id, (LPARAM)main_hwnd);
|
||||
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDHWND, (WPARAM) unique_id, (LPARAM) main_hwnd);
|
||||
|
||||
/* Send shutdown message to manager */
|
||||
QObject::connect(&app, &QApplication::destroyed, [main_hwnd](QObject*) {
|
||||
PostMessage((HWND)(uintptr_t)source_hwnd, WM_HAS_SHUTDOWN, (WPARAM)0, (LPARAM)main_hwnd);
|
||||
QObject::connect(&app, &QApplication::destroyed, [main_hwnd](QObject *) {
|
||||
PostMessage((HWND) (uintptr_t) source_hwnd, WM_HAS_SHUTDOWN, (WPARAM) 0, (LPARAM) main_hwnd);
|
||||
});
|
||||
}
|
||||
|
||||
/* Setup raw input */
|
||||
auto rawInputFilter = WindowsRawInputFilter::Register(main_window);
|
||||
if (rawInputFilter)
|
||||
{
|
||||
if (rawInputFilter) {
|
||||
app.installNativeEventFilter(rawInputFilter.get());
|
||||
QObject::disconnect(main_window, &MainWindow::pollMouse, 0, 0);
|
||||
QObject::connect(main_window, &MainWindow::pollMouse, (WindowsRawInputFilter*)rawInputFilter.get(), &WindowsRawInputFilter::mousePoll, Qt::DirectConnection);
|
||||
QObject::connect(main_window, &MainWindow::pollMouse, (WindowsRawInputFilter *) rawInputFilter.get(), &WindowsRawInputFilter::mousePoll, Qt::DirectConnection);
|
||||
main_window->setSendKeyboardInput(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
UnixManagerSocket socket;
|
||||
if (qgetenv("86BOX_MANAGER_SOCKET").size())
|
||||
{
|
||||
if (qgetenv("86BOX_MANAGER_SOCKET").size()) {
|
||||
QObject::connect(&socket, &UnixManagerSocket::showsettings, main_window, &MainWindow::showSettings);
|
||||
QObject::connect(&socket, &UnixManagerSocket::pause, main_window, &MainWindow::togglePause);
|
||||
QObject::connect(&socket, &UnixManagerSocket::resetVM, main_window, &MainWindow::hardReset);
|
||||
QObject::connect(&socket, &UnixManagerSocket::request_shutdown, main_window, &MainWindow::close);
|
||||
QObject::connect(&socket, &UnixManagerSocket::force_shutdown, [](){
|
||||
QObject::connect(&socket, &UnixManagerSocket::force_shutdown, []() {
|
||||
do_stop();
|
||||
emit main_window->close();
|
||||
});
|
||||
QObject::connect(&socket, &UnixManagerSocket::ctrlaltdel, [](){ pc_send_cad(); });
|
||||
QObject::connect(&socket, &UnixManagerSocket::ctrlaltdel, []() { pc_send_cad(); });
|
||||
main_window->installEventFilter(&socket);
|
||||
socket.connectToServer(qgetenv("86BOX_MANAGER_SOCKET"));
|
||||
}
|
||||
//pc_reset_hard_init();
|
||||
// pc_reset_hard_init();
|
||||
|
||||
/* Set the PAUSE mode depending on the renderer. */
|
||||
// plat_pause(0);
|
||||
@@ -297,13 +292,12 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
/* Initialize the rendering window, or fullscreen. */
|
||||
QTimer::singleShot(0, &app, []
|
||||
{
|
||||
QTimer::singleShot(0, &app, [] {
|
||||
pc_reset_hard_init();
|
||||
main_thread = new std::thread(main_thread_fn);
|
||||
});
|
||||
|
||||
auto ret = app.exec();
|
||||
auto ret = app.exec();
|
||||
cpu_thread_run = 0;
|
||||
main_thread->join();
|
||||
pc_close(nullptr);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,27 +20,26 @@ class MainWindow;
|
||||
|
||||
class MachineStatus;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
void showMessage(int flags, const QString& header, const QString& message);
|
||||
void getTitle(wchar_t* title);
|
||||
void blitToWidget(int x, int y, int w, int h, int monitor_index);
|
||||
void showMessage(int flags, const QString &header, const QString &message);
|
||||
void getTitle(wchar_t *title);
|
||||
void blitToWidget(int x, int y, int w, int h, int monitor_index);
|
||||
QSize getRenderWidgetSize();
|
||||
void setSendKeyboardInput(bool enabled);
|
||||
void setSendKeyboardInput(bool enabled);
|
||||
|
||||
std::array<std::unique_ptr<RendererStack>, 8> renderers;
|
||||
signals:
|
||||
void paint(const QImage& image);
|
||||
void paint(const QImage &image);
|
||||
void resizeContents(int w, int h);
|
||||
void resizeContentsMonitor(int w, int h, int monitor_index);
|
||||
void pollMouse();
|
||||
void statusBarMessage(const QString& msg);
|
||||
void statusBarMessage(const QString &msg);
|
||||
void updateStatusBarPanes();
|
||||
void updateStatusBarActivity(int tag, bool active);
|
||||
void updateStatusBarEmpty(int tag, bool empty);
|
||||
@@ -52,12 +51,12 @@ signals:
|
||||
void initRendererMonitorForNonQtThread(int monitor_index);
|
||||
void destroyRendererMonitorForNonQtThread(int monitor_index);
|
||||
|
||||
void setTitle(const QString& title);
|
||||
void setTitle(const QString &title);
|
||||
void setFullscreen(bool state);
|
||||
void setMouseCapture(bool state);
|
||||
|
||||
void showMessageForNonQtThread(int flags, const QString& header, const QString& message);
|
||||
void getTitleForNonQtThread(wchar_t* title);
|
||||
void showMessageForNonQtThread(int flags, const QString &header, const QString &message);
|
||||
void getTitleForNonQtThread(wchar_t *title);
|
||||
public slots:
|
||||
void showSettings();
|
||||
void hardReset();
|
||||
@@ -120,43 +119,43 @@ private slots:
|
||||
void on_actionRenderer_options_triggered();
|
||||
|
||||
void refreshMediaMenu();
|
||||
void showMessage_(int flags, const QString& header, const QString& message);
|
||||
void getTitle_(wchar_t* title);
|
||||
void showMessage_(int flags, const QString &header, const QString &message);
|
||||
void getTitle_(wchar_t *title);
|
||||
|
||||
void on_actionMCA_devices_triggered();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
void keyReleaseEvent(QKeyEvent* event) override;
|
||||
void focusInEvent(QFocusEvent* event) override;
|
||||
void focusOutEvent(QFocusEvent* event) override;
|
||||
bool eventFilter(QObject* receiver, QEvent* event) override;
|
||||
void showEvent(QShowEvent* event) override;
|
||||
void closeEvent(QCloseEvent* event) override;
|
||||
void changeEvent(QEvent* event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void keyReleaseEvent(QKeyEvent *event) override;
|
||||
void focusInEvent(QFocusEvent *event) override;
|
||||
void focusOutEvent(QFocusEvent *event) override;
|
||||
bool eventFilter(QObject *receiver, QEvent *event) override;
|
||||
void showEvent(QShowEvent *event) override;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void changeEvent(QEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void on_actionShow_non_primary_monitors_triggered();
|
||||
|
||||
void on_actionOpen_screenshots_folder_triggered();
|
||||
void on_actionOpen_screenshots_folder_triggered();
|
||||
|
||||
void on_actionApply_fullscreen_stretch_mode_when_maximized_triggered(bool checked);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
Ui::MainWindow *ui;
|
||||
std::unique_ptr<MachineStatus> status;
|
||||
std::shared_ptr<MediaMenu> mm;
|
||||
std::shared_ptr<MediaMenu> mm;
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
uint32_t last_modifiers = 0;
|
||||
void processMacKeyboardInput(bool down, const QKeyEvent* event);
|
||||
void processMacKeyboardInput(bool down, const QKeyEvent *event);
|
||||
#endif
|
||||
|
||||
/* If main window should send keyboard input */
|
||||
bool send_keyboard_input = true;
|
||||
bool shownonce = false;
|
||||
bool resizableonce = false;
|
||||
bool vnc_enabled = false;
|
||||
bool shownonce = false;
|
||||
bool resizableonce = false;
|
||||
bool vnc_enabled = false;
|
||||
|
||||
friend class SpecifyDimensions;
|
||||
friend class ProgSettings;
|
||||
|
||||
@@ -1,33 +1,27 @@
|
||||
#include "qt_mcadevicelist.hpp"
|
||||
#include "ui_qt_mcadevicelist.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/mca.h>
|
||||
#include <86box/plat.h>
|
||||
}
|
||||
|
||||
MCADeviceList::MCADeviceList(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::MCADeviceList)
|
||||
MCADeviceList::MCADeviceList(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::MCADeviceList)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
startblit();
|
||||
if (mca_get_nr_cards() == 0)
|
||||
{
|
||||
if (mca_get_nr_cards() == 0) {
|
||||
ui->listWidget->addItem(QObject::tr("No MCA devices."));
|
||||
ui->listWidget->setDisabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < mca_get_nr_cards(); i++)
|
||||
{
|
||||
} else {
|
||||
for (int i = 0; i < mca_get_nr_cards(); i++) {
|
||||
uint32_t deviceId = (mca_read_index(0x00, i) | (mca_read_index(0x01, i) << 8));
|
||||
if (deviceId != 0xFFFF)
|
||||
{
|
||||
if (deviceId != 0xFFFF) {
|
||||
QString hexRepresentation = QString::number(deviceId, 16).toUpper();
|
||||
ui->listWidget->addItem(QString("Slot %1: 0x%2 (@%3.ADF)").arg(i + 1).arg(hexRepresentation, hexRepresentation));
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ namespace Ui {
|
||||
class MCADeviceList;
|
||||
}
|
||||
|
||||
class MCADeviceList : public QDialog
|
||||
{
|
||||
class MCADeviceList : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Media history management module
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors: cold-brewed
|
||||
*
|
||||
* Copyright 2022 The 86Box development team
|
||||
*/
|
||||
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Media history management module
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors: cold-brewed
|
||||
*
|
||||
* Copyright 2022 The 86Box development team
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFileInfo>
|
||||
@@ -23,8 +22,7 @@
|
||||
#include <utility>
|
||||
#include "qt_mediahistorymanager.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#include <86box/timer.h>
|
||||
#include <86box/cdrom.h>
|
||||
#include <86box/fdd.h>
|
||||
@@ -32,23 +30,23 @@ extern "C"
|
||||
|
||||
namespace ui {
|
||||
|
||||
MediaHistoryManager::MediaHistoryManager() {
|
||||
MediaHistoryManager::MediaHistoryManager()
|
||||
{
|
||||
initializeImageHistory();
|
||||
deserializeAllImageHistory();
|
||||
initialDeduplication();
|
||||
|
||||
}
|
||||
|
||||
MediaHistoryManager::~MediaHistoryManager()
|
||||
= default;
|
||||
= default;
|
||||
|
||||
master_list_t &
|
||||
MediaHistoryManager::blankImageHistory(master_list_t &initialized_master_list) const
|
||||
{
|
||||
for ( const auto device_type : ui::AllSupportedMediaHistoryTypes ) {
|
||||
for (const auto device_type : ui::AllSupportedMediaHistoryTypes) {
|
||||
device_media_history_t device_media_history;
|
||||
// Loop for all possible media devices
|
||||
for (int device_index = 0 ; device_index < maxDevicesSupported(device_type); device_index++) {
|
||||
for (int device_index = 0; device_index < maxDevicesSupported(device_type); device_index++) {
|
||||
device_index_list_t indexing_list;
|
||||
device_media_history[device_index] = indexing_list;
|
||||
// Loop for each history slot
|
||||
@@ -61,12 +59,11 @@ MediaHistoryManager::blankImageHistory(master_list_t &initialized_master_list) c
|
||||
return initialized_master_list;
|
||||
}
|
||||
|
||||
|
||||
const device_index_list_t&
|
||||
const device_index_list_t &
|
||||
MediaHistoryManager::getHistoryListForDeviceIndex(int index, ui::MediaType type)
|
||||
{
|
||||
if (master_list.contains(type)) {
|
||||
if ((index >= 0 ) && (index < master_list[type].size())) {
|
||||
if ((index >= 0) && (index < master_list[type].size())) {
|
||||
return master_list[type][index];
|
||||
} else {
|
||||
qWarning("Media device index %i for device type %s was requested but index %i is out of range (valid range: >= 0 && < %i)",
|
||||
@@ -77,7 +74,8 @@ MediaHistoryManager::getHistoryListForDeviceIndex(int index, ui::MediaType type)
|
||||
return empty_device_index_list;
|
||||
}
|
||||
|
||||
void MediaHistoryManager::setHistoryListForDeviceIndex(int index, ui::MediaType type, device_index_list_t history_list)
|
||||
void
|
||||
MediaHistoryManager::setHistoryListForDeviceIndex(int index, ui::MediaType type, device_index_list_t history_list)
|
||||
{
|
||||
master_list[type][index] = std::move(history_list);
|
||||
}
|
||||
@@ -85,7 +83,7 @@ void MediaHistoryManager::setHistoryListForDeviceIndex(int index, ui::MediaType
|
||||
QString
|
||||
MediaHistoryManager::getImageForSlot(int index, int slot, ui::MediaType type)
|
||||
{
|
||||
QString image_name;
|
||||
QString image_name;
|
||||
device_index_list_t device_history = getHistoryListForDeviceIndex(index, type);
|
||||
if ((slot >= 0) && (slot < device_history.size())) {
|
||||
image_name = device_history[slot];
|
||||
@@ -99,44 +97,47 @@ MediaHistoryManager::getImageForSlot(int index, int slot, ui::MediaType type)
|
||||
// These are hardcoded since we can't include the various
|
||||
// header files where they are defined (e.g., fdd.h, mo.h).
|
||||
// However, all in ui::MediaType support 4 except cassette.
|
||||
int MediaHistoryManager::maxDevicesSupported(ui::MediaType type)
|
||||
int
|
||||
MediaHistoryManager::maxDevicesSupported(ui::MediaType type)
|
||||
{
|
||||
return type == ui::MediaType::Cassette ? 1 : 4;
|
||||
|
||||
}
|
||||
|
||||
void MediaHistoryManager::deserializeImageHistoryType(ui::MediaType type)
|
||||
void
|
||||
MediaHistoryManager::deserializeImageHistoryType(ui::MediaType type)
|
||||
{
|
||||
for (int device = 0; device < maxDevicesSupported(type); device++) {
|
||||
char **device_history_ptr = getEmuHistoryVarForType(type, device);
|
||||
if(device_history_ptr == nullptr) {
|
||||
if (device_history_ptr == nullptr) {
|
||||
// Device not supported, return and do not deserialize.
|
||||
// This will leave the image listing at the default initialization state
|
||||
// from the ui side (this class)
|
||||
continue;
|
||||
}
|
||||
for ( int slot = 0; slot < MAX_PREV_IMAGES; slot++) {
|
||||
for (int slot = 0; slot < MAX_PREV_IMAGES; slot++) {
|
||||
master_list[type][device][slot] = device_history_ptr[slot];
|
||||
}
|
||||
}
|
||||
}
|
||||
void MediaHistoryManager::deserializeAllImageHistory()
|
||||
void
|
||||
MediaHistoryManager::deserializeAllImageHistory()
|
||||
{
|
||||
for ( const auto device_type : ui::AllSupportedMediaHistoryTypes ) {
|
||||
for (const auto device_type : ui::AllSupportedMediaHistoryTypes) {
|
||||
deserializeImageHistoryType(device_type);
|
||||
}
|
||||
}
|
||||
void MediaHistoryManager::serializeImageHistoryType(ui::MediaType type)
|
||||
void
|
||||
MediaHistoryManager::serializeImageHistoryType(ui::MediaType type)
|
||||
{
|
||||
for (int device = 0; device < maxDevicesSupported(type); device++) {
|
||||
char **device_history_ptr = getEmuHistoryVarForType(type, device);
|
||||
if(device_history_ptr == nullptr) {
|
||||
if (device_history_ptr == nullptr) {
|
||||
// Device not supported, return and do not serialize.
|
||||
// This will leave the image listing at the current state,
|
||||
// and it will not be saved on the emu side
|
||||
continue;
|
||||
}
|
||||
for ( int slot = 0; slot < MAX_PREV_IMAGES; slot++) {
|
||||
for (int slot = 0; slot < MAX_PREV_IMAGES; slot++) {
|
||||
if (device_history_ptr[slot] != nullptr) {
|
||||
strncpy(device_history_ptr[slot], master_list[type][device][slot].toUtf8().constData(), MAX_IMAGE_PATH_LEN);
|
||||
}
|
||||
@@ -144,19 +145,21 @@ void MediaHistoryManager::serializeImageHistoryType(ui::MediaType type)
|
||||
}
|
||||
}
|
||||
|
||||
void MediaHistoryManager::serializeAllImageHistory()
|
||||
void
|
||||
MediaHistoryManager::serializeAllImageHistory()
|
||||
{
|
||||
for ( const auto device_type : ui::AllSupportedMediaHistoryTypes ) {
|
||||
for (const auto device_type : ui::AllSupportedMediaHistoryTypes) {
|
||||
serializeImageHistoryType(device_type);
|
||||
}
|
||||
}
|
||||
|
||||
void MediaHistoryManager::initialDeduplication()
|
||||
void
|
||||
MediaHistoryManager::initialDeduplication()
|
||||
{
|
||||
|
||||
QString current_image;
|
||||
// Perform initial dedup if an image is loaded
|
||||
for ( const auto device_type : ui::AllSupportedMediaHistoryTypes ) {
|
||||
for (const auto device_type : ui::AllSupportedMediaHistoryTypes) {
|
||||
for (int device_index = 0; device_index < maxDevicesSupported(device_type); device_index++) {
|
||||
device_index_list_t device_history = getHistoryListForDeviceIndex(device_index, device_type);
|
||||
switch (device_type) {
|
||||
@@ -170,10 +173,10 @@ void MediaHistoryManager::initialDeduplication()
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
deduplicateList(device_history, QVector<QString> (1, current_image));
|
||||
deduplicateList(device_history, QVector<QString>(1, current_image));
|
||||
// Fill in missing, if any
|
||||
int missing = MAX_PREV_IMAGES - device_history.size();
|
||||
if(missing) {
|
||||
if (missing) {
|
||||
for (int i = 0; i < missing; i++) {
|
||||
device_history.push_back(QString());
|
||||
}
|
||||
@@ -183,7 +186,8 @@ void MediaHistoryManager::initialDeduplication()
|
||||
}
|
||||
}
|
||||
|
||||
char ** MediaHistoryManager::getEmuHistoryVarForType(ui::MediaType type, int index)
|
||||
char **
|
||||
MediaHistoryManager::getEmuHistoryVarForType(ui::MediaType type, int index)
|
||||
{
|
||||
switch (type) {
|
||||
case ui::MediaType::Optical:
|
||||
@@ -192,24 +196,23 @@ char ** MediaHistoryManager::getEmuHistoryVarForType(ui::MediaType type, int ind
|
||||
return &fdd_image_history[index][0];
|
||||
default:
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
device_index_list_t &
|
||||
MediaHistoryManager::deduplicateList(device_index_list_t &device_history, const QVector<QString>& filenames)
|
||||
MediaHistoryManager::deduplicateList(device_index_list_t &device_history, const QVector<QString> &filenames)
|
||||
{
|
||||
QVector<QString> items_to_delete;
|
||||
for (auto &list_item_path : device_history) {
|
||||
if(list_item_path.isEmpty()) {
|
||||
continue ;
|
||||
if (list_item_path.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
for (const auto& path_to_check : filenames) {
|
||||
if(path_to_check.isEmpty()) {
|
||||
continue ;
|
||||
for (const auto &path_to_check : filenames) {
|
||||
if (path_to_check.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
QString adjusted_path = pathAdjustSingle(path_to_check);
|
||||
int match = QString::localeAwareCompare(list_item_path, adjusted_path);
|
||||
int match = QString::localeAwareCompare(list_item_path, adjusted_path);
|
||||
if (match == 0) {
|
||||
items_to_delete.append(list_item_path);
|
||||
}
|
||||
@@ -217,22 +220,22 @@ MediaHistoryManager::deduplicateList(device_index_list_t &device_history, const
|
||||
}
|
||||
// Remove by name rather than index because the index would change
|
||||
// after each removal
|
||||
for (const auto& path: items_to_delete) {
|
||||
for (const auto &path : items_to_delete) {
|
||||
device_history.removeAll(path);
|
||||
}
|
||||
return device_history;
|
||||
}
|
||||
|
||||
void MediaHistoryManager::addImageToHistory(int index, ui::MediaType type, const QString& image_name, const QString& new_image_name)
|
||||
void
|
||||
MediaHistoryManager::addImageToHistory(int index, ui::MediaType type, const QString &image_name, const QString &new_image_name)
|
||||
{
|
||||
device_index_list_t device_history = getHistoryListForDeviceIndex(index, type);
|
||||
QVector<QString> files_to_check;
|
||||
QVector<QString> files_to_check;
|
||||
|
||||
files_to_check.append(image_name);
|
||||
files_to_check.append(new_image_name);
|
||||
device_history = deduplicateList(device_history, files_to_check);
|
||||
|
||||
|
||||
if (!image_name.isEmpty()) {
|
||||
device_history.push_front(image_name);
|
||||
}
|
||||
@@ -244,7 +247,7 @@ void MediaHistoryManager::addImageToHistory(int index, ui::MediaType type, const
|
||||
|
||||
// Fill in missing, if any
|
||||
int missing = MAX_PREV_IMAGES - device_history.size();
|
||||
if(missing) {
|
||||
if (missing) {
|
||||
for (int i = 0; i < missing; i++) {
|
||||
device_history.push_back(QString());
|
||||
}
|
||||
@@ -257,7 +260,8 @@ void MediaHistoryManager::addImageToHistory(int index, ui::MediaType type, const
|
||||
serializeImageHistoryType(type);
|
||||
}
|
||||
|
||||
QString MediaHistoryManager::mediaTypeToString(ui::MediaType type)
|
||||
QString
|
||||
MediaHistoryManager::mediaTypeToString(ui::MediaType type)
|
||||
{
|
||||
QMetaEnum qme = QMetaEnum::fromType<ui::MediaType>();
|
||||
return qme.valueToKey(static_cast<int>(type));
|
||||
@@ -266,7 +270,7 @@ QString MediaHistoryManager::mediaTypeToString(ui::MediaType type)
|
||||
QString
|
||||
MediaHistoryManager::pathAdjustSingle(QString checked_path)
|
||||
{
|
||||
QString current_usr_path = getUsrPath();
|
||||
QString current_usr_path = getUsrPath();
|
||||
QFileInfo file_info(checked_path);
|
||||
if (file_info.filePath().isEmpty() || current_usr_path.isEmpty() || file_info.isRelative()) {
|
||||
return checked_path;
|
||||
@@ -285,7 +289,8 @@ MediaHistoryManager::pathAdjustFull(device_index_list_t &device_history)
|
||||
}
|
||||
return device_history;
|
||||
}
|
||||
QString MediaHistoryManager::getUsrPath()
|
||||
QString
|
||||
MediaHistoryManager::getUsrPath()
|
||||
{
|
||||
QString current_usr_path(usr_path);
|
||||
// Ensure `usr_path` has a trailing slash
|
||||
@@ -301,7 +306,7 @@ MediaHistoryManager::removeMissingImages(device_index_list_t &device_history)
|
||||
}
|
||||
// For this check, explicitly prepend `usr_path` to relative paths to account for $CWD platform variances
|
||||
QFileInfo absolute_path = file_info.isRelative() ? QFileInfo(getUsrPath().append(file_info.filePath())) : file_info;
|
||||
if(!absolute_path.exists()) {
|
||||
if (!absolute_path.exists()) {
|
||||
qWarning("Image file %s does not exist - removing from history", qPrintable(file_info.filePath()));
|
||||
checked_path = "";
|
||||
}
|
||||
@@ -309,7 +314,8 @@ MediaHistoryManager::removeMissingImages(device_index_list_t &device_history)
|
||||
return device_history;
|
||||
}
|
||||
|
||||
void MediaHistoryManager::initializeImageHistory()
|
||||
void
|
||||
MediaHistoryManager::initializeImageHistory()
|
||||
{
|
||||
auto initial_master_list = getMasterList();
|
||||
setMasterList(blankImageHistory(initial_master_list));
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Header for the media history management module
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors: cold-brewed
|
||||
*
|
||||
* Copyright 2022 The 86Box development team
|
||||
*/
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Header for the media history management module
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors: cold-brewed
|
||||
*
|
||||
* Copyright 2022 The 86Box development team
|
||||
*/
|
||||
|
||||
#ifndef QT_MEDIAHISTORYMANAGER_HPP
|
||||
#define QT_MEDIAHISTORYMANAGER_HPP
|
||||
@@ -30,110 +30,109 @@ extern "C" {
|
||||
|
||||
// This macro helps give us the required `qHash()` function in order to use the
|
||||
// enum as a hash key
|
||||
#define QHASH_FOR_CLASS_ENUM(T) \
|
||||
inline uint qHash(const T &t, uint seed) { \
|
||||
return ::qHash(static_cast<typename std::underlying_type<T>::type>(t), seed); \
|
||||
}
|
||||
#define QHASH_FOR_CLASS_ENUM(T) \
|
||||
inline uint qHash(const T &t, uint seed) \
|
||||
{ \
|
||||
return ::qHash(static_cast<typename std::underlying_type<T>::type>(t), seed); \
|
||||
}
|
||||
|
||||
typedef QVector<QString> device_index_list_t;
|
||||
typedef QHash<int, QVector<QString>> device_media_history_t;
|
||||
|
||||
|
||||
namespace ui {
|
||||
Q_NAMESPACE
|
||||
|
||||
enum class MediaType {
|
||||
Floppy,
|
||||
Optical,
|
||||
Zip,
|
||||
Mo,
|
||||
Cassette
|
||||
};
|
||||
// This macro allows us to do a reverse lookup of the enum with `QMetaEnum`
|
||||
Q_ENUM_NS(MediaType)
|
||||
|
||||
QHASH_FOR_CLASS_ENUM(MediaType)
|
||||
Q_NAMESPACE
|
||||
|
||||
typedef QHash<ui::MediaType, device_media_history_t> master_list_t;
|
||||
enum class MediaType {
|
||||
Floppy,
|
||||
Optical,
|
||||
Zip,
|
||||
Mo,
|
||||
Cassette
|
||||
};
|
||||
// This macro allows us to do a reverse lookup of the enum with `QMetaEnum`
|
||||
Q_ENUM_NS(MediaType)
|
||||
|
||||
// Used to iterate over all supported types when preparing data structures
|
||||
// Also useful to indicate which types support history
|
||||
static const MediaType AllSupportedMediaHistoryTypes[] = {
|
||||
MediaType::Optical,
|
||||
MediaType::Floppy,
|
||||
};
|
||||
QHASH_FOR_CLASS_ENUM(MediaType)
|
||||
|
||||
class MediaHistoryManager {
|
||||
typedef QHash<ui::MediaType, device_media_history_t> master_list_t;
|
||||
|
||||
public:
|
||||
MediaHistoryManager();
|
||||
virtual ~MediaHistoryManager();
|
||||
// Used to iterate over all supported types when preparing data structures
|
||||
// Also useful to indicate which types support history
|
||||
static const MediaType AllSupportedMediaHistoryTypes[] = {
|
||||
MediaType::Optical,
|
||||
MediaType::Floppy,
|
||||
};
|
||||
|
||||
// Get the image name for a particular slot,
|
||||
// index, and type combination
|
||||
QString getImageForSlot(int index, int slot, ui::MediaType type);
|
||||
class MediaHistoryManager {
|
||||
|
||||
// Add an image to history
|
||||
void addImageToHistory(int index, ui::MediaType type, const QString& image_name, const QString& new_image_name);
|
||||
public:
|
||||
MediaHistoryManager();
|
||||
virtual ~MediaHistoryManager();
|
||||
|
||||
// Convert the enum value to a string
|
||||
static QString mediaTypeToString(ui::MediaType type);
|
||||
// Get the image name for a particular slot,
|
||||
// index, and type combination
|
||||
QString getImageForSlot(int index, int slot, ui::MediaType type);
|
||||
|
||||
// Clear out the image history
|
||||
void clearImageHistory();
|
||||
// Add an image to history
|
||||
void addImageToHistory(int index, ui::MediaType type, const QString &image_name, const QString &new_image_name);
|
||||
|
||||
// Convert the enum value to a string
|
||||
static QString mediaTypeToString(ui::MediaType type);
|
||||
|
||||
private:
|
||||
int max_images = MAX_PREV_IMAGES;
|
||||
// Clear out the image history
|
||||
void clearImageHistory();
|
||||
|
||||
// Main hash of hash of vector of strings
|
||||
master_list_t master_list;
|
||||
[[nodiscard]] const master_list_t &getMasterList() const;
|
||||
void setMasterList(const master_list_t &masterList);
|
||||
private:
|
||||
int max_images = MAX_PREV_IMAGES;
|
||||
|
||||
device_index_list_t index_list, empty_device_index_list;
|
||||
// Main hash of hash of vector of strings
|
||||
master_list_t master_list;
|
||||
[[nodiscard]] const master_list_t &getMasterList() const;
|
||||
void setMasterList(const master_list_t &masterList);
|
||||
|
||||
// Return a blank, initialized image history list
|
||||
master_list_t &blankImageHistory(master_list_t &initialized_master_list) const;
|
||||
device_index_list_t index_list, empty_device_index_list;
|
||||
|
||||
// Initialize the image history
|
||||
void initializeImageHistory();
|
||||
// Return a blank, initialized image history list
|
||||
master_list_t &blankImageHistory(master_list_t &initialized_master_list) const;
|
||||
|
||||
// Max number of devices supported by media type
|
||||
static int maxDevicesSupported(ui::MediaType type);
|
||||
// Initialize the image history
|
||||
void initializeImageHistory();
|
||||
|
||||
// Serialize the data back into the C array
|
||||
// on the emu side
|
||||
void serializeImageHistoryType(ui::MediaType type);
|
||||
void serializeAllImageHistory();
|
||||
// Max number of devices supported by media type
|
||||
static int maxDevicesSupported(ui::MediaType type);
|
||||
|
||||
// Deserialize the data from C array on the emu side
|
||||
// for the ui side
|
||||
void deserializeImageHistoryType(ui::MediaType type);
|
||||
void deserializeAllImageHistory();
|
||||
// Serialize the data back into the C array
|
||||
// on the emu side
|
||||
void serializeImageHistoryType(ui::MediaType type);
|
||||
void serializeAllImageHistory();
|
||||
|
||||
// Get emu history variable for a device type
|
||||
static char** getEmuHistoryVarForType(ui::MediaType type, int index);
|
||||
// Deserialize the data from C array on the emu side
|
||||
// for the ui side
|
||||
void deserializeImageHistoryType(ui::MediaType type);
|
||||
void deserializeAllImageHistory();
|
||||
|
||||
// Get or set the history for a specific device/index combo
|
||||
const device_index_list_t &getHistoryListForDeviceIndex(int index, ui::MediaType type);
|
||||
void setHistoryListForDeviceIndex(int index, ui::MediaType type, device_index_list_t history_list);
|
||||
// Get emu history variable for a device type
|
||||
static char **getEmuHistoryVarForType(ui::MediaType type, int index);
|
||||
|
||||
// Remove missing image files from history list
|
||||
static device_index_list_t &removeMissingImages(device_index_list_t &device_history);
|
||||
// Get or set the history for a specific device/index combo
|
||||
const device_index_list_t &getHistoryListForDeviceIndex(int index, ui::MediaType type);
|
||||
void setHistoryListForDeviceIndex(int index, ui::MediaType type, device_index_list_t history_list);
|
||||
|
||||
// If an absolute path is contained within `usr_path`, convert to a relative path
|
||||
static device_index_list_t &pathAdjustFull(device_index_list_t &device_history);
|
||||
static QString pathAdjustSingle(QString checked_path);
|
||||
// Remove missing image files from history list
|
||||
static device_index_list_t &removeMissingImages(device_index_list_t &device_history);
|
||||
|
||||
// Deduplicate history entries
|
||||
static device_index_list_t &deduplicateList(device_index_list_t &device_history, const QVector<QString>& filenames);
|
||||
void initialDeduplication();
|
||||
// If an absolute path is contained within `usr_path`, convert to a relative path
|
||||
static device_index_list_t &pathAdjustFull(device_index_list_t &device_history);
|
||||
static QString pathAdjustSingle(QString checked_path);
|
||||
|
||||
// Gets the `usr_path` from the emu side and appends a
|
||||
// trailing slash if necessary
|
||||
static QString getUsrPath();
|
||||
};
|
||||
// Deduplicate history entries
|
||||
static device_index_list_t &deduplicateList(device_index_list_t &device_history, const QVector<QString> &filenames);
|
||||
void initialDeduplication();
|
||||
|
||||
// Gets the `usr_path` from the emu side and appends a
|
||||
// trailing slash if necessary
|
||||
static QString getUsrPath();
|
||||
};
|
||||
|
||||
} // ui
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ extern "C" {
|
||||
#include <86box/ui.h>
|
||||
#include <86box/thread.h>
|
||||
#include <86box/network.h>
|
||||
|
||||
};
|
||||
|
||||
#include "qt_newfloppydialog.hpp"
|
||||
@@ -58,14 +57,18 @@ extern "C" {
|
||||
|
||||
std::shared_ptr<MediaMenu> MediaMenu::ptr;
|
||||
|
||||
MediaMenu::MediaMenu(QWidget* parent) : QObject(parent) {
|
||||
MediaMenu::MediaMenu(QWidget *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
parentWidget = parent;
|
||||
}
|
||||
|
||||
void MediaMenu::refresh(QMenu *parentMenu) {
|
||||
void
|
||||
MediaMenu::refresh(QMenu *parentMenu)
|
||||
{
|
||||
parentMenu->clear();
|
||||
|
||||
if(MachineStatus::hasCassette()) {
|
||||
if (MachineStatus::hasCassette()) {
|
||||
cassetteMenu = parentMenu->addMenu("");
|
||||
cassetteMenu->addAction(tr("&New image..."), [this]() { cassetteNewImage(); });
|
||||
cassetteMenu->addSeparator();
|
||||
@@ -88,8 +91,8 @@ void MediaMenu::refresh(QMenu *parentMenu) {
|
||||
|
||||
cartridgeMenus.clear();
|
||||
if (machine_has_cartridge(machine)) {
|
||||
for(int i = 0; i < 2; i++) {
|
||||
auto* menu = parentMenu->addMenu("");
|
||||
for (int i = 0; i < 2; i++) {
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
menu->addAction(tr("&Image..."), [this, i]() { cartridgeSelectImage(i); });
|
||||
menu->addSeparator();
|
||||
cartridgeEjectPos = menu->children().count();
|
||||
@@ -101,7 +104,7 @@ void MediaMenu::refresh(QMenu *parentMenu) {
|
||||
|
||||
floppyMenus.clear();
|
||||
MachineStatus::iterateFDD([this, parentMenu](int i) {
|
||||
auto* menu = parentMenu->addMenu("");
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
menu->addAction(tr("&New image..."), [this, i]() { floppyNewImage(i); });
|
||||
menu->addSeparator();
|
||||
menu->addAction(tr("&Existing image..."), [this, i]() { floppySelectImage(i, false); });
|
||||
@@ -123,7 +126,7 @@ void MediaMenu::refresh(QMenu *parentMenu) {
|
||||
|
||||
cdromMenus.clear();
|
||||
MachineStatus::iterateCDROM([this, parentMenu](int i) {
|
||||
auto* menu = parentMenu->addMenu("");
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
cdromMutePos = menu->children().count();
|
||||
menu->addAction(QApplication::style()->standardIcon(QStyle::SP_MediaVolumeMuted), tr("&Mute"), [this, i]() { cdromMute(i); })->setCheckable(true);
|
||||
menu->addSeparator();
|
||||
@@ -136,7 +139,7 @@ void MediaMenu::refresh(QMenu *parentMenu) {
|
||||
}
|
||||
menu->addSeparator();
|
||||
cdromImagePos = menu->children().count();
|
||||
cdromDirPos = menu->children().count();
|
||||
cdromDirPos = menu->children().count();
|
||||
menu->addAction(tr("E&ject"), [this, i]() { cdromEject(i); })->setCheckable(false);
|
||||
cdromMenus[i] = menu;
|
||||
cdromUpdateMenu(i);
|
||||
@@ -144,7 +147,7 @@ void MediaMenu::refresh(QMenu *parentMenu) {
|
||||
|
||||
zipMenus.clear();
|
||||
MachineStatus::iterateZIP([this, parentMenu](int i) {
|
||||
auto* menu = parentMenu->addMenu("");
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
menu->addAction(tr("&New image..."), [this, i]() { zipNewImage(i); });
|
||||
menu->addSeparator();
|
||||
menu->addAction(tr("&Existing image..."), [this, i]() { zipSelectImage(i, false); });
|
||||
@@ -160,7 +163,7 @@ void MediaMenu::refresh(QMenu *parentMenu) {
|
||||
|
||||
moMenus.clear();
|
||||
MachineStatus::iterateMO([this, parentMenu](int i) {
|
||||
auto* menu = parentMenu->addMenu("");
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
menu->addAction(tr("&New image..."), [this, i]() { moNewImage(i); });
|
||||
menu->addSeparator();
|
||||
menu->addAction(tr("&Existing image..."), [this, i]() { moSelectImage(i, false); });
|
||||
@@ -176,9 +179,9 @@ void MediaMenu::refresh(QMenu *parentMenu) {
|
||||
|
||||
netMenus.clear();
|
||||
MachineStatus::iterateNIC([this, parentMenu](int i) {
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
netDisconnPos = menu->children().count();
|
||||
auto *action = menu->addAction(tr("&Connected"), [this, i] { network_is_connected(i) ? nicDisconnect(i) : nicConnect(i); });
|
||||
auto *action = menu->addAction(tr("&Connected"), [this, i] { network_is_connected(i) ? nicDisconnect(i) : nicConnect(i); });
|
||||
action->setCheckable(true);
|
||||
netMenus[i] = menu;
|
||||
nicUpdateMenu(i);
|
||||
@@ -186,36 +189,42 @@ void MediaMenu::refresh(QMenu *parentMenu) {
|
||||
parentMenu->addAction(tr("Clear image history"), [this]() { clearImageHistory(); });
|
||||
}
|
||||
|
||||
void MediaMenu::cassetteNewImage() {
|
||||
auto filename = QFileDialog::getSaveFileName(parentWidget, tr("Create..."));
|
||||
void
|
||||
MediaMenu::cassetteNewImage()
|
||||
{
|
||||
auto filename = QFileDialog::getSaveFileName(parentWidget, tr("Create..."));
|
||||
QFileInfo fileinfo(filename);
|
||||
if (fileinfo.suffix().isEmpty()) {
|
||||
filename.append(".cas");
|
||||
}
|
||||
if (!filename.isNull()) {
|
||||
if (filename.isEmpty()) cassetteEject();
|
||||
else cassetteMount(filename, false);
|
||||
if (filename.isEmpty())
|
||||
cassetteEject();
|
||||
else
|
||||
cassetteMount(filename, false);
|
||||
}
|
||||
}
|
||||
|
||||
void MediaMenu::cassetteSelectImage(bool wp) {
|
||||
void
|
||||
MediaMenu::cassetteSelectImage(bool wp)
|
||||
{
|
||||
auto filename = QFileDialog::getOpenFileName(parentWidget,
|
||||
QString(),
|
||||
getMediaOpenDirectory(),
|
||||
tr("Cassette images") %
|
||||
util::DlgFilter({ "pcm","raw","wav","cas" }) %
|
||||
tr("All files") %
|
||||
util::DlgFilter({ "*" }, true));
|
||||
QString(),
|
||||
getMediaOpenDirectory(),
|
||||
tr("Cassette images") % util::DlgFilter({ "pcm", "raw", "wav", "cas" }) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
|
||||
if (!filename.isEmpty()) cassetteMount(filename, wp);
|
||||
if (!filename.isEmpty())
|
||||
cassetteMount(filename, wp);
|
||||
}
|
||||
|
||||
void MediaMenu::cassetteMount(const QString& filename, bool wp) {
|
||||
void
|
||||
MediaMenu::cassetteMount(const QString &filename, bool wp)
|
||||
{
|
||||
pc_cas_set_fname(cassette, nullptr);
|
||||
memset(cassette_fname, 0, sizeof(cassette_fname));
|
||||
cassette_ui_writeprot = wp ? 1 : 0;
|
||||
|
||||
if (! filename.isEmpty()) {
|
||||
if (!filename.isEmpty()) {
|
||||
QByteArray filenameBytes = filename.toUtf8();
|
||||
strncpy(cassette_fname, filenameBytes.data(), sizeof(cassette_fname) - 1);
|
||||
pc_cas_set_fname(cassette, cassette_fname);
|
||||
@@ -227,7 +236,9 @@ void MediaMenu::cassetteMount(const QString& filename, bool wp) {
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::cassetteEject() {
|
||||
void
|
||||
MediaMenu::cassetteEject()
|
||||
{
|
||||
pc_cas_set_fname(cassette, nullptr);
|
||||
memset(cassette_fname, 0, sizeof(cassette_fname));
|
||||
ui_sb_update_icon_state(SB_CASSETTE, 1);
|
||||
@@ -236,15 +247,17 @@ void MediaMenu::cassetteEject() {
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::cassetteUpdateMenu() {
|
||||
QString name = cassette_fname;
|
||||
QString mode = cassette_mode;
|
||||
auto childs = cassetteMenu->children();
|
||||
auto* recordMenu = dynamic_cast<QAction*>(childs[cassetteRecordPos]);
|
||||
auto* playMenu = dynamic_cast<QAction*>(childs[cassettePlayPos]);
|
||||
auto* rewindMenu = dynamic_cast<QAction*>(childs[cassetteRewindPos]);
|
||||
auto* fastFwdMenu = dynamic_cast<QAction*>(childs[cassetteFastFwdPos]);
|
||||
auto* ejectMenu = dynamic_cast<QAction*>(childs[cassetteEjectPos]);
|
||||
void
|
||||
MediaMenu::cassetteUpdateMenu()
|
||||
{
|
||||
QString name = cassette_fname;
|
||||
QString mode = cassette_mode;
|
||||
auto childs = cassetteMenu->children();
|
||||
auto *recordMenu = dynamic_cast<QAction *>(childs[cassetteRecordPos]);
|
||||
auto *playMenu = dynamic_cast<QAction *>(childs[cassettePlayPos]);
|
||||
auto *rewindMenu = dynamic_cast<QAction *>(childs[cassetteRewindPos]);
|
||||
auto *fastFwdMenu = dynamic_cast<QAction *>(childs[cassetteFastFwdPos]);
|
||||
auto *ejectMenu = dynamic_cast<QAction *>(childs[cassetteEjectPos]);
|
||||
|
||||
recordMenu->setEnabled(!name.isEmpty());
|
||||
playMenu->setEnabled(!name.isEmpty());
|
||||
@@ -254,12 +267,13 @@ void MediaMenu::cassetteUpdateMenu() {
|
||||
|
||||
bool isSaving = mode == QStringLiteral("save");
|
||||
recordMenu->setChecked(isSaving);
|
||||
playMenu->setChecked(! isSaving);
|
||||
playMenu->setChecked(!isSaving);
|
||||
|
||||
cassetteMenu->setTitle(QString::asprintf(tr("Cassette: %s").toUtf8().constData(), (name.isEmpty() ? tr("(empty)") : name).toUtf8().constData()));
|
||||
}
|
||||
|
||||
void MediaMenu::cartridgeMount(int i, const QString &filename)
|
||||
void
|
||||
MediaMenu::cartridgeMount(int i, const QString &filename)
|
||||
{
|
||||
cart_close(i);
|
||||
QByteArray filenameBytes = filename.toUtf8();
|
||||
@@ -271,15 +285,14 @@ void MediaMenu::cartridgeMount(int i, const QString &filename)
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::cartridgeSelectImage(int i) {
|
||||
void
|
||||
MediaMenu::cartridgeSelectImage(int i)
|
||||
{
|
||||
auto filename = QFileDialog::getOpenFileName(
|
||||
parentWidget,
|
||||
QString(),
|
||||
getMediaOpenDirectory(),
|
||||
tr("Cartridge images") %
|
||||
util::DlgFilter({ "a","b","jrc" }) %
|
||||
tr("All files") %
|
||||
util::DlgFilter({ "*" }, true));
|
||||
tr("Cartridge images") % util::DlgFilter({ "a", "b", "jrc" }) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
|
||||
if (filename.isEmpty()) {
|
||||
return;
|
||||
@@ -287,7 +300,9 @@ void MediaMenu::cartridgeSelectImage(int i) {
|
||||
cartridgeMount(i, filename);
|
||||
}
|
||||
|
||||
void MediaMenu::cartridgeEject(int i) {
|
||||
void
|
||||
MediaMenu::cartridgeEject(int i)
|
||||
{
|
||||
cart_close(i);
|
||||
ui_sb_update_icon_state(SB_CARTRIDGE | i, 1);
|
||||
cartridgeUpdateMenu(i);
|
||||
@@ -295,27 +310,33 @@ void MediaMenu::cartridgeEject(int i) {
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::cartridgeUpdateMenu(int i) {
|
||||
QString name = cart_fns[i];
|
||||
auto* menu = cartridgeMenus[i];
|
||||
auto childs = menu->children();
|
||||
auto* ejectMenu = dynamic_cast<QAction*>(childs[cartridgeEjectPos]);
|
||||
void
|
||||
MediaMenu::cartridgeUpdateMenu(int i)
|
||||
{
|
||||
QString name = cart_fns[i];
|
||||
auto *menu = cartridgeMenus[i];
|
||||
auto childs = menu->children();
|
||||
auto *ejectMenu = dynamic_cast<QAction *>(childs[cartridgeEjectPos]);
|
||||
ejectMenu->setEnabled(!name.isEmpty());
|
||||
//menu->setTitle(tr("Cartridge %1: %2").arg(QString::number(i+1), name.isEmpty() ? tr("(empty)") : name));
|
||||
// menu->setTitle(tr("Cartridge %1: %2").arg(QString::number(i+1), name.isEmpty() ? tr("(empty)") : name));
|
||||
menu->setTitle(QString::asprintf(tr("Cartridge %i: %ls").toUtf8().constData(), i + 1, name.isEmpty() ? tr("(empty)").toStdU16String().data() : name.toStdU16String().data()));
|
||||
}
|
||||
|
||||
void MediaMenu::floppyNewImage(int i) {
|
||||
void
|
||||
MediaMenu::floppyNewImage(int i)
|
||||
{
|
||||
NewFloppyDialog dialog(NewFloppyDialog::MediaType::Floppy, parentWidget);
|
||||
switch (dialog.exec()) {
|
||||
case QDialog::Accepted:
|
||||
QByteArray filename = dialog.fileName().toUtf8();
|
||||
floppyMount(i, filename, false);
|
||||
break;
|
||||
case QDialog::Accepted:
|
||||
QByteArray filename = dialog.fileName().toUtf8();
|
||||
floppyMount(i, filename, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MediaMenu::floppySelectImage(int i, bool wp) {
|
||||
void
|
||||
MediaMenu::floppySelectImage(int i, bool wp)
|
||||
{
|
||||
auto filename = QFileDialog::getOpenFileName(
|
||||
parentWidget,
|
||||
QString(),
|
||||
@@ -336,11 +357,13 @@ void MediaMenu::floppySelectImage(int i, bool wp) {
|
||||
if (!filename.isEmpty()) floppyMount(i, filename, wp);
|
||||
}
|
||||
|
||||
void MediaMenu::floppyMount(int i, const QString &filename, bool wp) {
|
||||
void
|
||||
MediaMenu::floppyMount(int i, const QString &filename, bool wp)
|
||||
{
|
||||
auto previous_image = QFileInfo(floppyfns[i]);
|
||||
fdd_close(i);
|
||||
ui_writeprot[i] = wp ? 1 : 0;
|
||||
if (! filename.isEmpty()) {
|
||||
if (!filename.isEmpty()) {
|
||||
QByteArray filenameBytes = filename.toUtf8();
|
||||
fdd_load(i, filenameBytes.data());
|
||||
}
|
||||
@@ -351,7 +374,9 @@ void MediaMenu::floppyMount(int i, const QString &filename, bool wp) {
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::floppyEject(int i) {
|
||||
void
|
||||
MediaMenu::floppyEject(int i)
|
||||
{
|
||||
mhm.addImageToHistory(i, ui::MediaType::Floppy, floppyfns[i], QString());
|
||||
fdd_close(i);
|
||||
ui_sb_update_icon_state(SB_FLOPPY | i, 1);
|
||||
@@ -360,9 +385,11 @@ void MediaMenu::floppyEject(int i) {
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::floppyExportTo86f(int i) {
|
||||
void
|
||||
MediaMenu::floppyExportTo86f(int i)
|
||||
{
|
||||
auto filename = QFileDialog::getSaveFileName(parentWidget, QString(), QString(), tr("Surface images") % util::DlgFilter({ "86f" }, true));
|
||||
if (! filename.isEmpty()) {
|
||||
if (!filename.isEmpty()) {
|
||||
QByteArray filenameBytes = filename.toUtf8();
|
||||
plat_pause(1);
|
||||
if (d86f_export(i, filenameBytes.data()) == 0) {
|
||||
@@ -372,20 +399,22 @@ void MediaMenu::floppyExportTo86f(int i) {
|
||||
}
|
||||
}
|
||||
|
||||
void MediaMenu::floppyUpdateMenu(int i) {
|
||||
QString name = floppyfns[i];
|
||||
void
|
||||
MediaMenu::floppyUpdateMenu(int i)
|
||||
{
|
||||
QString name = floppyfns[i];
|
||||
QFileInfo fi(floppyfns[i]);
|
||||
|
||||
if (!floppyMenus.contains(i))
|
||||
return;
|
||||
|
||||
auto* menu = floppyMenus[i];
|
||||
auto childs = menu->children();
|
||||
auto *menu = floppyMenus[i];
|
||||
auto childs = menu->children();
|
||||
|
||||
auto* ejectMenu = dynamic_cast<QAction*>(childs[floppyEjectPos]);
|
||||
auto* exportMenu = dynamic_cast<QAction*>(childs[floppyExportPos]);
|
||||
auto *ejectMenu = dynamic_cast<QAction *>(childs[floppyEjectPos]);
|
||||
auto *exportMenu = dynamic_cast<QAction *>(childs[floppyExportPos]);
|
||||
ejectMenu->setEnabled(!name.isEmpty());
|
||||
ejectMenu->setText(QString::asprintf(tr("Eject %s").toUtf8().constData(), name.isEmpty() ? QString().toUtf8().constData() : fi.fileName().toUtf8().constData()));
|
||||
ejectMenu->setText(QString::asprintf(tr("Eject %s").toUtf8().constData(), name.isEmpty() ? QString().toUtf8().constData() : fi.fileName().toUtf8().constData()));
|
||||
exportMenu->setEnabled(!name.isEmpty());
|
||||
|
||||
for (int slot = 0; slot < MAX_PREV_IMAGES; slot++) {
|
||||
@@ -393,25 +422,30 @@ void MediaMenu::floppyUpdateMenu(int i) {
|
||||
}
|
||||
|
||||
int type = fdd_get_type(i);
|
||||
//floppyMenus[i]->setTitle(tr("Floppy %1 (%2): %3").arg(QString::number(i+1), fdd_getname(type), name.isEmpty() ? tr("(empty)") : name));
|
||||
// floppyMenus[i]->setTitle(tr("Floppy %1 (%2): %3").arg(QString::number(i+1), fdd_getname(type), name.isEmpty() ? tr("(empty)") : name));
|
||||
floppyMenus[i]->setTitle(QString::asprintf(tr("Floppy %i (%s): %ls").toUtf8().constData(), i + 1, fdd_getname(type), name.isEmpty() ? tr("(empty)").toStdU16String().data() : name.toStdU16String().data()));
|
||||
}
|
||||
|
||||
void MediaMenu::floppyMenuSelect(int index, int slot) {
|
||||
void
|
||||
MediaMenu::floppyMenuSelect(int index, int slot)
|
||||
{
|
||||
QString filename = mhm.getImageForSlot(index, slot, ui::MediaType::Floppy);
|
||||
floppyMount(index, filename.toUtf8().constData(), false);
|
||||
floppyUpdateMenu(index);
|
||||
ui_sb_update_tip(SB_FLOPPY | index);
|
||||
}
|
||||
|
||||
void MediaMenu::cdromMute(int i) {
|
||||
void
|
||||
MediaMenu::cdromMute(int i)
|
||||
{
|
||||
cdrom[i].sound_on ^= 1;
|
||||
config_save();
|
||||
cdromUpdateMenu(i);
|
||||
sound_cd_thread_reset();
|
||||
}
|
||||
|
||||
void MediaMenu::cdromMount(int i, const QString &filename)
|
||||
void
|
||||
MediaMenu::cdromMount(int i, const QString &filename)
|
||||
{
|
||||
QByteArray fn = filename.toUtf8().data();
|
||||
|
||||
@@ -438,8 +472,10 @@ void MediaMenu::cdromMount(int i, const QString &filename)
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::cdromMount(int i, int dir) {
|
||||
QString filename;
|
||||
void
|
||||
MediaMenu::cdromMount(int i, int dir)
|
||||
{
|
||||
QString filename;
|
||||
QFileInfo fi(cdrom[i].image_path);
|
||||
|
||||
if (dir) {
|
||||
@@ -450,10 +486,7 @@ void MediaMenu::cdromMount(int i, int dir) {
|
||||
parentWidget,
|
||||
QString(),
|
||||
QString(),
|
||||
tr("CD-ROM images") %
|
||||
util::DlgFilter({ "iso","cue" }) %
|
||||
tr("All files") %
|
||||
util::DlgFilter({ "*" }, true));
|
||||
tr("CD-ROM images") % util::DlgFilter({ "iso", "cue" }) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
}
|
||||
|
||||
if (filename.isEmpty()) {
|
||||
@@ -463,34 +496,40 @@ void MediaMenu::cdromMount(int i, int dir) {
|
||||
cdromMount(i, filename);
|
||||
}
|
||||
|
||||
void MediaMenu::cdromEject(int i) {
|
||||
void
|
||||
MediaMenu::cdromEject(int i)
|
||||
{
|
||||
mhm.addImageToHistory(i, ui::MediaType::Optical, cdrom[i].image_path, QString());
|
||||
cdrom_eject(i);
|
||||
cdromUpdateMenu(i);
|
||||
ui_sb_update_tip(SB_CDROM | i);
|
||||
}
|
||||
|
||||
void MediaMenu::cdromReload(int index, int slot) {
|
||||
void
|
||||
MediaMenu::cdromReload(int index, int slot)
|
||||
{
|
||||
QString filename = mhm.getImageForSlot(index, slot, ui::MediaType::Optical);
|
||||
cdromMount(index, filename.toUtf8().constData());
|
||||
cdromUpdateMenu(index);
|
||||
ui_sb_update_tip(SB_CDROM | index);
|
||||
}
|
||||
|
||||
void MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type) {
|
||||
QMenu* menu;
|
||||
QAction* imageHistoryUpdatePos;
|
||||
void
|
||||
MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type)
|
||||
{
|
||||
QMenu *menu;
|
||||
QAction *imageHistoryUpdatePos;
|
||||
QObjectList children;
|
||||
QFileInfo fi;
|
||||
QIcon menu_icon;
|
||||
QFileInfo fi;
|
||||
QIcon menu_icon;
|
||||
|
||||
switch (type) {
|
||||
case ui::MediaType::Optical:
|
||||
if (!cdromMenus.contains(index))
|
||||
return;
|
||||
menu = cdromMenus[index];
|
||||
children = menu->children();
|
||||
imageHistoryUpdatePos = dynamic_cast<QAction*>(children[cdromImageHistoryPos[slot]]);
|
||||
menu = cdromMenus[index];
|
||||
children = menu->children();
|
||||
imageHistoryUpdatePos = dynamic_cast<QAction *>(children[cdromImageHistoryPos[slot]]);
|
||||
fi.setFile(mhm.getImageForSlot(index, slot, type));
|
||||
menu_icon = fi.isDir() ? QApplication::style()->standardIcon(QStyle::SP_DirIcon) : ProgSettings::loadIcon("/cdrom.ico");
|
||||
imageHistoryUpdatePos->setIcon(menu_icon);
|
||||
@@ -498,9 +537,9 @@ void MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type) {
|
||||
case ui::MediaType::Floppy:
|
||||
if (!floppyMenus.contains(index))
|
||||
return;
|
||||
menu = floppyMenus[index];
|
||||
children = menu->children();
|
||||
imageHistoryUpdatePos = dynamic_cast<QAction*>(children[floppyImageHistoryPos[slot]]);
|
||||
menu = floppyMenus[index];
|
||||
children = menu->children();
|
||||
imageHistoryUpdatePos = dynamic_cast<QAction *>(children[floppyImageHistoryPos[slot]]);
|
||||
fi.setFile(mhm.getImageForSlot(index, slot, type));
|
||||
break;
|
||||
default:
|
||||
@@ -514,27 +553,31 @@ void MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type) {
|
||||
imageHistoryUpdatePos->setVisible(fi.exists());
|
||||
}
|
||||
|
||||
void MediaMenu::clearImageHistory() {
|
||||
void
|
||||
MediaMenu::clearImageHistory()
|
||||
{
|
||||
mhm.clearImageHistory();
|
||||
ui_sb_update_panes();
|
||||
}
|
||||
|
||||
void MediaMenu::cdromUpdateMenu(int i) {
|
||||
QString name = cdrom[i].image_path;
|
||||
void
|
||||
MediaMenu::cdromUpdateMenu(int i)
|
||||
{
|
||||
QString name = cdrom[i].image_path;
|
||||
QFileInfo fi(cdrom[i].image_path);
|
||||
|
||||
if (!cdromMenus.contains(i))
|
||||
return;
|
||||
auto* menu = cdromMenus[i];
|
||||
auto childs = menu->children();
|
||||
auto *menu = cdromMenus[i];
|
||||
auto childs = menu->children();
|
||||
|
||||
auto* muteMenu = dynamic_cast<QAction*>(childs[cdromMutePos]);
|
||||
auto *muteMenu = dynamic_cast<QAction *>(childs[cdromMutePos]);
|
||||
muteMenu->setChecked(cdrom[i].sound_on == 0);
|
||||
|
||||
auto* imageMenu = dynamic_cast<QAction*>(childs[cdromImagePos]);
|
||||
auto *imageMenu = dynamic_cast<QAction *>(childs[cdromImagePos]);
|
||||
imageMenu->setEnabled(!name.isEmpty());
|
||||
QString menu_item_name = name.isEmpty() ? QString().toUtf8().constData() : fi.fileName().toUtf8().constData();
|
||||
auto menu_icon = fi.isDir() ? QApplication::style()->standardIcon(QStyle::SP_DirIcon) : ProgSettings::loadIcon("/cdrom.ico");
|
||||
auto menu_icon = fi.isDir() ? QApplication::style()->standardIcon(QStyle::SP_DirIcon) : ProgSettings::loadIcon("/cdrom.ico");
|
||||
imageMenu->setIcon(menu_icon);
|
||||
imageMenu->setText(QString::asprintf(tr("Eject %s").toUtf8().constData(), menu_item_name.toUtf8().constData()));
|
||||
|
||||
@@ -544,47 +587,51 @@ void MediaMenu::cdromUpdateMenu(int i) {
|
||||
|
||||
QString busName = tr("Unknown Bus");
|
||||
switch (cdrom[i].bus_type) {
|
||||
case CDROM_BUS_ATAPI:
|
||||
busName = "ATAPI";
|
||||
break;
|
||||
case CDROM_BUS_SCSI:
|
||||
busName = "SCSI";
|
||||
break;
|
||||
case CDROM_BUS_ATAPI:
|
||||
busName = "ATAPI";
|
||||
break;
|
||||
case CDROM_BUS_SCSI:
|
||||
busName = "SCSI";
|
||||
break;
|
||||
}
|
||||
|
||||
//menu->setTitle(tr("CD-ROM %1 (%2): %3").arg(QString::number(i+1), busName, name.isEmpty() ? tr("(empty)") : name));
|
||||
// menu->setTitle(tr("CD-ROM %1 (%2): %3").arg(QString::number(i+1), busName, name.isEmpty() ? tr("(empty)") : name));
|
||||
menu->setTitle(QString::asprintf(tr("CD-ROM %i (%s): %s").toUtf8().constData(), i + 1, busName.toUtf8().data(), name.isEmpty() ? tr("(empty)").toUtf8().data() : name.toUtf8().data()));
|
||||
}
|
||||
|
||||
void MediaMenu::zipNewImage(int i) {
|
||||
void
|
||||
MediaMenu::zipNewImage(int i)
|
||||
{
|
||||
NewFloppyDialog dialog(NewFloppyDialog::MediaType::Zip, parentWidget);
|
||||
switch (dialog.exec()) {
|
||||
case QDialog::Accepted:
|
||||
QByteArray filename = dialog.fileName().toUtf8();
|
||||
zipMount(i, filename, false);
|
||||
break;
|
||||
case QDialog::Accepted:
|
||||
QByteArray filename = dialog.fileName().toUtf8();
|
||||
zipMount(i, filename, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MediaMenu::zipSelectImage(int i, bool wp) {
|
||||
void
|
||||
MediaMenu::zipSelectImage(int i, bool wp)
|
||||
{
|
||||
auto filename = QFileDialog::getOpenFileName(
|
||||
parentWidget,
|
||||
QString(),
|
||||
QString(),
|
||||
tr("ZIP images") %
|
||||
util::DlgFilter({ "im?","zdi" }) %
|
||||
tr("All files") %
|
||||
util::DlgFilter({ "*" }, true));
|
||||
tr("ZIP images") % util::DlgFilter({ "im?", "zdi" }) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
|
||||
if (!filename.isEmpty()) zipMount(i, filename, wp);
|
||||
if (!filename.isEmpty())
|
||||
zipMount(i, filename, wp);
|
||||
}
|
||||
|
||||
void MediaMenu::zipMount(int i, const QString &filename, bool wp) {
|
||||
void
|
||||
MediaMenu::zipMount(int i, const QString &filename, bool wp)
|
||||
{
|
||||
zip_t *dev = (zip_t *) zip_drives[i].priv;
|
||||
|
||||
zip_disk_close(dev);
|
||||
zip_drives[i].read_only = wp;
|
||||
if (! filename.isEmpty()) {
|
||||
if (!filename.isEmpty()) {
|
||||
QByteArray filenameBytes = filename.toUtf8();
|
||||
zip_load(dev, filenameBytes.data());
|
||||
zip_insert(dev);
|
||||
@@ -597,7 +644,9 @@ void MediaMenu::zipMount(int i, const QString &filename, bool wp) {
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::zipEject(int i) {
|
||||
void
|
||||
MediaMenu::zipEject(int i)
|
||||
{
|
||||
zip_t *dev = (zip_t *) zip_drives[i].priv;
|
||||
|
||||
zip_disk_close(dev);
|
||||
@@ -613,78 +662,89 @@ void MediaMenu::zipEject(int i) {
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::zipReload(int i) {
|
||||
void
|
||||
MediaMenu::zipReload(int i)
|
||||
{
|
||||
zip_t *dev = (zip_t *) zip_drives[i].priv;
|
||||
|
||||
zip_disk_reload(dev);
|
||||
if (strlen(zip_drives[i].image_path) == 0) {
|
||||
ui_sb_update_icon_state(SB_ZIP|i, 1);
|
||||
ui_sb_update_icon_state(SB_ZIP | i, 1);
|
||||
} else {
|
||||
ui_sb_update_icon_state(SB_ZIP|i, 0);
|
||||
ui_sb_update_icon_state(SB_ZIP | i, 0);
|
||||
}
|
||||
|
||||
zipUpdateMenu(i);
|
||||
ui_sb_update_tip(SB_ZIP|i);
|
||||
ui_sb_update_tip(SB_ZIP | i);
|
||||
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::zipUpdateMenu(int i) {
|
||||
QString name = zip_drives[i].image_path;
|
||||
void
|
||||
MediaMenu::zipUpdateMenu(int i)
|
||||
{
|
||||
QString name = zip_drives[i].image_path;
|
||||
QString prev_name = zip_drives[i].prev_image_path;
|
||||
if (!zipMenus.contains(i))
|
||||
return;
|
||||
auto* menu = zipMenus[i];
|
||||
auto childs = menu->children();
|
||||
auto *menu = zipMenus[i];
|
||||
auto childs = menu->children();
|
||||
|
||||
auto* ejectMenu = dynamic_cast<QAction*>(childs[zipEjectPos]);
|
||||
auto* reloadMenu = dynamic_cast<QAction*>(childs[zipReloadPos]);
|
||||
auto *ejectMenu = dynamic_cast<QAction *>(childs[zipEjectPos]);
|
||||
auto *reloadMenu = dynamic_cast<QAction *>(childs[zipReloadPos]);
|
||||
ejectMenu->setEnabled(!name.isEmpty());
|
||||
reloadMenu->setEnabled(!prev_name.isEmpty());
|
||||
|
||||
QString busName = tr("Unknown Bus");
|
||||
switch (zip_drives[i].bus_type) {
|
||||
case ZIP_BUS_ATAPI:
|
||||
busName = "ATAPI";
|
||||
break;
|
||||
case ZIP_BUS_SCSI:
|
||||
busName = "SCSI";
|
||||
break;
|
||||
case ZIP_BUS_ATAPI:
|
||||
busName = "ATAPI";
|
||||
break;
|
||||
case ZIP_BUS_SCSI:
|
||||
busName = "SCSI";
|
||||
break;
|
||||
}
|
||||
|
||||
//menu->setTitle(tr("ZIP %1 %2 (%3): %4").arg((zip_drives[i].is_250 > 0) ? "250" : "100", QString::number(i+1), busName, name.isEmpty() ? tr("(empty)") : name));
|
||||
// menu->setTitle(tr("ZIP %1 %2 (%3): %4").arg((zip_drives[i].is_250 > 0) ? "250" : "100", QString::number(i+1), busName, name.isEmpty() ? tr("(empty)") : name));
|
||||
menu->setTitle(QString::asprintf(tr("ZIP %03i %i (%s): %ls").toUtf8().constData(), (zip_drives[i].is_250 > 0) ? 250 : 100, i + 1, busName.toUtf8().data(), name.isEmpty() ? tr("(empty)").toStdU16String().data() : name.toStdU16String().data()));
|
||||
}
|
||||
|
||||
void MediaMenu::moNewImage(int i) {
|
||||
void
|
||||
MediaMenu::moNewImage(int i)
|
||||
{
|
||||
NewFloppyDialog dialog(NewFloppyDialog::MediaType::Mo, parentWidget);
|
||||
switch (dialog.exec()) {
|
||||
case QDialog::Accepted:
|
||||
QByteArray filename = dialog.fileName().toUtf8();
|
||||
moMount(i, filename, false);
|
||||
break;
|
||||
case QDialog::Accepted:
|
||||
QByteArray filename = dialog.fileName().toUtf8();
|
||||
moMount(i, filename, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MediaMenu::moSelectImage(int i, bool wp) {
|
||||
void
|
||||
MediaMenu::moSelectImage(int i, bool wp)
|
||||
{
|
||||
auto filename = QFileDialog::getOpenFileName(
|
||||
parentWidget,
|
||||
QString(),
|
||||
getMediaOpenDirectory(),
|
||||
tr("MO images") %
|
||||
util::DlgFilter({ "im?", "mdi" }) %
|
||||
tr("All files") %
|
||||
util::DlgFilter({ "*", }, true));
|
||||
tr("MO images") % util::DlgFilter({ "im?", "mdi" }) % tr("All files") % util::DlgFilter({
|
||||
"*",
|
||||
},
|
||||
true));
|
||||
|
||||
if (!filename.isEmpty()) moMount(i, filename, wp);
|
||||
if (!filename.isEmpty())
|
||||
moMount(i, filename, wp);
|
||||
}
|
||||
|
||||
void MediaMenu::moMount(int i, const QString &filename, bool wp) {
|
||||
void
|
||||
MediaMenu::moMount(int i, const QString &filename, bool wp)
|
||||
{
|
||||
mo_t *dev = (mo_t *) mo_drives[i].priv;
|
||||
|
||||
mo_disk_close(dev);
|
||||
mo_drives[i].read_only = wp;
|
||||
if (! filename.isEmpty()) {
|
||||
if (!filename.isEmpty()) {
|
||||
QByteArray filenameBytes = filename.toUtf8();
|
||||
mo_load(dev, filenameBytes.data());
|
||||
mo_insert(dev);
|
||||
@@ -697,7 +757,9 @@ void MediaMenu::moMount(int i, const QString &filename, bool wp) {
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::moEject(int i) {
|
||||
void
|
||||
MediaMenu::moEject(int i)
|
||||
{
|
||||
mo_t *dev = (mo_t *) mo_drives[i].priv;
|
||||
|
||||
mo_disk_close(dev);
|
||||
@@ -713,63 +775,73 @@ void MediaMenu::moEject(int i) {
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::moReload(int i) {
|
||||
void
|
||||
MediaMenu::moReload(int i)
|
||||
{
|
||||
mo_t *dev = (mo_t *) mo_drives[i].priv;
|
||||
|
||||
mo_disk_reload(dev);
|
||||
if (strlen(mo_drives[i].image_path) == 0) {
|
||||
ui_sb_update_icon_state(SB_MO|i, 1);
|
||||
ui_sb_update_icon_state(SB_MO | i, 1);
|
||||
} else {
|
||||
ui_sb_update_icon_state(SB_MO|i, 0);
|
||||
ui_sb_update_icon_state(SB_MO | i, 0);
|
||||
}
|
||||
|
||||
moUpdateMenu(i);
|
||||
ui_sb_update_tip(SB_MO|i);
|
||||
ui_sb_update_tip(SB_MO | i);
|
||||
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::moUpdateMenu(int i) {
|
||||
QString name = mo_drives[i].image_path;
|
||||
void
|
||||
MediaMenu::moUpdateMenu(int i)
|
||||
{
|
||||
QString name = mo_drives[i].image_path;
|
||||
QString prev_name = mo_drives[i].prev_image_path;
|
||||
if (!moMenus.contains(i))
|
||||
return;
|
||||
auto* menu = moMenus[i];
|
||||
auto childs = menu->children();
|
||||
auto *menu = moMenus[i];
|
||||
auto childs = menu->children();
|
||||
|
||||
auto* ejectMenu = dynamic_cast<QAction*>(childs[moEjectPos]);
|
||||
auto* reloadMenu = dynamic_cast<QAction*>(childs[moReloadPos]);
|
||||
auto *ejectMenu = dynamic_cast<QAction *>(childs[moEjectPos]);
|
||||
auto *reloadMenu = dynamic_cast<QAction *>(childs[moReloadPos]);
|
||||
ejectMenu->setEnabled(!name.isEmpty());
|
||||
reloadMenu->setEnabled(!prev_name.isEmpty());
|
||||
|
||||
QString busName = tr("Unknown Bus");
|
||||
switch (mo_drives[i].bus_type) {
|
||||
case MO_BUS_ATAPI:
|
||||
busName = "ATAPI";
|
||||
break;
|
||||
case MO_BUS_SCSI:
|
||||
busName = "SCSI";
|
||||
break;
|
||||
case MO_BUS_ATAPI:
|
||||
busName = "ATAPI";
|
||||
break;
|
||||
case MO_BUS_SCSI:
|
||||
busName = "SCSI";
|
||||
break;
|
||||
}
|
||||
|
||||
menu->setTitle(QString::asprintf(tr("MO %i (%ls): %ls").toUtf8().constData(), i + 1, busName.toStdU16String().data(), name.isEmpty() ? tr("(empty)").toStdU16String().data() : name.toStdU16String().data()));
|
||||
}
|
||||
|
||||
void MediaMenu::nicConnect(int i) {
|
||||
void
|
||||
MediaMenu::nicConnect(int i)
|
||||
{
|
||||
network_connect(i, 1);
|
||||
ui_sb_update_icon_state(SB_NETWORK|i, 0);
|
||||
ui_sb_update_icon_state(SB_NETWORK | i, 0);
|
||||
nicUpdateMenu(i);
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::nicDisconnect(int i) {
|
||||
void
|
||||
MediaMenu::nicDisconnect(int i)
|
||||
{
|
||||
network_connect(i, 0);
|
||||
ui_sb_update_icon_state(SB_NETWORK|i, 1);
|
||||
ui_sb_update_icon_state(SB_NETWORK | i, 1);
|
||||
nicUpdateMenu(i);
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MediaMenu::nicUpdateMenu(int i) {
|
||||
void
|
||||
MediaMenu::nicUpdateMenu(int i)
|
||||
{
|
||||
if (!netMenus.contains(i))
|
||||
return;
|
||||
|
||||
@@ -785,15 +857,17 @@ void MediaMenu::nicUpdateMenu(int i) {
|
||||
|
||||
QString devName = DeviceConfig::DeviceName(network_card_getdevice(net_cards_conf[i].device_num), network_card_get_internal_name(net_cards_conf[i].device_num), 1);
|
||||
|
||||
auto *menu = netMenus[i];
|
||||
auto childs = menu->children();
|
||||
auto *connectedAction = dynamic_cast<QAction*>(childs[netDisconnPos]);
|
||||
auto *menu = netMenus[i];
|
||||
auto childs = menu->children();
|
||||
auto *connectedAction = dynamic_cast<QAction *>(childs[netDisconnPos]);
|
||||
connectedAction->setChecked(network_is_connected(i));
|
||||
|
||||
menu->setTitle(QString::asprintf(tr("NIC %02i (%ls) %ls").toUtf8().constData(), i + 1, netType.toStdU16String().data(), devName.toStdU16String().data()));
|
||||
}
|
||||
|
||||
QString MediaMenu::getMediaOpenDirectory() {
|
||||
QString
|
||||
MediaMenu::getMediaOpenDirectory()
|
||||
{
|
||||
QString openDirectory;
|
||||
if (open_dir_usr_path > 0) {
|
||||
openDirectory = QString::fromUtf8(usr_path);
|
||||
@@ -804,20 +878,27 @@ QString MediaMenu::getMediaOpenDirectory() {
|
||||
// callbacks from 86box C code
|
||||
extern "C" {
|
||||
|
||||
void zip_eject(uint8_t id) {
|
||||
void
|
||||
zip_eject(uint8_t id)
|
||||
{
|
||||
MediaMenu::ptr->zipEject(id);
|
||||
}
|
||||
|
||||
void zip_reload(uint8_t id) {
|
||||
void
|
||||
zip_reload(uint8_t id)
|
||||
{
|
||||
MediaMenu::ptr->zipReload(id);
|
||||
}
|
||||
|
||||
void mo_eject(uint8_t id) {
|
||||
void
|
||||
mo_eject(uint8_t id)
|
||||
{
|
||||
MediaMenu::ptr->moEject(id);
|
||||
}
|
||||
|
||||
void mo_reload(uint8_t id) {
|
||||
void
|
||||
mo_reload(uint8_t id)
|
||||
{
|
||||
MediaMenu::ptr->moReload(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,13 +10,12 @@ extern "C" {
|
||||
}
|
||||
class QMenu;
|
||||
|
||||
class MediaMenu : QObject
|
||||
{
|
||||
class MediaMenu : QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MediaMenu(QWidget* parent);
|
||||
MediaMenu(QWidget *parent);
|
||||
|
||||
void refresh(QMenu* parentMenu);
|
||||
void refresh(QMenu *parentMenu);
|
||||
|
||||
// because some 86box C-only code needs to call zip and
|
||||
// mo eject directly
|
||||
@@ -24,18 +23,18 @@ public:
|
||||
|
||||
void cassetteNewImage();
|
||||
void cassetteSelectImage(bool wp);
|
||||
void cassetteMount(const QString& filename, bool wp);
|
||||
void cassetteMount(const QString &filename, bool wp);
|
||||
void cassetteEject();
|
||||
void cassetteUpdateMenu();
|
||||
|
||||
void cartridgeSelectImage(int i);
|
||||
void cartridgeMount(int i, const QString& filename);
|
||||
void cartridgeMount(int i, const QString &filename);
|
||||
void cartridgeEject(int i);
|
||||
void cartridgeUpdateMenu(int i);
|
||||
|
||||
void floppyNewImage(int i);
|
||||
void floppySelectImage(int i, bool wp);
|
||||
void floppyMount(int i, const QString& filename, bool wp);
|
||||
void floppyMount(int i, const QString &filename, bool wp);
|
||||
void floppyEject(int i);
|
||||
void floppyMenuSelect(int index, int slot);
|
||||
void floppyExportTo86f(int i);
|
||||
@@ -43,7 +42,7 @@ public:
|
||||
|
||||
void cdromMute(int i);
|
||||
void cdromMount(int i, int dir);
|
||||
void cdromMount(int i, const QString& filename);
|
||||
void cdromMount(int i, const QString &filename);
|
||||
void cdromEject(int i);
|
||||
void cdromReload(int index, int slot);
|
||||
void updateImageHistory(int index, int slot, ui::MediaType type);
|
||||
@@ -52,14 +51,14 @@ public:
|
||||
|
||||
void zipNewImage(int i);
|
||||
void zipSelectImage(int i, bool wp);
|
||||
void zipMount(int i, const QString& filename, bool wp);
|
||||
void zipMount(int i, const QString &filename, bool wp);
|
||||
void zipEject(int i);
|
||||
void zipReload(int i);
|
||||
void zipUpdateMenu(int i);
|
||||
|
||||
void moNewImage(int i);
|
||||
void moSelectImage(int i, bool wp);
|
||||
void moMount(int i, const QString& filename, bool wp);
|
||||
void moMount(int i, const QString &filename, bool wp);
|
||||
void moEject(int i);
|
||||
void moReload(int i);
|
||||
void moUpdateMenu(int i);
|
||||
@@ -67,18 +66,19 @@ public:
|
||||
void nicConnect(int i);
|
||||
void nicDisconnect(int i);
|
||||
void nicUpdateMenu(int i);
|
||||
|
||||
private:
|
||||
QWidget* parentWidget = nullptr;
|
||||
QWidget *parentWidget = nullptr;
|
||||
|
||||
QMenu* cassetteMenu = nullptr;
|
||||
QMap<int, QMenu*> cartridgeMenus;
|
||||
QMap<int, QMenu*> floppyMenus;
|
||||
QMap<int, QMenu*> cdromMenus;
|
||||
QMap<int, QMenu*> zipMenus;
|
||||
QMap<int, QMenu*> moMenus;
|
||||
QMap<int, QMenu*> netMenus;
|
||||
QMenu *cassetteMenu = nullptr;
|
||||
QMap<int, QMenu *> cartridgeMenus;
|
||||
QMap<int, QMenu *> floppyMenus;
|
||||
QMap<int, QMenu *> cdromMenus;
|
||||
QMap<int, QMenu *> zipMenus;
|
||||
QMap<int, QMenu *> moMenus;
|
||||
QMap<int, QMenu *> netMenus;
|
||||
|
||||
QString getMediaOpenDirectory();
|
||||
QString getMediaOpenDirectory();
|
||||
ui::MediaHistoryManager mhm;
|
||||
|
||||
int cassetteRecordPos;
|
||||
|
||||
@@ -2,43 +2,65 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
void plat_midi_play_msg(uint8_t *msg)
|
||||
{}
|
||||
void
|
||||
plat_midi_play_msg(uint8_t *msg)
|
||||
{
|
||||
}
|
||||
|
||||
void plat_midi_play_sysex(uint8_t *sysex, unsigned int len)
|
||||
{}
|
||||
void
|
||||
plat_midi_play_sysex(uint8_t *sysex, unsigned int len)
|
||||
{
|
||||
}
|
||||
|
||||
void plat_midi_input_init(void)
|
||||
{}
|
||||
void
|
||||
plat_midi_input_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
void plat_midi_input_close(void)
|
||||
{}
|
||||
void
|
||||
plat_midi_input_close(void)
|
||||
{
|
||||
}
|
||||
|
||||
int plat_midi_write(uint8_t val)
|
||||
{ return 0; }
|
||||
int
|
||||
plat_midi_write(uint8_t val)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void plat_midi_init()
|
||||
{}
|
||||
void
|
||||
plat_midi_init()
|
||||
{
|
||||
}
|
||||
|
||||
void plat_midi_close()
|
||||
{}
|
||||
void
|
||||
plat_midi_close()
|
||||
{
|
||||
}
|
||||
|
||||
int plat_midi_get_num_devs()
|
||||
{ return 0; }
|
||||
int
|
||||
plat_midi_get_num_devs()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int plat_midi_in_get_num_devs(void)
|
||||
{ return 0; }
|
||||
int
|
||||
plat_midi_in_get_num_devs(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void plat_midi_get_dev_name(int num, char *s)
|
||||
void
|
||||
plat_midi_get_dev_name(int num, char *s)
|
||||
{
|
||||
s[0] = ' ';
|
||||
s[1] = 0;
|
||||
}
|
||||
|
||||
void plat_midi_in_get_dev_name(int num, char *s)
|
||||
void
|
||||
plat_midi_in_get_dev_name(int num, char *s)
|
||||
{
|
||||
s[0] = ' ';
|
||||
s[1] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
int Models::AddEntry(QAbstractItemModel *model, const QString& displayRole, int userRole)
|
||||
int
|
||||
Models::AddEntry(QAbstractItemModel *model, const QString &displayRole, int userRole)
|
||||
{
|
||||
int row = model->rowCount();
|
||||
model->insertRow(row);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
class QString;
|
||||
class QAbstractItemModel;
|
||||
namespace Models
|
||||
{
|
||||
int AddEntry(QAbstractItemModel* model, const QString& displayRole, int userRole);
|
||||
namespace Models {
|
||||
int AddEntry(QAbstractItemModel *model, const QString &displayRole, int userRole);
|
||||
};
|
||||
|
||||
@@ -49,8 +49,8 @@ struct disk_size_t {
|
||||
int encoding;
|
||||
int rpm;
|
||||
int tracks;
|
||||
int sectors; /* For IMG and Japanese FDI only. */
|
||||
int sector_len; /* For IMG and Japanese FDI only. */
|
||||
int sectors; /* For IMG and Japanese FDI only. */
|
||||
int sector_len; /* For IMG and Japanese FDI only. */
|
||||
int media_desc;
|
||||
int spc;
|
||||
int num_fats;
|
||||
@@ -58,20 +58,22 @@ struct disk_size_t {
|
||||
int root_dir_entries;
|
||||
};
|
||||
|
||||
static const disk_size_t disk_sizes[14] = { { 0, 1, 2, 1, 0, 40, 8, 2, 0xfe, 2, 2, 1, 64 }, /* 160k */
|
||||
{ 0, 1, 2, 1, 0, 40, 9, 2, 0xfc, 2, 2, 1, 64 }, /* 180k */
|
||||
{ 0, 2, 2, 1, 0, 40, 8, 2, 0xff, 2, 2, 1, 112 }, /* 320k */
|
||||
{ 0, 2, 2, 1, 0, 40, 9, 2, 0xfd, 2, 2, 2, 112 }, /* 360k */
|
||||
{ 0, 2, 2, 1, 0, 80, 8, 2, 0xfb, 2, 2, 2, 112 }, /* 640k */
|
||||
{ 0, 2, 2, 1, 0, 80, 9, 2, 0xf9, 2, 2, 3, 112 }, /* 720k */
|
||||
{ 1, 2, 0, 1, 1, 80, 15, 2, 0xf9, 1, 2, 7, 224 }, /* 1.2M */
|
||||
{ 1, 2, 0, 1, 1, 77, 8, 3, 0xfe, 1, 2, 2, 192 }, /* 1.25M */
|
||||
{ 1, 2, 0, 1, 0, 80, 18, 2, 0xf0, 1, 2, 9, 224 }, /* 1.44M */
|
||||
{ 1, 2, 0, 1, 0, 80, 21, 2, 0xf0, 2, 2, 5, 16 }, /* DMF cluster 1024 */
|
||||
{ 1, 2, 0, 1, 0, 80, 21, 2, 0xf0, 4, 2, 3, 16 }, /* DMF cluster 2048 */
|
||||
{ 2, 2, 3, 1, 0, 80, 36, 2, 0xf0, 2, 2, 9, 240 }, /* 2.88M */
|
||||
{ 0, 64, 0, 0, 0, 96, 32, 2, 0, 0, 0, 0, 0 }, /* ZIP 100 */
|
||||
{ 0, 64, 0, 0, 0, 239, 32, 2, 0, 0, 0, 0, 0 } }; /* ZIP 250 */
|
||||
static const disk_size_t disk_sizes[14] = {
|
||||
{0, 1, 2, 1, 0, 40, 8, 2, 0xfe, 2, 2, 1, 64 }, /* 160k */
|
||||
{ 0, 1, 2, 1, 0, 40, 9, 2, 0xfc, 2, 2, 1, 64 }, /* 180k */
|
||||
{ 0, 2, 2, 1, 0, 40, 8, 2, 0xff, 2, 2, 1, 112}, /* 320k */
|
||||
{ 0, 2, 2, 1, 0, 40, 9, 2, 0xfd, 2, 2, 2, 112}, /* 360k */
|
||||
{ 0, 2, 2, 1, 0, 80, 8, 2, 0xfb, 2, 2, 2, 112}, /* 640k */
|
||||
{ 0, 2, 2, 1, 0, 80, 9, 2, 0xf9, 2, 2, 3, 112}, /* 720k */
|
||||
{ 1, 2, 0, 1, 1, 80, 15, 2, 0xf9, 1, 2, 7, 224}, /* 1.2M */
|
||||
{ 1, 2, 0, 1, 1, 77, 8, 3, 0xfe, 1, 2, 2, 192}, /* 1.25M */
|
||||
{ 1, 2, 0, 1, 0, 80, 18, 2, 0xf0, 1, 2, 9, 224}, /* 1.44M */
|
||||
{ 1, 2, 0, 1, 0, 80, 21, 2, 0xf0, 2, 2, 5, 16 }, /* DMF cluster 1024 */
|
||||
{ 1, 2, 0, 1, 0, 80, 21, 2, 0xf0, 4, 2, 3, 16 }, /* DMF cluster 2048 */
|
||||
{ 2, 2, 3, 1, 0, 80, 36, 2, 0xf0, 2, 2, 9, 240}, /* 2.88M */
|
||||
{ 0, 64, 0, 0, 0, 96, 32, 2, 0, 0, 0, 0, 0 }, /* ZIP 100 */
|
||||
{ 0, 64, 0, 0, 0, 239, 32, 2, 0, 0, 0, 0, 0 }
|
||||
}; /* ZIP 250 */
|
||||
|
||||
static const QStringList rpmModes = {
|
||||
"Perfect RPM",
|
||||
@@ -113,41 +115,36 @@ static const QStringList moTypes = {
|
||||
"5.25\" 1.3 GB",
|
||||
};
|
||||
|
||||
NewFloppyDialog::NewFloppyDialog(MediaType type, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::NewFloppyDialog),
|
||||
mediaType_(type)
|
||||
NewFloppyDialog::NewFloppyDialog(MediaType type, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::NewFloppyDialog)
|
||||
, mediaType_(type)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->fileField->setCreateFile(true);
|
||||
|
||||
auto* model = ui->comboBoxSize->model();
|
||||
auto *model = ui->comboBoxSize->model();
|
||||
switch (type) {
|
||||
case MediaType::Floppy:
|
||||
for (int i = 0; i < floppyTypes.size(); ++i) {
|
||||
Models::AddEntry(model, tr(floppyTypes[i].toUtf8().data()), i);
|
||||
}
|
||||
ui->fileField->setFilter(
|
||||
tr("All images") %
|
||||
util::DlgFilter({ "86f","dsk","flp","im?","*fd?" }) %
|
||||
tr("Basic sector images") %
|
||||
util::DlgFilter({ "dsk","flp","im?","img","*fd?" }) %
|
||||
tr("Surface images") %
|
||||
util::DlgFilter({ "86f" }, true));
|
||||
case MediaType::Floppy:
|
||||
for (int i = 0; i < floppyTypes.size(); ++i) {
|
||||
Models::AddEntry(model, tr(floppyTypes[i].toUtf8().data()), i);
|
||||
}
|
||||
ui->fileField->setFilter(
|
||||
tr("All images") % util::DlgFilter({ "86f", "dsk", "flp", "im?", "*fd?" }) % tr("Basic sector images") % util::DlgFilter({ "dsk", "flp", "im?", "img", "*fd?" }) % tr("Surface images") % util::DlgFilter({ "86f" }, true));
|
||||
|
||||
break;
|
||||
case MediaType::Zip:
|
||||
for (int i = 0; i < zipTypes.size(); ++i) {
|
||||
Models::AddEntry(model, tr(zipTypes[i].toUtf8().data()), i);
|
||||
}
|
||||
ui->fileField->setFilter(tr("ZIP images") % util::DlgFilter({ "im?","zdi" }, true));
|
||||
break;
|
||||
case MediaType::Mo:
|
||||
for (int i = 0; i < moTypes.size(); ++i) {
|
||||
Models::AddEntry(model, tr(moTypes[i].toUtf8().data()), i);
|
||||
}
|
||||
ui->fileField->setFilter(tr("MO images") % util::DlgFilter({ "im?","mdi" }) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
break;
|
||||
break;
|
||||
case MediaType::Zip:
|
||||
for (int i = 0; i < zipTypes.size(); ++i) {
|
||||
Models::AddEntry(model, tr(zipTypes[i].toUtf8().data()), i);
|
||||
}
|
||||
ui->fileField->setFilter(tr("ZIP images") % util::DlgFilter({ "im?", "zdi" }, true));
|
||||
break;
|
||||
case MediaType::Mo:
|
||||
for (int i = 0; i < moTypes.size(); ++i) {
|
||||
Models::AddEntry(model, tr(moTypes[i].toUtf8().data()), i);
|
||||
}
|
||||
ui->fileField->setFilter(tr("MO images") % util::DlgFilter({ "im?", "mdi" }) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
break;
|
||||
}
|
||||
|
||||
model = ui->comboBoxRpm->model();
|
||||
@@ -155,7 +152,7 @@ NewFloppyDialog::NewFloppyDialog(MediaType type, QWidget *parent) :
|
||||
Models::AddEntry(model, tr(rpmModes[i].toUtf8().data()), i);
|
||||
}
|
||||
|
||||
connect(ui->fileField, &FileField::fileSelected, this, [this](const QString& filename) {
|
||||
connect(ui->fileField, &FileField::fileSelected, this, [this](const QString &filename) {
|
||||
bool hide = true;
|
||||
if (mediaType_ == MediaType::Floppy) {
|
||||
if (QFileInfo(filename).suffix().toLower() == QStringLiteral("86f")) {
|
||||
@@ -172,134 +169,140 @@ NewFloppyDialog::NewFloppyDialog(MediaType type, QWidget *parent) :
|
||||
ui->comboBoxRpm->setHidden(true);
|
||||
}
|
||||
|
||||
NewFloppyDialog::~NewFloppyDialog() {
|
||||
NewFloppyDialog::~NewFloppyDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QString NewFloppyDialog::fileName() const{
|
||||
QString
|
||||
NewFloppyDialog::fileName() const
|
||||
{
|
||||
return ui->fileField->fileName();
|
||||
}
|
||||
|
||||
void NewFloppyDialog::onCreate() {
|
||||
auto filename = ui->fileField->fileName();
|
||||
void
|
||||
NewFloppyDialog::onCreate()
|
||||
{
|
||||
auto filename = ui->fileField->fileName();
|
||||
QFileInfo fi(filename);
|
||||
FileType fileType;
|
||||
FileType fileType;
|
||||
|
||||
QProgressDialog progress("Creating floppy image", QString(), 0, 100, this);
|
||||
connect(this, &NewFloppyDialog::fileProgress, &progress, &QProgressDialog::setValue);
|
||||
connect(this, &NewFloppyDialog::fileProgress, [] { QApplication::processEvents(); });
|
||||
switch (mediaType_) {
|
||||
case MediaType::Floppy:
|
||||
if (fi.suffix().toLower() == QStringLiteral("86f")) {
|
||||
if (create86f(filename, disk_sizes[ui->comboBoxSize->currentIndex()], ui->comboBoxRpm->currentIndex())) {
|
||||
return;
|
||||
case MediaType::Floppy:
|
||||
if (fi.suffix().toLower() == QStringLiteral("86f")) {
|
||||
if (create86f(filename, disk_sizes[ui->comboBoxSize->currentIndex()], ui->comboBoxRpm->currentIndex())) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
fileType = fi.suffix().toLower() == QStringLiteral("zdi") ? FileType::Fdi : FileType::Img;
|
||||
if (createSectorImage(filename, disk_sizes[ui->comboBoxSize->currentIndex()], fileType)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fileType = fi.suffix().toLower() == QStringLiteral("zdi") ? FileType::Fdi : FileType::Img;
|
||||
if (createSectorImage(filename, disk_sizes[ui->comboBoxSize->currentIndex()], fileType)) {
|
||||
return;
|
||||
break;
|
||||
case MediaType::Zip:
|
||||
{
|
||||
fileType = fi.suffix().toLower() == QStringLiteral("zdi") ? FileType::Zdi : FileType::Img;
|
||||
|
||||
std::atomic_bool res;
|
||||
std::thread t([this, &res, filename, fileType, &progress] {
|
||||
res = createZipSectorImage(filename, disk_sizes[ui->comboBoxSize->currentIndex() + 12], fileType, progress);
|
||||
});
|
||||
progress.exec();
|
||||
t.join();
|
||||
|
||||
if (res) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MediaType::Zip:
|
||||
{
|
||||
fileType = fi.suffix().toLower() == QStringLiteral("zdi") ? FileType::Zdi: FileType::Img;
|
||||
break;
|
||||
case MediaType::Mo:
|
||||
{
|
||||
fileType = fi.suffix().toLower() == QStringLiteral("mdi") ? FileType::Mdi : FileType::Img;
|
||||
|
||||
std::atomic_bool res;
|
||||
std::thread t([this, &res, filename, fileType, &progress] {
|
||||
res = createZipSectorImage(filename, disk_sizes[ui->comboBoxSize->currentIndex() + 12], fileType, progress);
|
||||
});
|
||||
progress.exec();
|
||||
t.join();
|
||||
std::atomic_bool res;
|
||||
std::thread t([this, &res, filename, fileType, &progress] {
|
||||
res = createMoSectorImage(filename, ui->comboBoxSize->currentIndex(), fileType, progress);
|
||||
});
|
||||
progress.exec();
|
||||
t.join();
|
||||
|
||||
if (res) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MediaType::Mo:
|
||||
{
|
||||
fileType = fi.suffix().toLower() == QStringLiteral("mdi") ? FileType::Mdi: FileType::Img;
|
||||
|
||||
std::atomic_bool res;
|
||||
std::thread t([this, &res, filename, fileType, &progress] {
|
||||
res = createMoSectorImage(filename, ui->comboBoxSize->currentIndex(), fileType, progress);
|
||||
});
|
||||
progress.exec();
|
||||
t.join();
|
||||
|
||||
if (res) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (res) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
QMessageBox::critical(this, tr("Unable to write file"), tr("Make sure the file is being saved to a writable directory"));
|
||||
reject();
|
||||
}
|
||||
|
||||
bool NewFloppyDialog::create86f(const QString& filename, const disk_size_t& disk_size, uint8_t rpm_mode)
|
||||
bool
|
||||
NewFloppyDialog::create86f(const QString &filename, const disk_size_t &disk_size, uint8_t rpm_mode)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
uint32_t magic = 0x46423638;
|
||||
uint16_t version = 0x020C;
|
||||
uint16_t dflags = 0;
|
||||
uint16_t tflags = 0;
|
||||
uint32_t magic = 0x46423638;
|
||||
uint16_t version = 0x020C;
|
||||
uint16_t dflags = 0;
|
||||
uint16_t tflags = 0;
|
||||
uint32_t index_hole_pos = 0;
|
||||
uint32_t tarray[512];
|
||||
uint32_t array_size;
|
||||
uint32_t track_base, track_size;
|
||||
int i;
|
||||
int i;
|
||||
uint32_t shift = 0;
|
||||
|
||||
dflags = 0; /* Has surface data? - Assume no for now. */
|
||||
dflags |= (disk_size.hole << 1); /* Hole */
|
||||
dflags |= ((disk_size.sides - 1) << 3); /* Sides. */
|
||||
dflags |= (0 << 4); /* Write protect? - Assume no for now. */
|
||||
dflags |= (rpm_mode << 5); /* RPM mode. */
|
||||
dflags |= (0 << 7); /* Has extra bit cells? - Assume no for now. */
|
||||
dflags = 0; /* Has surface data? - Assume no for now. */
|
||||
dflags |= (disk_size.hole << 1); /* Hole */
|
||||
dflags |= ((disk_size.sides - 1) << 3); /* Sides. */
|
||||
dflags |= (0 << 4); /* Write protect? - Assume no for now. */
|
||||
dflags |= (rpm_mode << 5); /* RPM mode. */
|
||||
dflags |= (0 << 7); /* Has extra bit cells? - Assume no for now. */
|
||||
|
||||
tflags = disk_size.data_rate; /* Data rate. */
|
||||
tflags |= (disk_size.encoding << 3); /* Encoding. */
|
||||
tflags |= (disk_size.rpm << 5); /* RPM. */
|
||||
tflags = disk_size.data_rate; /* Data rate. */
|
||||
tflags |= (disk_size.encoding << 3); /* Encoding. */
|
||||
tflags |= (disk_size.rpm << 5); /* RPM. */
|
||||
|
||||
switch (disk_size.hole) {
|
||||
case 0:
|
||||
case 1:
|
||||
default:
|
||||
switch(rpm_mode) {
|
||||
case 1:
|
||||
array_size = 25250;
|
||||
break;
|
||||
case 2:
|
||||
array_size = 25374;
|
||||
break;
|
||||
case 3:
|
||||
array_size = 25750;
|
||||
break;
|
||||
default:
|
||||
array_size = 25000;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch(rpm_mode) {
|
||||
case 1:
|
||||
array_size = 50500;
|
||||
break;
|
||||
case 2:
|
||||
array_size = 50750;
|
||||
break;
|
||||
case 3:
|
||||
array_size = 51000;
|
||||
break;
|
||||
default:
|
||||
array_size = 50000;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
default:
|
||||
switch (rpm_mode) {
|
||||
case 1:
|
||||
array_size = 25250;
|
||||
break;
|
||||
case 2:
|
||||
array_size = 25374;
|
||||
break;
|
||||
case 3:
|
||||
array_size = 25750;
|
||||
break;
|
||||
default:
|
||||
array_size = 25000;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (rpm_mode) {
|
||||
case 1:
|
||||
array_size = 50500;
|
||||
break;
|
||||
case 2:
|
||||
array_size = 50750;
|
||||
break;
|
||||
case 3:
|
||||
array_size = 51000;
|
||||
break;
|
||||
default:
|
||||
array_size = 50000;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
auto empty = (unsigned char *) malloc(array_size);
|
||||
@@ -309,7 +312,7 @@ bool NewFloppyDialog::create86f(const QString& filename, const disk_size_t& disk
|
||||
|
||||
f = plat_fopen(filename.toUtf8().data(), "wb");
|
||||
if (!f)
|
||||
return false;
|
||||
return false;
|
||||
|
||||
fwrite(&magic, 4, 1, f);
|
||||
fwrite(&version, 2, 1, f);
|
||||
@@ -320,17 +323,17 @@ bool NewFloppyDialog::create86f(const QString& filename, const disk_size_t& disk
|
||||
track_base = 8 + ((disk_size.sides == 2) ? 2048 : 1024);
|
||||
|
||||
if (disk_size.tracks <= 43)
|
||||
shift = 1;
|
||||
shift = 1;
|
||||
|
||||
for (i = 0; i < (disk_size.tracks * disk_size.sides) << shift; i++)
|
||||
tarray[i] = track_base + (i * track_size);
|
||||
tarray[i] = track_base + (i * track_size);
|
||||
|
||||
fwrite(tarray, 1, (disk_size.sides == 2) ? 2048 : 1024, f);
|
||||
|
||||
for (i = 0; i < (disk_size.tracks * disk_size.sides) << shift; i++) {
|
||||
fwrite(&tflags, 2, 1, f);
|
||||
fwrite(&index_hole_pos, 4, 1, f);
|
||||
fwrite(empty, 1, array_size, f);
|
||||
fwrite(&tflags, 2, 1, f);
|
||||
fwrite(&index_hole_pos, 4, 1, f);
|
||||
fwrite(empty, 1, array_size, f);
|
||||
}
|
||||
|
||||
free(empty);
|
||||
@@ -342,61 +345,62 @@ bool NewFloppyDialog::create86f(const QString& filename, const disk_size_t& disk
|
||||
|
||||
/* Ignore false positive warning caused by a bug on gcc */
|
||||
#if __GNUC__ >= 11
|
||||
#pragma GCC diagnostic ignored "-Wstringop-overflow"
|
||||
# pragma GCC diagnostic ignored "-Wstringop-overflow"
|
||||
#endif
|
||||
|
||||
bool NewFloppyDialog::createSectorImage(const QString &filename, const disk_size_t& disk_size, FileType type)
|
||||
bool
|
||||
NewFloppyDialog::createSectorImage(const QString &filename, const disk_size_t &disk_size, FileType type)
|
||||
{
|
||||
uint32_t total_size = 0;
|
||||
uint32_t total_sectors = 0;
|
||||
uint32_t sector_bytes = 0;
|
||||
uint32_t total_size = 0;
|
||||
uint32_t total_sectors = 0;
|
||||
uint32_t sector_bytes = 0;
|
||||
uint32_t root_dir_bytes = 0;
|
||||
uint32_t fat_size = 0;
|
||||
uint32_t fat1_offs = 0;
|
||||
uint32_t fat2_offs = 0;
|
||||
uint32_t zero_bytes = 0;
|
||||
uint16_t base = 0x1000;
|
||||
uint32_t fat_size = 0;
|
||||
uint32_t fat1_offs = 0;
|
||||
uint32_t fat2_offs = 0;
|
||||
uint32_t zero_bytes = 0;
|
||||
uint16_t base = 0x1000;
|
||||
|
||||
QFile file(filename);
|
||||
if (! file.open(QIODevice::WriteOnly)) {
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
return false;
|
||||
}
|
||||
QDataStream stream(&file);
|
||||
stream.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
sector_bytes = (128 << disk_size.sector_len);
|
||||
sector_bytes = (128 << disk_size.sector_len);
|
||||
total_sectors = disk_size.sides * disk_size.tracks * disk_size.sectors;
|
||||
if (total_sectors > ZIP_SECTORS)
|
||||
total_sectors = ZIP_250_SECTORS;
|
||||
total_size = total_sectors * sector_bytes;
|
||||
total_size = total_sectors * sector_bytes;
|
||||
root_dir_bytes = (disk_size.root_dir_entries << 5);
|
||||
fat_size = (disk_size.spfat * sector_bytes);
|
||||
fat1_offs = sector_bytes;
|
||||
fat2_offs = fat1_offs + fat_size;
|
||||
zero_bytes = fat2_offs + fat_size + root_dir_bytes;
|
||||
fat_size = (disk_size.spfat * sector_bytes);
|
||||
fat1_offs = sector_bytes;
|
||||
fat2_offs = fat1_offs + fat_size;
|
||||
zero_bytes = fat2_offs + fat_size + root_dir_bytes;
|
||||
|
||||
if (type == FileType::Fdi) {
|
||||
QByteArray bytes(base, 0);
|
||||
auto empty = bytes.data();
|
||||
auto empty = bytes.data();
|
||||
*(uint32_t *) &(empty[0x08]) = (uint32_t) base;
|
||||
*(uint32_t *) &(empty[0x0C]) = total_size;
|
||||
*(uint16_t *) &(empty[0x10]) = (uint16_t) sector_bytes;
|
||||
*(uint8_t *) &(empty[0x14]) = (uint8_t) disk_size.sectors;
|
||||
*(uint8_t *) &(empty[0x18]) = (uint8_t) disk_size.sides;
|
||||
*(uint8_t *) &(empty[0x1C]) = (uint8_t) disk_size.tracks;
|
||||
*(uint8_t *) &(empty[0x14]) = (uint8_t) disk_size.sectors;
|
||||
*(uint8_t *) &(empty[0x18]) = (uint8_t) disk_size.sides;
|
||||
*(uint8_t *) &(empty[0x1C]) = (uint8_t) disk_size.tracks;
|
||||
stream.writeRawData(empty, base);
|
||||
}
|
||||
|
||||
QByteArray bytes(total_size, 0);
|
||||
auto empty = bytes.data();
|
||||
auto empty = bytes.data();
|
||||
|
||||
memset(empty + zero_bytes, 0xF6, total_size - zero_bytes);
|
||||
|
||||
empty[0x00] = 0xEB; /* Jump to make MS-DOS happy. */
|
||||
empty[0x00] = 0xEB; /* Jump to make MS-DOS happy. */
|
||||
empty[0x01] = 0x58;
|
||||
empty[0x02] = 0x90;
|
||||
|
||||
empty[0x03] = 0x38; /* '86BOX5.0' OEM ID. */
|
||||
empty[0x03] = 0x38; /* '86BOX5.0' OEM ID. */
|
||||
empty[0x04] = 0x36;
|
||||
empty[0x05] = 0x42;
|
||||
empty[0x06] = 0x4F;
|
||||
@@ -406,17 +410,17 @@ bool NewFloppyDialog::createSectorImage(const QString &filename, const disk_size
|
||||
empty[0x0A] = 0x30;
|
||||
|
||||
*(uint16_t *) &(empty[0x0B]) = (uint16_t) sector_bytes;
|
||||
*(uint8_t *) &(empty[0x0D]) = (uint8_t) disk_size.spc;
|
||||
*(uint8_t *) &(empty[0x0D]) = (uint8_t) disk_size.spc;
|
||||
*(uint16_t *) &(empty[0x0E]) = (uint16_t) 1;
|
||||
*(uint8_t *) &(empty[0x10]) = (uint8_t) disk_size.num_fats;
|
||||
*(uint8_t *) &(empty[0x10]) = (uint8_t) disk_size.num_fats;
|
||||
*(uint16_t *) &(empty[0x11]) = (uint16_t) disk_size.root_dir_entries;
|
||||
*(uint16_t *) &(empty[0x13]) = (uint16_t) total_sectors;
|
||||
*(uint8_t *) &(empty[0x15]) = (uint8_t) disk_size.media_desc;
|
||||
*(uint8_t *) &(empty[0x15]) = (uint8_t) disk_size.media_desc;
|
||||
*(uint16_t *) &(empty[0x16]) = (uint16_t) disk_size.spfat;
|
||||
*(uint8_t *) &(empty[0x18]) = (uint8_t) disk_size.sectors;
|
||||
*(uint8_t *) &(empty[0x1A]) = (uint8_t) disk_size.sides;
|
||||
*(uint8_t *) &(empty[0x18]) = (uint8_t) disk_size.sectors;
|
||||
*(uint8_t *) &(empty[0x1A]) = (uint8_t) disk_size.sides;
|
||||
|
||||
empty[0x26] = 0x29; /* ')' followed by randomly-generated volume serial number. */
|
||||
empty[0x26] = 0x29; /* ')' followed by randomly-generated volume serial number. */
|
||||
empty[0x27] = random_generate();
|
||||
empty[0x28] = random_generate();
|
||||
empty[0x29] = random_generate();
|
||||
@@ -442,22 +446,23 @@ bool NewFloppyDialog::createSectorImage(const QString &filename, const disk_size
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NewFloppyDialog::createZipSectorImage(const QString &filename, const disk_size_t& disk_size, FileType type, QProgressDialog& pbar)
|
||||
bool
|
||||
NewFloppyDialog::createZipSectorImage(const QString &filename, const disk_size_t &disk_size, FileType type, QProgressDialog &pbar)
|
||||
{
|
||||
uint32_t total_size = 0;
|
||||
uint32_t total_size = 0;
|
||||
uint32_t total_sectors = 0;
|
||||
uint32_t sector_bytes = 0;
|
||||
uint16_t base = 0x1000;
|
||||
uint32_t pbar_max = 0;
|
||||
uint32_t sector_bytes = 0;
|
||||
uint16_t base = 0x1000;
|
||||
uint32_t pbar_max = 0;
|
||||
|
||||
QFile file(filename);
|
||||
if (! file.open(QIODevice::WriteOnly)) {
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
return false;
|
||||
}
|
||||
QDataStream stream(&file);
|
||||
stream.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
sector_bytes = (128 << disk_size.sector_len);
|
||||
sector_bytes = (128 << disk_size.sector_len);
|
||||
total_sectors = disk_size.sides * disk_size.tracks * disk_size.sectors;
|
||||
if (total_sectors > ZIP_SECTORS)
|
||||
total_sectors = ZIP_250_SECTORS;
|
||||
@@ -471,21 +476,21 @@ bool NewFloppyDialog::createZipSectorImage(const QString &filename, const disk_s
|
||||
|
||||
if (type == FileType::Zdi) {
|
||||
QByteArray data(base, 0);
|
||||
auto empty = data.data();
|
||||
auto empty = data.data();
|
||||
|
||||
*(uint32_t *) &(empty[0x08]) = (uint32_t) base;
|
||||
*(uint32_t *) &(empty[0x0C]) = total_size;
|
||||
*(uint16_t *) &(empty[0x10]) = (uint16_t) sector_bytes;
|
||||
*(uint8_t *) &(empty[0x14]) = (uint8_t) disk_size.sectors;
|
||||
*(uint8_t *) &(empty[0x18]) = (uint8_t) disk_size.sides;
|
||||
*(uint8_t *) &(empty[0x1C]) = (uint8_t) disk_size.tracks;
|
||||
*(uint8_t *) &(empty[0x14]) = (uint8_t) disk_size.sectors;
|
||||
*(uint8_t *) &(empty[0x18]) = (uint8_t) disk_size.sides;
|
||||
*(uint8_t *) &(empty[0x1C]) = (uint8_t) disk_size.tracks;
|
||||
|
||||
stream.writeRawData(empty, base);
|
||||
pbar_max -= 2;
|
||||
}
|
||||
|
||||
QByteArray bytes(total_size, 0);
|
||||
auto empty = bytes.data();
|
||||
auto empty = bytes.data();
|
||||
|
||||
if (total_sectors == ZIP_SECTORS) {
|
||||
/* ZIP 100 */
|
||||
@@ -515,7 +520,7 @@ bool NewFloppyDialog::createZipSectorImage(const QString &filename, const disk_s
|
||||
*(uint32_t *) &(empty[0x4020]) = 0x0002FFE0;
|
||||
*(uint16_t *) &(empty[0x4024]) = 0x0080;
|
||||
|
||||
empty[0x4026] = 0x29; /* ')' followed by randomly-generated volume serial number. */
|
||||
empty[0x4026] = 0x29; /* ')' followed by randomly-generated volume serial number. */
|
||||
empty[0x4027] = random_generate();
|
||||
empty[0x4028] = random_generate();
|
||||
empty[0x4029] = random_generate();
|
||||
@@ -586,7 +591,7 @@ bool NewFloppyDialog::createZipSectorImage(const QString &filename, const disk_s
|
||||
*(uint32_t *) &(empty[0x4020]) = 0x000777E0;
|
||||
*(uint16_t *) &(empty[0x4024]) = 0x0080;
|
||||
|
||||
empty[0x4026] = 0x29; /* ')' followed by randomly-generated volume serial number. */
|
||||
empty[0x4026] = 0x29; /* ')' followed by randomly-generated volume serial number. */
|
||||
empty[0x4027] = random_generate();
|
||||
empty[0x4028] = random_generate();
|
||||
empty[0x4029] = random_generate();
|
||||
@@ -624,26 +629,26 @@ bool NewFloppyDialog::createZipSectorImage(const QString &filename, const disk_s
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool NewFloppyDialog::createMoSectorImage(const QString& filename, int8_t disk_size, FileType type, QProgressDialog& pbar)
|
||||
bool
|
||||
NewFloppyDialog::createMoSectorImage(const QString &filename, int8_t disk_size, FileType type, QProgressDialog &pbar)
|
||||
{
|
||||
const mo_type_t *dp = &mo_types[disk_size];
|
||||
uint32_t total_size = 0, total_size2;
|
||||
uint32_t total_sectors = 0;
|
||||
uint32_t sector_bytes = 0;
|
||||
uint16_t base = 0x1000;
|
||||
uint32_t pbar_max = 0, blocks_num;
|
||||
const mo_type_t *dp = &mo_types[disk_size];
|
||||
uint32_t total_size = 0, total_size2;
|
||||
uint32_t total_sectors = 0;
|
||||
uint32_t sector_bytes = 0;
|
||||
uint16_t base = 0x1000;
|
||||
uint32_t pbar_max = 0, blocks_num;
|
||||
|
||||
QFile file(filename);
|
||||
if (! file.open(QIODevice::WriteOnly)) {
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
return false;
|
||||
}
|
||||
QDataStream stream(&file);
|
||||
stream.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
sector_bytes = dp->bytes_per_sector;
|
||||
sector_bytes = dp->bytes_per_sector;
|
||||
total_sectors = dp->sectors;
|
||||
total_size = total_sectors * sector_bytes;
|
||||
total_size = total_sectors * sector_bytes;
|
||||
|
||||
total_size2 = (total_size >> 20) << 20;
|
||||
total_size2 = total_size - total_size2;
|
||||
@@ -658,20 +663,20 @@ bool NewFloppyDialog::createMoSectorImage(const QString& filename, int8_t disk_s
|
||||
|
||||
if (type == FileType::Mdi) {
|
||||
QByteArray bytes(base, 0);
|
||||
auto empty = bytes.data();
|
||||
auto empty = bytes.data();
|
||||
|
||||
*(uint32_t *) &(empty[0x08]) = (uint32_t) base;
|
||||
*(uint32_t *) &(empty[0x0C]) = total_size;
|
||||
*(uint16_t *) &(empty[0x10]) = (uint16_t) sector_bytes;
|
||||
*(uint8_t *) &(empty[0x14]) = (uint8_t) 25;
|
||||
*(uint8_t *) &(empty[0x18]) = (uint8_t) 64;
|
||||
*(uint8_t *) &(empty[0x1C]) = (uint8_t) (dp->sectors / 64) / 25;
|
||||
*(uint8_t *) &(empty[0x14]) = (uint8_t) 25;
|
||||
*(uint8_t *) &(empty[0x18]) = (uint8_t) 64;
|
||||
*(uint8_t *) &(empty[0x1C]) = (uint8_t) (dp->sectors / 64) / 25;
|
||||
|
||||
stream.writeRawData(empty, base);
|
||||
}
|
||||
|
||||
QByteArray bytes(1048576, 0);
|
||||
auto empty = bytes.data();
|
||||
auto empty = bytes.data();
|
||||
|
||||
pbar.setMaximum(blocks_num);
|
||||
for (uint32_t i = 0; i < blocks_num; i++) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user