Files
86Box/src/printer/prt_text.c

480 lines
12 KiB
C
Raw Normal View History

/*
2022-10-29 10:52:49 -04:00
* 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.
*
* Implementation of a generic text printer.
*
* Simple old text printers were unable to do any formatting
* of the text. They were just sheets of paper with a fixed
* size (in the U.S., this would be Letter, 8.5"x11") with a
* set of fixed margings to allow for proper operation of the
* printer mechanics. This would lead to a page being 66 lines
* of 80 characters each.
*
2020-03-25 00:46:02 +02:00
*
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
*
2023-01-06 15:36:29 -05:00
* Copyright 2018-2019 Fred N. van Kempen.
*
* 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.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#include <86box/86box.h>
#include <86box/device.h>
#include <86box/timer.h>
#include <86box/pit.h>
2022-04-19 23:06:39 +02:00
#include <86box/path.h>
2022-02-20 02:26:27 -05:00
#include <86box/plat.h>
#include <86box/lpt.h>
#include <86box/printer.h>
#include <86box/prt_devs.h>
2022-09-18 17:17:25 -04:00
#define FULL_PAGE 1 /* set if no top/bot margins */
/* Default page values (for now.) */
2022-09-18 17:17:25 -04:00
#define PAGE_WIDTH 8.5 /* standard U.S. Letter */
#define PAGE_HEIGHT 11
#define PAGE_LMARGIN 0.25 /* 0.25" left and right */
#define PAGE_RMARGIN 0.25
#if FULL_PAGE
2022-09-18 17:17:25 -04:00
# define PAGE_TMARGIN 0
# define PAGE_BMARGIN 0
#else
2022-09-18 17:17:25 -04:00
# define PAGE_TMARGIN 0.25
# define PAGE_BMARGIN 0.25
#endif
2022-09-18 17:17:25 -04:00
#define PAGE_CPI 10.0 /* standard 10 cpi */
#define PAGE_LPI 6.0 /* standard 6 lpi */
2023-06-28 13:46:28 -04:00
typedef struct psurface_t {
2022-09-18 17:17:25 -04:00
int8_t dirty; /* has the page been printed on? */
char pad;
2022-09-18 17:17:25 -04:00
uint8_t w; /* size //INFO */
uint8_t h;
2022-09-18 17:17:25 -04:00
char *chars; /* character data */
} psurface_t;
2023-06-28 13:46:28 -04:00
typedef struct prnt_t {
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
const char *name;
2022-09-18 17:17:25 -04:00
void *lpt;
/* Output file name. */
2022-09-18 17:17:25 -04:00
char filename[1024];
/* Printer timeout. */
2022-09-18 17:17:25 -04:00
pc_timer_t pulse_timer;
pc_timer_t timeout_timer;
/* page data (TODO: make configurable) */
2023-06-28 13:46:28 -04:00
double page_width; /* all in inches */
double page_height;
double left_margin;
double top_margin;
double right_margin;
double bot_margin;
/* internal page data */
2022-09-18 17:17:25 -04:00
psurface_t *page;
2023-06-28 13:46:28 -04:00
uint8_t max_chars;
uint8_t max_lines;
uint8_t curr_x; /* print head position (x, chars) */
uint8_t curr_y; /* print head position (y, chars) */
/* font data */
2023-06-28 13:46:28 -04:00
double cpi; /* defined chars per inch */
double lpi; /* defined lines per inch */
/* handshake data */
2022-09-18 17:17:25 -04:00
uint8_t data;
int8_t ack;
int8_t select;
int8_t busy;
int8_t int_pending;
int8_t error;
int8_t autofeed;
uint8_t ctrl;
} prnt_t;
/* Dump the current page into a formatted file. */
2022-02-20 02:26:27 -05:00
static void
dump_page(prnt_t *dev)
{
2022-09-18 17:17:25 -04:00
char path[1024];
uint8_t ch;
FILE *fp;
/* Create the full path for this file. */
memset(path, 0x00, sizeof(path));
2022-04-19 23:06:39 +02:00
path_append_filename(path, usr_path, "printer");
2022-09-18 17:17:25 -04:00
if (!plat_dir_check(path))
plat_dir_create(path);
2022-04-19 23:06:39 +02:00
path_slash(path);
strcat(path, dev->filename);
/* Create the file. */
fp = plat_fopen(path, "a");
if (fp == NULL) {
2022-09-18 17:17:25 -04:00
// ERRLOG("PRNT: unable to create print page '%s'\n", path);
return;
}
fseek(fp, 0, SEEK_END);
/* If this is not a new file, add a formfeed first. */
if (ftell(fp) != 0)
2022-09-18 17:17:25 -04:00
fputc('\014', fp);
2023-05-16 15:43:20 -04:00
for (uint16_t y = 0; y < dev->curr_y; y++) {
for (uint16_t x = 0; x < dev->page->w; x++) {
2022-09-18 17:17:25 -04:00
ch = dev->page->chars[(y * dev->page->w) + x];
if (ch == 0x00) {
/* End of line marker. */
fputc('\n', fp);
break;
} else {
fputc(ch, fp);
}
}
}
/* All done, close the file. */
fclose(fp);
}
static void
new_page(prnt_t *dev)
{
/* Dump the current page if needed. */
if (dev->page->dirty)
2022-09-18 17:17:25 -04:00
dump_page(dev);
/* Clear page. */
memset(dev->page->chars, 0x00, dev->page->h * dev->page->w);
2022-09-18 17:17:25 -04:00
dev->curr_y = 0;
dev->page->dirty = 0;
}
static void
pulse_timer(void *priv)
{
prnt_t *dev = (prnt_t *) priv;
if (dev->ack) {
2022-09-18 17:17:25 -04:00
dev->ack = 0;
lpt_irq(dev->lpt, 1);
}
timer_disable(&dev->pulse_timer);
}
static void
timeout_timer(void *priv)
{
prnt_t *dev = (prnt_t *) priv;
if (dev->page->dirty)
2022-09-18 17:17:25 -04:00
new_page(dev);
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
timer_disable(&dev->timeout_timer);
}
static void
reset_printer(prnt_t *dev)
{
/* TODO: these three should be configurable */
2022-09-18 17:17:25 -04:00
dev->page_width = PAGE_WIDTH;
dev->page_height = PAGE_HEIGHT;
dev->left_margin = PAGE_LMARGIN;
dev->right_margin = PAGE_RMARGIN;
2022-09-18 17:17:25 -04:00
dev->top_margin = PAGE_TMARGIN;
dev->bot_margin = PAGE_BMARGIN;
dev->cpi = PAGE_CPI;
dev->lpi = PAGE_LPI;
dev->ack = 0;
/* Default page layout. */
dev->max_chars = (int) ((dev->page_width - dev->left_margin - dev->right_margin) * dev->cpi);
2022-09-18 17:17:25 -04:00
dev->max_lines = (int) ((dev->page_height - dev->top_margin - dev->bot_margin) * dev->lpi);
dev->curr_x = dev->curr_y = 0;
if (dev->page != NULL)
2022-09-18 17:17:25 -04:00
dev->page->dirty = 0;
/* Create a file for this page. */
plat_tempfile(dev->filename, NULL, ".txt");
timer_disable(&dev->pulse_timer);
timer_disable(&dev->timeout_timer);
}
static int
process_char(prnt_t *dev, uint8_t ch)
{
uint8_t i;
switch (ch) {
2022-09-18 17:17:25 -04:00
case 0x07: /* Beeper (BEL) */
/* TODO: beep? */
return 1;
case 0x08: /* Backspace (BS) */
if (dev->curr_x > 0)
dev->curr_x--;
return 1;
case 0x09: /* Tab horizontally (HT) */
/* Find tab right to current pos. */
i = dev->curr_x;
dev->page->chars[(dev->curr_y * dev->page->w) + i++] = ' ';
while ((i < dev->max_chars) && ((i % 8) != 0)) {
dev->page->chars[(dev->curr_y * dev->page->w) + i] = ' ';
i++;
}
dev->curr_x = i;
return 1;
case 0x0b: /* Tab vertically (VT) */
dev->curr_x = 0;
return 1;
case 0x0c: /* Form feed (FF) */
new_page(dev);
return 1;
case 0x0d: /* Carriage Return (CR) */
dev->curr_x = 0;
if (!dev->autofeed)
return 1;
2023-06-09 23:46:54 -04:00
[[fallthrough]];
2022-09-18 17:17:25 -04:00
case 0x0a: /* Line feed */
dev->curr_x = 0;
if (++dev->curr_y >= dev->max_lines)
new_page(dev);
return 1;
case 0x0e: /* select wide printing (SO) */
/* Ignore. */
return 1;
case 0x0f: /* select condensed printing (SI) */
/* Ignore. */
return 1;
case 0x11: /* select printer (DC1) */
/* Ignore. */
return 0;
case 0x12: /* cancel condensed printing (DC2) */
/* Ignore. */
return 1;
case 0x13: /* deselect printer (DC3) */
/* Ignore. */
return 1;
case 0x14: /* cancel double-width printing (one line) (DC4) */
/* Ignore. */
return 1;
case 0x18: /* cancel line (CAN) */
/* Ignore. */
return 1;
case 0x1b: /* ESC */
/* Ignore. */
return 1;
default:
break;
}
/* Just a printable character. */
2023-05-16 15:43:20 -04:00
return 0;
}
static void
handle_char(prnt_t *dev)
{
uint8_t ch = dev->data;
2022-09-18 17:17:25 -04:00
if (dev->page == NULL)
return;
if (process_char(dev, ch) == 1) {
2022-09-18 17:17:25 -04:00
/* Command was processed. */
return;
}
/* Store character in the page buffer. */
dev->page->chars[(dev->curr_y * dev->page->w) + dev->curr_x] = ch;
2022-09-18 17:17:25 -04:00
dev->page->dirty = 1;
/* Update print head position. */
if (++dev->curr_x >= dev->max_chars) {
2022-09-18 17:17:25 -04:00
dev->curr_x = 0;
if (++dev->curr_y >= dev->max_lines)
new_page(dev);
}
}
static void
write_data(uint8_t val, void *priv)
{
2022-09-18 17:17:25 -04:00
prnt_t *dev = (prnt_t *) priv;
2022-09-18 17:17:25 -04:00
if (dev == NULL)
return;
dev->data = val;
}
static void
write_ctrl(uint8_t val, void *priv)
{
2022-09-18 17:17:25 -04:00
prnt_t *dev = (prnt_t *) priv;
2022-09-18 17:17:25 -04:00
if (dev == NULL)
return;
/* set autofeed value */
dev->autofeed = val & 0x02 ? 1 : 0;
2022-09-18 17:17:25 -04:00
if (val & 0x08) { /* SELECT */
/* select printer */
dev->select = 1;
}
if ((val & 0x04) && !(dev->ctrl & 0x04)) {
2022-09-18 17:17:25 -04:00
/* reset printer */
dev->select = 0;
2022-09-18 17:17:25 -04:00
reset_printer(dev);
}
2022-09-18 17:17:25 -04:00
if (!(val & 0x01) && (dev->ctrl & 0x01)) { /* STROBE */
/* Process incoming character. */
handle_char(dev);
2022-09-18 17:17:25 -04:00
/* ACK it, will be read on next READ STATUS. */
dev->ack = 1;
2022-09-18 17:17:25 -04:00
timer_set_delay_u64(&dev->pulse_timer, ISACONST);
timer_set_delay_u64(&dev->timeout_timer, 5000000 * TIMER_USEC);
}
dev->ctrl = val;
}
static uint8_t
read_status(void *priv)
{
2022-09-18 17:17:25 -04:00
prnt_t *dev = (prnt_t *) priv;
uint8_t ret = 0x1f;
ret |= 0x80;
if (!dev->ack)
2022-09-18 17:17:25 -04:00
ret |= 0x40;
2023-05-16 15:43:20 -04:00
return ret;
}
static void *
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
prnt_init(void *lpt)
{
prnt_t *dev;
/* Initialize a device instance. */
2022-09-18 17:17:25 -04:00
dev = (prnt_t *) malloc(sizeof(prnt_t));
memset(dev, 0x00, sizeof(prnt_t));
dev->ctrl = 0x04;
2022-09-18 17:17:25 -04:00
dev->lpt = lpt;
/* Initialize parameters. */
reset_printer(dev);
/* Create a page buffer. */
2022-09-18 17:17:25 -04:00
dev->page = (psurface_t *) malloc(sizeof(psurface_t));
dev->page->w = dev->max_chars;
dev->page->h = dev->max_lines;
dev->page->chars = (char *) malloc(dev->page->w * dev->page->h);
memset(dev->page->chars, 0x00, dev->page->w * dev->page->h);
timer_add(&dev->pulse_timer, pulse_timer, dev, 0);
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
timer_add(&dev->timeout_timer, timeout_timer, dev, 0);
2023-05-16 15:43:20 -04:00
return dev;
}
static void
prnt_close(void *priv)
{
2022-09-18 17:17:25 -04:00
prnt_t *dev = (prnt_t *) priv;
if (dev == NULL)
2022-09-18 17:17:25 -04:00
return;
if (dev->page) {
2022-09-18 17:17:25 -04:00
/* print last page if it contains data */
if (dev->page->dirty)
dump_page(dev);
2022-09-18 17:17:25 -04:00
if (dev->page->chars != NULL)
free(dev->page->chars);
free(dev->page);
}
free(dev);
}
const lpt_device_t lpt_prt_text_device = {
2022-09-18 17:17:25 -04:00
.name = "Generic Text Printer",
2022-03-13 09:51:07 -04:00
.internal_name = "text_prt",
2022-09-18 17:17:25 -04:00
.init = prnt_init,
.close = prnt_close,
.write_data = write_data,
.write_ctrl = write_ctrl,
.read_data = NULL,
.read_status = read_status,
.read_ctrl = NULL
};