Skip to content

Commit

Permalink
Merge branch '86Box:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
1ahmadbassam authored Jun 1, 2024
2 parents 416b8b7 + 86b9ccc commit d7bd7e0
Show file tree
Hide file tree
Showing 17 changed files with 982 additions and 855 deletions.
15 changes: 14 additions & 1 deletion src/chipset/via_apollo.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv)
apollo_smram_map(dev, 0, 0x000a0000, 0x00020000, 0);
break;
}
else
else if (dev->id == VIA_595)
switch (val & 0x03) {
case 0x00:
apollo_smram_map(dev, 1, 0x000a0000, 0x00020000, 0);
Expand All @@ -468,6 +468,12 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv)
default:
break;
}
else {
smram_enable(dev->smram, 0x000a0000, 0x000a0000, 0x00020000,
(dev->pci_conf[0x6d] & 0x10) && (dev->pci_conf[0x63] & 0x01),
dev->pci_conf[0x63] & 0x01);
flushmmucache();
}
break;
case 0x65:
if (dev->id == VIA_585)
Expand Down Expand Up @@ -532,6 +538,13 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv)
dev->pci_conf[0x6d] = (dev->pci_conf[0x6d] & ~0x7f) | (val & 0x7f);
else
dev->pci_conf[0x6d] = val;
if (dev->id == VIA_585) {
smram_disable_all();
smram_enable(dev->smram, 0x000a0000, 0x000a0000, 0x00020000,
(dev->pci_conf[0x6d] & 0x10) && (dev->pci_conf[0x63] & 0x01),
dev->pci_conf[0x63] & 0x01);
flushmmucache();
}
break;
case 0x6e:
if ((dev->id == VIA_595) || (dev->id == VIA_694))
Expand Down
154 changes: 149 additions & 5 deletions src/device/isamem.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
*
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Jasmine Iwanek <jriwanek@gmail.com>
*
* Copyright 2018 Fred N. van Kempen.
* Copyright 2018 Fred N. van Kempen.
* Copyright 2022-2024 Jasmine Iwanek.
*
* Redistribution and use in source and binary forms, with
* or without modification, are permitted provided that the
Expand Down Expand Up @@ -98,14 +100,15 @@
#define ISAMEM_ABOVEBOARD_CARD 12
#define ISAMEM_BRAT_CARD 13
#define ISAMEM_EV165A_CARD 14
#define ISAMEM_LOTECH_CARD 15

#define ISAMEM_DEBUG 0

#define RAM_TOPMEM (640 << 10) /* end of low memory */
#define RAM_UMAMEM (384 << 10) /* upper memory block */
#define RAM_EXTMEM (1024 << 10) /* start of high memory */

#define EMS_MAXSIZE (2048 << 10) /* max EMS memory size */
#define EMS_MAXSIZE (4096 << 10) /* max EMS memory size */
#define EMS_PGSIZE (16 << 10) /* one page is this big */
#define EMS_MAXPAGE 4 /* number of viewport pages */

Expand Down Expand Up @@ -318,6 +321,26 @@ ems_read(uint16_t port, void *priv)
return ret;
}

/* Handle a READ operation from one of our registers. */
static uint8_t
consecutive_ems_read(uint16_t port, void *priv)
{
const memdev_t *dev = (memdev_t *) priv;
uint8_t ret = 0xff;
int vpage;

/* Get the viewport page number. */
vpage = (port - dev->base_addr);

isamem_log("ISAMEM: read(%04x) = %02x) page=%d\n", port, ret, vpage);

ret = dev->ems[vpage].page;
if (dev->ems[vpage].enabled)
ret |= 0x80;

return ret;
}

/* Handle a WRITE operation to one of our registers. */
static void
ems_write(uint16_t port, uint8_t val, void *priv)
Expand Down Expand Up @@ -393,6 +416,47 @@ ems_write(uint16_t port, uint8_t val, void *priv)
}
}

