home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / decus / RB140 / grlib03a.arj / MARKER.ASM < prev    next >
Assembly Source File  |  1988-12-08  |  14KB  |  404 lines

  1. PAGE ,132
  2. TITLE MARKER.ASM
  3.  
  4. ;UPDATE HISTORY
  5. ;==============
  6. ;
  7. ; 10 sep 1984  FT1a  Fix bug in st_locator - getkey lost SI/DI
  8. ;                       - return character lost
  9. ; 14 sep 1984  FT1a  Allow Function keys to be passed back as well
  10. ;             as characters in rq_locator, st_locator.
  11. ;                    Arrow keys & SEL keys are still trapped out in 
  12. ;             rq_locator cos they're used.
  13. ; 15 nov 1984         Convert to C86 V2.2
  14. ;  4 nov 1984 2.00.2 fix bug - pass function key bit back in rq-locator
  15.  
  16. ; Special key defines
  17. ; ===================
  18. SEL    equ    118h        ;Select Key        [10-sep-84]
  19. UP    equ    11Bh        ;Up Arrow Key        [10-sep-84]
  20. LEFT    equ    11Ch        ;Left Arrow Key        [10-sep-84]
  21. DOWN    equ    11Dh        ;Down Arrow Key        [10-sep-84]
  22. RIGHT    equ    11Eh        ;Right Arrow Key    [10-sep-84]
  23.  
  24.     include asmc.h
  25.  
  26.     SEGEND    CODE
  27.  
  28.     SEGDEF    DATA
  29.  
  30. EXTRN    l_type:BYTE, m_col:BYTE, gbmod:BYTE, m_type:BYTE
  31. EXTRN    m_tab:BYTE, x_start:WORD, x_stop:WORD, m_sca:BYTE, ws_wmo:BYTE
  32. EXTRN    y_start:WORD, ymax:WORD, xmax:WORD
  33.  
  34. Lmmul     DW      1
  35. Lmx       DW      0
  36. Lmy       DW      0
  37. fkey_flag DW      0    ;arrow key pressed        [10-sep-84]
  38.  
  39.     SEGEND    DATA
  40.  
  41.     SEGDEF    CODE
  42.  
  43. PUBLIC    polymark, rq_locator, st_locator
  44.  
  45.     IF    @bigmodel
  46. EXTRN    gdc_nb:FAR, chk_col:FAR, a_mode:FAR, line:FAR, a_wmode:FAR
  47. EXTRN    getkey:FAR, conout:FAR, a_patrn:FAR, eseg_sav:FAR
  48.     ELSE
  49. EXTRN    gdc_nb:NEAR, chk_col:NEAR, a_mode:NEAR, line:NEAR, a_wmode:NEAR
  50. EXTRN    getkey:NEAR, conout:NEAR, a_patrn:NEAR, eseg_sav:NEAR
  51.     ENDIF
  52.  
  53. ;************************************************************************
  54. ;*                                                                      *
  55. ;*      F U N C T I O N     polymark(count, array)                     *
  56. ;*                          int count, *array;                          *
  57. ;*                                                                      *
  58. ;*      entry:            8[bp] number of markers to show               *
  59. ;*                       10[bp] pointer to array of 'xy' points at      *
  60. ;*                               which to place markers.                *
  61. ;*                                                                      *
  62. ;************************************************************************
  63. ;The x,y coordinate information is represented by 3 bit 2's 
  64. ;complement numbers in the range of +-3 x, +-3 y. end of character
  65. ;is represented by bit 8 being set on the last vector byte.
  66. ;
  67. ;       bit     7 6 5 4 3 2 1 0 
  68. ;               |   |   | |   | 
  69. ;               |    \ /   \ /  
  70. ;              end    x     y   
  71.  
  72.  
  73. Lsho_mark PROC  NEAR
  74.         mov     al,BYTE PTR m_type      ;get marker type and use to
  75.         and     al,0FH            ;point into marker table.
  76.         xor     ah,ah            ;clear highDB.
  77.         mov     cl,4            ;table length.
  78.         shl     ax,cl
  79.         lea     si, m_tab
  80.         add     si,ax            ;point si to marker table.
  81. L1:     lea     di, x_start
  82.         call    Lvect            ;find start of line.
  83.         lea     di, x_stop
  84.         call    Lvect            ;find end of line.
  85.         lea     ax, x_start
  86.         push    ax
  87.         call    line            ;draw stroke.
  88.         add     sp,2
  89.         test    BYTE PTR -1[si],80H    ;test for end of line bit.
  90.         jz      L1
  91.         ret
  92. Lsho_mark ENDP
  93.  
  94. Lvect   PROC    NEAR
  95.         mov     ax,-2[bp]        ;get x value.
  96.         mov     [di],ax
  97.         mov     ax,-4[bp]        ;get y value.
  98.         mov     2[di],ax
  99.         lodsb                ;get stroke info
  100.         mov     bx,ax
  101.         and     ax,7            ;mask to y value
  102.         test    al,4            ;negative ?
  103.         jz      L2
  104.         or      ax,0FFF8H        ;sign extend
  105. L2:     mov     cl,BYTE PTR m_sca
  106.         xor     ch,ch
  107.         push    cx
  108.         imul    cx            ;multiply by scale value
  109.     mov    cx,2
  110.     idiv    cx
  111. ;    shr    ax,1            ;and divide by two.
  112.         add     2[di],ax        ;subtract to y offset 
  113.         and     bx,38H            ;mask to x value
  114.         shr     bx,1            ;shift to 3 lsb
  115.         shr     bx,1
  116.         shr     bx,1
  117.         test    bl,4            ;negative ?
  118.         jz      L3
  119.         or      bx,0FFF8H        ;sign extend
  120. L3:     mov     ax,bx
  121.         pop     cx            ;recover scale
  122.         imul    cx            ;multiply by scale value
  123.     mov    cx,2
  124.     idiv    cx
  125. ;       test    BYTE PTR gbmod,1    ;are we in high res ?
  126. ;       jnz     L3a            ;skip if we are.
  127. ;    shr    ax,1            ;and divide by two.
  128. L3a:    add     [di],ax            ;add to x offset 
  129.         ret
  130. Lvect   ENDP
  131. ;
  132.     PROCDEF    polymark
  133.         push    si
  134.         push    di
  135.         push    bp
  136.         mov     bp,sp
  137.         sub     sp,4      ;reserve space for xad offset -2[bp]} & yad {-4[bp]}
  138.  
  139.         mov     ax,cs:WORD PTR eseg_sav
  140.         mov     es,ax
  141.  
  142.         call    gdc_nb
  143.         mov     al,BYTE PTR l_type    ;get and save old line type.
  144.         push    ax
  145.         mov     BYTE PTR l_type,00    ;set up line type for solid lines.
  146.         call    a_patrn            ;set pattern multiplier.
  147.         pop     ax                  ;restore old line type.
  148.         mov     BYTE PTR l_type,al
  149.         mov     al,BYTE PTR m_col    ;check for correct colour.
  150.         call    chk_col
  151.         test    BYTE PTR gbmod,2    ;are we in vector mode ?
  152.         jnz     L0a
  153.         or      BYTE PTR gbmod,12H
  154.         call    a_mode
  155. L0a:    mov     cx,8[bp]        ;get number of markers.
  156.         mov     si,10[bp]        ;point to marker array elements.
  157.         cld
  158. Ldo_marks:
  159.         lodsw                ;get initial x
  160.         mov     -2[bp],ax        ;save it.
  161.         lodsw                ;get initial y
  162.         mov     -4[bp],ax        ;save it.
  163.         push    cx
  164.         push    si
  165.         call    Lsho_mark        ;display it
  166.         pop     si
  167.         pop     cx
  168.         loop    Ldo_marks        ;loop until done
  169.  
  170.         mov     sp,bp            ;restore stack position
  171.         pop     bp
  172.         pop     di
  173.         pop     si
  174.         ret
  175.     PROCEND    polymark
  176.  
  177.  
  178. ;**************************************************************************
  179. ;*                                                                        *
  180. ;*  F U N C T I O N  rq_locator(dev, x_strt, y_strt, char, x_end, y_end) *
  181. ;*                   int  dev, x_strt, y_strt;                            *
  182. ;*                   int  *char;                                          *
  183. ;*                   int  *x_end, *y_end;                                 *
  184. ;*                                                                        *
  185. ;*      purpose:        Place a moveable cross_hair on the display at     *
  186. ;*                      [x_strt, y_strt] and move it around with the      *
  187. ;*                      arrow keys until a character is typed or a        *
  188. ;*                      Function key pressed (not arrow or SEL).          *
  189. ;*                      The keystroke and the final 'xy' positions are    *
  190. ;*                      returned in 'char', 'x_end' & 'y_end'.            *
  191. ;*                      The cross_hair is then removed.                   *
  192. ;*                      The cross_hair is assumed to be marker type 1     *
  193. ;*                                                                        *
  194. ;*      entry:  8[bp]  included for GSX86MWC.OLB compatibility.           *
  195. ;*              10[bp] starting 'x' co-ordinate                           *
  196. ;*              12[bp] starting 'y' co-ordinate                           *
  197. ;*              14[bp] pointer to returned character                      *
  198. ;*              16[bp] pointer to ending 'x' co-ordinate                  *
  199. ;*              18[bp] pointer to ending 'y' co-ordinate                  *
  200. ;*                                                                        *
  201. ;**************************************************************************
  202. Lmsh_m    PROC    NEAR
  203.     mov     ax,[si]             ;show the marker at 'xy' end.
  204.         mov     WORD PTR x_start,ax
  205.         mov     ax,[di]
  206.         mov     WORD PTR y_start,ax
  207.         lea     ax, x_start
  208.         push    ax
  209.         mov     ax,1
  210.         push    ax
  211.         call    polymark
  212.         add     sp,4
  213.         ret
  214. Lmsh_m    ENDP
  215.  
  216.     PROCDEF    rq_locator
  217.         push    si
  218.         push    di
  219.         push    bp
  220.         mov     bp,sp
  221.         sub     sp,8                    ;make room to save the old marker info.
  222.  
  223.         mov     ax,cs:WORD PTR eseg_sav
  224.         mov     es,ax
  225.  
  226.         mov     al,BYTE PTR m_type      ;save all the marker info on the stack.
  227.         mov     -2[bp],ax
  228.         mov     al,BYTE PTR m_col
  229.         mov     -4[bp],ax
  230.         mov     al,BYTE PTR m_sca
  231.         mov     -6[bp],ax
  232.         mov     al,BYTE PTR ws_wmo
  233.         mov     -8[bp],ax
  234.  
  235.         mov     BYTE PTR m_type,1       ; '+'
  236.         mov     BYTE PTR m_col,3
  237.         mov     BYTE PTR m_sca,3
  238.         mov     BYTE PTR ws_wmo,1       ;COMPLIMENT mode.
  239.  
  240.         mov     ax,10[bp]       ;get starting 'x' and copy to 'x_end' & 'Lmx'.
  241.         mov     di,16[bp]
  242.         mov     si,di
  243.         mov     Lmx,ax
  244.         stosw
  245.  
  246.         mov     ax,12[bp]       ;get starting 'y' and copy to 'y_end' & 'Lmy'.
  247.         mov     di,18[bp]
  248.         mov     [di],ax
  249.         mov     Lmy,ax
  250.  
  251.         call    gdc_nb
  252.         call    a_wmode
  253.  
  254. Lm0:    call    Lmsh_m              ;show marker at 'x_end', 'y_end'.
  255. Lm1:    lea     ax, Lmy
  256.         push    ax
  257.         lea     ax, Lmx
  258.         push    ax
  259.         call    st_locator
  260.         add     sp,4
  261.         or      ax,ax
  262.         jz      Lm1
  263.         test    fkey_flag,100H ;was an arrow key pressed ?  [10-sep-84]
  264.         jnz     Lm2             ;yup                [14-sep-84]
  265.         mov     bx,14[bp]       ;get character pointer and save character.
  266.         mov     WORD PTR [bx],ax    ;allow function bit return ********
  267.         call    Lmsh_m              ;remove marker and exit.
  268.         jmp     Lmexit
  269.  
  270. Lm2:    call    Lmsh_m              ;remove old marker.
  271.         mov     ax,Lmx              ;update x_end.
  272.         mov     [si],ax
  273.         mov     ax,Lmy              ;update y_end.
  274.         mov     [di],ax
  275.         jmp     Lm0
  276.  
  277.  
  278. Lmexit: mov     ax,-8[bp]
  279.         mov     BYTE PTR ws_wmo,al
  280.         call    a_wmode
  281.         mov     ax,-6[bp]       ;restore all the marker info from the stack.
  282.         mov     BYTE PTR m_sca,al
  283.         mov     ax,-4[bp]
  284.         mov     BYTE PTR m_col,al
  285.         mov     ax,-2[bp]
  286.         mov     BYTE PTR m_type,al
  287.  
  288.         mov     sp,bp
  289.         pop     bp
  290.         pop     di
  291.         pop     si
  292.         ret
  293.  
  294.     PROCEND    rq_locator
  295.  
  296.  
  297. ;************************************************************************
  298. ;*                                                                      *
  299. ;*      F U N C T I O N     st_locator(x, y)                            *
  300. ;*                          int  *x, *y;                                *
  301. ;*                                                                      *
  302. ;*      purpose:        Updates 'x' &;or 'y' if an arrow key was        *
  303. ;*                      pressed. Updates Lmul if SELECT was pressed.    *
  304. ;*                      Returns '\0' in AX if SELECT or no character    *
  305. ;*                      was typed, otherwise, returns the character.    *
  306. ;*                                                                      *
  307. ;************************************************************************
  308.  
  309.     PROCDEF    st_locator
  310.         push    si
  311.         push    di
  312.         push    bp
  313.         mov     bp,sp
  314.  
  315.         call    getkey            ;get keystroke (if any)    [10-sep-84]
  316.  
  317.         mov     di,10[bp]        ;addr of y coordinate
  318.         mov     si,8[bp]        ;addr of x coordinate
  319.         mov     bx,cs:WORD PTR eseg_sav
  320.         mov     es,bx
  321.     push    ax        ;save keystroke value for exit    [10-sep-84]
  322.         or      ax,ax            ;was keystoke entered
  323.         jnz     Ls1            ;yup
  324.         jmp     Lsexit
  325.  
  326. Ls1:    mov     fkey_flag,ax     ;save in case function key    [10-sep-84]
  327.     and    fkey_flag,100H
  328.     test    fkey_flag,100H   ;q. function key
  329.     jnz    ls2              ;yup
  330.     jmp    lsexit1
  331.  
  332. Ls2:    cmp     ax,SEL           ;SELECT ?        [10-sep-84]
  333.         jnz     Ls4
  334.         mov     ax,Lmmul
  335.         dec     ax
  336.         jz      Ls3
  337.         mov     Lmmul,1
  338.         jmp     Lsexit
  339. Ls3:    mov     Lmmul,10
  340.         jmp     Lsexit
  341.  
  342. Ls4:    cmp     ax,UP            ;UP ?            [10-sep-84]
  343.         jnz     Ls5
  344.         mov     ax,[di]
  345.         add     ax,Lmmul
  346.         cmp     WORD PTR ymax,ax
  347.         jns     Ls4a
  348.         mov     ax,WORD PTR ymax
  349. Ls4a:   mov     [di],ax
  350.         jmp     Lsexit1
  351.  
  352. Ls5:    cmp     ax,DOWN          ;DOWN ?        [10-sep-84]
  353.         jnz     Ls6
  354.         mov     ax,[di]
  355.         sub     ax,Lmmul
  356.         or      ax,ax
  357.         jns     Ls5a
  358.         xor     ax,ax
  359. Ls5a:   mov     [di],ax
  360.         inc     ax
  361.         jmp     Lsexit1
  362.  
  363. Ls6:    cmp     ax,LEFT            ;LEFT ?        [10-sep-84]
  364.         jnz     Ls7
  365.         mov     ax,[si]
  366.         sub     ax,Lmmul
  367.         or      ax,ax
  368.         jns     Ls6a
  369.         xor     ax,ax
  370. Ls6a:   mov     [si],ax
  371.         inc     ax
  372.         jmp     Lsexit1
  373.  
  374. Ls7:    cmp     ax,RIGHT           ;RIGHT ?        [10-sep-84]
  375.         jnz     Ls8
  376.         mov     ax,[si]
  377.         add     ax,Lmmul
  378.         cmp     WORD PTR xmax,ax
  379.         jns     Ls7a
  380.         mov     ax,WORD PTR xmax
  381. Ls7a:   mov     [si],ax
  382.         jmp     Lsexit1
  383.  
  384. Ls8:    mov     fkey_flag,0    ;unknown function key pressed    [14-sep-84]
  385.     jmp    Lsexit1        ;turn off flag & continue    [14-sep-84]
  386.  
  387. Lsexit: pop    ax        ;retrieve keystroke ...        [10-sep-84]
  388.         xor     ax,ax        ;.. then lose it        [10-sep-84]
  389.         mov     fkey_flag,0
  390.     jmp    Lsexit2        ;continue            [10-sep-84]
  391.  
  392. Lsexit1:
  393.         pop    ax        ;retrieve keystroke        [10-sep-84]
  394. Lsexit2:            ;                [10-sep-84]
  395.         pop     bp
  396.         pop     di
  397.         pop     si
  398.         ret
  399.     PROCEND    st_locator
  400.  
  401.     include    epilogue.h
  402.     END
  403. 
  404.