home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 230.lha / ConsoleMessageMonitor / Cmm.asm < prev    next >
Encoding:
Assembly Source File  |  1989-04-08  |  15.3 KB  |  566 lines

  1.      opt   l-,c+,d-         nolink,case dependant,debug off
  2. *********************
  3. * "CMM" Console Message Monitor Demo by Maurice St. Sauveur
  4. *    edited by JHH Lowengard
  5. *
  6. * This program has two purposes: 
  7. *
  8. *  To demonstrate the no-so-intuitive call to RawKeyConvert
  9. *  To provide a handy way to see the real bytes straight out of Intuition
  10. *    for Code, Class, Mouse position, Time etc. etc.
  11. *  (It also provides a pretty good demo of RawDoFormat)
  12. * One exits the program by pressing both Amiga Keys.
  13. *
  14. *  The window leaves ten pixels on the top of the screen so you can use 
  15. *  the screen's back-front gadgets and drag bar.
  16. *
  17. * This program is meant to assemble under Hisoft's GenAm and GenIm
  18. * assemblers. Your Assembler may require you to make some changes
  19. * or option changes. Inline EQU's help speed the assembly: no
  20. * ,include files are needed.
  21. *
  22. *
  23. * This program is copyright 1989 by Maurice St. Sauveur 
  24. * In theory, there is no part of this program which couldn't 
  25. * have been figured out by deep scrutiny of the relevant Rom Kernal
  26. * Guides, but in practice this is not true. 
  27. *
  28. * Maurice St. Sauveur is also working on on an integrated SMTE
  29. * single frame edit system including reader, generator, and
  30. * edit Decision List software. This system is available now,
  31. * but might need to be customized to your studio's needs.
  32. * For more information,
  33. * contact :
  34. *
  35. * SMPTE ExorCiser
  36. * Maurice St. Sauveur
  37. * 100 Henry St, Suite 1229
  38. * Brooklyn, N.Y. 11201
  39. * (718) 624-5000, x1229
  40. *
  41. **********************    library vector equates         
  42.                
  43. _LVOGetMsg          equ   -372
  44. _LVOReplyMsg        equ   -378
  45. _LVOWaitPort        equ    -384
  46. _LVOOpenLibrary     equ   -552
  47. _LVOCloseLibrary    equ   -414      
  48. _LVOClose           equ   -36
  49. _LVOWait            equ   -318
  50. _LVOOpenWindow      equ   -204
  51. _LVOCloseWindow     equ   -72
  52. _LVOOpenScreen      equ   -198
  53. _LVOCloseScreen     equ   -66
  54. _LVOMove            equ   -240
  55. _LVORectFill        equ   -306
  56. _LVOText            equ   -60
  57. _LVOSetAPen         equ   -342
  58.  
  59. _LVOSetBPen         equ   -348
  60. _LVOOpen            equ   -30
  61. _LVORead            equ   -42
  62. _LVOWrite           equ   -48
  63. _LVODraw            equ   -246
  64. _LVOSetRGB4         equ   -288
  65. _LVOViewPortAddress equ   -300
  66. _LVOOpenFont        equ   -72
  67. _LVOCloseFont       equ   -78
  68. _LVOSetFont         equ   -66
  69. _LVODisable         equ   -120
  70. _LVOEnable          equ   -126
  71. _LVOModifyIDCMP     equ   -150
  72. _LVORawKeyConvert   equ   -48
  73. _LVOOpenDevice      equ   -444
  74. _LVOCloseDevice     equ   -450
  75. _LVORawDoFmt        equ   -522
  76.  
  77. LIBRARY_VERSION     equ   31
  78.  
  79.  
  80. im_Class            equ   20
  81. im_SubClass         equ   22
  82. im_Code             equ   24
  83. im_Qualifier        equ   26
  84. im_Mousex           equ   32
  85. im_Mousey           equ   34
  86. nw_Screen           equ   $001e
  87. wd_UserPort         equ   $0056
  88.  
  89.  
  90. **********************    intuition equates
  91.       even
  92. REPORTMOUSE         equ       $0200
  93. MOUSEBUTTONS        equ       $00000008
  94. MOUSEMOVE           equ       $00000010
  95. MENUPICK            equ       $00000100
  96. CLOSEWINDOW         equ       $00000200
  97. RAWKEY              equ       $00000400   *
  98. WBENCHMESSAGE       equ       $00020000
  99. VANILLAKEY          equ       $00200000   *
  100. INTUITICKS          equ       $00400000
  101.  
  102. DISKREMOVED         equ       $10000
  103. DISKINSERTED        equ       $08000
  104. GIMMEZEROZERO       equ       $0400
  105. WINDOWSIZING        equ       $0001       *
  106. WINDOWDRAG          equ       $0002       *
  107. WINDOWDEPTH         equ       $0004       *
  108. WINDOWCLOSE         equ       $0008       *
  109. BACKDROP            equ       $0100       *
  110. BORDERLESS          equ       $0800       *      
  111. ACTIVATE            equ       $1000       *
  112. WINDOWACTIVE        equ       $2000
  113. NOCAREREFRESH       equ       $00020000   *
  114. WINDOWREFRESH       equ       $01000000
  115. WBENCHWINDOW        equ       $02000000
  116. WINDOWTICKED        equ       $04000000
  117. CUSTOMSCREEN        equ       $000f       *
  118. WBENCHSCREEN        equ       $0001
  119. TOPAZ_SIXTY         equ       9
  120. TOPAZ_EIGHTY        equ       8
  121.  
  122. idcmp1: equ    RAWKEY!CLOSEWINDOW!MOUSEBUTTONS!DISKINSERTED!DISKREMOVED!MOUSEMOVE
  123. idcmp2: equ    VANILLAKEY!CLOSEWINDOW
  124.  
  125. Wflags: equ    ACTIVATE
  126. Modes:  equ    $8000
  127.  
  128. **********************   external ref library
  129.  
  130. AbsExecBase        equ      $4
  131. MODE_NEWFILE       equ      1006
  132. MODE_READWRITE     equ      1004
  133. *
  134. ************************** START OF PROGRAM *******************
  135. *
  136. * ----------------- open intuition library
  137.           even
  138. start:    move.l    a7,savreturn
  139.           movea.l   #IntuitionName,a1
  140.           move.l    #LIBRARY_VERSION,d0
  141.           move.l    AbsExecBase,a6
  142.           jsr       _LVOOpenLibrary(a6)
  143.           move.l    d0,IntBase
  144.           beq       cls_ilib
  145.  
  146. *  -------------------  open gfx libary
  147.  
  148.           movea.l   #GfxName,a1
  149.           move.l    #LIBRARY_VERSION,d0
  150.        
  151.           move.l    AbsExecBase,a6
  152.           jsr       _LVOOpenLibrary(a6)
  153.           move.l    d0,GfBase
  154.           beq       cls_glib
  155.  
  156. *  ---------------------- open screen
  157. scr:      
  158.           movea.l   #NewCustScreen,a0
  159.           movea.l   IntBase,a6
  160.           jsr       _LVOOpenScreen(a6)
  161.           move.l    d0,CustScr
  162.           beq       cls_sc
  163.  
  164. *  -----------------    open window
  165.       
  166.           movea.l   #NewWdw,a0
  167.           move.l    CustScr,nw_Screen(a0)
  168.           movea.l   IntBase,a6
  169.           jsr       _LVOOpenWindow(a6)
  170.           move.l    d0,Wdw
  171.           beq       cls_wdw
  172.  
  173. * -------------------- get rastport
  174.  
  175.           move.l    d0,a6
  176.           move.l    50(a6),Rp
  177.  
  178. * -------------------- get viewport
  179.  
  180. vp2:      move.l    d0,a0
  181.           movea.l   IntBase,a6
  182.           jsr       _LVOViewPortAddress(a6) 
  183.           move.l    d0,Vp
  184.  
  185. *  ----------------- open console libary
  186. * to use RawKeyConvert(), we need a base which comes from
  187. * a special call to the Console Device.
  188. *
  189. oc:
  190.           lea       CName,a0
  191.           move.l    #-1,d0
  192.           lea       IoRequest,a1
  193.           move.l    Wdw,(a1)
  194.           move.l    #0,d1
  195.           movea.l   AbsExecBase,a6
  196.           jsr       _LVOOpenDevice(a6)
  197.           move.l    20(a1),ConDbase
  198.           move.l    ConDbase,d0
  199.  
  200. * ------------ get rawkey from intuition message
  201. * Waiting for the message is less rude than busy polling
  202. *
  203. wfm:      movea.l   Wdw,a0
  204.           movea.l   wd_UserPort(a0),a0
  205.           movea.l   AbsExecBase,a6
  206.           jsr       _LVOWaitPort(a6)        * get any mail?
  207. * yep
  208.           movea.l   Wdw,a0
  209.           movea.l   wd_UserPort(a0),a0
  210.           movea.l   AbsExecBase,a6
  211.           jsr       _LVOGetMsg(a6)        * get message ptr
  212.           move.l    d0,newmessage
  213.           beq       wfm            * shouldn't be null, but who knows?
  214.  
  215. * ----------------------------------
  216.  
  217.           movea.l   d0,a0
  218.           lea       im_message,a1         * save message before replying
  219.           move.w    #11,d4
  220. immover:  move.l    (a0)+,(a1)+
  221.           dbra      d4,immover
  222.  
  223. * ----------------------------------
  224.  
  225.           movea.l   newmessage,a1
  226.           move.l    a1,mparms
  227.           move.l    AbsExecBase,a6        * reply
  228.           jsr       _LVOReplyMsg(a6)
  229.  
  230. * ----------------------------------
  231. * We're only interested in RAWKEY events...
  232.  
  233. nm:
  234.           move.l    im_class,d7
  235.           subi.w    #RAWKEY,d7
  236.           beq       gkey
  237.  
  238.           jmp       ddata
  239.  
  240. * ----------------------------------
  241.  
  242. gkey:     movea.l   newmessage,a0
  243.           move.w    im_code,d7             * check if rawkey 
  244.           move.w    d7,ie.code
  245.           move.w    im_qualifier,ie.qualifier
  246.  
  247. * comment out these two lines to see key-up events as well as key-downs
  248.           cmp.w     #$006f,im_code
  249.           bge       wfm
  250.  
  251. * ----------   convert rawkey
  252. cr:
  253.           lea       ie.event,a0
  254.           lea       ConKey,a1
  255.           clr.l     (a1)
  256.           
  257.           move.l    #0,a2
  258.           move.l    #4,d1
  259.  
  260. * note how the "base" for RawKeyConvert was obtained from the
  261. * Console Device - a rather peculiar method 
  262.  
  263.           movea.l   ConDbase,a6
  264.           jsr       _LVORawKeyConvert(a6)
  265.           move.b    ConKey,d1
  266.           move.l    ConKey,im_conkey
  267.           move.b    d0,noc 
  268.           jmp       ddata                  * go to display routine
  269.  
  270. * ------------------ test code
  271. * this qualifier detects the "Amiga-Amiga" combination.
  272. cr2:                         
  273.           cmpi.w    #$80c0,im_qualifier
  274.           beq       close               * press both Amiga to close
  275.  
  276. kc:       jmp       wfm
  277.          
  278. * ------------------ close everything
  279.  
  280. close:    clr       d1
  281.  
  282.  
  283. cls_wdw:  movea.l   Wdw,a0
  284.           movea.l   IntBase,a6
  285.           jsr       _LVOCloseWindow(a6)
  286.  
  287. cls_sc:   move.l    CustScr,a0
  288.           movea.l   IntBase,a6
  289.           jsr       _LVOCloseScreen(a6)
  290.  
  291. cls_glib: movea.l   GfBase,a1
  292.           movea.l   AbsExecBase,a6
  293.           jsr       _LVOCloseLibrary(a6)
  294.  
  295. cls_dev:  lea       IoRequest,a1
  296.           movea.l   AbsExecBase,a6
  297.           jsr       _LVOCloseDevice(a6)
  298.    
  299. cls_ilib: movea.l   IntBase,a1
  300.           movea.l   AbsExecBase,a6
  301.           jsr       _LVOCloseLibrary(a6)
  302.           move.l    savreturn,a7   
  303.  
  304. last:     clr.l     d0
  305.           rts
  306.  
  307. * -------------------- DATA ------------------
  308.  
  309.                even
  310. dosname:       dc.b  "dos.library",0
  311.                cnop  0,2
  312. IntuitionName: dc.b  "intuition.library",0
  313.                cnop  0,2
  314. GfxName:       dc.b  "graphics.library",0
  315.                cnop  0,2
  316. CName:         dc.b  "console.device",0
  317.                cnop  0,2
  318.  
  319. * -------------- IoRequest structure
  320.  
  321.                even
  322. IoRequest:     ds.b    20
  323. device:        ds.b    4
  324. unit:          ds.b    4              
  325. command:       ds.b    2              
  326. flags:         ds.b    1              
  327. error:         ds.b    1              
  328. actual:        ds.b    4              
  329. length:        ds.b    4              
  330. data:          ds.b    4              
  331. offset:        ds.b    4              
  332.  
  333. * ------------ input event structure
  334.  
  335.                even
  336. ie.event:      dc.l    0
  337. ie.class:      dc.b    1
  338. ie.subclass:   dc.b    0
  339. ie.code:       ds.w    1
  340. ie.qualifier:  ds.w    1
  341.  
  342. * ------------- intuition message and rawdofmt parameters
  343.  
  344.                even
  345. mparms         ds.l    1
  346. im_message:    ds.l    1
  347.                ds.l    1
  348.                ds.l    1
  349.                ds.l    1
  350.                ds.l    1
  351. im_class:      ds.l    1
  352. im_code:       ds.w    1
  353. im_qualifier:  ds.w    1
  354. iaddress:      ds.l    1
  355. im_mousex:     ds.w    1
  356. im_mousey:     ds.w    1
  357. seconds:       ds.l    1
  358. micros:        ds.l    1
  359.                ds.l    1
  360. im_char:       dc.l    ConKey
  361. im_conkey:     ds.l    1
  362.  
  363. * --------------------- Window Structure
  364.  
  365.                     even
  366. NewWdw:             dc.w     0
  367.                     dc.w     10
  368.                     dc.w     640
  369.                     dc.w     190
  370.                     dc.b     2
  371.                     dc.b     1
  372.                     dc.l     idcmp1
  373.                     dc.l     Wflags
  374.                     dc.l     0
  375.                     dc.l     0
  376.                     dc.l     Titw
  377.                     dc.l     0
  378.                     dc.l     0
  379.                     dc.w     0
  380.                     dc.w     0
  381.                     dc.w     0
  382.                     dc.w     0
  383.                     dc.w     CUSTOMSCREEN
  384.          
  385. NewCustScreen:
  386.                     dc.w     0
  387.                     dc.w     0
  388.                     dc.w     640
  389.                     dc.w     200
  390.                     dc.w     2
  391.                     dc.b     0
  392.                     dc.b     1
  393.                     dc.w     Modes
  394.                     dc.w     CUSTOMSCREEN
  395.                     dc.l     0
  396.                     dc.l     Tits
  397.                     dc.l     0
  398.                     dc.l     0
  399.  
  400.  
  401.             even
  402. Titw:       dc.b    " 100 Henry St, Suite 1229, Brooklyn NY 11201   "
  403.         dc.b    " (718) 624-5000 x1229",0
  404. Tits:       dc.b    " Console Message Monitor by Maurice St. Sauveur"
  405.         dc.b    "  Use Amiga-Amiga to Exit",0
  406.  
  407.  
  408. * ------------ regs -------------
  409.  
  410.             even
  411. newmessage: ds.l  1
  412. IntBase:    ds.l  1
  413. dosbase:    ds.l  1
  414. execbase:   ds.l  1
  415. ConDbase:   ds.l  1
  416. GfBase:     ds.l  1
  417. Wdw:        ds.l  1
  418. CustScr:    ds.l  1
  419. Rp:         ds.l  1
  420. Vp:         ds.l  1
  421. savreturn   ds.l  1
  422. fkey:       ds.l  1
  423. code:       ds.w  1
  424. class:      ds.w  1
  425. sptr:       ds.w  1
  426.  
  427.             even
  428. ConKey:     ds.b  4
  429.             dc.b  0
  430. noc:        dc.b  1
  431. Output:     ds.b  500
  432.  
  433. * -------------- rawdofmt data routines
  434.  
  435.           even
  436. Mstring:  dc.b 'GetMsg ptr    $%08lx',$b6
  437.           dc.b '-----------------------',$b6
  438.           dc.b 'ExecMessage   $%08lx',$b6
  439.           dc.b '              $%08lx',$b6
  440.           dc.b '              $%08lx',$b6
  441.           dc.b '              $%08lx',$b6
  442.           dc.b '              $%08lx',$b6
  443.           dc.b 'im_Class      $%08lx',$b6
  444.           dc.b 'im_Code       $%04x',$b6
  445.           dc.b 'im_Qualifier  $%04x',$b6
  446.           dc.b 'Aptr Iaddress $%08lx',$b6
  447.           dc.b 'im_Mousex     $%04x',$b6
  448.           dc.b 'im_Mousey     $%04x',$b6
  449.           dc.b 'seconds       $%08lx',$b6
  450.           dc.b 'micros        $%08lx',$b6
  451.           dc.b 'window ptr    $%08lx',$b6      ,$b6
  452.           dc.b '-----------------------',$b6
  453.           dc.b 'ConKey char    %s    ',$b6
  454.           dc.b 'ConKey hex    $%08lx',$b6,0  
  455.  
  456. * ------------------ draw data
  457.           even
  458.  
  459. * Use RawDoFmt to convert internal to (mostly) printable
  460.  
  461. ddata:
  462.           lea       Mstring,a0
  463.           lea       mparms,a1
  464.           lea       StoreIt,a2
  465.           lea       Output,a3
  466.           move.l    AbsExecBase,a6
  467.           jsr       _LVORawDoFmt(a6)   
  468.  
  469.           movea.l   GfBase,a6
  470.           move.l    Rp,a1           * set pen to white
  471.           moveq     #1,d0
  472.           jsr       _LVOSetAPen(a6)
  473.  
  474. * Scan the output string for $B6's and do line - wrap
  475.  
  476. fl:       lea       Output,a0
  477.           move.w    #20,d1
  478.           movea.l   a0,a4
  479.           clr       d4
  480. fl1:
  481.           cmp.b     #0,1(a4)
  482.           beq       fl5
  483.           cmp.b     #$b6,(a4)
  484.           beq       fl3
  485. fl2:      cmp.b     #0,(a4)
  486.           beq       cr2
  487.           addq.w    #1,d4
  488.           cmp.w     #75,d4
  489.           beq       fl4
  490.           lea       1(a4),a4
  491.           jmp       fl1
  492.  
  493. * ------------ clean up zeros ---------
  494. * having drawn screen, remove leading zeros.
  495.  
  496. fl5:      clr       d3
  497. cu:       move.b    noc,d3
  498.           mulu      #2,d3
  499.           clr.l     d5
  500.           move.b    #8,d5
  501.           sub.b     d3,d5    
  502.           clr       d0
  503.           lea       -8(a4),a4
  504.           lea       0(a4,d3.w),a4
  505.           
  506. cz:       cmp.b     #0,noc
  507.           beq       cz2
  508.           cmp.b     #$30,(a4)
  509.           bne       fl6
  510. cz2:      move.b    #$20,(a4)
  511. fl6:      lea       1(a4),a4
  512.           dbra      d5,cz
  513.  
  514.           jmp       fl7
  515.  
  516. * --------------------------------
  517. * $B6 found - skip a line
  518.  
  519.  
  520. fl3:      lea       1(a4),a4
  521. fl4:      move.w    d1,sptr
  522.           movea.l   GfBase,a6
  523.           move.l    Rp,a1
  524.           move.w    #220,d0
  525.           jsr       _LVOMove(a6)
  526.  
  527.           move.w    d4,d0       
  528.           movea.l   GfBase,a6
  529.           move.l    Rp,a1
  530. ftext:
  531.           jsr       _LVOText(a6)
  532.  
  533.           movea.l   a4,a0
  534.           clr       d4
  535.           move.w    sptr,d1
  536.           add.w     #9,d1         
  537.           jmp       fl1
  538.  
  539. * --------- last parameter -------------------------
  540.  
  541. fl7:      move.w    d1,sptr
  542.           movea.l   GfBase,a6
  543.           move.l    Rp,a1
  544.           move.w    #220,d0
  545.           jsr       _LVOMove(a6)
  546.  
  547.           move.w    d4,d0       
  548.           movea.l   GfBase,a6
  549.           move.l    Rp,a1
  550.  
  551.           jsr       _LVOText(a6)
  552.  
  553.           movea.l   a4,a0
  554.           clr       d4
  555.           move.w    sptr,d1
  556.           add.w     #8,d1         
  557.           jmp       cr2
  558.  
  559. * --------- rawkeyconv utility 
  560.  
  561. StoreIt:  move.b   d0,(a3)+    
  562.           rts
  563.  
  564.             END
  565.  
  566.