This commit is contained in:
RichardG867
2020-08-12 21:55:33 -03:00
4 changed files with 81 additions and 93 deletions

View File

@@ -1,9 +1,8 @@
86Box
=====
**86Box** is 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.
**86Box** is an 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.
86Box is released under the GNU General Public License, version 2 or later.
For more information, see the `COPYING` file.

View File

@@ -668,12 +668,12 @@ machine_at_presario4500_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_at_common_init(model);
machine_at_common_init_ex(model, 2);
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0);
pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0);
pci_register_slot(0x13, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x13, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x14, PCI_CARD_ONBOARD, 4, 0, 0, 0);
device_add(&i430vx_device);
@@ -681,7 +681,6 @@ machine_at_presario4500_init(const machine_t *model)
device_add(&keyboard_ps2_ami_pci_device);
device_add(&fdc37c931apm_device);
device_add(&intel_flash_bxt_device);
spd_register(SPD_TYPE_SDRAM, 0x01, 128);
return ret;
}

View File

@@ -32,12 +32,14 @@
#include <86box/ui.h>
#include <86box/prt_devs.h>
#ifdef _WIN32
# define GSDLLAPI __stdcall
#else
# define GSDLLAPI
#endif
#define GS_ARG_ENCODING_UTF16LE 2
#define gs_error_Quit -101
@@ -46,31 +48,6 @@
#define POSTSCRIPT_BUFFER_LENGTH 65536
typedef struct gsapi_revision_s {
const char *product;
const char *copyright;
long revision;
long revisiondate;
} gsapi_revision_t;
static int (GSDLLAPI *gsapi_revision)(gsapi_revision_t *pr, int len);
static int (GSDLLAPI *gsapi_new_instance)(void **pinstance, void *caller_handle);
static void (GSDLLAPI *gsapi_delete_instance)(void *instance);
static int (GSDLLAPI *gsapi_set_arg_encoding)(void *instance, int encoding);
static int (GSDLLAPI *gsapi_init_with_args)(void *instance, int argc, char **argv);
static int (GSDLLAPI *gsapi_exit)(void *instance);
static dllimp_t ghostscript_imports[] = {
{ "gsapi_revision", &gsapi_revision },
{ "gsapi_new_instance", &gsapi_new_instance },
{ "gsapi_delete_instance", &gsapi_delete_instance },
{ "gsapi_set_arg_encoding", &gsapi_set_arg_encoding },
{ "gsapi_init_with_args", &gsapi_init_with_args },
{ "gsapi_exit", &gsapi_exit },
{ NULL, NULL }
};
static void *ghostscript_handle = NULL;
typedef struct
{
@@ -98,12 +75,39 @@ typedef struct
size_t buffer_pos;
} ps_t;
typedef struct gsapi_revision_s {
const char *product;
const char *copyright;
long revision;
long revisiondate;
} gsapi_revision_t;
static int (GSDLLAPI *gsapi_revision)(gsapi_revision_t *pr, int len);
static int (GSDLLAPI *gsapi_new_instance)(void **pinstance, void *caller_handle);
static void (GSDLLAPI *gsapi_delete_instance)(void *instance);
static int (GSDLLAPI *gsapi_set_arg_encoding)(void *instance, int encoding);
static int (GSDLLAPI *gsapi_init_with_args)(void *instance, int argc, char **argv);
static int (GSDLLAPI *gsapi_exit)(void *instance);
static dllimp_t ghostscript_imports[] = {
{ "gsapi_revision", &gsapi_revision },
{ "gsapi_new_instance", &gsapi_new_instance },
{ "gsapi_delete_instance", &gsapi_delete_instance },
{ "gsapi_set_arg_encoding", &gsapi_set_arg_encoding },
{ "gsapi_init_with_args", &gsapi_init_with_args },
{ "gsapi_exit", &gsapi_exit },
{ NULL, NULL }
};
static void *ghostscript_handle = NULL;
static void
reset_ps(ps_t *dev)
{
if (dev == NULL) {
if (dev == NULL)
return;
}
dev->ack = false;
@@ -114,6 +118,7 @@ reset_ps(ps_t *dev)
timer_disable(&dev->timeout_timer);
}
static void
pulse_timer(void *priv)
{
@@ -127,6 +132,7 @@ pulse_timer(void *priv)
timer_disable(&dev->pulse_timer);
}
static int
convert_to_pdf(ps_t *dev)
{
@@ -153,42 +159,29 @@ convert_to_pdf(ps_t *dev)
gsargv[8] = input_fn;
code = gsapi_new_instance(&instance, dev);
if (code < 0) {
if (code < 0)
return code;
}
code = gsapi_set_arg_encoding(instance, GS_ARG_ENCODING_UTF16LE);
if (code == 0) {
if (code == 0)
code = gsapi_init_with_args(instance, 9, (char **) gsargv);
}
if (code == 0 || code == gs_error_Quit) {
if (code == 0 || code == gs_error_Quit)
code = gsapi_exit(instance);
} else {
else
gsapi_exit(instance);
}
gsapi_delete_instance(instance);
if (code == 0) {
if (code == 0)
plat_remove(input_fn);
} else {
else
plat_remove(output_fn);
}
return code;
}
static void
finish_document(ps_t *dev)
{
if (ghostscript_handle != NULL) {
convert_to_pdf(dev);
}
dev->filename[0] = 0;
}
static void
write_buffer(ps_t *dev, bool newline)
@@ -196,22 +189,19 @@ write_buffer(ps_t *dev, bool newline)
wchar_t path[1024];
FILE *fp;
if (dev->buffer[0] == 0) {
if (dev->buffer[0] == 0)
return;
}
if (dev->filename[0] == 0) {
if (dev->filename[0] == 0)
plat_tempfile(dev->filename, NULL, L".ps");
}
path[0] = 0;
wcscat(path, dev->printer_path);
wcscat(path, dev->filename);
fp = plat_fopen(path, L"a");
if (fp == NULL) {
if (fp == NULL)
return;
}
fseek(fp, 0, SEEK_END);
@@ -221,36 +211,42 @@ write_buffer(ps_t *dev, bool newline)
dev->buffer[0] = 0;
dev->buffer_pos = 0;
if (ghostscript_handle != NULL)
convert_to_pdf(dev);
dev->filename[0] = 0;
}
static void
timeout_timer(void *priv)
{
ps_t *dev = (ps_t *) priv;
write_buffer(dev, false);
finish_document(dev);
timer_disable(&dev->timeout_timer);
}
static void
ps_write_data(uint8_t val, void *p)
{
ps_t *dev = (ps_t *) p;
if (dev == NULL) {
if (dev == NULL)
return;
}
dev->data = (char) val;
}
static void
process_data(ps_t *dev)
{
/* Check for non-printable characters */
if (dev->data < 0x20 || dev->data == 0x7F) {
if ((dev->data < 0x20) || (dev->data == 0x7f)) {
switch (dev->data) {
/* The following characters are considered white-space
by the PostScript specification */
@@ -268,7 +264,6 @@ process_data(ps_t *dev)
/* Ctrl+D (0x04) marks the end of the document */
case '\4':
write_buffer(dev, false);
finish_document(dev);
return;
/* Don't bother with the others */
@@ -278,32 +273,29 @@ process_data(ps_t *dev)
}
/* Flush the buffer if we have run to its end */
if (dev->buffer_pos == POSTSCRIPT_BUFFER_LENGTH - 1) {
if (dev->buffer_pos == POSTSCRIPT_BUFFER_LENGTH - 1)
write_buffer(dev, false);
dev->buffer_pos = 0;
}
dev->buffer[dev->buffer_pos++] = dev->data;
dev->buffer[dev->buffer_pos] = 0;
}
static void
ps_write_ctrl(uint8_t val, void *p)
{
ps_t *dev = (ps_t *) p;
if (dev == NULL) {
if (dev == NULL)
return;
}
dev->autofeed = val & 0x02 ? true : false;
if (val & 0x08) {
if (val & 0x08)
dev->select = true;
}
if ((val & 0x04) && !(dev->ctrl & 0x04)) {
// reset printer
/* Reset printer */
dev->select = false;
reset_ps(dev);
@@ -321,21 +313,20 @@ ps_write_ctrl(uint8_t val, void *p)
dev->ctrl = val;
}
static uint8_t
ps_read_status(void *p)
{
ps_t *dev = (ps_t *) p;
uint8_t ret = 0x1f;
uint8_t ret = 0x9f;
ret |= 0x80;
if (!dev->ack) {
if (!dev->ack)
ret |= 0x40;
}
return(ret);
}
static void *
ps_init(void *lpt)
{
@@ -351,23 +342,22 @@ ps_init(void *lpt)
/* Try loading the DLL. */
ghostscript_handle = dynld_module(PATH_GHOSTSCRIPT_DLL, ghostscript_imports);
if (ghostscript_handle == NULL) {
if (ghostscript_handle == NULL)
ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2114, (wchar_t *) IDS_2132);
} else {
if (gsapi_revision(&rev, sizeof(rev)) == 0) {
else {
if (gsapi_revision(&rev, sizeof(rev)) == 0)
pclog("Loaded %s, rev %ld (%ld)\n", rev.product, rev.revision, rev.revisiondate);
} else {
else {
dynld_close(ghostscript_handle);
ghostscript_handle = NULL;
}
}
// Cache print folder path
/* Cache print folder path. */
memset(dev->printer_path, 0x00, sizeof(dev->printer_path));
plat_append_filename(dev->printer_path, usr_path, L"printer");
if (!plat_dir_check(dev->printer_path)) {
if (!plat_dir_check(dev->printer_path))
plat_dir_create(dev->printer_path);
}
plat_path_slash(dev->printer_path);
timer_add(&dev->pulse_timer, pulse_timer, dev, 0);
@@ -376,19 +366,17 @@ ps_init(void *lpt)
return(dev);
}
static void
ps_close(void *p)
{
ps_t *dev = (ps_t *) p;
if (dev == NULL) {
if (dev == NULL)
return;
}
if (dev->buffer[0] != 0) {
if (dev->buffer[0] != 0)
write_buffer(dev, false);
finish_document(dev);
}
if (ghostscript_handle != NULL) {
dynld_close(ghostscript_handle);
@@ -398,6 +386,7 @@ ps_close(void *p)
free(dev);
}
const lpt_device_t lpt_prt_ps_device = {
.name = "Generic PostScript printer",
.init = ps_init,

View File

@@ -632,7 +632,8 @@ fdc37c93x_write(uint16_t port, uint8_t val, void *priv)
}
static uint8_t fdc37c93x_read(uint16_t port, void *priv)
static uint8_t
fdc37c93x_read(uint16_t port, void *priv)
{
fdc37c93x_t *dev = (fdc37c93x_t *) priv;
uint8_t index = (port & 1) ? 0 : 1;
@@ -676,7 +677,7 @@ fdc37c93x_reset(fdc37c93x_t *dev)
dev->regs[0x26] = 0xF0;
dev->regs[0x27] = 0x03;
for (i = 0; i < 10; i++)
for (i = 0; i < 11; i++)
memset(dev->ld_regs[i], 0, 256);
/* Logical device 0: FDD */
@@ -826,7 +827,7 @@ fdc37c93x_init(const device_t *info)
nvr_bank_set(1, 0xff, dev->nvr);
}
if (dev->chip_id == 0x03)
if (dev->is_apm || (dev->chip_id == 0x03))
dev->access_bus = device_add(&access_bus_device);
if (dev->is_apm)