home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / a68kex_431.lzh / A68Kex / moire.asm < prev    next >
Assembly Source File  |  1991-01-17  |  11KB  |  419 lines

  1. *
  2. * This is a remake of moire on AmigaLibDisk9
  3. *
  4. ************************************************************************
  5. * Moire.c -- Yet another graphics dazzler for the Amiga.  This one draws
  6. *            Moire Patterns in Black and White - they tend to look better
  7. *            that way.  Uses a borderless backdrop window to make life
  8. *            easier, and so we get the whole screen if we want it.
  9. *
  10. *            Copyright (c) 1985 by Scott Ballantyne
  11. *            (I.E. Ok to give away for nothing )
  12. ************************************************************************
  13. *
  14. * This implementation was written by
  15. * E. Lenz
  16. * Johann-Fichte-Strasse 11
  17. * 8 Munich 40
  18. * Germany
  19. *
  20.  
  21. _AbsExecBase        equ 4
  22.  
  23. **** exec *****
  24.  
  25. _LVOForbid       equ -$84
  26. _LVOPermit       equ -$8a
  27. _LVOGetMsg       equ -$174
  28. _LVOReplyMsg     equ -$17a
  29. _LVOWaitPort     equ -$180
  30. _LVOCloseLibrary equ -$19e
  31. _LVOOpenLibrary  equ -$228
  32.  
  33. **** intuition ******
  34.  
  35. _LVOCloseScreen     equ -$42
  36. _LVOCloseWindow     equ -$48
  37. _LVOOpenScreen      equ -$c6
  38. _LVOOpenWindow      equ -$cc
  39. _LVOSetMenuStrip    equ -$108
  40. _LVOShowTitle       equ -$11a
  41. _LVOViewPortAddress equ -$12c
  42.  
  43. ***** graphics ******
  44.  
  45. _LVOMove            equ -$f0
  46. _LVODraw            equ -$f6
  47. _LVOSetRGB4         equ -$120
  48. _LVORectFill        equ -$132
  49. _LVOSetAPen         equ -$156
  50. _LVOSetDrMd         equ -$162
  51.  
  52. wd_RPort         equ $32
  53. wd_UserPort      equ $56
  54. pr_MsgPort       equ $5c
  55. pr_CLI           equ $ac
  56. ThisTask         equ $114
  57.  
  58. JAM1         set 0
  59. ERASE        set 0
  60. SHOW         set 1
  61. CUSTOMSCREEN set $f
  62. MAXX         set 640
  63. MAXY         set 200
  64. MENUPICK     set $100
  65. BACKDROP     set $100
  66. BORDERLESS   set $800
  67. ACTIVATE     set $1000
  68. HIRES        set $8000
  69.  
  70.        XREF    Random
  71.  
  72.        movea.l _AbsExecBase,a6   test if WB or CLI
  73.        movea.l ThisTask(a6),a0
  74.        moveq   #0,d0
  75.        tst.l   pr_CLI(a0)
  76.        bne.s   isCLI
  77.  
  78.        lea     pr_MsgPort(a0),a0     for WB get WB Message
  79.        jsr     _LVOWaitPort(a6)
  80.        jsr     _LVOGetMsg(a6)
  81.  
  82. isCLI  move.l  d0,-(a7)
  83.  
  84.        lea     GfxName(pc),a1   Open graphics.library
  85.        moveq   #0,d0
  86.        jsr     _LVOOpenLibrary(a6)
  87.        movea.l d0,a4
  88.        tst.l   d0
  89.        beq.s   Gexit
  90.  
  91.        lea     IntName(pc),a1         open intuition library
  92.        moveq   #0,d0
  93.        jsr     _LVOOpenLibrary(a6)
  94.        movea.l d0,a2
  95.        tst.l   d0
  96.        beq.s   Gexit
  97.  
  98.        lea     ns(pc),a0              open screen
  99.        movea.l a2,a6
  100.        jsr     _LVOOpenScreen(a6)
  101.        move.l  d0,nws
  102.        beq.s   Gexit
  103.  
  104.        lea     nw(pc),a0              open window
  105.        jsr     _LVOOpenWindow(a6)
  106.        movea.l d0,a3
  107.        tst.l   d0
  108. Gexit  beq     exit
  109.  
  110.        movea.l d0,a0
  111.        movea.l wd_RPort(a0),a5
  112.        jsr     _LVOViewPortAddress(a6)
  113.  
  114.        move.l  d0,-(a7)
  115.        movea.l d0,a0
  116.        movea.l a4,a6
  117.        moveq   #0,d0
  118.        moveq   #0,d1
  119.        moveq   #0,d2
  120.        moveq   #0,d3
  121.        jsr     _LVOSetRGB4(a6)
  122.  
  123.        movea.l (a7)+,a0
  124.        moveq   #1,d0
  125.        moveq   #$f,d1
  126.        moveq   #$f,d2
  127.        moveq   #$f,d3
  128.        jsr     _LVOSetRGB4(a6)
  129.  
  130. ; Set menu
  131.  
  132.        movea.l a2,a6
  133.        movea.l a3,a0           which window
  134.        lea     Menu1(pc),a1    which menu
  135.        jsr     _LVOSetMenuStrip(a6)
  136.  
  137.        movea.l a4,a6
  138.        movea.l a5,a1
  139.        moveq   #JAM1,d0
  140.        jsr     _LVOSetDrMd(a6)
  141.  
  142.        bsr     moire
  143.  
  144. loop   movea.l _AbsExecBase,a6
  145.  
  146.        movea.l a3,a0
  147.        movea.l wd_UserPort(a0),a0
  148.        jsr     _LVOGetMsg(a6)
  149.        tst.l   d0
  150.        beq.s   loop           ;No message
  151.  
  152.        movea.l d0,a1
  153.        move.l  $14(a1),d7       Message in a7
  154.        jsr     _LVOReplyMsg(a6) Always reply
  155.  
  156. ; Choice from menu
  157.  
  158.        movea.l a3,a0
  159.        movea.l $5e(a0),a0   Load Window.MessageKey
  160.        move.w  $18(a0),d0   Load message code
  161.        move.w  d0,d1
  162.        andi.w  #$f,d1
  163.        bne.s   loop
  164.  
  165.        andi.w  #$f0,d0      Menu 1
  166.        bne.s   menu12       Submenu 1
  167.        bsr     moire
  168. sedraw bra.s   loop
  169.  
  170. menu12 cmpi.w  #$20,d0      Submenu 2
  171.        bne.s   menu13
  172.        moveq   #0,d0
  173.        bra.s   show
  174.  
  175. menu13 cmpi.w  #$40,d0      Submenu 3
  176.        bne     exit
  177.        moveq   #1,d0
  178. show   movea.l a2,a6
  179.        lea     nws(pc),a0
  180.        move.l  (a0),a0
  181.        jsr     _LVOShowTitle(a6)
  182.        bra.s   loop
  183.  
  184. exit   movea.l a2,a6           close window
  185.        move.l  a3,d0
  186.        beq.s   noWin
  187.        movea.l d0,a0
  188.        jsr     _LVOCloseWindow(a6)
  189.  
  190. noWin  move.l  nws(pc),d0         close screen
  191.        beq.s   noScr
  192.        movea.l d0,a0
  193.        jsr     _LVOCloseScreen(a6)
  194.  
  195. noScr  movea.l _AbsExecBase,a6
  196.        move.l  (a7)+,d0
  197.        beq.s   NoBenh
  198.        jsr     _LVOForbid(a6)       reply to WB
  199.        movea.l d0,a1
  200.        jsr     _LVOReplyMsg(a6)
  201.        jsr     _LVOPermit(a6)
  202.  
  203. NoBenh move.l  a2,d1           close intuition library
  204.        beq.s   noInt
  205.        movea.l d1,a1
  206.        jsr     _LVOCloseLibrary(a6)
  207.  
  208. noInt  move.l  a4,d1               close graphics library
  209.        beq.s   noGfx
  210.        movea.l d1,a1
  211.        jsr     _LVOCloseLibrary(a6)
  212.  
  213. noGfx  moveq   #0,d0                no error
  214.        rts
  215.  
  216. moire  movea.l a4,a6
  217.        movea.l a5,a1
  218.        moveq   #ERASE,d0
  219.        jsr     _LVOSetAPen(a6)
  220.        movea.l a5,a1
  221.        moveq   #0,d0
  222.        moveq   #0,d1
  223.        move.l  #MAXX,d2
  224.        move.l  #MAXY,d3
  225.        jsr     _LVORectFill(a6)
  226.        move.l  #MAXY,d0
  227.        jsr     Random
  228.        move.l  d0,d5         y1
  229.        move.l  #MAXX,d0
  230.        jsr     Random
  231.        move.l  d0,d4         x1
  232.        moveq   #0,d3         y0
  233.        move.l  #MAXX-1,d6    x2
  234.        move.l  #MAXY,d7      y2
  235. loopx  moveq   #SHOW,d1      mode
  236.        move.l  d6,d2         x0
  237.        bsr     doline
  238.        subq.l  #1,d6
  239.        moveq   #ERASE,d1
  240.        move.l  d6,d2
  241.        bsr     doline
  242.        dbra    d6,loopx
  243.        move.l  #MAXY-1,d7
  244.        move.l  #MAXX,d6
  245.        moveq   #0,d2
  246. loopy  moveq   #SHOW,d1
  247.        move.l  d7,d3
  248.        bsr     doline
  249.        subq.l  #1,d7
  250.        moveq   #ERASE,d1
  251.        move.l  d7,d3
  252.        bsr     doline
  253.        dbra    d7,loopy
  254.        rts
  255.  
  256. doline movea.l a5,a1
  257.        move.l  d1,d0
  258.        jsr     _LVOSetAPen(a6)
  259.        movea.l a5,a1
  260.        move.l  d2,d0
  261.        move.l  d3,d1
  262.        jsr     _LVOMove(a6)
  263.        movea.l a5,a1
  264.        move.l  d4,d0
  265.        move.l  d5,d1
  266.        jsr     _LVODraw(a6)
  267.        movea.l a5,a1
  268.        move.l  d6,d0
  269.        move.l  d7,d1
  270.        jsr     _LVODraw(a6)
  271.        rts
  272.  
  273. GfxName     dc.b 'graphics.library',0
  274. IntName     dc.b 'intuition.library',0
  275.             even
  276.  
  277. title1      dc.b 'Moire Patterns',0
  278.             even
  279.  
  280. **** screen definition ****
  281.  
  282. ns          dc.w  0,0
  283.             dc.w  MAXX,MAXY,1
  284.             dc.b  0,1
  285.             dc.w  HIRES
  286.             dc.w  CUSTOMSCREEN
  287.             dc.l  0
  288.             dc.l  title1
  289.             dc.l  0
  290.             dc.l  0
  291.  
  292. ***** Window definition *****
  293.  
  294. nw          dc.w 0,0           ;Position left,top
  295.             dc.w MAXX,MAXY     ;Size width,height
  296.             dc.b 0,1           ;Colors detail-,block pen
  297.             dc.l MENUPICK      ;IDCMP-Flags
  298.             dc.l BORDERLESS+BACKDROP+ACTIVATE  ;Window flags
  299.             dc.l 0             ;^Gadget
  300.             dc.l 0             ;^Menu check
  301.             dc.l 0             ;^Window name
  302. nws         dc.l 0             ;^Screen structure,
  303.             dc.l 0             ;^BitMap
  304.             dc.w 0             ;MinWidth
  305.             dc.w 0             ;MinHeight
  306.             dc.w 0             ;MaxWidth
  307.             dc.w 0,CUSTOMSCREEN ;MaxHeight,Screen type
  308.  
  309. **** menu definition ****
  310.  
  311. Menu1       dc.l 0           Next menu
  312.             dc.w 0,0         Position left edge,top edge
  313.             dc.w 100,20      Dimensions width,height
  314.             dc.w 1           Menu enabled
  315.             dc.l mtext1      Text for menu header
  316.             dc.l item11      ^First in chain
  317.             dc.l 0,0         Internal
  318.  
  319. mtext1      dc.b 'Actions',0
  320.             even
  321.  
  322. item11      dc.l item12      next in chained list
  323.             dc.w 0,0         Position left edge,top edge
  324.             dc.w 120,10      Dimensions width,height
  325.             dc.w $52         itemtext+highcomp+itemenabled
  326.             dc.l 0           Mutual exclude
  327.             dc.l I11txt      Pointer to intuition text
  328.             dc.l 0
  329.             dc.b 0,0
  330.             dc.l 0
  331.             dc.w 0
  332.  
  333.  
  334. I11txt      dc.b 0           Front pen  (blue)
  335.             dc.b 1           Back pen   (white)
  336.             dc.b 0,0         Draw mode
  337.             dc.w 0           Left edge
  338.             dc.w 0           Top edge
  339.             dc.l 0           Text font
  340.             dc.l item11txt   Pointer to text
  341.             dc.l 0           Next text
  342.  
  343. item11txt   dc.b 'New Moire',0
  344.             even
  345.  
  346. item12      dc.l item13      next in chained list
  347.             dc.w 0,10        Position left edge,top edge
  348.             dc.w 120,10      Dimensions width,height
  349.             dc.w $52         itemtext+highcomp+itemenabled
  350.             dc.l 0           Mutual exclude
  351.             dc.l I12txt      Pointer to intuition text
  352.             dc.l 0
  353.             dc.b 0,0
  354.             dc.l 0
  355.             dc.w 0
  356.  
  357.  
  358. I12txt      dc.b 0           Front pen  (blue)
  359.             dc.b 1           Back pen   (white)
  360.             dc.b 0,0         Draw mode
  361.             dc.w 0           Left edge
  362.             dc.w 0           Top edge
  363.             dc.l 0           Text font
  364.             dc.l item12txt   Pointer to text
  365.             dc.l 0           Next text
  366.  
  367. item12txt   dc.b 'Hide Title Bar',0
  368.             even
  369.  
  370. item13      dc.l item14      next in chained list
  371.             dc.w 0,20        Position left edge,top edge
  372.             dc.w 120,10      Dimensions width,height
  373.             dc.w $52         itemtext+highcomp+itemenabled
  374.             dc.l 0           Mutual exclude
  375.             dc.l I13txt      Pointer to intuition text
  376.             dc.l 0
  377.             dc.b 0,0
  378.             dc.l 0
  379.             dc.w 0
  380.  
  381.  
  382. I13txt      dc.b 0           Front pen  (blue)
  383.             dc.b 1           Back pen   (white)
  384.             dc.b 0,0         Draw mode
  385.             dc.w 0           Left edge
  386.             dc.w 0           Top edge
  387.             dc.l 0           Text font
  388.             dc.l item13txt   Pointer to text
  389.             dc.l 0           Next text
  390.  
  391. item13txt   dc.b 'Show Title Bar',0
  392.  
  393. item14      dc.l 0           next in chained list
  394.             dc.w 0,30        Position left edge,top edge
  395.             dc.w 120,10      Dimensions width,height
  396.             dc.w $52         itemtext+highcomp+itemenabled
  397.             dc.l 0           Mutual exclude
  398.             dc.l I14txt      Pointer to intuition text
  399.             dc.l 0
  400.             dc.b 0,0
  401.             dc.l 0
  402.             dc.w 0
  403.  
  404.  
  405. I14txt      dc.b 0           Front pen  (blue)
  406.             dc.b 1           Back pen   (white)
  407.             dc.b 0,0         Draw mode
  408.             dc.w 0           Left edge
  409.             dc.w 0           Top edge
  410.             dc.l 0           Text font
  411.             dc.l item14txt   Pointer to text
  412.             dc.l 0           Next text
  413.  
  414. item14txt   dc.b 'Quit!',0
  415.  
  416.             even
  417.             end
  418.  
  419.