vogons - very old games on new systems Last Visit : never :: 2010-8-01 @ 01:50 am : Now
?FAQ sSearch mMemberlist uUsergroups
rRegister pProfile "Messages lLog in
View posts : unanswered
Forum Index :: DOSBox Patches ::
up Virtual printer
Reply with quote Virtual printer :: 2004-2-15 @ 12:06 am
Fizzban
Newbie
[avatar]
Joined: 2003-12-15
Posts: 75
I proudly present: The beta version of my dot-matrix printer emulation..

Main features:


  • Support for most ESC/P commands
  • Sans Serif, Roman, Courier and script font
  • Bold, italic, superscript, subscript, condensed, double-width, double-height
  • Different font sizes
  • Underline, strikethrough, overscore (single, double, broken score)
  • Bit graphics from 60x60 to 360x360 dpi


It does not emulate a specific printer but picking any 24-pin printer from EPSON should work.

The emulation uses Freetype2 and GPL'ed TrueType-fonts to "print" the text. It creates a surface in the main memory that acts as page. At the default settings, this is a 8.5''x11'' page at 360 dpi leading to a surface size of around 11.5 MB. This shouldn't be a problem but if you are low on RAM, try to reduce the dpi setting in dosbox.conf to 240 or 180 dpi.

Attached is a compiled version of the printer-enabled DOSBOX and its sources. If you want to compile it for yourself, you must download and install the FreeType2 library. The configure-script created by autogen.sh will automatically find and use it.

Currently, as soon as one page is done, it will be dumped as page.bmp in the DOSBOX directory. Of course, in the future I plan to send it directly to an actual printer.

EDIT: See my posting below for the files


Last edited by Fizzban on 2004-2-15 @ 10:57 pm; edited 2 times in total
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-15 @ 12:39 pm
Fizzban
Newbie
[avatar]
Joined: 2003-12-15
Posts: 75
Thanks.. Very Happy

BMP because SDL already has a "dump BMP image" function.. Happy

Yes, there is no way to forward the data to the printer in an OS-indepent way. I'm currently looking for a GPL-library that has support for different OSes.
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-15 @ 02:46 pm
mirekluza
DOSBox Moderator
no avatar
Joined: 2003-08-21
Posts: 1697
I have tried to use the provided binary with the following results (three failures, one partiall success). But at least two of these failures are caused by the fact that DOSBOX does not support printing device (LPT1) - so it does not even get to printing.

Games
-----
Dungeon Hack
- printing of level map (there is button "Print" when map is shown)
- nothing, it just corrupted screen a bit, BMP was not generated

Bolo Adventures III
- choosing "Upgrade", "Registration", "Print Form"
- error "Device unavailable in module BOLO3 ..."
- it probably needs PRN or LPT1 device which is not in DOSBOX

Freeware/shareware wordprocessors
---------------------------------
Breeze
- error "Cannot open printer"
- in DOSBOX: "Warning: file creation failed: c:\dosbox\BREEZE\LPT1"

PcWord 1.90 (from TaliSoft)
- here I had a partiall success
- when using "print document" (I think ALT z) BMP file was generated. I just do not know how the program decided which page from the whole document will be prented (I would expect the first or the last one, but the PAGE.BMP contained something from the middle of the document)
- semigraphic symbols are not ok (national characters are printed instead)
- the attempt to use "print project" (ALT w) brutally crashed DOSBOX (SDL parachute ...). Sometimes I had to restart the whole computer (Windows 98 ), because any attempt to run any program ended with error that there is not enough memory.

Mirek
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-15 @ 04:05 pm
Fizzban
Newbie
[avatar]
Joined: 2003-12-15
Posts: 75
Thanks for tests, mirekluza..

Dungeon Hack isn't sending any data to printer, either. Also, in the debug window, I see a lot of "INT10:Unhandled mode 10 for scroll" error messages. Not sure what scrolling has to do with printing but this is probably corrupting the screen. I guess the game is also using LPT1 for printing so this seems to be a top-priority to get the printer working in most programs..

About PcWord: The printer creates page.bmp as soon as a page is full or the program sends a Form Feed. That's why you are getting something in the middle of the document. If you turn "Use form feed to terminate page" on in the printer settings, you will see the last page. I will add a hotkey that allow "ejection" of the currently printed page. There is unfortunally no way to automatically decide if the program is done with printing.

The program doesn't crash here if I try to print a project. Can you please give me some semigraphic symbols that don't work so I can take a closer look? The printer basically just send the ASCII chars to FreeType for rendering, I haven't implemented handling of self-defined characters or different charsets yet.
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-15 @ 05:03 pm
mirekluza
DOSBox Moderator
no avatar
Joined: 2003-08-21
Posts: 1697
> Can you please give me some semigraphic symbols
Go to the PcWord documentation, file "keyboard.doc" and try to print the picture of keyboard which is there. The same goes for various big titles from the documentation.

