home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 92 / asm / source / fargo-old / sprite.asm < prev   
Encoding:
Assembly Source File  |  2001-07-01  |  5.1 KB  |  295 lines

  1.     @program    prog_code,prog_name
  2.  
  3. ;************** Start of Fargo program ***************
  4.  
  5. ; Fargo sprite demo
  6. ; Sprite routines by Rob Taylor
  7.  
  8. prog_code:
  9.     move.w    #$0700,d0
  10.     trap    #1
  11.     move.l    $64,old_int_1
  12.     bclr.b    #2,$600001
  13.     move.l    #int_1,$64
  14.     bset.b    #2,$600001
  15.     trap    #1
  16.  
  17.     move.l    #121,d6
  18.     move.l    #62,d7
  19.     move.l    #4,d4
  20.     lea    Spritedata(pc),a5
  21.  
  22. main_loop:
  23.     move.l    d6,d0
  24.     move.l    #10,d1
  25.     move.l    #10,d2
  26.     move.l    #3,d4
  27.  
  28.     jsr    hexlib[put_hex]
  29.     move.l    d7,d0
  30.     move.l    #10,d1
  31.     move.l    #20,d2
  32.     move.l    #3,d4
  33.     jsr    hexlib[put_hex]
  34.  
  35.     move.w    d6,d0
  36.     move.w    d7,d1
  37.     move.l    a5,a0
  38.  
  39.     bsr    PutSprite
  40.  
  41. test_key:
  42.     tst.w    ($75B0)
  43.     beq    test_arrow
  44.  
  45.     clr.w    ($75B0)
  46.     move.w    ($75B2),d0
  47.     cmp.w    #$108,d0
  48.     beq    exit
  49.  
  50. test_arrow:
  51.     move.w    ($75A0),d0
  52.     move.w    d0,d1
  53.     and.w    #$FFF0,d1
  54.     cmp.w    #$0050,d1
  55.     bne    wait_vbl
  56.  
  57. testdown:
  58.     btst    #1,d0
  59.     bne    testup
  60.     add.w    #1,d7
  61.     cmp.w    #112,d7
  62.     bcs    testup
  63.     move.w    #112,d7
  64.  
  65. testup:
  66.     btst    #3,d0
  67.     bne    testleft
  68.     sub.w    #1,d7
  69.     bcc    testleft
  70.     clr.w    d7
  71.  
  72. testleft:
  73.     btst    #2,d0
  74.     bne    testright
  75.     sub.w    #1,d6
  76.     bcc    testright
  77.     clr.w    d6
  78.  
  79. testright:
  80.     btst    #0,d0
  81.     bne    wait_vbl
  82.     add.w    #1,d6
  83.     cmp.w    #224,d6
  84.     bcs    wait_vbl
  85.     move.w    #224,d6
  86.  
  87. wait_vbl:
  88.     tst.w    vbl_phase
  89.     bne    wait_vbl
  90.     add.w    #4,vbl_phase
  91.  
  92.     bsr    RemoveSprite
  93.     bra    main_loop
  94.  
  95. exit:
  96.     move.w    #$0700,d0
  97.     trap    #1
  98.     bclr.b    #2,$600001
  99.     move.l    old_int_1,$64
  100.     bset.b    #2,$600001
  101.     trap    #1
  102.  
  103.     rts
  104.  
  105. ;*****************************************************
  106.  
  107. int_1:
  108.     add.w    #1,vbl_phase
  109.     and.w    #3,vbl_phase
  110.  
  111.     move.l    old_int_1,-(a7)
  112.     rts
  113.  
  114. ;*****************************************************
  115.  
  116. ;16*16 sprite put
  117. ;data is of the format
  118. ;32 bytes sprite
  119. ;32 bytes mask
  120. ;a0=pointer to sprite
  121. ;d0=x coord, d1=y coord
  122.  
  123. PutSprite:
  124.     move.w  d1,d2  multiply d1 by 30
  125.     lsl.w   #4,d1
  126.     sub.w   d2,d1
  127.     lsl.w   #1,d1
  128.     ext.l   d1
  129.     move.l  d1,a1
  130.  
  131.     move.w  d0,d2
  132.     and.w   #$F,d2
  133.     and.w   #$fff0,d0
  134.     asr.w   #3,d0
  135.     ext.l   d0
  136.     adda.l  d0,a1  a1=address to start putting sprite at
  137.     adda.l  #$004440,a1
  138.  
  139.     lea backstore(pc),a2
  140.  
  141.     move.l  a1,(a2)+
  142.     tst.w   d2
  143.     beq QuickPut    if x is on a word boundary we're OK
  144.     cmp.w   #8,d2
  145.     blt RightShift
  146.  
  147. LeftShift:
  148.     move.w  #1,(a2)+
  149.  
  150.     sub.w   #16,d2
  151.     neg.w   d2
  152.     move.w  #15,d3
  153. LeftLoop:
  154.  
  155.     move.l  (a1),d0
  156.     move.l  d0,(a2)+      store background
  157.  
  158.     clr.l   d1
  159.     move.w  32(a0),d1    get mask
  160.     lsl.l   d2,d1          shift it
  161.     not.l   d1
  162.     and.l   d1,d0         and with back
  163.     clr.l   d1
  164.     move.w  (a0)+,d1      get data
  165.     lsl.l   d2,d1          shift it
  166.     or.l    d1,d0           or with back+mask
  167.     move.l  d0,(a1)       put it on the screen
  168.     lea     30(a1),a1        next line
  169.     dbra    d3,LeftLoop      loop
  170.     rts
  171.  
  172. RightShift:
  173.     move.w #1,(a2)+
  174.     move.w #15,d3
  175. RightLoop:
  176.     move.l (a1),d0
  177.     move.l d0,(a2)+      store background
  178.  
  179.     clr.l d1
  180.     move.w 32(a0),d1    get mask
  181.     swap d1
  182.     lsr.l   d2,d1          shift it
  183.     not.l   d1
  184.     and.l   d1,d0         and with back
  185.  
  186.     clr.l d1
  187.     move.w (a0)+,d1      get data
  188.     swap d1
  189.     lsr.l d2,d1          shift it
  190.     or.l d1,d0           or with back+mask
  191.     move.l d0,(a1)       put it on the screen
  192.     lea 30(a1),a1        next line
  193.     dbra d3,RightLoop      loop
  194.     rts
  195.  
  196. QuickPut:
  197.     move.w #0,(a2)+
  198.     move.w #15,d3
  199. QuickLoop:
  200.     move.w (a1),d0
  201.     move.w d0,(a2)+      store background
  202.  
  203.     move.w 32(a0),d1    get mask
  204.     not.w   d1
  205.     and.w  d1,d0         and with back
  206.  
  207.     move.w (a0)+,d1      get data
  208.     or.w d1,d0           or with back+mask
  209.     move.w d0,(a1)       put it on the screen
  210.     lea 30(a1),a1        next line
  211.     dbra d3,QuickLoop      loop
  212.     rts
  213.  
  214. RemoveSprite:
  215.     lea backstore(pc),a1
  216.     move.l (a1)+,a0
  217.     tst.w (a1)+
  218.     beq QuickRemove
  219.  
  220.         move.w #15,d1
  221. RemoveLoop:
  222.     move.l (a1)+,(a0)
  223.     lea 30(a0),a0
  224.     dbra d1,RemoveLoop
  225.     rts
  226.  
  227. QuickRemove:
  228.     move.w #15,d1
  229. QRemoveLoop:
  230.     move.w (a1)+,(a0)
  231.     lea 30(a0),a0
  232.     dbra d1,QRemoveLoop
  233.     rts
  234.  
  235. ;*****************************************************
  236.  
  237. backstore:
  238.     dc.l 0
  239.     dc.w 0
  240.     dcb.l 16,0
  241.  
  242. ;*****************************************************
  243.  
  244. Spritedata:
  245.     dc.w    %1111000000001111
  246.     dc.w    %0111100000011110
  247.     dc.w    %0011110000111100
  248.     dc.w    %0001111001111000
  249.     dc.w    %0000111111110000
  250.     dc.w    %0000011111100000
  251.     dc.w    %0000001001000000
  252.     dc.w    %0000001001000000
  253.     dc.w    %0000001001000000
  254.     dc.w    %0000011111100000
  255.     dc.w    %0000111111110000
  256.     dc.w    %0001111001111000
  257.     dc.w    %0011110000111100
  258.     dc.w    %0111100000011110
  259.     dc.w    %1111000000001111
  260.     dc.w    %0000000000000000
  261.  
  262.     dc.w    %1111100000011111
  263.     dc.w    %1111110000111111
  264.     dc.w    %0111111001111110
  265.     dc.w    %0011111111111100
  266.     dc.w    %0001111111111000
  267.     dc.w    %0000111111110000
  268.     dc.w    %0000011111100000
  269.     dc.w    %0000011111100000
  270.     dc.w    %0000011111100000
  271.     dc.w    %0000111111110000
  272.     dc.w    %0001111111111000
  273.     dc.w    %0011111111111100
  274.     dc.w    %0111111001111110
  275.     dc.w    %1111110000111111
  276.     dc.w    %1111100000011111
  277.     dc.w    %1111000000001111
  278.  
  279. ;*****************************************************
  280.  
  281. old_int_1    dc.l    0
  282.  
  283. vbl_phase    dc.w    0
  284.  
  285. prog_name:
  286.     dc.b    "Sprite test",0
  287.     ds.w    0
  288.  
  289. ;*************** End of Fargo program ****************
  290.  
  291.     reloc_open
  292.     add_library    hexlib
  293.     reloc_close
  294.     end
  295.