mirror of
https://github.com/david-schmidt/gsport.git
synced 2025-01-02 06:30:49 +00:00
Merge Imagewriter branch into trunk.
This commit is contained in:
parent
21a61c06a7
commit
9fe038c8d0
@ -14,6 +14,8 @@ GSport Release History
|
||||
|
||||
* Emulated serial ports are individually configurable as either
|
||||
IP or passthrough to real hardware ports
|
||||
|
||||
* Added Imagewriter LQ printer emulation
|
||||
|
||||
[]
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
OBJECTS1 = adb.o clock.o config.o dis.o engine_c.o scc.o iwm.o \
|
||||
joystick_driver.o moremem.o paddles.o parallel.o printer.o \
|
||||
sim65816.o smartport.o sound.o sound_driver.o video.o \
|
||||
scc_socket_driver.o
|
||||
scc_socket_driver.o scc_imagewriter.o imagewriter.o
|
||||
|
||||
include vars
|
||||
|
||||
@ -148,7 +148,9 @@ scc.o: scc.c defc.h defcomm.h iwm.h protos.h scc.h
|
||||
scc_socket_driver.o: scc_socket_driver.c defc.h defcomm.h iwm.h protos.h scc.h
|
||||
scc_windriver.o: scc_windriver.c defc.h defcomm.h iwm.h protos.h scc.h
|
||||
scc_macdriver.o: scc_macdriver.c defc.h defcomm.h iwm.h protos.h scc.h
|
||||
scc_imagewriter.o: scc_imagewriter.c defc.h defcomm.h protos.h scc.h
|
||||
iwm.o: iwm.c defc.h defcomm.h iwm.h protos.h iwm_35_525.h
|
||||
imagewriter.o: imagewriter.cpp
|
||||
joystick_driver.o: joystick_driver.c defc.h defcomm.h iwm.h protos.h
|
||||
moremem.o: moremem.c defc.h defcomm.h iwm.h protos.h
|
||||
paddles.o: paddles.c defc.h defcomm.h iwm.h protos.h
|
||||
|
6648
src/config.c
6648
src/config.c
File diff suppressed because it is too large
Load Diff
@ -124,6 +124,8 @@ perl make_inst s 16 instable.h > 16inst_s.h</Command>
|
||||
<ClInclude Include="op_routs.h" />
|
||||
<ClInclude Include="printer.h" />
|
||||
<ClInclude Include="printer_charmaps.h" />
|
||||
<ClInclude Include="imagewriter.h" />
|
||||
<ClInclude Include="iw_charmaps.h" />
|
||||
<ClInclude Include="prodos.h" />
|
||||
<ClInclude Include="prodos_protos.h" />
|
||||
<ClInclude Include="protos.h" />
|
||||
@ -170,6 +172,8 @@ perl make_size c size_tab.h > size_c.h</Command>
|
||||
<ClCompile Include="paddles.c" />
|
||||
<ClCompile Include="parallel.c" />
|
||||
<ClCompile Include="printer.cpp" />
|
||||
<ClCompile Include="scc_imagewriter.c" />
|
||||
<ClCompile Include="imagewriter.cpp" />
|
||||
<ClCompile Include="scc.c" />
|
||||
<ClCompile Include="scc_socket_driver.c" />
|
||||
<ClCompile Include="scc_windriver.c" />
|
||||
|
@ -60,6 +60,12 @@
|
||||
<ClInclude Include="printer_charmaps.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="imagewriter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="iw_charmaps.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="prodos.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@ -182,6 +188,12 @@
|
||||
<ClCompile Include="printer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="scc_imagewriter.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="imagewriter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="size_tab.h">
|
||||
|
2173
src/imagewriter.cpp
Normal file
2173
src/imagewriter.cpp
Normal file
File diff suppressed because it is too large
Load Diff
312
src/imagewriter.h
Normal file
312
src/imagewriter.h
Normal file
@ -0,0 +1,312 @@
|
||||
/*
|
||||
GSport - an Apple //gs Emulator
|
||||
Copyright (C) 2010 - 2011 by GSport contributors
|
||||
|
||||
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2002-2004 The DOSBox Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
Modified for the GSport emulator by Christopher G. Mason 02/2014
|
||||
Extensively rewritten to provide full emulation of the Apple ImageWriter II
|
||||
printer.
|
||||
|
||||
Information used to write this emulator was provided by
|
||||
Apple's "ImageWriter II Technical Reference Manual"
|
||||
ISBN# 0-201-17766-8
|
||||
|
||||
Apple's "ImageWriter LQ Reference Manual"
|
||||
ISBN# 0-201-17751-X
|
||||
*/
|
||||
|
||||
#if !defined __IMAGEWRITER_H
|
||||
#define __IMAGEWRITER_H
|
||||
#ifdef __cplusplus
|
||||
#ifdef C_LIBPNG
|
||||
#include <png.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_SDL
|
||||
#include "SDL.h"
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#endif // HAVE_SDL
|
||||
|
||||
#if defined (WIN32)
|
||||
#include <windows.h>
|
||||
#include <winspool.h>
|
||||
#endif
|
||||
|
||||
#define STYLE_PROP 0x01
|
||||
#define STYLE_CONDENSED 0x02
|
||||
#define STYLE_BOLD 0x04
|
||||
#define STYLE_DOUBLESTRIKE 0x08
|
||||
#define STYLE_DOUBLEWIDTH 0x10
|
||||
#define STYLE_ITALICS 0x20
|
||||
#define STYLE_UNDERLINE 0x40
|
||||
#define STYLE_SUPERSCRIPT 0x80
|
||||
#define STYLE_SUBSCRIPT 0x100
|
||||
#define STYLE_HALFHEIGHT 0x200
|
||||
|
||||
#define SCORE_NONE 0x00
|
||||
#define SCORE_SINGLE 0x01
|
||||
#define SCORE_DOUBLE 0x02
|
||||
#define SCORE_SINGLEBROKEN 0x05
|
||||
#define SCORE_DOUBLEBROKEN 0x06
|
||||
|
||||
#define QUALITY_DRAFT 0x01
|
||||
#define QUALITY_LQ 0x02
|
||||
|
||||
#define COLOR_BLACK 7<<5
|
||||
typedef unsigned Bitu;
|
||||
typedef signed Bits;
|
||||
typedef unsigned char Bit8u;
|
||||
typedef signed char Bit8s;
|
||||
typedef unsigned short Bit16u;
|
||||
typedef signed short Bit16s;
|
||||
typedef unsigned long Bit32u;
|
||||
typedef signed long Bit32s;
|
||||
typedef double Real64;
|
||||
#if defined(_MSC_VER)
|
||||
typedef unsigned __int64 Bit64u;
|
||||
typedef signed __int64 Bit64s;
|
||||
#else
|
||||
typedef unsigned long long int Bit64u;
|
||||
typedef signed long long int Bit64s;
|
||||
#endif
|
||||
enum Typeface
|
||||
{
|
||||
fixed = 0,
|
||||
prop = 1
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
Bitu codepage;
|
||||
const Bit16u* map;
|
||||
} IWCHARMAP;
|
||||
|
||||
|
||||
class Imagewriter {
|
||||
public:
|
||||
|
||||
Imagewriter (Bit16u dpi, Bit16u width, Bit16u height, char* output, bool multipageOutput, int port);
|
||||
virtual ~Imagewriter();
|
||||
|
||||
// Process one character sent to virtual printer
|
||||
void printChar(Bit8u ch);
|
||||
|
||||
// Hard Reset (like switching printer off and on)
|
||||
void resetPrinterHard();
|
||||
|
||||
// Set Autofeed value
|
||||
void setAutofeed(bool feed);
|
||||
|
||||
// Get Autofeed value
|
||||
bool getAutofeed();
|
||||
|
||||
// True if printer is unable to process more data right now (do not use printChar)
|
||||
bool isBusy();
|
||||
|
||||
// True if the last sent character was received
|
||||
bool ack();
|
||||
|
||||
// Manual formfeed
|
||||
void formFeed();
|
||||
|
||||
#ifdef HAVE_SDL
|
||||
// Returns true if the current page is blank
|
||||
bool isBlank();
|
||||
#endif // HAVE_SDL
|
||||
|
||||
private:
|
||||
|
||||
// Resets the printer to the factory settings
|
||||
void resetPrinter();
|
||||
|
||||
// Clears page. If save is true, saves the current page to a bitmap
|
||||
void newPage(bool save, bool resetx);
|
||||
|
||||
// Closes a multipage document
|
||||
void finishMultipage();
|
||||
|
||||
// Output current page
|
||||
void outputPage();
|
||||
|
||||
#ifdef HAVE_SDL
|
||||
// used to fill the color "sub-pallettes"
|
||||
void FillPalette(Bit8u redmax, Bit8u greenmax, Bit8u bluemax, Bit8u colorID,
|
||||
SDL_Palette* pal);
|
||||
|
||||
// Checks if given char belongs to a command and process it. If false, the character
|
||||
// should be printed
|
||||
bool processCommandChar(Bit8u ch);
|
||||
|
||||
// Reload font. Must be called after changing dpi, style or cpi
|
||||
void updateFont();
|
||||
|
||||
// Reconfigures printer parameters after changing soft-switches with ESC Z and ESC D
|
||||
void updateSwitch();
|
||||
|
||||
// Overprints a slash over zero if softswitch B-1 is set
|
||||
void slashzero(Bit16u penX, Bit16u penY);
|
||||
|
||||
// Blits the given glyph on the page surface. If add is true, the values of bitmap are
|
||||
// added to the values of the pixels in the page
|
||||
void blitGlyph(FT_Bitmap bitmap, Bit16u destx, Bit16u desty, bool add);
|
||||
|
||||
// Draws an anti-aliased line from (fromx, y) to (tox, y). If broken is true, gaps are included
|
||||
void drawLine(Bitu fromx, Bitu tox, Bitu y, bool broken);
|
||||
|
||||
// Setup the bitGraph structure
|
||||
void setupBitImage(Bit8u dens, Bit16u numCols);
|
||||
|
||||
// Process a character that is part of bit image. Must be called iff bitGraph.remBytes > 0.
|
||||
void printBitGraph(Bit8u ch);
|
||||
|
||||
// Copies the codepage mapping from the constant array to CurMap
|
||||
void selectCodepage(Bit16u cp);
|
||||
|
||||
// Prints out a byte using ASCII85 encoding (only outputs something every four bytes). When b>255, closes the ASCII85 string
|
||||
void fprintASCII85(FILE* f, Bit16u b);
|
||||
|
||||
// Returns value of the num-th pixel (couting left-right, top-down) in a safe way
|
||||
Bit8u getPixel(Bit32u num);
|
||||
Bit8u getxyPixel(Bit32u x,Bit32u y);
|
||||
|
||||
FT_Library FTlib; // FreeType2 library used to render the characters
|
||||
|
||||
SDL_Surface* page; // Surface representing the current page
|
||||
FT_Face curFont; // The font currently used to render characters
|
||||
Bit8u color;
|
||||
Bit8u switcha; //Imagewriter softswitch A
|
||||
Bit8u switchb; //Imagewriter softswitch B
|
||||
|
||||
Real64 curX, curY; // Position of the print head (in inch)
|
||||
|
||||
Bit16u dpi; // dpi of the page
|
||||
Bit16u ESCCmd; // ESC-command that is currently processed
|
||||
bool ESCSeen; // True if last read character was an ESC (0x1B)
|
||||
bool FSSeen; // True if last read character was an FS (0x1C) (IBM commands)
|
||||
Bit8u numParam, neededParam; // Numbers of parameters already read/needed to process command
|
||||
|
||||
Bit8u params[20]; // Buffer for the read params
|
||||
Bit16u style; // Style of font (see STYLE_* constants)
|
||||
Real64 cpi, actcpi; // CPI value set by program and the actual one (taking in account font types)
|
||||
Bit8u score; // Score for lines (see SCORE_* constants)
|
||||
Bit8u verticalDot; // Vertical dot shift for Imagewriter LQ modes
|
||||
|
||||
Real64 topMargin, bottomMargin, rightMargin, leftMargin; // Margins of the page (in inch)
|
||||
Real64 pageWidth, pageHeight; // Size of page (in inch)
|
||||
Real64 defaultPageWidth, defaultPageHeight; // Default size of page (in inch)
|
||||
Real64 lineSpacing; // Size of one line (in inch)
|
||||
|
||||
Real64 horiztabs[32]; // Stores the set horizontal tabs (in inch)
|
||||
Bit8u numHorizTabs; // Number of configured tabs
|
||||
|
||||
Real64 verttabs[16]; // Stores the set vertical tabs (in inch)
|
||||
Bit8u numVertTabs; // Number of configured tabs
|
||||
|
||||
Bit8u curCharTable; // Currently used char table und charset
|
||||
Bit8u printQuality; // Print quality (see QUALITY_* constants)
|
||||
Bit8u printRes; // Graphics resolution
|
||||
Typeface LQtypeFace; // Typeface used in LQ printing mode
|
||||
|
||||
Real64 extraIntraSpace; // Extra space between two characters (set by program, in inch)
|
||||
|
||||
bool charRead; // True if a character was read since the printer was last initialized
|
||||
bool autoFeed; // True if a LF should automatically added after a CR
|
||||
bool printUpperContr; // True if the upper command characters should be printed
|
||||
|
||||
struct bitGraphicParams // Holds information about printing bit images
|
||||
{
|
||||
Bit16u horizDens, vertDens; // Density of image to print (in dpi)
|
||||
bool adjacent; // Print adjacent pixels? (ignored)
|
||||
Bit8u bytesColumn; // Bytes per column
|
||||
Bit16u remBytes; // Bytes left to read before image is done
|
||||
Bit8u column[6]; // Bytes of the current and last column
|
||||
Bit8u readBytesColumn; // Bytes read so far for the current column
|
||||
} bitGraph;
|
||||
|
||||
Bit8u densk, densl, densy, densz; // Image density modes used in ESC K/L/Y/Z commands
|
||||
|
||||
Bit16u curMap[256]; // Currently used ASCII => Unicode mapping
|
||||
Bit16u charTables[4]; // Charactertables
|
||||
|
||||
Real64 definedUnit; // Unit used by some ESC/P2 commands (negative => use default)
|
||||
|
||||
bool multipoint; // If multipoint mode is enabled
|
||||
Real64 multiPointSize; // Point size of font in multipoint mode
|
||||
Real64 multicpi; // CPI used in multipoint mode
|
||||
|
||||
Real64 hmi; // Horizontal motion index (in inch; overrides CPI settings)
|
||||
|
||||
Bit16u numPrintAsChar; // Number of bytes to print as characters (even when normally control codes)
|
||||
|
||||
#if defined (WIN32)
|
||||
HDC printerDC; // Win32 printer device
|
||||
#endif
|
||||
int port; // SCC Port
|
||||
|
||||
#endif // HAVE_SDL
|
||||
Bit8u msb; // MSB mode
|
||||
|
||||
char* output; // Output method selected by user
|
||||
void* outputHandle; // If not null, additional pages will be appended to the given handle
|
||||
bool multipageOutput; // If true, all pages are combined to one file/print job etc. until the "eject page" button is pressed
|
||||
Bit16u multiPageCounter; // Current page (when printing multipages)
|
||||
|
||||
Bit8u ASCII85Buffer[4]; // Buffer used in ASCII85 encoding
|
||||
Bit8u ASCII85BufferPos; // Position in ASCII85 encode buffer
|
||||
Bit8u ASCII85CurCol; // Columns printed so far in the current lines
|
||||
};
|
||||
|
||||
|
||||
//Interfaces to C code
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
void imagewriter_init(int pdpi, int pwidth, int pheight, char* poutput, bool mpage, int port);
|
||||
void imagewriter_loop(Bit8u pchar,int port);
|
||||
void imagewriter_close(int port);
|
||||
void imagewriter_feed(int port);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
60
src/iw_charmaps.h
Normal file
60
src/iw_charmaps.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
GSport - an Apple //gs Emulator
|
||||
Copyright (C) 2010 by GSport contributors
|
||||
|
||||
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
// Various ASCII codepage to unicode maps
|
||||
|
||||
static const Bit16u 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,
|
||||
0x00c7,0x00fc,0x00e9,0x00e2,0x00e4,0x00e0,0x00e5,0x00e7,0x00ea,0x00eb,0x00e8,0x00ef,0x00ee,0x00ec,0x00c4,0x00c5,
|
||||
0x00c9,0x00e6,0x00c6,0x00f4,0x00f6,0x00f2,0x00fb,0x00f9,0x00ff,0x00d6,0x00dc,0x00a2,0x00a3,0x00a5,0x20a7,0x0192,
|
||||
0x00e1,0x00ed,0x00f3,0x00fa,0x00f1,0x00d1,0x00aa,0x00ba,0x00bf,0x2310,0x00ac,0x00bd,0x00bc,0x00a1,0x00ab,0x00bb,
|
||||
0x2591,0x2592,0x2593,0x2502,0x2524,0x2561,0x2562,0x2556,0x2555,0x2563,0x2551,0x2557,0x255d,0x255c,0x255b,0x2510,
|
||||
0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x255e,0x255f,0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x2567,
|
||||
0x2568,0x2564,0x2565,0x2559,0x2558,0x2552,0x2553,0x256b,0x256a,0x2518,0x250c,0x2588,0x2584,0x258c,0x2590,0x2580,
|
||||
0x03b1,0x00df,0x0393,0x03c0,0x03a3,0x03c3,0x00b5,0x03c4,0x03a6,0x0398,0x03a9,0x03b4,0x221e,0x03c6,0x03b5,0x2229,
|
||||
0x2261,0x00b1,0x2265,0x2264,0x2320,0x2321,0x00f7,0x2248,0x00b0,0x2219,0x00b7,0x221a,0x207f,0x00b2,0x25a0,0x00a0
|
||||
};
|
||||
|
||||
IWCHARMAP iwcharmap[] = {
|
||||
{437, cp437Map},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
static const Bit16u codepages[15] = {0, 437};
|
||||
|
||||
static const Bit16u intCharSets[8][10] =
|
||||
{
|
||||
{0x0023, 0x0040, 0x005b, 0x005c, 0x005d, 0x0060, 0x007b, 0x007c, 0x007d, 0x007e}, // USA
|
||||
{0x00a3, 0x00a7, 0x00b0, 0x00e7, 0x00e9, 0x00f9, 0x00e0, 0x00f2, 0x00e8, 0x00ec}, // Italian
|
||||
{0x0023, 0x0040, 0x00c6, 0x00d8, 0x00c5, 0x0060, 0x00e6, 0x00f8, 0x00e5, 0x007e}, // Danish
|
||||
{0x00a3, 0x0040, 0x005b, 0x005c, 0x005d, 0x0060, 0x007b, 0x007c, 0x007d, 0x007e}, // UK
|
||||
{0x0023, 0x00a7, 0x00c4, 0x00d6, 0x00dc, 0x0060, 0x00e4, 0x00f6, 0x00fc, 0x00df}, // Germany
|
||||
{0x0023, 0x0040, 0x00c4, 0x00d6, 0x00c5, 0x0060, 0x00e4, 0x00f6, 0x00e5, 0x007e}, // Swedish
|
||||
{0x00a3, 0x00e0, 0x00b0, 0x00e7, 0x00a7, 0x0060, 0x00e9, 0x00f9, 0x00e8, 0x00a8}, // France
|
||||
{0x00a3, 0x00a7, 0x00a1, 0x00d1, 0x00bf, 0x0060, 0x00b0, 0x00f1, 0x00e7, 0x007e}, // Spanish
|
||||
};
|
@ -288,6 +288,11 @@ void scc_socket_modem_connect(int port, double dcycs);
|
||||
void scc_socket_modem_do_ring(int port, double dcycs);
|
||||
void scc_socket_do_answer(int port, double dcycs);
|
||||
|
||||
/* scc_imagewriter.c*/
|
||||
int scc_imagewriter_init(int port);
|
||||
void scc_imagewriter_fill_readbuf(int port, int space_left, double dcycs);
|
||||
void scc_imagewriter_empty_writebuf(int port, double dcycs);
|
||||
void imagewriter_update();
|
||||
|
||||
/* scc_windriver.c */
|
||||
|
||||
|
156
src/scc_imagewriter.c
Normal file
156
src/scc_imagewriter.c
Normal file
@ -0,0 +1,156 @@
|
||||
/*
|
||||
GSport - an Apple //gs Emulator
|
||||
Copyright (C) 2013 - 2014 by GSport contributors
|
||||
Originally authored by Christopher Mason
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* This is an interface between the SCC emulation and the Virtual Imagewriter. */
|
||||
|
||||
#include "defc.h"
|
||||
#include "scc.h"
|
||||
extern Scc scc_stat[2];
|
||||
extern int g_vbl_count;
|
||||
|
||||
extern int g_imagewriter;
|
||||
extern int g_imagewriter_dpi;
|
||||
extern char* g_imagewriter_output;
|
||||
extern int g_imagewriter_multipage;
|
||||
extern int g_imagewriter_timeout;
|
||||
|
||||
int imagewriter_vbl_count = 0;
|
||||
int imagewriter_port_block = 0;
|
||||
int iw_scc_write = 0;
|
||||
|
||||
int scc_imagewriter_init(int port)
|
||||
{
|
||||
Scc *scc_ptr;
|
||||
scc_ptr = &(scc_stat[port]);
|
||||
imagewriter_init(g_imagewriter_dpi,85,110,g_imagewriter_output,g_imagewriter_multipage, port);
|
||||
scc_ptr->state = 4;
|
||||
return 4;
|
||||
}
|
||||
|
||||
/** Transfer data from Imagewriter to the SCC **/
|
||||
void scc_imagewriter_fill_readbuf(int port, int space_left, double dcycs)
|
||||
{
|
||||
if (iw_scc_write)
|
||||
{
|
||||
size_t bytes_read;
|
||||
size_t i;
|
||||
byte data[9];
|
||||
if (g_imagewriter == 1)
|
||||
{
|
||||
//Imagewriter LQ self ID string. Tell machine we have a color ribbon and sheet feeder installed.
|
||||
data[0] = 0; //Start bit
|
||||
data[1] ='L'; //Printer type is Imagewriter LQ
|
||||
data[2] ='Q'; //(cont)
|
||||
data[3] ='1'; //15 inch carriage width
|
||||
data[4] ='C'; //Color ribbon installed
|
||||
data[5] ='F'; //Sheet feeder installed, no envelope attachment
|
||||
data[6] ='1'; //Number of sheet feeder bins
|
||||
data[7] = 0x0D; //CR terminates string
|
||||
data[8] = 0; //Stop bit
|
||||
bytes_read = 9;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Imagewriter II self ID string. Tell machine we have a color ribbon and sheet feeder installed.
|
||||
data[0] = 0; //Start bit
|
||||
data[1] ='I'; //Printer type is Imagewriter II
|
||||
data[2] ='W'; //(cont)
|
||||
data[3] ='1'; //10 inch carriage width
|
||||
data[4] ='0'; //(cont)
|
||||
data[5] ='C'; //Color ribbon installed
|
||||
data[6] ='F'; //Sheet feeder installed
|
||||
data[7] = 0; //Stop bit
|
||||
bytes_read = 8;
|
||||
}
|
||||
for(i = 0; i < bytes_read; i++) {
|
||||
scc_add_to_readbuf(port, data[i], dcycs);
|
||||
}
|
||||
iw_scc_write = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Transfer data from the SCC to the Imagewriter. **/
|
||||
void scc_imagewriter_empty_writebuf(int port, double dcycs)
|
||||
{
|
||||
Scc* scc_ptr;
|
||||
|
||||
int rdptr;
|
||||
int wrptr;
|
||||
int len;
|
||||
int done;
|
||||
//int ret;
|
||||
DWORD bytes_written;
|
||||
|
||||
scc_ptr = &(scc_stat[port]);
|
||||
done = 0;
|
||||
while(!done) {
|
||||
rdptr = scc_ptr->out_rdptr;
|
||||
wrptr = scc_ptr->out_wrptr;
|
||||
if(rdptr == wrptr) {
|
||||
//printf("...rdptr == wrptr\n");
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
len = wrptr - rdptr;
|
||||
if(len < 0) {
|
||||
len = SCC_OUTBUF_SIZE - rdptr;
|
||||
}
|
||||
if(len > 32) {
|
||||
len = 32;
|
||||
}
|
||||
if(len <= 0) {
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
bytes_written = 1;
|
||||
imagewriter_port_block = 1;
|
||||
imagewriter_loop(scc_ptr->out_buf[rdptr],port);
|
||||
imagewriter_vbl_count = g_vbl_count+(g_imagewriter_timeout*60);
|
||||
imagewriter_port_block = 0;
|
||||
//printf("Write Imagewriter ret: %d, bytes_written:%d, len:%d\n", ret,
|
||||
//(int)bytes_written, len);
|
||||
|
||||
if((bytes_written == 0)) {
|
||||
done = 1;
|
||||
break;
|
||||
} else {
|
||||
rdptr = rdptr + bytes_written;
|
||||
if(rdptr >= SCC_OUTBUF_SIZE) {
|
||||
rdptr = rdptr - SCC_OUTBUF_SIZE;
|
||||
}
|
||||
scc_ptr->out_rdptr = rdptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//This function handles the automatic timeout of the virtual printer if an
|
||||
//application doesn't send a form feed at the end of the page. It also
|
||||
//allows multipage mode Postscript and native printer documents to
|
||||
//print somewhat how a regular application would.
|
||||
void imagewriter_update()
|
||||
{
|
||||
if (imagewriter_port_block != 1 && imagewriter_vbl_count != 0 && g_vbl_count >= imagewriter_vbl_count)
|
||||
{
|
||||
printf("Calling imagewriter_update and flushing!\n");
|
||||
imagewriter_feed();
|
||||
imagewriter_vbl_count = 0;
|
||||
}
|
||||
return;
|
||||
}
|
5091
src/sim65816.c
5091
src/sim65816.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user