h45516
s 00247/00000/00000
d D 1.1 83/03/15 21:25:36 tes 1 0
c date and time created 83/03/15 21:25:36 by tes
e
u
4
U
t
T
I 1
Bdos     Equ     224
 
Parm1    Equ     Ss:(DWord Ptr .16)[Bp]
Parm2    Equ     Ss:(DWord Ptr .12)[Bp]
Parm3    Equ     Ss:(DWord Ptr .8)[Bp]
Old_Ds	Equ	Word Ptr 2[Bp]
Old_Bp	Equ	Word Ptr 0[Bp]
YCoord	Equ	Word Ptr (-2)[Bp]
XCoord	Equ	Word Ptr (-4)[Bp]
 
;        Sp+18        Segment Parameter 1
;        Sp+16        Offset Parameter 1
;        Sp+14        Segment Parameter 2
;        Sp+12        Offset Parameter 2
;        Sp+10        Segment Parameter 3
;        Sp+8         Offset Parameter 3
;        Sp+6         Segment Return Address
;        Sp+4         Offset Return Address
;        Sp+2         Old Base pointer
; [Bp]:  Sp           Old Data segment
 
XLIMITS      equ      671
RASTERBUFFER equ      672
RASTERLENGTH equ      2688
 
@raster  eseg  para  common
ytop     rw           1
ybot     rw           1
rasbuf   rb           RASTERLENGTH
;
; Device driver common
@gssdev  eseg  para   common
ndclrf  rw         1
ndclrl  rw         1
ndclrm  rw         1
ndclrp  rw         1
ndclrt  rw         1
ndflpt  rw         1
ndfstl  rw         1
ndlntp  rw         1
ndmktp  rw         1
ndmkht  rw         1
ndotkt  rw         1
ndpnpr  rw         1
ndtxrt  rw         1
ndtxsz  rw         1
ndtysz  rw         1
ndxpos  rw         1
ndypos  rw         1
ndlcmd  rw         1
ndvlmd  rw         1
ndchmd  rw         1
ndstmd  rw         1
 
         Public    Gzbdos
         Public    Setdma
         Public    Prtout
         Public    Prstot
         Public    SetBit
	 Extrn     LptOut:Far
;
;***************************************************************
;  subroutine setbit (x, y, qvis)
;     purpose:  set a bit in the raster buffer if the input (x,y)
;               is in the current raster strip
;               output qvis = .true. if the point is in the raster strip
 
IdsCCode    CSeg
 
Raster_Base	Dw	Seg YTop	; Paragraph base of /Raster/ Common
Gssdev_Base	Dw	Seg Ndclrf	; Paragraph base of /Gssdev/ Common
 
masks    db     1, 2, 4, 8, 16, 32, 64  ; Use these for masks

; setup the color table  by using bits
;        yellow  red  blue   black
;           1     1     0      0    makes orange
;                         nul  red  green blue orng yelw purp black
clrtbl  db                 00,  04,  10,  02,  12,  08,  06,  01
 
SetBit:	Push	Ds		; Save caller's DSeg base
	Push	Bp		; Save caller's frame
	Mov	Bp,Sp		; Make local frame
	Sub	Sp,4		; Two local variables
 
; Get the x and y points from the stack
 
         Lds          Si, Parm1
         Mov          Bx, Word Ptr[Si]
         Mov          Xcoord, Bx
 
         Lds          Si, Parm2
         Mov          Bx, Word Ptr[Si]
         Mov          Ycoord, Bx
 
         ; Set logical output parameter to false
         Lds          Si, Parm3
         Mov          Ds:(Word Ptr 0)[Si],  0
 
; Get a good segbase for Common /Raster/
	Mov	Es,Raster_Base		; Segbase of @Raster
 
; Now compare the ycoord to ytop and ybot to see if it is in the strip
         Mov          Cx, ytop    ; Test against top of strip
         Mov          Dx, ycoord
         Sub          Cx, Dx
         Js           Bailout
 
         Sub          Dx, Ybot  ; Test against bottem of strip
         Js           Bailout
 
; Check to make sure the x is within range too
         Mov          Cx, xcoord
         Or           Cx, Cx
         Js           Bailout   ; x less than 0
 
         Cmp          Cx, RASTERBUFFER
         Jns          Bailout   ; x greater than XLIMITS
 
