From a7488939afd13e8508ee0b31f8b06da9b0729bc3 Mon Sep 17 00:00:00 2001 From: MaxED Date: Thu, 11 Sep 2014 08:26:01 +0000 Subject: [PATCH] Updated Visplane Explorer plugin to v1.0. Visplanes of Hexen maps can now be explored. Map Options Form: example map name now uses current game's naming scheme. --- Source/Core/Windows/LinedefEditForm.cs | 2 +- .../Core/Windows/MapOptionsForm.Designer.cs | 16 +- Source/Core/Windows/MapOptionsForm.cs | 1 + .../VisplaneExplorer/Resources/vpo.dll | Bin 95744 -> 99328 bytes Source/Plugins/VisplaneExplorer/VPOManager.cs | 5 +- .../VisplaneExplorer/VisplaneExplorerMode.cs | 2 +- Source/Plugins/vpo_dll/doomdata.h | 456 +- Source/Plugins/vpo_dll/doomdef.h | 516 +- Source/Plugins/vpo_dll/doomtype.h | 168 +- Source/Plugins/vpo_dll/m_bbox.cc | 122 +- Source/Plugins/vpo_dll/m_bbox.h | 110 +- Source/Plugins/vpo_dll/m_fixed.cc | 132 +- Source/Plugins/vpo_dll/m_fixed.h | 84 +- Source/Plugins/vpo_dll/p_setup.cc | 1587 +++--- Source/Plugins/vpo_dll/r_bsp.cc | 1154 ++--- Source/Plugins/vpo_dll/r_bsp.h | 114 +- Source/Plugins/vpo_dll/r_defs.h | 629 ++- Source/Plugins/vpo_dll/r_main.cc | 1366 +++--- Source/Plugins/vpo_dll/r_main.h | 226 +- Source/Plugins/vpo_dll/r_plane.cc | 710 +-- Source/Plugins/vpo_dll/r_plane.h | 128 +- Source/Plugins/vpo_dll/r_segs.cc | 1244 ++--- Source/Plugins/vpo_dll/r_state.h | 214 +- Source/Plugins/vpo_dll/tables.cc | 4258 ++++++++--------- Source/Plugins/vpo_dll/tables.h | 188 +- Source/Plugins/vpo_dll/vpo_api.h | 182 +- Source/Plugins/vpo_dll/vpo_local.h | 158 +- Source/Plugins/vpo_dll/vpo_main.cc | 663 +-- Source/Plugins/vpo_dll/vpo_stuff.cc | 226 +- Source/Plugins/vpo_dll/w_file.cc | 170 +- Source/Plugins/vpo_dll/w_file.h | 110 +- Source/Plugins/vpo_dll/w_wad.cc | 725 +-- Source/Plugins/vpo_dll/w_wad.h | 163 +- 33 files changed, 8103 insertions(+), 7726 deletions(-) diff --git a/Source/Core/Windows/LinedefEditForm.cs b/Source/Core/Windows/LinedefEditForm.cs index a460977a..fff79cbc 100644 --- a/Source/Core/Windows/LinedefEditForm.cs +++ b/Source/Core/Windows/LinedefEditForm.cs @@ -701,7 +701,7 @@ namespace CodeImp.DoomBuilder.Windows } // Check if we have at least one activation flag when there's an action in UDMF map format (mxd) - if (General.Map.UDMF && !action.Empty && action.Value != 0) + if (General.Map.UDMF && action.Value != 0) { bool haveactivationflag = false; foreach (CheckBox c in udmfactivates.Checkboxes) diff --git a/Source/Core/Windows/MapOptionsForm.Designer.cs b/Source/Core/Windows/MapOptionsForm.Designer.cs index c09f1e12..438224d2 100644 --- a/Source/Core/Windows/MapOptionsForm.Designer.cs +++ b/Source/Core/Windows/MapOptionsForm.Designer.cs @@ -42,6 +42,7 @@ namespace CodeImp.DoomBuilder.Windows this.panelres = new System.Windows.Forms.GroupBox(); this.strictpatches = new System.Windows.Forms.CheckBox(); this.datalocations = new CodeImp.DoomBuilder.Controls.ResourceListEditor(); + this.examplelabel = new System.Windows.Forms.Label(); label3 = new System.Windows.Forms.Label(); label2 = new System.Windows.Forms.Label(); label1 = new System.Windows.Forms.Label(); @@ -56,9 +57,9 @@ namespace CodeImp.DoomBuilder.Windows label3.AutoSize = true; label3.Location = new System.Drawing.Point(239, 83); label3.Name = "label3"; - label3.Size = new System.Drawing.Size(90, 14); + label3.Size = new System.Drawing.Size(53, 14); label3.TabIndex = 9; - label3.Text = "example: MAP01"; + label3.Text = "example: "; // // label2 // @@ -82,6 +83,7 @@ namespace CodeImp.DoomBuilder.Windows // panelsettings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + panelsettings.Controls.Add(this.examplelabel); panelsettings.Controls.Add(this.scriptcompiler); panelsettings.Controls.Add(this.scriptcompilerlabel); panelsettings.Controls.Add(label3); @@ -206,6 +208,15 @@ namespace CodeImp.DoomBuilder.Windows this.datalocations.Size = new System.Drawing.Size(368, 130); this.datalocations.TabIndex = 0; // + // examplelabel + // + this.examplelabel.AutoSize = true; + this.examplelabel.Location = new System.Drawing.Point(288, 83); + this.examplelabel.Name = "examplelabel"; + this.examplelabel.Size = new System.Drawing.Size(41, 14); + this.examplelabel.TabIndex = 12; + this.examplelabel.Text = "MAP01"; + // // MapOptionsForm // this.AcceptButton = this.apply; @@ -247,6 +258,7 @@ namespace CodeImp.DoomBuilder.Windows private System.Windows.Forms.CheckBox strictpatches; private System.Windows.Forms.ComboBox scriptcompiler; private System.Windows.Forms.Label scriptcompilerlabel; + private System.Windows.Forms.Label examplelabel; } diff --git a/Source/Core/Windows/MapOptionsForm.cs b/Source/Core/Windows/MapOptionsForm.cs index 96fa0dae..4c349e81 100644 --- a/Source/Core/Windows/MapOptionsForm.cs +++ b/Source/Core/Windows/MapOptionsForm.cs @@ -293,6 +293,7 @@ namespace CodeImp.DoomBuilder.Windows { // Get default lump name from configuration levelname.Text = ci.DefaultLumpName; + examplelabel.Text = ci.DefaultLumpName; //mxd } //mxd diff --git a/Source/Plugins/VisplaneExplorer/Resources/vpo.dll b/Source/Plugins/VisplaneExplorer/Resources/vpo.dll index 845262b8934fe7378759c2a3c34d71cf0d702556..7b238858434cde3a8814ed9f7293e6dada886e8b 100644 GIT binary patch delta 21105 zcmd^neSDME`S+bPflv|}pn(bnQYnZQFfYyfTU&^$Kp-uY7exVSYpGBwG>S?|F`x}M zRq&PpKiQ<#P3ClCn*($zEiem?DKf@T*{rV4yQXU0I*Hnu=X;$yX^TJI^Z7jgKK*>o zeeV05>s;qL*SX%#OWM$_Y-k*^%Po&{yS+tKGcHfASo2E2no28w|2JzjzAyaqU6!x> z{Uz&Ke6Rfd8`e8ne#W{E`TPg0*1M3ed1apUc2?eQtzh|k)+&}?W_jtF)m4OhcTZO7 z$%P{qaml|9PM$MdHjLwLLBUiRD}81aGA&Xq`_!^`Imap4=RnRKPUkoU$Nfbk+#;Je zW>>w8>jKDgn`E4uKzF5chvmC-Myn5|b8FEBcQ?mn@6H*oI~Hb8=D6MrRDeX*VcluFt=PIm_=RG@ z=mq%VPxJre{p$Ut!Nn!wBZ~#CG89%d`PET>UlsLJ%~c)SCew;tWgHhdrRD>DC48Bx zv?`ItNi_-G%e9;~a!T9o?<0E5t&RS#b_Bj^418U6>|U9+sqE`g@mFZge|X!;vt@jD zq&t)MtAgU^Hxouhn<#JTY?NuuXPPN{NyXVX?#c%lyV|b2J^XZuD4WN?qW*5)-`#Qy zAbdboB9_ld7WeRFJ<+nh=3|Y*yULmJ&PHMQkn6*nr0P_k%{^#`?%5xsVLGEBN20-e z{zWxNzw&v@3m7XXq3k6+6%7!QH#gbi1>S$5QM z`i&C$s9)p*Vl>bv0Y%HY+x>AM=VIe|e>~DEi~8eypgYp0j|RH=vcAX(HAaLgmy$Zj zXj+fC2In)5kBpXG=KXjnmPZ4ZBK4QK&Dng}WtWavS3fdRe~H^XocCV}yOdP2c_bf* zmsCxw!vtRXPa+XHr2;fqg=tZrX<6tRS-u42}jBtfP`4(Xx(6eFsC=;Zj~2 zz_ygI?MPt*Ek%m94opgSv``J=@txilP8OiMj=Rnmr|CM-K3dj;9{4~{v^Y}&R7L%r ze4rCEm~njeoH2K`W~M0*VZ;oXmM`n%{ivB29COzhwCHYTb@No(=$tIprbrv(ZPf$~EHGAeaVRlpPzx`+Lz9I^lH;<7~M$T9_S6M@f5O zHcd>|o!=0+SSp%}h4Cu=UGLw-CZB}$0uVw(D1)$GB_f{}Cq;zG>dSy&vbyL8$>LtV ztT$Q~XKmX$(t;2h4MCNN*Od~8n%BMDC^QYr7EY)}$uBet7gbZ`!5;|UsK$m>%>)Ta zN$Oc_6ecRtCL^&bi$_kVfEc3TQW9bHg_!t^<0V73pWi$gf&_t4Y(KLZT*GV85UEm; zc0v-cEhEt|Sk*`qTktg#lh{*Cbp{kBoYdN_el`|p%s3kR=PidZUtkAiFBz_82cH@@ zV+W}quOYa*&KQ`+P)Vuy=b$unvI&2Zuwx1_chNwc*AWZ^r(F<+jmb1b15kGic3f(( zhqno@47(vq_Z3mCfCyAZi&RXh)Il-vrH~j_5N?u?4h#qeAmgZCHHB;7xVmdHjs{d) z-%o@S33IDUL)^9;V%g8udrb3bKIgpH^l=(O-88JQ6aM|n>J4kN84gv-{D0?ZN zvBTVN%7#lq6!mxT{*D%r_(7(uM#4cB4gv~OCXy-37T!o7mCpKZ5`jp_7&1{%4Y$tD zXo}*KC!5k&$uBC*s*IL(VmzHe@dZdN*pPAL^!78Mk>FHm)yp)gJL8h>Q=8sO=#@}1 z{HCm~@lRoLReRBNd6>XpoTv#r4Ou_xPv(->XHjDiB99j4ve!7hPJ>!gIs1^x8OXF` z%R+^#NKrp7*%kvT)F4A28j8k00ClOi56E?h`c zB@&k}vQa3^=K)q34H7+Qm=*adk!qQhY?&T;Js|;6w}c%)b#Mj@JsG=sWvW5e&Hz>r zUr4_&^8}R@`7%)l+mH96EN0DAgRNOUSu;!mi6AGuasAkEHrfTntpzE09f1nSD;ajk zD`hXidJT4Xd=Y~s8}09GAq&oH2=1;k#Y}yv1nSG&BF!$;SHhlB-yS|`_hGZbEI1&C z*T)=QAN)Y1ZA40;i&F|s9b_~e2PFVt4iClyFXZsVNPRbRc-;dIPh=iS9PoF2B~^+L zX2bq(N#@};jsa(wIlMSIJaLf2i!+A@!S1QVY*$7Lp_0k3A^3ugO@3iU3*j=7U+MV5 z{3gHD_`*cSOT-uYm;!cd{aoTBS9X8U?d#of}B47dn#d@N4PVuD@hVXTGMn+V=OZAkH}MC)R8J$z-tI-;HLRkdrZW>3yHGB3MVsJwgTH z9#H@cU(CX}LTywYYvnZ^h|;x_hZmF23-q~QRs@H(Mn2pl z{7gG#G7Se2jKA-$Rs*l;0S`cVbdfA~ph);!o2f7$tQUrjoSZ3%Z6mRX8WpE0(Luq; zhJ0!ZyOC0WQEZSh7F>&wRs##n(LL+%fu^zxrQ)-n2)!eJAm9Co;2AX`yx|jKoI3Vo zR~1HG)e3atOjf2y;e^!nTQoKj(7piu3<`T;!Mb@kJOvycy^JiCFl9>EsSqwSS&g?; zeXpup>i$PU+qBGZYK0XW+$H%bSBXBOX*(M|{An&qc*Smb?2IFtZcx1aOq~S`grgWm zv2lHG`sT@aYPJmDTHpIRn$^iEm;`u9!S?f^p~slxcE*fS;5dre=$=UUV=%5KQr{E0 z7fR8Saime5%V`t2O$uaEo1tB+!6tJn=@FmknapXgAaSzq`9s$->g#&}u4)&)>g)gZ z!EsXTntC#2h5)gk2L7mr;}YR^e=j<3NU93>3hg?9QDVYWFgLDZ@by8^2RF+Xg%MSB z^O=o^w%Yv^k#RH;5F;$#;F&~u{bI6^by#+E@+J9LsZo6=Uu=j5E@Ro1Tu{}`MDXYG ztLmomfe!c`SBYW^;5r}zjL|Uny@+zqe+Q4{UT^G)u1eB4zo+M|IIP!OU#7KTagGUf zmGy1WfztMZX#jvuLKb?XCDUUgFg-J9mjFf4!s*Pa37=j!Da_;?>vsreQm2{Q1=={T z1tAcGH>632(1b|qO2xa_N>8!9wGL)Cj=pHdn6uk0MVqlF2AfUrxjIqRQN?M?n~6uk z^5_)GOCsH>@WRDQq7_&KB2*}|B%PIH&vf7|#XY)wK3$t}WOllCduu2M^p{jMz^Ji3 zh=lGG+i6fAqaBGZ8wg?MDYKax?U<(>*~sKQQm^LfV9(SCN%|WRuEN(Tfjumtk8Dmy zJeosfRPFm7eECbmMe|} zVIsCvK%Gdu0FfjC$9{Yrr#*RW4?UAbF(pJaHc}M9ZZT^$)&b(*FriS7D z_FI{G$&Pp^P~z&QF_%p;hRq)Ff;3U>N>)jIvaJPb8S#*P1-IHb#l~Y^njPWDTC%Cft=dZtCo&6o%;w8YyhtjpMm3hi}j0K1f<9QnPPC;L9 znr`!cu%@i1new+f9R8krrt+H2`-PXY#!qH-kUj>Khv?!exM>XTtE};IfRDZAhK!XU zELw(uF3zjBuUsSquNfE4N4F6VJ-JYN*BNlP>l7ZaF(_&-z!YO`>{4w3hXzX0UB!yc z>0M6{^bh|xbg=@<_N%~Eb&A-nv1L*r?XB?|LY;BkUXt!Q5h`pZ+z8OI`jg6wRIbyZ z8+eUWUZQ4{06^_}D>Rzdfq6OO=2*9ZC$3^ucv!ptG|1p$6X4^TS!t2Fo=VBg$A;pC zww}qi=+-_iG>^-aBRe|IE^llQJ|8!F`pyQ5&Q!c&2aDyzw)YkM?p;&}7pmSxdpKoc z+Xo8%!N(f}!}tmEc?*OExm;x#l4-RMDv}{gOX=CZ_O3E<;P7Kzemg}B1xd}h52tH`;$v?M?rXE< zProhPa&4JvB{6z}?ruRd01SNfqBD>PPT8vXd-O?TIaB(*;WgGSReDTzV-YXUUWD;{B`OVuJgcVcAE_^5n4zH-#!?mE-Und2Zf_tudxR}c#e^tA(95fL% z$zX=bwL0RVU285hl$}__Zo_7{aAxXwIkvU`G1V%^Zo$Ost_hQx!(2p}rQyrKPcmk_ zKeL6jlxLoNkoxHwQQJ&aZQ^KNvyD7V=GLgrPE1si0VX<{i6FAbl=GSfK+zEidr1Xc zAQHU@N3NSH2VsA^?#3|VMGnkaC7aI5sG@A&m7&_m8SLTpRYuii+#xXG59sDusT&Ah z(iFEVccJS;&l3@k$}2o0-O< z-c=%2{fW&}%QkewGa@Ll& z{etrP89}0JqY9N>kD%MF9!5LBq!2K5LMw%UIHA4sdT@_mm_H)|fCw>M8$(St7F31-W+>_VaY94=i8jCujd=fKHlN~xX~Yz0?$AU%c<)qU}D|E z+_0BsLP)OUTm7R;gc&%PE)quMWy|+nCrr?c?#BDp z6A2uMw|%8XY}!m98OPOrno@{{BhU>!(@CWYHqk(bPzGzbPvEq%ce3F-syk^t*d>dG zDTGWlCYf>gdpBoFgk&7g3@|aGeG_c2B8uq^BLXF_o5o1pQP$a5qHAUaO2V=u(A(I! z1m=R*y?{?fa=f2phCdJo{{Ak*tOJn_kU{Wg62W&vs+jfeys9bDJD6PJfWzMz9z-r< z3fX-r=wjqj&~X*HtRP8lI7x5D5uE}qaQpeXa@HrW=>h#|>g~+5kV_VM9XUw|v`7LC zhfyM)c|)>Gx>f+^okI+cjf=K8t!E?_Ml~w5iJVTD&tI`*+Dy<1v^dvQ2YDUIK$`9_>y_U1&E0rU zQ)c14g;9e37;#PPvACm1IVB(_r13>4AlocIz3AsW5%x z>_Xejz>3w$K$8WX%@ld&DGxp*@nY}Wqqu47{labKDT85!Eu(#x* zk}6vw_DCC0EyU#{MtY4F;c!>&3aGZs2Lk4g(-eD1%Y))8QWL31I!R-MfLnP=h6QVb zfNDP?A)3D=PBxX{qD)~I&5yH8Kq^i1o@hh6iv2+>06_Y zENlP#M&8%fY@BlInk zQth%Js2l=XYMA6~bWV2c25Gy2m%Eh2<}Kr{hEMh*k;FDS*lq(KRA3Le{yIs_a6)}X zE|G-mI#O9`LZd-_%*1vsu#muAhbbhB4I&iBf~S3 z!<1OXBnUTnh*g7-!Hm-Q7_x8e#LQq|I9VxToKIq7eMyaYoZr7LXXQ9)ly+5cQj?O% z%QU%!lkb?zdgQ4MK3KM1upg*vL~MHOiywT$ZME2)iy zkZB_qW~hnKW~xssQnXMG;!uRcO!fBj8QZo(03}N!W486J4qihMf8Ob+hMbfnaLivt zi>6~Y78vr92ASZR6mwcAA6%2Bp>;$w%(AT>wy3~r5uORbvbe)9Hu}4g!EzU_JmQKG zuOmA)Tz3K3hcio;afF$_;pZ~;v^8od3hNKXGPcnwxZl-a{QmgXdb)Yoa1XX>;U!`@nj2{kYxB@>N{A(aD^f_NCp@NK6-asNQqtK>a?=)9 zB-MxnqU}pqR(g>vZ)r36mY{g8G!CqqC`jNfw1jW_27Zxz5_Y%US68>SS_}N$v0Tr_>IQhkvGI>yPh9Ag7 z`u-7p+rhUN=)wJlfhZm>jWvW%?~vihwI9vvGKPftRDx(9J=kqWP8gzSDBR|{GjALA zK3WW^u#h;In7O#I- zFE>0aEOzIFKO9Pc$s3bnAQ7ciyMRnwhZq9;-B^0YM+6F z%wQA*;}ZL@B_`s&E6&ldP@!v`_g`Qr5F1A7`#7AQW4pZSGBwopBX<&ZX>$!7h$^%f zHx6U_Y4m*vNZXauLHCX4zQNnH{x<_J7(97lqNg6~eH`dZr{Eb!=4t8dULLy`smE1J ztc?5Xcr~~;8!h-nT3DW9yuGHJMa*n|8)e6+K}?GgvHb&8 z*8?CvMRTrnyMlOw6@+w4e1no0vJwq&PcV&c`uxqaY-IB4J-bwe`vE;wLb2Bo#!a%* za2T6$7LOZzXYmSqAGqMsoTAd=JHI1ZcAt$4_bLxMYtCK5z-=cpwMcB9~l6LZ&ar703ikiCFz|a*}bCqXTHL#nkS< zjA`t@INO-trHMr88k<^I86%;GIeyF*%>%f3S(5;~4 zjWHO8^!hSvnqU*Ycq=BcEMAR0&Nw7Sg_Hl1gl?zQ11`f5LCa8!<0h$nTZaN*O^alz z(m`-_1ZRvLK+nTxY|gD#RXu(;8=?|t4;)Avz&P|69qq=H?CutBsQyZk8O|qWh4cVJ$pr=~hRCcKpzh1ymp?Hb`YpWGi2hmd#WPMO4b$KX1MCE8O zxO_BgyHx53_<6z~5KhdV7QP9aGqA}~|2f`&j-4vU!Q5^Py912Dm6RK$9MzJL zeslsBpfQMxqxh6(Jl=-(jdP%{xI~u8?jiy!_}keve?80{ZEBM8pACxVFjHU&8+}h7 z3A%!ORYG@~^{r@evmw%xhIpBVXqSEyaahJ~^y?OSSZ$rBnQ{n1xzw~>$;u%K{e0`M zVJsubRT6LUGU%YE1mhL%yeT(~-|P?^FrJkd0b#|hqrR9j_BvcazjtGXoAA)Dl5np} zwE;wyf625KgGqTXezsP9+ex?-Tp0UylWEk%IJilg4kAm2pLSa5w*=UgBK^P-H6lqn zs!GK+HrKTHp^8AV>$zlZyASVm3SCFy`kK*m?|#X2>@aYC2Mt_KQF(u8?IiAUdc?9#yFgu?XEVQCW4*(vI5oYYxFBB4%G)kCEUsZ^S0(JF~S3sIQ_MDuKlL*A9Hs|`9B z8vrOKfR`kIW@;N0-CrfbBzf&hHeyK{5>t+0*7*d;{lc%3FX6weo3gm-rb=l1y?qI5 zwR(x@fj*;7RyTC9_(zO(8UNbtu}pC`q8+JtiFkw+x39SEgn~;ti)sc7a^s&wcz%Xk*S=RhJ*d8`&NVM571w`BA34d?-%jD z%-niAuA>q|OU$hfzdAI+p{#|u-QrGYD2J`Y9??qbXBb^k)GXp3yIGfx?#Hai|3U)-5)Dq% z7bimSuvDDDc!WRStY3u&pcfHahO519Y?X)*D50B<(yK}D>n9yIM(Q*md?r!Q^;_b& zg&53Rf@qbvxC|`V-kP!PVOFz}7Z%T%G<6=)HMFiPVM|+_J-!R9K27^So8D5!Du)F~t1;J!<9?%jfS?v1%$W3af`5&1?I%EcV%mjoAzAE9hX zHMdZlMMv@g+&wo>j_lRB6J!qym*?iVF9PCZyD|$MK?oC)ppZm_l;XdLeH2O{8dQsC z;dYkYMg(S7W#Q_axL9z^^XYHEjPMn7#~k$uaUR;7&~nx4Dm%f%<-)#s&ag}>jnsE? zp^=GDCT1@YQUkYGK%G`?f*6WN0krHSurH;SQP}+dH5Z+cxYRD8Yaq_X?yOdcyQy8I zqAv+fbJ9r@0J*rh3=`PVG!L$`3BM4d!C0V2R1p*xpwC9I)7a|kk;Nl1DUx~ycL z&GIIkqa<|tTA@BTIgF-PE=Dc6$Zub9>zR{@DOCVUOj*mGwd`5Po}1WnGoCJu9^fJQ zzfN{xEyxDSxj_?15W)!Z-R zHX%KNbP(wmNUtKDL%NLgF;X0<5@{UT%|t3kYD9Vr>EHvhFn0(qzeYNXv>bq?NOO>i zkeo;+q^U^RNTZMxNWJ&TxK5;tNGfWJd?tvpBh5ydk5rCSgY@mc?AzIo^pnK~DNp@7 z0}9W#BE|9F1>&o*FAN=f{WhrqP3EPo!o;%DaH)Tef7T+7E1I`p*4#j0kdPGliwhUu zya2x{=D3@e6wanRn9LW1>h$X?_3J9ut>18;e#Q*_>h+_ z*43`5sa((f7ubz;8_Gkq`pThe)>hQ4T2~?bqwJyZk`?pTuPUF1=1w5guMTb4P*GE- zuLO*K+L9GT6?d+wDXmx~^|l(FRg~l632gMBDydk1@0z-*^&oXs&3*cN(SmT~d=G5h zy=zuiphZ|}vSfw7rkuK&$;}!xwi)YdD{Az0Re((5qtTaFtgWc4D95k1`kU#$O@h95 zL&ZI7)`vFg2N61xh}m!l$ED+%*|hoV_5KZ0Hmu)(@dVav+_W#Q&&(bffTD75e`44WHy?*_=q7Zmcv0=r+#q*ahTp!x7x?*{7Z3xo6arr&9 z>sOSoUAyYOqN+q+jwxUn!e9Q%~U`{$~0L7blI` z3bLImDmJaIsI6PGzNP?rSWrMPXmbPF&}CpoV27}G@k-f=X$Ii1Bh5w%A}vQMN2*2I zgw%l4h$OVh_w7~PAuE*aIy&bL*-L5R)4=q&@fXGyjBgmfF#g9l$>cDtF+FWMYxFhV!SJ-3r-Ol~aX6GNA|8`#IS{rt4 zbnS6H;d;jP2iMoG$?kl&&%MCC(*1?|KkiAMDITMz%(LC|yysQV8PD6Ek3G+Mf8+hL z_g(Kt-r+u%?-t)3zG~lxK2FbZ^iLYb8oY*}VU1z0VW!b-TwuJ@xYPJ!qu%rb(-~8@ z=_}J{v)LRqe`xMDEAmzO&s%uQuUJo5Pg~Dfb+#?G z9kyMzOSTT%zikQIF#9O`b#|lOWuI+dW?yYzXAjwT*dMq5*#3N5Q?^+OcEpjb$-QlWs zgKXJ9Y_PC#PA96qM{*C(;cbmK2{jqztC*WD;sqn1x-0#`zIq3Ph=a}cu z9+`K9_Xe-QJIh<_E%V;uz1w?_cbhlr-S2Jj9`?TEJ?(wV`<^$?SLj>e3;BNOJLP-Z z_oQ&R1KeTh>{2SYEQc zXZhNqw%!J5c*6P|czWLYp0(Gy-WIYwWjktn6*8d?+q3L5?LPY*_F8+y-eNyuzic1s zxCYF#I*P!)TO6yv!1azt9QzzUbDUso{1e#tfuq~;x#LSm!l81GaArEM0XxmkSY-LFY5hx18P1VJ@9(f@_v*m1~o$!S%4~Y1d`f6&L3o<{s%D>kj9*uX9g# zTijmvY-^Juf)Y&6@Ie}P1Nke_bRSxlBWmW7sOmfJ0NS~gfVSst=HYWZQ< z^0ehy%P%b_EN3j2Ebm)Bw!~pX(ySw_nO42^dh3nWe5>19WG%J^t&6R|E|F zcUD7&L(VPEZO*83w{x%aXU<xPI^kB)39I^+>uuKuu8&-wxW05HTne|^o#`I$&V|ss+=cG& z%`mr1-M2&P>)iLdBkmpUC)@|!&$y4m^t|Ri>;9|z@9rM=m+pjH<LM-pMR@$Di{mRy7 zGuh|bcf%*VY43tJm$u;s&G7}yl>+8U=bYf2?96leoOgtsk2rq_8#U53)-}oH zcLm@Na96-ptC)Rn6s&FCk#}ByV?Dm`z7}Yx5eXuIa=sh>8ZgK zZ1(K&{K)gH=S9zJo_9QCly3A|y)JKw_creX-iWu!yN_}DO>nu-EAtKYUF*Bf7dHE5 z`EK?FeRulS`5y5JzNdXJ`!4w2Avb}ThT|?F%P{B-c?PrLc37-x!+OI#h6qg7uMDpm zE*h>kE{2Q!qcP946XxY7rk}&STrj<7x?<9p$C;PFlGK|YG~4s>^V0lv`CIcJ&hN?p zBEK(RZW(QvWSJ3$QP^uaVEK*ZqUGfw#0UuZKLge z+k>`7+atD%@GkG$KeuE5hs(skdJN%gquw~pINgY^S{XMFS+}Lf(umFuSP#Ouv|3d# zC7HJAHiIo_tF`S!Jh0F9g6)*;EbK{W1K+w8mS`|Lo{Ameh8afWGz kMG(qj<2+-~xX8HFxZJqXSZ=H`uB9G1?&uF|WRDK{KX7qB#{d8T delta 17688 zcmc(HeRx#G+4tGaE?L4ZStN@Af@~mQFo660k=@OP$RZ%ivm01Gib~KBLqLd_D7J(R zEYTbeDfk=}skE|nt*8{OBtQ))T2!?7lxo0OPuSSTHkC-D`~L1ZyCL-H^ZxN( z*L%HtU2|s6%suzqbI<)Xb0%qQ9@f~S-tAR#ibqSz?g>x)QH5bkpEaHGhTUTwgZBgG zyR6qE&l|SNs%QCw*6}Q_wT?n=IlPOt8@BwzYGn0WtYcYTWzAvvYL=I;xw{&;_iSCO z82zYem?ae8xCII|_pJ4I|G}kxot!d%gkm_yg-|g`!D@BOkm->s#G4coefzUGPQ`Ic z)+#wAR|*g`QR`qXzn0c0xNg*LTCL!`)ZCcG9aKJ=KU%vxi`%W?xZVnm%X>6`yuoz0 zf-5D6^sj>B&Z9x>RcIXFBhmQ-^wv=N}B0J)nGsW@dvFg@<_ z#q8bfmp>kHGA#X|j6v~%9wE@v+6)LGs0mAF<<5MdSBUiTk%4$~ooLqPiA#rFr+lVP zTsv%9^qdSLe16CA(-EO3{yh4k$bNW_^%O8N9xY`9Sl|DRmPY=nb-PRqWk-zH67y_& z)bm2%eCs|UMn`b%7u4YzPB2hSxfHmKFh;cu{bw?IKF}ouyZGRM48%vIjzB+Qu1`Jg0324cswm=&5lY8oKBC0hYr1_!c_j>1$G`WEdOAtLcvLI72B zm4bm)s@?()ewGRdvZF`KRPCMM7AmwsLe}^5h8sU3!?}+ zHr(P-dOnnwz;vaK(mdi@cLxLS3QK?Yvjt@9EUzwmioKcWNatRk7TSMUEK$A_((tN+uoTG!cyx9Dl9FXNBFgZVP~EAPF9|{ZTNM{$Lho< zhEG-M{o)(LuaC;I{+^G~0U;X)+970(GBuPPDWs~a692hObBY?0T0uu}Yflw2A)}gd zscEh}GHKG}bdNqE*vAL^1p~qGk=~Agcs9$BQ^*#!KXz;!W&w%us2l6VZ?kU7jr=p2 zgbHF2tN1bv6GUxD^8Zuxk0@2X;}i44qwnm=Tfzi+H!KlgF$Lm3rmz`ffT5Hfv0Xcb zXXNRU&9v&G z(lrZT0VWBQ-dPRbin zQTK3E1vP_$34qcUjbbet#?pRama3?XpqOdsjeTFk)nhWf9i`Jj7?%j3DfW<-Dj`H= z(^1DIOf=?PO&C=|8N{UdG6|2SscnlE;2pE3ldph^vK|>67v&&OG@jlwsv(y;gOE{t z2xb?>J}MSM(+6MVdInOM>KRgb!m5UGslH(qA2O!kshpRPvGxg9Tl!fU>)tCwgJ5nr ztBMcFgV386Z`27kb4=`;WL+Mp1^;C8)jQODnJ^QYm5JsqL*>T$sR!A@a4s`Xy+h5D zjm#5RNV>pvU;cJDnX{g-^pacrqsAD$&y|+K8_*8@A+rblq3lQwRb4d!O>PF8G69lEyV{C2NoYS~*Zt(8eh z+hgWxZSkE%PN1tJFd&mNH79ol+2V%D@QYyRu=b1U4CX+Yra;p4LZnNWrRSB2HUaKQ zT$?j_L@Cp<0S|Oi+?%sr+2j<58>UPq^Vl#8`URo{9V05z&o5R$q|#Ml*pQpwXhka0HVEfScVz{>^C&pnBfe7?ye?&Q0##pco1f`!V2Ml5#<8|Koe_Mg{80lmRbj} zT2n4<{91kuU_CNI((#mmCSYY)Qhjq3cv!i#I<+nYoEefHxST9t=A59_VdZYaL z3tUNmNIIGB!CF}l;*Q*dgphhLFV2%W?<<#{K#wT6(4l6{tP4q|+=UD*QAN2d&S7bF zdJNXcI?xKr9rm#fpo$87gyO`Ilwx#;nzgbX6i3NDcGfAD$z-9VXC_)ImlWwisFDCX z)FhyCmjhG+Rg}xITv$3|WsBLNW{s@F<~p%x!nmoO#mW>0iAoP$4LnH{Vm&zs{tiQ; zC)^h8-$V!p1RWJ(?HZmH1OvTpy>uAEwO`3_8+w3eOIDmRFeP!F48OIT0eq9e9DFa& zz_$7bsuA>T9&2rD4t%{M_;qveaf3~PUeTg`?YA?Vn+!5)lzEnzadTdA3b6(60Llf}jf{39e~i7!sfRbrl}CZ4tt zO8Az>4)yCOK{t}|+)|~!wGD3_>JxHZv_nnfpJa7FcgmQrJXk087?-(j-zJ-Pab zhpyISdFHA%XLUbC&`QsppiRE%7MeKr(P-h=?g|j@z>Sx6XH=LJ7 zFv#^~8qdl4n*^O)AJ#HT0HF1}S3g=XfO!`t&3BZ7C!V>Q=p7K{Y(_di6dAO426y2s>wM@WDibuDVNoXznVOH`t7xtXG9~Yb}&OMwO>#Pk5*7+ zKqF{(%K=IIMU}9vvR3S!JVB`~6|)Pjr>wAGa#UWUuE90xdVujB3w8m0T9-l66ImT<$}s~@7OuG}kB-np zvj;n8#rl=?Gt&|h)|RIRFwV_NjeyuPB+X0VJ@i8*!+Yq5Vr1$=W0)nQE#?4dC~Q<> z#)i_Sm%65U72~IWPM$+Ud(wa&F<<*P#E*e;Y4qo!r*Otdk{li@9@G}0tN1|SElR0O ze628_vQG+UQZ{nh4V2BC=BI4KwDFYfoW|N-pEjA^E=(IYno#Yv9xFOVt~H=7QUl+} zo2(_C&r&4xBp{YO#0VJn_I@>1O)7(JY)4ILd-rJBs|c#crMozN2%&OVN?sJBH|4D& z>!2nmX0SCyx;k)F?#DWHwO<;Y>c@89eZVH;W z`9*QyraWckMR8nFM3V==4)xq7@xh{^f`i+@>Q9Dv|5%ScE?E?yPdA-dEgilfzF9P5 zp`;`SqvWC1Kky*wE-rM~+%jFmot7>-FX{N&I*YC;for{YF=EZD%q z(+iXukNC;-X*D!5c8Q(okp*1==2S#+C-yLXG4JCvM6#ajb%%7j-^ST67_p@1l6zriKt0!v{@*ljrlgi4083EEW}UTfdc`Nzj?e8d;6c=>`>xhV1d&Ci zT+oF86>C@UtdKqo0Ff9)e84nS3BrD2x;e^tkq>iL#g?;*S4Eb6mZ^`Oq9D17*GAez zFyU{WVixZNy%;hO6$EGW8NaO?DMT`3&?Z1^HxK zWUYsu#TQ#?F52B;sqj2wYikI|1tw(Wa>PLfC@c+^n=hYhJuHe*^UPctHh~kf0rit` z(sID=(Jg2ae`lT%BD(I!3C=+G4>9akAEO;$atL^3NAOB>@Smv=@So+Y}@$h~WD>R?E}%vJI8RYP7i{Cv$dqrTr9xwIp2sX364 zM-3*z(!?7nU}D3(q!i<2HFB9Lj<|$836??1`qLnbbL^0)pj-DRf z>v(3jC~&@weF@52k0o(7-F^kCPlG?m*w>9GQ^pqd7q)MweiyaqNO9rZ0*Jl)P>RBXvil zt2u0lvkEm~*%9n(Ze9v=AsA}$%1G`XB$?q4_5=UmkWn^(L}$ey_+gpg`_k6C>zb}a z?@)4y1MWZ<&LbHyL@r|r`4u_nV&qcLaSgewB1LXAMQ`>ihDT`d_v<9`*iHS!uHa7Nq{lN2%+V2{|!BqoB*Oeo*4O94c$g^2l{0aDQa zIOrD)r|~jG_y^)tk)hs115@$Zg?C2=qN4{TCZ!)d4vr!No=AVxgsHT$8NiL`Xa<7e zP!t(&ph>WfRXD?dy$ldT6QgA@lpFXQx$=gqV*2me(b@!L&^l~YNF(BB@BmsIM{7fZ zfn*@Vunte2m5uS|sYZPk&sHi5I#Qer-EKU2l*N44^)A|claZi&tB-BPVH{uxPc;WG z?TB1zj-*UdAQ6%lO#e{H{%tV!>{S0CJeyFaZ#_i0j=hC*ctaO3 z$LWEMmVWCgj;S!cSMl@paRxS5n+h~p&>5%5vq*jWMzPB^HOc@qIH)X_VKu_2a_Jp} ze=OvNR`ih5gW6Ca3LVCo2{Z-!>9exK=%kqkaZ*4m6AX03z}U{?NLNR1LPX1lHE~vC zRP*@Yqookf0BaeA+Q8nDi%O|%Sn6e?t6GWUDU4L)%W$--^#nCr76JkD#~G@}Ny|gh zZ{;rXh;)F>2m!Z>)C>#u20_hUL_)NFDV%I6qh&dCe!-|q_0dv)dAAf+6|vBOHylPk zdGCYJouUO^cOF%5s!3)zC)B3b})TwHjrf6S=&B-WYP(BxS%) zGTW4X20>8+g(nVnloilR z3N)8B$c$vi5Q4&^+%hrUFBgK!A)uv>DbDiq^Ab17#|?tgqb4?Q8FwvwY8;s)cF@62 z8wB}q{zh5M=H|vu;VUFz=I7_ib?F7gseQu2PA&x6#YSn6hDkE8P?j4ziO(0TLc6QSKsR!C<4JGgH%)S;hKv%wlv6K?XBAi0ofZVrDR~C^3yVpTfq*k~<0E+}K-6 zR!`pvNNHIz__{7JD?akO{}GL_}321>?lDk(o-I zW9eg^n!1q!BR0zG$QdS#DX}Y4{TrGh}# zR@BSeDUOH}qL82?9AW9{K^zoUT*bj+ka8JT`uym+fz0=CW!s3ilBPCXMY^ zR6Hw?L5S)-Y9giKmaFK~BvO}hY5Z0E&8T2jWRSw|-cHZ5aS*>p)|0Y9gmIcOx;%+2 zEWIsvp&6fMF#w|_&9+|-BHRS%m~R=L*wUv~DdwY13wvkA;_7ax0NXk0a7j_l)C9v3 zXjpoIMF-kedV_?ry~_J_1#t!~DWU+ZB)S9x4OK2}Nx{>b^d3H<$u0zL<$|(4JLT+2 zG3hLwwZ%3SaM?{e8M_H9qK)@1K$tZx^2QD$kOGFKN5;z0TtxHU#W>U9V?s3LBU1F^ z{EoG>XhS^fB~J_083v}a?0JpK;={_HcLe|39Q-1+tNx-~`sn%;Z35A)_@C%5Z&vNW~T;YgW0C^^H6 z%6jAAO8l#X?MRR3Y}wHY$5Jiem!#(cfhfpsJ~@ehdQWaCIXvNwtWz5P4(YnNV8W?l`96*azE~ zukQgU!GqUTKSNOS8I+2kN~CXbA|}lx(W46>yKq;IVQrAHo+0>gSFw&HqNImDOcrAt zl{^HFr6dgyNEzsivnqN&0IVHq33T6l<~x+S21`8~#ojtT5YP zfY!sPucuFksN#cNi5UXEmg77C7iO?LY^#HF6$A>@hjuImnlBDcS~1%Tw~jRh=@1s5 zg)-)=_~5z3NPLQ5_t&~IK=e5@2!V5mQ%2zafDk$735z$)&5s6h*coW!@7S91bakzh z&T@l29f9-UH<$XdPZx;LKO_XtLT2#ww?v{I`UF1Bp2vAE4#x-ZOdkHv+c^F4)Qb?v z6|hyL1FS8$9FZ$1`M_x$&9WLkcv^_y(p%s(uM~oL^x22@o&XHw(N&$30Aw|M*;}+1kZ8Wa@S+zbYmP%YPZ`|Ap4jbdrP}1-Wl}>0=yr`~)z$Og`2b&MDX3fy5 z=UJ7iCYdzsuMmGb&tFL5k=>GyEd@5H?H7l!5B3l`x`0EM2K#WWg5BFFnC}~(Dq|O& zqaf;gK_(=MU6tBAf7}g@JhGV(Xtd#XmaV8cxe6$ndw^^)wksY1k)IjGbAmVSuZLk|l1aQAu@b@vYme*U7X)3wil_msBWbFDMwts_71w zK$n_w%4-x5F(7-gLJTg*jpoK0w5kUB5cvU<8;YdT;*-8rgJbzVc7jNeRLt9wdmoO% zv$yXDB)Ec)OH_gB)?h}xWSr=dN7ArU9vXH?Wob)1i0@lqBRk~pk|5eDJ&w>148VzP(c=9t!40 z%b2OaeVMaD;4J&(+z&32>UKhP2f~s<9$zpJaT$^G_(Xt0oE~f2@{uQf4SgXfU5OZ- z9R|+`ku&8I-KdL|gEZU^8CWGw zYP?7ahIg${2)03qGT$MR7nVgFwfbgwbvY5`$ApPgviOM*>K%;V2za_lK$r2=%MD z9R(*qb7lmPakz%)5J5f4pkTa-<{<=NtT8fspu{0*J~+)-MYe%yVn2ogP(A~~Eo$w7`v}7r-(*R3$(^(8tiSN9~gojjuy$}F=KpT2ZkLE-!Y|JUx7*9vt_0orRkB@HIDxqW%4t;?&XOuB$+5e^+bUN1@3Ym&naRG(Cr z-Y0HYWL$*~GQru`P|E3RI3WB8_WTR_Troft#c4R)(5Taaa2HX~{W7YPcH*sIUjSUm zkCuZ6O>NoRA7L#y4~o5uCQc^0wI+8@5ukJ$#(eo5L}N~M zEzwvZeh~2+ZA9s6x|50aq_hNmj_J7?ZS`(~QD%siCB=#n;=M~IM&?2SrFH-;KMouR zsa=E-{clX~!d2dSEv>L&GqEsnPmM-;iu%P?52V0}`CW|D7nY1EEd?0XDKiXh_O3a-C2qrFj_rIB-uAolA|GUJ&$#w^F=w>BP+0RGv-c z@mVP=iA;QY>E5wt&{X}86`Z~@4m4Z{mJq5GH`a>bWl#Gb^HQimsPG;_U^fFx*0N_Edv3zhqcZ}$UitUq-IEx6~)Uv5;?I{GKaTyBIs9Q`=Lx`Re7SPi^ zm!7`acvkJi*HeW)TD21=3iLXmlx1o!%ci(kHp7N&-!64EG9kdV-p+CrK5^j+S3rZ0 z6sT|Ngb&4aP6&|#A9do?*m^tOI@BRNhpV_Y+y!8*&~GB0Z#suAaZK8b@_E`a7;KnA z>wZAhC?wqD=9bsMoN=hE&c(7M4Js64zWw)!D_0nZk6@t|8F6eo^5m40?0LH4rQIv$ zD00rQx3hR2UW^-@-8d*oitWmuMGwHr?L^vyREabn$%b?T(nzGfY6W)==?K!Vk@g|I ziF*23?on`ak-mpijkF1A2htNr&mjF8sSxQbl7w^v`j#OrK>8liUDb*xw+@Aek&FNs zgQP`LAq`YvaHJljPNa{JP9wd6bP#Dj(lNm8MlKPdNZ%pl;LqM}K>F9;w#DqP%vg2$ z5AKwlk>l=0)h7G}+$MZPKaZPwjuap*)`9!PnJdeq^Onwx|W_9$0N8K;wpuMglahsidn!w`{0iS4jXHSFc*PZo}Qib@lhwu32BT z0c}fH-nzPOVg0>xHf&tD>fY7Ggm3+ZI%Cy_`t_Ch)V=_~3&iY-2It1RI4%na3m0xM z1~zWouo0I;7;e^ML+$GIH)DiKV_o%XMjIi+5aNrgZdBd7s+QZc=`SLYu_hQCWU`#z7XfB-3NGD_ubPAH1po2Bv=8l1?Ryb`P@e98 zPVPUNRTRN$`jH5ruy)V8s}a~R6k^h6Q1KwP{0tBeVhkk{ z`b<)bV~OKNl&P*1IkLeY)%D^}Hq$>ZWZYZ9jphywsr)a}z=}un$Nc}+-xdE4^>@$3 zdlZwjS*n!}+`qndfi9YE60Lj_W3 zF2}VYFGZ?Ac|TGqBI`E5yo2;H(w~w3fuvfCen@$1U;TQm;(H3Ee$^i3dIkOzZ`Gb9 z$cNEj(zZPhuU8y18exkIk!(n%NDGh_BUK<(Bf-R;*`ujd%u+PII=@zNBqRDddOu!{g%fqPg#C$dE4?&i`JTNt+4K}{@nUs)_&_8ThO+_#@imZJ!3m- zn{Kz-BlZ>cd+dV!HT%7eI>!@^gN{zedFN+NwQB_KEO=aNT|aXjcMU6c74Iw-i(f8& zt+=B&Q9Rz$;(68ciKo{yJnD6N-}RpN{?(i5o9-*|wfVmA<@$|&yWj7h=P&o)(bxBO@QpZLG<5BNDF$IZsvhne)Iv8I_Om#NG&-?Y-S#?)lmWfD!# znZ7n9O&aq^bB=j}xxjq0*>0X~o^P%&udwX0JZ9Nz`Kjf9S)wmnUbCFC{ND1pCDZz$ z^;4^4{nGk(>$g^gEz@?BZM&_-w%7Ko?FHKr+aGM5wuG(UX0Xq)FSOU#Ywa<6v;A@V zkLe{+Yeke#NeFjB-qLtaWU4JneYd@mGh+Io3JT8FW@T1*hoT?>y=} z>HNUi=}bC{qAr(fsp~0MtLp{V5!W%-+phDjuU$!3rhBA&th>N%b9>zZ_d@p)_iFbB z_xIg`TXc^s9$!4E_<-k-=NnI+cY$}E_XY1;-YedTK96sK@5jEEe1G)y_>?8rl}s$L zmAqK;a>>P#%O&5HSp5t9%lzy8QU6c<2mQzWpZUM`M>!M6?Sua3nQk>L2lE~; zpRzt+N;+M*A+uKF2Q{M;vDypE@MRmyWL;O6NRh*tyhshjWed`_667-OeYS&pKapzUn;f zJnQ__`GxbJPK8VBy3Q5NcTIQMTz=QBuEnk@*Lv6YUE5qOuE$-^xn9JAw7Jf>K6ZWT z`m^hAu5Vphx6wV-ZFW1bBw_b*_ew0vTK9eKhuquTJKT@Eq@q@*ii?gn{#_8g7 z#h({{S^Rae+N1O2cy91a_Lx0RkIz%)nd=F97I~I?R(dvh8a)qt_IZBk`JLwj&mTP( zJeNFw^&~wS@Ack1?}c)`-c~eQ*0dgiu}d zNxm+vY}*a$q!3@RPytZ7fOCp@@C1~ zCFe>yOQe#2lqmd}{v0TFp?{{|WAcF|Vd=GeZOO2Xu#U2hwNA3$Xq{noTm9DA)&tNWDuyn9aZ_TpW|dx{T3*yh-F!qe@u#ci+Jj@vHSx@~_4lXL77>~?$5ei!`Sy|Di+ z_PzG!>@UItykq~s-e>>Dp5>V2D0Y-O7CY)44?7-p>~)-Qyba^@q2s)x+i}Hly|Vy3 z+~s`Tsd8DPu18^7IQIzmDEAb1F$~Kc?)%-1?%%qPxj%DD?gPay6dx`AQ}I{Dmy0Vr zRi1U8jh>iim*>ZxBc4pJ);rld$Ggb8(tD40gZBsCr&HSghW7+K!Wn4%pS@pu2cYp9 z-$-AMZ@h1kZ<^2KbHdXGd_iBt7rg^|ztQ)gufg{SwEijI&!O?J``UdSzIS||`7ZhX z=Ii%;=bHn44g0a(<8lx$NG2^*D%YH6#!H3#-#pe?YvDV4tOHigrhyT!uvOdE!GAW} z4%klGx*(*zHmyC+ZnJysA^Yw2N;~@2D#nu=M<7~gT5KYOMtJH%tenYgGrxLYgJRb( J@r?4b{|zT0MQs28 diff --git a/Source/Plugins/VisplaneExplorer/VPOManager.cs b/Source/Plugins/VisplaneExplorer/VPOManager.cs index f5a9f968..7329c7ff 100644 --- a/Source/Plugins/VisplaneExplorer/VPOManager.cs +++ b/Source/Plugins/VisplaneExplorer/VPOManager.cs @@ -50,7 +50,7 @@ namespace CodeImp.DoomBuilder.Plugins.VisplaneExplorer private delegate int VPO_LoadWAD(string filename); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int VPO_OpenMap(string mapname); + private delegate int VPO_OpenMap(string mapname, ref bool isHexen); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void VPO_FreeWAD(); @@ -151,8 +151,9 @@ namespace CodeImp.DoomBuilder.Plugins.VisplaneExplorer try { // Load the map + bool isHexen = (General.Map.Config.FormatInterface == "HexenMapSetIO"); if(LoadWAD(filename) != 0) throw new Exception("VPO is unable to read this file."); - if(OpenMap(mapname) != 0) throw new Exception("VPO is unable to open this map."); + if(OpenMap(mapname, ref isHexen) != 0) throw new Exception("VPO is unable to open this map."); // Processing Queue todo = new Queue(POINTS_PER_ITERATION); diff --git a/Source/Plugins/VisplaneExplorer/VisplaneExplorerMode.cs b/Source/Plugins/VisplaneExplorer/VisplaneExplorerMode.cs index 6d993e11..761da32f 100644 --- a/Source/Plugins/VisplaneExplorer/VisplaneExplorerMode.cs +++ b/Source/Plugins/VisplaneExplorer/VisplaneExplorerMode.cs @@ -25,7 +25,7 @@ namespace CodeImp.DoomBuilder.Plugins.VisplaneExplorer ButtonGroup = "002_tools", Volatile = true, UseByDefault = true, - SupportedMapFormats = new[] { "DoomMapSetIO" }, //mxd + SupportedMapFormats = new[] { "DoomMapSetIO", "HexenMapSetIO" }, //mxd AllowCopyPaste = false)] public class VisplaneExplorerMode : ClassicMode { diff --git a/Source/Plugins/vpo_dll/doomdata.h b/Source/Plugins/vpo_dll/doomdata.h index a87ae6c6..5431aee8 100644 --- a/Source/Plugins/vpo_dll/doomdata.h +++ b/Source/Plugins/vpo_dll/doomdata.h @@ -1,221 +1,235 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// all external data is defined here -// most of the data is loaded into different structures at run time -// some internal structures shared by many modules are here -// -//----------------------------------------------------------------------------- - -#ifndef __DOOMDATA__ -#define __DOOMDATA__ - -// The most basic types we use, portability. -#include "doomtype.h" - -// Some global defines, that configure the game. -#include "doomdef.h" - - - -// -// Map level types. -// The following data structures define the persistent format -// used in the lumps of the WAD files. -// - -// Lump order in a map WAD: each map needs a couple of lumps -// to provide a complete scene geometry description. -enum -{ - ML_LABEL, // A separator, name, ExMx or MAPxx - ML_THINGS, // Monsters, items.. - ML_LINEDEFS, // LineDefs, from editing - ML_SIDEDEFS, // SideDefs, from editing - ML_VERTEXES, // Vertices, edited and BSP splits generated - ML_SEGS, // LineSegs, from LineDefs split by BSP - ML_SSECTORS, // SubSectors, list of LineSegs - ML_NODES, // BSP nodes - ML_SECTORS, // Sectors, from editing - ML_REJECT, // LUT, sector-sector visibility - ML_BLOCKMAP // LUT, motion clipping, walls/grid element -}; - - -// A single Vertex. -typedef struct -{ - short x; - short y; -} PACKEDATTR mapvertex_t; - - -// A SideDef, defining the visual appearance of a wall, -// by setting textures and offsets. -typedef struct -{ - short textureoffset; - short rowoffset; - char toptexture[8]; - char bottomtexture[8]; - char midtexture[8]; - // Front sector, towards viewer. - short sector; -} PACKEDATTR mapsidedef_t; - - - -// A LineDef, as used for editing, and as input -// to the BSP builder. -typedef struct -{ - short v1; - short v2; - short flags; - short special; - short tag; - // sidenum[1] will be -1 if one sided - short sidenum[2]; -} PACKEDATTR maplinedef_t; - - -// -// LineDef attributes. -// - -// Solid, is an obstacle. -#define ML_BLOCKING 1 - -// Blocks monsters only. -#define ML_BLOCKMONSTERS 2 - -// Backside will not be present at all -// if not two sided. -#define ML_TWOSIDED 4 - -// If a texture is pegged, the texture will have -// the end exposed to air held constant at the -// top or bottom of the texture (stairs or pulled -// down things) and will move with a height change -// of one of the neighbor sectors. -// Unpegged textures allways have the first row of -// the texture at the top pixel of the line for both -// top and bottom textures (use next to windows). - -// upper texture unpegged -#define ML_DONTPEGTOP 8 - -// lower texture unpegged -#define ML_DONTPEGBOTTOM 16 - -// In AutoMap: don't map as two sided: IT'S A SECRET! -#define ML_SECRET 32 - -// Sound rendering: don't let sound cross two of these. -#define ML_SOUNDBLOCK 64 - -// Don't draw on the automap at all. -#define ML_DONTDRAW 128 - -// Set if already seen, thus drawn in automap. -#define ML_MAPPED 256 - - - - -// Sector definition, from editing. -typedef struct -{ - short floorheight; - short ceilingheight; - char floorpic[8]; - char ceilingpic[8]; - short lightlevel; - short special; - short tag; -} PACKEDATTR mapsector_t; - -// SubSector, as generated by BSP. -typedef struct -{ - short numsegs; - // Index of first one, segs are stored sequentially. - short firstseg; -} PACKEDATTR mapsubsector_t; - - -// LineSeg, generated by splitting LineDefs -// using partition lines selected by BSP builder. -typedef struct -{ - short v1; - short v2; - short angle; - short linedef; - short side; - short offset; -} PACKEDATTR mapseg_t; - - - -// BSP node structure. - -// Indicate a leaf. -#define NF_SUBSECTOR 0x8000 - -typedef struct -{ - // Partition line from (x,y) to x+dx,y+dy) - short x; - short y; - short dx; - short dy; - - // Bounding box for each child, - // clip against view frustum. - short bbox[2][4]; - - // If NF_SUBSECTOR its a subsector, - // else it's a node of another subtree. - unsigned short children[2]; - -} PACKEDATTR mapnode_t; - - - - -// Thing definition, position, orientation and type, -// plus skill/visibility flags and attributes. -typedef struct -{ - short x; - short y; - short angle; - short type; - short options; -} PACKEDATTR mapthing_t; - - - - - -#endif // __DOOMDATA__ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// all external data is defined here +// most of the data is loaded into different structures at run time +// some internal structures shared by many modules are here +// +//----------------------------------------------------------------------------- + +#ifndef __DOOMDATA__ +#define __DOOMDATA__ + +// The most basic types we use, portability. +#include "doomtype.h" + +// Some global defines, that configure the game. +#include "doomdef.h" + + + +// +// Map level types. +// The following data structures define the persistent format +// used in the lumps of the WAD files. +// + +// Lump order in a map WAD: each map needs a couple of lumps +// to provide a complete scene geometry description. +enum +{ + ML_LABEL, // A separator, name, ExMx or MAPxx + ML_THINGS, // Monsters, items.. + ML_LINEDEFS, // LineDefs, from editing + ML_SIDEDEFS, // SideDefs, from editing + ML_VERTEXES, // Vertices, edited and BSP splits generated + ML_SEGS, // LineSegs, from LineDefs split by BSP + ML_SSECTORS, // SubSectors, list of LineSegs + ML_NODES, // BSP nodes + ML_SECTORS, // Sectors, from editing + ML_REJECT, // LUT, sector-sector visibility + ML_BLOCKMAP, // LUT, motion clipping, walls/grid element + + ML_BEHAVIOR // HEXEN ONLY: compiled ACS scripts +}; + + +// A single Vertex. +typedef struct +{ + short x; + short y; +} PACKEDATTR mapvertex_t; + + +// A SideDef, defining the visual appearance of a wall, +// by setting textures and offsets. +typedef struct +{ + short textureoffset; + short rowoffset; + char toptexture[8]; + char bottomtexture[8]; + char midtexture[8]; + // Front sector, towards viewer. + short sector; +} PACKEDATTR mapsidedef_t; + + + +// A LineDef, as used for editing, and as input +// to the BSP builder. +typedef struct +{ + short v1; + short v2; + short flags; + short special; + short tag; + // sidenum[1] will be -1 if one sided + short sidenum[2]; +} PACKEDATTR maplinedef_t; + + +// the Hexen LineDef structure [andrewj: added this] +typedef struct +{ + short v1; + short v2; + short flags; + unsigned char special; + unsigned char args[5]; + short sidenum[2]; +} PACKEDATTR maplinedef_hexen_t; + + +// +// LineDef attributes. +// + +// Solid, is an obstacle. +#define ML_BLOCKING 1 + +// Blocks monsters only. +#define ML_BLOCKMONSTERS 2 + +// Backside will not be present at all +// if not two sided. +#define ML_TWOSIDED 4 + +// If a texture is pegged, the texture will have +// the end exposed to air held constant at the +// top or bottom of the texture (stairs or pulled +// down things) and will move with a height change +// of one of the neighbor sectors. +// Unpegged textures allways have the first row of +// the texture at the top pixel of the line for both +// top and bottom textures (use next to windows). + +// upper texture unpegged +#define ML_DONTPEGTOP 8 + +// lower texture unpegged +#define ML_DONTPEGBOTTOM 16 + +// In AutoMap: don't map as two sided: IT'S A SECRET! +#define ML_SECRET 32 + +// Sound rendering: don't let sound cross two of these. +#define ML_SOUNDBLOCK 64 + +// Don't draw on the automap at all. +#define ML_DONTDRAW 128 + +// Set if already seen, thus drawn in automap. +#define ML_MAPPED 256 + + + + +// Sector definition, from editing. +typedef struct +{ + short floorheight; + short ceilingheight; + char floorpic[8]; + char ceilingpic[8]; + short lightlevel; + short special; + short tag; +} PACKEDATTR mapsector_t; + +// SubSector, as generated by BSP. +typedef struct +{ + short numsegs; + // Index of first one, segs are stored sequentially. + short firstseg; +} PACKEDATTR mapsubsector_t; + + +// LineSeg, generated by splitting LineDefs +// using partition lines selected by BSP builder. +typedef struct +{ + short v1; + short v2; + short angle; + short linedef; + short side; + short offset; +} PACKEDATTR mapseg_t; + + + +// BSP node structure. + +// Indicate a leaf. +#define NF_SUBSECTOR 0x8000 + +typedef struct +{ + // Partition line from (x,y) to x+dx,y+dy) + short x; + short y; + short dx; + short dy; + + // Bounding box for each child, + // clip against view frustum. + short bbox[2][4]; + + // If NF_SUBSECTOR its a subsector, + // else it's a node of another subtree. + unsigned short children[2]; + +} PACKEDATTR mapnode_t; + + + + +// Thing definition, position, orientation and type, +// plus skill/visibility flags and attributes. +typedef struct +{ + short x; + short y; + short angle; + short type; + short options; +} PACKEDATTR mapthing_t; + + + + + +#endif // __DOOMDATA__ diff --git a/Source/Plugins/vpo_dll/doomdef.h b/Source/Plugins/vpo_dll/doomdef.h index abc03041..2aead1fc 100644 --- a/Source/Plugins/vpo_dll/doomdef.h +++ b/Source/Plugins/vpo_dll/doomdef.h @@ -1,258 +1,258 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Internally used data structures for virtually everything, -// lots of other stuff. -// -//----------------------------------------------------------------------------- - -#ifndef __DOOMDEF__ -#define __DOOMDEF__ - - -// #define macros to provide functions missing in Windows. -// Outside Windows, we use strings.h for str[n]casecmp. - - -#ifdef _WIN32 - -#define snprintf _snprintf -#define vsnprintf _vsnprintf -#define strcasecmp stricmp -#define strncasecmp strnicmp - -#else - -#include - -#endif - - -// -// The packed attribute forces structures to be packed into the minimum -// space necessary. If this is not done, the compiler may align structure -// fields differently to optimize memory access, inflating the overall -// structure size. It is important to use the packed attribute on certain -// structures where alignment is important, particularly data read/written -// to disk. -// - -#ifdef __GNUC__ -#define PACKEDATTR __attribute__((packed)) -#else -#define PACKEDATTR -#endif - -// -// Global parameters/defines. -// -// DOOM version -#define DOOM_VERSION 109 - -// Version code for cph's longtics hack ("v1.91") -#define DOOM_191_VERSION 111 - - -// Game mode handling - identify IWAD version -// to handle IWAD dependend animations etc. -typedef enum -{ - shareware, // DOOM 1 shareware, E1, M9 - registered, // DOOM 1 registered, E3, M27 - commercial, // DOOM 2 retail, E1 M34 - // DOOM 2 german edition not handled - retail, // DOOM 1 retail, E4, M36 - indetermined // Well, no IWAD found. - -} GameMode_t; - - -// Mission packs - might be useful for TC stuff? -typedef enum -{ - doom, // DOOM 1 - doom2, // DOOM 2 - pack_tnt, // TNT mission pack - pack_plut, // Plutonia pack - none - -} GameMission_t; - -// What version are we emulating? - -typedef enum -{ - exe_doom_1_9, // Doom 1.9: used for shareware, registered and commercial - exe_hacx, // Hacx executable (Doom 1.9 with patch applied) - exe_ultimate, // Ultimate Doom (retail) - exe_final, // Final Doom - exe_final2, // Final Doom (alternate exe) - exe_chex, // Chex Quest executable (based on Final Doom) -} GameVersion_t; - - -// If rangecheck is undefined, -// most parameter validation debugging code will not be compiled -#define RANGECHECK - - - -// Screen width and height. - -#define SCREENWIDTH 320 -#define SCREENHEIGHT 200 - -// Screen width used for "squash" scale functions - -#define SCREENWIDTH_4_3 256 - -// Screen height used for "stretch" scale functions. - -#define SCREENHEIGHT_4_3 240 - -// The maximum number of players, multiplayer/networking. -#define MAXPLAYERS 4 - -// State updates, number of tics / second. -#define TICRATE 35 - -// The current state of the game: whether we are -// playing, gazing at the intermission screen, -// the game final animation, or a demo. -typedef enum -{ - GS_LEVEL, - GS_INTERMISSION, - GS_FINALE, - GS_DEMOSCREEN, -} gamestate_t; - -// -// Difficulty/skill settings/filters. -// - -// Skill flags. -#define MTF_EASY 1 -#define MTF_NORMAL 2 -#define MTF_HARD 4 - -// Deaf monsters/do not react to sound. -#define MTF_AMBUSH 8 - -typedef enum -{ - sk_noitems = -1, // the "-skill 0" hack - sk_baby = 0, - sk_easy, - sk_medium, - sk_hard, - sk_nightmare -} skill_t; - - - - -// -// Key cards. -// -typedef enum -{ - it_bluecard, - it_yellowcard, - it_redcard, - it_blueskull, - it_yellowskull, - it_redskull, - - NUMCARDS - -} card_t; - - - -// The defined weapons, -// including a marker indicating -// user has not changed weapon. -typedef enum -{ - wp_fist, - wp_pistol, - wp_shotgun, - wp_chaingun, - wp_missile, - wp_plasma, - wp_bfg, - wp_chainsaw, - wp_supershotgun, - - NUMWEAPONS, - - // No pending weapon change. - wp_nochange - -} weapontype_t; - - -// Ammunition types defined. -typedef enum -{ - am_clip, // Pistol / chaingun ammo. - am_shell, // Shotgun / double barreled shotgun. - am_cell, // Plasma rifle, BFG. - am_misl, // Missile launcher. - NUMAMMO, - am_noammo // Unlimited for chainsaw / fist. - -} ammotype_t; - - -// Power up artifacts. -typedef enum -{ - pw_invulnerability, - pw_strength, - pw_invisibility, - pw_ironfeet, - pw_allmap, - pw_infrared, - NUMPOWERS - -} powertype_t; - - - -// -// Power up durations, -// how many seconds till expiration, -// assuming TICRATE is 35 ticks/second. -// -typedef enum -{ - INVULNTICS = (30*TICRATE), - INVISTICS = (60*TICRATE), - INFRATICS = (120*TICRATE), - IRONTICS = (60*TICRATE) - -} powerduration_t; - - -#endif // __DOOMDEF__ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// Internally used data structures for virtually everything, +// lots of other stuff. +// +//----------------------------------------------------------------------------- + +#ifndef __DOOMDEF__ +#define __DOOMDEF__ + + +// #define macros to provide functions missing in Windows. +// Outside Windows, we use strings.h for str[n]casecmp. + + +#ifdef _WIN32 + +#define snprintf _snprintf +#define vsnprintf _vsnprintf +#define strcasecmp stricmp +#define strncasecmp strnicmp + +#else + +#include + +#endif + + +// +// The packed attribute forces structures to be packed into the minimum +// space necessary. If this is not done, the compiler may align structure +// fields differently to optimize memory access, inflating the overall +// structure size. It is important to use the packed attribute on certain +// structures where alignment is important, particularly data read/written +// to disk. +// + +#ifdef __GNUC__ +#define PACKEDATTR __attribute__((packed)) +#else +#define PACKEDATTR +#endif + +// +// Global parameters/defines. +// +// DOOM version +#define DOOM_VERSION 109 + +// Version code for cph's longtics hack ("v1.91") +#define DOOM_191_VERSION 111 + + +// Game mode handling - identify IWAD version +// to handle IWAD dependend animations etc. +typedef enum +{ + shareware, // DOOM 1 shareware, E1, M9 + registered, // DOOM 1 registered, E3, M27 + commercial, // DOOM 2 retail, E1 M34 + // DOOM 2 german edition not handled + retail, // DOOM 1 retail, E4, M36 + indetermined // Well, no IWAD found. + +} GameMode_t; + + +// Mission packs - might be useful for TC stuff? +typedef enum +{ + doom, // DOOM 1 + doom2, // DOOM 2 + pack_tnt, // TNT mission pack + pack_plut, // Plutonia pack + none + +} GameMission_t; + +// What version are we emulating? + +typedef enum +{ + exe_doom_1_9, // Doom 1.9: used for shareware, registered and commercial + exe_hacx, // Hacx executable (Doom 1.9 with patch applied) + exe_ultimate, // Ultimate Doom (retail) + exe_final, // Final Doom + exe_final2, // Final Doom (alternate exe) + exe_chex, // Chex Quest executable (based on Final Doom) +} GameVersion_t; + + +// If rangecheck is undefined, +// most parameter validation debugging code will not be compiled +#define RANGECHECK + + + +// Screen width and height. + +#define SCREENWIDTH 320 +#define SCREENHEIGHT 200 + +// Screen width used for "squash" scale functions + +#define SCREENWIDTH_4_3 256 + +// Screen height used for "stretch" scale functions. + +#define SCREENHEIGHT_4_3 240 + +// The maximum number of players, multiplayer/networking. +#define MAXPLAYERS 4 + +// State updates, number of tics / second. +#define TICRATE 35 + +// The current state of the game: whether we are +// playing, gazing at the intermission screen, +// the game final animation, or a demo. +typedef enum +{ + GS_LEVEL, + GS_INTERMISSION, + GS_FINALE, + GS_DEMOSCREEN, +} gamestate_t; + +// +// Difficulty/skill settings/filters. +// + +// Skill flags. +#define MTF_EASY 1 +#define MTF_NORMAL 2 +#define MTF_HARD 4 + +// Deaf monsters/do not react to sound. +#define MTF_AMBUSH 8 + +typedef enum +{ + sk_noitems = -1, // the "-skill 0" hack + sk_baby = 0, + sk_easy, + sk_medium, + sk_hard, + sk_nightmare +} skill_t; + + + + +// +// Key cards. +// +typedef enum +{ + it_bluecard, + it_yellowcard, + it_redcard, + it_blueskull, + it_yellowskull, + it_redskull, + + NUMCARDS + +} card_t; + + + +// The defined weapons, +// including a marker indicating +// user has not changed weapon. +typedef enum +{ + wp_fist, + wp_pistol, + wp_shotgun, + wp_chaingun, + wp_missile, + wp_plasma, + wp_bfg, + wp_chainsaw, + wp_supershotgun, + + NUMWEAPONS, + + // No pending weapon change. + wp_nochange + +} weapontype_t; + + +// Ammunition types defined. +typedef enum +{ + am_clip, // Pistol / chaingun ammo. + am_shell, // Shotgun / double barreled shotgun. + am_cell, // Plasma rifle, BFG. + am_misl, // Missile launcher. + NUMAMMO, + am_noammo // Unlimited for chainsaw / fist. + +} ammotype_t; + + +// Power up artifacts. +typedef enum +{ + pw_invulnerability, + pw_strength, + pw_invisibility, + pw_ironfeet, + pw_allmap, + pw_infrared, + NUMPOWERS + +} powertype_t; + + + +// +// Power up durations, +// how many seconds till expiration, +// assuming TICRATE is 35 ticks/second. +// +typedef enum +{ + INVULNTICS = (30*TICRATE), + INVISTICS = (60*TICRATE), + INFRATICS = (120*TICRATE), + IRONTICS = (60*TICRATE) + +} powerduration_t; + + +#endif // __DOOMDEF__ diff --git a/Source/Plugins/vpo_dll/doomtype.h b/Source/Plugins/vpo_dll/doomtype.h index 917f246c..0a5b5e38 100644 --- a/Source/Plugins/vpo_dll/doomtype.h +++ b/Source/Plugins/vpo_dll/doomtype.h @@ -1,84 +1,84 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Simple basic typedefs, isolated here to make it easier -// separating modules. -// -//----------------------------------------------------------------------------- - - -#ifndef __DOOMTYPE__ -#define __DOOMTYPE__ - -// Windows CE is missing some vital ANSI C functions. We have to -// use our own replacements. - -#ifdef _WIN32_WCE -#include "libc_wince.h" -#endif - -// C99 integer types; with gcc we just use this. Other compilers -// should add conditional statements that define the C99 types. - -// What is really wanted here is stdint.h; however, some old versions -// of Solaris don't have stdint.h and only have inttypes.h (the -// pre-standardisation version). inttypes.h is also in the C99 -// standard and defined to include stdint.h, so include this. - -#include - -#ifdef __cplusplus - -// Use builtin bool type with C++. - -typedef bool boolean; - -#else - -typedef enum -{ - false, - true -} boolean; - -#endif - -typedef uint8_t byte; - -#include - -#ifdef _WIN32 - -#define DIR_SEPARATOR '\\' -#define PATH_SEPARATOR ';' - -#else - -#define DIR_SEPARATOR '/' -#define PATH_SEPARATOR ':' - -#endif - -#define arrlen(array) (sizeof(array) / sizeof(*array)) - -#endif - +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// Simple basic typedefs, isolated here to make it easier +// separating modules. +// +//----------------------------------------------------------------------------- + + +#ifndef __DOOMTYPE__ +#define __DOOMTYPE__ + +// Windows CE is missing some vital ANSI C functions. We have to +// use our own replacements. + +#ifdef _WIN32_WCE +#include "libc_wince.h" +#endif + +// C99 integer types; with gcc we just use this. Other compilers +// should add conditional statements that define the C99 types. + +// What is really wanted here is stdint.h; however, some old versions +// of Solaris don't have stdint.h and only have inttypes.h (the +// pre-standardisation version). inttypes.h is also in the C99 +// standard and defined to include stdint.h, so include this. + +#include + +#ifdef __cplusplus + +// Use builtin bool type with C++. + +typedef bool boolean; + +#else + +typedef enum +{ + false, + true +} boolean; + +#endif + +typedef uint8_t byte; + +#include + +#ifdef _WIN32 + +#define DIR_SEPARATOR '\\' +#define PATH_SEPARATOR ';' + +#else + +#define DIR_SEPARATOR '/' +#define PATH_SEPARATOR ':' + +#endif + +#define arrlen(array) (sizeof(array) / sizeof(*array)) + +#endif + diff --git a/Source/Plugins/vpo_dll/m_bbox.cc b/Source/Plugins/vpo_dll/m_bbox.cc index 2bb7d6a6..348f34a3 100644 --- a/Source/Plugins/vpo_dll/m_bbox.cc +++ b/Source/Plugins/vpo_dll/m_bbox.cc @@ -1,61 +1,61 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Main loop menu stuff. -// Random number LUT. -// Default Config File. -// PCX Screenshots. -// -//----------------------------------------------------------------------------- - -#include "vpo_local.h" - -namespace vpo -{ - - -void M_ClearBox (fixed_t *box) -{ - box[BOXTOP] = box[BOXRIGHT] = INT_MIN; - box[BOXBOTTOM] = box[BOXLEFT] = INT_MAX; -} - -void -M_AddToBox -( fixed_t* box, - fixed_t x, - fixed_t y ) -{ - if (xbox[BOXRIGHT]) - box[BOXRIGHT] = x; - if (ybox[BOXTOP]) - box[BOXTOP] = y; -} - - - -} // namespace vpo - +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// Main loop menu stuff. +// Random number LUT. +// Default Config File. +// PCX Screenshots. +// +//----------------------------------------------------------------------------- + +#include "vpo_local.h" + +namespace vpo +{ + + +void M_ClearBox (fixed_t *box) +{ + box[BOXTOP] = box[BOXRIGHT] = INT_MIN; + box[BOXBOTTOM] = box[BOXLEFT] = INT_MAX; +} + +void +M_AddToBox +( fixed_t* box, + fixed_t x, + fixed_t y ) +{ + if (xbox[BOXRIGHT]) + box[BOXRIGHT] = x; + if (ybox[BOXTOP]) + box[BOXTOP] = y; +} + + + +} // namespace vpo + diff --git a/Source/Plugins/vpo_dll/m_bbox.h b/Source/Plugins/vpo_dll/m_bbox.h index 1fb79fd6..3788044b 100644 --- a/Source/Plugins/vpo_dll/m_bbox.h +++ b/Source/Plugins/vpo_dll/m_bbox.h @@ -1,55 +1,55 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Nil. -// -//----------------------------------------------------------------------------- - - -#ifndef __M_BBOX__ -#define __M_BBOX__ - -#include - -#include "m_fixed.h" - - -// Bounding box coordinate storage. -enum -{ - BOXTOP, - BOXBOTTOM, - BOXLEFT, - BOXRIGHT -}; // bbox coordinates - -// Bounding box functions. -void M_ClearBox (fixed_t* box); - -void -M_AddToBox -( fixed_t* box, - fixed_t x, - fixed_t y ); - - -#endif +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// Nil. +// +//----------------------------------------------------------------------------- + + +#ifndef __M_BBOX__ +#define __M_BBOX__ + +#include + +#include "m_fixed.h" + + +// Bounding box coordinate storage. +enum +{ + BOXTOP, + BOXBOTTOM, + BOXLEFT, + BOXRIGHT +}; // bbox coordinates + +// Bounding box functions. +void M_ClearBox (fixed_t* box); + +void +M_AddToBox +( fixed_t* box, + fixed_t x, + fixed_t y ); + + +#endif diff --git a/Source/Plugins/vpo_dll/m_fixed.cc b/Source/Plugins/vpo_dll/m_fixed.cc index a3d3a3c9..e11bee67 100644 --- a/Source/Plugins/vpo_dll/m_fixed.cc +++ b/Source/Plugins/vpo_dll/m_fixed.cc @@ -1,66 +1,66 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Fixed point implementation. -// -//----------------------------------------------------------------------------- - -#include "vpo_local.h" - -namespace vpo -{ - -// Fixme. __USE_C_FIXED__ or something. - -fixed_t -FixedMul -( fixed_t a, - fixed_t b ) -{ - return ((int64_t) a * (int64_t) b) >> FRACBITS; -} - - - -// -// FixedDiv, C version. -// - -fixed_t FixedDiv(fixed_t a, fixed_t b) -{ - if ((abs(a) >> 14) >= abs(b)) - { - return (a^b) < 0 ? INT_MIN : INT_MAX; - } - else - { - int64_t result; - - result = ((int64_t) a << 16) / b; - - return (fixed_t) result; - } -} - - -} // namespace vpo - +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// Fixed point implementation. +// +//----------------------------------------------------------------------------- + +#include "vpo_local.h" + +namespace vpo +{ + +// Fixme. __USE_C_FIXED__ or something. + +fixed_t +FixedMul +( fixed_t a, + fixed_t b ) +{ + return ((int64_t) a * (int64_t) b) >> FRACBITS; +} + + + +// +// FixedDiv, C version. +// + +fixed_t FixedDiv(fixed_t a, fixed_t b) +{ + if ((abs(a) >> 14) >= abs(b)) + { + return (a^b) < 0 ? INT_MIN : INT_MAX; + } + else + { + int64_t result; + + result = ((int64_t) a << 16) / b; + + return (fixed_t) result; + } +} + + +} // namespace vpo + diff --git a/Source/Plugins/vpo_dll/m_fixed.h b/Source/Plugins/vpo_dll/m_fixed.h index 2a1fa200..f76b9763 100644 --- a/Source/Plugins/vpo_dll/m_fixed.h +++ b/Source/Plugins/vpo_dll/m_fixed.h @@ -1,42 +1,42 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Fixed point arithemtics, implementation. -// -//----------------------------------------------------------------------------- - - -#ifndef __M_FIXED__ -#define __M_FIXED__ - -// -// Fixed point, 32bit as 16.16. -// -#define FRACBITS 16 -#define FRACUNIT (1<x = SHORT(ml->x)<y = SHORT(ml->y)<v1 = &vertexes[SHORT(ml->v1)]; - li->v2 = &vertexes[SHORT(ml->v2)]; - - li->angle = (SHORT(ml->angle))<<16; - li->offset = (SHORT(ml->offset))<<16; - linedef = SHORT(ml->linedef); - ldef = &lines[linedef]; - li->linedef = ldef; - side = SHORT(ml->side); - li->sidedef = &sides[ldef->sidenum[side]]; - li->frontsector = sides[ldef->sidenum[side]].sector; - - if (ldef-> flags & ML_TWOSIDED) - { - sidenum = ldef->sidenum[side ^ 1]; - - // If the sidenum is out of range, this may be a "glass hack" - // impassible window. Point at side #0 (this may not be - // the correct Vanilla behavior; however, it seems to work for - // OTTAWAU.WAD, which is the one place I've seen this trick - // used). - - if (sidenum < 0 || sidenum >= numsides) - { - li->backsector = GetSectorAtNullAddress(); - } - else - { - li->backsector = sides[sidenum].sector; - } - } - else - { - li->backsector = 0; - } - } - - W_FreeLump(data); -} - - -// -// P_LoadSubsectors -// -void P_LoadSubsectors (int lump) -{ - byte* data; - int i; - mapsubsector_t* ms; - subsector_t* ss; - - numsubsectors = W_LumpLength (lump) / sizeof(mapsubsector_t); - subsectors = new subsector_t[numsubsectors]; - - data = W_LoadLump (lump); - - ms = (mapsubsector_t *)data; - memset (subsectors,0, numsubsectors*sizeof(subsector_t)); - ss = subsectors; - - for (i=0 ; inumlines = SHORT(ms->numsegs); - ss->firstline = SHORT(ms->firstseg); - } - - W_FreeLump(data); -} - - - -// -// P_LoadSectors -// -void P_LoadSectors (int lump) -{ - byte* data; - int i; - mapsector_t* ms; - sector_t* ss; - - numsectors = W_LumpLength (lump) / sizeof(mapsector_t); - sectors = new sector_t[numsectors]; - - memset (sectors, 0, numsectors*sizeof(sector_t)); - data = W_LoadLump (lump); - - ms = (mapsector_t *)data; - ss = sectors; - for (i=0 ; ifloorheight = SHORT(ms->floorheight)<ceilingheight = SHORT(ms->ceilingheight)<floorpic = R_FlatNumForName(ms->floorpic); - ss->ceilingpic = R_FlatNumForName(ms->ceilingpic); - ss->lightlevel = SHORT(ms->lightlevel); - ss->special = SHORT(ms->special); - ss->tag = SHORT(ms->tag); -/// ss->thinglist = NULL; - } - - W_FreeLump(data); -} - - -// -// P_LoadNodes -// -void P_LoadNodes (int lump) -{ - byte* data; - int i; - int j; - int k; - mapnode_t* mn; - node_t* no; - - numnodes = W_LumpLength (lump) / sizeof(mapnode_t); - nodes = new node_t[numnodes]; - - data = W_LoadLump (lump); - - mn = (mapnode_t *)data; - no = nodes; - - for (i=0 ; ix = SHORT(mn->x)<y = SHORT(mn->y)<dx = SHORT(mn->dx)<dy = SHORT(mn->dy)<children[j] = SHORT(mn->children[j]); - for (k=0 ; k<4 ; k++) - no->bbox[j][k] = SHORT(mn->bbox[j][k])<type)) - { - case 68: // Arachnotron - case 64: // Archvile - case 88: // Boss Brain - case 89: // Boss Shooter - case 69: // Hell Knight - case 67: // Mancubus - case 71: // Pain Elemental - case 65: // Former Human Commando - case 66: // Revenant - case 84: // Wolf SS - spawn = false; - break; - } - } - if (spawn == false) - break; - - // Do spawn all other stuff. - spawnthing.x = SHORT(mt->x); - spawnthing.y = SHORT(mt->y); - spawnthing.angle = SHORT(mt->angle); - spawnthing.type = SHORT(mt->type); - spawnthing.options = SHORT(mt->options); - - P_SpawnMapThing(&spawnthing); - } - - W_FreeLump(data); -#endif -} - - -// -// P_LoadLineDefs -// Also counts secret lines for intermissions. -// -void P_LoadLineDefs (int lump) -{ - byte* data; - int i; - maplinedef_t* mld; - line_t* ld; - vertex_t* v1; - vertex_t* v2; - - numlines = W_LumpLength (lump) / sizeof(maplinedef_t); - lines = new line_t[numlines]; - - memset (lines, 0, numlines*sizeof(line_t)); - data = W_LoadLump (lump); - - mld = (maplinedef_t *)data; - ld = lines; - for (i=0 ; iflags = SHORT(mld->flags); - ld->special = SHORT(mld->special); - ld->tag = SHORT(mld->tag); - v1 = ld->v1 = &vertexes[SHORT(mld->v1)]; - v2 = ld->v2 = &vertexes[SHORT(mld->v2)]; - ld->dx = v2->x - v1->x; - ld->dy = v2->y - v1->y; - - if (!ld->dx) - ld->slopetype = ST_VERTICAL; - else if (!ld->dy) - ld->slopetype = ST_HORIZONTAL; - else - { - if (FixedDiv (ld->dy , ld->dx) > 0) - ld->slopetype = ST_POSITIVE; - else - ld->slopetype = ST_NEGATIVE; - } - - if (v1->x < v2->x) - { - ld->bbox[BOXLEFT] = v1->x; - ld->bbox[BOXRIGHT] = v2->x; - } - else - { - ld->bbox[BOXLEFT] = v2->x; - ld->bbox[BOXRIGHT] = v1->x; - } - - if (v1->y < v2->y) - { - ld->bbox[BOXBOTTOM] = v1->y; - ld->bbox[BOXTOP] = v2->y; - } - else - { - ld->bbox[BOXBOTTOM] = v2->y; - ld->bbox[BOXTOP] = v1->y; - } - - ld->sidenum[0] = SHORT(mld->sidenum[0]); - ld->sidenum[1] = SHORT(mld->sidenum[1]); - - if (ld->sidenum[0] != -1) - ld->frontsector = sides[ld->sidenum[0]].sector; - else - ld->frontsector = 0; - - if (ld->sidenum[1] != -1) - ld->backsector = sides[ld->sidenum[1]].sector; - else - ld->backsector = 0; - } - - W_FreeLump(data); -} - - -// -// P_LoadSideDefs -// -void P_LoadSideDefs (int lump) -{ - byte* data; - int i; - mapsidedef_t* msd; - side_t* sd; - - numsides = W_LumpLength (lump) / sizeof(mapsidedef_t); - sides = new side_t[numsides]; - - memset (sides, 0, numsides*sizeof(side_t)); - data = W_LoadLump (lump); - - msd = (mapsidedef_t *)data; - sd = sides; - for (i=0 ; itextureoffset = SHORT(msd->textureoffset)<rowoffset = SHORT(msd->rowoffset)<toptexture = R_TextureNumForName(msd->toptexture); - sd->bottomtexture = R_TextureNumForName(msd->bottomtexture); - sd->midtexture = R_TextureNumForName(msd->midtexture); - sd->sector = §ors[SHORT(msd->sector)]; - } - - W_FreeLump(data); -} - - - -// -// P_GroupLines -// Builds sector line lists and subsector sector numbers. -// Finds block bounding boxes for sectors. -// -void P_GroupLines (void) -{ - line_t** linebuffer; - int i; - int j; - line_t* li; - sector_t* sector; - subsector_t* ss; - seg_t* seg; - fixed_t bbox[4]; - int totallines; - - // look up sector number for each subsector - ss = subsectors; - for (i=0 ; ifirstline]; - ss->sector = seg->sidedef->sector; - } - - // count number of lines in each sector - li = lines; - totallines = 0; - for (i=0 ; ifrontsector->linecount++; - - if (li->backsector && li->backsector != li->frontsector) - { - li->backsector->linecount++; - totallines++; - } - } - - // build line tables for each sector - linebuffer = new line_t* [totallines]; - - for (i=0; ifrontsector != NULL) - { - sector = li->frontsector; - - sector->lines[sector->linecount] = li; - ++sector->linecount; - } - - if (li->backsector != NULL && li->frontsector != li->backsector) - { - sector = li->backsector; - - sector->lines[sector->linecount] = li; - ++sector->linecount; - } - } - - // Generate bounding boxes for sectors - - sector = sectors; - for (i=0 ; ilinecount; j++) - { - li = sector->lines[j]; - - M_AddToBox (bbox, li->v1->x, li->v1->y); - M_AddToBox (bbox, li->v2->x, li->v2->y); - } - -//// // set the degenmobj_t to the middle of the bounding box -//// sector->soundorg.x = (bbox[BOXRIGHT]+bbox[BOXLEFT])/2; -//// sector->soundorg.y = (bbox[BOXTOP]+bbox[BOXBOTTOM])/2; - - } - -} - - -// -// P_SetupLevel -// -void P_SetupLevel ( const char *lumpname ) -{ - int lumpnum; - - lumpnum = W_GetNumForName (lumpname); - - // note: most of this ordering is important -/// P_LoadBlockMap (lumpnum+ML_BLOCKMAP); - P_LoadVertexes (lumpnum+ML_VERTEXES); - P_LoadSectors (lumpnum+ML_SECTORS); - P_LoadSideDefs (lumpnum+ML_SIDEDEFS); - - P_LoadLineDefs (lumpnum+ML_LINEDEFS); - P_LoadSubsectors (lumpnum+ML_SSECTORS); - P_LoadNodes (lumpnum+ML_NODES); - P_LoadSegs (lumpnum+ML_SEGS); - - P_GroupLines (); -/// P_LoadReject (lumpnum+ML_REJECT); - - P_LoadThings (lumpnum+ML_THINGS); -} - - -void P_FreeLevelData (void) -{ - if (vertexes) - { - delete[] vertexes; - vertexes = NULL; - numvertexes = 0; - } - - if (sectors) - { - delete[] sectors; - sectors = NULL; - numsectors = 0; - } - - if (sides) - { - delete[] sides; - sides = NULL; - numsides = 0; - } - - if (lines) - { - delete[] lines; - lines = NULL; - numlines = 0; - } - - if (segs) - { - delete[] segs; - segs = NULL; - numsegs = 0; - } - - if (subsectors) - { - delete[] subsectors; - subsectors = NULL; - numsubsectors = 0; - } - - if (nodes) - { - delete[] nodes; - nodes = NULL; - numnodes = 0; - } -} - - -} // namespace vpo - +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// Copyright(C) 2014 Andrew Apted +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// Do all the WAD I/O, get map description, +// set up initial state and misc. LUTs. +// +//----------------------------------------------------------------------------- + +#include "vpo_local.h" + +namespace vpo +{ + + +// the error message returned from P_SetupLevel() +static char level_error_msg[1024]; + +// this exception is thrown during P_SetupLevel() when a map with bad data +// is detected (e.g. vertex number out of range). The above message buffer +// should contain the error message. [added by andrewj] +class invalid_data_exception { }; + + +static bool level_is_hexen; + + +// +// MAP related Lookup tables. +// Store VERTEXES, LINEDEFS, SIDEDEFS, etc. +// +vertex_t* vertexes; +int numvertexes; + +seg_t* segs; +int numsegs; + +sector_t* sectors; +int numsectors; + +subsector_t* subsectors; +int numsubsectors; + +node_t* nodes; +int numnodes; + +line_t* lines; +int numlines; + +side_t* sides; +int numsides; + + +fixed_t Map_bbox[4]; + + +static int R_TextureNumForName (const char * name) +{ + // "NoTexture" marker. + if (name[0] == '-') + return 0; + + return 1; // dummy value +} + +static int R_FlatNumForName (const char * name) +{ + // SKY ? + if (name[0] == 'F' && name[1] == '_' && name[2] == 'S' && name[3] == 'K') + return skyflatnum; + + return 1; // dummy value +} + + +static void LevelError(const char *msg, ...) +{ + va_list argptr; + + va_start(argptr, msg); + memset(level_error_msg, 0, sizeof(level_error_msg)); + vsnprintf(level_error_msg, sizeof(level_error_msg) - 1, msg, argptr); + va_end(argptr); + + throw invalid_data_exception(); +} + + +// +// P_LoadVertexes +// +void P_LoadVertexes (int lump) +{ + byte* data; + int i; + mapvertex_t* ml; + vertex_t* li; + + // Determine number of lumps: + // total lump length / vertex record length. + numvertexes = W_LumpLength (lump) / sizeof(mapvertex_t); + + // Allocate zone memory for buffer. + vertexes = new vertex_t[numvertexes]; + + // Load data into cache. + data = W_LoadLump (lump); + + ml = (mapvertex_t *)data; + li = vertexes; + + // Copy and convert vertex coordinates, + // internal representation as fixed. + for (i=0 ; i < numvertexes ; i++, li++, ml++) + { + li->x = SHORT(ml->x)<y = SHORT(ml->y)<v1); + int v2_idx = SHORT(ml->v2); + + if (v1_idx < 0 || v1_idx >= numvertexes || + v2_idx < 0 || v2_idx >= numvertexes) + { + LevelError("Bad map data : vertex out of range (seg #%d)", i); + } + + li->v1 = &vertexes[v1_idx]; + li->v2 = &vertexes[v2_idx]; + + int line_idx = SHORT(ml->linedef); + + if (line_idx < 0 || line_idx >= numlines) + { + LevelError("Bad map data : linedef out of range (seg #%d)", i); + } + + li->angle = (SHORT(ml->angle))<<16; + li->offset = (SHORT(ml->offset))<<16; + + ldef = &lines[line_idx]; + li->linedef = ldef; + + side = SHORT(ml->side); + li->sidedef = &sides[ldef->sidenum[side]]; + li->frontsector = sides[ldef->sidenum[side]].sector; + + if (ldef-> flags & ML_TWOSIDED) + { + sidenum = ldef->sidenum[side ^ 1]; + + // If the sidenum is out of range, this may be a "glass hack" + // impassible window. Point at side #0 (this may not be + // the correct Vanilla behavior; however, it seems to work for + // OTTAWAU.WAD, which is the one place I've seen this trick + // used). + + if (sidenum < 0 || sidenum >= numsides) + { + li->backsector = GetSectorAtNullAddress(); + } + else + { + li->backsector = sides[sidenum].sector; + } + } + else + { + li->backsector = NULL; + } + } + + W_FreeLump(data); +} + + +// +// P_LoadSubsectors +// +void P_LoadSubsectors (int lump) +{ + byte* data; + int i; + mapsubsector_t* ms; + subsector_t* ss; + + numsubsectors = W_LumpLength (lump) / sizeof(mapsubsector_t); + subsectors = new subsector_t[numsubsectors]; + + data = W_LoadLump (lump); + + ms = (mapsubsector_t *)data; + memset (subsectors,0, numsubsectors*sizeof(subsector_t)); + ss = subsectors; + + for (i=0 ; i < numsubsectors ; i++, ss++, ms++) + { + ss->numlines = SHORT(ms->numsegs); + ss->firstline = SHORT(ms->firstseg); + } + + W_FreeLump(data); +} + + +// andrewj: added this +static void ValidateSubsectors () +{ + int i; + subsector_t * ss = subsectors; + + for (i=0 ; i < numsubsectors ; i++, ss++) + { + if (ss->firstline < 0 || ss->numlines < 0 || + ss->firstline + ss->numlines > numsegs) + { + LevelError("Bad map data : invalid seg range in subsector #%d\n", i); + } + } +} + + +// +// P_LoadSectors +// +void P_LoadSectors (int lump) +{ + byte* data; + int i; + mapsector_t* ms; + sector_t* ss; + + numsectors = W_LumpLength (lump) / sizeof(mapsector_t); + sectors = new sector_t[numsectors]; + + memset (sectors, 0, numsectors*sizeof(sector_t)); + data = W_LoadLump (lump); + + ms = (mapsector_t *)data; + ss = sectors; + + for (i=0 ; i < numsectors ; i++, ss++, ms++) + { + ss->floorheight = SHORT(ms->floorheight)<ceilingheight = SHORT(ms->ceilingheight)<floorpic = R_FlatNumForName(ms->floorpic); + ss->ceilingpic = R_FlatNumForName(ms->ceilingpic); + ss->lightlevel = SHORT(ms->lightlevel); + ss->special = SHORT(ms->special); + ss->tag = SHORT(ms->tag); + /// ss->thinglist = NULL; + } + + W_FreeLump(data); +} + + +static bool isChildValid(unsigned short child) +{ + if (child & NF_SUBSECTOR) + return ((child & ~NF_SUBSECTOR) < numsubsectors); + else + return (child < numnodes); +} + + +// +// P_LoadNodes +// +void P_LoadNodes (int lump) +{ + byte* data; + int i; + int j; + int k; + mapnode_t* mn; + node_t* no; + + numnodes = W_LumpLength (lump) / sizeof(mapnode_t); + nodes = new node_t[numnodes]; + + data = W_LoadLump (lump); + + mn = (mapnode_t *)data; + no = nodes; + + for (i=0 ; i < numnodes ; i++, no++, mn++) + { + no->x = SHORT(mn->x)<y = SHORT(mn->y)<dx = SHORT(mn->dx)<dy = SHORT(mn->dy)<children[j]); + + if (! isChildValid(child)) + LevelError("Bad map data : invalid child in node #%d", i); + + no->children[j] = child; + + for (k=0 ; k < 4 ; k++) + no->bbox[j][k] = SHORT(mn->bbox[j][k])<v1; + vertex_t *v2 = ld->v2; + + ld->dx = v2->x - v1->x; + ld->dy = v2->y - v1->y; + + if (!ld->dx) + ld->slopetype = ST_VERTICAL; + else if (!ld->dy) + ld->slopetype = ST_HORIZONTAL; + else + { + if (FixedDiv (ld->dy , ld->dx) > 0) + ld->slopetype = ST_POSITIVE; + else + ld->slopetype = ST_NEGATIVE; + } + + if (v1->x < v2->x) + { + ld->bbox[BOXLEFT] = v1->x; + ld->bbox[BOXRIGHT] = v2->x; + } + else + { + ld->bbox[BOXLEFT] = v2->x; + ld->bbox[BOXRIGHT] = v1->x; + } + + if (v1->y < v2->y) + { + ld->bbox[BOXBOTTOM] = v1->y; + ld->bbox[BOXTOP] = v2->y; + } + else + { + ld->bbox[BOXBOTTOM] = v2->y; + ld->bbox[BOXTOP] = v1->y; + } + + // andrewj: be tolerant of bad sidedef numbers + if (ld->sidenum[0] < 0 || ld->sidenum[0] >= numsides) + { + if (numsides == 0) + LevelError("Bad map data : no sidedefs!"); + + ld->sidenum[0] = 0; + } + + if (ld->sidenum[1] < -1 || ld->sidenum[1] >= numsides) + ld->sidenum[1] = -1; + + + if (ld->sidenum[0] != -1) + ld->frontsector = sides[ld->sidenum[0]].sector; + else + ld->frontsector = NULL; + + if (ld->sidenum[1] != -1) + ld->backsector = sides[ld->sidenum[1]].sector; + else + ld->backsector = NULL; +} + + +// +// P_LoadLineDefs +// Also counts secret lines for intermissions. +// +void P_LoadLineDefs (int lump) +{ + byte* data; + int i; + maplinedef_t* mld; + line_t* ld; + + numlines = W_LumpLength (lump) / sizeof(maplinedef_t); + lines = new line_t[numlines]; + + memset (lines, 0, numlines*sizeof(line_t)); + data = W_LoadLump (lump); + + mld = (maplinedef_t *)data; + ld = lines; + + for (i=0 ; i < numlines ; i++, mld++, ld++) + { + int v1_idx = SHORT(mld->v1); + int v2_idx = SHORT(mld->v2); + + if (v1_idx < 0 || v1_idx >= numvertexes || + v2_idx < 0 || v2_idx >= numvertexes) + { + LevelError("Bad map data : vertex out of range (line #%d)", i); + } + + ld->v1 = &vertexes[v1_idx]; + ld->v2 = &vertexes[v2_idx]; + + ld->flags = SHORT(mld->flags); + ld->special = SHORT(mld->special); + ld->tag = SHORT(mld->tag); + ld->sidenum[0] = SHORT(mld->sidenum[0]); + ld->sidenum[1] = SHORT(mld->sidenum[1]); + + LineDef_CommonSetup(ld); + } + + W_FreeLump(data); +} + + +// andrewj: added this for Hexen support +void P_LoadLineDefs_Hexen (int lump) +{ + byte* data; + int i, k; + maplinedef_hexen_t* mld; + line_t* ld; + + numlines = W_LumpLength (lump) / sizeof(maplinedef_hexen_t); + lines = new line_t[numlines]; + + memset (lines, 0, numlines*sizeof(line_t)); + data = W_LoadLump (lump); + + mld = (maplinedef_hexen_t *)data; + ld = lines; + + for (i=0 ; i < numlines ; i++, mld++, ld++) + { + int v1_idx = SHORT(mld->v1); + int v2_idx = SHORT(mld->v2); + + if (v1_idx < 0 || v1_idx >= numvertexes || + v2_idx < 0 || v2_idx >= numvertexes) + { + LevelError("Bad map data : vertex out of range (line #%d)", i); + } + + ld->v1 = &vertexes[v1_idx]; + ld->v2 = &vertexes[v2_idx]; + + ld->flags = SHORT(mld->flags); + ld->special = mld->special; + ld->tag = 0; + ld->sidenum[0] = SHORT(mld->sidenum[0]); + ld->sidenum[1] = SHORT(mld->sidenum[1]); + + for (k = 0 ; k < 5 ; k++) + ld->args[k] = mld->args[k]; + + LineDef_CommonSetup(ld); + } + + W_FreeLump(data); +} + + +// +// P_LoadSideDefs +// +void P_LoadSideDefs (int lump) +{ + byte* data; + int i; + mapsidedef_t* msd; + side_t* sd; + + numsides = W_LumpLength (lump) / sizeof(mapsidedef_t); + sides = new side_t[numsides]; + + memset (sides, 0, numsides*sizeof(side_t)); + data = W_LoadLump (lump); + + msd = (mapsidedef_t *)data; + sd = sides; + + for (i=0 ; i < numsides ; i++, msd++, sd++) + { + int sec_idx = SHORT(msd->sector); + + // andrewj : silently fix a bad sector number + if (sec_idx < 0 || sec_idx >= numsectors) + { + if (numsectors == 0) + LevelError("Bad map data : no sectors!"); + + sec_idx = 0; + } + + sd->textureoffset = SHORT(msd->textureoffset)<rowoffset = SHORT(msd->rowoffset)<toptexture = R_TextureNumForName(msd->toptexture); + sd->bottomtexture = R_TextureNumForName(msd->bottomtexture); + sd->midtexture = R_TextureNumForName(msd->midtexture); + sd->sector = §ors[sec_idx]; + } + + W_FreeLump(data); +} + + + +// +// P_GroupLines +// Builds sector line lists and subsector sector numbers. +// Finds block bounding boxes for sectors. +// +void P_GroupLines (void) +{ + line_t** linebuffer; + int i; + int j; + line_t* li; + sector_t* sector; + subsector_t* ss; + seg_t* seg; + fixed_t bbox[4]; + int totallines; + + // look up sector number for each subsector + ss = subsectors; + for (i=0 ; i < numsubsectors ; i++, ss++) + { + seg = &segs[ss->firstline]; + ss->sector = seg->sidedef->sector; + } + + // count number of lines in each sector + li = lines; + totallines = 0; + for (i=0 ; i < numlines ; i++, li++) + { + totallines++; + li->frontsector->linecount++; + + if (li->backsector && li->backsector != li->frontsector) + { + li->backsector->linecount++; + totallines++; + } + } + + // build line tables for each sector + linebuffer = new line_t* [totallines]; + + for (i=0; i < numsectors; ++i) + { + // Assign the line buffer for this sector + + sectors[i].lines = linebuffer; + linebuffer += sectors[i].linecount; + + // Reset linecount to zero so in the next stage we can count + // lines into the list. + + sectors[i].linecount = 0; + } + + // Assign lines to sectors + + for (i=0; i < numlines; ++i) + { + li = &lines[i]; + + if (li->frontsector != NULL) + { + sector = li->frontsector; + + sector->lines[sector->linecount] = li; + ++sector->linecount; + } + + if (li->backsector != NULL && li->frontsector != li->backsector) + { + sector = li->backsector; + + sector->lines[sector->linecount] = li; + ++sector->linecount; + } + } + + // Generate bounding boxes for sectors + + sector = sectors; + for (i=0 ; i < numsectors ; i++, sector++) + { + M_ClearBox (bbox); + + for (j=0 ; j < sector->linecount; j++) + { + li = sector->lines[j]; + + M_AddToBox (bbox, li->v1->x, li->v1->y); + M_AddToBox (bbox, li->v2->x, li->v2->y); + } + } + + // andrewj : generate bounding box for level + + M_ClearBox (Map_bbox); + + for (i=0; i < numlines; ++i) + { + li = &lines[i]; + + M_AddToBox (Map_bbox, li->v1->x, li->v1->y); + M_AddToBox (Map_bbox, li->v2->x, li->v2->y); + } +} + + +// +// andrewj: added this +// +// Find sectors which seem to be doors. +// Main criterion is that sector is closed, and either has a tag +// or one of the linedefs has a manual door type. +// +static int HasManualDoor(const sector_t *sec) +{ + int k; + + for (k = 0 ; k < sec->linecount ; k++) + { + const line_t *L = sec->lines[k]; + + if (level_is_hexen) + { + switch (L->special) + { + case 10: case 11: case 12: case 13: + case 202: /* zdoom's Generic_Door */ + { + if (L->args[0] == 0) + return +1; + } + default: break; + } + } + else + { + switch (L->special) + { + case 1: case 26: case 27: case 28: + case 31: case 32: case 33: case 34: + case 117: case 118: + return +1; + + default: break; + } + } + } + + return 0; +} + +static void CalcDoorAltHeight(sector_t *sec) +{ + fixed_t door_h = sec->floorheight; // == sec->ceilingheight + + // compute lowest ceiling and highest floor of neighbor sectors + fixed_t low_ceil = 32767 << FRACBITS; + fixed_t high_floor = -32767 << FRACBITS; + + int k, pass; + + for (k = 0 ; k < sec->linecount ; k++) + { + const line_t *L = sec->lines[k]; + + for (pass = 0 ; pass < 2 ; pass++) + { + const sector_t *nb = pass ? L->backsector : L->frontsector; + + if (nb && nb != sec) + { + if (low_ceil > nb->ceilingheight) + low_ceil = nb->ceilingheight; + + if (high_floor < nb->floorheight) + high_floor = nb->floorheight; + } + } + } + + // see if this is actually a lowering floor + // (like used on MAP12 of DOOM 2) + + fixed_t mid_h = (low_ceil >> 1) + (high_floor >> 1); + + if (door_h > mid_h) + { + sec->is_door = -1; + sec->alt_height = high_floor; + } + else + { + // is_door already set to +1 + sec->alt_height = low_ceil - (4 * FRACUNIT); + } +} + +void P_DetectDoorSectors(void) +{ + int i; + + for (i = 0 ; i < numsectors ; i++) + { + sector_t *sec = §ors[i]; + + if (sec->floorheight != sec->ceilingheight) + continue; + + if (sec->tag || HasManualDoor(sec)) + { + sec->is_door = +1; + + CalcDoorAltHeight(sec); + } + } +} + + +// +// P_SetupLevel +// +// Returns an error message if something went wrong +// or NULL on success. +// +const char * P_SetupLevel ( const char *lumpname, bool *is_hexen ) +{ + int base = W_CheckNumForName(lumpname); + + if (base < 0 || ! lumpinfo[base].is_map_header) + { + sprintf(level_error_msg, "No such map in wad: %s", lumpname); + return level_error_msg; + } + + level_is_hexen = lumpinfo[base].is_hexen; + + if (is_hexen) + *is_hexen = level_is_hexen; + + // check that we have some nodes + if (lumpinfo[base + ML_SEGS].size == 0) + { + sprintf(level_error_msg, "Missing nodes for: %s", lumpname); + return level_error_msg; + } + + W_BeginRead(); + + try + { + // note: most of this ordering is important + /// P_LoadBlockMap (base + ML_BLOCKMAP); + P_LoadVertexes (base + ML_VERTEXES); + P_LoadSectors (base + ML_SECTORS); + P_LoadSideDefs (base + ML_SIDEDEFS); + + if (level_is_hexen) + P_LoadLineDefs_Hexen (base + ML_LINEDEFS); + else + P_LoadLineDefs (base + ML_LINEDEFS); + + P_LoadSubsectors (base + ML_SSECTORS); + P_LoadNodes (base + ML_NODES); + P_LoadSegs (base + ML_SEGS); + + ValidateSubsectors(); + } + catch (invalid_data_exception) + { + W_EndRead(); + P_FreeLevelData(); + + return level_error_msg; + } + + W_EndRead(); + + P_GroupLines (); + + // andrewj: added this + P_DetectDoorSectors(); + + return NULL; +} + + +void P_FreeLevelData (void) +{ + if (vertexes) + { + delete[] vertexes; + vertexes = NULL; + numvertexes = 0; + } + + if (sectors) + { + delete[] sectors; + sectors = NULL; + numsectors = 0; + } + + if (sides) + { + delete[] sides; + sides = NULL; + numsides = 0; + } + + if (lines) + { + delete[] lines; + lines = NULL; + numlines = 0; + } + + if (segs) + { + delete[] segs; + segs = NULL; + numsegs = 0; + } + + if (subsectors) + { + delete[] subsectors; + subsectors = NULL; + numsubsectors = 0; + } + + if (nodes) + { + delete[] nodes; + nodes = NULL; + numnodes = 0; + } +} + + +} // namespace vpo + +//--- editor settings --- +// vi:ts=4:sw=4:noexpandtab +// Emacs style mode select -*- C++ -*- diff --git a/Source/Plugins/vpo_dll/r_bsp.cc b/Source/Plugins/vpo_dll/r_bsp.cc index a94926f9..920fed7f 100644 --- a/Source/Plugins/vpo_dll/r_bsp.cc +++ b/Source/Plugins/vpo_dll/r_bsp.cc @@ -1,577 +1,577 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// BSP traversal, handling of LineSegs for rendering. -// -//----------------------------------------------------------------------------- - -#include "vpo_local.h" - -namespace vpo -{ - - -seg_t* curline; -side_t* sidedef; -line_t* linedef; -sector_t* frontsector; -sector_t* backsector; - -drawseg_t drawsegs[MAXDRAWSEGS+10]; -drawseg_t* ds_p; - -int total_drawsegs; - - -void R_StoreWallRange ( int start, int stop ); - - -// -// R_ClearDrawSegs -// -void R_ClearDrawSegs (void) -{ - total_drawsegs = 0; - - ds_p = drawsegs; -} - - - -// -// ClipWallSegment -// Clips the given range of columns -// and includes it in the new clip list. -// -typedef struct -{ - int first; - int last; - -} cliprange_t; - - -// andrewj: increased limit to 128 for Visplane Explorer -// #define MAXSOLIDSEGS 32 -#define MAXSOLIDSEGS 128 - -// newend is one past the last valid seg -cliprange_t solidsegs[MAXSOLIDSEGS+8]; -cliprange_t* newend; - -int max_solidsegs; - - - -// -// R_ClipSolidWallSegment -// Does handle solid walls, -// e.g. single sided LineDefs (middle texture) -// that entirely block the view. -// -void -R_ClipSolidWallSegment ( int first, int last ) -{ - cliprange_t* next; - cliprange_t* start; - - // Find the first range that touches the range - // (adjacent pixels are touching). - start = solidsegs; - while (start->last < first-1) - start++; - - if (first < start->first) - { - if (last < start->first-1) - { - // Post is entirely visible (above start), - // so insert a new clippost. - R_StoreWallRange (first, last); - next = newend; - newend++; - - // andrewj: check for solidseg overflow - max_solidsegs = MAX(max_solidsegs, (newend - solidsegs)); - if (max_solidsegs >= MAXSOLIDSEGS) - throw overflow_exception(); - - while (next != start) - { - *next = *(next-1); - next--; - } - next->first = first; - next->last = last; - return; - } - - // There is a fragment above *start. - R_StoreWallRange (first, start->first - 1); - // Now adjust the clip size. - start->first = first; - } - - // Bottom contained in start? - if (last <= start->last) - return; - - next = start; - while (last >= (next+1)->first-1) - { - // There is a fragment between two posts. - R_StoreWallRange (next->last + 1, (next+1)->first - 1); - next++; - - if (last <= next->last) - { - // Bottom is contained in next. - // Adjust the clip size. - start->last = next->last; - goto crunch; - } - } - - // There is a fragment after *next. - R_StoreWallRange (next->last + 1, last); - // Adjust the clip size. - start->last = last; - - // Remove start+1 to next from the clip list, - // because start now covers their area. - crunch: - if (next == start) - { - // Post just extended past the bottom of one post. - return; - } - - - while (next++ != newend) - { - // Remove a post. - *++start = *next; - } - - newend = start+1; - - // andrewj: check for solidseg overflow - max_solidsegs = MAX(max_solidsegs, (newend - solidsegs)); - if (max_solidsegs >= MAXSOLIDSEGS) - throw overflow_exception(); -} - - - -// -// R_ClipPassWallSegment -// Clips the given range of columns, -// but does not includes it in the clip list. -// Does handle windows, -// e.g. LineDefs with upper and lower texture. -// -void R_ClipPassWallSegment ( int first, int last ) -{ - cliprange_t* start; - - // Find the first range that touches the range - // (adjacent pixels are touching). - start = solidsegs; - while (start->last < first-1) - start++; - - if (first < start->first) - { - if (last < start->first-1) - { - // Post is entirely visible (above start). - R_StoreWallRange (first, last); - return; - } - - // There is a fragment above *start. - R_StoreWallRange (first, start->first - 1); - } - - // Bottom contained in start? - if (last <= start->last) - return; - - while (last >= (start+1)->first-1) - { - // There is a fragment between two posts. - R_StoreWallRange (start->last + 1, (start+1)->first - 1); - start++; - - if (last <= start->last) - return; - } - - // There is a fragment after *next. - R_StoreWallRange (start->last + 1, last); -} - - - -// -// R_ClearClipSegs -// -void R_ClearClipSegs (void) -{ - solidsegs[0].first = -0x7fffffff; - solidsegs[0].last = -1; - solidsegs[1].first = viewwidth; - solidsegs[1].last = 0x7fffffff; - - newend = solidsegs+2; - max_solidsegs = 2; -} - -// -// R_AddLine -// Clips the given segment -// and adds any visible pieces to the line list. -// -void R_AddLine (seg_t* line) -{ - int x1; - int x2; - angle_t angle1; - angle_t angle2; - angle_t span; - angle_t tspan; - - curline = line; - - // OPTIMIZE: quickly reject orthogonal back sides. - angle1 = R_PointToAngle (line->v1->x, line->v1->y); - angle2 = R_PointToAngle (line->v2->x, line->v2->y); - - // Clip to view edges. - // OPTIMIZE: make constant out of 2*clipangle (FIELDOFVIEW). - span = angle1 - angle2; - - // Back side? I.e. backface culling? - if (span >= ANG180) - return; - - // Global angle needed by segcalc. - rw_angle1 = angle1; - angle1 -= viewangle; - angle2 -= viewangle; - - tspan = angle1 + clipangle; - if (tspan > 2*clipangle) - { - tspan -= 2*clipangle; - - // Totally off the left edge? - if (tspan >= span) - return; - - angle1 = clipangle; - } - tspan = clipangle - angle2; - if (tspan > 2*clipangle) - { - tspan -= 2*clipangle; - - // Totally off the left edge? - if (tspan >= span) - return; - angle2 = -clipangle; - } - - // The seg is in the view range, - // but not necessarily visible. - angle1 = (angle1+ANG90)>>ANGLETOFINESHIFT; - angle2 = (angle2+ANG90)>>ANGLETOFINESHIFT; - x1 = viewangletox[angle1]; - x2 = viewangletox[angle2]; - - // Does not cross a pixel? - if (x1 == x2) - return; - - backsector = line->backsector; - - // Single sided line? - if (!backsector) - goto clipsolid; - - // Closed door. - if (backsector->ceilingheight <= frontsector->floorheight - || backsector->floorheight >= frontsector->ceilingheight) - goto clipsolid; - - // Window. - if (backsector->ceilingheight != frontsector->ceilingheight - || backsector->floorheight != frontsector->floorheight) - goto clippass; - - // Reject empty lines used for triggers - // and special events. - // Identical floor and ceiling on both sides, - // identical light levels on both sides, - // and no middle texture. - if (backsector->ceilingpic == frontsector->ceilingpic - && backsector->floorpic == frontsector->floorpic - && backsector->lightlevel == frontsector->lightlevel - && curline->sidedef->midtexture == 0) - { - return; - } - - - clippass: - R_ClipPassWallSegment (x1, x2-1); - return; - - clipsolid: - R_ClipSolidWallSegment (x1, x2-1); -} - - -// -// R_CheckBBox -// Checks BSP node/subtree bounding box. -// Returns true -// if some part of the bbox might be visible. -// -int checkcoord[12][4] = -{ - {3,0,2,1}, - {3,0,2,0}, - {3,1,2,0}, - {0}, - {2,0,2,1}, - {0,0,0,0}, - {3,1,3,0}, - {0}, - {2,0,3,1}, - {2,1,3,1}, - {2,1,3,0} -}; - - -boolean R_CheckBBox (fixed_t* bspcoord) -{ - int boxx; - int boxy; - int boxpos; - - fixed_t x1; - fixed_t y1; - fixed_t x2; - fixed_t y2; - - angle_t angle1; - angle_t angle2; - angle_t span; - angle_t tspan; - - cliprange_t* start; - - int sx1; - int sx2; - - // Find the corners of the box - // that define the edges from current viewpoint. - if (viewx <= bspcoord[BOXLEFT]) - boxx = 0; - else if (viewx < bspcoord[BOXRIGHT]) - boxx = 1; - else - boxx = 2; - - if (viewy >= bspcoord[BOXTOP]) - boxy = 0; - else if (viewy > bspcoord[BOXBOTTOM]) - boxy = 1; - else - boxy = 2; - - boxpos = (boxy<<2)+boxx; - if (boxpos == 5) - return true; - - x1 = bspcoord[checkcoord[boxpos][0]]; - y1 = bspcoord[checkcoord[boxpos][1]]; - x2 = bspcoord[checkcoord[boxpos][2]]; - y2 = bspcoord[checkcoord[boxpos][3]]; - - // check clip list for an open space - angle1 = R_PointToAngle (x1, y1) - viewangle; - angle2 = R_PointToAngle (x2, y2) - viewangle; - - span = angle1 - angle2; - - // Sitting on a line? - if (span >= ANG180) - return true; - - tspan = angle1 + clipangle; - - if (tspan > 2*clipangle) - { - tspan -= 2*clipangle; - - // Totally off the left edge? - if (tspan >= span) - return false; - - angle1 = clipangle; - } - tspan = clipangle - angle2; - if (tspan > 2*clipangle) - { - tspan -= 2*clipangle; - - // Totally off the left edge? - if (tspan >= span) - return false; - - angle2 = -clipangle; - } - - - // Find the first clippost - // that touches the source post - // (adjacent pixels are touching). - angle1 = (angle1+ANG90)>>ANGLETOFINESHIFT; - angle2 = (angle2+ANG90)>>ANGLETOFINESHIFT; - sx1 = viewangletox[angle1]; - sx2 = viewangletox[angle2]; - - // Does not cross a pixel. - if (sx1 == sx2) - return false; - sx2--; - - start = solidsegs; - while (start->last < sx2) - start++; - - if (sx1 >= start->first - && sx2 <= start->last) - { - // The clippost contains the new span. - return false; - } - - return true; -} - - - -// -// R_Subsector -// Determine floor/ceiling planes. -// Add sprites of things in sector. -// Draw one or more line segments. -// -void R_Subsector (int num) -{ - int count; - seg_t* line; - subsector_t* sub; - -#ifdef RANGECHECK - if (num>=numsubsectors) - I_Error ("R_Subsector: ss %i with numss = %i", - num, - numsubsectors); -#endif - - sscount++; - sub = &subsectors[num]; - frontsector = sub->sector; - count = sub->numlines; - line = &segs[sub->firstline]; - - if (frontsector->floorheight < viewz) - { - floorplane = R_FindPlane (frontsector->floorheight, - frontsector->floorpic, - frontsector->lightlevel); - } - else - floorplane = NULL; - - if (frontsector->ceilingheight > viewz - || frontsector->ceilingpic == skyflatnum) - { - ceilingplane = R_FindPlane (frontsector->ceilingheight, - frontsector->ceilingpic, - frontsector->lightlevel); - } - else - ceilingplane = NULL; - -//// R_AddSprites (frontsector); - - while (count--) - { - R_AddLine (line); - line++; - } -} - - - - -// -// RenderBSPNode -// Renders all subsectors below a given node, -// traversing subtree recursively. -// Just call with BSP root. -void R_RenderBSPNode (int bspnum) -{ - node_t* bsp; - int side; - - // Found a subsector? - if (bspnum & NF_SUBSECTOR) - { - if (bspnum == -1) - R_Subsector (0); - else - R_Subsector (bspnum&(~NF_SUBSECTOR)); - return; - } - - bsp = &nodes[bspnum]; - - // Decide which side the view point is on. - side = R_PointOnSide (viewx, viewy, bsp); - - // Recursively divide front space. - R_RenderBSPNode (bsp->children[side]); - - // Possibly divide back space. - if (R_CheckBBox (bsp->bbox[side^1])) - R_RenderBSPNode (bsp->children[side^1]); -} - - -} // namespace vpo - +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// BSP traversal, handling of LineSegs for rendering. +// +//----------------------------------------------------------------------------- + +#include "vpo_local.h" + +namespace vpo +{ + + +seg_t* curline; +side_t* sidedef; +line_t* linedef; +sector_t* frontsector; +sector_t* backsector; + +drawseg_t drawsegs[MAXDRAWSEGS+10]; +drawseg_t* ds_p; + +int total_drawsegs; + + +void R_StoreWallRange ( int start, int stop ); + + +// +// R_ClearDrawSegs +// +void R_ClearDrawSegs (void) +{ + total_drawsegs = 0; + + ds_p = drawsegs; +} + + + +// +// ClipWallSegment +// Clips the given range of columns +// and includes it in the new clip list. +// +typedef struct +{ + int first; + int last; + +} cliprange_t; + + +// andrewj: increased limit to 128 for Visplane Explorer +// #define MAXSOLIDSEGS 32 +#define MAXSOLIDSEGS 128 + +// newend is one past the last valid seg +cliprange_t solidsegs[MAXSOLIDSEGS+8]; +cliprange_t* newend; + +int max_solidsegs; + + + +// +// R_ClipSolidWallSegment +// Does handle solid walls, +// e.g. single sided LineDefs (middle texture) +// that entirely block the view. +// +void +R_ClipSolidWallSegment ( int first, int last ) +{ + cliprange_t* next; + cliprange_t* start; + + // Find the first range that touches the range + // (adjacent pixels are touching). + start = solidsegs; + while (start->last < first-1) + start++; + + if (first < start->first) + { + if (last < start->first-1) + { + // Post is entirely visible (above start), + // so insert a new clippost. + R_StoreWallRange (first, last); + next = newend; + newend++; + + // andrewj: check for solidseg overflow + max_solidsegs = MAX(max_solidsegs, (newend - solidsegs)); + if (max_solidsegs >= MAXSOLIDSEGS) + throw overflow_exception(); + + while (next != start) + { + *next = *(next-1); + next--; + } + next->first = first; + next->last = last; + return; + } + + // There is a fragment above *start. + R_StoreWallRange (first, start->first - 1); + // Now adjust the clip size. + start->first = first; + } + + // Bottom contained in start? + if (last <= start->last) + return; + + next = start; + while (last >= (next+1)->first-1) + { + // There is a fragment between two posts. + R_StoreWallRange (next->last + 1, (next+1)->first - 1); + next++; + + if (last <= next->last) + { + // Bottom is contained in next. + // Adjust the clip size. + start->last = next->last; + goto crunch; + } + } + + // There is a fragment after *next. + R_StoreWallRange (next->last + 1, last); + // Adjust the clip size. + start->last = last; + + // Remove start+1 to next from the clip list, + // because start now covers their area. + crunch: + if (next == start) + { + // Post just extended past the bottom of one post. + return; + } + + + while (next++ != newend) + { + // Remove a post. + *++start = *next; + } + + newend = start+1; + + // andrewj: check for solidseg overflow + max_solidsegs = MAX(max_solidsegs, (newend - solidsegs)); + if (max_solidsegs >= MAXSOLIDSEGS) + throw overflow_exception(); +} + + + +// +// R_ClipPassWallSegment +// Clips the given range of columns, +// but does not includes it in the clip list. +// Does handle windows, +// e.g. LineDefs with upper and lower texture. +// +void R_ClipPassWallSegment ( int first, int last ) +{ + cliprange_t* start; + + // Find the first range that touches the range + // (adjacent pixels are touching). + start = solidsegs; + while (start->last < first-1) + start++; + + if (first < start->first) + { + if (last < start->first-1) + { + // Post is entirely visible (above start). + R_StoreWallRange (first, last); + return; + } + + // There is a fragment above *start. + R_StoreWallRange (first, start->first - 1); + } + + // Bottom contained in start? + if (last <= start->last) + return; + + while (last >= (start+1)->first-1) + { + // There is a fragment between two posts. + R_StoreWallRange (start->last + 1, (start+1)->first - 1); + start++; + + if (last <= start->last) + return; + } + + // There is a fragment after *next. + R_StoreWallRange (start->last + 1, last); +} + + + +// +// R_ClearClipSegs +// +void R_ClearClipSegs (void) +{ + solidsegs[0].first = -0x7fffffff; + solidsegs[0].last = -1; + solidsegs[1].first = viewwidth; + solidsegs[1].last = 0x7fffffff; + + newend = solidsegs+2; + max_solidsegs = 2; +} + +// +// R_AddLine +// Clips the given segment +// and adds any visible pieces to the line list. +// +void R_AddLine (seg_t* line) +{ + int x1; + int x2; + angle_t angle1; + angle_t angle2; + angle_t span; + angle_t tspan; + + curline = line; + + // OPTIMIZE: quickly reject orthogonal back sides. + angle1 = R_PointToAngle (line->v1->x, line->v1->y); + angle2 = R_PointToAngle (line->v2->x, line->v2->y); + + // Clip to view edges. + // OPTIMIZE: make constant out of 2*clipangle (FIELDOFVIEW). + span = angle1 - angle2; + + // Back side? I.e. backface culling? + if (span >= ANG180) + return; + + // Global angle needed by segcalc. + rw_angle1 = angle1; + angle1 -= viewangle; + angle2 -= viewangle; + + tspan = angle1 + clipangle; + if (tspan > 2*clipangle) + { + tspan -= 2*clipangle; + + // Totally off the left edge? + if (tspan >= span) + return; + + angle1 = clipangle; + } + tspan = clipangle - angle2; + if (tspan > 2*clipangle) + { + tspan -= 2*clipangle; + + // Totally off the left edge? + if (tspan >= span) + return; + angle2 = -clipangle; + } + + // The seg is in the view range, + // but not necessarily visible. + angle1 = (angle1+ANG90)>>ANGLETOFINESHIFT; + angle2 = (angle2+ANG90)>>ANGLETOFINESHIFT; + x1 = viewangletox[angle1]; + x2 = viewangletox[angle2]; + + // Does not cross a pixel? + if (x1 == x2) + return; + + backsector = line->backsector; + + // Single sided line? + if (!backsector) + goto clipsolid; + + // Closed door. + if (backsector->ceilingheight <= frontsector->floorheight + || backsector->floorheight >= frontsector->ceilingheight) + goto clipsolid; + + // Window. + if (backsector->ceilingheight != frontsector->ceilingheight + || backsector->floorheight != frontsector->floorheight) + goto clippass; + + // Reject empty lines used for triggers + // and special events. + // Identical floor and ceiling on both sides, + // identical light levels on both sides, + // and no middle texture. + if (backsector->ceilingpic == frontsector->ceilingpic + && backsector->floorpic == frontsector->floorpic + && backsector->lightlevel == frontsector->lightlevel + && curline->sidedef->midtexture == 0) + { + return; + } + + + clippass: + R_ClipPassWallSegment (x1, x2-1); + return; + + clipsolid: + R_ClipSolidWallSegment (x1, x2-1); +} + + +// +// R_CheckBBox +// Checks BSP node/subtree bounding box. +// Returns true +// if some part of the bbox might be visible. +// +int checkcoord[12][4] = +{ + {3,0,2,1}, + {3,0,2,0}, + {3,1,2,0}, + {0}, + {2,0,2,1}, + {0,0,0,0}, + {3,1,3,0}, + {0}, + {2,0,3,1}, + {2,1,3,1}, + {2,1,3,0} +}; + + +boolean R_CheckBBox (fixed_t* bspcoord) +{ + int boxx; + int boxy; + int boxpos; + + fixed_t x1; + fixed_t y1; + fixed_t x2; + fixed_t y2; + + angle_t angle1; + angle_t angle2; + angle_t span; + angle_t tspan; + + cliprange_t* start; + + int sx1; + int sx2; + + // Find the corners of the box + // that define the edges from current viewpoint. + if (viewx <= bspcoord[BOXLEFT]) + boxx = 0; + else if (viewx < bspcoord[BOXRIGHT]) + boxx = 1; + else + boxx = 2; + + if (viewy >= bspcoord[BOXTOP]) + boxy = 0; + else if (viewy > bspcoord[BOXBOTTOM]) + boxy = 1; + else + boxy = 2; + + boxpos = (boxy<<2)+boxx; + if (boxpos == 5) + return true; + + x1 = bspcoord[checkcoord[boxpos][0]]; + y1 = bspcoord[checkcoord[boxpos][1]]; + x2 = bspcoord[checkcoord[boxpos][2]]; + y2 = bspcoord[checkcoord[boxpos][3]]; + + // check clip list for an open space + angle1 = R_PointToAngle (x1, y1) - viewangle; + angle2 = R_PointToAngle (x2, y2) - viewangle; + + span = angle1 - angle2; + + // Sitting on a line? + if (span >= ANG180) + return true; + + tspan = angle1 + clipangle; + + if (tspan > 2*clipangle) + { + tspan -= 2*clipangle; + + // Totally off the left edge? + if (tspan >= span) + return false; + + angle1 = clipangle; + } + tspan = clipangle - angle2; + if (tspan > 2*clipangle) + { + tspan -= 2*clipangle; + + // Totally off the left edge? + if (tspan >= span) + return false; + + angle2 = -clipangle; + } + + + // Find the first clippost + // that touches the source post + // (adjacent pixels are touching). + angle1 = (angle1+ANG90)>>ANGLETOFINESHIFT; + angle2 = (angle2+ANG90)>>ANGLETOFINESHIFT; + sx1 = viewangletox[angle1]; + sx2 = viewangletox[angle2]; + + // Does not cross a pixel. + if (sx1 == sx2) + return false; + sx2--; + + start = solidsegs; + while (start->last < sx2) + start++; + + if (sx1 >= start->first + && sx2 <= start->last) + { + // The clippost contains the new span. + return false; + } + + return true; +} + + + +// +// R_Subsector +// Determine floor/ceiling planes. +// Add sprites of things in sector. +// Draw one or more line segments. +// +void R_Subsector (int num) +{ + int count; + seg_t* line; + subsector_t* sub; + +#ifdef RANGECHECK + if (num>=numsubsectors) + I_Error ("R_Subsector: ss %i with numss = %i", + num, + numsubsectors); +#endif + + sscount++; + sub = &subsectors[num]; + frontsector = sub->sector; + count = sub->numlines; + line = &segs[sub->firstline]; + + if (frontsector->floorheight < viewz) + { + floorplane = R_FindPlane (frontsector->floorheight, + frontsector->floorpic, + frontsector->lightlevel); + } + else + floorplane = NULL; + + if (frontsector->ceilingheight > viewz + || frontsector->ceilingpic == skyflatnum) + { + ceilingplane = R_FindPlane (frontsector->ceilingheight, + frontsector->ceilingpic, + frontsector->lightlevel); + } + else + ceilingplane = NULL; + +//// R_AddSprites (frontsector); + + while (count--) + { + R_AddLine (line); + line++; + } +} + + + + +// +// RenderBSPNode +// Renders all subsectors below a given node, +// traversing subtree recursively. +// Just call with BSP root. +void R_RenderBSPNode (int bspnum) +{ + node_t* bsp; + int side; + + // Found a subsector? + if (bspnum & NF_SUBSECTOR) + { + if (bspnum == -1) + R_Subsector (0); + else + R_Subsector (bspnum&(~NF_SUBSECTOR)); + return; + } + + bsp = &nodes[bspnum]; + + // Decide which side the view point is on. + side = R_PointOnSide (viewx, viewy, bsp); + + // Recursively divide front space. + R_RenderBSPNode (bsp->children[side]); + + // Possibly divide back space. + if (R_CheckBBox (bsp->bbox[side^1])) + R_RenderBSPNode (bsp->children[side^1]); +} + + +} // namespace vpo + diff --git a/Source/Plugins/vpo_dll/r_bsp.h b/Source/Plugins/vpo_dll/r_bsp.h index 3b752810..45c534ba 100644 --- a/Source/Plugins/vpo_dll/r_bsp.h +++ b/Source/Plugins/vpo_dll/r_bsp.h @@ -1,57 +1,57 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Refresh module, BSP traversal and handling. -// -//----------------------------------------------------------------------------- - -#ifndef __R_BSP__ -#define __R_BSP__ - -extern seg_t* curline; -extern side_t* sidedef; -extern line_t* linedef; -extern sector_t* frontsector; -extern sector_t* backsector; - -extern int rw_x; -extern int rw_stopx; - -extern boolean segtextured; - -// false if the back side is the same plane -extern boolean markfloor; -extern boolean markceiling; - -extern boolean skymap; - -extern drawseg_t drawsegs[MAXDRAWSEGS+10]; -extern drawseg_t* ds_p; - - -// BSP? -void R_ClearClipSegs (void); -void R_ClearDrawSegs (void); - -void R_RenderBSPNode (int bspnum); - -#endif +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// Refresh module, BSP traversal and handling. +// +//----------------------------------------------------------------------------- + +#ifndef __R_BSP__ +#define __R_BSP__ + +extern seg_t* curline; +extern side_t* sidedef; +extern line_t* linedef; +extern sector_t* frontsector; +extern sector_t* backsector; + +extern int rw_x; +extern int rw_stopx; + +extern boolean segtextured; + +// false if the back side is the same plane +extern boolean markfloor; +extern boolean markceiling; + +extern boolean skymap; + +extern drawseg_t drawsegs[MAXDRAWSEGS+10]; +extern drawseg_t* ds_p; + + +// BSP? +void R_ClearClipSegs (void); +void R_ClearDrawSegs (void); + +void R_RenderBSPNode (int bspnum); + +#endif diff --git a/Source/Plugins/vpo_dll/r_defs.h b/Source/Plugins/vpo_dll/r_defs.h index 1fd619a1..cd6fb1d1 100644 --- a/Source/Plugins/vpo_dll/r_defs.h +++ b/Source/Plugins/vpo_dll/r_defs.h @@ -1,321 +1,308 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Refresh/rendering module, shared data struct definitions. -// -//----------------------------------------------------------------------------- - -#ifndef __R_DEFS__ -#define __R_DEFS__ - - -// Silhouette, needed for clipping Segs (mainly) -// and sprites representing things. -#define SIL_NONE 0 -#define SIL_BOTTOM 1 -#define SIL_TOP 2 -#define SIL_BOTH 3 - -// #define MAXDRAWSEGS 256 -#define MAXDRAWSEGS 1024 // andrewj: increased for Visplane Explorer - - -#define skyflatnum 2 - - -// -// INTERNAL MAP TYPES -// used by play and refresh -// - -// -// Your plain vanilla vertex. -// Note: transformed values not buffered locally, -// like some DOOM-alikes ("wt", "WebView") did. -// -typedef struct -{ - fixed_t x; - fixed_t y; - -} vertex_t; - - -// Forward of LineDefs, for Sectors. -struct line_s; - - -// -// The SECTORS record, at runtime. -// Stores things/mobjs. -// -typedef struct -{ - fixed_t floorheight; - fixed_t ceilingheight; - - short floorpic; - short ceilingpic; - short lightlevel; - short special; - short tag; - - // 0 = untraversed, 1,2 = sndlines -1 - int soundtraversed; - -/// // thing that made a sound (or null) -/// mobj_t* soundtarget; - -/// // mapblock bounding box for height changes -/// int blockbox[4]; - - // origin for any sounds played by the sector -/// degenmobj_t soundorg; - - // if == validcount, already checked - int validcount; - -/// // list of mobjs in sector -/// mobj_t* thinglist; - - // thinker_t for reversable actions - void* specialdata; - - int linecount; - struct line_s** lines; // [linecount] size - -} sector_t; - - - -// -// The SideDef. -// - -typedef struct -{ - // add this to the calculated texture column - fixed_t textureoffset; - - // add this to the calculated texture top - fixed_t rowoffset; - - // Texture indices. - // We do not maintain names here. - short toptexture; - short bottomtexture; - short midtexture; - - // Sector the SideDef is facing. - sector_t* sector; - -} side_t; - - - -// -// Move clipping aid for LineDefs. -// -typedef enum -{ - ST_HORIZONTAL, - ST_VERTICAL, - ST_POSITIVE, - ST_NEGATIVE - -} slopetype_t; - - - -typedef struct line_s -{ - // Vertices, from v1 to v2. - vertex_t* v1; - vertex_t* v2; - - // Precalculated v2 - v1 for side checking. - fixed_t dx; - fixed_t dy; - - // Animation related. - short flags; - short special; - short tag; - - // Visual appearance: SideDefs. - // sidenum[1] will be -1 if one sided - short sidenum[2]; - - // Neat. Another bounding box, for the extent - // of the LineDef. - fixed_t bbox[4]; - - // To aid move clipping. - slopetype_t slopetype; - - // Front and back sector. - // Note: redundant? Can be retrieved from SideDefs. - sector_t* frontsector; - sector_t* backsector; - - // if == validcount, already checked - int validcount; - - // thinker_t for reversable actions - void* specialdata; -} line_t; - - - - -// -// A SubSector. -// References a Sector. -// Basically, this is a list of LineSegs, -// indicating the visible walls that define -// (all or some) sides of a convex BSP leaf. -// -typedef struct subsector_s -{ - sector_t* sector; - - short numlines; - short firstline; - -} subsector_t; - - - -// -// The LineSeg. -// -typedef struct -{ - vertex_t* v1; - vertex_t* v2; - - fixed_t offset; - - angle_t angle; - - side_t* sidedef; - line_t* linedef; - - // Sector references. - // Could be retrieved from linedef, too. - // backsector is NULL for one sided lines - sector_t* frontsector; - sector_t* backsector; - -} seg_t; - - - -// -// BSP node. -// -typedef struct -{ - // Partition line. - fixed_t x; - fixed_t y; - fixed_t dx; - fixed_t dy; - - // Bounding box for each child. - fixed_t bbox[2][4]; - - // If NF_SUBSECTOR its a subsector. - unsigned short children[2]; - -} node_t; - - - - - - -// -// OTHER TYPES -// - - - -// -// ? -// -typedef struct drawseg_s -{ - seg_t* curline; - int x1; - int x2; - - fixed_t scale1; - fixed_t scale2; - fixed_t scalestep; - - // 0=none, 1=bottom, 2=top, 3=both - int silhouette; - - // do not clip sprites above this - fixed_t bsilheight; - - // do not clip sprites below this - fixed_t tsilheight; - - // Pointers to lists for sprite clipping, - // all three adjusted so [x1] is first value. - short* sprtopclip; - short* sprbottomclip; - short* maskedtexturecol; - -} drawseg_t; - - - -// -// Now what is a visplane, anyway? -// -typedef struct -{ - fixed_t height; - int picnum; - int lightlevel; - int minx; - int maxx; - - // leave pads for [minx-1]/[maxx+1] - - byte pad1; - // Here lies the rub for all - // dynamic resize/change of resolution. - byte top[SCREENWIDTH]; - byte pad2; - byte pad3; - // See above. - byte bottom[SCREENWIDTH]; - byte pad4; - -} visplane_t; - - -#endif +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// Refresh/rendering module, shared data struct definitions. +// +//----------------------------------------------------------------------------- + +#ifndef __R_DEFS__ +#define __R_DEFS__ + + +// Silhouette, needed for clipping Segs (mainly) +// and sprites representing things. +#define SIL_NONE 0 +#define SIL_BOTTOM 1 +#define SIL_TOP 2 +#define SIL_BOTH 3 + +// andrewj: increased for Visplane Explorer (was 256) +#define MAXDRAWSEGS 1024 + + +#define skyflatnum 2 + + +extern fixed_t Map_bbox[4]; + + +// +// INTERNAL MAP TYPES +// used by play and refresh +// + +// +// Your plain vanilla vertex. +// Note: transformed values not buffered locally, +// like some DOOM-alikes ("wt", "WebView") did. +// +typedef struct +{ + fixed_t x; + fixed_t y; + +} vertex_t; + + +// Forward of LineDefs, for Sectors. +struct line_s; + + +// +// The SECTORS record, at runtime. +// Stores things/mobjs. +// +typedef struct +{ + fixed_t floorheight; + fixed_t ceilingheight; + + short floorpic; + short ceilingpic; + short lightlevel; + short special; + short tag; + + // 0 = untraversed, 1,2 = sndlines -1 + int soundtraversed; + + // if == validcount, already checked + int validcount; + + // thinker_t for reversable actions + void* specialdata; + + int linecount; + struct line_s** lines; // [linecount] size + + // andrewj: added these two field for Visplane Explorer. + // is_door is normally 0, + // can be +1 for a door (ceiling goes up) + // or -1 for a lowering floor (e.g. MAP12 of DOOM 2) + int is_door; + fixed_t alt_height; + +} sector_t; + + +// +// The SideDef. +// +typedef struct +{ + // add this to the calculated texture column + fixed_t textureoffset; + + // add this to the calculated texture top + fixed_t rowoffset; + + // Texture indices. + // We do not maintain names here. + short toptexture; + short bottomtexture; + short midtexture; + + // Sector the SideDef is facing. + sector_t* sector; + +} side_t; + + +// +// Move clipping aid for LineDefs. +// +typedef enum +{ + ST_HORIZONTAL, + ST_VERTICAL, + ST_POSITIVE, + ST_NEGATIVE + +} slopetype_t; + + +typedef struct line_s +{ + // Vertices, from v1 to v2. + vertex_t* v1; + vertex_t* v2; + + // Precalculated v2 - v1 for side checking. + fixed_t dx; + fixed_t dy; + + // Animation related. + short flags; + short special; + short tag; + + // Visual appearance: SideDefs. + // sidenum[1] will be -1 if one sided + short sidenum[2]; + + // Neat. Another bounding box, for the extent + // of the LineDef. + fixed_t bbox[4]; + + // To aid move clipping. + slopetype_t slopetype; + + // Front and back sector. + // Note: redundant? Can be retrieved from SideDefs. + sector_t* frontsector; + sector_t* backsector; + + // if == validcount, already checked + int validcount; + + // thinker_t for reversable actions + void* specialdata; + + // andrewj: added the following Hexen stuff + unsigned char args[5]; +} line_t; + + +// +// A SubSector. +// References a Sector. +// Basically, this is a list of LineSegs, +// indicating the visible walls that define +// (all or some) sides of a convex BSP leaf. +// +typedef struct subsector_s +{ + sector_t* sector; + + short numlines; + short firstline; + +} subsector_t; + + +// +// The LineSeg. +// +typedef struct +{ + vertex_t* v1; + vertex_t* v2; + + fixed_t offset; + + angle_t angle; + + side_t* sidedef; + line_t* linedef; + + // Sector references. + // Could be retrieved from linedef, too. + // backsector is NULL for one sided lines + sector_t* frontsector; + sector_t* backsector; + +} seg_t; + + +// +// BSP node. +// +typedef struct +{ + // Partition line. + fixed_t x; + fixed_t y; + fixed_t dx; + fixed_t dy; + + // Bounding box for each child. + fixed_t bbox[2][4]; + + // If NF_SUBSECTOR its a subsector. + unsigned short children[2]; + +} node_t; + + +// +// OTHER TYPES +// + + +typedef struct drawseg_s +{ + seg_t* curline; + int x1; + int x2; + + fixed_t scale1; + fixed_t scale2; + fixed_t scalestep; + + // 0=none, 1=bottom, 2=top, 3=both + int silhouette; + + // do not clip sprites above this + fixed_t bsilheight; + + // do not clip sprites below this + fixed_t tsilheight; + + // Pointers to lists for sprite clipping, + // all three adjusted so [x1] is first value. + short* sprtopclip; + short* sprbottomclip; + short* maskedtexturecol; + +} drawseg_t; + + +// +// Now what is a visplane, anyway? +// +typedef struct +{ + fixed_t height; + int picnum; + int lightlevel; + int minx; + int maxx; + + // leave pads for [minx-1]/[maxx+1] + + byte pad1; + // Here lies the rub for all + // dynamic resize/change of resolution. + byte top[SCREENWIDTH]; + byte pad2; + byte pad3; + // See above. + byte bottom[SCREENWIDTH]; + byte pad4; + +} visplane_t; + + +#endif /* __R_DEFS__ */ + +//--- editor settings --- +// vi:ts=4:sw=4:noexpandtab +// Emacs style mode select -*- C++ -*- diff --git a/Source/Plugins/vpo_dll/r_main.cc b/Source/Plugins/vpo_dll/r_main.cc index 66ec13ed..519ab7c0 100644 --- a/Source/Plugins/vpo_dll/r_main.cc +++ b/Source/Plugins/vpo_dll/r_main.cc @@ -1,683 +1,683 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Rendering main loop and setup functions, -// utility functions (BSP, geometry, trigonometry). -// See tables.c, too. -// -//----------------------------------------------------------------------------- - -#include "vpo_local.h" - -// #include "r_sky.h" - -namespace vpo -{ - - -// Fineangles in the SCREENWIDTH wide window. -#define FIELDOFVIEW 2048 - -int viewangleoffset; - -// increment every time a check is made -int validcount = 1; - - -int centerx; -int centery; - -fixed_t centerxfrac; -fixed_t centeryfrac; -fixed_t projection; - -// just for profiling purposes -int framecount; - -int sscount; -int linecount; -int loopcount; - -fixed_t viewx; -fixed_t viewy; -fixed_t viewz; - -angle_t viewangle; - -fixed_t viewcos; -fixed_t viewsin; - - -// -// precalculated math tables -// -angle_t clipangle; - -// The viewangletox[viewangle + FINEANGLES/4] lookup -// maps the visible view angles to screen X coordinates, -// flattening the arc to a flat projection plane. -// There will be many angles mapped to the same X. -int viewangletox[FINEANGLES/2]; - -// The xtoviewangleangle[] table maps a screen pixel -// to the lowest viewangle that maps back to x ranges -// from clipangle to -clipangle. -angle_t xtoviewangle[SCREENWIDTH+1]; - - -// UNUSED. -// The finetangentgent[angle+FINEANGLES/4] table -// holds the fixed_t tangent values for view angles, -// ranging from INT_MIN to 0 to INT_MAX. -// fixed_t finetangent[FINEANGLES/2]; - -// fixed_t finesine[5*FINEANGLES/4]; -const fixed_t* finecosine = &finesine[FINEANGLES/4]; - - -// bumped light from gun blasts -int extralight; - - -// from R_DRAW -int viewwidth; -int scaledviewwidth; -int viewheight; -int viewwindowx; -int viewwindowy; - - -// from R_THINGS -fixed_t pspritescale; -fixed_t pspriteiscale; - -short screenheightarray[SCREENWIDTH]; -short negonearray[SCREENWIDTH]; - - -// -// R_AddPointToBox -// Expand a given bbox -// so that it encloses a given point. -// -void R_AddPointToBox ( int x, int y, fixed_t* box ) -{ - if (x< box[BOXLEFT]) - box[BOXLEFT] = x; - if (x> box[BOXRIGHT]) - box[BOXRIGHT] = x; - if (y< box[BOXBOTTOM]) - box[BOXBOTTOM] = y; - if (y> box[BOXTOP]) - box[BOXTOP] = y; -} - - -// -// R_PointOnSide -// Traverse BSP (sub) tree, -// check point against partition plane. -// Returns side 0 (front) or 1 (back). -// -int R_PointOnSide ( fixed_t x, fixed_t y, node_t* node ) -{ - fixed_t dx; - fixed_t dy; - fixed_t left; - fixed_t right; - - if (!node->dx) - { - if (x <= node->x) - return node->dy > 0; - - return node->dy < 0; - } - if (!node->dy) - { - if (y <= node->y) - return node->dx < 0; - - return node->dx > 0; - } - - dx = (x - node->x); - dy = (y - node->y); - - // Try to quickly decide by looking at sign bits. - if ( (node->dy ^ node->dx ^ dx ^ dy)&0x80000000 ) - { - if ( (node->dy ^ dx) & 0x80000000 ) - { - // (left is negative) - return 1; - } - return 0; - } - - left = FixedMul ( node->dy>>FRACBITS , dx ); - right = FixedMul ( dy , node->dx>>FRACBITS ); - - if (right < left) - { - // front side - return 0; - } - // back side - return 1; -} - - -int R_PointOnSegSide ( fixed_t x, fixed_t y, seg_t* line ) -{ - fixed_t lx; - fixed_t ly; - fixed_t ldx; - fixed_t ldy; - fixed_t dx; - fixed_t dy; - fixed_t left; - fixed_t right; - - lx = line->v1->x; - ly = line->v1->y; - - ldx = line->v2->x - lx; - ldy = line->v2->y - ly; - - if (!ldx) - { - if (x <= lx) - return ldy > 0; - - return ldy < 0; - } - if (!ldy) - { - if (y <= ly) - return ldx < 0; - - return ldx > 0; - } - - dx = (x - lx); - dy = (y - ly); - - // Try to quickly decide by looking at sign bits. - if ( (ldy ^ ldx ^ dx ^ dy)&0x80000000 ) - { - if ( (ldy ^ dx) & 0x80000000 ) - { - // (left is negative) - return 1; - } - return 0; - } - - left = FixedMul ( ldy>>FRACBITS , dx ); - right = FixedMul ( dy , ldx>>FRACBITS ); - - if (right < left) - { - // front side - return 0; - } - // back side - return 1; -} - - -// -// R_PointToAngle -// To get a global angle from cartesian coordinates, -// the coordinates are flipped until they are in -// the first octant of the coordinate system, then -// the y (<=x) is scaled and divided by x to get a -// tangent (slope) value which is looked up in the -// tantoangle[] table. - -angle_t R_PointToAngle ( fixed_t x, fixed_t y ) -{ - x -= viewx; - y -= viewy; - - if ( (!x) && (!y) ) - return 0; - - if (x>= 0) - { - // x >=0 - if (y>= 0) - { - // y>= 0 - - if (x>y) - { - // octant 0 - return tantoangle[ SlopeDiv(y,x)]; - } - else - { - // octant 1 - return ANG90-1-tantoangle[ SlopeDiv(x,y)]; - } - } - else - { - // y<0 - y = -y; - - if (x>y) - { - // octant 8 - return -tantoangle[SlopeDiv(y,x)]; - } - else - { - // octant 7 - return ANG270+tantoangle[ SlopeDiv(x,y)]; - } - } - } - else - { - // x<0 - x = -x; - - if (y>= 0) - { - // y>= 0 - if (x>y) - { - // octant 3 - return ANG180-1-tantoangle[ SlopeDiv(y,x)]; - } - else - { - // octant 2 - return ANG90+ tantoangle[ SlopeDiv(x,y)]; - } - } - else - { - // y<0 - y = -y; - - if (x>y) - { - // octant 4 - return ANG180+tantoangle[ SlopeDiv(y,x)]; - } - else - { - // octant 5 - return ANG270-1-tantoangle[ SlopeDiv(x,y)]; - } - } - } - return 0; -} - - -angle_t R_PointToAngle2 ( fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2 ) -{ - viewx = x1; - viewy = y1; - - return R_PointToAngle (x2, y2); -} - - -fixed_t R_PointToDist ( fixed_t x, fixed_t y ) -{ - int angle; - fixed_t dx; - fixed_t dy; - fixed_t temp; - fixed_t dist; - fixed_t frac; - - dx = abs(x - viewx); - dy = abs(y - viewy); - - if (dy>dx) - { - temp = dx; - dx = dy; - dy = temp; - } - - // Fix crashes in udm1.wad - - if (dx != 0) - { - frac = FixedDiv(dy, dx); - } - else - { - frac = 0; - } - - angle = (tantoangle[frac>>DBITS]+ANG90) >> ANGLETOFINESHIFT; - - // use as cosine - dist = FixedDiv (dx, finesine[angle] ); - - return dist; -} - - -// -// R_ScaleFromGlobalAngle -// Returns the texture mapping scale -// for the current line (horizontal span) -// at the given angle. -// rw_distance must be calculated first. -// -fixed_t R_ScaleFromGlobalAngle (angle_t visangle) -{ - fixed_t scale; - angle_t anglea; - angle_t angleb; - int sinea; - int sineb; - fixed_t num; - int den; - - // UNUSED -#if 0 -{ - fixed_t dist; - fixed_t z; - fixed_t sinv; - fixed_t cosv; - - sinv = finesine[(visangle-rw_normalangle)>>ANGLETOFINESHIFT]; - dist = FixedDiv (rw_distance, sinv); - cosv = finecosine[(viewangle-visangle)>>ANGLETOFINESHIFT]; - z = abs(FixedMul (dist, cosv)); - scale = FixedDiv(projection, z); - return scale; -} -#endif - - anglea = ANG90 + (visangle-viewangle); - angleb = ANG90 + (visangle-rw_normalangle); - - // both sines are allways positive - sinea = finesine[anglea>>ANGLETOFINESHIFT]; - sineb = finesine[angleb>>ANGLETOFINESHIFT]; - num = FixedMul(projection,sineb)<<0; - den = FixedMul(rw_distance,sinea); - - if (den > num>>16) - { - scale = FixedDiv (num, den); - - if (scale > 64*FRACUNIT) - scale = 64*FRACUNIT; - else if (scale < 256) - scale = 256; - } - else - scale = 64*FRACUNIT; - - return scale; -} - - -void R_InitBuffer ( int width, int height ) -{ - int i; - - // Handle resize, - // e.g. smaller view windows - // with border and/or status bar. - viewwindowx = (SCREENWIDTH-width) >> 1; - viewwindowy = 0; - - // this was from R_InitSprites - for (i=0 ; i> 1; - - // Preclaculate all row offsets. - for (i=0 ; i FRACUNIT*2) - t = -1; - else if (finetangent[i] < -FRACUNIT*2) - t = viewwidth+1; - else - { - t = FixedMul (finetangent[i], focallength); - t = (centerxfrac - t+FRACUNIT-1)>>FRACBITS; - - if (t < -1) - t = -1; - else if (t>viewwidth+1) - t = viewwidth+1; - } - viewangletox[i] = t; - } - - // Scan viewangletox[] to generate xtoviewangle[]: - // xtoviewangle will give the smallest view angle - // that maps to x. - for (x=0;x<=viewwidth;x++) - { - i = 0; - while (viewangletox[i]>x) - i++; - xtoviewangle[x] = (i<> 0; - - centery = viewheight/2; - centerx = viewwidth/2; - centerxfrac = centerx<>ANGLETOFINESHIFT]); - distscale[i] = FixedDiv (FRACUNIT,cosadj); - } - -} - - - -// -// R_Init -// -void R_Init (void) -{ - R_SetViewSize (11, 0); - - framecount = 0; -} - - -// -// R_PointInSubsector -// -subsector_t* R_PointInSubsector ( fixed_t x, fixed_t y ) -{ - node_t* node; - int side; - int nodenum; - - // single subsector is a special case - if (!numnodes) - return subsectors; - - nodenum = numnodes-1; - - while (! (nodenum & NF_SUBSECTOR) ) - { - node = &nodes[nodenum]; - side = R_PointOnSide (x, y, node); - nodenum = node->children[side]; - } - - return &subsectors[nodenum & ~NF_SUBSECTOR]; -} - - -// -// R_SetupFrame -// -void R_SetupFrame (fixed_t x, fixed_t y, fixed_t z, angle_t angle) -{ - viewx = x; - viewy = y; - viewz = z; - - viewangle = angle; - - viewsin = finesine[viewangle>>ANGLETOFINESHIFT]; - viewcos = finecosine[viewangle>>ANGLETOFINESHIFT]; - - sscount = 0; - - framecount++; - validcount++; -} - - -// -// R_RenderView -// -void R_RenderView (fixed_t x, fixed_t y, fixed_t z, angle_t angle) -{ - R_SetupFrame (x, y, z, angle); - - // Clear buffers. - R_ClearClipSegs (); - R_ClearDrawSegs (); - R_ClearPlanes (); -/// R_ClearSprites (); - - // The head node is the last node output. - R_RenderBSPNode (numnodes - 1); -} - - -} // namespace vpo - +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// Rendering main loop and setup functions, +// utility functions (BSP, geometry, trigonometry). +// See tables.c, too. +// +//----------------------------------------------------------------------------- + +#include "vpo_local.h" + +// #include "r_sky.h" + +namespace vpo +{ + + +// Fineangles in the SCREENWIDTH wide window. +#define FIELDOFVIEW 2048 + +int viewangleoffset; + +// increment every time a check is made +int validcount = 1; + + +int centerx; +int centery; + +fixed_t centerxfrac; +fixed_t centeryfrac; +fixed_t projection; + +// just for profiling purposes +int framecount; + +int sscount; +int linecount; +int loopcount; + +fixed_t viewx; +fixed_t viewy; +fixed_t viewz; + +angle_t viewangle; + +fixed_t viewcos; +fixed_t viewsin; + + +// +// precalculated math tables +// +angle_t clipangle; + +// The viewangletox[viewangle + FINEANGLES/4] lookup +// maps the visible view angles to screen X coordinates, +// flattening the arc to a flat projection plane. +// There will be many angles mapped to the same X. +int viewangletox[FINEANGLES/2]; + +// The xtoviewangleangle[] table maps a screen pixel +// to the lowest viewangle that maps back to x ranges +// from clipangle to -clipangle. +angle_t xtoviewangle[SCREENWIDTH+1]; + + +// UNUSED. +// The finetangentgent[angle+FINEANGLES/4] table +// holds the fixed_t tangent values for view angles, +// ranging from INT_MIN to 0 to INT_MAX. +// fixed_t finetangent[FINEANGLES/2]; + +// fixed_t finesine[5*FINEANGLES/4]; +const fixed_t* finecosine = &finesine[FINEANGLES/4]; + + +// bumped light from gun blasts +int extralight; + + +// from R_DRAW +int viewwidth; +int scaledviewwidth; +int viewheight; +int viewwindowx; +int viewwindowy; + + +// from R_THINGS +fixed_t pspritescale; +fixed_t pspriteiscale; + +short screenheightarray[SCREENWIDTH]; +short negonearray[SCREENWIDTH]; + + +// +// R_AddPointToBox +// Expand a given bbox +// so that it encloses a given point. +// +void R_AddPointToBox ( int x, int y, fixed_t* box ) +{ + if (x< box[BOXLEFT]) + box[BOXLEFT] = x; + if (x> box[BOXRIGHT]) + box[BOXRIGHT] = x; + if (y< box[BOXBOTTOM]) + box[BOXBOTTOM] = y; + if (y> box[BOXTOP]) + box[BOXTOP] = y; +} + + +// +// R_PointOnSide +// Traverse BSP (sub) tree, +// check point against partition plane. +// Returns side 0 (front) or 1 (back). +// +int R_PointOnSide ( fixed_t x, fixed_t y, node_t* node ) +{ + fixed_t dx; + fixed_t dy; + fixed_t left; + fixed_t right; + + if (!node->dx) + { + if (x <= node->x) + return node->dy > 0; + + return node->dy < 0; + } + if (!node->dy) + { + if (y <= node->y) + return node->dx < 0; + + return node->dx > 0; + } + + dx = (x - node->x); + dy = (y - node->y); + + // Try to quickly decide by looking at sign bits. + if ( (node->dy ^ node->dx ^ dx ^ dy)&0x80000000 ) + { + if ( (node->dy ^ dx) & 0x80000000 ) + { + // (left is negative) + return 1; + } + return 0; + } + + left = FixedMul ( node->dy>>FRACBITS , dx ); + right = FixedMul ( dy , node->dx>>FRACBITS ); + + if (right < left) + { + // front side + return 0; + } + // back side + return 1; +} + + +int R_PointOnSegSide ( fixed_t x, fixed_t y, seg_t* line ) +{ + fixed_t lx; + fixed_t ly; + fixed_t ldx; + fixed_t ldy; + fixed_t dx; + fixed_t dy; + fixed_t left; + fixed_t right; + + lx = line->v1->x; + ly = line->v1->y; + + ldx = line->v2->x - lx; + ldy = line->v2->y - ly; + + if (!ldx) + { + if (x <= lx) + return ldy > 0; + + return ldy < 0; + } + if (!ldy) + { + if (y <= ly) + return ldx < 0; + + return ldx > 0; + } + + dx = (x - lx); + dy = (y - ly); + + // Try to quickly decide by looking at sign bits. + if ( (ldy ^ ldx ^ dx ^ dy)&0x80000000 ) + { + if ( (ldy ^ dx) & 0x80000000 ) + { + // (left is negative) + return 1; + } + return 0; + } + + left = FixedMul ( ldy>>FRACBITS , dx ); + right = FixedMul ( dy , ldx>>FRACBITS ); + + if (right < left) + { + // front side + return 0; + } + // back side + return 1; +} + + +// +// R_PointToAngle +// To get a global angle from cartesian coordinates, +// the coordinates are flipped until they are in +// the first octant of the coordinate system, then +// the y (<=x) is scaled and divided by x to get a +// tangent (slope) value which is looked up in the +// tantoangle[] table. + +angle_t R_PointToAngle ( fixed_t x, fixed_t y ) +{ + x -= viewx; + y -= viewy; + + if ( (!x) && (!y) ) + return 0; + + if (x>= 0) + { + // x >=0 + if (y>= 0) + { + // y>= 0 + + if (x>y) + { + // octant 0 + return tantoangle[ SlopeDiv(y,x)]; + } + else + { + // octant 1 + return ANG90-1-tantoangle[ SlopeDiv(x,y)]; + } + } + else + { + // y<0 + y = -y; + + if (x>y) + { + // octant 8 + return -tantoangle[SlopeDiv(y,x)]; + } + else + { + // octant 7 + return ANG270+tantoangle[ SlopeDiv(x,y)]; + } + } + } + else + { + // x<0 + x = -x; + + if (y>= 0) + { + // y>= 0 + if (x>y) + { + // octant 3 + return ANG180-1-tantoangle[ SlopeDiv(y,x)]; + } + else + { + // octant 2 + return ANG90+ tantoangle[ SlopeDiv(x,y)]; + } + } + else + { + // y<0 + y = -y; + + if (x>y) + { + // octant 4 + return ANG180+tantoangle[ SlopeDiv(y,x)]; + } + else + { + // octant 5 + return ANG270-1-tantoangle[ SlopeDiv(x,y)]; + } + } + } + return 0; +} + + +angle_t R_PointToAngle2 ( fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2 ) +{ + viewx = x1; + viewy = y1; + + return R_PointToAngle (x2, y2); +} + + +fixed_t R_PointToDist ( fixed_t x, fixed_t y ) +{ + int angle; + fixed_t dx; + fixed_t dy; + fixed_t temp; + fixed_t dist; + fixed_t frac; + + dx = abs(x - viewx); + dy = abs(y - viewy); + + if (dy>dx) + { + temp = dx; + dx = dy; + dy = temp; + } + + // Fix crashes in udm1.wad + + if (dx != 0) + { + frac = FixedDiv(dy, dx); + } + else + { + frac = 0; + } + + angle = (tantoangle[frac>>DBITS]+ANG90) >> ANGLETOFINESHIFT; + + // use as cosine + dist = FixedDiv (dx, finesine[angle] ); + + return dist; +} + + +// +// R_ScaleFromGlobalAngle +// Returns the texture mapping scale +// for the current line (horizontal span) +// at the given angle. +// rw_distance must be calculated first. +// +fixed_t R_ScaleFromGlobalAngle (angle_t visangle) +{ + fixed_t scale; + angle_t anglea; + angle_t angleb; + int sinea; + int sineb; + fixed_t num; + int den; + + // UNUSED +#if 0 +{ + fixed_t dist; + fixed_t z; + fixed_t sinv; + fixed_t cosv; + + sinv = finesine[(visangle-rw_normalangle)>>ANGLETOFINESHIFT]; + dist = FixedDiv (rw_distance, sinv); + cosv = finecosine[(viewangle-visangle)>>ANGLETOFINESHIFT]; + z = abs(FixedMul (dist, cosv)); + scale = FixedDiv(projection, z); + return scale; +} +#endif + + anglea = ANG90 + (visangle-viewangle); + angleb = ANG90 + (visangle-rw_normalangle); + + // both sines are allways positive + sinea = finesine[anglea>>ANGLETOFINESHIFT]; + sineb = finesine[angleb>>ANGLETOFINESHIFT]; + num = FixedMul(projection,sineb)<<0; + den = FixedMul(rw_distance,sinea); + + if (den > num>>16) + { + scale = FixedDiv (num, den); + + if (scale > 64*FRACUNIT) + scale = 64*FRACUNIT; + else if (scale < 256) + scale = 256; + } + else + scale = 64*FRACUNIT; + + return scale; +} + + +void R_InitBuffer ( int width, int height ) +{ + int i; + + // Handle resize, + // e.g. smaller view windows + // with border and/or status bar. + viewwindowx = (SCREENWIDTH-width) >> 1; + viewwindowy = 0; + + // this was from R_InitSprites + for (i=0 ; i> 1; + + // Preclaculate all row offsets. + for (i=0 ; i FRACUNIT*2) + t = -1; + else if (finetangent[i] < -FRACUNIT*2) + t = viewwidth+1; + else + { + t = FixedMul (finetangent[i], focallength); + t = (centerxfrac - t+FRACUNIT-1)>>FRACBITS; + + if (t < -1) + t = -1; + else if (t>viewwidth+1) + t = viewwidth+1; + } + viewangletox[i] = t; + } + + // Scan viewangletox[] to generate xtoviewangle[]: + // xtoviewangle will give the smallest view angle + // that maps to x. + for (x=0;x<=viewwidth;x++) + { + i = 0; + while (viewangletox[i]>x) + i++; + xtoviewangle[x] = (i<> 0; + + centery = viewheight/2; + centerx = viewwidth/2; + centerxfrac = centerx<>ANGLETOFINESHIFT]); + distscale[i] = FixedDiv (FRACUNIT,cosadj); + } + +} + + + +// +// R_Init +// +void R_Init (void) +{ + R_SetViewSize (11, 0); + + framecount = 0; +} + + +// +// R_PointInSubsector +// +subsector_t* R_PointInSubsector ( fixed_t x, fixed_t y ) +{ + node_t* node; + int side; + int nodenum; + + // single subsector is a special case + if (!numnodes) + return subsectors; + + nodenum = numnodes-1; + + while (! (nodenum & NF_SUBSECTOR) ) + { + node = &nodes[nodenum]; + side = R_PointOnSide (x, y, node); + nodenum = node->children[side]; + } + + return &subsectors[nodenum & ~NF_SUBSECTOR]; +} + + +// +// R_SetupFrame +// +void R_SetupFrame (fixed_t x, fixed_t y, fixed_t z, angle_t angle) +{ + viewx = x; + viewy = y; + viewz = z; + + viewangle = angle; + + viewsin = finesine[viewangle>>ANGLETOFINESHIFT]; + viewcos = finecosine[viewangle>>ANGLETOFINESHIFT]; + + sscount = 0; + + framecount++; + validcount++; +} + + +// +// R_RenderView +// +void R_RenderView (fixed_t x, fixed_t y, fixed_t z, angle_t angle) +{ + R_SetupFrame (x, y, z, angle); + + // Clear buffers. + R_ClearClipSegs (); + R_ClearDrawSegs (); + R_ClearPlanes (); +/// R_ClearSprites (); + + // The head node is the last node output. + R_RenderBSPNode (numnodes - 1); +} + + +} // namespace vpo + diff --git a/Source/Plugins/vpo_dll/r_main.h b/Source/Plugins/vpo_dll/r_main.h index ceb7a728..c3490e9a 100644 --- a/Source/Plugins/vpo_dll/r_main.h +++ b/Source/Plugins/vpo_dll/r_main.h @@ -1,113 +1,113 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// System specific interface stuff. -// -//----------------------------------------------------------------------------- - -#ifndef __R_MAIN__ -#define __R_MAIN__ - - -// -// POV related. -// -extern fixed_t viewcos; -extern fixed_t viewsin; - -extern int viewwidth; -extern int viewheight; -extern int viewwindowx; -extern int viewwindowy; - - -extern int centerx; -extern int centery; - -extern fixed_t centerxfrac; -extern fixed_t centeryfrac; -extern fixed_t projection; - -extern int validcount; - -extern int linecount; -extern int loopcount; - - -// -// Lighting LUT. -// Used for z-depth cuing per column/row, -// and other lighting effects (sector ambient, flash). -// - -// Lighting constants. -// Now why not 32 levels here? -#define LIGHTLEVELS 16 -#define LIGHTSEGSHIFT 4 - -#define MAXLIGHTSCALE 48 -#define LIGHTSCALESHIFT 12 -#define MAXLIGHTZ 128 -#define LIGHTZSHIFT 20 - - -// Number of diminishing brightness levels. -// There a 0-31, i.e. 32 LUT in the COLORMAP lump. -#define NUMCOLORMAPS 32 - - -// -// Utility functions. -int R_PointOnSide ( fixed_t x, fixed_t y, node_t* node ); - -int R_PointOnSegSide ( fixed_t x, fixed_t y, seg_t* line ); - -angle_t R_PointToAngle ( fixed_t x, fixed_t y ); - -angle_t R_PointToAngle2 ( fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2 ); - -fixed_t R_PointToDist ( fixed_t x, fixed_t y ); - - -fixed_t R_ScaleFromGlobalAngle (angle_t visangle); - -subsector_t* R_PointInSubsector ( fixed_t x, fixed_t y ); - -void R_AddPointToBox ( int x, int y, fixed_t* box ); - - - -// R_THINGS - -extern short screenheightarray[SCREENWIDTH]; -extern short negonearray[SCREENWIDTH]; - - -// -// REFRESH - the actual rendering functions. -// - -void R_Init (void); - -void R_RenderView (fixed_t x, fixed_t y, fixed_t z, angle_t angle); - -#endif +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// System specific interface stuff. +// +//----------------------------------------------------------------------------- + +#ifndef __R_MAIN__ +#define __R_MAIN__ + + +// +// POV related. +// +extern fixed_t viewcos; +extern fixed_t viewsin; + +extern int viewwidth; +extern int viewheight; +extern int viewwindowx; +extern int viewwindowy; + + +extern int centerx; +extern int centery; + +extern fixed_t centerxfrac; +extern fixed_t centeryfrac; +extern fixed_t projection; + +extern int validcount; + +extern int linecount; +extern int loopcount; + + +// +// Lighting LUT. +// Used for z-depth cuing per column/row, +// and other lighting effects (sector ambient, flash). +// + +// Lighting constants. +// Now why not 32 levels here? +#define LIGHTLEVELS 16 +#define LIGHTSEGSHIFT 4 + +#define MAXLIGHTSCALE 48 +#define LIGHTSCALESHIFT 12 +#define MAXLIGHTZ 128 +#define LIGHTZSHIFT 20 + + +// Number of diminishing brightness levels. +// There a 0-31, i.e. 32 LUT in the COLORMAP lump. +#define NUMCOLORMAPS 32 + + +// +// Utility functions. +int R_PointOnSide ( fixed_t x, fixed_t y, node_t* node ); + +int R_PointOnSegSide ( fixed_t x, fixed_t y, seg_t* line ); + +angle_t R_PointToAngle ( fixed_t x, fixed_t y ); + +angle_t R_PointToAngle2 ( fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2 ); + +fixed_t R_PointToDist ( fixed_t x, fixed_t y ); + + +fixed_t R_ScaleFromGlobalAngle (angle_t visangle); + +subsector_t* R_PointInSubsector ( fixed_t x, fixed_t y ); + +void R_AddPointToBox ( int x, int y, fixed_t* box ); + + + +// R_THINGS + +extern short screenheightarray[SCREENWIDTH]; +extern short negonearray[SCREENWIDTH]; + + +// +// REFRESH - the actual rendering functions. +// + +void R_Init (void); + +void R_RenderView (fixed_t x, fixed_t y, fixed_t z, angle_t angle); + +#endif diff --git a/Source/Plugins/vpo_dll/r_plane.cc b/Source/Plugins/vpo_dll/r_plane.cc index 46c09763..535d9d56 100644 --- a/Source/Plugins/vpo_dll/r_plane.cc +++ b/Source/Plugins/vpo_dll/r_plane.cc @@ -1,355 +1,355 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Here is a core component: drawing the floors and ceilings, -// while maintaining a per column clipping list only. -// Moreover, the sky areas have to be determined. -// -//----------------------------------------------------------------------------- - -#include "vpo_local.h" - -namespace vpo -{ - - -// -// opening -// - -// Here comes the obnoxious "visplane". -visplane_t visplanes[MAXVISPLANES+10]; -visplane_t* lastvisplane; -visplane_t* floorplane; -visplane_t* ceilingplane; - -int total_visplanes; - -short openings[MAXOPENINGS+400]; -short* lastopening; - -int total_openings; - - -// -// Clip values are the solid pixel bounding the range. -// floorclip starts out SCREENHEIGHT -// ceilingclip starts out -1 -// -short floorclip[SCREENWIDTH]; -short ceilingclip[SCREENWIDTH]; - -// -// spanstart holds the start of a plane span -// initialized to 0 at start -// -int spanstart[SCREENHEIGHT]; -int spanstop[SCREENHEIGHT]; - -// -// texture mapping -// -fixed_t planeheight; - -fixed_t yslope[SCREENHEIGHT]; -fixed_t distscale[SCREENWIDTH]; -fixed_t basexscale; -fixed_t baseyscale; - -fixed_t cachedheight[SCREENHEIGHT]; -fixed_t cacheddistance[SCREENHEIGHT]; -fixed_t cachedxstep[SCREENHEIGHT]; -fixed_t cachedystep[SCREENHEIGHT]; - - - -#if 0 -// -// R_MapPlane -// -// Uses global vars: -// planeheight -// ds_source -// basexscale -// baseyscale -// viewx -// viewy -// -// BASIC PRIMITIVE -// -void R_MapPlane ( int y, int x1, int x2 ) -{ - angle_t angle; - fixed_t distance; - fixed_t length; - unsigned index; - -#ifdef RANGECHECK - if (x2 < x1 - || x1 < 0 - || x2 >= viewwidth - || y > viewheight) - { - I_Error ("R_MapPlane: %i, %i at %i",x1,x2,y); - } -#endif - - if (planeheight != cachedheight[y]) - { - cachedheight[y] = planeheight; - distance = cacheddistance[y] = FixedMul (planeheight, yslope[y]); - ds_xstep = cachedxstep[y] = FixedMul (distance,basexscale); - ds_ystep = cachedystep[y] = FixedMul (distance,baseyscale); - } - else - { - distance = cacheddistance[y]; - ds_xstep = cachedxstep[y]; - ds_ystep = cachedystep[y]; - } - - length = FixedMul (distance,distscale[x1]); - angle = (viewangle + xtoviewangle[x1])>>ANGLETOFINESHIFT; - ds_xfrac = viewx + FixedMul(finecosine[angle], length); - ds_yfrac = -viewy - FixedMul(finesine[angle], length); - - if (fixedcolormap) - ds_colormap = fixedcolormap; - else - { - index = distance >> LIGHTZSHIFT; - - if (index >= MAXLIGHTZ ) - index = MAXLIGHTZ-1; - - ds_colormap = planezlight[index]; - } - - ds_y = y; - ds_x1 = x1; - ds_x2 = x2; - - // high or low detail - spanfunc (); -} -#endif - - -// -// R_ClearPlanes -// At begining of frame. -// -void R_ClearPlanes (void) -{ - int i; - angle_t angle; - - // opening / clipping determination - for (i=0 ; i>ANGLETOFINESHIFT; - - // scale will be unit scale at SCREENWIDTH/2 distance - basexscale = FixedDiv (finecosine[angle],centerxfrac); - baseyscale = -FixedDiv (finesine[angle],centerxfrac); -} - - - - -// -// R_FindPlane -// -visplane_t* R_FindPlane ( fixed_t height, int picnum, int lightlevel ) -{ - visplane_t* check; - - if (picnum == skyflatnum) - { - height = 0; // all skys map together - lightlevel = 0; - } - - for (check=visplanes; checkheight - && picnum == check->picnum - && lightlevel == check->lightlevel) - { - break; - } - } - - - if (check < lastvisplane) - return check; - - if (total_visplanes >= MAXVISPLANES) - throw overflow_exception(); // I_Error ("R_FindPlane: no more visplanes"); - - total_visplanes++; - lastvisplane++; - - check->height = height; - check->picnum = picnum; - check->lightlevel = lightlevel; - check->minx = SCREENWIDTH; - check->maxx = -1; - - memset (check->top,0xff,sizeof(check->top)); - - return check; -} - - -// -// R_CheckPlane -// -visplane_t* R_CheckPlane ( visplane_t* pl, int start, int stop ) -{ - int intrl; - int intrh; - int unionl; - int unionh; - int x; - - if (start < pl->minx) - { - intrl = pl->minx; - unionl = start; - } - else - { - unionl = pl->minx; - intrl = start; - } - - if (stop > pl->maxx) - { - intrh = pl->maxx; - unionh = stop; - } - else - { - unionh = pl->maxx; - intrh = stop; - } - - for (x=intrl ; x<= intrh ; x++) - if (pl->top[x] != 0xff) - break; - - if (x > intrh) - { - pl->minx = unionl; - pl->maxx = unionh; - - // use the same one - return pl; - } - - // make a new visplane - lastvisplane->height = pl->height; - lastvisplane->picnum = pl->picnum; - lastvisplane->lightlevel = pl->lightlevel; - - if (total_visplanes >= MAXVISPLANES) - throw overflow_exception(); // I_Error ("R_FindPlane: no more visplanes"); - - total_visplanes++; - - pl = lastvisplane++; - pl->minx = start; - pl->maxx = stop; - - memset (pl->top,0xff,sizeof(pl->top)); - - return pl; -} - - -#if 0 -// -// R_MakeSpans -// -void R_MakeSpans ( int x, int t1, int b1, int t2, int b2 ) -{ - while (t1 < t2 && t1<=b1) - { - R_MapPlane (t1,spanstart[t1],x-1); - t1++; - } - while (b1 > b2 && b1>=t1) - { - R_MapPlane (b1,spanstart[b1],x-1); - b1--; - } - - while (t2 < t1 && t2<=b2) - { - spanstart[t2] = x; - t2++; - } - while (b2 > b1 && b2>=t2) - { - spanstart[b2] = x; - b2--; - } -} -#endif - - - -#if 0 - was: R_DrawPlanes() - - - if (ds_p - drawsegs > MAXDRAWSEGS) - I_Error ("R_DrawPlanes: drawsegs overflow (%i)", - ds_p - drawsegs); - - if (lastvisplane - visplanes > MAXVISPLANES) - I_Error ("R_DrawPlanes: visplane overflow (%i)", - lastvisplane - visplanes); - - if (lastopening - openings > MAXOPENINGS) - I_Error ("R_DrawPlanes: opening overflow (%i)", - lastopening - openings); -#endif - - -} // namespace vpo - +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// Here is a core component: drawing the floors and ceilings, +// while maintaining a per column clipping list only. +// Moreover, the sky areas have to be determined. +// +//----------------------------------------------------------------------------- + +#include "vpo_local.h" + +namespace vpo +{ + + +// +// opening +// + +// Here comes the obnoxious "visplane". +visplane_t visplanes[MAXVISPLANES+10]; +visplane_t* lastvisplane; +visplane_t* floorplane; +visplane_t* ceilingplane; + +int total_visplanes; + +short openings[MAXOPENINGS+400]; +short* lastopening; + +int total_openings; + + +// +// Clip values are the solid pixel bounding the range. +// floorclip starts out SCREENHEIGHT +// ceilingclip starts out -1 +// +short floorclip[SCREENWIDTH]; +short ceilingclip[SCREENWIDTH]; + +// +// spanstart holds the start of a plane span +// initialized to 0 at start +// +int spanstart[SCREENHEIGHT]; +int spanstop[SCREENHEIGHT]; + +// +// texture mapping +// +fixed_t planeheight; + +fixed_t yslope[SCREENHEIGHT]; +fixed_t distscale[SCREENWIDTH]; +fixed_t basexscale; +fixed_t baseyscale; + +fixed_t cachedheight[SCREENHEIGHT]; +fixed_t cacheddistance[SCREENHEIGHT]; +fixed_t cachedxstep[SCREENHEIGHT]; +fixed_t cachedystep[SCREENHEIGHT]; + + + +#if 0 +// +// R_MapPlane +// +// Uses global vars: +// planeheight +// ds_source +// basexscale +// baseyscale +// viewx +// viewy +// +// BASIC PRIMITIVE +// +void R_MapPlane ( int y, int x1, int x2 ) +{ + angle_t angle; + fixed_t distance; + fixed_t length; + unsigned index; + +#ifdef RANGECHECK + if (x2 < x1 + || x1 < 0 + || x2 >= viewwidth + || y > viewheight) + { + I_Error ("R_MapPlane: %i, %i at %i",x1,x2,y); + } +#endif + + if (planeheight != cachedheight[y]) + { + cachedheight[y] = planeheight; + distance = cacheddistance[y] = FixedMul (planeheight, yslope[y]); + ds_xstep = cachedxstep[y] = FixedMul (distance,basexscale); + ds_ystep = cachedystep[y] = FixedMul (distance,baseyscale); + } + else + { + distance = cacheddistance[y]; + ds_xstep = cachedxstep[y]; + ds_ystep = cachedystep[y]; + } + + length = FixedMul (distance,distscale[x1]); + angle = (viewangle + xtoviewangle[x1])>>ANGLETOFINESHIFT; + ds_xfrac = viewx + FixedMul(finecosine[angle], length); + ds_yfrac = -viewy - FixedMul(finesine[angle], length); + + if (fixedcolormap) + ds_colormap = fixedcolormap; + else + { + index = distance >> LIGHTZSHIFT; + + if (index >= MAXLIGHTZ ) + index = MAXLIGHTZ-1; + + ds_colormap = planezlight[index]; + } + + ds_y = y; + ds_x1 = x1; + ds_x2 = x2; + + // high or low detail + spanfunc (); +} +#endif + + +// +// R_ClearPlanes +// At begining of frame. +// +void R_ClearPlanes (void) +{ + int i; + angle_t angle; + + // opening / clipping determination + for (i=0 ; i>ANGLETOFINESHIFT; + + // scale will be unit scale at SCREENWIDTH/2 distance + basexscale = FixedDiv (finecosine[angle],centerxfrac); + baseyscale = -FixedDiv (finesine[angle],centerxfrac); +} + + + + +// +// R_FindPlane +// +visplane_t* R_FindPlane ( fixed_t height, int picnum, int lightlevel ) +{ + visplane_t* check; + + if (picnum == skyflatnum) + { + height = 0; // all skys map together + lightlevel = 0; + } + + for (check=visplanes; checkheight + && picnum == check->picnum + && lightlevel == check->lightlevel) + { + break; + } + } + + + if (check < lastvisplane) + return check; + + if (total_visplanes >= MAXVISPLANES) + throw overflow_exception(); // I_Error ("R_FindPlane: no more visplanes"); + + total_visplanes++; + lastvisplane++; + + check->height = height; + check->picnum = picnum; + check->lightlevel = lightlevel; + check->minx = SCREENWIDTH; + check->maxx = -1; + + memset (check->top,0xff,sizeof(check->top)); + + return check; +} + + +// +// R_CheckPlane +// +visplane_t* R_CheckPlane ( visplane_t* pl, int start, int stop ) +{ + int intrl; + int intrh; + int unionl; + int unionh; + int x; + + if (start < pl->minx) + { + intrl = pl->minx; + unionl = start; + } + else + { + unionl = pl->minx; + intrl = start; + } + + if (stop > pl->maxx) + { + intrh = pl->maxx; + unionh = stop; + } + else + { + unionh = pl->maxx; + intrh = stop; + } + + for (x=intrl ; x<= intrh ; x++) + if (pl->top[x] != 0xff) + break; + + if (x > intrh) + { + pl->minx = unionl; + pl->maxx = unionh; + + // use the same one + return pl; + } + + // make a new visplane + lastvisplane->height = pl->height; + lastvisplane->picnum = pl->picnum; + lastvisplane->lightlevel = pl->lightlevel; + + if (total_visplanes >= MAXVISPLANES) + throw overflow_exception(); // I_Error ("R_FindPlane: no more visplanes"); + + total_visplanes++; + + pl = lastvisplane++; + pl->minx = start; + pl->maxx = stop; + + memset (pl->top,0xff,sizeof(pl->top)); + + return pl; +} + + +#if 0 +// +// R_MakeSpans +// +void R_MakeSpans ( int x, int t1, int b1, int t2, int b2 ) +{ + while (t1 < t2 && t1<=b1) + { + R_MapPlane (t1,spanstart[t1],x-1); + t1++; + } + while (b1 > b2 && b1>=t1) + { + R_MapPlane (b1,spanstart[b1],x-1); + b1--; + } + + while (t2 < t1 && t2<=b2) + { + spanstart[t2] = x; + t2++; + } + while (b2 > b1 && b2>=t2) + { + spanstart[b2] = x; + b2--; + } +} +#endif + + + +#if 0 + was: R_DrawPlanes() + + + if (ds_p - drawsegs > MAXDRAWSEGS) + I_Error ("R_DrawPlanes: drawsegs overflow (%i)", + ds_p - drawsegs); + + if (lastvisplane - visplanes > MAXVISPLANES) + I_Error ("R_DrawPlanes: visplane overflow (%i)", + lastvisplane - visplanes); + + if (lastopening - openings > MAXOPENINGS) + I_Error ("R_DrawPlanes: opening overflow (%i)", + lastopening - openings); +#endif + + +} // namespace vpo + diff --git a/Source/Plugins/vpo_dll/r_plane.h b/Source/Plugins/vpo_dll/r_plane.h index 5634d027..4543a5b5 100644 --- a/Source/Plugins/vpo_dll/r_plane.h +++ b/Source/Plugins/vpo_dll/r_plane.h @@ -1,64 +1,64 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Refresh, visplane stuff (floor, ceilings). -// -//----------------------------------------------------------------------------- - -#ifndef __R_PLANE__ -#define __R_PLANE__ - - -// Visplane related. -extern short * lastopening; - - -typedef void (*planefunction_t) (int top, int bottom); - -extern short floorclip[SCREENWIDTH]; -extern short ceilingclip[SCREENWIDTH]; - -extern fixed_t yslope[SCREENHEIGHT]; -extern fixed_t distscale[SCREENWIDTH]; - -void R_ClearPlanes (void); - -void R_MapPlane ( int y, int x1, int x2 ); -void R_MakeSpans ( int x, int t1, int b1, int t2, int b2 ); -void R_DrawPlanes (void); - -visplane_t* R_FindPlane ( fixed_t height, int picnum, int lightlevel ); -visplane_t* R_CheckPlane ( visplane_t* pl, int start, int stop ); - -// #define MAXVISPLANES 128 -#define MAXVISPLANES 512 // andrewj: increased for Visplane Explorer - -// #define MAXOPENINGS SCREENWIDTH*64 -#define MAXOPENINGS SCREENWIDTH*256 // andrewj: increased for Visplane Explorer - -extern int total_visplanes; -extern int total_drawsegs; -extern int total_openings; -extern int max_solidsegs; - - -#endif +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// Refresh, visplane stuff (floor, ceilings). +// +//----------------------------------------------------------------------------- + +#ifndef __R_PLANE__ +#define __R_PLANE__ + + +// Visplane related. +extern short * lastopening; + + +typedef void (*planefunction_t) (int top, int bottom); + +extern short floorclip[SCREENWIDTH]; +extern short ceilingclip[SCREENWIDTH]; + +extern fixed_t yslope[SCREENHEIGHT]; +extern fixed_t distscale[SCREENWIDTH]; + +void R_ClearPlanes (void); + +void R_MapPlane ( int y, int x1, int x2 ); +void R_MakeSpans ( int x, int t1, int b1, int t2, int b2 ); +void R_DrawPlanes (void); + +visplane_t* R_FindPlane ( fixed_t height, int picnum, int lightlevel ); +visplane_t* R_CheckPlane ( visplane_t* pl, int start, int stop ); + +// #define MAXVISPLANES 128 +#define MAXVISPLANES 512 // andrewj: increased for Visplane Explorer + +// #define MAXOPENINGS SCREENWIDTH*64 +#define MAXOPENINGS SCREENWIDTH*256 // andrewj: increased for Visplane Explorer + +extern int total_visplanes; +extern int total_drawsegs; +extern int total_openings; +extern int max_solidsegs; + + +#endif diff --git a/Source/Plugins/vpo_dll/r_segs.cc b/Source/Plugins/vpo_dll/r_segs.cc index c38816e6..ff22dc7c 100644 --- a/Source/Plugins/vpo_dll/r_segs.cc +++ b/Source/Plugins/vpo_dll/r_segs.cc @@ -1,622 +1,622 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// All the clipping: columns, horizontal spans, sky columns. -// -//----------------------------------------------------------------------------- - -#include "vpo_local.h" - -namespace vpo -{ - - -// OPTIMIZE: closed two sided lines as single sided - -// True if any of the segs textures might be visible. -boolean segtextured; - -// False if the back side is the same plane. -boolean markfloor; -boolean markceiling; - -boolean maskedtexture; -int toptexture; -int bottomtexture; -int midtexture; - - -angle_t rw_normalangle; -// angle to line origin -int rw_angle1; - -// -// regular wall -// -int rw_x; -int rw_stopx; -angle_t rw_centerangle; -fixed_t rw_offset; -fixed_t rw_distance; -fixed_t rw_scale; -fixed_t rw_scalestep; -fixed_t rw_midtexturemid; -fixed_t rw_toptexturemid; -fixed_t rw_bottomtexturemid; - -int worldtop; -int worldbottom; -int worldhigh; -int worldlow; - -fixed_t pixhigh; -fixed_t pixlow; -fixed_t pixhighstep; -fixed_t pixlowstep; - -fixed_t topfrac; -fixed_t topstep; - -fixed_t bottomfrac; -fixed_t bottomstep; - - -short* maskedtexturecol; - - -// R_DRAW bits -int dc_x; -int dc_yl; -int dc_yh; -fixed_t dc_iscale; -fixed_t dc_texturemid; - - -// -// R_RenderSegLoop -// Draws zero, one, or two textures (and possibly a masked -// texture) for walls. -// Can draw or mark the starting pixel of floor and ceiling -// textures. -// CALLED: CORE LOOPING ROUTINE. -// -#define HEIGHTBITS 12 -#define HEIGHTUNIT (1<>HEIGHTBITS; - - // no space above wall? - if (yl < ceilingclip[rw_x]+1) - yl = ceilingclip[rw_x]+1; - - if (markceiling) - { - top = ceilingclip[rw_x]+1; - bottom = yl-1; - - if (bottom >= floorclip[rw_x]) - bottom = floorclip[rw_x]-1; - - if (top <= bottom) - { - ceilingplane->top[rw_x] = top; - ceilingplane->bottom[rw_x] = bottom; - } - } - - yh = bottomfrac>>HEIGHTBITS; - - if (yh >= floorclip[rw_x]) - yh = floorclip[rw_x]-1; - - if (markfloor) - { - top = yh+1; - bottom = floorclip[rw_x]-1; - if (top <= ceilingclip[rw_x]) - top = ceilingclip[rw_x]+1; - if (top <= bottom) - { - floorplane->top[rw_x] = top; - floorplane->bottom[rw_x] = bottom; - } - } - - // texturecolumn and lighting are independent of wall tiers - if (segtextured) - { - // calculate texture offset - angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT; - texturecolumn = rw_offset-FixedMul(finetangent[angle],rw_distance); - texturecolumn >>= FRACBITS; - - dc_x = rw_x; - dc_iscale = 0xffffffffu / (unsigned)rw_scale; - } - else - { - // purely to shut up the compiler - - texturecolumn = 0; - } - - // draw the wall tiers - if (midtexture) - { - // single sided line - dc_yl = yl; - dc_yh = yh; - dc_texturemid = rw_midtexturemid; - ///--- dc_source = R_GetColumn(midtexture,texturecolumn); - ///--- colfunc (); - ceilingclip[rw_x] = viewheight; - floorclip[rw_x] = -1; - } - else - { - // two sided line - if (toptexture) - { - // top wall - mid = pixhigh>>HEIGHTBITS; - pixhigh += pixhighstep; - - if (mid >= floorclip[rw_x]) - mid = floorclip[rw_x]-1; - - if (mid >= yl) - { - dc_yl = yl; - dc_yh = mid; - dc_texturemid = rw_toptexturemid; - ///--- dc_source = R_GetColumn(toptexture,texturecolumn); - ///--- colfunc (); - ceilingclip[rw_x] = mid; - } - else - ceilingclip[rw_x] = yl-1; - } - else - { - // no top wall - if (markceiling) - ceilingclip[rw_x] = yl-1; - } - - if (bottomtexture) - { - // bottom wall - mid = (pixlow+HEIGHTUNIT-1)>>HEIGHTBITS; - pixlow += pixlowstep; - - // no space above wall? - if (mid <= ceilingclip[rw_x]) - mid = ceilingclip[rw_x]+1; - - if (mid <= yh) - { - dc_yl = mid; - dc_yh = yh; - dc_texturemid = rw_bottomtexturemid; -///--- dc_source = R_GetColumn(bottomtexture, texturecolumn); -///--- colfunc (); - floorclip[rw_x] = mid; - } - else - floorclip[rw_x] = yh+1; - } - else - { - // no bottom wall - if (markfloor) - floorclip[rw_x] = yh+1; - } - - if (maskedtexture) - { - // save texturecol - // for backdrawing of masked mid texture - maskedtexturecol[rw_x] = texturecolumn; - } - } - - rw_scale += rw_scalestep; - topfrac += topstep; - bottomfrac += bottomstep; - } -} - - - - -// -// R_StoreWallRange -// A wall segment will be drawn -// between start and stop pixels (inclusive). -// -void R_StoreWallRange ( int start, int stop ) -{ - fixed_t hyp; - fixed_t sineval; - angle_t distangle, offsetangle; - fixed_t vtop; - - // don't overflow and crash - total_drawsegs++; - - if (total_drawsegs >= MAXDRAWSEGS) - throw overflow_exception(); - -#ifdef RANGECHECK - if (start >=viewwidth || start > stop) - I_Error ("Bad R_RenderWallRange: %i to %i", start , stop); -#endif - - sidedef = curline->sidedef; - linedef = curline->linedef; - - // mark the segment as visible for auto map - linedef->flags |= ML_MAPPED; - - // calculate rw_distance for scale calculation - rw_normalangle = curline->angle + ANG90; - offsetangle = abs((int)rw_normalangle-rw_angle1); - - if (offsetangle > ANG90) - offsetangle = ANG90; - - distangle = ANG90 - offsetangle; - hyp = R_PointToDist (curline->v1->x, curline->v1->y); - sineval = finesine[distangle>>ANGLETOFINESHIFT]; - rw_distance = FixedMul (hyp, sineval); - - - ds_p->x1 = rw_x = start; - ds_p->x2 = stop; - ds_p->curline = curline; - rw_stopx = stop+1; - - // calculate scale at both ends and step - ds_p->scale1 = rw_scale = - R_ScaleFromGlobalAngle (viewangle + xtoviewangle[start]); - - if (stop > start ) - { - ds_p->scale2 = R_ScaleFromGlobalAngle (viewangle + xtoviewangle[stop]); - ds_p->scalestep = rw_scalestep = - (ds_p->scale2 - rw_scale) / (stop-start); - } - else - { - ds_p->scale2 = ds_p->scale1; - } - - // calculate texture boundaries - // and decide if floor / ceiling marks are needed - worldtop = frontsector->ceilingheight - viewz; - worldbottom = frontsector->floorheight - viewz; - - midtexture = toptexture = bottomtexture = maskedtexture = 0; - ds_p->maskedtexturecol = NULL; - - if (!backsector) - { - // single sided line - midtexture = sidedef->midtexture; - // a single sided line is terminal, so it must mark ends - markfloor = markceiling = true; - if (linedef->flags & ML_DONTPEGBOTTOM) - { - vtop = frontsector->floorheight - + 128; ///??? textureheight[sidedef->midtexture]; - // bottom of texture at bottom - rw_midtexturemid = vtop - viewz; - } - else - { - // top of texture at top - rw_midtexturemid = worldtop; - } - rw_midtexturemid += sidedef->rowoffset; - - ds_p->silhouette = SIL_BOTH; - ds_p->sprtopclip = screenheightarray; - ds_p->sprbottomclip = negonearray; - ds_p->bsilheight = INT_MAX; - ds_p->tsilheight = INT_MIN; - } - else - { - // two sided line - ds_p->sprtopclip = ds_p->sprbottomclip = NULL; - ds_p->silhouette = 0; - - if (frontsector->floorheight > backsector->floorheight) - { - ds_p->silhouette = SIL_BOTTOM; - ds_p->bsilheight = frontsector->floorheight; - } - else if (backsector->floorheight > viewz) - { - ds_p->silhouette = SIL_BOTTOM; - ds_p->bsilheight = INT_MAX; - // ds_p->sprbottomclip = negonearray; - } - - if (frontsector->ceilingheight < backsector->ceilingheight) - { - ds_p->silhouette |= SIL_TOP; - ds_p->tsilheight = frontsector->ceilingheight; - } - else if (backsector->ceilingheight < viewz) - { - ds_p->silhouette |= SIL_TOP; - ds_p->tsilheight = INT_MIN; - // ds_p->sprtopclip = screenheightarray; - } - - if (backsector->ceilingheight <= frontsector->floorheight) - { - ds_p->sprbottomclip = negonearray; - ds_p->bsilheight = INT_MAX; - ds_p->silhouette |= SIL_BOTTOM; - } - - if (backsector->floorheight >= frontsector->ceilingheight) - { - ds_p->sprtopclip = screenheightarray; - ds_p->tsilheight = INT_MIN; - ds_p->silhouette |= SIL_TOP; - } - - worldhigh = backsector->ceilingheight - viewz; - worldlow = backsector->floorheight - viewz; - - // hack to allow height changes in outdoor areas - if (frontsector->ceilingpic == skyflatnum - && backsector->ceilingpic == skyflatnum) - { - worldtop = worldhigh; - } - - - if (worldlow != worldbottom - || backsector->floorpic != frontsector->floorpic - || backsector->lightlevel != frontsector->lightlevel) - { - markfloor = true; - } - else - { - // same plane on both sides - markfloor = false; - } - - - if (worldhigh != worldtop - || backsector->ceilingpic != frontsector->ceilingpic - || backsector->lightlevel != frontsector->lightlevel) - { - markceiling = true; - } - else - { - // same plane on both sides - markceiling = false; - } - - if (backsector->ceilingheight <= frontsector->floorheight - || backsector->floorheight >= frontsector->ceilingheight) - { - // closed door - markceiling = markfloor = true; - } - - - if (worldhigh < worldtop) - { - // top texture - toptexture = sidedef->toptexture; - if (linedef->flags & ML_DONTPEGTOP) - { - // top of texture at top - rw_toptexturemid = worldtop; - } - else - { - vtop = backsector->ceilingheight - + 128; ///??? textureheight[sidedef->toptexture]; - - // bottom of texture - rw_toptexturemid = vtop - viewz; - } - } - if (worldlow > worldbottom) - { - // bottom texture - bottomtexture = sidedef->bottomtexture; - - if (linedef->flags & ML_DONTPEGBOTTOM ) - { - // bottom of texture at bottom - // top of texture at top - rw_bottomtexturemid = worldtop; - } - else // top of texture at top - rw_bottomtexturemid = worldlow; - } - rw_toptexturemid += sidedef->rowoffset; - rw_bottomtexturemid += sidedef->rowoffset; - - // allocate space for masked texture tables - if (sidedef->midtexture) - { - // masked midtexture - maskedtexture = true; - ds_p->maskedtexturecol = maskedtexturecol = lastopening - rw_x; - lastopening += rw_stopx - rw_x; - total_openings += (rw_stopx - rw_x); - - if (total_openings >= MAXOPENINGS) - throw overflow_exception(); - } - } - - // calculate rw_offset (only needed for textured lines) - segtextured = midtexture | toptexture | bottomtexture | maskedtexture; - - if (segtextured) - { - offsetangle = rw_normalangle-rw_angle1; - - if (offsetangle > ANG180) - offsetangle = -offsetangle; - - if (offsetangle > ANG90) - offsetangle = ANG90; - - sineval = finesine[offsetangle >>ANGLETOFINESHIFT]; - rw_offset = FixedMul (hyp, sineval); - - if (rw_normalangle-rw_angle1 < ANG180) - rw_offset = -rw_offset; - - rw_offset += sidedef->textureoffset + curline->offset; - rw_centerangle = ANG90 + viewangle - rw_normalangle; - - } - - // if a floor / ceiling plane is on the wrong side - // of the view plane, it is definitely invisible - // and doesn't need to be marked. - - - if (frontsector->floorheight >= viewz) - { - // above view plane - markfloor = false; - } - - if (frontsector->ceilingheight <= viewz - && frontsector->ceilingpic != skyflatnum) - { - // below view plane - markceiling = false; - } - - - // calculate incremental stepping values for texture edges - worldtop >>= 4; - worldbottom >>= 4; - - topstep = -FixedMul (rw_scalestep, worldtop); - topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale); - - bottomstep = -FixedMul (rw_scalestep,worldbottom); - bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); - - if (backsector) - { - worldhigh >>= 4; - worldlow >>= 4; - - if (worldhigh < worldtop) - { - pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale); - pixhighstep = -FixedMul (rw_scalestep,worldhigh); - } - - if (worldlow > worldbottom) - { - pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale); - pixlowstep = -FixedMul (rw_scalestep,worldlow); - } - } - - // andrewj: make sure floorplane/ceilingplane are not NULL (prevent a crash) - if (! floorplane) markfloor = false; - if (! ceilingplane) markceiling = false; - - // render it - if (markceiling) - ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1); - - if (markfloor) - floorplane = R_CheckPlane (floorplane, rw_x, rw_stopx-1); - - R_RenderSegLoop (); - - - // save sprite clipping info - if ( ((ds_p->silhouette & SIL_TOP) || maskedtexture) - && !ds_p->sprtopclip) - { - memcpy (lastopening, ceilingclip+start, 2*(rw_stopx-start)); - ds_p->sprtopclip = lastopening - start; - lastopening += rw_stopx - start; - total_openings += (rw_stopx - start); - - if (total_openings >= MAXOPENINGS) - throw overflow_exception(); - } - - if ( ((ds_p->silhouette & SIL_BOTTOM) || maskedtexture) - && !ds_p->sprbottomclip) - { - memcpy (lastopening, floorclip+start, 2*(rw_stopx-start)); - ds_p->sprbottomclip = lastopening - start; - lastopening += rw_stopx - start; - total_openings += (rw_stopx - start); - - if (total_openings >= MAXOPENINGS) - throw overflow_exception(); - } - - if (maskedtexture && !(ds_p->silhouette&SIL_TOP)) - { - ds_p->silhouette |= SIL_TOP; - ds_p->tsilheight = INT_MIN; - } - if (maskedtexture && !(ds_p->silhouette&SIL_BOTTOM)) - { - ds_p->silhouette |= SIL_BOTTOM; - ds_p->bsilheight = INT_MAX; - } - ds_p++; -} - - -} // namespace vpo - +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// All the clipping: columns, horizontal spans, sky columns. +// +//----------------------------------------------------------------------------- + +#include "vpo_local.h" + +namespace vpo +{ + + +// OPTIMIZE: closed two sided lines as single sided + +// True if any of the segs textures might be visible. +boolean segtextured; + +// False if the back side is the same plane. +boolean markfloor; +boolean markceiling; + +boolean maskedtexture; +int toptexture; +int bottomtexture; +int midtexture; + + +angle_t rw_normalangle; +// angle to line origin +int rw_angle1; + +// +// regular wall +// +int rw_x; +int rw_stopx; +angle_t rw_centerangle; +fixed_t rw_offset; +fixed_t rw_distance; +fixed_t rw_scale; +fixed_t rw_scalestep; +fixed_t rw_midtexturemid; +fixed_t rw_toptexturemid; +fixed_t rw_bottomtexturemid; + +int worldtop; +int worldbottom; +int worldhigh; +int worldlow; + +fixed_t pixhigh; +fixed_t pixlow; +fixed_t pixhighstep; +fixed_t pixlowstep; + +fixed_t topfrac; +fixed_t topstep; + +fixed_t bottomfrac; +fixed_t bottomstep; + + +short* maskedtexturecol; + + +// R_DRAW bits +int dc_x; +int dc_yl; +int dc_yh; +fixed_t dc_iscale; +fixed_t dc_texturemid; + + +// +// R_RenderSegLoop +// Draws zero, one, or two textures (and possibly a masked +// texture) for walls. +// Can draw or mark the starting pixel of floor and ceiling +// textures. +// CALLED: CORE LOOPING ROUTINE. +// +#define HEIGHTBITS 12 +#define HEIGHTUNIT (1<>HEIGHTBITS; + + // no space above wall? + if (yl < ceilingclip[rw_x]+1) + yl = ceilingclip[rw_x]+1; + + if (markceiling) + { + top = ceilingclip[rw_x]+1; + bottom = yl-1; + + if (bottom >= floorclip[rw_x]) + bottom = floorclip[rw_x]-1; + + if (top <= bottom) + { + ceilingplane->top[rw_x] = top; + ceilingplane->bottom[rw_x] = bottom; + } + } + + yh = bottomfrac>>HEIGHTBITS; + + if (yh >= floorclip[rw_x]) + yh = floorclip[rw_x]-1; + + if (markfloor) + { + top = yh+1; + bottom = floorclip[rw_x]-1; + if (top <= ceilingclip[rw_x]) + top = ceilingclip[rw_x]+1; + if (top <= bottom) + { + floorplane->top[rw_x] = top; + floorplane->bottom[rw_x] = bottom; + } + } + + // texturecolumn and lighting are independent of wall tiers + if (segtextured) + { + // calculate texture offset + angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT; + texturecolumn = rw_offset-FixedMul(finetangent[angle],rw_distance); + texturecolumn >>= FRACBITS; + + dc_x = rw_x; + dc_iscale = 0xffffffffu / (unsigned)rw_scale; + } + else + { + // purely to shut up the compiler + + texturecolumn = 0; + } + + // draw the wall tiers + if (midtexture) + { + // single sided line + dc_yl = yl; + dc_yh = yh; + dc_texturemid = rw_midtexturemid; + ///--- dc_source = R_GetColumn(midtexture,texturecolumn); + ///--- colfunc (); + ceilingclip[rw_x] = viewheight; + floorclip[rw_x] = -1; + } + else + { + // two sided line + if (toptexture) + { + // top wall + mid = pixhigh>>HEIGHTBITS; + pixhigh += pixhighstep; + + if (mid >= floorclip[rw_x]) + mid = floorclip[rw_x]-1; + + if (mid >= yl) + { + dc_yl = yl; + dc_yh = mid; + dc_texturemid = rw_toptexturemid; + ///--- dc_source = R_GetColumn(toptexture,texturecolumn); + ///--- colfunc (); + ceilingclip[rw_x] = mid; + } + else + ceilingclip[rw_x] = yl-1; + } + else + { + // no top wall + if (markceiling) + ceilingclip[rw_x] = yl-1; + } + + if (bottomtexture) + { + // bottom wall + mid = (pixlow+HEIGHTUNIT-1)>>HEIGHTBITS; + pixlow += pixlowstep; + + // no space above wall? + if (mid <= ceilingclip[rw_x]) + mid = ceilingclip[rw_x]+1; + + if (mid <= yh) + { + dc_yl = mid; + dc_yh = yh; + dc_texturemid = rw_bottomtexturemid; +///--- dc_source = R_GetColumn(bottomtexture, texturecolumn); +///--- colfunc (); + floorclip[rw_x] = mid; + } + else + floorclip[rw_x] = yh+1; + } + else + { + // no bottom wall + if (markfloor) + floorclip[rw_x] = yh+1; + } + + if (maskedtexture) + { + // save texturecol + // for backdrawing of masked mid texture + maskedtexturecol[rw_x] = texturecolumn; + } + } + + rw_scale += rw_scalestep; + topfrac += topstep; + bottomfrac += bottomstep; + } +} + + + + +// +// R_StoreWallRange +// A wall segment will be drawn +// between start and stop pixels (inclusive). +// +void R_StoreWallRange ( int start, int stop ) +{ + fixed_t hyp; + fixed_t sineval; + angle_t distangle, offsetangle; + fixed_t vtop; + + // don't overflow and crash + total_drawsegs++; + + if (total_drawsegs >= MAXDRAWSEGS) + throw overflow_exception(); + +#ifdef RANGECHECK + if (start >=viewwidth || start > stop) + I_Error ("Bad R_RenderWallRange: %i to %i", start , stop); +#endif + + sidedef = curline->sidedef; + linedef = curline->linedef; + + // mark the segment as visible for auto map + linedef->flags |= ML_MAPPED; + + // calculate rw_distance for scale calculation + rw_normalangle = curline->angle + ANG90; + offsetangle = abs((int)rw_normalangle-rw_angle1); + + if (offsetangle > ANG90) + offsetangle = ANG90; + + distangle = ANG90 - offsetangle; + hyp = R_PointToDist (curline->v1->x, curline->v1->y); + sineval = finesine[distangle>>ANGLETOFINESHIFT]; + rw_distance = FixedMul (hyp, sineval); + + + ds_p->x1 = rw_x = start; + ds_p->x2 = stop; + ds_p->curline = curline; + rw_stopx = stop+1; + + // calculate scale at both ends and step + ds_p->scale1 = rw_scale = + R_ScaleFromGlobalAngle (viewangle + xtoviewangle[start]); + + if (stop > start ) + { + ds_p->scale2 = R_ScaleFromGlobalAngle (viewangle + xtoviewangle[stop]); + ds_p->scalestep = rw_scalestep = + (ds_p->scale2 - rw_scale) / (stop-start); + } + else + { + ds_p->scale2 = ds_p->scale1; + } + + // calculate texture boundaries + // and decide if floor / ceiling marks are needed + worldtop = frontsector->ceilingheight - viewz; + worldbottom = frontsector->floorheight - viewz; + + midtexture = toptexture = bottomtexture = maskedtexture = 0; + ds_p->maskedtexturecol = NULL; + + if (!backsector) + { + // single sided line + midtexture = sidedef->midtexture; + // a single sided line is terminal, so it must mark ends + markfloor = markceiling = true; + if (linedef->flags & ML_DONTPEGBOTTOM) + { + vtop = frontsector->floorheight + + 128; ///??? textureheight[sidedef->midtexture]; + // bottom of texture at bottom + rw_midtexturemid = vtop - viewz; + } + else + { + // top of texture at top + rw_midtexturemid = worldtop; + } + rw_midtexturemid += sidedef->rowoffset; + + ds_p->silhouette = SIL_BOTH; + ds_p->sprtopclip = screenheightarray; + ds_p->sprbottomclip = negonearray; + ds_p->bsilheight = INT_MAX; + ds_p->tsilheight = INT_MIN; + } + else + { + // two sided line + ds_p->sprtopclip = ds_p->sprbottomclip = NULL; + ds_p->silhouette = 0; + + if (frontsector->floorheight > backsector->floorheight) + { + ds_p->silhouette = SIL_BOTTOM; + ds_p->bsilheight = frontsector->floorheight; + } + else if (backsector->floorheight > viewz) + { + ds_p->silhouette = SIL_BOTTOM; + ds_p->bsilheight = INT_MAX; + // ds_p->sprbottomclip = negonearray; + } + + if (frontsector->ceilingheight < backsector->ceilingheight) + { + ds_p->silhouette |= SIL_TOP; + ds_p->tsilheight = frontsector->ceilingheight; + } + else if (backsector->ceilingheight < viewz) + { + ds_p->silhouette |= SIL_TOP; + ds_p->tsilheight = INT_MIN; + // ds_p->sprtopclip = screenheightarray; + } + + if (backsector->ceilingheight <= frontsector->floorheight) + { + ds_p->sprbottomclip = negonearray; + ds_p->bsilheight = INT_MAX; + ds_p->silhouette |= SIL_BOTTOM; + } + + if (backsector->floorheight >= frontsector->ceilingheight) + { + ds_p->sprtopclip = screenheightarray; + ds_p->tsilheight = INT_MIN; + ds_p->silhouette |= SIL_TOP; + } + + worldhigh = backsector->ceilingheight - viewz; + worldlow = backsector->floorheight - viewz; + + // hack to allow height changes in outdoor areas + if (frontsector->ceilingpic == skyflatnum + && backsector->ceilingpic == skyflatnum) + { + worldtop = worldhigh; + } + + + if (worldlow != worldbottom + || backsector->floorpic != frontsector->floorpic + || backsector->lightlevel != frontsector->lightlevel) + { + markfloor = true; + } + else + { + // same plane on both sides + markfloor = false; + } + + + if (worldhigh != worldtop + || backsector->ceilingpic != frontsector->ceilingpic + || backsector->lightlevel != frontsector->lightlevel) + { + markceiling = true; + } + else + { + // same plane on both sides + markceiling = false; + } + + if (backsector->ceilingheight <= frontsector->floorheight + || backsector->floorheight >= frontsector->ceilingheight) + { + // closed door + markceiling = markfloor = true; + } + + + if (worldhigh < worldtop) + { + // top texture + toptexture = sidedef->toptexture; + if (linedef->flags & ML_DONTPEGTOP) + { + // top of texture at top + rw_toptexturemid = worldtop; + } + else + { + vtop = backsector->ceilingheight + + 128; ///??? textureheight[sidedef->toptexture]; + + // bottom of texture + rw_toptexturemid = vtop - viewz; + } + } + if (worldlow > worldbottom) + { + // bottom texture + bottomtexture = sidedef->bottomtexture; + + if (linedef->flags & ML_DONTPEGBOTTOM ) + { + // bottom of texture at bottom + // top of texture at top + rw_bottomtexturemid = worldtop; + } + else // top of texture at top + rw_bottomtexturemid = worldlow; + } + rw_toptexturemid += sidedef->rowoffset; + rw_bottomtexturemid += sidedef->rowoffset; + + // allocate space for masked texture tables + if (sidedef->midtexture) + { + // masked midtexture + maskedtexture = true; + ds_p->maskedtexturecol = maskedtexturecol = lastopening - rw_x; + lastopening += rw_stopx - rw_x; + total_openings += (rw_stopx - rw_x); + + if (total_openings >= MAXOPENINGS) + throw overflow_exception(); + } + } + + // calculate rw_offset (only needed for textured lines) + segtextured = midtexture | toptexture | bottomtexture | maskedtexture; + + if (segtextured) + { + offsetangle = rw_normalangle-rw_angle1; + + if (offsetangle > ANG180) + offsetangle = -offsetangle; + + if (offsetangle > ANG90) + offsetangle = ANG90; + + sineval = finesine[offsetangle >>ANGLETOFINESHIFT]; + rw_offset = FixedMul (hyp, sineval); + + if (rw_normalangle-rw_angle1 < ANG180) + rw_offset = -rw_offset; + + rw_offset += sidedef->textureoffset + curline->offset; + rw_centerangle = ANG90 + viewangle - rw_normalangle; + + } + + // if a floor / ceiling plane is on the wrong side + // of the view plane, it is definitely invisible + // and doesn't need to be marked. + + + if (frontsector->floorheight >= viewz) + { + // above view plane + markfloor = false; + } + + if (frontsector->ceilingheight <= viewz + && frontsector->ceilingpic != skyflatnum) + { + // below view plane + markceiling = false; + } + + + // calculate incremental stepping values for texture edges + worldtop >>= 4; + worldbottom >>= 4; + + topstep = -FixedMul (rw_scalestep, worldtop); + topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale); + + bottomstep = -FixedMul (rw_scalestep,worldbottom); + bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); + + if (backsector) + { + worldhigh >>= 4; + worldlow >>= 4; + + if (worldhigh < worldtop) + { + pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale); + pixhighstep = -FixedMul (rw_scalestep,worldhigh); + } + + if (worldlow > worldbottom) + { + pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale); + pixlowstep = -FixedMul (rw_scalestep,worldlow); + } + } + + // andrewj: make sure floorplane/ceilingplane are not NULL (prevent a crash) + if (! floorplane) markfloor = false; + if (! ceilingplane) markceiling = false; + + // render it + if (markceiling) + ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1); + + if (markfloor) + floorplane = R_CheckPlane (floorplane, rw_x, rw_stopx-1); + + R_RenderSegLoop (); + + + // save sprite clipping info + if ( ((ds_p->silhouette & SIL_TOP) || maskedtexture) + && !ds_p->sprtopclip) + { + memcpy (lastopening, ceilingclip+start, 2*(rw_stopx-start)); + ds_p->sprtopclip = lastopening - start; + lastopening += rw_stopx - start; + total_openings += (rw_stopx - start); + + if (total_openings >= MAXOPENINGS) + throw overflow_exception(); + } + + if ( ((ds_p->silhouette & SIL_BOTTOM) || maskedtexture) + && !ds_p->sprbottomclip) + { + memcpy (lastopening, floorclip+start, 2*(rw_stopx-start)); + ds_p->sprbottomclip = lastopening - start; + lastopening += rw_stopx - start; + total_openings += (rw_stopx - start); + + if (total_openings >= MAXOPENINGS) + throw overflow_exception(); + } + + if (maskedtexture && !(ds_p->silhouette&SIL_TOP)) + { + ds_p->silhouette |= SIL_TOP; + ds_p->tsilheight = INT_MIN; + } + if (maskedtexture && !(ds_p->silhouette&SIL_BOTTOM)) + { + ds_p->silhouette |= SIL_BOTTOM; + ds_p->bsilheight = INT_MAX; + } + ds_p++; +} + + +} // namespace vpo + diff --git a/Source/Plugins/vpo_dll/r_state.h b/Source/Plugins/vpo_dll/r_state.h index f3dca05e..eb9761dc 100644 --- a/Source/Plugins/vpo_dll/r_state.h +++ b/Source/Plugins/vpo_dll/r_state.h @@ -1,107 +1,107 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Refresh/render internal state variables (global). -// -//----------------------------------------------------------------------------- - - -#ifndef __R_STATE__ -#define __R_STATE__ - - -// -// Refresh internal data structures, -// for rendering. -// - -// needed for pre rendering (fracs) -extern fixed_t* spritewidth; - -extern fixed_t* spriteoffset; -extern fixed_t* spritetopoffset; - -extern int viewwidth; -extern int scaledviewwidth; -extern int viewheight; - -extern int firstflat; - - -// -// Lookup tables for map data. -// -extern int numvertexes; -extern vertex_t* vertexes; - -extern int numsegs; -extern seg_t* segs; - -extern int numsectors; -extern sector_t* sectors; - -extern int numsubsectors; -extern subsector_t* subsectors; - -extern int numnodes; -extern node_t* nodes; - -extern int numlines; -extern line_t* lines; - -extern int numsides; -extern side_t* sides; - - -// -// POV data. -// -extern fixed_t viewx; -extern fixed_t viewy; -extern fixed_t viewz; - -extern angle_t viewangle; - - -// ? -extern angle_t clipangle; - -extern int viewangletox[FINEANGLES/2]; -extern angle_t xtoviewangle[SCREENWIDTH+1]; -//extern fixed_t finetangent[FINEANGLES/2]; - -extern fixed_t rw_distance; -extern angle_t rw_normalangle; - - - -// angle to line origin -extern int rw_angle1; - -// Segs count? -extern int sscount; - -extern visplane_t* floorplane; -extern visplane_t* ceilingplane; - - -#endif +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// Refresh/render internal state variables (global). +// +//----------------------------------------------------------------------------- + + +#ifndef __R_STATE__ +#define __R_STATE__ + + +// +// Refresh internal data structures, +// for rendering. +// + +// needed for pre rendering (fracs) +extern fixed_t* spritewidth; + +extern fixed_t* spriteoffset; +extern fixed_t* spritetopoffset; + +extern int viewwidth; +extern int scaledviewwidth; +extern int viewheight; + +extern int firstflat; + + +// +// Lookup tables for map data. +// +extern int numvertexes; +extern vertex_t* vertexes; + +extern int numsegs; +extern seg_t* segs; + +extern int numsectors; +extern sector_t* sectors; + +extern int numsubsectors; +extern subsector_t* subsectors; + +extern int numnodes; +extern node_t* nodes; + +extern int numlines; +extern line_t* lines; + +extern int numsides; +extern side_t* sides; + + +// +// POV data. +// +extern fixed_t viewx; +extern fixed_t viewy; +extern fixed_t viewz; + +extern angle_t viewangle; + + +// ? +extern angle_t clipangle; + +extern int viewangletox[FINEANGLES/2]; +extern angle_t xtoviewangle[SCREENWIDTH+1]; +//extern fixed_t finetangent[FINEANGLES/2]; + +extern fixed_t rw_distance; +extern angle_t rw_normalangle; + + + +// angle to line origin +extern int rw_angle1; + +// Segs count? +extern int sscount; + +extern visplane_t* floorplane; +extern visplane_t* ceilingplane; + + +#endif diff --git a/Source/Plugins/vpo_dll/tables.cc b/Source/Plugins/vpo_dll/tables.cc index 43f90b46..a6a83cdb 100644 --- a/Source/Plugins/vpo_dll/tables.cc +++ b/Source/Plugins/vpo_dll/tables.cc @@ -1,2129 +1,2129 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Lookup tables. -// Do not try to look them up :-). -// In the order of appearance: -// -// int finetangent[4096] - Tangens LUT. -// Should work with BAM fairly well (12 of 16bit, -// effectively, by shifting). -// -// int finesine[10240] - Sine lookup. -// Guess what, serves as cosine, too. -// Remarkable thing is, how to use BAMs with this? -// -// int tantoangle[2049] - ArcTan LUT, -// maps tan(angle) to angle fast. Gotta search. -// -// -//----------------------------------------------------------------------------- - -#include "vpo_local.h" - -namespace vpo -{ - - -int -SlopeDiv -( unsigned num, - unsigned den) -{ - unsigned ans; - - if (den < 512) - return SLOPERANGE; - - ans = (num<<3)/(den>>8); - - return ans <= SLOPERANGE ? ans : SLOPERANGE; -} - - -const int finetangent[4096] = -{ - -170910304,-56965752,-34178904,-24413316,-18988036,-15535599,-13145455,-11392683, - -10052327,-8994149,-8137527,-7429880,-6835455,-6329090,-5892567,-5512368, - -5178251,-4882318,-4618375,-4381502,-4167737,-3973855,-3797206,-3635590, - -3487165,-3350381,-3223918,-3106651,-2997613,-2895966,-2800983,-2712030, - -2628549,-2550052,-2476104,-2406322,-2340362,-2277919,-2218719,-2162516, - -2109087,-2058233,-2009771,-1963536,-1919378,-1877161,-1836758,-1798063, - -1760956,-1725348,-1691149,-1658278,-1626658,-1596220,-1566898,-1538632, - -1511367,-1485049,-1459630,-1435065,-1411312,-1388330,-1366084,-1344537, - -1323658,-1303416,-1283783,-1264730,-1246234,-1228269,-1210813,-1193846, - -1177345,-1161294,-1145673,-1130465,-1115654,-1101225,-1087164,-1073455, - -1060087,-1047046,-1034322,-1021901,-1009774,-997931,-986361,-975054, - -964003,-953199,-942633,-932298,-922186,-912289,-902602,-893117, - -883829,-874730,-865817,-857081,-848520,-840127,-831898,-823827, - -815910,-808143,-800521,-793041,-785699,-778490,-771411,-764460, - -757631,-750922,-744331,-737853,-731486,-725227,-719074,-713023, - -707072,-701219,-695462,-689797,-684223,-678737,-673338,-668024, - -662792,-657640,-652568,-647572,-642651,-637803,-633028,-628323, - -623686,-619117,-614613,-610174,-605798,-601483,-597229,-593033, - -588896,-584815,-580789,-576818,-572901,-569035,-565221,-561456, - -557741,-554074,-550455,-546881,-543354,-539870,-536431,-533034, - -529680,-526366,-523094,-519861,-516667,-513512,-510394,-507313, - -504269,-501261,-498287,-495348,-492443,-489571,-486732,-483925, - -481150,-478406,-475692,-473009,-470355,-467730,-465133,-462565, - -460024,-457511,-455024,-452564,-450129,-447720,-445337,-442978, - -440643,-438332,-436045,-433781,-431540,-429321,-427125,-424951, - -422798,-420666,-418555,-416465,-414395,-412344,-410314,-408303, - -406311,-404338,-402384,-400448,-398530,-396630,-394747,-392882, - -391034,-389202,-387387,-385589,-383807,-382040,-380290,-378555, - -376835,-375130,-373440,-371765,-370105,-368459,-366826,-365208, - -363604,-362013,-360436,-358872,-357321,-355783,-354257,-352744, - -351244,-349756,-348280,-346816,-345364,-343924,-342495,-341078, - -339671,-338276,-336892,-335519,-334157,-332805,-331464,-330133, - -328812,-327502,-326201,-324910,-323629,-322358,-321097,-319844, - -318601,-317368,-316143,-314928,-313721,-312524,-311335,-310154, - -308983,-307819,-306664,-305517,-304379,-303248,-302126,-301011, - -299904,-298805,-297714,-296630,-295554,-294485,-293423,-292369, - -291322,-290282,-289249,-288223,-287204,-286192,-285186,-284188, - -283195,-282210,-281231,-280258,-279292,-278332,-277378,-276430, - -275489,-274553,-273624,-272700,-271782,-270871,-269965,-269064, - -268169,-267280,-266397,-265519,-264646,-263779,-262917,-262060, - -261209,-260363,-259522,-258686,-257855,-257029,-256208,-255392, - -254581,-253774,-252973,-252176,-251384,-250596,-249813,-249035, - -248261,-247492,-246727,-245966,-245210,-244458,-243711,-242967, - -242228,-241493,-240763,-240036,-239314,-238595,-237881,-237170, - -236463,-235761,-235062,-234367,-233676,-232988,-232304,-231624, - -230948,-230275,-229606,-228941,-228279,-227621,-226966,-226314, - -225666,-225022,-224381,-223743,-223108,-222477,-221849,-221225, - -220603,-219985,-219370,-218758,-218149,-217544,-216941,-216341, - -215745,-215151,-214561,-213973,-213389,-212807,-212228,-211652, - -211079,-210509,-209941,-209376,-208815,-208255,-207699,-207145, - -206594,-206045,-205500,-204956,-204416,-203878,-203342,-202809, - -202279,-201751,-201226,-200703,-200182,-199664,-199149,-198636, - -198125,-197616,-197110,-196606,-196105,-195606,-195109,-194614, - -194122,-193631,-193143,-192658,-192174,-191693,-191213,-190736, - -190261,-189789,-189318,-188849,-188382,-187918,-187455,-186995, - -186536,-186080,-185625,-185173,-184722,-184274,-183827,-183382, - -182939,-182498,-182059,-181622,-181186,-180753,-180321,-179891, - -179463,-179037,-178612,-178190,-177769,-177349,-176932,-176516, - -176102,-175690,-175279,-174870,-174463,-174057,-173653,-173251, - -172850,-172451,-172053,-171657,-171263,-170870,-170479,-170089, - -169701,-169315,-168930,-168546,-168164,-167784,-167405,-167027, - -166651,-166277,-165904,-165532,-165162,-164793,-164426,-164060, - -163695,-163332,-162970,-162610,-162251,-161893,-161537,-161182, - -160828,-160476,-160125,-159775,-159427,-159079,-158734,-158389, - -158046,-157704,-157363,-157024,-156686,-156349,-156013,-155678, - -155345,-155013,-154682,-154352,-154024,-153697,-153370,-153045, - -152722,-152399,-152077,-151757,-151438,-151120,-150803,-150487, - -150172,-149859,-149546,-149235,-148924,-148615,-148307,-148000, - -147693,-147388,-147084,-146782,-146480,-146179,-145879,-145580, - -145282,-144986,-144690,-144395,-144101,-143808,-143517,-143226, - -142936,-142647,-142359,-142072,-141786,-141501,-141217,-140934, - -140651,-140370,-140090,-139810,-139532,-139254,-138977,-138701, - -138426,-138152,-137879,-137607,-137335,-137065,-136795,-136526, - -136258,-135991,-135725,-135459,-135195,-134931,-134668,-134406, - -134145,-133884,-133625,-133366,-133108,-132851,-132594,-132339, - -132084,-131830,-131576,-131324,-131072,-130821,-130571,-130322, - -130073,-129825,-129578,-129332,-129086,-128841,-128597,-128353, - -128111,-127869,-127627,-127387,-127147,-126908,-126669,-126432, - -126195,-125959,-125723,-125488,-125254,-125020,-124787,-124555, - -124324,-124093,-123863,-123633,-123404,-123176,-122949,-122722, - -122496,-122270,-122045,-121821,-121597,-121374,-121152,-120930, - -120709,-120489,-120269,-120050,-119831,-119613,-119396,-119179, - -118963,-118747,-118532,-118318,-118104,-117891,-117678,-117466, - -117254,-117044,-116833,-116623,-116414,-116206,-115998,-115790, - -115583,-115377,-115171,-114966,-114761,-114557,-114354,-114151, - -113948,-113746,-113545,-113344,-113143,-112944,-112744,-112546, - -112347,-112150,-111952,-111756,-111560,-111364,-111169,-110974, - -110780,-110586,-110393,-110200,-110008,-109817,-109626,-109435, - -109245,-109055,-108866,-108677,-108489,-108301,-108114,-107927, - -107741,-107555,-107369,-107184,-107000,-106816,-106632,-106449, - -106266,-106084,-105902,-105721,-105540,-105360,-105180,-105000, - -104821,-104643,-104465,-104287,-104109,-103933,-103756,-103580, - -103404,-103229,-103054,-102880,-102706,-102533,-102360,-102187, - -102015,-101843,-101671,-101500,-101330,-101159,-100990,-100820, - -100651,-100482,-100314,-100146,-99979,-99812,-99645,-99479, - -99313,-99148,-98982,-98818,-98653,-98489,-98326,-98163, - -98000,-97837,-97675,-97513,-97352,-97191,-97030,-96870, - -96710,-96551,-96391,-96233,-96074,-95916,-95758,-95601, - -95444,-95287,-95131,-94975,-94819,-94664,-94509,-94354, - -94200,-94046,-93892,-93739,-93586,-93434,-93281,-93129, - -92978,-92826,-92675,-92525,-92375,-92225,-92075,-91926, - -91777,-91628,-91480,-91332,-91184,-91036,-90889,-90742, - -90596,-90450,-90304,-90158,-90013,-89868,-89724,-89579, - -89435,-89292,-89148,-89005,-88862,-88720,-88577,-88435, - -88294,-88152,-88011,-87871,-87730,-87590,-87450,-87310, - -87171,-87032,-86893,-86755,-86616,-86479,-86341,-86204, - -86066,-85930,-85793,-85657,-85521,-85385,-85250,-85114, - -84980,-84845,-84710,-84576,-84443,-84309,-84176,-84043, - -83910,-83777,-83645,-83513,-83381,-83250,-83118,-82987, - -82857,-82726,-82596,-82466,-82336,-82207,-82078,-81949, - -81820,-81691,-81563,-81435,-81307,-81180,-81053,-80925, - -80799,-80672,-80546,-80420,-80294,-80168,-80043,-79918, - -79793,-79668,-79544,-79420,-79296,-79172,-79048,-78925, - -78802,-78679,-78557,-78434,-78312,-78190,-78068,-77947, - -77826,-77705,-77584,-77463,-77343,-77223,-77103,-76983, - -76864,-76744,-76625,-76506,-76388,-76269,-76151,-76033, - -75915,-75797,-75680,-75563,-75446,-75329,-75213,-75096, - -74980,-74864,-74748,-74633,-74517,-74402,-74287,-74172, - -74058,-73944,-73829,-73715,-73602,-73488,-73375,-73262, - -73149,-73036,-72923,-72811,-72699,-72587,-72475,-72363, - -72252,-72140,-72029,-71918,-71808,-71697,-71587,-71477, - -71367,-71257,-71147,-71038,-70929,-70820,-70711,-70602, - -70494,-70385,-70277,-70169,-70061,-69954,-69846,-69739, - -69632,-69525,-69418,-69312,-69205,-69099,-68993,-68887, - -68781,-68676,-68570,-68465,-68360,-68255,-68151,-68046, - -67942,-67837,-67733,-67629,-67526,-67422,-67319,-67216, - -67113,-67010,-66907,-66804,-66702,-66600,-66498,-66396, - -66294,-66192,-66091,-65989,-65888,-65787,-65686,-65586, - -65485,-65385,-65285,-65185,-65085,-64985,-64885,-64786, - -64687,-64587,-64488,-64389,-64291,-64192,-64094,-63996, - -63897,-63799,-63702,-63604,-63506,-63409,-63312,-63215, - -63118,-63021,-62924,-62828,-62731,-62635,-62539,-62443, - -62347,-62251,-62156,-62060,-61965,-61870,-61775,-61680, - -61585,-61491,-61396,-61302,-61208,-61114,-61020,-60926, - -60833,-60739,-60646,-60552,-60459,-60366,-60273,-60181, - -60088,-59996,-59903,-59811,-59719,-59627,-59535,-59444, - -59352,-59261,-59169,-59078,-58987,-58896,-58805,-58715, - -58624,-58534,-58443,-58353,-58263,-58173,-58083,-57994, - -57904,-57815,-57725,-57636,-57547,-57458,-57369,-57281, - -57192,-57104,-57015,-56927,-56839,-56751,-56663,-56575, - -56487,-56400,-56312,-56225,-56138,-56051,-55964,-55877, - -55790,-55704,-55617,-55531,-55444,-55358,-55272,-55186, - -55100,-55015,-54929,-54843,-54758,-54673,-54587,-54502, - -54417,-54333,-54248,-54163,-54079,-53994,-53910,-53826, - -53741,-53657,-53574,-53490,-53406,-53322,-53239,-53156, - -53072,-52989,-52906,-52823,-52740,-52657,-52575,-52492, - -52410,-52327,-52245,-52163,-52081,-51999,-51917,-51835, - -51754,-51672,-51591,-51509,-51428,-51347,-51266,-51185, - -51104,-51023,-50942,-50862,-50781,-50701,-50621,-50540, - -50460,-50380,-50300,-50221,-50141,-50061,-49982,-49902, - -49823,-49744,-49664,-49585,-49506,-49427,-49349,-49270, - -49191,-49113,-49034,-48956,-48878,-48799,-48721,-48643, - -48565,-48488,-48410,-48332,-48255,-48177,-48100,-48022, - -47945,-47868,-47791,-47714,-47637,-47560,-47484,-47407, - -47331,-47254,-47178,-47102,-47025,-46949,-46873,-46797, - -46721,-46646,-46570,-46494,-46419,-46343,-46268,-46193, - -46118,-46042,-45967,-45892,-45818,-45743,-45668,-45593, - -45519,-45444,-45370,-45296,-45221,-45147,-45073,-44999, - -44925,-44851,-44778,-44704,-44630,-44557,-44483,-44410, - -44337,-44263,-44190,-44117,-44044,-43971,-43898,-43826, - -43753,-43680,-43608,-43535,-43463,-43390,-43318,-43246, - -43174,-43102,-43030,-42958,-42886,-42814,-42743,-42671, - -42600,-42528,-42457,-42385,-42314,-42243,-42172,-42101, - -42030,-41959,-41888,-41817,-41747,-41676,-41605,-41535, - -41465,-41394,-41324,-41254,-41184,-41113,-41043,-40973, - -40904,-40834,-40764,-40694,-40625,-40555,-40486,-40416, - -40347,-40278,-40208,-40139,-40070,-40001,-39932,-39863, - -39794,-39726,-39657,-39588,-39520,-39451,-39383,-39314, - -39246,-39178,-39110,-39042,-38973,-38905,-38837,-38770, - -38702,-38634,-38566,-38499,-38431,-38364,-38296,-38229, - -38161,-38094,-38027,-37960,-37893,-37826,-37759,-37692, - -37625,-37558,-37491,-37425,-37358,-37291,-37225,-37158, - -37092,-37026,-36959,-36893,-36827,-36761,-36695,-36629, - -36563,-36497,-36431,-36365,-36300,-36234,-36168,-36103, - -36037,-35972,-35907,-35841,-35776,-35711,-35646,-35580, - -35515,-35450,-35385,-35321,-35256,-35191,-35126,-35062, - -34997,-34932,-34868,-34803,-34739,-34675,-34610,-34546, - -34482,-34418,-34354,-34289,-34225,-34162,-34098,-34034, - -33970,-33906,-33843,-33779,-33715,-33652,-33588,-33525, - -33461,-33398,-33335,-33272,-33208,-33145,-33082,-33019, - -32956,-32893,-32830,-32767,-32705,-32642,-32579,-32516, - -32454,-32391,-32329,-32266,-32204,-32141,-32079,-32017, - -31955,-31892,-31830,-31768,-31706,-31644,-31582,-31520, - -31458,-31396,-31335,-31273,-31211,-31150,-31088,-31026, - -30965,-30904,-30842,-30781,-30719,-30658,-30597,-30536, - -30474,-30413,-30352,-30291,-30230,-30169,-30108,-30048, - -29987,-29926,-29865,-29805,-29744,-29683,-29623,-29562, - -29502,-29441,-29381,-29321,-29260,-29200,-29140,-29080, - -29020,-28959,-28899,-28839,-28779,-28719,-28660,-28600, - -28540,-28480,-28420,-28361,-28301,-28241,-28182,-28122, - -28063,-28003,-27944,-27884,-27825,-27766,-27707,-27647, - -27588,-27529,-27470,-27411,-27352,-27293,-27234,-27175, - -27116,-27057,-26998,-26940,-26881,-26822,-26763,-26705, - -26646,-26588,-26529,-26471,-26412,-26354,-26295,-26237, - -26179,-26120,-26062,-26004,-25946,-25888,-25830,-25772, - -25714,-25656,-25598,-25540,-25482,-25424,-25366,-25308, - -25251,-25193,-25135,-25078,-25020,-24962,-24905,-24847, - -24790,-24732,-24675,-24618,-24560,-24503,-24446,-24389, - -24331,-24274,-24217,-24160,-24103,-24046,-23989,-23932, - -23875,-23818,-23761,-23704,-23647,-23591,-23534,-23477, - -23420,-23364,-23307,-23250,-23194,-23137,-23081,-23024, - -22968,-22911,-22855,-22799,-22742,-22686,-22630,-22573, - -22517,-22461,-22405,-22349,-22293,-22237,-22181,-22125, - -22069,-22013,-21957,-21901,-21845,-21789,-21733,-21678, - -21622,-21566,-21510,-21455,-21399,-21343,-21288,-21232, - -21177,-21121,-21066,-21010,-20955,-20900,-20844,-20789, - -20734,-20678,-20623,-20568,-20513,-20457,-20402,-20347, - -20292,-20237,-20182,-20127,-20072,-20017,-19962,-19907, - -19852,-19797,-19742,-19688,-19633,-19578,-19523,-19469, - -19414,-19359,-19305,-19250,-19195,-19141,-19086,-19032, - -18977,-18923,-18868,-18814,-18760,-18705,-18651,-18597, - -18542,-18488,-18434,-18380,-18325,-18271,-18217,-18163, - -18109,-18055,-18001,-17946,-17892,-17838,-17784,-17731, - -17677,-17623,-17569,-17515,-17461,-17407,-17353,-17300, - -17246,-17192,-17138,-17085,-17031,-16977,-16924,-16870, - -16817,-16763,-16710,-16656,-16603,-16549,-16496,-16442, - -16389,-16335,-16282,-16229,-16175,-16122,-16069,-16015, - -15962,-15909,-15856,-15802,-15749,-15696,-15643,-15590, - -15537,-15484,-15431,-15378,-15325,-15272,-15219,-15166, - -15113,-15060,-15007,-14954,-14901,-14848,-14795,-14743, - -14690,-14637,-14584,-14531,-14479,-14426,-14373,-14321, - -14268,-14215,-14163,-14110,-14057,-14005,-13952,-13900, - -13847,-13795,-13742,-13690,-13637,-13585,-13533,-13480, - -13428,-13375,-13323,-13271,-13218,-13166,-13114,-13062, - -13009,-12957,-12905,-12853,-12800,-12748,-12696,-12644, - -12592,-12540,-12488,-12436,-12383,-12331,-12279,-12227, - -12175,-12123,-12071,-12019,-11967,-11916,-11864,-11812, - -11760,-11708,-11656,-11604,-11552,-11501,-11449,-11397, - -11345,-11293,-11242,-11190,-11138,-11086,-11035,-10983, - -10931,-10880,-10828,-10777,-10725,-10673,-10622,-10570, - -10519,-10467,-10415,-10364,-10312,-10261,-10209,-10158, - -10106,-10055,-10004,-9952,-9901,-9849,-9798,-9747, - -9695,-9644,-9592,-9541,-9490,-9438,-9387,-9336, - -9285,-9233,-9182,-9131,-9080,-9028,-8977,-8926, - -8875,-8824,-8772,-8721,-8670,-8619,-8568,-8517, - -8466,-8414,-8363,-8312,-8261,-8210,-8159,-8108, - -8057,-8006,-7955,-7904,-7853,-7802,-7751,-7700, - -7649,-7598,-7547,-7496,-7445,-7395,-7344,-7293, - -7242,-7191,-7140,-7089,-7038,-6988,-6937,-6886, - -6835,-6784,-6733,-6683,-6632,-6581,-6530,-6480, - -6429,-6378,-6327,-6277,-6226,-6175,-6124,-6074, - -6023,-5972,-5922,-5871,-5820,-5770,-5719,-5668, - -5618,-5567,-5517,-5466,-5415,-5365,-5314,-5264, - -5213,-5162,-5112,-5061,-5011,-4960,-4910,-4859, - -4808,-4758,-4707,-4657,-4606,-4556,-4505,-4455, - -4404,-4354,-4303,-4253,-4202,-4152,-4101,-4051, - -4001,-3950,-3900,-3849,-3799,-3748,-3698,-3648, - -3597,-3547,-3496,-3446,-3395,-3345,-3295,-3244, - -3194,-3144,-3093,-3043,-2992,-2942,-2892,-2841, - -2791,-2741,-2690,-2640,-2590,-2539,-2489,-2439, - -2388,-2338,-2288,-2237,-2187,-2137,-2086,-2036, - -1986,-1935,-1885,-1835,-1784,-1734,-1684,-1633, - -1583,-1533,-1483,-1432,-1382,-1332,-1281,-1231, - -1181,-1131,-1080,-1030,-980,-929,-879,-829, - -779,-728,-678,-628,-578,-527,-477,-427, - -376,-326,-276,-226,-175,-125,-75,-25, - 25,75,125,175,226,276,326,376, - 427,477,527,578,628,678,728,779, - 829,879,929,980,1030,1080,1131,1181, - 1231,1281,1332,1382,1432,1483,1533,1583, - 1633,1684,1734,1784,1835,1885,1935,1986, - 2036,2086,2137,2187,2237,2288,2338,2388, - 2439,2489,2539,2590,2640,2690,2741,2791, - 2841,2892,2942,2992,3043,3093,3144,3194, - 3244,3295,3345,3395,3446,3496,3547,3597, - 3648,3698,3748,3799,3849,3900,3950,4001, - 4051,4101,4152,4202,4253,4303,4354,4404, - 4455,4505,4556,4606,4657,4707,4758,4808, - 4859,4910,4960,5011,5061,5112,5162,5213, - 5264,5314,5365,5415,5466,5517,5567,5618, - 5668,5719,5770,5820,5871,5922,5972,6023, - 6074,6124,6175,6226,6277,6327,6378,6429, - 6480,6530,6581,6632,6683,6733,6784,6835, - 6886,6937,6988,7038,7089,7140,7191,7242, - 7293,7344,7395,7445,7496,7547,7598,7649, - 7700,7751,7802,7853,7904,7955,8006,8057, - 8108,8159,8210,8261,8312,8363,8414,8466, - 8517,8568,8619,8670,8721,8772,8824,8875, - 8926,8977,9028,9080,9131,9182,9233,9285, - 9336,9387,9438,9490,9541,9592,9644,9695, - 9747,9798,9849,9901,9952,10004,10055,10106, - 10158,10209,10261,10312,10364,10415,10467,10519, - 10570,10622,10673,10725,10777,10828,10880,10931, - 10983,11035,11086,11138,11190,11242,11293,11345, - 11397,11449,11501,11552,11604,11656,11708,11760, - 11812,11864,11916,11967,12019,12071,12123,12175, - 12227,12279,12331,12383,12436,12488,12540,12592, - 12644,12696,12748,12800,12853,12905,12957,13009, - 13062,13114,13166,13218,13271,13323,13375,13428, - 13480,13533,13585,13637,13690,13742,13795,13847, - 13900,13952,14005,14057,14110,14163,14215,14268, - 14321,14373,14426,14479,14531,14584,14637,14690, - 14743,14795,14848,14901,14954,15007,15060,15113, - 15166,15219,15272,15325,15378,15431,15484,15537, - 15590,15643,15696,15749,15802,15856,15909,15962, - 16015,16069,16122,16175,16229,16282,16335,16389, - 16442,16496,16549,16603,16656,16710,16763,16817, - 16870,16924,16977,17031,17085,17138,17192,17246, - 17300,17353,17407,17461,17515,17569,17623,17677, - 17731,17784,17838,17892,17946,18001,18055,18109, - 18163,18217,18271,18325,18380,18434,18488,18542, - 18597,18651,18705,18760,18814,18868,18923,18977, - 19032,19086,19141,19195,19250,19305,19359,19414, - 19469,19523,19578,19633,19688,19742,19797,19852, - 19907,19962,20017,20072,20127,20182,20237,20292, - 20347,20402,20457,20513,20568,20623,20678,20734, - 20789,20844,20900,20955,21010,21066,21121,21177, - 21232,21288,21343,21399,21455,21510,21566,21622, - 21678,21733,21789,21845,21901,21957,22013,22069, - 22125,22181,22237,22293,22349,22405,22461,22517, - 22573,22630,22686,22742,22799,22855,22911,22968, - 23024,23081,23137,23194,23250,23307,23364,23420, - 23477,23534,23591,23647,23704,23761,23818,23875, - 23932,23989,24046,24103,24160,24217,24274,24331, - 24389,24446,24503,24560,24618,24675,24732,24790, - 24847,24905,24962,25020,25078,25135,25193,25251, - 25308,25366,25424,25482,25540,25598,25656,25714, - 25772,25830,25888,25946,26004,26062,26120,26179, - 26237,26295,26354,26412,26471,26529,26588,26646, - 26705,26763,26822,26881,26940,26998,27057,27116, - 27175,27234,27293,27352,27411,27470,27529,27588, - 27647,27707,27766,27825,27884,27944,28003,28063, - 28122,28182,28241,28301,28361,28420,28480,28540, - 28600,28660,28719,28779,28839,28899,28959,29020, - 29080,29140,29200,29260,29321,29381,29441,29502, - 29562,29623,29683,29744,29805,29865,29926,29987, - 30048,30108,30169,30230,30291,30352,30413,30474, - 30536,30597,30658,30719,30781,30842,30904,30965, - 31026,31088,31150,31211,31273,31335,31396,31458, - 31520,31582,31644,31706,31768,31830,31892,31955, - 32017,32079,32141,32204,32266,32329,32391,32454, - 32516,32579,32642,32705,32767,32830,32893,32956, - 33019,33082,33145,33208,33272,33335,33398,33461, - 33525,33588,33652,33715,33779,33843,33906,33970, - 34034,34098,34162,34225,34289,34354,34418,34482, - 34546,34610,34675,34739,34803,34868,34932,34997, - 35062,35126,35191,35256,35321,35385,35450,35515, - 35580,35646,35711,35776,35841,35907,35972,36037, - 36103,36168,36234,36300,36365,36431,36497,36563, - 36629,36695,36761,36827,36893,36959,37026,37092, - 37158,37225,37291,37358,37425,37491,37558,37625, - 37692,37759,37826,37893,37960,38027,38094,38161, - 38229,38296,38364,38431,38499,38566,38634,38702, - 38770,38837,38905,38973,39042,39110,39178,39246, - 39314,39383,39451,39520,39588,39657,39726,39794, - 39863,39932,40001,40070,40139,40208,40278,40347, - 40416,40486,40555,40625,40694,40764,40834,40904, - 40973,41043,41113,41184,41254,41324,41394,41465, - 41535,41605,41676,41747,41817,41888,41959,42030, - 42101,42172,42243,42314,42385,42457,42528,42600, - 42671,42743,42814,42886,42958,43030,43102,43174, - 43246,43318,43390,43463,43535,43608,43680,43753, - 43826,43898,43971,44044,44117,44190,44263,44337, - 44410,44483,44557,44630,44704,44778,44851,44925, - 44999,45073,45147,45221,45296,45370,45444,45519, - 45593,45668,45743,45818,45892,45967,46042,46118, - 46193,46268,46343,46419,46494,46570,46646,46721, - 46797,46873,46949,47025,47102,47178,47254,47331, - 47407,47484,47560,47637,47714,47791,47868,47945, - 48022,48100,48177,48255,48332,48410,48488,48565, - 48643,48721,48799,48878,48956,49034,49113,49191, - 49270,49349,49427,49506,49585,49664,49744,49823, - 49902,49982,50061,50141,50221,50300,50380,50460, - 50540,50621,50701,50781,50862,50942,51023,51104, - 51185,51266,51347,51428,51509,51591,51672,51754, - 51835,51917,51999,52081,52163,52245,52327,52410, - 52492,52575,52657,52740,52823,52906,52989,53072, - 53156,53239,53322,53406,53490,53574,53657,53741, - 53826,53910,53994,54079,54163,54248,54333,54417, - 54502,54587,54673,54758,54843,54929,55015,55100, - 55186,55272,55358,55444,55531,55617,55704,55790, - 55877,55964,56051,56138,56225,56312,56400,56487, - 56575,56663,56751,56839,56927,57015,57104,57192, - 57281,57369,57458,57547,57636,57725,57815,57904, - 57994,58083,58173,58263,58353,58443,58534,58624, - 58715,58805,58896,58987,59078,59169,59261,59352, - 59444,59535,59627,59719,59811,59903,59996,60088, - 60181,60273,60366,60459,60552,60646,60739,60833, - 60926,61020,61114,61208,61302,61396,61491,61585, - 61680,61775,61870,61965,62060,62156,62251,62347, - 62443,62539,62635,62731,62828,62924,63021,63118, - 63215,63312,63409,63506,63604,63702,63799,63897, - 63996,64094,64192,64291,64389,64488,64587,64687, - 64786,64885,64985,65085,65185,65285,65385,65485, - 65586,65686,65787,65888,65989,66091,66192,66294, - 66396,66498,66600,66702,66804,66907,67010,67113, - 67216,67319,67422,67526,67629,67733,67837,67942, - 68046,68151,68255,68360,68465,68570,68676,68781, - 68887,68993,69099,69205,69312,69418,69525,69632, - 69739,69846,69954,70061,70169,70277,70385,70494, - 70602,70711,70820,70929,71038,71147,71257,71367, - 71477,71587,71697,71808,71918,72029,72140,72252, - 72363,72475,72587,72699,72811,72923,73036,73149, - 73262,73375,73488,73602,73715,73829,73944,74058, - 74172,74287,74402,74517,74633,74748,74864,74980, - 75096,75213,75329,75446,75563,75680,75797,75915, - 76033,76151,76269,76388,76506,76625,76744,76864, - 76983,77103,77223,77343,77463,77584,77705,77826, - 77947,78068,78190,78312,78434,78557,78679,78802, - 78925,79048,79172,79296,79420,79544,79668,79793, - 79918,80043,80168,80294,80420,80546,80672,80799, - 80925,81053,81180,81307,81435,81563,81691,81820, - 81949,82078,82207,82336,82466,82596,82726,82857, - 82987,83118,83250,83381,83513,83645,83777,83910, - 84043,84176,84309,84443,84576,84710,84845,84980, - 85114,85250,85385,85521,85657,85793,85930,86066, - 86204,86341,86479,86616,86755,86893,87032,87171, - 87310,87450,87590,87730,87871,88011,88152,88294, - 88435,88577,88720,88862,89005,89148,89292,89435, - 89579,89724,89868,90013,90158,90304,90450,90596, - 90742,90889,91036,91184,91332,91480,91628,91777, - 91926,92075,92225,92375,92525,92675,92826,92978, - 93129,93281,93434,93586,93739,93892,94046,94200, - 94354,94509,94664,94819,94975,95131,95287,95444, - 95601,95758,95916,96074,96233,96391,96551,96710, - 96870,97030,97191,97352,97513,97675,97837,98000, - 98163,98326,98489,98653,98818,98982,99148,99313, - 99479,99645,99812,99979,100146,100314,100482,100651, - 100820,100990,101159,101330,101500,101671,101843,102015, - 102187,102360,102533,102706,102880,103054,103229,103404, - 103580,103756,103933,104109,104287,104465,104643,104821, - 105000,105180,105360,105540,105721,105902,106084,106266, - 106449,106632,106816,107000,107184,107369,107555,107741, - 107927,108114,108301,108489,108677,108866,109055,109245, - 109435,109626,109817,110008,110200,110393,110586,110780, - 110974,111169,111364,111560,111756,111952,112150,112347, - 112546,112744,112944,113143,113344,113545,113746,113948, - 114151,114354,114557,114761,114966,115171,115377,115583, - 115790,115998,116206,116414,116623,116833,117044,117254, - 117466,117678,117891,118104,118318,118532,118747,118963, - 119179,119396,119613,119831,120050,120269,120489,120709, - 120930,121152,121374,121597,121821,122045,122270,122496, - 122722,122949,123176,123404,123633,123863,124093,124324, - 124555,124787,125020,125254,125488,125723,125959,126195, - 126432,126669,126908,127147,127387,127627,127869,128111, - 128353,128597,128841,129086,129332,129578,129825,130073, - 130322,130571,130821,131072,131324,131576,131830,132084, - 132339,132594,132851,133108,133366,133625,133884,134145, - 134406,134668,134931,135195,135459,135725,135991,136258, - 136526,136795,137065,137335,137607,137879,138152,138426, - 138701,138977,139254,139532,139810,140090,140370,140651, - 140934,141217,141501,141786,142072,142359,142647,142936, - 143226,143517,143808,144101,144395,144690,144986,145282, - 145580,145879,146179,146480,146782,147084,147388,147693, - 148000,148307,148615,148924,149235,149546,149859,150172, - 150487,150803,151120,151438,151757,152077,152399,152722, - 153045,153370,153697,154024,154352,154682,155013,155345, - 155678,156013,156349,156686,157024,157363,157704,158046, - 158389,158734,159079,159427,159775,160125,160476,160828, - 161182,161537,161893,162251,162610,162970,163332,163695, - 164060,164426,164793,165162,165532,165904,166277,166651, - 167027,167405,167784,168164,168546,168930,169315,169701, - 170089,170479,170870,171263,171657,172053,172451,172850, - 173251,173653,174057,174463,174870,175279,175690,176102, - 176516,176932,177349,177769,178190,178612,179037,179463, - 179891,180321,180753,181186,181622,182059,182498,182939, - 183382,183827,184274,184722,185173,185625,186080,186536, - 186995,187455,187918,188382,188849,189318,189789,190261, - 190736,191213,191693,192174,192658,193143,193631,194122, - 194614,195109,195606,196105,196606,197110,197616,198125, - 198636,199149,199664,200182,200703,201226,201751,202279, - 202809,203342,203878,204416,204956,205500,206045,206594, - 207145,207699,208255,208815,209376,209941,210509,211079, - 211652,212228,212807,213389,213973,214561,215151,215745, - 216341,216941,217544,218149,218758,219370,219985,220603, - 221225,221849,222477,223108,223743,224381,225022,225666, - 226314,226966,227621,228279,228941,229606,230275,230948, - 231624,232304,232988,233676,234367,235062,235761,236463, - 237170,237881,238595,239314,240036,240763,241493,242228, - 242967,243711,244458,245210,245966,246727,247492,248261, - 249035,249813,250596,251384,252176,252973,253774,254581, - 255392,256208,257029,257855,258686,259522,260363,261209, - 262060,262917,263779,264646,265519,266397,267280,268169, - 269064,269965,270871,271782,272700,273624,274553,275489, - 276430,277378,278332,279292,280258,281231,282210,283195, - 284188,285186,286192,287204,288223,289249,290282,291322, - 292369,293423,294485,295554,296630,297714,298805,299904, - 301011,302126,303248,304379,305517,306664,307819,308983, - 310154,311335,312524,313721,314928,316143,317368,318601, - 319844,321097,322358,323629,324910,326201,327502,328812, - 330133,331464,332805,334157,335519,336892,338276,339671, - 341078,342495,343924,345364,346816,348280,349756,351244, - 352744,354257,355783,357321,358872,360436,362013,363604, - 365208,366826,368459,370105,371765,373440,375130,376835, - 378555,380290,382040,383807,385589,387387,389202,391034, - 392882,394747,396630,398530,400448,402384,404338,406311, - 408303,410314,412344,414395,416465,418555,420666,422798, - 424951,427125,429321,431540,433781,436045,438332,440643, - 442978,445337,447720,450129,452564,455024,457511,460024, - 462565,465133,467730,470355,473009,475692,478406,481150, - 483925,486732,489571,492443,495348,498287,501261,504269, - 507313,510394,513512,516667,519861,523094,526366,529680, - 533034,536431,539870,543354,546881,550455,554074,557741, - 561456,565221,569035,572901,576818,580789,584815,588896, - 593033,597229,601483,605798,610174,614613,619117,623686, - 628323,633028,637803,642651,647572,652568,657640,662792, - 668024,673338,678737,684223,689797,695462,701219,707072, - 713023,719074,725227,731486,737853,744331,750922,757631, - 764460,771411,778490,785699,793041,800521,808143,815910, - 823827,831898,840127,848520,857081,865817,874730,883829, - 893117,902602,912289,922186,932298,942633,953199,964003, - 975054,986361,997931,1009774,1021901,1034322,1047046,1060087, - 1073455,1087164,1101225,1115654,1130465,1145673,1161294,1177345, - 1193846,1210813,1228269,1246234,1264730,1283783,1303416,1323658, - 1344537,1366084,1388330,1411312,1435065,1459630,1485049,1511367, - 1538632,1566898,1596220,1626658,1658278,1691149,1725348,1760956, - 1798063,1836758,1877161,1919378,1963536,2009771,2058233,2109087, - 2162516,2218719,2277919,2340362,2406322,2476104,2550052,2628549, - 2712030,2800983,2895966,2997613,3106651,3223918,3350381,3487165, - 3635590,3797206,3973855,4167737,4381502,4618375,4882318,5178251, - 5512368,5892567,6329090,6835455,7429880,8137527,8994149,10052327, - 11392683,13145455,15535599,18988036,24413316,34178904,56965752,170910304 -}; - - -const int finesine[10240] = -{ - 25,75,125,175,226,276,326,376, - 427,477,527,578,628,678,728,779, - 829,879,929,980,1030,1080,1130,1181, - 1231,1281,1331,1382,1432,1482,1532,1583, - 1633,1683,1733,1784,1834,1884,1934,1985, - 2035,2085,2135,2186,2236,2286,2336,2387, - 2437,2487,2537,2587,2638,2688,2738,2788, - 2839,2889,2939,2989,3039,3090,3140,3190, - 3240,3291,3341,3391,3441,3491,3541,3592, - 3642,3692,3742,3792,3843,3893,3943,3993, - 4043,4093,4144,4194,4244,4294,4344,4394, - 4445,4495,4545,4595,4645,4695,4745,4796, - 4846,4896,4946,4996,5046,5096,5146,5197, - 5247,5297,5347,5397,5447,5497,5547,5597, - 5647,5697,5748,5798,5848,5898,5948,5998, - 6048,6098,6148,6198,6248,6298,6348,6398, - 6448,6498,6548,6598,6648,6698,6748,6798, - 6848,6898,6948,6998,7048,7098,7148,7198, - 7248,7298,7348,7398,7448,7498,7548,7598, - 7648,7697,7747,7797,7847,7897,7947,7997, - 8047,8097,8147,8196,8246,8296,8346,8396, - 8446,8496,8545,8595,8645,8695,8745,8794, - 8844,8894,8944,8994,9043,9093,9143,9193, - 9243,9292,9342,9392,9442,9491,9541,9591, - 9640,9690,9740,9790,9839,9889,9939,9988, - 10038,10088,10137,10187,10237,10286,10336,10386, - 10435,10485,10534,10584,10634,10683,10733,10782, - 10832,10882,10931,10981,11030,11080,11129,11179, - 11228,11278,11327,11377,11426,11476,11525,11575, - 11624,11674,11723,11773,11822,11872,11921,11970, - 12020,12069,12119,12168,12218,12267,12316,12366, - 12415,12464,12514,12563,12612,12662,12711,12760, - 12810,12859,12908,12957,13007,13056,13105,13154, - 13204,13253,13302,13351,13401,13450,13499,13548, - 13597,13647,13696,13745,13794,13843,13892,13941, - 13990,14040,14089,14138,14187,14236,14285,14334, - 14383,14432,14481,14530,14579,14628,14677,14726, - 14775,14824,14873,14922,14971,15020,15069,15118, - 15167,15215,15264,15313,15362,15411,15460,15509, - 15557,15606,15655,15704,15753,15802,15850,15899, - 15948,15997,16045,16094,16143,16191,16240,16289, - 16338,16386,16435,16484,16532,16581,16629,16678, - 16727,16775,16824,16872,16921,16970,17018,17067, - 17115,17164,17212,17261,17309,17358,17406,17455, - 17503,17551,17600,17648,17697,17745,17793,17842, - 17890,17939,17987,18035,18084,18132,18180,18228, - 18277,18325,18373,18421,18470,18518,18566,18614, - 18663,18711,18759,18807,18855,18903,18951,19000, - 19048,19096,19144,19192,19240,19288,19336,19384, - 19432,19480,19528,19576,19624,19672,19720,19768, - 19816,19864,19912,19959,20007,20055,20103,20151, - 20199,20246,20294,20342,20390,20438,20485,20533, - 20581,20629,20676,20724,20772,20819,20867,20915, - 20962,21010,21057,21105,21153,21200,21248,21295, - 21343,21390,21438,21485,21533,21580,21628,21675, - 21723,21770,21817,21865,21912,21960,22007,22054, - 22102,22149,22196,22243,22291,22338,22385,22433, - 22480,22527,22574,22621,22668,22716,22763,22810, - 22857,22904,22951,22998,23045,23092,23139,23186, - 23233,23280,23327,23374,23421,23468,23515,23562, - 23609,23656,23703,23750,23796,23843,23890,23937, - 23984,24030,24077,24124,24171,24217,24264,24311, - 24357,24404,24451,24497,24544,24591,24637,24684, - 24730,24777,24823,24870,24916,24963,25009,25056, - 25102,25149,25195,25241,25288,25334,25381,25427, - 25473,25520,25566,25612,25658,25705,25751,25797, - 25843,25889,25936,25982,26028,26074,26120,26166, - 26212,26258,26304,26350,26396,26442,26488,26534, - 26580,26626,26672,26718,26764,26810,26856,26902, - 26947,26993,27039,27085,27131,27176,27222,27268, - 27313,27359,27405,27450,27496,27542,27587,27633, - 27678,27724,27770,27815,27861,27906,27952,27997, - 28042,28088,28133,28179,28224,28269,28315,28360, - 28405,28451,28496,28541,28586,28632,28677,28722, - 28767,28812,28858,28903,28948,28993,29038,29083, - 29128,29173,29218,29263,29308,29353,29398,29443, - 29488,29533,29577,29622,29667,29712,29757,29801, - 29846,29891,29936,29980,30025,30070,30114,30159, - 30204,30248,30293,30337,30382,30426,30471,30515, - 30560,30604,30649,30693,30738,30782,30826,30871, - 30915,30959,31004,31048,31092,31136,31181,31225, - 31269,31313,31357,31402,31446,31490,31534,31578, - 31622,31666,31710,31754,31798,31842,31886,31930, - 31974,32017,32061,32105,32149,32193,32236,32280, - 32324,32368,32411,32455,32499,32542,32586,32630, - 32673,32717,32760,32804,32847,32891,32934,32978, - 33021,33065,33108,33151,33195,33238,33281,33325, - 33368,33411,33454,33498,33541,33584,33627,33670, - 33713,33756,33799,33843,33886,33929,33972,34015, - 34057,34100,34143,34186,34229,34272,34315,34358, - 34400,34443,34486,34529,34571,34614,34657,34699, - 34742,34785,34827,34870,34912,34955,34997,35040, - 35082,35125,35167,35210,35252,35294,35337,35379, - 35421,35464,35506,35548,35590,35633,35675,35717, - 35759,35801,35843,35885,35927,35969,36011,36053, - 36095,36137,36179,36221,36263,36305,36347,36388, - 36430,36472,36514,36555,36597,36639,36681,36722, - 36764,36805,36847,36889,36930,36972,37013,37055, - 37096,37137,37179,37220,37262,37303,37344,37386, - 37427,37468,37509,37551,37592,37633,37674,37715, - 37756,37797,37838,37879,37920,37961,38002,38043, - 38084,38125,38166,38207,38248,38288,38329,38370, - 38411,38451,38492,38533,38573,38614,38655,38695, - 38736,38776,38817,38857,38898,38938,38979,39019, - 39059,39100,39140,39180,39221,39261,39301,39341, - 39382,39422,39462,39502,39542,39582,39622,39662, - 39702,39742,39782,39822,39862,39902,39942,39982, - 40021,40061,40101,40141,40180,40220,40260,40300, - 40339,40379,40418,40458,40497,40537,40576,40616, - 40655,40695,40734,40773,40813,40852,40891,40931, - 40970,41009,41048,41087,41127,41166,41205,41244, - 41283,41322,41361,41400,41439,41478,41517,41556, - 41595,41633,41672,41711,41750,41788,41827,41866, - 41904,41943,41982,42020,42059,42097,42136,42174, - 42213,42251,42290,42328,42366,42405,42443,42481, - 42520,42558,42596,42634,42672,42711,42749,42787, - 42825,42863,42901,42939,42977,43015,43053,43091, - 43128,43166,43204,43242,43280,43317,43355,43393, - 43430,43468,43506,43543,43581,43618,43656,43693, - 43731,43768,43806,43843,43880,43918,43955,43992, - 44029,44067,44104,44141,44178,44215,44252,44289, - 44326,44363,44400,44437,44474,44511,44548,44585, - 44622,44659,44695,44732,44769,44806,44842,44879, - 44915,44952,44989,45025,45062,45098,45135,45171, - 45207,45244,45280,45316,45353,45389,45425,45462, - 45498,45534,45570,45606,45642,45678,45714,45750, - 45786,45822,45858,45894,45930,45966,46002,46037, - 46073,46109,46145,46180,46216,46252,46287,46323, - 46358,46394,46429,46465,46500,46536,46571,46606, - 46642,46677,46712,46747,46783,46818,46853,46888, - 46923,46958,46993,47028,47063,47098,47133,47168, - 47203,47238,47273,47308,47342,47377,47412,47446, - 47481,47516,47550,47585,47619,47654,47688,47723, - 47757,47792,47826,47860,47895,47929,47963,47998, - 48032,48066,48100,48134,48168,48202,48237,48271, - 48305,48338,48372,48406,48440,48474,48508,48542, - 48575,48609,48643,48676,48710,48744,48777,48811, - 48844,48878,48911,48945,48978,49012,49045,49078, - 49112,49145,49178,49211,49244,49278,49311,49344, - 49377,49410,49443,49476,49509,49542,49575,49608, - 49640,49673,49706,49739,49771,49804,49837,49869, - 49902,49935,49967,50000,50032,50065,50097,50129, - 50162,50194,50226,50259,50291,50323,50355,50387, - 50420,50452,50484,50516,50548,50580,50612,50644, - 50675,50707,50739,50771,50803,50834,50866,50898, - 50929,50961,50993,51024,51056,51087,51119,51150, - 51182,51213,51244,51276,51307,51338,51369,51401, - 51432,51463,51494,51525,51556,51587,51618,51649, - 51680,51711,51742,51773,51803,51834,51865,51896, - 51926,51957,51988,52018,52049,52079,52110,52140, - 52171,52201,52231,52262,52292,52322,52353,52383, - 52413,52443,52473,52503,52534,52564,52594,52624, - 52653,52683,52713,52743,52773,52803,52832,52862, - 52892,52922,52951,52981,53010,53040,53069,53099, - 53128,53158,53187,53216,53246,53275,53304,53334, - 53363,53392,53421,53450,53479,53508,53537,53566, - 53595,53624,53653,53682,53711,53739,53768,53797, - 53826,53854,53883,53911,53940,53969,53997,54026, - 54054,54082,54111,54139,54167,54196,54224,54252, - 54280,54308,54337,54365,54393,54421,54449,54477, - 54505,54533,54560,54588,54616,54644,54672,54699, - 54727,54755,54782,54810,54837,54865,54892,54920, - 54947,54974,55002,55029,55056,55084,55111,55138, - 55165,55192,55219,55246,55274,55300,55327,55354, - 55381,55408,55435,55462,55489,55515,55542,55569, - 55595,55622,55648,55675,55701,55728,55754,55781, - 55807,55833,55860,55886,55912,55938,55965,55991, - 56017,56043,56069,56095,56121,56147,56173,56199, - 56225,56250,56276,56302,56328,56353,56379,56404, - 56430,56456,56481,56507,56532,56557,56583,56608, - 56633,56659,56684,56709,56734,56760,56785,56810, - 56835,56860,56885,56910,56935,56959,56984,57009, - 57034,57059,57083,57108,57133,57157,57182,57206, - 57231,57255,57280,57304,57329,57353,57377,57402, - 57426,57450,57474,57498,57522,57546,57570,57594, - 57618,57642,57666,57690,57714,57738,57762,57785, - 57809,57833,57856,57880,57903,57927,57950,57974, - 57997,58021,58044,58067,58091,58114,58137,58160, - 58183,58207,58230,58253,58276,58299,58322,58345, - 58367,58390,58413,58436,58459,58481,58504,58527, - 58549,58572,58594,58617,58639,58662,58684,58706, - 58729,58751,58773,58795,58818,58840,58862,58884, - 58906,58928,58950,58972,58994,59016,59038,59059, - 59081,59103,59125,59146,59168,59190,59211,59233, - 59254,59276,59297,59318,59340,59361,59382,59404, - 59425,59446,59467,59488,59509,59530,59551,59572, - 59593,59614,59635,59656,59677,59697,59718,59739, - 59759,59780,59801,59821,59842,59862,59883,59903, - 59923,59944,59964,59984,60004,60025,60045,60065, - 60085,60105,60125,60145,60165,60185,60205,60225, - 60244,60264,60284,60304,60323,60343,60363,60382, - 60402,60421,60441,60460,60479,60499,60518,60537, - 60556,60576,60595,60614,60633,60652,60671,60690, - 60709,60728,60747,60766,60785,60803,60822,60841, - 60859,60878,60897,60915,60934,60952,60971,60989, - 61007,61026,61044,61062,61081,61099,61117,61135, - 61153,61171,61189,61207,61225,61243,61261,61279, - 61297,61314,61332,61350,61367,61385,61403,61420, - 61438,61455,61473,61490,61507,61525,61542,61559, - 61577,61594,61611,61628,61645,61662,61679,61696, - 61713,61730,61747,61764,61780,61797,61814,61831, - 61847,61864,61880,61897,61913,61930,61946,61963, - 61979,61995,62012,62028,62044,62060,62076,62092, - 62108,62125,62141,62156,62172,62188,62204,62220, - 62236,62251,62267,62283,62298,62314,62329,62345, - 62360,62376,62391,62407,62422,62437,62453,62468, - 62483,62498,62513,62528,62543,62558,62573,62588, - 62603,62618,62633,62648,62662,62677,62692,62706, - 62721,62735,62750,62764,62779,62793,62808,62822, - 62836,62850,62865,62879,62893,62907,62921,62935, - 62949,62963,62977,62991,63005,63019,63032,63046, - 63060,63074,63087,63101,63114,63128,63141,63155, - 63168,63182,63195,63208,63221,63235,63248,63261, - 63274,63287,63300,63313,63326,63339,63352,63365, - 63378,63390,63403,63416,63429,63441,63454,63466, - 63479,63491,63504,63516,63528,63541,63553,63565, - 63578,63590,63602,63614,63626,63638,63650,63662, - 63674,63686,63698,63709,63721,63733,63745,63756, - 63768,63779,63791,63803,63814,63825,63837,63848, - 63859,63871,63882,63893,63904,63915,63927,63938, - 63949,63960,63971,63981,63992,64003,64014,64025, - 64035,64046,64057,64067,64078,64088,64099,64109, - 64120,64130,64140,64151,64161,64171,64181,64192, - 64202,64212,64222,64232,64242,64252,64261,64271, - 64281,64291,64301,64310,64320,64330,64339,64349, - 64358,64368,64377,64387,64396,64405,64414,64424, - 64433,64442,64451,64460,64469,64478,64487,64496, - 64505,64514,64523,64532,64540,64549,64558,64566, - 64575,64584,64592,64601,64609,64617,64626,64634, - 64642,64651,64659,64667,64675,64683,64691,64699, - 64707,64715,64723,64731,64739,64747,64754,64762, - 64770,64777,64785,64793,64800,64808,64815,64822, - 64830,64837,64844,64852,64859,64866,64873,64880, - 64887,64895,64902,64908,64915,64922,64929,64936, - 64943,64949,64956,64963,64969,64976,64982,64989, - 64995,65002,65008,65015,65021,65027,65033,65040, - 65046,65052,65058,65064,65070,65076,65082,65088, - 65094,65099,65105,65111,65117,65122,65128,65133, - 65139,65144,65150,65155,65161,65166,65171,65177, - 65182,65187,65192,65197,65202,65207,65212,65217, - 65222,65227,65232,65237,65242,65246,65251,65256, - 65260,65265,65270,65274,65279,65283,65287,65292, - 65296,65300,65305,65309,65313,65317,65321,65325, - 65329,65333,65337,65341,65345,65349,65352,65356, - 65360,65363,65367,65371,65374,65378,65381,65385, - 65388,65391,65395,65398,65401,65404,65408,65411, - 65414,65417,65420,65423,65426,65429,65431,65434, - 65437,65440,65442,65445,65448,65450,65453,65455, - 65458,65460,65463,65465,65467,65470,65472,65474, - 65476,65478,65480,65482,65484,65486,65488,65490, - 65492,65494,65496,65497,65499,65501,65502,65504, - 65505,65507,65508,65510,65511,65513,65514,65515, - 65516,65518,65519,65520,65521,65522,65523,65524, - 65525,65526,65527,65527,65528,65529,65530,65530, - 65531,65531,65532,65532,65533,65533,65534,65534, - 65534,65535,65535,65535,65535,65535,65535,65535, - 65535,65535,65535,65535,65535,65535,65535,65534, - 65534,65534,65533,65533,65532,65532,65531,65531, - 65530,65530,65529,65528,65527,65527,65526,65525, - 65524,65523,65522,65521,65520,65519,65518,65516, - 65515,65514,65513,65511,65510,65508,65507,65505, - 65504,65502,65501,65499,65497,65496,65494,65492, - 65490,65488,65486,65484,65482,65480,65478,65476, - 65474,65472,65470,65467,65465,65463,65460,65458, - 65455,65453,65450,65448,65445,65442,65440,65437, - 65434,65431,65429,65426,65423,65420,65417,65414, - 65411,65408,65404,65401,65398,65395,65391,65388, - 65385,65381,65378,65374,65371,65367,65363,65360, - 65356,65352,65349,65345,65341,65337,65333,65329, - 65325,65321,65317,65313,65309,65305,65300,65296, - 65292,65287,65283,65279,65274,65270,65265,65260, - 65256,65251,65246,65242,65237,65232,65227,65222, - 65217,65212,65207,65202,65197,65192,65187,65182, - 65177,65171,65166,65161,65155,65150,65144,65139, - 65133,65128,65122,65117,65111,65105,65099,65094, - 65088,65082,65076,65070,65064,65058,65052,65046, - 65040,65033,65027,65021,65015,65008,65002,64995, - 64989,64982,64976,64969,64963,64956,64949,64943, - 64936,64929,64922,64915,64908,64902,64895,64887, - 64880,64873,64866,64859,64852,64844,64837,64830, - 64822,64815,64808,64800,64793,64785,64777,64770, - 64762,64754,64747,64739,64731,64723,64715,64707, - 64699,64691,64683,64675,64667,64659,64651,64642, - 64634,64626,64617,64609,64600,64592,64584,64575, - 64566,64558,64549,64540,64532,64523,64514,64505, - 64496,64487,64478,64469,64460,64451,64442,64433, - 64424,64414,64405,64396,64387,64377,64368,64358, - 64349,64339,64330,64320,64310,64301,64291,64281, - 64271,64261,64252,64242,64232,64222,64212,64202, - 64192,64181,64171,64161,64151,64140,64130,64120, - 64109,64099,64088,64078,64067,64057,64046,64035, - 64025,64014,64003,63992,63981,63971,63960,63949, - 63938,63927,63915,63904,63893,63882,63871,63859, - 63848,63837,63825,63814,63803,63791,63779,63768, - 63756,63745,63733,63721,63709,63698,63686,63674, - 63662,63650,63638,63626,63614,63602,63590,63578, - 63565,63553,63541,63528,63516,63504,63491,63479, - 63466,63454,63441,63429,63416,63403,63390,63378, - 63365,63352,63339,63326,63313,63300,63287,63274, - 63261,63248,63235,63221,63208,63195,63182,63168, - 63155,63141,63128,63114,63101,63087,63074,63060, - 63046,63032,63019,63005,62991,62977,62963,62949, - 62935,62921,62907,62893,62879,62865,62850,62836, - 62822,62808,62793,62779,62764,62750,62735,62721, - 62706,62692,62677,62662,62648,62633,62618,62603, - 62588,62573,62558,62543,62528,62513,62498,62483, - 62468,62453,62437,62422,62407,62391,62376,62360, - 62345,62329,62314,62298,62283,62267,62251,62236, - 62220,62204,62188,62172,62156,62141,62125,62108, - 62092,62076,62060,62044,62028,62012,61995,61979, - 61963,61946,61930,61913,61897,61880,61864,61847, - 61831,61814,61797,61780,61764,61747,61730,61713, - 61696,61679,61662,61645,61628,61611,61594,61577, - 61559,61542,61525,61507,61490,61473,61455,61438, - 61420,61403,61385,61367,61350,61332,61314,61297, - 61279,61261,61243,61225,61207,61189,61171,61153, - 61135,61117,61099,61081,61062,61044,61026,61007, - 60989,60971,60952,60934,60915,60897,60878,60859, - 60841,60822,60803,60785,60766,60747,60728,60709, - 60690,60671,60652,60633,60614,60595,60576,60556, - 60537,60518,60499,60479,60460,60441,60421,60402, - 60382,60363,60343,60323,60304,60284,60264,60244, - 60225,60205,60185,60165,60145,60125,60105,60085, - 60065,60045,60025,60004,59984,59964,59944,59923, - 59903,59883,59862,59842,59821,59801,59780,59759, - 59739,59718,59697,59677,59656,59635,59614,59593, - 59572,59551,59530,59509,59488,59467,59446,59425, - 59404,59382,59361,59340,59318,59297,59276,59254, - 59233,59211,59190,59168,59146,59125,59103,59081, - 59059,59038,59016,58994,58972,58950,58928,58906, - 58884,58862,58840,58818,58795,58773,58751,58729, - 58706,58684,58662,58639,58617,58594,58572,58549, - 58527,58504,58481,58459,58436,58413,58390,58367, - 58345,58322,58299,58276,58253,58230,58207,58183, - 58160,58137,58114,58091,58067,58044,58021,57997, - 57974,57950,57927,57903,57880,57856,57833,57809, - 57785,57762,57738,57714,57690,57666,57642,57618, - 57594,57570,57546,57522,57498,57474,57450,57426, - 57402,57377,57353,57329,57304,57280,57255,57231, - 57206,57182,57157,57133,57108,57083,57059,57034, - 57009,56984,56959,56935,56910,56885,56860,56835, - 56810,56785,56760,56734,56709,56684,56659,56633, - 56608,56583,56557,56532,56507,56481,56456,56430, - 56404,56379,56353,56328,56302,56276,56250,56225, - 56199,56173,56147,56121,56095,56069,56043,56017, - 55991,55965,55938,55912,55886,55860,55833,55807, - 55781,55754,55728,55701,55675,55648,55622,55595, - 55569,55542,55515,55489,55462,55435,55408,55381, - 55354,55327,55300,55274,55246,55219,55192,55165, - 55138,55111,55084,55056,55029,55002,54974,54947, - 54920,54892,54865,54837,54810,54782,54755,54727, - 54699,54672,54644,54616,54588,54560,54533,54505, - 54477,54449,54421,54393,54365,54337,54308,54280, - 54252,54224,54196,54167,54139,54111,54082,54054, - 54026,53997,53969,53940,53911,53883,53854,53826, - 53797,53768,53739,53711,53682,53653,53624,53595, - 53566,53537,53508,53479,53450,53421,53392,53363, - 53334,53304,53275,53246,53216,53187,53158,53128, - 53099,53069,53040,53010,52981,52951,52922,52892, - 52862,52832,52803,52773,52743,52713,52683,52653, - 52624,52594,52564,52534,52503,52473,52443,52413, - 52383,52353,52322,52292,52262,52231,52201,52171, - 52140,52110,52079,52049,52018,51988,51957,51926, - 51896,51865,51834,51803,51773,51742,51711,51680, - 51649,51618,51587,51556,51525,51494,51463,51432, - 51401,51369,51338,51307,51276,51244,51213,51182, - 51150,51119,51087,51056,51024,50993,50961,50929, - 50898,50866,50834,50803,50771,50739,50707,50675, - 50644,50612,50580,50548,50516,50484,50452,50420, - 50387,50355,50323,50291,50259,50226,50194,50162, - 50129,50097,50065,50032,50000,49967,49935,49902, - 49869,49837,49804,49771,49739,49706,49673,49640, - 49608,49575,49542,49509,49476,49443,49410,49377, - 49344,49311,49278,49244,49211,49178,49145,49112, - 49078,49045,49012,48978,48945,48911,48878,48844, - 48811,48777,48744,48710,48676,48643,48609,48575, - 48542,48508,48474,48440,48406,48372,48338,48304, - 48271,48237,48202,48168,48134,48100,48066,48032, - 47998,47963,47929,47895,47860,47826,47792,47757, - 47723,47688,47654,47619,47585,47550,47516,47481, - 47446,47412,47377,47342,47308,47273,47238,47203, - 47168,47133,47098,47063,47028,46993,46958,46923, - 46888,46853,46818,46783,46747,46712,46677,46642, - 46606,46571,46536,46500,46465,46429,46394,46358, - 46323,46287,46252,46216,46180,46145,46109,46073, - 46037,46002,45966,45930,45894,45858,45822,45786, - 45750,45714,45678,45642,45606,45570,45534,45498, - 45462,45425,45389,45353,45316,45280,45244,45207, - 45171,45135,45098,45062,45025,44989,44952,44915, - 44879,44842,44806,44769,44732,44695,44659,44622, - 44585,44548,44511,44474,44437,44400,44363,44326, - 44289,44252,44215,44178,44141,44104,44067,44029, - 43992,43955,43918,43880,43843,43806,43768,43731, - 43693,43656,43618,43581,43543,43506,43468,43430, - 43393,43355,43317,43280,43242,43204,43166,43128, - 43091,43053,43015,42977,42939,42901,42863,42825, - 42787,42749,42711,42672,42634,42596,42558,42520, - 42481,42443,42405,42366,42328,42290,42251,42213, - 42174,42136,42097,42059,42020,41982,41943,41904, - 41866,41827,41788,41750,41711,41672,41633,41595, - 41556,41517,41478,41439,41400,41361,41322,41283, - 41244,41205,41166,41127,41088,41048,41009,40970, - 40931,40891,40852,40813,40773,40734,40695,40655, - 40616,40576,40537,40497,40458,40418,40379,40339, - 40300,40260,40220,40180,40141,40101,40061,40021, - 39982,39942,39902,39862,39822,39782,39742,39702, - 39662,39622,39582,39542,39502,39462,39422,39382, - 39341,39301,39261,39221,39180,39140,39100,39059, - 39019,38979,38938,38898,38857,38817,38776,38736, - 38695,38655,38614,38573,38533,38492,38451,38411, - 38370,38329,38288,38248,38207,38166,38125,38084, - 38043,38002,37961,37920,37879,37838,37797,37756, - 37715,37674,37633,37592,37551,37509,37468,37427, - 37386,37344,37303,37262,37220,37179,37137,37096, - 37055,37013,36972,36930,36889,36847,36805,36764, - 36722,36681,36639,36597,36556,36514,36472,36430, - 36388,36347,36305,36263,36221,36179,36137,36095, - 36053,36011,35969,35927,35885,35843,35801,35759, - 35717,35675,35633,35590,35548,35506,35464,35421, - 35379,35337,35294,35252,35210,35167,35125,35082, - 35040,34997,34955,34912,34870,34827,34785,34742, - 34699,34657,34614,34571,34529,34486,34443,34400, - 34358,34315,34272,34229,34186,34143,34100,34057, - 34015,33972,33929,33886,33843,33799,33756,33713, - 33670,33627,33584,33541,33498,33454,33411,33368, - 33325,33281,33238,33195,33151,33108,33065,33021, - 32978,32934,32891,32847,32804,32760,32717,32673, - 32630,32586,32542,32499,32455,32411,32368,32324, - 32280,32236,32193,32149,32105,32061,32017,31974, - 31930,31886,31842,31798,31754,31710,31666,31622, - 31578,31534,31490,31446,31402,31357,31313,31269, - 31225,31181,31136,31092,31048,31004,30959,30915, - 30871,30826,30782,30738,30693,30649,30604,30560, - 30515,30471,30426,30382,30337,30293,30248,30204, - 30159,30114,30070,30025,29980,29936,29891,29846, - 29801,29757,29712,29667,29622,29577,29533,29488, - 29443,29398,29353,29308,29263,29218,29173,29128, - 29083,29038,28993,28948,28903,28858,28812,28767, - 28722,28677,28632,28586,28541,28496,28451,28405, - 28360,28315,28269,28224,28179,28133,28088,28042, - 27997,27952,27906,27861,27815,27770,27724,27678, - 27633,27587,27542,27496,27450,27405,27359,27313, - 27268,27222,27176,27131,27085,27039,26993,26947, - 26902,26856,26810,26764,26718,26672,26626,26580, - 26534,26488,26442,26396,26350,26304,26258,26212, - 26166,26120,26074,26028,25982,25936,25889,25843, - 25797,25751,25705,25658,25612,25566,25520,25473, - 25427,25381,25334,25288,25241,25195,25149,25102, - 25056,25009,24963,24916,24870,24823,24777,24730, - 24684,24637,24591,24544,24497,24451,24404,24357, - 24311,24264,24217,24171,24124,24077,24030,23984, - 23937,23890,23843,23796,23750,23703,23656,23609, - 23562,23515,23468,23421,23374,23327,23280,23233, - 23186,23139,23092,23045,22998,22951,22904,22857, - 22810,22763,22716,22668,22621,22574,22527,22480, - 22433,22385,22338,22291,22243,22196,22149,22102, - 22054,22007,21960,21912,21865,21817,21770,21723, - 21675,21628,21580,21533,21485,21438,21390,21343, - 21295,21248,21200,21153,21105,21057,21010,20962, - 20915,20867,20819,20772,20724,20676,20629,20581, - 20533,20485,20438,20390,20342,20294,20246,20199, - 20151,20103,20055,20007,19959,19912,19864,19816, - 19768,19720,19672,19624,19576,19528,19480,19432, - 19384,19336,19288,19240,19192,19144,19096,19048, - 19000,18951,18903,18855,18807,18759,18711,18663, - 18614,18566,18518,18470,18421,18373,18325,18277, - 18228,18180,18132,18084,18035,17987,17939,17890, - 17842,17793,17745,17697,17648,17600,17551,17503, - 17455,17406,17358,17309,17261,17212,17164,17115, - 17067,17018,16970,16921,16872,16824,16775,16727, - 16678,16629,16581,16532,16484,16435,16386,16338, - 16289,16240,16191,16143,16094,16045,15997,15948, - 15899,15850,15802,15753,15704,15655,15606,15557, - 15509,15460,15411,15362,15313,15264,15215,15167, - 15118,15069,15020,14971,14922,14873,14824,14775, - 14726,14677,14628,14579,14530,14481,14432,14383, - 14334,14285,14236,14187,14138,14089,14040,13990, - 13941,13892,13843,13794,13745,13696,13646,13597, - 13548,13499,13450,13401,13351,13302,13253,13204, - 13154,13105,13056,13007,12957,12908,12859,12810, - 12760,12711,12662,12612,12563,12514,12464,12415, - 12366,12316,12267,12218,12168,12119,12069,12020, - 11970,11921,11872,11822,11773,11723,11674,11624, - 11575,11525,11476,11426,11377,11327,11278,11228, - 11179,11129,11080,11030,10981,10931,10882,10832, - 10782,10733,10683,10634,10584,10534,10485,10435, - 10386,10336,10286,10237,10187,10137,10088,10038, - 9988,9939,9889,9839,9790,9740,9690,9640, - 9591,9541,9491,9442,9392,9342,9292,9243, - 9193,9143,9093,9043,8994,8944,8894,8844, - 8794,8745,8695,8645,8595,8545,8496,8446, - 8396,8346,8296,8246,8196,8147,8097,8047, - 7997,7947,7897,7847,7797,7747,7697,7648, - 7598,7548,7498,7448,7398,7348,7298,7248, - 7198,7148,7098,7048,6998,6948,6898,6848, - 6798,6748,6698,6648,6598,6548,6498,6448, - 6398,6348,6298,6248,6198,6148,6098,6048, - 5998,5948,5898,5848,5798,5748,5697,5647, - 5597,5547,5497,5447,5397,5347,5297,5247, - 5197,5146,5096,5046,4996,4946,4896,4846, - 4796,4745,4695,4645,4595,4545,4495,4445, - 4394,4344,4294,4244,4194,4144,4093,4043, - 3993,3943,3893,3843,3792,3742,3692,3642, - 3592,3541,3491,3441,3391,3341,3291,3240, - 3190,3140,3090,3039,2989,2939,2889,2839, - 2788,2738,2688,2638,2587,2537,2487,2437, - 2387,2336,2286,2236,2186,2135,2085,2035, - 1985,1934,1884,1834,1784,1733,1683,1633, - 1583,1532,1482,1432,1382,1331,1281,1231, - 1181,1130,1080,1030,980,929,879,829, - 779,728,678,628,578,527,477,427, - 376,326,276,226,175,125,75,25, - -25,-75,-125,-175,-226,-276,-326,-376, - -427,-477,-527,-578,-628,-678,-728,-779, - -829,-879,-929,-980,-1030,-1080,-1130,-1181, - -1231,-1281,-1331,-1382,-1432,-1482,-1532,-1583, - -1633,-1683,-1733,-1784,-1834,-1884,-1934,-1985, - -2035,-2085,-2135,-2186,-2236,-2286,-2336,-2387, - -2437,-2487,-2537,-2588,-2638,-2688,-2738,-2788, - -2839,-2889,-2939,-2989,-3039,-3090,-3140,-3190, - -3240,-3291,-3341,-3391,-3441,-3491,-3541,-3592, - -3642,-3692,-3742,-3792,-3843,-3893,-3943,-3993, - -4043,-4093,-4144,-4194,-4244,-4294,-4344,-4394, - -4445,-4495,-4545,-4595,-4645,-4695,-4745,-4796, - -4846,-4896,-4946,-4996,-5046,-5096,-5146,-5197, - -5247,-5297,-5347,-5397,-5447,-5497,-5547,-5597, - -5647,-5697,-5748,-5798,-5848,-5898,-5948,-5998, - -6048,-6098,-6148,-6198,-6248,-6298,-6348,-6398, - -6448,-6498,-6548,-6598,-6648,-6698,-6748,-6798, - -6848,-6898,-6948,-6998,-7048,-7098,-7148,-7198, - -7248,-7298,-7348,-7398,-7448,-7498,-7548,-7598, - -7648,-7697,-7747,-7797,-7847,-7897,-7947,-7997, - -8047,-8097,-8147,-8196,-8246,-8296,-8346,-8396, - -8446,-8496,-8545,-8595,-8645,-8695,-8745,-8794, - -8844,-8894,-8944,-8994,-9043,-9093,-9143,-9193, - -9243,-9292,-9342,-9392,-9442,-9491,-9541,-9591, - -9640,-9690,-9740,-9790,-9839,-9889,-9939,-9988, - -10038,-10088,-10137,-10187,-10237,-10286,-10336,-10386, - -10435,-10485,-10534,-10584,-10634,-10683,-10733,-10782, - -10832,-10882,-10931,-10981,-11030,-11080,-11129,-11179, - -11228,-11278,-11327,-11377,-11426,-11476,-11525,-11575, - -11624,-11674,-11723,-11773,-11822,-11872,-11921,-11970, - -12020,-12069,-12119,-12168,-12218,-12267,-12316,-12366, - -12415,-12464,-12514,-12563,-12612,-12662,-12711,-12760, - -12810,-12859,-12908,-12957,-13007,-13056,-13105,-13154, - -13204,-13253,-13302,-13351,-13401,-13450,-13499,-13548, - -13597,-13647,-13696,-13745,-13794,-13843,-13892,-13941, - -13990,-14040,-14089,-14138,-14187,-14236,-14285,-14334, - -14383,-14432,-14481,-14530,-14579,-14628,-14677,-14726, - -14775,-14824,-14873,-14922,-14971,-15020,-15069,-15118, - -15167,-15215,-15264,-15313,-15362,-15411,-15460,-15509, - -15557,-15606,-15655,-15704,-15753,-15802,-15850,-15899, - -15948,-15997,-16045,-16094,-16143,-16191,-16240,-16289, - -16338,-16386,-16435,-16484,-16532,-16581,-16629,-16678, - -16727,-16775,-16824,-16872,-16921,-16970,-17018,-17067, - -17115,-17164,-17212,-17261,-17309,-17358,-17406,-17455, - -17503,-17551,-17600,-17648,-17697,-17745,-17793,-17842, - -17890,-17939,-17987,-18035,-18084,-18132,-18180,-18228, - -18277,-18325,-18373,-18421,-18470,-18518,-18566,-18614, - -18663,-18711,-18759,-18807,-18855,-18903,-18951,-19000, - -19048,-19096,-19144,-19192,-19240,-19288,-19336,-19384, - -19432,-19480,-19528,-19576,-19624,-19672,-19720,-19768, - -19816,-19864,-19912,-19959,-20007,-20055,-20103,-20151, - -20199,-20246,-20294,-20342,-20390,-20438,-20485,-20533, - -20581,-20629,-20676,-20724,-20772,-20819,-20867,-20915, - -20962,-21010,-21057,-21105,-21153,-21200,-21248,-21295, - -21343,-21390,-21438,-21485,-21533,-21580,-21628,-21675, - -21723,-21770,-21817,-21865,-21912,-21960,-22007,-22054, - -22102,-22149,-22196,-22243,-22291,-22338,-22385,-22433, - -22480,-22527,-22574,-22621,-22668,-22716,-22763,-22810, - -22857,-22904,-22951,-22998,-23045,-23092,-23139,-23186, - -23233,-23280,-23327,-23374,-23421,-23468,-23515,-23562, - -23609,-23656,-23703,-23750,-23796,-23843,-23890,-23937, - -23984,-24030,-24077,-24124,-24171,-24217,-24264,-24311, - -24357,-24404,-24451,-24497,-24544,-24591,-24637,-24684, - -24730,-24777,-24823,-24870,-24916,-24963,-25009,-25056, - -25102,-25149,-25195,-25241,-25288,-25334,-25381,-25427, - -25473,-25520,-25566,-25612,-25658,-25705,-25751,-25797, - -25843,-25889,-25936,-25982,-26028,-26074,-26120,-26166, - -26212,-26258,-26304,-26350,-26396,-26442,-26488,-26534, - -26580,-26626,-26672,-26718,-26764,-26810,-26856,-26902, - -26947,-26993,-27039,-27085,-27131,-27176,-27222,-27268, - -27313,-27359,-27405,-27450,-27496,-27542,-27587,-27633, - -27678,-27724,-27770,-27815,-27861,-27906,-27952,-27997, - -28042,-28088,-28133,-28179,-28224,-28269,-28315,-28360, - -28405,-28451,-28496,-28541,-28586,-28632,-28677,-28722, - -28767,-28812,-28858,-28903,-28948,-28993,-29038,-29083, - -29128,-29173,-29218,-29263,-29308,-29353,-29398,-29443, - -29488,-29533,-29577,-29622,-29667,-29712,-29757,-29801, - -29846,-29891,-29936,-29980,-30025,-30070,-30114,-30159, - -30204,-30248,-30293,-30337,-30382,-30426,-30471,-30515, - -30560,-30604,-30649,-30693,-30738,-30782,-30826,-30871, - -30915,-30959,-31004,-31048,-31092,-31136,-31181,-31225, - -31269,-31313,-31357,-31402,-31446,-31490,-31534,-31578, - -31622,-31666,-31710,-31754,-31798,-31842,-31886,-31930, - -31974,-32017,-32061,-32105,-32149,-32193,-32236,-32280, - -32324,-32368,-32411,-32455,-32499,-32542,-32586,-32630, - -32673,-32717,-32760,-32804,-32847,-32891,-32934,-32978, - -33021,-33065,-33108,-33151,-33195,-33238,-33281,-33325, - -33368,-33411,-33454,-33498,-33541,-33584,-33627,-33670, - -33713,-33756,-33799,-33843,-33886,-33929,-33972,-34015, - -34057,-34100,-34143,-34186,-34229,-34272,-34315,-34358, - -34400,-34443,-34486,-34529,-34571,-34614,-34657,-34699, - -34742,-34785,-34827,-34870,-34912,-34955,-34997,-35040, - -35082,-35125,-35167,-35210,-35252,-35294,-35337,-35379, - -35421,-35464,-35506,-35548,-35590,-35633,-35675,-35717, - -35759,-35801,-35843,-35885,-35927,-35969,-36011,-36053, - -36095,-36137,-36179,-36221,-36263,-36305,-36347,-36388, - -36430,-36472,-36514,-36555,-36597,-36639,-36681,-36722, - -36764,-36805,-36847,-36889,-36930,-36972,-37013,-37055, - -37096,-37137,-37179,-37220,-37262,-37303,-37344,-37386, - -37427,-37468,-37509,-37551,-37592,-37633,-37674,-37715, - -37756,-37797,-37838,-37879,-37920,-37961,-38002,-38043, - -38084,-38125,-38166,-38207,-38248,-38288,-38329,-38370, - -38411,-38451,-38492,-38533,-38573,-38614,-38655,-38695, - -38736,-38776,-38817,-38857,-38898,-38938,-38979,-39019, - -39059,-39100,-39140,-39180,-39221,-39261,-39301,-39341, - -39382,-39422,-39462,-39502,-39542,-39582,-39622,-39662, - -39702,-39742,-39782,-39822,-39862,-39902,-39942,-39982, - -40021,-40061,-40101,-40141,-40180,-40220,-40260,-40299, - -40339,-40379,-40418,-40458,-40497,-40537,-40576,-40616, - -40655,-40695,-40734,-40773,-40813,-40852,-40891,-40931, - -40970,-41009,-41048,-41087,-41127,-41166,-41205,-41244, - -41283,-41322,-41361,-41400,-41439,-41478,-41517,-41556, - -41595,-41633,-41672,-41711,-41750,-41788,-41827,-41866, - -41904,-41943,-41982,-42020,-42059,-42097,-42136,-42174, - -42213,-42251,-42290,-42328,-42366,-42405,-42443,-42481, - -42520,-42558,-42596,-42634,-42672,-42711,-42749,-42787, - -42825,-42863,-42901,-42939,-42977,-43015,-43053,-43091, - -43128,-43166,-43204,-43242,-43280,-43317,-43355,-43393, - -43430,-43468,-43506,-43543,-43581,-43618,-43656,-43693, - -43731,-43768,-43806,-43843,-43880,-43918,-43955,-43992, - -44029,-44067,-44104,-44141,-44178,-44215,-44252,-44289, - -44326,-44363,-44400,-44437,-44474,-44511,-44548,-44585, - -44622,-44659,-44695,-44732,-44769,-44806,-44842,-44879, - -44915,-44952,-44989,-45025,-45062,-45098,-45135,-45171, - -45207,-45244,-45280,-45316,-45353,-45389,-45425,-45462, - -45498,-45534,-45570,-45606,-45642,-45678,-45714,-45750, - -45786,-45822,-45858,-45894,-45930,-45966,-46002,-46037, - -46073,-46109,-46145,-46180,-46216,-46252,-46287,-46323, - -46358,-46394,-46429,-46465,-46500,-46536,-46571,-46606, - -46642,-46677,-46712,-46747,-46783,-46818,-46853,-46888, - -46923,-46958,-46993,-47028,-47063,-47098,-47133,-47168, - -47203,-47238,-47273,-47308,-47342,-47377,-47412,-47446, - -47481,-47516,-47550,-47585,-47619,-47654,-47688,-47723, - -47757,-47792,-47826,-47860,-47895,-47929,-47963,-47998, - -48032,-48066,-48100,-48134,-48168,-48202,-48236,-48271, - -48304,-48338,-48372,-48406,-48440,-48474,-48508,-48542, - -48575,-48609,-48643,-48676,-48710,-48744,-48777,-48811, - -48844,-48878,-48911,-48945,-48978,-49012,-49045,-49078, - -49112,-49145,-49178,-49211,-49244,-49278,-49311,-49344, - -49377,-49410,-49443,-49476,-49509,-49542,-49575,-49608, - -49640,-49673,-49706,-49739,-49771,-49804,-49837,-49869, - -49902,-49935,-49967,-50000,-50032,-50065,-50097,-50129, - -50162,-50194,-50226,-50259,-50291,-50323,-50355,-50387, - -50420,-50452,-50484,-50516,-50548,-50580,-50612,-50644, - -50675,-50707,-50739,-50771,-50803,-50834,-50866,-50898, - -50929,-50961,-50993,-51024,-51056,-51087,-51119,-51150, - -51182,-51213,-51244,-51276,-51307,-51338,-51369,-51401, - -51432,-51463,-51494,-51525,-51556,-51587,-51618,-51649, - -51680,-51711,-51742,-51773,-51803,-51834,-51865,-51896, - -51926,-51957,-51988,-52018,-52049,-52079,-52110,-52140, - -52171,-52201,-52231,-52262,-52292,-52322,-52353,-52383, - -52413,-52443,-52473,-52503,-52534,-52564,-52594,-52624, - -52653,-52683,-52713,-52743,-52773,-52803,-52832,-52862, - -52892,-52922,-52951,-52981,-53010,-53040,-53069,-53099, - -53128,-53158,-53187,-53216,-53246,-53275,-53304,-53334, - -53363,-53392,-53421,-53450,-53479,-53508,-53537,-53566, - -53595,-53624,-53653,-53682,-53711,-53739,-53768,-53797, - -53826,-53854,-53883,-53911,-53940,-53969,-53997,-54026, - -54054,-54082,-54111,-54139,-54167,-54196,-54224,-54252, - -54280,-54308,-54337,-54365,-54393,-54421,-54449,-54477, - -54505,-54533,-54560,-54588,-54616,-54644,-54672,-54699, - -54727,-54755,-54782,-54810,-54837,-54865,-54892,-54920, - -54947,-54974,-55002,-55029,-55056,-55084,-55111,-55138, - -55165,-55192,-55219,-55246,-55274,-55300,-55327,-55354, - -55381,-55408,-55435,-55462,-55489,-55515,-55542,-55569, - -55595,-55622,-55648,-55675,-55701,-55728,-55754,-55781, - -55807,-55833,-55860,-55886,-55912,-55938,-55965,-55991, - -56017,-56043,-56069,-56095,-56121,-56147,-56173,-56199, - -56225,-56250,-56276,-56302,-56328,-56353,-56379,-56404, - -56430,-56456,-56481,-56507,-56532,-56557,-56583,-56608, - -56633,-56659,-56684,-56709,-56734,-56760,-56785,-56810, - -56835,-56860,-56885,-56910,-56935,-56959,-56984,-57009, - -57034,-57059,-57083,-57108,-57133,-57157,-57182,-57206, - -57231,-57255,-57280,-57304,-57329,-57353,-57377,-57402, - -57426,-57450,-57474,-57498,-57522,-57546,-57570,-57594, - -57618,-57642,-57666,-57690,-57714,-57738,-57762,-57785, - -57809,-57833,-57856,-57880,-57903,-57927,-57950,-57974, - -57997,-58021,-58044,-58067,-58091,-58114,-58137,-58160, - -58183,-58207,-58230,-58253,-58276,-58299,-58322,-58345, - -58367,-58390,-58413,-58436,-58459,-58481,-58504,-58527, - -58549,-58572,-58594,-58617,-58639,-58662,-58684,-58706, - -58729,-58751,-58773,-58795,-58818,-58840,-58862,-58884, - -58906,-58928,-58950,-58972,-58994,-59016,-59038,-59059, - -59081,-59103,-59125,-59146,-59168,-59190,-59211,-59233, - -59254,-59276,-59297,-59318,-59340,-59361,-59382,-59404, - -59425,-59446,-59467,-59488,-59509,-59530,-59551,-59572, - -59593,-59614,-59635,-59656,-59677,-59697,-59718,-59739, - -59759,-59780,-59801,-59821,-59842,-59862,-59883,-59903, - -59923,-59944,-59964,-59984,-60004,-60025,-60045,-60065, - -60085,-60105,-60125,-60145,-60165,-60185,-60205,-60225, - -60244,-60264,-60284,-60304,-60323,-60343,-60363,-60382, - -60402,-60421,-60441,-60460,-60479,-60499,-60518,-60537, - -60556,-60576,-60595,-60614,-60633,-60652,-60671,-60690, - -60709,-60728,-60747,-60766,-60785,-60803,-60822,-60841, - -60859,-60878,-60897,-60915,-60934,-60952,-60971,-60989, - -61007,-61026,-61044,-61062,-61081,-61099,-61117,-61135, - -61153,-61171,-61189,-61207,-61225,-61243,-61261,-61279, - -61297,-61314,-61332,-61350,-61367,-61385,-61403,-61420, - -61438,-61455,-61473,-61490,-61507,-61525,-61542,-61559, - -61577,-61594,-61611,-61628,-61645,-61662,-61679,-61696, - -61713,-61730,-61747,-61764,-61780,-61797,-61814,-61831, - -61847,-61864,-61880,-61897,-61913,-61930,-61946,-61963, - -61979,-61995,-62012,-62028,-62044,-62060,-62076,-62092, - -62108,-62125,-62141,-62156,-62172,-62188,-62204,-62220, - -62236,-62251,-62267,-62283,-62298,-62314,-62329,-62345, - -62360,-62376,-62391,-62407,-62422,-62437,-62453,-62468, - -62483,-62498,-62513,-62528,-62543,-62558,-62573,-62588, - -62603,-62618,-62633,-62648,-62662,-62677,-62692,-62706, - -62721,-62735,-62750,-62764,-62779,-62793,-62808,-62822, - -62836,-62850,-62865,-62879,-62893,-62907,-62921,-62935, - -62949,-62963,-62977,-62991,-63005,-63019,-63032,-63046, - -63060,-63074,-63087,-63101,-63114,-63128,-63141,-63155, - -63168,-63182,-63195,-63208,-63221,-63235,-63248,-63261, - -63274,-63287,-63300,-63313,-63326,-63339,-63352,-63365, - -63378,-63390,-63403,-63416,-63429,-63441,-63454,-63466, - -63479,-63491,-63504,-63516,-63528,-63541,-63553,-63565, - -63578,-63590,-63602,-63614,-63626,-63638,-63650,-63662, - -63674,-63686,-63698,-63709,-63721,-63733,-63745,-63756, - -63768,-63779,-63791,-63803,-63814,-63825,-63837,-63848, - -63859,-63871,-63882,-63893,-63904,-63915,-63927,-63938, - -63949,-63960,-63971,-63981,-63992,-64003,-64014,-64025, - -64035,-64046,-64057,-64067,-64078,-64088,-64099,-64109, - -64120,-64130,-64140,-64151,-64161,-64171,-64181,-64192, - -64202,-64212,-64222,-64232,-64242,-64252,-64261,-64271, - -64281,-64291,-64301,-64310,-64320,-64330,-64339,-64349, - -64358,-64368,-64377,-64387,-64396,-64405,-64414,-64424, - -64433,-64442,-64451,-64460,-64469,-64478,-64487,-64496, - -64505,-64514,-64523,-64532,-64540,-64549,-64558,-64566, - -64575,-64584,-64592,-64601,-64609,-64617,-64626,-64634, - -64642,-64651,-64659,-64667,-64675,-64683,-64691,-64699, - -64707,-64715,-64723,-64731,-64739,-64747,-64754,-64762, - -64770,-64777,-64785,-64793,-64800,-64808,-64815,-64822, - -64830,-64837,-64844,-64852,-64859,-64866,-64873,-64880, - -64887,-64895,-64902,-64908,-64915,-64922,-64929,-64936, - -64943,-64949,-64956,-64963,-64969,-64976,-64982,-64989, - -64995,-65002,-65008,-65015,-65021,-65027,-65033,-65040, - -65046,-65052,-65058,-65064,-65070,-65076,-65082,-65088, - -65094,-65099,-65105,-65111,-65117,-65122,-65128,-65133, - -65139,-65144,-65150,-65155,-65161,-65166,-65171,-65177, - -65182,-65187,-65192,-65197,-65202,-65207,-65212,-65217, - -65222,-65227,-65232,-65237,-65242,-65246,-65251,-65256, - -65260,-65265,-65270,-65274,-65279,-65283,-65287,-65292, - -65296,-65300,-65305,-65309,-65313,-65317,-65321,-65325, - -65329,-65333,-65337,-65341,-65345,-65349,-65352,-65356, - -65360,-65363,-65367,-65371,-65374,-65378,-65381,-65385, - -65388,-65391,-65395,-65398,-65401,-65404,-65408,-65411, - -65414,-65417,-65420,-65423,-65426,-65429,-65431,-65434, - -65437,-65440,-65442,-65445,-65448,-65450,-65453,-65455, - -65458,-65460,-65463,-65465,-65467,-65470,-65472,-65474, - -65476,-65478,-65480,-65482,-65484,-65486,-65488,-65490, - -65492,-65494,-65496,-65497,-65499,-65501,-65502,-65504, - -65505,-65507,-65508,-65510,-65511,-65513,-65514,-65515, - -65516,-65518,-65519,-65520,-65521,-65522,-65523,-65524, - -65525,-65526,-65527,-65527,-65528,-65529,-65530,-65530, - -65531,-65531,-65532,-65532,-65533,-65533,-65534,-65534, - -65534,-65535,-65535,-65535,-65535,-65535,-65535,-65535, - -65535,-65535,-65535,-65535,-65535,-65535,-65535,-65534, - -65534,-65534,-65533,-65533,-65532,-65532,-65531,-65531, - -65530,-65530,-65529,-65528,-65527,-65527,-65526,-65525, - -65524,-65523,-65522,-65521,-65520,-65519,-65518,-65516, - -65515,-65514,-65513,-65511,-65510,-65508,-65507,-65505, - -65504,-65502,-65501,-65499,-65497,-65496,-65494,-65492, - -65490,-65488,-65486,-65484,-65482,-65480,-65478,-65476, - -65474,-65472,-65470,-65467,-65465,-65463,-65460,-65458, - -65455,-65453,-65450,-65448,-65445,-65442,-65440,-65437, - -65434,-65431,-65429,-65426,-65423,-65420,-65417,-65414, - -65411,-65408,-65404,-65401,-65398,-65395,-65391,-65388, - -65385,-65381,-65378,-65374,-65371,-65367,-65363,-65360, - -65356,-65352,-65349,-65345,-65341,-65337,-65333,-65329, - -65325,-65321,-65317,-65313,-65309,-65305,-65300,-65296, - -65292,-65287,-65283,-65279,-65274,-65270,-65265,-65260, - -65256,-65251,-65246,-65242,-65237,-65232,-65227,-65222, - -65217,-65212,-65207,-65202,-65197,-65192,-65187,-65182, - -65177,-65171,-65166,-65161,-65155,-65150,-65144,-65139, - -65133,-65128,-65122,-65117,-65111,-65105,-65099,-65094, - -65088,-65082,-65076,-65070,-65064,-65058,-65052,-65046, - -65040,-65033,-65027,-65021,-65015,-65008,-65002,-64995, - -64989,-64982,-64976,-64969,-64963,-64956,-64949,-64943, - -64936,-64929,-64922,-64915,-64908,-64902,-64895,-64887, - -64880,-64873,-64866,-64859,-64852,-64844,-64837,-64830, - -64822,-64815,-64808,-64800,-64793,-64785,-64777,-64770, - -64762,-64754,-64747,-64739,-64731,-64723,-64715,-64707, - -64699,-64691,-64683,-64675,-64667,-64659,-64651,-64642, - -64634,-64626,-64617,-64609,-64601,-64592,-64584,-64575, - -64566,-64558,-64549,-64540,-64532,-64523,-64514,-64505, - -64496,-64487,-64478,-64469,-64460,-64451,-64442,-64433, - -64424,-64414,-64405,-64396,-64387,-64377,-64368,-64358, - -64349,-64339,-64330,-64320,-64310,-64301,-64291,-64281, - -64271,-64261,-64252,-64242,-64232,-64222,-64212,-64202, - -64192,-64181,-64171,-64161,-64151,-64140,-64130,-64120, - -64109,-64099,-64088,-64078,-64067,-64057,-64046,-64035, - -64025,-64014,-64003,-63992,-63981,-63971,-63960,-63949, - -63938,-63927,-63915,-63904,-63893,-63882,-63871,-63859, - -63848,-63837,-63825,-63814,-63803,-63791,-63779,-63768, - -63756,-63745,-63733,-63721,-63709,-63698,-63686,-63674, - -63662,-63650,-63638,-63626,-63614,-63602,-63590,-63578, - -63565,-63553,-63541,-63528,-63516,-63504,-63491,-63479, - -63466,-63454,-63441,-63429,-63416,-63403,-63390,-63378, - -63365,-63352,-63339,-63326,-63313,-63300,-63287,-63274, - -63261,-63248,-63235,-63221,-63208,-63195,-63182,-63168, - -63155,-63141,-63128,-63114,-63101,-63087,-63074,-63060, - -63046,-63032,-63019,-63005,-62991,-62977,-62963,-62949, - -62935,-62921,-62907,-62893,-62879,-62865,-62850,-62836, - -62822,-62808,-62793,-62779,-62764,-62750,-62735,-62721, - -62706,-62692,-62677,-62662,-62648,-62633,-62618,-62603, - -62588,-62573,-62558,-62543,-62528,-62513,-62498,-62483, - -62468,-62453,-62437,-62422,-62407,-62391,-62376,-62360, - -62345,-62329,-62314,-62298,-62283,-62267,-62251,-62236, - -62220,-62204,-62188,-62172,-62156,-62141,-62125,-62108, - -62092,-62076,-62060,-62044,-62028,-62012,-61995,-61979, - -61963,-61946,-61930,-61913,-61897,-61880,-61864,-61847, - -61831,-61814,-61797,-61780,-61764,-61747,-61730,-61713, - -61696,-61679,-61662,-61645,-61628,-61611,-61594,-61577, - -61559,-61542,-61525,-61507,-61490,-61473,-61455,-61438, - -61420,-61403,-61385,-61367,-61350,-61332,-61314,-61297, - -61279,-61261,-61243,-61225,-61207,-61189,-61171,-61153, - -61135,-61117,-61099,-61081,-61062,-61044,-61026,-61007, - -60989,-60971,-60952,-60934,-60915,-60897,-60878,-60859, - -60841,-60822,-60803,-60785,-60766,-60747,-60728,-60709, - -60690,-60671,-60652,-60633,-60614,-60595,-60576,-60556, - -60537,-60518,-60499,-60479,-60460,-60441,-60421,-60402, - -60382,-60363,-60343,-60323,-60304,-60284,-60264,-60244, - -60225,-60205,-60185,-60165,-60145,-60125,-60105,-60085, - -60065,-60045,-60025,-60004,-59984,-59964,-59944,-59923, - -59903,-59883,-59862,-59842,-59821,-59801,-59780,-59759, - -59739,-59718,-59697,-59677,-59656,-59635,-59614,-59593, - -59572,-59551,-59530,-59509,-59488,-59467,-59446,-59425, - -59404,-59382,-59361,-59340,-59318,-59297,-59276,-59254, - -59233,-59211,-59189,-59168,-59146,-59125,-59103,-59081, - -59059,-59038,-59016,-58994,-58972,-58950,-58928,-58906, - -58884,-58862,-58840,-58818,-58795,-58773,-58751,-58729, - -58706,-58684,-58662,-58639,-58617,-58594,-58572,-58549, - -58527,-58504,-58481,-58459,-58436,-58413,-58390,-58367, - -58345,-58322,-58299,-58276,-58253,-58230,-58207,-58183, - -58160,-58137,-58114,-58091,-58067,-58044,-58021,-57997, - -57974,-57950,-57927,-57903,-57880,-57856,-57833,-57809, - -57785,-57762,-57738,-57714,-57690,-57666,-57642,-57618, - -57594,-57570,-57546,-57522,-57498,-57474,-57450,-57426, - -57402,-57377,-57353,-57329,-57304,-57280,-57255,-57231, - -57206,-57182,-57157,-57133,-57108,-57083,-57059,-57034, - -57009,-56984,-56959,-56935,-56910,-56885,-56860,-56835, - -56810,-56785,-56760,-56734,-56709,-56684,-56659,-56633, - -56608,-56583,-56557,-56532,-56507,-56481,-56456,-56430, - -56404,-56379,-56353,-56328,-56302,-56276,-56250,-56225, - -56199,-56173,-56147,-56121,-56095,-56069,-56043,-56017, - -55991,-55965,-55938,-55912,-55886,-55860,-55833,-55807, - -55781,-55754,-55728,-55701,-55675,-55648,-55622,-55595, - -55569,-55542,-55515,-55489,-55462,-55435,-55408,-55381, - -55354,-55327,-55300,-55274,-55246,-55219,-55192,-55165, - -55138,-55111,-55084,-55056,-55029,-55002,-54974,-54947, - -54920,-54892,-54865,-54837,-54810,-54782,-54755,-54727, - -54699,-54672,-54644,-54616,-54588,-54560,-54533,-54505, - -54477,-54449,-54421,-54393,-54365,-54337,-54308,-54280, - -54252,-54224,-54196,-54167,-54139,-54111,-54082,-54054, - -54026,-53997,-53969,-53940,-53911,-53883,-53854,-53826, - -53797,-53768,-53739,-53711,-53682,-53653,-53624,-53595, - -53566,-53537,-53508,-53479,-53450,-53421,-53392,-53363, - -53334,-53304,-53275,-53246,-53216,-53187,-53158,-53128, - -53099,-53069,-53040,-53010,-52981,-52951,-52922,-52892, - -52862,-52832,-52803,-52773,-52743,-52713,-52683,-52653, - -52624,-52594,-52564,-52534,-52503,-52473,-52443,-52413, - -52383,-52353,-52322,-52292,-52262,-52231,-52201,-52171, - -52140,-52110,-52079,-52049,-52018,-51988,-51957,-51926, - -51896,-51865,-51834,-51803,-51773,-51742,-51711,-51680, - -51649,-51618,-51587,-51556,-51525,-51494,-51463,-51432, - -51401,-51369,-51338,-51307,-51276,-51244,-51213,-51182, - -51150,-51119,-51087,-51056,-51024,-50993,-50961,-50929, - -50898,-50866,-50834,-50803,-50771,-50739,-50707,-50675, - -50644,-50612,-50580,-50548,-50516,-50484,-50452,-50420, - -50387,-50355,-50323,-50291,-50259,-50226,-50194,-50162, - -50129,-50097,-50065,-50032,-50000,-49967,-49935,-49902, - -49869,-49837,-49804,-49771,-49739,-49706,-49673,-49640, - -49608,-49575,-49542,-49509,-49476,-49443,-49410,-49377, - -49344,-49311,-49278,-49244,-49211,-49178,-49145,-49112, - -49078,-49045,-49012,-48978,-48945,-48911,-48878,-48844, - -48811,-48777,-48744,-48710,-48676,-48643,-48609,-48575, - -48542,-48508,-48474,-48440,-48406,-48372,-48338,-48305, - -48271,-48237,-48202,-48168,-48134,-48100,-48066,-48032, - -47998,-47963,-47929,-47895,-47860,-47826,-47792,-47757, - -47723,-47688,-47654,-47619,-47585,-47550,-47516,-47481, - -47446,-47412,-47377,-47342,-47307,-47273,-47238,-47203, - -47168,-47133,-47098,-47063,-47028,-46993,-46958,-46923, - -46888,-46853,-46818,-46783,-46747,-46712,-46677,-46642, - -46606,-46571,-46536,-46500,-46465,-46429,-46394,-46358, - -46323,-46287,-46251,-46216,-46180,-46145,-46109,-46073, - -46037,-46002,-45966,-45930,-45894,-45858,-45822,-45786, - -45750,-45714,-45678,-45642,-45606,-45570,-45534,-45498, - -45462,-45425,-45389,-45353,-45316,-45280,-45244,-45207, - -45171,-45135,-45098,-45062,-45025,-44989,-44952,-44915, - -44879,-44842,-44806,-44769,-44732,-44695,-44659,-44622, - -44585,-44548,-44511,-44474,-44437,-44400,-44363,-44326, - -44289,-44252,-44215,-44178,-44141,-44104,-44067,-44029, - -43992,-43955,-43918,-43880,-43843,-43806,-43768,-43731, - -43693,-43656,-43618,-43581,-43543,-43506,-43468,-43430, - -43393,-43355,-43317,-43280,-43242,-43204,-43166,-43128, - -43091,-43053,-43015,-42977,-42939,-42901,-42863,-42825, - -42787,-42749,-42711,-42672,-42634,-42596,-42558,-42520, - -42481,-42443,-42405,-42366,-42328,-42290,-42251,-42213, - -42174,-42136,-42097,-42059,-42020,-41982,-41943,-41904, - -41866,-41827,-41788,-41750,-41711,-41672,-41633,-41595, - -41556,-41517,-41478,-41439,-41400,-41361,-41322,-41283, - -41244,-41205,-41166,-41127,-41087,-41048,-41009,-40970, - -40931,-40891,-40852,-40813,-40773,-40734,-40695,-40655, - -40616,-40576,-40537,-40497,-40458,-40418,-40379,-40339, - -40299,-40260,-40220,-40180,-40141,-40101,-40061,-40021, - -39982,-39942,-39902,-39862,-39822,-39782,-39742,-39702, - -39662,-39622,-39582,-39542,-39502,-39462,-39422,-39382, - -39341,-39301,-39261,-39221,-39180,-39140,-39100,-39059, - -39019,-38979,-38938,-38898,-38857,-38817,-38776,-38736, - -38695,-38655,-38614,-38573,-38533,-38492,-38451,-38411, - -38370,-38329,-38288,-38248,-38207,-38166,-38125,-38084, - -38043,-38002,-37961,-37920,-37879,-37838,-37797,-37756, - -37715,-37674,-37633,-37592,-37550,-37509,-37468,-37427, - -37386,-37344,-37303,-37262,-37220,-37179,-37137,-37096, - -37055,-37013,-36972,-36930,-36889,-36847,-36805,-36764, - -36722,-36681,-36639,-36597,-36556,-36514,-36472,-36430, - -36388,-36347,-36305,-36263,-36221,-36179,-36137,-36095, - -36053,-36011,-35969,-35927,-35885,-35843,-35801,-35759, - -35717,-35675,-35633,-35590,-35548,-35506,-35464,-35421, - -35379,-35337,-35294,-35252,-35210,-35167,-35125,-35082, - -35040,-34997,-34955,-34912,-34870,-34827,-34785,-34742, - -34699,-34657,-34614,-34571,-34529,-34486,-34443,-34400, - -34358,-34315,-34272,-34229,-34186,-34143,-34100,-34057, - -34015,-33972,-33929,-33886,-33843,-33799,-33756,-33713, - -33670,-33627,-33584,-33541,-33498,-33454,-33411,-33368, - -33325,-33281,-33238,-33195,-33151,-33108,-33065,-33021, - -32978,-32934,-32891,-32847,-32804,-32760,-32717,-32673, - -32630,-32586,-32542,-32499,-32455,-32411,-32368,-32324, - -32280,-32236,-32193,-32149,-32105,-32061,-32017,-31974, - -31930,-31886,-31842,-31798,-31754,-31710,-31666,-31622, - -31578,-31534,-31490,-31446,-31402,-31357,-31313,-31269, - -31225,-31181,-31136,-31092,-31048,-31004,-30959,-30915, - -30871,-30826,-30782,-30738,-30693,-30649,-30604,-30560, - -30515,-30471,-30426,-30382,-30337,-30293,-30248,-30204, - -30159,-30114,-30070,-30025,-29980,-29936,-29891,-29846, - -29801,-29757,-29712,-29667,-29622,-29577,-29533,-29488, - -29443,-29398,-29353,-29308,-29263,-29218,-29173,-29128, - -29083,-29038,-28993,-28948,-28903,-28858,-28812,-28767, - -28722,-28677,-28632,-28586,-28541,-28496,-28451,-28405, - -28360,-28315,-28269,-28224,-28179,-28133,-28088,-28042, - -27997,-27952,-27906,-27861,-27815,-27770,-27724,-27678, - -27633,-27587,-27542,-27496,-27450,-27405,-27359,-27313, - -27268,-27222,-27176,-27131,-27085,-27039,-26993,-26947, - -26902,-26856,-26810,-26764,-26718,-26672,-26626,-26580, - -26534,-26488,-26442,-26396,-26350,-26304,-26258,-26212, - -26166,-26120,-26074,-26028,-25982,-25936,-25889,-25843, - -25797,-25751,-25705,-25658,-25612,-25566,-25520,-25473, - -25427,-25381,-25334,-25288,-25241,-25195,-25149,-25102, - -25056,-25009,-24963,-24916,-24870,-24823,-24777,-24730, - -24684,-24637,-24591,-24544,-24497,-24451,-24404,-24357, - -24311,-24264,-24217,-24171,-24124,-24077,-24030,-23984, - -23937,-23890,-23843,-23796,-23750,-23703,-23656,-23609, - -23562,-23515,-23468,-23421,-23374,-23327,-23280,-23233, - -23186,-23139,-23092,-23045,-22998,-22951,-22904,-22857, - -22810,-22763,-22716,-22668,-22621,-22574,-22527,-22480, - -22432,-22385,-22338,-22291,-22243,-22196,-22149,-22102, - -22054,-22007,-21960,-21912,-21865,-21817,-21770,-21723, - -21675,-21628,-21580,-21533,-21485,-21438,-21390,-21343, - -21295,-21248,-21200,-21153,-21105,-21057,-21010,-20962, - -20915,-20867,-20819,-20772,-20724,-20676,-20629,-20581, - -20533,-20485,-20438,-20390,-20342,-20294,-20246,-20199, - -20151,-20103,-20055,-20007,-19959,-19912,-19864,-19816, - -19768,-19720,-19672,-19624,-19576,-19528,-19480,-19432, - -19384,-19336,-19288,-19240,-19192,-19144,-19096,-19048, - -19000,-18951,-18903,-18855,-18807,-18759,-18711,-18663, - -18614,-18566,-18518,-18470,-18421,-18373,-18325,-18277, - -18228,-18180,-18132,-18084,-18035,-17987,-17939,-17890, - -17842,-17793,-17745,-17697,-17648,-17600,-17551,-17503, - -17455,-17406,-17358,-17309,-17261,-17212,-17164,-17115, - -17067,-17018,-16970,-16921,-16872,-16824,-16775,-16727, - -16678,-16629,-16581,-16532,-16484,-16435,-16386,-16338, - -16289,-16240,-16191,-16143,-16094,-16045,-15997,-15948, - -15899,-15850,-15802,-15753,-15704,-15655,-15606,-15557, - -15509,-15460,-15411,-15362,-15313,-15264,-15215,-15167, - -15118,-15069,-15020,-14971,-14922,-14873,-14824,-14775, - -14726,-14677,-14628,-14579,-14530,-14481,-14432,-14383, - -14334,-14285,-14236,-14187,-14138,-14089,-14040,-13990, - -13941,-13892,-13843,-13794,-13745,-13696,-13647,-13597, - -13548,-13499,-13450,-13401,-13351,-13302,-13253,-13204, - -13154,-13105,-13056,-13007,-12957,-12908,-12859,-12810, - -12760,-12711,-12662,-12612,-12563,-12514,-12464,-12415, - -12366,-12316,-12267,-12217,-12168,-12119,-12069,-12020, - -11970,-11921,-11872,-11822,-11773,-11723,-11674,-11624, - -11575,-11525,-11476,-11426,-11377,-11327,-11278,-11228, - -11179,-11129,-11080,-11030,-10981,-10931,-10882,-10832, - -10782,-10733,-10683,-10634,-10584,-10534,-10485,-10435, - -10386,-10336,-10286,-10237,-10187,-10137,-10088,-10038, - -9988,-9939,-9889,-9839,-9790,-9740,-9690,-9640, - -9591,-9541,-9491,-9442,-9392,-9342,-9292,-9243, - -9193,-9143,-9093,-9043,-8994,-8944,-8894,-8844, - -8794,-8745,-8695,-8645,-8595,-8545,-8496,-8446, - -8396,-8346,-8296,-8246,-8196,-8147,-8097,-8047, - -7997,-7947,-7897,-7847,-7797,-7747,-7697,-7648, - -7598,-7548,-7498,-7448,-7398,-7348,-7298,-7248, - -7198,-7148,-7098,-7048,-6998,-6948,-6898,-6848, - -6798,-6748,-6698,-6648,-6598,-6548,-6498,-6448, - -6398,-6348,-6298,-6248,-6198,-6148,-6098,-6048, - -5998,-5948,-5898,-5848,-5798,-5747,-5697,-5647, - -5597,-5547,-5497,-5447,-5397,-5347,-5297,-5247, - -5197,-5146,-5096,-5046,-4996,-4946,-4896,-4846, - -4796,-4745,-4695,-4645,-4595,-4545,-4495,-4445, - -4394,-4344,-4294,-4244,-4194,-4144,-4093,-4043, - -3993,-3943,-3893,-3843,-3792,-3742,-3692,-3642, - -3592,-3541,-3491,-3441,-3391,-3341,-3291,-3240, - -3190,-3140,-3090,-3039,-2989,-2939,-2889,-2839, - -2788,-2738,-2688,-2638,-2588,-2537,-2487,-2437, - -2387,-2336,-2286,-2236,-2186,-2135,-2085,-2035, - -1985,-1934,-1884,-1834,-1784,-1733,-1683,-1633, - -1583,-1532,-1482,-1432,-1382,-1331,-1281,-1231, - -1181,-1130,-1080,-1030,-980,-929,-879,-829, - -779,-728,-678,-628,-578,-527,-477,-427, - -376,-326,-276,-226,-175,-125,-75,-25, - 25,75,125,175,226,276,326,376, - 427,477,527,578,628,678,728,779, - 829,879,929,980,1030,1080,1130,1181, - 1231,1281,1331,1382,1432,1482,1532,1583, - 1633,1683,1733,1784,1834,1884,1934,1985, - 2035,2085,2135,2186,2236,2286,2336,2387, - 2437,2487,2537,2587,2638,2688,2738,2788, - 2839,2889,2939,2989,3039,3090,3140,3190, - 3240,3291,3341,3391,3441,3491,3542,3592, - 3642,3692,3742,3792,3843,3893,3943,3993, - 4043,4093,4144,4194,4244,4294,4344,4394, - 4445,4495,4545,4595,4645,4695,4745,4796, - 4846,4896,4946,4996,5046,5096,5146,5197, - 5247,5297,5347,5397,5447,5497,5547,5597, - 5647,5697,5747,5798,5848,5898,5948,5998, - 6048,6098,6148,6198,6248,6298,6348,6398, - 6448,6498,6548,6598,6648,6698,6748,6798, - 6848,6898,6948,6998,7048,7098,7148,7198, - 7248,7298,7348,7398,7448,7498,7548,7598, - 7648,7697,7747,7797,7847,7897,7947,7997, - 8047,8097,8147,8196,8246,8296,8346,8396, - 8446,8496,8545,8595,8645,8695,8745,8794, - 8844,8894,8944,8994,9043,9093,9143,9193, - 9243,9292,9342,9392,9442,9491,9541,9591, - 9640,9690,9740,9790,9839,9889,9939,9988, - 10038,10088,10137,10187,10237,10286,10336,10386, - 10435,10485,10534,10584,10634,10683,10733,10782, - 10832,10882,10931,10981,11030,11080,11129,11179, - 11228,11278,11327,11377,11426,11476,11525,11575, - 11624,11674,11723,11773,11822,11872,11921,11970, - 12020,12069,12119,12168,12218,12267,12316,12366, - 12415,12464,12514,12563,12612,12662,12711,12760, - 12810,12859,12908,12957,13007,13056,13105,13154, - 13204,13253,13302,13351,13401,13450,13499,13548, - 13597,13647,13696,13745,13794,13843,13892,13941, - 13990,14040,14089,14138,14187,14236,14285,14334, - 14383,14432,14481,14530,14579,14628,14677,14726, - 14775,14824,14873,14922,14971,15020,15069,15118, - 15167,15215,15264,15313,15362,15411,15460,15509, - 15557,15606,15655,15704,15753,15802,15850,15899, - 15948,15997,16045,16094,16143,16191,16240,16289, - 16338,16386,16435,16484,16532,16581,16629,16678, - 16727,16775,16824,16872,16921,16970,17018,17067, - 17115,17164,17212,17261,17309,17358,17406,17455, - 17503,17551,17600,17648,17697,17745,17793,17842, - 17890,17939,17987,18035,18084,18132,18180,18228, - 18277,18325,18373,18421,18470,18518,18566,18614, - 18663,18711,18759,18807,18855,18903,18951,19000, - 19048,19096,19144,19192,19240,19288,19336,19384, - 19432,19480,19528,19576,19624,19672,19720,19768, - 19816,19864,19912,19959,20007,20055,20103,20151, - 20199,20246,20294,20342,20390,20438,20485,20533, - 20581,20629,20676,20724,20772,20819,20867,20915, - 20962,21010,21057,21105,21153,21200,21248,21295, - 21343,21390,21438,21485,21533,21580,21628,21675, - 21723,21770,21817,21865,21912,21960,22007,22054, - 22102,22149,22196,22243,22291,22338,22385,22432, - 22480,22527,22574,22621,22668,22716,22763,22810, - 22857,22904,22951,22998,23045,23092,23139,23186, - 23233,23280,23327,23374,23421,23468,23515,23562, - 23609,23656,23703,23750,23796,23843,23890,23937, - 23984,24030,24077,24124,24171,24217,24264,24311, - 24357,24404,24451,24497,24544,24591,24637,24684, - 24730,24777,24823,24870,24916,24963,25009,25056, - 25102,25149,25195,25241,25288,25334,25381,25427, - 25473,25520,25566,25612,25658,25705,25751,25797, - 25843,25889,25936,25982,26028,26074,26120,26166, - 26212,26258,26304,26350,26396,26442,26488,26534, - 26580,26626,26672,26718,26764,26810,26856,26902, - 26947,26993,27039,27085,27131,27176,27222,27268, - 27313,27359,27405,27450,27496,27542,27587,27633, - 27678,27724,27770,27815,27861,27906,27952,27997, - 28042,28088,28133,28179,28224,28269,28315,28360, - 28405,28451,28496,28541,28586,28632,28677,28722, - 28767,28812,28858,28903,28948,28993,29038,29083, - 29128,29173,29218,29263,29308,29353,29398,29443, - 29488,29533,29577,29622,29667,29712,29757,29801, - 29846,29891,29936,29980,30025,30070,30114,30159, - 30204,30248,30293,30337,30382,30427,30471,30516, - 30560,30604,30649,30693,30738,30782,30826,30871, - 30915,30959,31004,31048,31092,31136,31181,31225, - 31269,31313,31357,31402,31446,31490,31534,31578, - 31622,31666,31710,31754,31798,31842,31886,31930, - 31974,32017,32061,32105,32149,32193,32236,32280, - 32324,32368,32411,32455,32499,32542,32586,32630, - 32673,32717,32760,32804,32847,32891,32934,32978, - 33021,33065,33108,33151,33195,33238,33281,33325, - 33368,33411,33454,33498,33541,33584,33627,33670, - 33713,33756,33799,33843,33886,33929,33972,34015, - 34057,34100,34143,34186,34229,34272,34315,34358, - 34400,34443,34486,34529,34571,34614,34657,34699, - 34742,34785,34827,34870,34912,34955,34997,35040, - 35082,35125,35167,35210,35252,35294,35337,35379, - 35421,35464,35506,35548,35590,35633,35675,35717, - 35759,35801,35843,35885,35927,35969,36011,36053, - 36095,36137,36179,36221,36263,36305,36347,36388, - 36430,36472,36514,36556,36597,36639,36681,36722, - 36764,36805,36847,36889,36930,36972,37013,37055, - 37096,37137,37179,37220,37262,37303,37344,37386, - 37427,37468,37509,37551,37592,37633,37674,37715, - 37756,37797,37838,37879,37920,37961,38002,38043, - 38084,38125,38166,38207,38248,38288,38329,38370, - 38411,38451,38492,38533,38573,38614,38655,38695, - 38736,38776,38817,38857,38898,38938,38979,39019, - 39059,39100,39140,39180,39221,39261,39301,39341, - 39382,39422,39462,39502,39542,39582,39622,39662, - 39702,39742,39782,39822,39862,39902,39942,39982, - 40021,40061,40101,40141,40180,40220,40260,40299, - 40339,40379,40418,40458,40497,40537,40576,40616, - 40655,40695,40734,40773,40813,40852,40891,40931, - 40970,41009,41048,41087,41127,41166,41205,41244, - 41283,41322,41361,41400,41439,41478,41517,41556, - 41595,41633,41672,41711,41750,41788,41827,41866, - 41904,41943,41982,42020,42059,42097,42136,42174, - 42213,42251,42290,42328,42366,42405,42443,42481, - 42520,42558,42596,42634,42672,42711,42749,42787, - 42825,42863,42901,42939,42977,43015,43053,43091, - 43128,43166,43204,43242,43280,43317,43355,43393, - 43430,43468,43506,43543,43581,43618,43656,43693, - 43731,43768,43806,43843,43880,43918,43955,43992, - 44029,44067,44104,44141,44178,44215,44252,44289, - 44326,44363,44400,44437,44474,44511,44548,44585, - 44622,44659,44695,44732,44769,44806,44842,44879, - 44915,44952,44989,45025,45062,45098,45135,45171, - 45207,45244,45280,45316,45353,45389,45425,45462, - 45498,45534,45570,45606,45642,45678,45714,45750, - 45786,45822,45858,45894,45930,45966,46002,46037, - 46073,46109,46145,46180,46216,46252,46287,46323, - 46358,46394,46429,46465,46500,46536,46571,46606, - 46642,46677,46712,46747,46783,46818,46853,46888, - 46923,46958,46993,47028,47063,47098,47133,47168, - 47203,47238,47273,47308,47342,47377,47412,47446, - 47481,47516,47550,47585,47619,47654,47688,47723, - 47757,47792,47826,47861,47895,47929,47963,47998, - 48032,48066,48100,48134,48168,48202,48237,48271, - 48305,48338,48372,48406,48440,48474,48508,48542, - 48575,48609,48643,48676,48710,48744,48777,48811, - 48844,48878,48911,48945,48978,49012,49045,49078, - 49112,49145,49178,49211,49244,49278,49311,49344, - 49377,49410,49443,49476,49509,49542,49575,49608, - 49640,49673,49706,49739,49771,49804,49837,49869, - 49902,49935,49967,50000,50032,50064,50097,50129, - 50162,50194,50226,50259,50291,50323,50355,50387, - 50420,50452,50484,50516,50548,50580,50612,50644, - 50675,50707,50739,50771,50803,50834,50866,50898, - 50929,50961,50993,51024,51056,51087,51119,51150, - 51182,51213,51244,51276,51307,51338,51369,51401, - 51432,51463,51494,51525,51556,51587,51618,51649, - 51680,51711,51742,51773,51803,51834,51865,51896, - 51926,51957,51988,52018,52049,52079,52110,52140, - 52171,52201,52231,52262,52292,52322,52353,52383, - 52413,52443,52473,52503,52534,52564,52594,52624, - 52653,52683,52713,52743,52773,52803,52832,52862, - 52892,52922,52951,52981,53010,53040,53069,53099, - 53128,53158,53187,53216,53246,53275,53304,53334, - 53363,53392,53421,53450,53479,53508,53537,53566, - 53595,53624,53653,53682,53711,53739,53768,53797, - 53826,53854,53883,53912,53940,53969,53997,54026, - 54054,54082,54111,54139,54167,54196,54224,54252, - 54280,54309,54337,54365,54393,54421,54449,54477, - 54505,54533,54560,54588,54616,54644,54672,54699, - 54727,54755,54782,54810,54837,54865,54892,54920, - 54947,54974,55002,55029,55056,55084,55111,55138, - 55165,55192,55219,55246,55274,55300,55327,55354, - 55381,55408,55435,55462,55489,55515,55542,55569, - 55595,55622,55648,55675,55701,55728,55754,55781, - 55807,55833,55860,55886,55912,55938,55965,55991, - 56017,56043,56069,56095,56121,56147,56173,56199, - 56225,56250,56276,56302,56328,56353,56379,56404, - 56430,56456,56481,56507,56532,56557,56583,56608, - 56633,56659,56684,56709,56734,56760,56785,56810, - 56835,56860,56885,56910,56935,56959,56984,57009, - 57034,57059,57083,57108,57133,57157,57182,57206, - 57231,57255,57280,57304,57329,57353,57377,57402, - 57426,57450,57474,57498,57522,57546,57570,57594, - 57618,57642,57666,57690,57714,57738,57762,57785, - 57809,57833,57856,57880,57903,57927,57950,57974, - 57997,58021,58044,58067,58091,58114,58137,58160, - 58183,58207,58230,58253,58276,58299,58322,58345, - 58367,58390,58413,58436,58459,58481,58504,58527, - 58549,58572,58594,58617,58639,58662,58684,58706, - 58729,58751,58773,58795,58818,58840,58862,58884, - 58906,58928,58950,58972,58994,59016,59038,59059, - 59081,59103,59125,59146,59168,59190,59211,59233, - 59254,59276,59297,59318,59340,59361,59382,59404, - 59425,59446,59467,59488,59509,59530,59551,59572, - 59593,59614,59635,59656,59677,59697,59718,59739, - 59759,59780,59801,59821,59842,59862,59883,59903, - 59923,59944,59964,59984,60004,60025,60045,60065, - 60085,60105,60125,60145,60165,60185,60205,60225, - 60244,60264,60284,60304,60323,60343,60363,60382, - 60402,60421,60441,60460,60479,60499,60518,60537, - 60556,60576,60595,60614,60633,60652,60671,60690, - 60709,60728,60747,60766,60785,60803,60822,60841, - 60859,60878,60897,60915,60934,60952,60971,60989, - 61007,61026,61044,61062,61081,61099,61117,61135, - 61153,61171,61189,61207,61225,61243,61261,61279, - 61297,61314,61332,61350,61367,61385,61403,61420, - 61438,61455,61473,61490,61507,61525,61542,61559, - 61577,61594,61611,61628,61645,61662,61679,61696, - 61713,61730,61747,61764,61780,61797,61814,61831, - 61847,61864,61880,61897,61913,61930,61946,61963, - 61979,61995,62012,62028,62044,62060,62076,62092, - 62108,62125,62141,62156,62172,62188,62204,62220, - 62236,62251,62267,62283,62298,62314,62329,62345, - 62360,62376,62391,62407,62422,62437,62453,62468, - 62483,62498,62513,62528,62543,62558,62573,62588, - 62603,62618,62633,62648,62662,62677,62692,62706, - 62721,62735,62750,62764,62779,62793,62808,62822, - 62836,62850,62865,62879,62893,62907,62921,62935, - 62949,62963,62977,62991,63005,63019,63032,63046, - 63060,63074,63087,63101,63114,63128,63141,63155, - 63168,63182,63195,63208,63221,63235,63248,63261, - 63274,63287,63300,63313,63326,63339,63352,63365, - 63378,63390,63403,63416,63429,63441,63454,63466, - 63479,63491,63504,63516,63528,63541,63553,63565, - 63578,63590,63602,63614,63626,63638,63650,63662, - 63674,63686,63698,63709,63721,63733,63745,63756, - 63768,63779,63791,63803,63814,63825,63837,63848, - 63859,63871,63882,63893,63904,63915,63927,63938, - 63949,63960,63971,63981,63992,64003,64014,64025, - 64035,64046,64057,64067,64078,64088,64099,64109, - 64120,64130,64140,64151,64161,64171,64181,64192, - 64202,64212,64222,64232,64242,64252,64261,64271, - 64281,64291,64301,64310,64320,64330,64339,64349, - 64358,64368,64377,64387,64396,64405,64414,64424, - 64433,64442,64451,64460,64469,64478,64487,64496, - 64505,64514,64523,64532,64540,64549,64558,64566, - 64575,64584,64592,64600,64609,64617,64626,64634, - 64642,64651,64659,64667,64675,64683,64691,64699, - 64707,64715,64723,64731,64739,64747,64754,64762, - 64770,64777,64785,64793,64800,64808,64815,64822, - 64830,64837,64844,64852,64859,64866,64873,64880, - 64887,64895,64902,64908,64915,64922,64929,64936, - 64943,64949,64956,64963,64969,64976,64982,64989, - 64995,65002,65008,65015,65021,65027,65033,65040, - 65046,65052,65058,65064,65070,65076,65082,65088, - 65094,65099,65105,65111,65117,65122,65128,65133, - 65139,65144,65150,65155,65161,65166,65171,65177, - 65182,65187,65192,65197,65202,65207,65212,65217, - 65222,65227,65232,65237,65242,65246,65251,65256, - 65260,65265,65270,65274,65279,65283,65287,65292, - 65296,65300,65305,65309,65313,65317,65321,65325, - 65329,65333,65337,65341,65345,65349,65352,65356, - 65360,65363,65367,65371,65374,65378,65381,65385, - 65388,65391,65395,65398,65401,65404,65408,65411, - 65414,65417,65420,65423,65426,65429,65431,65434, - 65437,65440,65442,65445,65448,65450,65453,65455, - 65458,65460,65463,65465,65467,65470,65472,65474, - 65476,65478,65480,65482,65484,65486,65488,65490, - 65492,65494,65496,65497,65499,65501,65502,65504, - 65505,65507,65508,65510,65511,65513,65514,65515, - 65516,65518,65519,65520,65521,65522,65523,65524, - 65525,65526,65527,65527,65528,65529,65530,65530, - 65531,65531,65532,65532,65533,65533,65534,65534, - 65534,65535,65535,65535,65535,65535,65535,65535 -}; - - - -const angle_t tantoangle[2049] = -{ - 0,333772,667544,1001315,1335086,1668857,2002626,2336395, - 2670163,3003929,3337694,3671457,4005219,4338979,4672736,5006492, - 5340245,5673995,6007743,6341488,6675230,7008968,7342704,7676435, - 8010164,8343888,8677609,9011325,9345037,9678744,10012447,10346145, - 10679838,11013526,11347209,11680887,12014558,12348225,12681885,13015539, - 13349187,13682829,14016464,14350092,14683714,15017328,15350936,15684536, - 16018129,16351714,16685291,17018860,17352422,17685974,18019518,18353054, - 18686582,19020100,19353610,19687110,20020600,20354080,20687552,21021014, - 21354466,21687906,22021338,22354758,22688168,23021568,23354956,23688332, - 24021698,24355052,24688396,25021726,25355046,25688352,26021648,26354930, - 26688200,27021456,27354702,27687932,28021150,28354356,28687548,29020724, - 29353888,29687038,30020174,30353296,30686404,31019496,31352574,31685636, - 32018684,32351718,32684734,33017736,33350722,33683692,34016648,34349584, - 34682508,35015412,35348300,35681172,36014028,36346868,36679688,37012492, - 37345276,37678044,38010792,38343524,38676240,39008936,39341612,39674272, - 40006912,40339532,40672132,41004716,41337276,41669820,42002344,42334848, - 42667332,42999796,43332236,43664660,43997060,44329444,44661800,44994140, - 45326456,45658752,45991028,46323280,46655512,46987720,47319908,47652072, - 47984212,48316332,48648428,48980500,49312548,49644576,49976580,50308556, - 50640512,50972444,51304352,51636236,51968096,52299928,52631740,52963524, - 53295284,53627020,53958728,54290412,54622068,54953704,55285308,55616888, - 55948444,56279972,56611472,56942948,57274396,57605816,57937212,58268576, - 58599916,58931228,59262512,59593768,59924992,60256192,60587364,60918508, - 61249620,61580704,61911760,62242788,62573788,62904756,63235692,63566604, - 63897480,64228332,64559148,64889940,65220696,65551424,65882120,66212788, - 66543420,66874024,67204600,67535136,67865648,68196120,68526568,68856984, - 69187360,69517712,69848024,70178304,70508560,70838776,71168960,71499112, - 71829224,72159312,72489360,72819376,73149360,73479304,73809216,74139096, - 74468936,74798744,75128520,75458264,75787968,76117632,76447264,76776864, - 77106424,77435952,77765440,78094888,78424304,78753688,79083032,79412336, - 79741608,80070840,80400032,80729192,81058312,81387392,81716432,82045440, - 82374408,82703336,83032224,83361080,83689896,84018664,84347400,84676096, - 85004760,85333376,85661952,85990488,86318984,86647448,86975864,87304240, - 87632576,87960872,88289128,88617344,88945520,89273648,89601736,89929792, - 90257792,90585760,90913688,91241568,91569408,91897200,92224960,92552672, - 92880336,93207968,93535552,93863088,94190584,94518040,94845448,95172816, - 95500136,95827416,96154648,96481832,96808976,97136080,97463136,97790144, - 98117112,98444032,98770904,99097736,99424520,99751256,100077944,100404592, - 100731192,101057744,101384248,101710712,102037128,102363488,102689808,103016080, - 103342312,103668488,103994616,104320696,104646736,104972720,105298656,105624552, - 105950392,106276184,106601928,106927624,107253272,107578872,107904416,108229920, - 108555368,108880768,109206120,109531416,109856664,110181872,110507016,110832120, - 111157168,111482168,111807112,112132008,112456856,112781648,113106392,113431080, - 113755720,114080312,114404848,114729328,115053760,115378136,115702464,116026744, - 116350960,116675128,116999248,117323312,117647320,117971272,118295176,118619024, - 118942816,119266560,119590248,119913880,120237456,120560984,120884456,121207864, - 121531224,121854528,122177784,122500976,122824112,123147200,123470224,123793200, - 124116120,124438976,124761784,125084528,125407224,125729856,126052432,126374960, - 126697424,127019832,127342184,127664472,127986712,128308888,128631008,128953072, - 129275080,129597024,129918912,130240744,130562520,130884232,131205888,131527480, - 131849016,132170496,132491912,132813272,133134576,133455816,133776992,134098120, - 134419184,134740176,135061120,135382000,135702816,136023584,136344272,136664912, - 136985488,137306016,137626464,137946864,138267184,138587456,138907664,139227808, - 139547904,139867920,140187888,140507776,140827616,141147392,141467104,141786752, - 142106336,142425856,142745312,143064720,143384048,143703312,144022512,144341664, - 144660736,144979744,145298704,145617584,145936400,146255168,146573856,146892480, - 147211040,147529536,147847968,148166336,148484640,148802880,149121056,149439152, - 149757200,150075168,150393072,150710912,151028688,151346400,151664048,151981616, - 152299136,152616576,152933952,153251264,153568496,153885680,154202784,154519824, - 154836784,155153696,155470528,155787296,156104000,156420624,156737200,157053696, - 157370112,157686480,158002768,158318976,158635136,158951216,159267232,159583168, - 159899040,160214848,160530592,160846256,161161840,161477376,161792832,162108208, - 162423520,162738768,163053952,163369040,163684080,163999040,164313936,164628752, - 164943504,165258176,165572784,165887312,166201776,166516160,166830480,167144736, - 167458912,167773008,168087040,168400992,168714880,169028688,169342432,169656096, - 169969696,170283216,170596672,170910032,171223344,171536576,171849728,172162800, - 172475808,172788736,173101600,173414384,173727104,174039728,174352288,174664784, - 174977200,175289536,175601792,175913984,176226096,176538144,176850096,177161984, - 177473792,177785536,178097200,178408784,178720288,179031728,179343088,179654368, - 179965568,180276704,180587744,180898720,181209616,181520448,181831184,182141856, - 182452448,182762960,183073408,183383760,183694048,184004240,184314368,184624416, - 184934400,185244288,185554096,185863840,186173504,186483072,186792576,187102000, - 187411344,187720608,188029808,188338912,188647936,188956896,189265760,189574560, - 189883264,190191904,190500448,190808928,191117312,191425632,191733872,192042016, - 192350096,192658096,192966000,193273840,193581584,193889264,194196848,194504352, - 194811792,195119136,195426400,195733584,196040688,196347712,196654656,196961520, - 197268304,197574992,197881616,198188144,198494592,198800960,199107248,199413456, - 199719584,200025616,200331584,200637456,200943248,201248960,201554576,201860128, - 202165584,202470960,202776256,203081456,203386592,203691632,203996592,204301472, - 204606256,204910976,205215600,205520144,205824592,206128960,206433248,206737456, - 207041584,207345616,207649568,207953424,208257216,208560912,208864512,209168048, - 209471488,209774832,210078112,210381296,210684384,210987408,211290336,211593184, - 211895936,212198608,212501184,212803680,213106096,213408432,213710672,214012816, - 214314880,214616864,214918768,215220576,215522288,215823920,216125472,216426928, - 216728304,217029584,217330784,217631904,217932928,218233856,218534704,218835472, - 219136144,219436720,219737216,220037632,220337952,220638192,220938336,221238384, - 221538352,221838240,222138032,222437728,222737344,223036880,223336304,223635664, - 223934912,224234096,224533168,224832160,225131072,225429872,225728608,226027232, - 226325776,226624240,226922608,227220880,227519056,227817152,228115168,228413088, - 228710912,229008640,229306288,229603840,229901312,230198688,230495968,230793152, - 231090256,231387280,231684192,231981024,232277760,232574416,232870960,233167440, - 233463808,233760096,234056288,234352384,234648384,234944304,235240128,235535872, - 235831504,236127056,236422512,236717888,237013152,237308336,237603424,237898416, - 238193328,238488144,238782864,239077488,239372016,239666464,239960816,240255072, - 240549232,240843312,241137280,241431168,241724960,242018656,242312256,242605776, - 242899200,243192512,243485744,243778896,244071936,244364880,244657744,244950496, - 245243168,245535744,245828224,246120608,246412912,246705104,246997216,247289216, - 247581136,247872960,248164688,248456320,248747856,249039296,249330640,249621904, - 249913056,250204128,250495088,250785968,251076736,251367424,251658016,251948512, - 252238912,252529200,252819408,253109520,253399536,253689456,253979280,254269008, - 254558640,254848176,255137632,255426976,255716224,256005376,256294432,256583392, - 256872256,257161024,257449696,257738272,258026752,258315136,258603424,258891600, - 259179696,259467696,259755600,260043392,260331104,260618704,260906224,261193632, - 261480960,261768176,262055296,262342320,262629248,262916080,263202816,263489456, - 263776000,264062432,264348784,264635024,264921168,265207216,265493168,265779024, - 266064784,266350448,266636000,266921472,267206832,267492096,267777264,268062336, - 268347312,268632192,268916960,269201632,269486208,269770688,270055072,270339360, - 270623552,270907616,271191616,271475488,271759296,272042976,272326560,272610048, - 272893440,273176736,273459936,273743040,274026048,274308928,274591744,274874432, - 275157024,275439520,275721920,276004224,276286432,276568512,276850528,277132416, - 277414240,277695936,277977536,278259040,278540448,278821728,279102944,279384032, - 279665056,279945952,280226752,280507456,280788064,281068544,281348960,281629248, - 281909472,282189568,282469568,282749440,283029248,283308960,283588544,283868032, - 284147424,284426720,284705920,284985024,285264000,285542912,285821696,286100384, - 286378976,286657440,286935840,287214112,287492320,287770400,288048384,288326240, - 288604032,288881696,289159264,289436768,289714112,289991392,290268576,290545632, - 290822592,291099456,291376224,291652896,291929440,292205888,292482272,292758528, - 293034656,293310720,293586656,293862496,294138240,294413888,294689440,294964864, - 295240192,295515424,295790560,296065600,296340512,296615360,296890080,297164704, - 297439200,297713632,297987936,298262144,298536256,298810240,299084160,299357952, - 299631648,299905248,300178720,300452128,300725408,300998592,301271680,301544640, - 301817536,302090304,302362976,302635520,302908000,303180352,303452608,303724768, - 303996800,304268768,304540608,304812320,305083968,305355520,305626944,305898272, - 306169472,306440608,306711616,306982528,307253344,307524064,307794656,308065152, - 308335552,308605856,308876032,309146112,309416096,309685984,309955744,310225408, - 310494976,310764448,311033824,311303072,311572224,311841280,312110208,312379040, - 312647776,312916416,313184960,313453376,313721696,313989920,314258016,314526016, - 314793920,315061728,315329408,315597024,315864512,316131872,316399168,316666336, - 316933408,317200384,317467232,317733984,318000640,318267200,318533632,318799968, - 319066208,319332352,319598368,319864288,320130112,320395808,320661408,320926912, - 321192320,321457632,321722816,321987904,322252864,322517760,322782528,323047200, - 323311744,323576192,323840544,324104800,324368928,324632992,324896928,325160736, - 325424448,325688096,325951584,326215008,326478304,326741504,327004608,327267584, - 327530464,327793248,328055904,328318496,328580960,328843296,329105568,329367712, - 329629760,329891680,330153536,330415264,330676864,330938400,331199808,331461120, - 331722304,331983392,332244384,332505280,332766048,333026752,333287296,333547776, - 333808128,334068384,334328544,334588576,334848512,335108352,335368064,335627712, - 335887200,336146624,336405920,336665120,336924224,337183200,337442112,337700864, - 337959552,338218112,338476576,338734944,338993184,339251328,339509376,339767296, - 340025120,340282848,340540480,340797984,341055392,341312704,341569888,341826976, - 342083968,342340832,342597600,342854272,343110848,343367296,343623648,343879904, - 344136032,344392064,344648000,344903808,345159520,345415136,345670656,345926048, - 346181344,346436512,346691616,346946592,347201440,347456224,347710880,347965440, - 348219872,348474208,348728448,348982592,349236608,349490528,349744320,349998048, - 350251648,350505152,350758528,351011808,351264992,351518048,351771040,352023872, - 352276640,352529280,352781824,353034272,353286592,353538816,353790944,354042944, - 354294880,354546656,354798368,355049952,355301440,355552800,355804096,356055264, - 356306304,356557280,356808128,357058848,357309504,357560032,357810464,358060768, - 358311008,358561088,358811104,359060992,359310784,359560480,359810048,360059520, - 360308896,360558144,360807296,361056352,361305312,361554144,361802880,362051488, - 362300032,362548448,362796736,363044960,363293056,363541024,363788928,364036704, - 364284384,364531936,364779392,365026752,365274016,365521152,365768192,366015136, - 366261952,366508672,366755296,367001792,367248192,367494496,367740704,367986784, - 368232768,368478656,368724416,368970080,369215648,369461088,369706432,369951680, - 370196800,370441824,370686752,370931584,371176288,371420896,371665408,371909792, - 372154080,372398272,372642336,372886304,373130176,373373952,373617600,373861152, - 374104608,374347936,374591168,374834304,375077312,375320224,375563040,375805760, - 376048352,376290848,376533248,376775520,377017696,377259776,377501728,377743584, - 377985344,378227008,378468544,378709984,378951328,379192544,379433664,379674688, - 379915584,380156416,380397088,380637696,380878176,381118560,381358848,381599040, - 381839104,382079072,382318912,382558656,382798304,383037856,383277280,383516640, - 383755840,383994976,384233984,384472896,384711712,384950400,385188992,385427488, - 385665888,385904160,386142336,386380384,386618368,386856224,387093984,387331616, - 387569152,387806592,388043936,388281152,388518272,388755296,388992224,389229024, - 389465728,389702336,389938816,390175200,390411488,390647680,390883744,391119712, - 391355584,391591328,391826976,392062528,392297984,392533312,392768544,393003680, - 393238720,393473632,393708448,393943168,394177760,394412256,394646656,394880960, - 395115136,395349216,395583200,395817088,396050848,396284512,396518080,396751520, - 396984864,397218112,397451264,397684288,397917248,398150080,398382784,398615424, - 398847936,399080320,399312640,399544832,399776928,400008928,400240832,400472608, - 400704288,400935872,401167328,401398720,401629984,401861120,402092192,402323136, - 402553984,402784736,403015360,403245888,403476320,403706656,403936896,404167008, - 404397024,404626944,404856736,405086432,405316032,405545536,405774912,406004224, - 406233408,406462464,406691456,406920320,407149088,407377760,407606336,407834784, - 408063136,408291392,408519520,408747584,408975520,409203360,409431072,409658720, - 409886240,410113664,410340992,410568192,410795296,411022304,411249216,411476032, - 411702720,411929312,412155808,412382176,412608480,412834656,413060736,413286720, - 413512576,413738336,413964000,414189568,414415040,414640384,414865632,415090784, - 415315840,415540800,415765632,415990368,416215008,416439552,416663968,416888288, - 417112512,417336640,417560672,417784576,418008384,418232096,418455712,418679200, - 418902624,419125920,419349120,419572192,419795200,420018080,420240864,420463552, - 420686144,420908608,421130976,421353280,421575424,421797504,422019488,422241344, - 422463104,422684768,422906336,423127776,423349120,423570400,423791520,424012576, - 424233536,424454368,424675104,424895744,425116288,425336736,425557056,425777280, - 425997408,426217440,426437376,426657184,426876928,427096544,427316064,427535488, - 427754784,427974016,428193120,428412128,428631040,428849856,429068544,429287168, - 429505664,429724064,429942368,430160576,430378656,430596672,430814560,431032352, - 431250048,431467616,431685120,431902496,432119808,432336992,432554080,432771040, - 432987936,433204736,433421408,433637984,433854464,434070848,434287104,434503296, - 434719360,434935360,435151232,435367008,435582656,435798240,436013696,436229088, - 436444352,436659520,436874592,437089568,437304416,437519200,437733856,437948416, - 438162880,438377248,438591520,438805696,439019744,439233728,439447584,439661344, - 439875008,440088576,440302048,440515392,440728672,440941824,441154880,441367872, - 441580736,441793472,442006144,442218720,442431168,442643552,442855808,443067968, - 443280032,443492000,443703872,443915648,444127296,444338880,444550336,444761696, - 444972992,445184160,445395232,445606176,445817056,446027840,446238496,446449088, - 446659552,446869920,447080192,447290400,447500448,447710432,447920320,448130112, - 448339776,448549376,448758848,448968224,449177536,449386720,449595808,449804800, - 450013664,450222464,450431168,450639776,450848256,451056640,451264960,451473152, - 451681248,451889248,452097152,452304960,452512672,452720288,452927808,453135232, - 453342528,453549760,453756864,453963904,454170816,454377632,454584384,454791008, - 454997536,455203968,455410304,455616544,455822688,456028704,456234656,456440512, - 456646240,456851904,457057472,457262912,457468256,457673536,457878688,458083744, - 458288736,458493600,458698368,458903040,459107616,459312096,459516480,459720768, - 459924960,460129056,460333056,460536960,460740736,460944448,461148064,461351584, - 461554976,461758304,461961536,462164640,462367680,462570592,462773440,462976160, - 463178816,463381344,463583776,463786144,463988384,464190560,464392608,464594560, - 464796448,464998208,465199872,465401472,465602944,465804320,466005600,466206816, - 466407904,466608896,466809824,467010624,467211328,467411936,467612480,467812896, - 468013216,468213440,468413600,468613632,468813568,469013440,469213184,469412832, - 469612416,469811872,470011232,470210528,470409696,470608800,470807776,471006688, - 471205472,471404192,471602784,471801312,471999712,472198048,472396288,472594400, - 472792448,472990400,473188256,473385984,473583648,473781216,473978688,474176064, - 474373344,474570528,474767616,474964608,475161504,475358336,475555040,475751648, - 475948192,476144608,476340928,476537184,476733312,476929376,477125344,477321184, - 477516960,477712640,477908224,478103712,478299104,478494400,478689600,478884704, - 479079744,479274656,479469504,479664224,479858880,480053408,480247872,480442240, - 480636512,480830656,481024736,481218752,481412640,481606432,481800128,481993760, - 482187264,482380704,482574016,482767264,482960416,483153472,483346432,483539296, - 483732064,483924768,484117344,484309856,484502240,484694560,484886784,485078912, - 485270944,485462880,485654720,485846464,486038144,486229696,486421184,486612576, - 486803840,486995040,487186176,487377184,487568096,487758912,487949664,488140320, - 488330880,488521312,488711712,488901984,489092160,489282240,489472256,489662176, - 489851968,490041696,490231328,490420896,490610336,490799712,490988960,491178144, - 491367232,491556224,491745120,491933920,492122656,492311264,492499808,492688256, - 492876608,493064864,493253056,493441120,493629120,493817024,494004832,494192544, - 494380160,494567712,494755136,494942496,495129760,495316928,495504000,495691008, - 495877888,496064704,496251424,496438048,496624608,496811040,496997408,497183680, - 497369856,497555936,497741920,497927840,498113632,498299360,498484992,498670560, - 498856000,499041376,499226656,499411840,499596928,499781920,499966848,500151680, - 500336416,500521056,500705600,500890080,501074464,501258752,501442944,501627040, - 501811072,501995008,502178848,502362592,502546240,502729824,502913312,503096704, - 503280000,503463232,503646368,503829408,504012352,504195200,504377984,504560672, - 504743264,504925760,505108192,505290496,505472736,505654912,505836960,506018944, - 506200832,506382624,506564320,506745952,506927488,507108928,507290272,507471552, - 507652736,507833824,508014816,508195744,508376576,508557312,508737952,508918528, - 509099008,509279392,509459680,509639904,509820032,510000064,510180000,510359872, - 510539648,510719328,510898944,511078432,511257856,511437216,511616448,511795616, - 511974688,512153664,512332576,512511392,512690112,512868768,513047296,513225792, - 513404160,513582432,513760640,513938784,514116800,514294752,514472608,514650368, - 514828064,515005664,515183168,515360608,515537952,515715200,515892352,516069440, - 516246432,516423328,516600160,516776896,516953536,517130112,517306592,517482976, - 517659264,517835488,518011616,518187680,518363648,518539520,518715296,518891008, - 519066624,519242144,519417600,519592960,519768256,519943424,520118528,520293568, - 520468480,520643328,520818112,520992800,521167392,521341888,521516320,521690656, - 521864896,522039072,522213152,522387168,522561056,522734912,522908640,523082304, - 523255872,523429376,523602784,523776096,523949312,524122464,524295552,524468512, - 524641440,524814240,524986976,525159616,525332192,525504640,525677056,525849344, - 526021568,526193728,526365792,526537760,526709632,526881440,527053152,527224800, - 527396352,527567840,527739200,527910528,528081728,528252864,528423936,528594880, - 528765760,528936576,529107296,529277920,529448480,529618944,529789344,529959648, - 530129856,530300000,530470048,530640000,530809888,530979712,531149440,531319072, - 531488608,531658080,531827488,531996800,532166016,532335168,532504224,532673184, - 532842080,533010912,533179616,533348288,533516832,533685312,533853728,534022048, - 534190272,534358432,534526496,534694496,534862400,535030240,535197984,535365632, - 535533216,535700704,535868128,536035456,536202720,536369888,536536992,536704000, - 536870912 -}; - - -} // namespace vpo - +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// Lookup tables. +// Do not try to look them up :-). +// In the order of appearance: +// +// int finetangent[4096] - Tangens LUT. +// Should work with BAM fairly well (12 of 16bit, +// effectively, by shifting). +// +// int finesine[10240] - Sine lookup. +// Guess what, serves as cosine, too. +// Remarkable thing is, how to use BAMs with this? +// +// int tantoangle[2049] - ArcTan LUT, +// maps tan(angle) to angle fast. Gotta search. +// +// +//----------------------------------------------------------------------------- + +#include "vpo_local.h" + +namespace vpo +{ + + +int +SlopeDiv +( unsigned num, + unsigned den) +{ + unsigned ans; + + if (den < 512) + return SLOPERANGE; + + ans = (num<<3)/(den>>8); + + return ans <= SLOPERANGE ? ans : SLOPERANGE; +} + + +const int finetangent[4096] = +{ + -170910304,-56965752,-34178904,-24413316,-18988036,-15535599,-13145455,-11392683, + -10052327,-8994149,-8137527,-7429880,-6835455,-6329090,-5892567,-5512368, + -5178251,-4882318,-4618375,-4381502,-4167737,-3973855,-3797206,-3635590, + -3487165,-3350381,-3223918,-3106651,-2997613,-2895966,-2800983,-2712030, + -2628549,-2550052,-2476104,-2406322,-2340362,-2277919,-2218719,-2162516, + -2109087,-2058233,-2009771,-1963536,-1919378,-1877161,-1836758,-1798063, + -1760956,-1725348,-1691149,-1658278,-1626658,-1596220,-1566898,-1538632, + -1511367,-1485049,-1459630,-1435065,-1411312,-1388330,-1366084,-1344537, + -1323658,-1303416,-1283783,-1264730,-1246234,-1228269,-1210813,-1193846, + -1177345,-1161294,-1145673,-1130465,-1115654,-1101225,-1087164,-1073455, + -1060087,-1047046,-1034322,-1021901,-1009774,-997931,-986361,-975054, + -964003,-953199,-942633,-932298,-922186,-912289,-902602,-893117, + -883829,-874730,-865817,-857081,-848520,-840127,-831898,-823827, + -815910,-808143,-800521,-793041,-785699,-778490,-771411,-764460, + -757631,-750922,-744331,-737853,-731486,-725227,-719074,-713023, + -707072,-701219,-695462,-689797,-684223,-678737,-673338,-668024, + -662792,-657640,-652568,-647572,-642651,-637803,-633028,-628323, + -623686,-619117,-614613,-610174,-605798,-601483,-597229,-593033, + -588896,-584815,-580789,-576818,-572901,-569035,-565221,-561456, + -557741,-554074,-550455,-546881,-543354,-539870,-536431,-533034, + -529680,-526366,-523094,-519861,-516667,-513512,-510394,-507313, + -504269,-501261,-498287,-495348,-492443,-489571,-486732,-483925, + -481150,-478406,-475692,-473009,-470355,-467730,-465133,-462565, + -460024,-457511,-455024,-452564,-450129,-447720,-445337,-442978, + -440643,-438332,-436045,-433781,-431540,-429321,-427125,-424951, + -422798,-420666,-418555,-416465,-414395,-412344,-410314,-408303, + -406311,-404338,-402384,-400448,-398530,-396630,-394747,-392882, + -391034,-389202,-387387,-385589,-383807,-382040,-380290,-378555, + -376835,-375130,-373440,-371765,-370105,-368459,-366826,-365208, + -363604,-362013,-360436,-358872,-357321,-355783,-354257,-352744, + -351244,-349756,-348280,-346816,-345364,-343924,-342495,-341078, + -339671,-338276,-336892,-335519,-334157,-332805,-331464,-330133, + -328812,-327502,-326201,-324910,-323629,-322358,-321097,-319844, + -318601,-317368,-316143,-314928,-313721,-312524,-311335,-310154, + -308983,-307819,-306664,-305517,-304379,-303248,-302126,-301011, + -299904,-298805,-297714,-296630,-295554,-294485,-293423,-292369, + -291322,-290282,-289249,-288223,-287204,-286192,-285186,-284188, + -283195,-282210,-281231,-280258,-279292,-278332,-277378,-276430, + -275489,-274553,-273624,-272700,-271782,-270871,-269965,-269064, + -268169,-267280,-266397,-265519,-264646,-263779,-262917,-262060, + -261209,-260363,-259522,-258686,-257855,-257029,-256208,-255392, + -254581,-253774,-252973,-252176,-251384,-250596,-249813,-249035, + -248261,-247492,-246727,-245966,-245210,-244458,-243711,-242967, + -242228,-241493,-240763,-240036,-239314,-238595,-237881,-237170, + -236463,-235761,-235062,-234367,-233676,-232988,-232304,-231624, + -230948,-230275,-229606,-228941,-228279,-227621,-226966,-226314, + -225666,-225022,-224381,-223743,-223108,-222477,-221849,-221225, + -220603,-219985,-219370,-218758,-218149,-217544,-216941,-216341, + -215745,-215151,-214561,-213973,-213389,-212807,-212228,-211652, + -211079,-210509,-209941,-209376,-208815,-208255,-207699,-207145, + -206594,-206045,-205500,-204956,-204416,-203878,-203342,-202809, + -202279,-201751,-201226,-200703,-200182,-199664,-199149,-198636, + -198125,-197616,-197110,-196606,-196105,-195606,-195109,-194614, + -194122,-193631,-193143,-192658,-192174,-191693,-191213,-190736, + -190261,-189789,-189318,-188849,-188382,-187918,-187455,-186995, + -186536,-186080,-185625,-185173,-184722,-184274,-183827,-183382, + -182939,-182498,-182059,-181622,-181186,-180753,-180321,-179891, + -179463,-179037,-178612,-178190,-177769,-177349,-176932,-176516, + -176102,-175690,-175279,-174870,-174463,-174057,-173653,-173251, + -172850,-172451,-172053,-171657,-171263,-170870,-170479,-170089, + -169701,-169315,-168930,-168546,-168164,-167784,-167405,-167027, + -166651,-166277,-165904,-165532,-165162,-164793,-164426,-164060, + -163695,-163332,-162970,-162610,-162251,-161893,-161537,-161182, + -160828,-160476,-160125,-159775,-159427,-159079,-158734,-158389, + -158046,-157704,-157363,-157024,-156686,-156349,-156013,-155678, + -155345,-155013,-154682,-154352,-154024,-153697,-153370,-153045, + -152722,-152399,-152077,-151757,-151438,-151120,-150803,-150487, + -150172,-149859,-149546,-149235,-148924,-148615,-148307,-148000, + -147693,-147388,-147084,-146782,-146480,-146179,-145879,-145580, + -145282,-144986,-144690,-144395,-144101,-143808,-143517,-143226, + -142936,-142647,-142359,-142072,-141786,-141501,-141217,-140934, + -140651,-140370,-140090,-139810,-139532,-139254,-138977,-138701, + -138426,-138152,-137879,-137607,-137335,-137065,-136795,-136526, + -136258,-135991,-135725,-135459,-135195,-134931,-134668,-134406, + -134145,-133884,-133625,-133366,-133108,-132851,-132594,-132339, + -132084,-131830,-131576,-131324,-131072,-130821,-130571,-130322, + -130073,-129825,-129578,-129332,-129086,-128841,-128597,-128353, + -128111,-127869,-127627,-127387,-127147,-126908,-126669,-126432, + -126195,-125959,-125723,-125488,-125254,-125020,-124787,-124555, + -124324,-124093,-123863,-123633,-123404,-123176,-122949,-122722, + -122496,-122270,-122045,-121821,-121597,-121374,-121152,-120930, + -120709,-120489,-120269,-120050,-119831,-119613,-119396,-119179, + -118963,-118747,-118532,-118318,-118104,-117891,-117678,-117466, + -117254,-117044,-116833,-116623,-116414,-116206,-115998,-115790, + -115583,-115377,-115171,-114966,-114761,-114557,-114354,-114151, + -113948,-113746,-113545,-113344,-113143,-112944,-112744,-112546, + -112347,-112150,-111952,-111756,-111560,-111364,-111169,-110974, + -110780,-110586,-110393,-110200,-110008,-109817,-109626,-109435, + -109245,-109055,-108866,-108677,-108489,-108301,-108114,-107927, + -107741,-107555,-107369,-107184,-107000,-106816,-106632,-106449, + -106266,-106084,-105902,-105721,-105540,-105360,-105180,-105000, + -104821,-104643,-104465,-104287,-104109,-103933,-103756,-103580, + -103404,-103229,-103054,-102880,-102706,-102533,-102360,-102187, + -102015,-101843,-101671,-101500,-101330,-101159,-100990,-100820, + -100651,-100482,-100314,-100146,-99979,-99812,-99645,-99479, + -99313,-99148,-98982,-98818,-98653,-98489,-98326,-98163, + -98000,-97837,-97675,-97513,-97352,-97191,-97030,-96870, + -96710,-96551,-96391,-96233,-96074,-95916,-95758,-95601, + -95444,-95287,-95131,-94975,-94819,-94664,-94509,-94354, + -94200,-94046,-93892,-93739,-93586,-93434,-93281,-93129, + -92978,-92826,-92675,-92525,-92375,-92225,-92075,-91926, + -91777,-91628,-91480,-91332,-91184,-91036,-90889,-90742, + -90596,-90450,-90304,-90158,-90013,-89868,-89724,-89579, + -89435,-89292,-89148,-89005,-88862,-88720,-88577,-88435, + -88294,-88152,-88011,-87871,-87730,-87590,-87450,-87310, + -87171,-87032,-86893,-86755,-86616,-86479,-86341,-86204, + -86066,-85930,-85793,-85657,-85521,-85385,-85250,-85114, + -84980,-84845,-84710,-84576,-84443,-84309,-84176,-84043, + -83910,-83777,-83645,-83513,-83381,-83250,-83118,-82987, + -82857,-82726,-82596,-82466,-82336,-82207,-82078,-81949, + -81820,-81691,-81563,-81435,-81307,-81180,-81053,-80925, + -80799,-80672,-80546,-80420,-80294,-80168,-80043,-79918, + -79793,-79668,-79544,-79420,-79296,-79172,-79048,-78925, + -78802,-78679,-78557,-78434,-78312,-78190,-78068,-77947, + -77826,-77705,-77584,-77463,-77343,-77223,-77103,-76983, + -76864,-76744,-76625,-76506,-76388,-76269,-76151,-76033, + -75915,-75797,-75680,-75563,-75446,-75329,-75213,-75096, + -74980,-74864,-74748,-74633,-74517,-74402,-74287,-74172, + -74058,-73944,-73829,-73715,-73602,-73488,-73375,-73262, + -73149,-73036,-72923,-72811,-72699,-72587,-72475,-72363, + -72252,-72140,-72029,-71918,-71808,-71697,-71587,-71477, + -71367,-71257,-71147,-71038,-70929,-70820,-70711,-70602, + -70494,-70385,-70277,-70169,-70061,-69954,-69846,-69739, + -69632,-69525,-69418,-69312,-69205,-69099,-68993,-68887, + -68781,-68676,-68570,-68465,-68360,-68255,-68151,-68046, + -67942,-67837,-67733,-67629,-67526,-67422,-67319,-67216, + -67113,-67010,-66907,-66804,-66702,-66600,-66498,-66396, + -66294,-66192,-66091,-65989,-65888,-65787,-65686,-65586, + -65485,-65385,-65285,-65185,-65085,-64985,-64885,-64786, + -64687,-64587,-64488,-64389,-64291,-64192,-64094,-63996, + -63897,-63799,-63702,-63604,-63506,-63409,-63312,-63215, + -63118,-63021,-62924,-62828,-62731,-62635,-62539,-62443, + -62347,-62251,-62156,-62060,-61965,-61870,-61775,-61680, + -61585,-61491,-61396,-61302,-61208,-61114,-61020,-60926, + -60833,-60739,-60646,-60552,-60459,-60366,-60273,-60181, + -60088,-59996,-59903,-59811,-59719,-59627,-59535,-59444, + -59352,-59261,-59169,-59078,-58987,-58896,-58805,-58715, + -58624,-58534,-58443,-58353,-58263,-58173,-58083,-57994, + -57904,-57815,-57725,-57636,-57547,-57458,-57369,-57281, + -57192,-57104,-57015,-56927,-56839,-56751,-56663,-56575, + -56487,-56400,-56312,-56225,-56138,-56051,-55964,-55877, + -55790,-55704,-55617,-55531,-55444,-55358,-55272,-55186, + -55100,-55015,-54929,-54843,-54758,-54673,-54587,-54502, + -54417,-54333,-54248,-54163,-54079,-53994,-53910,-53826, + -53741,-53657,-53574,-53490,-53406,-53322,-53239,-53156, + -53072,-52989,-52906,-52823,-52740,-52657,-52575,-52492, + -52410,-52327,-52245,-52163,-52081,-51999,-51917,-51835, + -51754,-51672,-51591,-51509,-51428,-51347,-51266,-51185, + -51104,-51023,-50942,-50862,-50781,-50701,-50621,-50540, + -50460,-50380,-50300,-50221,-50141,-50061,-49982,-49902, + -49823,-49744,-49664,-49585,-49506,-49427,-49349,-49270, + -49191,-49113,-49034,-48956,-48878,-48799,-48721,-48643, + -48565,-48488,-48410,-48332,-48255,-48177,-48100,-48022, + -47945,-47868,-47791,-47714,-47637,-47560,-47484,-47407, + -47331,-47254,-47178,-47102,-47025,-46949,-46873,-46797, + -46721,-46646,-46570,-46494,-46419,-46343,-46268,-46193, + -46118,-46042,-45967,-45892,-45818,-45743,-45668,-45593, + -45519,-45444,-45370,-45296,-45221,-45147,-45073,-44999, + -44925,-44851,-44778,-44704,-44630,-44557,-44483,-44410, + -44337,-44263,-44190,-44117,-44044,-43971,-43898,-43826, + -43753,-43680,-43608,-43535,-43463,-43390,-43318,-43246, + -43174,-43102,-43030,-42958,-42886,-42814,-42743,-42671, + -42600,-42528,-42457,-42385,-42314,-42243,-42172,-42101, + -42030,-41959,-41888,-41817,-41747,-41676,-41605,-41535, + -41465,-41394,-41324,-41254,-41184,-41113,-41043,-40973, + -40904,-40834,-40764,-40694,-40625,-40555,-40486,-40416, + -40347,-40278,-40208,-40139,-40070,-40001,-39932,-39863, + -39794,-39726,-39657,-39588,-39520,-39451,-39383,-39314, + -39246,-39178,-39110,-39042,-38973,-38905,-38837,-38770, + -38702,-38634,-38566,-38499,-38431,-38364,-38296,-38229, + -38161,-38094,-38027,-37960,-37893,-37826,-37759,-37692, + -37625,-37558,-37491,-37425,-37358,-37291,-37225,-37158, + -37092,-37026,-36959,-36893,-36827,-36761,-36695,-36629, + -36563,-36497,-36431,-36365,-36300,-36234,-36168,-36103, + -36037,-35972,-35907,-35841,-35776,-35711,-35646,-35580, + -35515,-35450,-35385,-35321,-35256,-35191,-35126,-35062, + -34997,-34932,-34868,-34803,-34739,-34675,-34610,-34546, + -34482,-34418,-34354,-34289,-34225,-34162,-34098,-34034, + -33970,-33906,-33843,-33779,-33715,-33652,-33588,-33525, + -33461,-33398,-33335,-33272,-33208,-33145,-33082,-33019, + -32956,-32893,-32830,-32767,-32705,-32642,-32579,-32516, + -32454,-32391,-32329,-32266,-32204,-32141,-32079,-32017, + -31955,-31892,-31830,-31768,-31706,-31644,-31582,-31520, + -31458,-31396,-31335,-31273,-31211,-31150,-31088,-31026, + -30965,-30904,-30842,-30781,-30719,-30658,-30597,-30536, + -30474,-30413,-30352,-30291,-30230,-30169,-30108,-30048, + -29987,-29926,-29865,-29805,-29744,-29683,-29623,-29562, + -29502,-29441,-29381,-29321,-29260,-29200,-29140,-29080, + -29020,-28959,-28899,-28839,-28779,-28719,-28660,-28600, + -28540,-28480,-28420,-28361,-28301,-28241,-28182,-28122, + -28063,-28003,-27944,-27884,-27825,-27766,-27707,-27647, + -27588,-27529,-27470,-27411,-27352,-27293,-27234,-27175, + -27116,-27057,-26998,-26940,-26881,-26822,-26763,-26705, + -26646,-26588,-26529,-26471,-26412,-26354,-26295,-26237, + -26179,-26120,-26062,-26004,-25946,-25888,-25830,-25772, + -25714,-25656,-25598,-25540,-25482,-25424,-25366,-25308, + -25251,-25193,-25135,-25078,-25020,-24962,-24905,-24847, + -24790,-24732,-24675,-24618,-24560,-24503,-24446,-24389, + -24331,-24274,-24217,-24160,-24103,-24046,-23989,-23932, + -23875,-23818,-23761,-23704,-23647,-23591,-23534,-23477, + -23420,-23364,-23307,-23250,-23194,-23137,-23081,-23024, + -22968,-22911,-22855,-22799,-22742,-22686,-22630,-22573, + -22517,-22461,-22405,-22349,-22293,-22237,-22181,-22125, + -22069,-22013,-21957,-21901,-21845,-21789,-21733,-21678, + -21622,-21566,-21510,-21455,-21399,-21343,-21288,-21232, + -21177,-21121,-21066,-21010,-20955,-20900,-20844,-20789, + -20734,-20678,-20623,-20568,-20513,-20457,-20402,-20347, + -20292,-20237,-20182,-20127,-20072,-20017,-19962,-19907, + -19852,-19797,-19742,-19688,-19633,-19578,-19523,-19469, + -19414,-19359,-19305,-19250,-19195,-19141,-19086,-19032, + -18977,-18923,-18868,-18814,-18760,-18705,-18651,-18597, + -18542,-18488,-18434,-18380,-18325,-18271,-18217,-18163, + -18109,-18055,-18001,-17946,-17892,-17838,-17784,-17731, + -17677,-17623,-17569,-17515,-17461,-17407,-17353,-17300, + -17246,-17192,-17138,-17085,-17031,-16977,-16924,-16870, + -16817,-16763,-16710,-16656,-16603,-16549,-16496,-16442, + -16389,-16335,-16282,-16229,-16175,-16122,-16069,-16015, + -15962,-15909,-15856,-15802,-15749,-15696,-15643,-15590, + -15537,-15484,-15431,-15378,-15325,-15272,-15219,-15166, + -15113,-15060,-15007,-14954,-14901,-14848,-14795,-14743, + -14690,-14637,-14584,-14531,-14479,-14426,-14373,-14321, + -14268,-14215,-14163,-14110,-14057,-14005,-13952,-13900, + -13847,-13795,-13742,-13690,-13637,-13585,-13533,-13480, + -13428,-13375,-13323,-13271,-13218,-13166,-13114,-13062, + -13009,-12957,-12905,-12853,-12800,-12748,-12696,-12644, + -12592,-12540,-12488,-12436,-12383,-12331,-12279,-12227, + -12175,-12123,-12071,-12019,-11967,-11916,-11864,-11812, + -11760,-11708,-11656,-11604,-11552,-11501,-11449,-11397, + -11345,-11293,-11242,-11190,-11138,-11086,-11035,-10983, + -10931,-10880,-10828,-10777,-10725,-10673,-10622,-10570, + -10519,-10467,-10415,-10364,-10312,-10261,-10209,-10158, + -10106,-10055,-10004,-9952,-9901,-9849,-9798,-9747, + -9695,-9644,-9592,-9541,-9490,-9438,-9387,-9336, + -9285,-9233,-9182,-9131,-9080,-9028,-8977,-8926, + -8875,-8824,-8772,-8721,-8670,-8619,-8568,-8517, + -8466,-8414,-8363,-8312,-8261,-8210,-8159,-8108, + -8057,-8006,-7955,-7904,-7853,-7802,-7751,-7700, + -7649,-7598,-7547,-7496,-7445,-7395,-7344,-7293, + -7242,-7191,-7140,-7089,-7038,-6988,-6937,-6886, + -6835,-6784,-6733,-6683,-6632,-6581,-6530,-6480, + -6429,-6378,-6327,-6277,-6226,-6175,-6124,-6074, + -6023,-5972,-5922,-5871,-5820,-5770,-5719,-5668, + -5618,-5567,-5517,-5466,-5415,-5365,-5314,-5264, + -5213,-5162,-5112,-5061,-5011,-4960,-4910,-4859, + -4808,-4758,-4707,-4657,-4606,-4556,-4505,-4455, + -4404,-4354,-4303,-4253,-4202,-4152,-4101,-4051, + -4001,-3950,-3900,-3849,-3799,-3748,-3698,-3648, + -3597,-3547,-3496,-3446,-3395,-3345,-3295,-3244, + -3194,-3144,-3093,-3043,-2992,-2942,-2892,-2841, + -2791,-2741,-2690,-2640,-2590,-2539,-2489,-2439, + -2388,-2338,-2288,-2237,-2187,-2137,-2086,-2036, + -1986,-1935,-1885,-1835,-1784,-1734,-1684,-1633, + -1583,-1533,-1483,-1432,-1382,-1332,-1281,-1231, + -1181,-1131,-1080,-1030,-980,-929,-879,-829, + -779,-728,-678,-628,-578,-527,-477,-427, + -376,-326,-276,-226,-175,-125,-75,-25, + 25,75,125,175,226,276,326,376, + 427,477,527,578,628,678,728,779, + 829,879,929,980,1030,1080,1131,1181, + 1231,1281,1332,1382,1432,1483,1533,1583, + 1633,1684,1734,1784,1835,1885,1935,1986, + 2036,2086,2137,2187,2237,2288,2338,2388, + 2439,2489,2539,2590,2640,2690,2741,2791, + 2841,2892,2942,2992,3043,3093,3144,3194, + 3244,3295,3345,3395,3446,3496,3547,3597, + 3648,3698,3748,3799,3849,3900,3950,4001, + 4051,4101,4152,4202,4253,4303,4354,4404, + 4455,4505,4556,4606,4657,4707,4758,4808, + 4859,4910,4960,5011,5061,5112,5162,5213, + 5264,5314,5365,5415,5466,5517,5567,5618, + 5668,5719,5770,5820,5871,5922,5972,6023, + 6074,6124,6175,6226,6277,6327,6378,6429, + 6480,6530,6581,6632,6683,6733,6784,6835, + 6886,6937,6988,7038,7089,7140,7191,7242, + 7293,7344,7395,7445,7496,7547,7598,7649, + 7700,7751,7802,7853,7904,7955,8006,8057, + 8108,8159,8210,8261,8312,8363,8414,8466, + 8517,8568,8619,8670,8721,8772,8824,8875, + 8926,8977,9028,9080,9131,9182,9233,9285, + 9336,9387,9438,9490,9541,9592,9644,9695, + 9747,9798,9849,9901,9952,10004,10055,10106, + 10158,10209,10261,10312,10364,10415,10467,10519, + 10570,10622,10673,10725,10777,10828,10880,10931, + 10983,11035,11086,11138,11190,11242,11293,11345, + 11397,11449,11501,11552,11604,11656,11708,11760, + 11812,11864,11916,11967,12019,12071,12123,12175, + 12227,12279,12331,12383,12436,12488,12540,12592, + 12644,12696,12748,12800,12853,12905,12957,13009, + 13062,13114,13166,13218,13271,13323,13375,13428, + 13480,13533,13585,13637,13690,13742,13795,13847, + 13900,13952,14005,14057,14110,14163,14215,14268, + 14321,14373,14426,14479,14531,14584,14637,14690, + 14743,14795,14848,14901,14954,15007,15060,15113, + 15166,15219,15272,15325,15378,15431,15484,15537, + 15590,15643,15696,15749,15802,15856,15909,15962, + 16015,16069,16122,16175,16229,16282,16335,16389, + 16442,16496,16549,16603,16656,16710,16763,16817, + 16870,16924,16977,17031,17085,17138,17192,17246, + 17300,17353,17407,17461,17515,17569,17623,17677, + 17731,17784,17838,17892,17946,18001,18055,18109, + 18163,18217,18271,18325,18380,18434,18488,18542, + 18597,18651,18705,18760,18814,18868,18923,18977, + 19032,19086,19141,19195,19250,19305,19359,19414, + 19469,19523,19578,19633,19688,19742,19797,19852, + 19907,19962,20017,20072,20127,20182,20237,20292, + 20347,20402,20457,20513,20568,20623,20678,20734, + 20789,20844,20900,20955,21010,21066,21121,21177, + 21232,21288,21343,21399,21455,21510,21566,21622, + 21678,21733,21789,21845,21901,21957,22013,22069, + 22125,22181,22237,22293,22349,22405,22461,22517, + 22573,22630,22686,22742,22799,22855,22911,22968, + 23024,23081,23137,23194,23250,23307,23364,23420, + 23477,23534,23591,23647,23704,23761,23818,23875, + 23932,23989,24046,24103,24160,24217,24274,24331, + 24389,24446,24503,24560,24618,24675,24732,24790, + 24847,24905,24962,25020,25078,25135,25193,25251, + 25308,25366,25424,25482,25540,25598,25656,25714, + 25772,25830,25888,25946,26004,26062,26120,26179, + 26237,26295,26354,26412,26471,26529,26588,26646, + 26705,26763,26822,26881,26940,26998,27057,27116, + 27175,27234,27293,27352,27411,27470,27529,27588, + 27647,27707,27766,27825,27884,27944,28003,28063, + 28122,28182,28241,28301,28361,28420,28480,28540, + 28600,28660,28719,28779,28839,28899,28959,29020, + 29080,29140,29200,29260,29321,29381,29441,29502, + 29562,29623,29683,29744,29805,29865,29926,29987, + 30048,30108,30169,30230,30291,30352,30413,30474, + 30536,30597,30658,30719,30781,30842,30904,30965, + 31026,31088,31150,31211,31273,31335,31396,31458, + 31520,31582,31644,31706,31768,31830,31892,31955, + 32017,32079,32141,32204,32266,32329,32391,32454, + 32516,32579,32642,32705,32767,32830,32893,32956, + 33019,33082,33145,33208,33272,33335,33398,33461, + 33525,33588,33652,33715,33779,33843,33906,33970, + 34034,34098,34162,34225,34289,34354,34418,34482, + 34546,34610,34675,34739,34803,34868,34932,34997, + 35062,35126,35191,35256,35321,35385,35450,35515, + 35580,35646,35711,35776,35841,35907,35972,36037, + 36103,36168,36234,36300,36365,36431,36497,36563, + 36629,36695,36761,36827,36893,36959,37026,37092, + 37158,37225,37291,37358,37425,37491,37558,37625, + 37692,37759,37826,37893,37960,38027,38094,38161, + 38229,38296,38364,38431,38499,38566,38634,38702, + 38770,38837,38905,38973,39042,39110,39178,39246, + 39314,39383,39451,39520,39588,39657,39726,39794, + 39863,39932,40001,40070,40139,40208,40278,40347, + 40416,40486,40555,40625,40694,40764,40834,40904, + 40973,41043,41113,41184,41254,41324,41394,41465, + 41535,41605,41676,41747,41817,41888,41959,42030, + 42101,42172,42243,42314,42385,42457,42528,42600, + 42671,42743,42814,42886,42958,43030,43102,43174, + 43246,43318,43390,43463,43535,43608,43680,43753, + 43826,43898,43971,44044,44117,44190,44263,44337, + 44410,44483,44557,44630,44704,44778,44851,44925, + 44999,45073,45147,45221,45296,45370,45444,45519, + 45593,45668,45743,45818,45892,45967,46042,46118, + 46193,46268,46343,46419,46494,46570,46646,46721, + 46797,46873,46949,47025,47102,47178,47254,47331, + 47407,47484,47560,47637,47714,47791,47868,47945, + 48022,48100,48177,48255,48332,48410,48488,48565, + 48643,48721,48799,48878,48956,49034,49113,49191, + 49270,49349,49427,49506,49585,49664,49744,49823, + 49902,49982,50061,50141,50221,50300,50380,50460, + 50540,50621,50701,50781,50862,50942,51023,51104, + 51185,51266,51347,51428,51509,51591,51672,51754, + 51835,51917,51999,52081,52163,52245,52327,52410, + 52492,52575,52657,52740,52823,52906,52989,53072, + 53156,53239,53322,53406,53490,53574,53657,53741, + 53826,53910,53994,54079,54163,54248,54333,54417, + 54502,54587,54673,54758,54843,54929,55015,55100, + 55186,55272,55358,55444,55531,55617,55704,55790, + 55877,55964,56051,56138,56225,56312,56400,56487, + 56575,56663,56751,56839,56927,57015,57104,57192, + 57281,57369,57458,57547,57636,57725,57815,57904, + 57994,58083,58173,58263,58353,58443,58534,58624, + 58715,58805,58896,58987,59078,59169,59261,59352, + 59444,59535,59627,59719,59811,59903,59996,60088, + 60181,60273,60366,60459,60552,60646,60739,60833, + 60926,61020,61114,61208,61302,61396,61491,61585, + 61680,61775,61870,61965,62060,62156,62251,62347, + 62443,62539,62635,62731,62828,62924,63021,63118, + 63215,63312,63409,63506,63604,63702,63799,63897, + 63996,64094,64192,64291,64389,64488,64587,64687, + 64786,64885,64985,65085,65185,65285,65385,65485, + 65586,65686,65787,65888,65989,66091,66192,66294, + 66396,66498,66600,66702,66804,66907,67010,67113, + 67216,67319,67422,67526,67629,67733,67837,67942, + 68046,68151,68255,68360,68465,68570,68676,68781, + 68887,68993,69099,69205,69312,69418,69525,69632, + 69739,69846,69954,70061,70169,70277,70385,70494, + 70602,70711,70820,70929,71038,71147,71257,71367, + 71477,71587,71697,71808,71918,72029,72140,72252, + 72363,72475,72587,72699,72811,72923,73036,73149, + 73262,73375,73488,73602,73715,73829,73944,74058, + 74172,74287,74402,74517,74633,74748,74864,74980, + 75096,75213,75329,75446,75563,75680,75797,75915, + 76033,76151,76269,76388,76506,76625,76744,76864, + 76983,77103,77223,77343,77463,77584,77705,77826, + 77947,78068,78190,78312,78434,78557,78679,78802, + 78925,79048,79172,79296,79420,79544,79668,79793, + 79918,80043,80168,80294,80420,80546,80672,80799, + 80925,81053,81180,81307,81435,81563,81691,81820, + 81949,82078,82207,82336,82466,82596,82726,82857, + 82987,83118,83250,83381,83513,83645,83777,83910, + 84043,84176,84309,84443,84576,84710,84845,84980, + 85114,85250,85385,85521,85657,85793,85930,86066, + 86204,86341,86479,86616,86755,86893,87032,87171, + 87310,87450,87590,87730,87871,88011,88152,88294, + 88435,88577,88720,88862,89005,89148,89292,89435, + 89579,89724,89868,90013,90158,90304,90450,90596, + 90742,90889,91036,91184,91332,91480,91628,91777, + 91926,92075,92225,92375,92525,92675,92826,92978, + 93129,93281,93434,93586,93739,93892,94046,94200, + 94354,94509,94664,94819,94975,95131,95287,95444, + 95601,95758,95916,96074,96233,96391,96551,96710, + 96870,97030,97191,97352,97513,97675,97837,98000, + 98163,98326,98489,98653,98818,98982,99148,99313, + 99479,99645,99812,99979,100146,100314,100482,100651, + 100820,100990,101159,101330,101500,101671,101843,102015, + 102187,102360,102533,102706,102880,103054,103229,103404, + 103580,103756,103933,104109,104287,104465,104643,104821, + 105000,105180,105360,105540,105721,105902,106084,106266, + 106449,106632,106816,107000,107184,107369,107555,107741, + 107927,108114,108301,108489,108677,108866,109055,109245, + 109435,109626,109817,110008,110200,110393,110586,110780, + 110974,111169,111364,111560,111756,111952,112150,112347, + 112546,112744,112944,113143,113344,113545,113746,113948, + 114151,114354,114557,114761,114966,115171,115377,115583, + 115790,115998,116206,116414,116623,116833,117044,117254, + 117466,117678,117891,118104,118318,118532,118747,118963, + 119179,119396,119613,119831,120050,120269,120489,120709, + 120930,121152,121374,121597,121821,122045,122270,122496, + 122722,122949,123176,123404,123633,123863,124093,124324, + 124555,124787,125020,125254,125488,125723,125959,126195, + 126432,126669,126908,127147,127387,127627,127869,128111, + 128353,128597,128841,129086,129332,129578,129825,130073, + 130322,130571,130821,131072,131324,131576,131830,132084, + 132339,132594,132851,133108,133366,133625,133884,134145, + 134406,134668,134931,135195,135459,135725,135991,136258, + 136526,136795,137065,137335,137607,137879,138152,138426, + 138701,138977,139254,139532,139810,140090,140370,140651, + 140934,141217,141501,141786,142072,142359,142647,142936, + 143226,143517,143808,144101,144395,144690,144986,145282, + 145580,145879,146179,146480,146782,147084,147388,147693, + 148000,148307,148615,148924,149235,149546,149859,150172, + 150487,150803,151120,151438,151757,152077,152399,152722, + 153045,153370,153697,154024,154352,154682,155013,155345, + 155678,156013,156349,156686,157024,157363,157704,158046, + 158389,158734,159079,159427,159775,160125,160476,160828, + 161182,161537,161893,162251,162610,162970,163332,163695, + 164060,164426,164793,165162,165532,165904,166277,166651, + 167027,167405,167784,168164,168546,168930,169315,169701, + 170089,170479,170870,171263,171657,172053,172451,172850, + 173251,173653,174057,174463,174870,175279,175690,176102, + 176516,176932,177349,177769,178190,178612,179037,179463, + 179891,180321,180753,181186,181622,182059,182498,182939, + 183382,183827,184274,184722,185173,185625,186080,186536, + 186995,187455,187918,188382,188849,189318,189789,190261, + 190736,191213,191693,192174,192658,193143,193631,194122, + 194614,195109,195606,196105,196606,197110,197616,198125, + 198636,199149,199664,200182,200703,201226,201751,202279, + 202809,203342,203878,204416,204956,205500,206045,206594, + 207145,207699,208255,208815,209376,209941,210509,211079, + 211652,212228,212807,213389,213973,214561,215151,215745, + 216341,216941,217544,218149,218758,219370,219985,220603, + 221225,221849,222477,223108,223743,224381,225022,225666, + 226314,226966,227621,228279,228941,229606,230275,230948, + 231624,232304,232988,233676,234367,235062,235761,236463, + 237170,237881,238595,239314,240036,240763,241493,242228, + 242967,243711,244458,245210,245966,246727,247492,248261, + 249035,249813,250596,251384,252176,252973,253774,254581, + 255392,256208,257029,257855,258686,259522,260363,261209, + 262060,262917,263779,264646,265519,266397,267280,268169, + 269064,269965,270871,271782,272700,273624,274553,275489, + 276430,277378,278332,279292,280258,281231,282210,283195, + 284188,285186,286192,287204,288223,289249,290282,291322, + 292369,293423,294485,295554,296630,297714,298805,299904, + 301011,302126,303248,304379,305517,306664,307819,308983, + 310154,311335,312524,313721,314928,316143,317368,318601, + 319844,321097,322358,323629,324910,326201,327502,328812, + 330133,331464,332805,334157,335519,336892,338276,339671, + 341078,342495,343924,345364,346816,348280,349756,351244, + 352744,354257,355783,357321,358872,360436,362013,363604, + 365208,366826,368459,370105,371765,373440,375130,376835, + 378555,380290,382040,383807,385589,387387,389202,391034, + 392882,394747,396630,398530,400448,402384,404338,406311, + 408303,410314,412344,414395,416465,418555,420666,422798, + 424951,427125,429321,431540,433781,436045,438332,440643, + 442978,445337,447720,450129,452564,455024,457511,460024, + 462565,465133,467730,470355,473009,475692,478406,481150, + 483925,486732,489571,492443,495348,498287,501261,504269, + 507313,510394,513512,516667,519861,523094,526366,529680, + 533034,536431,539870,543354,546881,550455,554074,557741, + 561456,565221,569035,572901,576818,580789,584815,588896, + 593033,597229,601483,605798,610174,614613,619117,623686, + 628323,633028,637803,642651,647572,652568,657640,662792, + 668024,673338,678737,684223,689797,695462,701219,707072, + 713023,719074,725227,731486,737853,744331,750922,757631, + 764460,771411,778490,785699,793041,800521,808143,815910, + 823827,831898,840127,848520,857081,865817,874730,883829, + 893117,902602,912289,922186,932298,942633,953199,964003, + 975054,986361,997931,1009774,1021901,1034322,1047046,1060087, + 1073455,1087164,1101225,1115654,1130465,1145673,1161294,1177345, + 1193846,1210813,1228269,1246234,1264730,1283783,1303416,1323658, + 1344537,1366084,1388330,1411312,1435065,1459630,1485049,1511367, + 1538632,1566898,1596220,1626658,1658278,1691149,1725348,1760956, + 1798063,1836758,1877161,1919378,1963536,2009771,2058233,2109087, + 2162516,2218719,2277919,2340362,2406322,2476104,2550052,2628549, + 2712030,2800983,2895966,2997613,3106651,3223918,3350381,3487165, + 3635590,3797206,3973855,4167737,4381502,4618375,4882318,5178251, + 5512368,5892567,6329090,6835455,7429880,8137527,8994149,10052327, + 11392683,13145455,15535599,18988036,24413316,34178904,56965752,170910304 +}; + + +const int finesine[10240] = +{ + 25,75,125,175,226,276,326,376, + 427,477,527,578,628,678,728,779, + 829,879,929,980,1030,1080,1130,1181, + 1231,1281,1331,1382,1432,1482,1532,1583, + 1633,1683,1733,1784,1834,1884,1934,1985, + 2035,2085,2135,2186,2236,2286,2336,2387, + 2437,2487,2537,2587,2638,2688,2738,2788, + 2839,2889,2939,2989,3039,3090,3140,3190, + 3240,3291,3341,3391,3441,3491,3541,3592, + 3642,3692,3742,3792,3843,3893,3943,3993, + 4043,4093,4144,4194,4244,4294,4344,4394, + 4445,4495,4545,4595,4645,4695,4745,4796, + 4846,4896,4946,4996,5046,5096,5146,5197, + 5247,5297,5347,5397,5447,5497,5547,5597, + 5647,5697,5748,5798,5848,5898,5948,5998, + 6048,6098,6148,6198,6248,6298,6348,6398, + 6448,6498,6548,6598,6648,6698,6748,6798, + 6848,6898,6948,6998,7048,7098,7148,7198, + 7248,7298,7348,7398,7448,7498,7548,7598, + 7648,7697,7747,7797,7847,7897,7947,7997, + 8047,8097,8147,8196,8246,8296,8346,8396, + 8446,8496,8545,8595,8645,8695,8745,8794, + 8844,8894,8944,8994,9043,9093,9143,9193, + 9243,9292,9342,9392,9442,9491,9541,9591, + 9640,9690,9740,9790,9839,9889,9939,9988, + 10038,10088,10137,10187,10237,10286,10336,10386, + 10435,10485,10534,10584,10634,10683,10733,10782, + 10832,10882,10931,10981,11030,11080,11129,11179, + 11228,11278,11327,11377,11426,11476,11525,11575, + 11624,11674,11723,11773,11822,11872,11921,11970, + 12020,12069,12119,12168,12218,12267,12316,12366, + 12415,12464,12514,12563,12612,12662,12711,12760, + 12810,12859,12908,12957,13007,13056,13105,13154, + 13204,13253,13302,13351,13401,13450,13499,13548, + 13597,13647,13696,13745,13794,13843,13892,13941, + 13990,14040,14089,14138,14187,14236,14285,14334, + 14383,14432,14481,14530,14579,14628,14677,14726, + 14775,14824,14873,14922,14971,15020,15069,15118, + 15167,15215,15264,15313,15362,15411,15460,15509, + 15557,15606,15655,15704,15753,15802,15850,15899, + 15948,15997,16045,16094,16143,16191,16240,16289, + 16338,16386,16435,16484,16532,16581,16629,16678, + 16727,16775,16824,16872,16921,16970,17018,17067, + 17115,17164,17212,17261,17309,17358,17406,17455, + 17503,17551,17600,17648,17697,17745,17793,17842, + 17890,17939,17987,18035,18084,18132,18180,18228, + 18277,18325,18373,18421,18470,18518,18566,18614, + 18663,18711,18759,18807,18855,18903,18951,19000, + 19048,19096,19144,19192,19240,19288,19336,19384, + 19432,19480,19528,19576,19624,19672,19720,19768, + 19816,19864,19912,19959,20007,20055,20103,20151, + 20199,20246,20294,20342,20390,20438,20485,20533, + 20581,20629,20676,20724,20772,20819,20867,20915, + 20962,21010,21057,21105,21153,21200,21248,21295, + 21343,21390,21438,21485,21533,21580,21628,21675, + 21723,21770,21817,21865,21912,21960,22007,22054, + 22102,22149,22196,22243,22291,22338,22385,22433, + 22480,22527,22574,22621,22668,22716,22763,22810, + 22857,22904,22951,22998,23045,23092,23139,23186, + 23233,23280,23327,23374,23421,23468,23515,23562, + 23609,23656,23703,23750,23796,23843,23890,23937, + 23984,24030,24077,24124,24171,24217,24264,24311, + 24357,24404,24451,24497,24544,24591,24637,24684, + 24730,24777,24823,24870,24916,24963,25009,25056, + 25102,25149,25195,25241,25288,25334,25381,25427, + 25473,25520,25566,25612,25658,25705,25751,25797, + 25843,25889,25936,25982,26028,26074,26120,26166, + 26212,26258,26304,26350,26396,26442,26488,26534, + 26580,26626,26672,26718,26764,26810,26856,26902, + 26947,26993,27039,27085,27131,27176,27222,27268, + 27313,27359,27405,27450,27496,27542,27587,27633, + 27678,27724,27770,27815,27861,27906,27952,27997, + 28042,28088,28133,28179,28224,28269,28315,28360, + 28405,28451,28496,28541,28586,28632,28677,28722, + 28767,28812,28858,28903,28948,28993,29038,29083, + 29128,29173,29218,29263,29308,29353,29398,29443, + 29488,29533,29577,29622,29667,29712,29757,29801, + 29846,29891,29936,29980,30025,30070,30114,30159, + 30204,30248,30293,30337,30382,30426,30471,30515, + 30560,30604,30649,30693,30738,30782,30826,30871, + 30915,30959,31004,31048,31092,31136,31181,31225, + 31269,31313,31357,31402,31446,31490,31534,31578, + 31622,31666,31710,31754,31798,31842,31886,31930, + 31974,32017,32061,32105,32149,32193,32236,32280, + 32324,32368,32411,32455,32499,32542,32586,32630, + 32673,32717,32760,32804,32847,32891,32934,32978, + 33021,33065,33108,33151,33195,33238,33281,33325, + 33368,33411,33454,33498,33541,33584,33627,33670, + 33713,33756,33799,33843,33886,33929,33972,34015, + 34057,34100,34143,34186,34229,34272,34315,34358, + 34400,34443,34486,34529,34571,34614,34657,34699, + 34742,34785,34827,34870,34912,34955,34997,35040, + 35082,35125,35167,35210,35252,35294,35337,35379, + 35421,35464,35506,35548,35590,35633,35675,35717, + 35759,35801,35843,35885,35927,35969,36011,36053, + 36095,36137,36179,36221,36263,36305,36347,36388, + 36430,36472,36514,36555,36597,36639,36681,36722, + 36764,36805,36847,36889,36930,36972,37013,37055, + 37096,37137,37179,37220,37262,37303,37344,37386, + 37427,37468,37509,37551,37592,37633,37674,37715, + 37756,37797,37838,37879,37920,37961,38002,38043, + 38084,38125,38166,38207,38248,38288,38329,38370, + 38411,38451,38492,38533,38573,38614,38655,38695, + 38736,38776,38817,38857,38898,38938,38979,39019, + 39059,39100,39140,39180,39221,39261,39301,39341, + 39382,39422,39462,39502,39542,39582,39622,39662, + 39702,39742,39782,39822,39862,39902,39942,39982, + 40021,40061,40101,40141,40180,40220,40260,40300, + 40339,40379,40418,40458,40497,40537,40576,40616, + 40655,40695,40734,40773,40813,40852,40891,40931, + 40970,41009,41048,41087,41127,41166,41205,41244, + 41283,41322,41361,41400,41439,41478,41517,41556, + 41595,41633,41672,41711,41750,41788,41827,41866, + 41904,41943,41982,42020,42059,42097,42136,42174, + 42213,42251,42290,42328,42366,42405,42443,42481, + 42520,42558,42596,42634,42672,42711,42749,42787, + 42825,42863,42901,42939,42977,43015,43053,43091, + 43128,43166,43204,43242,43280,43317,43355,43393, + 43430,43468,43506,43543,43581,43618,43656,43693, + 43731,43768,43806,43843,43880,43918,43955,43992, + 44029,44067,44104,44141,44178,44215,44252,44289, + 44326,44363,44400,44437,44474,44511,44548,44585, + 44622,44659,44695,44732,44769,44806,44842,44879, + 44915,44952,44989,45025,45062,45098,45135,45171, + 45207,45244,45280,45316,45353,45389,45425,45462, + 45498,45534,45570,45606,45642,45678,45714,45750, + 45786,45822,45858,45894,45930,45966,46002,46037, + 46073,46109,46145,46180,46216,46252,46287,46323, + 46358,46394,46429,46465,46500,46536,46571,46606, + 46642,46677,46712,46747,46783,46818,46853,46888, + 46923,46958,46993,47028,47063,47098,47133,47168, + 47203,47238,47273,47308,47342,47377,47412,47446, + 47481,47516,47550,47585,47619,47654,47688,47723, + 47757,47792,47826,47860,47895,47929,47963,47998, + 48032,48066,48100,48134,48168,48202,48237,48271, + 48305,48338,48372,48406,48440,48474,48508,48542, + 48575,48609,48643,48676,48710,48744,48777,48811, + 48844,48878,48911,48945,48978,49012,49045,49078, + 49112,49145,49178,49211,49244,49278,49311,49344, + 49377,49410,49443,49476,49509,49542,49575,49608, + 49640,49673,49706,49739,49771,49804,49837,49869, + 49902,49935,49967,50000,50032,50065,50097,50129, + 50162,50194,50226,50259,50291,50323,50355,50387, + 50420,50452,50484,50516,50548,50580,50612,50644, + 50675,50707,50739,50771,50803,50834,50866,50898, + 50929,50961,50993,51024,51056,51087,51119,51150, + 51182,51213,51244,51276,51307,51338,51369,51401, + 51432,51463,51494,51525,51556,51587,51618,51649, + 51680,51711,51742,51773,51803,51834,51865,51896, + 51926,51957,51988,52018,52049,52079,52110,52140, + 52171,52201,52231,52262,52292,52322,52353,52383, + 52413,52443,52473,52503,52534,52564,52594,52624, + 52653,52683,52713,52743,52773,52803,52832,52862, + 52892,52922,52951,52981,53010,53040,53069,53099, + 53128,53158,53187,53216,53246,53275,53304,53334, + 53363,53392,53421,53450,53479,53508,53537,53566, + 53595,53624,53653,53682,53711,53739,53768,53797, + 53826,53854,53883,53911,53940,53969,53997,54026, + 54054,54082,54111,54139,54167,54196,54224,54252, + 54280,54308,54337,54365,54393,54421,54449,54477, + 54505,54533,54560,54588,54616,54644,54672,54699, + 54727,54755,54782,54810,54837,54865,54892,54920, + 54947,54974,55002,55029,55056,55084,55111,55138, + 55165,55192,55219,55246,55274,55300,55327,55354, + 55381,55408,55435,55462,55489,55515,55542,55569, + 55595,55622,55648,55675,55701,55728,55754,55781, + 55807,55833,55860,55886,55912,55938,55965,55991, + 56017,56043,56069,56095,56121,56147,56173,56199, + 56225,56250,56276,56302,56328,56353,56379,56404, + 56430,56456,56481,56507,56532,56557,56583,56608, + 56633,56659,56684,56709,56734,56760,56785,56810, + 56835,56860,56885,56910,56935,56959,56984,57009, + 57034,57059,57083,57108,57133,57157,57182,57206, + 57231,57255,57280,57304,57329,57353,57377,57402, + 57426,57450,57474,57498,57522,57546,57570,57594, + 57618,57642,57666,57690,57714,57738,57762,57785, + 57809,57833,57856,57880,57903,57927,57950,57974, + 57997,58021,58044,58067,58091,58114,58137,58160, + 58183,58207,58230,58253,58276,58299,58322,58345, + 58367,58390,58413,58436,58459,58481,58504,58527, + 58549,58572,58594,58617,58639,58662,58684,58706, + 58729,58751,58773,58795,58818,58840,58862,58884, + 58906,58928,58950,58972,58994,59016,59038,59059, + 59081,59103,59125,59146,59168,59190,59211,59233, + 59254,59276,59297,59318,59340,59361,59382,59404, + 59425,59446,59467,59488,59509,59530,59551,59572, + 59593,59614,59635,59656,59677,59697,59718,59739, + 59759,59780,59801,59821,59842,59862,59883,59903, + 59923,59944,59964,59984,60004,60025,60045,60065, + 60085,60105,60125,60145,60165,60185,60205,60225, + 60244,60264,60284,60304,60323,60343,60363,60382, + 60402,60421,60441,60460,60479,60499,60518,60537, + 60556,60576,60595,60614,60633,60652,60671,60690, + 60709,60728,60747,60766,60785,60803,60822,60841, + 60859,60878,60897,60915,60934,60952,60971,60989, + 61007,61026,61044,61062,61081,61099,61117,61135, + 61153,61171,61189,61207,61225,61243,61261,61279, + 61297,61314,61332,61350,61367,61385,61403,61420, + 61438,61455,61473,61490,61507,61525,61542,61559, + 61577,61594,61611,61628,61645,61662,61679,61696, + 61713,61730,61747,61764,61780,61797,61814,61831, + 61847,61864,61880,61897,61913,61930,61946,61963, + 61979,61995,62012,62028,62044,62060,62076,62092, + 62108,62125,62141,62156,62172,62188,62204,62220, + 62236,62251,62267,62283,62298,62314,62329,62345, + 62360,62376,62391,62407,62422,62437,62453,62468, + 62483,62498,62513,62528,62543,62558,62573,62588, + 62603,62618,62633,62648,62662,62677,62692,62706, + 62721,62735,62750,62764,62779,62793,62808,62822, + 62836,62850,62865,62879,62893,62907,62921,62935, + 62949,62963,62977,62991,63005,63019,63032,63046, + 63060,63074,63087,63101,63114,63128,63141,63155, + 63168,63182,63195,63208,63221,63235,63248,63261, + 63274,63287,63300,63313,63326,63339,63352,63365, + 63378,63390,63403,63416,63429,63441,63454,63466, + 63479,63491,63504,63516,63528,63541,63553,63565, + 63578,63590,63602,63614,63626,63638,63650,63662, + 63674,63686,63698,63709,63721,63733,63745,63756, + 63768,63779,63791,63803,63814,63825,63837,63848, + 63859,63871,63882,63893,63904,63915,63927,63938, + 63949,63960,63971,63981,63992,64003,64014,64025, + 64035,64046,64057,64067,64078,64088,64099,64109, + 64120,64130,64140,64151,64161,64171,64181,64192, + 64202,64212,64222,64232,64242,64252,64261,64271, + 64281,64291,64301,64310,64320,64330,64339,64349, + 64358,64368,64377,64387,64396,64405,64414,64424, + 64433,64442,64451,64460,64469,64478,64487,64496, + 64505,64514,64523,64532,64540,64549,64558,64566, + 64575,64584,64592,64601,64609,64617,64626,64634, + 64642,64651,64659,64667,64675,64683,64691,64699, + 64707,64715,64723,64731,64739,64747,64754,64762, + 64770,64777,64785,64793,64800,64808,64815,64822, + 64830,64837,64844,64852,64859,64866,64873,64880, + 64887,64895,64902,64908,64915,64922,64929,64936, + 64943,64949,64956,64963,64969,64976,64982,64989, + 64995,65002,65008,65015,65021,65027,65033,65040, + 65046,65052,65058,65064,65070,65076,65082,65088, + 65094,65099,65105,65111,65117,65122,65128,65133, + 65139,65144,65150,65155,65161,65166,65171,65177, + 65182,65187,65192,65197,65202,65207,65212,65217, + 65222,65227,65232,65237,65242,65246,65251,65256, + 65260,65265,65270,65274,65279,65283,65287,65292, + 65296,65300,65305,65309,65313,65317,65321,65325, + 65329,65333,65337,65341,65345,65349,65352,65356, + 65360,65363,65367,65371,65374,65378,65381,65385, + 65388,65391,65395,65398,65401,65404,65408,65411, + 65414,65417,65420,65423,65426,65429,65431,65434, + 65437,65440,65442,65445,65448,65450,65453,65455, + 65458,65460,65463,65465,65467,65470,65472,65474, + 65476,65478,65480,65482,65484,65486,65488,65490, + 65492,65494,65496,65497,65499,65501,65502,65504, + 65505,65507,65508,65510,65511,65513,65514,65515, + 65516,65518,65519,65520,65521,65522,65523,65524, + 65525,65526,65527,65527,65528,65529,65530,65530, + 65531,65531,65532,65532,65533,65533,65534,65534, + 65534,65535,65535,65535,65535,65535,65535,65535, + 65535,65535,65535,65535,65535,65535,65535,65534, + 65534,65534,65533,65533,65532,65532,65531,65531, + 65530,65530,65529,65528,65527,65527,65526,65525, + 65524,65523,65522,65521,65520,65519,65518,65516, + 65515,65514,65513,65511,65510,65508,65507,65505, + 65504,65502,65501,65499,65497,65496,65494,65492, + 65490,65488,65486,65484,65482,65480,65478,65476, + 65474,65472,65470,65467,65465,65463,65460,65458, + 65455,65453,65450,65448,65445,65442,65440,65437, + 65434,65431,65429,65426,65423,65420,65417,65414, + 65411,65408,65404,65401,65398,65395,65391,65388, + 65385,65381,65378,65374,65371,65367,65363,65360, + 65356,65352,65349,65345,65341,65337,65333,65329, + 65325,65321,65317,65313,65309,65305,65300,65296, + 65292,65287,65283,65279,65274,65270,65265,65260, + 65256,65251,65246,65242,65237,65232,65227,65222, + 65217,65212,65207,65202,65197,65192,65187,65182, + 65177,65171,65166,65161,65155,65150,65144,65139, + 65133,65128,65122,65117,65111,65105,65099,65094, + 65088,65082,65076,65070,65064,65058,65052,65046, + 65040,65033,65027,65021,65015,65008,65002,64995, + 64989,64982,64976,64969,64963,64956,64949,64943, + 64936,64929,64922,64915,64908,64902,64895,64887, + 64880,64873,64866,64859,64852,64844,64837,64830, + 64822,64815,64808,64800,64793,64785,64777,64770, + 64762,64754,64747,64739,64731,64723,64715,64707, + 64699,64691,64683,64675,64667,64659,64651,64642, + 64634,64626,64617,64609,64600,64592,64584,64575, + 64566,64558,64549,64540,64532,64523,64514,64505, + 64496,64487,64478,64469,64460,64451,64442,64433, + 64424,64414,64405,64396,64387,64377,64368,64358, + 64349,64339,64330,64320,64310,64301,64291,64281, + 64271,64261,64252,64242,64232,64222,64212,64202, + 64192,64181,64171,64161,64151,64140,64130,64120, + 64109,64099,64088,64078,64067,64057,64046,64035, + 64025,64014,64003,63992,63981,63971,63960,63949, + 63938,63927,63915,63904,63893,63882,63871,63859, + 63848,63837,63825,63814,63803,63791,63779,63768, + 63756,63745,63733,63721,63709,63698,63686,63674, + 63662,63650,63638,63626,63614,63602,63590,63578, + 63565,63553,63541,63528,63516,63504,63491,63479, + 63466,63454,63441,63429,63416,63403,63390,63378, + 63365,63352,63339,63326,63313,63300,63287,63274, + 63261,63248,63235,63221,63208,63195,63182,63168, + 63155,63141,63128,63114,63101,63087,63074,63060, + 63046,63032,63019,63005,62991,62977,62963,62949, + 62935,62921,62907,62893,62879,62865,62850,62836, + 62822,62808,62793,62779,62764,62750,62735,62721, + 62706,62692,62677,62662,62648,62633,62618,62603, + 62588,62573,62558,62543,62528,62513,62498,62483, + 62468,62453,62437,62422,62407,62391,62376,62360, + 62345,62329,62314,62298,62283,62267,62251,62236, + 62220,62204,62188,62172,62156,62141,62125,62108, + 62092,62076,62060,62044,62028,62012,61995,61979, + 61963,61946,61930,61913,61897,61880,61864,61847, + 61831,61814,61797,61780,61764,61747,61730,61713, + 61696,61679,61662,61645,61628,61611,61594,61577, + 61559,61542,61525,61507,61490,61473,61455,61438, + 61420,61403,61385,61367,61350,61332,61314,61297, + 61279,61261,61243,61225,61207,61189,61171,61153, + 61135,61117,61099,61081,61062,61044,61026,61007, + 60989,60971,60952,60934,60915,60897,60878,60859, + 60841,60822,60803,60785,60766,60747,60728,60709, + 60690,60671,60652,60633,60614,60595,60576,60556, + 60537,60518,60499,60479,60460,60441,60421,60402, + 60382,60363,60343,60323,60304,60284,60264,60244, + 60225,60205,60185,60165,60145,60125,60105,60085, + 60065,60045,60025,60004,59984,59964,59944,59923, + 59903,59883,59862,59842,59821,59801,59780,59759, + 59739,59718,59697,59677,59656,59635,59614,59593, + 59572,59551,59530,59509,59488,59467,59446,59425, + 59404,59382,59361,59340,59318,59297,59276,59254, + 59233,59211,59190,59168,59146,59125,59103,59081, + 59059,59038,59016,58994,58972,58950,58928,58906, + 58884,58862,58840,58818,58795,58773,58751,58729, + 58706,58684,58662,58639,58617,58594,58572,58549, + 58527,58504,58481,58459,58436,58413,58390,58367, + 58345,58322,58299,58276,58253,58230,58207,58183, + 58160,58137,58114,58091,58067,58044,58021,57997, + 57974,57950,57927,57903,57880,57856,57833,57809, + 57785,57762,57738,57714,57690,57666,57642,57618, + 57594,57570,57546,57522,57498,57474,57450,57426, + 57402,57377,57353,57329,57304,57280,57255,57231, + 57206,57182,57157,57133,57108,57083,57059,57034, + 57009,56984,56959,56935,56910,56885,56860,56835, + 56810,56785,56760,56734,56709,56684,56659,56633, + 56608,56583,56557,56532,56507,56481,56456,56430, + 56404,56379,56353,56328,56302,56276,56250,56225, + 56199,56173,56147,56121,56095,56069,56043,56017, + 55991,55965,55938,55912,55886,55860,55833,55807, + 55781,55754,55728,55701,55675,55648,55622,55595, + 55569,55542,55515,55489,55462,55435,55408,55381, + 55354,55327,55300,55274,55246,55219,55192,55165, + 55138,55111,55084,55056,55029,55002,54974,54947, + 54920,54892,54865,54837,54810,54782,54755,54727, + 54699,54672,54644,54616,54588,54560,54533,54505, + 54477,54449,54421,54393,54365,54337,54308,54280, + 54252,54224,54196,54167,54139,54111,54082,54054, + 54026,53997,53969,53940,53911,53883,53854,53826, + 53797,53768,53739,53711,53682,53653,53624,53595, + 53566,53537,53508,53479,53450,53421,53392,53363, + 53334,53304,53275,53246,53216,53187,53158,53128, + 53099,53069,53040,53010,52981,52951,52922,52892, + 52862,52832,52803,52773,52743,52713,52683,52653, + 52624,52594,52564,52534,52503,52473,52443,52413, + 52383,52353,52322,52292,52262,52231,52201,52171, + 52140,52110,52079,52049,52018,51988,51957,51926, + 51896,51865,51834,51803,51773,51742,51711,51680, + 51649,51618,51587,51556,51525,51494,51463,51432, + 51401,51369,51338,51307,51276,51244,51213,51182, + 51150,51119,51087,51056,51024,50993,50961,50929, + 50898,50866,50834,50803,50771,50739,50707,50675, + 50644,50612,50580,50548,50516,50484,50452,50420, + 50387,50355,50323,50291,50259,50226,50194,50162, + 50129,50097,50065,50032,50000,49967,49935,49902, + 49869,49837,49804,49771,49739,49706,49673,49640, + 49608,49575,49542,49509,49476,49443,49410,49377, + 49344,49311,49278,49244,49211,49178,49145,49112, + 49078,49045,49012,48978,48945,48911,48878,48844, + 48811,48777,48744,48710,48676,48643,48609,48575, + 48542,48508,48474,48440,48406,48372,48338,48304, + 48271,48237,48202,48168,48134,48100,48066,48032, + 47998,47963,47929,47895,47860,47826,47792,47757, + 47723,47688,47654,47619,47585,47550,47516,47481, + 47446,47412,47377,47342,47308,47273,47238,47203, + 47168,47133,47098,47063,47028,46993,46958,46923, + 46888,46853,46818,46783,46747,46712,46677,46642, + 46606,46571,46536,46500,46465,46429,46394,46358, + 46323,46287,46252,46216,46180,46145,46109,46073, + 46037,46002,45966,45930,45894,45858,45822,45786, + 45750,45714,45678,45642,45606,45570,45534,45498, + 45462,45425,45389,45353,45316,45280,45244,45207, + 45171,45135,45098,45062,45025,44989,44952,44915, + 44879,44842,44806,44769,44732,44695,44659,44622, + 44585,44548,44511,44474,44437,44400,44363,44326, + 44289,44252,44215,44178,44141,44104,44067,44029, + 43992,43955,43918,43880,43843,43806,43768,43731, + 43693,43656,43618,43581,43543,43506,43468,43430, + 43393,43355,43317,43280,43242,43204,43166,43128, + 43091,43053,43015,42977,42939,42901,42863,42825, + 42787,42749,42711,42672,42634,42596,42558,42520, + 42481,42443,42405,42366,42328,42290,42251,42213, + 42174,42136,42097,42059,42020,41982,41943,41904, + 41866,41827,41788,41750,41711,41672,41633,41595, + 41556,41517,41478,41439,41400,41361,41322,41283, + 41244,41205,41166,41127,41088,41048,41009,40970, + 40931,40891,40852,40813,40773,40734,40695,40655, + 40616,40576,40537,40497,40458,40418,40379,40339, + 40300,40260,40220,40180,40141,40101,40061,40021, + 39982,39942,39902,39862,39822,39782,39742,39702, + 39662,39622,39582,39542,39502,39462,39422,39382, + 39341,39301,39261,39221,39180,39140,39100,39059, + 39019,38979,38938,38898,38857,38817,38776,38736, + 38695,38655,38614,38573,38533,38492,38451,38411, + 38370,38329,38288,38248,38207,38166,38125,38084, + 38043,38002,37961,37920,37879,37838,37797,37756, + 37715,37674,37633,37592,37551,37509,37468,37427, + 37386,37344,37303,37262,37220,37179,37137,37096, + 37055,37013,36972,36930,36889,36847,36805,36764, + 36722,36681,36639,36597,36556,36514,36472,36430, + 36388,36347,36305,36263,36221,36179,36137,36095, + 36053,36011,35969,35927,35885,35843,35801,35759, + 35717,35675,35633,35590,35548,35506,35464,35421, + 35379,35337,35294,35252,35210,35167,35125,35082, + 35040,34997,34955,34912,34870,34827,34785,34742, + 34699,34657,34614,34571,34529,34486,34443,34400, + 34358,34315,34272,34229,34186,34143,34100,34057, + 34015,33972,33929,33886,33843,33799,33756,33713, + 33670,33627,33584,33541,33498,33454,33411,33368, + 33325,33281,33238,33195,33151,33108,33065,33021, + 32978,32934,32891,32847,32804,32760,32717,32673, + 32630,32586,32542,32499,32455,32411,32368,32324, + 32280,32236,32193,32149,32105,32061,32017,31974, + 31930,31886,31842,31798,31754,31710,31666,31622, + 31578,31534,31490,31446,31402,31357,31313,31269, + 31225,31181,31136,31092,31048,31004,30959,30915, + 30871,30826,30782,30738,30693,30649,30604,30560, + 30515,30471,30426,30382,30337,30293,30248,30204, + 30159,30114,30070,30025,29980,29936,29891,29846, + 29801,29757,29712,29667,29622,29577,29533,29488, + 29443,29398,29353,29308,29263,29218,29173,29128, + 29083,29038,28993,28948,28903,28858,28812,28767, + 28722,28677,28632,28586,28541,28496,28451,28405, + 28360,28315,28269,28224,28179,28133,28088,28042, + 27997,27952,27906,27861,27815,27770,27724,27678, + 27633,27587,27542,27496,27450,27405,27359,27313, + 27268,27222,27176,27131,27085,27039,26993,26947, + 26902,26856,26810,26764,26718,26672,26626,26580, + 26534,26488,26442,26396,26350,26304,26258,26212, + 26166,26120,26074,26028,25982,25936,25889,25843, + 25797,25751,25705,25658,25612,25566,25520,25473, + 25427,25381,25334,25288,25241,25195,25149,25102, + 25056,25009,24963,24916,24870,24823,24777,24730, + 24684,24637,24591,24544,24497,24451,24404,24357, + 24311,24264,24217,24171,24124,24077,24030,23984, + 23937,23890,23843,23796,23750,23703,23656,23609, + 23562,23515,23468,23421,23374,23327,23280,23233, + 23186,23139,23092,23045,22998,22951,22904,22857, + 22810,22763,22716,22668,22621,22574,22527,22480, + 22433,22385,22338,22291,22243,22196,22149,22102, + 22054,22007,21960,21912,21865,21817,21770,21723, + 21675,21628,21580,21533,21485,21438,21390,21343, + 21295,21248,21200,21153,21105,21057,21010,20962, + 20915,20867,20819,20772,20724,20676,20629,20581, + 20533,20485,20438,20390,20342,20294,20246,20199, + 20151,20103,20055,20007,19959,19912,19864,19816, + 19768,19720,19672,19624,19576,19528,19480,19432, + 19384,19336,19288,19240,19192,19144,19096,19048, + 19000,18951,18903,18855,18807,18759,18711,18663, + 18614,18566,18518,18470,18421,18373,18325,18277, + 18228,18180,18132,18084,18035,17987,17939,17890, + 17842,17793,17745,17697,17648,17600,17551,17503, + 17455,17406,17358,17309,17261,17212,17164,17115, + 17067,17018,16970,16921,16872,16824,16775,16727, + 16678,16629,16581,16532,16484,16435,16386,16338, + 16289,16240,16191,16143,16094,16045,15997,15948, + 15899,15850,15802,15753,15704,15655,15606,15557, + 15509,15460,15411,15362,15313,15264,15215,15167, + 15118,15069,15020,14971,14922,14873,14824,14775, + 14726,14677,14628,14579,14530,14481,14432,14383, + 14334,14285,14236,14187,14138,14089,14040,13990, + 13941,13892,13843,13794,13745,13696,13646,13597, + 13548,13499,13450,13401,13351,13302,13253,13204, + 13154,13105,13056,13007,12957,12908,12859,12810, + 12760,12711,12662,12612,12563,12514,12464,12415, + 12366,12316,12267,12218,12168,12119,12069,12020, + 11970,11921,11872,11822,11773,11723,11674,11624, + 11575,11525,11476,11426,11377,11327,11278,11228, + 11179,11129,11080,11030,10981,10931,10882,10832, + 10782,10733,10683,10634,10584,10534,10485,10435, + 10386,10336,10286,10237,10187,10137,10088,10038, + 9988,9939,9889,9839,9790,9740,9690,9640, + 9591,9541,9491,9442,9392,9342,9292,9243, + 9193,9143,9093,9043,8994,8944,8894,8844, + 8794,8745,8695,8645,8595,8545,8496,8446, + 8396,8346,8296,8246,8196,8147,8097,8047, + 7997,7947,7897,7847,7797,7747,7697,7648, + 7598,7548,7498,7448,7398,7348,7298,7248, + 7198,7148,7098,7048,6998,6948,6898,6848, + 6798,6748,6698,6648,6598,6548,6498,6448, + 6398,6348,6298,6248,6198,6148,6098,6048, + 5998,5948,5898,5848,5798,5748,5697,5647, + 5597,5547,5497,5447,5397,5347,5297,5247, + 5197,5146,5096,5046,4996,4946,4896,4846, + 4796,4745,4695,4645,4595,4545,4495,4445, + 4394,4344,4294,4244,4194,4144,4093,4043, + 3993,3943,3893,3843,3792,3742,3692,3642, + 3592,3541,3491,3441,3391,3341,3291,3240, + 3190,3140,3090,3039,2989,2939,2889,2839, + 2788,2738,2688,2638,2587,2537,2487,2437, + 2387,2336,2286,2236,2186,2135,2085,2035, + 1985,1934,1884,1834,1784,1733,1683,1633, + 1583,1532,1482,1432,1382,1331,1281,1231, + 1181,1130,1080,1030,980,929,879,829, + 779,728,678,628,578,527,477,427, + 376,326,276,226,175,125,75,25, + -25,-75,-125,-175,-226,-276,-326,-376, + -427,-477,-527,-578,-628,-678,-728,-779, + -829,-879,-929,-980,-1030,-1080,-1130,-1181, + -1231,-1281,-1331,-1382,-1432,-1482,-1532,-1583, + -1633,-1683,-1733,-1784,-1834,-1884,-1934,-1985, + -2035,-2085,-2135,-2186,-2236,-2286,-2336,-2387, + -2437,-2487,-2537,-2588,-2638,-2688,-2738,-2788, + -2839,-2889,-2939,-2989,-3039,-3090,-3140,-3190, + -3240,-3291,-3341,-3391,-3441,-3491,-3541,-3592, + -3642,-3692,-3742,-3792,-3843,-3893,-3943,-3993, + -4043,-4093,-4144,-4194,-4244,-4294,-4344,-4394, + -4445,-4495,-4545,-4595,-4645,-4695,-4745,-4796, + -4846,-4896,-4946,-4996,-5046,-5096,-5146,-5197, + -5247,-5297,-5347,-5397,-5447,-5497,-5547,-5597, + -5647,-5697,-5748,-5798,-5848,-5898,-5948,-5998, + -6048,-6098,-6148,-6198,-6248,-6298,-6348,-6398, + -6448,-6498,-6548,-6598,-6648,-6698,-6748,-6798, + -6848,-6898,-6948,-6998,-7048,-7098,-7148,-7198, + -7248,-7298,-7348,-7398,-7448,-7498,-7548,-7598, + -7648,-7697,-7747,-7797,-7847,-7897,-7947,-7997, + -8047,-8097,-8147,-8196,-8246,-8296,-8346,-8396, + -8446,-8496,-8545,-8595,-8645,-8695,-8745,-8794, + -8844,-8894,-8944,-8994,-9043,-9093,-9143,-9193, + -9243,-9292,-9342,-9392,-9442,-9491,-9541,-9591, + -9640,-9690,-9740,-9790,-9839,-9889,-9939,-9988, + -10038,-10088,-10137,-10187,-10237,-10286,-10336,-10386, + -10435,-10485,-10534,-10584,-10634,-10683,-10733,-10782, + -10832,-10882,-10931,-10981,-11030,-11080,-11129,-11179, + -11228,-11278,-11327,-11377,-11426,-11476,-11525,-11575, + -11624,-11674,-11723,-11773,-11822,-11872,-11921,-11970, + -12020,-12069,-12119,-12168,-12218,-12267,-12316,-12366, + -12415,-12464,-12514,-12563,-12612,-12662,-12711,-12760, + -12810,-12859,-12908,-12957,-13007,-13056,-13105,-13154, + -13204,-13253,-13302,-13351,-13401,-13450,-13499,-13548, + -13597,-13647,-13696,-13745,-13794,-13843,-13892,-13941, + -13990,-14040,-14089,-14138,-14187,-14236,-14285,-14334, + -14383,-14432,-14481,-14530,-14579,-14628,-14677,-14726, + -14775,-14824,-14873,-14922,-14971,-15020,-15069,-15118, + -15167,-15215,-15264,-15313,-15362,-15411,-15460,-15509, + -15557,-15606,-15655,-15704,-15753,-15802,-15850,-15899, + -15948,-15997,-16045,-16094,-16143,-16191,-16240,-16289, + -16338,-16386,-16435,-16484,-16532,-16581,-16629,-16678, + -16727,-16775,-16824,-16872,-16921,-16970,-17018,-17067, + -17115,-17164,-17212,-17261,-17309,-17358,-17406,-17455, + -17503,-17551,-17600,-17648,-17697,-17745,-17793,-17842, + -17890,-17939,-17987,-18035,-18084,-18132,-18180,-18228, + -18277,-18325,-18373,-18421,-18470,-18518,-18566,-18614, + -18663,-18711,-18759,-18807,-18855,-18903,-18951,-19000, + -19048,-19096,-19144,-19192,-19240,-19288,-19336,-19384, + -19432,-19480,-19528,-19576,-19624,-19672,-19720,-19768, + -19816,-19864,-19912,-19959,-20007,-20055,-20103,-20151, + -20199,-20246,-20294,-20342,-20390,-20438,-20485,-20533, + -20581,-20629,-20676,-20724,-20772,-20819,-20867,-20915, + -20962,-21010,-21057,-21105,-21153,-21200,-21248,-21295, + -21343,-21390,-21438,-21485,-21533,-21580,-21628,-21675, + -21723,-21770,-21817,-21865,-21912,-21960,-22007,-22054, + -22102,-22149,-22196,-22243,-22291,-22338,-22385,-22433, + -22480,-22527,-22574,-22621,-22668,-22716,-22763,-22810, + -22857,-22904,-22951,-22998,-23045,-23092,-23139,-23186, + -23233,-23280,-23327,-23374,-23421,-23468,-23515,-23562, + -23609,-23656,-23703,-23750,-23796,-23843,-23890,-23937, + -23984,-24030,-24077,-24124,-24171,-24217,-24264,-24311, + -24357,-24404,-24451,-24497,-24544,-24591,-24637,-24684, + -24730,-24777,-24823,-24870,-24916,-24963,-25009,-25056, + -25102,-25149,-25195,-25241,-25288,-25334,-25381,-25427, + -25473,-25520,-25566,-25612,-25658,-25705,-25751,-25797, + -25843,-25889,-25936,-25982,-26028,-26074,-26120,-26166, + -26212,-26258,-26304,-26350,-26396,-26442,-26488,-26534, + -26580,-26626,-26672,-26718,-26764,-26810,-26856,-26902, + -26947,-26993,-27039,-27085,-27131,-27176,-27222,-27268, + -27313,-27359,-27405,-27450,-27496,-27542,-27587,-27633, + -27678,-27724,-27770,-27815,-27861,-27906,-27952,-27997, + -28042,-28088,-28133,-28179,-28224,-28269,-28315,-28360, + -28405,-28451,-28496,-28541,-28586,-28632,-28677,-28722, + -28767,-28812,-28858,-28903,-28948,-28993,-29038,-29083, + -29128,-29173,-29218,-29263,-29308,-29353,-29398,-29443, + -29488,-29533,-29577,-29622,-29667,-29712,-29757,-29801, + -29846,-29891,-29936,-29980,-30025,-30070,-30114,-30159, + -30204,-30248,-30293,-30337,-30382,-30426,-30471,-30515, + -30560,-30604,-30649,-30693,-30738,-30782,-30826,-30871, + -30915,-30959,-31004,-31048,-31092,-31136,-31181,-31225, + -31269,-31313,-31357,-31402,-31446,-31490,-31534,-31578, + -31622,-31666,-31710,-31754,-31798,-31842,-31886,-31930, + -31974,-32017,-32061,-32105,-32149,-32193,-32236,-32280, + -32324,-32368,-32411,-32455,-32499,-32542,-32586,-32630, + -32673,-32717,-32760,-32804,-32847,-32891,-32934,-32978, + -33021,-33065,-33108,-33151,-33195,-33238,-33281,-33325, + -33368,-33411,-33454,-33498,-33541,-33584,-33627,-33670, + -33713,-33756,-33799,-33843,-33886,-33929,-33972,-34015, + -34057,-34100,-34143,-34186,-34229,-34272,-34315,-34358, + -34400,-34443,-34486,-34529,-34571,-34614,-34657,-34699, + -34742,-34785,-34827,-34870,-34912,-34955,-34997,-35040, + -35082,-35125,-35167,-35210,-35252,-35294,-35337,-35379, + -35421,-35464,-35506,-35548,-35590,-35633,-35675,-35717, + -35759,-35801,-35843,-35885,-35927,-35969,-36011,-36053, + -36095,-36137,-36179,-36221,-36263,-36305,-36347,-36388, + -36430,-36472,-36514,-36555,-36597,-36639,-36681,-36722, + -36764,-36805,-36847,-36889,-36930,-36972,-37013,-37055, + -37096,-37137,-37179,-37220,-37262,-37303,-37344,-37386, + -37427,-37468,-37509,-37551,-37592,-37633,-37674,-37715, + -37756,-37797,-37838,-37879,-37920,-37961,-38002,-38043, + -38084,-38125,-38166,-38207,-38248,-38288,-38329,-38370, + -38411,-38451,-38492,-38533,-38573,-38614,-38655,-38695, + -38736,-38776,-38817,-38857,-38898,-38938,-38979,-39019, + -39059,-39100,-39140,-39180,-39221,-39261,-39301,-39341, + -39382,-39422,-39462,-39502,-39542,-39582,-39622,-39662, + -39702,-39742,-39782,-39822,-39862,-39902,-39942,-39982, + -40021,-40061,-40101,-40141,-40180,-40220,-40260,-40299, + -40339,-40379,-40418,-40458,-40497,-40537,-40576,-40616, + -40655,-40695,-40734,-40773,-40813,-40852,-40891,-40931, + -40970,-41009,-41048,-41087,-41127,-41166,-41205,-41244, + -41283,-41322,-41361,-41400,-41439,-41478,-41517,-41556, + -41595,-41633,-41672,-41711,-41750,-41788,-41827,-41866, + -41904,-41943,-41982,-42020,-42059,-42097,-42136,-42174, + -42213,-42251,-42290,-42328,-42366,-42405,-42443,-42481, + -42520,-42558,-42596,-42634,-42672,-42711,-42749,-42787, + -42825,-42863,-42901,-42939,-42977,-43015,-43053,-43091, + -43128,-43166,-43204,-43242,-43280,-43317,-43355,-43393, + -43430,-43468,-43506,-43543,-43581,-43618,-43656,-43693, + -43731,-43768,-43806,-43843,-43880,-43918,-43955,-43992, + -44029,-44067,-44104,-44141,-44178,-44215,-44252,-44289, + -44326,-44363,-44400,-44437,-44474,-44511,-44548,-44585, + -44622,-44659,-44695,-44732,-44769,-44806,-44842,-44879, + -44915,-44952,-44989,-45025,-45062,-45098,-45135,-45171, + -45207,-45244,-45280,-45316,-45353,-45389,-45425,-45462, + -45498,-45534,-45570,-45606,-45642,-45678,-45714,-45750, + -45786,-45822,-45858,-45894,-45930,-45966,-46002,-46037, + -46073,-46109,-46145,-46180,-46216,-46252,-46287,-46323, + -46358,-46394,-46429,-46465,-46500,-46536,-46571,-46606, + -46642,-46677,-46712,-46747,-46783,-46818,-46853,-46888, + -46923,-46958,-46993,-47028,-47063,-47098,-47133,-47168, + -47203,-47238,-47273,-47308,-47342,-47377,-47412,-47446, + -47481,-47516,-47550,-47585,-47619,-47654,-47688,-47723, + -47757,-47792,-47826,-47860,-47895,-47929,-47963,-47998, + -48032,-48066,-48100,-48134,-48168,-48202,-48236,-48271, + -48304,-48338,-48372,-48406,-48440,-48474,-48508,-48542, + -48575,-48609,-48643,-48676,-48710,-48744,-48777,-48811, + -48844,-48878,-48911,-48945,-48978,-49012,-49045,-49078, + -49112,-49145,-49178,-49211,-49244,-49278,-49311,-49344, + -49377,-49410,-49443,-49476,-49509,-49542,-49575,-49608, + -49640,-49673,-49706,-49739,-49771,-49804,-49837,-49869, + -49902,-49935,-49967,-50000,-50032,-50065,-50097,-50129, + -50162,-50194,-50226,-50259,-50291,-50323,-50355,-50387, + -50420,-50452,-50484,-50516,-50548,-50580,-50612,-50644, + -50675,-50707,-50739,-50771,-50803,-50834,-50866,-50898, + -50929,-50961,-50993,-51024,-51056,-51087,-51119,-51150, + -51182,-51213,-51244,-51276,-51307,-51338,-51369,-51401, + -51432,-51463,-51494,-51525,-51556,-51587,-51618,-51649, + -51680,-51711,-51742,-51773,-51803,-51834,-51865,-51896, + -51926,-51957,-51988,-52018,-52049,-52079,-52110,-52140, + -52171,-52201,-52231,-52262,-52292,-52322,-52353,-52383, + -52413,-52443,-52473,-52503,-52534,-52564,-52594,-52624, + -52653,-52683,-52713,-52743,-52773,-52803,-52832,-52862, + -52892,-52922,-52951,-52981,-53010,-53040,-53069,-53099, + -53128,-53158,-53187,-53216,-53246,-53275,-53304,-53334, + -53363,-53392,-53421,-53450,-53479,-53508,-53537,-53566, + -53595,-53624,-53653,-53682,-53711,-53739,-53768,-53797, + -53826,-53854,-53883,-53911,-53940,-53969,-53997,-54026, + -54054,-54082,-54111,-54139,-54167,-54196,-54224,-54252, + -54280,-54308,-54337,-54365,-54393,-54421,-54449,-54477, + -54505,-54533,-54560,-54588,-54616,-54644,-54672,-54699, + -54727,-54755,-54782,-54810,-54837,-54865,-54892,-54920, + -54947,-54974,-55002,-55029,-55056,-55084,-55111,-55138, + -55165,-55192,-55219,-55246,-55274,-55300,-55327,-55354, + -55381,-55408,-55435,-55462,-55489,-55515,-55542,-55569, + -55595,-55622,-55648,-55675,-55701,-55728,-55754,-55781, + -55807,-55833,-55860,-55886,-55912,-55938,-55965,-55991, + -56017,-56043,-56069,-56095,-56121,-56147,-56173,-56199, + -56225,-56250,-56276,-56302,-56328,-56353,-56379,-56404, + -56430,-56456,-56481,-56507,-56532,-56557,-56583,-56608, + -56633,-56659,-56684,-56709,-56734,-56760,-56785,-56810, + -56835,-56860,-56885,-56910,-56935,-56959,-56984,-57009, + -57034,-57059,-57083,-57108,-57133,-57157,-57182,-57206, + -57231,-57255,-57280,-57304,-57329,-57353,-57377,-57402, + -57426,-57450,-57474,-57498,-57522,-57546,-57570,-57594, + -57618,-57642,-57666,-57690,-57714,-57738,-57762,-57785, + -57809,-57833,-57856,-57880,-57903,-57927,-57950,-57974, + -57997,-58021,-58044,-58067,-58091,-58114,-58137,-58160, + -58183,-58207,-58230,-58253,-58276,-58299,-58322,-58345, + -58367,-58390,-58413,-58436,-58459,-58481,-58504,-58527, + -58549,-58572,-58594,-58617,-58639,-58662,-58684,-58706, + -58729,-58751,-58773,-58795,-58818,-58840,-58862,-58884, + -58906,-58928,-58950,-58972,-58994,-59016,-59038,-59059, + -59081,-59103,-59125,-59146,-59168,-59190,-59211,-59233, + -59254,-59276,-59297,-59318,-59340,-59361,-59382,-59404, + -59425,-59446,-59467,-59488,-59509,-59530,-59551,-59572, + -59593,-59614,-59635,-59656,-59677,-59697,-59718,-59739, + -59759,-59780,-59801,-59821,-59842,-59862,-59883,-59903, + -59923,-59944,-59964,-59984,-60004,-60025,-60045,-60065, + -60085,-60105,-60125,-60145,-60165,-60185,-60205,-60225, + -60244,-60264,-60284,-60304,-60323,-60343,-60363,-60382, + -60402,-60421,-60441,-60460,-60479,-60499,-60518,-60537, + -60556,-60576,-60595,-60614,-60633,-60652,-60671,-60690, + -60709,-60728,-60747,-60766,-60785,-60803,-60822,-60841, + -60859,-60878,-60897,-60915,-60934,-60952,-60971,-60989, + -61007,-61026,-61044,-61062,-61081,-61099,-61117,-61135, + -61153,-61171,-61189,-61207,-61225,-61243,-61261,-61279, + -61297,-61314,-61332,-61350,-61367,-61385,-61403,-61420, + -61438,-61455,-61473,-61490,-61507,-61525,-61542,-61559, + -61577,-61594,-61611,-61628,-61645,-61662,-61679,-61696, + -61713,-61730,-61747,-61764,-61780,-61797,-61814,-61831, + -61847,-61864,-61880,-61897,-61913,-61930,-61946,-61963, + -61979,-61995,-62012,-62028,-62044,-62060,-62076,-62092, + -62108,-62125,-62141,-62156,-62172,-62188,-62204,-62220, + -62236,-62251,-62267,-62283,-62298,-62314,-62329,-62345, + -62360,-62376,-62391,-62407,-62422,-62437,-62453,-62468, + -62483,-62498,-62513,-62528,-62543,-62558,-62573,-62588, + -62603,-62618,-62633,-62648,-62662,-62677,-62692,-62706, + -62721,-62735,-62750,-62764,-62779,-62793,-62808,-62822, + -62836,-62850,-62865,-62879,-62893,-62907,-62921,-62935, + -62949,-62963,-62977,-62991,-63005,-63019,-63032,-63046, + -63060,-63074,-63087,-63101,-63114,-63128,-63141,-63155, + -63168,-63182,-63195,-63208,-63221,-63235,-63248,-63261, + -63274,-63287,-63300,-63313,-63326,-63339,-63352,-63365, + -63378,-63390,-63403,-63416,-63429,-63441,-63454,-63466, + -63479,-63491,-63504,-63516,-63528,-63541,-63553,-63565, + -63578,-63590,-63602,-63614,-63626,-63638,-63650,-63662, + -63674,-63686,-63698,-63709,-63721,-63733,-63745,-63756, + -63768,-63779,-63791,-63803,-63814,-63825,-63837,-63848, + -63859,-63871,-63882,-63893,-63904,-63915,-63927,-63938, + -63949,-63960,-63971,-63981,-63992,-64003,-64014,-64025, + -64035,-64046,-64057,-64067,-64078,-64088,-64099,-64109, + -64120,-64130,-64140,-64151,-64161,-64171,-64181,-64192, + -64202,-64212,-64222,-64232,-64242,-64252,-64261,-64271, + -64281,-64291,-64301,-64310,-64320,-64330,-64339,-64349, + -64358,-64368,-64377,-64387,-64396,-64405,-64414,-64424, + -64433,-64442,-64451,-64460,-64469,-64478,-64487,-64496, + -64505,-64514,-64523,-64532,-64540,-64549,-64558,-64566, + -64575,-64584,-64592,-64601,-64609,-64617,-64626,-64634, + -64642,-64651,-64659,-64667,-64675,-64683,-64691,-64699, + -64707,-64715,-64723,-64731,-64739,-64747,-64754,-64762, + -64770,-64777,-64785,-64793,-64800,-64808,-64815,-64822, + -64830,-64837,-64844,-64852,-64859,-64866,-64873,-64880, + -64887,-64895,-64902,-64908,-64915,-64922,-64929,-64936, + -64943,-64949,-64956,-64963,-64969,-64976,-64982,-64989, + -64995,-65002,-65008,-65015,-65021,-65027,-65033,-65040, + -65046,-65052,-65058,-65064,-65070,-65076,-65082,-65088, + -65094,-65099,-65105,-65111,-65117,-65122,-65128,-65133, + -65139,-65144,-65150,-65155,-65161,-65166,-65171,-65177, + -65182,-65187,-65192,-65197,-65202,-65207,-65212,-65217, + -65222,-65227,-65232,-65237,-65242,-65246,-65251,-65256, + -65260,-65265,-65270,-65274,-65279,-65283,-65287,-65292, + -65296,-65300,-65305,-65309,-65313,-65317,-65321,-65325, + -65329,-65333,-65337,-65341,-65345,-65349,-65352,-65356, + -65360,-65363,-65367,-65371,-65374,-65378,-65381,-65385, + -65388,-65391,-65395,-65398,-65401,-65404,-65408,-65411, + -65414,-65417,-65420,-65423,-65426,-65429,-65431,-65434, + -65437,-65440,-65442,-65445,-65448,-65450,-65453,-65455, + -65458,-65460,-65463,-65465,-65467,-65470,-65472,-65474, + -65476,-65478,-65480,-65482,-65484,-65486,-65488,-65490, + -65492,-65494,-65496,-65497,-65499,-65501,-65502,-65504, + -65505,-65507,-65508,-65510,-65511,-65513,-65514,-65515, + -65516,-65518,-65519,-65520,-65521,-65522,-65523,-65524, + -65525,-65526,-65527,-65527,-65528,-65529,-65530,-65530, + -65531,-65531,-65532,-65532,-65533,-65533,-65534,-65534, + -65534,-65535,-65535,-65535,-65535,-65535,-65535,-65535, + -65535,-65535,-65535,-65535,-65535,-65535,-65535,-65534, + -65534,-65534,-65533,-65533,-65532,-65532,-65531,-65531, + -65530,-65530,-65529,-65528,-65527,-65527,-65526,-65525, + -65524,-65523,-65522,-65521,-65520,-65519,-65518,-65516, + -65515,-65514,-65513,-65511,-65510,-65508,-65507,-65505, + -65504,-65502,-65501,-65499,-65497,-65496,-65494,-65492, + -65490,-65488,-65486,-65484,-65482,-65480,-65478,-65476, + -65474,-65472,-65470,-65467,-65465,-65463,-65460,-65458, + -65455,-65453,-65450,-65448,-65445,-65442,-65440,-65437, + -65434,-65431,-65429,-65426,-65423,-65420,-65417,-65414, + -65411,-65408,-65404,-65401,-65398,-65395,-65391,-65388, + -65385,-65381,-65378,-65374,-65371,-65367,-65363,-65360, + -65356,-65352,-65349,-65345,-65341,-65337,-65333,-65329, + -65325,-65321,-65317,-65313,-65309,-65305,-65300,-65296, + -65292,-65287,-65283,-65279,-65274,-65270,-65265,-65260, + -65256,-65251,-65246,-65242,-65237,-65232,-65227,-65222, + -65217,-65212,-65207,-65202,-65197,-65192,-65187,-65182, + -65177,-65171,-65166,-65161,-65155,-65150,-65144,-65139, + -65133,-65128,-65122,-65117,-65111,-65105,-65099,-65094, + -65088,-65082,-65076,-65070,-65064,-65058,-65052,-65046, + -65040,-65033,-65027,-65021,-65015,-65008,-65002,-64995, + -64989,-64982,-64976,-64969,-64963,-64956,-64949,-64943, + -64936,-64929,-64922,-64915,-64908,-64902,-64895,-64887, + -64880,-64873,-64866,-64859,-64852,-64844,-64837,-64830, + -64822,-64815,-64808,-64800,-64793,-64785,-64777,-64770, + -64762,-64754,-64747,-64739,-64731,-64723,-64715,-64707, + -64699,-64691,-64683,-64675,-64667,-64659,-64651,-64642, + -64634,-64626,-64617,-64609,-64601,-64592,-64584,-64575, + -64566,-64558,-64549,-64540,-64532,-64523,-64514,-64505, + -64496,-64487,-64478,-64469,-64460,-64451,-64442,-64433, + -64424,-64414,-64405,-64396,-64387,-64377,-64368,-64358, + -64349,-64339,-64330,-64320,-64310,-64301,-64291,-64281, + -64271,-64261,-64252,-64242,-64232,-64222,-64212,-64202, + -64192,-64181,-64171,-64161,-64151,-64140,-64130,-64120, + -64109,-64099,-64088,-64078,-64067,-64057,-64046,-64035, + -64025,-64014,-64003,-63992,-63981,-63971,-63960,-63949, + -63938,-63927,-63915,-63904,-63893,-63882,-63871,-63859, + -63848,-63837,-63825,-63814,-63803,-63791,-63779,-63768, + -63756,-63745,-63733,-63721,-63709,-63698,-63686,-63674, + -63662,-63650,-63638,-63626,-63614,-63602,-63590,-63578, + -63565,-63553,-63541,-63528,-63516,-63504,-63491,-63479, + -63466,-63454,-63441,-63429,-63416,-63403,-63390,-63378, + -63365,-63352,-63339,-63326,-63313,-63300,-63287,-63274, + -63261,-63248,-63235,-63221,-63208,-63195,-63182,-63168, + -63155,-63141,-63128,-63114,-63101,-63087,-63074,-63060, + -63046,-63032,-63019,-63005,-62991,-62977,-62963,-62949, + -62935,-62921,-62907,-62893,-62879,-62865,-62850,-62836, + -62822,-62808,-62793,-62779,-62764,-62750,-62735,-62721, + -62706,-62692,-62677,-62662,-62648,-62633,-62618,-62603, + -62588,-62573,-62558,-62543,-62528,-62513,-62498,-62483, + -62468,-62453,-62437,-62422,-62407,-62391,-62376,-62360, + -62345,-62329,-62314,-62298,-62283,-62267,-62251,-62236, + -62220,-62204,-62188,-62172,-62156,-62141,-62125,-62108, + -62092,-62076,-62060,-62044,-62028,-62012,-61995,-61979, + -61963,-61946,-61930,-61913,-61897,-61880,-61864,-61847, + -61831,-61814,-61797,-61780,-61764,-61747,-61730,-61713, + -61696,-61679,-61662,-61645,-61628,-61611,-61594,-61577, + -61559,-61542,-61525,-61507,-61490,-61473,-61455,-61438, + -61420,-61403,-61385,-61367,-61350,-61332,-61314,-61297, + -61279,-61261,-61243,-61225,-61207,-61189,-61171,-61153, + -61135,-61117,-61099,-61081,-61062,-61044,-61026,-61007, + -60989,-60971,-60952,-60934,-60915,-60897,-60878,-60859, + -60841,-60822,-60803,-60785,-60766,-60747,-60728,-60709, + -60690,-60671,-60652,-60633,-60614,-60595,-60576,-60556, + -60537,-60518,-60499,-60479,-60460,-60441,-60421,-60402, + -60382,-60363,-60343,-60323,-60304,-60284,-60264,-60244, + -60225,-60205,-60185,-60165,-60145,-60125,-60105,-60085, + -60065,-60045,-60025,-60004,-59984,-59964,-59944,-59923, + -59903,-59883,-59862,-59842,-59821,-59801,-59780,-59759, + -59739,-59718,-59697,-59677,-59656,-59635,-59614,-59593, + -59572,-59551,-59530,-59509,-59488,-59467,-59446,-59425, + -59404,-59382,-59361,-59340,-59318,-59297,-59276,-59254, + -59233,-59211,-59189,-59168,-59146,-59125,-59103,-59081, + -59059,-59038,-59016,-58994,-58972,-58950,-58928,-58906, + -58884,-58862,-58840,-58818,-58795,-58773,-58751,-58729, + -58706,-58684,-58662,-58639,-58617,-58594,-58572,-58549, + -58527,-58504,-58481,-58459,-58436,-58413,-58390,-58367, + -58345,-58322,-58299,-58276,-58253,-58230,-58207,-58183, + -58160,-58137,-58114,-58091,-58067,-58044,-58021,-57997, + -57974,-57950,-57927,-57903,-57880,-57856,-57833,-57809, + -57785,-57762,-57738,-57714,-57690,-57666,-57642,-57618, + -57594,-57570,-57546,-57522,-57498,-57474,-57450,-57426, + -57402,-57377,-57353,-57329,-57304,-57280,-57255,-57231, + -57206,-57182,-57157,-57133,-57108,-57083,-57059,-57034, + -57009,-56984,-56959,-56935,-56910,-56885,-56860,-56835, + -56810,-56785,-56760,-56734,-56709,-56684,-56659,-56633, + -56608,-56583,-56557,-56532,-56507,-56481,-56456,-56430, + -56404,-56379,-56353,-56328,-56302,-56276,-56250,-56225, + -56199,-56173,-56147,-56121,-56095,-56069,-56043,-56017, + -55991,-55965,-55938,-55912,-55886,-55860,-55833,-55807, + -55781,-55754,-55728,-55701,-55675,-55648,-55622,-55595, + -55569,-55542,-55515,-55489,-55462,-55435,-55408,-55381, + -55354,-55327,-55300,-55274,-55246,-55219,-55192,-55165, + -55138,-55111,-55084,-55056,-55029,-55002,-54974,-54947, + -54920,-54892,-54865,-54837,-54810,-54782,-54755,-54727, + -54699,-54672,-54644,-54616,-54588,-54560,-54533,-54505, + -54477,-54449,-54421,-54393,-54365,-54337,-54308,-54280, + -54252,-54224,-54196,-54167,-54139,-54111,-54082,-54054, + -54026,-53997,-53969,-53940,-53911,-53883,-53854,-53826, + -53797,-53768,-53739,-53711,-53682,-53653,-53624,-53595, + -53566,-53537,-53508,-53479,-53450,-53421,-53392,-53363, + -53334,-53304,-53275,-53246,-53216,-53187,-53158,-53128, + -53099,-53069,-53040,-53010,-52981,-52951,-52922,-52892, + -52862,-52832,-52803,-52773,-52743,-52713,-52683,-52653, + -52624,-52594,-52564,-52534,-52503,-52473,-52443,-52413, + -52383,-52353,-52322,-52292,-52262,-52231,-52201,-52171, + -52140,-52110,-52079,-52049,-52018,-51988,-51957,-51926, + -51896,-51865,-51834,-51803,-51773,-51742,-51711,-51680, + -51649,-51618,-51587,-51556,-51525,-51494,-51463,-51432, + -51401,-51369,-51338,-51307,-51276,-51244,-51213,-51182, + -51150,-51119,-51087,-51056,-51024,-50993,-50961,-50929, + -50898,-50866,-50834,-50803,-50771,-50739,-50707,-50675, + -50644,-50612,-50580,-50548,-50516,-50484,-50452,-50420, + -50387,-50355,-50323,-50291,-50259,-50226,-50194,-50162, + -50129,-50097,-50065,-50032,-50000,-49967,-49935,-49902, + -49869,-49837,-49804,-49771,-49739,-49706,-49673,-49640, + -49608,-49575,-49542,-49509,-49476,-49443,-49410,-49377, + -49344,-49311,-49278,-49244,-49211,-49178,-49145,-49112, + -49078,-49045,-49012,-48978,-48945,-48911,-48878,-48844, + -48811,-48777,-48744,-48710,-48676,-48643,-48609,-48575, + -48542,-48508,-48474,-48440,-48406,-48372,-48338,-48305, + -48271,-48237,-48202,-48168,-48134,-48100,-48066,-48032, + -47998,-47963,-47929,-47895,-47860,-47826,-47792,-47757, + -47723,-47688,-47654,-47619,-47585,-47550,-47516,-47481, + -47446,-47412,-47377,-47342,-47307,-47273,-47238,-47203, + -47168,-47133,-47098,-47063,-47028,-46993,-46958,-46923, + -46888,-46853,-46818,-46783,-46747,-46712,-46677,-46642, + -46606,-46571,-46536,-46500,-46465,-46429,-46394,-46358, + -46323,-46287,-46251,-46216,-46180,-46145,-46109,-46073, + -46037,-46002,-45966,-45930,-45894,-45858,-45822,-45786, + -45750,-45714,-45678,-45642,-45606,-45570,-45534,-45498, + -45462,-45425,-45389,-45353,-45316,-45280,-45244,-45207, + -45171,-45135,-45098,-45062,-45025,-44989,-44952,-44915, + -44879,-44842,-44806,-44769,-44732,-44695,-44659,-44622, + -44585,-44548,-44511,-44474,-44437,-44400,-44363,-44326, + -44289,-44252,-44215,-44178,-44141,-44104,-44067,-44029, + -43992,-43955,-43918,-43880,-43843,-43806,-43768,-43731, + -43693,-43656,-43618,-43581,-43543,-43506,-43468,-43430, + -43393,-43355,-43317,-43280,-43242,-43204,-43166,-43128, + -43091,-43053,-43015,-42977,-42939,-42901,-42863,-42825, + -42787,-42749,-42711,-42672,-42634,-42596,-42558,-42520, + -42481,-42443,-42405,-42366,-42328,-42290,-42251,-42213, + -42174,-42136,-42097,-42059,-42020,-41982,-41943,-41904, + -41866,-41827,-41788,-41750,-41711,-41672,-41633,-41595, + -41556,-41517,-41478,-41439,-41400,-41361,-41322,-41283, + -41244,-41205,-41166,-41127,-41087,-41048,-41009,-40970, + -40931,-40891,-40852,-40813,-40773,-40734,-40695,-40655, + -40616,-40576,-40537,-40497,-40458,-40418,-40379,-40339, + -40299,-40260,-40220,-40180,-40141,-40101,-40061,-40021, + -39982,-39942,-39902,-39862,-39822,-39782,-39742,-39702, + -39662,-39622,-39582,-39542,-39502,-39462,-39422,-39382, + -39341,-39301,-39261,-39221,-39180,-39140,-39100,-39059, + -39019,-38979,-38938,-38898,-38857,-38817,-38776,-38736, + -38695,-38655,-38614,-38573,-38533,-38492,-38451,-38411, + -38370,-38329,-38288,-38248,-38207,-38166,-38125,-38084, + -38043,-38002,-37961,-37920,-37879,-37838,-37797,-37756, + -37715,-37674,-37633,-37592,-37550,-37509,-37468,-37427, + -37386,-37344,-37303,-37262,-37220,-37179,-37137,-37096, + -37055,-37013,-36972,-36930,-36889,-36847,-36805,-36764, + -36722,-36681,-36639,-36597,-36556,-36514,-36472,-36430, + -36388,-36347,-36305,-36263,-36221,-36179,-36137,-36095, + -36053,-36011,-35969,-35927,-35885,-35843,-35801,-35759, + -35717,-35675,-35633,-35590,-35548,-35506,-35464,-35421, + -35379,-35337,-35294,-35252,-35210,-35167,-35125,-35082, + -35040,-34997,-34955,-34912,-34870,-34827,-34785,-34742, + -34699,-34657,-34614,-34571,-34529,-34486,-34443,-34400, + -34358,-34315,-34272,-34229,-34186,-34143,-34100,-34057, + -34015,-33972,-33929,-33886,-33843,-33799,-33756,-33713, + -33670,-33627,-33584,-33541,-33498,-33454,-33411,-33368, + -33325,-33281,-33238,-33195,-33151,-33108,-33065,-33021, + -32978,-32934,-32891,-32847,-32804,-32760,-32717,-32673, + -32630,-32586,-32542,-32499,-32455,-32411,-32368,-32324, + -32280,-32236,-32193,-32149,-32105,-32061,-32017,-31974, + -31930,-31886,-31842,-31798,-31754,-31710,-31666,-31622, + -31578,-31534,-31490,-31446,-31402,-31357,-31313,-31269, + -31225,-31181,-31136,-31092,-31048,-31004,-30959,-30915, + -30871,-30826,-30782,-30738,-30693,-30649,-30604,-30560, + -30515,-30471,-30426,-30382,-30337,-30293,-30248,-30204, + -30159,-30114,-30070,-30025,-29980,-29936,-29891,-29846, + -29801,-29757,-29712,-29667,-29622,-29577,-29533,-29488, + -29443,-29398,-29353,-29308,-29263,-29218,-29173,-29128, + -29083,-29038,-28993,-28948,-28903,-28858,-28812,-28767, + -28722,-28677,-28632,-28586,-28541,-28496,-28451,-28405, + -28360,-28315,-28269,-28224,-28179,-28133,-28088,-28042, + -27997,-27952,-27906,-27861,-27815,-27770,-27724,-27678, + -27633,-27587,-27542,-27496,-27450,-27405,-27359,-27313, + -27268,-27222,-27176,-27131,-27085,-27039,-26993,-26947, + -26902,-26856,-26810,-26764,-26718,-26672,-26626,-26580, + -26534,-26488,-26442,-26396,-26350,-26304,-26258,-26212, + -26166,-26120,-26074,-26028,-25982,-25936,-25889,-25843, + -25797,-25751,-25705,-25658,-25612,-25566,-25520,-25473, + -25427,-25381,-25334,-25288,-25241,-25195,-25149,-25102, + -25056,-25009,-24963,-24916,-24870,-24823,-24777,-24730, + -24684,-24637,-24591,-24544,-24497,-24451,-24404,-24357, + -24311,-24264,-24217,-24171,-24124,-24077,-24030,-23984, + -23937,-23890,-23843,-23796,-23750,-23703,-23656,-23609, + -23562,-23515,-23468,-23421,-23374,-23327,-23280,-23233, + -23186,-23139,-23092,-23045,-22998,-22951,-22904,-22857, + -22810,-22763,-22716,-22668,-22621,-22574,-22527,-22480, + -22432,-22385,-22338,-22291,-22243,-22196,-22149,-22102, + -22054,-22007,-21960,-21912,-21865,-21817,-21770,-21723, + -21675,-21628,-21580,-21533,-21485,-21438,-21390,-21343, + -21295,-21248,-21200,-21153,-21105,-21057,-21010,-20962, + -20915,-20867,-20819,-20772,-20724,-20676,-20629,-20581, + -20533,-20485,-20438,-20390,-20342,-20294,-20246,-20199, + -20151,-20103,-20055,-20007,-19959,-19912,-19864,-19816, + -19768,-19720,-19672,-19624,-19576,-19528,-19480,-19432, + -19384,-19336,-19288,-19240,-19192,-19144,-19096,-19048, + -19000,-18951,-18903,-18855,-18807,-18759,-18711,-18663, + -18614,-18566,-18518,-18470,-18421,-18373,-18325,-18277, + -18228,-18180,-18132,-18084,-18035,-17987,-17939,-17890, + -17842,-17793,-17745,-17697,-17648,-17600,-17551,-17503, + -17455,-17406,-17358,-17309,-17261,-17212,-17164,-17115, + -17067,-17018,-16970,-16921,-16872,-16824,-16775,-16727, + -16678,-16629,-16581,-16532,-16484,-16435,-16386,-16338, + -16289,-16240,-16191,-16143,-16094,-16045,-15997,-15948, + -15899,-15850,-15802,-15753,-15704,-15655,-15606,-15557, + -15509,-15460,-15411,-15362,-15313,-15264,-15215,-15167, + -15118,-15069,-15020,-14971,-14922,-14873,-14824,-14775, + -14726,-14677,-14628,-14579,-14530,-14481,-14432,-14383, + -14334,-14285,-14236,-14187,-14138,-14089,-14040,-13990, + -13941,-13892,-13843,-13794,-13745,-13696,-13647,-13597, + -13548,-13499,-13450,-13401,-13351,-13302,-13253,-13204, + -13154,-13105,-13056,-13007,-12957,-12908,-12859,-12810, + -12760,-12711,-12662,-12612,-12563,-12514,-12464,-12415, + -12366,-12316,-12267,-12217,-12168,-12119,-12069,-12020, + -11970,-11921,-11872,-11822,-11773,-11723,-11674,-11624, + -11575,-11525,-11476,-11426,-11377,-11327,-11278,-11228, + -11179,-11129,-11080,-11030,-10981,-10931,-10882,-10832, + -10782,-10733,-10683,-10634,-10584,-10534,-10485,-10435, + -10386,-10336,-10286,-10237,-10187,-10137,-10088,-10038, + -9988,-9939,-9889,-9839,-9790,-9740,-9690,-9640, + -9591,-9541,-9491,-9442,-9392,-9342,-9292,-9243, + -9193,-9143,-9093,-9043,-8994,-8944,-8894,-8844, + -8794,-8745,-8695,-8645,-8595,-8545,-8496,-8446, + -8396,-8346,-8296,-8246,-8196,-8147,-8097,-8047, + -7997,-7947,-7897,-7847,-7797,-7747,-7697,-7648, + -7598,-7548,-7498,-7448,-7398,-7348,-7298,-7248, + -7198,-7148,-7098,-7048,-6998,-6948,-6898,-6848, + -6798,-6748,-6698,-6648,-6598,-6548,-6498,-6448, + -6398,-6348,-6298,-6248,-6198,-6148,-6098,-6048, + -5998,-5948,-5898,-5848,-5798,-5747,-5697,-5647, + -5597,-5547,-5497,-5447,-5397,-5347,-5297,-5247, + -5197,-5146,-5096,-5046,-4996,-4946,-4896,-4846, + -4796,-4745,-4695,-4645,-4595,-4545,-4495,-4445, + -4394,-4344,-4294,-4244,-4194,-4144,-4093,-4043, + -3993,-3943,-3893,-3843,-3792,-3742,-3692,-3642, + -3592,-3541,-3491,-3441,-3391,-3341,-3291,-3240, + -3190,-3140,-3090,-3039,-2989,-2939,-2889,-2839, + -2788,-2738,-2688,-2638,-2588,-2537,-2487,-2437, + -2387,-2336,-2286,-2236,-2186,-2135,-2085,-2035, + -1985,-1934,-1884,-1834,-1784,-1733,-1683,-1633, + -1583,-1532,-1482,-1432,-1382,-1331,-1281,-1231, + -1181,-1130,-1080,-1030,-980,-929,-879,-829, + -779,-728,-678,-628,-578,-527,-477,-427, + -376,-326,-276,-226,-175,-125,-75,-25, + 25,75,125,175,226,276,326,376, + 427,477,527,578,628,678,728,779, + 829,879,929,980,1030,1080,1130,1181, + 1231,1281,1331,1382,1432,1482,1532,1583, + 1633,1683,1733,1784,1834,1884,1934,1985, + 2035,2085,2135,2186,2236,2286,2336,2387, + 2437,2487,2537,2587,2638,2688,2738,2788, + 2839,2889,2939,2989,3039,3090,3140,3190, + 3240,3291,3341,3391,3441,3491,3542,3592, + 3642,3692,3742,3792,3843,3893,3943,3993, + 4043,4093,4144,4194,4244,4294,4344,4394, + 4445,4495,4545,4595,4645,4695,4745,4796, + 4846,4896,4946,4996,5046,5096,5146,5197, + 5247,5297,5347,5397,5447,5497,5547,5597, + 5647,5697,5747,5798,5848,5898,5948,5998, + 6048,6098,6148,6198,6248,6298,6348,6398, + 6448,6498,6548,6598,6648,6698,6748,6798, + 6848,6898,6948,6998,7048,7098,7148,7198, + 7248,7298,7348,7398,7448,7498,7548,7598, + 7648,7697,7747,7797,7847,7897,7947,7997, + 8047,8097,8147,8196,8246,8296,8346,8396, + 8446,8496,8545,8595,8645,8695,8745,8794, + 8844,8894,8944,8994,9043,9093,9143,9193, + 9243,9292,9342,9392,9442,9491,9541,9591, + 9640,9690,9740,9790,9839,9889,9939,9988, + 10038,10088,10137,10187,10237,10286,10336,10386, + 10435,10485,10534,10584,10634,10683,10733,10782, + 10832,10882,10931,10981,11030,11080,11129,11179, + 11228,11278,11327,11377,11426,11476,11525,11575, + 11624,11674,11723,11773,11822,11872,11921,11970, + 12020,12069,12119,12168,12218,12267,12316,12366, + 12415,12464,12514,12563,12612,12662,12711,12760, + 12810,12859,12908,12957,13007,13056,13105,13154, + 13204,13253,13302,13351,13401,13450,13499,13548, + 13597,13647,13696,13745,13794,13843,13892,13941, + 13990,14040,14089,14138,14187,14236,14285,14334, + 14383,14432,14481,14530,14579,14628,14677,14726, + 14775,14824,14873,14922,14971,15020,15069,15118, + 15167,15215,15264,15313,15362,15411,15460,15509, + 15557,15606,15655,15704,15753,15802,15850,15899, + 15948,15997,16045,16094,16143,16191,16240,16289, + 16338,16386,16435,16484,16532,16581,16629,16678, + 16727,16775,16824,16872,16921,16970,17018,17067, + 17115,17164,17212,17261,17309,17358,17406,17455, + 17503,17551,17600,17648,17697,17745,17793,17842, + 17890,17939,17987,18035,18084,18132,18180,18228, + 18277,18325,18373,18421,18470,18518,18566,18614, + 18663,18711,18759,18807,18855,18903,18951,19000, + 19048,19096,19144,19192,19240,19288,19336,19384, + 19432,19480,19528,19576,19624,19672,19720,19768, + 19816,19864,19912,19959,20007,20055,20103,20151, + 20199,20246,20294,20342,20390,20438,20485,20533, + 20581,20629,20676,20724,20772,20819,20867,20915, + 20962,21010,21057,21105,21153,21200,21248,21295, + 21343,21390,21438,21485,21533,21580,21628,21675, + 21723,21770,21817,21865,21912,21960,22007,22054, + 22102,22149,22196,22243,22291,22338,22385,22432, + 22480,22527,22574,22621,22668,22716,22763,22810, + 22857,22904,22951,22998,23045,23092,23139,23186, + 23233,23280,23327,23374,23421,23468,23515,23562, + 23609,23656,23703,23750,23796,23843,23890,23937, + 23984,24030,24077,24124,24171,24217,24264,24311, + 24357,24404,24451,24497,24544,24591,24637,24684, + 24730,24777,24823,24870,24916,24963,25009,25056, + 25102,25149,25195,25241,25288,25334,25381,25427, + 25473,25520,25566,25612,25658,25705,25751,25797, + 25843,25889,25936,25982,26028,26074,26120,26166, + 26212,26258,26304,26350,26396,26442,26488,26534, + 26580,26626,26672,26718,26764,26810,26856,26902, + 26947,26993,27039,27085,27131,27176,27222,27268, + 27313,27359,27405,27450,27496,27542,27587,27633, + 27678,27724,27770,27815,27861,27906,27952,27997, + 28042,28088,28133,28179,28224,28269,28315,28360, + 28405,28451,28496,28541,28586,28632,28677,28722, + 28767,28812,28858,28903,28948,28993,29038,29083, + 29128,29173,29218,29263,29308,29353,29398,29443, + 29488,29533,29577,29622,29667,29712,29757,29801, + 29846,29891,29936,29980,30025,30070,30114,30159, + 30204,30248,30293,30337,30382,30427,30471,30516, + 30560,30604,30649,30693,30738,30782,30826,30871, + 30915,30959,31004,31048,31092,31136,31181,31225, + 31269,31313,31357,31402,31446,31490,31534,31578, + 31622,31666,31710,31754,31798,31842,31886,31930, + 31974,32017,32061,32105,32149,32193,32236,32280, + 32324,32368,32411,32455,32499,32542,32586,32630, + 32673,32717,32760,32804,32847,32891,32934,32978, + 33021,33065,33108,33151,33195,33238,33281,33325, + 33368,33411,33454,33498,33541,33584,33627,33670, + 33713,33756,33799,33843,33886,33929,33972,34015, + 34057,34100,34143,34186,34229,34272,34315,34358, + 34400,34443,34486,34529,34571,34614,34657,34699, + 34742,34785,34827,34870,34912,34955,34997,35040, + 35082,35125,35167,35210,35252,35294,35337,35379, + 35421,35464,35506,35548,35590,35633,35675,35717, + 35759,35801,35843,35885,35927,35969,36011,36053, + 36095,36137,36179,36221,36263,36305,36347,36388, + 36430,36472,36514,36556,36597,36639,36681,36722, + 36764,36805,36847,36889,36930,36972,37013,37055, + 37096,37137,37179,37220,37262,37303,37344,37386, + 37427,37468,37509,37551,37592,37633,37674,37715, + 37756,37797,37838,37879,37920,37961,38002,38043, + 38084,38125,38166,38207,38248,38288,38329,38370, + 38411,38451,38492,38533,38573,38614,38655,38695, + 38736,38776,38817,38857,38898,38938,38979,39019, + 39059,39100,39140,39180,39221,39261,39301,39341, + 39382,39422,39462,39502,39542,39582,39622,39662, + 39702,39742,39782,39822,39862,39902,39942,39982, + 40021,40061,40101,40141,40180,40220,40260,40299, + 40339,40379,40418,40458,40497,40537,40576,40616, + 40655,40695,40734,40773,40813,40852,40891,40931, + 40970,41009,41048,41087,41127,41166,41205,41244, + 41283,41322,41361,41400,41439,41478,41517,41556, + 41595,41633,41672,41711,41750,41788,41827,41866, + 41904,41943,41982,42020,42059,42097,42136,42174, + 42213,42251,42290,42328,42366,42405,42443,42481, + 42520,42558,42596,42634,42672,42711,42749,42787, + 42825,42863,42901,42939,42977,43015,43053,43091, + 43128,43166,43204,43242,43280,43317,43355,43393, + 43430,43468,43506,43543,43581,43618,43656,43693, + 43731,43768,43806,43843,43880,43918,43955,43992, + 44029,44067,44104,44141,44178,44215,44252,44289, + 44326,44363,44400,44437,44474,44511,44548,44585, + 44622,44659,44695,44732,44769,44806,44842,44879, + 44915,44952,44989,45025,45062,45098,45135,45171, + 45207,45244,45280,45316,45353,45389,45425,45462, + 45498,45534,45570,45606,45642,45678,45714,45750, + 45786,45822,45858,45894,45930,45966,46002,46037, + 46073,46109,46145,46180,46216,46252,46287,46323, + 46358,46394,46429,46465,46500,46536,46571,46606, + 46642,46677,46712,46747,46783,46818,46853,46888, + 46923,46958,46993,47028,47063,47098,47133,47168, + 47203,47238,47273,47308,47342,47377,47412,47446, + 47481,47516,47550,47585,47619,47654,47688,47723, + 47757,47792,47826,47861,47895,47929,47963,47998, + 48032,48066,48100,48134,48168,48202,48237,48271, + 48305,48338,48372,48406,48440,48474,48508,48542, + 48575,48609,48643,48676,48710,48744,48777,48811, + 48844,48878,48911,48945,48978,49012,49045,49078, + 49112,49145,49178,49211,49244,49278,49311,49344, + 49377,49410,49443,49476,49509,49542,49575,49608, + 49640,49673,49706,49739,49771,49804,49837,49869, + 49902,49935,49967,50000,50032,50064,50097,50129, + 50162,50194,50226,50259,50291,50323,50355,50387, + 50420,50452,50484,50516,50548,50580,50612,50644, + 50675,50707,50739,50771,50803,50834,50866,50898, + 50929,50961,50993,51024,51056,51087,51119,51150, + 51182,51213,51244,51276,51307,51338,51369,51401, + 51432,51463,51494,51525,51556,51587,51618,51649, + 51680,51711,51742,51773,51803,51834,51865,51896, + 51926,51957,51988,52018,52049,52079,52110,52140, + 52171,52201,52231,52262,52292,52322,52353,52383, + 52413,52443,52473,52503,52534,52564,52594,52624, + 52653,52683,52713,52743,52773,52803,52832,52862, + 52892,52922,52951,52981,53010,53040,53069,53099, + 53128,53158,53187,53216,53246,53275,53304,53334, + 53363,53392,53421,53450,53479,53508,53537,53566, + 53595,53624,53653,53682,53711,53739,53768,53797, + 53826,53854,53883,53912,53940,53969,53997,54026, + 54054,54082,54111,54139,54167,54196,54224,54252, + 54280,54309,54337,54365,54393,54421,54449,54477, + 54505,54533,54560,54588,54616,54644,54672,54699, + 54727,54755,54782,54810,54837,54865,54892,54920, + 54947,54974,55002,55029,55056,55084,55111,55138, + 55165,55192,55219,55246,55274,55300,55327,55354, + 55381,55408,55435,55462,55489,55515,55542,55569, + 55595,55622,55648,55675,55701,55728,55754,55781, + 55807,55833,55860,55886,55912,55938,55965,55991, + 56017,56043,56069,56095,56121,56147,56173,56199, + 56225,56250,56276,56302,56328,56353,56379,56404, + 56430,56456,56481,56507,56532,56557,56583,56608, + 56633,56659,56684,56709,56734,56760,56785,56810, + 56835,56860,56885,56910,56935,56959,56984,57009, + 57034,57059,57083,57108,57133,57157,57182,57206, + 57231,57255,57280,57304,57329,57353,57377,57402, + 57426,57450,57474,57498,57522,57546,57570,57594, + 57618,57642,57666,57690,57714,57738,57762,57785, + 57809,57833,57856,57880,57903,57927,57950,57974, + 57997,58021,58044,58067,58091,58114,58137,58160, + 58183,58207,58230,58253,58276,58299,58322,58345, + 58367,58390,58413,58436,58459,58481,58504,58527, + 58549,58572,58594,58617,58639,58662,58684,58706, + 58729,58751,58773,58795,58818,58840,58862,58884, + 58906,58928,58950,58972,58994,59016,59038,59059, + 59081,59103,59125,59146,59168,59190,59211,59233, + 59254,59276,59297,59318,59340,59361,59382,59404, + 59425,59446,59467,59488,59509,59530,59551,59572, + 59593,59614,59635,59656,59677,59697,59718,59739, + 59759,59780,59801,59821,59842,59862,59883,59903, + 59923,59944,59964,59984,60004,60025,60045,60065, + 60085,60105,60125,60145,60165,60185,60205,60225, + 60244,60264,60284,60304,60323,60343,60363,60382, + 60402,60421,60441,60460,60479,60499,60518,60537, + 60556,60576,60595,60614,60633,60652,60671,60690, + 60709,60728,60747,60766,60785,60803,60822,60841, + 60859,60878,60897,60915,60934,60952,60971,60989, + 61007,61026,61044,61062,61081,61099,61117,61135, + 61153,61171,61189,61207,61225,61243,61261,61279, + 61297,61314,61332,61350,61367,61385,61403,61420, + 61438,61455,61473,61490,61507,61525,61542,61559, + 61577,61594,61611,61628,61645,61662,61679,61696, + 61713,61730,61747,61764,61780,61797,61814,61831, + 61847,61864,61880,61897,61913,61930,61946,61963, + 61979,61995,62012,62028,62044,62060,62076,62092, + 62108,62125,62141,62156,62172,62188,62204,62220, + 62236,62251,62267,62283,62298,62314,62329,62345, + 62360,62376,62391,62407,62422,62437,62453,62468, + 62483,62498,62513,62528,62543,62558,62573,62588, + 62603,62618,62633,62648,62662,62677,62692,62706, + 62721,62735,62750,62764,62779,62793,62808,62822, + 62836,62850,62865,62879,62893,62907,62921,62935, + 62949,62963,62977,62991,63005,63019,63032,63046, + 63060,63074,63087,63101,63114,63128,63141,63155, + 63168,63182,63195,63208,63221,63235,63248,63261, + 63274,63287,63300,63313,63326,63339,63352,63365, + 63378,63390,63403,63416,63429,63441,63454,63466, + 63479,63491,63504,63516,63528,63541,63553,63565, + 63578,63590,63602,63614,63626,63638,63650,63662, + 63674,63686,63698,63709,63721,63733,63745,63756, + 63768,63779,63791,63803,63814,63825,63837,63848, + 63859,63871,63882,63893,63904,63915,63927,63938, + 63949,63960,63971,63981,63992,64003,64014,64025, + 64035,64046,64057,64067,64078,64088,64099,64109, + 64120,64130,64140,64151,64161,64171,64181,64192, + 64202,64212,64222,64232,64242,64252,64261,64271, + 64281,64291,64301,64310,64320,64330,64339,64349, + 64358,64368,64377,64387,64396,64405,64414,64424, + 64433,64442,64451,64460,64469,64478,64487,64496, + 64505,64514,64523,64532,64540,64549,64558,64566, + 64575,64584,64592,64600,64609,64617,64626,64634, + 64642,64651,64659,64667,64675,64683,64691,64699, + 64707,64715,64723,64731,64739,64747,64754,64762, + 64770,64777,64785,64793,64800,64808,64815,64822, + 64830,64837,64844,64852,64859,64866,64873,64880, + 64887,64895,64902,64908,64915,64922,64929,64936, + 64943,64949,64956,64963,64969,64976,64982,64989, + 64995,65002,65008,65015,65021,65027,65033,65040, + 65046,65052,65058,65064,65070,65076,65082,65088, + 65094,65099,65105,65111,65117,65122,65128,65133, + 65139,65144,65150,65155,65161,65166,65171,65177, + 65182,65187,65192,65197,65202,65207,65212,65217, + 65222,65227,65232,65237,65242,65246,65251,65256, + 65260,65265,65270,65274,65279,65283,65287,65292, + 65296,65300,65305,65309,65313,65317,65321,65325, + 65329,65333,65337,65341,65345,65349,65352,65356, + 65360,65363,65367,65371,65374,65378,65381,65385, + 65388,65391,65395,65398,65401,65404,65408,65411, + 65414,65417,65420,65423,65426,65429,65431,65434, + 65437,65440,65442,65445,65448,65450,65453,65455, + 65458,65460,65463,65465,65467,65470,65472,65474, + 65476,65478,65480,65482,65484,65486,65488,65490, + 65492,65494,65496,65497,65499,65501,65502,65504, + 65505,65507,65508,65510,65511,65513,65514,65515, + 65516,65518,65519,65520,65521,65522,65523,65524, + 65525,65526,65527,65527,65528,65529,65530,65530, + 65531,65531,65532,65532,65533,65533,65534,65534, + 65534,65535,65535,65535,65535,65535,65535,65535 +}; + + + +const angle_t tantoangle[2049] = +{ + 0,333772,667544,1001315,1335086,1668857,2002626,2336395, + 2670163,3003929,3337694,3671457,4005219,4338979,4672736,5006492, + 5340245,5673995,6007743,6341488,6675230,7008968,7342704,7676435, + 8010164,8343888,8677609,9011325,9345037,9678744,10012447,10346145, + 10679838,11013526,11347209,11680887,12014558,12348225,12681885,13015539, + 13349187,13682829,14016464,14350092,14683714,15017328,15350936,15684536, + 16018129,16351714,16685291,17018860,17352422,17685974,18019518,18353054, + 18686582,19020100,19353610,19687110,20020600,20354080,20687552,21021014, + 21354466,21687906,22021338,22354758,22688168,23021568,23354956,23688332, + 24021698,24355052,24688396,25021726,25355046,25688352,26021648,26354930, + 26688200,27021456,27354702,27687932,28021150,28354356,28687548,29020724, + 29353888,29687038,30020174,30353296,30686404,31019496,31352574,31685636, + 32018684,32351718,32684734,33017736,33350722,33683692,34016648,34349584, + 34682508,35015412,35348300,35681172,36014028,36346868,36679688,37012492, + 37345276,37678044,38010792,38343524,38676240,39008936,39341612,39674272, + 40006912,40339532,40672132,41004716,41337276,41669820,42002344,42334848, + 42667332,42999796,43332236,43664660,43997060,44329444,44661800,44994140, + 45326456,45658752,45991028,46323280,46655512,46987720,47319908,47652072, + 47984212,48316332,48648428,48980500,49312548,49644576,49976580,50308556, + 50640512,50972444,51304352,51636236,51968096,52299928,52631740,52963524, + 53295284,53627020,53958728,54290412,54622068,54953704,55285308,55616888, + 55948444,56279972,56611472,56942948,57274396,57605816,57937212,58268576, + 58599916,58931228,59262512,59593768,59924992,60256192,60587364,60918508, + 61249620,61580704,61911760,62242788,62573788,62904756,63235692,63566604, + 63897480,64228332,64559148,64889940,65220696,65551424,65882120,66212788, + 66543420,66874024,67204600,67535136,67865648,68196120,68526568,68856984, + 69187360,69517712,69848024,70178304,70508560,70838776,71168960,71499112, + 71829224,72159312,72489360,72819376,73149360,73479304,73809216,74139096, + 74468936,74798744,75128520,75458264,75787968,76117632,76447264,76776864, + 77106424,77435952,77765440,78094888,78424304,78753688,79083032,79412336, + 79741608,80070840,80400032,80729192,81058312,81387392,81716432,82045440, + 82374408,82703336,83032224,83361080,83689896,84018664,84347400,84676096, + 85004760,85333376,85661952,85990488,86318984,86647448,86975864,87304240, + 87632576,87960872,88289128,88617344,88945520,89273648,89601736,89929792, + 90257792,90585760,90913688,91241568,91569408,91897200,92224960,92552672, + 92880336,93207968,93535552,93863088,94190584,94518040,94845448,95172816, + 95500136,95827416,96154648,96481832,96808976,97136080,97463136,97790144, + 98117112,98444032,98770904,99097736,99424520,99751256,100077944,100404592, + 100731192,101057744,101384248,101710712,102037128,102363488,102689808,103016080, + 103342312,103668488,103994616,104320696,104646736,104972720,105298656,105624552, + 105950392,106276184,106601928,106927624,107253272,107578872,107904416,108229920, + 108555368,108880768,109206120,109531416,109856664,110181872,110507016,110832120, + 111157168,111482168,111807112,112132008,112456856,112781648,113106392,113431080, + 113755720,114080312,114404848,114729328,115053760,115378136,115702464,116026744, + 116350960,116675128,116999248,117323312,117647320,117971272,118295176,118619024, + 118942816,119266560,119590248,119913880,120237456,120560984,120884456,121207864, + 121531224,121854528,122177784,122500976,122824112,123147200,123470224,123793200, + 124116120,124438976,124761784,125084528,125407224,125729856,126052432,126374960, + 126697424,127019832,127342184,127664472,127986712,128308888,128631008,128953072, + 129275080,129597024,129918912,130240744,130562520,130884232,131205888,131527480, + 131849016,132170496,132491912,132813272,133134576,133455816,133776992,134098120, + 134419184,134740176,135061120,135382000,135702816,136023584,136344272,136664912, + 136985488,137306016,137626464,137946864,138267184,138587456,138907664,139227808, + 139547904,139867920,140187888,140507776,140827616,141147392,141467104,141786752, + 142106336,142425856,142745312,143064720,143384048,143703312,144022512,144341664, + 144660736,144979744,145298704,145617584,145936400,146255168,146573856,146892480, + 147211040,147529536,147847968,148166336,148484640,148802880,149121056,149439152, + 149757200,150075168,150393072,150710912,151028688,151346400,151664048,151981616, + 152299136,152616576,152933952,153251264,153568496,153885680,154202784,154519824, + 154836784,155153696,155470528,155787296,156104000,156420624,156737200,157053696, + 157370112,157686480,158002768,158318976,158635136,158951216,159267232,159583168, + 159899040,160214848,160530592,160846256,161161840,161477376,161792832,162108208, + 162423520,162738768,163053952,163369040,163684080,163999040,164313936,164628752, + 164943504,165258176,165572784,165887312,166201776,166516160,166830480,167144736, + 167458912,167773008,168087040,168400992,168714880,169028688,169342432,169656096, + 169969696,170283216,170596672,170910032,171223344,171536576,171849728,172162800, + 172475808,172788736,173101600,173414384,173727104,174039728,174352288,174664784, + 174977200,175289536,175601792,175913984,176226096,176538144,176850096,177161984, + 177473792,177785536,178097200,178408784,178720288,179031728,179343088,179654368, + 179965568,180276704,180587744,180898720,181209616,181520448,181831184,182141856, + 182452448,182762960,183073408,183383760,183694048,184004240,184314368,184624416, + 184934400,185244288,185554096,185863840,186173504,186483072,186792576,187102000, + 187411344,187720608,188029808,188338912,188647936,188956896,189265760,189574560, + 189883264,190191904,190500448,190808928,191117312,191425632,191733872,192042016, + 192350096,192658096,192966000,193273840,193581584,193889264,194196848,194504352, + 194811792,195119136,195426400,195733584,196040688,196347712,196654656,196961520, + 197268304,197574992,197881616,198188144,198494592,198800960,199107248,199413456, + 199719584,200025616,200331584,200637456,200943248,201248960,201554576,201860128, + 202165584,202470960,202776256,203081456,203386592,203691632,203996592,204301472, + 204606256,204910976,205215600,205520144,205824592,206128960,206433248,206737456, + 207041584,207345616,207649568,207953424,208257216,208560912,208864512,209168048, + 209471488,209774832,210078112,210381296,210684384,210987408,211290336,211593184, + 211895936,212198608,212501184,212803680,213106096,213408432,213710672,214012816, + 214314880,214616864,214918768,215220576,215522288,215823920,216125472,216426928, + 216728304,217029584,217330784,217631904,217932928,218233856,218534704,218835472, + 219136144,219436720,219737216,220037632,220337952,220638192,220938336,221238384, + 221538352,221838240,222138032,222437728,222737344,223036880,223336304,223635664, + 223934912,224234096,224533168,224832160,225131072,225429872,225728608,226027232, + 226325776,226624240,226922608,227220880,227519056,227817152,228115168,228413088, + 228710912,229008640,229306288,229603840,229901312,230198688,230495968,230793152, + 231090256,231387280,231684192,231981024,232277760,232574416,232870960,233167440, + 233463808,233760096,234056288,234352384,234648384,234944304,235240128,235535872, + 235831504,236127056,236422512,236717888,237013152,237308336,237603424,237898416, + 238193328,238488144,238782864,239077488,239372016,239666464,239960816,240255072, + 240549232,240843312,241137280,241431168,241724960,242018656,242312256,242605776, + 242899200,243192512,243485744,243778896,244071936,244364880,244657744,244950496, + 245243168,245535744,245828224,246120608,246412912,246705104,246997216,247289216, + 247581136,247872960,248164688,248456320,248747856,249039296,249330640,249621904, + 249913056,250204128,250495088,250785968,251076736,251367424,251658016,251948512, + 252238912,252529200,252819408,253109520,253399536,253689456,253979280,254269008, + 254558640,254848176,255137632,255426976,255716224,256005376,256294432,256583392, + 256872256,257161024,257449696,257738272,258026752,258315136,258603424,258891600, + 259179696,259467696,259755600,260043392,260331104,260618704,260906224,261193632, + 261480960,261768176,262055296,262342320,262629248,262916080,263202816,263489456, + 263776000,264062432,264348784,264635024,264921168,265207216,265493168,265779024, + 266064784,266350448,266636000,266921472,267206832,267492096,267777264,268062336, + 268347312,268632192,268916960,269201632,269486208,269770688,270055072,270339360, + 270623552,270907616,271191616,271475488,271759296,272042976,272326560,272610048, + 272893440,273176736,273459936,273743040,274026048,274308928,274591744,274874432, + 275157024,275439520,275721920,276004224,276286432,276568512,276850528,277132416, + 277414240,277695936,277977536,278259040,278540448,278821728,279102944,279384032, + 279665056,279945952,280226752,280507456,280788064,281068544,281348960,281629248, + 281909472,282189568,282469568,282749440,283029248,283308960,283588544,283868032, + 284147424,284426720,284705920,284985024,285264000,285542912,285821696,286100384, + 286378976,286657440,286935840,287214112,287492320,287770400,288048384,288326240, + 288604032,288881696,289159264,289436768,289714112,289991392,290268576,290545632, + 290822592,291099456,291376224,291652896,291929440,292205888,292482272,292758528, + 293034656,293310720,293586656,293862496,294138240,294413888,294689440,294964864, + 295240192,295515424,295790560,296065600,296340512,296615360,296890080,297164704, + 297439200,297713632,297987936,298262144,298536256,298810240,299084160,299357952, + 299631648,299905248,300178720,300452128,300725408,300998592,301271680,301544640, + 301817536,302090304,302362976,302635520,302908000,303180352,303452608,303724768, + 303996800,304268768,304540608,304812320,305083968,305355520,305626944,305898272, + 306169472,306440608,306711616,306982528,307253344,307524064,307794656,308065152, + 308335552,308605856,308876032,309146112,309416096,309685984,309955744,310225408, + 310494976,310764448,311033824,311303072,311572224,311841280,312110208,312379040, + 312647776,312916416,313184960,313453376,313721696,313989920,314258016,314526016, + 314793920,315061728,315329408,315597024,315864512,316131872,316399168,316666336, + 316933408,317200384,317467232,317733984,318000640,318267200,318533632,318799968, + 319066208,319332352,319598368,319864288,320130112,320395808,320661408,320926912, + 321192320,321457632,321722816,321987904,322252864,322517760,322782528,323047200, + 323311744,323576192,323840544,324104800,324368928,324632992,324896928,325160736, + 325424448,325688096,325951584,326215008,326478304,326741504,327004608,327267584, + 327530464,327793248,328055904,328318496,328580960,328843296,329105568,329367712, + 329629760,329891680,330153536,330415264,330676864,330938400,331199808,331461120, + 331722304,331983392,332244384,332505280,332766048,333026752,333287296,333547776, + 333808128,334068384,334328544,334588576,334848512,335108352,335368064,335627712, + 335887200,336146624,336405920,336665120,336924224,337183200,337442112,337700864, + 337959552,338218112,338476576,338734944,338993184,339251328,339509376,339767296, + 340025120,340282848,340540480,340797984,341055392,341312704,341569888,341826976, + 342083968,342340832,342597600,342854272,343110848,343367296,343623648,343879904, + 344136032,344392064,344648000,344903808,345159520,345415136,345670656,345926048, + 346181344,346436512,346691616,346946592,347201440,347456224,347710880,347965440, + 348219872,348474208,348728448,348982592,349236608,349490528,349744320,349998048, + 350251648,350505152,350758528,351011808,351264992,351518048,351771040,352023872, + 352276640,352529280,352781824,353034272,353286592,353538816,353790944,354042944, + 354294880,354546656,354798368,355049952,355301440,355552800,355804096,356055264, + 356306304,356557280,356808128,357058848,357309504,357560032,357810464,358060768, + 358311008,358561088,358811104,359060992,359310784,359560480,359810048,360059520, + 360308896,360558144,360807296,361056352,361305312,361554144,361802880,362051488, + 362300032,362548448,362796736,363044960,363293056,363541024,363788928,364036704, + 364284384,364531936,364779392,365026752,365274016,365521152,365768192,366015136, + 366261952,366508672,366755296,367001792,367248192,367494496,367740704,367986784, + 368232768,368478656,368724416,368970080,369215648,369461088,369706432,369951680, + 370196800,370441824,370686752,370931584,371176288,371420896,371665408,371909792, + 372154080,372398272,372642336,372886304,373130176,373373952,373617600,373861152, + 374104608,374347936,374591168,374834304,375077312,375320224,375563040,375805760, + 376048352,376290848,376533248,376775520,377017696,377259776,377501728,377743584, + 377985344,378227008,378468544,378709984,378951328,379192544,379433664,379674688, + 379915584,380156416,380397088,380637696,380878176,381118560,381358848,381599040, + 381839104,382079072,382318912,382558656,382798304,383037856,383277280,383516640, + 383755840,383994976,384233984,384472896,384711712,384950400,385188992,385427488, + 385665888,385904160,386142336,386380384,386618368,386856224,387093984,387331616, + 387569152,387806592,388043936,388281152,388518272,388755296,388992224,389229024, + 389465728,389702336,389938816,390175200,390411488,390647680,390883744,391119712, + 391355584,391591328,391826976,392062528,392297984,392533312,392768544,393003680, + 393238720,393473632,393708448,393943168,394177760,394412256,394646656,394880960, + 395115136,395349216,395583200,395817088,396050848,396284512,396518080,396751520, + 396984864,397218112,397451264,397684288,397917248,398150080,398382784,398615424, + 398847936,399080320,399312640,399544832,399776928,400008928,400240832,400472608, + 400704288,400935872,401167328,401398720,401629984,401861120,402092192,402323136, + 402553984,402784736,403015360,403245888,403476320,403706656,403936896,404167008, + 404397024,404626944,404856736,405086432,405316032,405545536,405774912,406004224, + 406233408,406462464,406691456,406920320,407149088,407377760,407606336,407834784, + 408063136,408291392,408519520,408747584,408975520,409203360,409431072,409658720, + 409886240,410113664,410340992,410568192,410795296,411022304,411249216,411476032, + 411702720,411929312,412155808,412382176,412608480,412834656,413060736,413286720, + 413512576,413738336,413964000,414189568,414415040,414640384,414865632,415090784, + 415315840,415540800,415765632,415990368,416215008,416439552,416663968,416888288, + 417112512,417336640,417560672,417784576,418008384,418232096,418455712,418679200, + 418902624,419125920,419349120,419572192,419795200,420018080,420240864,420463552, + 420686144,420908608,421130976,421353280,421575424,421797504,422019488,422241344, + 422463104,422684768,422906336,423127776,423349120,423570400,423791520,424012576, + 424233536,424454368,424675104,424895744,425116288,425336736,425557056,425777280, + 425997408,426217440,426437376,426657184,426876928,427096544,427316064,427535488, + 427754784,427974016,428193120,428412128,428631040,428849856,429068544,429287168, + 429505664,429724064,429942368,430160576,430378656,430596672,430814560,431032352, + 431250048,431467616,431685120,431902496,432119808,432336992,432554080,432771040, + 432987936,433204736,433421408,433637984,433854464,434070848,434287104,434503296, + 434719360,434935360,435151232,435367008,435582656,435798240,436013696,436229088, + 436444352,436659520,436874592,437089568,437304416,437519200,437733856,437948416, + 438162880,438377248,438591520,438805696,439019744,439233728,439447584,439661344, + 439875008,440088576,440302048,440515392,440728672,440941824,441154880,441367872, + 441580736,441793472,442006144,442218720,442431168,442643552,442855808,443067968, + 443280032,443492000,443703872,443915648,444127296,444338880,444550336,444761696, + 444972992,445184160,445395232,445606176,445817056,446027840,446238496,446449088, + 446659552,446869920,447080192,447290400,447500448,447710432,447920320,448130112, + 448339776,448549376,448758848,448968224,449177536,449386720,449595808,449804800, + 450013664,450222464,450431168,450639776,450848256,451056640,451264960,451473152, + 451681248,451889248,452097152,452304960,452512672,452720288,452927808,453135232, + 453342528,453549760,453756864,453963904,454170816,454377632,454584384,454791008, + 454997536,455203968,455410304,455616544,455822688,456028704,456234656,456440512, + 456646240,456851904,457057472,457262912,457468256,457673536,457878688,458083744, + 458288736,458493600,458698368,458903040,459107616,459312096,459516480,459720768, + 459924960,460129056,460333056,460536960,460740736,460944448,461148064,461351584, + 461554976,461758304,461961536,462164640,462367680,462570592,462773440,462976160, + 463178816,463381344,463583776,463786144,463988384,464190560,464392608,464594560, + 464796448,464998208,465199872,465401472,465602944,465804320,466005600,466206816, + 466407904,466608896,466809824,467010624,467211328,467411936,467612480,467812896, + 468013216,468213440,468413600,468613632,468813568,469013440,469213184,469412832, + 469612416,469811872,470011232,470210528,470409696,470608800,470807776,471006688, + 471205472,471404192,471602784,471801312,471999712,472198048,472396288,472594400, + 472792448,472990400,473188256,473385984,473583648,473781216,473978688,474176064, + 474373344,474570528,474767616,474964608,475161504,475358336,475555040,475751648, + 475948192,476144608,476340928,476537184,476733312,476929376,477125344,477321184, + 477516960,477712640,477908224,478103712,478299104,478494400,478689600,478884704, + 479079744,479274656,479469504,479664224,479858880,480053408,480247872,480442240, + 480636512,480830656,481024736,481218752,481412640,481606432,481800128,481993760, + 482187264,482380704,482574016,482767264,482960416,483153472,483346432,483539296, + 483732064,483924768,484117344,484309856,484502240,484694560,484886784,485078912, + 485270944,485462880,485654720,485846464,486038144,486229696,486421184,486612576, + 486803840,486995040,487186176,487377184,487568096,487758912,487949664,488140320, + 488330880,488521312,488711712,488901984,489092160,489282240,489472256,489662176, + 489851968,490041696,490231328,490420896,490610336,490799712,490988960,491178144, + 491367232,491556224,491745120,491933920,492122656,492311264,492499808,492688256, + 492876608,493064864,493253056,493441120,493629120,493817024,494004832,494192544, + 494380160,494567712,494755136,494942496,495129760,495316928,495504000,495691008, + 495877888,496064704,496251424,496438048,496624608,496811040,496997408,497183680, + 497369856,497555936,497741920,497927840,498113632,498299360,498484992,498670560, + 498856000,499041376,499226656,499411840,499596928,499781920,499966848,500151680, + 500336416,500521056,500705600,500890080,501074464,501258752,501442944,501627040, + 501811072,501995008,502178848,502362592,502546240,502729824,502913312,503096704, + 503280000,503463232,503646368,503829408,504012352,504195200,504377984,504560672, + 504743264,504925760,505108192,505290496,505472736,505654912,505836960,506018944, + 506200832,506382624,506564320,506745952,506927488,507108928,507290272,507471552, + 507652736,507833824,508014816,508195744,508376576,508557312,508737952,508918528, + 509099008,509279392,509459680,509639904,509820032,510000064,510180000,510359872, + 510539648,510719328,510898944,511078432,511257856,511437216,511616448,511795616, + 511974688,512153664,512332576,512511392,512690112,512868768,513047296,513225792, + 513404160,513582432,513760640,513938784,514116800,514294752,514472608,514650368, + 514828064,515005664,515183168,515360608,515537952,515715200,515892352,516069440, + 516246432,516423328,516600160,516776896,516953536,517130112,517306592,517482976, + 517659264,517835488,518011616,518187680,518363648,518539520,518715296,518891008, + 519066624,519242144,519417600,519592960,519768256,519943424,520118528,520293568, + 520468480,520643328,520818112,520992800,521167392,521341888,521516320,521690656, + 521864896,522039072,522213152,522387168,522561056,522734912,522908640,523082304, + 523255872,523429376,523602784,523776096,523949312,524122464,524295552,524468512, + 524641440,524814240,524986976,525159616,525332192,525504640,525677056,525849344, + 526021568,526193728,526365792,526537760,526709632,526881440,527053152,527224800, + 527396352,527567840,527739200,527910528,528081728,528252864,528423936,528594880, + 528765760,528936576,529107296,529277920,529448480,529618944,529789344,529959648, + 530129856,530300000,530470048,530640000,530809888,530979712,531149440,531319072, + 531488608,531658080,531827488,531996800,532166016,532335168,532504224,532673184, + 532842080,533010912,533179616,533348288,533516832,533685312,533853728,534022048, + 534190272,534358432,534526496,534694496,534862400,535030240,535197984,535365632, + 535533216,535700704,535868128,536035456,536202720,536369888,536536992,536704000, + 536870912 +}; + + +} // namespace vpo + diff --git a/Source/Plugins/vpo_dll/tables.h b/Source/Plugins/vpo_dll/tables.h index 9885032b..baf785ca 100644 --- a/Source/Plugins/vpo_dll/tables.h +++ b/Source/Plugins/vpo_dll/tables.h @@ -1,94 +1,94 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Lookup tables. -// Do not try to look them up :-). -// In the order of appearance: -// -// int finetangent[4096] - Tangens LUT. -// Should work with BAM fairly well (12 of 16bit, -// effectively, by shifting). -// -// int finesine[10240] - Sine lookup. -// Guess what, serves as cosine, too. -// Remarkable thing is, how to use BAMs with this? -// -// int tantoangle[2049] - ArcTan LUT, -// maps tan(angle) to angle fast. Gotta search. -// -//----------------------------------------------------------------------------- - - -#ifndef __TABLES__ -#define __TABLES__ - - - -#include "m_fixed.h" - -#define FINEANGLES 8192 -#define FINEMASK (FINEANGLES-1) - - -// 0x100000000 to 0x2000 -#define ANGLETOFINESHIFT 19 - -// Effective size is 10240. -extern const fixed_t finesine[5*FINEANGLES/4]; - -// Re-use data, is just PI/2 pahse shift. -extern const fixed_t *finecosine; - - -// Effective size is 4096. -extern const fixed_t finetangent[FINEANGLES/2]; - -// Binary Angle Measument, BAM. -#define ANG45 0x20000000 -#define ANG90 0x40000000 -#define ANG180 0x80000000 -#define ANG270 0xc0000000 - - -#define SLOPERANGE 2048 -#define SLOPEBITS 11 -#define DBITS (FRACBITS-SLOPEBITS) - -typedef unsigned angle_t; - - -// Effective size is 2049; -// The +1 size is to handle the case when x==y -// without additional checking. -extern const angle_t tantoangle[SLOPERANGE+1]; - - -// Utility function, -// called by R_PointToAngle. -int -SlopeDiv -( unsigned num, - unsigned den); - - -#endif - +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// Lookup tables. +// Do not try to look them up :-). +// In the order of appearance: +// +// int finetangent[4096] - Tangens LUT. +// Should work with BAM fairly well (12 of 16bit, +// effectively, by shifting). +// +// int finesine[10240] - Sine lookup. +// Guess what, serves as cosine, too. +// Remarkable thing is, how to use BAMs with this? +// +// int tantoangle[2049] - ArcTan LUT, +// maps tan(angle) to angle fast. Gotta search. +// +//----------------------------------------------------------------------------- + + +#ifndef __TABLES__ +#define __TABLES__ + + + +#include "m_fixed.h" + +#define FINEANGLES 8192 +#define FINEMASK (FINEANGLES-1) + + +// 0x100000000 to 0x2000 +#define ANGLETOFINESHIFT 19 + +// Effective size is 10240. +extern const fixed_t finesine[5*FINEANGLES/4]; + +// Re-use data, is just PI/2 pahse shift. +extern const fixed_t *finecosine; + + +// Effective size is 4096. +extern const fixed_t finetangent[FINEANGLES/2]; + +// Binary Angle Measument, BAM. +#define ANG45 0x20000000 +#define ANG90 0x40000000 +#define ANG180 0x80000000 +#define ANG270 0xc0000000 + + +#define SLOPERANGE 2048 +#define SLOPEBITS 11 +#define DBITS (FRACBITS-SLOPEBITS) + +typedef unsigned angle_t; + + +// Effective size is 2049; +// The +1 size is to handle the case when x==y +// without additional checking. +extern const angle_t tantoangle[SLOPERANGE+1]; + + +// Utility function, +// called by R_PointToAngle. +int +SlopeDiv +( unsigned num, + unsigned den); + + +#endif + diff --git a/Source/Plugins/vpo_dll/vpo_api.h b/Source/Plugins/vpo_dll/vpo_api.h index f0eb9903..1fd149a0 100644 --- a/Source/Plugins/vpo_dll/vpo_api.h +++ b/Source/Plugins/vpo_dll/vpo_api.h @@ -1,84 +1,98 @@ -//------------------------------------------------------------------------ -// Visplane Overflow Library -//------------------------------------------------------------------------ -// -// Copyright (C) 1993-1996 Id Software, Inc. -// Copyright (C) 2005 Simon Howard -// Copyright (C) 2012 Andrew Apted -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -//------------------------------------------------------------------------ - -#ifndef __VPO_API_H__ -#define __VPO_API_H__ - - -// return error message when something fails -// (this will be a static buffer, so is not guaranteed to remain valid -// after any other API call) -const char* APIENTRY VPO_GetError(void); - -// try to load a wad file -// returns 0 on success, negative value on error -int APIENTRY VPO_LoadWAD(const char *wad_filename); - -// free all data associated with the wad file -// can be safely called without any loaded wad file -void APIENTRY VPO_FreeWAD(void); - -// retrieve the map names in the wad, one at a time -// index starts at 0 -// returns NULL when index is past the end of the list -// NOTE: return pointer may be a static buffer, not guaranteed to -// remain valid once this function is called again -const char* APIENTRY VPO_GetMapName(unsigned int index); - -// try to open a map from the current wad file -// returns 0 on success, negative value on error -int APIENTRY VPO_OpenMap(const char *map_name); - -// free all data associated with a map -// can be safely called without any opened map -void APIENTRY VPO_CloseMap(void); - -// retrieve the linedefs in the current map, one at a time -// index starts at 0 -// returns number of sides (0 to 2), or -1 for invalid index -int APIENTRY VPO_GetLinedef(unsigned int index, int *x1, int *y1, int *x2, int *y2); - -// test a spot and angle, returning the number of visplanes -// dz is the height above the floor (or offset from ceiling if < 0) -// angle is in degrees (0 to 360), 0 is east, 90 is north -// returns RESULT_OK on success, or a negative value spot was in the -// void or an error occurred -- see the RESULT_* values below -// -// the num_xxx parameters point to variables which get _updated_ by -// this call (i.e. new value is maximum of old value + checked value). -// hence you need to set those variables to zero before the first -// call at a particular (X Y) location. -// -// RESULT_OVERFLOW means that an internal limit overflowed (which are -// four times or more the actual DOOM limits). - -#define RESULT_OK 0 -#define RESULT_BAD_Z -1 -#define RESULT_IN_VOID -2 -#define RESULT_OVERFLOW -3 - -int APIENTRY VPO_TestSpot(int x, int y, int dz, int angle, - int *num_visplanes, - int *num_drawsegs, - int *num_openings, - int *num_solidsegs); - -#endif /* __VPO_API_H__ */ - +//------------------------------------------------------------------------ +// Visplane Overflow Library +//------------------------------------------------------------------------ +// +// Copyright (C) 1993-1996 Id Software, Inc. +// Copyright (C) 2005 Simon Howard +// Copyright (C) 2012-2014 Andrew Apted +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +//------------------------------------------------------------------------ + +#ifndef __VPO_API_H__ +#define __VPO_API_H__ + + +// return error message when something fails +// (this will be a static buffer, so is not guaranteed to remain valid +// after any other API call) +const char *VPO_GetError(void); + +// try to load a wad file +// returns 0 on success, negative value on error +int VPO_LoadWAD(const char *wad_filename); + +// free all data associated with the wad file +// can be safely called without any loaded wad file +void VPO_FreeWAD(void); + +// retrieve the map names in the wad, one at a time +// index starts at 0 +// returns NULL when index is past the end of the list +// NOTE: return pointer is a static buffer, and is NOT guaranteed to +// remain valid once this function is called again +const char * VPO_GetMapName(unsigned int index, bool *is_hexen = NULL); + +// try to open a map from the current wad file +// returns 0 on success, negative value on error +int VPO_OpenMap(const char *map_name, bool *is_hexen = NULL); + +// free all data associated with a map +// can be safely called without any opened map +void VPO_CloseMap(void); + +// retrieve the linedefs in the current map, one at a time +// index starts at 0 +// returns number of sides (0 to 2), or -1 for invalid index +int VPO_GetLinedef(unsigned int index, int *x1, int *y1, int *x2, int *y2); + +// retrieve a seg for the current map +// index starts at 0 +// side value will be 0 for front/right, 1 for back/left +// returns a value >= 0 if valid, otherwise -1 +int VPO_GetSeg(unsigned int index, int *linedef, int *side, + int *x1, int *y1, int *x2, int *y2); + +// retrieve the bounding box of the map +void VPO_GetBBox(int *x1, int *y1, int *x2, int *y2); + +// open or close all sectors which seem to be doors +// dir must be > 0 to open them, or -1 to close them +void VPO_OpenDoorSectors(int dir); + +// test a spot and angle, returning the number of visplanes +// dz is the height above the floor (or offset from ceiling if < 0) +// angle is in degrees (0 to 360), 0 is east, 90 is north +// returns RESULT_OK on success, or a negative value spot was in the +// void or an error occurred -- see the RESULT_* values below +// +// the num_xxx parameters point to variables which get _updated_ by +// this call (i.e. new value is maximum of old value + checked value). +// hence you need to set those variables to zero before the first +// call at a particular (X Y) location. +// +// RESULT_OVERFLOW means that an internal limit overflowed (which are +// four times or more the actual DOOM limits). + +#define RESULT_OK 0 +#define RESULT_BAD_Z -1 +#define RESULT_IN_VOID -2 +#define RESULT_OVERFLOW -3 + +int VPO_TestSpot(int x, int y, int dz, int angle, + int *num_visplanes, + int *num_drawsegs, + int *num_openings, + int *num_solidsegs); + +#endif /* __VPO_API_H__ */ + diff --git a/Source/Plugins/vpo_dll/vpo_local.h b/Source/Plugins/vpo_dll/vpo_local.h index 667b1fed..d503c031 100644 --- a/Source/Plugins/vpo_dll/vpo_local.h +++ b/Source/Plugins/vpo_dll/vpo_local.h @@ -1,80 +1,78 @@ -//------------------------------------------------------------------------ -// Visplane Overflow Library -//------------------------------------------------------------------------ -// -// Copyright (C) 1993-1996 Id Software, Inc. -// Copyright (C) 2005 Simon Howard -// Copyright (C) 2012 Andrew Apted -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -//------------------------------------------------------------------------ - -#ifndef __VPO_LOCAL_H__ -#define __VPO_LOCAL_H__ - -#define WIN32_LEAN_AND_MEAN -#include -#include -#include -#include -#include -#include -#include - -#include "sys_type.h" -#include "sys_macro.h" -#include "sys_endian.h" - -namespace vpo -{ - -#include "doomtype.h" -#include "doomdef.h" -#include "doomdata.h" - -#include "m_bbox.h" -#include "m_fixed.h" - -#include "w_file.h" -#include "w_wad.h" - -#include "tables.h" -#include "r_defs.h" -#include "r_state.h" - -#include "r_main.h" -#include "r_bsp.h" -#include "r_plane.h" - - -//------------------------------------------------------------ - -#define SHORT(x) LE_S16(x) -#define LONG(x) LE_S32(x) - -void P_SetupLevel (const char *lumpname ); -void P_FreeLevelData (void); - -void I_Error (const char *error, ...); - -sector_t * X_SectorForPoint(fixed_t x, fixed_t y); - -// exceptions thrown on overflows -class overflow_exception { }; - -} // namespace vpo - - -#endif /* __VPO_LOCAL_H__ */ - -//--- editor settings --- -// vi:ts=4:sw=4:noexpandtab +//------------------------------------------------------------------------ +// Visplane Overflow Library +//------------------------------------------------------------------------ +// +// Copyright (C) 1993-1996 Id Software, Inc. +// Copyright (C) 2005 Simon Howard +// Copyright (C) 2012 Andrew Apted +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +//------------------------------------------------------------------------ + +#ifndef __VPO_LOCAL_H__ +#define __VPO_LOCAL_H__ + +#include +#include +#include +#include +#include +#include + +#include "sys_type.h" +#include "sys_macro.h" +#include "sys_endian.h" + +namespace vpo +{ + +#include "doomtype.h" +#include "doomdef.h" +#include "doomdata.h" + +#include "m_bbox.h" +#include "m_fixed.h" + +#include "w_file.h" +#include "w_wad.h" + +#include "tables.h" +#include "r_defs.h" +#include "r_state.h" + +#include "r_main.h" +#include "r_bsp.h" +#include "r_plane.h" + + +//------------------------------------------------------------ + +#define SHORT(x) LE_S16(x) +#define LONG(x) LE_S32(x) + +const char * P_SetupLevel (const char *lumpname, bool *is_hexen ); +void P_FreeLevelData (void); + +void I_Error (const char *error, ...); + +sector_t * X_SectorForPoint(fixed_t x, fixed_t y); + +// exceptions thrown on overflows +class overflow_exception { }; + +} // namespace vpo + + +#endif /* __VPO_LOCAL_H__ */ + +//--- editor settings --- +// vi:ts=4:sw=4:noexpandtab diff --git a/Source/Plugins/vpo_dll/vpo_main.cc b/Source/Plugins/vpo_dll/vpo_main.cc index 085a2283..f3106a74 100644 --- a/Source/Plugins/vpo_dll/vpo_main.cc +++ b/Source/Plugins/vpo_dll/vpo_main.cc @@ -1,294 +1,369 @@ -//------------------------------------------------------------------------ -// Visplane Overflow Library -//------------------------------------------------------------------------ -// -// Copyright (C) 1993-1996 Id Software, Inc. -// Copyright (C) 2005 Simon Howard -// Copyright (C) 2012 Andrew Apted -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -//------------------------------------------------------------------------ - -#include "vpo_local.h" -#include "vpo_api.h" - - -static char error_buffer[1024]; - -// cache for the sector lookup -static int last_x, last_y; -static vpo::sector_t *last_sector; - - -static void ClearError(void) -{ - strcpy(error_buffer, "(No Error)"); -} - -static void SetError(const char *msg, ...) -{ - va_list argptr; - - va_start(argptr, msg); - memset(error_buffer, 0, sizeof(error_buffer)); - vsnprintf(error_buffer, sizeof(error_buffer) - 1, msg, argptr); - va_end(argptr); -} - - -const char* APIENTRY VPO_GetError(void) -{ - return error_buffer; -} - - -//------------------------------------------------------------------------ - -int APIENTRY VPO_LoadWAD(const char *wad_filename) -{ - ClearError(); - - // free any previously loaded wad - VPO_FreeWAD(); - - vpo::R_Init(); - - if (! vpo::W_AddFile(wad_filename)) - { - SetError("Could not open/read the file: %s", wad_filename); - return -1; - } - - return 0; // OK ! -} - - -int APIENTRY VPO_OpenMap(const char *map_name) -{ - // check a wad is loaded - if (vpo::numlumps <= 0) - { - SetError("VPO_OpenMap called without any loaded map"); - return -1; - } - - ClearError(); - - // close any previously loaded map - VPO_CloseMap(); - - if (vpo::W_CheckNumForName(map_name) < 0) - { - SetError("No such map in wad: %s", map_name); - return -1; - } - - vpo::P_SetupLevel(map_name); - - return 0; // OK ! -} - - -void APIENTRY VPO_FreeWAD(void) -{ - VPO_CloseMap(); - - vpo::W_RemoveFile(); -} - - -void APIENTRY VPO_CloseMap(void) -{ - ClearError(); - - last_x = -77777; - last_y = -77777; - last_sector = NULL; - - vpo::P_FreeLevelData(); -} - - -const char* APIENTRY VPO_GetMapName(unsigned int index) -{ - static char buffer[16]; - - for (unsigned int lump_i = 0 ; lump_i < vpo::numlumps ; lump_i++) - { - if (! vpo::lumpinfo[lump_i].is_map_header) - continue; - - if (index == 0) - { - // found it - memcpy(buffer, vpo::lumpinfo[lump_i].name, 8); - buffer[8] = 0; - - return buffer; - } - - index--; - } - - // not found - return NULL; -} - - -int APIENTRY VPO_GetLinedef(unsigned int index, int *x1, int *y1, int *x2, int *y2) -{ - if (index >= (unsigned int)vpo::numlines) - return -1; - - const vpo::line_t *L = &vpo::lines[index]; - - *x1 = L->v1->x >> FRACBITS; - *y1 = L->v1->y >> FRACBITS; - - *x2 = L->v2->x >> FRACBITS; - *y2 = L->v2->y >> FRACBITS; - - return L->backsector ? 2 : 1; -} - - -//------------------------------------------------------------------------ - -int APIENTRY VPO_TestSpot(int x, int y, int dz, int angle, - int *num_visplanes, int *num_drawsegs, - int *num_openings, int *num_solidsegs) -{ - // the actual spot we will use - // (this prevents issues with X_SectorForPoint getting the wrong - // value when the casted ray hits a vertex) - vpo::fixed_t rx = (x << FRACBITS) + (FRACUNIT / 2); - vpo::fixed_t ry = (y << FRACBITS) + (FRACUNIT / 2); - - vpo::sector_t *sec; - - // optimization: we cache the last sector lookup - if (x == last_x && y == last_y) - sec = last_sector; - else - { - sec = vpo::X_SectorForPoint(rx, ry); - - last_x = x; - last_y = y; - last_sector = sec; - } - - if (! sec) - return RESULT_IN_VOID; - - vpo::fixed_t rz; - - if (dz < 0) - rz = sec->ceilingheight + (dz << FRACBITS); - else - rz = sec->floorheight + (dz << FRACBITS); - - if (rz <= sec->floorheight || rz >= sec->ceilingheight) - return RESULT_BAD_Z; - - // convert angle to the 32-bit BAM representation - if (angle == 360) - angle = 0; - - vpo::fixed_t ang2 = vpo::FixedDiv(angle << FRACBITS, 360 << FRACBITS); - - vpo::angle_t r_ang = (vpo::angle_t) (ang2 << 16); - - int result = RESULT_OK; - - // perform a no-draw render and see how many visplanes were needed - try - { - vpo::R_RenderView(rx, ry, rz, r_ang); - } - catch (vpo::overflow_exception& e) - { - result = RESULT_OVERFLOW; - } - - *num_visplanes = MAX(*num_visplanes, vpo::total_visplanes); - *num_drawsegs = MAX(*num_drawsegs, vpo::total_drawsegs); - *num_openings = MAX(*num_openings, vpo::total_openings); - *num_solidsegs = MAX(*num_solidsegs, vpo::max_solidsegs); - - return result; -} - - -//------------------------------------------------------------------------ - -#ifdef VPO_TEST_PROGRAM - -#define EYE_HEIGHT 41 - -int main(int argc, char **argv) -{ - printf("----------------\n"); - printf("VPO TEST PROGRAM\n"); - printf("----------------\n"); - printf("\n"); - - if (argc < 5 || - (strcmp (argv[1], "-h") == 0 || - strcmp (argv[1], "--help") == 0 || - strcmp (argv[1], "/?") == 0) ) - { - printf("Usage: vpotest file.wad MAP01 x y angle\n"); - fflush(stdout); - return 0; - } - - const char *filename = argv[1]; - const char *map = argv[2]; - - int x = atoi(argv[3]); - int y = atoi(argv[4]); - int angle = atoi(argv[5]); - - printf("Loading file: %s [%s]\n", filename, map); - - if (VPO_LoadWAD(filename) != 0) - { - printf("ERROR: %s\n", VPO_GetError()); - fflush(stdout); - return 1; - } - - if (VPO_OpenMap(map) != 0) - { - printf("ERROR: %s\n", VPO_GetError()); - fflush(stdout); - VPO_FreeWAD(); - return 1; - } - - int vp_num = VPO_TestSpot(TEST_VISPLANES, x, y, EYE_HEIGHT, angle); - - printf("\n"); - printf("Visplanes @ (%d %d) ---> %d\n", x, y, vp_num); - fflush(stdout); - - VPO_CloseMap(); - VPO_FreeWAD(); - - return 0; -} - -#endif // VPO_TEST_PROGRAM - -//--- editor settings --- -// vi:ts=4:sw=4:noexpandtab +//------------------------------------------------------------------------ +// Visplane Overflow Library +//------------------------------------------------------------------------ +// +// Copyright (C) 1993-1996 Id Software, Inc. +// Copyright (C) 2005 Simon Howard +// Copyright (C) 2012-2014 Andrew Apted +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +//------------------------------------------------------------------------ + +#include "vpo_local.h" +#include "vpo_api.h" + + +static char error_buffer[1024]; + +// cache for the sector lookup +static int last_x, last_y; +static vpo::sector_t *last_sector; + + +static void ClearError(void) +{ + strcpy(error_buffer, "(No Error)"); +} + +static void SetError(const char *msg, ...) +{ + va_list argptr; + + va_start(argptr, msg); + memset(error_buffer, 0, sizeof(error_buffer)); + vsnprintf(error_buffer, sizeof(error_buffer) - 1, msg, argptr); + va_end(argptr); +} + + +const char *VPO_GetError(void) +{ + return error_buffer; +} + + +//------------------------------------------------------------------------ + +int VPO_LoadWAD(const char *wad_filename) +{ + ClearError(); + + // free any previously loaded wad + VPO_FreeWAD(); + + vpo::R_Init(); + + if (! vpo::W_AddFile(wad_filename)) + { + SetError("Missing or invalid wad file: %s", wad_filename); + return -1; + } + + return 0; // OK ! +} + + +int VPO_OpenMap(const char *map_name, bool *is_hexen) +{ + // check a wad is loaded + if (vpo::numlumps <= 0) + { + SetError("VPO_OpenMap called without any loaded wad"); + return -1; + } + + ClearError(); + + // close any previously loaded map + VPO_CloseMap(); + + const char *err_msg = vpo::P_SetupLevel(map_name, is_hexen); + + if (err_msg) + { + SetError("%s", err_msg); + return -1; + } + + return 0; // OK ! +} + + +void VPO_FreeWAD(void) +{ + VPO_CloseMap(); + + vpo::W_RemoveFile(); +} + + +void VPO_CloseMap(void) +{ + ClearError(); + + last_x = -77777; + last_y = -77777; + last_sector = NULL; + + vpo::P_FreeLevelData(); +} + + +const char * VPO_GetMapName(unsigned int index, bool *is_hexen) +{ + static char buffer[16]; + + for (int lump_i = 0 ; lump_i < vpo::numlumps ; lump_i++) + { + if (! vpo::lumpinfo[lump_i].is_map_header) + continue; + + if (index == 0) + { + // found it + memcpy(buffer, vpo::lumpinfo[lump_i].name, 8); + buffer[8] = 0; + + if (is_hexen) + *is_hexen = vpo::lumpinfo[lump_i].is_hexen; + + return buffer; + } + + index--; + } + + // not found + return NULL; +} + + +int VPO_GetLinedef(unsigned int index, int *x1, int *y1, int *x2, int *y2) +{ + if (index >= (unsigned int)vpo::numlines) + return -1; + + const vpo::line_t *L = &vpo::lines[index]; + + *x1 = L->v1->x >> FRACBITS; + *y1 = L->v1->y >> FRACBITS; + + *x2 = L->v2->x >> FRACBITS; + *y2 = L->v2->y >> FRACBITS; + + return L->backsector ? 2 : 1; +} + + +int VPO_GetSeg(unsigned int index, int *linedef, int *side, + int *x1, int *y1, int *x2, int *y2) +{ + if (index >= (unsigned int)vpo::numsegs) + return -1; + + const vpo::seg_t *seg = &vpo::segs[index]; + const vpo::line_t *L = seg->linedef; + + *x1 = seg->v1->x >> FRACBITS; + *y1 = seg->v1->y >> FRACBITS; + + *x2 = seg->v2->x >> FRACBITS; + *y2 = seg->v2->y >> FRACBITS; + + *linedef = (L - vpo::lines); + *side = 0; + + if (L->sidenum[1] >= 0 && seg->sidedef == &vpo::sides[L->sidenum[1]]) + *side = 1; + + return 0; +} + + +void VPO_GetBBox(int *x1, int *y1, int *x2, int *y2) +{ + *x1 = (vpo::Map_bbox[vpo::BOXLEFT] >> FRACBITS); + *y1 = (vpo::Map_bbox[vpo::BOXBOTTOM] >> FRACBITS); + *x2 = (vpo::Map_bbox[vpo::BOXRIGHT] >> FRACBITS); + *y2 = (vpo::Map_bbox[vpo::BOXTOP] >> FRACBITS); +} + + +void VPO_OpenDoorSectors(int dir) +{ + for (int i = 0 ; i < vpo::numsectors ; i++) + { + vpo::sector_t *sec = &vpo::sectors[i]; + + if (sec->is_door == 0) + continue; + + if (dir > 0) // open them + { + if (sec->is_door > 0) + sec->ceilingheight = sec->alt_height; + else + sec->floorheight = sec->alt_height; + } + else if (dir < 0) // close them + { + if (sec->is_door > 0) + sec->ceilingheight = sec->floorheight; + else + sec->floorheight = sec->ceilingheight; + } + } +} + + +//------------------------------------------------------------------------ + +int VPO_TestSpot(int x, int y, int dz, int angle, + int *num_visplanes, int *num_drawsegs, + int *num_openings, int *num_solidsegs) +{ + // the actual spot we will use + // (this prevents issues with X_SectorForPoint getting the wrong + // value when the casted ray hits a vertex) + vpo::fixed_t rx = (x << FRACBITS) + (FRACUNIT / 2); + vpo::fixed_t ry = (y << FRACBITS) + (FRACUNIT / 2); + + // check if spot is outside the map + if (rx < vpo::Map_bbox[vpo::BOXLEFT] || + rx > vpo::Map_bbox[vpo::BOXRIGHT] || + ry < vpo::Map_bbox[vpo::BOXBOTTOM] || + ry > vpo::Map_bbox[vpo::BOXTOP]) + { + return RESULT_IN_VOID; + } + + // optimization: we cache the last sector lookup + vpo::sector_t *sec; + + if (x == last_x && y == last_y) + sec = last_sector; + else + { + sec = vpo::X_SectorForPoint(rx, ry); + + last_x = x; + last_y = y; + last_sector = sec; + } + + if (! sec) + return RESULT_IN_VOID; + + vpo::fixed_t rz; + + if (dz < 0) + rz = sec->ceilingheight + (dz << FRACBITS); + else + rz = sec->floorheight + (dz << FRACBITS); + + if (rz <= sec->floorheight || rz >= sec->ceilingheight) + return RESULT_BAD_Z; + + // convert angle to the 32-bit BAM representation + if (angle == 360) + angle = 0; + + vpo::fixed_t ang2 = vpo::FixedDiv(angle << FRACBITS, 360 << FRACBITS); + + vpo::angle_t r_ang = (vpo::angle_t) (ang2 << 16); + + int result = RESULT_OK; + + // perform a no-draw render and see how many visplanes were needed + try + { + vpo::R_RenderView(rx, ry, rz, r_ang); + } + catch (vpo::overflow_exception& e) + { + result = RESULT_OVERFLOW; + } + + *num_visplanes = MAX(*num_visplanes, vpo::total_visplanes); + *num_drawsegs = MAX(*num_drawsegs, vpo::total_drawsegs); + *num_openings = MAX(*num_openings, vpo::total_openings); + *num_solidsegs = MAX(*num_solidsegs, vpo::max_solidsegs); + + return result; +} + + +//------------------------------------------------------------------------ + +#if 0 // VPO_TEST_PROGRAM + +// NOTE: this is out of date and will not compile + +#define EYE_HEIGHT 41 + +int main(int argc, char **argv) +{ + printf("----------------\n"); + printf("VPO TEST PROGRAM\n"); + printf("----------------\n"); + printf("\n"); + + if (argc < 5 || + (strcmp (argv[1], "-h") == 0 || + strcmp (argv[1], "--help") == 0 || + strcmp (argv[1], "/?") == 0) ) + { + printf("Usage: vpotest file.wad MAP01 x y angle\n"); + fflush(stdout); + return 0; + } + + const char *filename = argv[1]; + const char *map = argv[2]; + + int x = atoi(argv[3]); + int y = atoi(argv[4]); + int angle = atoi(argv[5]); + + printf("Loading file: %s [%s]\n", filename, map); + + if (VPO_LoadWAD(filename) != 0) + { + printf("ERROR: %s\n", VPO_GetError()); + fflush(stdout); + return 1; + } + + if (VPO_OpenMap(map) != 0) + { + printf("ERROR: %s\n", VPO_GetError()); + fflush(stdout); + VPO_FreeWAD(); + return 1; + } + + int vp_num = VPO_TestSpot(TEST_VISPLANES, x, y, EYE_HEIGHT, angle); + + printf("\n"); + printf("Visplanes @ (%d %d) ---> %d\n", x, y, vp_num); + fflush(stdout); + + VPO_CloseMap(); + VPO_FreeWAD(); + + return 0; +} + +#endif // VPO_TEST_PROGRAM + +//--- editor settings --- +// vi:ts=4:sw=4:noexpandtab diff --git a/Source/Plugins/vpo_dll/vpo_stuff.cc b/Source/Plugins/vpo_dll/vpo_stuff.cc index d56b92b9..f4d8bb7b 100644 --- a/Source/Plugins/vpo_dll/vpo_stuff.cc +++ b/Source/Plugins/vpo_dll/vpo_stuff.cc @@ -1,113 +1,113 @@ -//------------------------------------------------------------------------ -// VPO_LIB : misc stuff -//------------------------------------------------------------------------ -// -// Copyright (C) 1993-1996 Id Software, Inc. -// Copyright (C) 2005 Simon Howard -// Copyright (C) 2012 Andrew Apted -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -//------------------------------------------------------------------------ - -#include "vpo_local.h" - -namespace vpo -{ - - -void I_Error (const char *error, ...) -{ - va_list argptr; - - va_start(argptr, error); - vfprintf(stderr, error, argptr); - va_end(argptr); - - fprintf(stderr, "\n\n"); - fflush(stderr); - - exit(-1); -} - - -static int ClosestLine_CastingHoriz(fixed_t x, fixed_t y, int *side) -{ - int best_match = -1; - fixed_t best_dist = 32000 << FRACBITS; - - for (int n = 0 ; n < numlines ; n++) - { - fixed_t ly1 = lines[n].v1->y; - fixed_t ly2 = lines[n].v2->y; - - // ignore purely horizontal lines - if (ly1 == ly2) - continue; - - // does the linedef cross the horizontal ray? - if ( (y < ly1) && (y < ly2) ) continue; - if ( (y > ly1) && (y > ly2) ) continue; - - fixed_t lx1 = lines[n].v1->x; - fixed_t lx2 = lines[n].v2->x; - - fixed_t quot = FixedDiv(y - ly1, ly2 - ly1); - fixed_t dist = lx1 - x + FixedMul(lx2 - lx1, quot); - - if (abs(dist) < best_dist) - { - best_match = n; - best_dist = abs(dist); - - if (side) - { - if (best_dist < FRACUNIT / 8) - *side = 0; // on the line - else if ( (ly1 > ly2) == (dist > 0)) - *side = 1; // right side - else - *side = -1; // left side - } - } - } - - return best_match; -} - - -sector_t * X_SectorForPoint(fixed_t x, fixed_t y) -{ - /* hack, hack... I look for the first LineDef crossing - an horizontal half-line drawn from the cursor */ - - int sd = 0; - int ld = ClosestLine_CastingHoriz(x, y, &sd); - - // VOID checks - if (ld < 0) - return NULL; - - if (lines[ld].sidenum[sd <= 0 ? 1 : 0] < 0) - return NULL; - - // get sector as DOOM would - // (need this to handle self-referencing linedef tricks) - subsector_t *sub = R_PointInSubsector(x, y); - - return sub->sector; -} - - -} // namespace vpo - -//--- editor settings --- -// vi:ts=4:sw=4:noexpandtab +//------------------------------------------------------------------------ +// VPO_LIB : misc stuff +//------------------------------------------------------------------------ +// +// Copyright (C) 1993-1996 Id Software, Inc. +// Copyright (C) 2005 Simon Howard +// Copyright (C) 2012 Andrew Apted +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +//------------------------------------------------------------------------ + +#include "vpo_local.h" + +namespace vpo +{ + + +void I_Error (const char *error, ...) +{ + va_list argptr; + + va_start(argptr, error); + vfprintf(stderr, error, argptr); + va_end(argptr); + + fprintf(stderr, "\n\n"); + fflush(stderr); + + exit(-1); +} + + +static int ClosestLine_CastingHoriz(fixed_t x, fixed_t y, int *side) +{ + int best_match = -1; + fixed_t best_dist = 32000 << FRACBITS; + + for (int n = 0 ; n < numlines ; n++) + { + fixed_t ly1 = lines[n].v1->y; + fixed_t ly2 = lines[n].v2->y; + + // ignore purely horizontal lines + if (ly1 == ly2) + continue; + + // does the linedef cross the horizontal ray? + if ( (y < ly1) && (y < ly2) ) continue; + if ( (y > ly1) && (y > ly2) ) continue; + + fixed_t lx1 = lines[n].v1->x; + fixed_t lx2 = lines[n].v2->x; + + fixed_t quot = FixedDiv(y - ly1, ly2 - ly1); + fixed_t dist = lx1 - x + FixedMul(lx2 - lx1, quot); + + if (abs(dist) < best_dist) + { + best_match = n; + best_dist = abs(dist); + + if (side) + { + if (best_dist < FRACUNIT / 8) + *side = 0; // on the line + else if ( (ly1 > ly2) == (dist > 0)) + *side = 1; // right side + else + *side = -1; // left side + } + } + } + + return best_match; +} + + +sector_t * X_SectorForPoint(fixed_t x, fixed_t y) +{ + /* hack, hack... I look for the first LineDef crossing + an horizontal half-line drawn from the cursor */ + + int sd = 0; + int ld = ClosestLine_CastingHoriz(x, y, &sd); + + // VOID checks + if (ld < 0) + return NULL; + + if (lines[ld].sidenum[sd <= 0 ? 1 : 0] < 0) + return NULL; + + // get sector as DOOM would + // (need this to handle self-referencing linedef tricks) + subsector_t *sub = R_PointInSubsector(x, y); + + return sub->sector; +} + + +} // namespace vpo + +//--- editor settings --- +// vi:ts=4:sw=4:noexpandtab diff --git a/Source/Plugins/vpo_dll/w_file.cc b/Source/Plugins/vpo_dll/w_file.cc index 68e6adf7..76d6d44f 100644 --- a/Source/Plugins/vpo_dll/w_file.cc +++ b/Source/Plugins/vpo_dll/w_file.cc @@ -1,85 +1,85 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2008 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// WAD I/O functions. -// -//----------------------------------------------------------------------------- - -#include "vpo_local.h" - -namespace vpo -{ - - -wad_file_t *W_OpenFile(const char *path) -{ - wad_file_t *result; - - FILE *fstream = fopen(path, "rb"); - - if (fstream == NULL) - { - return NULL; - } - - // Create a new wad_file_t to hold the file handle. - - result = new wad_file_t; - - result->fstream = fstream; - -// result->length = M_FileLength(fstream); - - return result; -} - - -void W_CloseFile(wad_file_t *wad) -{ - fclose(wad->fstream); - - delete wad; -} - - -// Read data from the specified position in the file into the -// provided buffer. Returns the number of bytes read. - -size_t W_Read(wad_file_t *wad, unsigned int offset, - void *buffer, size_t buffer_len) -{ - size_t result; - - // Jump to the specified position in the file. - - fseek(wad->fstream, offset, SEEK_SET); - - // Read into the buffer. - - result = fread(buffer, 1, buffer_len, wad->fstream); - - return result; -} - - -} // namespace vpo - +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2008 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// WAD I/O functions. +// +//----------------------------------------------------------------------------- + +#include "vpo_local.h" + +namespace vpo +{ + + +wad_file_t *W_OpenFile(const char *path) +{ + wad_file_t *result; + + FILE *fstream = fopen(path, "rb"); + + if (fstream == NULL) + { + return NULL; + } + + // Create a new wad_file_t to hold the file handle. + + result = new wad_file_t; + + result->fstream = fstream; + +// result->length = M_FileLength(fstream); + + return result; +} + + +void W_CloseFile(wad_file_t *wad) +{ + fclose(wad->fstream); + + delete wad; +} + + +// Read data from the specified position in the file into the +// provided buffer. Returns the number of bytes read. + +size_t W_Read(wad_file_t *wad, unsigned int offset, + void *buffer, size_t buffer_len) +{ + size_t result; + + // Jump to the specified position in the file. + + fseek(wad->fstream, offset, SEEK_SET); + + // Read into the buffer. + + result = fread(buffer, 1, buffer_len, wad->fstream); + + return result; +} + + +} // namespace vpo + diff --git a/Source/Plugins/vpo_dll/w_file.h b/Source/Plugins/vpo_dll/w_file.h index 22266706..dba21d83 100644 --- a/Source/Plugins/vpo_dll/w_file.h +++ b/Source/Plugins/vpo_dll/w_file.h @@ -1,55 +1,55 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2008 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// WAD I/O functions. -// -//----------------------------------------------------------------------------- - -#ifndef __W_FILE__ -#define __W_FILE__ - -#include -#include "doomtype.h" - -typedef struct _wad_file_s -{ - FILE *fstream; - -} wad_file_t; - -// Open the specified file. Returns a pointer to a new wad_file_t -// handle for the WAD file, or NULL if it could not be opened. - -wad_file_t *W_OpenFile(const char *path); - -// Close the specified WAD file. - -void W_CloseFile(wad_file_t *wad); - -// Read data from the specified file into the provided buffer. The -// data is read from the specified offset from the start of the file. -// Returns the number of bytes read. - -size_t W_Read(wad_file_t *wad, unsigned int offset, - void *buffer, size_t buffer_len); - -#endif /* #ifndef __W_FILE__ */ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2008 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// WAD I/O functions. +// +//----------------------------------------------------------------------------- + +#ifndef __W_FILE__ +#define __W_FILE__ + +#include +#include "doomtype.h" + +typedef struct _wad_file_s +{ + FILE *fstream; + +} wad_file_t; + +// Open the specified file. Returns a pointer to a new wad_file_t +// handle for the WAD file, or NULL if it could not be opened. + +wad_file_t *W_OpenFile(const char *path); + +// Close the specified WAD file. + +void W_CloseFile(wad_file_t *wad); + +// Read data from the specified file into the provided buffer. The +// data is read from the specified offset from the start of the file. +// Returns the number of bytes read. + +size_t W_Read(wad_file_t *wad, unsigned int offset, + void *buffer, size_t buffer_len); + +#endif /* #ifndef __W_FILE__ */ diff --git a/Source/Plugins/vpo_dll/w_wad.cc b/Source/Plugins/vpo_dll/w_wad.cc index 87fbfd07..d5a1547d 100644 --- a/Source/Plugins/vpo_dll/w_wad.cc +++ b/Source/Plugins/vpo_dll/w_wad.cc @@ -1,359 +1,366 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// Handles WAD file header, directory, lump I/O. -// -//----------------------------------------------------------------------------- - -#include "vpo_local.h" - -namespace vpo -{ - - -typedef struct -{ - // Should be "IWAD" or "PWAD". - char identification[4]; - int numlumps; - int infotableofs; -} PACKEDATTR wadinfo_t; - - -typedef struct -{ - int filepos; - int size; - char name[8]; -} PACKEDATTR filelump_t; - -// -// GLOBALS -// - -// Location of each lump on disk. - -lumpinfo_t *lumpinfo; -unsigned int numlumps = 0; - - - - -// -// LUMP BASED ROUTINES. -// - -// andrewj: added this to find level names -bool CheckMapHeader(filelump_t *lumps, int num_after) -{ - static const char *level_lumps[] = - { - "THINGS", "LINEDEFS", "SIDEDEFS", "VERTEXES", - "SEGS", "SSECTORS", "NODES", "SECTORS", - - NULL // end of list - }; - - if (num_after < 4) - return false; - - int seen_mask = 0; - int seen_count = 0; - - for (int i = 0 ; level_lumps[i] ; i++) - { - const char *name = level_lumps[i]; - - // level lumps are never valid map header names - if (strncmp(lumps[0].name, name, 8) == 0) - return false; - - for (int pos = 1 ; pos <= 4 ; pos++) - { - if (strncmp(lumps[pos].name, name, 8) == 0) - { - int mask = 1 << i; - - // check if name was duplicated - if (seen_mask & mask) - return false; - - seen_mask |= mask; - seen_count += 1; - } - } - - // found enough level lumps - if (seen_count >= 4) - return true; - } - - return false; -} - - -// -// W_AddFile -// -// All files are optional, but at least one file must be -// found (PWAD, if all required lumps are present). -// Files with a .wad extension are wadlink files -// with multiple lumps. -// Other files are single lumps with the base filename -// for the lump name. - -wad_file_t *W_AddFile (const char *filename) -{ - wadinfo_t header; - lumpinfo_t *lump_p; - unsigned int i; - wad_file_t *wad_file; - int length; - int startlump; - filelump_t *fileinfo; - filelump_t *filerover; - - // open the file and add to directory - - wad_file = W_OpenFile(filename); - - if (wad_file == NULL) - { -/// printf (" couldn't open %s\n", filename); - return NULL; - } - - startlump = numlumps; - - W_Read(wad_file, 0, &header, sizeof(header)); - - if (strncmp(header.identification,"IWAD",4)) - { - // Homebrew levels? - if (strncmp(header.identification,"PWAD",4)) - { - I_Error ("Wad file %s doesn't have IWAD " - "or PWAD id\n", filename); - } - - // ???modifiedgame = true; - } - - header.numlumps = LONG(header.numlumps); - header.infotableofs = LONG(header.infotableofs); - - length = header.numlumps * sizeof(filelump_t); - - fileinfo = new filelump_t[header.numlumps]; - - W_Read(wad_file, header.infotableofs, fileinfo, length); - numlumps += header.numlumps; - - - // Fill in lumpinfo - lumpinfo = (lumpinfo_t *)realloc(lumpinfo, numlumps * sizeof(lumpinfo_t)); - - if (lumpinfo == NULL) - { - I_Error ("Couldn't realloc lumpinfo"); - } - - lump_p = &lumpinfo[startlump]; - - filerover = fileinfo; - - for (i=startlump; iwad_file = wad_file; - lump_p->position = LONG(filerover->filepos); - lump_p->size = LONG(filerover->size); - - strncpy(lump_p->name, filerover->name, 8); - - lump_p->is_map_header = CheckMapHeader(filerover, numlumps - i - 1); - - ++lump_p; - ++filerover; - } - - delete[] fileinfo; - - return wad_file; -} - - -void W_RemoveFile(void) -{ - if (lumpinfo) - { - // andrewj: horrible hack, assumes a single wad file - W_CloseFile(lumpinfo[0].wad_file); - - free(lumpinfo); - - lumpinfo = NULL; - numlumps = 0; - } -} - - - -// -// W_NumLumps -// -int W_NumLumps (void) -{ - return numlumps; -} - - -// -// W_CheckNumForName -// Returns -1 if name not found. -// - -int W_CheckNumForName (const char* name) -{ - int i; - - { - // scan backwards so patch lump files take precedence - - for (i=numlumps-1; i >= 0; --i) - { - if (!strncasecmp(lumpinfo[i].name, name, 8)) - { - return i; - } - } - } - - // TFB. Not found. - - return -1; -} - - -// -// W_GetNumForName -// Calls W_CheckNumForName, but bombs out if not found. -// -int W_GetNumForName (const char* name) -{ - int i; - - i = W_CheckNumForName (name); - - if (i < 0) - { - I_Error ("W_GetNumForName: %s not found!", name); - } - - return i; -} - - -// -// W_LumpLength -// Returns the buffer size needed to load the given lump. -// -int W_LumpLength (unsigned int lump) -{ - if (lump >= numlumps) - { - I_Error ("W_LumpLength: %i >= numlumps", lump); - } - - return lumpinfo[lump].size; -} - - - -// -// W_ReadLump -// Loads the lump into the given buffer, -// which must be >= W_LumpLength(). -// -void W_ReadLump(unsigned int lump, void *dest) -{ - int c; - lumpinfo_t *l; - - if (lump >= numlumps) - { - I_Error ("W_ReadLump: %i >= numlumps", lump); - } - - l = lumpinfo+lump; - -/// I_BeginRead (); - - c = W_Read(l->wad_file, l->position, dest, l->size); - - if (c < l->size) - { - I_Error ("W_ReadLump: only read %i of %i on lump %i", - c, l->size, lump); - } - -/// I_EndRead (); -} - - - -// -// W_LoadLump -// -// Load a lump into memory and return a pointer to a buffer containing -// the lump data. -// - -byte * W_LoadLump(int lumpnum) -{ - byte *result; - lumpinfo_t *lump; - - if ((unsigned)lumpnum >= numlumps) - { - I_Error ("W_LoadLump: %i >= numlumps", lumpnum); - } - - lump = &lumpinfo[lumpnum]; - - // load it now - - result = new byte[W_LumpLength(lumpnum) + 1]; - - W_ReadLump (lumpnum, result); - - return result; -} - - -void W_FreeLump(byte * data) -{ - delete[] data; -} - - -} // namespace vpo - +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// Handles WAD file header, directory, lump I/O. +// +//----------------------------------------------------------------------------- + +#include "vpo_local.h" + +namespace vpo +{ + + +typedef struct +{ + // Should be "IWAD" or "PWAD". + char identification[4]; + int numlumps; + int infotableofs; + +} PACKEDATTR wadinfo_t; + + +typedef struct +{ + int filepos; + int size; + char name[8]; + +} PACKEDATTR filelump_t; + +// +// GLOBALS +// + +// Location of each lump on disk. + +lumpinfo_t *lumpinfo; + +int numlumps = 0; + +static char * wad_filename; + +static wad_file_t * current_file; + + + +// +// LUMP BASED ROUTINES. +// + +// andrewj: added this to find level names +// returns 0 if not a level, 1 for DOOM, 2 for HEXEN format +static int CheckMapHeader(filelump_t *lumps, int num_after) +{ + static const char *level_lumps[] = + { + "THINGS", "LINEDEFS", "SIDEDEFS", "VERTEXES", + "SEGS", "SSECTORS", "NODES", "SECTORS", + "REJECT", "BLOCKMAP" + }; + + if (num_after < 10) + return 0; + + for (int i = 0 ; i < 10 ; i++) + { + const char *name = level_lumps[i]; + + // level lumps are never valid map header names + if (strncmp(lumps[0].name, name, 8) == 0) + return 0; + + // require a one-to-one correspondence + // (anything else would crash DOOM) + if (strncmp(lumps[1 + i].name, name, 8) != 0) + return 0; + } + + // hexen format is distinguished by a following BEHAVIOR lump + if (num_after >= 11 && strncmp(lumps[11].name, "BEHAVIOR", 8) == 0) + return 2; + + return 1; +} + + +// +// W_AddFile +// +// All files are optional, but at least one file must be +// found (PWAD, if all required lumps are present). +// Files with a .wad extension are wadlink files +// with multiple lumps. +// Other files are single lumps with the base filename +// for the lump name. + +bool W_AddFile (const char *filename) +{ + wadinfo_t header; + lumpinfo_t *lump_p; + wad_file_t *wad_file; + + int i; + int length; + int startlump; + + filelump_t *fileinfo; + filelump_t *filerover; + + // open the file and add to directory + + wad_file = W_OpenFile(filename); + + if (wad_file == NULL) + { + return false; + } + + startlump = numlumps; + + W_Read(wad_file, 0, &header, sizeof(header)); + + if (strncmp(header.identification,"IWAD",4) != 0) + { + // Homebrew levels? + if (strncmp(header.identification,"PWAD",4) != 0) + { +/// I_Error ("Wad file %s doesn't have IWAD " +/// "or PWAD id\n", filename); + + W_CloseFile(wad_file); + + return false; + } + } + + header.numlumps = LONG(header.numlumps); + header.infotableofs = LONG(header.infotableofs); + + length = header.numlumps * sizeof(filelump_t); + + fileinfo = new filelump_t[header.numlumps]; + + W_Read(wad_file, header.infotableofs, fileinfo, length); + numlumps += header.numlumps; + + + // Fill in lumpinfo + lumpinfo = (lumpinfo_t *)realloc(lumpinfo, numlumps * sizeof(lumpinfo_t)); + + if (! lumpinfo) + I_Error ("Out of memory -- could not realloc lumpinfo"); + + lump_p = &lumpinfo[startlump]; + + filerover = fileinfo; + + for (i=startlump; i < numlumps; ++i) + { + int map_header; + + lump_p->position = LONG(filerover->filepos); + lump_p->size = LONG(filerover->size); + + strncpy(lump_p->name, filerover->name, 8); + + map_header = CheckMapHeader(filerover, numlumps - i - 1); + + lump_p->is_map_header = (map_header >= 1); + lump_p->is_hexen = (map_header == 2); + + ++lump_p; + ++filerover; + } + + delete[] fileinfo; + + // close the file now, we re-open it later to load the map + W_CloseFile(wad_file); + + wad_filename = strdup(filename); + + if (! wad_filename) + I_Error ("Out of memory -- could not strdup filename"); + + return true; +} + + +void W_RemoveFile(void) +{ + if (wad_filename) + { + free(wad_filename); + + wad_filename = NULL; + + free(lumpinfo); + + lumpinfo = NULL; + numlumps = 0; + } +} + + +// +// W_NumLumps +// +int W_NumLumps (void) +{ + return numlumps; +} + + +// +// W_CheckNumForName +// Returns -1 if name not found. +// +int W_CheckNumForName (const char* name) +{ + int i; + + // scan backwards so patch lump files take precedence + + for (i=numlumps-1; i >= 0; --i) + { + if (strncasecmp(lumpinfo[i].name, name, 8) == 0) + { + return i; + } + } + + // TFB. Not found. + + return -1; +} + + +// +// W_LumpLength +// Returns the buffer size needed to load the given lump. +// +int W_LumpLength (int lumpnum) +{ + if (lumpnum >= numlumps) + { + I_Error ("W_LumpLength: %i >= numlumps", lumpnum); + } + + return lumpinfo[lumpnum].size; +} + + +// +// W_ReadLump +// Loads the lump into the given buffer, +// which must be >= W_LumpLength(). +// +static void W_ReadLump(int lump, void *dest) +{ + int c; + lumpinfo_t *l; + + if (lump >= numlumps) + { + I_Error ("W_ReadLump: %i >= numlumps", lump); + } + + l = lumpinfo+lump; + + c = W_Read(current_file, l->position, dest, l->size); + + if (c < l->size) + { + I_Error ("W_ReadLump: only read %i of %i on lump %i", c, l->size, lump); + } +} + + +// +// W_LoadLump +// +// Load a lump into memory and return a pointer to a buffer containing +// the lump data. +// +byte * W_LoadLump(int lumpnum) +{ + byte *result; + + if (lumpnum < 0 || lumpnum >= numlumps) + { + I_Error ("W_LoadLump: %i >= numlumps", lumpnum); + } + + if (! current_file) + I_Error ("W_LoadLump: no current file (W_BeginRead not called)"); + + // load it now + + result = new byte[W_LumpLength(lumpnum) + 1]; + + W_ReadLump (lumpnum, result); + + return result; +} + + +void W_FreeLump(byte * data) +{ + delete[] data; +} + + +void W_BeginRead(void) +{ + // check API usage + if (! wad_filename) + I_Error("W_BeginRead called without any wad file!"); + + if (current_file) + I_Error("W_BeginRead called twice without W_EndRead."); + + current_file = W_OpenFile(wad_filename); + + // it should normally succeed, as it is unlikely the file suddenly + // disappears between reading the directory and loading a map. + if (! current_file) + I_Error("Could not re-open the wad file -- deleted?"); +} + + +void W_EndRead() +{ + if (! current_file) + I_Error("W_EndRead called without a previous W_BeginRead."); + + W_CloseFile(current_file); + + current_file = NULL; +} + + +} // namespace vpo + +//--- editor settings --- +// vi:ts=4:sw=4:noexpandtab +// Emacs style mode select -*- C++ -*- diff --git a/Source/Plugins/vpo_dll/w_wad.h b/Source/Plugins/vpo_dll/w_wad.h index 440bd7a7..1973f2d0 100644 --- a/Source/Plugins/vpo_dll/w_wad.h +++ b/Source/Plugins/vpo_dll/w_wad.h @@ -1,79 +1,84 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 2005 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// DESCRIPTION: -// WAD I/O functions. -// -//----------------------------------------------------------------------------- - - -#ifndef __W_WAD__ -#define __W_WAD__ - -#include - -#include "doomtype.h" -#include "w_file.h" - - -// -// TYPES -// - -// -// WADFILE I/O related stuff. -// - -typedef struct lumpinfo_s lumpinfo_t; - -struct lumpinfo_s -{ - char name[8]; - wad_file_t *wad_file; - int position; - int size; - bool is_map_header; // e.g. MAP01 or E1M1 - - // Used for hash table lookups - - lumpinfo_t *next; -}; - - -extern lumpinfo_t *lumpinfo; -extern unsigned int numlumps; - - -wad_file_t *W_AddFile (const char *filename); - -void W_RemoveFile(void); - - -int W_CheckNumForName (const char* name); -int W_GetNumForName (const char* name); - -int W_LumpLength (unsigned int lump); - -byte * W_LoadLump(int lumpnum); -void W_FreeLump(byte * data); - - -#endif // __W_WAD__ +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// WAD I/O functions. +// +//----------------------------------------------------------------------------- + +#ifndef __W_WAD__ +#define __W_WAD__ + +#include + +#include "doomtype.h" +#include "w_file.h" + + +// +// TYPES +// + +// +// WADFILE I/O related stuff. +// + +typedef struct lumpinfo_s lumpinfo_t; + +struct lumpinfo_s +{ + char name[8]; + + int position; + int size; + + bool is_map_header; // e.g. MAP01 or E1M1 + bool is_hexen; +}; + + +extern lumpinfo_t *lumpinfo; +extern int numlumps; + + +// andrewj: only a single file can be added now +bool W_AddFile (const char *filename); + +void W_RemoveFile(void); + + +int W_CheckNumForName (const char *name); + +int W_LumpLength (int lumpnum); + + +// andrewj: all lump loading must occur between these calls +void W_BeginRead(void); +void W_EndRead(); + +byte * W_LoadLump(int lumpnum); +void W_FreeLump(byte * data); + + +#endif /* __W_WAD__ */ + +//--- editor settings --- +// vi:ts=4:sw=4:noexpandtab +// Emacs style mode select -*- C++ -*-