home *** CD-ROM | disk | FTP | other *** search
- page 58,132
-
- ; graphic.asm
- ; contains: palette(),wtdot(),getdot(),fillbox(),readpen()
- ;
- include model.h
- include prologue.h
- include equ.h
- name graphic
- pseg pallette
-
- ;==>-- void palette(id,value)
- ;
- ;; ARGUMENTS:
- ; (int) id - palette color ID
- ; (int) value - color value
- ;
- ;; DESCRIPTION:
- ; Set color Palette via Rom bios
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc palette
- mov bx,parm2_ ;get color value to BL
- mov bh,parm1_ ;get ID to AL
- and bx,07F0Fh ;mask off some undesirable bits
- mov ah,11 ;function 11
- int 10h
- cproce
-
- ;==>-- void wtdot(row,column,color)
- ;
- ;; ARGUMENTS:
- ; (int) row - y position
- ; (int) column - x position
- ; (int) color - color to write
- ;
- ;; DESCRIPTION:
- ; Write a dot via ROM-BIOS
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc wtdot
- mov dx,parm1_ ;get row
- mov cx,parm2_ ;get column
- mov al,parm3_ ;get color value to AL
- mov ah,12 ;function 12
- int 10h
- cproce
-
- ;==>-- unsigned getdot(row,column)
- ;
- ;; ARGUMENTS:
- ; (int) row - y position
- ; (int) column - x position
- ;
- ;; DESCRIPTION:
- ; Read the current color value of a specified dot on graphics
- ; screen.
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc getdot
- mov dx,parm1_ ;get row
- mov cx,parm2_ ;get column
- mov ah,13 ;function to read dot
- int 10h
- xor ah,ah ;entire return in AL
- cproce
-
- ;==>-- void fillbox(urow,lrow,lcol,rcol,color)
- ;
- ;; ARGUMENTS:
- ; (int) urow - upper row 0.199 of box shaped area
- ; (int) lrow - lower row of area
- ; (int) lcol - left column
- ; (int) rcol - right column
- ; (int) color - fill and edge color
- ;
- ;; DESCRIPTION:
- ; Generate a rectangular area and fill with the specified color
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;
- ; MODIFICATIONS:
- ; Checked video mode in order to make correct calculation for
- ; offset into video buffer.
- ;;;
-
-
-
- if _LCODE
- _fdyn struc
- _vidmod dw ? ;current video mode
- _curcol dw ?
- _colcnt dw ?
- _currow dw ?
- _rowcnt dw ?
- _sav1 dw ?
- _bpsav dw ?
- _retn dd ?
- _urow dw ?
- _lrow dw ?
- _lcol dw ?
- _rcol dw ?
- _colr dw ?
- _fdyn ends
- else
- _fdyn struc
- _vidmod dw ? ;current video mode
- _curcol dw ?
- _colcnt dw ?
- _currow dw ?
- _rowcnt dw ?
- _sav1 dw ?
- _bpsav dw ?
- _retn dw ?
- _urow dw ?
- _lrow dw ?
- _lcol dw ?
- _rcol dw ?
- _colr dw ?
- _fdyn ends
- endif
- cproc fillbox,,,,12
- mov ax,[bp]._lrow ;LROW
- mov bx,[bp]._urow ;UROW
- mov [bp]._currow,bx ;init current row
- sub ax,bx ;form row_count
- jl _fbox98 ;hop if lower < upper
- inc ax ;if same, count is 1
- mov [bp]._rowcnt,ax ;else OK, store row_count here..
- mov ax,[bp]._rcol ;RCOL
- mov bx,[bp]._lcol ;LCOL
- mov [bp]._curcol,bx ;init current column
- sub ax,bx ;form column count
- jl _fbox98 ;hop if right < left
- inc ax
- mov [bp]._colcnt,ax ;else OK, store column_count
- mov ah,0fh ;get video mode
- int 10h ;
- mov ah,0 ;
- mov [bp]._vidmod,ax ;and store it
- do_all_rows:
- call do_row
- mov dx,[bp]._currow
- inc dx
- mov [bp]._currow,dx
- mov cx,[bp]._rowcnt
- dec cx
- mov [bp]._rowcnt,cx
- jnz do_all_rows ;loop if not done yet
- xor ax,ax
- jmp short _fbox98
- _fbox98:
- cproce
-
- ;==>-- void readpen(out)
- ;
- ;; ARGUMENTS:
- ; (struct GFREGS *) out - pointer to GFREGS
- ;
- ;; DESCRIPTION:
- ; Read light pen position and transfer values to GFREGS structure.
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc readpen
- mov ax,0400h ;function 4 to AH
- int 10h
- if _LDATA
- push ds
- lds si,dword ptr parm1_
- else
- mov si,parm1_ ;get address of output structure
- endif
- mov [si+gfax],ax ;transfer pen trigger bit (AH bit 1)
- mov [si+gfbx],bx ;transfer pixel column 0..319,639
- mov [si+gfcx],cx ;transfer raster line (row 0..199)
- mov [si+gfdx],dx ;transfer character row,column
- if _LDATA
- pop ds
- endif
- cproce
-
- ; Subroutine to Do A Single Row.
- ;
- do_row proc near
- mov ax,[bp]._lcol ;get LCOL
- mov [bp]._curcol,ax ;and init current_column
- mov cx,[bp]._colcnt ;get column_count
- mov [bp]._sav1,cx
-
- do_row2:
- call $dot ;do a single dot
- inc word ptr [bp]._curcol ;update current_column
- mov cx,[bp]._sav1
- dec cx
- mov [bp]._sav1,cx
- jnz do_row2
- ret
- do_row endp
-
- ;********************
- ;
- ; $DOT
- ;
- ;********************
- ;
- ; This is a fast dot producing routine which works ONLY with _fbox at
- ; this time. DO NOT CALL THIS FROM C !!
- ;
- ; The major difference between this and _fdot is the linkage with callers.
- ;
- ; The same stack setup as for _fbox exists:
- ;
- ; BP+ 0 -> current_column
- ; 2 -> column_count
- ; 4 -> current_row
- ; 6 -> row_count
- ; 8 -> <BP from C>
- ; -> <ret addr > (2 or 4 bytes)
- ; @ab+8 -> U Row (may be BP+12 or +14)
- ; @ab+10 -> L Row
- ; @ab+12 -> L Col
- ; @ab+14 -> R Col
- ; @ab+16 -> Color
-
- $dot proc near
- mov ax,[bp]._currow ;get row
- mov ah,0 ;must be < 255
- test al,1 ;check for odd/even
- jnz $dot_odd_row ;hop if odd
- shr al,1 ;N/2 to AX
- cmp al,0 ;if 0, hop around..
- jz $dot2
- mov bx,ax
- mov cl,6
- shl bx,cl ;* 40h in BX
- mov cl,4
- shl ax,cl ;* 10h in AX
- add ax,bx ;* 50h in AX
- jmp short $dot2
- $dot_odd_row: ;do odd row
- dec al ;N - 1
- shr al,1 ;(N-1)/2
- cmp al,0 ;is it zero here ?
- jz $dot1 ;if so, starts at 2000h period.
- mov bx,ax
- mov cl,6
- shl bx,cl ;* 40h
- mov cl,4
- shl ax,cl ;* 10h
- add ax,bx ;* 50h in AX
- $dot1: add ax,2000h ;+ offset for odd bank
- $dot2: mov bx,[bp]._curcol ;get column
- mov dx,bx ;& to DX
- shr bx,1 ;M/2
- shr bx,1 ;M/2
- mov cx,[bp]._vidmod ;check video mode
- cmp cx,06h ;see if video mode == 6
- jne nodiv2 ;if not, do not perform M/2
- shr bx,1 ;M/2
- nodiv2: add ax,bx ;+ row offset = target byte offset
- mov si,ax ;to index reg.
- ; M is in DX here - derive mask to BL with color in AL
- mov ax,[bp]._colr ;get color
- and ax,3 ;must be <= 3
- and dx,3 ;form M % 4 in DX
- cmp dl,0
- jz $dot00 ;use bits 7,6
- cmp dl,1
- jz $dot01 ;5,4
- cmp dl,2
- jz $dot10 ;3,2
- mov bl,0FCh ;else use 1,0, and color bits are OK
- jmp short $dot4
- $dot00: mov cl,6 ;shift color bits to 7,6
- mov bl,03Fh ;mask
- jmp short $dot3
- $dot01: mov cl,4 ;color bits to 5,4
- mov bl,0CFh
- jmp short $dot3
- $dot10: mov cl,2 ;color bits to 2,3
- mov bl,0F3h
- $dot3: shl al,cl ;move color bits left
- $dot4: push ds
- mov dx,0B800h ;segment addr of graphics memory
- mov ds,dx
- mov dl,[si] ;get current byte...
- and dl,bl ;mask off bits for this PEL
- or dl,al ;then merge in new color bits
- mov [si],dl ;and put it back.
- pop ds
- ret
- $dot endp
- endps
- end
-