mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 09:35:32 -07:00
Merge branch '86Box:master' into t1000rsx
This commit is contained in:
@@ -4758,7 +4758,7 @@ static const scancode scancode_set82[512] = {
|
||||
// clang-format on
|
||||
};
|
||||
/* Scancode set 8Ah : IBM 5556 keyboard compatible scancode set used by J-DOS */
|
||||
static scancode scancode_set8a[512] =
|
||||
const scancode scancode_set8a[512] =
|
||||
{
|
||||
// clang-format off
|
||||
{.mk = { 0 }, .brk = { 0 } }, /* 000 */
|
||||
@@ -4817,7 +4817,7 @@ static scancode scancode_set8a[512] =
|
||||
{.mk = { 0x0a, 0 }, .brk = { 0 } }, /* 035 */
|
||||
{.mk = { 0x39, 0 }, .brk = { 0xb9, 0 } }, /* 036 RSHIFT */
|
||||
{.mk = { 0x64, 0 }, .brk = { 0 } }, /* 037 * (asterisk) */
|
||||
{.mk = { 0x3A, 0 }, .brk = { 0xba, 0 } }, /* 038 0x3A LALT = Kanji */
|
||||
{.mk = { 0x3a, 0 }, .brk = { 0xba, 0 } }, /* 038 0x3A LALT = Kanji */
|
||||
{.mk = { 0x34, 0 }, .brk = { 0 } }, /* 039 */
|
||||
{.mk = { 0x32, 0 }, .brk = { 0xb2, 0 } }, /* 03a CAPSLOCK */
|
||||
{.mk = { 0x68, 0 }, .brk = { 0 } }, /* 03b F1 */
|
||||
|
||||
@@ -195,6 +195,8 @@ postcard_init(UNUSED(const device_t *info))
|
||||
postcard_port = 0x190; /* ISA PS/2 machines */
|
||||
else if (strstr(machines[machine].name, " IBM XT "))
|
||||
postcard_port = 0x60; /* IBM XT */
|
||||
else if (strstr(machines[machine].name, " Multistation "))
|
||||
postcard_port = 0xA1; /* IBM 5550 */
|
||||
else if (strstr(machines[machine].name, " IBM PCjr")) {
|
||||
postcard_port = 0x10; /* IBM PCjr */
|
||||
postcard_ports_num = 3; /* IBM PCjr error ports 11h and 12h */
|
||||
|
||||
13
src/dma.c
13
src/dma.c
@@ -978,10 +978,15 @@ dma_page_write(uint16_t addr, uint8_t val, UNUSED(void *priv))
|
||||
addr &= 0x0f;
|
||||
dmaregs[2][addr] = val;
|
||||
|
||||
if (addr >= 8)
|
||||
addr = convert[addr & 0x07] | 4;
|
||||
else
|
||||
addr = convert[addr & 0x07];
|
||||
if (machines[machine].init == machine_xt_ibm5550_init) {
|
||||
if (addr >= 4)
|
||||
addr = 8;
|
||||
} else {
|
||||
if (addr >= 8)
|
||||
addr = convert[addr & 0x07] | 4;
|
||||
else
|
||||
addr = convert[addr & 0x07];
|
||||
}
|
||||
|
||||
if (addr < 8) {
|
||||
dma[addr].page_l = val;
|
||||
|
||||
122
src/floppy/fdc.c
122
src/floppy/fdc.c
@@ -664,6 +664,21 @@ real_drive(fdc_t *fdc, int drive)
|
||||
return drive;
|
||||
}
|
||||
|
||||
void
|
||||
fdc_diskchange_interrupt(fdc_t *fdc, int drive)
|
||||
{
|
||||
/*
|
||||
For the IBM 5550 machine to detect the disk in the drive has been changed.
|
||||
A hardware interrupt is caused by the FDC (NEC uPD765A) when the Ready line from the drive changes its state.
|
||||
Other PCs never use the Ready line.
|
||||
*/
|
||||
if (fdc->flags & FDC_FLAG_5550) {
|
||||
fdc->st0 = 0xc0 | (drive & 3);
|
||||
fdc_int(fdc, 1);
|
||||
fdd_changed[drive] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* FDD notifies FDC when seek operation is complete */
|
||||
void
|
||||
fdc_seek_complete_interrupt(fdc_t *fdc, int drive)
|
||||
@@ -822,8 +837,47 @@ fdc_write(uint16_t addr, uint8_t val, void *priv)
|
||||
case 0:
|
||||
return;
|
||||
case 1:
|
||||
if (fdc->flags & FDC_FLAG_5550) {
|
||||
val = 0;
|
||||
if (!(val & 0x08)) { /* Drive 2 active */
|
||||
val = 0x42;
|
||||
}
|
||||
if (!(val & 0x04)) { /* Drive 1 active */
|
||||
val &= 0xf0;
|
||||
val |= 0x21;
|
||||
}
|
||||
if (!(val & 0x02)) { /* Drive 0 active */
|
||||
val &= 0xf0;
|
||||
val |= 0x10;
|
||||
}
|
||||
/* Update the DOR because this emulation module depend on it */
|
||||
fdc->dor &= 0x0c;
|
||||
fdc->dor |= val;
|
||||
/* We can now simplify this since each motor now spins separately. */
|
||||
for (int i = 0; i < FDD_NUM; i++) {
|
||||
drive_num = real_drive(fdc, i);
|
||||
if ((!fdd_get_flags(drive_num)) || (drive_num >= FDD_NUM))
|
||||
val &= ~(0x10 << drive_num);
|
||||
else
|
||||
fdd_set_motor_enable(i, (val & (0x10 << drive_num)));
|
||||
}
|
||||
drive_num = real_drive(fdc, val & 0x03);
|
||||
current_drive = drive_num;
|
||||
fdc->st0 = (fdc->st0 & 0xf8) | (val & 0x03) | (fdd_get_head(drive_num) ? 4 : 0);
|
||||
fdc_log("val:%x, dor=%x, drv=%x\n", val, fdc->dor, drive_num);
|
||||
}
|
||||
return;
|
||||
case 2: /*DOR*/
|
||||
if (fdc->flags & FDC_FLAG_5550) { /* Reset */
|
||||
fdd_stop(fdc->drive);
|
||||
for (int i = 0; i < FDD_NUM; i++)
|
||||
fdd_set_motor_enable(i, 0); /* Need to restart fdd timer */
|
||||
fdc->stat = 0x00;
|
||||
fdc->pnum = fdc->ptot = 0;
|
||||
fdc_soft_reset(fdc);
|
||||
fdc->dor = 0x0c;
|
||||
return;
|
||||
}
|
||||
if (fdc->flags & FDC_FLAG_PCJR) {
|
||||
if ((fdc->dor & 0x40) && !(val & 0x40)) {
|
||||
timer_set_delay_u64(&fdc->watchdog_timer, 1000 * TIMER_USEC);
|
||||
@@ -903,6 +957,8 @@ fdc_write(uint16_t addr, uint8_t val, void *priv)
|
||||
}
|
||||
return;
|
||||
case 4: /* DSR */
|
||||
if (fdc->flags & FDC_FLAG_5550)
|
||||
picintc(1 << fdc->irq);
|
||||
if (!(fdc->flags & FDC_FLAG_NO_DSR_RESET)) {
|
||||
if (!(val & 0x80)) {
|
||||
timer_set_delay_u64(&fdc->timer, 8 * TIMER_USEC);
|
||||
@@ -914,6 +970,8 @@ fdc_write(uint16_t addr, uint8_t val, void *priv)
|
||||
fdc->dsr = val;
|
||||
return;
|
||||
case 5: /*Command register*/
|
||||
if (fdc->flags & FDC_FLAG_5550)
|
||||
picintc(1 << fdc->irq);
|
||||
if (fdc->fifointest) {
|
||||
/* Write FIFO buffer in the test mode (PS/55) */
|
||||
fdc_log("FIFO buffer position = %X\n", ((fifo_t *) fdc->fifo_p)->end);
|
||||
@@ -948,7 +1006,33 @@ fdc_write(uint16_t addr, uint8_t val, void *priv)
|
||||
|
||||
fdc->command = val;
|
||||
fdc->stat |= 0x10;
|
||||
fdc_log("Starting FDC command %02X\n", fdc->command);
|
||||
fdc_log("Starting FDC command %02X ", fdc->command);
|
||||
switch (fdc->command & 0x1f) {
|
||||
case 0x06:
|
||||
fdc_log("READ DATA\n");
|
||||
break;
|
||||
case 0x0a:
|
||||
fdc_log("READ ID\n");
|
||||
break;
|
||||
case 0x07:
|
||||
fdc_log("RECALIB\n");
|
||||
break;
|
||||
case 0x08:
|
||||
fdc_log("SENSE INTERRUPT\n");
|
||||
break;
|
||||
case 0x03:
|
||||
fdc_log("SPECIFY\n");
|
||||
break;
|
||||
case 0x04:
|
||||
fdc_log("SENSE DRIVE\n");
|
||||
break;
|
||||
case 0x0f:
|
||||
fdc_log("SEEK\n");
|
||||
break;
|
||||
default:
|
||||
fdc_log("\n");
|
||||
break;
|
||||
}
|
||||
fdc->error = 0;
|
||||
|
||||
if (((fdc->command & 0x1f) == 0x02) || ((fdc->command & 0x1f) == 0x05) ||
|
||||
@@ -1106,6 +1190,8 @@ fdc_write(uint16_t addr, uint8_t val, void *priv)
|
||||
if (command_has_drivesel[fdc->command & 0x1F]) {
|
||||
if (fdc->flags & FDC_FLAG_PCJR)
|
||||
fdc->drive = 0;
|
||||
else if (fdc->flags & FDC_FLAG_5550)
|
||||
fdc->drive = fdc->params[0] & 3;
|
||||
else
|
||||
fdc->drive = fdc->dor & 3;
|
||||
fdc->rw_drive = fdc->params[0] & 3;
|
||||
@@ -1115,6 +1201,8 @@ fdc_write(uint16_t addr, uint8_t val, void *priv)
|
||||
}
|
||||
if (fdc->pnum == fdc->ptot) {
|
||||
fdc_log("Got all params %02X\n", fdc->command);
|
||||
for (int i = 0; i < fdc->ptot; i++)
|
||||
fdc_log(" [%d] %02x\n", i, fdc->params[i]);
|
||||
fifo_reset(fdc->fifo_p);
|
||||
fdc->interrupt = fdc->processed_cmd;
|
||||
fdc->reset_stat = 0;
|
||||
@@ -1451,6 +1539,8 @@ fdc_read(uint16_t addr, void *priv)
|
||||
ret = 0xc0;
|
||||
ret |= (fdc->dor & 0x01) << 5; /* Drive Select 0 */
|
||||
ret |= (fdc->dor & 0x30) >> 4; /* Motor Select 1, 0 */
|
||||
} else if (fdc->flags & FDC_FLAG_5550) {
|
||||
ret = 0;
|
||||
} else {
|
||||
if (is486 || !fdc->enable_3f1)
|
||||
ret = 0xff;
|
||||
@@ -1503,9 +1593,13 @@ fdc_read(uint16_t addr, void *priv)
|
||||
ret = (fdc->rwc[drive] << 4) | (fdc->media_id << 6);
|
||||
break;
|
||||
case 4: /*Status*/
|
||||
if (fdc->flags & FDC_FLAG_5550)
|
||||
picintc(1 << fdc->irq);
|
||||
ret = fdc->stat;
|
||||
break;
|
||||
case 5: /*Data*/
|
||||
if (fdc->flags & FDC_FLAG_5550)
|
||||
picintc(1 << fdc->irq);
|
||||
if (fdc->fifointest) {
|
||||
/* Read FIFO buffer in the test mode (PS/55) */
|
||||
ret = fifo_read(fdc->fifo_p);
|
||||
@@ -1733,6 +1827,8 @@ fdc_callback(void *priv)
|
||||
}
|
||||
if (writeprot[fdc->drive])
|
||||
fdc->res[10] |= 0x40;
|
||||
if ((fdc->flags & FDC_FLAG_5550) && drive_empty[fdc->drive])//IBM 5550
|
||||
fdc->res[10] &= 0xdf; /* Set Not Ready */
|
||||
|
||||
fdc->stat = (fdc->stat & 0xf) | 0xd0;
|
||||
fdc->paramstogo = 1;
|
||||
@@ -2349,6 +2445,10 @@ fdc_set_base(fdc_t *fdc, int base)
|
||||
if (fdc->flags & FDC_FLAG_NSC) {
|
||||
io_sethandler(base + 2, 0x0004, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
|
||||
io_sethandler(base + 7, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
|
||||
} else if (fdc->flags & FDC_FLAG_5550) {
|
||||
io_sethandler(base, 0x0003, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
|
||||
io_sethandler(base + 0x0004, 0x0001, fdc_read, NULL, NULL, NULL, NULL, NULL, fdc);
|
||||
io_sethandler(base + 0x0005, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
|
||||
} else {
|
||||
if ((fdc->flags & FDC_FLAG_AT) || (fdc->flags & FDC_FLAG_AMSTRAD)) {
|
||||
io_sethandler(base + (super_io ? 2 : 0), super_io ? 0x0004 : 0x0006, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
|
||||
@@ -2383,6 +2483,10 @@ fdc_remove(fdc_t *fdc)
|
||||
if (fdc->flags & FDC_FLAG_NSC) {
|
||||
io_removehandler(fdc->base_address + 2, 0x0004, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
|
||||
io_removehandler(fdc->base_address + 7, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
|
||||
} else if (fdc->flags & FDC_FLAG_5550) {
|
||||
io_removehandler(fdc->base_address, 0x0003, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
|
||||
io_removehandler(fdc->base_address + 4, 0x0001, fdc_read, NULL, NULL, NULL, NULL, NULL, fdc);
|
||||
io_removehandler(fdc->base_address + 5, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
|
||||
} else {
|
||||
if ((fdc->flags & FDC_FLAG_AT) || (fdc->flags & FDC_FLAG_AMSTRAD)) {
|
||||
io_removehandler(fdc->base_address + (super_io ? 2 : 0), super_io ? 0x0004 : 0x0006, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
|
||||
@@ -2534,6 +2638,8 @@ fdc_init(const device_t *info)
|
||||
fdc->irq = FDC_TERTIARY_IRQ;
|
||||
else if (fdc->flags & FDC_FLAG_QUA)
|
||||
fdc->irq = FDC_QUATERNARY_IRQ;
|
||||
else if (fdc->flags & FDC_FLAG_5550)
|
||||
fdc->irq = 4;
|
||||
else
|
||||
fdc->irq = FDC_PRIMARY_IRQ;
|
||||
|
||||
@@ -2686,6 +2792,20 @@ const device_t fdc_xt_umc_um8398_device = {
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t fdc_xt_5550_device = {
|
||||
.name = "IBM 5550 Floppy Drive Controller",
|
||||
.internal_name = "fdc_xt_5550",
|
||||
.flags = 0,
|
||||
.local = FDC_FLAG_5550,
|
||||
.init = fdc_init,
|
||||
.close = fdc_close,
|
||||
.reset = fdc_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t fdc_pcjr_device = {
|
||||
.name = "PCjr Floppy Drive Controller",
|
||||
.internal_name = "fdc_pcjr",
|
||||
|
||||
@@ -777,6 +777,10 @@ fdd_poll(void *priv)
|
||||
if (!fdd_notfound)
|
||||
fdc_noidam(fdd_fdc);
|
||||
}
|
||||
|
||||
if (fdd_changed[drive]) {
|
||||
fdc_diskchange_interrupt(fdd_fdc, drive);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#define FDC_FLAG_TER 0x40000 /* Is Tertiary */
|
||||
#define FDC_FLAG_QUA 0x80000 /* Is Quaternary */
|
||||
#define FDC_FLAG_SMC661 0x100000 /* SM(s)C FDC37C661 - different TDR enhanced mode */
|
||||
#define FDC_FLAG_5550 0x200000 /* IBM Multistation 5550 */
|
||||
|
||||
typedef struct fdc_t {
|
||||
uint8_t dor;
|
||||
@@ -252,6 +253,7 @@ extern void fdc_reset(void *priv);
|
||||
|
||||
extern uint8_t fdc_get_current_drive(void);
|
||||
extern void fdc_seek_complete_interrupt(fdc_t *fdc, int drive);
|
||||
extern void fdc_diskchange_interrupt(fdc_t *fdc, int drive);
|
||||
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern const device_t fdc_xt_device;
|
||||
@@ -262,6 +264,7 @@ extern const device_t fdc_xt_t1x00_device;
|
||||
extern const device_t fdc_xt_tandy_device;
|
||||
extern const device_t fdc_xt_amstrad_device;
|
||||
extern const device_t fdc_xt_umc_um8398_device;
|
||||
extern const device_t fdc_xt_5550_device;
|
||||
extern const device_t fdc_pcjr_device;
|
||||
extern const device_t fdc_at_device;
|
||||
extern const device_t fdc_at_sec_device;
|
||||
|
||||
@@ -170,6 +170,7 @@ extern void kbd_adddata_process(uint16_t val, void (*adddata)(uint16_t val));
|
||||
extern void kbd_adddata_process_10x(uint16_t val, void (*adddata)(uint16_t val));
|
||||
|
||||
extern const scancode scancode_xt[512];
|
||||
extern const scancode scancode_set8a[512];
|
||||
|
||||
extern uint8_t keyboard_set3_flags[512];
|
||||
extern uint8_t keyboard_set3_all_repeat;
|
||||
|
||||
@@ -1512,6 +1512,10 @@ extern int machine_xt_iskra3104_init(const machine_t *);
|
||||
extern int machine_xt_lxt3_init(const machine_t *);
|
||||
extern int machine_xt_compaq_deskpro_init(const machine_t *);
|
||||
|
||||
/* m_xt_ibm5550.c */
|
||||
|
||||
extern int machine_xt_ibm5550_init(const machine_t *);
|
||||
|
||||
/* m_xt_t1000.c */
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern const device_t t1000_video_device;
|
||||
|
||||
@@ -90,6 +90,8 @@ typedef struct pit_intf_t {
|
||||
void (*write)(uint16_t addr, uint8_t val, void *priv);
|
||||
/* Gets a counter's count. */
|
||||
uint16_t (*get_count)(void *data, int counter_id);
|
||||
/* Gets a counter's out. */
|
||||
int (*get_outlevel)(void *data, int counter_id);
|
||||
/* Sets a counter's GATE input. */
|
||||
void (*set_gate)(void *data, int counter_id, int gate);
|
||||
/* Sets if a counter's CLOCK input is from the timer or not - used by PCjr. */
|
||||
|
||||
@@ -26,6 +26,7 @@ add_library(mch OBJECT
|
||||
m_europc.c
|
||||
m_elt.c
|
||||
m_xt_olivetti.c
|
||||
m_xt_ibm5550.c
|
||||
m_tandy.c
|
||||
m_v86p.c
|
||||
m_at_t3100e.c
|
||||
|
||||
2132
src/machine/m_xt_ibm5550.c
Normal file
2132
src/machine/m_xt_ibm5550.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3033,6 +3033,49 @@ const machine_t machines[] = {
|
||||
.snd_device = NULL,
|
||||
.net_device = NULL
|
||||
},
|
||||
{
|
||||
.name = "[8086] IBM Multistation 5550",
|
||||
.internal_name = "ibm5550",
|
||||
.type = MACHINE_TYPE_8086,
|
||||
.chipset = MACHINE_CHIPSET_DISCRETE,
|
||||
.init = machine_xt_ibm5550_init,
|
||||
.p1_handler = NULL,
|
||||
.gpio_handler = NULL,
|
||||
.available_flag = MACHINE_AVAILABLE,
|
||||
.gpio_acpi_handler = NULL,
|
||||
.cpu = {
|
||||
.package = CPU_PKG_8086,
|
||||
.block = CPU_BLOCK_NONE,
|
||||
.min_bus = 0,
|
||||
.max_bus = 0,
|
||||
.min_voltage = 0,
|
||||
.max_voltage = 0,
|
||||
.min_multi = 0,
|
||||
.max_multi = 0
|
||||
},
|
||||
.bus_flags = MACHINE_PC,
|
||||
.flags = MACHINE_VIDEO_FIXED | MACHINE_KEYBOARD,
|
||||
.ram = {
|
||||
.min = 256,
|
||||
.max = 640,
|
||||
.step = 128
|
||||
},
|
||||
.nvrmask = 15,
|
||||
.jumpered_ecp_dma = 0,
|
||||
.default_jumpered_ecp_dma = -1,
|
||||
.kbc_device = NULL,
|
||||
.kbc_params = 0x00000000,
|
||||
.kbc_p1 = 0xff,
|
||||
.gpio = 0xffffffff,
|
||||
.gpio_acpi = 0xffffffff,
|
||||
.device = NULL,
|
||||
.kbd_device = NULL,
|
||||
.fdc_device = NULL,
|
||||
.sio_device = NULL,
|
||||
.vid_device = NULL,
|
||||
.snd_device = NULL,
|
||||
.net_device = NULL
|
||||
},
|
||||
|
||||
/* 286 AT machines */
|
||||
/* Has IBM AT KBC firmware. */
|
||||
|
||||
15
src/pit.c
15
src/pit.c
@@ -420,6 +420,15 @@ pit_ctr_get_count(void *data, int counter_id)
|
||||
return (uint16_t) ctr->l;
|
||||
}
|
||||
|
||||
int
|
||||
pit_ctr_get_outlevel(void *data, int counter_id)
|
||||
{
|
||||
const pit_t *pit = (pit_t *) data;
|
||||
const ctr_t *ctr = &pit->counters[counter_id];
|
||||
|
||||
return (int) ctr->out;
|
||||
}
|
||||
|
||||
void
|
||||
pit_ctr_set_load_func(void *data, int counter_id, void (*func)(uint8_t new_m, int new_count))
|
||||
{
|
||||
@@ -1208,6 +1217,11 @@ pit_set_clock(uint32_t clock)
|
||||
CGACONST = (uint64_t) ((cpuclock / (157500000.0 / 88.0)) * (double) (1ULL << 32));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (machines[machine].init == machine_xt_ibm5550_init) {
|
||||
PITCONSTD = (cpuclock / 2000000.0); /* CLK input 2.0 MHz */
|
||||
PITCONST = (uint64_t) (PITCONSTD * (double) (1ULL << 32));
|
||||
}
|
||||
|
||||
ISACONST = (1ULL << 32ULL);
|
||||
}
|
||||
@@ -1263,6 +1277,7 @@ const pit_intf_t pit_classic_intf = {
|
||||
.read = &pit_read,
|
||||
.write = &pit_write,
|
||||
.get_count = &pit_ctr_get_count,
|
||||
.get_outlevel = &pit_ctr_get_outlevel,
|
||||
.set_gate = &pit_ctr_set_gate,
|
||||
.set_using_timer = &pit_ctr_set_using_timer,
|
||||
.set_out_func = &pit_ctr_set_out_func,
|
||||
|
||||
@@ -1,75 +1,24 @@
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
* 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.
|
||||
*
|
||||
* Various ASCII to Unicode maps, for the various codepages.
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Authors: Michael Drüing, <michael@drueing.de>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Code page to Unicode mapping
|
||||
* for a generic ESC/P 2 dot-matrix printer.
|
||||
*
|
||||
* Based on code by Frederic Weymann (originally for DosBox.)
|
||||
* Authors: Lili Kurek, <lili@lili.lgbt>
|
||||
*
|
||||
* Copyright 2018 Michael Drüing.
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Based on code by Frederic Weymann (originally for DOSBox.)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with
|
||||
* or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the entire
|
||||
* above notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names
|
||||
* of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* Copyright 2025-2026 Lili Kurek.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <86box/86box.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/printer.h>
|
||||
|
||||
static const uint16_t cp437Map[256] = {
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
|
||||
static const uint16_t cp437Map[128] = {
|
||||
0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7,
|
||||
0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
|
||||
0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
|
||||
@@ -88,23 +37,7 @@ static const uint16_t cp437Map[256] = {
|
||||
0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
|
||||
};
|
||||
|
||||
static const uint16_t cp737Map[256] = {
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
|
||||
static const uint16_t cp737Map[128] = {
|
||||
0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398,
|
||||
0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, 0x03a0,
|
||||
0x03a1, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7, 0x03a8, 0x03a9,
|
||||
@@ -123,23 +56,7 @@ static const uint16_t cp737Map[256] = {
|
||||
0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
|
||||
};
|
||||
|
||||
static const uint16_t cp775Map[256] = {
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
|
||||
static const uint16_t cp775Map[128] = {
|
||||
0x0106, 0x00fc, 0x00e9, 0x0101, 0x00e4, 0x0123, 0x00e5, 0x0107,
|
||||
0x0142, 0x0113, 0x0156, 0x0157, 0x012b, 0x0179, 0x00c4, 0x00c5,
|
||||
0x00c9, 0x00e6, 0x00c6, 0x014d, 0x00f6, 0x0122, 0x00a2, 0x015a,
|
||||
@@ -158,23 +75,7 @@ static const uint16_t cp775Map[256] = {
|
||||
0x00b0, 0x2219, 0x00b7, 0x00b9, 0x00b3, 0x00b2, 0x25a0, 0x00a0
|
||||
};
|
||||
|
||||
static const uint16_t cp850Map[256] = {
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
|
||||
static const uint16_t cp850Map[128] = {
|
||||
0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7,
|
||||
0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
|
||||
0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
|
||||
@@ -193,23 +94,7 @@ static const uint16_t cp850Map[256] = {
|
||||
0x00b0, 0x00a8, 0x00b7, 0x00b9, 0x00b3, 0x00b2, 0x25a0, 0x00a0
|
||||
};
|
||||
|
||||
static const uint16_t cp852Map[256] = {
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
|
||||
static const uint16_t cp852Map[128] = {
|
||||
0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x016f, 0x0107, 0x00e7,
|
||||
0x0142, 0x00eb, 0x0150, 0x0151, 0x00ee, 0x0179, 0x00c4, 0x0106,
|
||||
0x00c9, 0x0139, 0x013a, 0x00f4, 0x00f6, 0x013d, 0x013e, 0x015a,
|
||||
@@ -228,23 +113,7 @@ static const uint16_t cp852Map[256] = {
|
||||
0x00b0, 0x00a8, 0x02d9, 0x0171, 0x0158, 0x0159, 0x25a0, 0x00a0
|
||||
};
|
||||
|
||||
static const uint16_t cp855Map[256] = {
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
|
||||
static const uint16_t cp855Map[128] = {
|
||||
0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404,
|
||||
0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408,
|
||||
0x0459, 0x0409, 0x045a, 0x040a, 0x045b, 0x040b, 0x045c, 0x040c,
|
||||
@@ -263,23 +132,7 @@ static const uint16_t cp855Map[256] = {
|
||||
0x042d, 0x0449, 0x0429, 0x0447, 0x0427, 0x00a7, 0x25a0, 0x00a0
|
||||
};
|
||||
|
||||
static const uint16_t cp857Map[256] = {
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
|
||||
static const uint16_t cp857Map[128] = {
|
||||
0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7,
|
||||
0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x0131, 0x00c4, 0x00c5,
|
||||
0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
|
||||
@@ -298,23 +151,7 @@ static const uint16_t cp857Map[256] = {
|
||||
0x00b0, 0x00a8, 0x00b7, 0x00b9, 0x00b3, 0x00b2, 0x25a0, 0x00a0
|
||||
};
|
||||
|
||||
static const uint16_t cp860Map[256] = {
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
|
||||
static const uint16_t cp860Map[128] = {
|
||||
0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e3, 0x00e0, 0x00c1, 0x00e7,
|
||||
0x00ea, 0x00ca, 0x00e8, 0x00cd, 0x00d4, 0x00ec, 0x00c3, 0x00c2,
|
||||
0x00c9, 0x00c0, 0x00c8, 0x00f4, 0x00f5, 0x00f2, 0x00da, 0x00f9,
|
||||
@@ -333,23 +170,7 @@ static const uint16_t cp860Map[256] = {
|
||||
0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
|
||||
};
|
||||
|
||||
static const uint16_t cp861Map[256] = {
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
|
||||
static const uint16_t cp861Map[128] = {
|
||||
0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7,
|
||||
0x00ea, 0x00eb, 0x00e8, 0x00d0, 0x00f0, 0x00de, 0x00c4, 0x00c5,
|
||||
0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00fe, 0x00fb, 0x00dd,
|
||||
@@ -368,23 +189,7 @@ static const uint16_t cp861Map[256] = {
|
||||
0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
|
||||
};
|
||||
|
||||
static const uint16_t cp862Map[256] = {
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
|
||||
static const uint16_t cp862Map[128] = {
|
||||
0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7,
|
||||
0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df,
|
||||
0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7,
|
||||
@@ -403,23 +208,7 @@ static const uint16_t cp862Map[256] = {
|
||||
0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
|
||||
};
|
||||
|
||||
static const uint16_t cp863Map[256] = {
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
|
||||
static const uint16_t cp863Map[128] = {
|
||||
0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00c2, 0x00e0, 0x00b6, 0x00e7,
|
||||
0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x2017, 0x00c0, 0x00a7,
|
||||
0x00c9, 0x00c8, 0x00ca, 0x00f4, 0x00cb, 0x00cf, 0x00fb, 0x00f9,
|
||||
@@ -438,23 +227,7 @@ static const uint16_t cp863Map[256] = {
|
||||
0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
|
||||
};
|
||||
|
||||
static const uint16_t cp864Map[256] = {
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x066a, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
|
||||
static const uint16_t cp864Map[128] = {
|
||||
0x00b0, 0x00b7, 0x2219, 0x221a, 0x2592, 0x2500, 0x2502, 0x253c,
|
||||
0x2524, 0x252c, 0x251c, 0x2534, 0x2510, 0x250c, 0x2514, 0x2518,
|
||||
0x03b2, 0x221e, 0x03c6, 0x00b1, 0x00bd, 0x00bc, 0x2248, 0x00ab,
|
||||
@@ -473,23 +246,7 @@ static const uint16_t cp864Map[256] = {
|
||||
0xfed5, 0xfef5, 0xfef6, 0xfedd, 0xfed9, 0xfef1, 0x25a0, 0x00a0
|
||||
};
|
||||
|
||||
static const uint16_t cp865Map[256] = {
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
|
||||
static const uint16_t cp865Map[128] = {
|
||||
0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7,
|
||||
0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
|
||||
0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
|
||||
@@ -508,23 +265,7 @@ static const uint16_t cp865Map[256] = {
|
||||
0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
|
||||
};
|
||||
|
||||
static const uint16_t cp866Map[256] = {
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
|
||||
static const uint16_t cp866Map[128] = {
|
||||
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
|
||||
0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
|
||||
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
|
||||
@@ -570,7 +311,7 @@ static const struct {
|
||||
void
|
||||
select_codepage(uint16_t code, uint16_t *curmap)
|
||||
{
|
||||
uint16_t i = 0;
|
||||
uint8_t i = 0;
|
||||
const uint16_t *map_to_use;
|
||||
|
||||
map_to_use = maps[0].map;
|
||||
@@ -583,6 +324,9 @@ select_codepage(uint16_t code, uint16_t *curmap)
|
||||
i++;
|
||||
}
|
||||
|
||||
for (uint16_t j = 0; j < 256; j++)
|
||||
curmap[j] = map_to_use[j];
|
||||
for (i = 0; i < 128; ++i)
|
||||
curmap[i] = i;
|
||||
|
||||
for (; i != 0; ++i)
|
||||
curmap[i] = map_to_use[i - 128];
|
||||
}
|
||||
|
||||
@@ -1,63 +1,30 @@
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
* 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.
|
||||
*
|
||||
* Implementation of the Generic ESC/P 2 Dot-Matrix printer.
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Authors: Michael Drüing, <michael@drueing.de>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Implementation of a generic ESC/P 2 dot-matrix printer.
|
||||
*
|
||||
* Based on code by Frederic Weymann (originally for DosBox.)
|
||||
* Authors: Lili Kurek, <lili@lili.lgbt>
|
||||
*
|
||||
* Copyright 2018-2019 Michael Drüing.
|
||||
* Copyright 2019 Fred N. van Kempen.
|
||||
* Based on code by Frederic Weymann (originally for DOSBox.)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with
|
||||
* or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the entire
|
||||
* above notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names
|
||||
* of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* Copyright 2025-2026 Lili Kurek.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <math.h>
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
#include <86box/device.h>
|
||||
#include "cpu.h"
|
||||
#include <86box/machine.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/rom.h>
|
||||
@@ -79,6 +46,11 @@ enum {
|
||||
LANG_ESCP2
|
||||
};
|
||||
|
||||
enum {
|
||||
QUALITY_DRAFT = 0,
|
||||
QUALITY_LQ
|
||||
};
|
||||
|
||||
enum {
|
||||
PAPER_LETTER = 0,
|
||||
PAPER_A4,
|
||||
@@ -88,7 +60,7 @@ enum {
|
||||
|
||||
/* Default page values (for now.) */
|
||||
#define COLOR_BLACK 7 << 5
|
||||
#define PAGE_CPI 10.0 /* standard310 cpi */
|
||||
#define PAGE_CPI 10.0 /* standard 10 cpi */
|
||||
#define PAGE_LPI 6.0 /* standard 6 lpi */
|
||||
|
||||
/* FreeType library handles - global so they can be shared. */
|
||||
@@ -106,19 +78,19 @@ enum {
|
||||
};
|
||||
|
||||
/* Font styles. */
|
||||
#define STYLE_PROP 0x0001
|
||||
#define STYLE_CONDENSED 0x0002
|
||||
#define STYLE_BOLD 0x0004
|
||||
#define STYLE_DOUBLESTRIKE 0x0008
|
||||
#define STYLE_DOUBLEWIDTH 0x0010
|
||||
#define STYLE_ITALICS 0x0020
|
||||
#define STYLE_UNDERLINE 0x0040
|
||||
#define STYLE_SUPERSCRIPT 0x0080
|
||||
#define STYLE_SUBSCRIPT 0x0100
|
||||
#define STYLE_STRIKETHROUGH 0x0200
|
||||
#define STYLE_OVERSCORE 0x0400
|
||||
#define STYLE_DOUBLEWIDTHONELINE 0x0800
|
||||
#define STYLE_DOUBLEHEIGHT 0x1000
|
||||
#define STYLE_PROP 0x0002
|
||||
#define STYLE_CONDENSED 0x0004
|
||||
#define STYLE_BOLD 0x0008
|
||||
#define STYLE_DOUBLESTRIKE 0x0010
|
||||
#define STYLE_DOUBLEWIDTH 0x0020
|
||||
#define STYLE_ITALICS 0x0040
|
||||
#define STYLE_UNDERLINE 0x0080
|
||||
#define STYLE_SUPERSCRIPT 0x0100
|
||||
#define STYLE_SUBSCRIPT 0x0200
|
||||
#define STYLE_STRIKETHROUGH 0x0400
|
||||
#define STYLE_OVERSCORE 0x0800
|
||||
#define STYLE_DOUBLEWIDTHONELINE 0x1000
|
||||
#define STYLE_DOUBLEHEIGHT 0x2000
|
||||
|
||||
/* Underlining styles. */
|
||||
#define SCORE_NONE 0x00
|
||||
@@ -127,10 +99,6 @@ enum {
|
||||
#define SCORE_SINGLEBROKEN 0x05
|
||||
#define SCORE_DOUBLEBROKEN 0x06
|
||||
|
||||
/* Print quality. */
|
||||
#define QUALITY_DRAFT 0x01
|
||||
#define QUALITY_LQ 0x02
|
||||
|
||||
/* Typefaces. */
|
||||
enum {
|
||||
TYPEFACE_ROMAN = 0,
|
||||
@@ -179,6 +147,8 @@ typedef struct escp_t {
|
||||
char page_fn[260];
|
||||
uint8_t color;
|
||||
|
||||
bool dc1_selected;
|
||||
|
||||
/* page data (TODO: make configurable) */
|
||||
double page_width; /* all in inches */
|
||||
double page_height;
|
||||
@@ -213,16 +183,16 @@ typedef struct escp_t {
|
||||
|
||||
/* handshake data */
|
||||
uint8_t data;
|
||||
uint8_t ack;
|
||||
uint8_t select;
|
||||
uint8_t busy;
|
||||
uint8_t int_pending;
|
||||
uint8_t error;
|
||||
uint8_t autofeed;
|
||||
bool ack;
|
||||
bool select;
|
||||
bool busy;
|
||||
bool int_pending;
|
||||
bool error;
|
||||
bool autofeed;
|
||||
|
||||
/* ESC command data */
|
||||
int8_t esc_seen; /* set to 1 if an ESC char was seen */
|
||||
int8_t fss_seen;
|
||||
bool esc_seen; /* set if an ESC char was seen */
|
||||
bool fss_seen;
|
||||
uint16_t esc_pending; /* in which ESC command are we */
|
||||
uint8_t esc_parms_req;
|
||||
uint8_t esc_parms_curr;
|
||||
@@ -267,7 +237,7 @@ typedef struct escp_t {
|
||||
|
||||
PALETTE palcol;
|
||||
|
||||
uint8_t auto_lf;
|
||||
bool auto_lf;
|
||||
} escp_t;
|
||||
|
||||
/* Codepage table, needed for ESC t ( */
|
||||
@@ -328,18 +298,13 @@ static const uint16_t intCharSets[15][12] = {
|
||||
};
|
||||
|
||||
#ifdef ENABLE_ESCP_LOG
|
||||
int escp_do_log = ENABLE_ESCP_LOG;
|
||||
|
||||
static void
|
||||
escp_log(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (escp_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 escp_log(fmt, ...)
|
||||
@@ -382,7 +347,7 @@ pulse_timer(void *priv)
|
||||
escp_t *dev = (escp_t *) priv;
|
||||
|
||||
if (dev->ack) {
|
||||
dev->ack = 0;
|
||||
dev->ack = false;
|
||||
lpt_irq(dev->lpt, 1);
|
||||
}
|
||||
|
||||
@@ -426,7 +391,7 @@ update_font(escp_t *dev)
|
||||
double vpoints = 10.5;
|
||||
|
||||
/* We need the FreeType library. */
|
||||
if (ft_lib == NULL)
|
||||
if (!ft_lib)
|
||||
return;
|
||||
|
||||
/* Release current font if we have one. */
|
||||
@@ -560,9 +525,10 @@ reset_printer(escp_t *dev)
|
||||
dev->bottom_margin = dev->page_height - 1.0 / 36.0;
|
||||
/* TODO: these should be configurable. */
|
||||
dev->color = COLOR_BLACK;
|
||||
dev->dc1_selected = true;
|
||||
dev->curr_x = dev->curr_y = 0.0;
|
||||
dev->esc_seen = 0;
|
||||
dev->fss_seen = 0;
|
||||
dev->esc_seen = false;
|
||||
dev->fss_seen = false;
|
||||
dev->esc_pending = 0;
|
||||
dev->esc_parms_req = dev->esc_parms_curr = 0;
|
||||
dev->lpi = PAGE_LPI;
|
||||
@@ -570,7 +536,7 @@ reset_printer(escp_t *dev)
|
||||
dev->cpi = PAGE_CPI;
|
||||
dev->curr_char_table = 1;
|
||||
dev->font_style = 0;
|
||||
dev->print_quality = QUALITY_DRAFT;
|
||||
dev->print_quality = device_get_config_int("quality");
|
||||
dev->extra_intra_space = 0.0;
|
||||
dev->print_upper_control = 1;
|
||||
dev->bg_remaining_bytes = 0;
|
||||
@@ -600,7 +566,7 @@ reset_printer(escp_t *dev)
|
||||
dev->num_horizontal_tabs = 32;
|
||||
dev->num_vertical_tabs = -1;
|
||||
|
||||
if (dev->page != NULL)
|
||||
if (dev->page)
|
||||
dev->page->dirty = 0;
|
||||
|
||||
escp_log("ESC/P: width=%.1fin,height=%.1fin dpi=%i cpi=%i lpi=%i\n",
|
||||
@@ -611,7 +577,7 @@ reset_printer(escp_t *dev)
|
||||
static void
|
||||
reset_printer_hard(escp_t *dev)
|
||||
{
|
||||
dev->ack = 0;
|
||||
dev->ack = false;
|
||||
timer_disable(&dev->pulse_timer);
|
||||
timer_stop(&dev->timeout_timer);
|
||||
reset_printer(dev);
|
||||
@@ -803,7 +769,7 @@ process_char(escp_t *dev, uint8_t ch)
|
||||
dev->esc_pending = ch;
|
||||
if (dev->fss_seen)
|
||||
dev->esc_pending |= 0x800;
|
||||
dev->esc_seen = dev->fss_seen = 0;
|
||||
dev->esc_seen = dev->fss_seen = false;
|
||||
dev->esc_parms_curr = 0;
|
||||
|
||||
escp_log("Command pending=%02x, font path=%s\n", dev->esc_pending, dev->fontpath);
|
||||
@@ -1169,24 +1135,11 @@ process_char(escp_t *dev, uint8_t ch)
|
||||
case '!': /* master select */
|
||||
dev->cpi = (dev->esc_parms[0]) & 0x01 ? 12.0 : 10.0;
|
||||
|
||||
/* Reset first seven bits. */
|
||||
dev->font_style &= 0xFF80;
|
||||
if (dev->esc_parms[0] & 0x02)
|
||||
dev->font_style |= STYLE_PROP;
|
||||
if (dev->esc_parms[0] & 0x04)
|
||||
dev->font_style |= STYLE_CONDENSED;
|
||||
if (dev->esc_parms[0] & 0x08)
|
||||
dev->font_style |= STYLE_BOLD;
|
||||
if (dev->esc_parms[0] & 0x10)
|
||||
dev->font_style |= STYLE_DOUBLESTRIKE;
|
||||
if (dev->esc_parms[0] & 0x20)
|
||||
dev->font_style |= STYLE_DOUBLEWIDTH;
|
||||
if (dev->esc_parms[0] & 0x40)
|
||||
dev->font_style |= STYLE_ITALICS;
|
||||
if (dev->esc_parms[0] & 0x80) {
|
||||
/* Reset first seven style bits (starting from two as CPI had one). */
|
||||
dev->font_style &= 0xFF01;
|
||||
dev->font_style |= dev->esc_parms[0];
|
||||
if (dev->esc_parms[0] & 0x80)
|
||||
dev->font_score = SCORE_SINGLE;
|
||||
dev->font_style |= STYLE_UNDERLINE;
|
||||
}
|
||||
|
||||
dev->hmi = -1;
|
||||
dev->multipoint_mode = 0;
|
||||
@@ -1268,6 +1221,10 @@ process_char(escp_t *dev, uint8_t ch)
|
||||
dev->print_upper_control = 0;
|
||||
break;
|
||||
|
||||
case '8': // disable
|
||||
case '9': // enable paper-out sensor
|
||||
// We don't have real paper, ignore.
|
||||
|
||||
case '<': /* unidirectional mode (one line) */
|
||||
/* We don't have a print head, so just
|
||||
* ignore this. */
|
||||
@@ -1409,7 +1366,7 @@ process_char(escp_t *dev, uint8_t ch)
|
||||
break;
|
||||
|
||||
case 'T': /* cancel superscript/subscript printing */
|
||||
dev->font_style &= 0xFFFF - STYLE_SUPERSCRIPT - STYLE_SUBSCRIPT;
|
||||
dev->font_style &= ~(STYLE_SUPERSCRIPT | STYLE_SUBSCRIPT);
|
||||
update_font(dev);
|
||||
break;
|
||||
|
||||
@@ -1737,7 +1694,7 @@ process_char(escp_t *dev, uint8_t ch)
|
||||
}
|
||||
|
||||
if (dev->font_style & STYLE_DOUBLEWIDTHONELINE) {
|
||||
dev->font_style &= 0xFFFF - STYLE_DOUBLEWIDTHONELINE;
|
||||
dev->font_style &= ~STYLE_DOUBLEWIDTHONELINE;
|
||||
update_font(dev);
|
||||
}
|
||||
return 1;
|
||||
@@ -1784,8 +1741,8 @@ process_char(escp_t *dev, uint8_t ch)
|
||||
return 1;
|
||||
|
||||
case 0x11: /* select printer (DC1) */
|
||||
/* Ignore. */
|
||||
return 0;
|
||||
dev->dc1_selected = true;
|
||||
return 1;
|
||||
|
||||
case 0x12: /* cancel condensed printing (DC2) */
|
||||
dev->hmi = -1;
|
||||
@@ -1794,7 +1751,7 @@ process_char(escp_t *dev, uint8_t ch)
|
||||
return 1;
|
||||
|
||||
case 0x13: /* deselect printer (DC3) */
|
||||
/* Ignore. */
|
||||
dev->dc1_selected = false;
|
||||
return 1;
|
||||
|
||||
case 0x14: /* cancel double-width printing (one line) (DC4) */
|
||||
@@ -1807,13 +1764,13 @@ process_char(escp_t *dev, uint8_t ch)
|
||||
return 1;
|
||||
|
||||
case 0x1b: /* ESC */
|
||||
dev->esc_seen = 1;
|
||||
dev->esc_seen = true;
|
||||
return 1;
|
||||
|
||||
case 0x1c: /* FS (IBM Proprinter II)
|
||||
TODO: Make an IBM printer. */
|
||||
if (dev->lang == LANG_ESCP2) {
|
||||
dev->fss_seen = 1;
|
||||
dev->fss_seen = true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1832,7 +1789,7 @@ blit_glyph(escp_t *dev, unsigned destx, unsigned desty, int8_t add)
|
||||
uint8_t *dst;
|
||||
|
||||
/* check if freetype is available */
|
||||
if (ft_lib == NULL)
|
||||
if (!ft_lib)
|
||||
return;
|
||||
|
||||
for (unsigned int y = 0; y < bitmap->rows; y++) {
|
||||
@@ -1954,16 +1911,18 @@ handle_char(escp_t *dev, uint8_t ch)
|
||||
uint16_t line_y;
|
||||
double x_advance;
|
||||
|
||||
if (dev->page == NULL)
|
||||
if (!(dev->page))
|
||||
return;
|
||||
|
||||
/* MSB mode */
|
||||
if (dev->msb != 255) {
|
||||
if (dev->msb == 0)
|
||||
ch &= 0x7f;
|
||||
else if (dev->msb == 1)
|
||||
ch |= 0x80;
|
||||
}
|
||||
if (dev->msb == 0)
|
||||
ch &= 0x7f;
|
||||
else if (dev->msb == 1)
|
||||
ch |= 0x80;
|
||||
// else it's neutral at 255
|
||||
|
||||
if (!(dev->dc1_selected) && ch != 0x11)
|
||||
return;
|
||||
|
||||
if (dev->bg_remaining_bytes > 0) {
|
||||
print_bit_graph(dev, ch);
|
||||
@@ -1981,7 +1940,7 @@ handle_char(escp_t *dev, uint8_t ch)
|
||||
}
|
||||
|
||||
/* We cannot print if we have no font loaded. */
|
||||
if (dev->fontface == NULL)
|
||||
if (!(dev->fontface))
|
||||
return;
|
||||
|
||||
if (ch == 0x01)
|
||||
@@ -2066,7 +2025,7 @@ write_data(uint8_t val, void *priv)
|
||||
{
|
||||
escp_t *dev = (escp_t *) priv;
|
||||
|
||||
if (dev == NULL)
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
dev->data = val;
|
||||
@@ -2077,7 +2036,7 @@ strobe(uint8_t old, uint8_t val, void *priv)
|
||||
{
|
||||
escp_t *dev = (escp_t *) priv;
|
||||
|
||||
if (dev == NULL)
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
/* Data is strobed to the parallel printer on the falling edge of the
|
||||
@@ -2094,7 +2053,7 @@ strobe(uint8_t old, uint8_t val, void *priv)
|
||||
#endif
|
||||
}
|
||||
/* ACK it, will be read on next READ STATUS. */
|
||||
dev->ack = 1;
|
||||
dev->ack = true;
|
||||
timer_set_delay_u64(&dev->pulse_timer, ISACONST);
|
||||
|
||||
timer_on_auto(&dev->timeout_timer, 5000000.0);
|
||||
@@ -2106,17 +2065,17 @@ write_ctrl(uint8_t val, void *priv)
|
||||
{
|
||||
escp_t *dev = (escp_t *) priv;
|
||||
|
||||
if (dev == NULL)
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
if (val & 0x08) { /* SELECT */
|
||||
/* select printer */
|
||||
dev->select = 1;
|
||||
dev->select = true;
|
||||
}
|
||||
|
||||
if ((val & 0x04) && !(dev->ctrl & 0x04)) {
|
||||
/* reset printer */
|
||||
dev->select = 0;
|
||||
dev->select = false;
|
||||
|
||||
reset_printer_hard(dev);
|
||||
}
|
||||
@@ -2135,7 +2094,7 @@ write_ctrl(uint8_t val, void *priv)
|
||||
#endif
|
||||
}
|
||||
/* ACK it, will be read on next READ STATUS. */
|
||||
dev->ack = 1;
|
||||
dev->ack = true;
|
||||
timer_set_delay_u64(&dev->pulse_timer, ISACONST);
|
||||
|
||||
timer_on_auto(&dev->timeout_timer, 5000000.0);
|
||||
@@ -2174,11 +2133,11 @@ escp_init(const device_t *info)
|
||||
escp_t *dev = NULL;
|
||||
|
||||
/* Initialize FreeType. */
|
||||
if (ft_lib == NULL) {
|
||||
if (!ft_lib) {
|
||||
if (FT_Init_FreeType(&ft_lib)) {
|
||||
pclog("ESC/P: FT_Init_FreeType failed\n");
|
||||
ft_lib = NULL;
|
||||
return (NULL);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2197,7 +2156,7 @@ escp_init(const device_t *info)
|
||||
ui_msgbox_header(MBX_ERROR, plat_get_string(STRING_ESCP_ERROR_TITLE),
|
||||
plat_get_string(STRING_ESCP_ERROR_DESC));
|
||||
free(dev);
|
||||
return (NULL);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Create the full path for the page images. */
|
||||
@@ -2264,7 +2223,7 @@ escp_init(const device_t *info)
|
||||
|
||||
dev->color = COLOR_BLACK;
|
||||
dev->fontface = 0;
|
||||
dev->autofeed = 0;
|
||||
dev->autofeed = false;
|
||||
|
||||
reset_printer(dev);
|
||||
|
||||
@@ -2282,15 +2241,15 @@ escp_close(void *priv)
|
||||
{
|
||||
escp_t *dev = (escp_t *) priv;
|
||||
|
||||
if (dev == NULL)
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
if (dev->page != NULL) {
|
||||
if (dev->page) {
|
||||
/* Print last page if it contains data. */
|
||||
if (dev->page->dirty)
|
||||
dump_page(dev);
|
||||
|
||||
if (dev->page->pixels != NULL)
|
||||
if (dev->page->pixels)
|
||||
free(dev->page->pixels);
|
||||
free(dev->page);
|
||||
}
|
||||
@@ -2337,6 +2296,21 @@ static const device_config_t lpt_prt_escp_config[] = {
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{
|
||||
.name = "quality",
|
||||
.description = "Quality",
|
||||
.type = CONFIG_SELECTION,
|
||||
.default_string = NULL,
|
||||
.default_int = 0,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ .description = "Draft", .value = QUALITY_DRAFT },
|
||||
{ .description = "(Near) Letter", .value = QUALITY_LQ },
|
||||
{ .description = "" }
|
||||
},
|
||||
.bios = { { 0 } }
|
||||
},
|
||||
{
|
||||
.name = "auto_lf",
|
||||
.description = "Auto LF",
|
||||
|
||||
@@ -592,10 +592,10 @@ MediaMenu::cdromMount(int i, int dir, const QString &arg)
|
||||
if (dir > 1)
|
||||
filename = QString::asprintf(R"(ioctl://%s)", arg.toUtf8().data());
|
||||
else if (dir == 1)
|
||||
filename = QFileDialog::getExistingDirectory(parentWidget);
|
||||
filename = QFileDialog::getExistingDirectory(parentWidget, QString(), getMediaOpenDirectory());
|
||||
else {
|
||||
filename = QFileDialog::getOpenFileName(parentWidget, QString(),
|
||||
QString(),
|
||||
getMediaOpenDirectory(),
|
||||
tr("CD-ROM images") % util::DlgFilter({ "iso", "cue", "mds", "mdx" }) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
}
|
||||
|
||||
@@ -1199,10 +1199,13 @@ MediaMenu::nicUpdateMenu(int i)
|
||||
QString
|
||||
MediaMenu::getMediaOpenDirectory()
|
||||
{
|
||||
QString openDirectory;
|
||||
static bool firstCall = true;
|
||||
QString openDirectory;
|
||||
|
||||
if (open_dir_usr_path > 0)
|
||||
if (open_dir_usr_path > 0 && firstCall) {
|
||||
openDirectory = QString::fromUtf8(usr_path);
|
||||
firstCall = false;
|
||||
}
|
||||
|
||||
return openDirectory;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user