home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / keyboard.lha / keyboard.s < prev   
Encoding:
Text File  |  1994-06-05  |  3.4 KB  |  200 lines

  1.     section    lard,code
  2.  
  3.     ;how to read RAWKEYS from a screen and de-code using current
  4.     ;KEYMAP
  5.  
  6.     ;by shagratt/LSD
  7.  
  8.     opt    d+
  9.     
  10. code:    IncDir    "DH0:Include/"
  11.     Include    Intuition/Intuition.I
  12.     Include    Intuition/Intuition_Lib.I
  13.     Include    Libraries/dos_LIb.i
  14.     Include    Libraries/Dos.i
  15.     Include    Exec/Exec_Lib.I
  16.     Include    Exec/Exec.I
  17.     Include    Graphics/Graphics_Lib.I
  18.  
  19.  
  20.     ;Include    Misc/EasyStart.i
  21.  
  22.     Lea    DosName,A1
  23.     Moveq    #0,D0
  24.     CALLEXEC    OpenLibrary
  25.     Move.l     D0,_DOSBase
  26.     Beq    Error
  27.  
  28.     Lea    GFXName,A1
  29.     Moveq    #0,D0
  30.     CALLEXEC    OpenLibrary
  31.     Move.l     D0,_GFXBase
  32.     Beq    Error
  33.  
  34.     Lea    IntName,A1
  35.     Moveq    #0,D0
  36.     CALLEXEC    OpenLibrary
  37.     Move.l    D0,_IntuitionBase
  38.     Beq    Error
  39.  
  40.     *-----------------------------------------------*
  41.  
  42.     move.l    #0,a1
  43.     CALLEXEC    FindTask
  44.  
  45.     lea    reply_port,a1
  46.     move.l    d0,MP_SIGTASK(a1)
  47.     CALLEXEC    AddPort
  48.         
  49.     lea    IO_port,a1
  50.     move.l    #-1,d0
  51.     move.l    #0,d1
  52.     lea    console_dev,a0
  53.     CALLEXEC    OpenDevice
  54.     cmp.l    #0,d0
  55.     bne    Quit
  56.     
  57.     lea    IO_port,a0
  58.     move.l    IO_DEVICE(a0),d0
  59.     move.l    d0,ConsoleDevice
  60.  
  61.     *-----------------------------------------------*
  62.  
  63.     Lea    MyWindow,a0
  64.     CALLINT    OpenWindow
  65.     Move.l    D0,_MyWinBase
  66.     Beq    CloseInt
  67.     Move.l    D0,A0
  68.     Move.l    wd_RPort(A0),_MyWinRPort
  69.     Move.l    wd_UserPort(a0),_MyWinUserPort
  70.  
  71.     *-----------------------------------------------*
  72.  
  73. WaitLoop    Move.l    _MyWinUserPort,A0
  74.     CALLEXEC    WaitPort
  75.     Move.l    _MyWinUserPort,A0
  76.     CALLEXEC    GetMsg
  77.     
  78.     Move.l    D0,A1
  79.     Move.l    im_Class(A1),D2    ;D2=IDCMP Flags Directly
  80.     
  81.     Cmp.l    #RAWKEY,D2
  82.     bne    .next
  83.  
  84.     Movem.l    D0-D7/A0-A6,-(A7)    
  85.     
  86.     lea    Event,a0
  87.     move.b    #IECLASS_RAWKEY,ie_Class(a0)
  88.     move.w    im_Code(a1),ie_Code(a0)
  89.     move.w    im_Qualifier(a1),ie_Qualifier(a0)
  90.     move.l    im_IAddress,ie_EventAddress(a0)
  91.  
  92.     lea    ConBuff,a1
  93.  
  94.     move.l    #15,d1
  95.     move.l    #0,a2
  96.     move.l    ConsoleDevice,a6
  97.     jsr    -48(a6)
  98.     cmp.l    #0,d0
  99.     beq    .nokeys
  100.  
  101.     lea    Ascii,a0
  102.     lea    ConBuff,a1
  103. .copy    move.b    (a1),(a0)+
  104.     move.b    #0,(a1)+
  105.     cmp.b    #0,(a1)
  106.     bne    .copy
  107.  
  108.     move.w    $dff006,$dff180
  109.  
  110. .nokeys    Movem.l    (a7)+,D0-D7/A0-A6
  111.     
  112. .next    Move.l    D0,A1
  113.     Move.l    im_Class(A1),D2    ;D2=IDCMP Flags Directly
  114.     Move.w    im_Code(A1),D3    ;D3=Data ie key why class=Rawkey
  115.     Move.w    im_Qualifier(A1),D4    ;D4=things like CTRL SHIFT
  116.     Move.w    im_MouseX(a1),D5    ;D5=MouseX Coordinate
  117.     Move.w    im_MouseY(a1),D6    ;D5=MouseY Coordinate
  118.     Move.l    im_IAddress(A1),D7    ;D7=Addres of Intuition Obj ie Gadget
  119.     Movem.l    D0-D7/A0-A6,-(A7)    
  120.     CALLEXEC    ReplyMsg
  121.     Movem.l    (a7)+,D0-D7/A0-A6
  122.  
  123.     Cmp.l    #CLOSEWINDOW,D2
  124.     bne    WaitLoop
  125.  
  126. Exit    Move.l    _MyWinBase,A0
  127.     CALLINT    CloseWindow
  128.  
  129. Quit    lea    reply_port,a1
  130.     CALLEXEC    RemPort
  131.     
  132.     lea    IO_port,a1
  133.     CALLEXEC    CloseDevice
  134.  
  135.  
  136. CloseInt    Move.l    _IntuitionBase,A1
  137.     CALLEXEC    CloseLibrary
  138.  
  139.     Move.l    _DOSBase,A1
  140.     CALLEXEC    CloseLibrary
  141.  
  142.     Move.l    _GFXBase,A1
  143.     CALLEXEC    CloseLibrary
  144.  
  145.     *-------------------------------*
  146.  
  147. Error    Moveq    #0,D0
  148.     Rts
  149.  
  150.     *-------------------------------*
  151.  
  152.  
  153. _MyScrBase        Dc.l    0
  154. _MyWinBase        Dc.l    0
  155. _MyWinRPort        Dc.l    0
  156. _MyWinUserPort    Dc.l    0
  157. _MyWinVPort        Dc.l    0
  158.  
  159. IO_port:        dcb.l    20,0
  160. reply_port:        dcb.l    8,0
  161. ConsoleDevice:    dc.l    0
  162.  
  163. ConBuff:        ds.b    16
  164. Event:        ds.b    16
  165. Ascii:        dc.l    0,0,0
  166.  
  167. console_dev        dc.b    "console.device",0
  168.  
  169. _IntuitionBase    Dc.l    0
  170. _DOSBase        Dc.l    0
  171. _GFXBase        dc.l    0
  172. IntName        INTNAME
  173. DosName        DOSNAME
  174. GFXName        GRAFNAME
  175.         even
  176.  
  177. **************************************************
  178.  
  179. MyWindow:    dc.w    0,0
  180.     dc.w    640,200
  181.     dc.b    0,1
  182.     dc.l    CLOSEWINDOW+RAWKEY
  183.     dc.l    WINDOWSIZING+WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+ACTIVATE+RMBTRAP+NOCAREREFRESH
  184.     dc.l    0
  185.     dc.l    0
  186.     dc.l    NewWindowName1
  187.     dc.l    0
  188.     dc.l    0
  189.     dc.w    5,5
  190.     dc.w    -1,-1
  191.     dc.w    WBENCHSCREEN
  192. NewWindowName1:
  193.     dc.b    'Your new window',0
  194.     cnop 0,2
  195.  
  196.  
  197. ; end of PowerWindows source generation
  198.     
  199.  
  200.