home *** CD-ROM | disk | FTP | other *** search
- ;----------------------------------------------------------------
- ; Program POINT.INV
- ; This program is an assembly language module interfaced to a
- ; calling TurboPascal routine. It plots a point on the hi-resolution
- ; graphics screen.
- ;
- ; The calling format is:
- ; PROCEDURE POINT(x,y,Color:integer);
- ; EXTERNAL 'POINT.INV';
- ;
- ; POINT(x,y,0);
- ;
- ; The program is directly derived from a Medium Resolution point
- ; plotting program. All the old code is still in place, although
- ; much of it is preceeded by a semicolon.
- ;
- ; AUTHOR: Christopher L. Morgan.
- ; Taken from PC Tech Journal, March 1984, pp. 38-58.
- ; Adapted by Jeff Firestone, HAL-PC Assembler SIG, 4/15/84.
- ;--------------------------------------------------------------------
-
- Msar MACRO REG, TIMES ;Shift REG right # of TIMES
- REPT TIMES
- SAR REG, 1
- ENDM
- ENDM
-
- MPOP MACRO DEST ;Move the stack addr. into DEST
- POP AX
- MOV DEST, AX
- ENDM
-
- MPUSH MACRO SOURCE ;Push the SOURCE onto the Stack
- MOV AX, SOURCE
- PUSH AX
- ENDM
-
- @bioscall MACRO parm
- int parm
- ENDM
-
- @doscall macro parm
- mov ah, parm
- int 21h
- ENDM
-
-
- code segment para public 'code'
- assume cs:code
- public TrigFunc
-
- TrigFunc proc near
-
- CALL BEGIN
-
-
- BasePage dw ? ;Storage for BP reg
- return dw ?
-
-
- ;------- TABLES OF COLOR MASKS FOR PLOTTING POINTS --------------------------
- ctable dw 0003Fh, 0403Fh, 0803Fh, 0C03Fh
- dw 000CFh, 010CFh, 020CFh, 030CFh
- dw 000F3h, 004F3h, 008F3h, 00CF3h
- dw 000FCh, 001FCh, 002FCh, 003FCh
-
- cctable db 0080h, 0040h, 0020h, 0010h
- db 0008h, 0004h, 0002h, 0001h
-
-
- Screen equ 0B800h
-
-
- BEGIN:
- pop ax ;Get the data pointer
- sub ax, 3 ;Adjust it
- mov si, ax
- mov BasePage[si], bp ;Save old BP for exit
- mov bp, ax
-
- MPOP RETURN[bp] ;Save the RETURN Addr.
- mpop dx ;Get Color
- mpop di ;Y Coordinate
- mpop si ;X Coordinate
- MPUSH RETURN[bp] ;Replace the Return Addr.
-
- mov ax, screen ;Point to screen with ES
- mov es, ax
- call setpt
- quit: mov bp, BasePage[bp] ;Restore the BasePage
- RET
-
-
-
- ;------------------------------------------------------------------------------
- ; ROUTINE: SETPT - Plot a point on the medium resolution color screen.
- ;
- ; This routine plots a point on the medium-resolution color graphics
- ; screen. The pixel at the specified location is given a specified
- ; color, overwriting the old color
- ;
- ; INPUT: X-coordinate (0-619) of the point is in SI
- ; Y-coordinate (0-199) of the point is in DI
- ; COLOR (0-3) is in DX
- ; OUTPUT: Just to the screen.
- ;
- ; REGISTERS USED: No registers are modified. SI, DI, and DX are used
- ; for input.
- ; SEGMENTS REFERENCED: Upon entry ES must point to the screen RAM at B8000h,
- ; and DS must pint to a data segment containing the
- ; following look-up table of ratated color masks:
- ; ctable dw 0003Fh, 0403Fh, 0803Fh, 0C03Fh
- ; dw 000CFh, 010CFh, 020CFh, 030CFh
- ; dw 000F3h, 004F3h, 008F3h, 00CF3h
- ; dw 000FCh, 001FCh, 002FCh, 003FCh
- ; ROUTINES CALLED: None.
- ; SPECIAL NOTES: No bounds checking is performed. The user must make sure
- ; that the coordinates and the color are in their proper ranges.
- ;------------------------------------------------------------------------------
- setpt proc near
-
-
- ; Multiply y-coord by bytes per row and adjust for even/odd lines
- mov ax, di ; Get y-coord into low part
- mov ah, al ; and into high part
- and ax, 01FEh ; Mask off unwanted parts
- sal ax, 1 ; Times 4
- sal ax, 1 ; Times 8
- sal ax, 1 ; Times 16
- mov bx, ax ; Gets into address
- and bh, 7 ; without adjustment
- sal ax, 1 ; Times 32
- sal ax, 1 ; Times 64
- add bx, ax ; Address gets y-coord times 80
-
- ; Add x-coord to address
- mov ax, si ; Get x-coordinate
- sar ax, 1 ; Divide
- sar ax, 1 ; by 4
- sar ax, 1 ; by 8 (hires)
- add bx, ax ; Here is the address
-
- ; Compute the rotated mask and color
- and si, 7 ; Just pixel position into the index
- ; sal si, 1 ; Index times 2
- ; sal si, 1 ; Index times 4
- ; add si, dx ; 4*pixel position + color
- ; sal si, 1 ; 8*pixel position + 2*color
- ; mov ax, ctable[si+bp] ; Look up rotated color and mask
- mov ah, cctable[si+bp] ; Loop up table for hires
-
- ; Insert the color into the video byte
- ; and al, es:[bx] ; Get old byte & remove old pixel
- mov al, es:[bx] ; Get old byte (Hires)
- or al, ah ; Insert new color
- mov es:[bx],al ; Put the byte back
-
- ret
-
- setpt endp
-
- TrigFunc endp
- code ends
- end