M EQU Byte Ptr 0[BX] DGROUP GROUP DATA TITLE 'Open Workstation' ;***************************************************************************** ; * ; OPEN WORKSTATION : Initializes default Primitive Attributes and * ; Returns Printer Capabilities Parameters to * ; the Application Program * ; * ;***************************************************************************** ; * ; Revision Feb. 10, 1984 File "A:ZOPWK.A86" GSX-86 V1.3 1-0 * ; Feb-02-84 Allocate Memory for bit map buffer under CP/M * ; Dec-22-83 Allocate Memory for bit map buffer under PC DOS 2.0 * ; Dec-16-83 Save and Restore Version and Extra Segment * ; Nov-27-83 Modified for OS check and printer allocation * ; Oct-31-83 Add Color Support variables * ; May-04-82 Add Writing mode support global variables * ; * ; opcode == OPEN WORKSTATION * ; ENTRY: SS:BP -> stacked parameter pointers * ; ES:DI -> CONTRL(1) * ; EXIT: CONTRL(3) = 6 * ; CONTRL(5) = 45 * ; INTOUT(1) - (45) = Device Capability Parameters * ; * ; 1) Get Default Primitive Attributes from INTIN into NDATTR array * ; * ; 2) Returns Device Capability Parameters in INTOUT array * ; * ; 3) Returns Min/Max Primitive Sizes (pixels) in PTSOUT array * ; * ; 4) Returns INTOUT and PTSOUT data length in Contrl array, * ; Contrl(3) = 6 points in PTSOUT, Contrl(5) = 44 entries in INTOUT * ; * ; 5) Initialize OBJLST buffer Flags/Pointers for Object List Buffer * ; Access Routines * ; * ;----------------------------------------------------------------------------* cseg PUBLIC ZOPWK EXTRN NOFILE:near, msgout:near dseg PUBLIC ndinit, NDLNSZ, NDTXSZ, NDTXRT, NDMKSZ PUBLIC WKID, NDLNTY, NDLNCO, NDMKTY, NDMKCO, NDTXTY, NDTXCO PUBLIC NDINTY, NDFITY, NDFICO, COLOR PUBLIC CHRSZ, CHRHT, PMKSZ, LSTYLE, ZXMAX, ZYMAX public ndrite, nopflg, rflg, ritflg, bmask, bitmask public rflgm, rflgt, rflgl, rflgf public bmaskm, bmaskt, bmaskl, bmaskf public dline, dtext, dmark, dfill, dcell public Version Public Bitmap_Offset, Allocated, Bitmap_segment, Bitmap_size Public Bitmap_words, Mcb, M_ext Extrn Bitmap:word, Bsize:word, Wordcount:word extrn xdpi:word, ydpi:word, xsiz:word, ysiz:word extrn ccap:word, xcor:word EXTRN RSTAT:byte EXTRN XMAX:word, YMAX:word, XMIN:word, YMIN:word Extrn Err_no:byte cseg ;----------------------------------------------------------------------------+ ; EQUATES FOR ARGUMENTS ADDRESSING + ;----------------------------------------------------------------------------+ CONTRL EQU Dword ptr 2 ; Control Parameter Block INTIN EQU Dword ptr 6 ; Integer Input Parameter Block PTSIN EQU Dword ptr 10 ; Point Coordinates Input Array INTOUT EQU Dword ptr 14 ; Integer output Parameter Block PTSOUT EQU Dword ptr 18 ; Point Coordinates Output Array ;----------------------------------------------------------------------------+ ; Define Word Displacements to Successive Entries in a Word Array + ;----------------------------------------------------------------------------+ W_1 EQU Word ptr 0 W_2 EQU Word ptr 2 W_3 EQU Word ptr 4 W_4 EQU Word ptr 6 W_5 EQU Word ptr 8 W_6 EQU Word ptr 10 W_7 EQU Word ptr 12 W_8 EQU Word ptr 14 W_9 EQU Word ptr 16 W_10 EQU Word ptr 18 ;----------------------------------------------------------------------------+ ; Define DEVICE CAPABILITIES + ;----------------------------------------------------------------------------+ zdxlng EQU 479 ; Set the length of each axis in pixels zdylng EQU 575 ; 60 (pixels per Horizontal inch) : 480 Dots mode ; 72 (pixels per Vertical Inch) x 8 inches deunit EQU 0 ; Precisely scaled image pixsiz EQU 424 ; Size per Pixel piysiz EQU 352 ; SIZE PER PIXEL HIGHT lincap EQU 6 ; Capable of 6 different line styles lszcap EQU 1 ; Capable of 1 different line widths mrkcap EQU 5 ; Capable of 5 different Markers mszcap EQU 12 ; Capable of 12 different maker sizes tszcap EQU 12 ; Capable of 12 different text sizes txtcap EQU 1 ; No. of fonts patcap EQU 6 ; Capable of 6 different patterns hatcap EQU 6 ; Capable of 6 different hatch styles cordef EQU 8 ; 8 predefined colors (monochrome) gdpcap EQU 1 ; No. of GDPs corcap EQU 1 ; Capable of Color rotcap EQU 1 ; Capable of Text Rotation filcap EQU 1 ; Capable of Fill Area Operation pixcap EQU 0 ; No Pixel Operation palete EQU 2 ; Total of 2 Colors in the color pallette indevs EQU 0 ; No input devices gincap EQU 0 ; No Gin capability (Workastation type : Output only) ;----------------------------------------------------------------------------+ ; Define Minimum/Maximum Primitive Sizes in Pixels + ;----------------------------------------------------------------------------+ CHRBOX EQU 8 LNSZ0 EQU 1 LNSZ9 EQU 1 MKSZ0 EQU 8 MKSZ9 EQU 96 TXSZ0 EQU 8 TXSZ9 EQU 96 ;---------------------------------------------------------------------+ ; Operating System Equates + ;---------------------------------------------------------------------+ BDOS Equ 224 CPM_Type equ 0 MPM_Type equ 1 CCPM_Type equ 4 CPM equ 20H CPMPLUS equ 30H CCPM2 equ 20H CCPM3 equ 30H PCDOS1 equ 0F1H PCDOS2 equ 0F2H MSDOS equ 0FFH CPM_V equ 0001H MPM_V equ 0002H CPMPLUS_V equ 0003H CCPM2_V equ 0004H CCPM3_V equ 0005H PCDOS1_V equ 00F1H PCDOS2_V equ 00F2H MSDOS_V equ 00FFH PlusKeyOPCode equ 0F980H Entry_to_PlusKey equ 0 PCKeyOPCode equ 0FC80H Entry_to_PCKey equ 0EH ; Buffer Size in paragraphs: A00h=40K, 900h=36K, 800h=32K, 600h=24K SEG_PARA Equ 0A00h SEG_BYTE Equ 0A000h SEG_WORD Equ 05000h DSEG ; The Printer GIOS will attempt to dynamically allocate ; a Block of Memory for the Bitmap Buffer, if the allocation is ; successiful, bitmap offset is zero relative to the memory segment ; block allocated, otherwise it is the offset of the bitmap buffer ; from the driver Data Segment. This offset address pointer is used ; by the setbit and scan output modules. Bitmap_Segment Dw Seg Bitmap_offset ; Initialize to Data segment Bitmap_offset Dw (Offset Bitmap) ; Initialize to Internal buffer Bitmap_size Dw 3840 ; Buffer Size in bytes Bitmap_words Dw 1920 ; Buffer size in words Allocated Db 0 ; Initialize to no Allocation Db 0 ; Memory Control Block for CP/M allocate memory Function 37h Mcb Dw 0 M_length Dw SEG_PARA M_ext Dw 0 ;----------------------------------------------------------------------------+ ; Initialize Printer Output Parameter Blocks + ;----------------------------------------------------------------------------+ OUTBLK: ZXMAX DW ZDXLNG ; Addressable width in pixels zymax DW ZDYLNG ; Adderssable height in pixels DW DEUNIT ; Precisely Scaled Image Capability zxpix DW PIXSIZ ; Pixel Size in Micrometers (width) zypix DW PIYSIZ ; Pixel Size (Height) DW TSZCAP ; No. of Character Heights DW LINCAP ; No. of Line styles DW LSZCAP ; No. of Line widths DW MRKCAP ; No. of Marker types DW MSZCAP ; No. of Marker sizes DW TXTCAP ; No. of Fonts DW PATCAP ; No. of Patterns DW HATCAP ; No. of Hatch Styles zcordef DW CORDEF ; No. of Predefined Colors ; Generalized Drawing Primitives Capabilities DW GDPCAP DW 1 ; Device has bars DW -1,-1,-1,-1,-1,-1,-1,-1,-1 ; No other GDPs are defined DW 3 DW -1,-1,-1,-1,-1,-1,-1,-1,-1 zccap DW CORCAP ; Color Capability Flag DW ROTCAP ; Text Rotation DW FILCAP ; Fill Area DW PIXCAP ; Pixel Operation DW PALETE ; No. of available colors ; Available Input devices DW INDEVS DW INDEVS DW INDEVS DW INDEVS DW GINCAP ; Workstation type : Output Only ;----------------------------------------------------------------------------+ ; More Output Initializations + ;----------------------------------------------------------------------------+ DWSIZE: DW 0 DW TXSZ0 ; Minimum character height in pixels DW 0 DW TXSZ9 ; Maximum character height DW LNSZ0 ; Minimum Line width in pixels DW 0 DW LNSZ9 ; Maximun Line width in pixels DW 0 DW 0 DW MKSZ0 ; Minimum Marker Height in Pixels DW 0 DW MKSZ9 ; Maximum Maker height ;----------------------------------------------------------------------------+ ; Initialize other default values + ;----------------------------------------------------------------------------+ NDSIZE: ndlnsz RS 02 ; Set current device line size ndtxsz RS 02 ; Set current device text size (1-16) ndtxrt RS 02 ; Set currnet device text rotation (0-3) ; 0=0, 1=90, 2=180, 3=270 ndmksz RS 02 ; Set Current Device Marker Size (1-16) ;----------------------------------------------------------------------------+ ; Initial defaults (Line style, Color, Character size, etc) + ;----------------------------------------------------------------------------+ CHRSZ RS 02 ;Character width = 6 pixels * NDTXSZ CHRHT RS 02 ;Character height = 8 pixels * NDTXSZ PMKSZ RS 02 ;Maker size in pixels = 8 * NDMKSZ Version dw 0 ; used to hold what version of OS NDATTR: wkid RS 02 ;Workstation Identifier ndlnty RS 02 ;Current Line Style ndlnco RS 02 ; Line Color ndmkty RS 02 ; Marker Type ndmkco RS 02 ; Marker Color ndtxty RS 02 ; Text Font ndtxco RS 02 ; Text Color ndinty RS 02 ; Fill Interior Style ndfity RS 02 ; Fill Style ndfico RS 02 ; Fill Color ndrite rs 02 ; Current Writing Mode COLOR RS 01 RS 01 LSTYLE DW 0FC30H ;Line style pattern word ; Writing Mode Support Variables nopflg db 0 ; nopflg = 0, if writing mode = replace ; nopflg = 1 for set/xor/clear modes rflg db 00 ; rflg = 0, new data = old data OR bitmask ; rflg = 1, new data = old data AND bitmask ; rflg = -1, new data = old data XOR bitmask ; rflg and bmask used by setbit routine bmask db 00000001b ; the initial bit mask unless changed ; by set writing mode or set color db 0 dline db 01 ; These are the draw object flags dfill db 01 ; set to 0 if color = 0 and mode is not replace dtext db 01 ; when it is set to 0, the object is not stored dmark db 01 ; in the object list, thus will not be drawn dcell db 01 db 0 ritflg db 0 bitmask db 00000001b rflgm db 0 rflgt db 0 rflgl db 0 rflgf db 0 bmaskm db 00000001b bmaskt db 00000001b bmaskl db 00000001b bmaskf db 00000001b rs 08 NDINIT RS 70 ;Initial Device Default Attribute settings ;used to reinitialize the drawing parameters ;after raster and scanning each plot strip cseg ZOPWK: ;----------------------------------------------------------------------+ ; Initialize bit map parameters before memory allocation + ;----------------------------------------------------------------------+ ; First initialize the bit map buffer segment:offset values and ; the memory allocation flag ; Set the segment address of the memory block to Data Segment Mov Ax, Ds Mov Word Ptr Bitmap_Segment, Ax ; Set the bit map buffer offset to driver internal buffer Mov Word Ptr Bitmap_offset, (Offset Bitmap) ; Set the bit map buffer size to internal buffer size Mov Ax, Word Ptr Bsize Mov Word Ptr Bitmap_size, Ax Mov Ax, Word Ptr Wordcount Mov Word Ptr Bitmap_words, Ax ; Clear the memory allocation flag Mov Byte Ptr Allocated, 0 ;----------------------------------------------------------------------+ ; Determine the OS + ;----------------------------------------------------------------------+ push ds xor ax,ax mov ds,ax ; System Offset mov bx,380H ; GDOS Interrupt Verctor Address mov ax,[bx] ; GDOS Code Address inc bx inc bx mov cx,[bx] ; GDOS Data Offset Address mov ds,cx mov bx,ax ; Setup DS:BX to get OS Key from GDOS area mov cx,word ptr Entry_to_PlusKey[bx] mov ax,word ptr Entry_to_PCKey[bx] pop ds ; Restore Ds Push ES ; Save Es !! cmp cx,PlusKeyOPCode Jne CPMDOS_OW cmp ax,PCKeyOPCode je PCDOS_OW CPMDOS_OW: ;---------------------------------------------------------------------+ ; Try allocate some extra memory for bit map buffer + ;---------------------------------------------------------------------+ ; Set up parameters for CP/M allocate memory function ; Cl: 037h, Dx: MCB Offset Address, Ds: MCB segment address Mov Cl, 037h Mov Dx, (Offset Mcb) Mov Word Ptr M_Length, SEG_PARA ; Buffer Size in paragraphs Int BDOS Cmp Al, 0 ; Al:0 if Ok, 0ffh if failed Je All_Ok Mov Ax, 6 ; Error Message No. Call Msgout Jmp Cpm_path All_ok: ; Set up allocated Memory block for bit map buffer Mov Ax, Word Ptr Mcb Call Big_buffer Cpm_path: mov cl,0CH ; Check CP/M Version Number int BDOS and bh,0DH ; turn off the networking bit cmp bh,CPM_type je CPM_type_OW cmp bh,MPM_type je MPM_type_OW CCPM_type_OW: ; Concurrent Environment, Allocate Printer Resourse mov cl,9EH int BDOS mov cl,3AH ; Which CCPM Version ? int BDOS cmp al,CCPM3 jb CCPM2_OW CCPM3_OW: mov ax,CCPM3_V jmp OS_OW_Done CCPM2_OW: mov ax,CCPM2_V jmp OS_OW_Done MPM_type_OW: mov ax,MPM_V jmp OS_OW_Done CPM_type_OW: cmp bl,CPMPLUS jge CPMPLUS_OW CPM_OW: mov ax,CPM_V jmp OS_OW_Done CPMPLUS_OW: mov ax,CPMPLUS_V jmp OS_OW_Done PCDOS_OW: ; Get DOS Version Number, DOS V1.1 does not support memory allocation Mov Ax, 03000h Int 21h Cmp Al, 0 ; If Al returns zero, it is pre-DOS V2.0 Jne PCDOS2_OW Mov Ax, PCDOS1_V ; PC-DOS V1.0... Jmp OS_OW_Done ; Try Allocate some memory block for the bit map buffer ; Size in paragraphs:1000H=40K, 900H=36K, 800H=32K, 600H=24K PCDOS2_OW: Mov Bx, SEG_PARA ; Bx = memory block size to allocate Mov Ax, 04800h ; Ah = allocate memory function :48h Int 21h ; DOS 2.0 function call Jc MA_error ; Carry flag set indicates allocation failed Call Big_buffer ; = Segment address of memory block Jmp PC_path MA_error: Add Al, 30h ; Display error code returned for debug Mov Byte Ptr Err_no, Al Mov Ax, 6 ; Error Message No. Call Msgout Pc_path: ; The PC Dos Os Version code mov ax,PCDOS2_V Jmp OS_OW_DONE Big_buffer: ; We Got A Big Buffer to use !!! ; Save the segment address of the memory block allocated Mov Word Ptr Bitmap_Segment, Ax ; Set the bit map buffer offset to zero Mov Word Ptr Bitmap_offset, 0 ; Set the bit map buffer size in bytes and words Mov Word Ptr Bitmap_size, SEG_BYTE Mov Word Ptr Bitmap_words, SEG_WORD ; Set the memory allocation flag, close wk should free the memory Mov Byte Ptr Allocated, 0ffH Ret OS_OW_DONE: ; We will be in big trouble if this version is clobbered. Mov Version,ax ; OS Version Pop Es ; Restore Es ;----------------------------------------------------------------------------+ ; Setup Device Horizontal (dots per inch x 8 inches) and + ; Vertical (dots per inch x 11 inches) Resolution + ;----------------------------------------------------------------------------+ mov ax, 0 call msgout ; I'm here ! mov bx, word ptr xdpi mov word ptr zxmax, bx ; X resolution mov bx, word ptr ydpi mov word ptr zymax, bx ; Y resolution mov bx, word ptr xsiz mov word ptr zxpix, bx ; Pixel Size (width) mov bx, word ptr ysiz mov word ptr zypix, bx ; Pixel Size (hight) Mov Bx, Word Ptr Xcor Mov Word Ptr ZCORDEF, Bx ; Pre-defined Color Mov Bx, Word Ptr Ccap Mov Word Ptr ZCCAP, Bx ; Color Capability ;----------------------------------------------------------------------------+ ; Setup Output Control Parameters + ;----------------------------------------------------------------------------+ Mov ES:W_3[DI],6 ;set up CONTRL(3) Mov ES:W_5[DI],45 ;set up CONTRL(5) ;----------------------------------------------------------------------------+ ; Output Device Capability Parameters in INTOUT array + ;----------------------------------------------------------------------------+ Les DI,INTOUT[BP] ;point at the output array Mov SI,offset OUTBLK Mov CX,45 ;number of words to move Cld ;make sure we go the right direction Rep MOVSW ;----------------------------------------------------------------------------+ ; Output Values that need to be Transformed to NDC space in PTSOUT + ;----------------------------------------------------------------------------+ LES DI, PTSOUT[BP] MOV SI,(Offset DWSIZE) ; Predefined Drawing Primitive ; Size in Pixels MOV CX,12 ;Move 12 Words of data to PTSOUT Rep MOVSW ;----------------------------------------------------------------------------+ ; Setup Default Device Primitive Attributes in NDATTR Array + ;----------------------------------------------------------------------------+ ; Move Primitive Attribute Defaults from INTIN to NDATTR ; Push DS ;save our data segment Mov AX,DS ;get our data segment Mov ES,AX ;into the extra segment Mov DI,offset NDATTR ;point at the variables Lds SI,INTIN[BP] ;point at the default values Mov CX,10 ;words to move Rep MOVSW Pop Ds ;Recover our Ds ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Input Line Style Index = 1 - 6 ;Stored Line Style index = 0 - 5 DEC Word Ptr NDLNTY DEC Word Ptr NDMKTY MOV Byte Ptr NDTXSZ,1 ;Initialize Text size MOV Byte Ptr NDMKSZ,01 ; Maker size MOV Byte Ptr NDLNSZ,01 ; Line size MOV Byte Ptr NDTXRT,01 ; Text rotation MOV Byte Ptr CHRHT,08 MOV Byte Ptr PMKSZ,08 ; Maker Height MOV Byte Ptr CHRSZ,06 ; Character Width mov ax, 0 ; Initialize max, min plot extent mov xmax,ax mov ymax,ax ; Initialize object draw flag, writing mode flag and bit masks ; for each of the output primitives : since if the driver is ; already loaded, a fresh copy of driver will not get loaded into ; memory at a open workstation call, variables must be re-initialized ; to prevent left over effect mov byte ptr ndrite,al ; writing mode = replace mov nopflg, al mov rflg, al ; rflg and bmask is used by the mov ritflg, al ; setbit routine to determine mov Byte Ptr rflgm, Al ; how the data bit should be set mov Byte Ptr rflgl, Al Mov Byte Ptr rflgt, Al Mov Byte Ptr rflgf, Al mov Al, 1 mov bmask, al mov Byte Ptr bmaskm, Al mov Byte Ptr bmaskt, Al mov Byte Ptr bmaskl, Al mov Byte Ptr bmaskf, Al mov Byte Ptr dline, Al mov Byte Ptr dfill, Al mov Byte Ptr dtext, Al mov Byte Ptr dmark, Al mov dcell, al mov ymin,07fffh mov xmin,07fffh ; Initialize Device Default Attribute Value List MOV SI,(Offset NDSIZE) ;These Are the Current Attibute Values MOV DI,(Offset NDINIT) ;These Default Values Never get Modified MOV CX,32 Rep MOVSW ;----------------------------------------------------------------------------+ ; Initialize OBJLST Buffer Flags, Indeces and Pointers + ;----------------------------------------------------------------------------+ MOV Byte Ptr RSTAT,0 ;Set Roll-Out File Flag, 0=No File Used CALL NOFILE ;Initialize Buffer Index and Address Pointers ret END