/* Handle a WRITE operation to one of our registers. */
static void
consecutive_ems_write(uint16_t port, uint8_t val, void *priv)
{
memdev_t *dev = (memdev_t *) priv;
int vpage;

/* Get the viewport page number. */
vpage = (port - dev->base_addr);

isamem_log("ISAMEM: write(%04x, %02x) page=%d\n", port, val, vpage);

isamem_log("EMS: write(%02x) to register 0! (%02x)\n", val);
/* Set the page number. */
dev->ems[vpage].enabled = (val & 0xff);
dev->ems[vpage].page = (val & 0xff);

/* Make sure we can do that.. */
if (dev->flags & FLAG_CONFIG) {
if (dev->ems[vpage].page < dev->ems_pages) {
/* Pre-calculate the page address in EMS RAM. */
dev->ems[vpage].addr = dev->ram + dev->ems_start + ((val & 0xff) * EMS_PGSIZE);
} else {
/* That page does not exist. */
dev->ems[vpage].enabled = 0;
}

if (dev->ems[vpage].enabled) {
/* Update the EMS RAM address for this page. */
mem_mapping_set_exec(&dev->ems[vpage].mapping,
dev->ems[vpage].addr);

/* Enable this page. */
mem_mapping_enable(&dev->ems[vpage].mapping);
} else {
/* Disable this page. */
mem_mapping_disable(&dev->ems[vpage].mapping);
}
}
}

/* Initialize the device for use. */
static void *
isamem_init(const device_t *info)
Expand Down Expand Up @@ -435,6 +499,7 @@ isamem_init(const device_t *info)
case ISAMEM_EMS5150_CARD: /* Micro Mainframe EMS-5150(T) */
dev->base_addr = device_get_config_hex16("base");
dev->total_size = device_get_config_int("size");
dev->start_addr = 0;
dev->frame_addr = 0xD0000;
dev->flags |= (FLAG_EMS | FLAG_CONFIG);
break;
Expand Down Expand Up @@ -476,6 +541,13 @@ isamem_init(const device_t *info)
dev->flags |= FLAG_FAST;
break;

case ISAMEM_LOTECH_CARD:
dev->base_addr = device_get_config_hex16("base");
dev->total_size = device_get_config_int("size");
dev->start_addr = 0;
dev->frame_addr = device_get_config_hex20("frame");
dev->flags |= (FLAG_EMS | FLAG_CONFIG);

default:
break;
}
Expand Down Expand Up @@ -625,7 +697,7 @@ isamem_init(const device_t *info)

/* If EMS is enabled, use the remainder for EMS. */
if (dev->flags & FLAG_EMS) {
/* EMS 3.2 cannot have more than 2048KB per board. */
/* EMS 3.2 cannot have more than 4096KB per board. */
t = k;
if (t > EMS_MAXSIZE)
t = EMS_MAXSIZE;
Expand Down Expand Up @@ -663,9 +735,14 @@ isamem_init(const device_t *info)
mem_mapping_disable(&dev->ems[i].mapping);

/* Set up an I/O port handler. */
io_sethandler(dev->base_addr + (EMS_PGSIZE * i), 2,
ems_read, NULL, NULL, ems_write, NULL, NULL, dev);
if (dev->board != ISAMEM_LOTECH_CARD)
io_sethandler(dev->base_addr + (EMS_PGSIZE * i), 2,
ems_read, NULL, NULL, ems_write, NULL, NULL, dev);
}

if (dev->board == ISAMEM_LOTECH_CARD)
io_sethandler(dev->base_addr, 4,
consecutive_ems_read, NULL, NULL, consecutive_ems_write, NULL, NULL, dev);
}

/* Let them know our device instance. */
Expand Down Expand Up @@ -1439,6 +1516,72 @@ static const device_t brat_device = {
};
#endif

