home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / pxm_ray / pxm_ray.lha / pxm-ray / host_initialize.c next >
Encoding:
C/C++ Source or Header  |  1992-12-09  |  4.1 KB  |  177 lines

  1.  
  2. /*
  3.  * just to initialize some stuff
  4.  */
  5.  
  6. /*
  7.  *    (c) 1988 by George Kyriazis
  8.  */
  9.  
  10. #include    <stdio.h>
  11. #include    "ray.h"
  12. #include    <hypdefs.h>
  13. #include    <hyper.h>
  14. #include    <hypio.h>
  15. #include    <devlib.h>
  16. #include    <devextern.h>
  17. #include    <msgserve.h>
  18. #include    "pxm.h"
  19.  
  20. #define        HOST
  21. #include    "msg.h"
  22.  
  23. extern    send_data();
  24.  
  25. struct    dsp_vector    { Ulong    x, y, z; };
  26.  
  27. initialize()
  28. {
  29. /* for the moment just initialize the statistics */
  30.     raycount = rayline = 0;
  31.     shadowcount = shadowline = 0;
  32.     reflectcount = reflectline = 0;
  33.     refractcount = refractline = 0;
  34.     intersectcount = intersectline = 0;
  35.     objtestcount = objtestline = 0;
  36.  
  37.     pixel_initialize();
  38. }
  39.  
  40. null()
  41. {
  42.     printf("NULL CALLED!!!!\n\n");
  43. }
  44.  
  45. msg_done()
  46. {
  47.     exit(0);
  48. }
  49.  
  50.  
  51. static    send_noo(opcode, dsp, node)
  52. int    opcode;
  53. DrawDsp    *dsp;
  54. int    node;
  55. {
  56. /* first get the noo buffer */
  57.     pixel_nos[node] = HypDrawGetPir(dsp);
  58.     pixel_nosq[node] = HypDrawGetPir(dsp);
  59.  
  60.     pixel_bgflag[node] = HypDrawGetPir(dsp);
  61. /* then get the status buffer */
  62.     pixel_status[node] = HypDrawGetPir(dsp);
  63. }
  64.  
  65. static    msg_print(opcode, dsp, node)
  66. int    opcode;
  67. DrawDsp    *dsp;
  68. int    node;
  69. {
  70.     int    tt;
  71.  
  72.     tt = (int) HypDrawGetPir(dsp);
  73.     printf("%d\n", tt);
  74. }
  75.  
  76. static    msg_res(opcode, dsp, node)
  77. int    opcode;
  78. DrawDsp    *dsp;
  79. int    node;
  80. {
  81.     Ushort    xxx, yyy, zzz;
  82.     Ushort    t1, t2;
  83.     Ushort    afov, aeye, aeyedir, aup;
  84.     Ushort    afoc, alens;
  85.     Ushort    tr = tries;
  86.     short    xresdsp = xres;
  87.     int    zero = 0;
  88.     Ulong    temp;
  89.     struct    dsp_vector    dtemp;
  90.  
  91.     xxx = HypDrawGetPir(dsp);
  92.     yyy = HypDrawGetPir(dsp);
  93.     t1 = HypDrawGetPir(dsp);
  94.     t2 = HypDrawGetPir(dsp);
  95.     afov = HypDrawGetPir(dsp);
  96.     aeye = HypDrawGetPir(dsp);
  97.     aeyedir = HypDrawGetPir(dsp);
  98.     aup = HypDrawGetPir(dsp);
  99.     afoc = HypDrawGetPir(dsp);
  100.     alens = HypDrawGetPir(dsp);
  101.  
  102.     SHORT_SWAP(xresdsp);
  103.     SHORT_SWAP(tr);
  104.     HypDrawWrite( DEVsystem->draw_dsp[node], xxx,
  105.         &xresdsp, sizeof(short) );
  106.     HypDrawWrite( DEVsystem->draw_dsp[node], yyy,
  107.         &tr, sizeof(short) );
  108.     temp = C_FtoDsp(time1); temp = Swapl(temp);
  109.     HypDrawWrite( DEVsystem->draw_dsp[node], t1,
  110.         &temp, sizeof(Ulong) );
  111.     temp = C_FtoDsp(time2); temp = Swapl(temp);
  112.     HypDrawWrite( DEVsystem->draw_dsp[node], t2,
  113.         &temp, sizeof(Ulong) );
  114.     temp = C_FtoDsp(fov); temp = Swapl(temp);
  115.     HypDrawWrite( DEVsystem->draw_dsp[node], afov,
  116.         &temp, sizeof(Ulong) );
  117.     dtemp.x = C_FtoDsp(eye.x); dtemp.x = Swapl(dtemp.x);
  118.     dtemp.y = C_FtoDsp(eye.y); dtemp.y = Swapl(dtemp.y);
  119.     dtemp.z = C_FtoDsp(eye.z); dtemp.z = Swapl(dtemp.z);
  120.     HypDrawWrite( DEVsystem->draw_dsp[node], aeye,
  121.         &dtemp, sizeof(struct dsp_vector) );
  122.     dtemp.x = C_FtoDsp(eye_dir.x); dtemp.x = Swapl(dtemp.x);
  123.     dtemp.y = C_FtoDsp(eye_dir.y); dtemp.y = Swapl(dtemp.y);
  124.     dtemp.z = C_FtoDsp(eye_dir.z); dtemp.z = Swapl(dtemp.z);
  125.     HypDrawWrite( DEVsystem->draw_dsp[node], aeyedir,
  126.         &dtemp, sizeof(struct dsp_vector) );
  127.     dtemp.x = C_FtoDsp(up.x); dtemp.x = Swapl(dtemp.x);
  128.     dtemp.y = C_FtoDsp(up.y); dtemp.y = Swapl(dtemp.y);
  129.     dtemp.z = C_FtoDsp(up.z); dtemp.z = Swapl(dtemp.z);
  130.     HypDrawWrite( DEVsystem->draw_dsp[node], aup,
  131.         &dtemp, sizeof(struct dsp_vector) );
  132.     temp = C_FtoDsp(foc); temp = Swapl(temp);
  133.     HypDrawWrite( DEVsystem->draw_dsp[node], afoc,
  134.         &temp, sizeof(Ulong) );
  135.     temp = C_FtoDsp(lens); temp = Swapl(temp);
  136.     HypDrawWrite( DEVsystem->draw_dsp[node], alens,
  137.         &temp, sizeof(Ulong) );
  138.     HypDrawWrite( DEVsystem->draw_dsp[node], pixel_status[node],
  139.         &zero, sizeof(int) );
  140. }
  141.  
  142. pixel_initialize()
  143. {
  144.     if( DEVinit() != DEVERR_OK ) {
  145.         fprintf(stderr, "Error during DEVinit\n");
  146.         exit(1);
  147.     }
  148.  
  149.     DEVmsg_init();
  150.     DEVenable_print(DEV_TRUE);
  151.  
  152.     if( DEVuser_msg_enable( MSG_NOO, null, send_noo) != 0 ) {
  153.         fprintf(stderr, "DEVuser_msg_enable failed\n");
  154.         exit(1);
  155.     }
  156.     if( DEVuser_msg_enable( MSG_READY, null, send_data) != 0 ) {
  157.         fprintf(stderr, "DEVuser_msg_enable failed\n");
  158.         exit(1);
  159.     }
  160.     if( DEVuser_msg_enable( MSG_DONE, null, msg_done) != 0 ) {
  161.         fprintf(stderr, "DEVuser_msg_enable failed\n");
  162.         exit(1);
  163.     }
  164.     if( DEVuser_msg_enable( MSG_PRINT, null, msg_print) != 0 ) {
  165.         fprintf(stderr, "DEVuser_msg_enable failed\n");
  166.         exit(1);
  167.     }
  168.     if( DEVuser_msg_enable( MSG_RES, null, msg_res) != 0 ) {
  169.         fprintf(stderr, "DEVuser_msg_enable failed\n");
  170.         exit(1);
  171.     }
  172.  
  173.     DEVpoll_nodes(DEV_NONE, DEV_NONE,
  174.         0, (DEVsystem->draw_nodes) - 1,
  175.         2, 1);
  176. }
  177.