home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / 2d / mspeed.c < prev    next >
C/C++ Source or Header  |  1998-06-08  |  8KB  |  260 lines

  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  12. */
  13. /*
  14.  * $Source: f:/miner/source/2d/rcs/mspeed.c $
  15.  * $Revision: 1.2 $
  16.  * $Author: john $
  17.  * $Date: 1993/10/15 16:23:32 $
  18.  *
  19.  * Program for testing video speed.
  20.  *
  21.  * $Log: mspeed.c $
  22.  * Revision 1.2  1993/10/15  16:23:32  john
  23.  * y
  24.  * 
  25.  * Revision 1.1  1993/09/08  11:43:59  john
  26.  * Initial revision
  27.  * 
  28.  *
  29.  */
  30.  
  31. #include <stdlib.h>
  32. #include <stdio.h>
  33. #include <conio.h>
  34. #include <math.h>
  35.  
  36. #include "gr.h"
  37. #include "grdef.h"
  38. #include "timer.h"
  39.  
  40.  
  41. #define RelTime(x)  (((float)(x*100/fastest))/100.0)
  42.  
  43. unsigned int MyPoly[100];
  44.  
  45. char TempBufferX[320*200+16];
  46. char TempBuffer2[320*200+16];
  47.  
  48. char * TempBuffer1;
  49.  
  50. char * Video1;
  51. char * Video2;
  52. char * Video4;
  53.  
  54. char * System1;
  55. char * System2;
  56. char * System4;
  57.  
  58.  
  59. main()
  60. {
  61.     unsigned int t1, t2, fastest;
  62.     unsigned int timeb1v, timeb2v, timeb4v, timeb1s, timeb2s, timeb4s;
  63.     unsigned int timew1v, timew2v, timew4v, timew1s, timew2s, timew4s;
  64.     unsigned int timed1v, timed2v, timed4v, timed1s, timed2s, timed4s;
  65.  
  66.     gr_init( 0 );
  67.  
  68.     timer_init( 0, NULL );
  69.  
  70.  
  71.     TempBuffer1 = (unsigned char *)(((unsigned int)TempBufferX+0xF) & 0xFFFFFFF0);
  72.  
  73.     System4  = (unsigned char *)(((unsigned int)TempBuffer2+0xF) & 0xFFFFFFF0);
  74.     System2  = (unsigned char *)((unsigned int)System4 + 2);
  75.     System1  = (unsigned char *)((unsigned int)System4 + 1);
  76.  
  77.  
  78.  
  79.     Video4 = (unsigned char *)0xA0000;
  80.     Video2 = (unsigned char *)0xA0002;
  81.     Video1 = (unsigned char *)0xA0001;
  82.  
  83.  
  84.     t1 = timer_get_microseconds();
  85.     gr_linear_movsb(TempBuffer1, Video1, 320*200);
  86.     t2 = timer_get_microseconds();
  87.     t1 = timer_get_microseconds();
  88.     gr_linear_movsb(TempBuffer1, Video1, 320*200);
  89.     t2 = timer_get_microseconds();
  90.     fastest = t2-t1;
  91.     if ((t2-t1) < fastest) fastest = t2-t1;
  92.     timeb1v = t2 - t1;
  93.  
  94.     t1 = timer_get_microseconds();
  95.     gr_linear_movsb(TempBuffer1, Video2, 320*200);
  96.     t2 = timer_get_microseconds();
  97.     t1 = timer_get_microseconds();
  98.     gr_linear_movsb(TempBuffer1, Video2, 320*200);
  99.     t2 = timer_get_microseconds();
  100.     if ((t2-t1) < fastest) fastest = t2-t1;
  101.     timeb2v = t2 - t1;
  102.  
  103.     t1 = timer_get_microseconds();
  104.     gr_linear_movsb(TempBuffer1, Video4, 320*200);
  105.     t2 = timer_get_microseconds();
  106.     t1 = timer_get_microseconds();
  107.     gr_linear_movsb(TempBuffer1, Video4, 320*200);
  108.     t2 = timer_get_microseconds();
  109.     if ((t2-t1) < fastest) fastest = t2-t1;
  110.     timeb4v = t2 - t1;
  111.  
  112.     t1 = timer_get_microseconds();
  113.     gr_linear_movsb(TempBuffer1, System1, 320*200);
  114.     t2 = timer_get_microseconds();
  115.     t1 = timer_get_microseconds();
  116.     gr_linear_movsb(TempBuffer1, System1, 320*200);
  117.     t2 = timer_get_microseconds();
  118.     if ((t2-t1) < fastest) fastest = t2-t1;
  119.     timeb1s = t2 - t1;
  120.  
  121.     t1 = timer_get_microseconds();
  122.     gr_linear_movsb(TempBuffer1, System2, 320*200);
  123.     t2 = timer_get_microseconds();
  124.     t1 = timer_get_microseconds();
  125.     gr_linear_movsb(TempBuffer1, System2, 320*200);
  126.     t2 = timer_get_microseconds();
  127.     if ((t2-t1) < fastest) fastest = t2-t1;
  128.     timeb2s = t2 - t1;
  129.  
  130.     t1 = timer_get_microseconds();
  131.     gr_linear_movsb(TempBuffer1, System4, 320*200);
  132.     t2 = timer_get_microseconds();
  133.     t1 = timer_get_microseconds();
  134.     gr_linear_movsb(TempBuffer1, System4, 320*200);
  135.     t2 = timer_get_microseconds();
  136.     if ((t2-t1) < fastest) fastest = t2-t1;
  137.     timeb4s = t2 - t1;
  138.  
  139.     t1 = timer_get_microseconds();
  140.     gr_linear_movsw(TempBuffer1, Video1, 320*200);
  141.     t2 = timer_get_microseconds();
  142.     t1 = timer_get_microseconds();
  143.     gr_linear_movsw(TempBuffer1, Video1, 320*200);
  144.     t2 = timer_get_microseconds();
  145.     if ((t2-t1) < fastest) fastest = t2-t1;
  146.     timew1v = t2 - t1;
  147.  
  148.     t1 = timer_get_microseconds();
  149.     gr_linear_movsw(TempBuffer1, Video2, 320*200);
  150.     t2 = timer_get_microseconds();
  151.     t1 = timer_get_microseconds();
  152.     gr_linear_movsw(TempBuffer1, Video2, 320*200);
  153.     t2 = timer_get_microseconds();
  154.     if ((t2-t1) < fastest) fastest = t2-t1;
  155.     timew2v = t2 - t1;
  156.  
  157.     t1 = timer_get_microseconds();
  158.     gr_linear_movsw(TempBuffer1, Video4, 320*200);
  159.     t2 = timer_get_microseconds();
  160.     t1 = timer_get_microseconds();
  161.     gr_linear_movsw(TempBuffer1, Video4, 320*200);
  162.     t2 = timer_get_microseconds();
  163.     if ((t2-t1) < fastest) fastest = t2-t1;
  164.     timew4v = t2 - t1;
  165.  
  166.     t1 = timer_get_microseconds();
  167.     gr_linear_movsw(TempBuffer1, System1, 320*200);
  168.     t2 = timer_get_microseconds();
  169.     t1 = timer_get_microseconds();
  170.     gr_linear_movsw(TempBuffer1, System1, 320*200);
  171.     t2 = timer_get_microseconds();
  172.     if ((t2-t1) < fastest) fastest = t2-t1;
  173.     timew1s = t2 - t1;
  174.  
  175.     t1 = timer_get_microseconds();
  176.     gr_linear_movsw(TempBuffer1, System2, 320*200);
  177.     t2 = timer_get_microseconds();
  178.     t1 = timer_get_microseconds();
  179.     gr_linear_movsw(TempBuffer1, System2, 320*200);
  180.     t2 = timer_get_microseconds();
  181.     if ((t2-t1) < fastest) fastest = t2-t1;
  182.     timew2s = t2 - t1;
  183.  
  184.     t1 = timer_get_microseconds();
  185.     gr_linear_movsw(TempBuffer1, System4, 320*200);
  186.     t2 = timer_get_microseconds();
  187.     t1 = timer_get_microseconds();
  188.     gr_linear_movsw(TempBuffer1, System4, 320*200);
  189.     t2 = timer_get_microseconds();
  190.     if ((t2-t1) < fastest) fastest = t2-t1;
  191.     timew4s = t2 - t1;
  192.  
  193.     t1 = timer_get_microseconds();
  194.     gr_linear_movsd(TempBuffer1, Video1, 320*200);
  195.     t2 = timer_get_microseconds();
  196.     t1 = timer_get_microseconds();
  197.     gr_linear_movsd(TempBuffer1, Video1, 320*200);
  198.     t2 = timer_get_microseconds();
  199.     if ((t2-t1) < fastest) fastest = t2-t1;
  200.     timed1v = t2 - t1;
  201.  
  202.     t1 = timer_get_microseconds();
  203.     gr_linear_movsd(TempBuffer1, Video2, 320*200);
  204.     t2 = timer_get_microseconds();
  205.     t1 = timer_get_microseconds();
  206.     gr_linear_movsd(TempBuffer1, Video2, 320*200);
  207.     t2 = timer_get_microseconds();
  208.     if ((t2-t1) < fastest) fastest = t2-t1;
  209.     timed2v = t2 - t1;
  210.  
  211.     t1 = timer_get_microseconds();
  212.     gr_linear_movsd(TempBuffer1, Video4, 320*200);
  213.     t2 = timer_get_microseconds();
  214.     t1 = timer_get_microseconds();
  215.     gr_linear_movsd(TempBuffer1, Video4, 320*200);
  216.     t2 = timer_get_microseconds();
  217.     if ((t2-t1) < fastest) fastest = t2-t1;
  218.     timed4v = t2 - t1;
  219.  
  220.     t1 = timer_get_microseconds();
  221.     gr_linear_movsd(TempBuffer1, System1, 320*200);
  222.     t2 = timer_get_microseconds();
  223.     t1 = timer_get_microseconds();
  224.     gr_linear_movsd(TempBuffer1, System1, 320*200);
  225.     t2 = timer_get_microseconds();
  226.     if ((t2-t1) < fastest) fastest = t2-t1;
  227.     timed1s = t2 - t1;
  228.  
  229.     t1 = timer_get_microseconds();
  230.     gr_linear_movsd(TempBuffer1, System2, 320*200);
  231.     t2 = timer_get_microseconds();
  232.     t1 = timer_get_microseconds();
  233.     gr_linear_movsd(TempBuffer1, System2, 320*200);
  234.     t2 = timer_get_microseconds();
  235.     if ((t2-t1) < fastest) fastest = t2-t1;
  236.     timed2s = t2 - t1;
  237.  
  238.     t1 = timer_get_microseconds();
  239.     gr_linear_movsd(TempBuffer1, System4, 320*200);
  240.     t2 = timer_get_microseconds();
  241.     t1 = timer_get_microseconds();
  242.     gr_linear_movsd(TempBuffer1, System4, 320*200);
  243.     t2 = timer_get_microseconds();
  244.     if ((t2-t1) < fastest) fastest = t2-t1;
  245.     timed4s = t2 - t1;
  246.  
  247.     timer_close();
  248.     gr_close();
  249.  
  250.     printf( "Relative memory move speeds: \n\n" );
  251.     printf( "           Vid1  Vid2  Vid4  Sys1  Sys2  Sys4\n" );
  252.     printf( "REP MOVSB: %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f\n", RelTime(timeb1v),RelTime(timeb2v),RelTime(timeb4v), RelTime(timeb1s),RelTime(timeb2s),RelTime(timeb4s) );
  253.     printf( "REP MOVSW: %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f\n", RelTime(timew1v),RelTime(timew2v),RelTime(timew4v), RelTime(timew1s),RelTime(timew2s),RelTime(timew4s) );
  254.     printf( "REP MOVSD: %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f\n", RelTime(timed1v),RelTime(timed2v),RelTime(timed4v), RelTime(timed1s),RelTime(timed2s),RelTime(timed4s) );
  255.  
  256.     printf( "\nA 1.00 corresponds to %d microseconds to move 320x200 unsigned chars.\n", fastest );
  257.  
  258.     return;
  259. }
  260.