Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
2.7 KiB

  1. /**
  2. ** File : vsplit.cxx
  3. ** Description: vsplit implementations
  4. **/
  5. #include "precomp.h"
  6. #pragma hdrstop
  7. #include "vsplit.h"
  8. #include "fileio.h"
  9. /*
  10. * VsplitArray: Constructor
  11. */
  12. VsplitArray::VsplitArray(DWORD i)
  13. {
  14. m_vsarr = new Vsplit[i];
  15. numVS = i;
  16. if (m_vsarr)
  17. m_cRef=1;
  18. else
  19. throw CExNewFailed();
  20. }
  21. void VsplitArray::write(ostream& os) const
  22. {
  23. os << "\n\nVSplits: (total = " << numVS << ")";
  24. for (int i=0; i<numVS; i++)
  25. {
  26. os << "\nVsplit[" << i << "] = \n{\n";
  27. m_vsarr[i].write (os);
  28. os << "\n}";
  29. }
  30. }
  31. void Vsplit::read(istream& is)
  32. {
  33. read_DWORD(is,flclw);
  34. read_WORD(is,vlr_offset1);
  35. read_WORD(is,code);
  36. if (code&(FLN_MASK|FRN_MASK))
  37. {
  38. read_WORD(is,fl_matid);
  39. read_WORD(is,fr_matid);
  40. }
  41. else
  42. {
  43. fl_matid=0;
  44. fr_matid=0;
  45. }
  46. for (int c=0; c<3; ++c)
  47. read_float(is,vad_large[c]);
  48. for (c=0; c<3; ++c)
  49. read_float(is,vad_small[c]);
  50. int nwa=expected_wad_num();
  51. for(int i=0; i<nwa; ++i)
  52. for(c=0; c<5; ++c)
  53. read_float(is, ar_wad[i][c]);
  54. modified = FALSE;
  55. }
  56. void Vsplit::write(ostream& os) const
  57. {
  58. os << "\nflclw: " << flclw;
  59. os << "\nvlr_offset1: " << vlr_offset1;
  60. os << "\ncode: " << code;
  61. if (code&(FLN_MASK|FRN_MASK))
  62. {
  63. os << "\nfl_matid: " << fl_matid;
  64. os << "\nfr_matid: " << fr_matid;
  65. }
  66. else
  67. {
  68. os << "\nfl_matid: " << (WORD) 0;
  69. os << "\nfr_matid: " << (WORD) 0;
  70. }
  71. os << "\nvad_large: (" << vad_large[0] << ", " << vad_large[1] << ", "
  72. << vad_large[2] << ") ";
  73. os << "\nvad_small: (" << vad_small[0] << ", " << vad_small[1] << ", "
  74. << vad_small[2] << ") ";
  75. int nwa = expected_wad_num();
  76. for(int i=0; i<nwa; ++i)
  77. {
  78. os << "\nar_wad[" << i << "] : {" ;
  79. for(int c=0; c<5; ++c)
  80. os << ar_wad[i][c] << " ";
  81. os << "}" ;
  82. }
  83. }
  84. int Vsplit::expected_wad_num() const
  85. {
  86. // optimize: construct static const lookup table on (S_MASK|T_MASK).
  87. int nwa=0;
  88. int nt=!(code&T_LSAME);
  89. int ns=!(code&S_LSAME);
  90. nwa+=nt&&ns?2:1;
  91. if (vlr_offset1>1)
  92. {
  93. int nt=!(code&T_RSAME);
  94. int ns=!(code&S_RSAME);
  95. if (nt && ns)
  96. {
  97. if (!(code&T_CSAME))
  98. nwa++;
  99. if (!(code&S_CSAME))
  100. nwa++;
  101. }
  102. else
  103. {
  104. int ii=(code&II_MASK)>>II_SHIFT;
  105. switch (ii)
  106. {
  107. case 2:
  108. if (!(code&T_CSAME)) nwa++;
  109. break;
  110. case 0:
  111. if (!(code&S_CSAME)) nwa++;
  112. break;
  113. case 1:
  114. if (!(code&T_CSAME) || !(code&S_CSAME)) nwa++;
  115. break;
  116. default:
  117. throw CBadVsplit();
  118. }
  119. }
  120. }
  121. if (code&L_NEW)
  122. nwa++;
  123. if (code&R_NEW)
  124. nwa++;
  125. return nwa;
  126. }