Advertisement
Guest User

ArcadeVolleyball.c

a guest
Sep 18th, 2013
919
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 29.86 KB | None | 0 0
  1. /*
  2.    Arcade Volleyball
  3.    Copyright 1989 COMPUTE! Publications, Inc.
  4.    All rights reserved.
  5.  
  6.    Please excuse the unorthodox programming style presented in this code.
  7.    With three separate programmers working on one game, things tend to
  8.    get a bit sloppy.
  9. */
  10.  
  11. #include <exec/types.h>
  12. #include <exec/memory.h>
  13. #include <devices/audio.h>
  14. #include <stdio.h>
  15. #include <intuition/intuition.h>
  16. #include <graphics/gfx.h>
  17. #include <graphics/sprite.h>
  18.  
  19. #define NUMSAMPLES 3
  20. #define JIF1 75
  21. #define PER1 500
  22. #define JIF2 32
  23. #define PER2 500
  24.  
  25. struct Screen   *OpenScreen();
  26. struct Window   *OpenWindow();
  27. struct ViewPort *ViewPortAddress();
  28.  
  29. void    OpenStuff();
  30. void    InitShapes();
  31. void    Quit();
  32. USHORT *LoadSample();
  33. USHORT *AllocateMem();
  34. void    StartSound();
  35. void    UpdateSounds();
  36. void    GetPos();
  37. int     DoMenu();
  38. void    Delay();
  39. void    InitGame();
  40. void    CheckKeyboard();
  41. void    Game();
  42.  
  43. struct IntuitionBase *IntuitionBase = NULL;
  44. struct GfxBase *GfxBase = NULL;
  45.  
  46. struct TextAttr Font80 = {
  47.  "topaz.font",
  48.  TOPAZ_EIGHTY,
  49.  0,
  50.  FPF_ROMFONT
  51. };
  52.  
  53. struct Screen *AVScreen = NULL;
  54. struct NewScreen AVNewScreen = {
  55.  0,0,
  56.  320,200,
  57.  3,
  58.  3,0,
  59.  SPRITES,
  60.  CUSTOMSCREEN,
  61.  &Font80,
  62.  NULL,
  63.  NULL,
  64.  NULL
  65. };
  66.  
  67. struct ViewPort *AVViewPort = NULL;
  68. struct RastPort *AVRastPort = NULL;
  69. struct RastPort *TitleRastPort = NULL;
  70. struct Window *TitleWindow = NULL;
  71. struct Window *AVWindow = NULL;
  72. struct NewWindow NewTitleWindow = {
  73.  0,2,
  74.  280,10,
  75.  0,0,
  76.  NULL,
  77.  NOCAREREFRESH | BACKDROP | BORDERLESS | RMBTRAP,
  78.  NULL,
  79.  NULL,
  80.  NULL,
  81.  NULL,
  82.  NULL,
  83.  0,0,
  84.  0,0,
  85.  CUSTOMSCREEN
  86. };
  87. struct NewWindow AVNewWindow = {
  88.  4,13,
  89.  308,187,
  90.  0,7,
  91.  VANILLAKEY,
  92.  NOCAREREFRESH | BACKDROP | ACTIVATE | RMBTRAP,
  93.  NULL,
  94.  NULL,
  95.  NULL,
  96.  NULL,
  97.  NULL,
  98.  0,0,
  99.  0,0,
  100.  CUSTOMSCREEN
  101. };
  102.  
  103. USHORT chip AVSpriteData[20][56] = {
  104.  /* lmanOneLeft */
  105.  {0x0000,0x0000,
  106.   0x001A,0x000F,
  107.   0x00D1,0x002F,
  108.   0x0103,0x02FF,
  109.   0x04C7,0x033F,
  110.   0x0906,0x06FE,
  111.   0x1A86,0x057E,
  112.   0x1E52,0x01AE,
  113.   0x3FF3,0x000C,
  114.   0x3F4D,0x00B2,
  115.   0x37FB,0x0804,
  116.   0x3D41,0x02BE,
  117.   0x3A71,0x058E,
  118.   0x0FB8,0x1047,
  119.   0x1FC8,0x0037,
  120.   0x0C88,0x0377,
  121.   0x039B,0x0464,
  122.   0x02DD,0x0122,
  123.   0x0034,0x01CB,
  124.   0x0034,0x000B,
  125.   0x0000,0x0003,
  126.   0x0000,0x0001,
  127.   0x0000,0x0001,
  128.   0x0000,0x0003,
  129.   0x0003,0x0000,
  130.   0x0003,0x0003,
  131.   0x0007,0x0007,
  132.   0x0000,0x0000},
  133.  /* lmanOneRight */
  134.  {0x0000,0x0000,
  135.   0xC000,0xC000,
  136.   0xC800,0xF800,
  137.   0xF400,0xEC00,
  138.   0x30F8,0x3EF8,
  139.   0x1986,0x167E,
  140.   0x1901,0x56FF,
  141.   0x1FA1,0x005F,
  142.   0x2A08,0xD5F7,
  143.   0x3240,0xCDBE,
  144.   0xF000,0x0FF8,
  145.   0x3800,0x07C0,
  146.   0x0E00,0x01C0,
  147.   0x8380,0x0000,
  148.   0xE000,0x0000,
  149.   0x3800,0xC000,
  150.   0xB600,0x4800,
  151.   0x6000,0x9C00,
  152.   0x0000,0xF800,
  153.   0x0000,0xE000,
  154.   0x0000,0x0000,
  155.   0x0000,0x8000,
  156.   0x0000,0x8000,
  157.   0x0000,0x0000,
  158.   0x0000,0x0000,
  159.   0x8000,0x8000,
  160.   0xF800,0xF800,
  161.   0x0000,0x0000},
  162.  /* lmanTwoLeft */
  163.  {0x0000,0x0000,
  164.   0x001A,0x000F,
  165.   0x00D1,0x002F,
  166.   0x0103,0x02FF,
  167.   0x04C7,0x033F,
  168.   0x0906,0x06FE,
  169.   0x1A86,0x057E,
  170.   0x1E52,0x01AE,
  171.   0x3FF3,0x000C,
  172.   0x3F4D,0x00B2,
  173.   0x37FB,0x0804,
  174.   0x3D41,0x02BE,
  175.   0x3A71,0x058E,
  176.   0x0FB8,0x1047,
  177.   0x1FC8,0x0037,
  178.   0x0C88,0x0377,
  179.   0x039B,0x0464,
  180.   0x02DD,0x0122,
  181.   0x0034,0x01CB,
  182.   0x0034,0x000B,
  183.   0x0000,0x0007,
  184.   0x0000,0x000C,
  185.   0x0010,0x0008,
  186.   0x0030,0x0020,
  187.   0x0070,0x0070,
  188.   0x0018,0x0018,
  189.   0x000C,0x000C,
  190.   0x0000,0x0000},
  191.  /* lmanTwoRight */
  192.  {0x0000,0x0000,
  193.   0xC000,0xC000,
  194.   0xC800,0xF800,
  195.   0xF400,0xEC00,
  196.   0x30F8,0x3EF8,
  197.   0x1986,0x167E,
  198.   0x1901,0x56FF,
  199.   0x1FA1,0x005F,
  200.   0x2A08,0xD5F7,
  201.   0x3240,0xCDBE,
  202.   0xF000,0x0FF8,
  203.   0x3800,0x07C0,
  204.   0x0E00,0x01C0,
  205.   0x8380,0x0000,
  206.   0xE000,0x0000,
  207.   0x3800,0xC000,
  208.   0xB600,0x4800,
  209.   0x6000,0x9C00,
  210.   0x0000,0xF800,
  211.   0x0000,0xE000,
  212.   0x0000,0x8000,
  213.   0x0000,0xC000,
  214.   0x0000,0x6000,
  215.   0x0000,0x6000,
  216.   0x6000,0x0000,
  217.   0x7000,0x7000,
  218.   0xFF00,0xFF00,
  219.   0x0000,0x0000},
  220.  /* lmanThreeLeft */
  221.  {0x0000,0x0000,
  222.   0x001A,0x000F,
  223.   0x00D1,0x002F,
  224.   0x0103,0x02FF,
  225.   0x04C7,0x033F,
  226.   0x0906,0x06FE,
  227.   0x1A86,0x057E,
  228.   0x1E52,0x01AE,
  229.   0x3FF3,0x000C,
  230.   0x3F4D,0x00B2,
  231.   0x37FB,0x0804,
  232.   0x3D41,0x02BE,
  233.   0x3A71,0x058E,
  234.   0x0FB8,0x1047,
  235.   0x1FC8,0x0037,
  236.   0x0C88,0x0377,
  237.   0x039B,0x0464,
  238.   0x02DD,0x0122,
  239.   0x0034,0x01CB,
  240.   0x0034,0x000B,
  241.   0x0000,0x0003,
  242.   0x0000,0x0001,
  243.   0x0000,0x0007,
  244.   0x0018,0x0016,
  245.   0x0038,0x0030,
  246.   0x001C,0x001C,
  247.   0x0007,0x0007,
  248.   0x0000,0x0000},
  249.  /* lmanThreeRight */
  250.  {0x0000,0x0000,
  251.   0xC000,0xC000,
  252.   0xC800,0xF800,
  253.   0xF400,0xEC00,
  254.   0x30F8,0x3EF8,
  255.   0x1986,0x167E,
  256.   0x1901,0x56FF,
  257.   0x1FA1,0x005F,
  258.   0x2A08,0xD5F7,
  259.   0x3240,0xCDBE,
  260.   0xF000,0x0FF8,
  261.   0x3800,0x07C0,
  262.   0x0E00,0x01C0,
  263.   0x8380,0x0000,
  264.   0xE000,0x0000,
  265.   0x3800,0xC000,
  266.   0xB600,0x4800,
  267.   0x6000,0x9C00,
  268.   0x0000,0xF800,
  269.   0x0000,0xE000,
  270.   0x0000,0x0000,
  271.   0x0000,0x8000,
  272.   0x0000,0x8000,
  273.   0x0000,0x0000,
  274.   0x0000,0x0000,
  275.   0x0000,0x0000,
  276.   0x0000,0x0000,
  277.   0x0000,0x0000},
  278.  /* rmanOneLeft */
  279.  {0x0000,0x0000,
  280.   0x0000,0x0000,
  281.   0x0003,0x0002,
  282.   0x0007,0x0005,
  283.   0x07CB,0x07C7,
  284.   0x1FC2,0x183E,
  285.   0x3F12,0x20EE,
  286.   0x3628,0x29D6,
  287.   0x3EFF,0x0100,
  288.   0x1F7F,0x0080,
  289.   0x07EE,0x0011,
  290.   0x0070,0x000F,
  291.   0x0070,0x000C,
  292.   0x0000,0x0030,
  293.   0x0000,0x0000,
  294.   0x0000,0x0003,
  295.   0x0001,0x000E,
  296.   0x0007,0x0000,
  297.   0x0003,0x0000,
  298.   0x0000,0x0000,
  299.   0x0000,0x0000,
  300.   0x0000,0x0000,
  301.   0x0000,0x0000,
  302.   0x0000,0x0000,
  303.   0x0000,0x0000,
  304.   0x0000,0x0000,
  305.   0x0003,0x0003,
  306.   0x0000,0x0000},
  307.  /* rmanOneRight */
  308.  {0x0000,0x0000,
  309.   0x7E00,0x6B00,
  310.   0xF300,0xECE0,
  311.   0xFF20,0xF0D0,
  312.   0x3FD0,0x3828,
  313.   0x1FE0,0x181C,
  314.   0x9EC0,0x193E,
  315.   0x1F60,0x109E,
  316.   0x6010,0x9FEF,
  317.   0xC0C8,0x3F37,
  318.   0x0840,0xF7BF,
  319.   0x0FD0,0x102F,
  320.   0x0F82,0x107D,
  321.   0x0DC0,0x323E,
  322.   0x1E80,0xE17E,
  323.   0x7820,0x87DC,
  324.   0xA400,0x5BF8,
  325.   0xF820,0x07D0,
  326.   0xFA00,0x05E0,
  327.   0xC800,0x3700,
  328.   0x1800,0x0000,
  329.   0x3000,0x0000,
  330.   0x3000,0x0000,
  331.   0x1800,0x0000,
  332.   0x0000,0x1800,
  333.   0x3800,0x3800,
  334.   0xFC00,0xFC00,
  335.   0x0000,0x0000},
  336.  /* rmanTwoLeft */
  337.  {0x0000,0x0000,
  338.   0x0000,0x0000,
  339.   0x0003,0x0002,
  340.   0x0007,0x0005,
  341.   0x07CB,0x07C7,
  342.   0x1FC2,0x183E,
  343.   0x3F12,0x20EE,
  344.   0x3628,0x29D6,
  345.   0x3EFF,0x0100,
  346.   0x1F7F,0x0080,
  347.   0x07EE,0x0011,
  348.   0x0070,0x000F,
  349.   0x0070,0x000C,
  350.   0x0000,0x0030,
  351.   0x0000,0x0000,
  352.   0x0000,0x0003,
  353.   0x0001,0x000E,
  354.   0x0007,0x0000,
  355.   0x0003,0x0000,
  356.   0x0000,0x0000,
  357.   0x0000,0x0000,
  358.   0x0000,0x0000,
  359.   0x0000,0x0000,
  360.   0x0000,0x0000,
  361.   0x0000,0x0000,
  362.   0x0001,0x0001,
  363.   0x001F,0x001F,
  364.   0x0000,0x0000},
  365.  /* rmanTwoRight */
  366.  {0x0000,0x0000,
  367.   0x7E00,0x6B00,
  368.   0xF300,0xECE0,
  369.   0xFF20,0xF0D0,
  370.   0x3FD0,0x3828,
  371.   0x1FE0,0x181C,
  372.   0x9EC0,0x193E,
  373.   0x1F60,0x109E,
  374.   0x6010,0x9FEF,
  375.   0xC0C8,0x3F37,
  376.   0x0840,0xF7BF,
  377.   0x0FD0,0x102F,
  378.   0x0F82,0x107D,
  379.   0x0DC0,0x323E,
  380.   0x1E80,0xE17E,
  381.   0x7820,0x87DC,
  382.   0xA400,0x5BF8,
  383.   0xF820,0x07D0,
  384.   0xFA00,0x05E0,
  385.   0xC800,0x3700,
  386.   0x3C00,0x0000,
  387.   0x6600,0x0000,
  388.   0xC200,0x0100,
  389.   0xC080,0x0180,
  390.   0x01C0,0xC1C0,
  391.   0xC300,0xC300,
  392.   0xE600,0xE600,
  393.   0x0000,0x0000},
  394.  /* rmanThreeLeft */
  395.  {0x0000,0x0000,
  396.   0x0000,0x0000,
  397.   0x0003,0x0002,
  398.   0x0007,0x0005,
  399.   0x07CB,0x07C7,
  400.   0x1FC2,0x183E,
  401.   0x3F12,0x20EE,
  402.   0x3628,0x29D6,
  403.   0x3EFF,0x0100,
  404.   0x1F7F,0x0080,
  405.   0x07EE,0x0011,
  406.   0x0070,0x000F,
  407.   0x0070,0x000C,
  408.   0x0000,0x0030,
  409.   0x0000,0x0000,
  410.   0x0000,0x0003,
  411.   0x0001,0x000E,
  412.   0x0007,0x0000,
  413.   0x0003,0x0000,
  414.   0x0000,0x0000,
  415.   0x0000,0x0000,
  416.   0x0000,0x0000,
  417.   0x0000,0x0000,
  418.   0x0000,0x0000,
  419.   0x0000,0x0000,
  420.   0x0000,0x0000,
  421.   0x0000,0x0000,
  422.   0x0000,0x0000},
  423.  /* rmanThreeRight */
  424.  {0x0000,0x0000,
  425.   0x7E00,0x6B00,
  426.   0xF300,0xECE0,
  427.   0xFF20,0xF0D0,
  428.   0x3FD0,0x3828,
  429.   0x1FE0,0x181C,
  430.   0x9EC0,0x193E,
  431.   0x1F60,0x109E,
  432.   0x6010,0x9FEF,
  433.   0xC0C8,0x3F37,
  434.   0x0840,0xF7BF,
  435.   0x0FD0,0x102F,
  436.   0x0F82,0x107D,
  437.   0x0DC0,0x323E,
  438.   0x1E80,0xE17E,
  439.   0x7820,0x87DC,
  440.   0xA400,0x5BF8,
  441.   0xF820,0x07D0,
  442.   0xFA00,0x05E0,
  443.   0xC800,0x3700,
  444.   0x1800,0x0000,
  445.   0x3000,0x0000,
  446.   0x3C00,0x0000,
  447.   0x0D00,0x0300,
  448.   0x0180,0x0380,
  449.   0x0700,0x0700,
  450.   0x1C00,0x1C00,
  451.   0x0000,0x0000},
  452.  /* ballOneLeft */
  453.  {0x0000,0x0000,
  454.   0x00BF,0x00BF,
  455.   0x0352,0x0352,
  456.   0x07BF,0x07BF,
  457.   0x17C0,0x17C0,
  458.   0x1BEF,0x1BEF,
  459.   0x3CEF,0x3CEF,
  460.   0x3F6F,0x3F6F,
  461.   0xDF9E,0xDF9E,
  462.   0xEFDD,0xEFDD,
  463.   0xB3BD,0xB3BD,
  464.   0x5CBB,0x5CBB,
  465.   0xCF77,0xCF77,
  466.   0x56F7,0x56F7,
  467.   0xD1EF,0xD1EF,
  468.   0x57DF,0x57DF,
  469.   0x1BBE,0x1BBE,
  470.   0x2D79,0x2D79,
  471.   0x16F7,0x16F7,
  472.   0x052F,0x052F,
  473.   0x03CE,0x03CE,
  474.   0x0075,0x0075,
  475.   0x0000,0x0000,
  476.   0x0000,0x0000,
  477.   0x0000,0x0000,
  478.   0x0000,0x0000,
  479.   0x0000,0x0000,
  480.   0x0000,0x0000},
  481.  /* ballOneRight */
  482.  {0x0000,0x0000,
  483.   0x0000,0x0000,
  484.   0xE000,0xE000,
  485.   0x5000,0x5000,
  486.   0xE800,0xE800,
  487.   0x1C00,0x1C00,
  488.   0x6A00,0x6A00,
  489.   0x7500,0x7500,
  490.   0xF300,0xF300,
  491.   0xF580,0xF580,
  492.   0xED80,0xED80,
  493.   0xEE00,0xEE00,
  494.   0xDC80,0xDC80,
  495.   0xDD80,0xDD80,
  496.   0xBA80,0xBA80,
  497.   0x7B00,0x7B00,
  498.   0xF700,0xF700,
  499.   0xEE00,0xEE00,
  500.   0x9400,0x9400,
  501.   0x7800,0x7800,
  502.   0x6000,0x6000,
  503.   0x0000,0x0000,
  504.   0x0000,0x0000,
  505.   0x0000,0x0000,
  506.   0x0000,0x0000,
  507.   0x0000,0x0000,
  508.   0x0000,0x0000,
  509.   0x0000,0x0000},
  510.  /* ballTwoLeft */
  511.  {0x0000,0x0000,
  512.   0x0075,0x0075,
  513.   0x03CE,0x03CE,
  514.   0x052F,0x052F,
  515.   0x16F7,0x16F7,
  516.   0x2D79,0x2D79,
  517.   0x1BBE,0x1BBE,
  518.   0x57DF,0x57DF,
  519.   0xD1EF,0xD1EF,
  520.   0x56F7,0x56F7,
  521.   0xCF77,0xCF77,
  522.   0x5CBB,0x5CBB,
  523.   0xB3BD,0xB3BD,
  524.   0xEFDD,0xEFDD,
  525.   0xDF9E,0xDF9E,
  526.   0x3F6F,0x3F6F,
  527.   0x3CEF,0x3CEF,
  528.   0x1BEF,0x1BEF,
  529.   0x17C0,0x17C0,
  530.   0x07BF,0x07BF,
  531.   0x0352,0x0352,
  532.   0x00BF,0x00BF,
  533.   0x0000,0x0000,
  534.   0x0000,0x0000,
  535.   0x0000,0x0000,
  536.   0x0000,0x0000,
  537.   0x0000,0x0000,
  538.   0x0000,0x0000},
  539.  /* ballTwoRight */
  540.  {0x0000,0x0000,
  541.   0x0000,0x0000,
  542.   0x6000,0x6000,
  543.   0x7800,0x7800,
  544.   0x9400,0x9400,
  545.   0xEE00,0xEE00,
  546.   0xF700,0xF700,
  547.   0x7B00,0x7B00,
  548.   0xBA80,0xBA80,
  549.   0xDD80,0xDD80,
  550.   0xDC80,0xDC80,
  551.   0xEE00,0xEE00,
  552.   0xED80,0xED80,
  553.   0xF580,0xF580,
  554.   0xF300,0xF300,
  555.   0x7500,0x7500,
  556.   0x6A00,0x6A00,
  557.   0x1C00,0x1C00,
  558.   0xE800,0xE800,
  559.   0x5000,0x5000,
  560.   0xE000,0xE000,
  561.   0x0000,0x0000,
  562.   0x0000,0x0000,
  563.   0x0000,0x0000,
  564.   0x0000,0x0000,
  565.   0x0000,0x0000,
  566.   0x0000,0x0000,
  567.   0x0000,0x0000},
  568.  /* ballThreeLeft */
  569.  {0x0000,0x0000,
  570.   0x0057,0x0057,
  571.   0x0339,0x0339,
  572.   0x0F7A,0x0F7A,
  573.   0x14F7,0x14F7,
  574.   0x3BCF,0x3BCF,
  575.   0x77BE,0x77BE,
  576.   0x6F7D,0x6F7D,
  577.   0xAEFB,0xAEFB,
  578.   0xDDF7,0xDDF7,
  579.   0x9DF7,0x9DF7,
  580.   0x3BEE,0x3BEE,
  581.   0xDBDE,0xDBDE,
  582.   0xD7DD,0xD7DD,
  583.   0x67BC,0x67BC,
  584.   0x577B,0x577B,
  585.   0x2B7B,0x2B7B,
  586.   0x1C7B,0x1C7B,
  587.   0x0B81,0x0B81,
  588.   0x057E,0x057E,
  589.   0x03A5,0x03A5,
  590.   0x007E,0x007E,
  591.   0x0000,0x0000,
  592.   0x0000,0x0000,
  593.   0x0000,0x0000,
  594.   0x0000,0x0000,
  595.   0x0000,0x0000,
  596.   0x0000,0x0000},
  597.  /* ballThreeRight */
  598.  {0x0000,0x0000,
  599.   0x0000,0x0000,
  600.   0xE000,0xE000,
  601.   0x5000,0x5000,
  602.   0xB400,0xB400,
  603.   0x5A00,0x5A00,
  604.   0xEC00,0xEC00,
  605.   0xF500,0xF500,
  606.   0xC580,0xC580,
  607.   0xB500,0xB500,
  608.   0x7980,0x7980,
  609.   0x9D00,0x9D00,
  610.   0xE680,0xE680,
  611.   0xFB80,0xFB80,
  612.   0xFD80,0xFD80,
  613.   0x7E00,0x7E00,
  614.   0x9E00,0x9E00,
  615.   0xEC00,0xEC00,
  616.   0xF400,0xF400,
  617.   0xF000,0xF000,
  618.   0x6000,0x6000,
  619.   0x8000,0x8000,
  620.   0x0000,0x0000,
  621.   0x0000,0x0000,
  622.   0x0000,0x0000,
  623.   0x0000,0x0000,
  624.   0x0000,0x0000,
  625.   0x0000,0x0000},
  626.  /* ballFourLeft */
  627.  {0x0000,0x0000,
  628.   0x007E,0x007E,
  629.   0x03A5,0x03A5,
  630.   0x057E,0x057E,
  631.   0x0B81,0x0B81,
  632.   0x1C7B,0x1C7B,
  633.   0x2B7B,0x2B7B,
  634.   0x577B,0x577B,
  635.   0x67BC,0x67BC,
  636.   0xD7DD,0xD7DD,
  637.   0xDBDE,0xDBDE,
  638.   0x3BEE,0x3BEE,
  639.   0x9DF7,0x9DF7,
  640.   0xDDF7,0xDDF7,
  641.   0xAEFB,0xAEFB,
  642.   0x6F7D,0x6F7D,
  643.   0x77BE,0x77BE,
  644.   0x3BCF,0x3BCF,
  645.   0x14F7,0x14F7,
  646.   0x0F7A,0x0F7A,
  647.   0x0339,0x0339,
  648.   0x0057,0x0057,
  649.   0x0000,0x0000,
  650.   0x0000,0x0000,
  651.   0x0000,0x0000,
  652.   0x0000,0x0000,
  653.   0x0000,0x0000,
  654.   0x0000,0x0000},
  655.  /* ballFourLeft */
  656.  {0x0000,0x0000,
  657.   0x8000,0x8000,
  658.   0x6000,0x6000,
  659.   0xF000,0xF000,
  660.   0xF400,0xF400,
  661.   0xEC00,0xEC00,
  662.   0x9E00,0x9E00,
  663.   0x7E00,0x7E00,
  664.   0xFD80,0xFD80,
  665.   0xFB80,0xFB80,
  666.   0xE680,0xE680,
  667.   0x9D00,0x9D00,
  668.   0x7980,0x7980,
  669.   0xB500,0xB500,
  670.   0xC580,0xC580,
  671.   0xF500,0xF500,
  672.   0xEC00,0xEC00,
  673.   0x5A00,0x5A00,
  674.   0xB400,0xB400,
  675.   0x5000,0x5000,
  676.   0xE000,0xE000,
  677.   0x0000,0x0000,
  678.   0x0000,0x0000,
  679.   0x0000,0x0000,
  680.   0x0000,0x0000,
  681.   0x0000,0x0000,
  682.   0x0000,0x0000,
  683.   0x0000,0x0000}
  684. };
  685. struct SimpleSprite AVSprites[] = {
  686.  {NULL,26,0,0,0},
  687.  {NULL,26,0,0,0},
  688.  {NULL,26,0,0,0},
  689.  {NULL,26,0,0,0},
  690.  {NULL,26,0,0,0},
  691.  {NULL,26,0,0,0}
  692. };
  693.  
  694. struct {
  695.  int left, right, up;
  696. } keymove[2];
  697.  
  698. char *menu[5] = {
  699.  {"    Human vs. Human    "},
  700.  {"  Human vs. Computer   "},
  701.  {"  Computer vs. Human   "},
  702.  {" Computer vs. Computer "},
  703.  {"         Quit          "}
  704. };
  705.  
  706. char opts[2] = {
  707.  {'C'},
  708.  {'C'}
  709. };
  710.  
  711. USHORT *waveform[NUMSAMPLES];
  712. USHORT wavelength[NUMSAMPLES];
  713. USHORT *dmaconw = (USHORT *)0xDFF096;
  714. USHORT inuse[4];
  715.  
  716. int x[2], px[2], y[2], frame[2], frameindex[2], rebound[2], score[2],
  717.     bx, by, pbx, pby, tbx, tby, bvelx, bvely, blogic, bframe, bindex,
  718.     serve, server, servevel, compserve, hits, hitter, starter,
  719.     gravity, sstage, bytop, rnd, endgame, xit, menuon, jflag,
  720.     polecol[]={0,1,2,3,3,4,6,7,9,14},
  721.     jump[]={-4,-4,-3,-3,-3,-3,-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,-1, 0, 0,
  722.              0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4};
  723.  
  724.  
  725. int CXBRK()
  726. {
  727.  return(0);
  728. }
  729.  
  730. void main()
  731. {
  732.  printf("\n");
  733.  printf("\n");
  734.  printf("          Arcade Volleyball\n");
  735.  printf("  Copyright 1989 COMPUTE! Pub., Inc.\n");
  736.  printf("         All Rights Reserved\n");
  737.  OpenStuff();InitShapes();
  738.  inuse[0]=inuse[1]=inuse[2]=inuse[3]=starter=xit=0;
  739.  while (!xit) {
  740.   Game();
  741.   starter=starter^1;
  742.  }
  743.  Quit(0);
  744. }
  745.  
  746. void OpenStuff()
  747. {
  748.  waveform[0]=LoadSample("samples/hit.sample",&wavelength[0]);
  749.  waveform[1]=LoadSample("samples/loss.sample",&wavelength[1]);
  750.  waveform[2]=LoadSample("samples/point.sample",&wavelength[2]);
  751.  if ((IntuitionBase=
  752.   (struct IntiutionBase *)OpenLibrary("intuition.library",0))==NULL)
  753.   Quit(1);
  754.  if ((GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0))==NULL)
  755.   Quit(1);
  756.  if ((AVScreen=OpenScreen(&AVNewScreen))==NULL)
  757.   Quit(1);
  758.  AVNewWindow.Screen=AVScreen;NewTitleWindow.Screen=AVScreen;
  759.  if ((AVWindow=OpenWindow(&AVNewWindow))==NULL)
  760.   Quit(1);
  761.  if ((TitleWindow=OpenWindow(&NewTitleWindow))==NULL)
  762.   Quit(1);
  763.  ShowTitle(AVScreen,FALSE);
  764.  AVViewPort=ViewPortAddress(AVWindow);
  765.  AVRastPort=AVWindow->RPort;TitleRastPort=TitleWindow->RPort;
  766. }
  767.  
  768. void InitShapes()
  769. {
  770.  BYTE i;
  771.  
  772.  for (i=2;i<8;i++) if (GetSprite(&AVSprites[i-2],i)!=i) Quit(1);
  773.  SetRGB4(AVViewPort,0,0,0,0);
  774.  SetRGB4(AVViewPort,1,0,0,0);
  775.  SetRGB4(AVViewPort,2,0,0,0);
  776.  SetRGB4(AVViewPort,21,8,15,8);
  777.  SetRGB4(AVViewPort,22,6,12,6);
  778.  SetRGB4(AVViewPort,23,12,13,12);
  779.  SetRGB4(AVViewPort,25,15,8,8);
  780.  SetRGB4(AVViewPort,26,12,6,6);
  781.  SetRGB4(AVViewPort,27,13,12,12);
  782.  SetRGB4(AVViewPort,29,12,12,12);
  783.  SetRGB4(AVViewPort,30,12,12,12);
  784.  SetRGB4(AVViewPort,31,12,12,12);
  785.  SetRGB4(AVViewPort,6,6,8,12);
  786.  SetRGB4(AVViewPort,7,5,7,8);
  787.  SetAPen(AVRastPort,7);
  788.  RectFill(AVRastPort,149,93,155,189);
  789.  SetAPen(AVRastPort,6);
  790.  RectFill(AVRastPort,150,94,154,188);
  791.  SetAPen(TitleRastPort,3);
  792.  Move(TitleRastPort,32,8);
  793.  Text(TitleRastPort,"00     Arcade Volleyball     00",31);
  794. }
  795.  
  796. void Quit(e)
  797. int e;
  798. {
  799.  BYTE i;
  800.  
  801.  *dmaconw=0x000F;
  802.  for (i=2;i<8;i++)
  803.   if (AVSprites[i-2].num==i) FreeSprite(i);
  804.  for (i=0;i<NUMSAMPLES;i++)
  805.   if (waveform[i]) FreeMem(waveform[i],wavelength[i]<<1);
  806.  if (TitleWindow) CloseWindow(TitleWindow);
  807.  if (AVWindow) CloseWindow(AVWindow);
  808.  if (AVScreen) CloseScreen(AVScreen);
  809.  if (GfxBase) CloseLibrary(GfxBase);
  810.  if (IntuitionBase) CloseLibrary(IntuitionBase);
  811.  exit(e);
  812. }
  813.  
  814. USHORT *LoadSample(filename,length)
  815. char *filename;
  816. USHORT *length;
  817. {
  818.   FILE *file;
  819.   USHORT *buffer;
  820.   ULONG size;
  821.  
  822.   if((file=fopen(filename,"r"))==NULL)
  823.     return(NULL);
  824.   fseek(file,0L,2);
  825.   size = ftell(file) & ~1L;
  826.   fseek(file,0L,0);
  827.   if((buffer=AllocateMem(size,MEMF_CHIP))==NULL) {
  828.     fclose(file);
  829.     return(NULL);
  830.   }
  831.   *length=(USHORT)(fread((UBYTE *)buffer,1,(int)size,file)>>1);
  832.   fclose(file);
  833.   return(buffer);
  834. }
  835.  
  836. USHORT *AllocateMem(size,requirements)
  837. ULONG size, requirements;
  838. {
  839.   if(AvailMem(requirements)-size<=32000L)
  840.     return(NULL);
  841.   return((void *)AllocMem(size,requirements));
  842. }
  843.  
  844. void StartSound(locat,len,jiffs,per,vol,chan)
  845. USHORT *locat;
  846. USHORT len;
  847. int jiffs;
  848. USHORT per,vol,chan;
  849. {
  850.  USHORT *dmaconw = (USHORT *)0xDFF096;
  851.  ULONG *audioaddr[4] = {
  852.   {(ULONG *)0xDFF0A0},
  853.   {(ULONG *)0xDFF0B0},
  854.   {(ULONG *)0xDFF0C0},
  855.   {(ULONG *)0xDFF0D0},
  856.  };
  857.  USHORT *audiolen[4] = {
  858.   {(USHORT *)0xDFF0A4},
  859.   {(USHORT *)0xDFF0B4},
  860.   {(USHORT *)0xDFF0C4},
  861.   {(USHORT *)0xDFF0D4},
  862.  };
  863.  USHORT *audioper[4] = {
  864.   {(USHORT *)0xDFF0A6},
  865.   {(USHORT *)0xDFF0B6},
  866.   {(USHORT *)0xDFF0C6},
  867.   {(USHORT *)0xDFF0D6},
  868.  };
  869.  USHORT *audiovol[4] = {
  870.   {(USHORT *)0xDFF0A8},
  871.   {(USHORT *)0xDFF0B8},
  872.   {(USHORT *)0xDFF0C8},
  873.   {(USHORT *)0xDFF0D8},
  874.  };
  875.  if (locat!=NULL) {
  876.   if (inuse[chan]==0) {
  877.    inuse[chan]=jiffs;
  878.    *audioaddr[chan]=(ULONG)locat;
  879.    *audiolen[chan]=len;
  880.    *audioper[chan]=per;
  881.    *audiovol[chan]=vol;
  882.    switch(chan) {
  883.     case 0: *dmaconw=0x8201;break;
  884.     case 1: *dmaconw=0x8202;break;
  885.     case 2: *dmaconw=0x8204;break;
  886.     case 3: *dmaconw=0x8208;break;
  887.     default: break;
  888.    }
  889.   }
  890.  }
  891. }
  892.  
  893. void UpdateSounds()
  894. {
  895.  int i;
  896.  
  897.  for (i=0;i<4;i++) {
  898.   if (inuse[i]!=0) {
  899.    inuse[i]--;
  900.    if (inuse[i]==0) {
  901.     switch(i) {
  902.      case 0: *dmaconw=0x1;break;
  903.      case 1: *dmaconw=0x2;break;
  904.      case 2: *dmaconw=0x4;break;
  905.      case 3: *dmaconw=0x8;break;
  906.     }
  907.    }
  908.   }
  909.  }
  910. }
  911.  
  912. int DoMenu()
  913. {
  914.  int i;
  915.  static int opt=0;
  916.  static int reprint=1;
  917.  static int timer=0;
  918.  static USHORT lastjoy = 0xFFFF;
  919.  USHORT *joy = (USHORT *)0xDFF00C;
  920.  USHORT *firereg = (USHORT *)0xBFE0FE;
  921.  
  922.  if ((timer++==10) || (lastjoy!=*joy)) {
  923.   if (*joy&0x01) {
  924.    opt++;if (opt>4) opt=0;
  925.    reprint=1;
  926.   }
  927.   if (*joy&0x100) {
  928.    opt--;if (opt<0) opt=4;
  929.    reprint=1;
  930.   }
  931.   timer=0;
  932.  }
  933.  lastjoy=*joy;
  934.  
  935.  if (reprint) {
  936.   for (i=0;i<5;i++) {
  937.    if (i!=opt) {
  938.     SetAPen(AVRastPort,7);
  939.     SetBPen(AVRastPort,0);
  940.    } else {
  941.     SetAPen(AVRastPort,0);
  942.     SetBPen(AVRastPort,7);
  943.    }
  944.    Move(AVRastPort,64,28+i*10);
  945.    Text(AVRastPort,menu[i],23);
  946.   }
  947.   reprint=0;
  948.  }
  949.  
  950.  if ((*firereg&(0x80))==0) {
  951.   switch (opt) {
  952.    case 0: opts[0]=opts[1]='H';break;
  953.    case 1: opts[0]='H';opts[1]='C';jflag=1;break;
  954.    case 2: opts[0]='C';opts[1]='H';break;
  955.    case 3: opts[0]='C';opts[1]='C';break;
  956.    case 4: endgame=xit=1;break;
  957.    default: break;
  958.   }
  959.   if (!xit) {
  960.    SetAPen(AVRastPort,0);
  961.    RectFill(AVRastPort,64,22,248,72);
  962.    InitGame();Delay(50);
  963.    reprint=1;
  964.   }
  965.  }
  966.  return(!reprint);
  967. }
  968.  
  969. void joystick(pl)
  970. int pl;
  971. {
  972.  USHORT *joy[2] = {
  973.   {(USHORT *)0xDFF00A},
  974.   {(USHORT *)0xDFF00C}
  975.  };
  976.  USHORT *firereg = (USHORT *)0xBFE0FE;
  977.  
  978.  keymove[pl].right=0;
  979.  keymove[pl].left=0;
  980.  keymove[pl].up=0;
  981.  if ((*joy[pl^jflag]&0x0002)==0) keymove[pl].left=-2;
  982.  if ((*joy[pl^jflag]&0x0200)==0) keymove[pl].right=2;
  983.  if ((*firereg&(0x40<<(pl^jflag)))==0) keymove[pl].up=1;
  984. }
  985.  
  986. void GetPos()
  987. {
  988.  int i, tx, velx, bnd;
  989.  
  990.  for (i=0;i<2;i++)
  991.  {
  992.   if (keymove[i].up && frameindex[i]==-1) frameindex[i]=0;
  993.   tx=x[i]+(velx=keymove[i].left+keymove[i].right);
  994.   bnd=3+i*155;
  995.   if (velx>0) {
  996.    if (tx<bnd+119)
  997.     x[i]=tx;
  998.    else
  999.     x[i]=bnd+119;
  1000.   }
  1001.   else
  1002.    if (tx>bnd)
  1003.     x[i]=tx;
  1004.    else
  1005.     x[i]=bnd;
  1006.   if (frameindex[i]==-2) {
  1007.    y[i]=173;
  1008.    frame[i]=0;
  1009.    frameindex[i]=-1;
  1010.   }
  1011.   if (frameindex[i]==-1) {
  1012.    if (velx!=0) {
  1013.     if (abs(px[i]-x[i])>4) {
  1014.      frame[i]^=1;
  1015.      px[i]=x[i];
  1016.     }
  1017.    }
  1018.    else
  1019.     frame[i]=0;
  1020.   }
  1021.   else {
  1022.    frame[i]=2+(frameindex[i]>18);
  1023.    if (frameindex[i]==19) y[i]-=4;
  1024.    y[i]+=jump[frameindex[i]++];
  1025.    if (frameindex[i]>37) frameindex[i]=-2;
  1026.   }
  1027.  }
  1028. }
  1029.  
  1030. int moveball()
  1031. {
  1032.  int rbvelx, rbvely, hitfloor;
  1033.  
  1034.  rbvelx=bvelx;rbvely=bvely;
  1035.  if (rbvelx>319) rbvelx=319;
  1036.  if (rbvelx<-319) rbvelx=-319;
  1037.  if (rbvely>319) rbvely=319;
  1038.  if (rbvely<-319) rbvely=-319;
  1039.  pbx=tbx;pby=tby;
  1040.  bx+=rbvelx;by+=rbvely;
  1041.  if (bx<320) {
  1042.   bx=320;
  1043.   rbvelx=-rbvelx;
  1044.   rbvelx-=rbvelx>>4;
  1045.   rbvely-=rbvely>>4;
  1046.   if (hitter==1) {
  1047.    hitter=2;
  1048.    hits=0;
  1049.   }
  1050.  }
  1051.  if (bx>18112) {
  1052.   bx=18112;
  1053.   rbvelx=-rbvelx;
  1054.   rbvelx-=rbvelx>>4;
  1055.   rbvely-=rbvely>>4;
  1056.   if (hitter==0) {
  1057.    hitter=2;
  1058.    hits=0;
  1059.   }
  1060.  }
  1061.  if (by<832) {
  1062.   by=832;
  1063.   rbvely=-rbvely;
  1064.   rbvelx-=rbvelx>>4;
  1065.   rbvely-=rbvely>>4;
  1066.  }
  1067.  if (by>11392) {
  1068.   by=11392;
  1069.   rbvely=-rbvely;
  1070.   hitfloor=0;
  1071.  }
  1072.  else
  1073.   hitfloor=1;
  1074.  if (rbvely>0)
  1075.   rbvely+=1;
  1076.  else
  1077.   rbvely+=1;
  1078.  tbx=bx>>6;tby=by>>6;
  1079.  bvelx=rbvelx;bvely=rbvely;
  1080.  return(hitfloor);
  1081. }
  1082.  
  1083. void docollisions()
  1084. {
  1085.  int i, dx, dy, dist, rndoff, avy, jif, per;
  1086.  
  1087.  for (i=0;i<2;i++) {
  1088.   dx=tbx-x[i]-i*7;dy=tby-y[i]>>1;
  1089.   dist=(dx>>2)*dx+dy*dy;
  1090.   if (dist<110) {
  1091.    rndoff=8-(rnd&15);
  1092.    if (frameindex[i]>-1)
  1093.     bvely=-abs(bvely)+(jump[frameindex[i]]<<(3<<servevel));
  1094.    else
  1095.     bvely=-abs(bvely);
  1096.    bvely+=rndoff;
  1097.    bvelx+=dx*abs(dx)+(keymove[i].right+keymove[i].left<<(4+servevel))+rndoff;
  1098.    if (!rebound[i]) {
  1099.     if (!menuon) {
  1100.      avy=abs(320-abs(bvely));
  1101.      per=300+avy;jif=per>>5;
  1102.      StartSound(waveform[0],wavelength[0],jif,per,55,i); /* head hit */
  1103.     }
  1104.     bytop=200;
  1105.     serve=0;
  1106.     rebound[i]=1;
  1107.     if (hitter!=i) {
  1108.      hitter=i;
  1109.      hits=0;
  1110.     }
  1111.     else
  1112.      hits++;
  1113.    }
  1114.   }
  1115.   else
  1116.    if (rebound[i]) rebound[i]=servevel=0;
  1117.  }
  1118.  i=1;
  1119.  if (tby>91) {
  1120.   if (pbx<128 && tbx>127) {
  1121.    bvelx=-abs(bvelx)>>1;
  1122.    bx=127*64;
  1123.    i=0;
  1124.   }
  1125.   else
  1126.    if (pbx>159 && tbx<160) {
  1127.     bvelx=abs(bvelx)>>1;
  1128.     bx=160*64;
  1129.     i=0;
  1130.    }
  1131.  }
  1132.  if (i && tby>81 && tbx>127 && tbx<160) {
  1133.   if (tby>91) {
  1134.    if (tbx<148)
  1135.     bvelx=-abs(bvelx);
  1136.    else
  1137.     bvelx=abs(bvelx);
  1138.   }
  1139.   else
  1140.    if ((tbx>147 && 161-tbx>=polecol[91-tby]) ||
  1141.       (tbx<148 && tbx-133>=polecol[91-tby])) {
  1142.     if (bvely>0) {
  1143.      dx=tbx-145;
  1144.      if (dx<-5) bvelx=-abs(bvelx);
  1145.      if (dx>5) bvelx=abs(bvelx);
  1146.      bvely=-abs(bvely);
  1147.     }
  1148.     if (abs(bvelx)>32) bvelx=bvelx>>1;
  1149.     if (abs(bvely)>32) bvely=bvely>>1;
  1150.    }
  1151.  }
  1152. }
  1153.  
  1154. void putshapes()
  1155. {
  1156.  UpdateSounds();
  1157.  WaitBOVP(AVViewPort);
  1158.  MoveSprite(AVViewPort,&AVSprites[4],tbx,tby);
  1159.  MoveSprite(AVViewPort,&AVSprites[5],tbx+16,tby);
  1160.  if (y[0]<173) {
  1161.   ChangeSprite(AVViewPort,&AVSprites[0],AVSpriteData[4]);
  1162.   ChangeSprite(AVViewPort,&AVSprites[1],AVSpriteData[5]);
  1163.  }
  1164.  else {
  1165.   ChangeSprite(AVViewPort,&AVSprites[0],AVSpriteData[((x[0]/8)&1)*2]);
  1166.   ChangeSprite(AVViewPort,&AVSprites[1],AVSpriteData[((x[0]/8)&1)*2+1]);
  1167.  }
  1168.  ChangeSprite(AVViewPort,&AVSprites[4],AVSpriteData[((tbx/16)&3)*2+12]);
  1169.  ChangeSprite(AVViewPort,&AVSprites[5],AVSpriteData[((tbx/16)&3)*2+13]);
  1170.  if (y[1]<173) {
  1171.   ChangeSprite(AVViewPort,&AVSprites[2],AVSpriteData[10]);
  1172.   ChangeSprite(AVViewPort,&AVSprites[3],AVSpriteData[11]);
  1173.  }
  1174.  else {
  1175.   ChangeSprite(AVViewPort,&AVSprites[2],AVSpriteData[((x[1]/8)&1)*2+6]);
  1176.   ChangeSprite(AVViewPort,&AVSprites[3],AVSpriteData[((x[1]/8)&1)*2+7]);
  1177.  }
  1178.  MoveSprite(AVViewPort,&AVSprites[0],x[0],y[0]);
  1179.  MoveSprite(AVViewPort,&AVSprites[1],x[0]+16,y[0]);
  1180.  MoveSprite(AVViewPort,&AVSprites[2],x[1],y[1]);
  1181.  MoveSprite(AVViewPort,&AVSprites[3],x[1]+16,y[1]);
  1182. }
  1183.  
  1184. void resetpt()
  1185. {
  1186.  int i, j, tvelx, tvely;
  1187.  char *scrstr = "  ";
  1188.  
  1189.  if (hits>2)
  1190.  {
  1191.   i=1-hitter;
  1192.  }
  1193.  else
  1194.   i=tbx<150;
  1195.  putshapes();
  1196.  tvely=abs(bvely)>>3;tvelx=abs(bvelx)>>3;
  1197.  j=20;
  1198.  do {
  1199.   keymove[0].up=keymove[1].up=0;
  1200.   GetPos();
  1201.   if (abs(bvelx)>tvelx)
  1202.    if (bvelx<0)
  1203.     bvelx=-tvelx;
  1204.    else
  1205.     bvelx=tvelx;
  1206.   if (abs(bvely)>tvely)
  1207.    if (bvely<0)
  1208.     bvely=-tvely;
  1209.    else
  1210.     bvely=tvely;
  1211.   docollisions();
  1212.   moveball();
  1213.   putshapes();
  1214.  } while (j-->0 || frameindex[0]!=-1 || frameindex[1]!=-1);
  1215.  *dmaconw=0x000F;
  1216.  if (i==server) {
  1217.   if (!menuon)
  1218.    StartSound(waveform[2],wavelength[2],JIF2,PER2,63,3-i); /* point scored */
  1219.   score[i]++;
  1220.   if (score[i]>14 && score[i]-score[1-i]>1) endgame=1;
  1221.   sprintf(scrstr,"%02d",score[server]);
  1222.   Move(TitleRastPort,32+232*server,8);
  1223.   SetAPen(TitleRastPort,3);
  1224.   Text(TitleRastPort,scrstr,2);
  1225.  }
  1226.  else {
  1227.   if (!menuon)
  1228.    StartSound(waveform[1],wavelength[1],JIF1,PER1,63,2+i); /* serve lossed */
  1229.   server=i;
  1230.   SetAPen(TitleRastPort,6);
  1231.   if (server) {
  1232.    Move(TitleRastPort,48,8);Text(TitleRastPort," ",1);
  1233.    Move(TitleRastPort,256,8);Text(TitleRastPort,"*",1);
  1234.   }
  1235.   else {
  1236.    Move(TitleRastPort,48,8);Text(TitleRastPort,"*",1);
  1237.    Move(TitleRastPort,256,8);Text(TitleRastPort," ",1);
  1238.   }
  1239.   SetAPen(TitleRastPort,3);
  1240.  }
  1241.  if (!menuon) for (j=1;j<50;j++) putshapes();
  1242.  bx=(tbx=pbx=(64+i*165))<<6;by=(tby=pby=135)<<6;
  1243.  bframe=blogic=bvelx=bvely=hits=rebound[0]=rebound[1]=0;bindex=6;
  1244.  serve=servevel=1;hitter=2;
  1245.  compserve=abs(rnd)%5;
  1246.  if (score[server]==14) compserve=5;
  1247.  sstage=0;
  1248. }
  1249.  
  1250. int destination(int pl, int destx, int tol)
  1251. {
  1252.  int xp, *dir;
  1253.  
  1254.  dir=(int *)&keymove[pl];xp=x[pl];
  1255.  if (abs(xp-destx)<tol) {
  1256.   *dir=0;*(dir+1)=0;
  1257.   return(1);
  1258.  }
  1259.  if (xp<destx) {
  1260.   *dir=0;*(dir+1)=2;
  1261.  }
  1262.  else {
  1263.   *dir=-2;*(dir+1)=0;
  1264.  }
  1265.  return(0);
  1266. }
  1267.  
  1268. void computer0()
  1269. {
  1270.  int ystep, destx, dx, rndoff, dest;
  1271.  
  1272.  keymove[0].up=0;
  1273.  if (tby<bytop) bytop=tby;
  1274.  rndoff=5-rnd%10;
  1275.  if (serve && ((server&1)==0))
  1276.  {
  1277.   switch (compserve) {
  1278.    case 0: dest=destination(0,55,2);break;
  1279.    case 1: dest=destination(0,84,2);break;
  1280.    case 2: dest=destination(0,80,2);break;
  1281.    case 3: if (sstage==0) {
  1282.              if (dest=destination(0,44,2)) sstage=1;
  1283.            }
  1284.             else {
  1285.              destination(0,58,2);
  1286.              dest=1;
  1287.             }
  1288.             break;
  1289.    case 4 : if (sstage==0) {
  1290.              if (dest=destination(0,90,2)) sstage=1;
  1291.             }
  1292.             else {
  1293.              destination(0,58,2);
  1294.              dest=1;
  1295.             }
  1296.             break;
  1297.    case 5 : if (sstage==0) {
  1298.              if (destination(0,3,2)) sstage=1;
  1299.              dest=0;
  1300.             }
  1301.             else {
  1302.              destination(0,8+sstage++,1);
  1303.              dest=1;
  1304.             }
  1305.             break;
  1306.   }
  1307.   keymove[0].up=dest;
  1308.  }
  1309.  else
  1310.   if (bvely>0 && tbx<140) {
  1311.    if (bvely>>6==0)
  1312.     ystep=0;
  1313.    else
  1314.     ystep=(140-tby)/(bvely>>6);
  1315.     if (ystep<1 || (bvelx>>6)==0)
  1316.      destx=tbx;
  1317.     else
  1318.      destx=tbx+(bvelx>>6)*ystep-4;
  1319.    dx=x[0]-tbx;
  1320.    if (abs(bvelx)<128 && bytop<75) {
  1321.     if ((tby<158)^(bvelx<0))
  1322.      destination(0,tbx-15,3);
  1323.     else
  1324.      destination(0,tbx+15,3);
  1325.    }
  1326.    else {
  1327.     if (tby>130) {
  1328.      if (abs(dx)>6 && abs(bvelx)<1024)
  1329.       destination(0,tbx-(x[0]-60>>3),3);
  1330.      else {
  1331.       destination(0,tbx+rndoff+(x[0]-60>>3),10);
  1332.       keymove[0].up=x[0]<105 && (hitter!=0 || hits<2);
  1333.      }
  1334.     }
  1335.     else {
  1336.      if (destx<3)
  1337.       destx=6-destx;
  1338.      if (destx>123)
  1339.       destx=246-destx;
  1340.      destination(0,destx+rndoff,3);
  1341.     }
  1342.    }
  1343.   }
  1344.   else
  1345.    destination(0,56,8);
  1346. }
  1347.  
  1348. void computer1()
  1349. {
  1350.  int ystep, destx, dx, rndoff, dest;
  1351.  
  1352.  keymove[1].up=0;
  1353.  if (tby<bytop) bytop=tby;
  1354.  rndoff=5-rnd%10;
  1355.  if (serve && ((server&1)==1))
  1356.  {
  1357.   switch (compserve) {
  1358.    case 0: dest=destination(1,232,2);break;
  1359.    case 1: dest=destination(1,202,2);break;
  1360.    case 2: dest=destination(1,208,2);break;
  1361.    case 3: if (sstage==0) {
  1362.              if (dest=destination(1,250,2)) sstage=1;
  1363.             }
  1364.             else {
  1365.              destination(1,220,2);
  1366.              dest=1;
  1367.             }
  1368.             break;
  1369.    case 4 : if (sstage==0) {
  1370.              if (dest=destination(1,190,2)) sstage=1;
  1371.             }
  1372.             else {
  1373.              destination(1,230,2);
  1374.              dest=1;
  1375.             }
  1376.             break;
  1377.    case 5 : if (sstage==0) {
  1378.              if (destination(1,277,2)) sstage=1;
  1379.              dest=0;
  1380.             }
  1381.             else {
  1382.              destination(1,272-sstage++,1);
  1383.              dest=1;
  1384.             }
  1385.             break;
  1386.   }
  1387.   keymove[1].up=dest;
  1388.  }
  1389.  else
  1390.   if (bvely>0 && tbx>125) {
  1391.    if (bvely>>6==0)
  1392.     ystep=0;
  1393.    else
  1394.     ystep=(140-tby)/(bvely>>6);
  1395.     if (ystep<1 || (bvelx>>6)==0)
  1396.      destx=tbx;
  1397.     else
  1398.      destx=tbx+(bvelx>>6)*ystep-4;
  1399.    dx=x[1]-tbx;
  1400.    if (abs(bvelx)<128 && bytop<75) {
  1401.     if ((tby<158)^(bvelx<0))
  1402.      destination(1,tbx+15,3);
  1403.     else
  1404.      destination(1,tbx-15,3);
  1405.    }
  1406.    else {
  1407.     if (tby>130) {
  1408.      if (abs(dx)>6 && abs(bvelx)<1024)
  1409.       destination(1,tbx+(x[1]-218>>3),3);
  1410.      else {
  1411.       destination(1,tbx-rndoff-(x[1]-218>>3),10);
  1412.        keymove[1].up=x[1]>175 && (hitter!=1 || hits<2);
  1413.      }
  1414.     }
  1415.     else {
  1416.      if (destx<158)
  1417.       destx=316-destx;
  1418.      if (destx>277)
  1419.       destx=554-destx;
  1420.      destination(1,destx-rndoff,3);
  1421.     }
  1422.    }
  1423.   }
  1424.   else
  1425.    destination(1,211,8);
  1426. }
  1427.  
  1428. void CheckKeyboard()
  1429. {
  1430.  struct IntuiMessage *Msg;
  1431.  ULONG class;
  1432.  USHORT code;
  1433.  
  1434.  while(Msg=(struct IntuiMessage *)GetMsg(AVWindow->UserPort)) {
  1435.   class = Msg->Class;
  1436.   code = Msg->Code;
  1437.   ReplyMsg((struct Message *)Msg);
  1438.   if (class==VANILLAKEY && code==27)
  1439.    endgame=1;
  1440.   if (class==VANILLAKEY && code==32) {
  1441.    *dmaconw=0x000F;
  1442.    WaitPort(AVWindow->UserPort);
  1443.   }
  1444.  }
  1445. }
  1446.  
  1447. void InitGame()
  1448. {
  1449.  int i;
  1450.  
  1451.  *dmaconw=0x000F;
  1452.  hits=bframe=blogic=bvelx=bvely=tby=0;
  1453.  bindex=6;bytop=200;
  1454.  x[0]=64;x[1]=226;
  1455.  tbx=400;
  1456.  for (i=0;i<2;i++) {
  1457.   px[i]=x[i];y[i]=173;
  1458.   frameindex[i]=-1;
  1459.   rebound[i]=score[i]=keymove[i].right=0;
  1460.   keymove[i].left=keymove[i].up=frame[i]=0;
  1461.  }
  1462.  putshapes();
  1463.  bx=(tbx=pbx=64+starter*165)<<6;by=(tby=pby=135)<<6;
  1464.  server=2+starter;hitter=2;serve=servevel=1;
  1465.  Move(TitleRastPort,32,8);
  1466.  Text(TitleRastPort,"00     Arcade Volleyball     00",31);
  1467. }
  1468.  
  1469. void Game()
  1470. {
  1471.  int air;
  1472.  
  1473.  InitGame();
  1474.  opts[0]='C';opts[1]='C';
  1475.  jflag=0;menuon=1;endgame=0;
  1476.  while (!endgame)
  1477.  {
  1478.   rnd=rnd*5+1;
  1479.   if (menuon)
  1480.    menuon=DoMenu();
  1481.   else
  1482.    CheckKeyboard();
  1483.   if (opts[0]=='H')
  1484.    joystick(0);
  1485.   else
  1486.    computer0();
  1487.   if (opts[1]=='H')
  1488.    joystick(1);
  1489.   else
  1490.    computer1();
  1491.   GetPos();
  1492.   if (serve) {
  1493.    docollisions();
  1494.    putshapes();
  1495.    air=1;
  1496.   }
  1497.   else {
  1498.    if (air) {
  1499.     docollisions();
  1500.     air=moveball();
  1501.     putshapes();
  1502.    }
  1503.   }
  1504.   if (!air || hits>2)
  1505.    resetpt();
  1506.  }
  1507.  *dmaconw=0x000F;
  1508.  if (!menu) Delay(150);
  1509. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement