home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / barflydemo-1.10.lha / BarflyDemo / Source / Demo.S < prev    next >
Text File  |  1994-08-21  |  34KB  |  1,870 lines

  1. ;-----------------------------------------------------------------------------
  2. ; FUNCTION:    NONE
  3. ;
  4. ; INPUT:    NONE
  5. ;
  6. ; OUTPUT:    NONE
  7. ;
  8. ; REQUIREMENT:
  9. ;    - V2.x : Because 1.x is a pain
  10. ;    - 020+ : Because I wanted too
  11. ;
  12. ; NOTE:    - There was no point to make this code resident, so the program
  13. ;      variables are in the XDATA to save us from an Allocmem.
  14. ;    - Because the code require a bit of CPU power there was no point
  15. ;      to take the time to make it 68000 compatible.
  16. ;    - I removed the 3.x WB support, cause I was not happy with it.
  17. ;    - On my basic 3.1 A3000 blitting the image to the window take ~50%
  18. ;      of the machine time, the C2P ~20%.Think what you want of this fact.
  19. ;    - All drawing routines are custom but use bltbitmap to display
  20. ;      the result in a window.(With a prior c2p pass is needed)
  21. ;
  22. ;-----------------------------------------------------------------------------
  23. ;    ADDSYM
  24.     MC68020
  25.     OUTPUT    T:DEMO
  26.     BOPT    x+,O+,wo-    ;,OG+
  27.  
  28. ;--------------------------------------
  29.     INCDIR    "includes:"
  30.     INCLUDE "exec/execbase.i"
  31.     INCLUDE "exec/memory.i"
  32.     INCLUDE    "intuition/intuition.i"
  33.     INCLUDE    "all_lvo.i"            ;File auto created with LK FDINCLUDE option
  34.  
  35. ;-----------------------------------------------------------------------------
  36. GSTRING    MACRO                    ;This macro should be SECTION based
  37.     bsr.b    \@
  38.     db    "\1",0
  39.     EVEN
  40. \@    movea.l    (sp)+,\2
  41.     ENDM
  42.  
  43. TRUE    = 1
  44. FALSE    = 0
  45.  
  46.     RSRESET                    ;Program Variable
  47. DEMO_Stack        RS.L    1
  48. DEMO_EBase        RS.L    1
  49. DEMO_DBase        RS.L    1
  50. DEMO_IBase        RS.L    1
  51. DEMO_GBase        RS.L    1
  52. DEMO_Error        RS.L    1
  53. DEMO_Screen        RS.L    1
  54. DEMO_WindowXPos        RS.W    1
  55. DEMO_WindowYPos        RS.W    1
  56. DEMO_PolyWindow        RS.L    1
  57. DEMO_BoxWindow        RS.L    1
  58. DEMO_PixelWindow    RS.L    1
  59. DEMO_FireWindow        RS.L    1
  60. DEMO_RingWindow        RS.L    1
  61. DEMO_WeirdWindow    RS.L    1
  62. DEMO_ZoomWindow        RS.L    1
  63. DEMO_DiscWindow        RS.L    1
  64. DEMO_RND        RS.L    1
  65. DEMO_WBVP        RS.L    1
  66. DEMO_ColorMap        RS.L    1
  67. DEMO_HScroll        RS.L    1
  68. DEMO_HSize        RS.W    1
  69. DEMO_VSize        RS.W    1
  70. DEMO_MouseX        RS.W    1
  71. DEMO_MouseY        RS.W    1
  72. DEMO_Dist        RS.L    1
  73. DEMO_Chunky1        RS.L    1
  74. DEMO_Chunky2        RS.L    1
  75. DEMO_SinTable        RS.L    1
  76. DEMO_Pens        RS.B    16
  77. DEMO_AvailPens        RS.B    16
  78. DEMO_BitMap        RS.B    bm_SIZEOF
  79. DEMO_Maping        RS.B    256
  80. DEMO_Points        RS.W    32*3*2
  81. DEMO_SIZEOF        RS.L    0
  82.  
  83. ;    SECTION    DEMOCode,CODE            ;Read ONLY
  84.  
  85. ;--------------------------------------
  86. DEMO_Startup
  87.     lea    (DEMO_BSS,pc),a4
  88.     ml    a7,(DEMO_Stack,a4)
  89.  
  90.     bsr    DEMO_AllocLib
  91.     beq    DEMO_Exit
  92.  
  93.     mw    (DEMO_EBase,a4,),a0
  94.     mw    (AttnFlags,a0),d0
  95.     btst    #AFB_68020,d0
  96.     beq    DEMO_Exit
  97.  
  98. DEMO_Main
  99.     GSTRING    <Demo Screen>,a0
  100.     bsr    DEMO_AllocScreen
  101.     ml    d0,(DEMO_Screen,a4)
  102.     beq    DEMO_Quit
  103.     movea.l    d0,a0
  104.     mq    #0,d0
  105.     mb    (sc_BarHeight,a0),d0
  106.     add.b    (sc_BarVBorder,a0),d0
  107.     mw    d0,(DEMO_WindowYPos,a4)
  108.  
  109.     GSTRING    <Fire>,a0
  110.     bsr    DEMO_AllocWindow
  111.     ml    d0,(DEMO_FireWindow,a4)
  112.     beq    DEMO_Quit
  113.  
  114.     GSTRING    <Zoom>,a0
  115.     bsr    DEMO_AllocWindow
  116.     ml    d0,(DEMO_ZoomWindow,a4)
  117.     beq    DEMO_Quit
  118.  
  119.     GSTRING    <Poly>,a0
  120.     bsr    DEMO_AllocWindow
  121.     ml    d0,(DEMO_PolyWindow,a4)
  122.     beq    DEMO_Quit
  123.  
  124.     GSTRING    <Box>,a0
  125.     bsr    DEMO_AllocWindow
  126.     ml    d0,(DEMO_BoxWindow,a4)
  127.     beq    DEMO_Quit
  128.  
  129.     GSTRING    <Pixel>,a0
  130.     bsr    DEMO_AllocWindow
  131.     ml    d0,(DEMO_PixelWindow,a4)
  132.     beq    DEMO_Quit
  133.  
  134.     GSTRING    <Disc>,a0
  135.     bsr    DEMO_AllocWindow
  136.     ml    d0,(DEMO_DiscWindow,a4)
  137.     beq    DEMO_Quit
  138.  
  139.     GSTRING    <Weird>,a0
  140.     bsr    DEMO_AllocWindow
  141.     ml    d0,(DEMO_WeirdWindow,a4)
  142.     beq    DEMO_Quit
  143.  
  144.     GSTRING    <Ring>,a0
  145.     bsr    DEMO_AllocWindow
  146.     ml    d0,(DEMO_RingWindow,a4)
  147.     beq    DEMO_Quit
  148.  
  149.     movea.l    (DEMO_Screen,a4),a0
  150.     movea.l    (DEMO_IBase,a4),a6
  151.     jsr    (_LVOScreenToFront,a6)        ;Show screen with all window opened
  152.  
  153. .Loop    pea    .Loop(pc)
  154.     mq    #0,D0
  155.     lea    (DEMO_FireWindow,a4),a0
  156.     bsr    .SetBit
  157.     lea    (DEMO_WeirdWindow,a4),a0
  158.     bsr    .SetBit
  159.     lea    (DEMO_PolyWindow,a4),a0
  160.     bsr    .SetBit
  161.     lea    (DEMO_BoxWindow,a4),a0
  162.     bsr    .SetBit
  163.     lea    (DEMO_PixelWindow,a4),a0
  164.     bsr    .SetBit
  165.     lea    (DEMO_DiscWindow,a4),a0
  166.     bsr    .SetBit
  167.     lea    (DEMO_ZoomWindow,a4),a0
  168.     bsr    .SetBit
  169.     lea    (DEMO_RingWindow,a4),a0
  170.     bsr    .SetBit
  171.     beq    DEMO_Quit
  172.     movea.l    (DEMO_EBase,a4),a6
  173.     jsr    (_LVOWait,a6)            ;Wait on any window left opened
  174.  
  175.     ml    #IDCMP_ACTIVEWINDOW,d2
  176.  
  177.     lea    (DEMO_RingWindow,a4),a0
  178.     bsr    DEMO_GetWindowInput
  179.     cmp.l    d2,d0
  180.     beq    DEMO_Ring
  181.  
  182.     lea    (DEMO_FireWindow,a4),a0
  183.     bsr    DEMO_GetWindowInput
  184.     cmp.l    d2,d0
  185.     beq    DEMO_Fire
  186.  
  187.     lea    (DEMO_WeirdWindow,a4),a0
  188.     bsr    DEMO_GetWindowInput
  189.     cmp.l    d2,d0
  190.     beq    DEMO_Weird
  191.  
  192.     lea    (DEMO_ZoomWindow,a4),a0
  193.     bsr    DEMO_GetWindowInput
  194.     cmp.l    d2,d0
  195.     beq    DEMO_Zoom
  196.  
  197.     lea    (DEMO_PolyWindow,a4),a0
  198.     bsr    DEMO_GetWindowInput
  199.     cmp.l    d2,d0
  200.     beq    DEMO_Poly
  201.  
  202.     lea    (DEMO_BoxWindow,a4),a0
  203.     bsr    DEMO_GetWindowInput
  204.     cmp.l    d2,d0
  205.     beq    DEMO_Box
  206.  
  207.     lea    (DEMO_PixelWindow,a4),a0
  208.     bsr    DEMO_GetWindowInput
  209.     cmp.l    d2,d0
  210.     beq    DEMO_Pixel
  211.  
  212.     lea    (DEMO_DiscWindow,a4),a0
  213.     bsr    DEMO_GetWindowInput
  214.     cmp.l    d2,d0
  215.     beq    DEMO_Disc
  216.  
  217.     rts
  218.  
  219. .SetBit    ml    (a0),d1
  220.     beq.b    .TstBit
  221.     movea.l    d1,a0
  222.     mb    ([wd_UserPort,a0],MP_SIGBIT),d1
  223.     bset    d1,d0
  224. .TstBit    tst.l    d0
  225.     rts
  226.  
  227. DEMO_Quit
  228.     ml    (DEMO_Screen,a4),d0
  229.     beq.b    DEMO_Exit
  230.     movea.l    d0,a0
  231.     movea.l    (DEMO_IBase,a4),a6
  232.     jsr    (_LVOScreenToBack,a6)
  233.     bsr    DEMO_FreeBuffer
  234.     lea    (DEMO_FireWindow,a4),a0
  235.     bsr    DEMO_FreeWindow
  236.     lea    (DEMO_RingWindow,a4),a0
  237.     bsr    DEMO_FreeWindow
  238.     lea    (DEMO_ZoomWindow,a4),a0
  239.     bsr    DEMO_FreeWindow
  240.     lea    (DEMO_WeirdWindow,a4),a0
  241.     bsr    DEMO_FreeWindow
  242.     lea    (DEMO_PolyWindow,a4),a0
  243.     bsr    DEMO_FreeWindow
  244.     lea    (DEMO_BoxWindow,a4),a0
  245.     bsr    DEMO_FreeWindow
  246.     lea    (DEMO_PixelWindow,a4),a0
  247.     bsr    DEMO_FreeWindow
  248.     lea    (DEMO_DiscWindow,a4),a0
  249.     bsr    DEMO_FreeWindow
  250.     bsr    DEMO_FreeScreen
  251. DEMO_Exit
  252.     bsr    DEMO_FreeLib
  253.     ml    (DEMO_Stack,a4),a7
  254.     ml    (DEMO_Error,a4),d0
  255.     rts
  256.  
  257. ;--------------------------------------
  258. DEMO_AllocLib
  259.     ml    ($4).w,(DEMO_EBase,a4)
  260.     movea.l    (DEMO_EBase,a4),a6
  261.     lea    (DName,pc),a1
  262.     mq    #0,d0
  263.     jsr    (_LVOOpenLibrary,a6)
  264.     ml    d0,(DEMO_DBase,a4)
  265.     beq.b    .Fail
  266.     lea    (IName,pc),a1
  267.     mq    #37,d0
  268.     jsr    (_LVOOpenLibrary,a6)
  269.     ml    d0,(DEMO_IBase,a4)
  270.     beq.b    .Fail
  271.     lea    (GName,pc),a1
  272.     mq    #37,d0
  273.     jsr    (_LVOOpenLibrary,a6)
  274.     ml    d0,(DEMO_GBase,a4)
  275.     beq.b    .Fail
  276. .Exit    mq    #TRUE,d0
  277.     rts
  278. .Fail    mq    #FALSE,d0
  279.     rts
  280.  
  281. DEMO_FreeLib
  282.     lea    (DEMO_IBase,a4),a0
  283.     bsr.b    .Close
  284.     lea    (DEMO_GBase,a4),a0
  285.     bsr.b    .Close
  286.     lea    (DEMO_DBase,a4),a0
  287. .Close    ml    (a0),d0
  288.     beq.b    .Rts
  289.     clr.l    (a0)
  290.     movea.l    d0,a1
  291.     movea.l    (DEMO_EBase,a4),a6
  292.     jmp    (_LVOCloseLibrary,a6)
  293. .Rts    rts
  294.  
  295. IName        DC.B    "intuition.library",0
  296. GName        DC.B    "graphics.library",0
  297. DName        DC.B    "dos.library",0
  298.     EVEN
  299.  
  300. ;--------------------------------------
  301. DEMO_AllocScreen
  302.     ml    a7,d2
  303.     ml    #-1,-(sp)
  304.     ml    a7,d3
  305.     ml    #TAG_END,-(sp)
  306.     ml    #5,-(sp)
  307.     ml    #SA_Depth,-(sp)
  308.     ml    a0,-(sp)
  309.     ml    #SA_Title,-(sp)
  310.     ml    #CUSTOMSCREEN,-(sp)
  311.     ml    #SA_Type,-(sp)
  312.     ml    #TRUE,-(sp)
  313.     ml    #SA_Behind,-(sp)
  314.     ml    d3,-(sp)
  315.     ml    #SA_Pens,-(sp)
  316.     suba.l    a0,a0
  317.     movea.l    a7,a1
  318.     movea.l    (DEMO_IBase,a4),a6
  319.     jsr    (_LVOOpenScreenTagList,a6)
  320.     ml    d2,a7
  321.     rts
  322.  
  323. DEMO_FreeScreen
  324.     lea    (DEMO_Screen,a4),a0
  325. .Close    ml    (a0),d0
  326.     beq    .Rts
  327.     clr.l    (a0)
  328.     movea.l    d0,a0
  329.     movea.l    (DEMO_IBase,a4),a6
  330.     jmp    (_LVOCloseScreen,a6)
  331. .Rts    rts
  332.  
  333. ;--------------------------------------
  334. DEMO_AllocWindow
  335.     ml    a7,d2
  336.     mq    #0,d0
  337.     ml    #TAG_END,-(sp)
  338.     mw    (DEMO_WindowYPos,a4),d0
  339.     ml    d0,-(sp)
  340.     ml    #WA_Top,-(sp)
  341.     mw    (DEMO_WindowXPos,a4),d0
  342.     ml    d0,-(sp)
  343.     ml    #WA_Left,-(sp)
  344.     ml    #256,-(sp)
  345.     ml    #WA_MaxWidth,-(sp)
  346.     ml    #200,-(sp)
  347.     ml    #WA_MaxHeight,-(sp)
  348.     ml    #32,-(sp)
  349.     ml    #WA_InnerWidth,-(sp)
  350.     ml    #32,-(sp)
  351.     ml    #WA_InnerHeight,-(sp)
  352.     ml    #IDCMP_CLOSEWINDOW!IDCMP_NEWSIZE!IDCMP_ACTIVEWINDOW!IDCMP_INACTIVEWINDOW,-(sp)
  353.     ml    #WA_IDCMP,-(sp)
  354.     ml    #WFLG_SIZEGADGET!WFLG_CLOSEGADGET!WFLG_DRAGBAR!WFLG_DEPTHGADGET,-(sp)
  355.     ml    #WA_Flags,-(sp)
  356.     ml    a0,-(sp)
  357.     ml    #WA_Title,-(sp)
  358.     ml    (DEMO_Screen,a4),-(sp)
  359.     ml    #WA_CustomScreen,-(sp)
  360.     suba.l    a0,a0
  361.     movea.l    a7,a1
  362.     movea.l    (DEMO_IBase,a4),a6
  363.     jsr    (_LVOOpenWindowTagList,a6)
  364.     ml    d2,a7
  365.     tst.l    d0
  366.     beq.b    .Rts
  367.     movea.l    d0,a0
  368.     mw    (wd_Width,a0),d1
  369.     add.w    d1,(DEMO_WindowXPos,a4)
  370.     cmpi.w    #256,(DEMO_WindowXPos,a4)
  371.     ble.b    .Rts
  372.     clr.w    (DEMO_WindowXPos,a4)
  373.     mw    (wd_TopEdge,a0),d1
  374.     add.w    (wd_Height,a0),d1
  375.     mw    d1,(DEMO_WindowYPos,a4)
  376. .Rts    rts
  377.  
  378. DEMO_FreeWindow
  379. .Close    ml    (a0),d0
  380.     beq    .Rts
  381.     clr.l    (a0)
  382.     movea.l    d0,a0
  383.     movea.l    (DEMO_IBase,a4),a6
  384.     jmp    (_LVOCloseWindow,a6)
  385. .Rts    rts
  386.  
  387. ;--------------------------------------
  388. DEMO_GetWindowInput
  389.     ml    (a0),d0
  390.     beq.b    .Rts
  391.     movea.l    d0,a0
  392.     movem.l    d2-d3,-(a7)
  393.     movea.l    (DEMO_EBase,a4),a6
  394.     movea.l    (wd_UserPort,a0),a0
  395.     mq    #0,d2
  396.     jsr    (_LVOGetMsg,a6)
  397.     tst.l    d0
  398.     beq.b    .Done
  399.     movea.l    d0,a1
  400.     ml    (im_Class,a1),d2
  401.     mw    (im_Code,a1),d3
  402.     jsr    (_LVOReplyMsg,a6)
  403. .Done    ml    d2,d0
  404.     mw    d3,d1
  405. .Exit    movem.l    (a7)+,d2-d3
  406. .Rts    rts
  407.  
  408. ;----------------------------------