h42138
s 00209/00000/00000
d D 1.1 83/03/15 21:24:28 tes 1 0
c date and time created 83/03/15 21:24:28 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
 
         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
 
IdsCode    CSeg
 
Raster_Base	Dw	Seg YTop	; Paragraph base of /Raster/ Common
 
masks    db     1, 2, 4, 8, 16, 32, 64  ; Use these for masks
 
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 four rows the particular point is located in
         Xor          Si, Si  ; Ax holds the index into rasbuf, set to 0
 
         Mov          Cx, ytop   ; subtract the row from the top to get the row
         Sub          Cx, ycoord
         Push         Cx         ; keep the current row on the stack
 
findrow: Sub          Cx, 7      ; Decrement the row by 7 until negative
         Js           foundit
         Pop          Bx         ; Clean out the old row
         Push         Cx         ; save the new row
 
         Add          Si, RASTERBUFFER
         Jmp          findrow
 
foundit: Add          Si, xcoord ; Complete the rasbuf index
         Pop          Di         ; Get the row from the stack
 
         Mov          Al,  masks[Di]  ; put the mask into Dl
         Or           rasbuf[Si], Al  ; set the bit in the byte
 
Bailout:
	Mov	Sp,Bp		; Trash local variables
	Pop	Bp		; Restore caller's stack frame
	Pop	Ds		;  & DSeg base
	Retf	12		;  & return
 
;***************************************************************
;  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
