SCORE.CPP 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316
  1. /*
  2. ** Command & Conquer(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: F:\projects\c&c\vcs\code\score.cpv 2.17 16 Oct 1995 16:49:54 JOE_BOSTIC $ */
  19. /***********************************************************************************************
  20. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : SCORE.CPP *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : April 19, 1994 *
  30. * *
  31. * Last Update : May 3, 1995 [BWG] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * Call_Back_Delay -- Combines Call_Back() and Delay() functions *
  36. * Draw_Bar_Graphs -- Draw "Casualties" bar graphs *
  37. * Draw_InfantryMan -- Draw one guy in score screen, update animation *
  38. * Draw_Infantrymen -- Draw all the guys on the score screen *
  39. * New_Infantry_Anim -- Start up a new animation for one of the infantrymen *
  40. * ScoreClass::Count_Up_Print -- Prints a number (up to its max) into a string, cleanly *
  41. * ScoreClass::Delay -- Pauses waiting for keypress. *
  42. * ScoreClass::DO_GDI_GRAPH -- Show # of people or buildings killed on GDI score screen *
  43. * ScoreClass::Presentation -- Main routine to display score screen. *
  44. * ScoreClass::Print_Graph_Title -- Prints title on score screen. *
  45. * ScoreClass::Print_Minutes -- Print out hours/minutes up to max *
  46. * ScoreClass::Pulse_Bar_Graph -- Pulses the bargraph color. *
  47. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  48. #include "function.h"
  49. #include "textblit.h"
  50. #define SCORETEXT_X 184
  51. #define SCORETEXT_Y 8
  52. #define CASUALTY_Y 88
  53. #define BUILDING_X 256
  54. #define BUILDING_Y 128
  55. #define BARGRAPH_X 266
  56. #define MAX_BAR_X 318 // max possible is 319 because of bar's right shadow
  57. #define SIZEGBAR 119
  58. #define HALLFAME_X 19
  59. #define HALLFAME_Y 120
  60. #define MULTISCOREX 30
  61. #define TEDIT_FAME 1
  62. #define NUMINFANTRYMEN 15
  63. #define NUMFAMENAMES 7
  64. #define MAX_FAMENAME_LENGTH 12
  65. struct InfantryAnim {
  66. int xpos;
  67. int ypos;
  68. void const *shapefile;
  69. void const *remap;
  70. int anim;
  71. int stage;
  72. char delay;
  73. InfantryTypeClass const *Class;
  74. } InfantryMan[NUMINFANTRYMEN];
  75. void Draw_InfantryMen(void);
  76. void Draw_InfantryMan(int index);
  77. void New_Infantry_Anim(int index, int anim);
  78. void Draw_Bar_Graphs(int i, int gkilled, int nkilled, int ckilled);
  79. void Animate_Cursor(int pos, int ypos);
  80. void Animate_Score_Objs(void);
  81. void Cycle_Wait_Click(void);
  82. int ScorePass;
  83. void const * Beepy6;
  84. int ControlQ; // cheat key to skip past score/mapsel screens
  85. bool StillUpdating;
  86. GraphicBufferClass *PseudoSeenBuff;
  87. GraphicBufferClass *TextPrintBuffer;
  88. #ifdef WRITE_LBM
  89. PUBLIC bool CCWrite_LBM_File(CCFileClass &lbmhandle, BufferClass& buff, short bitplanes, unsigned char *palette);
  90. #endif
  91. unsigned char RemapCiv[256]={
  92. 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
  93. 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0xD0,0x18,0x19,0xD1,0xD2,0xD3,0xD4,0x1E,0xD5,
  94. 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
  95. 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
  96. 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
  97. 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
  98. 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
  99. 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0xD6,0xD7,0xD8,0xD9,0x7E,0xDA,
  100. 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
  101. 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
  102. 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,
  103. 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
  104. 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
  105. 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xDB,0xDC,0xDD,0xDE,0xDB,0xDC,0xDD,0xDE,0xDF,
  106. 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
  107. 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF};
  108. unsigned char const ScoreRemapGrey[256] = {
  109. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0..15
  110. 16, 17, 18, 19, 20,176, 22,208, 24, 25,209,210,211,212, 30,213, // 16..31
  111. 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, // 32..47
  112. 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, // 48..63
  113. 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, // 64..79
  114. 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, // 80..95
  115. 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, // 96..111
  116. 112,113,114,115,116,117,118,119,120,121,214,215,216,217,149,218, // 112..127
  117. 128,129,130,131,132,133,134,135,136,137,138,108,140,141,142,143, // 128..143
  118. 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, // 144..159
  119. 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, // 160..175
  120. 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, // 176..191
  121. 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, // 192..207
  122. 208,209,210,211,212,213,214,219,220,221,222,219,220,221,222,223, // 208..223
  123. 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, // 224..239
  124. 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 // 240..255
  125. };
  126. unsigned char const ScoreRemapYellow[256] = {
  127. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0..15
  128. 16, 17, 18, 19, 20,176, 22,208, 24, 25,209,210,211,212, 30,213, // 16..31
  129. 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, // 32..47
  130. 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, // 48..63
  131. 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, // 64..79
  132. 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, // 80..95
  133. 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, // 96..111
  134. 112,113,114,115,116,117,118,119,120,121,214,215,216,217,149,218, // 112..127
  135. 128,129,130,131,132,133,134,135,136,137,138,108,140,141,142,143, // 128..143
  136. 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, // 144..159
  137. 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, // 160..175
  138. 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, // 176..191
  139. 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, // 192..207
  140. 208,209,210,211,212,213,214,219,220,221,222,219,220,221,222,223, // 208..223
  141. 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, // 224..239
  142. 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 // 240..255
  143. };
  144. unsigned char const ScoreRemapBldg[256]={
  145. 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
  146. 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
  147. 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
  148. 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
  149. 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
  150. 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
  151. 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
  152. 0x70,0x71,0xCE,0xC5,0x49,0x48,0x47,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,
  153. 0x80,0x81,0xB8,0x83,0x7C,0x7A,0x76,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
  154. 0x74,0x91,0x92,0x93,0x94,0x95,0xB5,0x97,0x98,0xCF,0x4B,0x7F,0x9C,0x9D,0x9E,0x9F,
  155. 0xA0,0xA1,0xA2,0x83,0x79,0xA5,0xA6,0xA7,0x43,0x99,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,
  156. 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
  157. 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
  158. 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xBB,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
  159. 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
  160. 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF
  161. };
  162. unsigned char const ScoreRemapFBall[256]={
  163. 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
  164. 0xB0,0xE5,0x82,0xE4,0xE3,0xE2,0xB1,0xD0,0xE1,0xE0,0xD1,0xD2,0xD3,0xD4,0xDF,0xD5,
  165. 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0xE6,0xE7,0xA0,0xE8,0x2E,0x2F,
  166. 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
  167. 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
  168. 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
  169. 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
  170. 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,
  171. 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
  172. 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
  173. 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,
  174. 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
  175. 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
  176. 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
  177. 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
  178. 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF
  179. };
  180. TextBlitClass BlitList;
  181. char *ScreenNames[2]={"S-GDIIN2.WSA","SCRSCN1.WSA"};
  182. //extern short StreamLowImpact;
  183. struct Fame {
  184. char name[MAX_FAMENAME_LENGTH];
  185. int score;
  186. int level;
  187. };
  188. ScoreAnimClass *ScoreObjs[MAXSCOREOBJS];
  189. ScoreAnimClass::ScoreAnimClass(int x, int y, void const * data)
  190. {
  191. BlitList.Add (x*2, y*2, x*2, y*2, 2* String_Pixel_Width ( (char*)data ) , 16);
  192. XPos = x;
  193. YPos = y;
  194. Timer.Set(0);
  195. Timer.Start();
  196. DataPtr = data;
  197. }
  198. ScoreTimeClass::ScoreTimeClass(int xpos, int ypos, void const * data, int max, int timer) :
  199. ScoreAnimClass(xpos, ypos, data)
  200. {
  201. Stage = 0;
  202. MaxStage = max;
  203. TimerReset = timer;
  204. }
  205. void ScoreTimeClass::Update(void)
  206. {
  207. GraphicViewPortClass *oldpage;
  208. if (!Timer.Time()) {
  209. Timer.Set(TimerReset);
  210. if (++Stage >= MaxStage) Stage = 0;
  211. oldpage = LogicPage;
  212. Set_Logic_Page(PseudoSeenBuff);
  213. CC_Draw_Shape(DataPtr, Stage, XPos, YPos, WINDOW_MAIN, SHAPE_WIN_REL, 0, 0);
  214. Set_Logic_Page(oldpage);
  215. }
  216. }
  217. ScoreCredsClass::ScoreCredsClass(int xpos, int ypos, void const * data, int max, int timer) :
  218. ScoreAnimClass(xpos, ypos, data)
  219. {
  220. Stage = 0;
  221. MaxStage = max;
  222. TimerReset = timer;
  223. Clock1 = MixFileClass::Retrieve("CLOCK1.AUD");
  224. CashTurn = MixFileClass::Retrieve("CASHTURN.AUD");
  225. }
  226. void ScoreCredsClass::Update(void)
  227. {
  228. GraphicViewPortClass *oldpage;
  229. if (!Timer.Time()) {
  230. Timer.Set(TimerReset);
  231. if (++Stage >= MaxStage) Stage = 0;
  232. oldpage = LogicPage;
  233. Set_Logic_Page(PseudoSeenBuff);
  234. if (Stage <22) {
  235. Play_Sample(Clock1, 255, Options.Normalize_Sound(70));
  236. } else {
  237. if (Stage==24) {
  238. Play_Sample(CashTurn, 255, Options.Normalize_Sound(70));
  239. }
  240. }
  241. CC_Draw_Shape(DataPtr,Stage, XPos, YPos, WINDOW_MAIN,SHAPE_WIN_REL, 0, 0);
  242. Set_Logic_Page(oldpage);
  243. }
  244. }
  245. ScorePrintClass::ScorePrintClass(int string, int xpos, int ypos, void const * palette, int background) :
  246. ScoreAnimClass(xpos, ypos, Text_String(string))
  247. {
  248. Background = background;
  249. PrimaryPalette = palette;
  250. Stage = 0;
  251. }
  252. ScorePrintClass::ScorePrintClass(void const * string, int xpos, int ypos, void const * palette, int background) :
  253. ScoreAnimClass(xpos, ypos, string)
  254. {
  255. Background = background;
  256. PrimaryPalette = palette;
  257. Stage = 0;
  258. }
  259. void ScorePrintClass::Update(void)
  260. {
  261. static char localstr[2]={0,0};
  262. static char _whitepal[]={0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F};
  263. if (Stage && (((char *)DataPtr)[Stage-1]==0) ) {
  264. for (int i = 0; i < MAXSCOREOBJS; i++) {
  265. if (ScoreObjs[i] == this) {
  266. ScoreObjs[i] = 0;
  267. }
  268. }
  269. BlitList.Add (XPos*2, YPos*2, XPos*2, YPos*2,(Stage*6)+14, 8*2);
  270. delete this;
  271. return;
  272. }
  273. StillUpdating = true;
  274. if (!Timer.Time()) {
  275. Timer.Set(1);
  276. int pos = XPos+(Stage*6);
  277. if (Stage) {
  278. localstr[0]=((char *)DataPtr)[Stage-1];
  279. /*
  280. ** Clear out the white letter overlay
  281. */
  282. static char const _blackpal[]={BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK};
  283. Set_Font_Palette(_blackpal);
  284. TextPrintBuffer->Print(localstr, 2*(pos-6),2*(YPos-1), TBLACK, TBLACK);
  285. TextPrintBuffer->Print(localstr, 2*(pos-6),2*(YPos+1), TBLACK, TBLACK);
  286. TextPrintBuffer->Print(localstr, 2*(pos-6+1),2*(YPos), TBLACK, TBLACK);
  287. Set_Font_Palette(PrimaryPalette);
  288. TextPrintBuffer->Print(localstr, 2*(pos-6),2*YPos, TBLACK, TBLACK);
  289. }
  290. if (((char *)DataPtr)[Stage]) {
  291. localstr[0]=((char *)DataPtr)[Stage];
  292. Set_Font_Palette(_whitepal);
  293. TextPrintBuffer->Print(localstr, pos*2, 2*(YPos-1), TBLACK, TBLACK);
  294. TextPrintBuffer->Print(localstr, pos*2, 2*(YPos+1), TBLACK, TBLACK);
  295. TextPrintBuffer->Print(localstr, (pos+1)*2,2*YPos , TBLACK, TBLACK);
  296. }
  297. Stage++;
  298. }
  299. }
  300. MultiStagePrintClass::MultiStagePrintClass(int string, int xpos, int ypos, void const * palette, int background) :
  301. ScoreAnimClass(xpos, ypos, Text_String(string))
  302. {
  303. Background = background;
  304. PrimaryPalette = palette;
  305. Stage = 0;
  306. }
  307. MultiStagePrintClass::MultiStagePrintClass(void const * string, int xpos, int ypos, void const * palette, int background) :
  308. ScoreAnimClass(xpos, ypos, string)
  309. {
  310. Background = background;
  311. PrimaryPalette = palette;
  312. Stage = 0;
  313. }
  314. void MultiStagePrintClass::Update(void)
  315. {
  316. static char localstr[2]={0,0};
  317. static char _whitepal[]={0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F};
  318. if (Stage && (((char *)DataPtr)[Stage-1]==0) ) {
  319. for (int i = 0; i < MAXSCOREOBJS; i++) {
  320. if (ScoreObjs[i] == this) {
  321. ScoreObjs[i] = 0;
  322. }
  323. }
  324. BlitList.Add (XPos*2, YPos*2, XPos*2, YPos*2,(Stage*6)+14, 8*2);
  325. delete this;
  326. return;
  327. }
  328. StillUpdating = true;
  329. if (!Timer.Time()) {
  330. Timer.Set(1);
  331. /*
  332. ** Do 10 stages at once
  333. */
  334. for (int wibble = 0 ; wibble < 10 ; wibble ++){
  335. int pos = XPos+(Stage*6);
  336. if (Stage) {
  337. localstr[0]=((char *)DataPtr)[Stage-1];
  338. /*
  339. ** Clear out the white letter overlay
  340. */
  341. static char const _blackpal[]={BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK};
  342. Set_Font_Palette(_blackpal);
  343. TextPrintBuffer->Print(localstr, 2*(pos-6),2*(YPos-1), TBLACK, TBLACK);
  344. TextPrintBuffer->Print(localstr, 2*(pos-6),2*(YPos+1), TBLACK, TBLACK);
  345. TextPrintBuffer->Print(localstr, 2*(pos-6+1),2*(YPos), TBLACK, TBLACK);
  346. Set_Font_Palette(PrimaryPalette);
  347. TextPrintBuffer->Print(localstr, 2*(pos-6),2*YPos, TBLACK, TBLACK);
  348. }
  349. if (((char *)DataPtr)[Stage]) {
  350. localstr[0]=((char *)DataPtr)[Stage];
  351. Set_Font_Palette(_whitepal);
  352. TextPrintBuffer->Print(localstr, pos*2, 2*(YPos-1), TBLACK, TBLACK);
  353. TextPrintBuffer->Print(localstr, pos*2, 2*(YPos+1), TBLACK, TBLACK);
  354. TextPrintBuffer->Print(localstr, (pos+1)*2,2*YPos , TBLACK, TBLACK);
  355. }
  356. Stage++;
  357. if ( ( (char *) DataPtr) [Stage-1] == 0 ) break;
  358. }
  359. }
  360. }
  361. ScoreScaleClass::ScoreScaleClass(void const * string, int xpos, int ypos, char const palette[]) :
  362. ScoreAnimClass(xpos, ypos, string)
  363. {
  364. Palette = &palette[0];
  365. Stage = 5;
  366. }
  367. void ScoreScaleClass::Update(void)
  368. {
  369. static int _destx[]={0,80,107,134,180,228};
  370. static int _destw[]={6,20, 30, 40, 60, 80};
  371. /*
  372. ** Restore the background for the scaled-up letter
  373. */
  374. if (!Timer.Time()) {
  375. Timer.Set(1);
  376. if (Stage != 5) {
  377. TextPrintBuffer->Blit(HidPage, _destx[Stage+1]*2, YPos*2, _destx[Stage+1]*2, YPos*2, _destw[Stage+1]*2, _destw[Stage+1]*2);
  378. //SysMemPage.Blit(*PseudoSeenBuff, _destx[Stage+1], YPos, _destx[Stage+1], YPos, _destw[Stage+1], _destw[Stage+1]);
  379. }
  380. if (Stage) {
  381. Set_Font_Palette(Palette);
  382. TextPrintBuffer->Fill_Rect(0,0, 7*2,7*2, TBLACK);
  383. TextPrintBuffer->Print((char *)DataPtr, 0,0, TBLACK, TBLACK);
  384. TextPrintBuffer->Scale(HidPage, 0,0, _destx[Stage]*2, YPos*2, 5*2,5*2, _destw[Stage]*2, _destw[Stage]*2, true);
  385. //SysMemPage.Fill_Rect(0,0, 7,7, TBLACK);
  386. //SysMemPage.Print((char *)DataPtr, 0,0, TBLACK, TBLACK);
  387. //SysMemPage.Scale(*PseudoSeenBuff, 0,0, _destx[Stage], YPos, 5,5, _destw[Stage], _destw[Stage], true);
  388. Stage--;
  389. } else {
  390. Set_Font_Palette(Palette);
  391. for (int i = 0; i < MAXSCOREOBJS; i++) {
  392. if (ScoreObjs[i]==this) ScoreObjs[i] = 0;
  393. }
  394. TextPrintBuffer->Print((char *)DataPtr, XPos*2,YPos*2, TBLACK, TBLACK);
  395. //TextPrintBuffer->Blit(HidPage, XPos*2, YPos*2, XPos*2, YPos*2,2*6,2*6);
  396. //BlitList.Add (XPos, YPos, XPos, YPos, 6,6);
  397. //SysMemPage.Print((char *)DataPtr, XPos,YPos, TBLACK, TBLACK);
  398. //SysMemPage.Blit(*PseudoSeenBuff, XPos,YPos, XPos, YPos, 6,6);
  399. delete this;
  400. return;
  401. }
  402. }
  403. }
  404. int Alloc_Object(ScoreAnimClass *obj)
  405. {
  406. int i,ret;
  407. for (i = ret = 0; i < MAXSCOREOBJS; i++) {
  408. if (!ScoreObjs[i]) {
  409. ScoreObjs[i] = obj;
  410. ret = i;
  411. break;
  412. }
  413. }
  414. return(ret);
  415. }
  416. TextBlitClass::TextBlitClass (void)
  417. {
  418. Clear();
  419. }
  420. void TextBlitClass::Add (int x, int y, int dx, int dy, int w, int h)
  421. {
  422. if ( Count < MAX_ENTRIES ){
  423. BlitListo [Count].SourceX = x;
  424. BlitListo [Count].SourceY = y;
  425. BlitListo [Count].DestX = dx;
  426. BlitListo [Count].DestY = dy;
  427. BlitListo [Count].Width = w;
  428. BlitListo [Count].Height = h;
  429. Count++;
  430. }
  431. }
  432. void TextBlitClass::Clear(void)
  433. {
  434. Count = 0;
  435. }
  436. void TextBlitClass::Update(void)
  437. {
  438. if (TextPrintBuffer){
  439. if (HidPage.Lock()){
  440. for (int i=0 ; i<Count ; i++){
  441. TextPrintBuffer->Blit (HidPage, BlitListo[i].SourceX,
  442. BlitListo[i].SourceY,
  443. BlitListo[i].DestX,
  444. BlitListo[i].DestY,
  445. BlitListo[i].Width,
  446. BlitListo[i].Height,
  447. true);
  448. }
  449. HidPage.Unlock();
  450. }
  451. }
  452. }
  453. void Disable_Uncompressed_Shapes (void);
  454. void Enable_Uncompressed_Shapes (void);
  455. /***********************************************************************************************
  456. * ScoreClass::Presentation -- Main routine to display score screen. *
  457. * *
  458. * This is the main routine that displays the score screen graphics. *
  459. * It gets called at the end of each scenario and is used to present *
  460. * the results and a rating of the player's battle. *
  461. * *
  462. * INPUT: none *
  463. * *
  464. * OUTPUT: none *
  465. * *
  466. * WARNINGS: none *
  467. * *
  468. * HISTORY: *
  469. * 05/02/1994 : Created. *
  470. *=============================================================================================*/
  471. void ScoreClass::Presentation(void)
  472. {
  473. //static char const _redpal[]={0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x21,0x2F};
  474. static char const _redpal[]={0x20,0x22,0x24,0x26,0x28,0x28,0x28,0x28,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x21,0x2F};
  475. static char const _greenpal[]={0x10,0x12,0x14,0x16,0x18,0x18,0x18,0x18,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x10,0x1F};
  476. static char const _bluepal[]={0x60,0x62,0x64,0x66,0x68,0x68,0x68,0x68,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x61,0x6F};
  477. //static char const _bluepal[]={0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x61,0x6F};
  478. static char const _yellowpal[]={0x0,0x0,0xEC,0x0,0xEB,0x0,0xEA,0x0,0xE9,0x0,0x0,0x0,0x0,0x0,0xED,0x0};
  479. static int const _casuax[2]={144,146};
  480. static int const _casuay[2]={ 78, 90};
  481. static int const _gditxx[2]={150,224};
  482. static int const _gditxy[2]={ 90, 90};
  483. static int const _nodtxx[2]={150,224};
  484. static int const _nodtxy[2]={102,102};
  485. // static int _bargrx[2]={297,SCORETEXT_X+64};
  486. // static int _bargry[2]={ 90,CASUALTY_Y + 2};
  487. static int const _bldggy[2]={138,128};
  488. static int const _bldgny[2]={150,140};
  489. // int gdikilled, nodkilled, civkilled, max, i, k, shapenum;
  490. int i;
  491. int max;
  492. void const * yellowptr;
  493. void const * redptr;
  494. CCFileClass file(FAME_FILE_NAME);
  495. struct Fame hallfame[NUMFAMENAMES];
  496. void *anim, *oldfont;
  497. int oldfontxspacing = FontXSpacing;
  498. int house = PlayerPtr->Class->House; // 0 or 1
  499. char inter_pal[15];
  500. /*
  501. ** Choose an appropriate palette file for the interpolation
  502. */
  503. if (house == HOUSE_GOOD){
  504. sprintf(inter_pal,"SCORPAL1.PAL");
  505. }else{
  506. sprintf(inter_pal,"SNODPAL1.PAL");
  507. }
  508. if (Special.IsJurassic && AreThingiesEnabled) return;
  509. PseudoSeenBuff = new GraphicBufferClass(320,200,(void*)NULL);
  510. TextPrintBuffer = new GraphicBufferClass(SeenBuff.Get_Width(), SeenBuff.Get_Height(), (void*)NULL);
  511. TextPrintBuffer->Clear();
  512. BlitList.Clear();
  513. Disable_Uncompressed_Shapes ();
  514. ControlQ = 0;
  515. FontXSpacing = 0;
  516. Map.Override_Mouse_Shape(MOUSE_NORMAL);
  517. Theme.Queue_Song(THEME_WIN1);
  518. VisiblePage.Clear();
  519. PseudoSeenBuff->Clear();
  520. SysMemPage.Clear();
  521. WWMouse->Erase_Mouse(&HidPage, TRUE);
  522. HiddenPage.Clear();
  523. Set_Palette(BlackPalette);
  524. Set_Logic_Page(SysMemPage);
  525. void const * country4 = MixFileClass::Retrieve("COUNTRY4.AUD");
  526. void const * sfx4 = MixFileClass::Retrieve("SFX4.AUD");
  527. Beepy6 = MixFileClass::Retrieve("BEEPY6.AUD");
  528. /*
  529. ** Load the background for the score screen
  530. */
  531. anim = Open_Animation(ScreenNames[house],NULL,0L,(WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE),Palette);
  532. unsigned minutes = (unsigned)((ElapsedTime / (long)TIMER_MINUTE))+1;
  533. /*
  534. ** Determine leadership rating.
  535. */
  536. unsigned leadership = 0;
  537. for (int index = 0; index < Logic.Count(); index++) {
  538. ObjectClass * object = Logic[index];
  539. if (object->Owner() == house) {
  540. leadership++;
  541. }
  542. }
  543. HouseClass *houses[3];
  544. for (index = 0; index < 3; index++) {
  545. houses[index] =(HouseClass::As_Pointer((HousesType)(HOUSE_GOOD+index)));
  546. }
  547. GKilled = (HouseClass::As_Pointer(HOUSE_GOOD))->UnitsLost;
  548. NKilled = (HouseClass::As_Pointer(HOUSE_BAD))->UnitsLost;
  549. CKilled = (HouseClass::As_Pointer(HOUSE_NEUTRAL))->UnitsLost;
  550. GBKilled = (HouseClass::As_Pointer(HOUSE_GOOD))->BuildingsLost;
  551. NBKilled = (HouseClass::As_Pointer(HOUSE_BAD))->BuildingsLost;
  552. CBKilled = (HouseClass::As_Pointer(HOUSE_NEUTRAL))->BuildingsLost;
  553. /*
  554. ** New - ST 6/12/96 2:40PM
  555. */
  556. GHarvested = (HouseClass::As_Pointer(HOUSE_GOOD))->HarvestedCredits;
  557. NHarvested = (HouseClass::As_Pointer(HOUSE_BAD))->HarvestedCredits;
  558. if (!leadership) leadership++;
  559. leadership = Cardinal_To_Fixed(GKilled+GBKilled+leadership, leadership);
  560. leadership = Fixed_To_Cardinal(100, leadership);
  561. if (leadership > 100) leadership = 100;
  562. /*
  563. ** Determine efficiency rating.
  564. */
  565. int gharv = GHarvested;
  566. int init = PlayerPtr->InitialCredits;
  567. int cred = PlayerPtr->Available_Money();
  568. unsigned efficiency = Cardinal_To_Fixed( (house == HOUSE_GOOD ? GHarvested : NHarvested) + (unsigned)PlayerPtr->InitialCredits+1, (unsigned)PlayerPtr->Available_Money()+1);
  569. if (!efficiency) efficiency++;
  570. efficiency = Fixed_To_Cardinal(100, efficiency);
  571. if (efficiency > 100) efficiency = 100;
  572. /*
  573. ** Calculate total score
  574. */
  575. long total = ((leadership * 40) + (4600) + (efficiency * 14))/100;
  576. if (!total) total++;
  577. total *= (BuildLevel+1);
  578. // Load up the shapes for the Nod score screen
  579. if (house == HOUSE_GOOD) {
  580. yellowptr = MixFileClass::Retrieve("BAR3YLW.SHP");
  581. redptr = MixFileClass::Retrieve("BAR3RED.SHP");
  582. }
  583. /* Change to the six-point font for Text_Print */
  584. oldfont = Set_Font(ScoreFontPtr);
  585. Call_Back();
  586. /* --- Now display the background animation --- */
  587. Hide_Mouse();
  588. Animate_Frame(anim, SysMemPage, 1);
  589. SysMemPage.Blit(*PseudoSeenBuff);
  590. Increase_Palette_Luminance (Palette , 30,30,30,63);
  591. InterpolationPalette = Palette;
  592. InterpolationPaletteChanged = TRUE;
  593. Read_Interpolation_Palette(inter_pal);
  594. Interpolate_2X_Scale( PseudoSeenBuff , &SeenBuff , inter_pal);
  595. Fade_Palette_To(Palette, FADE_PALETTE_FAST, Call_Back);
  596. Play_Sample(country4, 255, Options.Normalize_Sound(90));
  597. int frame = 1;
  598. StreamLowImpact = true;
  599. while (frame < Get_Animation_Frame_Count(anim)) {
  600. Animate_Frame(anim, *PseudoSeenBuff, frame++);
  601. ////////////////Interpolate_2X_Scale( PseudoSeenBuff , &SeenBuff , NULL);
  602. Call_Back_Delay(2);
  603. }
  604. StreamLowImpact = false;
  605. Call_Back();
  606. Close_Animation(anim);
  607. /*
  608. ** Background's up, so now load various shapes and animations
  609. */
  610. void const * timeshape = MixFileClass::Retrieve("TIME.SHP");
  611. ScoreObjs[0] = new ScoreTimeClass(233, 2, timeshape, 30, 4);
  612. void const * hiscore1shape = MixFileClass::Retrieve("HISCORE1.SHP");
  613. void const * hiscore2shape = MixFileClass::Retrieve("HISCORE2.SHP");
  614. ScoreObjs[1] = new ScoreTimeClass(4, 97, hiscore1shape, 10, 4);
  615. ScoreObjs[2] = new ScoreTimeClass(8, 172, hiscore2shape, 10, 4);
  616. /* Now display the stuff */
  617. PseudoSeenBuff->Blit(SysMemPage);
  618. if (house == HOUSE_BAD) {
  619. /*
  620. ** load the logo
  621. */
  622. void const * logoptr = MixFileClass::Retrieve("LOGOS.SHP");
  623. CC_Draw_Shape(logoptr, 1, 0, 0, WINDOW_MAIN, SHAPE_WIN_REL, 0, 0);
  624. Bit_It_In_Scale(0,0, 128,104-16, &SysMemPage, PseudoSeenBuff, &SeenBuff , 1);
  625. }
  626. Set_Logic_Page(PseudoSeenBuff);
  627. #ifdef FRENCH
  628. Alloc_Object(new ScorePrintClass(TXT_SCORE_TIME, 200, 3,_greenpal));
  629. #else
  630. Alloc_Object(new ScorePrintClass(TXT_SCORE_TIME, 206, 3,_greenpal));
  631. #endif
  632. Alloc_Object(new ScorePrintClass(TXT_SCORE_LEAD, 182, 26,_greenpal));
  633. Alloc_Object(new ScorePrintClass(TXT_SCORE_EFFI, 182, 38,_greenpal));
  634. Alloc_Object(new ScorePrintClass(TXT_SCORE_TOTA, 182, 50,_greenpal));
  635. Play_Sample(sfx4, 255, Options.Normalize_Sound(120));
  636. Call_Back_Delay(13);
  637. max = MAX((long)leadership, (long)efficiency);
  638. int scorecounter = 0;
  639. Keyboard::Clear();
  640. BlitList.Add (264*2, 26*2, 264*2, 26*2, 4*12 , 12);
  641. BlitList.Add (264*2, 38*2, 264*2, 38*2, 4*12 , 12);
  642. BlitList.Add (264*2, 50*2, 264*2, 50*2, 4*12 , 12);
  643. BlitList.Add (275*2, 9*2, 275*2, 9*2, 64, 12 ); //Minutes
  644. for (i = 0; i <= 160; i++) {
  645. Set_Font_Palette(_greenpal);
  646. Count_Up_Print("%3d%%", i, leadership, 264, 26);
  647. if (i>=30) Count_Up_Print("%3d%%", i-30, efficiency, 264, 38);
  648. if (i>=60) {
  649. Count_Up_Print("%3d",scorecounter, total, 264, 50);
  650. scorecounter += total/100;
  651. }
  652. Print_Minutes(minutes);
  653. Call_Back_Delay(1);
  654. Play_Sample(Beepy6, 255, Options.Normalize_Sound(60));
  655. if (Check_Key() && i < (max-5) ) {
  656. i=158;
  657. Keyboard::Clear();
  658. }
  659. }
  660. Count_Up_Print("%3d", total, total, 264, 50);
  661. Call_Back_Delay(60);
  662. if (house == HOUSE_BAD) Show_Credits(house, _greenpal);
  663. Call_Back_Delay(60);
  664. /*
  665. ** Show stats on # of units killed
  666. */
  667. Set_Logic_Page(*PseudoSeenBuff);
  668. Play_Sample(sfx4, 255, Options.Normalize_Sound(90));
  669. Alloc_Object(new ScorePrintClass(TXT_SCORE_CASU, _casuax[house], _casuay[house],_redpal));
  670. Call_Back_Delay(9);
  671. if (house == HOUSE_BAD) {
  672. Alloc_Object(new ScorePrintClass(TXT_SCORE_NEUT, 200, 114,_redpal));
  673. Call_Back_Delay(4);
  674. }
  675. Alloc_Object(new ScorePrintClass(TXT_SCORE_GDI, _gditxx[house], _gditxy[house],_redpal));
  676. Alloc_Object(new ScorePrintClass(TXT_SCORE_NOD, _nodtxx[house], _nodtxy[house],_redpal));
  677. Call_Back_Delay(6);
  678. Set_Font_Palette(_redpal);
  679. if (house == HOUSE_BAD) {
  680. Do_Nod_Casualties_Graph();
  681. } else {
  682. Do_GDI_Graph(yellowptr, redptr, GKilled + CKilled, NKilled, 88);
  683. }
  684. Set_Logic_Page(*PseudoSeenBuff);
  685. /*
  686. ** Print out stats on buildings destroyed
  687. */
  688. Play_Sample(sfx4, 255, Options.Normalize_Sound(90));
  689. if (house == HOUSE_GOOD) {
  690. Alloc_Object(new ScorePrintClass(TXT_SCORE_BUIL, 144, 126,_greenpal));
  691. Call_Back_Delay(9);
  692. } else {
  693. Alloc_Object(new ScorePrintClass(TXT_SCORE_BUIL1, 146, 128,_greenpal));
  694. Alloc_Object(new ScorePrintClass(TXT_SCORE_BUIL2, 146, 136,_greenpal));
  695. Call_Back_Delay(9);
  696. Alloc_Object(new ScorePrintClass(TXT_SCORE_NEUT, 200, 152,_greenpal));
  697. Call_Back_Delay(4);
  698. }
  699. Alloc_Object(new ScorePrintClass(TXT_SCORE_GDI, _gditxx[house], _bldggy[house],_greenpal));
  700. Alloc_Object(new ScorePrintClass(TXT_SCORE_NOD, _gditxx[house], _bldgny[house],_greenpal));
  701. Call_Back_Delay(7);
  702. if (house==HOUSE_BAD) {
  703. Call_Back_Delay(6);
  704. Set_Font_Palette(_greenpal);
  705. Do_Nod_Buildings_Graph();
  706. } else {
  707. Do_GDI_Graph(yellowptr, redptr, GBKilled + CBKilled, NBKilled, 136);
  708. }
  709. // Wait for text printing to complete
  710. while (StillUpdating){
  711. Call_Back_Delay(1);
  712. }
  713. if (Keyboard::Check()) Keyboard::Clear();
  714. if (house == HOUSE_GOOD) Show_Credits(house, _greenpal);
  715. /*
  716. ** Hall of fame display and processing
  717. */
  718. Play_Sample(sfx4, 255, Options.Normalize_Sound(90));
  719. Alloc_Object(new ScorePrintClass(TXT_SCORE_TOP, 28, 110,_bluepal));
  720. Call_Back_Delay(9);
  721. /*
  722. ** First check for the existence of the file, and if there isn't one,
  723. ** make a new one filled with blanks.
  724. */
  725. if (!file.Is_Available()) {
  726. // hall of fame doesn't exist, so blank it out & write it
  727. file.Open(WRITE);
  728. for (i = 0; i < NUMFAMENAMES; i++) {
  729. hallfame[i].name[0] =
  730. hallfame[i].score =
  731. hallfame[i].level = 0;
  732. file.Write(&hallfame[i], sizeof(struct Fame));
  733. }
  734. file.Close();
  735. }
  736. file.Open(READ);
  737. for (i = 0; i < NUMFAMENAMES; i++) {
  738. file.Read(&hallfame[i], sizeof(struct Fame));
  739. }
  740. file.Close();
  741. /*
  742. ** If the player's score is good enough to bump someone off the list,
  743. ** remove their data, move everyone down a notch, and set index = where
  744. ** their info goes
  745. */
  746. if(hallfame[NUMFAMENAMES-1].score >= total)
  747. hallfame[NUMFAMENAMES-1].score = 0;
  748. for (index = 0; index < NUMFAMENAMES; index++) {
  749. if (total > hallfame[index].score) {
  750. if (index < (NUMFAMENAMES-1)) for (i = (NUMFAMENAMES-1); i > index; i--) hallfame[i] = hallfame[i-1];
  751. hallfame[index].score = total;
  752. hallfame[index].level = Scenario;
  753. // hallfame[index].level = BuildLevel;
  754. //hallfame[index].name[0] = 0; // blank out the name
  755. memset (hallfame[index].name, ' ', sizeof (hallfame[index].name) -1);
  756. hallfame[index].name[sizeof (hallfame[index].name)-1] = 0;
  757. break;
  758. }
  759. }
  760. /*
  761. ** Now display the hall of fame
  762. */
  763. Set_Logic_Page(*PseudoSeenBuff);
  764. for (i = 0; i < NUMFAMENAMES; i++) {
  765. Alloc_Object(new ScorePrintClass(hallfame[i].name, HALLFAME_X, HALLFAME_Y + (i*8), _bluepal));
  766. if (hallfame[i].score) {
  767. char *str = (char *)(SysMemPage.Get_Buffer()) + i*32;
  768. sprintf(str,"%d", hallfame[i].score);
  769. Alloc_Object(new ScorePrintClass(str, HALLFAME_X+(6*15), HALLFAME_Y + (i*8), _bluepal, BLACK));
  770. if (hallfame[i].level < 20) {
  771. sprintf(str+16,"%d", hallfame[i].level);
  772. } else {
  773. strcpy(str+16, "**");
  774. }
  775. Alloc_Object(new ScorePrintClass(str+16, HALLFAME_X+(6*12), HALLFAME_Y + (i*8), _bluepal, BLACK));
  776. Call_Back_Delay(13);
  777. }
  778. }
  779. // Wait for text printing to complete
  780. while (StillUpdating){
  781. Call_Back_Delay(1);
  782. }
  783. /*
  784. ** If the player's on the hall of fame, have him enter his name now
  785. */
  786. Keyboard::Clear();
  787. if (index < NUMFAMENAMES) {
  788. Input_Name(hallfame[index].name, HALLFAME_X, HALLFAME_Y + (index*8), _bluepal);
  789. file.Open(WRITE);
  790. for (i = 0; i < NUMFAMENAMES; i++) {
  791. file.Write(&hallfame[i], sizeof(struct Fame));
  792. }
  793. file.Close();
  794. } else {
  795. #ifdef FRENCH
  796. Alloc_Object(new ScorePrintClass(TXT_MAP_CLICK2, 145, 190, _yellowpal));
  797. #else
  798. Alloc_Object(new ScorePrintClass(TXT_MAP_CLICK2, 149, 190, _yellowpal));
  799. #endif
  800. Cycle_Wait_Click();
  801. }
  802. #ifdef WRITE_LBM
  803. file.Open("e:scorscrn.lbm",WRITE);
  804. SeenBuff.Blit(SysMemPage,0,0, 0,0, 320,200);
  805. CCWrite_LBM_File(file, SysMemPage, 8, Palette);
  806. file.Close();
  807. #endif
  808. Keyboard::Clear();
  809. /* get rid of all the animating objects */
  810. for (i = 0; i < MAXSCOREOBJS; i++) if (ScoreObjs[i]) {
  811. delete ScoreObjs[i];
  812. ScoreObjs[i] = 0;
  813. }
  814. Fade_Palette_To(BlackPalette, FADE_PALETTE_FAST, NULL);
  815. VisiblePage.Clear();
  816. Show_Mouse();
  817. // Map_Selection();
  818. Theme.Queue_Song(THEME_NONE);
  819. Fade_Palette_To(BlackPalette, FADE_PALETTE_FAST, NULL);
  820. VisiblePage.Clear();
  821. Set_Palette(GamePalette);
  822. Set_Font(oldfont);
  823. FontXSpacing = oldfontxspacing;
  824. ControlQ = 0;
  825. Set_Logic_Page (SeenBuff);
  826. delete PseudoSeenBuff;
  827. delete TextPrintBuffer;
  828. TextPrintBuffer = NULL;
  829. BlitList.Clear();
  830. Enable_Uncompressed_Shapes();
  831. }
  832. void Cycle_Wait_Click(void)
  833. {
  834. int counter;
  835. int minclicks = 20;
  836. unsigned long timingtime = TickCount.Time();
  837. SerialPacketType sendpacket;
  838. SerialPacketType receivepacket;
  839. int packetlen;
  840. Keyboard::Clear();
  841. while (minclicks || (!Check_Key() && !ControlQ) ) {
  842. if (GameToPlay == GAME_NULL_MODEM ||
  843. GameToPlay == GAME_MODEM){
  844. //GameToPlay == GAME_INTERNET) {
  845. //
  846. // send a timing packet if enough time has gone by.
  847. //
  848. if ( (TickCount.Time() - timingtime) > PACKET_TIMING_TIMEOUT) {
  849. sendpacket.Command = SERIAL_SCORE_SCREEN;
  850. sendpacket.ResponseTime = NullModem.Response_Time();
  851. sendpacket.ID = ModemGameToPlay;
  852. NullModem.Send_Message (&sendpacket, sizeof(sendpacket), 0);
  853. timingtime = TickCount.Time();
  854. }
  855. if (NullModem.Get_Message (&receivepacket, &packetlen) > 0) {
  856. // throw packet away
  857. packetlen = packetlen;
  858. }
  859. NullModem.Service();
  860. }
  861. Call_Back_Delay(1);
  862. if (minclicks) {
  863. minclicks--;
  864. Keyboard::Clear();
  865. }
  866. counter = ((++counter) & 7);
  867. if (!counter) {
  868. unsigned char r,g,b;
  869. r = Palette[233*3+0];
  870. g = Palette[233*3+1];
  871. b = Palette[233*3+2];
  872. for (int i = 233; i < 237; i++) {
  873. Palette[i*3+0] = Palette[(i+1)*3+0];
  874. Palette[i*3+1] = Palette[(i+1)*3+1];
  875. Palette[i*3+2] = Palette[(i+1)*3+2];
  876. }
  877. Palette[237*3+0] = r;
  878. Palette[237*3+1] = g;
  879. Palette[237*3+2] = b;
  880. Set_Palette(Palette);
  881. }
  882. }
  883. Keyboard::Clear();
  884. }
  885. void ScoreClass::Do_Nod_Buildings_Graph(void)
  886. {
  887. int shapenum;
  888. InfantryTypeClass const *ramboclass;
  889. void const * factptr = MixFileClass::Retrieve("FACT.SHP");
  890. void const * rmboptr = MixFileClass::Retrieve("RMBO.SHP");
  891. void const * fball1ptr = MixFileClass::Retrieve("FBALL1.SHP");
  892. ramboclass = &InfantryTypeClass::As_Reference(INFANTRY_E5);
  893. /*
  894. ** Print the # of buildings on the hidpage so we only need to do it once
  895. */
  896. PseudoSeenBuff->Blit(SysMemPage);
  897. Set_Logic_Page(SysMemPage);
  898. Call_Back_Delay(30);
  899. BlitList.Add (2* (BUILDING_X + 8), 2* (BUILDING_Y), 2* (BUILDING_X+8), 2* (BUILDING_Y), 5*12 , 12);
  900. BlitList.Add (2* (BUILDING_X + 8), 2* (BUILDING_Y + 12), 2* (BUILDING_X+8), 2* (BUILDING_Y + 12), 5*12 , 12);
  901. BlitList.Add (2* (BUILDING_X + 8), 2* (BUILDING_Y + 24), 2* (BUILDING_X+8), 2* (BUILDING_Y + 24), 5*12 , 12);
  902. TextPrintBuffer->Print( 0, (BUILDING_X + 8)*2, BUILDING_Y*2, TBLACK, TBLACK);
  903. TextPrintBuffer->Print( 0, (BUILDING_X + 8)*2, (BUILDING_Y + 12)*2, TBLACK, TBLACK);
  904. TextPrintBuffer->Print( 0, (BUILDING_X + 8)*2, (BUILDING_Y + 24)*2, TBLACK, TBLACK);
  905. /*
  906. ** Here's the animation/draw loop for blowing up the factory
  907. */
  908. for (int i=0; i<98; i++) {
  909. SysMemPage.Blit(SysMemPage, BUILDING_X, BUILDING_Y, 0, 0, 320-BUILDING_X,48);
  910. shapenum = 0; // no damage
  911. if (i >= 60) {
  912. shapenum = Extract_Shape_Count(factptr) - 2; // some damage
  913. if (i == 60) {
  914. Shake_Screen(6);
  915. Sound_Effect(VOC_CRUMBLE, VOL_FULL, 0);
  916. }
  917. if (i > 65) {
  918. shapenum = Extract_Shape_Count(factptr) - 1; // mega damage
  919. }
  920. }
  921. /*
  922. ** Draw the building before Rambo
  923. */
  924. if (i < 68) {
  925. CC_Draw_Shape(factptr,shapenum, 0, 0, WINDOW_MAIN,
  926. SHAPE_FADING|SHAPE_WIN_REL, ScoreRemapBldg,Map.UnitShadow);
  927. }
  928. /*
  929. ** Now draw some fires, if appropriate
  930. */
  931. if (i >= 61) {
  932. int firecount = Extract_Shape_Count(fball1ptr);
  933. int shapeindex = (i-61)>>1;
  934. if (shapeindex < firecount) {
  935. CC_Draw_Shape(fball1ptr, shapeindex, 10, 10, WINDOW_MAIN,
  936. SHAPE_FADING|SHAPE_CENTER|SHAPE_WIN_REL,//|SHAPE_GHOST,
  937. ScoreRemapFBall,0);
  938. }
  939. if (i > 64) {
  940. shapeindex = (i-64)>>1;
  941. if (shapeindex < firecount) {
  942. CC_Draw_Shape(fball1ptr, shapeindex, 50, 30, WINDOW_MAIN,
  943. SHAPE_FADING|SHAPE_CENTER|SHAPE_WIN_REL,//|SHAPE_GHOST,
  944. ScoreRemapFBall,0);
  945. }
  946. }
  947. }
  948. /*
  949. ** Draw the Rambo character running away from the building
  950. */
  951. CC_Draw_Shape(rmboptr, (ramboclass->DoControls[DO_WALK].Frame + ramboclass->DoControls[DO_WALK].Jump*6) + ((i>>1)%ramboclass->DoControls[DO_WALK].Count),
  952. i+32, 40, WINDOW_MAIN,
  953. SHAPE_FADING|SHAPE_CENTER|SHAPE_WIN_REL,//|SHAPE_GHOST,
  954. ScoreRemapYellow,Map.UnitShadow);
  955. SysMemPage.Blit(*PseudoSeenBuff, 0, 0, BUILDING_X, BUILDING_Y, 320-BUILDING_X,48);
  956. /*
  957. ** Extra font related stuff. ST - 7/29/96 2:22PM
  958. */
  959. Interpolate_2X_Scale(PseudoSeenBuff , &HidPage ,NULL);
  960. BlitList.Update();
  961. WWMouse->Draw_Mouse(&HidPage);
  962. HidPage.Blit(SeenBuff);
  963. WWMouse->Erase_Mouse(&HidPage, TRUE);
  964. //Interpolate_2X_Scale( PseudoSeenBuff , &SeenBuff , NULL);
  965. if (!Check_Key()) Call_Back_Delay(1);
  966. }
  967. i = MAX(GBKilled, NBKilled);
  968. i = MAX(i, CBKilled);
  969. for (int q = 0; q <= i; q++) {
  970. Count_Up_Print( "%d", q, GBKilled,BUILDING_X + 8,BUILDING_Y );
  971. Count_Up_Print( "%d", q, NBKilled,BUILDING_X + 8,BUILDING_Y + 12);
  972. Count_Up_Print( "%d", q, CBKilled,BUILDING_X + 8,BUILDING_Y + 24);
  973. if (!Check_Key()) {
  974. Play_Sample(Beepy6, 255, Options.Normalize_Sound(110));
  975. Call_Back_Delay(1);
  976. }
  977. }
  978. }
  979. /***************************************************************************
  980. * DO_GDI_GRAPH -- Show # of people or buildings killed on GDI score screen*
  981. * *
  982. * *
  983. * *
  984. * INPUT: yellowptr, redptr = pointers to shape file for graphs *
  985. * *
  986. * OUTPUT: *
  987. * *
  988. * WARNINGS: *
  989. * *
  990. * HISTORY: *
  991. * 05/03/1995 BWG : Created. *
  992. *=========================================================================*/
  993. void ScoreClass::Do_GDI_Graph(void const * yellowptr, void const * redptr, int gkilled, int nkilled, int ypos)
  994. {
  995. int i, max;
  996. int gdikilled = gkilled, nodkilled=nkilled;
  997. max = MAX(gdikilled, nodkilled);
  998. if (!max) max=1;
  999. gdikilled = (gdikilled * SIZEGBAR) / max;
  1000. nodkilled = (nodkilled * SIZEGBAR) / max;
  1001. if (max < 20) {
  1002. gdikilled = gkilled * 5;
  1003. nodkilled = nkilled * 5;
  1004. }
  1005. max = MAX(gdikilled, nodkilled);
  1006. if (!max) max=1;
  1007. // Draw the white-flash shape on the hidpage
  1008. Set_Logic_Page(SysMemPage);
  1009. SysMemPage.Fill_Rect(0,0, 124,9, TBLACK);
  1010. CC_Draw_Shape(redptr, 120, 0,0, WINDOW_MAIN,SHAPE_WIN_REL, 0, 0);
  1011. Set_Logic_Page(PseudoSeenBuff);
  1012. BlitList.Add (2* 297, 2* (ypos+2), 2* 297, 2* (ypos+2), 5*12 , 12);
  1013. for (i = 1; i <= gdikilled; i++) {
  1014. if (i != gdikilled) {
  1015. CC_Draw_Shape(yellowptr,i, 172, ypos, WINDOW_MAIN,SHAPE_WIN_REL, 0, 0);
  1016. } else {
  1017. SysMemPage.Blit(*PseudoSeenBuff,0,0, 172, ypos, 3+gdikilled,9);
  1018. }
  1019. Count_Up_Print("%d", (i*gkilled) / max, gkilled, 297, ypos+2);
  1020. if (!Check_Key()) {
  1021. Play_Sample(Beepy6, 255, Options.Normalize_Sound(110));
  1022. Call_Back_Delay(2);
  1023. }
  1024. }
  1025. CC_Draw_Shape(yellowptr,gdikilled, 172,ypos , WINDOW_MAIN,SHAPE_WIN_REL, 0, 0);
  1026. Count_Up_Print("%d", gkilled, gkilled, 297, ypos+ 2);
  1027. if (!Check_Key()) Call_Back_Delay(40);
  1028. BlitList.Add (2* 297, 2* (ypos+14), 2* 297, 2* (ypos+14), 5*12 , 12);
  1029. for (i = 1; i <= nodkilled; i++) {
  1030. if (i != nodkilled) {
  1031. CC_Draw_Shape(redptr, i, 172, ypos+12, WINDOW_MAIN,SHAPE_WIN_REL, 0, 0);
  1032. } else {
  1033. SysMemPage.Blit(*PseudoSeenBuff,0,0, 172,ypos+12, 3+nodkilled,9);
  1034. }
  1035. Count_Up_Print("%d", (i*nkilled) / max, nkilled, 297, ypos+14);
  1036. if (!Check_Key()) {
  1037. Play_Sample(Beepy6, 255, Options.Normalize_Sound(110));
  1038. Call_Back_Delay(2);
  1039. }
  1040. }
  1041. // if (Keyboard::Check()) Keyboard::Clear();
  1042. /*
  1043. ** Make sure accurate count is printed at end
  1044. */
  1045. CC_Draw_Shape( redptr,nodkilled, 172,ypos+12, WINDOW_MAIN,SHAPE_WIN_REL, 0, 0);
  1046. Count_Up_Print("%d", nkilled, nkilled, 297, ypos+14);
  1047. if (!Check_Key()) Call_Back_Delay(40);
  1048. }
  1049. void ScoreClass::Do_Nod_Casualties_Graph(void)
  1050. {
  1051. int i, gdikilled, nodkilled, civkilled, max;
  1052. void const * e1ptr = MixFileClass::Retrieve("E1.SHP");
  1053. void const * c1ptr = MixFileClass::Retrieve("C1.SHP");
  1054. gdikilled = GKilled;
  1055. nodkilled = NKilled;
  1056. civkilled = CKilled;
  1057. max = MAX(gdikilled, nodkilled);
  1058. max = MAX(max, civkilled);
  1059. if (!max) max=1;
  1060. if ((gdikilled > (MAX_BAR_X - BARGRAPH_X)) || (nodkilled > (MAX_BAR_X - BARGRAPH_X)) || (civkilled > (MAX_BAR_X - BARGRAPH_X))) {
  1061. gdikilled = (gdikilled * (MAX_BAR_X - BARGRAPH_X)) / max;
  1062. nodkilled = (nodkilled * (MAX_BAR_X - BARGRAPH_X)) / max;
  1063. civkilled = (civkilled * (MAX_BAR_X - BARGRAPH_X)) / max;
  1064. }
  1065. max = MAX(gdikilled, nodkilled);
  1066. max = MAX(max, civkilled);
  1067. if (!max) max=1;
  1068. /*
  1069. ** Initialize a bunch of objects for the infantrymen who pose for the bar
  1070. ** graphs of casualties.
  1071. */
  1072. int q = NUMINFANTRYMEN/3;
  1073. int r = q*2;
  1074. for (i = 0; i < NUMINFANTRYMEN/3; i++) {
  1075. InfantryMan[i+0].xpos =
  1076. InfantryMan[i+q].xpos =
  1077. InfantryMan[i+r].xpos = (i*10) + 7;
  1078. InfantryMan[i+0].ypos = 11;
  1079. InfantryMan[i+q].ypos = 21;
  1080. InfantryMan[i+r].ypos = 31;
  1081. InfantryMan[i+0].shapefile =
  1082. InfantryMan[i+q].shapefile = e1ptr;
  1083. InfantryMan[i+r].shapefile = c1ptr;
  1084. InfantryMan[i+0].remap = ScoreRemapYellow;
  1085. InfantryMan[i+q].remap = ScoreRemapGrey;
  1086. InfantryMan[i+r].remap = RemapCiv;
  1087. InfantryMan[i+0].anim =
  1088. InfantryMan[i+q].anim =
  1089. InfantryMan[i+r].anim = 0;
  1090. InfantryMan[i+0].stage =
  1091. InfantryMan[i+q].stage =
  1092. InfantryMan[i+r].stage = 0;
  1093. InfantryMan[i+0].delay =
  1094. InfantryMan[i+q].delay =
  1095. InfantryMan[i+r].delay = Random() & 0x1F;
  1096. InfantryMan[i+0].Class =
  1097. InfantryMan[i+q].Class = &InfantryTypeClass::As_Reference(INFANTRY_E1);
  1098. InfantryMan[i+r].Class = &InfantryTypeClass::As_Reference(INFANTRY_C1);
  1099. }
  1100. /*
  1101. ** Draw the infantrymen and pause briefly before running the graph
  1102. */
  1103. Draw_InfantryMen();
  1104. SysMemPage.Blit(*PseudoSeenBuff, 0, 0, BARGRAPH_X, CASUALTY_Y, 320-BARGRAPH_X, 34);
  1105. //Interpolate_2X_Scale( PseudoSeenBuff , &SeenBuff, NULL);
  1106. /*
  1107. ** Extra font related stuff. ST - 7/29/96 2:22PM
  1108. */
  1109. Interpolate_2X_Scale(PseudoSeenBuff , &HidPage ,NULL);
  1110. BlitList.Update();
  1111. WWMouse->Draw_Mouse(&HidPage);
  1112. HidPage.Blit(SeenBuff);
  1113. WWMouse->Erase_Mouse(&HidPage, TRUE);
  1114. Call_Back_Delay(40);
  1115. BlitList.Add (2* (SCORETEXT_X + 64), 2* (CASUALTY_Y + 2), 2* (SCORETEXT_X + 64), 2* (CASUALTY_Y + 2), 5*12 , 12);
  1116. BlitList.Add (2* (SCORETEXT_X + 64), 2* (CASUALTY_Y + 14), 2* (SCORETEXT_X + 64), 2* (CASUALTY_Y + 14), 5*12 , 12);
  1117. BlitList.Add (2* (SCORETEXT_X + 64), 2* (CASUALTY_Y + 26), 2* (SCORETEXT_X + 64), 2* (CASUALTY_Y + 26), 5*12 , 12);
  1118. for (i = 1; i <= max; i++) {
  1119. // Draw & update infantrymen 3 times for every tick on the graph (i)
  1120. for (int q = 0; q < 3; q++) {
  1121. Draw_InfantryMen();
  1122. Draw_Bar_Graphs(i, gdikilled, nodkilled, civkilled);
  1123. SysMemPage.Blit(*PseudoSeenBuff, 0, 0, BARGRAPH_X, CASUALTY_Y, 320-BARGRAPH_X, 34);
  1124. Count_Up_Print("%d", (i*GKilled) / max, GKilled, SCORETEXT_X+64, CASUALTY_Y + 2);
  1125. Count_Up_Print("%d", (i*NKilled) / max, NKilled, SCORETEXT_X+64, CASUALTY_Y + 14);
  1126. Count_Up_Print("%d", (i*CKilled) / max, CKilled, SCORETEXT_X+64, CASUALTY_Y + 26);
  1127. if (!Check_Key()) Call_Back_Delay(3);
  1128. }
  1129. Play_Sample(Beepy6, 255, Options.Normalize_Sound(110));
  1130. }
  1131. if (Check_Key()) Keyboard::Clear();
  1132. /*
  1133. ** Make sure accurate count is printed at end
  1134. */
  1135. Count_Up_Print("%d", GKilled, GKilled, SCORETEXT_X+64, CASUALTY_Y + 2);
  1136. Count_Up_Print("%d", NKilled, NKilled, SCORETEXT_X+64, CASUALTY_Y + 14);
  1137. Count_Up_Print("%d", CKilled, CKilled, SCORETEXT_X+64, CASUALTY_Y + 26);
  1138. /*
  1139. ** Finish up death animations, if there are any active
  1140. */
  1141. int k = 1;
  1142. while (k) {
  1143. for (i=k=0; i<NUMINFANTRYMEN; i++) if (InfantryMan[i].anim >= DO_GUN_DEATH) k=1;
  1144. if (k) Draw_InfantryMen();
  1145. Draw_Bar_Graphs(max, gdikilled, nodkilled, civkilled);
  1146. SysMemPage.Blit(*PseudoSeenBuff, 0, 0, BARGRAPH_X, CASUALTY_Y, 320-BARGRAPH_X, 34);
  1147. Call_Back_Delay(1);
  1148. }
  1149. }
  1150. void ScoreClass::Show_Credits(int house, char const pal[])
  1151. {
  1152. static int _credsx[2]={276,276};
  1153. static int _credsy[2]={173,58};
  1154. static int _credpx[2]={228,236};
  1155. #ifdef GERMAN
  1156. static int _credpy[2]={181, 74};
  1157. static int _credtx[2]={162,162};
  1158. static int _credty[2]={173, 62};
  1159. #else
  1160. static int _credpy[2]={189-12, 74};
  1161. static int _credtx[2]={182,182};
  1162. static int _credty[2]={179-12, 62};
  1163. #endif
  1164. int credobj,i;
  1165. int min,add;
  1166. void const * credshape = MixFileClass::Retrieve("CREDS.SHP");
  1167. Alloc_Object(new ScorePrintClass(TXT_SCORE_ENDCRED, _credtx[house], _credty[house],pal));
  1168. Call_Back_Delay(15);
  1169. credobj = Alloc_Object(new ScoreCredsClass(_credsx[house], _credsy[house], credshape, 32, 2));
  1170. min = PlayerPtr->Available_Money() / 100;
  1171. /*
  1172. ** Print out total credits left at end of scenario
  1173. */
  1174. i = -50;
  1175. BlitList.Add (2* (_credpx[house]), 2* (_credpy[house]), 2* (_credpx[house]), 2* (_credpy[house]), 5*12 , 12);
  1176. do {
  1177. add = 5;
  1178. if ((PlayerPtr->Available_Money() - i) > 100 ) add += 15;
  1179. if ((PlayerPtr->Available_Money() - i) > 1000) add += 30;
  1180. if (add < min) add = min;
  1181. i += add;
  1182. if (i < 0) i=0;
  1183. Set_Font_Palette(pal);
  1184. Count_Up_Print("%d", i, PlayerPtr->Available_Money(), _credpx[house], _credpy[house]);
  1185. Call_Back_Delay(2);
  1186. if (Check_Key()) {
  1187. i=PlayerPtr->Available_Money() - 5;
  1188. Keyboard::Clear();
  1189. }
  1190. } while (i < PlayerPtr->Available_Money()) ;
  1191. // Make sure the credits object doesn't freeze on the white stage
  1192. while (((ScoreTimeClass *)ScoreObjs[credobj])->Stage >= 20 && !ControlQ) {
  1193. Call_Back_Delay(1);
  1194. }
  1195. delete ScoreObjs[credobj];
  1196. ScoreObjs[credobj] = 0;
  1197. }
  1198. /***************************************************************************
  1199. * SCORECLASS::PRINT_MINUTES -- Print out hours/minutes up to max *
  1200. * *
  1201. * Same as count-up-print, but for the time *
  1202. * *
  1203. * INPUT: current minute count and maximum *
  1204. * *
  1205. * OUTPUT: *
  1206. * *
  1207. * WARNINGS: *
  1208. * *
  1209. * HISTORY: *
  1210. * 04/13/1995 BWG : Created. *
  1211. *=========================================================================*/
  1212. void ScoreClass::Print_Minutes(int minutes)
  1213. {
  1214. char str[20];
  1215. if (minutes >= 60) {
  1216. if ((minutes/60) > 9) minutes = (9*60 + 59);
  1217. sprintf(str,Text_String(TXT_SCORE_TIMEFORMAT1), (minutes / 60),(minutes % 60));
  1218. } else {
  1219. sprintf(str,Text_String(TXT_SCORE_TIMEFORMAT2), minutes);
  1220. }
  1221. TextPrintBuffer->Print(str, 275*2, 9*2, TBLACK, TBLACK);
  1222. }
  1223. /***********************************************************************************************
  1224. * ScoreClass::Count_Up_Print -- Prints a number (up to its max) into a string, cleanly. *
  1225. * *
  1226. * This routine prints out a number (like 70) or its maximum number, into a string, onto *
  1227. * the screen, on a clean section of the screen, and blits it forward to the seenpage so you*
  1228. * can print without flashing and can print over something (to count up %'s). *
  1229. * *
  1230. * INPUT: str = string to print into *
  1231. * percent = # to print *
  1232. * max = # to print if percent > max *
  1233. * xpos = x pixel coord *
  1234. * ypos = y pixel coord *
  1235. * *
  1236. * OUTPUT: none *
  1237. * *
  1238. * WARNINGS: none *
  1239. * *
  1240. * HISTORY: *
  1241. * 04/07/1995 BWG : Created. *
  1242. *=============================================================================================*/
  1243. void ScoreClass::Count_Up_Print(char *str, int percent, int max, int xpos, int ypos)
  1244. {
  1245. char destbuf[64];
  1246. int width;
  1247. sprintf(destbuf, str, percent <= max ? percent : max);
  1248. width = strlen(destbuf) * 7;
  1249. // HidPage.Blit(HidPage, xpos, ypos, 0, 0, width, 8);
  1250. // Set_Logic_Page(HidPage);
  1251. // LogicPage->Print( destbuf, 0, 0, WHITE, TBLACK);
  1252. // HidPage.Blit(SeenBuff, 0, 0, xpos, ypos, width, 8);
  1253. TextPrintBuffer->Fill_Rect (xpos*2, ypos*2, (xpos + width)*2, (ypos+7)*2, BLACK);
  1254. TextPrintBuffer->Print (destbuf, xpos*2, ypos*2, WHITE, TBLACK);
  1255. //TextPrintBuffer->Blit(*TextPrintBuffer, xpos*2, ypos*2, 0, 0, width*2, 8*2);
  1256. //TextPrintBuffer->Print(destbuf, 0, 0, WHITE, TBLACK);
  1257. //TextPrintBuffer->Blit(SeenBuff, 0, 0, xpos*2, ypos*2, width*2, 8*2);
  1258. // PseudoSeenBuff->Print( destbuf, xpos, ypos, TBLACK, BLACK);
  1259. // Interpolate_2X_Scale( PseudoSeenBuff , &SeenBuff , NULL);
  1260. }
  1261. /***********************************************************************************************
  1262. * ScoreClass::Input_Name -- Gets the name from the keyboard *
  1263. * *
  1264. * This routine handles keyboard input, and does a nifty zooming letter effect too. *
  1265. * *
  1266. * INPUT: str = string to put user's typing into *
  1267. * xpos = x pixel coord *
  1268. * ypos = y pixel coord *
  1269. * pal = text remapping palette to print using *
  1270. * *
  1271. * OUTPUT: none *
  1272. * *
  1273. * WARNINGS: none *
  1274. * *
  1275. * HISTORY: *
  1276. * 05/15/1995 BWG : Created. *
  1277. *=============================================================================================*/
  1278. void ScoreClass::Input_Name(char str[], int xpos, int ypos, char const pal[])
  1279. {
  1280. int key, ascii, index=0;
  1281. void const * keystrok = MixFileClass::Retrieve("KEYSTROK.AUD");
  1282. /*
  1283. ** Ready the hidpage so it can restore background under zoomed letters
  1284. */
  1285. PseudoSeenBuff->Blit(SysMemPage);
  1286. do {
  1287. Call_Back();
  1288. Animate_Score_Objs();
  1289. Animate_Cursor(index, ypos);
  1290. /*
  1291. ** Extra font related stuff. ST - 7/29/96 2:22PM
  1292. */
  1293. Interpolate_2X_Scale (PseudoSeenBuff , &HidPage ,NULL);
  1294. BlitList.Update();
  1295. HidPage.Blit(SeenBuff);
  1296. if (Check_Key()) { //if (Keyboard::Check()) {
  1297. key = Get_Key(); //key = Keyboard::Get();
  1298. if (index == MAX_FAMENAME_LENGTH-2) {
  1299. while (Check_Key()) {
  1300. Get_Key();
  1301. }
  1302. }
  1303. /*
  1304. ** If they hit 'backspace' when they're on the last letter,
  1305. ** turn it into a space instead.
  1306. */
  1307. if ((key == KA_BACKSPACE) && (index == MAX_FAMENAME_LENGTH-2) ) {
  1308. if (str[index] && str[index]!=32) key = 32;
  1309. }
  1310. if (key == KA_BACKSPACE) { //if (key == KN_BACKSPACE) {
  1311. if (index) {
  1312. str[--index] = 0;
  1313. int xposindex6 = xpos+(index*6);
  1314. PseudoSeenBuff->Fill_Rect(xposindex6,ypos,xposindex6+6,ypos+6,TBLACK);
  1315. SysMemPage.Fill_Rect(xposindex6,ypos,xposindex6+6,ypos+6,TBLACK);
  1316. TextPrintBuffer->Fill_Rect(xposindex6*2,ypos*2,(xposindex6+6)*2,(ypos+6)*2, BLACK);
  1317. }
  1318. } else if (key!=KA_RETURN) { //else if (key != KN_RETURN && key!=KN_KEYPAD_RETURN) {
  1319. ascii = key; //ascii = KN_To_KA(key);
  1320. if (ascii >= 'a' && ascii <= 'z') ascii -= ('a' - 'A');
  1321. //if (ascii >='A' && ascii<='Z' || ascii == ' ') {
  1322. if ( (ascii >= '!' && ascii <= KA_TILDA) || ascii == ' ') {
  1323. PseudoSeenBuff->Fill_Rect(xpos + (index*6), ypos, xpos + (index*6)+6, ypos+5, TBLACK);
  1324. SysMemPage.Fill_Rect(xpos + (index*6), ypos, xpos + (index*6)+6, ypos+5, TBLACK);
  1325. TextPrintBuffer->Fill_Rect(2*(xpos + (index*6)), ypos*2, 2*(xpos + (index*6)+6), 2*(ypos+6), BLACK);
  1326. str[index] = ascii;
  1327. str[index+1] = 0;
  1328. int objindex;
  1329. Play_Sample(keystrok, 255, Options.Normalize_Sound(255));
  1330. objindex = Alloc_Object(new ScoreScaleClass(str+index,xpos+(index*6), ypos, pal));
  1331. while (ScoreObjs[objindex]) Call_Back_Delay(1);
  1332. if (index < (MAX_FAMENAME_LENGTH-2) ) index++;
  1333. }
  1334. }
  1335. }
  1336. } while(key!=KA_RETURN); // } while(key != KN_RETURN && key!=KN_KEYPAD_RETURN);
  1337. }
  1338. void Animate_Cursor(int pos, int ypos)
  1339. {
  1340. static int _lastpos, _state;
  1341. static CountDownTimerClass _timer;
  1342. ypos += 7; // move cursor to bottom of letter
  1343. // If they moved the cursor, erase old one and force state=0, to make green draw right away
  1344. if (pos != _lastpos) {
  1345. PseudoSeenBuff->Draw_Line(HALLFAME_X + (_lastpos*6),ypos, HALLFAME_X + (_lastpos*6) + 5, ypos, TBLACK);
  1346. TextPrintBuffer->Fill_Rect(2*(HALLFAME_X + (_lastpos*6)),2*ypos, 2*(HALLFAME_X + (_lastpos*6) + 5), 2*ypos+1, BLACK);
  1347. _lastpos = pos;
  1348. _state = 0;
  1349. }
  1350. PseudoSeenBuff->Draw_Line(HALLFAME_X + (pos*6),ypos, HALLFAME_X + (pos*6)+5, ypos, _state ? LTBLUE : TBLACK);
  1351. TextPrintBuffer->Fill_Rect(2*(HALLFAME_X + (pos*6)),2*ypos, 2*(HALLFAME_X + (pos*6)+5), 2*ypos+1, _state ? LTBLUE : BLACK);
  1352. /*
  1353. ** Toggle the color of the cursor, green or black, if it's time to do so.
  1354. */
  1355. if (!_timer.Time()) {
  1356. _state ^= 1;
  1357. _timer.Set(5);
  1358. }
  1359. }
  1360. /***************************************************************************
  1361. * Draw_InfantryMen -- Draw all the guys on the score screen *
  1362. * *
  1363. * *
  1364. * *
  1365. * INPUT: *
  1366. * *
  1367. * OUTPUT: *
  1368. * *
  1369. * WARNINGS: *
  1370. * *
  1371. * HISTORY: *
  1372. * 04/13/1995 BWG : Created. *
  1373. *=========================================================================*/
  1374. void Draw_InfantryMen()
  1375. {
  1376. int k;
  1377. // Only draw the infantrymen if we're playing Nod... GDI wouldn't execute
  1378. // people like that.
  1379. /*
  1380. ** First restore the background
  1381. */
  1382. SysMemPage.Blit(SysMemPage, BARGRAPH_X, CASUALTY_Y, 0, 0, 320-BARGRAPH_X, 34);
  1383. Set_Logic_Page(SysMemPage);
  1384. /*
  1385. ** Then draw all the infantrymen on the clean SysMemPage
  1386. */
  1387. for (k = 0; k < NUMINFANTRYMEN; k++) Draw_InfantryMan(k);
  1388. /*
  1389. ** They'll all be blitted over to the seenpage after the graphs are drawn
  1390. */
  1391. }
  1392. /***************************************************************************
  1393. * Draw_InfantryMan -- Draw one guy in score screen, update animation *
  1394. * *
  1395. * This routine draws one of the infantrymen in the "Casualties" area *
  1396. * *
  1397. * INPUT: *
  1398. * *
  1399. * OUTPUT: *
  1400. * *
  1401. * WARNINGS: *
  1402. * *
  1403. * HISTORY: *
  1404. * 04/13/1995 BWG : Created. *
  1405. *=========================================================================*/
  1406. void Draw_InfantryMan(int index)
  1407. {
  1408. int stage;
  1409. /* If the infantryman's dead, just abort this function */
  1410. if (InfantryMan[index].anim == -1) return;
  1411. stage = InfantryMan[index].stage + InfantryMan[index].Class->DoControls[InfantryMan[index].anim].Frame;
  1412. CC_Draw_Shape(InfantryMan[index].shapefile,
  1413. stage,
  1414. InfantryMan[index].xpos,
  1415. InfantryMan[index].ypos,
  1416. WINDOW_MAIN,
  1417. SHAPE_FADING|SHAPE_CENTER|SHAPE_WIN_REL,//|SHAPE_GHOST,
  1418. InfantryMan[index].remap,
  1419. Map.UnitShadow);
  1420. /*
  1421. ** see if it's time to run a new anim
  1422. */
  1423. if (--InfantryMan[index].delay < 0) {
  1424. InfantryMan[index].delay = 3;
  1425. if (++InfantryMan[index].stage >= InfantryMan[index].Class->DoControls[InfantryMan[index].anim].Count) {
  1426. /*
  1427. ** was he playing a death anim? If so, and it's done, erase him
  1428. */
  1429. if (InfantryMan[index].anim >= DO_GUN_DEATH) {
  1430. InfantryMan[index].anim = -1;
  1431. } else {
  1432. New_Infantry_Anim(index, DO_STAND_READY);
  1433. }
  1434. }
  1435. }
  1436. }
  1437. /***************************************************************************
  1438. * New_Infantry_Anim -- Start up a new animation for one of the infantrymen*
  1439. * *
  1440. * *
  1441. * *
  1442. * INPUT: index: which of the 30 infantrymen to affect *
  1443. * anim: which animation sequence to start him into *
  1444. * OUTPUT: *
  1445. * *
  1446. * WARNINGS: *
  1447. * *
  1448. * HISTORY: *
  1449. * 04/13/1995 BWG : Created. *
  1450. *=========================================================================*/
  1451. void New_Infantry_Anim(int index, int anim)
  1452. {
  1453. InfantryMan[index].anim = anim;
  1454. InfantryMan[index].stage = 0;
  1455. if (anim >= DO_GUN_DEATH) {
  1456. InfantryMan[index].delay = 1; // start right away
  1457. } else {
  1458. InfantryMan[index].delay = Random() & 15;
  1459. }
  1460. }
  1461. /***************************************************************************
  1462. * Draw_Bar_Graphs -- Draw "Casualties" bar graphs *
  1463. * *
  1464. * *
  1465. * *
  1466. * INPUT: i = current count of how far to draw graph *
  1467. * gkilled = # of GDI forces killed (adjusted to fit in space) *
  1468. * nkilled = # of Nod forces killed (adjusted to fit in space) *
  1469. * ckilled = # of civilians killed (adjusted to fit in space) *
  1470. * OUTPUT: *
  1471. * *
  1472. * WARNINGS: *
  1473. * *
  1474. * HISTORY: *
  1475. * 04/13/1995 BWG : Created. *
  1476. *=========================================================================*/
  1477. void Draw_Bar_Graphs(int i, int gkilled, int nkilled, int ckilled)
  1478. {
  1479. if (gkilled) {
  1480. LogicPage->Fill_Rect(0, 0+4, 0+MIN(i,gkilled), 0+5, LTCYAN);
  1481. LogicPage->Draw_Line(0+1, 0+6, 0+MIN(i,gkilled)+1, 0+6, TBLACK);
  1482. LogicPage->Draw_Line(0+MIN(i,gkilled)+1,0+5, 0+MIN(i,gkilled)+1, 0+5, TBLACK);
  1483. if (i <= gkilled) {
  1484. int anim = InfantryMan[i/11].anim;
  1485. if (anim!=-1 && anim < DO_GUN_DEATH) {
  1486. if (i/11) {
  1487. New_Infantry_Anim(i/11,DO_GUN_DEATH + (Random() & 3));
  1488. } else {
  1489. New_Infantry_Anim(i/11,DO_GUN_DEATH);
  1490. }
  1491. // Sound_Effect(Random_Pick(VOC_SCREAM1, VOC_SCREAM5));
  1492. }
  1493. }
  1494. }
  1495. if (nkilled) {
  1496. LogicPage->Fill_Rect(0, 0+16, 0+MIN(i,nkilled), 0+17, RED);
  1497. LogicPage->Draw_Line(0+1, 0+18, 0+MIN(i,nkilled)+1, 0+18, TBLACK);
  1498. LogicPage->Draw_Line(0+MIN(i,nkilled)+1, 0+17, 0+MIN(i,nkilled)+1, 0+17, TBLACK);
  1499. if (i <= nkilled) {
  1500. int anim = InfantryMan[(NUMINFANTRYMEN/3)+(i/11)].anim;
  1501. if (anim!=-1 && anim < DO_GUN_DEATH) {
  1502. if (i/11) {
  1503. New_Infantry_Anim((NUMINFANTRYMEN/3)+(i/11),DO_GUN_DEATH + (Random() & 3));
  1504. } else {
  1505. New_Infantry_Anim((NUMINFANTRYMEN/3)+(i/11),DO_GUN_DEATH);
  1506. }
  1507. // Sound_Effect(Random_Pick(VOC_SCREAM1, VOC_SCREAM5));
  1508. }
  1509. }
  1510. }
  1511. if (ckilled) {
  1512. LogicPage->Fill_Rect(0, 0+28, 0+MIN(i,ckilled), 0+29, RED);
  1513. LogicPage->Draw_Line(0+1, 0+30, 0+MIN(i,ckilled)+1, 0+30, TBLACK);
  1514. LogicPage->Draw_Line(0+MIN(i,ckilled)+1, 0+29, 0+MIN(i,ckilled)+1, 0+29, TBLACK);
  1515. if (i <= ckilled) {
  1516. int anim = InfantryMan[((NUMINFANTRYMEN*2)/3)+(i/11)].anim;
  1517. if (anim!=-1 && anim < DO_GUN_DEATH) {
  1518. if (i/11) {
  1519. New_Infantry_Anim(((NUMINFANTRYMEN*2)/3)+(i/11),DO_GUN_DEATH + (Random() & 3));
  1520. } else {
  1521. New_Infantry_Anim(((NUMINFANTRYMEN*2)/3)+(i/11),DO_GUN_DEATH);
  1522. }
  1523. // Sound_Effect(Random_Pick(VOC_SCREAM1, VOC_SCREAM5));
  1524. }
  1525. }
  1526. }
  1527. }
  1528. /***************************************************************************
  1529. * Call_Back_Delay -- Combines Call_Back() and Delay() functions *
  1530. * *
  1531. * This is just to cut down on code size and typing a little. *
  1532. * *
  1533. * INPUT: *
  1534. * *
  1535. * OUTPUT: *
  1536. * *
  1537. * WARNINGS: *
  1538. * *
  1539. * HISTORY: *
  1540. * 04/13/1995 BWG : Created. *
  1541. *=========================================================================*/
  1542. void Call_Back_Delay(int time)
  1543. {
  1544. CountDownTimerClass cd;
  1545. if (!ControlQ) {
  1546. if (Keyboard::Down(KN_LCTRL) && Keyboard::Down(KN_Q)) {
  1547. ControlQ = 1;
  1548. Keyboard::Clear();
  1549. }
  1550. }
  1551. if (ControlQ) time=0;
  1552. cd.Set(time);
  1553. StreamLowImpact = true;
  1554. do {
  1555. Call_Back();
  1556. //Animate_Score_Objs();
  1557. //Interpolate_2X_Scale(PseudoSeenBuff , &SeenBuff ,NULL);
  1558. //if (Get_Mouse_State()){
  1559. // Interpolate_2X_Scale(PseudoSeenBuff , &SeenBuff ,NULL);
  1560. //BlitList.Update();
  1561. //}else{
  1562. Animate_Score_Objs();
  1563. Interpolate_2X_Scale(PseudoSeenBuff , &HidPage ,NULL);
  1564. BlitList.Update();
  1565. WWMouse->Draw_Mouse(&HidPage);
  1566. HidPage.Blit(SeenBuff);
  1567. WWMouse->Erase_Mouse(&HidPage, TRUE);
  1568. //}
  1569. } while(cd.Time());
  1570. StreamLowImpact = false;
  1571. }
  1572. void Animate_Score_Objs()
  1573. {
  1574. StillUpdating = false;
  1575. for (int i = 0; i < MAXSCOREOBJS; i++) {
  1576. if (ScoreObjs[i]) {
  1577. ScoreObjs[i]->Update();
  1578. }
  1579. }
  1580. }
  1581. char *Int_Print(int a)
  1582. {
  1583. static char str[10];
  1584. sprintf(str,"%d",a);
  1585. return str;
  1586. }
  1587. /***********************************************************************************************
  1588. * Multi_Score_Presentation -- Multiplayer routine to display score screen. *
  1589. * *
  1590. * *
  1591. * INPUT: none *
  1592. * *
  1593. * OUTPUT: none *
  1594. * *
  1595. * WARNINGS: none *
  1596. * *
  1597. * HISTORY: *
  1598. * 06/11/1995 BWG: Created. *
  1599. *=============================================================================================*/
  1600. void Multi_Score_Presentation(void)
  1601. {
  1602. static char const _cycleyellowpal[]={0x0,0xec,0xEb,0xea,0xE9,0xe9,0xE9,0x0,0xE9,0x0,0x0,0x0,0x0,0x0,0xED,0x0};
  1603. static char const _greenpal[]= {0x0,0x12,0x14,0x16,0x18,0x18,0x18,0x0,0x18,0x0,0x0,0x0,0x0,0x0,0x10,0x0};
  1604. static char const _redpal[]= {0x0,0x22,0x24,0x26,0x28,0x28,0x28,0x0,0x28,0x0,0x0,0x0,0x0,0x0,0x20,0x0};
  1605. static char const _graypal[]= {0x0,0xca,0xCb,0xcc,0xCd,0xcd,0xCd,0x0,0xCD,0x0,0x0,0x0,0x0,0x0,0xC8,0x0};
  1606. static char const _orangepal[]={0x0,0xd1,0xD2,0xd3,0xD4,0xd4,0xD4,0x0,0xD4,0x0,0x0,0x0,0x0,0x0,0xD0,0x0};
  1607. static char const _bluepal[]= {0x0,0x2,0x0a,0xb,0x0b,0xb,0x0B,0x0,0x0B,0x0,0x0,0x0,0x0,0x0,0x09,0x0};
  1608. static char const _yellowpal[]={0x0,0x5,0xee,0xf1,0xf2,0xf2,0xF2,0xf2,0xF2,0x0,0x0,0x0,0x0,0x0,0x7D,0x0};
  1609. //static char const _greenpal[]= {0x0,0x0,0x12,0x0,0x14,0x0,0x16,0x0,0x18,0x0,0x0,0x0,0x0,0x0,0x10,0x0};
  1610. //static char const _redpal[]= {0x0,0x0,0x22,0x0,0x24,0x0,0x26,0x0,0x28,0x0,0x0,0x0,0x0,0x0,0x20,0x0};
  1611. //static char const _graypal[]= {0x0,0x0,0xCA,0x0,0xCB,0x0,0xCC,0x0,0xCD,0x0,0x0,0x0,0x0,0x0,0xC8,0x0};
  1612. //static char const _orangepal[]={0x0,0x0,0xD1,0x0,0xD2,0x0,0xD3,0x0,0xD4,0x0,0x0,0x0,0x0,0x0,0xD0,0x0};
  1613. //static char const _bluepal[]= {0x0,0x0,0x02,0x0,0x0A,0x0,0x0B,0x0,0x0B,0x0,0x0,0x0,0x0,0x0,0x09,0x0};
  1614. //static char const _yellowpal[]={0x0,0x0,0x05,0x0,0xEE,0x0,0xF1,0x0,0xF2,0x0,0x0,0x0,0x0,0x0,0x7D,0x0};
  1615. static char const *_colors[]={_yellowpal,_redpal,_bluepal,_orangepal,_greenpal,_graypal};
  1616. int i,k;
  1617. void *oldfont, *anim;
  1618. int oldfontxspacing = FontXSpacing;
  1619. char const *pal;
  1620. FontXSpacing = 0;
  1621. Map.Override_Mouse_Shape(MOUSE_NORMAL);
  1622. Theme.Queue_Song(THEME_WIN1);
  1623. PseudoSeenBuff = new GraphicBufferClass(320,200,(void*)NULL);
  1624. TextPrintBuffer = new GraphicBufferClass(SeenBuff.Get_Width(), SeenBuff.Get_Height() ,(void*)NULL);
  1625. BlitList.Clear();
  1626. SysMemPage.Clear();
  1627. PseudoSeenBuff->Clear();
  1628. HiddenPage.Clear();
  1629. TextPrintBuffer->Clear();
  1630. Set_Palette(BlackPalette);
  1631. anim = Open_Animation("MLTIPLYR.WSA",NULL,0L,(WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE),Palette);
  1632. Hide_Mouse();
  1633. /*
  1634. ** Display the background animation
  1635. */
  1636. VisiblePage.Clear();
  1637. InterpolationPaletteChanged = TRUE;
  1638. InterpolationPalette = Palette;
  1639. Increase_Palette_Luminance (Palette , 30,30,30,63);
  1640. Animate_Frame(anim, *PseudoSeenBuff, 1);
  1641. Interpolate_2X_Scale( PseudoSeenBuff , &SeenBuff , "MULTSCOR.PAL");
  1642. Fade_Palette_To(Palette, FADE_PALETTE_FAST, Call_Back);
  1643. int frame = 1;
  1644. while (frame < Get_Animation_Frame_Count(anim)) {
  1645. Animate_Frame(anim, *PseudoSeenBuff, frame++);
  1646. Call_Back_Delay(2);
  1647. }
  1648. Close_Animation(anim);
  1649. /* Change to the six-point font for Text_Print */
  1650. oldfont = Set_Font(ScoreFontPtr);
  1651. Call_Back();
  1652. Set_Logic_Page(*PseudoSeenBuff);
  1653. /*
  1654. ** Move all the scores over a notch if there's more games than can be
  1655. ** shown (which is known by MPlayerCurGame == MAX_MULTI_GAMES-1);
  1656. */
  1657. if (MPlayerCurGame == MAX_MULTI_GAMES-1) {
  1658. for(i = 0; i < MAX_MULTI_NAMES; i++) {
  1659. for(k = 0; k < MAX_MULTI_GAMES-1; k++) {
  1660. MPlayerScore[i].Kills[k] = MPlayerScore[i].Kills[k+1];
  1661. }
  1662. }
  1663. }
  1664. int y = 41;
  1665. for(i = 0; i < MAX_MULTI_NAMES; i++) {
  1666. if (strlen(MPlayerScore[i].Name)) {
  1667. pal = _colors[MPlayerScore[i].Color];
  1668. Alloc_Object(new ScorePrintClass(MPlayerScore[i].Name, 15, y,pal));
  1669. Call_Back_Delay(20);
  1670. Alloc_Object(new ScorePrintClass(Int_Print(MPlayerScore[i].Wins), 118, y, pal));
  1671. Call_Back_Delay(6);
  1672. for(k = 0; k <= MIN(MPlayerCurGame, MAX_MULTI_GAMES-2); k++) {
  1673. if (MPlayerScore[i].Kills[k] >= 0) {
  1674. Alloc_Object(new ScorePrintClass(Int_Print(MPlayerScore[i].Kills[k]), 225+(24*k), y, pal));
  1675. Call_Back_Delay(6);
  1676. }
  1677. }
  1678. y += 12;
  1679. }
  1680. }
  1681. #if (FRENCH)
  1682. Alloc_Object(new ScorePrintClass(TXT_MAP_CLICK2, 90 /*(320-strlen(Text_String(TXT_MAP_CLICK2)))/2*/, 185, _cycleyellowpal));
  1683. #else
  1684. Alloc_Object(new ScorePrintClass(TXT_MAP_CLICK2, 109 /*(320-strlen(Text_String(TXT_MAP_CLICK2)))/2*/, 185, _cycleyellowpal));
  1685. #endif
  1686. Cycle_Wait_Click();
  1687. /* get rid of all the animating objects */
  1688. for (i = 0; i < MAXSCOREOBJS; i++) if (ScoreObjs[i]) {
  1689. delete ScoreObjs[i];
  1690. ScoreObjs[i] = 0;
  1691. }
  1692. Theme.Queue_Song(THEME_NONE);
  1693. Fade_Palette_To(BlackPalette, FADE_PALETTE_FAST, NULL);
  1694. VisiblePage.Clear();
  1695. Set_Palette(GamePalette);
  1696. Set_Logic_Page (SeenBuff);
  1697. delete PseudoSeenBuff;
  1698. delete TextPrintBuffer;
  1699. BlitList.Clear();
  1700. Set_Font(oldfont);
  1701. FontXSpacing = oldfontxspacing;
  1702. ControlQ = 0;
  1703. Show_Mouse();
  1704. }
  1705. #ifdef WRITE_LBM
  1706. // A BitMapHeader is stored in a BMHD chunk. This structure MUST be an even size
  1707. typedef struct {
  1708. unsigned short w, h; // raster width & height in pixels
  1709. unsigned short x, y; // position for this image
  1710. unsigned char planes; // # source bitplanes
  1711. unsigned char masking; // masking technique
  1712. unsigned char compression; // compression algoithm
  1713. unsigned char pad1; // UNUSED. For consistency, put 0 here.
  1714. unsigned short transcolor; // transparent "color number"
  1715. unsigned char xaspect, yaspect; // aspect ratio, a rational number x/y
  1716. unsigned short pagewidth, pageheight; // source "page" size in pixels
  1717. } BitMapHeaderType;
  1718. // All values in LocalHeader are always the same except planes. This is set in Write_BMHD
  1719. // the WORD values must be in low-high order for compatibility.
  1720. static BitMapHeaderType LocalHeader = {
  1721. 0x4001, 0xc800, 0, 0, 0, 0, // width, height, x, y, planes, mask
  1722. 1, 0, 0xFF00, 5, 6, // compress, pad1, transcolor, xasptect, yaspect
  1723. 0x4001, 0xC800 }; // pagewidth, pageheight
  1724. #define BM_HEADER_SIZE (((sizeof(BitMapHeaderType) + 1) & 0xFFFE) + 8L)
  1725. /*=========================================================================*/
  1726. /* The following static functions are in this file: */
  1727. /*=========================================================================*/
  1728. static long CCWrite_BMHD(CCFileClass &lbmhandle, short bitplanes);
  1729. static long CCWrite_CMAP(CCFileClass &lbmhandle, unsigned char * palette, short bitplanes);
  1730. static long CCWrite_BODY(CCFileClass &lbmhandle, BufferClass& buff, short bitplanes);
  1731. static long CCWrite_Row(CCFileClass &lbmhandle, unsigned char *buffer);
  1732. /*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
  1733. /***************************************************************************
  1734. * CCWrite_LBM_File -- Writes out a file in LBM format *
  1735. * *
  1736. * INPUT: short lbmhandle -- lbm file handle already opened by caller *
  1737. * BufferClass buff -- buff where MCGA picture is *
  1738. * short bitplane -- number of bitplanes to convert to *
  1739. * char *palette -- pointer to palette for buff *
  1740. * *
  1741. * OUTPUT: Returns bool -- successfull or not *
  1742. * *
  1743. * WARNINGS: *
  1744. * *
  1745. * HISTORY: *
  1746. * 11/18/1991 SB : Created. *
  1747. *=========================================================================*/
  1748. bool CCWrite_LBM_File(CCFileClass &lbmhandle, BufferClass& buff, short bitplanes, unsigned char *palette)
  1749. {
  1750. long filesize;
  1751. lbmhandle.Seek(0L, SEEK_SET); // goto beginning of file
  1752. lbmhandle.Write("FORM????ILBM", 12L); // First 12 bytes of all .lbm files
  1753. // size is unkown so write ????
  1754. filesize = 12L; // 4 bytes for "ILBM"
  1755. filesize += CCWrite_BMHD(lbmhandle, bitplanes); // write out BMHD (fixed size)
  1756. filesize += CCWrite_CMAP(lbmhandle, palette, bitplanes); // write out CMAP
  1757. // Write out the body, or compressed picture image. This size will depend
  1758. // on the compression, but the value passed back is what the compressor
  1759. // assumed was written to file
  1760. filesize += CCWrite_BODY(lbmhandle, buff, bitplanes);
  1761. // Verify that we were able to write out the file without running out of space
  1762. if (lbmhandle.Seek(0L, SEEK_END) != filesize) {
  1763. return(false);
  1764. }
  1765. lbmhandle.Seek(4L, SEEK_SET); // goto beginning of file
  1766. filesize = Reverse_LONG(filesize - 8L); // - 8 because of "FORM" + short (size)
  1767. lbmhandle.Write( (char *) &filesize, 4L); // patch in filesize
  1768. return(true);
  1769. }
  1770. /***************************************************************************
  1771. * CCWrite_BMHD -- writes out the bit map header (LocalHeader) *
  1772. * *
  1773. * INPUT: short lbmhandle -- file handle for lbm file *
  1774. * short pitplanes -- number of bitplanes to write out *
  1775. * *
  1776. * OUTPUT: LONG number of bytes hopefully written out to .LBM file *
  1777. * *
  1778. * WARNINGS: *
  1779. * *
  1780. * HISTORY: *
  1781. * 11/19/1991 SB : Created. *
  1782. *=========================================================================*/
  1783. static long CCWrite_BMHD(CCFileClass &lbmhandle, short bitplanes)
  1784. {
  1785. long size;
  1786. lbmhandle.Write("BMHD", 4L); // write out chunk title
  1787. size = Reverse_LONG(sizeof(LocalHeader)); // write out size of LocalHeader chunk
  1788. lbmhandle.Write((char *) &size, 4L);
  1789. LocalHeader.planes = bitplanes; // only nonconstant value in LocalHeader
  1790. // Make sure size is even. Return 8 = "BMHD" + size of the bitmap header structure
  1791. return(lbmhandle.Write((char *) &LocalHeader,
  1792. (sizeof(LocalHeader) + 1) & 0xFFFE) + 8L);
  1793. }
  1794. /***************************************************************************
  1795. * CCWrite_CMAP -- Writes out CMAP (palette) information *
  1796. * *
  1797. * *
  1798. * INPUT: short lbmhandle -- file handle of lbm file *
  1799. * char * palette -- pointer to paletter information *
  1800. * short bitplanes -- used to figure out size of palette *
  1801. * *
  1802. * OUTPUT: long number of bytes that should have been written out to .LBM. *
  1803. * *
  1804. * WARNINGS: *
  1805. * *
  1806. * HISTORY: *
  1807. * 11/19/1991 SB : Created. *
  1808. *=========================================================================*/
  1809. static long CCWrite_CMAP(CCFileClass &lbmhandle, unsigned char * palette, short bitplanes)
  1810. {
  1811. short color, r, g, b, colors;
  1812. long size;
  1813. unsigned char *pal_ptr;
  1814. char rgb[3];
  1815. lbmhandle.Write("CMAP", 4L); // write out palette info
  1816. colors = 1 << bitplanes; // colors = 2 to the bitplanes
  1817. size = Reverse_LONG(colors * 3L); // size = colors * 3 guns
  1818. lbmhandle.Write((char *) &size, 4L);
  1819. for (pal_ptr = palette, color = 0; color < colors; color++) { // for each color
  1820. if ((r = *pal_ptr++) != 0) { // DPaint changes allows 0 - 100 for gun values
  1821. r = (r << 2) | 0x03; // this must be converted to 0 - 256 for LBM
  1822. } // so LBM_val = (DP_val * 4) | 3 if DP_val != 0
  1823. if ((g = *pal_ptr++) != 0) {
  1824. g = (g << 2) | 0x03;
  1825. }
  1826. if ((b = *pal_ptr++) != 0) {
  1827. b = (b << 2) | 0x03;
  1828. }
  1829. rgb[0] = r; // assign gun values to an array to write out
  1830. rgb[1] = g;
  1831. rgb[2] = b;
  1832. lbmhandle.Write(rgb, 3L);
  1833. }
  1834. // size = colors * 3
  1835. return(((colors << 1) + colors) + 8L); // total size of CMAP 8 = "CMAP" + short (size)
  1836. }
  1837. /***************************************************************************
  1838. * CCWrite_Body -- writes out compressed data in an LBM file *
  1839. * *
  1840. * INPUT: short lbmhandle -- file handle of lbm file *
  1841. * *
  1842. * OUTPUT: long - number of byte written *
  1843. * *
  1844. * WARNINGS: *
  1845. * *
  1846. * HISTORY: *
  1847. * 11/19/1991 SB : Created. *
  1848. *=========================================================================*/
  1849. static long CCWrite_BODY(CCFileClass &lbmhandle, BufferClass& buff, short bitplanes)
  1850. {
  1851. long bodysize = 0;
  1852. long actualsize;
  1853. long size;
  1854. short planebit;
  1855. short line, plane;
  1856. unsigned char buffer[40];
  1857. unsigned char *buffptr;
  1858. lbmhandle.Write("BODY????", 8L); // BODY chunk ID, ???? reserved for chuncksize
  1859. buffptr = (unsigned char *) buff.Get_Buffer(); // point to beginning of buff
  1860. for (line = 0; line < 200; line++) {
  1861. planebit = 1; // start with bit 1 set
  1862. for (plane = 0; plane < bitplanes; plane++) {
  1863. Pack_2_Plane(buffer, buffptr, planebit); // convert to planar
  1864. bodysize += CCWrite_Row(lbmhandle, buffer); // write to to the BODY in the LBM
  1865. planebit <<= 1; // set next bit
  1866. }
  1867. buffptr += 320; // row size is 320
  1868. }
  1869. actualsize = bodysize + (bodysize&0x01);
  1870. if (actualsize != bodysize) {
  1871. lbmhandle.Write(buffer, 1); // Padd the block.
  1872. }
  1873. lbmhandle.Seek( -(actualsize + 4L), SEEK_CUR); // Patch in chunksize
  1874. size = Reverse_LONG(bodysize);
  1875. lbmhandle.Write( (char *) &size ,4L);
  1876. return(actualsize + 8L); // total size of BODY, "BODY????" = 8 bytes
  1877. }
  1878. /***************************************************************************
  1879. * CCWrite_Row -- compresses and writes a row plane to .lbm file *
  1880. * *
  1881. * INPUT: short lbmhandle -- lbm file handle *
  1882. * unsigned char *buffer -- pointer to buffer to be written out *
  1883. * *
  1884. * OUTPUT: long size of chunk that should have been written out *
  1885. * *
  1886. * WARNINGS: *
  1887. * *
  1888. * HISTORY: *
  1889. * 11/19/1991 SB : Created. *
  1890. *=========================================================================*/
  1891. static long CCWrite_Row(CCFileClass &lbmhandle, unsigned char *buffer)
  1892. {
  1893. short i;
  1894. short chunksize = 0;
  1895. short dataLength = 40; // 320 rows / 8 ( 1 plane per row)
  1896. unsigned char repCode, current, curr_plus_2;
  1897. unsigned char *buffptr;
  1898. while (dataLength) {
  1899. // If at least 2 more bytes and they are equal, then replicate
  1900. if ((dataLength >= 2) && (buffer[0] == buffer[1])) {
  1901. buffptr = buffer;
  1902. for (i = 0; (i <= 128) && (i < (dataLength - 1)); i++) {
  1903. if (*buffptr != buffptr[1]) {
  1904. break;
  1905. }
  1906. buffptr++;
  1907. }
  1908. i++;
  1909. repCode = -i + 1;
  1910. lbmhandle.Write(&repCode, 1L); // Write count as -count+1
  1911. lbmhandle.Write(buffer, 1L); // Write byte to replicate
  1912. buffer += i;
  1913. dataLength -= i;
  1914. chunksize += 2;
  1915. } else { // Copy literally till 3 byte run or two 2 byte runs found
  1916. for (i = 0; (i <= 128) && (i < dataLength); i++) {
  1917. current = buffer[i];
  1918. curr_plus_2 = buffer[i + 2];
  1919. if (i == dataLength - 1)
  1920. continue;
  1921. if (current != buffer[i + 1])
  1922. continue;
  1923. if (i == dataLength - 2)
  1924. continue;
  1925. if (current == curr_plus_2)
  1926. break;
  1927. if (i == dataLength - 3)
  1928. continue;
  1929. if (curr_plus_2 == buffer[i + 3])
  1930. break;
  1931. }
  1932. repCode = i - 1;
  1933. lbmhandle.Write(&repCode, 1L); // Write count as count-1
  1934. lbmhandle.Write(buffer, (long) i); // Write 'count' bytes
  1935. buffer += i;
  1936. dataLength -= i;
  1937. chunksize += i + 1;
  1938. }
  1939. } // end while
  1940. return(chunksize);
  1941. }
  1942. #endif