Mirek
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-15 @ 11:07 pm
Fizzban
Newbie
[avatar]
Joined: 2003-12-15
Posts: 75
A few small updates:


  • Added support for different codepages. This solves the problem with semi-graphic symbols and allows printing of some foreign texts
  • For now, the key ALT-F8 is the "Eject current page" key. This forces DOSBOX to save the internal buffer to a BMP, then clear the page. Helps with programs that does not send a Form Feed after finishing with the print job.
  • Output now goes to page1.bmp, page2.bmp etc.



Last edited by Fizzban on 2004-2-17 @ 01:38 am; edited 2 times in total
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-16 @ 07:03 pm
Fizzban
Newbie
[avatar]
Joined: 2003-12-15
Posts: 75
Another small update:


  • Implemented the LPT1/PRN device and the DOS function "Print character".
  • Started to implement ESC/P2 commands


Breeze and Bolo Adventures III are now working nicely. Dungeon Hack isn't sending any data to the printer through any of the four available ways (BIOS, DOS, direct write to PORT, LPT device), so I guess the problem is the unhandeled scrolling command. Will try to debug that later..

Attached is the compiled version. Source code will follow later. With anon CVS down, I lost track of the changes I made.. Laughing Out Loud


Last edited by Fizzban on 2004-2-17 @ 01:38 am; edited 1 time in total
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-16 @ 07:25 pm
mirekluza
DOSBox Moderator
no avatar
Joined: 2003-08-21
Posts: 1697
You are very quick ... Happy I spent the whole day at work so I only now download the current version ...
Anyway, just a comment before any testing: If it works as you wrote then it starts to be already really usefull. I do not know how it is with possibility of platform independend printing, but even without that it could be usefull to have it in DOSBOX as it is now (making image files). There is just one thing which would have to be taken care off - using some other format instead of BMP (too big). I think that for screenshots "libpng" is used, perhaps you could use it as well.

Mirek
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-16 @ 10:39 pm
Fizzban
Newbie
[avatar]
Joined: 2003-12-15
Posts: 75
mirekluza wrote:
There is just one thing which would have to be taken care off - using some other format instead of BMP (too big). I think that for screenshots "libpng" is used, perhaps you could use it as well.


Good suggestion.. I did a little Copy&Paste and the printer now outputs nice (and small) PNG images..
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-17 @ 01:37 am
Fizzban
Newbie
[avatar]
Joined: 2003-12-15
Posts: 75
Next update:


  • Implemented virtually all ESC/P commands
  • Implemented most ESC/P2 commands
  • Page output is in PNG format now


The features that are now missing to get a complete emulation of a 48-pin EPSON matrix printer are the definition of own characters, raster and TIFF graphics and (maybe) colors..


Last edited by Fizzban on 2004-2-17 @ 02:44 pm; edited 1 time in total
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-17 @ 02:02 am
Stiletto
Oldbie
[avatar]
Joined: 2002-07-01
Posts: 1116
Fizzban wrote:
Yes, there is no way to forward the data to the printer in an OS-indepent way. I'm currently looking for a GPL-library that has support for different OSes.


Great job!

If you want source to look at and not necessarily a library, I recomment the following projects:
UAE - Universal Amiga Emulator
Basilisk II - 68k Macintosh Emulator

I believe both of those have printer output code for Unix, Mac, and Win32 in their code. If you're interested, I'll find you the exact links.

_________________
"I see a little silhouette-o of a man, Scaramouche, Scaramouche, will you
do the Fandango!" - Queen

Stiletto
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-17 @ 03:04 am
Fizzban
Newbie
[avatar]
Joined: 2003-12-15
Posts: 75
Stiletto wrote:
If you want source to look at and not necessarily a library, I recomment the following projects:
UAE - Universal Amiga Emulator
Basilisk II - 68k Macintosh Emulator

I believe both of those have printer output code for Unix, Mac, and Win32 in their code. If you're interested, I'll find you the exact links.


Yes, I am very interested! But I already found the URLs via Google so don't worry looking them up.. Happy

Thanks a lot of the tip! Very Happy
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-17 @ 10:49 am
Stiletto
Oldbie
[avatar]
Joined: 2002-07-01
Posts: 1116
No problem.

Of course, the Mac used a serial port for printing instead of a parallel port, but hopefully you should get some ideas. And this details what advanced features people are looking for in UAE's emulation. FWIW, I think this feature will be difficult to maintain. Good luck!

