home *** CD-ROM | disk | FTP | other *** search
/ M.u.C.S. Disc 2000 / MUCS2000.iso / falcon / modules / whipong / source / whipong.s < prev   
Text File  |  1999-06-29  |  10KB  |  660 lines

  1.    ; Copyright 1999 Tomas Berndtsson <tomas@nocrew.org>
  2.  
  3.       include    macros.s
  4.  
  5. VLM_MODULE    =    1
  6. GFXMODE    =    %100110100
  7. SHOWVBL    =    0
  8.  
  9. XRES    =    320
  10. YRES    =    240
  11.  
  12. PADSIZE    =    42
  13. BALLSIZE    =    4
  14.  
  15. NUMWIDTH    =    5
  16. NUMHEIGHT    =    5
  17.  
  18. P1NUMPOS    =    176
  19. P2NUMPOS    =    (XRES-44)*2-P1NUMPOS
  20.  
  21.     ifne    VLM_MODULE
  22.     opt    nodebug
  23.     output    d:\sound\whip!\vlm\whipong.vlm
  24.     include    vlmserv.s
  25.     endc
  26.  
  27.     text
  28.  
  29.     ifne    VLM_MODULE
  30.  
  31.     dc.b    "VLM2"
  32.     dc.l    infotext
  33.     dc.l    settings
  34.     dc.l    init
  35.     dc.l    deinit
  36.     dc.l    main
  37.  
  38.     else
  39.     
  40.     bsr.w    init
  41.  
  42.     endc
  43.  
  44.     ifne    VLM_MODULE
  45.     nop
  46.     endc
  47.  
  48. ;    nop
  49. main
  50.     bsr    scrswap
  51.  
  52.     ifne    SHOWVBL
  53.     move.l    scrp,a3
  54.     move.w    $468.w,d7
  55.     subq.w    #1,d7
  56. .vsl
  57.     move.l    #$ffffffff,(a3)+
  58.     move.l    #$00000000,(a3)+
  59.     dbra    d7,.vsl
  60.  
  61.     move.l    #$00000000,(a3)+
  62.     move.l    #$00000000,(a3)+
  63.     move.l    #$00000000,(a3)+
  64.     move.l    #$00000000,(a3)+
  65.     endc
  66.  
  67.     ifne    VLM_MODULE
  68.     vlm_wait_vbl
  69.     else
  70.     vsync
  71.     endc
  72.  
  73.     bsr    clrpads
  74.     bsr    clrball
  75.  
  76.     bsr    movepads
  77.     bsr    moveball
  78.  
  79.     bsr    drawpads
  80.     bsr    drawball
  81.     
  82.     ifne    VLM_MODULE
  83.  
  84.     rts
  85.     
  86.     else
  87.  
  88.     cmp.b    #$3b,$fffffc02.w
  89.     bne    main
  90.  
  91. slu
  92.     stdexit
  93.     pea    0.w
  94.     trap    #1
  95.  
  96.     endc
  97.  
  98. init    
  99.     ifne    VLM_MODULE
  100.  
  101.     move.l    a0,service_struct
  102.     vlm_set_resolution #VLM_320x240x16
  103.     
  104.     else
  105.  
  106.     super
  107.     stdinit    #-1,#-1,#GFXMODE
  108.  
  109.     endc
  110.     
  111.     clr.w    p1pos
  112.     clr.w    p2pos
  113.     move.w    #160-BALLSIZE/2,ballx
  114.     move.w    #160-BALLSIZE/2,ballx+2
  115.     move.w    #120-BALLSIZE/2,bally
  116.     move.w    #120-BALLSIZE/2,bally+2
  117.     move.w    option_speedx+2,balldx
  118.     move.w    option_speedy+2,balldy
  119.  
  120.     lea    savedback1,a0
  121.     lea    savedback2,a1
  122.     move.w    #BALLSIZE*BALLSIZE-1,d7
  123. .csbl
  124.     clr.w    (a0)+
  125.     clr.w    (a1)+
  126.     dbra    d7,.csbl
  127.  
  128.     lea    scr1,a0
  129.     lea    scr2,a1
  130.     move.w    #XRES*YRES/4-1,d7
  131. .csl
  132.     clr.l    (a0)+
  133.     clr.l    (a0)+
  134.     clr.l    (a1)+
  135.     clr.l    (a1)+
  136.     dbra    d7,.csl
  137.  
  138.     moveq    #0,d0
  139.     move.l    #P1NUMPOS,d1
  140.     bsr    drawwins
  141.     moveq    #0,d0
  142.     move.l    #P2NUMPOS,d1
  143.     bsr    drawwins
  144.  
  145.     rts
  146.  
  147. deinit
  148.     rts
  149.  
  150.  
  151. scrswap
  152.     ifeq    VLM_MODULE
  153.     move.l    scrp,-(sp)
  154.     move.l    scrp+4,scrp
  155.     move.b    1(sp),$ffff8201.w
  156.     move.b    2(sp),$ffff8203.w
  157.     move.b    3(sp),$ffff820d.w
  158.     move.l    (sp)+,scrp+4
  159.  
  160.     else
  161.  
  162.     move.l    scrp,tmpscrp
  163.     move.l    scrp+4,scrp
  164.     move.l    tmpscrp,scrp+4
  165.     vlm_set_scradr    tmpscrp
  166.  
  167.     endc
  168.  
  169.     move.w    p1pos,d0
  170.     move.w    p1pos+2,p1pos
  171.     move.w    d0,p1pos+2
  172.     move.w    p2pos,d0
  173.     move.w    p2pos+2,p2pos
  174.     move.w    d0,p2pos+2
  175.     move.w    ballx,d0
  176.     move.w    ballx+2,ballx
  177.     move.w    d0,ballx+2
  178.     move.w    bally,d0
  179.     move.w    bally+2,bally
  180.     move.w    d0,bally+2
  181.  
  182.     move.l    savedbackp,d0
  183.     move.l    savedbackp+4,savedbackp
  184.     move.l    d0,savedbackp+4
  185.  
  186.     rts
  187.  
  188.  
  189. drawpads
  190.     move.l    scrp,a0
  191.     move.w    p1pos,d0
  192.     mulu.w    #XRES*2,d0
  193.     add.l    d0,a0
  194.     move.w    #PADSIZE,d7
  195. .dp1l
  196.     move.l    #$ffffffff,(a0)
  197.     lea    XRES*2(a0),a0
  198.     dbra    d7,.dp1l
  199.  
  200.     move.l    scrp,a0
  201.     move.w    p2pos,d0
  202.     mulu.w    #XRES*2,d0
  203.     add.l    d0,a0
  204.     add.w    #(XRES-2)*2,a0
  205.     move.w    #PADSIZE,d7
  206. .dp2l
  207.     move.l    #$ffffffff,(a0)
  208.     lea    XRES*2(a0),a0
  209.     dbra    d7,.dp2l
  210.     
  211.     rts
  212.     
  213. drawball
  214.     move.l    scrp,a0
  215.     move.l    savedbackp,a1
  216.     move.w    ballx,d0
  217.     ext.l    d0
  218.     move.w    bally,d1
  219.     mulu.w    #XRES*2,d1
  220.     add.l    d1,a0
  221.     add.l    d0,a0
  222.     add.l    d0,a0
  223.     move.w    #BALLSIZE-1,d7
  224. .yl
  225.     move.w    #BALLSIZE-1,d6
  226. .xl
  227.     move.w    (a0),(a1)+
  228.     move.w    #$f800,(a0)+
  229.     dbra    d6,.xl
  230.     lea    (XRES-BALLSIZE)*2(a0),a0
  231.     dbra    d7,.yl
  232.     rts
  233.  
  234.  
  235. clrpads
  236.     move.l    scrp,a0
  237.     move.w    p1pos,d0
  238.     mulu.w    #640,d0
  239.     add.l    d0,a0
  240.     move.w    #PADSIZE,d7
  241. .dp1l
  242.     clr.l    (a0)
  243.     lea    640(a0),a0
  244.     dbra    d7,.dp1l
  245.  
  246.     move.l    scrp,a0
  247.     move.w    p2pos,d0
  248.     mulu.w    #640,d0
  249.     add.l    d0,a0
  250.     add.w    #318*2,a0
  251.     move.w    #PADSIZE,d7
  252. .dp2l
  253.     clr.l    (a0)
  254.     lea    640(a0),a0
  255.     dbra    d7,.dp2l
  256.     rts
  257.  
  258. clrball
  259.     move.l    scrp,a0
  260.     move.l    savedbackp,a1
  261.     move.w    ballx,d0
  262.     ext.l    d0
  263.     move.w    bally,d1
  264.     mulu.w    #XRES*2,d1
  265.     add.l    d1,a0
  266.     add.l    d0,a0
  267.     add.l    d0,a0
  268.     move.w    #BALLSIZE-1,d7
  269. .yl
  270.     move.w    #BALLSIZE-1,d6
  271. .xl
  272.     move.w    (a1)+,(a0)+
  273.     dbra    d6,.xl
  274.     lea    (XRES-BALLSIZE)*2(a0),a0
  275.     dbra    d7,.yl
  276.     rts
  277.     
  278. movepads
  279.     ifne    VLM_MODULE
  280.  
  281.     vlm_get_left_volume d7
  282.     and.l    #$ffff,d7
  283.     move.l    option_sense,d0
  284.     mulu.w    d0,d7
  285.     swap    d7
  286.     cmp.w    #YRES-PADSIZE,d7
  287.     blt.s    .lok
  288.     move.w    #YRES-PADSIZE-1,d7
  289. .lok
  290.     move.w    p1pos+2,d6
  291.     sub.w    d6,d7
  292.     bpl.s    .lnoneg
  293.     neg.w    d7
  294.     cmp.w    option_smooth+2,d7
  295.     ble.s    .lnotmin
  296.     move.w    option_smooth+2,d7
  297. .lnotmin
  298.     sub.w    d7,d6
  299.     move.w    d6,p1pos
  300.     bra.s    .ldone
  301. .lnoneg
  302.     cmp.w    option_smooth+2,d7
  303.     ble.s    .lnotmax
  304.     move.w    option_smooth+2,d7
  305. .lnotmax
  306.     add.w    d7,d6
  307.     move.w    d6,p1pos
  308. .ldone
  309.     vlm_get_right_volume d7
  310.     and.l    #$ffff,d7
  311.     move.l    option_sense,d0
  312.     mulu.w    d0,d7
  313.     swap    d7
  314.     cmp.w    #YRES-PADSIZE,d7
  315.     blt.s    .rok
  316.     move.w    #YRES-PADSIZE-1,d7
  317. .rok
  318.     
  319.     move.w    p2pos+2,d6
  320.     sub.w    d6,d7
  321.     bpl.s    .rnoneg
  322.     neg.w    d7
  323.     cmp.w    option_smooth+2,d7
  324.     ble.s    .rnotmin
  325.     move.w    option_smooth+2,d7
  326. .rnotmin
  327.     sub.w    d7,d6
  328.     move.w    d6,p2pos
  329.     bra.s    .rdone
  330. .rnoneg
  331.     cmp.w    option_smooth+2,d7
  332.     ble.s    .rnotmax
  333.     move.w    option_smooth+2,d7
  334. .rnotmax
  335.     add.w    d7,d6
  336.     move.w    d6,p2pos
  337. .rdone
  338.  
  339.     else
  340.  
  341.     addq.w    #1,p1pos
  342.     cmp.w    #YRES-PADSIZE,p1pos
  343.     blt.s    .noreset1
  344.     clr.w    p1pos
  345. .noreset1
  346.     addq.w    #1,p2pos
  347.     cmp.w    #YRES-PADSIZE,p2pos
  348.     blt.s    .noreset2
  349.     clr.w    p2pos
  350. .noreset2
  351.     endc
  352.     rts
  353.  
  354. moveball
  355.     move.w    ballx+2,d0
  356.     move.w    bally+2,d1
  357.     move.w    #2,d2
  358.     add.w    option_speedx+2,d2
  359.     cmp.w    d2,d0
  360.     bgt.s    .noxmin
  361.     move.w    p1pos+2,d2
  362.     sub.w    #BALLSIZE,d2
  363.     bpl.s    .notneg11
  364.     clr.w    d2
  365. .notneg11
  366.     cmp.w    d2,d1
  367.     blt.s    .sec1
  368.     add.w    #PADSIZE-BALLSIZE,d2
  369.     cmp.w    d2,d1
  370.     ble    .on1
  371. .sec1
  372.     move.w    p1pos,d2
  373.     sub.w    #BALLSIZE,d2
  374.     bpl.s    .notneg12
  375.     clr.w    d2
  376. .notneg12
  377.     cmp.w    d2,d1
  378.     blt    p2won
  379.     add.w    #PADSIZE-BALLSIZE,d2
  380.     cmp.w    d2,d1
  381.     bgt    p2won
  382. .on1
  383.     neg.w    balldx
  384. .noxmin
  385.     cmp.w    #0,d1
  386.     bgt.s    .noymin
  387.     neg.w    balldy
  388. .noymin
  389.     move.w    #XRES-BALLSIZE-2,d2
  390.     sub.w    option_speedx+2,d2
  391.     cmp.w    d2,d0
  392.     blt.s    .noxmax
  393.     move.w    p2pos+2,d2
  394.     sub.w    #BALLSIZE,d2
  395.     bpl.s    .notneg21
  396.     clr.w    d2
  397. .notneg21
  398.     cmp.w    d2,d1
  399.     blt    .sec2
  400.     add.w    #PADSIZE-BALLSIZE,d2
  401.     cmp.w    d2,d1
  402.     ble    .on2
  403. .sec2
  404.     move.w    p2pos,d2
  405.     sub.w    #BALLSIZE,d2
  406.     bpl.s    .notneg22
  407.     clr.w    d2
  408. .notneg22
  409.     cmp.w    d2,d1
  410.     blt    p1won
  411.     add.w    #PADSIZE-BALLSIZE,d2
  412.     cmp.w    d2,d1
  413.     bgt    p1won
  414. .on2
  415.     neg.w    balldx
  416. .noxmax
  417.     move.w    #YRES-BALLSIZE,d2
  418.     sub.w    option_speedy+2,d2
  419.     cmp.w    d2,d1
  420.     blt.s    .noymax
  421.     neg.w    balldy
  422. .noymax
  423.     
  424.     add.w    balldx,d0
  425.     move.w    d0,ballx
  426.     
  427.     add.w    balldy,d1
  428.     move.w    d1,bally
  429.     rts
  430.  
  431. p1won
  432.     moveq    #1,d0
  433.     move.w    p1wins,d1
  434.     abcd    d0,d1
  435.     move.w    d1,p1wins
  436.     move.w    p1wins,d0
  437.     move.l    #P1NUMPOS,d1
  438.     bsr    drawwins
  439.     move.w    #160,ballx
  440.     move.w    #120,bally
  441.     move.w    option_speedx+2,balldx
  442.     neg.w    balldx
  443.     rts
  444. p2won
  445.     moveq    #1,d0
  446.     move.w    p2wins,d1
  447.     abcd    d0,d1
  448.     move.w    d1,p2wins
  449.     move.w    p2wins,d0
  450.     move.l    #P2NUMPOS,d1
  451.     bsr    drawwins
  452.     move.w    #160,ballx
  453.     move.w    #120,bally
  454.     move.w    option_speedx+2,balldx
  455.     rts
  456.  
  457. drawwins
  458.     move.l    scrp,a0
  459.     lea    numbers,a1
  460.     moveq    #0,d2
  461.     move.b    d0,d2
  462.     lsr.w    #4,d2
  463.     mulu.w    #NUMWIDTH*NUMHEIGHT*2,d2
  464.     lea    (a1,d2.l),a3
  465.     lea    (a0,d1.l),a2
  466.     bsr    setnum
  467.  
  468.     moveq    #0,d2
  469.     move.b    d0,d2
  470.     and.w    #$f,d2
  471.     mulu.w    #NUMWIDTH*NUMHEIGHT*2,d2
  472.     lea    (a1,d2.l),a3
  473.     lea    (a0,d1.l),a2
  474.     lea    (NUMWIDTH+1)*4*2(a2),a2
  475.     bsr    setnum
  476.  
  477.     move.l    scrp+4,a0
  478.     moveq    #0,d2
  479.     move.b    d0,d2
  480.     lsr.w    #4,d2
  481.     mulu.w    #NUMWIDTH*NUMHEIGHT*2,d2
  482.     lea    (a1,d2.l),a3
  483.     lea    (a0,d1.l),a2
  484.     bsr    setnum
  485.  
  486.     moveq    #0,d2
  487.     move.b    d0,d2
  488.     and.w    #$f,d2
  489.     mulu.w    #NUMWIDTH*NUMHEIGHT*2,d2
  490.     lea    (a1,d2.l),a3
  491.     lea    (a0,d1.l),a2
  492.     lea    (NUMWIDTH+1)*4*2(a2),a2
  493.     bsr    setnum
  494.     rts
  495.  
  496.  
  497. setnum
  498.     move.w    #NUMHEIGHT-1,d7
  499. .yl
  500.     move.w    #NUMWIDTH-1,d6
  501. .xl
  502.     moveq    #0,d5
  503.     tst.w    (a3)+
  504.     beq.s    .set
  505.     move.w    #$07e0,d5
  506. .set
  507.     bsr    setdot
  508.     lea    4*2(a2),a2
  509.     dbra    d6,.xl
  510.     lea    (3*XRES+XRES-NUMWIDTH*4)*2(a2),a2
  511.     dbra    d7,.yl
  512.     rts
  513.  
  514. setdot
  515.     move.l    a2,a4
  516.     move.w    #4-1,d4
  517. .yl
  518.     move.w    #4-1,d3
  519. .xl
  520.     move.w    d5,(a4)+
  521.     dbra    d3,.xl
  522.     lea    (XRES-4)*2(a4),a4
  523.     dbra    d4,.yl
  524.     rts
  525.  
  526.  
  527.     data
  528.  
  529. scrp    dc.l    scr1,scr2
  530. savedbackp    dc.l    savedback1,savedback2
  531.  
  532. p1wins    dc.w    0
  533. p2wins    dc.w    0
  534.  
  535.     ifne    VLM_MODULE
  536. infotext    dc.b    'WHIPONG',0
  537.     dc.b    'Author:  NoBrain/NoCrew',0
  538.     dc.b    'Version: 0.42',0
  539.     dc.b    'Date:    1999-06-22',0
  540.     dc.b    0
  541.     even
  542.     
  543. settings    dc.l    4
  544.  
  545.     dc.l    par1name
  546.     dc.l    3
  547. option_sense    dc.l    YRES-PADSIZE
  548.     dc.l    sensestruct
  549.  
  550.     dc.l    par2name
  551.     dc.l    3
  552. option_smooth    dc.l    (YRES-PADSIZE)/2
  553.     dc.l    smoothstruct
  554.  
  555.     dc.l    par3name
  556.     dc.l    3
  557. option_speedx    dc.l    1
  558.     dc.l    speedstruct
  559.  
  560.     dc.l    par4name
  561.     dc.l    3
  562. option_speedy    dc.l    1
  563.     dc.l    speedstruct
  564.  
  565. par1name    dc.b    'SENSITIVITY',0
  566. par2name    dc.b    'SMOOTHNESS',0
  567. par3name    dc.b    'BALL X SPEED',0
  568. par4name    dc.b    'BALL Y SPEED',0
  569.     even
  570.  
  571. sensestruct    dc.l    0,2*YRES
  572. smoothstruct    dc.l    1,YRES-PADSIZE
  573. speedstruct    dc.l    1,8
  574.         
  575.     endc
  576.  
  577. numbers
  578.     dc.w    1,1,1,1,1
  579.     dc.w    1,0,0,0,1
  580.     dc.w    1,0,0,0,1
  581.     dc.w    1,0,0,0,1
  582.     dc.w    1,1,1,1,1
  583.  
  584.     dc.w    1,1,1,0,0
  585.     dc.w    0,0,1,0,0
  586.     dc.w    0,0,1,0,0
  587.     dc.w    0,0,1,0,0
  588.     dc.w    1,1,1,1,1
  589.  
  590.     dc.w    1,1,1,1,1
  591.     dc.w    0,0,0,0,1
  592.     dc.w    1,1,1,1,1
  593.     dc.w    1,0,0,0,0
  594.     dc.w    1,1,1,1,1
  595.  
  596.     dc.w    1,1,1,1,1
  597.     dc.w    0,0,0,0,1
  598.     dc.w    0,0,1,1,1
  599.     dc.w    0,0,0,0,1
  600.     dc.w    1,1,1,1,1
  601.  
  602.     dc.w    1,0,0,0,1
  603.     dc.w    1,0,0,0,1
  604.     dc.w    1,1,1,1,1
  605.     dc.w    0,0,0,0,1
  606.     dc.w    0,0,0,0,1
  607.  
  608.     dc.w    1,1,1,1,1
  609.     dc.w    1,0,0,0,0
  610.     dc.w    1,1,1,1,1
  611.     dc.w    0,0,0,0,1
  612.     dc.w    1,1,1,1,1
  613.  
  614.     dc.w    1,1,1,1,1
  615.     dc.w    1,0,0,0,0
  616.     dc.w    1,1,1,1,1
  617.     dc.w    1,0,0,0,1
  618.     dc.w    1,1,1,1,1
  619.  
  620.     dc.w    1,1,1,1,1
  621.     dc.w    0,0,0,0,1
  622.     dc.w    0,0,0,0,1
  623.     dc.w    0,0,0,0,1
  624.     dc.w    0,0,0,0,1
  625.  
  626.     dc.w    1,1,1,1,1
  627.     dc.w    1,0,0,0,1
  628.     dc.w    1,1,1,1,1
  629.     dc.w    1,0,0,0,1
  630.     dc.w    1,1,1,1,1
  631.  
  632.     dc.w    1,1,1,1,1
  633.     dc.w    1,0,0,0,1
  634.     dc.w    1,1,1,1,1
  635.     dc.w    0,0,0,0,1
  636.     dc.w    1,1,1,1,1
  637.  
  638.     bss
  639.  
  640.     ifne    VLM_MODULE
  641. tmpscrp    ds.l    1
  642. service_struct ds.l    1
  643.     endc
  644.  
  645. p1pos    ds.w    2
  646. p2pos    ds.w    2
  647. ballx    ds.w    2
  648. bally    ds.w    2
  649. balldx    ds.w    1
  650. balldy    ds.w    1
  651.  
  652. savedback1    ds.w    BALLSIZE*BALLSIZE
  653. savedback2    ds.w    BALLSIZE*BALLSIZE
  654.     
  655.     ifeq    VLM_MODULE
  656.     stdbss
  657.     endc
  658. scr1    ds.w    XRES*YRES
  659. scr2    ds.w    XRES*YRES
  660.