Take over the PDriver SWI chunk. Call the printer driver modules by jumping to their SWI handlers with R11 = SWI number to call, to ease the transition to shared drivers. This is not that much of an overhead, as SWI's are slow anyway, and not repeatedly used.
On initialisation perform Service_PDriverStarting with R3 => code for declaring printers. This code will be called by all the currently resident printer driver submodules with R0 => SWI branch table, R1=R12 for calls through the branch table, R2=printer number.
Provide SWI PDriver_DeclarePrinter. Entry R0 => branch table, R1=R12 for calls through the branch table, R2=printer number
Provide SWI PDriver_SelectPrinter. Entry R0=printer number. Exit new printer selected, or error if that printer number is currently not known.
Pass PDriver calls which depend on the current job to the PDriver submodule which owns that job. These are PDriver_FontSWI, PDriver_GiveRectangle,PDriver_DrawPage,PDriver_GetRectangle,PDriver_InsertIllustration
Pass PDriver calls which are current-PDriver specific to the current
PDriver. These are:
PDriver_Info,PDriver_SetInfo,PDriver_CheckFeatures,PDriver_PageSize,PDriver_SetPageSize,PDriver_ScreenDump,PDriver_SetPrinter
Keep track of which PDriver submodules own which jobs so that the above distinctions can be made. The following calls will have to be tracked to handle this:
PDriver_SelectJob,PDriver_CurrentJob,PDriver_EndJob,PDriver_AbortJob,PDriver_Reset,PDriver_CancelJob,PDriver_EnumerateJobs,PDriver_CancelJobWithError,PDriver_SelectIllustration.
Note that the PDriver shell module must know which is the current job, and which module owns it. Have a table of 256 job entries, each containing a pointer to the printer's data block. Have a 'current job' handle from 1 to 255 (0=>none). Break this list down into:
Internally handled: PDriver_CurrentJob (return current job handle), PDriver_EnumerateJobs (return next handle higher than the one given).
Job killers: PDriver_EndJob, PDriver_AbortJob (Call driver which owns job handle in R0 with appropriate call, and then clear th job descriptor for the job). If R0=current job then clear current job
Job cancellers: PDriver_CancelJob, PDriver_CancelJobWithError (Call driver which owns job handle in R0).
Job selectors: PDriver_SelectJob, PDriver_SelectIllustration. (R0=0 => call driver which owns current job with appropriate call, then set current job to 0. R0<>0 => if new job then create descriptor. Call driver which owns job handle in R0 with appropriate routine. Set current job to R0. NOTE ERROR CONDITIONS - READ MANUAL)
Job clearing: PDriver_Reset. Call all drivers with PDriver_Reset. Clear all job descriptors. Clear current job handle.
Possibly provide new SWI's such as PDriver_InfoForDriver, which take an extra parameter to say which driver they should use. These will use R7 as the driver number. They will be available on all SWI's which would otherwise refer to the 'current' printer driver.