_________________
"I see a little silhouette-o of a man, Scaramouche, Scaramouche, will you
do the Fandango!" - Queen

Stiletto
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-17 @ 10:57 am
Qbix
DOSBox Author
[avatar]
Joined: 2002-11-27
Posts: 8229
Location: Fryslan
I vote for a library Happy
To make it easier maintanable.

_________________
Water flows down the stream
How to ask questions the smart way
Post new topicReply to topic
Hidden
Reply with quote Re: Virtual printer :: 2004-2-17 @ 02:43 pm
Fizzban
Newbie
[avatar]
Joined: 2003-12-15
Posts: 75
Update: The newest version of the printer is able to send the data directly to an actual printer under Win32 (where this is easy to realize). For the other OSes, it will PNG output unless I find a good printing library.

The default output method is png image creation, direct printing needs to be set up in the dosbox.conf. DOSBOX will then display a print dialog as soon as you start printing.


Last edited by Fizzban on 2004-2-17 @ 11:50 pm; edited 1 time in total
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-17 @ 03:13 pm
Qbix
DOSBox Author
[avatar]
Joined: 2002-11-27
Posts: 8229
Location: Fryslan
hmmm not sure if it's a good idea to allow to host printing at all.
I think sticking to png in all cases is more approate.

_________________
Water flows down the stream
How to ask questions the smart way
Post new topicReply to topic
Hidden
Reply with quote Re: Virtual printer :: 2004-2-17 @ 03:34 pm
Fizzban
Newbie
[avatar]
Joined: 2003-12-15
Posts: 75
Mmh, host printing is surely one of the most tricky features of the virtual printer so just discarding it is a tempting idea.. Laughing Out Loud

On the other hand, the support for Win32 is already there and it should work fine on all windows versions from Win98 on so I do really see the point to remove it. Printing under LINUX and MacOS is much harder, so I will not implement the support for now.

Yeah, I know, this may lead to questions like "Why is there no direct printing under my OS?" but we have the "It's open-source. If you want it, just implement it" answer for that.. Very Happy
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-17 @ 03:43 pm
Qbix
DOSBox Author
[avatar]
Joined: 2002-11-27
Posts: 8229
Location: Fryslan
Q: Why isn't Virtual Printer support included in the CVS.

A: Adding printing directly to the printer will give a lot headaches.
(especially if the result isn't what they expect).
DosBox goal is to be an emulator with as little contact with the host hardware as possible so as to maintain compatibility across all platforms.

_________________
Water flows down the stream
How to ask questions the smart way
Post new topicReply to topic
Hidden
Reply with quote Re: Virtual printer :: 2004-2-17 @ 03:59 pm
Fizzban
Newbie
[avatar]
Joined: 2003-12-15
Posts: 75
IMHO, the direct printing option isn't really hurting the emulation concept of DOSBOX.

Probably my description was misleading here: Even with direct printing on, the virtual printer does not directly forward the printer commands he gets to the actual printer. It still creates the page as image and after this is done, it just sends the bitmap to the printer.

Basically, this just adds a little comfort, so people don't have to take the PNGs, resize them and print them (nothing more is done by the direct printing option).

Trying to convert ESC/P(2) commands to commands the target printer understands would be madness. I never intended any kind of virtualization.
Post new topicReply to topic
Offline
Reply with quote Re: Virtual printer :: 2004-2-17 @ 06:34 pm
mirekluza
DOSBox Moderator
no avatar
Joined: 2003-08-21
Posts: 1697
IMHO the direct Windows printing is good (although I do not need it personally - I do not have printer). Occasionaly somebody complains here about not being able to do it.
It is possible to add big warning to config file/documentation that the output does need to be precisely as with the DOS printer.
Well, but I understand that people who use non-Windows system (as QBIX with Linux Happy ) will complain. But it is probable that sooner or later somebody adds support for Linux as well.

Anyway, when it will be integrated into normal CVS? I usually compile CVS snapshot and I am too lazy to add patches to it Happy Happy Happy.
There is already one other addition which kept separately from regular CVS (MT-32 - legal problems with Roland).

Mirek
Post new topicReply to topic
Offline
page 1 of 8
Goto page 1, 2, 3, 4, 5, 6, 7, 8  Next
All times are GMT
Moderate
Quick Reply & Options
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Powered by phpBB © 2001-2003 phpBB Group.
vogons and vogons site design and content herein is under a creative commons license 2002-2003 zetafleet.dom.
This site hosts no abandonware. There is no material that is knowingly illegal here.
zetafleet.dom will not be held responsible for users' posts.
This disclaimer is brought to you thanks to the BSA.