Skip to content

Commit

Permalink
Host printer support (#175)
Browse files Browse the repository at this point in the history
* Initial implementation of printing.

* Working Printer code for 3 dpi settings

* Added Printer Driver files.

* Fixed formatting

* Disable printer code on unsupported platforms.

* Format

* Fixes for other platforms

* Syntax

* Release notes

* Name conflict

* Include files

* Format

* Fixing warning
  • Loading branch information
MatthiasWM authored May 29, 2022
1 parent be03279 commit f481e34
Show file tree
Hide file tree
Showing 25 changed files with 1,104 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

cmake_minimum_required(VERSION 3.13)

project( "Einstein" VERSION "2022.4.18" )
project( "Einstein" VERSION "2022.4.19" )

# ---- Configuration for all targets on all platforms

Expand Down
1 change: 1 addition & 0 deletions Drivers/Einstein.rex.src
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ package "obj/EinsteinSerialVoyager.pkg"
package "obj/EinsteinInTranslator.pkg"
package "obj/EinsteinOutTranslator.pkg"
package "obj/EinsteinNativeCalls.pkg"
package "PrinterDriver/printerDriver.pkg"
// Handlers & NS runtime.
package "NSRuntime/Einstein NS Runtime.pkg"
// NewtTest 1.1i
Expand Down
1 change: 1 addition & 0 deletions Drivers/PrinterDriver/EinsteinDriver.cp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* File: EinsteinDriver.cp Contains: Newton printer driver for the Einstein emulator. This is an implementation of the TDotPrinterDriver protocol. Copyright: (c)2022, Matthias Melcher, based on the Kodak sample printer driver included in the DDK © 1992-1994 by Apple Computer, Inc., all rights reserved.*/#ifndef __EINSTEINDRIVER_H #include "EinsteinDriver.impl.h" // **Master File Name** (.impl.h)#endif#ifndef __string_h #include "string.h"#endif#ifndef __stdio_h #include "stdio.h"#endif#ifndef __COMMMANAGERINTERFACE_H #include "CommManagerInterface.h"#endif#ifndef __COMMSERVICES_H #include "CommServices.h"#endif#ifndef __ENDPOINT_H #include "Endpoint.h"#endif#ifndef __SERIALOPTIONS_H #include "SerialOptions.h"#endif/* NATIVE_PRIM 0x0C01, PDNew NATIVE_PRIM 0x0C02, PDDelete NATIVE_PRIM 0x0C03, PDOpen NATIVE_PRIM 0x0C04, PDClose NATIVE_PRIM 0x0C05, PDOpenPage NATIVE_PRIM 0x0C06, PDClosePage NATIVE_PRIM 0x0C07, PDImageBand NATIVE_PRIM 0x0C08, PDCancelJob NATIVE_PRIM 0x0C09, PDIsProblemResolved NATIVE_PRIM 0x0C0A, PDGetPageInfo NATIVE_PRIM 0x0C0B, PDGetBandPrefs NATIVE_PRIM 0x0C0C, PDFaxEndPage*/extern "C" { void PDNew(DRIVERCLASSNAME *self); void PDDelete(DRIVERCLASSNAME *self); NewtonErr PDOpen(DRIVERCLASSNAME *self); NewtonErr PDClose(DRIVERCLASSNAME *self); NewtonErr PDOpenPage(DRIVERCLASSNAME *self); NewtonErr PDClosePage(DRIVERCLASSNAME *self); NewtonErr PDImageBand(DRIVERCLASSNAME *self, PixelMap* theBand, const Rect* minRect); void PDCancelJob(DRIVERCLASSNAME *self, Boolean asyncCancel); PrProblemResolution PDIsProblemResolved(DRIVERCLASSNAME *self); void PDGetPageInfo(DRIVERCLASSNAME *self, PrPageInfo* info); void PDGetBandPrefs(DRIVERCLASSNAME *self, DotPrinterPrefs* prefs); NewtonErr PDFaxEndPage(DRIVERCLASSNAME *self, long pageCount);}PROTOCOL_IMPL_SOURCE_MACRO(DRIVERCLASSNAME)/*----- Globals -----*/// IMPORTANT: LOADED PROTOCOLS MAY NOT HAVE GLOBALS// If you have driver-global data, it belongs in your object./*----- Driver Functions -----*//*----------------------------------------------------------------------------- NewtonErr Open(void) Initialize and Open the driver. Remember, if this call fails, no other calls will follow. So you must clean up anything you do here (especially allocations). -----------------------------------------------------------------------------*/NewtonErr DRIVERCLASSNAME::Open(void){ fAsyncIntf = nil; fCurrentError = noErr; // PRINT(("DRIVERCLASSNAME::Open")); { // check user-specified psuedo-driver RefVar routingSlip = fConnect->fConnectInfo; RefVar prRef = GetFrameSlot(routingSlip, SYM(printer)); RefVar modelRef = GetFrameSlot(prRef, SYM(prmodel)); fHWType = (EinsteinVersion) RINT(modelRef); } return PDOpen(this);}/*----------------------------------------------------------------------------- void Delete(void) Historical entry point. Probably shouldn't be used. -----------------------------------------------------------------------------*/void DRIVERCLASSNAME::Delete(void){ PDDelete(this);}/*----------------------------------------------------------------------------- NewtonErr Close(void) Close the driver. This call should follow this format: send final commands close connection cleanup allocations -----------------------------------------------------------------------------*/NewtonErr DRIVERCLASSNAME::Close(){ return PDClose(this);}/*----------------------------------------------------------------------------- NewtonErr OpenPage(void) Send any commands required to begin a new page. -----------------------------------------------------------------------------*/NewtonErr DRIVERCLASSNAME::OpenPage(){ return PDOpenPage(this);}/*----------------------------------------------------------------------------- NewtonErr ClosePage(void) Send any commands required to finish a page. -----------------------------------------------------------------------------*/NewtonErr DRIVERCLASSNAME::ClosePage(){ return PDClosePage(this);}/*----------------------------------------------------------------------------- NewtonErr ImageBand(PixelMap* theBand, const Rect* minBounds) -----------------------------------------------------------------------------*/NewtonErr DRIVERCLASSNAME::ImageBand(PixelMap* theBand, const Rect* minBounds){ return PDImageBand(this, theBand, minBounds);}/*----------------------------------------------------------------------------- void CancelJob(Boolean asyncCancel) Called by the print loop if we are going to early-abort a print job. The print loop will still call the appropriate close() calls. This just warns the driver that something fishy is going on. -----------------------------------------------------------------------------*/void DRIVERCLASSNAME::CancelJob(Boolean asyncCancel){ PDCancelJob(this, asyncCancel); return; }/*----------------------------------------------------------------------------- PrProblemResolution IsProblemResolved(void); Report on the possible resolution of the current problem or error. -----------------------------------------------------------------------------*/PrProblemResolution DRIVERCLASSNAME::IsProblemResolved(void){ return PDIsProblemResolved(this);}/*----------------------------------------------------------------------------- void GetPageInfo(PrPageInfo* result) -----------------------------------------------------------------------------*/void DRIVERCLASSNAME::GetPageInfo(PrPageInfo* result){ PrPageInfo dummy; dummy.printerDPI.x = Long2Fixed(300); dummy.printerDPI.y = Long2Fixed(300); dummy.printerPageSize.v = (Short) 10.375*300; dummy.printerPageSize.h = (Short) (2400); *result = dummy; PDGetPageInfo(this, result); return;}/*----------------------------------------------------------------------------- void GetBandPrefs(DotPrinterPrefs* result) -----------------------------------------------------------------------------*/void DRIVERCLASSNAME::GetBandPrefs(DotPrinterPrefs* result){ DotPrinterPrefs dummy; dummy.minBand = 50; // 50 because of 50 pin head dummy.optimumBand = 50; dummy.asyncBanding = false; dummy.wantMinBounds = true; *result = dummy; PDGetBandPrefs(this, result); return;}/*----------------------------------------------------------------------------- NewtonErr FaxEndPage(long pageCount) This method is used only by the fax driver. For all others, leave empty. -----------------------------------------------------------------------------*/NewtonErr DRIVERCLASSNAME::FaxEndPage(long pageCount){ return PDFaxEndPage(this, pageCount);}
Expand Down
1 change: 1 addition & 0 deletions Drivers/PrinterDriver/EinsteinDriver.impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* File: EinsteinDriver.impl.h Contains: Protocol Implementation header for sample driver Copyright: © 1992-1994 by Apple Computer, Inc., all rights reserved.*/#ifndef __EINSTEINDRIVER_H#define __EINSTEINDRIVER_H#ifndef __DOTDRIVERS_H #include "DotDrivers.h"#endif#define DRIVERCLASSNAME TEinsteinDriver // **Driver Protocol Name**class TEndpoint;typedef enum { k180si = 0, k701} EinsteinVersion;PROTOCOL DRIVERCLASSNAME : public TDotPrinterDriver PROTOCOLVERSION(1.0){ // Everything in the "public" section is specified by the // protocol definition in "DotDrivers.h". Don't change it. public: PROTOCOL_IMPL_HEADER_MACRO(DRIVERCLASSNAME); void Delete(void); NewtonErr Open(void); NewtonErr Close(void); NewtonErr OpenPage(void); NewtonErr ClosePage(void); NewtonErr ImageBand(PixelMap* theBand, const Rect* minRect); void CancelJob(Boolean asyncCancel); PrProblemResolution IsProblemResolved(void); void GetPageInfo(PrPageInfo* info); void GetBandPrefs(DotPrinterPrefs* prefs); NewtonErr FaxEndPage(long pageCount); // New method for 2.0 // These two fields are automatically created by the // protocol interface (see DotDrivers.h). You will be // able to access them from your code. // PrintConnect* fConnect; // TPrinter* fPrinter;private: // Driver-specific items go here, as private items. void Cleanup(); Boolean InitConnection(); void SendData(Ptr data, long length); void SendString(char* str); void ReleaseConnection(); TEndpoint* fAsyncIntf; EinsteinVersion fHWType; NewtonErr fCurrentError;};#endif
Expand Down
1 change: 1 addition & 0 deletions Drivers/PrinterDriver/EinsteinDriver.pf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## File: EinsteinDriver.pf## Contains: Pram source to build sample print driver## Copyright: � 1992-1994 by Apple Computer, Inc., all rights reserved.### one entry each for the driver(s) we are building# each entry must contain name, driverName, imagingName, and type.# only multiplexed drivers will use the last field;# set it to zero otherwise. # Name driverName imagingName type prModel"EinsteinPrtr 72dpi" TEinsteinDriver TDotPrinter serialSym 0"EinsteinPrtr 150dpi" TEinsteinDriver TDotPrinter serialSym 1"EinsteinPrtr 300dpi" TEinsteinDriver TDotPrinter serialSym 2
Expand Down
1 change: 1 addition & 0 deletions Drivers/PrinterDriver/EinsteinDriverPrims.a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; ==============================; File: EinsteinDriverPrims.s; Project: Einstein;; Copyright 2022 by Matthias Melcher ([email protected]);; 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.,; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.; ============================== MACRO NATIVE_PRIM $id, $symbol AREA $symbol, CODE, READONLY EXPORT $symbol stmdb sp!, {lr} ldr lr, id_for_$symbol mcr p10, 0, lr, c0, c0 ldmia sp!, {pc}id_for_$symbol DCD $id MEND NATIVE_PRIM 0x0C01, PDNew NATIVE_PRIM 0x0C02, PDDelete NATIVE_PRIM 0x0C03, PDOpen NATIVE_PRIM 0x0C04, PDClose NATIVE_PRIM 0x0C05, PDOpenPage NATIVE_PRIM 0x0C06, PDClosePage NATIVE_PRIM 0x0C07, PDImageBand NATIVE_PRIM 0x0C08, PDCancelJob NATIVE_PRIM 0x0C09, PDIsProblemResolved NATIVE_PRIM 0x0C0A, PDGetPageInfo NATIVE_PRIM 0x0C0B, PDGetBandPrefs NATIVE_PRIM 0x0C0C, PDFaxEndPage END; =========================================================================== ;; THEGODDESSOFTHENETHASTWISTINGFINGERSANDHERVOICEISLIKEAJAVELININTHENIGHTDUDE ;; =========================================================================== ;
Expand Down
1 change: 1 addition & 0 deletions Drivers/PrinterDriver/FilesInBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# DDK project created on Tuesday, August 20, 1996 4:38:22 PM # by Newton C++ Tools #PackageofPartsLocalLinkOptions="-dupok "LocalARMCppOptions="-cfront -W "LocalCfronttOptions=""LocalCfrontCOptions="-W "LocalCOptions="-d forARM "LocalPackerOptions=" -packageid 'xxxx' -copyright 'Copyright (c) 1997 Apple Computer, Inc.'"# add/change/delete lines like those below for other include files needed by your source files.-i "{DDK_Includes-dir}"-ic "{DDK_Includes-dir}Bootstrap"-ic "{DDK_Includes-dir}CLibrary"-ic "{DDK_Includes-dir}CommAPI"-ic "{DDK_Includes-dir}Communications"-ic "{DDK_Includes-dir}Frames"-ic "{DDK_Includes-dir}HAL"-ic "{DDK_Includes-dir}OS600"-ic "{DDK_Includes-dir}Packages"-ic "{DDK_Includes-dir}Power"-ic "{DDK_Includes-dir}PSS"-ic "{DDK_Includes-dir}QD"-ic "{DDK_Includes-dir}Toolbox"-ic "{DDK_Includes-dir}UtilityClasses"-ic "{DDK_Includes-dir}Printing"-srcdirs ':'-tpart -protocol -aif "{Objects-dir}printerDriver.bin" -autoload -autoRemove # add lines here with the names of your protocol source filesEinsteinDriverPrims.sEinsteinDriver.cp-clike EinsteinDriver.impl.h# ARMCpp will compile files named with the suffix .cp# ARMCfront will compile files named with the suffix .cf# ARMCpp -ansic will compile files named with the suffix .c# ARMAsm will compile files named with the suffix .a"{DDK_Libraries-dir}CardGlue.a.o"# Repeat the -tpart line above for other -protocol parts or -frame parts, etc# and follow it with source/library file lines to build it# use a line like this �-clike ExampleTool.impl.h� for the .impl.h files of a protocol-tpart -frames "{Objects-dir}EinsteinDriver.pf.part" -notify 'prnt' �"�"EinsteinDriver.pf# following line defines the final build target name followed by the �package name� # and any other Packer options you didn't define above in the LocalPackerOptions= definition. -tpackage "{Objects-dir}printerDriver.pkg" "printerDriver" -version 01
Expand Down
Loading

0 comments on commit f481e34

Please sign in to comment.