; since the point was not clipped away, the qvis parameter is set true
         Mov          Ds:(Word Ptr 0)[Si],  1
 
; Now determine which of the bytes the particular point is located in
         Mov          Si, 2016; Si holds the index into rasbuf, start at end

; Get a good segbase for Common /gssdev/
	 Mov	Es,Gssdev_Base		; Segbase of @Gssdev

	 Mov          Di, ndclrp  ; get the color index

	 Mov          Al, clrtbl[Di]  ; put mask in Al

; Get a good segbase for Common /Raster/
       	Mov	Es,Raster_Base		; Segbase of @Raster
 
         Mov          Di, ytop   ; subtract the row from the top to get the row
         Sub          Di, ycoord
	 Mov          Ah, masks[Di]  ; this is the mask to use
	 Mov          Bx, RASTERBUFFER

Another: Ror    Al, 1          ; Determine if color is set
	 Jb     Setcolr        ; Use procedure if color was set
Back:    Sub    Si, Bx
	 Jge    Another        ; Index not less than 0 yet
 
Bailout:
	Mov	Sp,Bp		; Trash local variables
	Pop	Bp		; Restore caller's stack frame
	Pop	Ds		;  & DSeg base
	Retf	12		;  & return

Setcolr:  Mov   Di, Si          ; Get the current base
	  Add   Di, xcoord      ; Add in the xcoord offset
	  Or    Rasbuf[Di], Ah  ; Or in mask
	  Jmp   Back            ; And get back for next color
 
;***************************************************************
;  prtout (char):  Output a byte character to the printer
 
Prtout:  Jmpf  Lptout   ; Let it do the work, it's fortran callable

;
;***************************************************************
;  prstot (icnt, charay):  Output a byte character array to the printer
 
Prstot:	Push	Ds		; Save caller's DSeg base
	Push	Bp		; Save caller's frame
	Mov	Bp,Sp		; Make local frame
 
; Get the character count into Cx
 
         Lds          Si, Parm2
         Mov          Cx, [Si]
; Get the address of the character array to be output
         Lds          Si, Parm3
NextChr: Push         Cx       ; Save the count on the stack
 
         Push         Ds      ; Save these away for my future use
         Push         Si
 
         Push         Ds      ; Put out a copy for the fortran callable Lptout
         Push         Si
 
         CallF        Lptout
 
         Pop          Si
         Pop          Ds
	 Inc          Si      ; Go after next character
         Pop          Cx      ; retrieve the count for the loop instruction
         Loop         NextChr
 
	Mov	Sp,Bp		; Trash local variables
	Pop	Bp		; Restore caller's stack frame
	Pop	Ds		;  & DSeg base
	Retf	8		;  & return
 
;
;***************************************************************
;  byte integer function gzbdos (function, parameter)
 
Gzbdos:	Push	Ds		; Save caller's DSeg base
	Push	Bp		; Save caller's frame
	Mov	Bp,Sp		; Make local frame
 
; Get the opcode parameter from the stack
 
         Lds          Si, Parm2
         Mov          Cl, [Si]
; Get the bdos parameter from the stack
         Lds          Dx, Parm3
 
         Int          Bdos
 
	Mov	Sp,Bp		; Trash local variables
	Pop	Bp		; Restore caller's stack frame
	Pop	Ds		;  & DSeg base
	Retf	8		;  & return
 
;***************************************************************
;      setdma (parameter)
;
SetDMA:	Push	Ds		; Save caller's DSeg base
	Push	Bp		; Save caller's frame
	Mov	Bp,Sp		; Make local frame
 
  Mov          Cl, 51   ; Set dma base
 
; Get the DMA parameter from the stack
 
         Lds          Si, Parm3
         Mov          Dx, Ds
         Push         Si
 
         Int          Bdos
 
         Pop          Dx
         Mov          Cl, 26   ; Set dma offset
         Int          Bdos
 
	Mov	Sp,Bp		; Trash local variables
	Pop	Bp		; Restore caller's stack frame
	Pop	Ds		;  & DSeg base
        Retf         4  ; Return and remove parameter addresses from the stack
Stack    SSeg
         Rs           20	; Ds, Bp, Cx, Ds, Si, Int Bdos in Prstot
 
         End
E 1
