home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 July / VPR9707B.ISO / DRIVER / IODATA / GA360 / DISK2.EXE / SAMPLE / SUB.ASM < prev    next >
Assembly Source File  |  1992-02-01  |  3KB  |  153 lines

  1. ;--------------------------------------------------------------
  2. ;
  3. ;    sub.asm
  4. ;
  5. ;--------------------------------------------------------------
  6. ;
  7. ;
  8. DGROUP    GROUP    _DATA
  9.     assume    CS:_TEXT, DS:DGROUP
  10. ;
  11. _DATA    segment  word public 'DATA'
  12. ;
  13. _DATA    ends
  14. ;
  15. ;    引数
  16. X        equ    [bp + 6 + 0]
  17. Y        equ    [bp + 6 + 4]
  18. LEFT        equ    [bp + 6 + 8]
  19. RIGHT        equ    [bp + 6 + 12]
  20. ;
  21. ;
  22. _TEXT    segment    byte public 'CODE'
  23.     assume    CS:_TEXT
  24.  
  25.  
  26. public        _GetMouse
  27. ;----------------------------------------------------------------
  28. ;
  29. ;    マウス座標の収得
  30. ;
  31. ;    int    GetMouse(int *X, int *Y, int *LEFT, int *RIGHT)
  32. ;
  33. ;    entry
  34. ;        *X    水平座標を格納するアドレス
  35. ;        *Y     垂直座標を格納するアドレス
  36. ;        *LEFT    左ボタンの状態を格納するアドレス
  37. ;        *RIGHT    右ボタンの状態を格納するアドレス
  38. ;
  39. ;    return
  40. ;        0    
  41. ;
  42. ;------------------------------------------------------------------
  43. _GetMouse    proc    far
  44.         push    bp
  45.         mov    bp, sp
  46.         push    es
  47.         push    di
  48.  
  49.         mov    ax,03h        ; カーソルの位置
  50.         int    33h
  51.         les    di,LEFT        ; 左ボタンの状態
  52.         mov    es:[di],ax
  53.         les    di,RIGHT    ; 右ボタンの状態
  54.         mov    es:[di],bx
  55.         les    di,X        ; 水平位置
  56.         mov    es:[di],cx
  57.         les    di,Y        ; 垂直位置
  58.         mov    es:[di],dx
  59.         xor    ax,ax
  60.  
  61.         pop    di
  62.         pop    es
  63.         pop    bp
  64.         ret
  65.  
  66. _GetMouse    endp
  67.  
  68. ;-------------------------------------------------------------
  69. ;  マウスの初期化
  70. ;
  71. ;  int InitMouse()
  72. ;
  73. ; リタ-ン  0: 正常   -1:異常 
  74. ;-------------------------------------------------------------
  75. public        _InitMouse
  76.  
  77. _InitMouse    proc    far
  78.  
  79.         mov    ax,0        ; 環境チェック
  80.         int    33h
  81.         cmp    ax,-1
  82.         je    usems ;@f
  83.         mov    ax,-1
  84.         jmp    endmouse
  85.  
  86. usems:        mov    ax,10h        ; 移動範囲設定(水平)
  87.         mov    cx,0        ; min:0
  88.         mov    dx,1024-1    ; max:1023(0x3ff)
  89.         int    33h
  90.  
  91.         mov    ax,11h        ; 移動範囲設定(垂直)
  92.         mov    cx,0        ; min:0
  93.         mov    dx,768-1    ; max:767(0x2ff)
  94.         int    33h
  95.         xor    ax,ax
  96. endmouse:
  97.         ret
  98.  
  99. _InitMouse    endp
  100.  
  101.  
  102.  
  103. ;------------------------------------------------------------
  104. ;
  105. ;  垂直同期信号をカウントして時間待ちをする
  106. ;          20mSec x 引数
  107. ;
  108. ;   void VWait(int  time)
  109. ;
  110. ;------------------------------------------------------------
  111. public        _VWait
  112.  
  113.     assume    CS:_TEXT, DS:DGROUP
  114. ;
  115. ;
  116. ;    引数
  117. COUNT        equ    [bp + 6]
  118. ;
  119. _VWait    proc    far
  120.         push    bp
  121.         mov    bp, sp
  122.         push    es
  123.         push    ds
  124.         mov    ax,DGROUP
  125.         mov    ds,ax
  126.  
  127.         mov    cx,COUNT
  128. vwait_10:
  129. lop1:        in    al, 60h
  130.         jmp    short $+2
  131.         jmp    short $+2
  132.         jmp    short $+2
  133.         test    al, 20h
  134.         jz    lop1
  135. lop2:        in    al, 60h
  136.         jmp    short $+2
  137.         jmp    short $+2
  138.         jmp    short $+2
  139.         test    al, 20h
  140.         jnz    lop2
  141.         loop    vwait_10
  142.         xor    ax, ax
  143.  
  144.         pop    ds
  145.         pop    es
  146.         pop    bp
  147.         ret
  148. _VWait    endp
  149.  
  150. _TEXT        ends
  151.         end
  152.  
  153.