123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322 |
- //
- // Copyright 2020 Electronic Arts Inc.
- //
- // TiberianDawn.DLL and RedAlert.dll and corresponding source code 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 3 of the License, or (at your option) any later version.
- // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
- // in the hope that it will be useful, but with permitted additional restrictions
- // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
- // distributed with this program. You should have received a copy of the
- // GNU General Public License along with permitted additional restrictions
- // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
- /* $Header: F:\projects\c&c\vcs\code\score.cpv 2.17 16 Oct 1995 16:49:54 JOE_BOSTIC $ */
- /***********************************************************************************************
- *** 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 ***
- ***********************************************************************************************
- * *
- * Project Name : Command & Conquer *
- * *
- * File Name : SCORE.CPP *
- * *
- * Programmer : Joe L. Bostic *
- * *
- * Start Date : April 19, 1994 *
- * *
- * Last Update : May 3, 1995 [BWG] *
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * Call_Back_Delay -- Combines Call_Back() and Delay() functions *
- * Draw_Bar_Graphs -- Draw "Casualties" bar graphs *
- * Draw_InfantryMan -- Draw one guy in score screen, update animation *
- * Draw_Infantrymen -- Draw all the guys on the score screen *
- * New_Infantry_Anim -- Start up a new animation for one of the infantrymen *
- * ScoreClass::Count_Up_Print -- Prints a number (up to its max) into a string, cleanly *
- * ScoreClass::Delay -- Pauses waiting for keypress. *
- * ScoreClass::DO_GDI_GRAPH -- Show # of people or buildings killed on GDI score screen *
- * ScoreClass::Presentation -- Main routine to display score screen. *
- * ScoreClass::Print_Graph_Title -- Prints title on score screen. *
- * ScoreClass::Print_Minutes -- Print out hours/minutes up to max *
- * ScoreClass::Pulse_Bar_Graph -- Pulses the bargraph color. *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "function.h"
- #include "textblit.h"
- #define SCORETEXT_X 184
- #define SCORETEXT_Y 8
- #define CASUALTY_Y 88
- #define BUILDING_X 256
- #define BUILDING_Y 128
- #define BARGRAPH_X 266
- #define MAX_BAR_X 318 // max possible is 319 because of bar's right shadow
- #define SIZEGBAR 119
- #define HALLFAME_X 19
- #define HALLFAME_Y 120
- #define MULTISCOREX 30
- #define TEDIT_FAME 1
- #define NUMINFANTRYMEN 15
- #define NUMFAMENAMES 7
- #define MAX_FAMENAME_LENGTH 12
- struct InfantryAnim {
- int xpos;
- int ypos;
- void const *shapefile;
- void const *remap;
- int anim;
- int stage;
- char delay;
- InfantryTypeClass const *Class;
- } InfantryMan[NUMINFANTRYMEN];
- void Draw_InfantryMen(void);
- void Draw_InfantryMan(int index);
- void New_Infantry_Anim(int index, int anim);
- void Draw_Bar_Graphs(int i, int gkilled, int nkilled, int ckilled);
- void Animate_Cursor(int pos, int ypos);
- void Animate_Score_Objs(void);
- void Cycle_Wait_Click(void);
- int ScorePass;
- void const * Beepy6;
- int ControlQ; // cheat key to skip past score/mapsel screens
- bool StillUpdating;
- GraphicBufferClass *PseudoSeenBuff;
- GraphicBufferClass *TextPrintBuffer;
- #ifdef WRITE_LBM
- PUBLIC bool CCWrite_LBM_File(CCFileClass &lbmhandle, BufferClass& buff, short bitplanes, unsigned char *palette);
- #endif
- unsigned char RemapCiv[256]={
- 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
- 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0xD0,0x18,0x19,0xD1,0xD2,0xD3,0xD4,0x1E,0xD5,
- 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
- 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
- 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
- 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
- 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
- 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0xD6,0xD7,0xD8,0xD9,0x7E,0xDA,
- 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
- 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
- 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,
- 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
- 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
- 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xDB,0xDC,0xDD,0xDE,0xDB,0xDC,0xDD,0xDE,0xDF,
- 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
- 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF};
- unsigned char const ScoreRemapGrey[256] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0..15
- 16, 17, 18, 19, 20,176, 22,208, 24, 25,209,210,211,212, 30,213, // 16..31
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, // 32..47
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, // 48..63
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, // 64..79
- 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, // 80..95
- 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, // 96..111
- 112,113,114,115,116,117,118,119,120,121,214,215,216,217,149,218, // 112..127
- 128,129,130,131,132,133,134,135,136,137,138,108,140,141,142,143, // 128..143
- 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, // 144..159
- 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, // 160..175
- 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, // 176..191
- 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, // 192..207
- 208,209,210,211,212,213,214,219,220,221,222,219,220,221,222,223, // 208..223
- 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, // 224..239
- 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 // 240..255
- };
- unsigned char const ScoreRemapYellow[256] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0..15
- 16, 17, 18, 19, 20,176, 22,208, 24, 25,209,210,211,212, 30,213, // 16..31
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, // 32..47
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, // 48..63
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, // 64..79
- 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, // 80..95
- 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, // 96..111
- 112,113,114,115,116,117,118,119,120,121,214,215,216,217,149,218, // 112..127
- 128,129,130,131,132,133,134,135,136,137,138,108,140,141,142,143, // 128..143
- 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, // 144..159
- 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, // 160..175
- 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, // 176..191
- 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, // 192..207
- 208,209,210,211,212,213,214,219,220,221,222,219,220,221,222,223, // 208..223
- 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, // 224..239
- 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 // 240..255
- };
- unsigned char const ScoreRemapBldg[256]={
- 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
- 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
- 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
- 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
- 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
- 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
- 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
- 0x70,0x71,0xCE,0xC5,0x49,0x48,0x47,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,
- 0x80,0x81,0xB8,0x83,0x7C,0x7A,0x76,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
- 0x74,0x91,0x92,0x93,0x94,0x95,0xB5,0x97,0x98,0xCF,0x4B,0x7F,0x9C,0x9D,0x9E,0x9F,
- 0xA0,0xA1,0xA2,0x83,0x79,0xA5,0xA6,0xA7,0x43,0x99,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,
- 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
- 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
- 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xBB,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
- 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
- 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF
- };
- unsigned char const ScoreRemapFBall[256]={
- 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
- 0xB0,0xE5,0x82,0xE4,0xE3,0xE2,0xB1,0xD0,0xE1,0xE0,0xD1,0xD2,0xD3,0xD4,0xDF,0xD5,
- 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0xE6,0xE7,0xA0,0xE8,0x2E,0x2F,
- 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
- 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
- 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
- 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
- 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,
- 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
- 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
- 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,
- 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
- 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
- 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
- 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
- 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF
- };
- TextBlitClass BlitList;
- char *ScreenNames[2]={"S-GDIIN2.WSA","SCRSCN1.WSA"};
- //extern short StreamLowImpact;
- // ST - 1/3/2019 10:38AM
- int StreamLowImpact = FALSE;
- struct Fame {
- char name[MAX_FAMENAME_LENGTH];
- int score;
- int level;
- };
- ScoreAnimClass *ScoreObjs[MAXSCOREOBJS];
- ScoreAnimClass::ScoreAnimClass(int x, int y, void const * data)
- {
- BlitList.Add (x*2, y*2, x*2, y*2, 2* String_Pixel_Width ( (char*)data ) , 16);
- XPos = x;
- YPos = y;
- Timer.Set(0);
- Timer.Start();
- DataPtr = data;
- }
- ScoreTimeClass::ScoreTimeClass(int xpos, int ypos, void const * data, int max, int timer) :
- ScoreAnimClass(xpos, ypos, data)
- {
- Stage = 0;
- MaxStage = max;
- TimerReset = timer;
- }
- void ScoreTimeClass::Update(void)
- {
- GraphicViewPortClass *oldpage;
- if (!Timer.Time()) {
- Timer.Set(TimerReset);
- if (++Stage >= MaxStage) Stage = 0;
- oldpage = LogicPage;
- Set_Logic_Page(PseudoSeenBuff);
- CC_Draw_Shape(DataPtr, Stage, XPos, YPos, WINDOW_MAIN, SHAPE_WIN_REL, 0, 0);
- Set_Logic_Page(oldpage);
- }
- }
- ScoreCredsClass::ScoreCredsClass(int xpos, int ypos, void const * data, int max, int timer) :
- ScoreAnimClass(xpos, ypos, data)
- {
- Stage = 0;
- MaxStage = max;
- TimerReset = timer;
- Clock1 = MixFileClass::Retrieve("CLOCK1.AUD");
- CashTurn = MixFileClass::Retrieve("CASHTURN.AUD");
- }
- void ScoreCredsClass::Update(void)
- {
- GraphicViewPortClass *oldpage;
- if (!Timer.Time()) {
- Timer.Set(TimerReset);
- if (++Stage >= MaxStage) Stage = 0;
- oldpage = LogicPage;
- Set_Logic_Page(PseudoSeenBuff);
- if (Stage <22) {
- Play_Sample(Clock1, 255, Options.Normalize_Sound(70));
- } else {
- if (Stage==24) {
- Play_Sample(CashTurn, 255, Options.Normalize_Sound(70));
- }
- }
- CC_Draw_Shape(DataPtr,Stage, XPos, YPos, WINDOW_MAIN,SHAPE_WIN_REL, 0, 0);
- Set_Logic_Page(oldpage);
- }
- }
- ScorePrintClass::ScorePrintClass(int string, int xpos, int ypos, void const * palette, int background) :
- ScoreAnimClass(xpos, ypos, Text_String(string))
- {
- Background = background;
- PrimaryPalette = palette;
- Stage = 0;
- }
- ScorePrintClass::ScorePrintClass(void const * string, int xpos, int ypos, void const * palette, int background) :
- ScoreAnimClass(xpos, ypos, string)
- {
- Background = background;
- PrimaryPalette = palette;
- Stage = 0;
- }
- void ScorePrintClass::Update(void)
- {
- static char localstr[2]={0,0};
- static char _whitepal[]={0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F};
- if (Stage && (((char *)DataPtr)[Stage-1]==0) ) {
- for (int i = 0; i < MAXSCOREOBJS; i++) {
- if (ScoreObjs[i] == this) {
- ScoreObjs[i] = 0;
- }
- }
- BlitList.Add (XPos*2, YPos*2, XPos*2, YPos*2,(Stage*6)+14, 8*2);
- delete this;
- return;
- }
- StillUpdating = true;
- if (!Timer.Time()) {
- Timer.Set(1);
- int pos = XPos+(Stage*6);
- if (Stage) {
- localstr[0]=((char *)DataPtr)[Stage-1];
- /*
- ** Clear out the white letter overlay
- */
- static char const _blackpal[]={BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK};
- Set_Font_Palette(_blackpal);
- TextPrintBuffer->Print(localstr, 2*(pos-6),2*(YPos-1), TBLACK, TBLACK);
- TextPrintBuffer->Print(localstr, 2*(pos-6),2*(YPos+1), TBLACK, TBLACK);
- TextPrintBuffer->Print(localstr, 2*(pos-6+1),2*(YPos), TBLACK, TBLACK);
- Set_Font_Palette(PrimaryPalette);
- TextPrintBuffer->Print(localstr, 2*(pos-6),2*YPos, TBLACK, TBLACK);
- }
- if (((char *)DataPtr)[Stage]) {
- localstr[0]=((char *)DataPtr)[Stage];
- Set_Font_Palette(_whitepal);
- TextPrintBuffer->Print(localstr, pos*2, 2*(YPos-1), TBLACK, TBLACK);
- TextPrintBuffer->Print(localstr, pos*2, 2*(YPos+1), TBLACK, TBLACK);
- TextPrintBuffer->Print(localstr, (pos+1)*2,2*YPos , TBLACK, TBLACK);
- }
- Stage++;
- }
- }
- MultiStagePrintClass::MultiStagePrintClass(int string, int xpos, int ypos, void const * palette, int background) :
- ScoreAnimClass(xpos, ypos, Text_String(string))
- {
- Background = background;
- PrimaryPalette = palette;
- Stage = 0;
- }
- MultiStagePrintClass::MultiStagePrintClass(void const * string, int xpos, int ypos, void const * palette, int background) :
- ScoreAnimClass(xpos, ypos, string)
- {
- Background = background;
- PrimaryPalette = palette;
- Stage = 0;
- }
- void MultiStagePrintClass::Update(void)
- {
- static char localstr[2]={0,0};
- static char _whitepal[]={0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F};
- if (Stage && (((char *)DataPtr)[Stage-1]==0) ) {
- for (int i = 0; i < MAXSCOREOBJS; i++) {
- if (ScoreObjs[i] == this) {
- ScoreObjs[i] = 0;
- }
- }
- BlitList.Add (XPos*2, YPos*2, XPos*2, YPos*2,(Stage*6)+14, 8*2);
- delete this;
- return;
- }
- StillUpdating = true;
- if (!Timer.Time()) {
- Timer.Set(1);
- /*
- ** Do 10 stages at once
- */
- for (int wibble = 0 ; wibble < 10 ; wibble ++){
- int pos = XPos+(Stage*6);
- if (Stage) {
- localstr[0]=((char *)DataPtr)[Stage-1];
- /*
- ** Clear out the white letter overlay
- */
- static char const _blackpal[]={BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK,BLACK};
- Set_Font_Palette(_blackpal);
- TextPrintBuffer->Print(localstr, 2*(pos-6),2*(YPos-1), TBLACK, TBLACK);
- TextPrintBuffer->Print(localstr, 2*(pos-6),2*(YPos+1), TBLACK, TBLACK);
- TextPrintBuffer->Print(localstr, 2*(pos-6+1),2*(YPos), TBLACK, TBLACK);
- Set_Font_Palette(PrimaryPalette);
- TextPrintBuffer->Print(localstr, 2*(pos-6),2*YPos, TBLACK, TBLACK);
- }
- if (((char *)DataPtr)[Stage]) {
- localstr[0]=((char *)DataPtr)[Stage];
- Set_Font_Palette(_whitepal);
- TextPrintBuffer->Print(localstr, pos*2, 2*(YPos-1), TBLACK, TBLACK);
- TextPrintBuffer->Print(localstr, pos*2, 2*(YPos+1), TBLACK, TBLACK);
- TextPrintBuffer->Print(localstr, (pos+1)*2,2*YPos , TBLACK, TBLACK);
- }
- Stage++;
- if ( ( (char *) DataPtr) [Stage-1] == 0 ) break;
- }
- }
- }
- ScoreScaleClass::ScoreScaleClass(void const * string, int xpos, int ypos, char const palette[]) :
- ScoreAnimClass(xpos, ypos, string)
- {
- Palette = &palette[0];
- Stage = 5;
- }
- void ScoreScaleClass::Update(void)
- {
- static int _destx[]={0,80,107,134,180,228};
- static int _destw[]={6,20, 30, 40, 60, 80};
- /*
- ** Restore the background for the scaled-up letter
- */
- if (!Timer.Time()) {
- Timer.Set(1);
- if (Stage != 5) {
- TextPrintBuffer->Blit(HidPage, _destx[Stage+1]*2, YPos*2, _destx[Stage+1]*2, YPos*2, _destw[Stage+1]*2, _destw[Stage+1]*2);
- //SysMemPage.Blit(*PseudoSeenBuff, _destx[Stage+1], YPos, _destx[Stage+1], YPos, _destw[Stage+1], _destw[Stage+1]);
- }
- if (Stage) {
- Set_Font_Palette(Palette);
- TextPrintBuffer->Fill_Rect(0,0, 7*2,7*2, TBLACK);
- TextPrintBuffer->Print((char *)DataPtr, 0,0, TBLACK, TBLACK);
- TextPrintBuffer->Scale(HidPage, 0,0, _destx[Stage]*2, YPos*2, 5*2,5*2, _destw[Stage]*2, _destw[Stage]*2, true);
- //SysMemPage.Fill_Rect(0,0, 7,7, TBLACK);
- //SysMemPage.Print((char *)DataPtr, 0,0, TBLACK, TBLACK);
- //SysMemPage.Scale(*PseudoSeenBuff, 0,0, _destx[Stage], YPos, 5,5, _destw[Stage], _destw[Stage], true);
- Stage--;
- } else {
- Set_Font_Palette(Palette);
- for (int i = 0; i < MAXSCOREOBJS; i++) {
- if (ScoreObjs[i]==this) ScoreObjs[i] = 0;
- }
- TextPrintBuffer->Print((char *)DataPtr, XPos*2,YPos*2, TBLACK, TBLACK);
- //TextPrintBuffer->Blit(HidPage, XPos*2, YPos*2, XPos*2, YPos*2,2*6,2*6);
- //BlitList.Add (XPos, YPos, XPos, YPos, 6,6);
- //SysMemPage.Print((char *)DataPtr, XPos,YPos, TBLACK, TBLACK);
- //SysMemPage.Blit(*PseudoSeenBuff, XPos,YPos, XPos, YPos, 6,6);
- delete this;
- return;
- }
- }
- }
- int Alloc_Object(ScoreAnimClass *obj)
- {
- int i,ret;
- for (i = ret = 0; i < MAXSCOREOBJS; i++) {
- if (!ScoreObjs[i]) {
- ScoreObjs[i] = obj;
- ret = i;
- break;
- }
- }
- return(ret);
- }
- TextBlitClass::TextBlitClass (void)
- {
- Clear();
- }
- void TextBlitClass::Add (int x, int y, int dx, int dy, int w, int h)
- {
- if ( Count < MAX_ENTRIES ){
- BlitListo [Count].SourceX = x;
- BlitListo [Count].SourceY = y;
- BlitListo [Count].DestX = dx;
- BlitListo [Count].DestY = dy;
- BlitListo [Count].Width = w;
- BlitListo [Count].Height = h;
- Count++;
- }
- }
- void TextBlitClass::Clear(void)
- {
- Count = 0;
- }
- void TextBlitClass::Update(void)
- {
- if (TextPrintBuffer){
- if (HidPage.Lock()){
- for (int i=0 ; i<Count ; i++){
- TextPrintBuffer->Blit (HidPage, BlitListo[i].SourceX,
- BlitListo[i].SourceY,
- BlitListo[i].DestX,
- BlitListo[i].DestY,
- BlitListo[i].Width,
- BlitListo[i].Height,
- true);
- }
- HidPage.Unlock();
- }
- }
- }
- void Disable_Uncompressed_Shapes (void);
- void Enable_Uncompressed_Shapes (void);
- /***********************************************************************************************
- * ScoreClass::Presentation -- Main routine to display score screen. *
- * *
- * This is the main routine that displays the score screen graphics. *
- * It gets called at the end of each scenario and is used to present *
- * the results and a rating of the player's battle. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 05/02/1994 : Created. *
- *=============================================================================================*/
- void ScoreClass::Presentation(void)
- {
- //static char const _redpal[]={0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x21,0x2F};
- static char const _redpal[]={0x20,0x22,0x24,0x26,0x28,0x28,0x28,0x28,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x21,0x2F};
- static char const _greenpal[]={0x10,0x12,0x14,0x16,0x18,0x18,0x18,0x18,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x10,0x1F};
- static char const _bluepal[]={0x60,0x62,0x64,0x66,0x68,0x68,0x68,0x68,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x61,0x6F};
- //static char const _bluepal[]={0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x61,0x6F};
- static unsigned char const _yellowpal[]={0x0,0x0,0xEC,0x0,0xEB,0x0,0xEA,0x0,0xE9,0x0,0x0,0x0,0x0,0x0,0xED,0x0};
- static int const _casuax[2]={144,146};
- static int const _casuay[2]={ 78, 90};
- static int const _gditxx[2]={150,224};
- static int const _gditxy[2]={ 90, 90};
- static int const _nodtxx[2]={150,224};
- static int const _nodtxy[2]={102,102};
- // static int _bargrx[2]={297,SCORETEXT_X+64};
- // static int _bargry[2]={ 90,CASUALTY_Y + 2};
- static int const _bldggy[2]={138,128};
- static int const _bldgny[2]={150,140};
- // int gdikilled, nodkilled, civkilled, max, i, k, shapenum;
- int i;
- int max;
- void const * yellowptr;
- void const * redptr;
- CCFileClass file(FAME_FILE_NAME);
- struct Fame hallfame[NUMFAMENAMES];
- void *anim, *oldfont;
- int oldfontxspacing = FontXSpacing;
- int house = PlayerPtr->Class->House; // 0 or 1
- char inter_pal[15];
- /*
- ** Choose an appropriate palette file for the interpolation
- */
- if (house == HOUSE_GOOD){
- sprintf(inter_pal,"SCORPAL1.PAL");
- }else{
- sprintf(inter_pal,"SNODPAL1.PAL");
- }
- if (Special.IsJurassic && AreThingiesEnabled) return;
- PseudoSeenBuff = new GraphicBufferClass(320,200,(void*)NULL);
- TextPrintBuffer = new GraphicBufferClass(SeenBuff.Get_Width(), SeenBuff.Get_Height(), (void*)NULL);
- TextPrintBuffer->Clear();
- BlitList.Clear();
- Disable_Uncompressed_Shapes ();
- ControlQ = 0;
- FontXSpacing = 0;
- Map.Override_Mouse_Shape(MOUSE_NORMAL);
- Theme.Queue_Song(THEME_WIN1);
- VisiblePage.Clear();
- PseudoSeenBuff->Clear();
- SysMemPage.Clear();
- WWMouse->Erase_Mouse(&HidPage, TRUE);
- HiddenPage.Clear();
- Set_Palette(BlackPalette);
- Set_Logic_Page(SysMemPage);
- void const * country4 = MixFileClass::Retrieve("COUNTRY4.AUD");
- void const * sfx4 = MixFileClass::Retrieve("SFX4.AUD");
- Beepy6 = MixFileClass::Retrieve("BEEPY6.AUD");
- /*
- ** Load the background for the score screen
- */
- anim = Open_Animation(ScreenNames[house],NULL,0L,(WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE),Palette);
- unsigned minutes = (unsigned)((ElapsedTime / (long)TIMER_MINUTE))+1;
- /*
- ** Determine leadership rating.
- */
- unsigned leadership = 0;
- int index;
- for (index = 0; index < Logic.Count(); index++) {
- ObjectClass * object = Logic[index];
- if (object->Owner() == house) {
- leadership++;
- }
- }
- HouseClass *houses[3];
- for (index = 0; index < 3; index++) {
- houses[index] =(HouseClass::As_Pointer((HousesType)(HOUSE_GOOD+index)));
- }
- GKilled = (HouseClass::As_Pointer(HOUSE_GOOD))->UnitsLost;
- NKilled = (HouseClass::As_Pointer(HOUSE_BAD))->UnitsLost;
- CKilled = (HouseClass::As_Pointer(HOUSE_NEUTRAL))->UnitsLost;
- GBKilled = (HouseClass::As_Pointer(HOUSE_GOOD))->BuildingsLost;
- NBKilled = (HouseClass::As_Pointer(HOUSE_BAD))->BuildingsLost;
- CBKilled = (HouseClass::As_Pointer(HOUSE_NEUTRAL))->BuildingsLost;
- /*
- ** New - ST 6/12/96 2:40PM
- */
- GHarvested = (HouseClass::As_Pointer(HOUSE_GOOD))->HarvestedCredits;
- NHarvested = (HouseClass::As_Pointer(HOUSE_BAD))->HarvestedCredits;
- if (!leadership) leadership++;
- leadership = Cardinal_To_Fixed(GKilled+GBKilled+leadership, leadership);
- leadership = Fixed_To_Cardinal(100, leadership);
- if (leadership > 100) leadership = 100;
- /*
- ** Determine efficiency rating.
- */
- int gharv = GHarvested;
- int init = PlayerPtr->InitialCredits;
- int cred = PlayerPtr->Available_Money();
- unsigned efficiency = Cardinal_To_Fixed( (house == HOUSE_GOOD ? GHarvested : NHarvested) + (unsigned)PlayerPtr->InitialCredits+1, (unsigned)PlayerPtr->Available_Money()+1);
- if (!efficiency) efficiency++;
- efficiency = Fixed_To_Cardinal(100, efficiency);
- if (efficiency > 100) efficiency = 100;
- /*
- ** Calculate total score
- */
- long total = ((leadership * 40) + (4600) + (efficiency * 14))/100;
- if (!total) total++;
- total *= (BuildLevel+1);
- // Load up the shapes for the Nod score screen
- if (house == HOUSE_GOOD) {
- yellowptr = MixFileClass::Retrieve("BAR3YLW.SHP");
- redptr = MixFileClass::Retrieve("BAR3RED.SHP");
- }
- /* Change to the six-point font for Text_Print */
- oldfont = Set_Font(ScoreFontPtr);
- Call_Back();
- /* --- Now display the background animation --- */
- Hide_Mouse();
- Animate_Frame(anim, SysMemPage, 1);
- SysMemPage.Blit(*PseudoSeenBuff);
- Increase_Palette_Luminance (Palette , 30,30,30,63);
- InterpolationPalette = Palette;
- InterpolationPaletteChanged = TRUE;
- Read_Interpolation_Palette(inter_pal);
- Interpolate_2X_Scale( PseudoSeenBuff , &SeenBuff , inter_pal);
- Fade_Palette_To(Palette, FADE_PALETTE_FAST, Call_Back);
- Play_Sample(country4, 255, Options.Normalize_Sound(90));
- int frame = 1;
- StreamLowImpact = true;
- while (frame < Get_Animation_Frame_Count(anim)) {
- Animate_Frame(anim, *PseudoSeenBuff, frame++);
- ////////////////Interpolate_2X_Scale( PseudoSeenBuff , &SeenBuff , NULL);
- Call_Back_Delay(2);
- }
- StreamLowImpact = false;
- Call_Back();
- Close_Animation(anim);
- /*
- ** Background's up, so now load various shapes and animations
- */
- void const * timeshape = MixFileClass::Retrieve("TIME.SHP");
- ScoreObjs[0] = new ScoreTimeClass(233, 2, timeshape, 30, 4);
- void const * hiscore1shape = MixFileClass::Retrieve("HISCORE1.SHP");
- void const * hiscore2shape = MixFileClass::Retrieve("HISCORE2.SHP");
- ScoreObjs[1] = new ScoreTimeClass(4, 97, hiscore1shape, 10, 4);
- ScoreObjs[2] = new ScoreTimeClass(8, 172, hiscore2shape, 10, 4);
- /* Now display the stuff */
- PseudoSeenBuff->Blit(SysMemPage);
- if (house == HOUSE_BAD) {
- /*
- ** load the logo
- */
- void const * logoptr = MixFileClass::Retrieve("LOGOS.SHP");
- CC_Draw_Shape(logoptr, 1, 0, 0, WINDOW_MAIN, SHAPE_WIN_REL, 0, 0);
- Bit_It_In_Scale(0,0, 128,104-16, &SysMemPage, PseudoSeenBuff, &SeenBuff , 1);
- }
- Set_Logic_Page(PseudoSeenBuff);
- #ifdef FRENCH
- Alloc_Object(new ScorePrintClass(TXT_SCORE_TIME, 200, 3,_greenpal));
- #else
- Alloc_Object(new ScorePrintClass(TXT_SCORE_TIME, 206, 3,_greenpal));
- #endif
- Alloc_Object(new ScorePrintClass(TXT_SCORE_LEAD, 182, 26,_greenpal));
- Alloc_Object(new ScorePrintClass(TXT_SCORE_EFFI, 182, 38,_greenpal));
- Alloc_Object(new ScorePrintClass(TXT_SCORE_TOTA, 182, 50,_greenpal));
- Play_Sample(sfx4, 255, Options.Normalize_Sound(120));
- Call_Back_Delay(13);
- max = MAX((long)leadership, (long)efficiency);
- int scorecounter = 0;
- Keyboard::Clear();
- BlitList.Add (264*2, 26*2, 264*2, 26*2, 4*12 , 12);
- BlitList.Add (264*2, 38*2, 264*2, 38*2, 4*12 , 12);
- BlitList.Add (264*2, 50*2, 264*2, 50*2, 4*12 , 12);
- BlitList.Add (275*2, 9*2, 275*2, 9*2, 64, 12 ); //Minutes
- for (i = 0; i <= 160; i++) {
- Set_Font_Palette(_greenpal);
- Count_Up_Print("%3d%%", i, leadership, 264, 26);
- if (i>=30) Count_Up_Print("%3d%%", i-30, efficiency, 264, 38);
- if (i>=60) {
- Count_Up_Print("%3d",scorecounter, total, 264, 50);
- scorecounter += total/100;
- }
- Print_Minutes(minutes);
- Call_Back_Delay(1);
- Play_Sample(Beepy6, 255, Options.Normalize_Sound(60));
- if (Check_Key() && i < (max-5) ) {
- i=158;
- Keyboard::Clear();
- }
- }
- Count_Up_Print("%3d", total, total, 264, 50);
- Call_Back_Delay(60);
- if (house == HOUSE_BAD) Show_Credits(house, _greenpal);
- Call_Back_Delay(60);
- /*
- ** Show stats on # of units killed
- */
- Set_Logic_Page(*PseudoSeenBuff);
- Play_Sample(sfx4, 255, Options.Normalize_Sound(90));
- Alloc_Object(new ScorePrintClass(TXT_SCORE_CASU, _casuax[house], _casuay[house],_redpal));
- Call_Back_Delay(9);
- if (house == HOUSE_BAD) {
- Alloc_Object(new ScorePrintClass(TXT_SCORE_NEUT, 200, 114,_redpal));
- Call_Back_Delay(4);
- }
- Alloc_Object(new ScorePrintClass(TXT_SCORE_GDI, _gditxx[house], _gditxy[house],_redpal));
- Alloc_Object(new ScorePrintClass(TXT_SCORE_NOD, _nodtxx[house], _nodtxy[house],_redpal));
- Call_Back_Delay(6);
- Set_Font_Palette(_redpal);
- if (house == HOUSE_BAD) {
- Do_Nod_Casualties_Graph();
- } else {
- Do_GDI_Graph(yellowptr, redptr, GKilled + CKilled, NKilled, 88);
- }
- Set_Logic_Page(*PseudoSeenBuff);
- /*
- ** Print out stats on buildings destroyed
- */
- Play_Sample(sfx4, 255, Options.Normalize_Sound(90));
- if (house == HOUSE_GOOD) {
- Alloc_Object(new ScorePrintClass(TXT_SCORE_BUIL, 144, 126,_greenpal));
- Call_Back_Delay(9);
- } else {
- Alloc_Object(new ScorePrintClass(TXT_SCORE_BUIL1, 146, 128,_greenpal));
- Alloc_Object(new ScorePrintClass(TXT_SCORE_BUIL2, 146, 136,_greenpal));
- Call_Back_Delay(9);
- Alloc_Object(new ScorePrintClass(TXT_SCORE_NEUT, 200, 152,_greenpal));
- Call_Back_Delay(4);
- }
- Alloc_Object(new ScorePrintClass(TXT_SCORE_GDI, _gditxx[house], _bldggy[house],_greenpal));
- Alloc_Object(new ScorePrintClass(TXT_SCORE_NOD, _gditxx[house], _bldgny[house],_greenpal));
- Call_Back_Delay(7);
- if (house==HOUSE_BAD) {
- Call_Back_Delay(6);
- Set_Font_Palette(_greenpal);
- Do_Nod_Buildings_Graph();
- } else {
- Do_GDI_Graph(yellowptr, redptr, GBKilled + CBKilled, NBKilled, 136);
- }
- // Wait for text printing to complete
- while (StillUpdating){
- Call_Back_Delay(1);
- }
- if (Keyboard::Check()) Keyboard::Clear();
- if (house == HOUSE_GOOD) Show_Credits(house, _greenpal);
- /*
- ** Hall of fame display and processing
- */
- Play_Sample(sfx4, 255, Options.Normalize_Sound(90));
- Alloc_Object(new ScorePrintClass(TXT_SCORE_TOP, 28, 110,_bluepal));
- Call_Back_Delay(9);
- /*
- ** First check for the existence of the file, and if there isn't one,
- ** make a new one filled with blanks.
- */
- if (!file.Is_Available()) {
- // hall of fame doesn't exist, so blank it out & write it
- file.Open(WRITE);
- for (i = 0; i < NUMFAMENAMES; i++) {
- hallfame[i].name[0] =
- hallfame[i].score =
- hallfame[i].level = 0;
- file.Write(&hallfame[i], sizeof(struct Fame));
- }
- file.Close();
- }
- file.Open(READ);
- for (i = 0; i < NUMFAMENAMES; i++) {
- file.Read(&hallfame[i], sizeof(struct Fame));
- }
- file.Close();
- /*
- ** If the player's score is good enough to bump someone off the list,
- ** remove their data, move everyone down a notch, and set index = where
- ** their info goes
- */
- if(hallfame[NUMFAMENAMES-1].score >= total)
- hallfame[NUMFAMENAMES-1].score = 0;
- for (index = 0; index < NUMFAMENAMES; index++) {
- if (total > hallfame[index].score) {
- if (index < (NUMFAMENAMES-1)) for (i = (NUMFAMENAMES-1); i > index; i--) hallfame[i] = hallfame[i-1];
- hallfame[index].score = total;
- hallfame[index].level = Scenario;
- // hallfame[index].level = BuildLevel;
- //hallfame[index].name[0] = 0; // blank out the name
- memset (hallfame[index].name, ' ', sizeof (hallfame[index].name) -1);
- hallfame[index].name[sizeof (hallfame[index].name)-1] = 0;
- break;
- }
- }
- /*
- ** Now display the hall of fame
- */
- Set_Logic_Page(*PseudoSeenBuff);
- for (i = 0; i < NUMFAMENAMES; i++) {
- Alloc_Object(new ScorePrintClass(hallfame[i].name, HALLFAME_X, HALLFAME_Y + (i*8), _bluepal));
- if (hallfame[i].score) {
- char *str = (char *)(SysMemPage.Get_Buffer()) + i*32;
- sprintf(str,"%d", hallfame[i].score);
- Alloc_Object(new ScorePrintClass(str, HALLFAME_X+(6*15), HALLFAME_Y + (i*8), _bluepal, BLACK));
- if (hallfame[i].level < 20) {
- sprintf(str+16,"%d", hallfame[i].level);
- } else {
- strcpy(str+16, "**");
- }
- Alloc_Object(new ScorePrintClass(str+16, HALLFAME_X+(6*12), HALLFAME_Y + (i*8), _bluepal, BLACK));
- Call_Back_Delay(13);
- }
- }
- // Wait for text printing to complete
- while (StillUpdating){
- Call_Back_Delay(1);
- }
- /*
- ** If the player's on the hall of fame, have him enter his name now
- */
- Keyboard::Clear();
- if (index < NUMFAMENAMES) {
- Input_Name(hallfame[index].name, HALLFAME_X, HALLFAME_Y + (index*8), _bluepal);
- file.Open(WRITE);
- for (i = 0; i < NUMFAMENAMES; i++) {
- file.Write(&hallfame[i], sizeof(struct Fame));
- }
- file.Close();
- } else {
- #ifdef FRENCH
- Alloc_Object(new ScorePrintClass(TXT_MAP_CLICK2, 145, 190, _yellowpal));
- #else
- Alloc_Object(new ScorePrintClass(TXT_MAP_CLICK2, 149, 190, _yellowpal));
- #endif
- Cycle_Wait_Click();
- }
- #ifdef WRITE_LBM
- file.Open("e:scorscrn.lbm",WRITE);
- SeenBuff.Blit(SysMemPage,0,0, 0,0, 320,200);
- CCWrite_LBM_File(file, SysMemPage, 8, Palette);
- file.Close();
- #endif
- Keyboard::Clear();
- /* get rid of all the animating objects */
- for (i = 0; i < MAXSCOREOBJS; i++) if (ScoreObjs[i]) {
- delete ScoreObjs[i];
- ScoreObjs[i] = 0;
- }
- Fade_Palette_To(BlackPalette, FADE_PALETTE_FAST, NULL);
- VisiblePage.Clear();
- Show_Mouse();
- // Map_Selection();
- Theme.Queue_Song(THEME_NONE);
- Fade_Palette_To(BlackPalette, FADE_PALETTE_FAST, NULL);
- VisiblePage.Clear();
- Set_Palette(GamePalette);
- Set_Font(oldfont);
- FontXSpacing = oldfontxspacing;
- ControlQ = 0;
- Set_Logic_Page (SeenBuff);
- delete PseudoSeenBuff;
- delete TextPrintBuffer;
- TextPrintBuffer = NULL;
- BlitList.Clear();
- Enable_Uncompressed_Shapes();
- }
- // ST = 12/17/2018 5:44PM
- #ifndef TickCount
- extern TimerClass TickCount;
- #endif
- void Cycle_Wait_Click(void)
- {
- int counter = 0;
- int minclicks = 20;
- unsigned long timingtime = TickCount.Time();
- //SerialPacketType sendpacket;
- //SerialPacketType receivepacket;
- //int packetlen;
- Keyboard::Clear();
- while (minclicks || (!Check_Key() && !ControlQ) ) {
- if (GameToPlay == GAME_NULL_MODEM ||
- GameToPlay == GAME_MODEM){
- //GameToPlay == GAME_INTERNET) {
- #if (0) //PG_TO_FIX
- //
- // send a timing packet if enough time has gone by.
- //
- if ( (TickCount.Time() - timingtime) > PACKET_TIMING_TIMEOUT) {
- sendpacket.Command = SERIAL_SCORE_SCREEN;
- sendpacket.ResponseTime = NullModem.Response_Time();
- sendpacket.ID = ModemGameToPlay;
- NullModem.Send_Message (&sendpacket, sizeof(sendpacket), 0);
- timingtime = TickCount.Time();
- }
- if (NullModem.Get_Message (&receivepacket, &packetlen) > 0) {
- // throw packet away
- packetlen = packetlen;
- }
- NullModem.Service();
- #endif
- }
- Call_Back_Delay(1);
- if (minclicks) {
- minclicks--;
- Keyboard::Clear();
- }
- counter = ((++counter) & 7);
- if (!counter) {
- unsigned char r,g,b;
- r = Palette[233*3+0];
- g = Palette[233*3+1];
- b = Palette[233*3+2];
- for (int i = 233; i < 237; i++) {
- Palette[i*3+0] = Palette[(i+1)*3+0];
- Palette[i*3+1] = Palette[(i+1)*3+1];
- Palette[i*3+2] = Palette[(i+1)*3+2];
- }
- Palette[237*3+0] = r;
- Palette[237*3+1] = g;
- Palette[237*3+2] = b;
- Set_Palette(Palette);
- }
- }
- Keyboard::Clear();
- }
- void ScoreClass::Do_Nod_Buildings_Graph(void)
- {
- int shapenum;
- InfantryTypeClass const *ramboclass;
- void const * factptr = MixFileClass::Retrieve("FACT.SHP");
- void const * rmboptr = MixFileClass::Retrieve("RMBO.SHP");
- void const * fball1ptr = MixFileClass::Retrieve("FBALL1.SHP");
- ramboclass = &InfantryTypeClass::As_Reference(INFANTRY_E5);
- /*
- ** Print the # of buildings on the hidpage so we only need to do it once
- */
- PseudoSeenBuff->Blit(SysMemPage);
- Set_Logic_Page(SysMemPage);
- Call_Back_Delay(30);
- BlitList.Add (2* (BUILDING_X + 8), 2* (BUILDING_Y), 2* (BUILDING_X+8), 2* (BUILDING_Y), 5*12 , 12);
- BlitList.Add (2* (BUILDING_X + 8), 2* (BUILDING_Y + 12), 2* (BUILDING_X+8), 2* (BUILDING_Y + 12), 5*12 , 12);
- BlitList.Add (2* (BUILDING_X + 8), 2* (BUILDING_Y + 24), 2* (BUILDING_X+8), 2* (BUILDING_Y + 24), 5*12 , 12);
- TextPrintBuffer->Print( 0, (BUILDING_X + 8)*2, BUILDING_Y*2, TBLACK, TBLACK);
- TextPrintBuffer->Print( 0, (BUILDING_X + 8)*2, (BUILDING_Y + 12)*2, TBLACK, TBLACK);
- TextPrintBuffer->Print( 0, (BUILDING_X + 8)*2, (BUILDING_Y + 24)*2, TBLACK, TBLACK);
- /*
- ** Here's the animation/draw loop for blowing up the factory
- */
- int i;
- for (i=0; i<98; i++) {
- SysMemPage.Blit(SysMemPage, BUILDING_X, BUILDING_Y, 0, 0, 320-BUILDING_X,48);
- shapenum = 0; // no damage
- if (i >= 60) {
- shapenum = Extract_Shape_Count(factptr) - 2; // some damage
- if (i == 60) {
- Shake_The_Screen(6);
- Sound_Effect(VOC_CRUMBLE, VOL_FULL, 0);
- }
- if (i > 65) {
- shapenum = Extract_Shape_Count(factptr) - 1; // mega damage
- }
- }
- /*
- ** Draw the building before Rambo
- */
- if (i < 68) {
- CC_Draw_Shape(factptr,shapenum, 0, 0, WINDOW_MAIN,
- SHAPE_FADING|SHAPE_WIN_REL, ScoreRemapBldg,Map.UnitShadow);
- }
- /*
- ** Now draw some fires, if appropriate
- */
- if (i >= 61) {
- int firecount = Extract_Shape_Count(fball1ptr);
- int shapeindex = (i-61)>>1;
- if (shapeindex < firecount) {
- CC_Draw_Shape(fball1ptr, shapeindex, 10, 10, WINDOW_MAIN,
- SHAPE_FADING|SHAPE_CENTER|SHAPE_WIN_REL,//|SHAPE_GHOST,
- ScoreRemapFBall,0);
- }
- if (i > 64) {
- shapeindex = (i-64)>>1;
- if (shapeindex < firecount) {
- CC_Draw_Shape(fball1ptr, shapeindex, 50, 30, WINDOW_MAIN,
- SHAPE_FADING|SHAPE_CENTER|SHAPE_WIN_REL,//|SHAPE_GHOST,
- ScoreRemapFBall,0);
- }
- }
- }
- /*
- ** Draw the Rambo character running away from the building
- */
- CC_Draw_Shape(rmboptr, (ramboclass->DoControls[DO_WALK].Frame + ramboclass->DoControls[DO_WALK].Jump*6) + ((i>>1)%ramboclass->DoControls[DO_WALK].Count),
- i+32, 40, WINDOW_MAIN,
- SHAPE_FADING|SHAPE_CENTER|SHAPE_WIN_REL,//|SHAPE_GHOST,
- ScoreRemapYellow,Map.UnitShadow);
- SysMemPage.Blit(*PseudoSeenBuff, 0, 0, BUILDING_X, BUILDING_Y, 320-BUILDING_X,48);
- /*
- ** Extra font related stuff. ST - 7/29/96 2:22PM
- */
- Interpolate_2X_Scale(PseudoSeenBuff , &HidPage ,NULL);
- BlitList.Update();
- WWMouse->Draw_Mouse(&HidPage);
- Blit_Hid_Page_To_Seen_Buff();
- WWMouse->Erase_Mouse(&HidPage, TRUE);
- //Interpolate_2X_Scale( PseudoSeenBuff , &SeenBuff , NULL);
- if (!Check_Key()) Call_Back_Delay(1);
- }
- i = MAX(GBKilled, NBKilled);
- i = MAX(i, CBKilled);
- for (int q = 0; q <= i; q++) {
- Count_Up_Print( "%d", q, GBKilled,BUILDING_X + 8,BUILDING_Y );
- Count_Up_Print( "%d", q, NBKilled,BUILDING_X + 8,BUILDING_Y + 12);
- Count_Up_Print( "%d", q, CBKilled,BUILDING_X + 8,BUILDING_Y + 24);
- if (!Check_Key()) {
- Play_Sample(Beepy6, 255, Options.Normalize_Sound(110));
- Call_Back_Delay(1);
- }
- }
- }
- /***************************************************************************
- * DO_GDI_GRAPH -- Show # of people or buildings killed on GDI score screen*
- * *
- * *
- * *
- * INPUT: yellowptr, redptr = pointers to shape file for graphs *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 05/03/1995 BWG : Created. *
- *=========================================================================*/
- void ScoreClass::Do_GDI_Graph(void const * yellowptr, void const * redptr, int gkilled, int nkilled, int ypos)
- {
- int i, max;
- int gdikilled = gkilled, nodkilled=nkilled;
- max = MAX(gdikilled, nodkilled);
- if (!max) max=1;
- gdikilled = (gdikilled * SIZEGBAR) / max;
- nodkilled = (nodkilled * SIZEGBAR) / max;
- if (max < 20) {
- gdikilled = gkilled * 5;
- nodkilled = nkilled * 5;
- }
- max = MAX(gdikilled, nodkilled);
- if (!max) max=1;
- // Draw the white-flash shape on the hidpage
- Set_Logic_Page(SysMemPage);
- SysMemPage.Fill_Rect(0,0, 124,9, TBLACK);
- CC_Draw_Shape(redptr, 120, 0,0, WINDOW_MAIN,SHAPE_WIN_REL, 0, 0);
- Set_Logic_Page(PseudoSeenBuff);
- BlitList.Add (2* 297, 2* (ypos+2), 2* 297, 2* (ypos+2), 5*12 , 12);
- for (i = 1; i <= gdikilled; i++) {
- if (i != gdikilled) {
- CC_Draw_Shape(yellowptr,i, 172, ypos, WINDOW_MAIN,SHAPE_WIN_REL, 0, 0);
- } else {
- SysMemPage.Blit(*PseudoSeenBuff,0,0, 172, ypos, 3+gdikilled,9);
- }
- Count_Up_Print("%d", (i*gkilled) / max, gkilled, 297, ypos+2);
- if (!Check_Key()) {
- Play_Sample(Beepy6, 255, Options.Normalize_Sound(110));
- Call_Back_Delay(2);
- }
- }
- CC_Draw_Shape(yellowptr,gdikilled, 172,ypos , WINDOW_MAIN,SHAPE_WIN_REL, 0, 0);
- Count_Up_Print("%d", gkilled, gkilled, 297, ypos+ 2);
- if (!Check_Key()) Call_Back_Delay(40);
- BlitList.Add (2* 297, 2* (ypos+14), 2* 297, 2* (ypos+14), 5*12 , 12);
- for (i = 1; i <= nodkilled; i++) {
- if (i != nodkilled) {
- CC_Draw_Shape(redptr, i, 172, ypos+12, WINDOW_MAIN,SHAPE_WIN_REL, 0, 0);
- } else {
- SysMemPage.Blit(*PseudoSeenBuff,0,0, 172,ypos+12, 3+nodkilled,9);
- }
- Count_Up_Print("%d", (i*nkilled) / max, nkilled, 297, ypos+14);
- if (!Check_Key()) {
- Play_Sample(Beepy6, 255, Options.Normalize_Sound(110));
- Call_Back_Delay(2);
- }
- }
- // if (Keyboard::Check()) Keyboard::Clear();
- /*
- ** Make sure accurate count is printed at end
- */
- CC_Draw_Shape( redptr,nodkilled, 172,ypos+12, WINDOW_MAIN,SHAPE_WIN_REL, 0, 0);
- Count_Up_Print("%d", nkilled, nkilled, 297, ypos+14);
- if (!Check_Key()) Call_Back_Delay(40);
- }
- void ScoreClass::Do_Nod_Casualties_Graph(void)
- {
- int i, gdikilled, nodkilled, civkilled, max;
- void const * e1ptr = MixFileClass::Retrieve("E1.SHP");
- void const * c1ptr = MixFileClass::Retrieve("C1.SHP");
- gdikilled = GKilled;
- nodkilled = NKilled;
- civkilled = CKilled;
- max = MAX(gdikilled, nodkilled);
- max = MAX(max, civkilled);
- if (!max) max=1;
- if ((gdikilled > (MAX_BAR_X - BARGRAPH_X)) || (nodkilled > (MAX_BAR_X - BARGRAPH_X)) || (civkilled > (MAX_BAR_X - BARGRAPH_X))) {
- gdikilled = (gdikilled * (MAX_BAR_X - BARGRAPH_X)) / max;
- nodkilled = (nodkilled * (MAX_BAR_X - BARGRAPH_X)) / max;
- civkilled = (civkilled * (MAX_BAR_X - BARGRAPH_X)) / max;
- }
- max = MAX(gdikilled, nodkilled);
- max = MAX(max, civkilled);
- if (!max) max=1;
- /*
- ** Initialize a bunch of objects for the infantrymen who pose for the bar
- ** graphs of casualties.
- */
- int q = NUMINFANTRYMEN/3;
- int r = q*2;
- for (i = 0; i < NUMINFANTRYMEN/3; i++) {
- InfantryMan[i+0].xpos =
- InfantryMan[i+q].xpos =
- InfantryMan[i+r].xpos = (i*10) + 7;
- InfantryMan[i+0].ypos = 11;
- InfantryMan[i+q].ypos = 21;
- InfantryMan[i+r].ypos = 31;
- InfantryMan[i+0].shapefile =
- InfantryMan[i+q].shapefile = e1ptr;
- InfantryMan[i+r].shapefile = c1ptr;
- InfantryMan[i+0].remap = ScoreRemapYellow;
- InfantryMan[i+q].remap = ScoreRemapGrey;
- InfantryMan[i+r].remap = RemapCiv;
- InfantryMan[i+0].anim =
- InfantryMan[i+q].anim =
- InfantryMan[i+r].anim = 0;
- InfantryMan[i+0].stage =
- InfantryMan[i+q].stage =
- InfantryMan[i+r].stage = 0;
- InfantryMan[i+0].delay =
- InfantryMan[i+q].delay =
- InfantryMan[i+r].delay = Random() & 0x1F;
- InfantryMan[i+0].Class =
- InfantryMan[i+q].Class = &InfantryTypeClass::As_Reference(INFANTRY_E1);
- InfantryMan[i+r].Class = &InfantryTypeClass::As_Reference(INFANTRY_C1);
- }
- /*
- ** Draw the infantrymen and pause briefly before running the graph
- */
- Draw_InfantryMen();
- SysMemPage.Blit(*PseudoSeenBuff, 0, 0, BARGRAPH_X, CASUALTY_Y, 320-BARGRAPH_X, 34);
- //Interpolate_2X_Scale( PseudoSeenBuff , &SeenBuff, NULL);
- /*
- ** Extra font related stuff. ST - 7/29/96 2:22PM
- */
- Interpolate_2X_Scale(PseudoSeenBuff , &HidPage ,NULL);
- BlitList.Update();
- WWMouse->Draw_Mouse(&HidPage);
- Blit_Hid_Page_To_Seen_Buff();
- WWMouse->Erase_Mouse(&HidPage, TRUE);
- Call_Back_Delay(40);
- BlitList.Add (2* (SCORETEXT_X + 64), 2* (CASUALTY_Y + 2), 2* (SCORETEXT_X + 64), 2* (CASUALTY_Y + 2), 5*12 , 12);
- BlitList.Add (2* (SCORETEXT_X + 64), 2* (CASUALTY_Y + 14), 2* (SCORETEXT_X + 64), 2* (CASUALTY_Y + 14), 5*12 , 12);
- BlitList.Add (2* (SCORETEXT_X + 64), 2* (CASUALTY_Y + 26), 2* (SCORETEXT_X + 64), 2* (CASUALTY_Y + 26), 5*12 , 12);
- for (i = 1; i <= max; i++) {
- // Draw & update infantrymen 3 times for every tick on the graph (i)
- for (int q = 0; q < 3; q++) {
- Draw_InfantryMen();
- Draw_Bar_Graphs(i, gdikilled, nodkilled, civkilled);
- SysMemPage.Blit(*PseudoSeenBuff, 0, 0, BARGRAPH_X, CASUALTY_Y, 320-BARGRAPH_X, 34);
- Count_Up_Print("%d", (i*GKilled) / max, GKilled, SCORETEXT_X+64, CASUALTY_Y + 2);
- Count_Up_Print("%d", (i*NKilled) / max, NKilled, SCORETEXT_X+64, CASUALTY_Y + 14);
- Count_Up_Print("%d", (i*CKilled) / max, CKilled, SCORETEXT_X+64, CASUALTY_Y + 26);
- if (!Check_Key()) Call_Back_Delay(3);
- }
- Play_Sample(Beepy6, 255, Options.Normalize_Sound(110));
- }
- if (Check_Key()) Keyboard::Clear();
- /*
- ** Make sure accurate count is printed at end
- */
- Count_Up_Print("%d", GKilled, GKilled, SCORETEXT_X+64, CASUALTY_Y + 2);
- Count_Up_Print("%d", NKilled, NKilled, SCORETEXT_X+64, CASUALTY_Y + 14);
- Count_Up_Print("%d", CKilled, CKilled, SCORETEXT_X+64, CASUALTY_Y + 26);
- /*
- ** Finish up death animations, if there are any active
- */
- int k = 1;
- while (k) {
- for (i=k=0; i<NUMINFANTRYMEN; i++) if (InfantryMan[i].anim >= DO_GUN_DEATH) k=1;
- if (k) Draw_InfantryMen();
- Draw_Bar_Graphs(max, gdikilled, nodkilled, civkilled);
- SysMemPage.Blit(*PseudoSeenBuff, 0, 0, BARGRAPH_X, CASUALTY_Y, 320-BARGRAPH_X, 34);
- Call_Back_Delay(1);
- }
- }
- void ScoreClass::Show_Credits(int house, char const pal[])
- {
- static int _credsx[2]={276,276};
- static int _credsy[2]={173,58};
- static int _credpx[2]={228,236};
- #ifdef GERMAN
- static int _credpy[2]={181, 74};
- static int _credtx[2]={162,162};
- static int _credty[2]={173, 62};
- #else
- static int _credpy[2]={189-12, 74};
- static int _credtx[2]={182,182};
- static int _credty[2]={179-12, 62};
- #endif
- int credobj,i;
- int min,add;
- void const * credshape = MixFileClass::Retrieve("CREDS.SHP");
- Alloc_Object(new ScorePrintClass(TXT_SCORE_ENDCRED, _credtx[house], _credty[house],pal));
- Call_Back_Delay(15);
- credobj = Alloc_Object(new ScoreCredsClass(_credsx[house], _credsy[house], credshape, 32, 2));
- min = PlayerPtr->Available_Money() / 100;
- /*
- ** Print out total credits left at end of scenario
- */
- i = -50;
- BlitList.Add (2* (_credpx[house]), 2* (_credpy[house]), 2* (_credpx[house]), 2* (_credpy[house]), 5*12 , 12);
- do {
- add = 5;
- if ((PlayerPtr->Available_Money() - i) > 100 ) add += 15;
- if ((PlayerPtr->Available_Money() - i) > 1000) add += 30;
- if (add < min) add = min;
- i += add;
- if (i < 0) i=0;
- Set_Font_Palette(pal);
- Count_Up_Print("%d", i, PlayerPtr->Available_Money(), _credpx[house], _credpy[house]);
- Call_Back_Delay(2);
- if (Check_Key()) {
- i=PlayerPtr->Available_Money() - 5;
- Keyboard::Clear();
- }
- } while (i < PlayerPtr->Available_Money()) ;
- // Make sure the credits object doesn't freeze on the white stage
- while (((ScoreTimeClass *)ScoreObjs[credobj])->Stage >= 20 && !ControlQ) {
- Call_Back_Delay(1);
- }
- delete ScoreObjs[credobj];
- ScoreObjs[credobj] = 0;
- }
- /***************************************************************************
- * SCORECLASS::PRINT_MINUTES -- Print out hours/minutes up to max *
- * *
- * Same as count-up-print, but for the time *
- * *
- * INPUT: current minute count and maximum *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 04/13/1995 BWG : Created. *
- *=========================================================================*/
- void ScoreClass::Print_Minutes(int minutes)
- {
- char str[20];
- if (minutes >= 60) {
- if ((minutes/60) > 9) minutes = (9*60 + 59);
- sprintf(str,Text_String(TXT_SCORE_TIMEFORMAT1), (minutes / 60),(minutes % 60));
- } else {
- sprintf(str,Text_String(TXT_SCORE_TIMEFORMAT2), minutes);
- }
- TextPrintBuffer->Print(str, 275*2, 9*2, TBLACK, TBLACK);
- }
- /***********************************************************************************************
- * ScoreClass::Count_Up_Print -- Prints a number (up to its max) into a string, cleanly. *
- * *
- * This routine prints out a number (like 70) or its maximum number, into a string, onto *
- * the screen, on a clean section of the screen, and blits it forward to the seenpage so you*
- * can print without flashing and can print over something (to count up %'s). *
- * *
- * INPUT: str = string to print into *
- * percent = # to print *
- * max = # to print if percent > max *
- * xpos = x pixel coord *
- * ypos = y pixel coord *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 04/07/1995 BWG : Created. *
- *=============================================================================================*/
- void ScoreClass::Count_Up_Print(char *str, int percent, int max, int xpos, int ypos)
- {
- char destbuf[64];
- int width;
- sprintf(destbuf, str, percent <= max ? percent : max);
- width = strlen(destbuf) * 7;
- // HidPage.Blit(HidPage, xpos, ypos, 0, 0, width, 8);
- // Set_Logic_Page(HidPage);
- // LogicPage->Print( destbuf, 0, 0, WHITE, TBLACK);
- // HidPage.Blit(SeenBuff, 0, 0, xpos, ypos, width, 8);
- TextPrintBuffer->Fill_Rect (xpos*2, ypos*2, (xpos + width)*2, (ypos+7)*2, BLACK);
- TextPrintBuffer->Print (destbuf, xpos*2, ypos*2, WHITE, TBLACK);
- //TextPrintBuffer->Blit(*TextPrintBuffer, xpos*2, ypos*2, 0, 0, width*2, 8*2);
- //TextPrintBuffer->Print(destbuf, 0, 0, WHITE, TBLACK);
- //TextPrintBuffer->Blit(SeenBuff, 0, 0, xpos*2, ypos*2, width*2, 8*2);
- // PseudoSeenBuff->Print( destbuf, xpos, ypos, TBLACK, BLACK);
- // Interpolate_2X_Scale( PseudoSeenBuff , &SeenBuff , NULL);
- }
- /***********************************************************************************************
- * ScoreClass::Input_Name -- Gets the name from the keyboard *
- * *
- * This routine handles keyboard input, and does a nifty zooming letter effect too. *
- * *
- * INPUT: str = string to put user's typing into *
- * xpos = x pixel coord *
- * ypos = y pixel coord *
- * pal = text remapping palette to print using *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 05/15/1995 BWG : Created. *
- *=============================================================================================*/
- void ScoreClass::Input_Name(char str[], int xpos, int ypos, char const pal[])
- {
- int key, ascii, index=0;
- void const * keystrok = MixFileClass::Retrieve("KEYSTROK.AUD");
- /*
- ** Ready the hidpage so it can restore background under zoomed letters
- */
- PseudoSeenBuff->Blit(SysMemPage);
- do {
- Call_Back();
- Animate_Score_Objs();
- Animate_Cursor(index, ypos);
- /*
- ** Extra font related stuff. ST - 7/29/96 2:22PM
- */
- Interpolate_2X_Scale (PseudoSeenBuff , &HidPage ,NULL);
- BlitList.Update();
- Blit_Hid_Page_To_Seen_Buff();
- if (Check_Key()) { //if (Keyboard::Check()) {
- key = Get_Key(); //key = Keyboard::Get();
- if (index == MAX_FAMENAME_LENGTH-2) {
- while (Check_Key()) {
- Get_Key();
- }
- }
- /*
- ** If they hit 'backspace' when they're on the last letter,
- ** turn it into a space instead.
- */
- if ((key == KA_BACKSPACE) && (index == MAX_FAMENAME_LENGTH-2) ) {
- if (str[index] && str[index]!=32) key = 32;
- }
- if (key == KA_BACKSPACE) { //if (key == KN_BACKSPACE) {
- if (index) {
- str[--index] = 0;
- int xposindex6 = xpos+(index*6);
- PseudoSeenBuff->Fill_Rect(xposindex6,ypos,xposindex6+6,ypos+6,TBLACK);
- SysMemPage.Fill_Rect(xposindex6,ypos,xposindex6+6,ypos+6,TBLACK);
- TextPrintBuffer->Fill_Rect(xposindex6*2,ypos*2,(xposindex6+6)*2,(ypos+6)*2, BLACK);
- }
- } else if (key!=KA_RETURN) { //else if (key != KN_RETURN && key!=KN_KEYPAD_RETURN) {
- ascii = key; //ascii = KN_To_KA(key);
- if (ascii >= 'a' && ascii <= 'z') ascii -= ('a' - 'A');
- //if (ascii >='A' && ascii<='Z' || ascii == ' ') {
- if ( (ascii >= '!' && ascii <= KA_TILDA) || ascii == ' ') {
- PseudoSeenBuff->Fill_Rect(xpos + (index*6), ypos, xpos + (index*6)+6, ypos+5, TBLACK);
- SysMemPage.Fill_Rect(xpos + (index*6), ypos, xpos + (index*6)+6, ypos+5, TBLACK);
- TextPrintBuffer->Fill_Rect(2*(xpos + (index*6)), ypos*2, 2*(xpos + (index*6)+6), 2*(ypos+6), BLACK);
- str[index] = ascii;
- str[index+1] = 0;
- int objindex;
- Play_Sample(keystrok, 255, Options.Normalize_Sound(255));
- objindex = Alloc_Object(new ScoreScaleClass(str+index,xpos+(index*6), ypos, pal));
- while (ScoreObjs[objindex]) Call_Back_Delay(1);
- if (index < (MAX_FAMENAME_LENGTH-2) ) index++;
- }
- }
- }
- } while(key!=KA_RETURN); // } while(key != KN_RETURN && key!=KN_KEYPAD_RETURN);
- }
- void Animate_Cursor(int pos, int ypos)
- {
- static int _lastpos, _state;
- static CountDownTimerClass _timer;
- ypos += 7; // move cursor to bottom of letter
- // If they moved the cursor, erase old one and force state=0, to make green draw right away
- if (pos != _lastpos) {
- PseudoSeenBuff->Draw_Line(HALLFAME_X + (_lastpos*6),ypos, HALLFAME_X + (_lastpos*6) + 5, ypos, TBLACK);
- TextPrintBuffer->Fill_Rect(2*(HALLFAME_X + (_lastpos*6)),2*ypos, 2*(HALLFAME_X + (_lastpos*6) + 5), 2*ypos+1, BLACK);
- _lastpos = pos;
- _state = 0;
- }
- PseudoSeenBuff->Draw_Line(HALLFAME_X + (pos*6),ypos, HALLFAME_X + (pos*6)+5, ypos, _state ? LTBLUE : TBLACK);
- TextPrintBuffer->Fill_Rect(2*(HALLFAME_X + (pos*6)),2*ypos, 2*(HALLFAME_X + (pos*6)+5), 2*ypos+1, _state ? LTBLUE : BLACK);
- /*
- ** Toggle the color of the cursor, green or black, if it's time to do so.
- */
- if (!_timer.Time()) {
- _state ^= 1;
- _timer.Set(5);
- }
- }
- /***************************************************************************
- * Draw_InfantryMen -- Draw all the guys on the score screen *
- * *
- * *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 04/13/1995 BWG : Created. *
- *=========================================================================*/
- void Draw_InfantryMen()
- {
- int k;
- // Only draw the infantrymen if we're playing Nod... GDI wouldn't execute
- // people like that.
- /*
- ** First restore the background
- */
- SysMemPage.Blit(SysMemPage, BARGRAPH_X, CASUALTY_Y, 0, 0, 320-BARGRAPH_X, 34);
- Set_Logic_Page(SysMemPage);
- /*
- ** Then draw all the infantrymen on the clean SysMemPage
- */
- for (k = 0; k < NUMINFANTRYMEN; k++) Draw_InfantryMan(k);
- /*
- ** They'll all be blitted over to the seenpage after the graphs are drawn
- */
- }
- /***************************************************************************
- * Draw_InfantryMan -- Draw one guy in score screen, update animation *
- * *
- * This routine draws one of the infantrymen in the "Casualties" area *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 04/13/1995 BWG : Created. *
- *=========================================================================*/
- void Draw_InfantryMan(int index)
- {
- int stage;
- /* If the infantryman's dead, just abort this function */
- if (InfantryMan[index].anim == -1) return;
- stage = InfantryMan[index].stage + InfantryMan[index].Class->DoControls[InfantryMan[index].anim].Frame;
- CC_Draw_Shape(InfantryMan[index].shapefile,
- stage,
- InfantryMan[index].xpos,
- InfantryMan[index].ypos,
- WINDOW_MAIN,
- SHAPE_FADING|SHAPE_CENTER|SHAPE_WIN_REL,//|SHAPE_GHOST,
- InfantryMan[index].remap,
- Map.UnitShadow);
- /*
- ** see if it's time to run a new anim
- */
- if (--InfantryMan[index].delay < 0) {
- InfantryMan[index].delay = 3;
- if (++InfantryMan[index].stage >= InfantryMan[index].Class->DoControls[InfantryMan[index].anim].Count) {
- /*
- ** was he playing a death anim? If so, and it's done, erase him
- */
- if (InfantryMan[index].anim >= DO_GUN_DEATH) {
- InfantryMan[index].anim = -1;
- } else {
- New_Infantry_Anim(index, DO_STAND_READY);
- }
- }
- }
- }
- /***************************************************************************
- * New_Infantry_Anim -- Start up a new animation for one of the infantrymen*
- * *
- * *
- * *
- * INPUT: index: which of the 30 infantrymen to affect *
- * anim: which animation sequence to start him into *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 04/13/1995 BWG : Created. *
- *=========================================================================*/
- void New_Infantry_Anim(int index, int anim)
- {
- InfantryMan[index].anim = anim;
- InfantryMan[index].stage = 0;
- if (anim >= DO_GUN_DEATH) {
- InfantryMan[index].delay = 1; // start right away
- } else {
- InfantryMan[index].delay = Random() & 15;
- }
- }
- /***************************************************************************
- * Draw_Bar_Graphs -- Draw "Casualties" bar graphs *
- * *
- * *
- * *
- * INPUT: i = current count of how far to draw graph *
- * gkilled = # of GDI forces killed (adjusted to fit in space) *
- * nkilled = # of Nod forces killed (adjusted to fit in space) *
- * ckilled = # of civilians killed (adjusted to fit in space) *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 04/13/1995 BWG : Created. *
- *=========================================================================*/
- void Draw_Bar_Graphs(int i, int gkilled, int nkilled, int ckilled)
- {
- if (gkilled) {
- LogicPage->Fill_Rect(0, 0+4, 0+MIN(i,gkilled), 0+5, LTCYAN);
- LogicPage->Draw_Line(0+1, 0+6, 0+MIN(i,gkilled)+1, 0+6, TBLACK);
- LogicPage->Draw_Line(0+MIN(i,gkilled)+1,0+5, 0+MIN(i,gkilled)+1, 0+5, TBLACK);
- if (i <= gkilled) {
- int anim = InfantryMan[i/11].anim;
- if (anim!=-1 && anim < DO_GUN_DEATH) {
- if (i/11) {
- New_Infantry_Anim(i/11,DO_GUN_DEATH + (Random() & 3));
- } else {
- New_Infantry_Anim(i/11,DO_GUN_DEATH);
- }
- // Sound_Effect(Random_Pick(VOC_SCREAM1, VOC_SCREAM5));
- }
- }
- }
- if (nkilled) {
- LogicPage->Fill_Rect(0, 0+16, 0+MIN(i,nkilled), 0+17, RED);
- LogicPage->Draw_Line(0+1, 0+18, 0+MIN(i,nkilled)+1, 0+18, TBLACK);
- LogicPage->Draw_Line(0+MIN(i,nkilled)+1, 0+17, 0+MIN(i,nkilled)+1, 0+17, TBLACK);
- if (i <= nkilled) {
- int anim = InfantryMan[(NUMINFANTRYMEN/3)+(i/11)].anim;
- if (anim!=-1 && anim < DO_GUN_DEATH) {
- if (i/11) {
- New_Infantry_Anim((NUMINFANTRYMEN/3)+(i/11),DO_GUN_DEATH + (Random() & 3));
- } else {
- New_Infantry_Anim((NUMINFANTRYMEN/3)+(i/11),DO_GUN_DEATH);
- }
- // Sound_Effect(Random_Pick(VOC_SCREAM1, VOC_SCREAM5));
- }
- }
- }
- if (ckilled) {
- LogicPage->Fill_Rect(0, 0+28, 0+MIN(i,ckilled), 0+29, RED);
- LogicPage->Draw_Line(0+1, 0+30, 0+MIN(i,ckilled)+1, 0+30, TBLACK);
- LogicPage->Draw_Line(0+MIN(i,ckilled)+1, 0+29, 0+MIN(i,ckilled)+1, 0+29, TBLACK);
- if (i <= ckilled) {
- int anim = InfantryMan[((NUMINFANTRYMEN*2)/3)+(i/11)].anim;
- if (anim!=-1 && anim < DO_GUN_DEATH) {
- if (i/11) {
- New_Infantry_Anim(((NUMINFANTRYMEN*2)/3)+(i/11),DO_GUN_DEATH + (Random() & 3));
- } else {
- New_Infantry_Anim(((NUMINFANTRYMEN*2)/3)+(i/11),DO_GUN_DEATH);
- }
- // Sound_Effect(Random_Pick(VOC_SCREAM1, VOC_SCREAM5));
- }
- }
- }
- }
- /***************************************************************************
- * Call_Back_Delay -- Combines Call_Back() and Delay() functions *
- * *
- * This is just to cut down on code size and typing a little. *
- * *
- * INPUT: *
- * *
- * OUTPUT: *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 04/13/1995 BWG : Created. *
- *=========================================================================*/
- void Call_Back_Delay(int time)
- {
- CountDownTimerClass cd;
- if (!ControlQ) {
- if (Keyboard::Down(KN_LCTRL) && Keyboard::Down(KN_Q)) {
- ControlQ = 1;
- Keyboard::Clear();
- }
- }
- if (ControlQ) time=0;
- cd.Set(time);
- StreamLowImpact = true;
- do {
- Call_Back();
- //Animate_Score_Objs();
- //Interpolate_2X_Scale(PseudoSeenBuff , &SeenBuff ,NULL);
- //if (Get_Mouse_State()){
- // Interpolate_2X_Scale(PseudoSeenBuff , &SeenBuff ,NULL);
- //BlitList.Update();
- //}else{
- Animate_Score_Objs();
- Interpolate_2X_Scale(PseudoSeenBuff , &HidPage ,NULL);
- BlitList.Update();
- WWMouse->Draw_Mouse(&HidPage);
- Blit_Hid_Page_To_Seen_Buff();
- WWMouse->Erase_Mouse(&HidPage, TRUE);
- //}
- } while(cd.Time());
- StreamLowImpact = false;
- }
- void Animate_Score_Objs()
- {
- StillUpdating = false;
- for (int i = 0; i < MAXSCOREOBJS; i++) {
- if (ScoreObjs[i]) {
- ScoreObjs[i]->Update();
- }
- }
- }
- char *Int_Print(int a)
- {
- static char str[10];
- sprintf(str,"%d",a);
- return str;
- }
- /***********************************************************************************************
- * Multi_Score_Presentation -- Multiplayer routine to display score screen. *
- * *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 06/11/1995 BWG: Created. *
- *=============================================================================================*/
- void Multi_Score_Presentation(void)
- {
- static unsigned char const _cycleyellowpal[]={0x0,0xec,0xEb,0xea,0xE9,0xe9,0xE9,0x0,0xE9,0x0,0x0,0x0,0x0,0x0,0xED,0x0};
- static unsigned char const _greenpal[]= {0x0,0x12,0x14,0x16,0x18,0x18,0x18,0x0,0x18,0x0,0x0,0x0,0x0,0x0,0x10,0x0};
- static unsigned char const _redpal[]= {0x0,0x22,0x24,0x26,0x28,0x28,0x28,0x0,0x28,0x0,0x0,0x0,0x0,0x0,0x20,0x0};
- static unsigned char const _graypal[]= {0x0,0xca,0xCb,0xcc,0xCd,0xcd,0xCd,0x0,0xCD,0x0,0x0,0x0,0x0,0x0,0xC8,0x0};
- static unsigned char const _orangepal[]={0x0,0xd1,0xD2,0xd3,0xD4,0xd4,0xD4,0x0,0xD4,0x0,0x0,0x0,0x0,0x0,0xD0,0x0};
- static unsigned char const _bluepal[]= {0x0,0x2,0x0a,0xb,0x0b,0xb,0x0B,0x0,0x0B,0x0,0x0,0x0,0x0,0x0,0x09,0x0};
- static unsigned char const _yellowpal[]={0x0,0x5,0xee,0xf1,0xf2,0xf2,0xF2,0xf2,0xF2,0x0,0x0,0x0,0x0,0x0,0x7D,0x0};
- //static char const _greenpal[]= {0x0,0x0,0x12,0x0,0x14,0x0,0x16,0x0,0x18,0x0,0x0,0x0,0x0,0x0,0x10,0x0};
- //static char const _redpal[]= {0x0,0x0,0x22,0x0,0x24,0x0,0x26,0x0,0x28,0x0,0x0,0x0,0x0,0x0,0x20,0x0};
- //static char const _graypal[]= {0x0,0x0,0xCA,0x0,0xCB,0x0,0xCC,0x0,0xCD,0x0,0x0,0x0,0x0,0x0,0xC8,0x0};
- //static char const _orangepal[]={0x0,0x0,0xD1,0x0,0xD2,0x0,0xD3,0x0,0xD4,0x0,0x0,0x0,0x0,0x0,0xD0,0x0};
- //static char const _bluepal[]= {0x0,0x0,0x02,0x0,0x0A,0x0,0x0B,0x0,0x0B,0x0,0x0,0x0,0x0,0x0,0x09,0x0};
- //static char const _yellowpal[]={0x0,0x0,0x05,0x0,0xEE,0x0,0xF1,0x0,0xF2,0x0,0x0,0x0,0x0,0x0,0x7D,0x0};
- static unsigned char const *_colors[]={_yellowpal,_redpal,_bluepal,_orangepal,_greenpal,_graypal};
- int i,k;
- void *oldfont, *anim;
- int oldfontxspacing = FontXSpacing;
- char const *pal;
- FontXSpacing = 0;
- Map.Override_Mouse_Shape(MOUSE_NORMAL);
- Theme.Queue_Song(THEME_WIN1);
- PseudoSeenBuff = new GraphicBufferClass(320,200,(void*)NULL);
- TextPrintBuffer = new GraphicBufferClass(SeenBuff.Get_Width(), SeenBuff.Get_Height() ,(void*)NULL);
- BlitList.Clear();
- SysMemPage.Clear();
- PseudoSeenBuff->Clear();
- HiddenPage.Clear();
- TextPrintBuffer->Clear();
- Set_Palette(BlackPalette);
- anim = Open_Animation("MLTIPLYR.WSA",NULL,0L,(WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE),Palette);
- Hide_Mouse();
- /*
- ** Display the background animation
- */
- VisiblePage.Clear();
- InterpolationPaletteChanged = TRUE;
- InterpolationPalette = Palette;
- Increase_Palette_Luminance (Palette , 30,30,30,63);
- Animate_Frame(anim, *PseudoSeenBuff, 1);
- Interpolate_2X_Scale( PseudoSeenBuff , &SeenBuff , "MULTSCOR.PAL");
- Fade_Palette_To(Palette, FADE_PALETTE_FAST, Call_Back);
- int frame = 1;
- while (frame < Get_Animation_Frame_Count(anim)) {
- Animate_Frame(anim, *PseudoSeenBuff, frame++);
- Call_Back_Delay(2);
- }
- Close_Animation(anim);
- /* Change to the six-point font for Text_Print */
- oldfont = Set_Font(ScoreFontPtr);
- Call_Back();
- Set_Logic_Page(*PseudoSeenBuff);
- /*
- ** Move all the scores over a notch if there's more games than can be
- ** shown (which is known by MPlayerCurGame == MAX_MULTI_GAMES-1);
- */
- if (MPlayerCurGame == MAX_MULTI_GAMES-1) {
- for(i = 0; i < MAX_MULTI_NAMES; i++) {
- for(k = 0; k < MAX_MULTI_GAMES-1; k++) {
- MPlayerScore[i].Kills[k] = MPlayerScore[i].Kills[k+1];
- }
- }
- }
- int y = 41;
- for(i = 0; i < MAX_MULTI_NAMES; i++) {
- if (strlen(MPlayerScore[i].Name)) {
- pal = (const char*)_colors[MPlayerScore[i].Color];
- Alloc_Object(new ScorePrintClass(MPlayerScore[i].Name, 15, y,pal));
- Call_Back_Delay(20);
- Alloc_Object(new ScorePrintClass(Int_Print(MPlayerScore[i].Wins), 118, y, pal));
- Call_Back_Delay(6);
- for(k = 0; k <= MIN(MPlayerCurGame, MAX_MULTI_GAMES-2); k++) {
- if (MPlayerScore[i].Kills[k] >= 0) {
- Alloc_Object(new ScorePrintClass(Int_Print(MPlayerScore[i].Kills[k]), 225+(24*k), y, pal));
- Call_Back_Delay(6);
- }
- }
- y += 12;
- }
- }
- #if (FRENCH)
- Alloc_Object(new ScorePrintClass(TXT_MAP_CLICK2, 90 /*(320-strlen(Text_String(TXT_MAP_CLICK2)))/2*/, 185, _cycleyellowpal));
- #else
- Alloc_Object(new ScorePrintClass(TXT_MAP_CLICK2, 109 /*(320-strlen(Text_String(TXT_MAP_CLICK2)))/2*/, 185, _cycleyellowpal));
- #endif
- Cycle_Wait_Click();
- /* get rid of all the animating objects */
- for (i = 0; i < MAXSCOREOBJS; i++) if (ScoreObjs[i]) {
- delete ScoreObjs[i];
- ScoreObjs[i] = 0;
- }
- Theme.Queue_Song(THEME_NONE);
- Fade_Palette_To(BlackPalette, FADE_PALETTE_FAST, NULL);
- VisiblePage.Clear();
- Set_Palette(GamePalette);
- Set_Logic_Page (SeenBuff);
- delete PseudoSeenBuff;
- delete TextPrintBuffer;
- BlitList.Clear();
- Set_Font(oldfont);
- FontXSpacing = oldfontxspacing;
- ControlQ = 0;
- Show_Mouse();
- }
- #ifdef WRITE_LBM
- // A BitMapHeader is stored in a BMHD chunk. This structure MUST be an even size
- typedef struct {
- unsigned short w, h; // raster width & height in pixels
- unsigned short x, y; // position for this image
- unsigned char planes; // # source bitplanes
- unsigned char masking; // masking technique
- unsigned char compression; // compression algoithm
- unsigned char pad1; // UNUSED. For consistency, put 0 here.
- unsigned short transcolor; // transparent "color number"
- unsigned char xaspect, yaspect; // aspect ratio, a rational number x/y
- unsigned short pagewidth, pageheight; // source "page" size in pixels
- } BitMapHeaderType;
- // All values in LocalHeader are always the same except planes. This is set in Write_BMHD
- // the WORD values must be in low-high order for compatibility.
- static BitMapHeaderType LocalHeader = {
- 0x4001, 0xc800, 0, 0, 0, 0, // width, height, x, y, planes, mask
- 1, 0, 0xFF00, 5, 6, // compress, pad1, transcolor, xasptect, yaspect
- 0x4001, 0xC800 }; // pagewidth, pageheight
- #define BM_HEADER_SIZE (((sizeof(BitMapHeaderType) + 1) & 0xFFFE) + 8L)
- /*=========================================================================*/
- /* The following static functions are in this file: */
- /*=========================================================================*/
- static long CCWrite_BMHD(CCFileClass &lbmhandle, short bitplanes);
- static long CCWrite_CMAP(CCFileClass &lbmhandle, unsigned char * palette, short bitplanes);
- static long CCWrite_BODY(CCFileClass &lbmhandle, BufferClass& buff, short bitplanes);
- static long CCWrite_Row(CCFileClass &lbmhandle, unsigned char *buffer);
- /*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
- /***************************************************************************
- * CCWrite_LBM_File -- Writes out a file in LBM format *
- * *
- * INPUT: short lbmhandle -- lbm file handle already opened by caller *
- * BufferClass buff -- buff where MCGA picture is *
- * short bitplane -- number of bitplanes to convert to *
- * char *palette -- pointer to palette for buff *
- * *
- * OUTPUT: Returns bool -- successfull or not *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/18/1991 SB : Created. *
- *=========================================================================*/
- bool CCWrite_LBM_File(CCFileClass &lbmhandle, BufferClass& buff, short bitplanes, unsigned char *palette)
- {
- long filesize;
- lbmhandle.Seek(0L, SEEK_SET); // goto beginning of file
- lbmhandle.Write("FORM????ILBM", 12L); // First 12 bytes of all .lbm files
- // size is unkown so write ????
- filesize = 12L; // 4 bytes for "ILBM"
- filesize += CCWrite_BMHD(lbmhandle, bitplanes); // write out BMHD (fixed size)
- filesize += CCWrite_CMAP(lbmhandle, palette, bitplanes); // write out CMAP
- // Write out the body, or compressed picture image. This size will depend
- // on the compression, but the value passed back is what the compressor
- // assumed was written to file
- filesize += CCWrite_BODY(lbmhandle, buff, bitplanes);
- // Verify that we were able to write out the file without running out of space
- if (lbmhandle.Seek(0L, SEEK_END) != filesize) {
- return(false);
- }
- lbmhandle.Seek(4L, SEEK_SET); // goto beginning of file
- filesize = Reverse_LONG(filesize - 8L); // - 8 because of "FORM" + short (size)
- lbmhandle.Write( (char *) &filesize, 4L); // patch in filesize
- return(true);
- }
- /***************************************************************************
- * CCWrite_BMHD -- writes out the bit map header (LocalHeader) *
- * *
- * INPUT: short lbmhandle -- file handle for lbm file *
- * short pitplanes -- number of bitplanes to write out *
- * *
- * OUTPUT: LONG number of bytes hopefully written out to .LBM file *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/19/1991 SB : Created. *
- *=========================================================================*/
- static long CCWrite_BMHD(CCFileClass &lbmhandle, short bitplanes)
- {
- long size;
- lbmhandle.Write("BMHD", 4L); // write out chunk title
- size = Reverse_LONG(sizeof(LocalHeader)); // write out size of LocalHeader chunk
- lbmhandle.Write((char *) &size, 4L);
- LocalHeader.planes = bitplanes; // only nonconstant value in LocalHeader
- // Make sure size is even. Return 8 = "BMHD" + size of the bitmap header structure
- return(lbmhandle.Write((char *) &LocalHeader,
- (sizeof(LocalHeader) + 1) & 0xFFFE) + 8L);
- }
- /***************************************************************************
- * CCWrite_CMAP -- Writes out CMAP (palette) information *
- * *
- * *
- * INPUT: short lbmhandle -- file handle of lbm file *
- * char * palette -- pointer to paletter information *
- * short bitplanes -- used to figure out size of palette *
- * *
- * OUTPUT: long number of bytes that should have been written out to .LBM. *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/19/1991 SB : Created. *
- *=========================================================================*/
- static long CCWrite_CMAP(CCFileClass &lbmhandle, unsigned char * palette, short bitplanes)
- {
- short color, r, g, b, colors;
- long size;
- unsigned char *pal_ptr;
- char rgb[3];
- lbmhandle.Write("CMAP", 4L); // write out palette info
- colors = 1 << bitplanes; // colors = 2 to the bitplanes
- size = Reverse_LONG(colors * 3L); // size = colors * 3 guns
- lbmhandle.Write((char *) &size, 4L);
- for (pal_ptr = palette, color = 0; color < colors; color++) { // for each color
- if ((r = *pal_ptr++) != 0) { // DPaint changes allows 0 - 100 for gun values
- r = (r << 2) | 0x03; // this must be converted to 0 - 256 for LBM
- } // so LBM_val = (DP_val * 4) | 3 if DP_val != 0
- if ((g = *pal_ptr++) != 0) {
- g = (g << 2) | 0x03;
- }
- if ((b = *pal_ptr++) != 0) {
- b = (b << 2) | 0x03;
- }
- rgb[0] = r; // assign gun values to an array to write out
- rgb[1] = g;
- rgb[2] = b;
- lbmhandle.Write(rgb, 3L);
- }
- // size = colors * 3
- return(((colors << 1) + colors) + 8L); // total size of CMAP 8 = "CMAP" + short (size)
- }
- /***************************************************************************
- * CCWrite_Body -- writes out compressed data in an LBM file *
- * *
- * INPUT: short lbmhandle -- file handle of lbm file *
- * *
- * OUTPUT: long - number of byte written *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/19/1991 SB : Created. *
- *=========================================================================*/
- static long CCWrite_BODY(CCFileClass &lbmhandle, BufferClass& buff, short bitplanes)
- {
- long bodysize = 0;
- long actualsize;
- long size;
- short planebit;
- short line, plane;
- unsigned char buffer[40];
- unsigned char *buffptr;
- lbmhandle.Write("BODY????", 8L); // BODY chunk ID, ???? reserved for chuncksize
- buffptr = (unsigned char *) buff.Get_Buffer(); // point to beginning of buff
- for (line = 0; line < 200; line++) {
- planebit = 1; // start with bit 1 set
- for (plane = 0; plane < bitplanes; plane++) {
- Pack_2_Plane(buffer, buffptr, planebit); // convert to planar
- bodysize += CCWrite_Row(lbmhandle, buffer); // write to to the BODY in the LBM
- planebit <<= 1; // set next bit
- }
- buffptr += 320; // row size is 320
- }
- actualsize = bodysize + (bodysize&0x01);
- if (actualsize != bodysize) {
- lbmhandle.Write(buffer, 1); // Padd the block.
- }
- lbmhandle.Seek( -(actualsize + 4L), SEEK_CUR); // Patch in chunksize
- size = Reverse_LONG(bodysize);
- lbmhandle.Write( (char *) &size ,4L);
- return(actualsize + 8L); // total size of BODY, "BODY????" = 8 bytes
- }
- /***************************************************************************
- * CCWrite_Row -- compresses and writes a row plane to .lbm file *
- * *
- * INPUT: short lbmhandle -- lbm file handle *
- * unsigned char *buffer -- pointer to buffer to be written out *
- * *
- * OUTPUT: long size of chunk that should have been written out *
- * *
- * WARNINGS: *
- * *
- * HISTORY: *
- * 11/19/1991 SB : Created. *
- *=========================================================================*/
- static long CCWrite_Row(CCFileClass &lbmhandle, unsigned char *buffer)
- {
- short i;
- short chunksize = 0;
- short dataLength = 40; // 320 rows / 8 ( 1 plane per row)
- unsigned char repCode, current, curr_plus_2;
- unsigned char *buffptr;
- while (dataLength) {
- // If at least 2 more bytes and they are equal, then replicate
- if ((dataLength >= 2) && (buffer[0] == buffer[1])) {
- buffptr = buffer;
- for (i = 0; (i <= 128) && (i < (dataLength - 1)); i++) {
- if (*buffptr != buffptr[1]) {
- break;
- }
- buffptr++;
- }
- i++;
- repCode = -i + 1;
- lbmhandle.Write(&repCode, 1L); // Write count as -count+1
- lbmhandle.Write(buffer, 1L); // Write byte to replicate
- buffer += i;
- dataLength -= i;
- chunksize += 2;
- } else { // Copy literally till 3 byte run or two 2 byte runs found
- for (i = 0; (i <= 128) && (i < dataLength); i++) {
- current = buffer[i];
- curr_plus_2 = buffer[i + 2];
- if (i == dataLength - 1)
- continue;
- if (current != buffer[i + 1])
- continue;
- if (i == dataLength - 2)
- continue;
- if (current == curr_plus_2)
- break;
- if (i == dataLength - 3)
- continue;
- if (curr_plus_2 == buffer[i + 3])
- break;
- }
- repCode = i - 1;
- lbmhandle.Write(&repCode, 1L); // Write count as count-1
- lbmhandle.Write(buffer, (long) i); // Write 'count' bytes
- buffer += i;
- dataLength -= i;
- chunksize += i + 1;
- }
- } // end while
- return(chunksize);
- }
- #endif
|