home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / TURBO.ZIP / POINT.ASM < prev    next >
Encoding:
Assembly Source File  |  1984-05-09  |  6.0 KB  |  165 lines

  1. ;----------------------------------------------------------------
  2. ;                   Program  POINT.INV
  3. ;  This program is an assembly language module interfaced to a
  4. ;  calling TurboPascal routine.  It plots a point on the hi-resolution
  5. ;  graphics screen.
  6. ;
  7. ;  The calling format is:
  8. ;              PROCEDURE POINT(x,y,Color:integer);
  9. ;                          EXTERNAL 'POINT.INV';
  10. ;
  11. ;              POINT(x,y,0);
  12. ;
  13. ;  The program is directly derived from a Medium Resolution point
  14. ;  plotting program.  All the old code is still in place, although
  15. ;  much of it is preceeded by a semicolon.
  16. ;
  17. ; AUTHOR: Christopher L. Morgan.
  18. ;         Taken from PC Tech Journal, March 1984, pp. 38-58.
  19. ;         Adapted by Jeff Firestone, HAL-PC Assembler SIG, 4/15/84.
  20. ;--------------------------------------------------------------------
  21.  
  22. Msar    MACRO   REG, TIMES              ;Shift REG right # of TIMES
  23.         REPT    TIMES
  24.         SAR     REG, 1
  25.         ENDM
  26.         ENDM
  27.  
  28. MPOP    MACRO   DEST                     ;Move the stack addr. into DEST
  29.         POP     AX
  30.         MOV     DEST, AX
  31.         ENDM
  32.  
  33. MPUSH   MACRO   SOURCE                   ;Push the SOURCE onto the Stack
  34.         MOV     AX, SOURCE
  35.         PUSH    AX
  36.         ENDM
  37.  
  38. @bioscall MACRO  parm
  39.           int    parm
  40.           ENDM
  41.  
  42. @doscall macro  parm
  43.          mov    ah, parm
  44.          int    21h
  45.         ENDM
  46.  
  47.  
  48. code segment para public 'code'
  49.              assume cs:code
  50.              public   TrigFunc
  51.  
  52. TrigFunc      proc     near
  53.  
  54.              CALL   BEGIN
  55.  
  56.  
  57. BasePage   dw     ?                  ;Storage for BP reg
  58. return     dw     ?
  59.  
  60.  
  61. ;------- TABLES OF COLOR MASKS FOR PLOTTING POINTS --------------------------
  62. ctable     dw      0003Fh, 0403Fh, 0803Fh, 0C03Fh
  63.            dw      000CFh, 010CFh, 020CFh, 030CFh
  64.            dw      000F3h, 004F3h, 008F3h, 00CF3h
  65.            dw      000FCh, 001FCh, 002FCh, 003FCh
  66.  
  67. cctable    db      0080h, 0040h, 0020h, 0010h
  68.            db      0008h, 0004h, 0002h, 0001h
  69.  
  70.  
  71. Screen  equ      0B800h
  72.  
  73.  
  74. BEGIN:
  75.         pop      ax                    ;Get the data pointer
  76.         sub      ax, 3                 ;Adjust it
  77.         mov      si, ax
  78.         mov      BasePage[si], bp      ;Save old BP for exit
  79.         mov      bp, ax
  80.  
  81.         MPOP     RETURN[bp]            ;Save the RETURN Addr.
  82.         mpop     dx                    ;Get Color
  83.         mpop     di                    ;Y Coordinate
  84.         mpop     si                    ;X Coordinate
  85.         MPUSH    RETURN[bp]            ;Replace the Return Addr.
  86.  
  87.         mov      ax, screen            ;Point to screen with ES
  88.         mov      es, ax
  89.         call     setpt
  90. quit:   mov      bp, BasePage[bp]       ;Restore the BasePage
  91.         RET
  92.  
  93.  
  94.  
  95. ;------------------------------------------------------------------------------
  96. ; ROUTINE: SETPT  -  Plot a point on the medium resolution color screen.
  97. ;
  98. ;          This routine plots a point on the medium-resolution color graphics
  99. ;          screen.  The pixel at the specified location is given a specified
  100. ;          color, overwriting the old color
  101. ;
  102. ; INPUT:  X-coordinate (0-619) of the point is in SI
  103. ;         Y-coordinate (0-199) of the point is in DI
  104. ;         COLOR (0-3) is in DX
  105. ; OUTPUT: Just to the screen.
  106. ;
  107. ; REGISTERS USED: No registers are modified.  SI, DI, and DX are used
  108. ;                 for input.
  109. ; SEGMENTS REFERENCED: Upon entry ES must point to the screen RAM at B8000h,
  110. ;                      and DS must pint to a data segment containing the
  111. ;                      following look-up table of ratated color masks:
  112. ;                      ctable  dw      0003Fh, 0403Fh, 0803Fh, 0C03Fh
  113. ;                              dw      000CFh, 010CFh, 020CFh, 030CFh
  114. ;                              dw      000F3h, 004F3h, 008F3h, 00CF3h
  115. ;                              dw      000FCh, 001FCh, 002FCh, 003FCh
  116. ; ROUTINES CALLED: None.
  117. ; SPECIAL NOTES: No bounds checking is performed.  The user must make sure
  118. ;                that the coordinates and the color are in their proper ranges.
  119. ;------------------------------------------------------------------------------
  120. setpt   proc    near
  121.  
  122.  
  123. ; Multiply y-coord by bytes per row and adjust for even/odd lines
  124.         mov     ax, di                  ; Get y-coord into low part
  125.         mov     ah, al                  ;  and into high part
  126.         and     ax, 01FEh               ; Mask off unwanted parts
  127.         sal     ax, 1                   ; Times 4
  128.         sal     ax, 1                   ; Times 8
  129.         sal     ax, 1                   ; Times 16
  130.         mov     bx, ax                  ; Gets into address
  131.         and     bh, 7                   ; without adjustment
  132.         sal     ax, 1                   ; Times 32
  133.         sal     ax, 1                   ; Times 64
  134.         add     bx, ax                  ; Address gets y-coord times 80
  135.  
  136. ; Add x-coord to address
  137.         mov     ax, si                  ; Get x-coordinate
  138.         sar     ax, 1                   ; Divide
  139.         sar     ax, 1                   ;  by 4
  140.         sar     ax, 1                   ;  by 8  (hires)
  141.         add     bx, ax                  ; Here is the address
  142.  
  143. ; Compute the rotated mask and color
  144.         and     si, 7                   ; Just pixel position into the index
  145. ;       sal     si, 1                   ; Index times 2
  146. ;       sal     si, 1                   ; Index times 4
  147. ;        add     si, dx                  ; 4*pixel position + color
  148. ;        sal     si, 1                   ; 8*pixel position + 2*color
  149. ;        mov     ax, ctable[si+bp]       ; Look up rotated color and mask
  150.         mov     ah, cctable[si+bp]      ; Loop up table for hires
  151.  
  152. ; Insert the color into the video byte
  153. ;        and     al, es:[bx]             ; Get old byte & remove old pixel
  154.         mov     al, es:[bx]             ; Get old byte (Hires)
  155.         or      al, ah                  ; Insert new color
  156.         mov     es:[bx],al              ; Put the byte back
  157.  
  158.         ret
  159.  
  160. setpt   endp
  161.  
  162. TrigFunc endp
  163. code     ends
  164.          end
  165.