static const device_config_t lotech_config[] = {
// clang-format off
{
.name = "base",
.description = "Address",
.type = CONFIG_HEX16,
.default_string = "",
.default_int = 0x0260,
.file_filter = "",
.spinner = { 0 },
.selection = {
{ .description = "260H", .value = 0x0260 },
{ .description = "264H", .value = 0x0264 },
{ .description = "268H", .value = 0x0268 },
{ .description = "26CH", .value = 0x026C },
{ .description = "" }
},
},
{
.name = "frame",
.description = "Frame Address",
.type = CONFIG_HEX20,
.default_string = "",
.default_int = 0xe0000,
.file_filter = "",
.spinner = { 0 },
.selection = {
{ .description = "Disabled", .value = 0x00000 },
{ .description = "C000H", .value = 0xC0000 },
{ .description = "D000H", .value = 0xD0000 },
{ .description = "E000H", .value = 0xE0000 },
{ .description = "" }
},
},
{
.name = "size",
.description = "Memory Size",
.type = CONFIG_SPINNER,
.default_string = "",
.default_int = 2048,
.file_filter = "",
.spinner = {
.min = 512,
.max = 4096,
.step = 512
},
.selection = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
// clang-format on
};

static const device_t lotech_device = {
.name = "Lo-tech EMS Board",
.internal_name = "lotechems",
.flags = DEVICE_ISA,
.local = ISAMEM_LOTECH_CARD,
.init = isamem_init,
.close = isamem_close,
.reset = NULL,
{ .available = NULL },
.speed_changed = NULL,
.force_redraw = NULL,
.config = lotech_config
};

#if defined(DEV_BRANCH) && defined(USE_ISAMEM_RAMPAGE)
static const device_config_t rampage_config[] = {
// clang-format off
Expand Down Expand Up @@ -1676,6 +1819,7 @@ static const struct {
#if defined(DEV_BRANCH) && defined(USE_ISAMEM_IAB)
{ &iab_device },
#endif
{ &lotech_device },
{ NULL }
// clang-format on
};
Expand Down
3 changes: 2 additions & 1 deletion src/include/86box/vid_8514a.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ typedef union {

typedef struct ibm8514_t {
rom_t bios_rom;
rom_t bios_rom2;
hwcursor8514_t hwcursor;
hwcursor8514_t hwcursor_latch;
uint8_t pos_regs[8];
char *rom_path;

int force_old_addr;
int type;
Expand All @@ -56,6 +56,7 @@ typedef struct ibm8514_t {
uint32_t vram_size;
uint32_t vram_mask;
uint32_t pallook[512];
uint32_t bios_addr;

PALETTE vgapal;
uint8_t hwcursor_oddeven;
Expand Down
1 change: 1 addition & 0 deletions src/include/86box/vid_ati_mach8.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ typedef struct mach_t {
uint16_t shadow_set;
uint16_t shadow_cntl;
int ext_on[2];
int extended_mode;
int compat_mode;

struct {
Expand Down
38 changes: 23 additions & 15 deletions src/include/86box/vid_svga.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ typedef struct svga_t {
uint8_t overlay_oddeven;
uint8_t fcr;
uint8_t hblank_overscan;
uint8_t vidsys_ena;

int dac_addr;
int dac_pos;
Expand Down Expand Up @@ -199,6 +200,7 @@ typedef struct svga_t {

void (*ven_write)(struct svga_t *svga, uint8_t val, uint32_t addr);
float (*getclock)(int clock, void *priv);
float (*getclock8514)(int clock, void *priv);

/* Called when VC=R18 and friends. If this returns zero then MA resetting
is skipped. Matrox Mystique in Power mode reuses this counter for
Expand Down Expand Up @@ -288,26 +290,32 @@ typedef struct svga_t {

void * dev8514;
void * ext8514;
void * clock_gen8514;
void * xga;
} svga_t;

extern int vga_on;

extern void ibm8514_poll(void *priv);
extern void ibm8514_recalctimings(svga_t *svga);
extern uint8_t ibm8514_ramdac_in(uint16_t port, void *priv);
extern void ibm8514_ramdac_out(uint16_t port, uint8_t val, void *priv);
extern int ibm8514_cpu_src(svga_t *svga);
extern int ibm8514_cpu_dest(svga_t *svga);
extern void ibm8514_accel_out_pixtrans(svga_t *svga, uint16_t port, uint32_t val, int len);
extern void ibm8514_short_stroke_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, svga_t *svga, uint8_t ssv, int len);
extern void ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, svga_t *svga, int len);
extern int vga_on;

extern void ibm8514_poll(void *priv);
extern void ibm8514_recalctimings(svga_t *svga);
extern uint8_t ibm8514_ramdac_in(uint16_t port, void *priv);
extern void ibm8514_ramdac_out(uint16_t port, uint8_t val, void *priv);
extern void ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len);
extern void ibm8514_accel_out(uint16_t port, uint32_t val, svga_t *svga, int len);
extern uint16_t ibm8514_accel_in_fifo(svga_t *svga, uint16_t port, int len);
extern uint8_t ibm8514_accel_in(uint16_t port, svga_t *svga);
extern int ibm8514_cpu_src(svga_t *svga);
extern int ibm8514_cpu_dest(svga_t *svga);
extern void ibm8514_accel_out_pixtrans(svga_t *svga, uint16_t port, uint32_t val, int len);
extern void ibm8514_short_stroke_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, svga_t *svga, uint8_t ssv, int len);
extern void ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, svga_t *svga, int len);

#ifdef ATI_8514_ULTRA
extern void ati8514_recalctimings(svga_t *svga);
extern uint8_t ati8514_mca_read(int port, void *priv);
extern void ati8514_mca_write(int port, uint8_t val, void *priv);
extern void ati8514_init(svga_t *svga, void *ext8514, void *dev8514);
extern void ati8514_recalctimings(svga_t *svga);
extern uint8_t ati8514_mca_read(int port, void *priv);
extern void ati8514_mca_write(int port, uint8_t val, void *priv);
extern void ati8514_pos_write(uint16_t port, uint8_t val, void *priv);
extern void ati8514_init(svga_t *svga, void *ext8514, void *dev8514);
#endif

extern void xga_poll(void *priv, svga_t *svga);
Expand Down
5 changes: 3 additions & 2 deletions src/include/86box/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,15 +507,15 @@ extern const device_t s3_phoenix_vision864_pci_device;
extern const device_t s3_phoenix_vision864_vlb_device;
extern const device_t s3_9fx_531_pci_device;
extern const device_t s3_phoenix_vision868_pci_device;
extern const device_t s3_phoenix_vision868_vlb_device;
extern const device_t s3_diamond_stealth64_pci_device;
extern const device_t s3_diamond_stealth64_vlb_device;
extern const device_t s3_diamond_stealth64_964_pci_device;
extern const device_t s3_diamond_stealth64_964_vlb_device;
extern const device_t s3_diamond_stealth64_968_pci_device;
extern const device_t s3_diamond_stealth64_968_vlb_device;
extern const device_t s3_mirovideo_40sv_ergo_968_pci_device;
extern const device_t s3_9fx_771_pci_device;
extern const device_t s3_phoenix_vision968_pci_device;
extern const device_t s3_phoenix_vision968_vlb_device;
extern const device_t s3_spea_mercury_p64v_pci_device;
extern const device_t s3_elsa_winner2000_pro_x_964_pci_device;
extern const device_t s3_elsa_winner2000_pro_x_pci_device;
Expand All @@ -528,6 +528,7 @@ extern const device_t s3_diamond_stealth_2000_pci_device;
extern const device_t s3_diamond_stealth_3000_pci_device;
extern const device_t s3_stb_velocity_3d_pci_device;
extern const device_t s3_virge_375_pci_device;
extern const device_t s3_virge_375_onboard_pci_device;
extern const device_t s3_diamond_stealth_2000pro_pci_device;
extern const device_t s3_virge_385_pci_device;
extern const device_t s3_virge_357_pci_device;
Expand Down
Loading

0 comments on commit d7bd7e0

Please sign in to comment.