home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Assembler / dse-src3.dms / in.adf / Source / Pobs / Pobs.lha / Pobs.Good.S next >
Encoding:
Text File  |  1993-01-03  |  11.0 KB  |  479 lines

  1. ***********************************************************
  2. * This is yet another piece of source code that was compatability
  3. * fixed and optimized by the Dancing Fool of Epsilon.  The
  4. * original source SHOULD also be in this archive, if it isn't
  5. * then jump up and down and yell "IDIOTS!" at the top of your
  6. * lungs. :^)  Enjoy.
  7. ***********************************************************
  8. * Includes
  9. ***********************************************************
  10.  
  11.         incdir    "DevpacAm:include/"
  12.         include    "exec/exec_lib.i"
  13.         include    "exec/execbase.i"
  14.         include    "graphics/gfxbase.i"
  15.         include    "graphics/graphics_lib.i"
  16.         include    "hardware/custom.i"
  17.  
  18. ***********************************************************
  19. * Other Macros
  20. ***********************************************************
  21.  
  22. CALL        MACRO
  23.         jsr    _LVO\1(a6)
  24.         ENDM
  25.  
  26. SwapBmaps    MACRO
  27.         movem.l    ClearBmap,d0/d1
  28.         move.l    VisualBmap,ClearBmap
  29.         movem.l    d0-d1,ActiveBmap
  30.  
  31.         lea    bmapptrs+2,a0
  32.         move.w    d1,4(a0)
  33.         swap    d1
  34.         move.w    d1,(a0)
  35.         ENDM
  36.  
  37. ClearBmaps    MACRO
  38.         move.l    ClearBmap,$dff054
  39.         move.l    #$01000000,$dff040
  40.         move.w    #0,$dff066
  41.         move.w    #(height*64)+(width/2),$dff058
  42.         ENDM
  43.  
  44. ***********************************************************
  45. * Other Equates
  46. ***********************************************************
  47.  
  48.  IFND    gb_ActiView
  49. gb_ActiView    EQU    32
  50.  ENDIF
  51.  
  52.  IFND    gb_CopInit
  53. gb_CopInit    EQU    36
  54.  ENDIF
  55.  
  56. width        EQU    40
  57. height        EQU    256
  58.  
  59. ***********************************************************
  60.  
  61.         section TheCode,code
  62.  
  63.         bsr.w    TakeSystem
  64.  move.w #$20,$dff1dc
  65.         move.l    #copper,$80-2(a5)
  66.         move.w    #$83c0,$96-2(a5)    ; turn on the dma we need
  67.  
  68.         bsr.b    main
  69.  
  70.  move.w    #$0,$dff1dc
  71.         bsr.w    RestoreSystem
  72.         rts
  73.  
  74. ***********************************************************
  75.  
  76. main:        bsr.w    InPtabs
  77.         bsr.w    Rmasks
  78.  
  79. .loop:        cmp.b    #$f4,$dff006
  80.         bne.b    .loop
  81.     
  82.         SwapBmaps
  83.         ClearBmaps
  84.  
  85.         bsr.w    Calc        
  86.         bsr.w    Put        
  87.         
  88.         cmpi.w    #293-1,number
  89.         beq.b    .1
  90.         addq.w    #1,number
  91. .1:
  92.         btst.b    #6,$bfe001
  93.         bne.b    .loop
  94.         rts
  95.  
  96. ***********************************************************
  97.  
  98. InPtabs:    lea    pob_xbuffer,a0
  99.         moveq    #0,d0
  100. .xloop:        move.w    d0,d1
  101.         move.w    d0,d2
  102.         and.w    #$000f,d1
  103.         lsl.w    #6,d1
  104.         move.w    d1,(a0)+
  105.         and.w    #$fff0,d2
  106.         ror.w    #3,d2
  107.         move.w    d2,(a0)+
  108.         addq.w    #1,d0
  109.         cmpi.w    #width*8,d0
  110.         bne.b    .xloop
  111.         
  112.         lea    pob_ybuffer,a0
  113.         moveq    #0,d0
  114. .yloop:        move.w    d0,d1
  115.         mulu    #width,d1
  116.         move.l    d1,(a0)+
  117.         addq.w    #1,d0
  118.         cmp.w    #height,d0
  119.         bne.b    .yloop
  120.         rts
  121.  
  122. ***********************************************************
  123.  
  124. Rmasks:        moveq    #0,d7
  125.         lea    shape_buffer,a1
  126. .loop1:        lea    pob_shape,a0
  127.         move.w    #16,d6
  128. .loop2:        move.l    (a0)+,d0
  129.         ror.l    d7,d0
  130.         move.l    d0,(a1)+
  131.         subq.w    #1,d6
  132.         bne.b    .loop2
  133.         addq.w    #1,d7
  134.         cmpi.w    #16,d7
  135.         bne.b    .loop1
  136.         rts
  137.  
  138. ***********************************************************
  139.  
  140. Calc:        move.w    #$eeee,d0
  141.         move.w    #720,d6
  142.         lea    sinx_pointer1,a0
  143.  
  144.         movem.l    (a0),a2/a3/a4/a5
  145.         movem.w    sinx_add1,d2/d3/d4/d5
  146.  
  147.         adda.w    d2,a2
  148.         cmp.w    (a2),d0
  149.         bne.b    .bkip1
  150.         suba.w    d6,a2
  151.  
  152. .bkip1:        adda.w    d3,a3
  153.         cmp.w    (a3),d0
  154.         bne.b    .bkip2
  155.         suba.w    d6,a3
  156.  
  157. .bkip2:        adda.w    d4,a4
  158.         cmp.w    (a4),d0
  159.         bne.b    .bkip3
  160.         suba.w    d6,a4
  161.  
  162. .bkip3:        adda.w    d5,a5
  163.         cmp.w    (a5),d0
  164.         bne.b    .bkip4
  165.         suba.w    d6,a5
  166.  
  167. .bkip4:        movem.l    a2/a3/a4/a5,(a0)
  168.  
  169.         lea    coord_stack,a0
  170.         movem.w    sinx_dist1,d3-d4/a1/a6
  171.  
  172.         move.w    d0,d5
  173.  
  174.         move.w    number,d7
  175. .loop:        add.w    d3,a2
  176.         add.w    d4,a3
  177.         cmp.w    (a2),d5
  178.         bne.b    .not_x1
  179.         suba.w    d6,a2
  180.  
  181. .not_x1:    cmp.w    (a3),d5
  182.         bne.b    .not_x2
  183.         suba.w    d6,a3
  184.  
  185. .not_x2:    move.w    (a2),d0
  186.         add.w    (a3),d0
  187.         add.w    a1,a4
  188.         add.w    a6,a5
  189.         cmp.w    (a4),d5
  190.         bne.b    .not_y1
  191.         suba.w    d6,a4
  192.  
  193. .not_y1:    cmp.w    (a5),d5
  194.         bne.b    .not_y2
  195.         suba.w    d6,a5
  196.  
  197. .not_y2:    move.w    (a4),d1
  198.         add.w    (a5),d1
  199.         move.w    d0,(a0)+
  200.         move.w    d1,(a0)+
  201.  
  202.         dbf    d7,.loop
  203.         rts
  204.  
  205. ***********************************************************
  206.  
  207. Put:        lea    pob_xbuffer,a0
  208.         lea    pob_ybuffer,a1
  209.         lea    shape_buffer,a4
  210.         move.l    ActiveBmap,a6
  211.         lea    coord_stack,a5
  212.  
  213.         move.w    number,d7
  214. .loop:        movem.w    (a5)+,d0/d1
  215.  
  216.         add.w    d0,d0
  217.         add.w    d0,d0
  218.         add.w    d1,d1
  219.         add.w    d1,d1
  220.         move.l    (a0,d0.w),d0
  221.         lea    width(a6,d0.w),a3
  222.         add.l    (a1,d1.w),a3
  223.         swap    d0
  224.         lea    (a4,d0.w),a2
  225.         
  226.         movem.l    (a2),d0-d5
  227.         or.l    d0,(width*0)(a3)
  228.         or.l    d1,(width*1)(a3)
  229.         or.l    d2,(width*2)(a3)
  230.         or.l    d3,(width*3)(a3)
  231.         or.l    d4,(width*4)(a3)
  232.         or.l    d5,(width*5)(a3)
  233.  
  234.         dbf    d7,.loop
  235.         rts
  236.  
  237. ***********************************************************
  238.  
  239. TakeSystem:    movea.l    4.w,a6        ; exec base
  240.         lea    $dff002,a5    ; custom chip base + 2
  241.  
  242.         lea    GraphicsName,a1    ; "graphics.library"
  243.         moveq    #0,d0        ; any version
  244.         CALL    OpenLibrary    ; open it.
  245.         move.l    d0,gfx_base    ; save pointer to gfx base
  246.         move.l    d0,a6        ; for later callls...
  247.  
  248.         move.l  gb_ActiView(a6),OldView    ; save old view
  249.  
  250.         move.w    #0,a1        ; clears full long-word
  251.         CALL    LoadView    ; Open a NULL view (resets display
  252.                     ;   on any Amiga)
  253.  
  254.         CALL    WaitTOF        ; Wait twice so that an interlace
  255.         CALL    WaitTOF        ;   display can reset.
  256.  
  257.         CALL    OwnBlitter    ; take over the blitter and...
  258.         CALL    WaitBlit    ;   wait for it to finish so we
  259.                     ;   safely use it as we please.
  260.  
  261.         movea.l    4.w,a6        ; exec base
  262.         CALL    Forbid        ; kill multitasking
  263.  
  264.         move.w    dmaconr-2(a5),d0    ; old DMACON bits
  265.         ori.w    #$8000,d0    ; or it set bit for restore
  266.         move.w    d0,OldDMACon    ; save it
  267.  
  268.         move.w    intenar-2(a5),d0    ; old INTEna bits
  269.         ori.w    #$c000,d0    ; or it set bit for restore
  270.         move.w    d0,OldINTEna    ; save it
  271.  
  272.         move.l    #$7fff7fff,intena-2(a5)    ; kill all ints
  273.         move.w    #$7fff,dmacon-2(a5)    ; kill all dma
  274.         rts
  275.  
  276. ***********************************************************
  277.  
  278. RestoreSystem:    lea    $dff002,a5    ; custom chip base + 2
  279.  
  280.     ; You must do these in this order or you're asking for trouble!
  281.         move.l    #$7fff7fff,intena-2(a5)    ; kill all ints
  282.         move.w    #$7fff,dmacon-2(a5)    ; kill all dma
  283.         move.w    OldDMACon,dmacon-2(a5)    ; restore old dma bits
  284.         move.w    OldINTEna,intena-2(a5)    ; restore old int bits
  285.  
  286.         move.l    OldView,a1    ; old Work Bench view
  287.         move.l    gfx_base,a6    ; gfx base
  288.         CALL    LoadView    ; Restore the view
  289.         CALL    DisOwnBlitter    ; give blitter back to the system.
  290.  
  291.         move.l    gb_CopInit(a6),$80-2(a5) ; restore system clist
  292.         move.l    a6,a1
  293.         movea.l    4.w,a6        ; exec base
  294.         CALL    CloseLibrary
  295.  
  296.     ; there is no call to Permit() because it is implied by the return
  297.     ; to AmigaDOS! :^)
  298.         rts
  299.  
  300. ***********************************************************
  301.  
  302.         section    pants,data
  303.  
  304. sinx_pointer1:    dc.l    sin_xtab
  305. sinx_pointer2:    dc.l    sin_xtab
  306. siny_pointer1:    dc.l    sin_ytab
  307. siny_pointer2:    dc.l    sin_ytab
  308. sinx_add1:    dc.w    1*2        ;change values here to obtain
  309. sinx_add2:    dc.w    5*2        ;new patterns
  310. siny_add1:    dc.w    3*2
  311. siny_add2:    dc.w    2*2
  312. sinx_dist1:    dc.w    4*2
  313. sinx_dist2:    dc.w    3*2
  314. siny_dist1:    dc.w    1*2
  315. siny_dist2:    dc.w    2*2
  316. number:        dc.w    0        ;number of 'pobs'
  317.  
  318. ClearBmap:    dc.l    screen+(height*width*2)
  319. ActiveBmap:    dc.l    screen+(height*width)
  320. VisualBmap:    dc.l    screen
  321.  
  322. GraphicsName:    GRAFNAME        ; name of gfx library
  323.         EVEN
  324.  
  325. sin_xtab:    dc.w    75,76,78,79,80,82,83,84
  326.         dc.w    85,87,88,89,91,92,93,94
  327.         dc.w    96,97,98,99,101,102,103,104
  328.         dc.w    106,107,108,109,110,111,112,114
  329.         dc.w    115,116,117,118,119,120,121,122
  330.         dc.w    123,124,125,126,127,128,129,130
  331.         dc.w    131,132,132,133,134,135,136,136
  332.         dc.w    137,138,139,139,140,141,141,142
  333.         dc.w    142,143,144,144,145,145,145,146
  334.         dc.w    146,147,147,147,148,148,148,149
  335.         dc.w    149,149,149,149,150,150,150,150
  336.         dc.w    150,150,150,150,150,150,150,150
  337.         dc.w    150,149,149,149,149,149,148,148
  338.         dc.w    148,147,147,147,146,146,145,145
  339.         dc.w    145,144,144,143,142,142,141,141
  340.         dc.w    140,139,139,138,137,136,136,135
  341.         dc.w    134,133,132,132,131,130,129,128
  342.         dc.w    127,126,125,124,123,122,121,120
  343.         dc.w    119,118,117,116,115,114,113,111
  344.         dc.w    110,109,108,107,106,104,103,102
  345.         dc.w    101,99,98,97,96,94,93,92
  346.         dc.w    91,89,88,87,85,84,83,82
  347.         dc.w    80,79,78,76,75,74,72,71
  348.         dc.w    70,68,67,66,65,63,62,61
  349.         dc.w    59,58,57,56,54,53,52,51
  350.         dc.w    49,48,47,46,44,43,42,41
  351.         dc.w    40,39,38,36,35,34,33,32
  352.         dc.w    31,30,29,28,27,26,25,24
  353.         dc.w    23,22,21,20,19,18,18,17
  354.         dc.w    16,15,14,14,13,12,11,11
  355.         dc.w    10,9,9,8,8,7,6,6
  356.         dc.w    5,5,5,4,4,3,3,3
  357.         dc.w    2,2,2,1,1,1,1,1
  358.         dc.w    0,0,0,0,0,0,0,0
  359.         dc.w    0,0,0,0,0,1,1,1
  360.         dc.w    1,1,2,2,2,3,3,3
  361.         dc.w    4,4,5,5,5,6,6,7
  362.         dc.w    8,8,9,9,10,11,11,12
  363.         dc.w    13,14,14,15,16,17,18,18
  364.         dc.w    19,20,21,22,23,24,25,26
  365.         dc.w    27,28,29,30,31,32,33,34
  366.         dc.w    35,36,37,39,40,41,42,43
  367.         dc.w    44,46,47,48,49,51,52,53
  368.         dc.w    54,56,57,58,59,61,62,63
  369.         dc.w    65,66,67,68,70,71,72,74
  370.         dc.w    75
  371.         dc.w    $eeee,$eeee,$eeee,$eeee
  372.         dc.w    $eeee,$eeee,$eeee,$eeee
  373.         dc.w    $eeee,$eeee,$eeee,$eeee
  374.         dc.w    $eeee,$eeee,$eeee,$eeee
  375.         dc.w    $eeee,$eeee,$eeee,$eeee
  376.         dc.w    $eeee,$eeee,$eeee,$eeee
  377.         dc.w    $eeee,$eeee,$eeee,$eeee
  378.         dc.w    $eeee,$eeee,$eeee,$eeee
  379.         dc.w    $eeee,$eeee,$eeee,$eeee
  380.         dc.w    $eeee,$eeee,$eeee,$eeee
  381.  
  382. sin_ytab:    dc.w    57,59,60,61,62,63,64,65
  383.         dc.w    66,66,67,68,69,70,71,72
  384.         dc.w    73,74,75,76,77,78,79,80
  385.         dc.w    81,82,83,84,84,85,86,87
  386.         dc.w    88,89,90,90,91,92,93,94
  387.         dc.w    94,95,96,97,97,98,99,100
  388.         dc.w    100,101,102,102,103,103,104,105
  389.         dc.w    105,106,106,107,107,108,108,109
  390.         dc.w    109,110,110,110,111,111,112,112
  391.         dc.w    112,112,113,113,113,114,114,114
  392.         dc.w    114,114,114,115,115,115,115,115
  393.         dc.w    115,115,115,115,115,115,115,115
  394.         dc.w    115,115,114,114,114,114,114,114
  395.         dc.w    113,113,113,112,112,112,112,111
  396.         dc.w    111,110,110,110,109,109,108,108
  397.         dc.w    107,107,106,106,105,105,104,103
  398.         dc.w    103,102,102,101,100,100,99,98
  399.         dc.w    97,97,96,95,94,94,93,92
  400.         dc.w    91,90,90,89,88,87,86,85
  401.         dc.w    84,84,83,82,81,80,79,78
  402.         dc.w    77,76,75,74,73,72,71,70
  403.         dc.w    69,68,67,66,66,65,64,63
  404.         dc.w    62,61,60,59,58,56,55,54
  405.         dc.w    53,52,51,50,49,49,48,47
  406.         dc.w    46,45,44,43,42,41,40,39
  407.         dc.w    38,37,36,35,34,33,32,31
  408.         dc.w    31,30,29,28,27,26,25,25
  409.         dc.w    24,23,22,21,21,20,19,18
  410.         dc.w    18,17,16,15,15,14,13,13
  411.         dc.w    12,12,11,10,10,9,9,8
  412.         dc.w    8,7,7,6,6,5,5,5
  413.         dc.w    4,4,3,3,3,3,2,2
  414.         dc.w    2,1,1,1,1,1,1,0
  415.         dc.w    0,0,0,0,0,0,0,0
  416.         dc.w    0,0,0,0,0,0,1,1
  417.         dc.w    1,1,1,1,2,2,2,3
  418.         dc.w    3,3,3,4,4,5,5,5
  419.         dc.w    6,6,7,7,8,8,9,9
  420.         dc.w    10,10,11,12,12,13,13,14
  421.         dc.w    15,15,16,17,18,18,19,20
  422.         dc.w    21,21,22,23,24,25,25,26
  423.         dc.w    27,28,29,30,31,31,32,33
  424.         dc.w    34,35,36,37,38,39,40,41
  425.         dc.w    42,43,44,45,46,47,48,49
  426.         dc.w    49,50,51,52,53,54,55,56
  427.         dc.w    57
  428.         dc.w    $eeee,$eeee,$eeee,$eeee
  429.         dc.w    $eeee,$eeee,$eeee,$eeee
  430.         dc.w    $eeee,$eeee,$eeee,$eeee
  431.         dc.w    $eeee,$eeee,$eeee,$eeee
  432.         dc.w    $eeee,$eeee,$eeee,$eeee
  433.         dc.w    $eeee,$eeee,$eeee,$eeee
  434.         dc.w    $eeee,$eeee,$eeee,$eeee
  435.         dc.w    $eeee,$eeee,$eeee,$eeee
  436.         dc.w    $eeee,$eeee,$eeee,$eeee
  437.         dc.w    $eeee,$eeee,$eeee,$eeee
  438.  
  439. pob_shape:    dc.w    %0000000110000000,0
  440.         dc.w    %0000000110000000,0
  441.         dc.w    %0000011111100000,0
  442.         dc.w    %0000011111100000,0
  443.         dc.w    %0000000110000000,0
  444.         dc.w    %0000000110000000,0
  445.  
  446. ***********************************************************
  447.  
  448.         section    stuff,data_c
  449.  
  450. copper:        dc.l     $008e2c81,$00902cc1
  451.         dc.l    $00920038,$009400d0
  452.         dc.l    $01080000,$010a0000
  453.         dc.l     $01001200,$01020000,$01040000
  454.         dc.l    $01800000,$01820ff0
  455. bmapptrs:    dc.l     $00e00000,$00e20000
  456.         dc.l     -2,-2
  457.  
  458. ***********************************************************
  459.  
  460.         section    Screens,bss_c
  461.  
  462. screen:        ds.b    (height*width*3)+(width*50)
  463.  
  464. shape_buffer:    ds.l    256
  465. pob_xbuffer:    ds.l    [width*8]
  466. pob_ybuffer:    ds.l    height
  467.  
  468. ***********************************************************
  469.  
  470.         section    OldPointers_and_such,bss
  471.  
  472. gfx_base    ds.l    1        ; pointer to graphics base
  473. OldView        ds.l    1        ; old Work Bench view addr.
  474.  
  475. OldDMACon:    ds.w    1        ; old dmacon bits
  476. OldINTEna:    ds.w    1        ; old intena bits
  477.  
  478. coord_stack:    ds.l    1500
  479.